diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-05 22:42:53 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-05 22:42:53 +0200 |
commit | 5fa8608e9877eab40336a60ed8ed979aaf3cfbd0 (patch) | |
tree | b13061569d1c9d99f58edd2c31c1c6ba3f86618c | |
parent | 268eb7207b955bb92e4ae2572996877e7f837325 (diff) | |
download | kube-5fa8608e9877eab40336a60ed8ed979aaf3cfbd0.tar.gz kube-5fa8608e9877eab40336a60ed8ed979aaf3cfbd0.zip |
Adapted to new API
-rw-r--r-- | framework/domain/accountfactory.cpp | 2 | ||||
-rw-r--r-- | framework/domain/actions/sinkactions.cpp | 16 | ||||
-rw-r--r-- | framework/domain/folderlistmodel.cpp | 4 | ||||
-rw-r--r-- | framework/domain/maillistmodel.cpp | 2 | ||||
-rw-r--r-- | framework/domain/settings/accountsettings.cpp | 28 |
5 files changed, 26 insertions, 26 deletions
diff --git a/framework/domain/accountfactory.cpp b/framework/domain/accountfactory.cpp index 6261eaf1..182a0a1d 100644 --- a/framework/domain/accountfactory.cpp +++ b/framework/domain/accountfactory.cpp | |||
@@ -43,7 +43,7 @@ QString AccountFactory::name() const | |||
43 | void AccountFactory::setAccountId(const QString &accountId) | 43 | void AccountFactory::setAccountId(const QString &accountId) |
44 | { | 44 | { |
45 | mAccountId = accountId; | 45 | mAccountId = accountId; |
46 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query::IdentityFilter(accountId.toUtf8())) | 46 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query().filter(accountId.toUtf8())) |
47 | .syncThen<void, Sink::ApplicationDomain::SinkAccount>([this](const Sink::ApplicationDomain::SinkAccount &account) { | 47 | .syncThen<void, Sink::ApplicationDomain::SinkAccount>([this](const Sink::ApplicationDomain::SinkAccount &account) { |
48 | mAccountType = account.getProperty("type").toByteArray(); | 48 | mAccountType = account.getProperty("type").toByteArray(); |
49 | loadPackage(); | 49 | loadPackage(); |
diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index e79e79c9..cc8d324e 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp | |||
@@ -85,7 +85,7 @@ static ActionHandlerHelper synchronizeHandler("org.kde.kube.actions.synchronize" | |||
85 | [](Context *context) { | 85 | [](Context *context) { |
86 | if (auto folder = context->property("folder").value<Folder::Ptr>()) { | 86 | if (auto folder = context->property("folder").value<Folder::Ptr>()) { |
87 | SinkLog() << "Synchronizing resource " << folder->resourceInstanceIdentifier(); | 87 | SinkLog() << "Synchronizing resource " << folder->resourceInstanceIdentifier(); |
88 | Store::synchronize(Query::ResourceFilter(folder->resourceInstanceIdentifier())).exec(); | 88 | Store::synchronize(Query().resourceFilter(folder->resourceInstanceIdentifier())).exec(); |
89 | } else { | 89 | } else { |
90 | SinkLog() << "Synchronizing all"; | 90 | SinkLog() << "Synchronizing all"; |
91 | Store::synchronize(Query()).exec(); | 91 | Store::synchronize(Query()).exec(); |
@@ -106,7 +106,7 @@ static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", | |||
106 | 106 | ||
107 | Query query; | 107 | Query query; |
108 | query.containsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::transport); | 108 | query.containsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::transport); |
109 | query.filter(ApplicationDomain::SinkAccount(accountId)); | 109 | query.filter<SinkResource::Account>(accountId); |
110 | Store::fetchAll<ApplicationDomain::SinkResource>(query) | 110 | Store::fetchAll<ApplicationDomain::SinkResource>(query) |
111 | .then<void, QList<ApplicationDomain::SinkResource::Ptr>>([=](const QList<ApplicationDomain::SinkResource::Ptr> &resources) -> KAsync::Job<void> { | 111 | .then<void, QList<ApplicationDomain::SinkResource::Ptr>>([=](const QList<ApplicationDomain::SinkResource::Ptr> &resources) -> KAsync::Job<void> { |
112 | if (!resources.isEmpty()) { | 112 | if (!resources.isEmpty()) { |
@@ -129,7 +129,7 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", | |||
129 | return !accountId.isEmpty() && message; | 129 | return !accountId.isEmpty() && message; |
130 | }, | 130 | }, |
131 | ActionHandlerHelper::JobHandler([](Context *context) -> KAsync::Job<void> { | 131 | ActionHandlerHelper::JobHandler([](Context *context) -> KAsync::Job<void> { |
132 | SinkWarning() << "executing save as draft"; | 132 | SinkLog() << "Executing the save-as-draft action"; |
133 | const auto accountId = context->property("accountId").value<QByteArray>(); | 133 | const auto accountId = context->property("accountId").value<QByteArray>(); |
134 | const auto message = context->property("message").value<KMime::Message::Ptr>(); | 134 | const auto message = context->property("message").value<KMime::Message::Ptr>(); |
135 | auto existingMail = context->property("existingMail").value<Mail>(); | 135 | auto existingMail = context->property("existingMail").value<Mail>(); |
@@ -140,18 +140,18 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", | |||
140 | 140 | ||
141 | if (existingMail.identifier().isEmpty()) { | 141 | if (existingMail.identifier().isEmpty()) { |
142 | Query query; | 142 | Query query; |
143 | query.containsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::drafts); | 143 | query.containsFilter<SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::drafts); |
144 | query.filter(ApplicationDomain::SinkAccount(accountId)); | 144 | query.filter<SinkResource::Account>(accountId); |
145 | return Store::fetchOne<SinkResource>(query) | 145 | return Store::fetchOne<SinkResource>(query) |
146 | .then<void, SinkResource>([=](const SinkResource &resource) -> KAsync::Job<void> { | 146 | .then<void, SinkResource>([=](const SinkResource &resource) -> KAsync::Job<void> { |
147 | Mail mail(resource.identifier()); | 147 | Mail mail(resource.identifier()); |
148 | mail.setProperty("draft", true); | 148 | mail.setDraft(true); |
149 | mail.setBlobProperty("mimeMessage", message->encodedContent()); | 149 | mail.setMimeMessage(message->encodedContent()); |
150 | return Store::create(mail); | 150 | return Store::create(mail); |
151 | }); | 151 | }); |
152 | } else { | 152 | } else { |
153 | SinkWarning() << "Modifying an existing mail" << existingMail.identifier(); | 153 | SinkWarning() << "Modifying an existing mail" << existingMail.identifier(); |
154 | existingMail.setBlobProperty("mimeMessage", message->encodedContent()); | 154 | existingMail.setMimeMessage(message->encodedContent()); |
155 | return Store::modify(existingMail); | 155 | return Store::modify(existingMail); |
156 | } | 156 | } |
157 | }) | 157 | }) |
diff --git a/framework/domain/folderlistmodel.cpp b/framework/domain/folderlistmodel.cpp index e852288f..7cf5ad5d 100644 --- a/framework/domain/folderlistmodel.cpp +++ b/framework/domain/folderlistmodel.cpp | |||
@@ -29,7 +29,7 @@ FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() | |||
29 | { | 29 | { |
30 | Query query; | 30 | Query query; |
31 | query.liveQuery = true; | 31 | query.liveQuery = true; |
32 | query.requestedProperties << "name" << "icon" << "parent"; | 32 | query.request<Folder::Name>().request<Folder::Icon>().request<Folder::Parent>(); |
33 | query.parentProperty = "parent"; | 33 | query.parentProperty = "parent"; |
34 | runQuery(query); | 34 | runQuery(query); |
35 | } | 35 | } |
@@ -79,7 +79,7 @@ void FolderListModel::setAccountId(const QVariant &accountId) | |||
79 | 79 | ||
80 | //Get all folders of an account | 80 | //Get all folders of an account |
81 | auto query = Query(); | 81 | auto query = Query(); |
82 | query.filter(SinkAccount(account)); | 82 | query.resourceFilter<SinkResource::Account>(account); |
83 | query.liveQuery = true; | 83 | query.liveQuery = true; |
84 | query.request<Folder::Name>() | 84 | query.request<Folder::Name>() |
85 | .request<Folder::Icon>() | 85 | .request<Folder::Icon>() |
diff --git a/framework/domain/maillistmodel.cpp b/framework/domain/maillistmodel.cpp index e3f555c4..9afb6408 100644 --- a/framework/domain/maillistmodel.cpp +++ b/framework/domain/maillistmodel.cpp | |||
@@ -107,7 +107,7 @@ void MailListModel::setParentFolder(const QVariant &parentFolder) | |||
107 | } | 107 | } |
108 | Sink::Query query; | 108 | Sink::Query query; |
109 | query.liveQuery = true; | 109 | query.liveQuery = true; |
110 | query.resources << folder->resourceInstanceIdentifier(); | 110 | query.resourceFilter(folder->resourceInstanceIdentifier()); |
111 | query.sort<Mail::Date>(); | 111 | query.sort<Mail::Date>(); |
112 | query.limit = 100; | 112 | query.limit = 100; |
113 | query.request<Mail::Subject>(); | 113 | query.request<Mail::Subject>(); |
diff --git a/framework/domain/settings/accountsettings.cpp b/framework/domain/settings/accountsettings.cpp index 635aef6e..ea798a73 100644 --- a/framework/domain/settings/accountsettings.cpp +++ b/framework/domain/settings/accountsettings.cpp | |||
@@ -134,9 +134,9 @@ void AccountSettings::saveAccount() | |||
134 | qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; | 134 | qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; |
135 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | 135 | Q_ASSERT(!mAccountIdentifier.isEmpty()); |
136 | SinkAccount account(mAccountIdentifier); | 136 | SinkAccount account(mAccountIdentifier); |
137 | account.setProperty("type", "imap"); | 137 | account.setAccountType("imap"); |
138 | account.setProperty("name", mName); | 138 | account.setName(mName); |
139 | account.setProperty("icon", mIcon); | 139 | account.setIcon(mIcon); |
140 | Q_ASSERT(!account.identifier().isEmpty()); | 140 | Q_ASSERT(!account.identifier().isEmpty()); |
141 | Store::modify(account) | 141 | Store::modify(account) |
142 | .onError([](const KAsync::Error &error) { | 142 | .onError([](const KAsync::Error &error) { |
@@ -148,17 +148,17 @@ void AccountSettings::saveAccount() | |||
148 | void AccountSettings::loadAccount() | 148 | void AccountSettings::loadAccount() |
149 | { | 149 | { |
150 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | 150 | Q_ASSERT(!mAccountIdentifier.isEmpty()); |
151 | Store::fetchOne<SinkAccount>(Query::IdentityFilter(mAccountIdentifier)) | 151 | Store::fetchOne<SinkAccount>(Query().filter(mAccountIdentifier)) |
152 | .syncThen<void, SinkAccount>([this](const SinkAccount &account) { | 152 | .syncThen<void, SinkAccount>([this](const SinkAccount &account) { |
153 | mIcon = account.getProperty("icon").toString(); | 153 | mIcon = account.getIcon(); |
154 | mName = account.getProperty("name").toString(); | 154 | mName = account.getName(); |
155 | emit changed(); | 155 | emit changed(); |
156 | }).exec(); | 156 | }).exec(); |
157 | } | 157 | } |
158 | 158 | ||
159 | void AccountSettings::loadImapResource() | 159 | void AccountSettings::loadImapResource() |
160 | { | 160 | { |
161 | Store::fetchOne<SinkResource>(Query().filter(SinkAccount(mAccountIdentifier)).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) | 161 | Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) |
162 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { | 162 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { |
163 | mImapIdentifier = resource.identifier(); | 163 | mImapIdentifier = resource.identifier(); |
164 | mImapServer = resource.getProperty("server").toString(); | 164 | mImapServer = resource.getProperty("server").toString(); |
@@ -172,7 +172,7 @@ void AccountSettings::loadImapResource() | |||
172 | 172 | ||
173 | void AccountSettings::loadMaildirResource() | 173 | void AccountSettings::loadMaildirResource() |
174 | { | 174 | { |
175 | Store::fetchOne<SinkResource>(Query().filter(SinkAccount(mAccountIdentifier)).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) | 175 | Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) |
176 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { | 176 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { |
177 | mMaildirIdentifier = resource.identifier(); | 177 | mMaildirIdentifier = resource.identifier(); |
178 | auto path = resource.getProperty("path").toString(); | 178 | auto path = resource.getProperty("path").toString(); |
@@ -187,7 +187,7 @@ void AccountSettings::loadMaildirResource() | |||
187 | 187 | ||
188 | void AccountSettings::loadMailtransportResource() | 188 | void AccountSettings::loadMailtransportResource() |
189 | { | 189 | { |
190 | Store::fetchOne<SinkResource>(Query().filter(SinkAccount(mAccountIdentifier)).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport)) | 190 | Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport)) |
191 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { | 191 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { |
192 | mMailtransportIdentifier = resource.identifier(); | 192 | mMailtransportIdentifier = resource.identifier(); |
193 | mSmtpServer = resource.getProperty("server").toString(); | 193 | mSmtpServer = resource.getProperty("server").toString(); |
@@ -202,7 +202,7 @@ void AccountSettings::loadMailtransportResource() | |||
202 | void AccountSettings::loadIdentity() | 202 | void AccountSettings::loadIdentity() |
203 | { | 203 | { |
204 | //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 |
205 | Store::fetchOne<Identity>(Query().filter(SinkAccount(mAccountIdentifier))) | 205 | Store::fetchOne<Identity>(Query().filter<Identity::Account>(mAccountIdentifier)) |
206 | .syncThen<void, Identity>([this](const Identity &identity) { | 206 | .syncThen<void, Identity>([this](const Identity &identity) { |
207 | mIdentityIdentifier = identity.identifier(); | 207 | mIdentityIdentifier = identity.identifier(); |
208 | mUsername = identity.getProperty("username").toString(); | 208 | mUsername = identity.getProperty("username").toString(); |
@@ -283,7 +283,7 @@ void AccountSettings::saveIdentity() | |||
283 | } else { | 283 | } else { |
284 | auto identity = ApplicationDomainType::createEntity<Identity>(); | 284 | auto identity = ApplicationDomainType::createEntity<Identity>(); |
285 | mIdentityIdentifier = identity.identifier(); | 285 | mIdentityIdentifier = identity.identifier(); |
286 | identity.setProperty("account", mAccountIdentifier); | 286 | identity.setAccount(mAccountIdentifier); |
287 | identity.setProperty("username", mUsername); | 287 | identity.setProperty("username", mUsername); |
288 | identity.setProperty("address", mEmailAddress); | 288 | identity.setProperty("address", mEmailAddress); |
289 | Store::create(identity) | 289 | Store::create(identity) |
@@ -299,7 +299,7 @@ void AccountSettings::removeResource(const QByteArray &identifier) | |||
299 | if (identifier.isEmpty()) { | 299 | if (identifier.isEmpty()) { |
300 | qWarning() << "We're missing an identifier"; | 300 | qWarning() << "We're missing an identifier"; |
301 | } else { | 301 | } else { |
302 | SinkResource resource("", identifier, 0, QSharedPointer<MemoryBufferAdaptor>::create()); | 302 | SinkResource resource(identifier); |
303 | Store::remove(resource) | 303 | Store::remove(resource) |
304 | .onError([](const KAsync::Error &error) { | 304 | .onError([](const KAsync::Error &error) { |
305 | qWarning() << "Error while removing resource: " << error.errorMessage; | 305 | qWarning() << "Error while removing resource: " << error.errorMessage; |
@@ -313,7 +313,7 @@ void AccountSettings::removeAccount() | |||
313 | if (mAccountIdentifier.isEmpty()) { | 313 | if (mAccountIdentifier.isEmpty()) { |
314 | qWarning() << "We're missing an identifier"; | 314 | qWarning() << "We're missing an identifier"; |
315 | } else { | 315 | } else { |
316 | SinkAccount account("", mAccountIdentifier, 0, QSharedPointer<MemoryBufferAdaptor>::create()); | 316 | SinkAccount account(mAccountIdentifier); |
317 | Store::remove(account) | 317 | Store::remove(account) |
318 | .onError([](const KAsync::Error &error) { | 318 | .onError([](const KAsync::Error &error) { |
319 | qWarning() << "Error while removing account: " << error.errorMessage; | 319 | qWarning() << "Error while removing account: " << error.errorMessage; |
@@ -327,7 +327,7 @@ void AccountSettings::removeIdentity() | |||
327 | if (mIdentityIdentifier.isEmpty()) { | 327 | if (mIdentityIdentifier.isEmpty()) { |
328 | qWarning() << "We're missing an identifier"; | 328 | qWarning() << "We're missing an identifier"; |
329 | } else { | 329 | } else { |
330 | Identity identity("", mIdentityIdentifier, 0, QSharedPointer<MemoryBufferAdaptor>::create()); | 330 | Identity identity(mIdentityIdentifier); |
331 | Store::remove(identity) | 331 | Store::remove(identity) |
332 | .onError([](const KAsync::Error &error) { | 332 | .onError([](const KAsync::Error &error) { |
333 | qWarning() << "Error while removing identity: " << error.errorMessage; | 333 | qWarning() << "Error while removing identity: " << error.errorMessage; |