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


Commits:
aeb80da8 by lovetox at 2022-06-15T23:50:57+02:00
fix: Remote: Don’t fail on list_contacts

Fixes #10985

- - - - -


2 changed files:

- gajim/gui_interface.py
- gajim/remote_control.py


Changes:

=====================================
gajim/gui_interface.py
=====================================
@@ -700,7 +700,8 @@ def remote_init():
                     from gajim import remote_control
                     remote_control.GajimRemote()
                 except Exception:
-                    pass
+                    log.exception('Failed to init remote control')
+
         GLib.timeout_add_seconds(5, remote_init)
 
 


=====================================
gajim/remote_control.py
=====================================
@@ -35,6 +35,7 @@
 from gajim.common import helpers
 from gajim.common import events
 from gajim.common.structs import OutgoingMessage
+from gajim.common.modules.contacts import BareContact
 
 from gajim.gui.add_contact import AddContact
 
@@ -689,31 +690,26 @@ def _get_real_jid(self, jid, account=None):
                 return contact.real_jid
             return jid
 
-    def _contacts_as_dbus_structure(self, bare_contact):
+    def _contacts_as_dbus_structure(self, contact: BareContact):
         """
         Get info from list of Contact objects and create dbus dict
         """
-        prim_contact = None  # primary contact
-        for res_contact in bare_contact:
-            if (prim_contact is None or
-                    res_contact.priority > prim_contact.priority):
-                prim_contact = res_contact
+
         contact_dict = {}
-        name = bare_contact.name
-        contact_dict['name'] = GLib.Variant('s', name)
-        contact_dict['show'] = GLib.Variant('s', prim_contact.show)
-        contact_dict['jid'] = GLib.Variant('s', prim_contact.jid)
-
-        resources = GLib.VariantBuilder(GLib.VariantType('a(sis)'))
-        for res_contact in bare_contact:
-            resource_props = (res_contact.jid.resource,
-                              int(res_contact.priority),
+
+        contact_dict['name'] = GLib.Variant('s', contact.name)
+        contact_dict['show'] = GLib.Variant('s', contact.show.value)
+        contact_dict['jid'] = GLib.Variant('s', str(contact.jid))
+
+        resources = GLib.VariantBuilder(GLib.VariantType('a(ss)'))
+        for res_contact in contact.iter_resources():
+            resource_props = (res_contact.resource,
                               res_contact.status)
-            resources.add_value(GLib.Variant('(sis)', resource_props))
+            resources.add_value(GLib.Variant('(ss)', resource_props))
         contact_dict['resources'] = resources.end()
 
         groups = GLib.VariantBuilder(GLib.VariantType('as'))
-        for group in bare_contact.groups:
+        for group in contact.groups:
             groups.add_value(GLib.Variant('s', group))
         contact_dict['groups'] = groups.end()
         return contact_dict



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/aeb80da81863079850d9bde7213858d6c8212f21

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/aeb80da81863079850d9bde7213858d6c8212f21
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