Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:drf/amsn2
Browse files Browse the repository at this point in the history
Conflicts:
	README
  • Loading branch information
Youness Alaoui committed Jun 26, 2009
2 parents f3e3784 + d86a6a0 commit 3d325ff
Show file tree
Hide file tree
Showing 315 changed files with 2,789 additions and 20,749 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,4 +1,5 @@
*.pyc
*.pyo
build/
*~
.project
Expand All @@ -8,3 +9,5 @@ build/
.svn/
Debug/
ui_*
.*.swp
pymsn/
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "papyon"]
path = papyon
url = git://github.com/Kjir/papyon.git
8 changes: 8 additions & 0 deletions README
Expand Up @@ -5,6 +5,9 @@ python-pyopenssl
python-crypto
maybe some other stuff...

Before launching amsn2 you have to fetch the submodules (papyon). Instructions can be found on the aMSN forum:
http://www.amsn-project.net/forums/viewtopic.php?t=5994

If you launch ./amsn2.py and it gives an error, that error probably tells you which dependency you need...
You can type ./amsn2.py --help for more info... and the front ends can be selected with -f :
./amsn2.py -f efl
Expand All @@ -21,6 +24,7 @@ Once done, go to ./e17_src/BINDINGS/python and type
PKG_CONFIG_PATH=/opt/e17/lib/pkgconfig ./build-all.sh /usr
(this will build and install the python extensions into /usr/python2.X/...)
Then the efl front end should become available...
If it's not, fire up a python shell and try to import the ecore module; diagnose from there the problem.


If you have the following error with the qt4 front-end:
Expand All @@ -31,3 +35,7 @@ If you have the following error with the qt4 front-end:
self._loop = self._gui.gui.aMSNMainLoop(self)
AttributeError: 'NoneType' object has no attribute 'aMSNMainLoop'
try moving into the amsn2/gui/front_ends/qt4 directory and calling generateFiles.sh

If the backspace is not working as expected with the ncurses front-end it is probably because your TERM is not set to the correct value. Try to launch amsn2 with some other setting for TERM, like:
TERM=konsole ./amsn2.py -f curses
If it works with some other value it means that your terminal emulator is not set correctly.
31 changes: 5 additions & 26 deletions amsn2.py 100644 → 100755
Expand Up @@ -2,38 +2,17 @@
import sys
import os
import optparse
sys.path.insert(0, "./pymsn")
os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))
sys.path.insert(0, "./papyon")
import locale
locale.setlocale(locale.LC_ALL, '')

from amsn2.core import aMSNCore

if __name__ == '__main__':
account = None
passwd = None
default_front_end = "console"

# Detect graphical toolkit available.
# Format - 'default_front_end : module name'
# cocoa > efl > qt4 > gtk > console
toolkits = {'cocoa' : '????',
'elf' : 'ecore',
'qt4' : 'PyQt4.QtGui',
'gtk' : 'gtk',
'console' : None}
for toolkit in toolkits:
try:
default_front_end = toolkit
module_name = toolkits[toolkit]
module = __import__(module_name)
vars()[module_name] = module
# Debug
# print 'Imported toolkit "%s" with module "%s"' % (toolkit, module)
break
except ImportError:
# Debug
# print 'Couldn\'t import %s - doesn\'t exist!' % module_name
pass
except TypeError:
pass
default_front_end = "gtk"

