From 5d197dec9dc8f5c8ef4acd72555c32108404c4ae Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 27 Jul 2017 15:44:32 -0600 Subject: Only print modified properties if we have any. --- common/domain/applicationdomaintype.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'common/domain') diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index 3718f77..2050fac 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp @@ -34,7 +34,13 @@ QDebug Sink::ApplicationDomain::operator<< (QDebug d, const Sink::ApplicationDom QDebug Sink::ApplicationDomain::operator<< (QDebug d, const Sink::ApplicationDomain::ApplicationDomainType &type) { d << "ApplicationDomainType(\n"; - auto properties = type.mAdaptor->availableProperties(); + auto properties = [&] { + if (!type.changedProperties().isEmpty()) { + return type.changedProperties(); + } else { + return type.mAdaptor->availableProperties(); + } + }(); std::sort(properties.begin(), properties.end()); d << " " << "Id: " << "\t" << type.identifier() << "\n"; d << " " << "Resource: " << "\t" << type.resourceInstanceIdentifier() << "\n"; -- cgit v1.2.3 From 63290ccce102495427a26e689725e565a03ae77a Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 27 Jul 2017 15:45:12 -0600 Subject: Skip modifications that do nothing. This allows us to i.e. blindly mark mails as read in kube, with the modification automatically being dropped if it doesn't do anything useful. --- common/domain/applicationdomaintype.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'common/domain') diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index 2050fac..ee70c35 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp @@ -222,8 +222,13 @@ QVariant ApplicationDomainType::getProperty(const QByteArray &key) const void ApplicationDomainType::setProperty(const QByteArray &key, const QVariant &value) { Q_ASSERT(mAdaptor); - mChangeSet->insert(key); - mAdaptor->setProperty(key, value); + auto existing = mAdaptor->getProperty(key); + if (existing.isValid() && existing == value) { + SinkTrace() << "Tried to set property that is still the same: " << key << value; + } else { + mChangeSet->insert(key); + mAdaptor->setProperty(key, value); + } } void ApplicationDomainType::setResource(const QByteArray &identifier) -- cgit v1.2.3 From 5275b0f173579162176e2340cbb9eaedafe8334a Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 27 Jul 2017 16:00:50 -0600 Subject: Adjusted docs and test. --- common/domain/applicationdomaintype.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'common/domain') diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 602d54c..1250455 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -270,7 +270,17 @@ public: bool hasProperty(const QByteArray &key) const; QVariant getProperty(const QByteArray &key) const; + + /** + * Set a property and record a changed property + * + * If the propery is available and did not change the call will be ignored. + */ void setProperty(const QByteArray &key, const QVariant &value); + + /** + * Convenience method to set a reference property. + */ void setProperty(const QByteArray &key, const ApplicationDomainType &value); QByteArray getBlobProperty(const QByteArray &key) const; -- cgit v1.2.3 From 1e9879479ea22017266de596db61d06d3950941b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 11 Aug 2017 20:17:16 -0600 Subject: Silence the compiler warning --- common/domain/applicationdomaintype_p.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common/domain') diff --git a/common/domain/applicationdomaintype_p.h b/common/domain/applicationdomaintype_p.h index a5a6b1d..a60df38 100644 --- a/common/domain/applicationdomaintype_p.h +++ b/common/domain/applicationdomaintype_p.h @@ -45,5 +45,7 @@ struct TypeHelper { } else { Q_ASSERT(false); } + //Silence compiler warning + return Func{}(std::forward(args...)); } }; -- cgit v1.2.3 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 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'common/domain') 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, -- cgit v1.2.3 From 1ba34f8b16cd06a74ff96dfae803ce4b0521652b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 28 Aug 2017 17:19:51 -0600 Subject: Detect connection lost so we can go to offline state kimap should really have better error codes... --- common/domain/applicationdomaintype.h | 1 + 1 file changed, 1 insertion(+) (limited to 'common/domain') 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 { LoginError, ConfigurationError, TransmissionError, + ConnectionLostError, }; enum SINK_EXPORT SuccessCode { -- cgit v1.2.3