summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-08-25 18:21:15 -0600
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-08-25 18:21:15 -0600
commitea75d4bdba79d2a879c2ed31564928d4ef3cd9b1 (patch)
tree468831622a6924b00df160b228733803c29032a7
parent8e14799f43ea51a6d9f195c56ca4f0c0439d4039 (diff)
downloadsink-ea75d4bdba79d2a879c2ed31564928d4ef3cd9b1.tar.gz
sink-ea75d4bdba79d2a879c2ed31564928d4ef3cd9b1.zip
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.
-rw-r--r--common/domain/applicationdomaintype.h4
-rw-r--r--common/resourceaccess.cpp2
-rw-r--r--common/synchronizer.cpp2
-rw-r--r--tests/accountstest.cpp2
-rw-r--r--tests/resourceconfigtest.cpp2
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 {
118 * The status of an account or resource. 118 * The status of an account or resource.
119 * 119 *
120 * It is set as follows: 120 * It is set as follows:
121 * * By default the status is offline. 121 * * By default the status is no status.
122 * * If a connection to the server failed the status is Offline.
122 * * If a connection to the server could be established the status is Connected. 123 * * If a connection to the server could be established the status is Connected.
123 * * If an error occurred that keeps the resource from operating (so non transient), the resource enters the error state. 124 * * If an error occurred that keeps the resource from operating (so non transient), the resource enters the error state.
124 * * If a long running operation is started the resource goes to the busy state (and return to the previous state after that). 125 * * If a long running operation is started the resource goes to the busy state (and return to the previous state after that).
125 */ 126 */
126enum SINK_EXPORT Status { 127enum SINK_EXPORT Status {
128 NoStatus,
127 OfflineStatus, 129 OfflineStatus,
128 ConnectedStatus, 130 ConnectedStatus,
129 BusyStatus, 131 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<void> ResourceAccess::Private::initializeSocket()
232ResourceAccess::ResourceAccess(const QByteArray &resourceInstanceIdentifier, const QByteArray &resourceType) 232ResourceAccess::ResourceAccess(const QByteArray &resourceInstanceIdentifier, const QByteArray &resourceType)
233 : ResourceAccessInterface(), d(new Private(resourceType, resourceInstanceIdentifier, this)) 233 : ResourceAccessInterface(), d(new Private(resourceType, resourceInstanceIdentifier, this))
234{ 234{
235 mResourceStatus = Sink::ApplicationDomain::OfflineStatus; 235 mResourceStatus = Sink::ApplicationDomain::NoStatus;
236 SinkTrace() << "Starting access"; 236 SinkTrace() << "Starting access";
237} 237}
238 238
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)
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
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:
139 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkAccount>(query); 139 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkAccount>(query);
140 QTRY_COMPARE(model->rowCount(QModelIndex()), 1); 140 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
141 auto account = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>(); 141 auto account = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>();
142 QCOMPARE(account->getStatus(), static_cast<int>(Sink::ApplicationDomain::OfflineStatus)); 142 QCOMPARE(account->getStatus(), static_cast<int>(Sink::ApplicationDomain::NoStatus));
143 143
144 //Synchronize to connect 144 //Synchronize to connect
145 VERIFYEXEC(Sink::Store::synchronize(Query().resourceFilter(res.identifier()))); 145 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:
91 auto model = Sink::Store::loadModel<SinkResource>(query); 91 auto model = Sink::Store::loadModel<SinkResource>(query);
92 QTRY_COMPARE(model->rowCount(QModelIndex()), 1); 92 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
93 auto resource = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<SinkResource::Ptr>(); 93 auto resource = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<SinkResource::Ptr>();
94 QCOMPARE(resource->getStatus(), static_cast<int>(OfflineStatus)); 94 QCOMPARE(resource->getStatus(), static_cast<int>(NoStatus));
95 95
96 //Synchronize to connect 96 //Synchronize to connect
97 VERIFYEXEC(Sink::Store::synchronize(query)); 97 VERIFYEXEC(Sink::Store::synchronize(query));