diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-04 12:19:27 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-04 12:19:27 +0200 |
commit | 268eb7207b955bb92e4ae2572996877e7f837325 (patch) | |
tree | cac5dbbdf98afcc8d3f7c595a7bbbe1a993e2028 /framework | |
parent | dd060cc5e3b336a77f8e5e76df4bc76a58e22cd4 (diff) | |
download | kube-268eb7207b955bb92e4ae2572996877e7f837325.tar.gz kube-268eb7207b955bb92e4ae2572996877e7f837325.zip |
Less namespaces improve readability
Diffstat (limited to 'framework')
-rw-r--r-- | framework/domain/actions/sinkactions.cpp | 37 | ||||
-rw-r--r-- | framework/domain/folderlistmodel.cpp | 16 | ||||
-rw-r--r-- | framework/domain/settings/accountsettings.cpp | 59 |
3 files changed, 59 insertions, 53 deletions
diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index 47041a5b..e79e79c9 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp | |||
@@ -29,20 +29,21 @@ SINK_DEBUG_AREA("sinkactions") | |||
29 | 29 | ||
30 | using namespace Kube; | 30 | using namespace Kube; |
31 | using namespace Sink; | 31 | using namespace Sink; |
32 | using namespace Sink::ApplicationDomain; | ||
32 | 33 | ||
33 | static ActionHandlerHelper markAsReadHandler("org.kde.kube.actions.mark-as-read", | 34 | static ActionHandlerHelper markAsReadHandler("org.kde.kube.actions.mark-as-read", |
34 | [](Context *context) -> bool { | 35 | [](Context *context) -> bool { |
35 | return context->property("mail").isValid(); | 36 | return context->property("mail").isValid(); |
36 | }, | 37 | }, |
37 | [](Context *context) { | 38 | [](Context *context) { |
38 | auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>(); | 39 | auto mail = context->property("mail").value<Mail::Ptr>(); |
39 | if (!mail) { | 40 | if (!mail) { |
40 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); | 41 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); |
41 | return; | 42 | return; |
42 | } | 43 | } |
43 | mail->setProperty("unread", false); | 44 | mail->setProperty("unread", false); |
44 | SinkLog() << "Mark as read " << mail->identifier(); | 45 | SinkLog() << "Mark as read " << mail->identifier(); |
45 | Sink::Store::modify(*mail).exec(); | 46 | Store::modify(*mail).exec(); |
46 | } | 47 | } |
47 | ); | 48 | ); |
48 | 49 | ||
@@ -51,14 +52,14 @@ static ActionHandlerHelper moveToTrashHandler("org.kde.kube.actions.move-to-tras | |||
51 | return context->property("mail").isValid(); | 52 | return context->property("mail").isValid(); |
52 | }, | 53 | }, |
53 | [](Context *context) { | 54 | [](Context *context) { |
54 | auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>(); | 55 | auto mail = context->property("mail").value<Mail::Ptr>(); |
55 | if (!mail) { | 56 | if (!mail) { |
56 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); | 57 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); |
57 | return; | 58 | return; |
58 | } | 59 | } |
59 | mail->setTrash(true); | 60 | mail->setTrash(true); |
60 | SinkLog() << "Move to trash " << mail->identifier(); | 61 | SinkLog() << "Move to trash " << mail->identifier(); |
61 | Sink::Store::modify(*mail).exec(); | 62 | Store::modify(*mail).exec(); |
62 | } | 63 | } |
63 | ); | 64 | ); |
64 | 65 | ||
@@ -67,13 +68,13 @@ static ActionHandlerHelper deleteHandler("org.kde.kube.actions.delete", | |||
67 | return context->property("mail").isValid(); | 68 | return context->property("mail").isValid(); |
68 | }, | 69 | }, |
69 | [](Context *context) { | 70 | [](Context *context) { |
70 | auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>(); | 71 | auto mail = context->property("mail").value<Mail::Ptr>(); |
71 | if (!mail) { | 72 | if (!mail) { |
72 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); | 73 | SinkWarning() << "Failed to get the mail mail: " << context->property("mail"); |
73 | return; | 74 | return; |
74 | } | 75 | } |
75 | SinkLog() << "Remove " << mail->identifier(); | 76 | SinkLog() << "Remove " << mail->identifier(); |
76 | Sink::Store::remove(*mail).exec(); | 77 | Store::remove(*mail).exec(); |
77 | } | 78 | } |
78 | ); | 79 | ); |
79 | 80 | ||
@@ -82,12 +83,12 @@ static ActionHandlerHelper synchronizeHandler("org.kde.kube.actions.synchronize" | |||
82 | return true; | 83 | return true; |
83 | }, | 84 | }, |
84 | [](Context *context) { | 85 | [](Context *context) { |
85 | if (auto folder = context->property("folder").value<Sink::ApplicationDomain::Folder::Ptr>()) { | 86 | if (auto folder = context->property("folder").value<Folder::Ptr>()) { |
86 | SinkLog() << "Synchronizing resource " << folder->resourceInstanceIdentifier(); | 87 | SinkLog() << "Synchronizing resource " << folder->resourceInstanceIdentifier(); |
87 | Sink::Store::synchronize(Sink::Query::ResourceFilter(folder->resourceInstanceIdentifier())).exec(); | 88 | Store::synchronize(Query::ResourceFilter(folder->resourceInstanceIdentifier())).exec(); |
88 | } else { | 89 | } else { |
89 | SinkLog() << "Synchronizing all"; | 90 | SinkLog() << "Synchronizing all"; |
90 | Sink::Store::synchronize(Sink::Query()).exec(); | 91 | Store::synchronize(Query()).exec(); |
91 | } | 92 | } |
92 | } | 93 | } |
93 | ); | 94 | ); |
@@ -111,9 +112,9 @@ static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", | |||
111 | if (!resources.isEmpty()) { | 112 | if (!resources.isEmpty()) { |
112 | auto resourceId = resources[0]->identifier(); | 113 | auto resourceId = resources[0]->identifier(); |
113 | SinkTrace() << "Sending message via resource: " << resourceId; | 114 | SinkTrace() << "Sending message via resource: " << resourceId; |
114 | Sink::ApplicationDomain::Mail mail(resourceId); | 115 | Mail mail(resourceId); |
115 | mail.setBlobProperty("mimeMessage", message->encodedContent()); | 116 | mail.setBlobProperty("mimeMessage", message->encodedContent()); |
116 | return Sink::Store::create(mail); | 117 | return Store::create(mail); |
117 | } | 118 | } |
118 | SinkWarning() << "Failed to find a mailtransport resource"; | 119 | SinkWarning() << "Failed to find a mailtransport resource"; |
119 | return KAsync::error<void>(0, "Failed to find a MailTransport resource."); | 120 | return KAsync::error<void>(0, "Failed to find a MailTransport resource."); |
@@ -131,27 +132,27 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", | |||
131 | SinkWarning() << "executing save as draft"; | 132 | SinkWarning() << "executing save as draft"; |
132 | const auto accountId = context->property("accountId").value<QByteArray>(); | 133 | const auto accountId = context->property("accountId").value<QByteArray>(); |
133 | const auto message = context->property("message").value<KMime::Message::Ptr>(); | 134 | const auto message = context->property("message").value<KMime::Message::Ptr>(); |
134 | auto existingMail = context->property("existingMail").value<Sink::ApplicationDomain::Mail>(); | 135 | auto existingMail = context->property("existingMail").value<Mail>(); |
135 | if (!message) { | 136 | if (!message) { |
136 | SinkWarning() << "Failed to get the mail: " << context->property("mail"); | 137 | SinkWarning() << "Failed to get the mail: " << context->property("mail"); |
137 | return KAsync::error<void>(1, "Failed to get the mail: " + context->property("mail").toString()); | 138 | return KAsync::error<void>(1, "Failed to get the mail: " + context->property("mail").toString()); |
138 | } | 139 | } |
139 | 140 | ||
140 | if (existingMail.identifier().isEmpty()) { | 141 | if (existingMail.identifier().isEmpty()) { |
141 | Sink::Query query; | 142 | Query query; |
142 | query.containsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::drafts); | 143 | query.containsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::drafts); |
143 | query.filter(ApplicationDomain::SinkAccount(accountId)); | 144 | query.filter(ApplicationDomain::SinkAccount(accountId)); |
144 | return Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(query) | 145 | return Store::fetchOne<SinkResource>(query) |
145 | .then<void, Sink::ApplicationDomain::SinkResource>([=](const Sink::ApplicationDomain::SinkResource &resource) -> KAsync::Job<void> { | 146 | .then<void, SinkResource>([=](const SinkResource &resource) -> KAsync::Job<void> { |
146 | Sink::ApplicationDomain::Mail mail(resource.identifier()); | 147 | Mail mail(resource.identifier()); |
147 | mail.setProperty("draft", true); | 148 | mail.setProperty("draft", true); |
148 | mail.setBlobProperty("mimeMessage", message->encodedContent()); | 149 | mail.setBlobProperty("mimeMessage", message->encodedContent()); |
149 | return Sink::Store::create(mail); | 150 | return Store::create(mail); |
150 | }); | 151 | }); |
151 | } else { | 152 | } else { |
152 | SinkWarning() << "Modifying an existing mail" << existingMail.identifier(); | 153 | SinkWarning() << "Modifying an existing mail" << existingMail.identifier(); |
153 | existingMail.setBlobProperty("mimeMessage", message->encodedContent()); | 154 | existingMail.setBlobProperty("mimeMessage", message->encodedContent()); |
154 | return Sink::Store::modify(existingMail); | 155 | return Store::modify(existingMail); |
155 | } | 156 | } |
156 | }) | 157 | }) |
157 | ); | 158 | ); |
diff --git a/framework/domain/folderlistmodel.cpp b/framework/domain/folderlistmodel.cpp index 98453ce9..e852288f 100644 --- a/framework/domain/folderlistmodel.cpp +++ b/framework/domain/folderlistmodel.cpp | |||
@@ -22,9 +22,12 @@ | |||
22 | #include <sink/store.h> | 22 | #include <sink/store.h> |
23 | #include <settings/settings.h> | 23 | #include <settings/settings.h> |
24 | 24 | ||
25 | using namespace Sink; | ||
26 | using namespace Sink::ApplicationDomain; | ||
27 | |||
25 | FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() | 28 | FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() |
26 | { | 29 | { |
27 | Sink::Query query; | 30 | Query query; |
28 | query.liveQuery = true; | 31 | query.liveQuery = true; |
29 | query.requestedProperties << "name" << "icon" << "parent"; | 32 | query.requestedProperties << "name" << "icon" << "parent"; |
30 | query.parentProperty = "parent"; | 33 | query.parentProperty = "parent"; |
@@ -57,26 +60,25 @@ QVariant FolderListModel::data(const QModelIndex &idx, int role) const | |||
57 | case Icon: | 60 | case Icon: |
58 | return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); | 61 | return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); |
59 | case Id: | 62 | case Id: |
60 | return srcIdx.data(Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>()->identifier(); | 63 | return srcIdx.data(Store::DomainObjectBaseRole).value<ApplicationDomainType::Ptr>()->identifier(); |
61 | case DomainObject: | 64 | case DomainObject: |
62 | return srcIdx.data(Sink::Store::DomainObjectRole); | 65 | return srcIdx.data(Store::DomainObjectRole); |
63 | } | 66 | } |
64 | return QIdentityProxyModel::data(idx, role); | 67 | return QIdentityProxyModel::data(idx, role); |
65 | } | 68 | } |
66 | 69 | ||
67 | void FolderListModel::runQuery(const Sink::Query &query) | 70 | void FolderListModel::runQuery(const Query &query) |
68 | { | 71 | { |
69 | mModel = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 72 | mModel = Store::loadModel<Folder>(query); |
70 | setSourceModel(mModel.data()); | 73 | setSourceModel(mModel.data()); |
71 | } | 74 | } |
72 | 75 | ||
73 | void FolderListModel::setAccountId(const QVariant &accountId) | 76 | void FolderListModel::setAccountId(const QVariant &accountId) |
74 | { | 77 | { |
75 | using namespace Sink::ApplicationDomain; | ||
76 | const auto account = accountId.toString().toUtf8(); | 78 | const auto account = accountId.toString().toUtf8(); |
77 | 79 | ||
78 | //Get all folders of an account | 80 | //Get all folders of an account |
79 | auto query = Sink::Query(); | 81 | auto query = Query(); |
80 | query.filter(SinkAccount(account)); | 82 | query.filter(SinkAccount(account)); |
81 | query.liveQuery = true; | 83 | query.liveQuery = true; |
82 | query.request<Folder::Name>() | 84 | query.request<Folder::Name>() |
diff --git a/framework/domain/settings/accountsettings.cpp b/framework/domain/settings/accountsettings.cpp index 020fd503..635aef6e 100644 --- a/framework/domain/settings/accountsettings.cpp +++ b/framework/domain/settings/accountsettings.cpp | |||
@@ -23,6 +23,9 @@ | |||
23 | #include <QDir> | 23 | #include <QDir> |
24 | #include <QUrl> | 24 | #include <QUrl> |
25 | 25 | ||
26 | using namespace Sink; | ||
27 | using namespace Sink::ApplicationDomain; | ||
28 | |||
26 | AccountSettings::AccountSettings(QObject *parent) | 29 | AccountSettings::AccountSettings(QObject *parent) |
27 | : QObject(parent) | 30 | : QObject(parent) |
28 | { | 31 | { |
@@ -130,12 +133,12 @@ void AccountSettings::saveAccount() | |||
130 | { | 133 | { |
131 | qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; | 134 | qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; |
132 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | 135 | Q_ASSERT(!mAccountIdentifier.isEmpty()); |
133 | Sink::ApplicationDomain::SinkAccount account(mAccountIdentifier); | 136 | SinkAccount account(mAccountIdentifier); |
134 | account.setProperty("type", "imap"); | 137 | account.setProperty("type", "imap"); |
135 | account.setProperty("name", mName); | 138 | account.setProperty("name", mName); |
136 | account.setProperty("icon", mIcon); | 139 | account.setProperty("icon", mIcon); |
137 | Q_ASSERT(!account.identifier().isEmpty()); | 140 | Q_ASSERT(!account.identifier().isEmpty()); |
138 | Sink::Store::modify(account) | 141 | Store::modify(account) |
139 | .onError([](const KAsync::Error &error) { | 142 | .onError([](const KAsync::Error &error) { |
140 | qWarning() << "Error while creating account: " << error.errorMessage;; | 143 | qWarning() << "Error while creating account: " << error.errorMessage;; |
141 | }) | 144 | }) |
@@ -145,8 +148,8 @@ void AccountSettings::saveAccount() | |||
145 | void AccountSettings::loadAccount() | 148 | void AccountSettings::loadAccount() |
146 | { | 149 | { |
147 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | 150 | Q_ASSERT(!mAccountIdentifier.isEmpty()); |
148 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query::IdentityFilter(mAccountIdentifier)) | 151 | Store::fetchOne<SinkAccount>(Query::IdentityFilter(mAccountIdentifier)) |
149 | .syncThen<void, Sink::ApplicationDomain::SinkAccount>([this](const Sink::ApplicationDomain::SinkAccount &account) { | 152 | .syncThen<void, SinkAccount>([this](const SinkAccount &account) { |
150 | mIcon = account.getProperty("icon").toString(); | 153 | mIcon = account.getProperty("icon").toString(); |
151 | mName = account.getProperty("name").toString(); | 154 | mName = account.getProperty("name").toString(); |
152 | emit changed(); | 155 | emit changed(); |
@@ -155,8 +158,8 @@ void AccountSettings::loadAccount() | |||
155 | 158 | ||
156 | void AccountSettings::loadImapResource() | 159 | void AccountSettings::loadImapResource() |
157 | { | 160 | { |
158 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query().filter(Sink::ApplicationDomain::SinkAccount(mAccountIdentifier)).containsFilter<Sink::ApplicationDomain::SinkResource::Capabilities>(Sink::ApplicationDomain::ResourceCapabilities::Mail::storage)) | 161 | Store::fetchOne<SinkResource>(Query().filter(SinkAccount(mAccountIdentifier)).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) |
159 | .syncThen<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 162 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { |
160 | mImapIdentifier = resource.identifier(); | 163 | mImapIdentifier = resource.identifier(); |
161 | mImapServer = resource.getProperty("server").toString(); | 164 | mImapServer = resource.getProperty("server").toString(); |
162 | mImapUsername = resource.getProperty("username").toString(); | 165 | mImapUsername = resource.getProperty("username").toString(); |
@@ -169,8 +172,8 @@ void AccountSettings::loadImapResource() | |||
169 | 172 | ||
170 | void AccountSettings::loadMaildirResource() | 173 | void AccountSettings::loadMaildirResource() |
171 | { | 174 | { |
172 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query().filter(Sink::ApplicationDomain::SinkAccount(mAccountIdentifier)).containsFilter<Sink::ApplicationDomain::SinkResource::Capabilities>(Sink::ApplicationDomain::ResourceCapabilities::Mail::storage)) | 175 | Store::fetchOne<SinkResource>(Query().filter(SinkAccount(mAccountIdentifier)).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) |
173 | .syncThen<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 176 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { |
174 | mMaildirIdentifier = resource.identifier(); | 177 | mMaildirIdentifier = resource.identifier(); |
175 | auto path = resource.getProperty("path").toString(); | 178 | auto path = resource.getProperty("path").toString(); |
176 | if (mPath != path) { | 179 | if (mPath != path) { |
@@ -184,8 +187,8 @@ void AccountSettings::loadMaildirResource() | |||
184 | 187 | ||
185 | void AccountSettings::loadMailtransportResource() | 188 | void AccountSettings::loadMailtransportResource() |
186 | { | 189 | { |
187 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query().filter(Sink::ApplicationDomain::SinkAccount(mAccountIdentifier)).containsFilter<Sink::ApplicationDomain::SinkResource::Capabilities>(Sink::ApplicationDomain::ResourceCapabilities::Mail::transport)) | 190 | Store::fetchOne<SinkResource>(Query().filter(SinkAccount(mAccountIdentifier)).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport)) |
188 | .syncThen<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 191 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { |
189 | mMailtransportIdentifier = resource.identifier(); | 192 | mMailtransportIdentifier = resource.identifier(); |
190 | mSmtpServer = resource.getProperty("server").toString(); | 193 | mSmtpServer = resource.getProperty("server").toString(); |
191 | mSmtpUsername = resource.getProperty("username").toString(); | 194 | mSmtpUsername = resource.getProperty("username").toString(); |
@@ -199,8 +202,8 @@ void AccountSettings::loadMailtransportResource() | |||
199 | void AccountSettings::loadIdentity() | 202 | void AccountSettings::loadIdentity() |
200 | { | 203 | { |
201 | //FIXME this assumes that we only ever have one identity per account | 204 | //FIXME this assumes that we only ever have one identity per account |
202 | Sink::Store::fetchOne<Sink::ApplicationDomain::Identity>(Sink::Query().filter(Sink::ApplicationDomain::SinkAccount(mAccountIdentifier))) | 205 | Store::fetchOne<Identity>(Query().filter(SinkAccount(mAccountIdentifier))) |
203 | .syncThen<void, Sink::ApplicationDomain::Identity>([this](const Sink::ApplicationDomain::Identity &identity) { | 206 | .syncThen<void, Identity>([this](const Identity &identity) { |
204 | mIdentityIdentifier = identity.identifier(); | 207 | mIdentityIdentifier = identity.identifier(); |
205 | mUsername = identity.getProperty("username").toString(); | 208 | mUsername = identity.getProperty("username").toString(); |
206 | mEmailAddress = identity.getProperty("address").toString(); | 209 | mEmailAddress = identity.getProperty("address").toString(); |
@@ -216,11 +219,11 @@ template<typename ResourceType> | |||
216 | static QByteArray saveResource(const QByteArray &accountIdentifier, const QByteArray &identifier, const std::map<QByteArray, QVariant> &properties) | 219 | static QByteArray saveResource(const QByteArray &accountIdentifier, const QByteArray &identifier, const std::map<QByteArray, QVariant> &properties) |
217 | { | 220 | { |
218 | if (!identifier.isEmpty()) { | 221 | if (!identifier.isEmpty()) { |
219 | Sink::ApplicationDomain::SinkResource resource(identifier); | 222 | SinkResource resource(identifier); |
220 | for (const auto &pair : properties) { | 223 | for (const auto &pair : properties) { |
221 | resource.setProperty(pair.first, pair.second); | 224 | resource.setProperty(pair.first, pair.second); |
222 | } | 225 | } |
223 | Sink::Store::modify(resource) | 226 | Store::modify(resource) |
224 | .onError([](const KAsync::Error &error) { | 227 | .onError([](const KAsync::Error &error) { |
225 | qWarning() << "Error while modifying resource: " << error.errorMessage; | 228 | qWarning() << "Error while modifying resource: " << error.errorMessage; |
226 | }) | 229 | }) |
@@ -231,7 +234,7 @@ static QByteArray saveResource(const QByteArray &accountIdentifier, const QByteA | |||
231 | for (const auto &pair : properties) { | 234 | for (const auto &pair : properties) { |
232 | resource.setProperty(pair.first, pair.second); | 235 | resource.setProperty(pair.first, pair.second); |
233 | } | 236 | } |
234 | Sink::Store::create(resource) | 237 | Store::create(resource) |
235 | .onError([](const KAsync::Error &error) { | 238 | .onError([](const KAsync::Error &error) { |
236 | qWarning() << "Error while creating resource: " << error.errorMessage; | 239 | qWarning() << "Error while creating resource: " << error.errorMessage; |
237 | }) | 240 | }) |
@@ -243,7 +246,7 @@ static QByteArray saveResource(const QByteArray &accountIdentifier, const QByteA | |||
243 | 246 | ||
244 | void AccountSettings::saveImapResource() | 247 | void AccountSettings::saveImapResource() |
245 | { | 248 | { |
246 | mImapIdentifier = saveResource<Sink::ApplicationDomain::ImapResource>(mAccountIdentifier, mImapIdentifier, { | 249 | mImapIdentifier = saveResource<ImapResource>(mAccountIdentifier, mImapIdentifier, { |
247 | {"server", mImapServer}, | 250 | {"server", mImapServer}, |
248 | {"username", mImapUsername}, | 251 | {"username", mImapUsername}, |
249 | {"password", mImapPassword}, | 252 | {"password", mImapPassword}, |
@@ -252,14 +255,14 @@ void AccountSettings::saveImapResource() | |||
252 | 255 | ||
253 | void AccountSettings::saveMaildirResource() | 256 | void AccountSettings::saveMaildirResource() |
254 | { | 257 | { |
255 | mMaildirIdentifier = saveResource<Sink::ApplicationDomain::MaildirResource>(mAccountIdentifier, mMaildirIdentifier, { | 258 | mMaildirIdentifier = saveResource<MaildirResource>(mAccountIdentifier, mMaildirIdentifier, { |
256 | {"path", mPath}, | 259 | {"path", mPath}, |
257 | }); | 260 | }); |
258 | } | 261 | } |
259 | 262 | ||
260 | void AccountSettings::saveMailtransportResource() | 263 | void AccountSettings::saveMailtransportResource() |
261 | { | 264 | { |
262 | mMailtransportIdentifier = saveResource<Sink::ApplicationDomain::MailtransportResource>(mAccountIdentifier, mMailtransportIdentifier, { | 265 | mMailtransportIdentifier = saveResource<MailtransportResource>(mAccountIdentifier, mMailtransportIdentifier, { |
263 | {"server", mSmtpServer}, | 266 | {"server", mSmtpServer}, |
264 | {"username", mSmtpUsername}, | 267 | {"username", mSmtpUsername}, |
265 | {"password", mSmtpPassword}, | 268 | {"password", mSmtpPassword}, |
@@ -269,21 +272,21 @@ void AccountSettings::saveMailtransportResource() | |||
269 | void AccountSettings::saveIdentity() | 272 | void AccountSettings::saveIdentity() |
270 | { | 273 | { |
271 | if (!mIdentityIdentifier.isEmpty()) { | 274 | if (!mIdentityIdentifier.isEmpty()) { |
272 | Sink::ApplicationDomain::Identity identity(mMailtransportIdentifier); | 275 | Identity identity(mMailtransportIdentifier); |
273 | identity.setProperty("username", mUsername); | 276 | identity.setProperty("username", mUsername); |
274 | identity.setProperty("address", mEmailAddress); | 277 | identity.setProperty("address", mEmailAddress); |
275 | Sink::Store::modify(identity) | 278 | Store::modify(identity) |
276 | .onError([](const KAsync::Error &error) { | 279 | .onError([](const KAsync::Error &error) { |
277 | qWarning() << "Error while modifying identity: " << error.errorMessage; | 280 | qWarning() << "Error while modifying identity: " << error.errorMessage; |
278 | }) | 281 | }) |
279 | .exec(); | 282 | .exec(); |
280 | } else { | 283 | } else { |
281 | auto identity = Sink::ApplicationDomain::ApplicationDomainType::createEntity<Sink::ApplicationDomain::Identity>(); | 284 | auto identity = ApplicationDomainType::createEntity<Identity>(); |
282 | mIdentityIdentifier = identity.identifier(); | 285 | mIdentityIdentifier = identity.identifier(); |
283 | identity.setProperty("account", mAccountIdentifier); | 286 | identity.setProperty("account", mAccountIdentifier); |
284 | identity.setProperty("username", mUsername); | 287 | identity.setProperty("username", mUsername); |
285 | identity.setProperty("address", mEmailAddress); | 288 | identity.setProperty("address", mEmailAddress); |
286 | Sink::Store::create(identity) | 289 | Store::create(identity) |
287 | .onError([](const KAsync::Error &error) { | 290 | .onError([](const KAsync::Error &error) { |
288 | qWarning() << "Error while creating identity: " << error.errorMessage; | 291 | qWarning() << "Error while creating identity: " << error.errorMessage; |
289 | }) | 292 | }) |
@@ -296,8 +299,8 @@ void AccountSettings::removeResource(const QByteArray &identifier) | |||
296 | if (identifier.isEmpty()) { | 299 | if (identifier.isEmpty()) { |
297 | qWarning() << "We're missing an identifier"; | 300 | qWarning() << "We're missing an identifier"; |
298 | } else { | 301 | } else { |
299 | Sink::ApplicationDomain::SinkResource resource("", identifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 302 | SinkResource resource("", identifier, 0, QSharedPointer<MemoryBufferAdaptor>::create()); |
300 | Sink::Store::remove(resource) | 303 | Store::remove(resource) |
301 | .onError([](const KAsync::Error &error) { | 304 | .onError([](const KAsync::Error &error) { |
302 | qWarning() << "Error while removing resource: " << error.errorMessage; | 305 | qWarning() << "Error while removing resource: " << error.errorMessage; |
303 | }) | 306 | }) |
@@ -310,8 +313,8 @@ void AccountSettings::removeAccount() | |||
310 | if (mAccountIdentifier.isEmpty()) { | 313 | if (mAccountIdentifier.isEmpty()) { |
311 | qWarning() << "We're missing an identifier"; | 314 | qWarning() << "We're missing an identifier"; |
312 | } else { | 315 | } else { |
313 | Sink::ApplicationDomain::SinkAccount account("", mAccountIdentifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 316 | SinkAccount account("", mAccountIdentifier, 0, QSharedPointer<MemoryBufferAdaptor>::create()); |
314 | Sink::Store::remove(account) | 317 | Store::remove(account) |
315 | .onError([](const KAsync::Error &error) { | 318 | .onError([](const KAsync::Error &error) { |
316 | qWarning() << "Error while removing account: " << error.errorMessage; | 319 | qWarning() << "Error while removing account: " << error.errorMessage; |
317 | }) | 320 | }) |
@@ -324,8 +327,8 @@ void AccountSettings::removeIdentity() | |||
324 | if (mIdentityIdentifier.isEmpty()) { | 327 | if (mIdentityIdentifier.isEmpty()) { |
325 | qWarning() << "We're missing an identifier"; | 328 | qWarning() << "We're missing an identifier"; |
326 | } else { | 329 | } else { |
327 | Sink::ApplicationDomain::Identity identity("", mIdentityIdentifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 330 | Identity identity("", mIdentityIdentifier, 0, QSharedPointer<MemoryBufferAdaptor>::create()); |
328 | Sink::Store::remove(identity) | 331 | Store::remove(identity) |
329 | .onError([](const KAsync::Error &error) { | 332 | .onError([](const KAsync::Error &error) { |
330 | qWarning() << "Error while removing identity: " << error.errorMessage; | 333 | qWarning() << "Error while removing identity: " << error.errorMessage; |
331 | }) | 334 | }) |