diff libervia.tac @ 19:e8e3704eb97f

Added basic chat panel - the chat panel show history, timestamp, and nickname (pretty similar to primitivus and wix chat window) - JID has be rewritten to work with pyjamas, and is now in browser_side directory - a widget can now be selected: the message send in uniBox will be sent to it if there is no explicit target prefix ("@something") - a basic status panel is added under the uniBox, but not used yet
author Goffi <goffi@goffi.org>
date Sat, 16 Apr 2011 01:46:01 +0200
parents 9bf8ed012adc
children 8f4b1a8914c3
line wrap: on
line diff
--- a/libervia.tac	Fri Apr 15 15:30:31 2011 +0200
+++ b/libervia.tac	Sat Apr 16 01:46:01 2011 +0200
@@ -54,11 +54,22 @@
             fault = jsonrpclib.Fault(0, "Not allowed") #FIXME: define some standard error codes for libervia
             return jsonrpc.JSONRPC._cbRender(self, fault, request, parsed.get('id'), parsed.get('jsonrpc'))
         return jsonrpc.JSONRPC.render(self, request)
+
+    def jsonrpc_getProfileJid(self):
+        """Return the jid of the profile"""
+        profile = self.session.sat_profile
+        self.session.sat_jid = self.sat_host.bridge.getParamA("JabberID", "Connection", profile_key=profile)
+        return self.session.sat_jid
         
     def jsonrpc_getContacts(self):
         """Return all passed args."""
         profile = self.session.sat_profile
         return self.sat_host.bridge.getContacts(profile)
+    
+    def jsonrpc_sendMessage(self, to_jid, msg, subject, type):
+        """send message"""
+        profile = self.session.sat_profile
+        return self.sat_host.bridge.sendMessage(to_jid, msg, subject, type, profile)
 
     def jsonrpc_sendMblog(self, raw_text):
         """Parse raw_text of the microblog box, and send message consequently"""
@@ -74,6 +85,20 @@
             else:
                 return self.sat_host.bridge.sendGroupBlog([recip], text, profile)
 
+    def jsonrpc_getHistory(self, from_jid, to_jid, size):
+        """Return history for the from_jid/to_jid couple"""
+        #FIXME: this method should definitely be asynchrone, need to fix it !!!
+        profile = self.session.sat_profile
+        try:
+            _jid = JID(self.session.sat_jid)
+        except:
+            error("No jid saved for this profile")
+            return {}
+        if JID(from_jid).userhost() != _jid.userhost() and JID(to_jid) != _jid.userhost():
+            error("Trying to get history from a different jid, maybe a hack attempt ?")
+            return {}
+        return self.sat_host.bridge.getHistory(from_jid, to_jid, size) 
+
 
 
 class Register(jsonrpc.JSONRPC):
@@ -285,7 +310,7 @@
             sys.exit(1)
         self.bridge.register("connected", self.signal_handler.connected)
         self.bridge.register("connectionError", self.signal_handler.connectionError)
-        for signal_name in ['presenceUpdate', 'personalEvent']:
+        for signal_name in ['presenceUpdate', 'personalEvent', 'newMessage']:
             self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name))
         root.putChild('json_signal_api', self.signal_handler)
         root.putChild('json_api', MethodHandler(self))