gajim: prevent traceback. Fixes #7960

2015-03-07 Thread Gajim
changeset 4b6ab138eb75 in /home/hg/repos/gajim

author: Yann Leboulanger aste...@lagaule.org
branches: gajim_0.16
details:http://hg.gajim.org/gajim?cmd=changeset;node=4b6ab138eb75
description: prevent traceback. Fixes #7960

diffstat:

 src/roster_window.py |  3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diffs (13 lines):

diff -r 06f40d177c27 -r 4b6ab138eb75 src/roster_window.py
--- a/src/roster_window.py  Sat Mar 07 15:04:41 2015 +0100
+++ b/src/roster_window.py  Sat Mar 07 21:03:25 2015 +0100
@@ -976,6 +976,9 @@
 
 # FIXME: maybe move to gajim.py
 def remove_newly_added(self, jid, account):
+if account not in gajim.newly_added:
+# Account has been deleted during the timeout that called us
+return
 if jid in gajim.newly_added[account]:
 gajim.newly_added[account].remove(jid)
 self.draw_contact(jid, account)
___
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits


gajim: don't request privacy lists when connecting if server doe...

2015-03-07 Thread Gajim
changeset 06f40d177c27 in /home/hg/repos/gajim

author: Yann Leboulanger aste...@lagaule.org
branches: gajim_0.16
details:http://hg.gajim.org/gajim?cmd=changeset;node=06f40d177c27
description: don't request privacy lists when connecting if server doesn't 
support that. Fixes #7990

diffstat:

 src/common/connection.py  |  41 --
 src/common/connection_handlers.py |  30 +--
 2 files changed, 40 insertions(+), 31 deletions(-)

diffs (118 lines):

diff -r 0b4f8f6bfcdc -r 06f40d177c27 src/common/connection.py
--- a/src/common/connection.py  Sun Mar 01 15:07:14 2015 +0100
+++ b/src/common/connection.py  Sat Mar 07 15:04:41 2015 +0100
@@ -1837,7 +1837,6 @@
 if iq_obj.getType() == 'error': # server doesn't support privacy lists
 return
 # active the privacy rule
-self.privacy_rules_supported = True
 self.activate_privacy_rule('invisible')
 self.connected = gajim.SHOW_LIST.index('invisible')
 self.status = msg
@@ -1915,13 +1914,40 @@
 self.awaiting_answers[id_] = (PRIVACY_ARRIVED, )
 self.connection.send(iq)
 
+def _continue_connection_request_privacy(self):
+if self.privacy_rules_supported:
+if not self.privacy_rules_requested:
+self.privacy_rules_requested = True
+self._request_privacy()
+else:
+if self.continue_connect_info and self.continue_connect_info[0]\
+== 'invisible':
+# Trying to login as invisible but privacy list not
+# supported
+self.disconnect(on_purpose=True)
+gajim.nec.push_incoming_event(OurShowEvent(None, conn=self,
+show='offline'))
+gajim.nec.push_incoming_event(InformationEvent(None,
+conn=self, level='error', pri_txt=_('Invisibility not '
+'supported'), sec_txt=_('Account %s doesn\'t support '
+'invisibility.') % self.name))
+return
+if self.blocking_supported:
+iq = nbxmpp.Iq('get', xmlns='')
+query = iq.setQuery(name='blocklist')
+query.setNamespace(nbxmpp.NS_BLOCKING)
+id2_ = self.connection.getAnID()
+iq.setID(id2_)
+self.awaiting_answers[id2_] = (BLOCKING_ARRIVED, )
+self.connection.send(iq)
+# Ask metacontacts before roster
+self.get_metacontacts()
+
 def _nec_agent_info_error_received(self, obj):
 if obj.conn.name != self.name:
 return
 if obj.id_[:6] == 'Gajim_':
-if not self.privacy_rules_requested:
-self.privacy_rules_requested = True
-self._request_privacy()
+self._continue_connection_request_privacy()
 
 def _nec_agent_info_received(self, obj):
 if obj.conn.name != self.name:
@@ -1992,6 +2018,9 @@
 iq = nbxmpp.Iq('set')
 iq.setTag('enable', namespace=nbxmpp.NS_CARBONS)
 self.connection.send(iq)
+if nbxmpp.NS_PRIVACY in obj.features:
+self.privacy_rules_supported = True
+
 if nbxmpp.NS_BYTESTREAM in obj.features and \
 gajim.config.get_per('accounts', self.name, 'use_ft_proxies'):
 our_fjid = helpers.parse_jid(our_jid + '/' + \
@@ -2008,9 +2037,7 @@
 self.available_transports[transport_type].append(obj.fjid)
 else:
 self.available_transports[transport_type] = [obj.fjid]
-if not self.privacy_rules_requested:
-self.privacy_rules_requested = True
-self._request_privacy()
+self._continue_connection_request_privacy()
 
 def send_custom_status(self, show, msg, jid):
 if not show in gajim.SHOW_LIST:
diff -r 0b4f8f6bfcdc -r 06f40d177c27 src/common/connection_handlers.py
--- a/src/common/connection_handlers.py Sun Mar 01 15:07:14 2015 +0100
+++ b/src/common/connection_handlers.py Sat Mar 07 15:04:41 2015 +0100
@@ -575,32 +575,14 @@
 elif self.awaiting_answers[id_][0] == PRIVACY_ARRIVED:
 del self.awaiting_answers[id_]
 if iq_obj.getType() != 'error':
-self.privacy_rules_supported = True
 self.get_privacy_list('block')
+# Ask metacontacts before roster
+self.get_metacontacts()
 else:
-if self.blocking_supported:
-iq = nbxmpp.Iq('get', xmlns='')
-query = iq.setQuery(name='blocklist')
-query.setNamespace(nbxmpp.NS_BLOCKING)
-id2_ = self.connection.getAnID()
-iq.setID(id2_)
-self.awaiting_answers[id2_] = (BLOCKING_ARRIVED, )
-