parser = optparse.OptionParser()
parser.add_option("-a", "--account", dest="account",
Expand Down
2 changes: 1 addition & 1 deletion amsn2/__init__.py
@@ -1,5 +1,5 @@

import core
import backend
import gui
import protocol
import gui.front_ends
2 changes: 2 additions & 0 deletions amsn2/backend/__init__.py
@@ -0,0 +1,2 @@
from backend import aMSNBackendManager
__all__ = ['aMSNBackendManager', 'defaultbackend']
33 changes: 33 additions & 0 deletions amsn2/backend/backend.py
@@ -0,0 +1,33 @@
"""ElementTree independent from the available distribution"""
try:
from xml.etree.cElementTree import *
except ImportError:
try:
from cElementTree import *
except ImportError:
from elementtree.ElementTree import *

class aMSNBackendManager(object):
def __init__(self):
self.switchToBackend('nullbackend')

def setBackendForFunc(self, funcname, backendname):
try:
m = __import__(backendname, globals(), locals(), [], -1)
except ImportError:
m = __import__('defaultbackend', globals(), locals(), [], -1)
try:
f = getattr(m, funcname)
self.__setattr__(funcname, f)
except AttributeError:
self.__setattr__(funcname, self.__missingFunc)

def switchToBackend(self, backend):
self.setBackendForFunc('getPassword', backend)
self.setBackendForFunc('setPassword', backend)
self.setBackendForFunc('saveConfig', backend)
self.setBackendForFunc('loadConfig', backend)

def __missingFunc(*args):
print 'Function not implemented for this backend'

17 changes: 17 additions & 0 deletions amsn2/backend/basebackend.py
@@ -0,0 +1,17 @@
"""
Base backend, should be used as a model to implement others backends
As it is right now it's not used directly by aMSN2's code
"""

def getPassword(passwdElmt):
raise NotImplementedError

def setPassword(password, root_section):
raise NotImplementedError

def saveConfig(account, config):
raise NotImplementedError

def loadConfig(account):
raise NotImplementedError

57 changes: 57 additions & 0 deletions amsn2/backend/defaultbackend.py
@@ -0,0 +1,57 @@
""" Backend used to save the config on the home directory of the user """

import os
"""ElementTree independent from the available distribution"""
try:
from xml.etree.cElementTree import *
except ImportError:
try:
from cElementTree import *
except ImportError:
from elementtree.ElementTree import *
from amsn2.core.config import aMSNConfig

def getPassword(passwdElmt):
return passwdElmt.text

def setPassword(password, root_section):
elmt = SubElement(root_section, "password", backend='DefaultBackend')
elmt.text = password
return elmt


def saveConfig(account, config):
#TODO: improve
root_section = Element("aMSNConfig")
for e in config._config:
val = config._config[e]
elmt = SubElement(root_section, "entry",
type=type(val).__name__,
name=str(e))
elmt.text = str(val)

accpath = os.path.join(account.account_dir, "config.xml")
xml_tree = ElementTree(root_section)
xml_tree.write(accpath, encoding='utf-8')

def loadConfig(account):
c = aMSNConfig()
c.setKey("ns_server", "messenger.hotmail.com")
c.setKey("ns_port", 1863)
configpath = os.path.join(account.account_dir, "config.xml")
try:
configfile = file(configpath, "r")
except IOError:
return c
configfile = file(configpath, "r")
root_tree = ElementTree(file=configfile)
configfile.close()
config = root_tree.getroot()
if config.tag == "aMSNConfig":
lst = config.findall("entry")
for elmt in lst:
if elmt.attrib['type'] == 'int':
c.setKey(elmt.attrib['name'], int(elmt.text))
else:
c.setKey(elmt.attrib['name'], elmt.text)
return c
22 changes: 22 additions & 0 deletions amsn2/backend/nullbackend.py
@@ -0,0 +1,22 @@
""" Backend that will not save anything, used for on-the-fly-sessions """

from amsn2.core.config import aMSNConfig

def getPassword(passwdElmt):
return passwdElmt.text

def setPassword(password, root_section):
elmt = SubElement(root_section, "password", backend='NullBackend')
elmt.text = password
return elmt

def saveConfig(account, config):
pass

def loadConfig(account):
c = aMSNConfig()
c._config = {"ns_server":'messenger.hotmail.com',
"ns_port":1863,
}
return c

4 changes: 3 additions & 1 deletion amsn2/core/__init__.py
@@ -1,6 +1,8 @@

from amsn import *
from profile import *
from views import *
from lang import *
from config import *
from contactlist_manager import *
from account_manager import *
from personalinfo_manager import *

0 comments on commit 3d325ff

Please sign in to comment.