Random bug fixes, advancing the channels, unit tests, seperating contacts not just...
[theonering] / src / connection.py
index a772bb5..063d2c9 100644 (file)
@@ -174,19 +174,21 @@ class TheOneRingConnection(telepathy.server.Connection):
                        self.add_client_handle(h, sender)
                return handles
 
-       def _create_contact_handle(self, name):
-               requestedContactId = name
-
-               contacts = self.session.addressbook.get_contacts()
-               contactsFound = [
-                       contactId for contactId in contacts
-                       if contactId == requestedContactId
-               ]
-
-               if 0 < len(contactsFound):
-                       contactId = contactsFound[0]
-                       if len(contactsFound) != 1:
-                               _moduleLogger.error("Contact ID was not unique: %s for %s" % (contactId, ))
-               else:
-                       contactId = requestedContactId
-               h = handle.create_handle(self, 'contact', contactId)
+       def _create_contact_handle(self, requestedHandleName):
+               """
+               @todo Determine if nay of this is really needed
+               """
+               requestedContactId, requestedContactName = handle.ContactHandle.from_handle_name(
+                       requestedHandleName
+               )
+               h = handle.create_handle(self, 'contact', requestedContactId, requestedHandleName)
+               return h
+
+       def _on_invite_text(self, contactId):
+               """
+               @todo Make this work
+               """
+               h = self._create_contact_handle(contactId)
+
+               channelManager = self._channelManager
+               channel = channelManager.channel_for_text(handle)