summaryrefslogtreecommitdiff
path: root/sunshine
diff options
context:
space:
mode:
authorKrzysztof Klinikowski <kkszysiu@gmail.com>2010-03-29 16:52:04 +0200
committerKrzysztof Klinikowski <kkszysiu@gmail.com>2010-03-29 16:52:04 +0200
commit7295793671319f4f24f39c4dc7bc82984e65a14f (patch)
tree27487404f1d57a8a1f82142b42b32a6336f3f1bb /sunshine
parent778710291e7e3745a57a6b555beaad260084d24c (diff)
Messages handling from older clients should work correctly now. Some GG 10 data structures support added.
Diffstat (limited to 'sunshine')
-rw-r--r--sunshine/connection.py27
-rwxr-xr-xsunshine/lqsoft/pygadu/models.py11
-rwxr-xr-xsunshine/lqsoft/pygadu/twisted_protocol.py7
3 files changed, 36 insertions, 9 deletions
diff --git a/sunshine/connection.py b/sunshine/connection.py
index bcf6ee1..955257f 100644
--- a/sunshine/connection.py
+++ b/sunshine/connection.py
@@ -248,6 +248,9 @@ class SunshineConnection(telepathy.server.Connection,
self.profile.onLoginFailure = self.on_loginFailed
self.profile.onContactStatusChange = self.on_updateContact
self.profile.onMessageReceived = self.on_messageReceived
+ self.profile.onXmlAction = self.onXmlAction
+ self.profile.onXmlEvent = self.onXmlEvent
+ self.profile.onUserData = self.onUserData
#self.profile.onStatusNoticiesRecv = self.on_StatusNoticiesRecv
self.password = str(parameters['password'])
@@ -615,10 +618,12 @@ class SunshineConnection(telepathy.server.Connection,
logger.info("Msg from %r %d %d [%r] [%r]" % (msg.sender, msg.content.offset_plain, msg.content.offset_attrs, msg.content.plain_message, msg.content.html_message))
- #we need to strip all html tags
- text = stripHTML(msg.content.html_message)
+ if msg.content.html_message:
+ #we need to strip all html tags
+ text = stripHTML(msg.content.html_message).replace('&lt;', '<').replace('&gt;', '>')
+ else:
+ text = msg.content.plain_message
- #message = "%s" % unicode(str(msg.content.plain_message).replace('\x00', '').replace('\r', '').decode('windows-1250').encode('utf-8'))
message = "%s" % unicode(str(text).replace('\x00', '').replace('\r', ''))
#print 'message: ', message
channel.Received(self._recv_id, timestamp, ahandle, type, 0, message)
@@ -647,11 +652,23 @@ class SunshineConnection(telepathy.server.Connection,
channel = self._channel_manager.channel_for_props(props,
signal=True, conversation=None)
- #we need to strip all html tags
- text = stripHTML(msg.content.html_message).replace('&lt;', '<').replace('&gt;', '>')
+ if msg.content.html_message:
+ #we need to strip all html tags
+ text = stripHTML(msg.content.html_message).replace('&lt;', '<').replace('&gt;', '>')
+ else:
+ text = msg.content.plain_message
message = "%s" % unicode(str(text).replace('\x00', '').replace('\r', ''))
#message = "%s" % unicode(str(msg.content.plain_message).replace('\x00', '').replace('\r', '').decode('windows-1250').encode('utf-8'))
#print 'message: ', message
channel.Received(self._recv_id, timestamp, handle, type, 0, message)
self._recv_id += 1
+
+ def onXmlAction(self, xml):
+ logger.info("XmlAction: %s" % xml.data)
+
+ def onXmlEvent(self, xml):
+ logger.info("XmlEvent: %s" % xml,data)
+
+ def onUserData(self, data):
+ logger.info("UserData: %s" % str(data)) \ No newline at end of file
diff --git a/sunshine/lqsoft/pygadu/models.py b/sunshine/lqsoft/pygadu/models.py
index 6c70631..311dbc9 100755
--- a/sunshine/lqsoft/pygadu/models.py
+++ b/sunshine/lqsoft/pygadu/models.py
@@ -192,8 +192,15 @@ class GaduProfile(object):
"""Called when a contact list notify was sent"""
pass
- def onXml(self, data):
- """Called when a XML action/event packet was sent"""
+ def onXmlAction(self, data):
+ """Called when a XML action packet was sent"""
+ pass
+
+ def onXmlEvent(self, data):
+ """Called when a XML event packet was sent"""
+ pass
+
+ def onUserData(self, data):
pass
def isContactExist(self, uin):
diff --git a/sunshine/lqsoft/pygadu/twisted_protocol.py b/sunshine/lqsoft/pygadu/twisted_protocol.py
index e6dadb3..f5d5481 100755
--- a/sunshine/lqsoft/pygadu/twisted_protocol.py
+++ b/sunshine/lqsoft/pygadu/twisted_protocol.py
@@ -127,10 +127,13 @@ class GaduClient(Protocol):
self.loginSuccess.errback(msg)
def _handleXmlEventPacket(self, data):
- self.user_profile.onXml(data)
+ self.user_profile.onXmlEvent(data)
def _handleXmlActionPacket(self, data):
- self.user_profile.onXml(data)
+ self.user_profile.onXmlAction(data)
+
+ def _handleUserDataPacket(self, data):
+ self.user_profile.onUserData(data)
def _handleStatusUpdatePacket(self, msg):
self.user_profile._updateContact(msg.contact)