Request security catalog from the barejid

- Some Code/UI cleanup
This commit is contained in:
Philipp Hörist 2018-09-30 00:15:00 +02:00
parent 944a1a9318
commit dd3bbf2bb7
3 changed files with 70 additions and 74 deletions

View File

@ -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]

View File

@ -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)

View File

@ -634,17 +634,57 @@
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<object class="GtkComboBox" id="label_selector">
<object class="GtkMenuButton" id="emoticons_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Show a list of emoticons (Alt+M)</property>
<property name="relief">none</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">face-smile-symbolic</property>
</object>
</child>
<style>
<class name="chatcontrol-actionbar-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="formattings_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="has_tooltip">True</property>
<property name="relief">none</property>
<property name="popup">formattings_menu</property>
<child>
<object class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">format-text-bold-symbolic</property>
<property name="icon_size">1</property>
</object>
</child>
<style>
<class name="chatcontrol-actionbar-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="audio_buttons_hbox">
<property name="can_focus">False</property>
@ -746,7 +786,18 @@ audio-mic-volume-low</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="label_selector">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
@ -770,7 +821,7 @@ audio-mic-volume-low</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">2</property>
<property name="position">4</property>
</packing>
</child>
<child>
@ -797,7 +848,7 @@ audio-mic-volume-low</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">3</property>
<property name="position">5</property>
</packing>
</child>
<child>
@ -818,7 +869,7 @@ audio-mic-volume-low</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">4</property>
<property name="position">6</property>
</packing>
</child>
<child>
@ -845,58 +896,6 @@ audio-mic-volume-low</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="emoticons_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Show a list of emoticons (Alt+M)</property>
<property name="relief">none</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">face-smile-symbolic</property>
</object>
</child>
<style>
<class name="chatcontrol-actionbar-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="formattings_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="has_tooltip">True</property>
<property name="relief">none</property>
<property name="popup">formattings_menu</property>
<child>
<object class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">format-text-bold-symbolic</property>
<property name="icon_size">1</property>
</object>
</child>
<style>
<class name="chatcontrol-actionbar-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
</packing>
</child>