diff options
Diffstat (limited to 'examples/imapresource/imapresource.cpp')
-rw-r--r-- | examples/imapresource/imapresource.cpp | 17 |
1 files changed, 15 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"); |