- @gtk_toolbox.log_exception(_moduleLogger)
- def RequestHandles(self, handleType, names, sender):
- """
- For org.freedesktop.telepathy.Connection
- Overiding telepathy.server.Connecton to allow custom handles
- """
- self.check_connected()
- self.check_handle_type(handleType)
-
- handles = []
- for name in names:
- name = name.encode('utf-8')
- if handleType == telepathy.HANDLE_TYPE_CONTACT:
- _moduleLogger.info("RequestHandles Contact: %s" % name)
- h = self._create_contact_handle(name)
- elif handleType == telepathy.HANDLE_TYPE_LIST:
- # Support only server side (immutable) lists
- _moduleLogger.info("RequestHandles List: %s" % name)
- h = handle.create_handle(self, 'list', name)
- else:
- raise telepathy.NotAvailable('Handle type unsupported %d' % handleType)
- handles.append(h.id)
- self.add_client_handle(h, sender)
- return handles
-
- def _create_contact_handle(self, requestedHandleName):
- """
- @todo Determine if nay of this is really needed
- """
- requestedContactId, requestedContactNumber = handle.ContactHandle.from_handle_name(
- requestedHandleName
+ 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
+
+ def disconnect(self, reason):
+ _moduleLogger.info("Disconnecting")
+ # Not having the disconnect first can cause weird behavior with clients
+ # including not being able to reconnect or even crashing
+ self.StatusChanged(
+ telepathy.CONNECTION_STATUS_DISCONNECTED,
+ reason,