Starting to generalize the gv backend
[theonering] / src / channel / text.py
1 import time
2 import weakref
3
4 import telepathy
5
6
7 class TextChannel(telepathy.server.ChannelTypeText):
8         """
9         Look into implementing ChannelInterfaceMessages for rich text formatting
10         """
11
12         def __init__(self, connection):
13                 self._recv_id = 0
14                 self._connRef = weakref.ref(connection)
15
16                 telepathy.server.ChannelTypeText.__init__(self, connection, None)
17
18                 self.GroupFlagsChanged(telepathy.CHANNEL_GROUP_FLAG_CAN_ADD, 0)
19                 self.__add_initial_participants()
20
21         def Send(self, messageType, text):
22                 if messageType == telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
23                         pass
24                 else:
25                         raise telepathy.NotImplemented("Unhandled message type")
26                 self.Sent(int(time.time()), messageType, text)
27
28         def Close(self):
29                 self._conversation.leave()
30                 telepathy.server.ChannelTypeText.Close(self)
31                 self.remove_from_connection()