def __init__(self, parent, domain, backend, leap_signaler): """ :param parent: parent object of the EIPPreferencesWindow. :type parent: QWidget :param domain: the selected by default domain. :type domain: unicode :param backend: Backend being used :type backend: Backend """ QtGui.QDialog.__init__(self, parent) self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic") self._settings = LeapSettings() self._leap_signaler = leap_signaler self._backend = backend # Load UI self.ui = Ui_EIPPreferences() self.ui.setupUi(self) self.ui.lblProvidersGatewayStatus.setVisible(False) # Connections self.ui.cbProvidersGateway.currentIndexChanged[int].connect( self._populate_gateways) self.ui.cbGateways.currentIndexChanged[unicode].connect( lambda x: self.ui.lblProvidersGatewayStatus.setVisible(False)) self._selected_domain = domain self._configured_providers = [] self._backend_connect() self._add_configured_providers()
def __init__(self, username, domain): self._settings = LeapSettings() self.username = username self.domain = domain if self.username is not None: self.address = make_address(self.username, self.domain) else: self.address = self.domain
def test_get_configured_providers_in_bundle(self): """ Test that the config file IS stored under the CWD. """ flags.STANDALONE = True self._leapsettings = LeapSettings() with mock.patch('os.listdir') as os_listdir: # use this method only to spy where LeapSettings is looking for self._leapsettings.get_configured_providers() args, kwargs = os_listdir.call_args config_dir = args[0] self.assertTrue(config_dir.startswith(os.getcwd())) self.assertFalse(config_dir.endswith('config'))
def __init__(self): QtGui.QWidget.__init__(self) self.settings = LeapSettings() self.backend = BackendProxy() self.backend.start() self.signaler = LeapSignaler() self.signaler.start() # periodically check if the backend is alive self._backend_checker = QtCore.QTimer(self) self._backend_checker.timeout.connect(self._check_backend_status) self._backend_checker.start(2000)
def __init__(self, parent, account, app): """ :param parent: parent object of the PreferencesWindow. :parent type: QWidget :param account: user account (user + provider or just provider) :type account: Account :param app: the current App object :type app: App """ PreferencesPage.__init__(self, parent, account, app) self.settings = LeapSettings() self.ui = Ui_PreferencesEmailPage() self.ui.setupUi(self) # the only way to set the tab titles is to re-add them: self.ui.email_tabs.addTab(self.ui.config_tab, self.tr("Mail Client")) self.ui.email_tabs.addTab(self.ui.my_key_tab, self.tr("My Key")) self.ui.email_tabs.addTab(self.ui.other_keys_tab, self.tr("Other Keys")) # set mail client configuration help text lang = QtCore.QLocale.system().name().replace('_', '-') thunderbird_extension_url = \ "https://addons.mozilla.org/{0}/" \ "thunderbird/addon/bitmask/".format(lang) self.ui.thunderbird_label.setText( self.tr("For Thunderbird, you can use the Bitmask extension. " "Search for \"Bitmask\" in the add-on manager or " "download it from <a href='{0}'>addons.mozilla.org</a>.". format(thunderbird_extension_url))) self.ui.mail_client_label.setText( self. tr("Alternatively, you can manually configure your mail client to " "use Bitmask with these options:")) self.ui.webmail_label.setText( self.tr("Bitmask Mail is an integrated mail client based " "on <a href='https://pixelated-project.org/'>Pixelated " "User Agent</a>. If enabled, any user on your device " "can read your mail by opening http://localhost:9090")) self.ui.keys_table.horizontalHeader().setResizeMode( 0, QtGui.QHeaderView.Stretch) self.setup_connections()
def __init__(self, backend, signaler, parent=None): """ Constructs the LoginWidget. :param backend: Backend being used :type backend: Backend :param signaler: Object in charge of handling communication back to the frontend :type signaler: Signaler :param parent: The parent widget for this widget :type parent: QWidget or None """ QtGui.QWidget.__init__(self, parent) SignalTracker.__init__(self) self.ui = Ui_LoginWidget() self.ui.setupUi(self) self.ui.chkRemember.stateChanged.connect(self._remember_state_changed) self.ui.chkRemember.setEnabled(has_keyring()) self.ui.lnUser.textChanged.connect(self._credentials_changed) self.ui.lnPassword.textChanged.connect(self._credentials_changed) self.ui.btnLogin.clicked.connect(self._do_login) self.ui.btnLogout.clicked.connect(self.do_logout) self.ui.lnUser.setValidator( QtGui.QRegExpValidator(QtCore.QRegExp(USERNAME_REGEX), self)) self.ui.clblErrorMsg.hide() self.ui.clblErrorMsg.clicked.connect(self.ui.clblErrorMsg.hide) self.ui.lnUser.textEdited.connect(self.ui.clblErrorMsg.hide) self.ui.lnPassword.textEdited.connect(self.ui.clblErrorMsg.hide) self._settings = LeapSettings() self._backend = backend self._leap_signaler = signaler # the selected provider that we'll use to login self._provider = None self._state = LoginState() self._set_logged_out()
def start_mail_service(self, download_if_needed=False, offline=False): """ Start the IMAP and SMTP servcies. """ if self._firewall is not None: self._firewall.start() if not offline: logger.debug("Starting smtp service...") self.start_smtp_service(download_if_needed=download_if_needed) self.start_imap_service() settings = LeapSettings() pixelmail = settings.get_pixelmail_enabled() if pixelmail: self.start_pixelated_service() self._mail_services_started = True
def __init__(self): QtGui.QWidget.__init__(self) self.settings = LeapSettings() self.backend = BackendProxy() self.backend.start() self.signaler = LeapSignaler() self.signaler.start() self.soledad_started = False self.service_tokens = {} self.login_state = None self.providers_widget = None # periodically check if the backend is alive self._backend_checker = QtCore.QTimer(self) self._backend_checker.timeout.connect(self._check_backend_status) self._backend_checker.start(2000) # store the service tokens for later use, once they are known. self.signaler.soledad_got_service_token.connect( self._set_service_tokens)
def check_missing(): """ Check for the need of installing missing scripts, and raises a dialog to ask user for permission to do it. """ config = LeapSettings() complain_missing = False alert_missing = config.get_alert_missing_scripts() if alert_missing and not flags.STANDALONE: # We refuse to install missing stuff if not running with standalone # flag. Right now we rely on the flag alone, but we can disable this # by overwriting some constant from within the Debian package. alert_missing = False complain_missing = True launcher = get_vpn_launcher() missing_scripts = launcher.missing_updown_scripts() missing_other = launcher.missing_other_files() if missing_scripts: logger.warning("Missing scripts: %s" % (missing_scripts)) if missing_other: logger.warning("Missing other files: %s" % (missing_other)) missing_some = missing_scripts or missing_other if alert_missing and missing_some: msg = get_missing_helpers_dialog() ret = msg.exec_() if ret == QtGui.QMessageBox.Yes: install_missing_fun = globals().get( "_%s_install_missing_scripts" % (_system.lower(), ), None) if not install_missing_fun: logger.warning("Installer not found for platform %s." % (_system, )) return # XXX maybe move constants to fun ok = install_missing_fun(HELPERS_BADEXEC_MSG, HELPERS_NOTFOUND_MSG) if not ok: msg = QtGui.QMessageBox() msg.setWindowTitle(msg.tr("Problem installing files")) msg.setText(msg.tr('Some of the files could not be copied.')) msg.setIcon(QtGui.QMessageBox.Warning) msg.exec_() elif ret == QtGui.QMessageBox.No: logger.debug("Not installing missing scripts, " "user decided to ignore our warning.") init_signals.eip_missing_helpers.emit() elif ret == QtGui.QMessageBox.Rejected: logger.debug("Setting alert_missing_scripts to False, we will not " "ask again") init_signals.eip_missing_helpers.emit() config.set_alert_missing_scripts(False) if complain_missing and missing_some: missing = missing_scripts + missing_other msg = _get_missing_complain_dialog(missing) ret = msg.exec_() # If there is some missing file and we don't want to complain, we emit the # 'missing helpers' signal so the eip status can show that some files are # missing. if missing_some and not alert_missing and not complain_missing: init_signals.eip_missing_helpers.emit()
def _load_configured_providers_with_pinned(self, pinned): """ Once we have the pinned providers from the backend, we continue setting everything up :param pinned: list of pinned providers :type pinned: list of str How the combobox items are arranged: ----------------------------------- First run: demo.bitmask.net -- pinned2.org pinned1.org pinned3.org After some usage: added-by-user.org pinned-but-then-used.org --- demo.bitmask.net pinned1.org pinned3.org pinned2.org In other words: * There are two sections. * Section one consists of all the providers that the user has used. If this is empty, than use demo.bitmask.net for this section. This list is sorted alphabetically. * Section two consists of all the pinned or 'pre seeded' providers, minus any providers that are now in section one. This last list is in random order. """ ls = LeapSettings() user_added = ls.get_configured_providers() if not user_added and not pinned: self.ui.rbExistingProvider.setEnabled(False) self.ui.label_8.setEnabled(False) # 'https://' label self.ui.cbProviders.setEnabled(False) return user_added.sort() if not user_added: user_added = [pinned.pop(0)] # separate unused pinned providers from user added ones for p in user_added: if p in pinned: pinned.remove(p) if user_added: self.ui.cbProviders.addItems(user_added) if user_added and pinned: self.ui.cbProviders.addItem('---') if pinned: random.shuffle(pinned) # don't prioritize alphabetically self.ui.cbProviders.addItems(pinned) # We have configured providers, so by default we select the # 'Use existing provider' option. self.ui.rbExistingProvider.setChecked(True) # We need to set it as complete explicitly self.page(self.INTRO_PAGE).set_completed()