diff options
Diffstat (limited to 'common/synchronizer.cpp')
-rw-r--r-- | common/synchronizer.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index 3b32e68..46d3980 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp | |||
@@ -40,7 +40,7 @@ Synchronizer::Synchronizer(const Sink::ResourceContext &context) | |||
40 | mSyncStorage(Sink::storageLocation(), mResourceContext.instanceId() + ".synchronization", Sink::Storage::DataStore::DataStore::ReadWrite), | 40 | mSyncStorage(Sink::storageLocation(), mResourceContext.instanceId() + ".synchronization", Sink::Storage::DataStore::DataStore::ReadWrite), |
41 | mSyncInProgress(false) | 41 | mSyncInProgress(false) |
42 | { | 42 | { |
43 | mCurrentState.push(ApplicationDomain::Status::OfflineStatus); | 43 | mCurrentState.push(ApplicationDomain::Status::NoStatus); |
44 | SinkTraceCtx(mLogCtx) << "Starting synchronizer: " << mResourceContext.resourceType << mResourceContext.instanceId(); | 44 | SinkTraceCtx(mLogCtx) << "Starting synchronizer: " << mResourceContext.resourceType << mResourceContext.instanceId(); |
45 | } | 45 | } |
46 | 46 | ||
@@ -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); |
@@ -593,17 +596,13 @@ KAsync::Job<void> Synchronizer::replay(const QByteArray &type, const QByteArray | |||
593 | KAsync::Job<QByteArray> job = KAsync::null<QByteArray>(); | 596 | KAsync::Job<QByteArray> job = KAsync::null<QByteArray>(); |
594 | //TODO This requires supporting every domain type here as well. Can we solve this better so we can do the dispatch somewhere centrally? | 597 | //TODO This requires supporting every domain type here as well. Can we solve this better so we can do the dispatch somewhere centrally? |
595 | if (type == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { | 598 | if (type == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { |
596 | auto folder = store().readEntity<ApplicationDomain::Folder>(key); | 599 | job = replay(store().readEntity<ApplicationDomain::Folder>(key), operation, oldRemoteId, modifiedProperties); |
597 | job = replay(folder, operation, oldRemoteId, modifiedProperties); | ||
598 | } else if (type == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) { | 600 | } else if (type == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) { |
599 | auto mail = store().readEntity<ApplicationDomain::Mail>(key); | 601 | job = replay(store().readEntity<ApplicationDomain::Mail>(key), operation, oldRemoteId, modifiedProperties); |
600 | job = replay(mail, operation, oldRemoteId, modifiedProperties); | ||
601 | } else if (type == ApplicationDomain::getTypeName<ApplicationDomain::Contact>()) { | 602 | } else if (type == ApplicationDomain::getTypeName<ApplicationDomain::Contact>()) { |
602 | auto mail = store().readEntity<ApplicationDomain::Contact>(key); | 603 | job = replay(store().readEntity<ApplicationDomain::Contact>(key), operation, oldRemoteId, modifiedProperties); |
603 | job = replay(mail, operation, oldRemoteId, modifiedProperties); | ||
604 | } else if (type == ApplicationDomain::getTypeName<ApplicationDomain::Addressbook>()) { | 604 | } else if (type == ApplicationDomain::getTypeName<ApplicationDomain::Addressbook>()) { |
605 | auto mail = store().readEntity<ApplicationDomain::Addressbook>(key); | 605 | job = replay(store().readEntity<ApplicationDomain::Addressbook>(key), operation, oldRemoteId, modifiedProperties); |
606 | job = replay(mail, operation, oldRemoteId, modifiedProperties); | ||
607 | } else { | 606 | } else { |
608 | SinkErrorCtx(mLogCtx) << "Replayed unknown type: " << type; | 607 | SinkErrorCtx(mLogCtx) << "Replayed unknown type: " << type; |
609 | } | 608 | } |