- 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)
+ def _generate_props(self, channelType, handle, suppressHandler, initiatorHandle=None):
+ targetHandle = 0 if handle is None else handle.get_id()
+ targetHandleType = telepathy.HANDLE_TYPE_NONE if handle is None else handle.get_type()
+ props = {
+ telepathy.CHANNEL_INTERFACE + '.ChannelType': channelType,
+ telepathy.CHANNEL_INTERFACE + '.TargetHandle': targetHandle,
+ telepathy.CHANNEL_INTERFACE + '.TargetHandleType': targetHandleType,
+ telepathy.CHANNEL_INTERFACE + '.Requested': suppressHandler
+ }
+
+ if initiatorHandle is not None:
+ props[telepathy.CHANNEL_INTERFACE + '.InitiatorHandle'] = initiatorHandle.id
+
+ return props
+
+ @gobject_utils.async
+ @gtk_toolbox.log_exception(_moduleLogger)
+ def _on_conversations_updated(self, conv, conversationIds):
+ # @todo get conversations update running
+ # @todo test conversatiuons
+ _moduleLogger.info("Incoming messages from: %r" % (conversationIds, ))
+ for contactId, phoneNumber in conversationIds:
+ h = handle.create_handle(self, 'contact', contactId, phoneNumber)
+ # Just let the TextChannel decide whether it should be reported to the user or not
+ props = self._generate_props(telepathy.CHANNEL_TYPE_TEXT, h, False)
+ channel = self._channelManager.channel_for_props(props, signal=True)