summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/imapresource/imapresource.cpp17
-rw-r--r--examples/imapresource/imapserverproxy.cpp10
-rw-r--r--examples/imapresource/imapserverproxy.h5
3 files changed, 30 insertions, 2 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp
index b27c2b2..ba0251c 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -469,6 +469,19 @@ public:
469 } 469 }
470 } 470 }
471 471
472 KAsync::Error getError(const KAsync::Error &error)
473 {
474 if (error) {
475 if (error.errorCode == Imap::CouldNotConnectError) {
476 return {ApplicationDomain::LoginError, error.errorMessage};
477 } else if (error.errorCode == Imap::SslHandshakeError) {
478 return {ApplicationDomain::LoginError, error.errorMessage};
479 }
480 return {ApplicationDomain::UnknownError, error.errorMessage};
481 }
482 return {};
483 }
484
472 KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE 485 KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE
473 { 486 {
474 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, &mSessionCache); 487 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, &mSessionCache);
@@ -488,7 +501,7 @@ public:
488 SinkWarning() << "Error during folder sync: " << error.errorMessage; 501 SinkWarning() << "Error during folder sync: " << error.errorMessage;
489 } 502 }
490 return imap->logout() 503 return imap->logout()
491 .then(KAsync::error(ApplicationDomain::LoginError, error.errorMessage)); 504 .then(KAsync::error(getError(error)));
492 }); 505 });
493 } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) { 506 } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) {
494 //TODO 507 //TODO
@@ -560,7 +573,7 @@ public:
560 SinkWarning() << "Error during sync: " << error.errorMessage; 573 SinkWarning() << "Error during sync: " << error.errorMessage;
561 } 574 }
562 return imap->logout() 575 return imap->logout()
563 .then(KAsync::error(ApplicationDomain::LoginError, error.errorMessage)); 576 .then(KAsync::error(getError(error)));
564 }); 577 });
565 } 578 }
566 return KAsync::error<void>("Nothing to do"); 579 return KAsync::error<void>("Nothing to do");
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp
index dabdd8e..a856576 100644
--- a/examples/imapresource/imapserverproxy.cpp
+++ b/examples/imapresource/imapserverproxy.cpp
@@ -159,6 +159,16 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString
159 // SinkTrace() << "Found personal namespaces: " << mNamespaces.personal; 159 // SinkTrace() << "Found personal namespaces: " << mNamespaces.personal;
160 // SinkTrace() << "Found shared namespaces: " << mNamespaces.shared; 160 // SinkTrace() << "Found shared namespaces: " << mNamespaces.shared;
161 // SinkTrace() << "Found user namespaces: " << mNamespaces.user; 161 // SinkTrace() << "Found user namespaces: " << mNamespaces.user;
162 }).then([=] (const KAsync::Error &error) {
163 if (error) {
164 if (error.errorCode == KIMAP2::LoginJob::ErrorCode::ERR_COULD_NOT_CONNECT) {
165 return KAsync::error(CouldNotConnectError, "Failed to connect: " + error.errorMessage);
166 } else if (error.errorCode == KIMAP2::LoginJob::ErrorCode::ERR_SSL_HANDSHAKE_FAILED) {
167 return KAsync::error(SslHandshakeError, "Ssl handshake failed: " + error.errorMessage);
168 }
169 return KAsync::error(error);
170 }
171 return KAsync::null();
162 }); 172 });
163} 173}
164 174
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h
index 6eb47ee..cae3105 100644
--- a/examples/imapresource/imapserverproxy.h
+++ b/examples/imapresource/imapserverproxy.h
@@ -29,6 +29,11 @@
29 29
30namespace Imap { 30namespace Imap {
31 31
32enum ErrorCode {
33 CouldNotConnectError,
34 SslHandshakeError
35};
36
32namespace Flags 37namespace Flags
33{ 38{
34 /// The flag for a message being seen (i.e. opened by user). 39 /// The flag for a message being seen (i.e. opened by user).