Philipp Hörist pushed to branch master at gajim / gajim


Commits:
7ee22d83 by Philipp Hörist at 2019-07-02T19:53:32Z
MUC: Add possibility to override default config

- - - - -


3 changed files:

- gajim/common/modules/muc.py
- gajim/common/structs.py
- gajim/gui_interface.py


Changes:

=====================================
gajim/common/modules/muc.py
=====================================
@@ -130,11 +130,12 @@ class MUC(BaseModule):
     def get_mucs_with_state(self, states):
         return [muc for muc in self._muc_data.values() if muc.state in states]
 
-    def join(self, room_jid, nick, password, rejoin=False):
+    def join(self, room_jid, nick, password, rejoin=False, config=None):
         if not app.account_is_connected(self._account):
             return
 
-        self._muc_data[room_jid] = MUCData(room_jid, nick, password, rejoin)
+        self._muc_data[room_jid] = MUCData(room_jid, nick,
+                                           password, rejoin, config)
 
         self._con.get_module('Discovery').disco_muc(
             room_jid, partial(self._join, room_jid))
@@ -182,16 +183,19 @@ class MUC(BaseModule):
             return
 
         self._log.info('Configure room: %s', result.jid)
-        self._apply_config(result.form)
+
+        muc = self._get_muc_data(result.jid)
+        self._apply_config(result.form, muc.config)
         self.set_config(result.jid,
                         result.form,
                         callback=self._on_config_result)
 
     @staticmethod
     def _apply_config(form, config=None):
-        if config is None:
-            config = get_default_muc_config()
-        for var, value in config.items():
+        default_config = get_default_muc_config()
+        if config is not None:
+            default_config.update(config)
+        for var, value in default_config.items():
             try:
                 field = form[var]
             except KeyError:


=====================================
gajim/common/structs.py
=====================================
@@ -24,11 +24,12 @@ CapsIdentity = namedtuple('CapsIdentity', 'category type 
name lang')
 
 
 class MUCData:
-    def __init__(self, room_jid, nick, password, rejoin):
+    def __init__(self, room_jid, nick, password, rejoin, config=None):
         self._room_jid = room_jid
         self._nick = nick
         self._password = password
         self._rejoin = rejoin
+        self._config = config
         self._state = MUCJoinedState.NOT_JOINED
 
     @property
@@ -62,3 +63,7 @@ class MUCData:
     @rejoin.setter
     def rejoin(self, value):
         self._rejoin = value
+
+    @property
+    def config(self):
+        return self._config


=====================================
gajim/gui_interface.py
=====================================
@@ -1568,7 +1568,7 @@ class Interface:
 
################################################################################
 
     def join_gc_room(self, account, room_jid, nick, password, minimize=False,
-                     is_continued=False):
+                     is_continued=False, config=None):
         """
         Join the room immediately
         """
@@ -1628,7 +1628,7 @@ class Interface:
 
         # Connect
         app.connections[account].get_module('MUC').join(
-            room_jid, nick, password)
+            room_jid, nick, password, config=config)
         if password:
             app.gc_passwords[room_jid] = password
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/7ee22d832e73d71ff41d75f8a26881101b9899b4

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/7ee22d832e73d71ff41d75f8a26881101b9899b4
You're receiving this email because of your account on dev.gajim.org.

_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to