correctly decide whether to autonegotiate after a session was replaced

This commit is contained in:
Brendan Taylor 2008-08-08 22:55:12 +00:00
parent f5059b4e26
commit ab70491d56
2 changed files with 10 additions and 10 deletions

View file

@ -1153,7 +1153,6 @@ class ChatControl(ChatControlBase):
self.print_esession_details() self.print_esession_details()
# Enable encryption if needed # Enable encryption if needed
self.no_autonegotiation = False
e2e_is_active = self.session and self.session.enable_encryption e2e_is_active = self.session and self.session.enable_encryption
self.gpg_is_active = False self.gpg_is_active = False
gpg_pref = gajim.config.get_per('contacts', contact.jid, gpg_pref = gajim.config.get_per('contacts', contact.jid,
@ -2325,18 +2324,22 @@ class ChatControl(ChatControlBase):
self.account, 'autonegotiate_esessions') and \ self.account, 'autonegotiate_esessions') and \
gajim.config.get_per('contacts', gajim.config.get_per('contacts',
self.contact.jid, 'autonegotiate_esessions') self.contact.jid, 'autonegotiate_esessions')
want_e2e = not e2e_is_active and not self.gpg_is_active \ want_e2e = not e2e_is_active and not self.gpg_is_active \
and e2e_pref and e2e_pref
already_negotiating = bool(self.session and \
self.session.status)
# XXX: Once we have fallback to disco, remove # XXX: Once we have fallback to disco, remove
# notexistant check # notexistant check
if want_e2e and not self.no_autonegotiation \ can_e2e = gajim.HAVE_PYCRYPTO and gajim.capscache. \
and gajim.HAVE_PYCRYPTO \ is_supported(self.contact, NS_ESESSION) and \
and gajim.capscache.is_supported(self.contact, not gajim.capscache.is_supported(self.contact,
NS_ESESSION) and not gajim.capscache.is_supported( 'notexistant')
self.contact, 'notexistant'):
if want_e2e and not already_negotiating and can_e2e:
self.begin_e2e_negotiation() self.begin_e2e_negotiation()
self.no_autonegotiation = True
else: else:
self.send_chatstate('active', self.contact) self.send_chatstate('active', self.contact)

View file

@ -816,9 +816,6 @@ class Interface:
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
ctrl = sess.control
if ctrl:
ctrl.no_autonegotiation = False
if sess.enable_encryption: if sess.enable_encryption:
sess.terminate_e2e() sess.terminate_e2e()
conn.delete_session(jid, conn.delete_session(jid,