merged realtime cancellation patch
This commit is contained in:
parent
88f017a20d
commit
b8882ba48e
|
@ -1464,6 +1464,9 @@ class ChatControl(ChatControlBase):
|
|||
self.mouse_over_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
|
||||
def print_esession_details(self):
|
||||
|
@ -2155,7 +2158,7 @@ class ChatControl(ChatControlBase):
|
|||
# this is reverse logic, as we are on 'activate' (before change happens)
|
||||
tb = self.xml.get_widget('gpg_togglebutton')
|
||||
tb.set_active(not tb.get_active())
|
||||
|
||||
|
||||
def _on_convert_to_gc_menuitem_activate(self, widget):
|
||||
'''user want to invite some friends to chat'''
|
||||
dialogs.TransformChatToMUC(self.account, [self.contact.jid])
|
||||
|
@ -2164,9 +2167,7 @@ class ChatControl(ChatControlBase):
|
|||
if self.session and self.session.enable_encryption:
|
||||
self.session.terminate_e2e()
|
||||
|
||||
msg = _('Encryption disabled')
|
||||
ChatControlBase.print_conversation_line(self, msg,
|
||||
'status', '', None)
|
||||
self.print_esession_details()
|
||||
|
||||
jid = str(self.session.jid)
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class StanzaSession(object):
|
|||
self.last_send = 0
|
||||
self.status = None
|
||||
self.negotiated = {}
|
||||
|
||||
|
||||
def generate_thread_id(self):
|
||||
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)
|
||||
self.conn.send_stanza(msg)
|
||||
|
||||
|
||||
if isinstance(msg, xmpp.Message):
|
||||
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.'''
|
||||
|
||||
if hasattr(self, 'control'):
|
||||
msg = _('Session negotiation cancelled')
|
||||
self.control.print_conversation_line(self, msg, 'status', '', None)
|
||||
self.control.on_cancel_session_negotiation()
|
||||
|
||||
self.status = None
|
||||
self.negotiated = {}
|
||||
|
@ -350,7 +349,7 @@ class EncryptedStanzaSession(StanzaSession):
|
|||
hash = crypto.sha256(mac_o_calculated)
|
||||
|
||||
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:
|
||||
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()
|
||||
|
||||
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 = ''
|
||||
|
|
25
src/gajim.py
25
src/gajim.py
|
@ -1902,8 +1902,6 @@ class Interface:
|
|||
jid, session, form = data
|
||||
|
||||
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()
|
||||
return
|
||||
|
||||
|
@ -2018,23 +2016,26 @@ class Interface:
|
|||
except exceptions.Cancelled:
|
||||
# user cancelled the negotiation
|
||||
|
||||
session.cancelled_negotiation()
|
||||
session.reject_negotiation()
|
||||
|
||||
return
|
||||
|
||||
if form.getField('terminate'):
|
||||
if form.getField('terminate').getValue() in ('1', 'true'):
|
||||
session.acknowledge_termination()
|
||||
if form.getField('terminate') and\
|
||||
form.getField('terminate').getValue() in ('1', 'true'):
|
||||
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:
|
||||
new_sess = gajim.connections[account].make_new_session(str(jid))
|
||||
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
|
||||
# to test my test suite.
|
||||
|
|
|
@ -19,7 +19,7 @@ def show_sas_dialog(session, jid, sas, on_success):
|
|||
on_success(checked)
|
||||
|
||||
def failure_cb():
|
||||
session.cancelled_negotiation()
|
||||
session.reject_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.
|
||||
|
|
Loading…
Reference in New Issue