Merging in the tweaks branch
[gc-dialer] / src / dialcentral / evo_backend.py
index c094c2e..c1c0487 100644 (file)
@@ -39,7 +39,17 @@ class EvolutionAddressBook(object):
                        return
 
                self._phoneTypes = None
-               self._bookId = bookId if bookId is not None else self.get_addressbooks().next()[1]
+               if bookId is not None:
+                       self._bookId = bookId
+               else:
+                       try:
+                               self._bookId = [
+                                       bookData[1]
+                                               for bookData in self.get_addressbooks()
+                               ][0]
+                       except IndexError:
+                               global evolution
+                               evolution = None
                self._book = evolution.ebook.open_addressbook(self._bookId)
        
        @classmethod
@@ -66,7 +76,7 @@ class EvolutionAddressBook(object):
                return self
 
        @staticmethod
-       def factory_short_name():
+       def contact_source_short_name(contactId):
                return "Evo"
 
        @staticmethod
@@ -81,13 +91,13 @@ class EvolutionAddressBook(object):
                        return
 
                for contact in self._book.get_all_contacts():
-                       yield contact.get_uid(), contact.props.full_name
+                       yield str(contact.get_uid()), contact.props.full_name
        
        def get_contact_details(self, contactId):
                """
                @returns Iterable of (Phone Type, Phone Number)
                """
-               contact = self._book.get_contact(contactId)
+               contact = self._book.get_contact(int(contactId))
 
                if self._phoneTypes is None and contact is not None:
                        self._phoneTypes = [pt for pt in dir(contact.props) if "phone" in pt.lower()]
@@ -97,7 +107,8 @@ class EvolutionAddressBook(object):
                        if isinstance(phoneNumber, str):
                                yield phoneType, phoneNumber
 
-def print_addressbooks():
+
+def print_evobooks():
        """
        Included here for debugging.