Author: asterix Date: 2008-06-25 11:25:43 +0200 (Wed, 25 Jun 2008) New Revision: 9839
Modified: trunk/src/common/connection.py trunk/src/common/connection_handlers.py trunk/src/roster_window.py Log: 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
Modified: trunk/src/common/connection.py =================================================================== --- trunk/src/common/connection.py 2008-06-25 07:35:35 UTC (rev 9838) +++ trunk/src/common/connection.py 2008-06-25 09:25:43 UTC (rev 9839) @@ -811,6 +811,11 @@ 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 @@ {'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 @@ 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 @@ # 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)
Modified: trunk/src/common/connection_handlers.py =================================================================== --- trunk/src/common/connection_handlers.py 2008-06-25 07:35:35 UTC (rev 9838) +++ trunk/src/common/connection_handlers.py 2008-06-25 09:25:43 UTC (rev 9839) @@ -1101,6 +1101,14 @@ 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:
Modified: trunk/src/roster_window.py =================================================================== --- trunk/src/roster_window.py 2008-06-25 07:35:35 UTC (rev 9838) +++ trunk/src/roster_window.py 2008-06-25 09:25:43 UTC (rev 9839) @@ -4450,7 +4450,12 @@ 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)