def init_app(app):
    leap_session = init_leap_session(app)

    tag_service = TagService()
    search_engine = SearchEngine()
    pixelated_mail_sender = MailSender(leap_session.account_email())

    soledad_querier = SoledadQuerier(soledad=leap_session.account._soledad)
    pixelated_mailboxes = Mailboxes(leap_session.account, soledad_querier)
    draft_service = DraftService(pixelated_mailboxes)
    mail_service = MailService(pixelated_mailboxes, pixelated_mail_sender, tag_service, soledad_querier)

    MailboxIndexerListener.SEARCH_ENGINE = search_engine
    InputMail.FROM_EMAIL_ADDRESS = leap_session.account_email()

    home_controller = HomeController()
    features_controller = FeaturesController()
    mails_controller = MailsController(mail_service=mail_service,
                                       draft_service=draft_service,
                                       search_engine=search_engine)
    tags_controller = TagsController(search_engine=search_engine)
    sync_info_controller = SyncInfoController()
    attachments_controller = AttachmentsController(soledad_querier)

    register(signal=proto.SOLEDAD_SYNC_RECEIVE_STATUS,
             callback=update_info_sync_and_index_partial(sync_info_controller=sync_info_controller,
                                                         search_engine=search_engine,
                                                         mail_service=mail_service))
    register(signal=proto.SOLEDAD_DONE_DATA_SYNC,
             callback=init_index_and_remove_dupes(querier=soledad_querier,
                                                  search_engine=search_engine,
                                                  mail_service=mail_service))

    _setup_routes(app, home_controller, mails_controller, tags_controller, features_controller,
                  sync_info_controller, attachments_controller)
示例#2
0
    def test_signal_response_status(self):
        """
        Ensure there's an appropriate response from server when signaling.
        """
        sig = 4
        request = SignalRequest()
        request.event = sig
        request.content = 'my signal contents'
        request.mac_method = mac_auth.MacMethod.MAC_NONE
        request.mac = ""
        service = RpcService(EventsServerService_Stub, port, 'localhost')
        # test synch
        response = service.signal(request, timeout=1000)
        self.assertEqual(EventResponse.OK, response.status,
                         'Wrong response status.')
        # test asynch

        def local_callback(request, response):
            global local_callback_executed
            local_callback_executed = True

        events.register(sig, local_callback)
        service.signal(request, callback=local_callback)
        time.sleep(0.1)
        self.assertTrue(local_callback_executed,
                        'Local callback did not execute.')
def init_app(app, leap_home, leap_session):
    leap_session.start_background_jobs()
    keymanager = leap_session.nicknym.keymanager

    soledad_querier = SoledadQuerier(soledad=leap_session.account._soledad)

    search_engine = SearchEngine(soledad_querier, agent_home=leap_home)
    pixelated_mail_sender = MailSender(
        leap_session.account_email(),
        lambda: leap_session.smtp.ensure_running())

    pixelated_mailboxes = Mailboxes(leap_session.account, soledad_querier,
                                    search_engine)
    draft_service = DraftService(pixelated_mailboxes)
    mail_service = MailService(pixelated_mailboxes, pixelated_mail_sender,
                               soledad_querier, search_engine)

    MailboxIndexerListener.SEARCH_ENGINE = search_engine
    InputMail.FROM_EMAIL_ADDRESS = leap_session.account_email()

    app.resource.initialize(soledad_querier, keymanager, search_engine,
                            mail_service, draft_service)

    register(signal=proto.SOLEDAD_DONE_DATA_SYNC,
             callback=init_index_and_remove_dupes(querier=soledad_querier,
                                                  search_engine=search_engine,
                                                  mail_service=mail_service))

    register(signal=proto.SOLEDAD_DONE_DATA_SYNC,
             uid=CREATE_KEYS_IF_KEYS_DONT_EXISTS_CALLBACK,
             callback=look_for_user_key_and_create_if_cant_find(leap_session))

    reactor.threadpool.adjustPoolsize(20, 40)
    reactor.stop = stop_incoming_mail_fetcher(reactor.stop, leap_session)
