changeset 692:7a9c7b9f6a28

browser_side: use host.default_muc instead of C.DEFAULT_MUC
author souliane <souliane@mailoo.org>
date Thu, 09 Apr 2015 11:37:25 +0200
parents 16079280a39e
children 1d60fa4d25a4
files src/browser/libervia_main.py src/browser/sat_browser/contact_panel.py src/browser/sat_browser/dialog.py src/browser/sat_browser/game_radiocol.py src/browser/sat_browser/json.py src/server/server.py
diffstat 6 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/libervia_main.py	Thu Apr 09 11:46:45 2015 +0200
+++ b/src/browser/libervia_main.py	Thu Apr 09 11:37:25 2015 +0200
@@ -404,6 +404,10 @@
         #we ask for our own microblogs:
         self.loadOurMainEntries()
 
+        def gotDefaultMUC(default_muc):
+            self.default_muc = default_muc
+        self.bridge.getDefaultMUC(profile=None, callback=gotDefaultMUC)
+
     def addContactList(self, dummy):
         contact_list = ContactList(self)
         self.panel.addContactList(contact_list)
@@ -1090,7 +1094,7 @@
         @param failure (defer.Failure): Failure instance
         """
         # FIXME: remove asap, see self.showFailure
-        msg = _(u"Invalid room identifier. Please give a room short or full identifier like 'room' or 'room@%s'.") % C.DEFAULT_MUC_SERVICE
+        msg = _(u"Invalid room identifier. Please give a room short or full identifier like 'room' or '%s'.") % self.default_muc
         self.showFailure(err_data, msg)
 
 
--- a/src/browser/sat_browser/contact_panel.py	Thu Apr 09 11:46:45 2015 +0200
+++ b/src/browser/sat_browser/contact_panel.py	Thu Apr 09 11:37:25 2015 +0200
@@ -38,7 +38,7 @@
     """
 
     def __init__(self, host, merge_resources=True, contacts_click=None,
-                 contacts_style=None, contacts_menus=True,
+                 contacts_style=None, contacts_menus=None,
                  contacts_display=C.CONTACT_DEFAULT_DISPLAY):
         """
 
--- a/src/browser/sat_browser/dialog.py	Thu Apr 09 11:46:45 2015 +0200
+++ b/src/browser/sat_browser/dialog.py	Thu Apr 09 11:37:25 2015 +0200
@@ -54,10 +54,11 @@
 
     GENERATE_MUC = "<use random name>"
 
-    def __init__(self, host, default_room=C.DEFAULT_MUC):
+    def __init__(self, host, room_jid_s=None):
         """
 
         @param host (SatWebFrontend)
+        @param room_jid_s (unicode): room JID
         """
         Grid.__init__(self, 2, 2, Width='100%')
         self.host = host
@@ -65,7 +66,7 @@
         self.new_radio = RadioButton("room", "Discussion room:")
         self.new_radio.setChecked(True)
         self.box = TextBox(Width='95%')
-        self.box.setText(self.GENERATE_MUC if default_room == "" else default_room)
+        self.box.setText(room_jid_s if room_jid_s else self.GENERATE_MUC)
         self.exist_radio = RadioButton("room", "Already joined:")
         self.rooms_list = ListBox(Width='95%')
 
@@ -203,7 +204,7 @@
         button_panel.add(ok_button)
         button_panel.add(Button("Cancel", self.onCancel))
 
-        self.room_panel = RoomChooser(host, "" if visible == (False, True) else C.DEFAULT_MUC)
+        self.room_panel = RoomChooser(host, None if visible == (False, True) else host.default_muc)
         self.contact_panel = ContactsChooser(host, nb_contact, ok_button)
 
         self.stack_panel = base_panel.ToggleStackPanel(Width="100%")
--- a/src/browser/sat_browser/game_radiocol.py	Thu Apr 09 11:46:45 2015 +0200
+++ b/src/browser/sat_browser/game_radiocol.py	Thu Apr 09 11:37:25 2015 +0200
@@ -257,7 +257,7 @@
         help_msg = """Accepted file formats: Ogg Vorbis (recommended), MP3.<br />
         Please do not submit files that are protected by copyright.<br />
         Click <a style="color: red;">here</a> if you need some support :)"""
-        link_cb = lambda: self._parent.host.bridge.joinMUC(C.DEFAULT_MUC, self._parent.nick, profile=C.PROF_KEY_NONE, callback=lambda dummy: None, errback=self.host.showFailureRoomInvalid)
+        link_cb = lambda: self._parent.host.bridge.joinMUC(self._parent.host.default_muc, self._parent.nick, profile=C.PROF_KEY_NONE, callback=lambda dummy: None, errback=self.host.showFailureRoomInvalid)
         self._parent.printInfo(help_msg, type_='link', link_cb=link_cb)
 
     def pushNextSong(self, title):
--- a/src/browser/sat_browser/json.py	Thu Apr 09 11:46:45 2015 +0200
+++ b/src/browser/sat_browser/json.py	Thu Apr 09 11:37:25 2015 +0200
@@ -186,7 +186,7 @@
                          "getEntityData", "getParamsUI", "asyncGetParamA", "setParam", "launchAction",
                          "disconnect", "chatStateComposing", "getNewAccountDomain", "confirmationAnswer",
                          "syntaxConvert", "getAccountDialogUI", "getMainResource", "getWaitingConf", "getEntitiesData",
-                         "getVersion", "getLiberviaVersion",
+                         "getVersion", "getLiberviaVersion", "getDefaultMUC",
                         ])
     def __call__(self, *args, **kwargs):
         return LiberviaJsonProxy.__call__(self, *args, **kwargs)
--- a/src/server/server.py	Thu Apr 09 11:46:45 2015 +0200
+++ b/src/server/server.py	Thu Apr 09 11:37:25 2015 +0200
@@ -431,6 +431,11 @@
         profile = ISATSession(self.session).profile
         return self.sat_host.bridge.getRoomsSubjects(profile)
 
+    def jsonrpc_getDefaultMUC(self):
+        """@return: the default MUC"""
+        d = self.asyncBridgeCall("getDefaultMUC")
+        return d
+
     def jsonrpc_launchTarotGame(self, other_players, room_jid=""):
         """Create a room, invite the other players and start a Tarot game.