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):
@ -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

@ -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 = {}
@ -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,22 +2016,25 @@ 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'):
was_encrypted = session.enable_encryption
ctrl = session.control
session.acknowledge_termination() session.acknowledge_termination()
gajim.connections[account].delete_session(str(jid), session.thread_id) gajim.connections[account].delete_session(str(jid), session.thread_id)
ctrl = gajim.interface.msg_win_mgr.get_control(str(jid), account)
if ctrl: if ctrl:
new_sess = gajim.connections[account].make_new_session(str(jid)) new_sess = gajim.connections[account].make_new_session(str(jid))
ctrl.set_session(new_sess) ctrl.set_session(new_sess)
if was_encrypted:
ctrl.print_esession_details()
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

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.