summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/domain/applicationdomaintype.h1
-rw-r--r--common/synchronizer.cpp5
-rw-r--r--examples/imapresource/imapresource.cpp2
-rw-r--r--examples/imapresource/imapserverproxy.cpp32
-rw-r--r--examples/imapresource/imapserverproxy.h4
5 files changed, 27 insertions, 17 deletions
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h
index 518f6d5..f7fd07e 100644
--- a/common/domain/applicationdomaintype.h
+++ b/common/domain/applicationdomaintype.h
@@ -101,6 +101,7 @@ enum SINK_EXPORT ErrorCode {
101 LoginError, 101 LoginError,
102 ConfigurationError, 102 ConfigurationError,
103 TransmissionError, 103 TransmissionError,
104 ConnectionLostError,
104}; 105};
105 106
106enum SINK_EXPORT SuccessCode { 107enum SINK_EXPORT SuccessCode {
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp
index b6e33d5..46d3980 100644
--- a/common/synchronizer.cpp
+++ b/common/synchronizer.cpp
@@ -344,8 +344,11 @@ void Synchronizer::setStatusFromResult(const KAsync::Error &error, const QString
344 } else if (error.errorCode == ApplicationDomain::LoginError) { 344 } else if (error.errorCode == ApplicationDomain::LoginError) {
345 //If we failed to login altough we could connect that indicates a problem with our setup. 345 //If we failed to login altough we could connect that indicates a problem with our setup.
346 setStatus(ApplicationDomain::ErrorStatus, s, requestId); 346 setStatus(ApplicationDomain::ErrorStatus, s, requestId);
347 } else if (error.errorCode == ApplicationDomain::ConnectionLostError) {
348 //We've lost the connection so we assume the connection to the server broke.
349 setStatus(ApplicationDomain::OfflineStatus, s, requestId);
347 } 350 }
348 //We don't know what kind of error this was, so we assume it's transient and don't change ou status. 351 //We don't know what kind of error this was, so we assume it's transient and don't change our status.
349 } else { 352 } else {
350 //An operation against the server worked, so we're probably online. 353 //An operation against the server worked, so we're probably online.
351 setStatus(ApplicationDomain::ConnectedStatus, s, requestId); 354 setStatus(ApplicationDomain::ConnectedStatus, s, requestId);
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp
index 0c0c134..3ae7fd7 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -511,6 +511,8 @@ public:
511 return {ApplicationDomain::LoginError, error.errorMessage}; 511 return {ApplicationDomain::LoginError, error.errorMessage};
512 case Imap::HostNotFoundError: 512 case Imap::HostNotFoundError:
513 return {ApplicationDomain::NoServerError, error.errorMessage}; 513 return {ApplicationDomain::NoServerError, error.errorMessage};
514 case Imap::ConnectionLost:
515 return {ApplicationDomain::ConnectionLostError, error.errorMessage};
514 default: 516 default:
515 return {ApplicationDomain::UnknownError, error.errorMessage}; 517 return {ApplicationDomain::UnknownError, error.errorMessage};
516 } 518 }
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp
index 538105c..a0f0970 100644
--- a/examples/imapresource/imapserverproxy.cpp
+++ b/examples/imapresource/imapserverproxy.cpp
@@ -80,6 +80,21 @@ static KAsync::Job<T> runJob(KJob *job, const std::function<T(KJob*)> &f)
80 }); 80 });
81} 81}
82 82
83static int translateImapError(int error)
84{
85 switch (error) {
86 case KJob::UserDefinedError:
87 return Imap::ConnectionLost;
88 case KIMAP2::LoginJob::ErrorCode::ERR_HOST_NOT_FOUND:
89 return Imap::HostNotFoundError;
90 case KIMAP2::LoginJob::ErrorCode::ERR_COULD_NOT_CONNECT:
91 return Imap::CouldNotConnectError;
92 case KIMAP2::LoginJob::ErrorCode::ERR_SSL_HANDSHAKE_FAILED:
93 return Imap::SslHandshakeError;
94 }
95 return Imap::UnknownError;
96}
97
83static KAsync::Job<void> runJob(KJob *job) 98static KAsync::Job<void> runJob(KJob *job)
84{ 99{
85 return KAsync::start<void>([job](KAsync::Future<void> &future) { 100 return KAsync::start<void>([job](KAsync::Future<void> &future) {
@@ -87,7 +102,8 @@ static KAsync::Job<void> runJob(KJob *job)
87 SinkTrace() << "Job done: " << job->metaObject()->className(); 102 SinkTrace() << "Job done: " << job->metaObject()->className();
88 if (job->error()) { 103 if (job->error()) {
89 SinkWarning() << "Job failed: " << job->errorString() << job->metaObject()->className(); 104 SinkWarning() << "Job failed: " << job->errorString() << job->metaObject()->className();
90 future.setError(job->error(), job->errorString()); 105 auto proxyError = translateImapError(job->error());
106 future.setError(proxyError, job->errorString());
91 } else { 107 } else {
92 future.setFinished(); 108 future.setFinished();
93 } 109 }
@@ -166,20 +182,6 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString
166 // SinkTrace() << "Found personal namespaces: " << mNamespaces.personal; 182 // SinkTrace() << "Found personal namespaces: " << mNamespaces.personal;
167 // SinkTrace() << "Found shared namespaces: " << mNamespaces.shared; 183 // SinkTrace() << "Found shared namespaces: " << mNamespaces.shared;
168 // SinkTrace() << "Found user namespaces: " << mNamespaces.user; 184 // SinkTrace() << "Found user namespaces: " << mNamespaces.user;
169 }).then([=] (const KAsync::Error &error) {
170 if (error) {
171 switch (error.errorCode) {
172 case KIMAP2::LoginJob::ErrorCode::ERR_HOST_NOT_FOUND:
173 return KAsync::error(HostNotFoundError, "Host not found: " + error.errorMessage);
174 case KIMAP2::LoginJob::ErrorCode::ERR_COULD_NOT_CONNECT:
175 return KAsync::error(CouldNotConnectError, "Failed to connect: " + error.errorMessage);
176 case KIMAP2::LoginJob::ErrorCode::ERR_SSL_HANDSHAKE_FAILED:
177 return KAsync::error(SslHandshakeError, "Ssl handshake failed: " + error.errorMessage);
178 default:
179 return KAsync::error(error);
180 }
181 }
182 return KAsync::null();
183 }); 185 });
184} 186}
185 187
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h
index 82f4f58..f9b854b 100644
--- a/examples/imapresource/imapserverproxy.h
+++ b/examples/imapresource/imapserverproxy.h
@@ -33,7 +33,9 @@ enum ErrorCode {
33 NoError, 33 NoError,
34 HostNotFoundError, 34 HostNotFoundError,
35 CouldNotConnectError, 35 CouldNotConnectError,
36 SslHandshakeError 36 SslHandshakeError,
37 ConnectionLost,
38 UnknownError
37}; 39};
38 40
39namespace Flags 41namespace Flags