summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui/mainwindow.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-08-14 15:42:41 -0300
committerTomás Touceda <chiiph@leap.se>2014-08-14 15:42:41 -0300
commita104bbfccdeffe48323703ce7a307d4eed17ac6e (patch)
tree47d24ae16a7a9adcd27d597e4ae9db820cd25ce2 /src/leap/bitmask/gui/mainwindow.py
parent96f9849eb62f0240d9c49be55b0fafb366553c10 (diff)
parent9a7df988191e2cdeb2e01fb30da55a0c5f4651f9 (diff)
Merge remote-tracking branch 'refs/remotes/elijah/feature/provider-on-top' into develop
Diffstat (limited to 'src/leap/bitmask/gui/mainwindow.py')
-rw-r--r--src/leap/bitmask/gui/mainwindow.py76
1 files changed, 35 insertions, 41 deletions
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py
index 03f91996..8ce7f2fc 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -45,6 +45,7 @@ from leap.bitmask.gui.mail_status import MailStatusWidget
from leap.bitmask.gui.preferenceswindow import PreferencesWindow
from leap.bitmask.gui.systray import SysTray
from leap.bitmask.gui.wizard import Wizard
+from leap.bitmask.gui.providers import Providers
from leap.bitmask.platform_init import IS_WIN, IS_MAC, IS_LINUX
from leap.bitmask.platform_init.initializers import init_platform
@@ -148,13 +149,17 @@ class MainWindow(QtGui.QMainWindow):
self._mail_status = MailStatusWidget(self)
self.ui.mailLayout.addWidget(self._mail_status)
+ # Provider List
+ self._providers = Providers(self.ui.cmbProviders)
+
# Qt Signal Connections #####################################
# TODO separate logic from ui signals.
self._login_widget.login.connect(self._login)
self._login_widget.cancel_login.connect(self._cancel_login)
self._login_widget.logout.connect(self._logout)
- self._login_widget.provider_changed.connect(self._on_provider_changed)
+
+ self._providers.connect_provider_changed(self._on_provider_changed)
# EIP Control redux #########################################
self._eip_conductor = eip_conductor.EIPConductor(
@@ -577,7 +582,7 @@ class MainWindow(QtGui.QMainWindow):
Display the Advanced Key Management dialog.
"""
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
logged_user = "{0}@{1}".format(self._logged_user, domain)
details = self._provider_details
@@ -600,7 +605,7 @@ class MainWindow(QtGui.QMainWindow):
Display the preferences window.
"""
user = self._logged_user
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
mx_provided = False
if self._provider_details is not None:
mx_provided = MX_SERVICE in self._provider_details['services']
@@ -717,7 +722,7 @@ class MainWindow(QtGui.QMainWindow):
Display the EIP preferences window.
"""
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
pref = EIPPreferencesWindow(self, domain,
self._backend, self._leap_signaler)
pref.show()
@@ -794,7 +799,7 @@ class MainWindow(QtGui.QMainWindow):
# XXX: May be this can be divided into two methods?
providers = self._settings.get_configured_providers()
- self._login_widget.set_providers(providers)
+ self._providers.set_providers(providers)
self._show_systray()
if not self._start_hidden:
@@ -810,12 +815,12 @@ class MainWindow(QtGui.QMainWindow):
# select the configured provider in the combo box
domain = self._wizard.get_domain()
- self._login_widget.select_provider_by_name(domain)
+ self._providers.select_provider_by_name(domain)
self._login_widget.set_remember(self._wizard.get_remember())
self._enabled_services = list(self._wizard.get_services())
self._settings.set_enabled_services(
- self._login_widget.get_selected_provider(),
+ self._providers.get_selected_provider(),
self._enabled_services)
if possible_username is not None:
self._login_widget.set_user(possible_username)
@@ -832,7 +837,7 @@ class MainWindow(QtGui.QMainWindow):
domain = self._settings.get_provider()
if domain is not None:
- self._login_widget.select_provider_by_name(domain)
+ self._providers.select_provider_by_name(domain)
if not self._settings.get_remember():
# nothing to do here
@@ -895,11 +900,7 @@ class MainWindow(QtGui.QMainWindow):
"""
Set the login label to reflect offline status.
"""
- provider = ""
- if not self._logged_in_offline:
- provider = self.ui.lblLoginProvider.text()
-
- self.ui.lblLoginProvider.setText(provider + self.tr(" (offline mode)"))
+ # TODO: figure out what widget to use for this. Maybe the window title?
#
# systray
@@ -1159,7 +1160,7 @@ class MainWindow(QtGui.QMainWindow):
emit the corresponding signals inmediately
"""
self._disconnect_scheduled_login()
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
self._backend.provider_setup(provider=domain)
@QtCore.Slot(dict)
@@ -1176,7 +1177,7 @@ class MainWindow(QtGui.QMainWindow):
:type data: dict
"""
if data[PASSED_KEY]:
- selected_provider = self._login_widget.get_selected_provider()
+ selected_provider = self._providers.get_selected_provider()
self._backend.provider_bootstrap(provider=selected_provider)
else:
logger.error(data[ERROR_KEY])
@@ -1230,7 +1231,7 @@ class MainWindow(QtGui.QMainWindow):
def _on_provider_changed(self, wizard=True):
"""
TRIGGERS:
- self._login.provider_changed
+ self._providers._provider_changed
self.ui.action_create_new_account.triggered
Ask the user if really wants to change provider since a services stop
@@ -1250,12 +1251,9 @@ class MainWindow(QtGui.QMainWindow):
return
title = self.tr("Stop services")
- text = self.tr("<b>Do you want to stop all services?</b>")
+ text = "<b>" + self.tr("Do you want to stop all services?") + "</b>"
informative_text = self.tr("In order to change the provider, the "
"running services needs to be stopped.")
- if wizard:
- informative_text = self.tr("In order to start the wizard, the "
- "running services needs to be stopped.")
msg = QtGui.QMessageBox(self)
msg.setWindowTitle(title)
@@ -1274,7 +1272,7 @@ class MainWindow(QtGui.QMainWindow):
else:
if not wizard:
# if wizard, the widget restores itself
- self._login_widget.restore_previous_provider()
+ self._providers.restore_previous_provider()
@QtCore.Slot()
def _login(self):
@@ -1288,19 +1286,18 @@ class MainWindow(QtGui.QMainWindow):
bootstrapping the EIP service
"""
# TODO most of this could ve handled by the login widget,
- # but we'd have to move lblLoginProvider into the widget itself,
- # instead of having it as a top-level attribute.
+ provider = self._providers.get_selected_provider()
if flags.OFFLINE is True:
logger.debug("OFFLINE mode! bypassing remote login")
# TODO reminder, we're not handling logout for offline
# mode.
- self._login_widget.logged_in()
+ self._login_widget.logged_in(provider)
self._logged_in_offline = True
self._set_label_offline()
self.offline_mode_bypass_login.emit()
else:
self.ui.action_create_new_account.setEnabled(False)
- if self._login_widget.start_login():
+ if self._login_widget.start_login(provider):
if self._trying_to_start_eip:
self._schedule_login()
else:
@@ -1380,7 +1377,7 @@ class MainWindow(QtGui.QMainWindow):
self._show_hide_unsupported_services()
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
self._backend.user_login(provider=domain,
username=username, password=password)
else:
@@ -1400,7 +1397,7 @@ class MainWindow(QtGui.QMainWindow):
self._logged_user = self._login_widget.get_user()
user = self._logged_user
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
full_user_id = make_address(user, domain)
self._mail_conductor.userid = full_user_id
self._start_eip_bootstrap()
@@ -1423,9 +1420,8 @@ class MainWindow(QtGui.QMainWindow):
triggers the eip bootstrapping.
"""
- self._login_widget.logged_in()
- domain = self._login_widget.get_selected_provider()
- self.ui.lblLoginProvider.setText(domain)
+ domain = self._providers.get_selected_provider()
+ self._login_widget.logged_in(domain)
self._enabled_services = self._settings.get_enabled_services(domain)
@@ -1447,7 +1443,7 @@ class MainWindow(QtGui.QMainWindow):
and enabled.
This is triggered right after the provider has been set up.
"""
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
lang = QtCore.QLocale.system().name()
self._backend.provider_get_details(domain=domain, lang=lang)
@@ -1468,7 +1464,7 @@ class MainWindow(QtGui.QMainWindow):
:returns: True if provides and is enabled, False otherwise
:rtype: bool
"""
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
enabled_services = self._settings.get_enabled_services(domain)
mx_enabled = MX_SERVICE in enabled_services
@@ -1485,7 +1481,7 @@ class MainWindow(QtGui.QMainWindow):
:returns: True if provides and is enabled, False otherwise
:rtype: bool
"""
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
enabled_services = self._settings.get_enabled_services(domain)
eip_enabled = EIP_SERVICE in enabled_services
@@ -1506,7 +1502,7 @@ class MainWindow(QtGui.QMainWindow):
username = self._login_widget.get_user()
password = unicode(self._login_widget.get_password())
- provider_domain = self._login_widget.get_selected_provider()
+ provider_domain = self._providers.get_selected_provider()
if flags.OFFLINE:
full_user_id = make_address(username, provider_domain)
@@ -1522,7 +1518,7 @@ class MainWindow(QtGui.QMainWindow):
password=password, uuid=uuid)
else:
if self._logged_user is not None:
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
self._backend.soledad_bootstrap(username=username,
domain=domain,
password=password)
@@ -1606,7 +1602,7 @@ class MainWindow(QtGui.QMainWindow):
"""
self._already_started_eip = True
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
self._settings.set_defaultprovider(domain)
self._backend.eip_get_gateway_country_code(domain=domain)
@@ -1633,7 +1629,7 @@ class MainWindow(QtGui.QMainWindow):
Set the current provider and country code in the eip status widget.
"""
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
self._eip_status.set_provider(domain, country_code)
@QtCore.Slot()
@@ -1641,7 +1637,7 @@ class MainWindow(QtGui.QMainWindow):
"""
Trigger this if we don't have a working DNS resolver.
"""
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
msg = self.tr(
"The server at {0} can't be found, because the DNS lookup "
"failed. DNS is the network service that translates a "
@@ -1705,7 +1701,7 @@ class MainWindow(QtGui.QMainWindow):
self._eip_status.eip_button.hide()
self._eip_status.eip_button.setEnabled(False)
- domain = self._login_widget.get_selected_provider()
+ domain = self._providers.get_selected_provider()
self._backend.eip_setup(provider=domain)
self._already_started_eip = True
@@ -1796,7 +1792,6 @@ class MainWindow(QtGui.QMainWindow):
Inform the user about a logout error.
"""
self._login_widget.done_logout()
- self.ui.lblLoginProvider.setText(self.tr("Login"))
self._login_widget.set_status(
self.tr("Something went wrong with the logout."))
@@ -1810,7 +1805,6 @@ class MainWindow(QtGui.QMainWindow):
logging out
"""
self._login_widget.done_logout()
- self.ui.lblLoginProvider.setText(self.tr("Login"))
self._logged_user = None
self._login_widget.logged_out()