9 class TheOneRingChannelText(
10 telepathy.server.ChannelTypeText,
11 telepathy.server.ChannelInterfaceGroup,
12 telepathy.server.ChannelInterfaceChatState
15 def __init__(self, connection, conversation):
17 self._conversation = conversation
18 self._conn_ref = weakref.ref(connection)
20 telepathy.server.ChannelTypeText.__init__(self, connection, None)
21 telepathy.server.ChannelInterfaceGroup.__init__(self)
22 telepathy.server.ChannelInterfaceChatState.__init__(self)
24 self.GroupFlagsChanged(telepathy.CHANNEL_GROUP_FLAG_CAN_ADD, 0)
25 self.__add_initial_participants()
27 def SetChatState(self, state):
28 if state == telepathy.CHANNEL_CHAT_STATE_COMPOSING:
29 self._conversation.send_typing_notification()
30 h = handle.create_handle(self._conn_ref(), 'self')
31 self.ChatStateChanged(h, state)
33 def Send(self, messageType, text):
34 if messageType == telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
35 self._conversation.send_text_message(text)
36 elif messageType == telepathy.CHANNEL_TEXT_MESSAGE_TYPE_ACTION and text == u"nudge":
37 self._conversation.send_nudge()
39 raise telepathy.NotImplemented("Unhandled message type")
40 self.Sent(int(time.time()), messageType, text)
43 self._conversation.leave()
44 telepathy.server.ChannelTypeText.Close(self)
45 self.remove_from_connection()