change the insecure connection dialog behaviour. Fixes #7019

This commit is contained in:
Yann Leboulanger 2011-10-31 09:47:01 +01:00
parent 493187d448
commit 520bc6b268
4 changed files with 24 additions and 8 deletions

View File

@ -323,7 +323,7 @@ class Config:
'enable_esessions': [opt_bool, True, _('Enable ESessions encryption for this account.')],
'autonegotiate_esessions': [opt_bool, True, _('Should Gajim automatically start an encrypted session when possible?')],
'connection_types': [ opt_str, 'tls ssl plain', _('Ordered list (space separated) of connection type to try. Can contain tls, ssl or plain')],
'warn_when_plaintext_connection': [ opt_bool, True, _('Show a warning dialog before sending password on an plaintext connection.') ],
'action_when_plaintext_connection': [ opt_str, 'warn', _('Show a warning dialog before sending password on an plaintext connection. Can be \'warn\', \'connect\', \'disconnect\'') ],
'warn_when_insecure_ssl_connection': [ opt_bool, True, _('Show a warning dialog before using standard SSL library.') ],
'warn_when_insecure_password': [ opt_bool, True, _('Show a warning dialog before sending PLAIN password over a plain connection.') ],
'ssl_fingerprint_sha1': [ opt_str, '', '', True ],

View File

@ -1254,10 +1254,16 @@ class Connection(CommonConnection, ConnectionHandlers):
return
con.RegisterDisconnectHandler(self._on_disconnected)
if _con_type == 'plain' and gajim.config.get_per('accounts', self.name,
'warn_when_plaintext_connection'):
'action_when_plaintext_connection') == 'warn':
gajim.nec.push_incoming_event(PlainConnectionEvent(None, conn=self,
xmpp_client=con))
return True
if _con_type == 'plain' and gajim.config.get_per('accounts', self.name,
'action_when_plaintext_connection') == 'disconnect':
self.disconnect(on_purpose=True)
gajim.nec.push_incoming_event(OurShowEvent(None, conn=self,
show='offline'))
return False
if _con_type in ('tls', 'ssl') and con.Connection.ssl_lib != 'PYOPENSSL' \
and gajim.config.get_per('accounts', self.name,
'warn_when_insecure_ssl_connection') and \

View File

@ -1722,7 +1722,8 @@ class ConfirmationDialogDoubleCheck(ConfirmationDialog):
"""
def __init__(self, pritext, sectext='', checktext1='', checktext2='',
on_response_ok=None, on_response_cancel=None, is_modal=True):
tooltip1='', tooltip2='', on_response_ok=None, on_response_cancel=None,
is_modal=True):
self.user_response_ok = on_response_ok
self.user_response_cancel = on_response_cancel
@ -1741,11 +1742,15 @@ class ConfirmationDialogDoubleCheck(ConfirmationDialog):
if checktext1:
self.checkbutton1 = gtk.CheckButton(checktext1)
if tooltip1:
self.checkbutton1.set_tooltip_text(tooltip1)
self.vbox.pack_start(self.checkbutton1, expand=False, fill=True)
else:
self.checkbutton1 = None
if checktext2:
self.checkbutton2 = gtk.CheckButton(checktext2)
if tooltip2:
self.checkbutton2.set_tooltip_text(tooltip2)
self.vbox.pack_start(self.checkbutton2, expand=False, fill=True)
else:
self.checkbutton2 = None

View File

@ -1249,6 +1249,9 @@ class Interface:
# ('PLAIN_CONNECTION', account, (connection))
def on_ok(is_checked):
if not is_checked[0]:
if is_checked[1]:
gajim.config.set_per('accounts', obj.conn.name,
'action_when_plaintext_connection', 'disconnect')
on_cancel()
return
# On cancel call del self.instances, so don't call it another time
@ -1257,7 +1260,7 @@ class Interface:
['plain_connection']
if is_checked[1]:
gajim.config.set_per('accounts', obj.conn.name,
'warn_when_plaintext_connection', False)
'action_when_plaintext_connection', 'connect')
obj.conn.connection_accepted(obj.xmpp_client, 'plain')
def on_cancel():
@ -1270,18 +1273,20 @@ class Interface:
pritext = _('Insecure connection')
sectext = _('You are about to connect to the account %(account)s '
'(%(server)s) with an insecure connection. This means all your '
'conversations will be exchanged unencrypted. Are you sure you '
'want to do that?') % {'account': obj.conn.name,
'conversations will be exchanged unencrypted. This type of '
'connection is really discouraged.\nAre you sure you want to do '
'that?') % {'account': obj.conn.name,
'server': gajim.get_hostname_from_account(obj.conn.name)}
checktext1 = _('Yes, I really want to connect insecurely')
tooltip1 = _('Gajim will NOT connect unless you check this box')
checktext2 = _('_Do not ask me again')
if 'plain_connection' in self.instances[obj.conn.name]['online_dialog']:
self.instances[obj.conn.name]['online_dialog']['plain_connection'].\
destroy()
self.instances[obj.conn.name]['online_dialog']['plain_connection'] = \
dialogs.ConfirmationDialogDoubleCheck(pritext, sectext, checktext1,
checktext2, on_response_ok=on_ok, on_response_cancel=on_cancel,
is_modal=False)
checktext2, tooltip1=tooltip1, on_response_ok=on_ok,
on_response_cancel=on_cancel, is_modal=False)
def handle_event_insecure_ssl_connection(self, obj):
# ('INSECURE_SSL_CONNECTION', account, (connection, connection_type))