Example #1
0
class App(QtGui.QWidget):

    # the user has changed which services are enabled for a particular account
    # args: account (Account), active services (list of str)
    service_selection_changed = QtCore.Signal(object, list)

    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 _check_backend_status(self):
        """
        TRIGGERS:
            self._backend_checker.timeout

        Check that the backend is running. Otherwise show an error to the user.
        """
        if not self.backend.online:
            logger.critical("Backend is not online.")
            QtGui.QMessageBox.critical(
                self, self.tr("Application error"),
                self.tr("There is a problem contacting the backend, please "
                        "restart Bitmask."))
            self._backend_checker.stop()
Example #2
0
class App(QtGui.QWidget):

    # the user has changed which services are enabled for a particular account
    # args: account (Account), active services (list of str)
    service_selection_changed = QtCore.Signal(object, list)

    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 _check_backend_status(self):
        """
        TRIGGERS:
            self._backend_checker.timeout

        Check that the backend is running. Otherwise show an error to the user.
        """
        if not self.backend.online:
            logger.critical("Backend is not online.")
            QtGui.QMessageBox.critical(
                self, self.tr("Application error"),
                self.tr("There is a problem contacting the backend, please "
                        "restart Bitmask."))
            self._backend_checker.stop()
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
    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)
Example #6
0
def start_app():
    """
    Starts the main event loop and launches the main window.
    """
    qt_hack_ubuntu()

    # Ignore the signals since we handle them in the subprocesses
    # signal.signal(signal.SIGINT, signal.SIG_IGN)

    # Parse arguments and store them
    opts = leap_argparse.get_options()
    do_display_version(opts)

    options = {
        'start_hidden': opts.start_hidden,
        'debug': opts.debug,
    }

    flags.STANDALONE = opts.standalone

    if platform.system() != 'Darwin':
        # XXX this hangs the OSX bundles.
        if getattr(sys, 'frozen', False):
            flags.STANDALONE = True

    flags.OFFLINE = opts.offline
    flags.MAIL_LOGFILE = opts.mail_log_file
    flags.APP_VERSION_CHECK = opts.app_version_check
    flags.API_VERSION_CHECK = opts.api_version_check
    flags.OPENVPN_VERBOSITY = opts.openvpn_verb
    flags.SKIP_WIZARD_CHECKS = opts.skip_wizard_checks

    flags.CA_CERT_FILE = opts.ca_cert_file

    flags.DEBUG = opts.debug

    common_flags.STANDALONE = flags.STANDALONE

    logger = get_logger(perform_rollover=True)

    # NOTE: since we are not using this right now, the code that replaces the
    # stdout needs to be reviewed when we enable this again
    # replace_stdout = True

    # XXX mail repair commands disabled for now
    # if opts.repair or opts.import_maildir:
    #    We don't want too much clutter on the comand mode
    #    this could be more generic with a Command class.
    #    replace_stdout = False

    # ok, we got logging in place, we can satisfy mail plumbing requests
    # and show logs there. it normally will exit there if we got that path.
    # XXX mail repair commands disabled for now
    # do_mail_plumbing(opts)

    PLAY_NICE = os.environ.get("LEAP_NICE")
    if PLAY_NICE and PLAY_NICE.isdigit():
        nice = os.nice(int(PLAY_NICE))
        logger.info("Setting NICE: %s" % nice)

    # TODO move to a different module: commands?
    if not we_are_the_one_and_only():
        # Bitmask is already running
        logger.warning("Tried to launch more than one instance "
                       "of Bitmask. Raising the existing "
                       "one instead.")
        sys.exit(1)

    check_requirements()

    logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    logger.info('Bitmask version %s' % VERSION)
    logger.info('leap.mail version %s' % MAIL_VERSION)
    log_lsb_release_info(logger)
    logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    logger.info('Starting app')

    backend_running = BackendProxy().check_online()
    logger.debug("Backend online: {0}".format(backend_running))

    flags_dict = flags_to_dict()

    backend_pid = None
    if not backend_running:
        frontend_pid = os.getpid()
        backend_process = multiprocessing.Process(target=run_backend,
                                                  name='Backend',
                                                  args=(opts.danger,
                                                        flags_dict,
                                                        frontend_pid))
        # we don't set the 'daemon mode' since we need to start child processes
        # in the backend
        # backend_process.daemon = True
        backend_process.start()
        backend_pid = backend_process.pid

    fix_qtplugins_path()
    run_frontend(options, flags_dict, backend_pid=backend_pid)
