Commit 58bb2d25 authored by Philipp Hörist's avatar Philipp Hörist

Presence: Raise notification instead of popup

When a contact accepts our subscription request issue a system
notification instead of a InformationDialog
parent 8adb6ce3
Pipeline #4774 passed with stages
in 3 minutes and 24 seconds
......@@ -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):
......
......@@ -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():
......
......@@ -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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment