Example #1
0
    def get_collection(self, mbox_collection=True, mbox_name=None,
                       mbox_uuid=None):
        """
        Get a collection for tests.
        """
        adaptor = SoledadMailAdaptor()
        store = self._soledad
        adaptor.store = store

        if mbox_collection:
            mbox_indexer = MailboxIndexer(store)
            mbox_name = mbox_name or "TestMbox"
            mbox_uuid = mbox_uuid or str(uuid.uuid4())
        else:
            mbox_indexer = mbox_name = None

        def get_collection_from_mbox_wrapper(wrapper):
            wrapper.uuid = mbox_uuid
            return MessageCollection(
                adaptor, store,
                mbox_indexer=mbox_indexer, mbox_wrapper=wrapper)

        d = adaptor.initialize_store(store)
        if mbox_collection:
            d.addCallback(lambda _: mbox_indexer.create_table(mbox_uuid))
        d.addCallback(lambda _: adaptor.get_or_create_mbox(store, mbox_name))
        d.addCallback(get_collection_from_mbox_wrapper)
        return d
Example #2
0
    def get_lastuid(self, mbox):
        if isinstance(mbox, str):
            mbox = (yield defer.maybeDeferred(self.get_mbox, mbox))[0]

        indexer = MailboxIndexer(self.soledad)
        yield indexer.create_table(mbox.content['uuid'])
        last_uuid = yield indexer.get_last_uid(mbox.content['uuid'])

        defer.returnValue(last_uuid)
Example #3
0
    def __init__(self, store, ready_cb=None):
        self.store = store
        self.adaptor = self.adaptor_class()
        self.mbox_indexer = MailboxIndexer(self.store)

        # This flag is only used from the imap service for the moment.
        # In the future, we should prevent any public method to continue if
        # this is set to True. Also, it would be good to plug to the
        # authentication layer.
        self.session_ended = False

        self.deferred_initialization = defer.Deferred()
        self._ready_cb = ready_cb

        self._init_d = self._initialize_storage()
        self._initialize_sync_hooks()