예제 #1
0
class caveConnection(Connection, ConnectionInterfaceRequests, caveContacts):
    def __init__(self, manager, parameters):
        self._manager = weakref.proxy(manager)
        # create a new channel manager and tell it we're it's connection
        self._channel_manager = caveChannelManager(self)

        # assume we have an 'account' name passed to us
        Connection.__init__(self, PROTOCOL, parameters["account"], PROGRAM)
        ConnectionInterfaceRequests.__init__(self)
        caveContacts.__init__(self)

        self._self_handle = Handle(self.get_handle_id(), HANDLE_TYPE_CONTACT, parameters["account"])
        self._handles[HANDLE_TYPE_CONTACT, self._self_handle.get_id()] = self._self_handle

    # borrowed from butterfly, required by telepathy's channel init
    def handle(self, handle_type, handle_id):
        self.check_handle(handle_type, handle_id)
        return self._handles[handle_type, handle_id]

    def Connect(self):
        self.StatusChanged(CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_REASON_REQUESTED)

    def Disconnect(self):
        self.StatusChanged(CONNECTION_STATUS_DISCONNECTED, CONNECTION_STATUS_REASON_REQUESTED)
        # stop handling all channels
        self._channel_manager.close()
        # stop handling this connection
        self._manager.disconnected(self)
예제 #2
0
    def __init__(self, manager, parameters):
        self._manager = weakref.proxy(manager)
        # create a new channel manager and tell it we're it's connection
        self._channel_manager = caveChannelManager(self)

        # assume we have an 'account' name passed to us
        Connection.__init__(self, PROTOCOL, parameters["account"], PROGRAM)
        ConnectionInterfaceRequests.__init__(self)
        caveContacts.__init__(self)

        self._self_handle = Handle(self.get_handle_id(), HANDLE_TYPE_CONTACT, parameters["account"])
        self._handles[HANDLE_TYPE_CONTACT, self._self_handle.get_id()] = self._self_handle
예제 #3
0
 def create_handle(self, type, name, **kwargs):
     id = self.get_handle_id()
     handle = Handle(id, type, name)
     self._handles[type, id] = handle
     return handle