Beispiel #1
0
    def __init__(self, user_id, store, d=defer.Deferred()):
        """
        Keeps track of the mailboxes and subscriptions handled by this account.

        The account is not ready to be used, since the store needs to be
        initialized and we also need to do some initialization routines.
        You can either pass a deferred to this constructor, or use
        `callWhenReady` method.

        :param user_id: The name of the account (user id, in the form
                        user@provider).
        :type user_id: str

        :param store: a Soledad instance.
        :type store: Soledad

        :param d: a deferred that will be fired with this IMAPAccount instance
                  when the account is ready to be used.
        :type d: defer.Deferred
        """
        leap_assert(store, "Need a store instance to initialize")
        leap_assert_type(store, Soledad)

        # TODO assert too that the name matches the user/uuid with which
        # soledad has been initialized. Although afaik soledad doesn't know
        # about user_id, only the client backend.

        self.user_id = user_id
        self.account = Account(store, ready_cb=lambda: d.callback(self))
Beispiel #2
0
    def __init__(self, userid, soledad, keymanager):
        self.userid = userid

        self.soledad = soledad

        # XXX this needs to be converged with our public apis.
        self.nicknym = NickNym(keymanager, userid)
        self.mail_store = LeapMailStore(soledad)

        self.user_auth = Config()
        self.user_auth.uuid = soledad.uuid

        self.fresh_account = False
        self.incoming_mail_fetcher = None
        self.account = Account(soledad, userid)

        username, provider = userid.split('@')
        smtp_client_cert = os.path.join(
            get_path_prefix(), 'leap', 'providers', provider, 'keys', 'client',
            'smtp_{username}.pem'.format(username=username))

        assert (os.path.isfile(smtp_client_cert))

        smtp_config = get_smtp_config(provider)
        smtp_host = smtp_config.host
        smtp_port = smtp_config.port

        self.smtp_config = LeapSMTPConfig(userid, smtp_client_cert, smtp_host,
                                          smtp_port)
Beispiel #3
0
def start_incoming_mail_service(keymanager, soledad, userid):
    """
    Initalizes and starts the incomming mail service.

    :returns: a Deferred that will be fired with the IncomingMail instance
    """
    def setUpIncomingMail(inbox):
        incoming_mail = IncomingMail(keymanager,
                                     soledad,
                                     inbox,
                                     userid,
                                     check_period=get_mail_check_period())
        return incoming_mail

    acc = Account(soledad, userid)
    d = acc.callWhenReady(lambda _: acc.get_collection_by_mailbox(INBOX_NAME))
    d.addCallback(setUpIncomingMail)
    return d
Beispiel #4
0
 def get_account(self):
     store = self._soledad
     return Account(store)
 def _create_account(self, soledad, user_id):
     self.account = Account(soledad, user_id)
     return self.account.deferred_initialization
Beispiel #6
0
 def _initialize_account(self):
     self.account = Account(self.soledad, self._user_id)
     return self.account.deferred_initialization