summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui/mainwindow.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-04-17 12:14:39 -0300
committerTomás Touceda <chiiph@leap.se>2014-04-17 12:14:39 -0300
commiteb940b04bd2921974b094150a763ad8b9bbae8ca (patch)
tree2b867e3acaf8a86d431f2aeae9cf3dd57abf8e01 /src/leap/bitmask/gui/mainwindow.py
parentdcfaeea8c892ecb962080a1fbdc456bdfe851eea (diff)
parent1603228feac95c32b62661c15c6edd4c95978827 (diff)
Merge remote-tracking branch 'refs/remotes/ivan/feature/5506_use-pyside-slot-decorator' into develop
Diffstat (limited to 'src/leap/bitmask/gui/mainwindow.py')
-rw-r--r--src/leap/bitmask/gui/mainwindow.py164
1 files changed, 88 insertions, 76 deletions
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py
index e5c11eb7..b911e5d8 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -457,10 +457,11 @@ class MainWindow(QtGui.QMainWindow):
self._backend_connected_signals = {}
+ @QtCore.Slot()
def _rejected_wizard(self):
"""
- SLOT
- TRIGGERS: self._wizard.rejected
+ TRIGGERS:
+ self._wizard.rejected
Called if the wizard has been cancelled or closed before
finishing.
@@ -481,12 +482,12 @@ class MainWindow(QtGui.QMainWindow):
if self._wizard_firstrun:
self._finish_init()
+ @QtCore.Slot()
def _launch_wizard(self):
"""
- SLOT
TRIGGERS:
- self._login_widget.show_wizard
- self.ui.action_wizard.triggered
+ self._login_widget.show_wizard
+ self.ui.action_wizard.triggered
Also called in first run.
@@ -509,11 +510,11 @@ class MainWindow(QtGui.QMainWindow):
self._wizard.finished.connect(self._wizard_finished)
self._settings.set_skip_first_run(True)
+ @QtCore.Slot()
def _wizard_finished(self):
"""
- SLOT
- TRIGGERS
- self._wizard.finished
+ TRIGGERS:
+ self._wizard.finished
Called when the wizard has finished.
"""
@@ -534,11 +535,11 @@ class MainWindow(QtGui.QMainWindow):
return h
return None
+ @QtCore.Slot()
def _show_logger_window(self):
"""
- SLOT
TRIGGERS:
- self.ui.action_show_logs.triggered
+ self.ui.action_show_logs.triggered
Displays the window with the history of messages logged until now
and displays the new ones on arrival.
@@ -555,9 +556,9 @@ class MainWindow(QtGui.QMainWindow):
else:
self._logger_window.setVisible(not self._logger_window.isVisible())
+ @QtCore.Slot()
def _show_AKM(self):
"""
- SLOT
TRIGGERS:
self.ui.action_advanced_key_management.triggered
@@ -569,12 +570,12 @@ class MainWindow(QtGui.QMainWindow):
logged_user, self._keymanager, self._soledad)
self._akm.show()
+ @QtCore.Slot()
def _show_preferences(self):
"""
- SLOT
TRIGGERS:
- self.ui.btnPreferences.clicked (disabled for now)
- self.ui.action_preferences
+ self.ui.btnPreferences.clicked (disabled for now)
+ self.ui.action_preferences
Displays the preferences window.
"""
@@ -586,9 +587,9 @@ class MainWindow(QtGui.QMainWindow):
preferences.show()
preferences.preferences_saved.connect(self._update_eip_enabled_status)
+ @QtCore.Slot()
def _update_eip_enabled_status(self):
"""
- SLOT
TRIGGER:
PreferencesWindow.preferences_saved
@@ -622,12 +623,12 @@ class MainWindow(QtGui.QMainWindow):
return eip_enabled
+ @QtCore.Slot()
def _show_eip_preferences(self):
"""
- SLOT
TRIGGERS:
- self.ui.btnEIPPreferences.clicked
- self.ui.action_eip_preferences (disabled for now)
+ self.ui.btnEIPPreferences.clicked
+ self.ui.action_eip_preferences (disabled for now)
Displays the EIP preferences window.
"""
@@ -647,22 +648,27 @@ class MainWindow(QtGui.QMainWindow):
"""
self.new_updates.emit(req)
+ @QtCore.Slot(object)
def _react_to_new_updates(self, req):
"""
- SLOT
- TRIGGER: self._new_updates_available
+ TRIGGERS:
+ self.new_updates
Displays the new updates label and sets the updates_content
+
+ :param req: Request type
+ :type req: leap.common.events.events_pb2.SignalRequest
"""
self.moveToThread(QtCore.QCoreApplication.instance().thread())
self.ui.lblNewUpdates.setVisible(True)
self.ui.btnMore.setVisible(True)
self._updates_content = req.content
+ @QtCore.Slot()
def _updates_details(self):
"""
- SLOT
- TRIGGER: self.ui.btnMore.clicked
+ TRIGGERS:
+ self.ui.btnMore.clicked
Parses and displays the updates details
"""
@@ -686,11 +692,11 @@ class MainWindow(QtGui.QMainWindow):
self.tr("Updates available"),
msg)
+ @QtCore.Slot()
def _finish_init(self):
"""
- SLOT
TRIGGERS:
- self._wizard.accepted
+ self._wizard.accepted
Also called at the end of the constructor if not first run.
@@ -832,10 +838,14 @@ class MainWindow(QtGui.QMainWindow):
# we wait for the systray to be ready
reactor.callLater(1, hello)
+ @QtCore.Slot(int)
def _tray_activated(self, reason=None):
"""
- SLOT
- TRIGGER: self._systray.activated
+ TRIGGERS:
+ self._systray.activated
+
+ :param reason: the reason why the tray got activated.
+ :type reason: int
Displays the context menu from the tray icon
"""
@@ -862,10 +872,11 @@ class MainWindow(QtGui.QMainWindow):
visible = self.isVisible() and self.isActiveWindow()
self._action_visible.setText(get_action(visible))
+ @QtCore.Slot()
def _toggle_visible(self):
"""
- SLOT
- TRIGGER: self._action_visible.triggered
+ TRIGGERS:
+ self._action_visible.triggered
Toggles the window visibility
"""
@@ -909,10 +920,11 @@ class MainWindow(QtGui.QMainWindow):
if state is not None:
self.restoreState(state)
+ @QtCore.Slot()
def _about(self):
"""
- SLOT
- TRIGGERS: self.ui.action_about_leap.triggered
+ TRIGGERS:
+ self.ui.action_about_leap.triggered
Display the About Bitmask dialog
"""
@@ -936,10 +948,11 @@ class MainWindow(QtGui.QMainWindow):
"<a href='https://leap.se'>More about LEAP"
"</a>") % (VERSION, VERSION_HASH[:10], greet))
+ @QtCore.Slot()
def _help(self):
"""
- SLOT
- TRIGGERS: self.ui.action_help.triggered
+ TRIGGERS:
+ self.ui.action_help.triggered
Display the Bitmask help dialog.
"""
@@ -1036,10 +1049,11 @@ class MainWindow(QtGui.QMainWindow):
provider = self._login_widget.get_selected_provider()
self._backend.setup_provider(provider)
+ @QtCore.Slot(dict)
def _load_provider_config(self, data):
"""
- SLOT
- TRIGGER: self._backend.signaler.prov_download_provider_info
+ TRIGGERS:
+ self._backend.signaler.prov_download_provider_info
Once the provider config has been downloaded, this loads the
self._provider_config instance with it and starts the second
@@ -1064,11 +1078,11 @@ class MainWindow(QtGui.QMainWindow):
self.tr("Unable to login: Problem with provider"))
self._login_widget.set_enabled(True)
+ @QtCore.Slot()
def _login(self):
"""
- SLOT
TRIGGERS:
- self._login_widget.login
+ self._login_widget.login
Starts the login sequence. Which involves bootstrapping the
selected provider if the selection is valid (not empty), then
@@ -1092,9 +1106,9 @@ class MainWindow(QtGui.QMainWindow):
if self._login_widget.start_login():
self._download_provider_config()
+ @QtCore.Slot(unicode)
def _authentication_error(self, msg):
"""
- SLOT
TRIGGERS:
Signaler.srp_auth_error
Signaler.srp_auth_server_error
@@ -1110,11 +1124,11 @@ class MainWindow(QtGui.QMainWindow):
self._login_widget.set_enabled(True)
self.ui.action_create_new_account.setEnabled(True)
+ @QtCore.Slot()
def _cancel_login(self):
"""
- SLOT
TRIGGERS:
- self._login_widget.cancel_login
+ self._login_widget.cancel_login
Stops the login sequence.
"""
@@ -1134,9 +1148,9 @@ class MainWindow(QtGui.QMainWindow):
self._soledad_defer.cancel()
self._soledad_defer = None
+ @QtCore.Slot()
def _set_login_cancelled(self):
"""
- SLOT
TRIGGERS:
Signaler.prov_cancelled_setup fired by
self._backend.cancel_setup_provider()
@@ -1147,10 +1161,11 @@ class MainWindow(QtGui.QMainWindow):
self._login_widget.set_status(self.tr("Log in cancelled by the user."))
self._login_widget.set_enabled(True)
+ @QtCore.Slot(dict)
def _provider_config_loaded(self, data):
"""
- SLOT
- TRIGGER: self._backend.signaler.prov_check_api_certificate
+ TRIGGERS:
+ self._backend.signaler.prov_check_api_certificate
Once the provider configuration is loaded, this starts the SRP
authentication
@@ -1171,10 +1186,11 @@ class MainWindow(QtGui.QMainWindow):
logger.error(data[self._backend.ERROR_KEY])
self._login_widget.set_enabled(True)
+ @QtCore.Slot()
def _authentication_finished(self):
"""
- SLOT
- TRIGGER: self._srp_auth.authentication_finished
+ TRIGGERS:
+ self._srp_auth.authentication_finished
Once the user is properly authenticated, try starting the EIP
service
@@ -1285,12 +1301,12 @@ class MainWindow(QtGui.QMainWindow):
###################################################################
# Service control methods: soledad
+ @QtCore.Slot(dict)
def _soledad_intermediate_stage(self, data):
# TODO missing param docstring
"""
- SLOT
TRIGGERS:
- self._soledad_bootstrapper.download_config
+ self._soledad_bootstrapper.download_config
If there was a problem, displays it, otherwise it does nothing.
This is used for intermediate bootstrapping stages, in case
@@ -1320,12 +1336,12 @@ class MainWindow(QtGui.QMainWindow):
logger.warning("Max number of soledad initialization "
"retries reached.")
+ @QtCore.Slot(dict)
def _soledad_bootstrapped_stage(self, data):
"""
- SLOT
TRIGGERS:
- self._soledad_bootstrapper.gen_key
- self._soledad_bootstrapper.local_only_ready
+ self._soledad_bootstrapper.gen_key
+ self._soledad_bootstrapper.local_only_ready
If there was a problem, displays it, otherwise it does nothing.
This is used for intermediate bootstrapping stages, in case
@@ -1364,7 +1380,6 @@ class MainWindow(QtGui.QMainWindow):
@QtCore.Slot()
def _start_smtp_bootstrapping(self):
"""
- SLOT
TRIGGERS:
self.soledad_ready
"""
@@ -1385,7 +1400,6 @@ class MainWindow(QtGui.QMainWindow):
@QtCore.Slot()
def _stop_smtp_service(self):
"""
- SLOT
TRIGGERS:
self.logout
"""
@@ -1398,7 +1412,6 @@ class MainWindow(QtGui.QMainWindow):
@QtCore.Slot()
def _start_imap_service(self):
"""
- SLOT
TRIGGERS:
self.soledad_ready
"""
@@ -1428,7 +1441,6 @@ class MainWindow(QtGui.QMainWindow):
@QtCore.Slot()
def _fetch_incoming_mail(self):
"""
- SLOT
TRIGGERS:
self.mail_client_logged_in
"""
@@ -1438,7 +1450,6 @@ class MainWindow(QtGui.QMainWindow):
@QtCore.Slot()
def _stop_imap_service(self):
"""
- SLOT
TRIGGERS:
self.logout
"""
@@ -1487,9 +1498,9 @@ class MainWindow(QtGui.QMainWindow):
@QtCore.Slot()
def _on_eip_connection_connected(self):
"""
- SLOT
TRIGGERS:
self._eip_status.eip_connection_connected
+
Emits the EIPConnection.qtsigs.connected_signal
This is a little workaround for connecting the vpn-connected
@@ -1589,9 +1600,9 @@ class MainWindow(QtGui.QMainWindow):
self._backend.start_eip()
+ @QtCore.Slot()
def _on_eip_connection_aborted(self):
"""
- SLOT
TRIGGERS:
Signaler.eip_connection_aborted
"""
@@ -1667,7 +1678,6 @@ class MainWindow(QtGui.QMainWindow):
@QtCore.Slot()
def _stop_eip(self):
"""
- SLOT
TRIGGERS:
self._eip_connection.qtsigs.do_disconnect_signal (via state machine)
@@ -1697,7 +1707,6 @@ class MainWindow(QtGui.QMainWindow):
def _on_eip_network_unreachable(self):
# XXX Should move to EIP Conductor
"""
- SLOT
TRIGGERS:
self._eip_connection.qtsigs.network_unreachable
@@ -1711,7 +1720,7 @@ class MainWindow(QtGui.QMainWindow):
def _do_eip_restart(self):
# XXX Should move to EIP Conductor
"""
- SLOT
+ TRIGGERS:
self._eip_connection.qtsigs.process_restart
Restart the connection.
@@ -1729,9 +1738,9 @@ class MainWindow(QtGui.QMainWindow):
self._eip_status.set_eip_status("", error=error)
self._eip_status.set_eip_status_icon("error")
+ @QtCore.Slot(int)
def _eip_finished(self, exitCode):
"""
- SLOT
TRIGGERS:
Signaler.eip_process_finished
@@ -1822,10 +1831,11 @@ class MainWindow(QtGui.QMainWindow):
# eip will not start, so we start soledad anyway
self._maybe_run_soledad_setup_checks()
+ @QtCore.Slot(dict)
def _finish_eip_bootstrap(self, data):
"""
- SLOT
- TRIGGER: self._backend.signaler.eip_client_certificate_ready
+ TRIGGERS:
+ self._backend.signaler.eip_client_certificate_ready
Starts the VPN thread if the eip configuration is properly
loaded
@@ -1842,12 +1852,12 @@ class MainWindow(QtGui.QMainWindow):
# DO START EIP Connection!
self._eip_connection.qtsigs.do_connect_signal.emit()
+ @QtCore.Slot(dict)
def _eip_intermediate_stage(self, data):
# TODO missing param
"""
- SLOT
TRIGGERS:
- self._backend.signaler.eip_config_ready
+ self._backend.signaler.eip_config_ready
If there was a problem, displays it, otherwise it does nothing.
This is used for intermediate bootstrapping stages, in case
@@ -1889,8 +1899,8 @@ class MainWindow(QtGui.QMainWindow):
@QtCore.Slot()
def _logout(self):
"""
- SLOT
- TRIGGER: self._login_widget.logout
+ TRIGGERS:
+ self._login_widget.logout
Starts the logout sequence
"""
@@ -1907,10 +1917,11 @@ class MainWindow(QtGui.QMainWindow):
self._backend.logout()
self.logout.emit()
+ @QtCore.Slot()
def _logout_error(self):
"""
- SLOT
- TRIGGER: self._srp_auth.logout_error
+ TRIGGER:
+ self._srp_auth.logout_error
Inform the user about a logout error.
"""
@@ -1919,10 +1930,11 @@ class MainWindow(QtGui.QMainWindow):
self._login_widget.set_status(
self.tr("Something went wrong with the logout."))
+ @QtCore.Slot()
def _logout_ok(self):
"""
- SLOT
- TRIGGER: self._srp_auth.logout_ok
+ TRIGGER:
+ self._srp_auth.logout_ok
Switches the stackedWidget back to the login stage after
logging out
@@ -1934,15 +1946,15 @@ class MainWindow(QtGui.QMainWindow):
self._login_widget.logged_out()
self._mail_status.mail_state_disabled()
+ @QtCore.Slot(dict)
def _intermediate_stage(self, data):
# TODO this method name is confusing as hell.
"""
- SLOT
TRIGGERS:
- self._backend.signaler.prov_name_resolution
- self._backend.signaler.prov_https_connection
- self._backend.signaler.prov_download_ca_cert
- self._backend.signaler.eip_config_ready
+ self._backend.signaler.prov_name_resolution
+ self._backend.signaler.prov_https_connection
+ self._backend.signaler.prov_download_ca_cert
+ self._backend.signaler.eip_config_ready
If there was a problem, displays it, otherwise it does nothing.
This is used for intermediate bootstrapping stages, in case
@@ -1967,9 +1979,9 @@ class MainWindow(QtGui.QMainWindow):
raise_window_ack()
self.raise_window.emit()
+ @QtCore.Slot()
def _do_raise_mainwindow(self):
"""
- SLOT
TRIGGERS:
self._on_raise_window_event