diff options
-rw-r--r-- | src/leap/bitmask/gui/mainwindow.py | 21 | ||||
-rw-r--r-- | src/leap/bitmask/gui/statemachines.py | 4 | ||||
-rw-r--r-- | src/leap/bitmask/services/eip/conductor.py | 58 |
3 files changed, 61 insertions, 22 deletions
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index 27ef6109..aa317d96 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -158,6 +158,8 @@ class MainWindow(QtGui.QMainWindow): self._eip_conductor.connect_signals() self._eip_conductor.qtsigs.connected_signal.connect( self._on_eip_connection_connected) + self._eip_conductor.qtsigs.disconnected_signal.connect( + self._on_eip_connection_disconnected) self._eip_conductor.qtsigs.connected_signal.connect( self._maybe_run_soledad_setup_checks) @@ -1466,6 +1468,25 @@ class MainWindow(QtGui.QMainWindow): # check for connectivity self._check_name_resolution(domain) + @QtCore.Slot() + def _on_eip_connection_disconnected(self): + """ + TRIGGERS: + self._eip_conductor.qtsigs.disconnected_signal + + Workaround for updating the eip_status widget with + the provider when the eip connection disconnects. + """ + # TODO + # We should move this to the conductor<->widget interface. + # To do that, we need to subscribe to logged_user, + # for example by using the observer pattern or a proxy object. + user = self._logged_user + if user: + domain = self._login_widget.get_selected_provider() + full_user_id = make_address(user, domain) + self._eip_status.set_provider(full_user_id) + def _check_name_resolution(self, domain): # FIXME this has to be moved to backend !!! # Should move to netchecks module. diff --git a/src/leap/bitmask/gui/statemachines.py b/src/leap/bitmask/gui/statemachines.py index f8e5479d..2a876b83 100644 --- a/src/leap/bitmask/gui/statemachines.py +++ b/src/leap/bitmask/gui/statemachines.py @@ -55,6 +55,10 @@ class SignallingState(QState): """ Emits the signal on entry. """ + print "IIIIIIIIIIIIIIIIIII" + print "TO STATE", self._name, self.objectName() + print "IIIIIIIIIIIIIIIIIII" + logger.debug('State %s::%s entered. Emitting signal ...' % (self._name, self.objectName())) if self._signal is not None: diff --git a/src/leap/bitmask/services/eip/conductor.py b/src/leap/bitmask/services/eip/conductor.py index 253f76c0..7cc80014 100644 --- a/src/leap/bitmask/services/eip/conductor.py +++ b/src/leap/bitmask/services/eip/conductor.py @@ -69,6 +69,7 @@ class EIPConductor(object): Connect signals. """ self.qtsigs.connecting_signal.connect(self._start_eip) + self.qtsigs.disconnecting_signal.connect(self._stop_eip) self.qtsigs.disconnected_signal.connect(self._eip_status.eip_stopped) @@ -154,43 +155,55 @@ class EIPConductor(object): self._eip_status.is_restart = restart self.user_stopped_eip = not restart - def reconnect_stop_signal(): - self.qtsigs.disconnecting_signal.connect(self._stop_eip) - def on_disconnected_do_restart(): # hard restarts + logger.debug("HARD RESTART") eip_status_label = self._eip_status.tr("{0} is restarting") eip_status_label = eip_status_label.format(self.eip_name) self._eip_status.eip_stopped(restart=True) self._eip_status.set_eip_status(eip_status_label, error=False) - QtDelayedCall(1000, self.qtsigs.do_connect_signal.emit) + QtDelayedCall(2000, self.do_connect) + + def plug_restart_on_disconnected(): + #print "PLUGGING RESTART ON DISCONNECTED" + self.qtsigs.disconnected_signal.connect(on_disconnected_do_restart) + + def reconnect_disconnected_signal(): + #print "RECONNECTING DISCONNECTED SIGNAL" + self.qtsigs.disconnected_signal.disconnect( + on_disconnected_do_restart) + + def do_stop(*args): + self._stop_eip(restart=False) + + def reconnect_stop_signal(): + #print "RECONNECTING StOP SIGNAL" + self.qtsigs.disconnecting_signal.disconnect() + self.qtsigs.disconnecting_signal.connect(do_stop) if restart: # we bypass the on_eip_disconnected here - #qtsigs.disconnected_signal.disconnect() - self.qtsigs.disconnected_signal.connect(on_disconnected_do_restart) - QtDelayedCall(0, self.qtsigs.disconnected_signal.emit) + plug_restart_on_disconnected() + self.qtsigs.disconnected_signal.emit() + #QtDelayedCall(0, self.qtsigs.disconnected_signal.emit) + # ...and reconnect the original signal again, after having used the + # diversion + QtDelayedCall(500, reconnect_disconnected_signal) + else: + logger.debug('Setting autostart to: False') + self._settings.set_autostart_eip(False) # Call to the backend. self._backend.eip_stop(restart=restart) - self._eip_status.set_eipstatus_off(False) self._already_started_eip = False - - logger.debug('Setting autostart to: False') - self._settings.set_autostart_eip(False) - - if self._logged_user: - self._eip_status.set_provider( - make_address( - self._logged_user, - self._get_best_provider_config().get_domain())) - + self._eip_status.set_eipstatus_off(False) self._eip_status.eip_stopped(restart=restart) + # XXX needed? if restart: - QtDelayedCall(50000, reconnect_stop_signal) + QtDelayedCall(3000, reconnect_stop_signal) @QtCore.Slot() def _do_eip_restart(self): @@ -202,14 +215,15 @@ class EIPConductor(object): """ if self._eip_status is not None: self._eip_status.is_restart = True + + def do_stop(*args): + self._stop_eip(restart=True) + try: self.qtsigs.disconnecting_signal.disconnect() except Exception: logger.error("cannot disconnect signals") - def do_stop(*args): - self._stop_eip(restart=True) - self.qtsigs.disconnecting_signal.connect(do_stop) self.qtsigs.do_disconnect_signal.emit() |