예제 #1
0
def test_load_from_config(config):
    am = AccountManager()
    am.load_from_cfg(config, enabled_only=False)
    accounts = am.to_list()
    assert len(accounts) == 6
    imap_account = get_account(am.to_list(), 'IMAP mailbox config')
    pop3_account = get_account(am.to_list(), 'POP3 mailbox config')
    assert imap_account.get_config()['password'] == 'drowssap'
    assert pop3_account.get_config()['password'] == 'poppoppop'
예제 #2
0
def test_load_from_config_with_credential_store(config):
    cs = FakeCredentialStore()
    cs.set('Mailnag password for imap://[email protected]', 'verry seecret')
    cs.set('Mailnag password for pop://[email protected]', 'seecret too')
    am = AccountManager(cs)
    am.load_from_cfg(config, enabled_only=False)
    accounts = am.to_list()
    assert len(accounts) == 6
    imap_account = get_account(am.to_list(), 'IMAP mailbox config')
    pop3_account = get_account(am.to_list(), 'POP3 mailbox config')
    assert imap_account.get_config()['password'] == 'verry seecret'
    assert pop3_account.get_config()['password'] == 'seecret too'
예제 #3
0
    def init(self):
        with self._lock:
            if self._disposed:
                raise InvalidOperationException("Daemon has been disposed")

            if self._initialized:
                raise InvalidOperationException(
                    "Daemon has already been initialized")

            self._cfg = read_cfg()

            accountman = AccountManager()
            accountman.load_from_cfg(self._cfg, enabled_only=True)
            self._accounts = accountman.to_list()
            self._hookreg = HookRegistry()
            self._conntest = ConnectivityTest(testmode_mapping[self._cfg.get(
                'core', 'connectivity_test')])

            memorizer = Memorizer()
            memorizer.load()

            self._mailchecker = MailChecker(self._cfg, memorizer,
                                            self._hookreg, self._conntest)

            # Note: all code following _load_plugins() should be executed
            # asynchronously because the dbus plugin requires an active mainloop
            # (usually started in the programs main function).
            self._load_plugins(self._cfg, self._hookreg, memorizer)

            # Start checking for mails asynchronously.
            self._start_thread = threading.Thread(target=self._start)
            self._start_thread.start()

            self._initialized = True
예제 #4
0
	def init(self):			
		with self._lock:
			if self._disposed:
				raise InvalidOperationException("Daemon has been disposed")
		
			if self._initialized:
				raise InvalidOperationException("Daemon has already been initialized")
			
			self._cfg = read_cfg()
			
			accountman = AccountManager(CredentialStore.from_string(self._cfg.get('core', 'credentialstore')))
			accountman.load_from_cfg(self._cfg, enabled_only = True)
			self._accounts = accountman.to_list()
			self._hookreg = HookRegistry()
			self._conntest = ConnectivityTest(testmode_mapping[self._cfg.get('core', 'connectivity_test')])
			
			memorizer = Memorizer()
			memorizer.load()

			self._mailchecker = MailChecker(self._cfg, memorizer, self._hookreg, self._conntest)

			# Note: all code following _load_plugins() should be executed
			# asynchronously because the dbus plugin requires an active mainloop
			# (usually started in the programs main function).
			self._load_plugins(self._cfg, self._hookreg, memorizer)

			# Start checking for mails asynchronously.
			self._start_thread = threading.Thread(target = self._start)
			self._start_thread.start()

			self._initialized = True
예제 #5
0
    def __init__(self,
                 fatal_error_handler=None,
                 shutdown_request_handler=None):
        self._fatal_error_handler = fatal_error_handler
        self._shutdown_request_handler = shutdown_request_handler
        self._plugins = []
        self._poll_thread = None
        self._poll_thread_stop = threading.Event()
        self._idlrunner = None
        self._disposed = False

        self._cfg = read_cfg()

        accountman = AccountManager()
        accountman.load_from_cfg(self._cfg, enabled_only=True)
        self._accounts = accountman.to_list()
        self._hookreg = HookRegistry()
        self._conntest = ConnectivityTest(testmode_mapping[self._cfg.get(
            'core', 'connectivity_test')])

        self._memorizer = Memorizer()
        self._memorizer.load()

        dbus_service = DBusService(self)

        self._mailchecker = MailChecker(self._cfg, self._memorizer,
                                        self._hookreg, self._conntest,
                                        dbus_service)

        # Note: all code following _load_plugins() should be executed
        # asynchronously because the dbus plugin requires an active mainloop
        # (usually started in the programs main function).
        self._load_plugins(self._cfg)

        # Start checking for mails asynchronously.
        self._start_thread = threading.Thread(target=self._start)
        self._start_thread.start()