corrected realtime notification of session cancellation

This commit is contained in:
Brendan Taylor 2007-12-08 08:51:10 +00:00
parent 88f017a20d
commit 015d3221e1
4 changed files with 29 additions and 22 deletions

View File

@ -1464,6 +1464,9 @@ class ChatControl(ChatControlBase):
self.mouse_over_in_last_30_secs = False self.mouse_over_in_last_30_secs = False
self.kbd_activity_in_last_30_secs = False self.kbd_activity_in_last_30_secs = False
def on_cancel_session_negotiation(self):
msg = _('Session negotiation cancelled')
ChatControlBase.print_conversation_line(self, msg, 'status', '', None)
# print esession settings to textview # print esession settings to textview
def print_esession_details(self): def print_esession_details(self):
@ -2155,7 +2158,7 @@ class ChatControl(ChatControlBase):
# this is reverse logic, as we are on 'activate' (before change happens) # this is reverse logic, as we are on 'activate' (before change happens)
tb = self.xml.get_widget('gpg_togglebutton') tb = self.xml.get_widget('gpg_togglebutton')
tb.set_active(not tb.get_active()) tb.set_active(not tb.get_active())
def _on_convert_to_gc_menuitem_activate(self, widget): def _on_convert_to_gc_menuitem_activate(self, widget):
'''user want to invite some friends to chat''' '''user want to invite some friends to chat'''
dialogs.TransformChatToMUC(self.account, [self.contact.jid]) dialogs.TransformChatToMUC(self.account, [self.contact.jid])
@ -2164,9 +2167,7 @@ class ChatControl(ChatControlBase):
if self.session and self.session.enable_encryption: if self.session and self.session.enable_encryption:
self.session.terminate_e2e() self.session.terminate_e2e()
msg = _('Encryption disabled') self.print_esession_details()
ChatControlBase.print_conversation_line(self, msg,
'status', '', None)
jid = str(self.session.jid) jid = str(self.session.jid)

View File

@ -36,7 +36,7 @@ class StanzaSession(object):
self.last_send = 0 self.last_send = 0
self.status = None self.status = None
self.negotiated = {} self.negotiated = {}
def generate_thread_id(self): def generate_thread_id(self):
return "".join([random.choice(string.ascii_letters) for x in xrange(0,32)]) return "".join([random.choice(string.ascii_letters) for x in xrange(0,32)])
@ -46,7 +46,7 @@ class StanzaSession(object):
msg.setAttr('to', self.jid) msg.setAttr('to', self.jid)
self.conn.send_stanza(msg) self.conn.send_stanza(msg)
if isinstance(msg, xmpp.Message): if isinstance(msg, xmpp.Message):
self.last_send = time.time() self.last_send = time.time()
@ -72,8 +72,7 @@ class StanzaSession(object):
'''A negotiation has been cancelled, so reset this session to its default state.''' '''A negotiation has been cancelled, so reset this session to its default state.'''
if hasattr(self, 'control'): if hasattr(self, 'control'):
msg = _('Session negotiation cancelled') self.control.on_cancel_session_negotiation()
self.control.print_conversation_line(self, msg, 'status', '', None)
self.status = None self.status = None
self.negotiated = {} self.negotiated = {}
@ -350,7 +349,7 @@ class EncryptedStanzaSession(StanzaSession):
hash = crypto.sha256(mac_o_calculated) hash = crypto.sha256(mac_o_calculated)
if not eir_pubkey.verify(hash, signature): if not eir_pubkey.verify(hash, signature):
raise exceptions.NegotiationError, 'public key signature verification failed!' raise exceptions.NegotiationError, 'public key signature verification failed!'
elif mac_o_calculated != mac_o: elif mac_o_calculated != mac_o:
raise exceptions.NegotiationError, 'calculated mac_%s differs from received mac_%s' % (i_o, i_o) raise exceptions.NegotiationError, 'calculated mac_%s differs from received mac_%s' % (i_o, i_o)
@ -903,3 +902,9 @@ otherwise, list the fields we haven't implemented'''
no_log_for = no_log_for.split() no_log_for = no_log_for.split()
return self.loggable and account not in no_log_for and self.jid not in no_log_for return self.loggable and account not in no_log_for and self.jid not in no_log_for
def cancelled_negotiation(self):
StanzaSession.cancelled_negotiation(self)
self.enable_encryption = False
self.km_o = ''

View File

@ -1902,8 +1902,6 @@ class Interface:
jid, session, form = data jid, session, form = data
if form.getField('accept') and not form['accept'] in ('1', 'true'): if form.getField('accept') and not form['accept'] in ('1', 'true'):
dialogs.InformationDialog(_('Session negotiation cancelled'),
_('The client at %s cancelled the session negotiation.') % (jid))
session.cancelled_negotiation() session.cancelled_negotiation()
return return
@ -2018,23 +2016,26 @@ class Interface:
except exceptions.Cancelled: except exceptions.Cancelled:
# user cancelled the negotiation # user cancelled the negotiation
session.cancelled_negotiation() session.reject_negotiation()
return return
if form.getField('terminate'): if form.getField('terminate') and\
if form.getField('terminate').getValue() in ('1', 'true'): form.getField('terminate').getValue() in ('1', 'true'):
session.acknowledge_termination() was_encrypted = session.enable_encryption
ctrl = session.control
gajim.connections[account].delete_session(str(jid), session.thread_id) session.acknowledge_termination()
gajim.connections[account].delete_session(str(jid), session.thread_id)
ctrl = gajim.interface.msg_win_mgr.get_control(str(jid), account) if ctrl:
new_sess = gajim.connections[account].make_new_session(str(jid))
ctrl.set_session(new_sess)
if ctrl: if was_encrypted:
new_sess = gajim.connections[account].make_new_session(str(jid)) ctrl.print_esession_details()
ctrl.set_session(new_sess)
return return
# non-esession negotiation. this isn't very useful, but i'm keeping it around # non-esession negotiation. this isn't very useful, but i'm keeping it around
# to test my test suite. # to test my test suite.

View File

@ -19,7 +19,7 @@ def show_sas_dialog(session, jid, sas, on_success):
on_success(checked) on_success(checked)
def failure_cb(): def failure_cb():
session.cancelled_negotiation() session.reject_negotiation()
dialogs.ConfirmationDialogCheck(_('''OK to continue with negotiation?'''), dialogs.ConfirmationDialogCheck(_('''OK to continue with negotiation?'''),
_('''You've begun an encrypted session with %s, but it can't be guaranteed that you're talking directly to the person you think you are. _('''You've begun an encrypted session with %s, but it can't be guaranteed that you're talking directly to the person you think you are.