示例#4
0
    def _register_smtp_error_handler(self):
        def on_error(event):
            delivery_error_mail = InputMail.delivery_error_template(
                delivery_address=event.content)
            self._mail_service.mailboxes.inbox.add(delivery_error_mail)

        register(events.SMTP_SEND_MESSAGE_ERROR, callback=on_error)
    def _register_smtp_error_handler(self):

        def on_error(event):
            delivery_error_mail = InputMail.delivery_error_template(delivery_address=event.content)
            self._mail_service.mailboxes.inbox.add(delivery_error_mail)

        register(events.SMTP_SEND_MESSAGE_ERROR, callback=on_error)
示例#6
0
def initialize_leap(leap_provider_cert,
                    leap_provider_cert_fingerprint,
                    credentials_file,
                    organization_mode,
                    leap_home,
                    initial_sync=True):
    init_monkeypatches()
    events_server.ensure_server()
    register(events.KEYMANAGER_FINISHED_KEY_GENERATION,
             set_fresh_account)
    provider, username, password = credentials.read(organization_mode,
                                                    credentials_file)
    LeapCertificate.set_cert_and_fingerprint(leap_provider_cert,
                                             leap_provider_cert_fingerprint)

    config = LeapConfig(leap_home=leap_home, start_background_jobs=True)
    provider = LeapProvider(provider, config)
    LeapCertificate(provider).setup_ca_bundle()
    leap_session = LeapSessionFactory(provider).create(username, password)

    if initial_sync:
        leap_session = yield leap_session.initial_sync()

    global fresh_account
    if fresh_account:
        add_welcome_mail(leap_session.mail_store)

    defer.returnValue(leap_session)
def init_app(app, leap_home, leap_session):
    leap_session.start_background_jobs()
    keymanager = leap_session.nicknym.keymanager

    soledad_querier = SoledadQuerier(soledad=leap_session.account._soledad)

    search_engine = SearchEngine(soledad_querier, agent_home=leap_home)
    pixelated_mail_sender = MailSender(leap_session.account_email(),
                                       lambda: leap_session.smtp.ensure_running())

    pixelated_mailboxes = Mailboxes(leap_session.account, soledad_querier, search_engine)
    draft_service = DraftService(pixelated_mailboxes)
    mail_service = MailService(pixelated_mailboxes, pixelated_mail_sender, soledad_querier, search_engine)

    MailboxIndexerListener.SEARCH_ENGINE = search_engine
    InputMail.FROM_EMAIL_ADDRESS = leap_session.account_email()

    app.resource.initialize(soledad_querier, keymanager, search_engine, mail_service, draft_service)

    register(signal=proto.SOLEDAD_DONE_DATA_SYNC,
             callback=init_index_and_remove_dupes(querier=soledad_querier,
                                                  search_engine=search_engine,
                                                  mail_service=mail_service))

    register(signal=proto.SOLEDAD_DONE_DATA_SYNC, uid=CREATE_KEYS_IF_KEYS_DONT_EXISTS_CALLBACK,
             callback=look_for_user_key_and_create_if_cant_find(leap_session))

    reactor.threadpool.adjustPoolsize(20, 40)
    reactor.stop = stop_incoming_mail_fetcher(reactor.stop, leap_session)
示例#8
0
    def _register_smtp_error_handler(self):
        def on_error(event):
            delivery_error_mail = InputMail.delivery_error_template(
                delivery_address=event.content)
            delivery_error_mail = self._mail_service.mailboxes.inbox().add(
                delivery_error_mail)
            self._search_engine.index_mail(delivery_error_mail)

        register(signal=proto.SMTP_SEND_MESSAGE_ERROR, callback=on_error)
示例#9
0
 def __init__(self, provider, user_auth, mail_store, soledad_session, nicknym, smtp):
     self.smtp = smtp
     self.config = provider.config
     self.provider = provider
     self.user_auth = user_auth
     self.mail_store = mail_store
     self.soledad_session = soledad_session
     self.nicknym = nicknym
     self.fresh_account = False
     register(events.KEYMANAGER_FINISHED_KEY_GENERATION, self._set_fresh_account)
示例#10
0
 def __init__(self, provider, user_auth, mail_store, soledad, keymanager, smtp_config):
     self.smtp_config = smtp_config
     self.provider = provider
     self.user_auth = user_auth
     self.mail_store = mail_store
     self.soledad = soledad
     self.keymanager = keymanager
     self.fresh_account = False
     self.incoming_mail_fetcher = None
     self.account = None
     self._has_been_initially_synced = False
     self._is_closed = False
     register(events.KEYMANAGER_FINISHED_KEY_GENERATION, self._set_fresh_account, uid=self.account_email(), replace=True)
示例#11
0
 def test_register_signal_replace(self):
     """
     Make sure components can replace already registered callbacks.
     """
     sig = 3
     cbk = lambda x: True
     events.register(sig, cbk, uid=1)
     self.assertRaises(Exception, events.register, sig, lambda x: True,
                       uid=1)
     events.register(sig, lambda x: True, uid=1, replace=True)
     self.assertTrue(sig in self.callbacks, 'Could not register signal.')
     self.assertEqual(1, len(self.callbacks[sig]),
                      'Wrong number of registered callbacks.')
示例#12
0
 def test_register_signal_replace(self):
     """
     Make sure clients can replace already registered callbacks.
     """
     sig = 3
     cbk = lambda x: True
     events.register(sig, cbk, uid=1)
     self.assertRaises(Exception, events.register, sig, lambda x: True,
                       uid=1)
     events.register(sig, lambda x: True, uid=1, replace=True)
     self.assertTrue(sig in self.callbacks, 'Could not register signal.')
     self.assertEqual(1, len(self.callbacks[sig]),
                      'Wrong number of registered callbacks.')
示例#13
0
 def test_client_unregister_all(self):
     """
     Test that the client can unregister all events for one signal.
     """
     sig = CLIENT_UID
     complist = server.registered_clients
     events.register(sig, lambda x: True)
     events.register(sig, lambda x: True)
     time.sleep(0.1)
     events.unregister(sig)
     time.sleep(0.1)
     port = client.EventsClientDaemon.get_instance().get_port()
     self.assertFalse(bool(complist[sig]))
     self.assertTrue(port not in complist[sig])
示例#14
0
 def test_component_register(self):
     """
     Ensure components can register callbacks.
     """
     self.assertTrue(1 not in self.callbacks,
                     'There should should be no callback for this signal.')
     events.register(1, lambda x: True)
     self.assertTrue(1 in self.callbacks,
                     'Could not register signal in local component.')
     events.register(2, lambda x: True)
     self.assertTrue(1 in self.callbacks,
                     'Could not register signal in local component.')
     self.assertTrue(2 in self.callbacks,
                     'Could not register signal in local component.')
示例#15
0
 def test_client_register(self):
     """
     Ensure clients can register callbacks.
     """
     self.assertTrue(1 not in self.callbacks,
                     'There should should be no callback for this signal.')
     events.register(1, lambda x: True)
     self.assertTrue(1 in self.callbacks,
                     'Could not register signal in local client.')
     events.register(2, lambda x: True)
     self.assertTrue(1 in self.callbacks,
                     'Could not register signal in local client.')
     self.assertTrue(2 in self.callbacks,
                     'Could not register signal in local client.')
示例#16
0
 def test_component_request_register(self):
     """
     Ensure components can register themselves with server.
     """
     sig = 6
     complist = server.registered_components
     self.assertTrue(sig not in complist,
                     'There should be no registered components for this '
                     'signal.')
     events.register(sig, lambda x: True)
     time.sleep(0.1)
     port = component.EventsComponentDaemon.get_instance().get_port()
     self.assertTrue(sig in complist, 'Failed registering component.')
     self.assertTrue(port in complist[sig],
                     'Failed registering component port.')
示例#17
0
 def __init__(self, provider, user_auth, mail_store, soledad, nicknym, smtp_config):
     self.smtp_config = smtp_config
     self.config = provider.config
     self.provider = provider
     self.user_auth = user_auth
     self.mail_store = mail_store
     self.soledad = soledad
     self.nicknym = nicknym
     self.fresh_account = False
     self.incoming_mail_fetcher = None
     self.account = None
     self._has_been_initially_synced = False
     self._sem_intial_sync = defer.DeferredLock()
     self._is_closed = False
     register(events.KEYMANAGER_FINISHED_KEY_GENERATION, self._set_fresh_account, uid=self.account_email())
