-import weakref
import logging
import telepathy
):
def __init__(self, connection):
- self._recv_id = 0
- self._connRef = weakref.ref(connection)
-
- telepathy.server.ChannelTypeText.__init__(self, connection, None)
+ h = None
+ telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, h)
telepathy.server.ChannelInterfaceGroup.__init__(self)
telepathy.server.ChannelInterfaceChatState.__init__(self)
- self.GroupFlagsChanged(telepathy.CHANNEL_GROUP_FLAG_CAN_ADD, 0)
- self.__add_initial_participants()
-
def ListStreams(self):
"""
For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
-import weakref
import logging
import telepathy
telepathy.server.ChannelTypeContactList.__init__(self, connection, h)
telepathy.server.ChannelInterfaceGroup.__init__(self)
- self._conn_ref = weakref.ref(connection)
self._session = connection.session
@todo This currently does not handle people with multiple phone
numbers, yay that'll be annoying to resolve
"""
- connection = self._conn_ref()
+ connection = self._conn
handlesAdded = [
handle.create_handle(connection, "contact", contactId)
for contactId in added
import time
-import weakref
+import logger
import telepathy
+import handle
+
+
+_moduleLogger = logger.getLogger("channel.text")
+
class TextChannel(telepathy.server.ChannelTypeText):
"""
"""
def __init__(self, connection):
- self._recv_id = 0
- self._connRef = weakref.ref(connection)
-
- telepathy.server.ChannelTypeText.__init__(self, connection, None)
+ h = None
+ telepathy.server.ChannelTypeText.__init__(self, connection, h)
+ self._nextRecievedId = 0
- self.GroupFlagsChanged(telepathy.CHANNEL_GROUP_FLAG_CAN_ADD, 0)
- self.__add_initial_participants()
+ handles = []
+ # @todo Populate participants
+ self.MembersChanged('', handles, [], [], [],
+ 0, telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
def Send(self, messageType, text):
- if messageType == telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
- pass
- else:
+ if messageType != telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
raise telepathy.NotImplemented("Unhandled message type")
+ # @todo implement sending message
self.Sent(int(time.time()), messageType, text)
def Close(self):
- self._conversation.leave()
telepathy.server.ChannelTypeText.Close(self)
self.remove_from_connection()
+
+ def _on_message_received(self, sender, message):
+ """
+ @todo Attatch this to receiving a message
+ """
+ currentReceivedId = self._nextRecievedId
+
+ timestamp = int(time.time())
+ h = handle.create_handle(self._conn, "contact", sender.account)
+ type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL
+ message = message.content
+
+ _moduleLogger.info("Received message from User %r" % h)
+ self.Received(id, timestamp, h, type, 0, message)
+
+ self._nextRecievedId += 1
@returns DBus object path for the channel created or retrieved
"""
self.check_connected()
+ self.check_handle(handleType, handleId)
channel = None
channelManager = self._channelManager
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)
def __init__(self, shutdown_func=None):
telepathy.server.ConnectionManager.__init__(self, constants._telepathy_implementation_name_)
+ # self._protos is from super
self._protos[constants._telepathy_protocol_name_] = connection.TheOneRingConnection
self._on_shutdown = shutdown_func
_moduleLogger.info("Connection manager created")
handleName = contactId
TheOneRingHandle.__init__(self, connection, id, handleType, handleName)
- self._id = contactId
+ self._contactId = contactId
@property
def contactID(self):
- return self._id
+ return self._contactId
@property
def contactDetails(self):
handle = cache[key]
isNewHandle = False
except KeyError:
+ # The misnamed get_handle_id requests a new handle id
handle = Handle(connection, connection.get_handle_id(), *args)
cache[key] = handle
isNewHandle = True