changeset 125:f9d63624699f

radio collective integration, first draft
author Goffi <goffi@goffi.org>
date Thu, 05 Jan 2012 00:22:03 +0100
parents 6d1f4a3da29b
children adecb2566b53
files browser_side/dialog.py browser_side/menu.py libervia.py libervia.tac
diffstat 4 files changed, 23 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/dialog.py	Mon Dec 12 22:26:55 2011 +0100
+++ b/browser_side/dialog.py	Thu Jan 05 00:22:03 2012 +0100
@@ -59,7 +59,8 @@
         content.add(self.contacts_list)
         button_panel = HorizontalPanel()
         self.choose_button = Button("Choose", self.onChoose)
-        self.choose_button.setEnabled(False)
+        if (nb_contact):
+            self.choose_button.setEnabled(False)
         button_panel.add(self.choose_button)
         button_panel.add(Button("Cancel", self.onCancel))
         content.add(button_panel)
--- a/browser_side/menu.py	Mon Dec 12 22:26:55 2011 +0100
+++ b/browser_side/menu.py	Thu Jan 05 00:22:03 2012 +0100
@@ -82,6 +82,7 @@
 
         menu_group = MenuBar(vertical=True)
         menu_group.addItem("join room", MenuCmd(self, "onJoinRoom"))
+        menu_group.addItem("Collective radio", MenuCmd(self, "onCollectiveRadio"))
 
         menu_games = MenuBar(vertical=True)
         menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame"))
@@ -229,7 +230,12 @@
         _dialog.setHTML('Group discussions')
         _dialog.setWidget(_main_panel)
         _dialog.show()
-        
+    
+    def onCollectiveRadio(self):
+        def onContactsSelected(contacts):
+            print("let's go :)")
+            self.host.bridge.call('launchRadioCollective', None, contacts)
+        dialog.ContactsChooser(self.host, onContactsSelected, None, text="Please select contacts to invite").getContacts() 
 
     #Game menu
 
--- a/libervia.py	Mon Dec 12 22:26:55 2011 +0100
+++ b/libervia.py	Thu Jan 05 00:22:03 2012 +0100
@@ -78,7 +78,7 @@
         LiberviaJsonProxy.__init__(self, "/json_api",
                         ["getContacts", "addContact", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory", "getPresenceStatus",
                          "joinMUC", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed",
-                         "tarotGamePlayCards", "getWaitingSub", "subscription", "delContact", "updateContact", "getCardCache"])
+                         "tarotGamePlayCards", "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getCardCache"])
 
 class BridgeSignals(LiberviaJsonProxy):
     def __init__(self, host):
@@ -320,26 +320,26 @@
         if (not self.whoami or self.whoami.bare != _entity.bare):
             self.contact_panel.setConnected(_entity.bare, _entity.resource, show, priority, statuses)
 
-    def _roomJoinedCb(self, room_id, room_service, room_nicks, user_nick):
-        _target = JID("%s@%s" % (room_id,room_service))
+    def _roomJoinedCb(self, room_jid, room_nicks, user_nick):
+        _target = JID(room_jid)
         self.room_list.add(_target)
         chat_panel = panels.ChatPanel(self, _target, type='group')
         chat_panel.setUserNick(user_nick)
-        if room_id.startswith('sat_tarot_'): #XXX: it's not really beautiful, but it works :)
+        if room_jid.node.startswith('sat_tarot_'): #XXX: it's not really beautiful, but it works :)
             self.addTab(chat_panel, "Tarot")
         else:
             self.addTab(chat_panel, _target.node)
         chat_panel.setPresents(room_nicks)
         chat_panel.historyPrint()
 
-    def _roomUserJoinedCb(self, room_id, room_service, user_nick, user_data):
+    def _roomUserJoinedCb(self, room_jid, user_nick, user_data):
         for lib_wid in self.libervia_widgets:
-            if isinstance(lib_wid,panels.ChatPanel) and lib_wid.type == 'group' and lib_wid.target.bare == "%s@%s" % (room_id, room_service):
+            if isinstance(lib_wid,panels.ChatPanel) and lib_wid.type == 'group' and lib_wid.target.bare == room_jid.bare:
                 lib_wid.userJoined(user_nick, user_data)
 
-    def _roomUserLeftCb(self, room_id, room_service, user_nick, user_data):
+    def _roomUserLeftCb(self, room_jid, user_nick, user_data):
         for lib_wid in self.libervia_widgets:
-            if isinstance(lib_wid,panels.ChatPanel) and lib_wid.type == 'group' and lib_wid.target.bare == "%s@%s" % (room_id, room_service):
+            if isinstance(lib_wid,panels.ChatPanel) and lib_wid.type == 'group' and lib_wid.target.bare == room_jid.bare:
                 lib_wid.userLeft(user_nick, user_data)
         
     def _tarotGameStartedCb(self, room_jid, referee, players):
--- a/libervia.tac	Mon Dec 12 22:26:55 2011 +0100
+++ b/libervia.tac	Thu Jan 05 00:22:03 2012 +0100
@@ -240,7 +240,7 @@
         except:
             warning('Invalid room jid')
             return
-        self.sat_host.bridge.joinMUC(room_jid.host, room_jid.user, nick, profile)
+        self.sat_host.bridge.joinMUC(room_jid.userhost(), nick, {}, profile)
 
     def jsonrpc_getRoomsJoined(self):
         """Return list of room already joined by user"""
@@ -273,6 +273,11 @@
         profile = ISATSession(self.session).profile
         self.sat_host.bridge.tarotGamePlayCards(player_nick, referee, cards, profile)
 
+    def jsonrpc_launchRadioCollective(self, invited):
+        """Create a room, invite people, and start a radio collective"""
+        profile = ISATSession(self.session).profile
+        self.sat_host.bridge.radiocolLaunch(invited, profile)
+
     def jsonrpc_getCardCache(self, jid):
         """Get the avatar of a contact
         @param jid: jid of contact from who we want the avatar