示例#18
0
 def test_client_request_register(self):
     """
     Ensure clients can register themselves with server.
     """
     sig = 6
     complist = server.registered_clients
     self.assertTrue(sig not in complist,
                     'There should be no registered clients for this '
                     'signal.')
     events.register(sig, lambda x: True)
     time.sleep(0.1)
     port = client.EventsClientDaemon.get_instance().get_port()
     self.assertTrue(sig in complist, 'Failed registering client.')
     self.assertTrue(port in complist[sig],
                     'Failed registering client port.')
示例#19
0
 def __init__(self, provider, user_auth, mail_store, soledad, nicknym, smtp_config):
     self.smtp_config = smtp_config
     self.config = provider.config
     self.provider = provider
     self.user_auth = user_auth
     self.mail_store = mail_store
     self.soledad = soledad
     self.nicknym = nicknym
     self.fresh_account = False
     self.incoming_mail_fetcher = None
     self.account = None
     self._has_been_initially_synced = False
     self._sem_intial_sync = defer.DeferredLock()
     self._is_closed = False
     register(events.KEYMANAGER_FINISHED_KEY_GENERATION, self._set_fresh_account, uid=self.account_email())
示例#20
0
 def test_client_unregister_by_uid(self):
     """
     Test that the client can unregister an event by uid.
     """
     sig = CLIENT_UID
     complist = server.registered_clients
     events.register(sig, lambda x: True, uid='cbkuid')
     events.register(sig, lambda x: True, uid='cbkuid2')
     time.sleep(0.1)
     events.unregister(sig, uid='cbkuid')
     time.sleep(0.1)
     port = client.EventsClientDaemon.get_instance().get_port()
     self.assertTrue(sig in complist)
     self.assertTrue(len(complist[sig]) == 1)
     self.assertTrue(
         client.registered_callbacks[sig].pop()[0] == 'cbkuid2')
     self.assertTrue(port in complist[sig])
示例#21
0
 def __init__(self, provider, user_auth, mail_store, soledad, keymanager,
              smtp_config):
     self.smtp_config = smtp_config
     self.provider = provider
     self.user_auth = user_auth
     self.mail_store = mail_store
     self.soledad = soledad
     self.keymanager = keymanager
     self.fresh_account = False
     self.incoming_mail_fetcher = None
     self.account = None
     self._has_been_initially_synced = False
     self._is_closed = False
     register(events.KEYMANAGER_FINISHED_KEY_GENERATION,
              self._set_fresh_account,
              uid=self.account_email(),
              replace=True)
示例#22
0
    def test_client_receives_signal(self):
        """
        Ensure clients can receive signals.
        """
        sig = 7
        flag = Mock()

        events.register(sig, lambda req: flag(req.event))
        request = SignalRequest()
        request.event = sig
        request.content = ""
        request.mac_method = mac_auth.MacMethod.MAC_NONE
        request.mac = ""
        service = RpcService(EventsServerService_Stub, port, 'localhost')
        response = service.signal(request, timeout=1000)
        self.assertTrue(response is not None, 'Did not receive response.')
        time.sleep(0.5)
        flag.assert_called_once_with(sig)
示例#23
0
    def test_async_unregister(self):
        """
        Test asynchronous unregistering of callbacks.
        """
        flag = Mock()

        # executed after async signal, when response is received from server
        def reqcbk(request, response):
            flag(request.event, response.status)

        # callback registered by application
        def callback(request):
            pass

        # passing a callback as reqcbk param makes the call asynchronous
        events.register(CLIENT_UID, callback)
        result = events.unregister(CLIENT_UID, reqcbk=reqcbk)
        self.assertIsNone(result)
        time.sleep(1)  # wait for signal to arrive from server
        flag.assert_called_once_with(CLIENT_UID, EventResponse.OK)
示例#24
0
    def test_component_receives_signal(self):
        """
        Ensure components can receive signals.
        """
        sig = 7

        def getsig(param=None):
            global received
            received = True

        events.register(sig, getsig)
        request = SignalRequest()
        request.event = sig
        request.content = ""
        request.mac_method = mac_auth.MacMethod.MAC_NONE
        request.mac = ""
        service = RpcService(EventsServerService_Stub, port, 'localhost')
        response = service.signal(request, timeout=1000)
        self.assertTrue(response is not None, 'Did not receive response.')
        time.sleep(0.5)
        self.assertTrue(received, 'Did not receive signal back.')
