diff libervia.py @ 62:12e889a683ce SàT v0.2.0

server side: misc stuff: - fixed lot of misuse in callbacks - chat history fixed - a visual indicator now appear when we have message waiting from a contact - fixed About dialog size issue in webkit - fixed Drag'n'Drop for webkit - defaut room to join is now libervia@conference.libervia.org
author Goffi <goffi@goffi.org>
date Tue, 31 May 2011 17:06:59 +0200
parents 4fa3d57f72f8
children 104e71ce2293
line wrap: on
line diff
--- a/libervia.py	Tue May 31 17:03:37 2011 +0200
+++ b/libervia.py	Tue May 31 17:06:59 2011 +0200
@@ -50,8 +50,14 @@
             del self.cb[request_info.id]
         
     def onRemoteError(self, code, errobj, request_info):
+        """def dump(obj):
+            print "\n\nDUMPING %s\n\n" % obj
+            for i in dir(obj):
+                print "%s: %s" % (i, getattr(obj,i))"""
         if code != 0:
             Window.alert("Internal server error")
+            """for o in code, error, request_info:
+                dump(o)"""
         else:
             if isinstance(errobj['message'],dict):
                 Window.alert("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString']))
@@ -152,7 +158,7 @@
 
     def _isConnectedCB(self, connected):
         if not connected:
-            self._register.call('connect',self.logged)
+            self._register.call('connect',lambda x:self.logged())
         else:
             self.logged()
 
@@ -256,9 +262,17 @@
     def _newMessageCb(self, from_jid, msg, msg_type, to_jid):
         _from = JID(from_jid)
         _to = JID(to_jid)
+        showed = False
         for panel in self.mpanels + self.other_panels:
             if isinstance(panel,panels.ChatPanel) and (panel.target.bare == _from.bare or panel.target.bare == _to.bare):
                 panel.printMessage(_from, msg)
+                showed = True
+        if not showed:
+            #The message has not been showed, we must indicate it
+            other = _to if _from.bare == self.whoami.bare else _from
+            self.contact_panel.setContactMessageWaiting(other.bare, True)
+            
+
 
     def _presenceUpdateCb(self, entity, show, priority, statuses):
         _entity = JID(entity)
@@ -327,9 +341,9 @@
             _dialog = None
             msg = HTML('The contact <b>%s</b> want to add you in his/her contact list, do you accept ?' % html_sanitize(entity))
             
-            def ok_cb():
+            def ok_cb(ignore):
                 self.bridge.call('subscription', None, "subscribed", entity, '', _dialog.getSelectedGroups())
-            def cancel_cb():
+            def cancel_cb(ignore):
                 self.bridge.call('subscription', None, "unsubscribed", entity, '', '')
             
             _dialog = dialog.GroupSelector([msg], self.contact_panel.getGroups(), [], ok_cb, cancel_cb)