10 _moduleLogger = logging.getLogger("channel.text")
13 class TextChannel(telepathy.server.ChannelTypeText):
15 Look into implementing ChannelInterfaceMessages for rich text formatting
18 def __init__(self, connection, h):
19 telepathy.server.ChannelTypeText.__init__(self, connection, h)
20 self._nextRecievedId = 0
24 #self.MembersChanged('', handles, [], [], [],
25 # 0, telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
27 @gtk_toolbox.log_exception(_moduleLogger)
28 def Send(self, messageType, text):
29 if messageType != telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
30 raise telepathy.NotImplemented("Unhandled message type: %r" % messageType)
32 self._conn.session.backend.send_sms(self._otherHandle.phoneNumber, text)
34 self.Sent(int(time.time()), messageType, text)
36 @gtk_toolbox.log_exception(_moduleLogger)
38 telepathy.server.ChannelTypeText.Close(self)
39 self.remove_from_connection()
41 def _on_message_received(self, contactId, contactNumber, message):
43 @todo Attatch this to receiving a message
45 currentReceivedId = self._nextRecievedId
47 timestamp = int(time.time())
48 h = handle.create_handle(self._conn, "contact", contactId, contactNumber)
49 type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL
50 message = message.content
52 _moduleLogger.info("Received message from User %r" % h)
53 self.Received(id, timestamp, h, type, 0, message)
55 self._nextRecievedId += 1