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


Commits:
58bb2d25 by Philipp Hörist at 2019-12-14T09:52:53Z
Presence: Raise notification instead of popup

When a contact accepts our subscription request issue a system
notification instead of a InformationDialog

- - - - -


3 changed files:

- gajim/common/modules/presence.py
- gajim/gui_interface.py
- gajim/remote_control.py


Changes:

=====================================
gajim/common/modules/presence.py
=====================================
@@ -279,7 +279,6 @@ class Presence(BaseModule):
 
     def _subscribed_received(self, _con, _stanza, properties):
         jid = properties.jid.getBare()
-        resource = properties.jid.getResource()
         self._log.info('Received Subscribed: %s', properties.jid)
         if jid in self.automatically_added:
             self.automatically_added.remove(jid)
@@ -287,7 +286,8 @@ class Presence(BaseModule):
 
         app.nec.push_incoming_event(NetworkEvent(
             'subscribed-presence-received',
-            conn=self._con, jid=jid, resource=resource))
+            account=self._account,
+            jid=properties.jid))
         raise nbxmpp.NodeProcessed
 
     def _unsubscribe_received(self, _con, _stanza, properties):


=====================================
gajim/gui_interface.py
=====================================
@@ -320,25 +320,39 @@ class Interface:
                 event_type, obj.jid, account, 'subscription_request',
                 'gajim-subscription_request', event_type, obj.jid)
 
-    def handle_event_subscribed_presence(self, obj):
-        #('SUBSCRIBED', account, (jid, resource))
-        account = obj.conn.name
-        if obj.jid in app.contacts.get_jid_list(account):
-            c = app.contacts.get_first_contact_from_jid(account, obj.jid)
-            c.resource = obj.resource
-            self.roster.remove_contact_from_groups(c.jid, account,
-                [_('Not in contact list'), _('Observers')], update=False)
+    def handle_event_subscribed_presence(self, event):
+        bare_jid = event.jid.getBare()
+        resource = event.jid.getResource()
+        if bare_jid in app.contacts.get_jid_list(event.account):
+            contact = app.contacts.get_first_contact_from_jid(event.account,
+                                                              bare_jid)
+            contact.resource = resource
+            self.roster.remove_contact_from_groups(contact.jid,
+                                                   event.account,
+                                                   [_('Not in contact list'),
+                                                    _('Observers')],
+                                                   update=False)
         else:
-            name = obj.jid.split('@', 1)[0]
+            name = event.jid.getNode()
             name = name.split('%', 1)[0]
-            contact1 = app.contacts.create_contact(jid=obj.jid,
-                account=account, name=name, groups=[], show='online',
-                status='online', ask='to', resource=obj.resource)
-            app.contacts.add_contact(account, contact1)
-            self.roster.add_contact(obj.jid, account)
-        InformationDialog(_('Authorization accepted'),
-            _('The contact "%s" has authorized you to see their status.')
-            % obj.jid)
+            contact = app.contacts.create_contact(jid=bare_jid,
+                                                  account=event.account,
+                                                  name=name,
+                                                  groups=[],
+                                                  show='online',
+                                                  status='online',
+                                                  ask='to',
+                                                  resource=resource)
+            app.contacts.add_contact(event.account, contact)
+            self.roster.add_contact(bare_jid, event.account)
+
+        app.notification.popup(
+            None,
+            bare_jid,
+            event.account,
+            title=_('Authorization accepted'),
+            text=_('The contact "%s" has authorized you'
+                   ' to see their status.') % event.jid)
 
     def show_unsubscribed_dialog(self, account, contact):
         def _remove():


=====================================
gajim/remote_control.py
=====================================
@@ -357,9 +357,10 @@ class GajimRemote(Server):
         self.raise_signal('Subscribe', (obj.conn.name, [obj.jid, obj.status,
             obj.user_nick]))
 
-    def on_subscribed_presence_received(self, obj):
-        self.raise_signal('Subscribed', (obj.conn.name, [obj.jid,
-            obj.resource]))
+    def on_subscribed_presence_received(self, event):
+        self.raise_signal('Subscribed', (event.account,
+                                         [event.jid.getBare(),
+                                          event.jid.getResource()]))
 
     def on_unsubscribed_presence_received(self, obj):
         self.raise_signal('Unsubscribed', (obj.conn.name, obj.jid))



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/58bb2d25a672da45f5bd088ae7e8f26abd106b6f

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