summaryrefslogtreecommitdiff
path: root/sunshine/channel
diff options
context:
space:
mode:
authorKrzysztof Klinikowski <kkszysiu@gmail.com>2010-04-24 16:13:31 +0200
committerKrzysztof Klinikowski <kkszysiu@gmail.com>2010-04-24 16:13:31 +0200
commit0e261b0d5afb831f6ce4b45176749b07da2fe94d (patch)
treee931a3717d30573146098b6e6b21136d4e38fe03 /sunshine/channel
parent2032cf05a66260d0b423134eaf38397e105d44b2 (diff)
Typing notifications, called "pisak" in GG implemented.
Diffstat (limited to 'sunshine/channel')
-rw-r--r--sunshine/channel/text.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/sunshine/channel/text.py b/sunshine/channel/text.py
index d37b6d0..fe63763 100644
--- a/sunshine/channel/text.py
+++ b/sunshine/channel/text.py
@@ -32,7 +32,8 @@ __all__ = ['SunshineTextChannel']
logger = logging.getLogger('Sunshine.TextChannel')
-class SunshineTextChannel(telepathy.server.ChannelTypeText):
+class SunshineTextChannel(telepathy.server.ChannelTypeText,
+ telepathy.server.ChannelInterfaceChatState):
def __init__(self, conn, manager, conversation, props, object_path=None):
_, surpress_handler, handle = manager._get_type_requested_handle(props)
@@ -42,6 +43,7 @@ class SunshineTextChannel(telepathy.server.ChannelTypeText):
self.handle = handle
telepathy.server.ChannelTypeText.__init__(self, conn, manager, props, object_path=None)
+ telepathy.server.ChannelInterfaceChatState.__init__(self)
def Send(self, message_type, text):
if message_type == telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
@@ -49,7 +51,8 @@ class SunshineTextChannel(telepathy.server.ChannelTypeText):
msg = text.decode('UTF-8').encode('windows-1250', 'replace')
#gg_text = escape(text.decode('UTF-8')).encode('UTF-8').replace('<', '&lt;').replace('>', '&gt;')
gg_text = text.decode('UTF-8', 'xmlcharrefreplace').replace('<', '&lt;').replace('>', '&gt;')
- self.conn.gadu_client.sendTo(int(self.handle.name), str(gg_text), str(msg))
+ self._conn_ref().profile.sendTo(int(self.handle.name), str(gg_text), str(msg))
+ self._conn_ref().profile.sendTypingNotify(int(self.handle.name), 0)
else:
raise telepathy.NotImplemented("Unhandled message type")
self.Sent(int(time.time()), message_type, text)
@@ -79,6 +82,16 @@ class SunshineTextChannel(telepathy.server.ChannelTypeText):
def ListPendingMessages(self, clear):
return telepathy.server.ChannelTypeText.ListPendingMessages(self, clear)
+ def SetChatState(self, state):
+ # Not useful if we dont have a conversation.
+ if state == telepathy.CHANNEL_CHAT_STATE_COMPOSING:
+ t = 1
+ else:
+ t = 0
+
+ handle = SunshineHandleFactory(self._conn_ref(), 'self')
+ self._conn_ref().profile.sendTypingNotify(int(self.handle.name), t)
+ self.ChatStateChanged(handle, state)
class SunshineRoomTextChannel(telepathy.server.ChannelTypeText, telepathy.server.ChannelInterfaceGroup):