diff options
Diffstat (limited to 'src/leap/bitmask/gui')
-rw-r--r-- | src/leap/bitmask/gui/mainwindow.py | 88 | ||||
-rw-r--r-- | src/leap/bitmask/gui/ui/wizard.ui | 93 | ||||
-rw-r--r-- | src/leap/bitmask/gui/wizard.py | 3 |
3 files changed, 59 insertions, 125 deletions
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index 6d612d4e..7a94fd0f 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -14,9 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. - """ -Main window for the leap client +Main window for Bitmask. """ import logging import os @@ -102,6 +101,7 @@ class MainWindow(QtGui.QMainWindow): raise_window = QtCore.Signal([]) soledad_ready = QtCore.Signal([]) mail_client_logged_in = QtCore.Signal([]) + logout = QtCore.Signal([]) # We use this flag to detect abnormal terminations user_stopped_eip = False @@ -286,6 +286,8 @@ class MainWindow(QtGui.QMainWindow): self.soledad_ready.connect(self._start_imap_service) self.soledad_ready.connect(self._set_soledad_ready) self.mail_client_logged_in.connect(self._fetch_incoming_mail) + self.logout.connect(self._stop_imap_service) + self.logout.connect(self._stop_smtp_service) ################################# end Qt Signals connection ######## @@ -301,6 +303,7 @@ class MainWindow(QtGui.QMainWindow): self._soledad = None self._soledad_ready = False self._keymanager = None + self._smtp_service = None self._imap_service = None self._login_defer = None @@ -909,7 +912,7 @@ class MainWindow(QtGui.QMainWindow): self._srp_auth.logout_finished.connect( self._done_logging_out) - # TODO: Add errback! + # TODO Add errback! self._login_defer = self._srp_auth.authenticate(username, password) else: self._login_widget.set_status( @@ -976,7 +979,7 @@ class MainWindow(QtGui.QMainWindow): """ passed = data[self._soledad_bootstrapper.PASSED_KEY] if not passed: - # TODO: display in the GUI: + # TODO display in the GUI: # should pass signal to a slot in status_panel # that sets the global status logger.error("Soledad failed to start: %s" % @@ -1037,13 +1040,13 @@ class MainWindow(QtGui.QMainWindow): True) else: if self._enabled_services.count(self.MX_SERVICE) > 0: - pass # TODO: show MX status + pass # TODO show MX status #self._status_panel.set_eip_status( # self.tr("%s does not support MX") % # (self._provider_config.get_domain(),), # error=True) else: - pass # TODO: show MX status + pass # TODO show MX status #self._status_panel.set_eip_status( # self.tr("MX is disabled")) @@ -1070,25 +1073,43 @@ class MainWindow(QtGui.QMainWindow): logger.debug("Done bootstrapping SMTP") hosts = self._smtp_config.get_hosts() - # TODO: handle more than one host and define how to choose + # TODO handle more than one host and define how to choose if len(hosts) > 0: hostname = hosts.keys()[0] logger.debug("Using hostname %s for SMTP" % (hostname,)) host = hosts[hostname][self.IP_KEY].encode("utf-8") port = hosts[hostname][self.PORT_KEY] - # TODO: pick local smtp port in a better way - # TODO: Make the encrypted_only configurable + # TODO move the start to _start_smtp_service + + # TODO Make the encrypted_only configurable + # TODO pick local smtp port in a better way + # TODO remove hard-coded port and let leap.mail set + # the specific default. from leap.mail.smtp import setup_smtp_relay client_cert = self._eip_config.get_client_cert_path( self._provider_config) - setup_smtp_relay(port=2013, - keymanager=self._keymanager, - smtp_host=host, - smtp_port=port, - smtp_cert=client_cert, - smtp_key=client_cert, - encrypted_only=False) + self._smtp_service = setup_smtp_relay( + port=2013, + keymanager=self._keymanager, + smtp_host=host, + smtp_port=port, + smtp_cert=client_cert, + smtp_key=client_cert, + encrypted_only=False) + + def _stop_smtp_service(self): + """ + SLOT + TRIGGERS: + self.logout + """ + # There is a subtle difference here: + # we are stopping the factory for the smtp service here, + # but in the imap case we are just stopping the fetcher. + if self._smtp_service is not None: + logger.debug('Stopping smtp service.') + self._smtp_service.doStop() ################################################################### # Service control methods: imap @@ -1097,7 +1118,7 @@ class MainWindow(QtGui.QMainWindow): """ SLOT TRIGGERS: - soledad_ready + self.soledad_ready """ if self._provider_config.provides_mx() and \ self._enabled_services.count(self.MX_SERVICE) > 0: @@ -1106,17 +1127,6 @@ class MainWindow(QtGui.QMainWindow): self._imap_service = imap.start_imap_service( self._soledad, self._keymanager) - else: - if self._enabled_services.count(self.MX_SERVICE) > 0: - pass # TODO: show MX status - #self._status_panel.set_eip_status( - # self.tr("%s does not support MX") % - # (self._provider_config.get_domain(),), - # error=True) - else: - pass # TODO: show MX status - #self._status_panel.set_eip_status( - # self.tr("MX is disabled")) def _on_mail_client_logged_in(self, req): """ @@ -1128,13 +1138,27 @@ class MainWindow(QtGui.QMainWindow): """ SLOT TRIGGERS: - mail_client_logged_in + self.mail_client_logged_in """ # TODO have a mutex over fetch operation. if self._imap_service: logger.debug('Client connected, fetching mail...') self._imap_service.fetch() + def _stop_imap_service(self): + """ + SLOT + TRIGGERS: + self.logout + """ + # There is a subtle difference here: + # we are just stopping the fetcher here, + # but in the smtp case we are stopping the factory. + # We should homogenize both services. + if self._imap_service is not None: + logger.debug('Stopping imap service.') + self._imap_service.stop() + # end service control methods (imap) ################################################################### @@ -1146,7 +1170,8 @@ class MainWindow(QtGui.QMainWindow): :rtype: tuple (str, str) (host, port) """ - # TODO: make this properly multiplatform + # TODO make this properly multiplatform + # TODO get this out of gui/ if platform.system() == "Windows": host = "localhost" @@ -1399,6 +1424,7 @@ class MainWindow(QtGui.QMainWindow): # XXX: If other defers are doing authenticated stuff, this # might conflict with those. CHECK! threads.deferToThread(self._srp_auth.logout) + self.logout.emit() def _done_logging_out(self, ok, message): """ @@ -1573,7 +1599,7 @@ class MainWindow(QtGui.QMainWindow): """ Cleanup and tidely close the main window before quitting. """ - # TODO: separate the shutting down of services from the + # TODO separate the shutting down of services from the # UI stuff. self._cleanup_and_quit() diff --git a/src/leap/bitmask/gui/ui/wizard.ui b/src/leap/bitmask/gui/ui/wizard.ui index 3b8f1215..2a412784 100644 --- a/src/leap/bitmask/gui/ui/wizard.ui +++ b/src/leap/bitmask/gui/ui/wizard.ui @@ -183,7 +183,7 @@ <item row="2" column="0"> <widget class="QLabel" name="label_4"> <property name="text"> - <string>Can we stablish a secure connection?</string> + <string>Can we establish a secure connection?</string> </property> </widget> </item> @@ -740,97 +740,6 @@ </item> </layout> </widget> - <widget class="QWizardPage" name="finish_page"> - <property name="title"> - <string>Congratulations!</string> - </property> - <property name="subTitle"> - <string>You have successfully configured Bitmask.</string> - </property> - <attribute name="pageId"> - <string notr="true">6</string> - </attribute> - <layout class="QGridLayout" name="gridLayout_10"> - <item row="1" column="0"> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="1"> - <spacer name="verticalSpacer_9"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="label_23"> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/mask-icon.png</pixmap> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QLabel" name="label_25"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/Globe.png</pixmap> - </property> - </widget> - </item> - <item row="3" column="1"> - <spacer name="verticalSpacer_10"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="3"> - <spacer name="horizontalSpacer_5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> </widget> <customwidgets> <customwidget> diff --git a/src/leap/bitmask/gui/wizard.py b/src/leap/bitmask/gui/wizard.py index ac0f032f..e004e6cf 100644 --- a/src/leap/bitmask/gui/wizard.py +++ b/src/leap/bitmask/gui/wizard.py @@ -52,7 +52,6 @@ class Wizard(QtGui.QWizard): SETUP_PROVIDER_PAGE = 3 REGISTER_USER_PAGE = 4 SERVICES_PAGE = 5 - FINISH_PAGE = 6 WEAK_PASSWORDS = ("123456", "qweasd", "qwerty", "password") @@ -144,7 +143,7 @@ class Wizard(QtGui.QWizard): self.page(self.REGISTER_USER_PAGE).setButtonText( QtGui.QWizard.CommitButton, self.tr("&Next >")) - self.page(self.FINISH_PAGE).setButtonText( + self.page(self.SERVICES_PAGE).setButtonText( QtGui.QWizard.FinishButton, self.tr("Connect")) # XXX: Temporary removal for enrollment policy |