summaryrefslogtreecommitdiffstats
path: root/common/domain
diff options
context:
space:
mode:
Diffstat (limited to 'common/domain')
-rw-r--r--common/domain/applicationdomaintype.cpp17
-rw-r--r--common/domain/applicationdomaintype.h15
-rw-r--r--common/domain/applicationdomaintype_p.h2
3 files changed, 30 insertions, 4 deletions
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp
index 3718f77..ee70c35 100644
--- a/common/domain/applicationdomaintype.cpp
+++ b/common/domain/applicationdomaintype.cpp
@@ -34,7 +34,13 @@ QDebug Sink::ApplicationDomain::operator<< (QDebug d, const Sink::ApplicationDom
34QDebug Sink::ApplicationDomain::operator<< (QDebug d, const Sink::ApplicationDomain::ApplicationDomainType &type) 34QDebug Sink::ApplicationDomain::operator<< (QDebug d, const Sink::ApplicationDomain::ApplicationDomainType &type)
35{ 35{
36 d << "ApplicationDomainType(\n"; 36 d << "ApplicationDomainType(\n";
37 auto properties = type.mAdaptor->availableProperties(); 37 auto properties = [&] {
38 if (!type.changedProperties().isEmpty()) {
39 return type.changedProperties();
40 } else {
41 return type.mAdaptor->availableProperties();
42 }
43 }();
38 std::sort(properties.begin(), properties.end()); 44 std::sort(properties.begin(), properties.end());
39 d << " " << "Id: " << "\t" << type.identifier() << "\n"; 45 d << " " << "Id: " << "\t" << type.identifier() << "\n";
40 d << " " << "Resource: " << "\t" << type.resourceInstanceIdentifier() << "\n"; 46 d << " " << "Resource: " << "\t" << type.resourceInstanceIdentifier() << "\n";
@@ -216,8 +222,13 @@ QVariant ApplicationDomainType::getProperty(const QByteArray &key) const
216void ApplicationDomainType::setProperty(const QByteArray &key, const QVariant &value) 222void ApplicationDomainType::setProperty(const QByteArray &key, const QVariant &value)
217{ 223{
218 Q_ASSERT(mAdaptor); 224 Q_ASSERT(mAdaptor);
219 mChangeSet->insert(key); 225 auto existing = mAdaptor->getProperty(key);
220 mAdaptor->setProperty(key, value); 226 if (existing.isValid() && existing == value) {
227 SinkTrace() << "Tried to set property that is still the same: " << key << value;
228 } else {
229 mChangeSet->insert(key);
230 mAdaptor->setProperty(key, value);
231 }
221} 232}
222 233
223void ApplicationDomainType::setResource(const QByteArray &identifier) 234void ApplicationDomainType::setResource(const QByteArray &identifier)
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h
index 602d54c..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 {
@@ -118,12 +119,14 @@ enum SINK_EXPORT SyncStatus {
118 * The status of an account or resource. 119 * The status of an account or resource.
119 * 120 *
120 * It is set as follows: 121 * It is set as follows:
121 * * By default the status is offline. 122 * * By default the status is no status.
123 * * 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. 124 * * 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. 125 * * 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). 126 * * If a long running operation is started the resource goes to the busy state (and return to the previous state after that).
125 */ 127 */
126enum SINK_EXPORT Status { 128enum SINK_EXPORT Status {
129 NoStatus,
127 OfflineStatus, 130 OfflineStatus,
128 ConnectedStatus, 131 ConnectedStatus,
129 BusyStatus, 132 BusyStatus,
@@ -270,7 +273,17 @@ public:
270 bool hasProperty(const QByteArray &key) const; 273 bool hasProperty(const QByteArray &key) const;
271 274
272 QVariant getProperty(const QByteArray &key) const; 275 QVariant getProperty(const QByteArray &key) const;
276
277 /**
278 * Set a property and record a changed property
279 *
280 * If the propery is available and did not change the call will be ignored.
281 */
273 void setProperty(const QByteArray &key, const QVariant &value); 282 void setProperty(const QByteArray &key, const QVariant &value);
283
284 /**
285 * Convenience method to set a reference property.
286 */
274 void setProperty(const QByteArray &key, const ApplicationDomainType &value); 287 void setProperty(const QByteArray &key, const ApplicationDomainType &value);
275 288
276 QByteArray getBlobProperty(const QByteArray &key) const; 289 QByteArray getBlobProperty(const QByteArray &key) const;
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 {
45 } else { 45 } else {
46 Q_ASSERT(false); 46 Q_ASSERT(false);
47 } 47 }
48 //Silence compiler warning
49 return Func<Sink::ApplicationDomain::Mail>{}(std::forward<Args...>(args...));
48 } 50 }
49}; 51};