summaryrefslogtreecommitdiff
path: root/sunshine
diff options
context:
space:
mode:
authorKrzysztof Klinikowski <kkszysiu@gmail.com>2010-01-24 13:25:48 +0100
committerKrzysztof Klinikowski <kkszysiu@gmail.com>2010-01-24 13:25:48 +0100
commitabb9c98ae71d4cd569f12aead48a992abc0e3be1 (patch)
tree05df61bca3e8303de9a5467d012854a1ccd869ea /sunshine
parenteecc35863f17d131a5e4d1385ab9e9cc7560d5ca (diff)
Aliasing feature implemented.
Diffstat (limited to 'sunshine')
-rw-r--r--sunshine/aliasing.py7
-rw-r--r--sunshine/connection.py16
2 files changed, 20 insertions, 3 deletions
diff --git a/sunshine/aliasing.py b/sunshine/aliasing.py
index d5fd250..23a7b9f 100644
--- a/sunshine/aliasing.py
+++ b/sunshine/aliasing.py
@@ -72,6 +72,7 @@ class SunshineAliasing(telepathy.server.ConnectionInterfaceAliasing):
self.AliasesChanged([(handle, alias)])
else:
logger.info("Self alias changed to '%s'" % alias)
+ self.configfile.save_self_alias(alias)
self.AliasesChanged(((SunshineHandleFactory(self, 'self'), alias), ))
# # papyon.event.ContactEventInterface
@@ -104,7 +105,10 @@ class SunshineAliasing(telepathy.server.ConnectionInterfaceAliasing):
"""Get the alias from one handle id"""
handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)
if handle == SunshineHandleFactory(self, 'self'):
- alias = 'Ja'
+ alias = self.configfile.get_self_alias()
+ if alias == None and len(alias) == 0:
+ alias = handle.name
+
else:
contact = handle.contact
#print str(self.aliases)
@@ -113,6 +117,7 @@ class SunshineAliasing(telepathy.server.ConnectionInterfaceAliasing):
#del self.aliases[handle.name]
elif contact is None:
alias = handle.name
+ self.configfile.save_self_alias(alias)
else:
alias = contact.ShowName
if alias == '' or alias is None:
diff --git a/sunshine/connection.py b/sunshine/connection.py
index 2dd7cf6..c251256 100644
--- a/sunshine/connection.py
+++ b/sunshine/connection.py
@@ -72,6 +72,7 @@ class SunshineConfig(object):
main_xml.write(os.path.join(path, 'profile.xml'), encoding="UTF-8")
self.path = os.path.join(path, 'profile.xml')
+ self.path2 = os.path.join(path, 'alias')
return os.path.join(path, 'profile.xml')
def get_contacts(self):
@@ -90,6 +91,18 @@ class SunshineConfig(object):
return self.roster
+ def get_self_alias(self):
+ if os.path.exists(self.path2):
+ file = open(self.path2, "r")
+ alias = file.read()
+ file.close()
+ return alias
+
+ def save_self_alias(self, alias):
+ file = open(self.path2, "w")
+ file.write(alias)
+ file.close()
+
def make_contacts_file(self, groups, contacts):
contactbook_xml = ET.Element("ContactBook")
@@ -223,7 +236,6 @@ class SunshineConnection(telepathy.server.Connection,
telepathy.server.Connection.__init__(self, 'gadugadu', account, 'sunshine')
telepathy.server.ConnectionInterfaceRequests.__init__(self)
SunshinePresence.__init__(self)
-
SunshineAvatars.__init__(self)
SunshineCapabilities.__init__(self)
SunshineContacts.__init__(self)
@@ -500,7 +512,7 @@ class SunshineConnection(telepathy.server.Connection,
# logger.info("Status noticies received.")
def on_loginFailed(self):
- logger.info("Method on_loginFailed called.")
+ logger.info("Login failed.")
self._status = telepathy.CONNECTION_STATUS_DISCONNECTED
self.StatusChanged(telepathy.CONNECTION_STATUS_DISCONNECTED,
telepathy.CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED)