Beispiel #1
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
Beispiel #2
0
    def open(self):
        if self._conn != None:
            raise InvalidOperationException("Account is aready open")

        conn = None

        try:
            if self.ssl:
                if self.port == '':
                    conn = poplib.POP3_SSL(self.server)
                else:
                    conn = poplib.POP3_SSL(self.server, int(self.port))
            else:
                if self.port == '':
                    conn = poplib.POP3(self.server)
                else:
                    conn = poplib.POP3(self.server, int(self.port))

                try:
                    conn.stls()
                except:
                    logging.warning(
                        "Using unencrypted connection for account '%s'" %
                        self.name)

            conn.getwelcome()
            conn.user(self.user)
            conn.pass_(self.password)
        except:
            try:
                if conn != None:
                    conn.quit()
            except:
                pass
            raise  # re-throw exception

        self._conn = conn
Beispiel #3
0
    def open(self):
        if self._conn != None:
            raise InvalidOperationException("Account is aready open")

        conn = None

        try:
            if self.ssl:
                if self.port == '':
                    conn = poplib.POP3_SSL(self.server)
                else:
                    conn = poplib.POP3_SSL(self.server, int(self.port))
            else:
                if self.port == '':
                    conn = poplib.POP3(self.server)
                else:
                    conn = poplib.POP3(self.server, int(self.port))

                # TODO : Use STARTTLS when Mailnag has been migrated to python 3
                # (analogous to open() in imap backend).
                logging.warning(
                    "Using unencrypted connection for account '%s'" %
                    self.name)

            conn.getwelcome()
            conn.user(self.user)
            conn.pass_(self.password)
        except:
            try:
                if conn != None:
                    conn.quit()
            except:
                pass
            raise  # re-throw exception

        self._conn = conn
Beispiel #4
0
	def start(self):
		if self._disposed:
			raise InvalidOperationException("Idler has been disposed")
			
		self._thread.start()
Beispiel #5
0
    def open(self):
        if self._conn != None:
            raise InvalidOperationException("Account is aready open")

        self._conn = self._connect()
Beispiel #6
0
 def _ensure_open(self):
     if not self.is_open():
         raise InvalidOperationException("Account is not open")
Beispiel #7
0
    def _ensure_valid_state(self):
        if not self._initialized:
            raise InvalidOperationException("Daemon has not been initialized")

        if self._disposed:
            raise InvalidOperationException("Daemon has been disposed")
Beispiel #8
0
 def _ensure_not_disposed(self):
     if self._disposed:
         raise InvalidOperationException("Daemon has been disposed")