diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-08 14:09:43 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-08 14:09:43 +0100 |
commit | a41d7ee237918584ea45405d20dee4f680fe7071 (patch) | |
tree | aa87ba170b2f5b5e9f67254dd598193cd4c15987 /examples/imapresource/imapresource.cpp | |
parent | a21368827de7a2d70ef2a260cb35c25fcf5967e8 (diff) | |
download | sink-a41d7ee237918584ea45405d20dee4f680fe7071.tar.gz sink-a41d7ee237918584ea45405d20dee4f680fe7071.zip |
Added session cache.
So we can avoid logging in for every command.
Diffstat (limited to 'examples/imapresource/imapresource.cpp')
-rw-r--r-- | examples/imapresource/imapresource.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 06dc340..04cedff 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp | |||
@@ -89,6 +89,7 @@ static QByteArray parentRid(const Imap::Folder &folder) | |||
89 | 89 | ||
90 | 90 | ||
91 | class ImapSynchronizer : public Sink::Synchronizer { | 91 | class ImapSynchronizer : public Sink::Synchronizer { |
92 | Q_OBJECT | ||
92 | public: | 93 | public: |
93 | ImapSynchronizer(const ResourceContext &resourceContext) | 94 | ImapSynchronizer(const ResourceContext &resourceContext) |
94 | : Sink::Synchronizer(resourceContext) | 95 | : Sink::Synchronizer(resourceContext) |
@@ -432,7 +433,7 @@ public: | |||
432 | 433 | ||
433 | KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE | 434 | KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE |
434 | { | 435 | { |
435 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); | 436 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, &mSessionCache); |
436 | if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { | 437 | if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { |
437 | return login(imap) | 438 | return login(imap) |
438 | .then([=] { | 439 | .then([=] { |
@@ -528,7 +529,7 @@ public: | |||
528 | 529 | ||
529 | KAsync::Job<QByteArray> replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) Q_DECL_OVERRIDE | 530 | KAsync::Job<QByteArray> replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) Q_DECL_OVERRIDE |
530 | { | 531 | { |
531 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); | 532 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, &mSessionCache); |
532 | auto login = imap->login(mUser, mPassword); | 533 | auto login = imap->login(mUser, mPassword); |
533 | KAsync::Job<QByteArray> job = KAsync::null<QByteArray>(); | 534 | KAsync::Job<QByteArray> job = KAsync::null<QByteArray>(); |
534 | if (operation == Sink::Operation_Creation) { | 535 | if (operation == Sink::Operation_Creation) { |
@@ -607,7 +608,7 @@ public: | |||
607 | 608 | ||
608 | KAsync::Job<QByteArray> replay(const ApplicationDomain::Folder &folder, Sink::Operation operation, const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) Q_DECL_OVERRIDE | 609 | KAsync::Job<QByteArray> replay(const ApplicationDomain::Folder &folder, Sink::Operation operation, const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) Q_DECL_OVERRIDE |
609 | { | 610 | { |
610 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); | 611 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, &mSessionCache); |
611 | auto login = imap->login(mUser, mPassword); | 612 | auto login = imap->login(mUser, mPassword); |
612 | if (operation == Sink::Operation_Creation) { | 613 | if (operation == Sink::Operation_Creation) { |
613 | QString parentFolder; | 614 | QString parentFolder; |
@@ -684,6 +685,7 @@ public: | |||
684 | QString mUser; | 685 | QString mUser; |
685 | QString mPassword; | 686 | QString mPassword; |
686 | QByteArray mResourceInstanceIdentifier; | 687 | QByteArray mResourceInstanceIdentifier; |
688 | Imap::SessionCache mSessionCache; | ||
687 | }; | 689 | }; |
688 | 690 | ||
689 | class ImapInspector : public Sink::Inspector { | 691 | class ImapInspector : public Sink::Inspector { |
@@ -908,3 +910,4 @@ void ImapResourceFactory::removeDataFromDisk(const QByteArray &instanceIdentifie | |||
908 | ImapResource::removeFromDisk(instanceIdentifier); | 910 | ImapResource::removeFromDisk(instanceIdentifier); |
909 | } | 911 | } |
910 | 912 | ||
913 | #include "imapresource.moc" | ||