diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-15 11:15:34 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-15 11:15:34 +0100 |
commit | 2b517b2fd28e804e82036f55967a1777c1b8d2e9 (patch) | |
tree | a64dee652b7f61ebc0c45657321eb8f21f4f0829 | |
parent | 42f70f035f7c7799ace26f6dfc85d189ec27f5ae (diff) | |
download | sink-2b517b2fd28e804e82036f55967a1777c1b8d2e9.tar.gz sink-2b517b2fd28e804e82036f55967a1777c1b8d2e9.zip |
Made references serializable so we can store them in config files
-rw-r--r-- | common/domain/applicationdomaintype.cpp | 15 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.h | 2 | ||||
-rw-r--r-- | tests/accountstest.cpp | 3 |
3 files changed, 19 insertions, 1 deletions
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index 42ae11a..c59a01e 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp | |||
@@ -31,12 +31,13 @@ namespace ApplicationDomain { | |||
31 | 31 | ||
32 | constexpr const char *Mail::ThreadId::name; | 32 | constexpr const char *Mail::ThreadId::name; |
33 | 33 | ||
34 | int foo = [] { | 34 | static const int foo = [] { |
35 | QMetaType::registerEqualsComparator<Reference>(); | 35 | QMetaType::registerEqualsComparator<Reference>(); |
36 | QMetaType::registerDebugStreamOperator<Reference>(); | 36 | QMetaType::registerDebugStreamOperator<Reference>(); |
37 | QMetaType::registerConverter<Reference, QByteArray>(); | 37 | QMetaType::registerConverter<Reference, QByteArray>(); |
38 | QMetaType::registerDebugStreamOperator<BLOB>(); | 38 | QMetaType::registerDebugStreamOperator<BLOB>(); |
39 | QMetaType::registerDebugStreamOperator<Mail::Contact>(); | 39 | QMetaType::registerDebugStreamOperator<Mail::Contact>(); |
40 | qRegisterMetaTypeStreamOperators<Sink::ApplicationDomain::Reference>(); | ||
40 | return 0; | 41 | return 0; |
41 | }(); | 42 | }(); |
42 | 43 | ||
@@ -395,3 +396,15 @@ bool isGlobalType(const QByteArray &type) { | |||
395 | } | 396 | } |
396 | } | 397 | } |
397 | 398 | ||
399 | QDataStream &operator<<(QDataStream &out, const Sink::ApplicationDomain::Reference &reference) | ||
400 | { | ||
401 | out << reference.value; | ||
402 | return out; | ||
403 | } | ||
404 | |||
405 | QDataStream &operator>>(QDataStream &in, Sink::ApplicationDomain::Reference &reference) | ||
406 | { | ||
407 | in >> reference.value; | ||
408 | return in; | ||
409 | } | ||
410 | |||
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 1848224..b4d6f8a 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -502,6 +502,8 @@ class SINK_EXPORT TypeImplementation; | |||
502 | REGISTER_TYPE(Sink::ApplicationDomain::SinkAccount); \ | 502 | REGISTER_TYPE(Sink::ApplicationDomain::SinkAccount); \ |
503 | REGISTER_TYPE(Sink::ApplicationDomain::Identity); \ | 503 | REGISTER_TYPE(Sink::ApplicationDomain::Identity); \ |
504 | 504 | ||
505 | QDataStream & SINK_EXPORT operator<<(QDataStream &out, const Sink::ApplicationDomain::Reference &reference); | ||
506 | QDataStream & SINK_EXPORT operator>>(QDataStream &in, Sink::ApplicationDomain::Reference &reference); | ||
505 | 507 | ||
506 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType) | 508 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType) |
507 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr) | 509 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr) |
diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp index 029b92f..cce5c7b 100644 --- a/tests/accountstest.cpp +++ b/tests/accountstest.cpp | |||
@@ -76,6 +76,9 @@ private slots: | |||
76 | 76 | ||
77 | Store::fetchAll<Identity>(Query()).syncThen<void, QList<Identity::Ptr>>([&](const QList<Identity::Ptr> &identities) { | 77 | Store::fetchAll<Identity>(Query()).syncThen<void, QList<Identity::Ptr>>([&](const QList<Identity::Ptr> &identities) { |
78 | QCOMPARE(identities.size(), 1); | 78 | QCOMPARE(identities.size(), 1); |
79 | QCOMPARE(identities.first()->getName(), smtpServer); | ||
80 | QCOMPARE(identities.first()->getAddress(), smtpUsername); | ||
81 | QCOMPARE(identities.first()->getAccount(), account.identifier()); | ||
79 | }) | 82 | }) |
80 | .exec().waitForFinished(); | 83 | .exec().waitForFinished(); |
81 | 84 | ||