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

Commits:

2 changed files:

Changes:

  • gajim/gui_interface.py
    ... ... @@ -700,7 +700,8 @@ def remote_init():
    700 700
                         from gajim import remote_control
    
    701 701
                         remote_control.GajimRemote()
    
    702 702
                     except Exception:
    
    703
    -                    pass
    
    703
    +                    log.exception('Failed to init remote control')
    
    704
    +
    
    704 705
             GLib.timeout_add_seconds(5, remote_init)
    
    705 706
     
    
    706 707
     
    

  • gajim/remote_control.py
    ... ... @@ -35,6 +35,7 @@
    35 35
     from gajim.common import helpers
    
    36 36
     from gajim.common import events
    
    37 37
     from gajim.common.structs import OutgoingMessage
    
    38
    +from gajim.common.modules.contacts import BareContact
    
    38 39
     
    
    39 40
     from gajim.gui.add_contact import AddContact
    
    40 41
     
    
    ... ... @@ -689,31 +690,26 @@ def _get_real_jid(self, jid, account=None):
    689 690
                     return contact.real_jid
    
    690 691
                 return jid
    
    691 692
     
    
    692
    -    def _contacts_as_dbus_structure(self, bare_contact):
    
    693
    +    def _contacts_as_dbus_structure(self, contact: BareContact):
    
    693 694
             """
    
    694 695
             Get info from list of Contact objects and create dbus dict
    
    695 696
             """
    
    696
    -        prim_contact = None  # primary contact
    
    697
    -        for res_contact in bare_contact:
    
    698
    -            if (prim_contact is None or
    
    699
    -                    res_contact.priority > prim_contact.priority):
    
    700
    -                prim_contact = res_contact
    
    697
    +
    
    701 698
             contact_dict = {}
    
    702
    -        name = bare_contact.name
    
    703
    -        contact_dict['name'] = GLib.Variant('s', name)
    
    704
    -        contact_dict['show'] = GLib.Variant('s', prim_contact.show)
    
    705
    -        contact_dict['jid'] = GLib.Variant('s', prim_contact.jid)
    
    706
    -
    
    707
    -        resources = GLib.VariantBuilder(GLib.VariantType('a(sis)'))
    
    708
    -        for res_contact in bare_contact:
    
    709
    -            resource_props = (res_contact.jid.resource,
    
    710
    -                              int(res_contact.priority),
    
    699
    +
    
    700
    +        contact_dict['name'] = GLib.Variant('s', contact.name)
    
    701
    +        contact_dict['show'] = GLib.Variant('s', contact.show.value)
    
    702
    +        contact_dict['jid'] = GLib.Variant('s', str(contact.jid))
    
    703
    +
    
    704
    +        resources = GLib.VariantBuilder(GLib.VariantType('a(ss)'))
    
    705
    +        for res_contact in contact.iter_resources():
    
    706
    +            resource_props = (res_contact.resource,
    
    711 707
                                   res_contact.status)
    
    712
    -            resources.add_value(GLib.Variant('(sis)', resource_props))
    
    708
    +            resources.add_value(GLib.Variant('(ss)', resource_props))
    
    713 709
             contact_dict['resources'] = resources.end()
    
    714 710
     
    
    715 711
             groups = GLib.VariantBuilder(GLib.VariantType('as'))
    
    716
    -        for group in bare_contact.groups:
    
    712
    +        for group in contact.groups:
    
    717 713
                 groups.add_value(GLib.Variant('s', group))
    
    718 714
             contact_dict['groups'] = groups.end()
    
    719 715
             return contact_dict