diff options
Diffstat (limited to 'common/domain/applicationdomaintype.h')
-rw-r--r-- | common/domain/applicationdomaintype.h | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 8a0daef..b4db54e 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -62,16 +62,6 @@ | |||
62 | void setStatus##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ | 62 | void setStatus##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ |
63 | TYPE get##NAME() const { return getProperty(NAME::name).value<TYPE>(); } \ | 63 | TYPE get##NAME() const { return getProperty(NAME::name).value<TYPE>(); } \ |
64 | 64 | ||
65 | #define SINK_BLOB_PROPERTY(NAME, LOWERCASENAME) \ | ||
66 | struct NAME { \ | ||
67 | static constexpr const char *name = #LOWERCASENAME; \ | ||
68 | typedef BLOB Type; \ | ||
69 | }; \ | ||
70 | void set##NAME(const QByteArray &value) { setBlobProperty(NAME::name, value); } \ | ||
71 | void set##NAME##Path(const QString &path) { setProperty(NAME::name, QVariant::fromValue(BLOB{path})); } \ | ||
72 | QByteArray get##NAME() const { return getBlobProperty(NAME::name); } \ | ||
73 | QString get##NAME##Path() const { return getProperty(NAME::name).value<BLOB>().value; } \ | ||
74 | |||
75 | #define SINK_REFERENCE_PROPERTY(TYPE, NAME, LOWERCASENAME) \ | 65 | #define SINK_REFERENCE_PROPERTY(TYPE, NAME, LOWERCASENAME) \ |
76 | struct NAME { \ | 66 | struct NAME { \ |
77 | static constexpr const char *name = #LOWERCASENAME; \ | 67 | static constexpr const char *name = #LOWERCASENAME; \ |
@@ -145,23 +135,6 @@ struct SINK_EXPORT Progress { | |||
145 | /** | 135 | /** |
146 | * Internal type. | 136 | * Internal type. |
147 | * | 137 | * |
148 | * Represents a BLOB property. | ||
149 | */ | ||
150 | struct BLOB { | ||
151 | BLOB() = default; | ||
152 | BLOB(const BLOB &) = default; | ||
153 | BLOB(const QString &id) : value(id) {}; | ||
154 | ~BLOB() = default; | ||
155 | bool operator==(const BLOB &other) const { | ||
156 | return value == other.value && isExternal == other.isExternal; | ||
157 | } | ||
158 | QString value; | ||
159 | bool isExternal = true; | ||
160 | }; | ||
161 | |||
162 | /** | ||
163 | * Internal type. | ||
164 | * | ||
165 | * Represents a reference to another entity in the same resource. | 138 | * Represents a reference to another entity in the same resource. |
166 | */ | 139 | */ |
167 | struct Reference { | 140 | struct Reference { |
@@ -179,7 +152,7 @@ struct Reference { | |||
179 | QByteArray value; | 152 | QByteArray value; |
180 | }; | 153 | }; |
181 | 154 | ||
182 | void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::ApplicationDomain::BufferAdaptor &memoryAdaptor, const QList<QByteArray> &properties = QList<QByteArray>(), bool copyBlobs = false, bool pruneReferences = false); | 155 | void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::ApplicationDomain::BufferAdaptor &memoryAdaptor, const QList<QByteArray> &properties = QList<QByteArray>(), bool pruneReferences = false); |
183 | 156 | ||
184 | /** | 157 | /** |
185 | * The domain type interface has two purposes: | 158 | * The domain type interface has two purposes: |
@@ -223,7 +196,7 @@ public: | |||
223 | static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType, const QList<QByteArray> properties = QList<QByteArray>()) | 196 | static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType, const QList<QByteArray> properties = QList<QByteArray>()) |
224 | { | 197 | { |
225 | auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(); | 198 | auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(); |
226 | copyBuffer(*(domainType.mAdaptor), *memoryAdaptor, properties, false, false); | 199 | copyBuffer(*(domainType.mAdaptor), *memoryAdaptor, properties, false); |
227 | //mIdentifier internally still refers to the memory-mapped memory, we need to copy the memory or it will become invalid | 200 | //mIdentifier internally still refers to the memory-mapped memory, we need to copy the memory or it will become invalid |
228 | return QSharedPointer<DomainType>::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); | 201 | return QSharedPointer<DomainType>::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); |
229 | } | 202 | } |
@@ -236,7 +209,7 @@ public: | |||
236 | { | 209 | { |
237 | auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(); | 210 | auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(); |
238 | Q_ASSERT(domainType.mAdaptor); | 211 | Q_ASSERT(domainType.mAdaptor); |
239 | copyBuffer(*(domainType.mAdaptor), *memoryAdaptor, properties, true, true); | 212 | copyBuffer(*(domainType.mAdaptor), *memoryAdaptor, properties, true); |
240 | return QSharedPointer<DomainType>::create(QByteArray{}, QByteArray{}, 0, memoryAdaptor); | 213 | return QSharedPointer<DomainType>::create(QByteArray{}, QByteArray{}, 0, memoryAdaptor); |
241 | } | 214 | } |
242 | 215 | ||
@@ -287,9 +260,6 @@ public: | |||
287 | */ | 260 | */ |
288 | void setProperty(const QByteArray &key, const ApplicationDomainType &value); | 261 | void setProperty(const QByteArray &key, const ApplicationDomainType &value); |
289 | 262 | ||
290 | QByteArray getBlobProperty(const QByteArray &key) const; | ||
291 | void setBlobProperty(const QByteArray &key, const QByteArray &value); | ||
292 | |||
293 | void setChangedProperties(const QSet<QByteArray> &changeset); | 263 | void setChangedProperties(const QSet<QByteArray> &changeset); |
294 | QByteArrayList changedProperties() const; | 264 | QByteArrayList changedProperties() const; |
295 | QByteArrayList availableProperties() const; | 265 | QByteArrayList availableProperties() const; |
@@ -321,7 +291,6 @@ inline bool operator==(const ApplicationDomainType& lhs, const ApplicationDomain | |||
321 | 291 | ||
322 | SINK_EXPORT QDebug operator<< (QDebug d, const ApplicationDomainType &type); | 292 | SINK_EXPORT QDebug operator<< (QDebug d, const ApplicationDomainType &type); |
323 | SINK_EXPORT QDebug operator<< (QDebug d, const Reference &ref); | 293 | SINK_EXPORT QDebug operator<< (QDebug d, const Reference &ref); |
324 | SINK_EXPORT QDebug operator<< (QDebug d, const BLOB &blob); | ||
325 | 294 | ||
326 | 295 | ||
327 | struct SINK_EXPORT SinkAccount : public ApplicationDomainType { | 296 | struct SINK_EXPORT SinkAccount : public ApplicationDomainType { |
@@ -439,7 +408,6 @@ struct SINK_EXPORT Mail : public Entity { | |||
439 | SINK_PROPERTY(bool, Unread, unread); | 408 | SINK_PROPERTY(bool, Unread, unread); |
440 | SINK_PROPERTY(bool, Important, important); | 409 | SINK_PROPERTY(bool, Important, important); |
441 | SINK_REFERENCE_PROPERTY(Folder, Folder, folder); | 410 | SINK_REFERENCE_PROPERTY(Folder, Folder, folder); |
442 | // SINK_BLOB_PROPERTY(MimeMessage, mimeMessage); | ||
443 | SINK_PROPERTY(QByteArray, MimeMessage, mimeMessage); | 411 | SINK_PROPERTY(QByteArray, MimeMessage, mimeMessage); |
444 | SINK_EXTRACTED_PROPERTY(bool, FullPayloadAvailable, fullPayloadAvailable); | 412 | SINK_EXTRACTED_PROPERTY(bool, FullPayloadAvailable, fullPayloadAvailable); |
445 | SINK_PROPERTY(bool, Draft, draft); | 413 | SINK_PROPERTY(bool, Draft, draft); |
@@ -542,7 +510,6 @@ class SINK_EXPORT TypeImplementation; | |||
542 | #undef SINK_ENTITY | 510 | #undef SINK_ENTITY |
543 | #undef SINK_PROPERTY | 511 | #undef SINK_PROPERTY |
544 | #undef SINK_EXTRACTED_PROPERTY | 512 | #undef SINK_EXTRACTED_PROPERTY |
545 | #undef SINK_BLOB_PROPERTY | ||
546 | #undef SINK_REFERENCE_PROPERTY | 513 | #undef SINK_REFERENCE_PROPERTY |
547 | #undef SINK_INDEX_PROPERTY | 514 | #undef SINK_INDEX_PROPERTY |
548 | 515 | ||
@@ -576,5 +543,4 @@ Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail::Contact) | |||
576 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Contact::Email) | 543 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Contact::Email) |
577 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Error) | 544 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Error) |
578 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Progress) | 545 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Progress) |
579 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::BLOB) | ||
580 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Reference) | 546 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Reference) |