import telepathy
+_moduleLogger = logging.getLogger("handle")
+
+
class MetaMemoize(type):
"""
Allows a class to cache off instances for reuse
obj, newlyCreated = cls.__new__(cls, connection, *args)
if newlyCreated:
obj.__init__(connection, connection.get_handle_id(), *args)
- logging.info("New Handle %r" % obj)
+ _moduleLogger.info("New Handle %r" % obj)
return obj
self.profile = connection.username
-def field_join(fields):
- """
- >>> field_join("1", "First Name")
- '1#First Name'
- """
- return "#".join(fields)
-
-
-def field_split(fields):
- """
- >>> field_split('1#First Name')
- ['1', 'First Name']
- """
- return fields.split("#")
-
-
class ContactHandle(TheOneRingHandle):
- def __init__(self, connection, id, contactId, contactAccount):
+ def __init__(self, connection, id, contactId):
handleType = telepathy.HANDLE_TYPE_CONTACT
- handleName = field_join(contactId, contactAccount)
+ handleName = contactId
TheOneRingHandle.__init__(self, connection, id, handleType, handleName)
- self.account = contactAccount
self._id = contactId
@property
- def contact(self):
- return self._conn.gvoice_client.get_contact_details(self._id)
+ def contactID(self):
+ return self._id
+
+ @property
+ def contactDetails(self):
+ return self._conn.addressbook.get_contact_details(self._id)
class ListHandle(TheOneRingHandle):
TheOneRingHandle.__init__(self, connection, id, handleType, handleName)
-class GroupHandle(TheOneRingHandle):
-
- def __init__(self, connection, id, groupName):
- handleType = telepathy.HANDLE_TYPE_GROUP
- handleName = groupName
- TheOneRingHandle.__init__(self, connection, id, handleType, handleName)
-
-
_HANDLE_TYPE_MAPPING = {
'connection': ConnectionHandle,
'contact': ContactHandle,
'list': ListHandle,
- 'group': GroupHandle,
}