don't allow to have several ssl_error / fingerprint_error / plain_connection / insecure_ssl dialog at the same time for one account. Fixes #4642
This commit is contained in:
parent
54283f7779
commit
3813f20888
2 changed files with 37 additions and 8 deletions
|
@ -1810,7 +1810,8 @@ class AccountsWindow:
|
||||||
# change account variable for chat / gc controls
|
# change account variable for chat / gc controls
|
||||||
gajim.interface.msg_win_mgr.change_account_name(old_name, new_name)
|
gajim.interface.msg_win_mgr.change_account_name(old_name, new_name)
|
||||||
# upgrade account variable in opened windows
|
# upgrade account variable in opened windows
|
||||||
for kind in ('infos', 'disco', 'gc_config', 'search'):
|
for kind in ('infos', 'disco', 'gc_config', 'search',
|
||||||
|
'online_dialog'):
|
||||||
for j in gajim.interface.instances[new_name][kind]:
|
for j in gajim.interface.instances[new_name][kind]:
|
||||||
gajim.interface.instances[new_name][kind][j].account = \
|
gajim.interface.instances[new_name][kind][j].account = \
|
||||||
new_name
|
new_name
|
||||||
|
@ -2227,7 +2228,7 @@ class AccountsWindow:
|
||||||
self.init_account_gpg()
|
self.init_account_gpg()
|
||||||
# update variables
|
# update variables
|
||||||
gajim.interface.instances[gajim.ZEROCONF_ACC_NAME] = {'infos': {},
|
gajim.interface.instances[gajim.ZEROCONF_ACC_NAME] = {'infos': {},
|
||||||
'disco': {}, 'gc_config': {}, 'search': {}}
|
'disco': {}, 'gc_config': {}, 'search': {}, 'online_dialog': {}}
|
||||||
gajim.interface.minimized_controls[gajim.ZEROCONF_ACC_NAME] = {}
|
gajim.interface.minimized_controls[gajim.ZEROCONF_ACC_NAME] = {}
|
||||||
gajim.connections[gajim.ZEROCONF_ACC_NAME].connected = 0
|
gajim.connections[gajim.ZEROCONF_ACC_NAME].connected = 0
|
||||||
gajim.groups[gajim.ZEROCONF_ACC_NAME] = {}
|
gajim.groups[gajim.ZEROCONF_ACC_NAME] = {}
|
||||||
|
@ -3490,7 +3491,7 @@ class AccountCreationWizardWindow:
|
||||||
|
|
||||||
# update variables
|
# update variables
|
||||||
gajim.interface.instances[self.account] = {'infos': {}, 'disco': {},
|
gajim.interface.instances[self.account] = {'infos': {}, 'disco': {},
|
||||||
'gc_config': {}, 'search': {}}
|
'gc_config': {}, 'search': {}, 'online_dialog': {}}
|
||||||
gajim.interface.minimized_controls[self.account] = {}
|
gajim.interface.minimized_controls[self.account] = {}
|
||||||
gajim.connections[self.account].connected = 0
|
gajim.connections[self.account].connected = 0
|
||||||
gajim.connections[self.account].keepalives = gajim.config.get_per(
|
gajim.connections[self.account].keepalives = gajim.config.get_per(
|
||||||
|
|
38
src/gajim.py
38
src/gajim.py
|
@ -598,6 +598,12 @@ class Interface:
|
||||||
def handle_event_status(self, account, status): # OUR status
|
def handle_event_status(self, account, status): # OUR status
|
||||||
#('STATUS', account, status)
|
#('STATUS', account, status)
|
||||||
model = self.roster.status_combobox.get_model()
|
model = self.roster.status_combobox.get_model()
|
||||||
|
if status in ('offline', 'error'):
|
||||||
|
for name in self.instances[account]['online_dialog'].keys():
|
||||||
|
# .keys() is needed to not have a dictionary length changed during
|
||||||
|
# iteration error
|
||||||
|
self.instances[account]['online_dialog'][name].destroy()
|
||||||
|
del self.instances[account]['online_dialog'][name]
|
||||||
if status == 'offline':
|
if status == 'offline':
|
||||||
# sensitivity for this menuitem
|
# sensitivity for this menuitem
|
||||||
if gajim.get_number_of_connected_accounts() == 0:
|
if gajim.get_number_of_connected_accounts() == 0:
|
||||||
|
@ -1957,6 +1963,7 @@ class Interface:
|
||||||
server = gajim.config.get_per('accounts', account, 'hostname')
|
server = gajim.config.get_per('accounts', account, 'hostname')
|
||||||
|
|
||||||
def on_ok(is_checked):
|
def on_ok(is_checked):
|
||||||
|
del self.instances[account]['online_dialog']['ssl_error']
|
||||||
if is_checked[0]:
|
if is_checked[0]:
|
||||||
# Check if cert is already in file
|
# Check if cert is already in file
|
||||||
certs = ''
|
certs = ''
|
||||||
|
@ -1983,6 +1990,7 @@ class Interface:
|
||||||
gajim.connections[account].ssl_certificate_accepted()
|
gajim.connections[account].ssl_certificate_accepted()
|
||||||
|
|
||||||
def on_cancel():
|
def on_cancel():
|
||||||
|
del self.instances[account]['online_dialog']['ssl_error']
|
||||||
gajim.connections[account].disconnect(on_purpose=True)
|
gajim.connections[account].disconnect(on_purpose=True)
|
||||||
self.handle_event_status(account, 'offline')
|
self.handle_event_status(account, 'offline')
|
||||||
|
|
||||||
|
@ -1993,18 +2001,23 @@ class Interface:
|
||||||
else:
|
else:
|
||||||
checktext1 = ''
|
checktext1 = ''
|
||||||
checktext2 = _('Ignore this error for this certificate.')
|
checktext2 = _('Ignore this error for this certificate.')
|
||||||
dialogs.ConfirmationDialogDubbleCheck(pritext, sectext, checktext1,
|
if 'ssl_error' in self.instances[account]['online_dialog']:
|
||||||
|
self.instances[account]['online_dialog']['ssl_error'].destroy()
|
||||||
|
self.instances[account]['online_dialog']['ssl_error'] = \
|
||||||
|
dialogs.ConfirmationDialogDubbleCheck(pritext, sectext, checktext1,
|
||||||
checktext2, on_response_ok=on_ok, on_response_cancel=on_cancel)
|
checktext2, on_response_ok=on_ok, on_response_cancel=on_cancel)
|
||||||
|
|
||||||
def handle_event_fingerprint_error(self, account, data):
|
def handle_event_fingerprint_error(self, account, data):
|
||||||
# ('FINGERPRINT_ERROR', account, (new_fingerprint,))
|
# ('FINGERPRINT_ERROR', account, (new_fingerprint,))
|
||||||
def on_yes(is_checked):
|
def on_yes(is_checked):
|
||||||
|
del self.instances[account]['online_dialog']['fingerprint_error']
|
||||||
gajim.config.set_per('accounts', account, 'ssl_fingerprint_sha1',
|
gajim.config.set_per('accounts', account, 'ssl_fingerprint_sha1',
|
||||||
data[0])
|
data[0])
|
||||||
# Reset the ignored ssl errors
|
# Reset the ignored ssl errors
|
||||||
gajim.config.set_per('accounts', account, 'ignore_ssl_errors', '')
|
gajim.config.set_per('accounts', account, 'ignore_ssl_errors', '')
|
||||||
gajim.connections[account].ssl_certificate_accepted()
|
gajim.connections[account].ssl_certificate_accepted()
|
||||||
def on_no():
|
def on_no():
|
||||||
|
del self.instances[account]['online_dialog']['fingerprint_error']
|
||||||
gajim.connections[account].disconnect(on_purpose=True)
|
gajim.connections[account].disconnect(on_purpose=True)
|
||||||
self.handle_event_status(account, 'offline')
|
self.handle_event_status(account, 'offline')
|
||||||
pritext = _('SSL certificate error')
|
pritext = _('SSL certificate error')
|
||||||
|
@ -2013,13 +2026,17 @@ class Interface:
|
||||||
'\n\nDo you still want to connect and update the fingerprint of the '
|
'\n\nDo you still want to connect and update the fingerprint of the '
|
||||||
'certificate?') % {'old': gajim.config.get_per('accounts', account,
|
'certificate?') % {'old': gajim.config.get_per('accounts', account,
|
||||||
'ssl_fingerprint_sha1'), 'new': data[0]}
|
'ssl_fingerprint_sha1'), 'new': data[0]}
|
||||||
dialog = dialogs.YesNoDialog(pritext, sectext, on_response_yes=on_yes,
|
if 'fingerprint_error' in self.instances[account]['online_dialog']:
|
||||||
|
self.instances[account]['online_dialog']['fingerprint_error'].destroy()
|
||||||
|
self.instances[account]['online_dialog']['fingerprint_error'] = \
|
||||||
|
dialogs.YesNoDialog(pritext, sectext, on_response_yes=on_yes,
|
||||||
on_response_no=on_no)
|
on_response_no=on_no)
|
||||||
|
|
||||||
def handle_event_plain_connection(self, account, data):
|
def handle_event_plain_connection(self, account, data):
|
||||||
# ('PLAIN_CONNECTION', account, (connection))
|
# ('PLAIN_CONNECTION', account, (connection))
|
||||||
server = gajim.config.get_per('accounts', account, 'hostname')
|
server = gajim.config.get_per('accounts', account, 'hostname')
|
||||||
def on_ok(is_checked):
|
def on_ok(is_checked):
|
||||||
|
del self.instances[account]['online_dialog']['plain_connection']
|
||||||
if not is_checked[0]:
|
if not is_checked[0]:
|
||||||
on_cancel()
|
on_cancel()
|
||||||
return
|
return
|
||||||
|
@ -2028,6 +2045,7 @@ class Interface:
|
||||||
'warn_when_plaintext_connection', False)
|
'warn_when_plaintext_connection', False)
|
||||||
gajim.connections[account].connection_accepted(data[0], 'tcp')
|
gajim.connections[account].connection_accepted(data[0], 'tcp')
|
||||||
def on_cancel():
|
def on_cancel():
|
||||||
|
del self.instances[account]['online_dialog']['plain_connection']
|
||||||
gajim.connections[account].disconnect(on_purpose=True)
|
gajim.connections[account].disconnect(on_purpose=True)
|
||||||
self.handle_event_status(account, 'offline')
|
self.handle_event_status(account, 'offline')
|
||||||
pritext = _('Insecure connection')
|
pritext = _('Insecure connection')
|
||||||
|
@ -2035,7 +2053,10 @@ class Interface:
|
||||||
'connection. Are you sure you want to do that?')
|
'connection. Are you sure you want to do that?')
|
||||||
checktext1 = _('Yes, I really want to connect insecurely')
|
checktext1 = _('Yes, I really want to connect insecurely')
|
||||||
checktext2 = _('Do _not ask me again')
|
checktext2 = _('Do _not ask me again')
|
||||||
dialog = dialogs.ConfirmationDialogDubbleCheck(pritext, sectext,
|
if 'plain_connection' in self.instances[account]['online_dialog']:
|
||||||
|
self.instances[account]['online_dialog']['plain_connection'].destroy()
|
||||||
|
self.instances[account]['online_dialog']['plain_connection'] = \
|
||||||
|
dialogs.ConfirmationDialogDubbleCheck(pritext, sectext,
|
||||||
checktext1, checktext2, on_response_ok=on_ok,
|
checktext1, checktext2, on_response_ok=on_ok,
|
||||||
on_response_cancel=on_cancel, is_modal=False)
|
on_response_cancel=on_cancel, is_modal=False)
|
||||||
|
|
||||||
|
@ -2043,6 +2064,7 @@ class Interface:
|
||||||
# ('INSECURE_SSL_CONNECTION', account, (connection, connection_type))
|
# ('INSECURE_SSL_CONNECTION', account, (connection, connection_type))
|
||||||
server = gajim.config.get_per('accounts', account, 'hostname')
|
server = gajim.config.get_per('accounts', account, 'hostname')
|
||||||
def on_ok(is_checked):
|
def on_ok(is_checked):
|
||||||
|
del self.instances[account]['online_dialog']['insecure_ssl']
|
||||||
if not is_checked[0]:
|
if not is_checked[0]:
|
||||||
on_cancel()
|
on_cancel()
|
||||||
return
|
return
|
||||||
|
@ -2058,6 +2080,7 @@ class Interface:
|
||||||
return
|
return
|
||||||
gajim.connections[account].connection_accepted(data[0], data[1])
|
gajim.connections[account].connection_accepted(data[0], data[1])
|
||||||
def on_cancel():
|
def on_cancel():
|
||||||
|
del self.instances[account]['online_dialog']['insecure_ssl']
|
||||||
gajim.connections[account].disconnect(on_purpose=True)
|
gajim.connections[account].disconnect(on_purpose=True)
|
||||||
self.handle_event_status(account, 'offline')
|
self.handle_event_status(account, 'offline')
|
||||||
pritext = _('Insecure connection')
|
pritext = _('Insecure connection')
|
||||||
|
@ -2065,7 +2088,10 @@ class Interface:
|
||||||
'connection. You should install PyOpenSSL to prevent that. Are you sure you want to do that?')
|
'connection. You should install PyOpenSSL to prevent that. Are you sure you want to do that?')
|
||||||
checktext1 = _('Yes, I really want to connect insecurely')
|
checktext1 = _('Yes, I really want to connect insecurely')
|
||||||
checktext2 = _('Do _not ask me again')
|
checktext2 = _('Do _not ask me again')
|
||||||
dialog = dialogs.ConfirmationDialogDubbleCheck(pritext, sectext,
|
if 'insecure_ssl' in self.instances[account]['online_dialog']:
|
||||||
|
self.instances[account]['online_dialog']['insecure_ssl'].destroy()
|
||||||
|
self.instances[account]['online_dialog']['insecure_ssl'] = \
|
||||||
|
dialogs.ConfirmationDialogDubbleCheck(pritext, sectext,
|
||||||
checktext1, checktext2, on_response_ok=on_ok,
|
checktext1, checktext2, on_response_ok=on_ok,
|
||||||
on_response_cancel=on_cancel, is_modal=False)
|
on_response_cancel=on_cancel, is_modal=False)
|
||||||
|
|
||||||
|
@ -3137,7 +3163,9 @@ class Interface:
|
||||||
|
|
||||||
for a in gajim.connections:
|
for a in gajim.connections:
|
||||||
self.instances[a] = {'infos': {}, 'disco': {}, 'gc_config': {},
|
self.instances[a] = {'infos': {}, 'disco': {}, 'gc_config': {},
|
||||||
'search': {}}
|
'search': {}, 'online_dialog': {}}
|
||||||
|
# online_dialog contains all dialogs that have a meaning only when we
|
||||||
|
# are not disconnected
|
||||||
self.minimized_controls[a] = {}
|
self.minimized_controls[a] = {}
|
||||||
gajim.contacts.add_account(a)
|
gajim.contacts.add_account(a)
|
||||||
gajim.groups[a] = {}
|
gajim.groups[a] = {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue