changeset 266:cc778206b7ae

bridge: added inviteMUC + modify joinMUC to make it accept room_jid = ""
author souliane <souliane@mailoo.org>
date Sun, 17 Nov 2013 17:47:39 +0100
parents 56a307f08ffe
children a76243c02074
files libervia.py libervia.tac
diffstat 2 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libervia.py	Sun Nov 17 17:43:31 2013 +0100
+++ b/libervia.py	Sun Nov 17 17:47:39 2013 +0100
@@ -115,7 +115,7 @@
                         ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment",
                          "getLastMblogs", "getMassiveLastMblogs", "getMblogComments", "getProfileJid",
                          "getHistory", "getPresenceStatus", "joinMUC", "mucLeave", "getRoomsJoined",
-                         "launchTarotGame", "getTarotCardsPaths", "tarotGameReady",
+                         "inviteMUC", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady",
                          "tarotGameContratChoosed", "tarotGamePlayCards", "launchRadioCollective",
                          "getWaitingSub", "subscription", "delContact", "updateContact", "getCard",
                          "getEntityData", "getParamsUI", "asyncGetParamA", "setParam", "launchAction",
--- a/libervia.tac	Sun Nov 17 17:43:31 2013 +0100
+++ b/libervia.tac	Sun Nov 17 17:47:39 2013 +0100
@@ -318,14 +318,30 @@
         return d
 
     def jsonrpc_joinMUC(self, room_jid, nick):
-        """Join a Multi-User Chat room"""
+        """Join a Multi-User Chat room
+        @room_jid: leave empty string to generate a unique name
+        """
         profile = ISATSession(self.session).profile
         try:
-            room_jid = JID(room_jid)
+            if room_jid != "":
+                room_jid = JID(room_jid).userhost()
         except:
             warning('Invalid room jid')
             return
-        self.sat_host.bridge.joinMUC(room_jid.userhost(), nick, {}, profile)
+        d = self.asyncBridgeCall("joinMUC", room_jid, nick, {}, profile)
+        return d
+
+    def jsonrpc_inviteMUC(self, contact_jid, room_jid):
+        """Invite a user to a Multi-User Chat room"""
+        profile = ISATSession(self.session).profile
+        try:
+            room_jid = JID(room_jid).userhost()
+        except:
+            warning('Invalid room jid')
+            return
+        room_id = room_jid.split("@")[0]
+        service = room_jid.split("@")[1]
+        self.sat_host.bridge.inviteMUC(contact_jid, service, room_id, {}, profile)
 
     def jsonrpc_mucLeave(self, room_jid):
         """Quit a Multi-User Chat room"""