From a8c0567bd099c2915fb3c2a6d2509c2155334d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Sun, 30 Sep 2018 00:15:00 +0200 Subject: [PATCH] Request security catalog from the barejid - Some Code/UI cleanup --- gajim/chat_control_base.py | 20 ++-- gajim/common/modules/security_labels.py | 7 +- gajim/data/gui/chat_control.ui | 117 ++++++++++++------------ 3 files changed, 70 insertions(+), 74 deletions(-) diff --git a/gajim/chat_control_base.py b/gajim/chat_control_base.py index 4e9249171..8dbced420 100644 --- a/gajim/chat_control_base.py +++ b/gajim/chat_control_base.py @@ -185,19 +185,18 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): def _sec_labels_received(self, event): if event.account != self.account: return - jid = nbxmpp.JID(self.contact.jid) - if event.host != jid.getDomain(): + if event.jid != self.contact.jid: return - lb = self.seclabel_combo.get_model() - lb.clear() - i = 0 + model = self.seclabel_combo.get_model() + model.clear() + sel = 0 _label, labellist, default = event.catalog - for label in labellist: - lb.append([label]) + for index, label in enumerate(labellist): + model.append([label]) if label == default: - sel = i - i += 1 + sel = index + self.seclabel_combo.set_active(sel) self.seclabel_combo.set_no_show_all(False) self.seclabel_combo.show_all() @@ -773,8 +772,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): return con = app.connections[self.account] - jid = nbxmpp.JID(self.contact.jid) - catalog = con.get_module('SecLabels').get_catalog(jid.getDomain()) + catalog = con.get_module('SecLabels').get_catalog(self.contact.jid) labels, label_list, _ = catalog lname = label_list[idx] label = labels[lname] diff --git a/gajim/common/modules/security_labels.py b/gajim/common/modules/security_labels.py index ba84e1c7e..37cd4ca51 100644 --- a/gajim/common/modules/security_labels.py +++ b/gajim/common/modules/security_labels.py @@ -42,12 +42,11 @@ class SecLabels: log.info('Discovered security labels: %s', from_) def request_catalog(self, jid): - jid = nbxmpp.JID(jid) server = app.get_jid_from_account(self._account).split("@")[1] iq = nbxmpp.Iq(typ='get', to=server) iq.addChild(name='catalog', namespace=nbxmpp.NS_SECLABEL_CATALOG, - attrs={'to': jid.getDomain()}) + attrs={'to': jid}) log.info('Request catalog: server: %s, to: %s', server, jid) self._con.connection.SendAndCallForResponse( iq, self._catalog_received) @@ -74,11 +73,11 @@ class SecLabels: catalog = (labels, label_list, default) self._catalogs[to] = catalog - log.info('Received catalog from %s', stanza.getFrom()) + log.info('Received catalog: %s', to) log.debug(catalog) app.nec.push_incoming_event(SecLabelCatalog( - None, account=self._account, host=to, catalog=catalog)) + None, account=self._account, jid=to, catalog=catalog)) def get_catalog(self, jid): return self._catalogs.get(jid) diff --git a/gajim/data/gui/chat_control.ui b/gajim/data/gui/chat_control.ui index 0935ff898..1f95f50d9 100644 --- a/gajim/data/gui/chat_control.ui +++ b/gajim/data/gui/chat_control.ui @@ -634,17 +634,57 @@ False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True - False + True + True + Show a list of emoticons (Alt+M) + none + + + True + False + face-smile-symbolic + + + False True - end 0 + + + True + True + False + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + none + formattings_menu + + + True + False + format-text-bold-symbolic + 1 + + + + + + False + True + 1 + + False @@ -746,7 +786,18 @@ audio-mic-volume-low False True end - 1 + 2 + + + + + True + False + + + False + True + 3 @@ -770,7 +821,7 @@ audio-mic-volume-low False True end - 2 + 4 @@ -797,7 +848,7 @@ audio-mic-volume-low False False end - 3 + 5 @@ -818,7 +869,7 @@ audio-mic-volume-low False True end - 4 + 6 @@ -845,58 +896,6 @@ audio-mic-volume-low False False end - 5 - - - - - True - True - True - Show a list of emoticons (Alt+M) - none - - - True - False - face-smile-symbolic - - - - - - False - True - 6 - - - - - True - True - False - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - none - formattings_menu - - - True - False - format-text-bold-symbolic - 1 - - - - - - False - True 7