don't show sign in/out notifications if another resource or a metacontact brother is already connected. Fixes #5318
This commit is contained in:
parent
b21d538b0f
commit
8abbf990ba
1 changed files with 53 additions and 12 deletions
|
@ -285,7 +285,7 @@ class Interface:
|
||||||
# FIXME: Drop and rewrite...
|
# FIXME: Drop and rewrite...
|
||||||
|
|
||||||
statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 'dnd',
|
statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 'dnd',
|
||||||
'invisible']
|
'invisible']
|
||||||
# Ignore invalid show
|
# Ignore invalid show
|
||||||
if array[1] not in statuss:
|
if array[1] not in statuss:
|
||||||
return
|
return
|
||||||
|
@ -295,6 +295,7 @@ class Interface:
|
||||||
jid = array[0].split('/')[0]
|
jid = array[0].split('/')[0]
|
||||||
keyID = array[5]
|
keyID = array[5]
|
||||||
contact_nickname = array[7]
|
contact_nickname = array[7]
|
||||||
|
lcontact = []
|
||||||
|
|
||||||
# Get the proper keyID
|
# Get the proper keyID
|
||||||
keyID = helpers.prepare_and_validate_gpg_keyID(account, jid, keyID)
|
keyID = helpers.prepare_and_validate_gpg_keyID(account, jid, keyID)
|
||||||
|
@ -309,8 +310,7 @@ class Interface:
|
||||||
else:
|
else:
|
||||||
ji = jid
|
ji = jid
|
||||||
|
|
||||||
highest = gajim.contacts. \
|
highest = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
get_contact_with_highest_priority(account, jid)
|
|
||||||
was_highest = (highest and highest.resource == resource)
|
was_highest = (highest and highest.resource == resource)
|
||||||
|
|
||||||
conn = gajim.connections[account]
|
conn = gajim.connections[account]
|
||||||
|
@ -422,7 +422,7 @@ class Interface:
|
||||||
account_ji = account + '/' + ji
|
account_ji = account + '/' + ji
|
||||||
gajim.block_signed_in_notifications[account_ji] = True
|
gajim.block_signed_in_notifications[account_ji] = True
|
||||||
gobject.timeout_add_seconds(30,
|
gobject.timeout_add_seconds(30,
|
||||||
self.unblock_signed_in_notifications, account_ji)
|
self.unblock_signed_in_notifications, account_ji)
|
||||||
locations = (self.instances, self.instances[account])
|
locations = (self.instances, self.instances[account])
|
||||||
for location in locations:
|
for location in locations:
|
||||||
if 'add_contact' in location:
|
if 'add_contact' in location:
|
||||||
|
@ -438,7 +438,7 @@ class Interface:
|
||||||
# (when contact signs out or has errors)
|
# (when contact signs out or has errors)
|
||||||
if array[1] in ('offline', 'error'):
|
if array[1] in ('offline', 'error'):
|
||||||
contact1.our_chatstate = contact1.chatstate = \
|
contact1.our_chatstate = contact1.chatstate = \
|
||||||
contact1.composing_xep = None
|
contact1.composing_xep = None
|
||||||
|
|
||||||
# TODO: This causes problems when another
|
# TODO: This causes problems when another
|
||||||
# resource signs off!
|
# resource signs off!
|
||||||
|
@ -452,7 +452,7 @@ class Interface:
|
||||||
# there won't be any sessions here if the contact terminated
|
# there won't be any sessions here if the contact terminated
|
||||||
# their sessions before going offline (which we do)
|
# their sessions before going offline (which we do)
|
||||||
for sess in conn.get_sessions(ji):
|
for sess in conn.get_sessions(ji):
|
||||||
if (ji+'/'+resource) != str(sess.jid):
|
if (ji + '/' + resource) != str(sess.jid):
|
||||||
continue
|
continue
|
||||||
if sess.control:
|
if sess.control:
|
||||||
sess.control.no_autonegotiation = False
|
sess.control.no_autonegotiation = False
|
||||||
|
@ -461,17 +461,58 @@ class Interface:
|
||||||
conn.delete_session(jid, sess.thread_id)
|
conn.delete_session(jid, sess.thread_id)
|
||||||
|
|
||||||
self.roster.chg_contact_status(contact1, array[1], status_message,
|
self.roster.chg_contact_status(contact1, array[1], status_message,
|
||||||
account)
|
account)
|
||||||
# Notifications
|
# Notifications
|
||||||
if old_show < 2 and new_show > 1:
|
if old_show < 2 and new_show > 1:
|
||||||
notify.notify('contact_connected', jid, account, status_message)
|
show_notif = True
|
||||||
|
for c in lcontact:
|
||||||
|
if c.resource == resource:
|
||||||
|
# we look for other connected resources
|
||||||
|
continue
|
||||||
|
if c.show not in ('offline', 'error'):
|
||||||
|
show_notif = False
|
||||||
|
break
|
||||||
|
if show_notif:
|
||||||
|
# no other resource is connected, let's look in metacontacts
|
||||||
|
family = gajim.contacts.get_metacontacts_family(account, ji)
|
||||||
|
for info in family:
|
||||||
|
acct_ = info['account']
|
||||||
|
jid_ = info['jid']
|
||||||
|
c_ = gajim.contacts.get_contact_with_highest_priority(
|
||||||
|
acct_, jid_)
|
||||||
|
if c_.show not in ('offline', 'error'):
|
||||||
|
show_notif = False
|
||||||
|
break
|
||||||
|
if show_notif:
|
||||||
|
notify.notify('contact_connected', jid, account,
|
||||||
|
status_message)
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('ContactPresence', (account,
|
self.remote_ctrl.raise_signal('ContactPresence', (account,
|
||||||
array))
|
array))
|
||||||
|
|
||||||
elif old_show > 1 and new_show < 2:
|
elif old_show > 1 and new_show < 2:
|
||||||
notify.notify('contact_disconnected', jid, account,
|
show_notif = True
|
||||||
status_message)
|
for c in lcontact:
|
||||||
|
if c.resource == resource:
|
||||||
|
# we look for other connected resources
|
||||||
|
continue
|
||||||
|
if c.show not in ('offline', 'error'):
|
||||||
|
show_notif = False
|
||||||
|
break
|
||||||
|
if show_notif:
|
||||||
|
# no other resource is connected, let's look in metacontacts
|
||||||
|
family = gajim.contacts.get_metacontacts_family(account, ji)
|
||||||
|
for info in family:
|
||||||
|
acct_ = info['account']
|
||||||
|
jid_ = info['jid']
|
||||||
|
c_ = gajim.contacts.get_contact_with_highest_priority(
|
||||||
|
acct_, jid_)
|
||||||
|
if c_.show not in ('offline', 'error'):
|
||||||
|
show_notif = False
|
||||||
|
break
|
||||||
|
if show_notif:
|
||||||
|
notify.notify('contact_disconnected', jid, account,
|
||||||
|
status_message)
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('ContactAbsence', (account,
|
self.remote_ctrl.raise_signal('ContactAbsence', (account,
|
||||||
array))
|
array))
|
||||||
|
@ -480,7 +521,7 @@ class Interface:
|
||||||
# error (<1))
|
# error (<1))
|
||||||
elif new_show > 1:
|
elif new_show > 1:
|
||||||
notify.notify('status_change', jid, account, [new_show,
|
notify.notify('status_change', jid, account, [new_show,
|
||||||
status_message])
|
status_message])
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('ContactStatus', (account,
|
self.remote_ctrl.raise_signal('ContactStatus', (account,
|
||||||
array))
|
array))
|
||||||
|
|
Loading…
Add table
Reference in a new issue