示例#25
0
    def test_signal_executes_callback(self):
        """
        Ensure callback is executed upon receiving signal.
        """
        sig = CLIENT_UID
        request = SignalRequest()
        request.event = sig
        request.content = 'my signal contents'
        request.mac_method = mac_auth.MacMethod.MAC_NONE
        request.mac = ""
        service = RpcService(EventsServerService_Stub, port, 'localhost')

        # register a callback
        flag = Mock()
        events.register(sig, lambda req: flag(req.event))
        # signal
        response = service.signal(request)
        self.assertEqual(EventResponse.OK, response.status,
                         'Wrong response status.')
        time.sleep(1)  # wait for signal to arrive
        flag.assert_called_once_with(sig)
def init_app(app):
    leap_session = init_leap_session(app)
    soledad_querier = SoledadQuerier(soledad=leap_session.account._soledad)

    tag_service = TagService()
    search_engine = SearchEngine(soledad_querier)
    pixelated_mail_sender = MailSender(leap_session.account_email())

    pixelated_mailboxes = Mailboxes(leap_session.account, soledad_querier)
    draft_service = DraftService(pixelated_mailboxes)
    mail_service = MailService(pixelated_mailboxes, pixelated_mail_sender,
                               tag_service, soledad_querier)

    MailboxIndexerListener.SEARCH_ENGINE = search_engine
    InputMail.FROM_EMAIL_ADDRESS = leap_session.account_email()

    home_controller = HomeController()
    features_controller = FeaturesController()
    mails_controller = MailsController(mail_service=mail_service,
                                       draft_service=draft_service,
                                       search_engine=search_engine)
    tags_controller = TagsController(search_engine=search_engine)
    contacts_controller = ContactsController(search_engine=search_engine)
    sync_info_controller = SyncInfoController()
    attachments_controller = AttachmentsController(soledad_querier)

    register(signal=proto.SOLEDAD_SYNC_RECEIVE_STATUS,
             callback=update_info_sync_and_index_partial(
                 sync_info_controller=sync_info_controller,
                 search_engine=search_engine,
                 mail_service=mail_service))
    register(signal=proto.SOLEDAD_DONE_DATA_SYNC,
             callback=init_index_and_remove_dupes(querier=soledad_querier,
                                                  search_engine=search_engine,
                                                  mail_service=mail_service))

    register(signal=proto.SOLEDAD_DONE_DATA_SYNC,
             uid=CREATE_KEYS_IF_KEYS_DONT_EXISTS_CALLBACK,
             callback=look_for_user_key_and_create_if_cant_find(leap_session))

    setup_routes(app, home_controller, mails_controller, tags_controller,
                 features_controller, sync_info_controller,
                 attachments_controller, contacts_controller)
    def __init__(self, parent=None):
        """
        Constructor for MailStatusWidget

        :param parent: parent widget for this one.
        :type parent: QtGui.QWidget
        """
        QtGui.QWidget.__init__(self, parent)

        self._systray = None
        self._disabled = True
        self._started = False

        self._unread_mails = 0

        self.ui = Ui_MailStatusWidget()
        self.ui.setupUi(self)

        self.ui.lblMailReadyHelp.setVisible(False)

        # set systray tooltip status
        self._mx_status = ""
        self._service_name = get_service_display_name(MX_SERVICE)

        # Set the Mail status icons
        self.CONNECTING_ICON = None
        self.CONNECTED_ICON = None
        self.ERROR_ICON = None
        self.CONNECTING_ICON_TRAY = None
        self.CONNECTED_ICON_TRAY = None
        self.ERROR_ICON_TRAY = None
        self._set_mail_icons()

        register(event=catalog.KEYMANAGER_LOOKING_FOR_KEY,
                 callback=self._mail_handle_keymanager_events)
        register(event=catalog.KEYMANAGER_KEY_FOUND,
                 callback=self._mail_handle_keymanager_events)
        register(event=catalog.KEYMANAGER_KEY_NOT_FOUND,
                 callback=self._mail_handle_keymanager_events)
        register(event=catalog.KEYMANAGER_STARTED_KEY_GENERATION,
                 callback=self._mail_handle_keymanager_events)
        register(event=catalog.KEYMANAGER_FINISHED_KEY_GENERATION,
                 callback=self._mail_handle_keymanager_events)
        register(event=catalog.KEYMANAGER_DONE_UPLOADING_KEYS,
                 callback=self._mail_handle_keymanager_events)

        register(event=catalog.SOLEDAD_DONE_DOWNLOADING_KEYS,
                 callback=self._mail_handle_soledad_events)
        register(event=catalog.SOLEDAD_DONE_UPLOADING_KEYS,
                 callback=self._mail_handle_soledad_events)
        register(event=catalog.SOLEDAD_SYNC_RECEIVE_STATUS,
                 callback=self._mail_handle_soledad_events)
        register(event=catalog.SOLEDAD_SYNC_SEND_STATUS,
                 callback=self._mail_handle_soledad_events)
        register(event=catalog.SOLEDAD_INVALID_AUTH_TOKEN,
                 callback=self.set_soledad_invalid_auth_token)
        register(event=catalog.SOLEDAD_DONE_DATA_SYNC,
                 callback=self._mail_handle_soledad_events)

        register(event=catalog.MAIL_UNREAD_MESSAGES,
                 callback=self._mail_handle_imap_events)
        register(event=catalog.IMAP_SERVICE_STARTED,
                 callback=self._mail_handle_imap_events)
        register(event=catalog.SMTP_SERVICE_STARTED,
                 callback=self._mail_handle_imap_events)
        register(event=catalog.IMAP_CLIENT_LOGIN,
                 callback=self._mail_handle_imap_events)

        self._soledad_event.connect(self._mail_handle_soledad_events_slot)
        self._imap_event.connect(self._mail_handle_imap_events_slot)
        self._smtp_event.connect(self._mail_handle_smtp_events_slot)
        self._keymanager_event.connect(
            self._mail_handle_keymanager_events_slot)
示例#28
0
    def __init__(self, parent=None):
        """
        Constructor for MailStatusWidget

        :param parent: parent widget for this one.
        :type parent: QtGui.QWidget
        """
        QtGui.QWidget.__init__(self, parent)

        self._systray = None
        self._disabled = True
        self._started = False

        self._unread_mails = 0

        self.ui = Ui_MailStatusWidget()
        self.ui.setupUi(self)

        self.ui.lblMailReadyHelp.setVisible(False)

        # set systray tooltip status
        self._mx_status = ""
        self._service_name = get_service_display_name(MX_SERVICE)

        # Set the Mail status icons
        self.CONNECTING_ICON = None
        self.CONNECTED_ICON = None
        self.ERROR_ICON = None
        self.CONNECTING_ICON_TRAY = None
        self.CONNECTED_ICON_TRAY = None
        self.ERROR_ICON_TRAY = None
        self._set_mail_icons()

        register(event=catalog.KEYMANAGER_LOOKING_FOR_KEY, callback=self._mail_handle_keymanager_events)
        register(event=catalog.KEYMANAGER_KEY_FOUND, callback=self._mail_handle_keymanager_events)
        register(event=catalog.KEYMANAGER_KEY_NOT_FOUND, callback=self._mail_handle_keymanager_events)
        register(event=catalog.KEYMANAGER_STARTED_KEY_GENERATION, callback=self._mail_handle_keymanager_events)
        register(event=catalog.KEYMANAGER_FINISHED_KEY_GENERATION, callback=self._mail_handle_keymanager_events)
        register(event=catalog.KEYMANAGER_DONE_UPLOADING_KEYS, callback=self._mail_handle_keymanager_events)

        register(event=catalog.SOLEDAD_DONE_DOWNLOADING_KEYS, callback=self._mail_handle_soledad_events)
        register(event=catalog.SOLEDAD_DONE_UPLOADING_KEYS, callback=self._mail_handle_soledad_events)
        register(event=catalog.SOLEDAD_SYNC_RECEIVE_STATUS, callback=self._mail_handle_soledad_events)
        register(event=catalog.SOLEDAD_SYNC_SEND_STATUS, callback=self._mail_handle_soledad_events)
        register(event=catalog.SOLEDAD_INVALID_AUTH_TOKEN, callback=self.set_soledad_invalid_auth_token)
        register(event=catalog.SOLEDAD_DONE_DATA_SYNC, callback=self._mail_handle_soledad_events)

        register(event=catalog.MAIL_UNREAD_MESSAGES, callback=self._mail_handle_imap_events)
        register(event=catalog.IMAP_SERVICE_STARTED, callback=self._mail_handle_imap_events)
        register(event=catalog.SMTP_SERVICE_STARTED, callback=self._mail_handle_imap_events)
        register(event=catalog.IMAP_CLIENT_LOGIN, callback=self._mail_handle_imap_events)

        self._soledad_event.connect(self._mail_handle_soledad_events_slot)
        self._imap_event.connect(self._mail_handle_imap_events_slot)
        self._smtp_event.connect(self._mail_handle_smtp_events_slot)
        self._keymanager_event.connect(self._mail_handle_keymanager_events_slot)
示例#29
0
 def _log_user_out_on_token_expire(leap_session):
     register(events.SOLEDAD_INVALID_AUTH_TOKEN, _log_user_out)
     return leap_session
    def __init__(self, parent=None):
        """
        Constructor for MailStatusWidget

        :param parent: parent widget for this one.
        :type parent: QtGui.QWidget
        """
        QtGui.QWidget.__init__(self, parent)

        self._systray = None
        self._disabled = True
        self._started = False

        self.ui = Ui_MailStatusWidget()
        self.ui.setupUi(self)

        # set systray tooltip status
        self._mx_status = ""
        self._service_name = get_service_display_name(MX_SERVICE)

        # Set the Mail status icons
        self.CONNECTING_ICON = None
        self.CONNECTED_ICON = None
        self.ERROR_ICON = None
        self.CONNECTING_ICON_TRAY = None
        self.CONNECTED_ICON_TRAY = None
        self.ERROR_ICON_TRAY = None
        self._set_mail_icons()

        register(signal=proto.KEYMANAGER_LOOKING_FOR_KEY,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_KEY_FOUND,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        # register(signal=proto.KEYMANAGER_KEY_NOT_FOUND,
        #          callback=self._mail_handle_keymanager_events,
        #          reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_STARTED_KEY_GENERATION,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_FINISHED_KEY_GENERATION,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_DONE_UPLOADING_KEYS,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.SOLEDAD_DONE_DOWNLOADING_KEYS,
                 callback=self._mail_handle_soledad_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.SOLEDAD_DONE_UPLOADING_KEYS,
                 callback=self._mail_handle_soledad_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.IMAP_UNREAD_MAIL,
                 callback=self._mail_handle_imap_events,
                 reqcbk=lambda req, resp: None)
        register(signal=proto.IMAP_SERVICE_STARTED,
                 callback=self._mail_handle_imap_events,
                 reqcbk=lambda req, resp: None)
        register(signal=proto.SMTP_SERVICE_STARTED,
                 callback=self._mail_handle_imap_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.SOLEDAD_INVALID_AUTH_TOKEN,
                 callback=self.set_soledad_invalid_auth_token,
                 reqcbk=lambda req, resp: None)

        self._soledad_event.connect(self._mail_handle_soledad_events_slot)
        self._imap_event.connect(self._mail_handle_imap_events_slot)
        self._smtp_event.connect(self._mail_handle_smtp_events_slot)
        self._keymanager_event.connect(
            self._mail_handle_keymanager_events_slot)
示例#31
0
 def _register_shutdown_on_token_expire(leap_session):
     register(events.SOLEDAD_INVALID_AUTH_TOKEN,
              lambda *unused: reactor.stop())
     return leap_session
示例#32
0
 def do_REGISTER(self, _, *parts, **kw):
     event = getattr(catalog, parts[2])
     register(event, self._callback)
 def _log_user_out_on_token_expire(leap_session):
     register(events.SOLEDAD_INVALID_AUTH_TOKEN, _log_user_out)
     return leap_session
