don't try the old (XEP-018) way to go invisible. It's not XMPP complient. That prevent to show the we are invisible but we are not. Fixes #4012
This commit is contained in:
parent
d2b5b31bde
commit
9457c28a63
|
@ -811,6 +811,11 @@ class Connection(ConnectionHandlers):
|
|||
def send_invisible_presence(self, msg, signed, initial = False):
|
||||
if not self.connection:
|
||||
return
|
||||
if not self.privacy_rules_supported:
|
||||
self.dispatch('STATUS', gajim.SHOW_LIST[self.connected])
|
||||
self.dispatch('ERROR', (_('Invisibility not supported'),
|
||||
_('Account %s doesn\'t support invisibility.') % self.name))
|
||||
return
|
||||
# If we are already connected, and privacy rules are supported, send
|
||||
# offline presence first as it's required by XEP-0126
|
||||
if self.connected > 1 and self.privacy_rules_supported:
|
||||
|
@ -828,19 +833,16 @@ class Connection(ConnectionHandlers):
|
|||
{'msg': msg, 'signed': signed, 'initial': initial})
|
||||
|
||||
def _continue_invisible(self, con, iq_obj, msg, signed, initial):
|
||||
ptype = ''
|
||||
show = ''
|
||||
if iq_obj.getType() == 'error': # server doesn't support privacy lists
|
||||
# We use the old way which is not xmpp complient
|
||||
ptype = 'invisible'
|
||||
show = 'invisible'
|
||||
else:
|
||||
# active the privacy rule
|
||||
self.privacy_rules_supported = True
|
||||
self.activate_privacy_rule('invisible')
|
||||
priority = unicode(gajim.get_priority(self.name, show))
|
||||
p = common.xmpp.Presence(typ = ptype, priority = priority, show = show)
|
||||
p = self.add_sha(p, ptype != 'unavailable')
|
||||
return
|
||||
# active the privacy rule
|
||||
self.privacy_rules_supported = True
|
||||
self.activate_privacy_rule('invisible')
|
||||
self.connected = STATUS_LIST.index('invisible')
|
||||
self.status = msg
|
||||
priority = unicode(gajim.get_priority(self.name, 'invisible'))
|
||||
p = common.xmpp.Presence(priority = priority)
|
||||
p = self.add_sha(p, True)
|
||||
if msg:
|
||||
p.setStatus(msg)
|
||||
if signed:
|
||||
|
@ -953,7 +955,9 @@ class Connection(ConnectionHandlers):
|
|||
sign_msg = False
|
||||
if not auto and not show == 'offline':
|
||||
sign_msg = True
|
||||
self.status = msg
|
||||
if show != 'invisible':
|
||||
# We save it only when privacy list is accepted
|
||||
self.status = msg
|
||||
if show != 'offline' and self.connected < 1:
|
||||
# set old_show to requested 'show' in case we need to
|
||||
# recconect before we auth to server
|
||||
|
@ -993,12 +997,12 @@ class Connection(ConnectionHandlers):
|
|||
# dont'try to connect, when we are in state 'connecting'
|
||||
if self.connected == 1:
|
||||
return
|
||||
was_invisible = self.connected == STATUS_LIST.index('invisible')
|
||||
self.connected = STATUS_LIST.index(show)
|
||||
if show == 'invisible':
|
||||
signed = self.get_signed_presence(msg)
|
||||
self.send_invisible_presence(msg, signed)
|
||||
return
|
||||
was_invisible = self.connected == STATUS_LIST.index('invisible')
|
||||
self.connected = STATUS_LIST.index(show)
|
||||
if was_invisible and self.privacy_rules_supported:
|
||||
iq = self.build_privacy_rule('visible', 'allow')
|
||||
self.connection.send(iq)
|
||||
|
|
|
@ -1101,6 +1101,14 @@ class ConnectionVcard:
|
|||
if iq_obj.getType() != 'error':
|
||||
self.privacy_rules_supported = True
|
||||
self.get_privacy_list('block')
|
||||
elif self.continue_connect_info:
|
||||
if self.continue_connect_info[0] == 'invisible':
|
||||
# Trying to login as invisible but privacy list not supported
|
||||
self.disconnect(on_purpose=True)
|
||||
self.dispatch('STATUS', 'offline')
|
||||
self.dispatch('ERROR', (_('Invisibility not supported'),
|
||||
_('Account %s doesn\'t support invisibility.') % self.name))
|
||||
return
|
||||
# Ask metacontacts before roster
|
||||
self.get_metacontacts()
|
||||
elif self.awaiting_answers[id][0] == PEP_CONFIG:
|
||||
|
|
|
@ -4450,7 +4450,12 @@ class RosterWindow:
|
|||
icon = state_images[show]
|
||||
item.set_image(icon)
|
||||
sub_menu.append(item)
|
||||
item.connect('activate', self.change_status, account, show)
|
||||
con = gajim.connections[account]
|
||||
if show == 'invisible' and con.connected > 1 and \
|
||||
not con.privacy_rules_supported:
|
||||
item.set_sensitive(False)
|
||||
else:
|
||||
item.connect('activate', self.change_status, account, show)
|
||||
|
||||
item = gtk.SeparatorMenuItem()
|
||||
sub_menu.append(item)
|
||||
|
|
Loading…
Reference in New Issue