From ea75d4bdba79d2a879c2ed31564928d4ef3cd9b1 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 25 Aug 2017 18:21:15 -0600 Subject: Default to NoStatus for resources until we know more. This allows the aggregation to ignore resources where we don't have any status information yet, so the account doesn't always end up being offline. --- common/domain/applicationdomaintype.h | 4 +++- common/resourceaccess.cpp | 2 +- common/synchronizer.cpp | 2 +- tests/accountstest.cpp | 2 +- tests/resourceconfigtest.cpp | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 1250455..518f6d5 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -118,12 +118,14 @@ enum SINK_EXPORT SyncStatus { * The status of an account or resource. * * It is set as follows: - * * By default the status is offline. + * * By default the status is no status. + * * If a connection to the server failed the status is Offline. * * If a connection to the server could be established the status is Connected. * * If an error occurred that keeps the resource from operating (so non transient), the resource enters the error state. * * If a long running operation is started the resource goes to the busy state (and return to the previous state after that). */ enum SINK_EXPORT Status { + NoStatus, OfflineStatus, ConnectedStatus, BusyStatus, diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 808d892..35fa46c 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp @@ -232,7 +232,7 @@ KAsync::Job ResourceAccess::Private::initializeSocket() ResourceAccess::ResourceAccess(const QByteArray &resourceInstanceIdentifier, const QByteArray &resourceType) : ResourceAccessInterface(), d(new Private(resourceType, resourceInstanceIdentifier, this)) { - mResourceStatus = Sink::ApplicationDomain::OfflineStatus; + mResourceStatus = Sink::ApplicationDomain::NoStatus; SinkTrace() << "Starting access"; } diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index d6b1c1f..b6e33d5 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -40,7 +40,7 @@ Synchronizer::Synchronizer(const Sink::ResourceContext &context) mSyncStorage(Sink::storageLocation(), mResourceContext.instanceId() + ".synchronization", Sink::Storage::DataStore::DataStore::ReadWrite), mSyncInProgress(false) { - mCurrentState.push(ApplicationDomain::Status::OfflineStatus); + mCurrentState.push(ApplicationDomain::Status::NoStatus); SinkTraceCtx(mLogCtx) << "Starting synchronizer: " << mResourceContext.resourceType << mResourceContext.instanceId(); } diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp index 0ab18ef..cc67645 100644 --- a/tests/accountstest.cpp +++ b/tests/accountstest.cpp @@ -139,7 +139,7 @@ private slots: auto model = Sink::Store::loadModel(query); QTRY_COMPARE(model->rowCount(QModelIndex()), 1); auto account = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value(); - QCOMPARE(account->getStatus(), static_cast(Sink::ApplicationDomain::OfflineStatus)); + QCOMPARE(account->getStatus(), static_cast(Sink::ApplicationDomain::NoStatus)); //Synchronize to connect VERIFYEXEC(Sink::Store::synchronize(Query().resourceFilter(res.identifier()))); diff --git a/tests/resourceconfigtest.cpp b/tests/resourceconfigtest.cpp index df98a61..78a0d4c 100644 --- a/tests/resourceconfigtest.cpp +++ b/tests/resourceconfigtest.cpp @@ -91,7 +91,7 @@ private slots: auto model = Sink::Store::loadModel(query); QTRY_COMPARE(model->rowCount(QModelIndex()), 1); auto resource = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value(); - QCOMPARE(resource->getStatus(), static_cast(OfflineStatus)); + QCOMPARE(resource->getStatus(), static_cast(NoStatus)); //Synchronize to connect VERIFYEXEC(Sink::Store::synchronize(query)); -- cgit v1.2.3