Example #7
0
class App(QtGui.QWidget):

    # the user has changed which services are enabled for a particular account
    # args: account (Account), active services (list of str)
    service_selection_changed = QtCore.Signal(object, list)

    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 current_account(self):
        """
        Alas, the only definitive account information is buried in the memory
        of QT widgets.

        :returns: an object representing the current user account.
        :rtype: Account
        """
        if self.login_state is None or self.providers_widget is None:
            return None

        if self.login_state.full_logged_username is not None:
            username, domain = self.login_state.full_logged_username.split('@')
            return Account(username, domain)
        else:
            domain = self.providers_widget.get_selected_provider()
            return Account(None, domain)

    def _check_backend_status(self):
        """
        TRIGGERS:
            self._backend_checker.timeout

        Check that the backend is running. Otherwise show an error to the user.
        """
        if not self.backend.online:
            logger.critical("Backend is not online.")
            QtGui.QMessageBox.critical(
                self, self.tr("Application error"),
                self.tr("There is a problem contacting the backend, please "
                        "restart Bitmask."))
            self._backend_checker.stop()

    def _set_service_tokens(self, data):
        """
        Triggered by signal soledad_got_service_token.
        Saves the service tokens.
        """
        service, token = data
        self.service_tokens[service] = token
Example #8
0
def start_app():
    """
    Starts the main event loop and launches the main window.
    """
    # Ignore the signals since we handle them in the subprocesses
    # signal.signal(signal.SIGINT, signal.SIG_IGN)

    # Parse arguments and store them
    opts = leap_argparse.get_options()
    do_display_version(opts)

    options = {
        'start_hidden': opts.start_hidden,
        'debug': opts.debug,
        'log_file': opts.log_file,
    }

    flags.STANDALONE = opts.standalone
    # XXX Disabled right now since it's not tested after login refactor
    # flags.OFFLINE = opts.offline
    flags.OFFLINE = False
    flags.MAIL_LOGFILE = opts.mail_log_file
    flags.APP_VERSION_CHECK = opts.app_version_check
    flags.API_VERSION_CHECK = opts.api_version_check
    flags.OPENVPN_VERBOSITY = opts.openvpn_verb
    flags.SKIP_WIZARD_CHECKS = opts.skip_wizard_checks

    flags.CA_CERT_FILE = opts.ca_cert_file

    replace_stdout = True
    if opts.repair or opts.import_maildir:
        # We don't want too much clutter on the comand mode
        # this could be more generic with a Command class.
        replace_stdout = False

    logger = create_logger(opts.debug, opts.log_file, replace_stdout)

    # ok, we got logging in place, we can satisfy mail plumbing requests
    # and show logs there. it normally will exit there if we got that path.
    do_mail_plumbing(opts)

    try:
        event_server.ensure_server(event_server.SERVER_PORT)
    except Exception as e:
        # We don't even have logger configured in here
        print "Could not ensure server: %r" % (e, )

    PLAY_NICE = os.environ.get("LEAP_NICE")
    if PLAY_NICE and PLAY_NICE.isdigit():
        nice = os.nice(int(PLAY_NICE))
        logger.info("Setting NICE: %s" % nice)

    # TODO move to a different module: commands?
    if not we_are_the_one_and_only():
        # Bitmask is already running
        logger.warning("Tried to launch more than one instance "
                       "of Bitmask. Raising the existing "
                       "one instead.")
        sys.exit(1)

    check_requirements()

    logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    logger.info('Bitmask version %s', VERSION)
    logger.info('leap.mail version %s', MAIL_VERSION)
    logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')

    logger.info('Starting app')

    backend_running = BackendProxy().check_online()
    logger.debug("Backend online: {0}".format(backend_running))

    flags_dict = flags_to_dict()

    backend_pid = None
    if not backend_running:
        frontend_pid = os.getpid()
        backend = lambda: run_backend(opts.danger, flags_dict, frontend_pid)
        backend_process = multiprocessing.Process(target=backend,
                                                  name='Backend')
        # we don't set the 'daemon mode' since we need to start child processes
        # in the backend
        # backend_process.daemon = True
        backend_process.start()
        backend_pid = backend_process.pid

    run_frontend(options, flags_dict, backend_pid=backend_pid)