示例#34
0
    def __init__(self, parent=None):
        """
        Constructor for MailStatusWidget

        :param parent: parent widget for this one.
        :type parent: QtGui.QWidget
        """
        QtGui.QWidget.__init__(self, parent)

        self._systray = None
        self._disabled = True
        self._started = False

        self.ui = Ui_MailStatusWidget()
        self.ui.setupUi(self)

        # set systray tooltip status
        self._mx_status = ""
        self._service_name = get_service_display_name(MX_SERVICE)

        # Set the Mail status icons
        self.CONNECTING_ICON = None
        self.CONNECTED_ICON = None
        self.ERROR_ICON = None
        self.CONNECTING_ICON_TRAY = None
        self.CONNECTED_ICON_TRAY = None
        self.ERROR_ICON_TRAY = None
        self._set_mail_icons()

        register(signal=proto.KEYMANAGER_LOOKING_FOR_KEY,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_KEY_FOUND,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        # register(signal=proto.KEYMANAGER_KEY_NOT_FOUND,
        #          callback=self._mail_handle_keymanager_events,
        #          reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_STARTED_KEY_GENERATION,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_FINISHED_KEY_GENERATION,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_DONE_UPLOADING_KEYS,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.SOLEDAD_DONE_DOWNLOADING_KEYS,
                 callback=self._mail_handle_soledad_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.SOLEDAD_DONE_UPLOADING_KEYS,
                 callback=self._mail_handle_soledad_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.IMAP_UNREAD_MAIL,
                 callback=self._mail_handle_imap_events,
                 reqcbk=lambda req, resp: None)
        register(signal=proto.IMAP_SERVICE_STARTED,
                 callback=self._mail_handle_imap_events,
                 reqcbk=lambda req, resp: None)
        register(signal=proto.SMTP_SERVICE_STARTED,
                 callback=self._mail_handle_imap_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.SOLEDAD_INVALID_AUTH_TOKEN,
                 callback=self.set_soledad_invalid_auth_token,
                 reqcbk=lambda req, resp: None)

        self._soledad_event.connect(
            self._mail_handle_soledad_events_slot)
        self._imap_event.connect(
            self._mail_handle_imap_events_slot)
        self._smtp_event.connect(
            self._mail_handle_smtp_events_slot)
        self._keymanager_event.connect(
            self._mail_handle_keymanager_events_slot)
 def _register_shutdown_on_token_expire(leap_session):
     register(events.SOLEDAD_INVALID_AUTH_TOKEN, lambda _: reactor.stop())
     return leap_session
示例#36
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self._systray = None
        self._eip_status_menu = None

        self.ui = Ui_StatusPanel()
        self.ui.setupUi(self)

        self.eipconnection = EIPConnection()

        self.hide_status_box()

        # set systray tooltip statuses
        self._eip_status = self._mx_status = ""

        # Set the EIP status icons
        self.CONNECTING_ICON = None
        self.CONNECTED_ICON = None
        self.ERROR_ICON = None
        self.CONNECTING_ICON_TRAY = None
        self.CONNECTED_ICON_TRAY = None
        self.ERROR_ICON_TRAY = None
        self._set_eip_icons()

        self._set_traffic_rates()
        self._make_status_clickable()

        register(signal=proto.KEYMANAGER_LOOKING_FOR_KEY,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_KEY_FOUND,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        # register(signal=proto.KEYMANAGER_KEY_NOT_FOUND,
        #          callback=self._mail_handle_keymanager_events,
        #          reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_STARTED_KEY_GENERATION,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_FINISHED_KEY_GENERATION,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.KEYMANAGER_DONE_UPLOADING_KEYS,
                 callback=self._mail_handle_keymanager_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.SOLEDAD_DONE_DOWNLOADING_KEYS,
                 callback=self._mail_handle_soledad_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.SOLEDAD_DONE_UPLOADING_KEYS,
                 callback=self._mail_handle_soledad_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.SMTP_SERVICE_STARTED,
                 callback=self._mail_handle_smtp_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.SMTP_SERVICE_FAILED_TO_START,
                 callback=self._mail_handle_smtp_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.IMAP_SERVICE_STARTED,
                 callback=self._mail_handle_imap_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.IMAP_SERVICE_FAILED_TO_START,
                 callback=self._mail_handle_imap_events,
                 reqcbk=lambda req, resp: None)

        register(signal=proto.IMAP_UNREAD_MAIL,
                 callback=self._mail_handle_imap_events,
                 reqcbk=lambda req, resp: None)

        self._set_long_mail_status("")
        self.ui.lblUnread.setVisible(False)

        self._smtp_started = False
        self._imap_started = False

        self._soledad_event.connect(
            self._mail_handle_soledad_events_slot)
        self._imap_event.connect(
            self._mail_handle_imap_events_slot)
        self._smtp_event.connect(
            self._mail_handle_smtp_events_slot)
        self._keymanager_event.connect(
            self._mail_handle_keymanager_events_slot)