diff options
author | Krzysztof <kkszysiu@gmail.com> | 2011-03-27 16:34:25 +0200 |
---|---|---|
committer | Krzysztof <kkszysiu@gmail.com> | 2011-03-27 16:34:25 +0200 |
commit | 30f24ed1224ffaef679e0b07d92d8ed5d981f1fb (patch) | |
tree | 4ae8092301bcbc71d821341ddf9448fbf8cbe852 | |
parent | 061d3e42434b6d9ba4a24fc4b36a969d2d31c015 (diff) |
Revert "Huge update of synchronisation feature. Remember: this code is experimental. Use it on own risk."
This reverts commit 83963893c34c6069f7202cf7d55add2d334581b5.
-rw-r--r-- | data/sunshine.manager | 2 | ||||
-rw-r--r-- | sunshine/connection.py | 46 | ||||
-rwxr-xr-x | sunshine/lqsoft/pygadu/models.py | 4 | ||||
-rw-r--r-- | sunshine/util/config.py | 45 |
4 files changed, 5 insertions, 92 deletions
diff --git a/data/sunshine.manager b/data/sunshine.manager index f11194a..a5ebb08 100644 --- a/data/sunshine.manager +++ b/data/sunshine.manager @@ -10,9 +10,7 @@ param-server = s param-port = q param-use-ssl = b param-use-specified-server = b -param-synchronise-contacts-with-server = b default-server = 91.197.13.67 default-port = 8074 default-use-ssl = true default-use-specified-server = false -param-synchronise-contacts-with-server = true diff --git a/sunshine/connection.py b/sunshine/connection.py index 935fe59..ffc65a5 100644 --- a/sunshine/connection.py +++ b/sunshine/connection.py @@ -123,15 +123,13 @@ class SunshineConnection(telepathy.server.Connection, 'server' : 's', 'port' : 'q', 'use-ssl' : 'b', - 'use-specified-server' : 'b', - 'synchronise-contacts-with-server' : 'b' + 'use-specified-server' : 'b' } _parameter_defaults = { 'server' : '91.197.13.67', 'port' : 8074, 'use-ssl' : True, - 'use-specified-server' : False, - 'synchronise-contacts-with-server' : True + 'use-specified-server' : False } def __init__(self, manager, parameters): @@ -146,7 +144,6 @@ class SunshineConnection(telepathy.server.Connection, self.param_server = (parameters['server'], parameters['port']) self.param_use_ssl = bool(parameters['use-ssl']) self.param_specified_server = bool(parameters['use-specified-server']) - self.param_synchronisation = bool(parameters['synchronise-contacts-with-server']) self.profile = GaduProfile(uin= int(parameters['account']) ) self.profile.uin = int(parameters['account']) @@ -162,27 +159,6 @@ class SunshineConnection(telepathy.server.Connection, self.profile.onUserData = self.onUserData self.configfile = SunshineConfig(int(parameters['account'])) - self.configfile.check_dirs() - #lets get contacts from contacts config file - contacts_list = self.configfile.get_contacts() - - for contact_from_list in contacts_list['contacts']: - c = GaduContact.from_xml(contact_from_list) - try: - c.uin - if self.param_synchronisation: - self.profile.connection.addNewContact(c) - else: - self.profile.addContact(c) - except: - pass - - for group_from_list in contacts_list['groups']: - g = GaduContactGroup.from_xml(group_from_list) - if g.Name: - self.profile.addGroup(g) - - logger.info("We have %s contacts in file." % (self.configfile.get_contacts_count())) self.factory = GaduClientFactory(self.profile) self.ggapi = GG_Oauth(self.profile.uin, parameters['password']) @@ -345,8 +321,6 @@ class SunshineConnection(telepathy.server.Connection, contents = output.getvalue() output.close() - reactor.callLater(1, self.configfile.make_contacts_file, self.profile.groups, self.profile.contacts, True) - if len(ET.tostring(contacts_xml.getroot())) != 0: logger.info("Exporting contacts.") print 'Output:', str(contents) @@ -423,23 +397,11 @@ class SunshineConnection(telepathy.server.Connection, self._status = telepathy.CONNECTION_STATUS_CONNECTED self.StatusChanged(telepathy.CONNECTION_STATUS_CONNECTED, telepathy.CONNECTION_STATUS_REASON_REQUESTED) - - reactor.callLater(1, self.configfile.make_contacts_file, self.profile.groups, self.profile.contacts, True) def on_loginSuccess(self): logger.info("Connected") - - if self.param_synchronisation == False and self.configfile.get_contacts_count() == 0: - self.profile.importContacts(self.on_contactsImported) - elif self.param_synchronisation == True: - self.profile.importContacts(self.on_contactsImported) - else: - self.makeTelepathyContactsChannel() - self.makeTelepathyGroupChannels() - - self._status = telepathy.CONNECTION_STATUS_CONNECTED - self.StatusChanged(telepathy.CONNECTION_STATUS_CONNECTED, - telepathy.CONNECTION_STATUS_REASON_REQUESTED) + + self.profile.importContacts(self.on_contactsImported) def on_loginFailed(self, response): logger.info("Login failed: ", response) diff --git a/sunshine/lqsoft/pygadu/models.py b/sunshine/lqsoft/pygadu/models.py index 478efcc..14c8cdb 100755 --- a/sunshine/lqsoft/pygadu/models.py +++ b/sunshine/lqsoft/pygadu/models.py @@ -67,10 +67,6 @@ class GaduProfile(object): # high-level interface @property - def connection(self): - return self.__connection - - @property def connected(self): """Is the profile currently used in an active connection""" return self.__connection is not None diff --git a/sunshine/util/config.py b/sunshine/util/config.py index 8025ec9..3a209a3 100644 --- a/sunshine/util/config.py +++ b/sunshine/util/config.py @@ -16,44 +16,7 @@ class SunshineConfig(object): self.contacts_len = 0 self.groups_len = 0 - def check_dirs(self): - path = os.path.join(os.path.join(os.environ['HOME'], '.telepathy-sunshine')) - try: - os.makedirs(path) - except: - pass - if not os.path.isfile(os.path.join(path, '%s.xml' % (str(self.uin)))): - contactbook_xml = ET.Element("ContactBook") - - ET.SubElement(contactbook_xml, "Groups") - ET.SubElement(contactbook_xml, "Contacts") - - main_xml = ET.ElementTree(contactbook_xml) - main_xml.write(os.path.join(path, '%s.xml' % (str(self.uin))), encoding="UTF-8") - - self.path = os.path.join(path, '%s.xml' % (str(self.uin))) - return os.path.join(path, '%s.xml' % (str(self.uin))) - - def get_contacts(self): - self.roster = {'groups':[], 'contacts':[]} - try: - file = open(self.path, "r") - config_xml = ET.parse(file).getroot() - - for elem in config_xml.find('Groups').getchildren(): - self.roster['groups'].append(elem) - - for elem in config_xml.find('Contacts').getchildren(): - self.roster['contacts'].append(elem) - - self.contacts_count = len(config_xml.find('Contacts').getchildren()) - - return self.roster - except: - self.contacts_count = 0 - return self.roster - - def make_contacts_file(self, groups, contacts, to_file=False): + def make_contacts_file(self, groups, contacts): contactbook_xml = ET.Element("ContactBook") groups_xml = ET.SubElement(contactbook_xml, "Groups") @@ -86,14 +49,8 @@ class SunshineConfig(object): main_xml = ET.ElementTree(contactbook_xml) if self.contacts_len >= 0 and self.groups_len >= 0: - if to_file: - main_xml.write(self.path, encoding="UTF-8") return main_xml def get_contacts_count(self): return self.contacts_count - def save_to_file(self, xml): - xml.write(self.path, encoding="UTF-8") - - |