diff options
-rw-r--r-- | accounts/imap/tests/settingstest.cpp | 4 | ||||
-rw-r--r-- | accounts/maildir/tests/settingstest.cpp | 4 | ||||
-rw-r--r-- | framework/actions/actionhandler.cpp | 12 | ||||
-rw-r--r-- | framework/domain/accountfactory.cpp | 2 | ||||
-rw-r--r-- | framework/domain/accountscontroller.cpp | 10 | ||||
-rw-r--r-- | framework/domain/actions/sinkactions.cpp | 4 | ||||
-rw-r--r-- | framework/domain/composercontroller.cpp | 2 | ||||
-rw-r--r-- | framework/domain/folderlistmodel.cpp | 2 | ||||
-rw-r--r-- | framework/domain/identitiesmodel.cpp | 2 | ||||
-rw-r--r-- | framework/domain/settings/accountsettings.cpp | 88 |
10 files changed, 63 insertions, 67 deletions
diff --git a/accounts/imap/tests/settingstest.cpp b/accounts/imap/tests/settingstest.cpp index 4301943c..2fbc9b7b 100644 --- a/accounts/imap/tests/settingstest.cpp +++ b/accounts/imap/tests/settingstest.cpp | |||
@@ -43,7 +43,7 @@ private slots: | |||
43 | settings.setProperty("emailAddress", emailAddress); | 43 | settings.setProperty("emailAddress", emailAddress); |
44 | settings.save(); | 44 | settings.save(); |
45 | 45 | ||
46 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query()).then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { | 46 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query()).syncThen<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { |
47 | QCOMPARE(resources.size(), 2); | 47 | QCOMPARE(resources.size(), 2); |
48 | }) | 48 | }) |
49 | .exec().waitForFinished(); | 49 | .exec().waitForFinished(); |
@@ -76,7 +76,7 @@ private slots: | |||
76 | settings.remove(); | 76 | settings.remove(); |
77 | } | 77 | } |
78 | 78 | ||
79 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query()).then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { | 79 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query()).syncThen<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { |
80 | QCOMPARE(resources.size(), 0); | 80 | QCOMPARE(resources.size(), 0); |
81 | }) | 81 | }) |
82 | .exec().waitForFinished(); | 82 | .exec().waitForFinished(); |
diff --git a/accounts/maildir/tests/settingstest.cpp b/accounts/maildir/tests/settingstest.cpp index 342a3b40..47cb3b35 100644 --- a/accounts/maildir/tests/settingstest.cpp +++ b/accounts/maildir/tests/settingstest.cpp | |||
@@ -39,7 +39,7 @@ private slots: | |||
39 | settings.setProperty("emailAddress", emailAddress); | 39 | settings.setProperty("emailAddress", emailAddress); |
40 | settings.save(); | 40 | settings.save(); |
41 | 41 | ||
42 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query()).then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { | 42 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query()).syncThen<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { |
43 | QCOMPARE(resources.size(), 2); | 43 | QCOMPARE(resources.size(), 2); |
44 | }) | 44 | }) |
45 | .exec().waitForFinished(); | 45 | .exec().waitForFinished(); |
@@ -70,7 +70,7 @@ private slots: | |||
70 | settings.remove(); | 70 | settings.remove(); |
71 | } | 71 | } |
72 | 72 | ||
73 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query()).then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { | 73 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query()).syncThen<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { |
74 | QCOMPARE(resources.size(), 0); | 74 | QCOMPARE(resources.size(), 0); |
75 | }) | 75 | }) |
76 | .exec().waitForFinished(); | 76 | .exec().waitForFinished(); |
diff --git a/framework/actions/actionhandler.cpp b/framework/actions/actionhandler.cpp index 4ae8d0a9..9d58f464 100644 --- a/framework/actions/actionhandler.cpp +++ b/framework/actions/actionhandler.cpp | |||
@@ -106,14 +106,12 @@ ActionResult ActionHandlerHelper::execute(Context *context) | |||
106 | handlerFunction(context); | 106 | handlerFunction(context); |
107 | result.setDone(); | 107 | result.setDone(); |
108 | } else { | 108 | } else { |
109 | jobHandlerFunction(context).then<void>([=]() { | 109 | jobHandlerFunction(context).syncThen<void>([=](const KAsync::Error &error) { |
110 | auto modifyableResult = result; | 110 | auto modifyableResult = result; |
111 | modifyableResult.setDone(); | 111 | if (error) { |
112 | }, | 112 | qWarning() << "Job failed: " << error.errorCode << error.errorMessage; |
113 | [=](int errorCode, const QString &string) { | 113 | modifyableResult.setError(1); |
114 | qWarning() << "Job failed: " << errorCode << string; | 114 | } |
115 | auto modifyableResult = result; | ||
116 | modifyableResult.setError(1); | ||
117 | modifyableResult.setDone(); | 115 | modifyableResult.setDone(); |
118 | }).exec(); | 116 | }).exec(); |
119 | } | 117 | } |
diff --git a/framework/domain/accountfactory.cpp b/framework/domain/accountfactory.cpp index 10f01f65..6261eaf1 100644 --- a/framework/domain/accountfactory.cpp +++ b/framework/domain/accountfactory.cpp | |||
@@ -44,7 +44,7 @@ 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::IdentityFilter(accountId.toUtf8())) |
47 | .then<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(); |
50 | }).exec(); | 50 | }).exec(); |
diff --git a/framework/domain/accountscontroller.cpp b/framework/domain/accountscontroller.cpp index 2f47fa03..5cb60d0c 100644 --- a/framework/domain/accountscontroller.cpp +++ b/framework/domain/accountscontroller.cpp | |||
@@ -34,9 +34,9 @@ void AccountsController::createAccount(const QString &accountType) | |||
34 | { | 34 | { |
35 | auto account = Sink::ApplicationDomain::ApplicationDomainType::createEntity<Sink::ApplicationDomain::SinkAccount>(); | 35 | auto account = Sink::ApplicationDomain::ApplicationDomainType::createEntity<Sink::ApplicationDomain::SinkAccount>(); |
36 | account.setProperty("type", accountType); | 36 | account.setProperty("type", accountType); |
37 | Sink::Store::create(account).then<void>([]() {}, | 37 | Sink::Store::create(account).syncThen<void>([](const KAsync::Error &error) { |
38 | [](int errorCode, const QString &errorMessage) { | 38 | if (error) { |
39 | qWarning() << "Error while creating account: " << errorMessage; | 39 | qWarning() << "Error while creating account: " << error.errorMessage; |
40 | }) | 40 | } |
41 | .exec(); | 41 | }).exec(); |
42 | } | 42 | } |
diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index 921fe748..f8a4e9ff 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp | |||
@@ -106,7 +106,7 @@ static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", | |||
106 | query += Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::transport); | 106 | query += Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::transport); |
107 | query += Sink::Query::AccountFilter(accountId); | 107 | query += Sink::Query::AccountFilter(accountId); |
108 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(query) | 108 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(query) |
109 | .then<void, KAsync::Job<void>, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([=](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) -> KAsync::Job<void> { | 109 | .then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([=](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) -> KAsync::Job<void> { |
110 | if (!resources.isEmpty()) { | 110 | if (!resources.isEmpty()) { |
111 | auto resourceId = resources[0]->identifier(); | 111 | auto resourceId = resources[0]->identifier(); |
112 | SinkTrace() << "Sending message via resource: " << resourceId; | 112 | SinkTrace() << "Sending message via resource: " << resourceId; |
@@ -141,7 +141,7 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", | |||
141 | query += Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::drafts); | 141 | query += Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::drafts); |
142 | query += Sink::Query::AccountFilter(accountId); | 142 | query += Sink::Query::AccountFilter(accountId); |
143 | return Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(query) | 143 | return Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(query) |
144 | .then<void, KAsync::Job<void>, Sink::ApplicationDomain::SinkResource>([=](const Sink::ApplicationDomain::SinkResource &resource) -> KAsync::Job<void> { | 144 | .then<void, Sink::ApplicationDomain::SinkResource>([=](const Sink::ApplicationDomain::SinkResource &resource) -> KAsync::Job<void> { |
145 | Sink::ApplicationDomain::Mail mail(resource.identifier()); | 145 | Sink::ApplicationDomain::Mail mail(resource.identifier()); |
146 | mail.setProperty("draft", true); | 146 | mail.setProperty("draft", true); |
147 | mail.setBlobProperty("mimeMessage", message->encodedContent()); | 147 | mail.setBlobProperty("mimeMessage", message->encodedContent()); |
diff --git a/framework/domain/composercontroller.cpp b/framework/domain/composercontroller.cpp index 2dcf1bb1..b2ad7ecc 100644 --- a/framework/domain/composercontroller.cpp +++ b/framework/domain/composercontroller.cpp | |||
@@ -133,7 +133,7 @@ void ComposerController::loadMessage(const QVariant &message, bool loadAsDraft) | |||
133 | { | 133 | { |
134 | Sink::Query query(*message.value<Sink::ApplicationDomain::Mail::Ptr>()); | 134 | Sink::Query query(*message.value<Sink::ApplicationDomain::Mail::Ptr>()); |
135 | query.request<Sink::ApplicationDomain::Mail::MimeMessage>(); | 135 | query.request<Sink::ApplicationDomain::Mail::MimeMessage>(); |
136 | Sink::Store::fetchOne<Sink::ApplicationDomain::Mail>(query).then<void, Sink::ApplicationDomain::Mail>([this, loadAsDraft](const Sink::ApplicationDomain::Mail &mail) { | 136 | Sink::Store::fetchOne<Sink::ApplicationDomain::Mail>(query).syncThen<void, Sink::ApplicationDomain::Mail>([this, loadAsDraft](const Sink::ApplicationDomain::Mail &mail) { |
137 | m_existingMail = mail; | 137 | m_existingMail = mail; |
138 | const auto mailData = KMime::CRLFtoLF(mail.getMimeMessage()); | 138 | const auto mailData = KMime::CRLFtoLF(mail.getMimeMessage()); |
139 | if (!mailData.isEmpty()) { | 139 | if (!mailData.isEmpty()) { |
diff --git a/framework/domain/folderlistmodel.cpp b/framework/domain/folderlistmodel.cpp index 14d3d5a7..000dd263 100644 --- a/framework/domain/folderlistmodel.cpp +++ b/framework/domain/folderlistmodel.cpp | |||
@@ -74,7 +74,7 @@ void FolderListModel::setAccountId(const QVariant &accountId) | |||
74 | { | 74 | { |
75 | const auto account = accountId.toString().toUtf8(); | 75 | const auto account = accountId.toString().toUtf8(); |
76 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query::PropertyFilter("account", QVariant::fromValue(account))) | 76 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query::PropertyFilter("account", QVariant::fromValue(account))) |
77 | .then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([this, account](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { | 77 | .syncThen<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([this, account](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { |
78 | Sink::Query query; | 78 | Sink::Query query; |
79 | query.liveQuery = true; | 79 | query.liveQuery = true; |
80 | query.requestedProperties << "name" << "icon" << "parent"; | 80 | query.requestedProperties << "name" << "icon" << "parent"; |
diff --git a/framework/domain/identitiesmodel.cpp b/framework/domain/identitiesmodel.cpp index adb5d625..1958d2f5 100644 --- a/framework/domain/identitiesmodel.cpp +++ b/framework/domain/identitiesmodel.cpp | |||
@@ -83,7 +83,7 @@ void IdentitiesModel::runQuery(const Sink::Query &query) | |||
83 | setSourceModel(mModel.data()); | 83 | setSourceModel(mModel.data()); |
84 | 84 | ||
85 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkAccount>(Sink::Query()) | 85 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkAccount>(Sink::Query()) |
86 | .then<void, QList<Sink::ApplicationDomain::SinkAccount::Ptr> >([this](const QList<Sink::ApplicationDomain::SinkAccount::Ptr> &accounts) { | 86 | .syncThen<void, QList<Sink::ApplicationDomain::SinkAccount::Ptr> >([this](const QList<Sink::ApplicationDomain::SinkAccount::Ptr> &accounts) { |
87 | for (const auto &account : accounts) { | 87 | for (const auto &account : accounts) { |
88 | mAccountNames.insert(account->identifier(), account->getProperty("name").toString()); | 88 | mAccountNames.insert(account->identifier(), account->getProperty("name").toString()); |
89 | mAccountIcons.insert(account->identifier(), account->getProperty("icon").toString()); | 89 | mAccountIcons.insert(account->identifier(), account->getProperty("icon").toString()); |
diff --git a/framework/domain/settings/accountsettings.cpp b/framework/domain/settings/accountsettings.cpp index cf348f39..9a3be059 100644 --- a/framework/domain/settings/accountsettings.cpp +++ b/framework/domain/settings/accountsettings.cpp | |||
@@ -135,18 +135,18 @@ void AccountSettings::saveAccount() | |||
135 | account.setProperty("name", mName); | 135 | account.setProperty("name", mName); |
136 | account.setProperty("icon", mIcon); | 136 | account.setProperty("icon", mIcon); |
137 | Q_ASSERT(!account.identifier().isEmpty()); | 137 | Q_ASSERT(!account.identifier().isEmpty()); |
138 | Sink::Store::modify(account).then<void>([]() {}, | 138 | Sink::Store::modify(account) |
139 | [](int errorCode, const QString &errorMessage) { | 139 | .onError([](const KAsync::Error &error) { |
140 | qWarning() << "Error while creating account: " << errorMessage; | 140 | qWarning() << "Error while creating account: " << error.errorMessage;; |
141 | }) | 141 | }) |
142 | .exec(); | 142 | .exec(); |
143 | } | 143 | } |
144 | 144 | ||
145 | void AccountSettings::loadAccount() | 145 | void AccountSettings::loadAccount() |
146 | { | 146 | { |
147 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | 147 | Q_ASSERT(!mAccountIdentifier.isEmpty()); |
148 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query::IdentityFilter(mAccountIdentifier)) | 148 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query::IdentityFilter(mAccountIdentifier)) |
149 | .then<void, Sink::ApplicationDomain::SinkAccount>([this](const Sink::ApplicationDomain::SinkAccount &account) { | 149 | .syncThen<void, Sink::ApplicationDomain::SinkAccount>([this](const Sink::ApplicationDomain::SinkAccount &account) { |
150 | mIcon = account.getProperty("icon").toString(); | 150 | mIcon = account.getProperty("icon").toString(); |
151 | mName = account.getProperty("name").toString(); | 151 | mName = account.getProperty("name").toString(); |
152 | emit changed(); | 152 | emit changed(); |
@@ -156,46 +156,43 @@ void AccountSettings::loadAccount() | |||
156 | void AccountSettings::loadImapResource() | 156 | void AccountSettings::loadImapResource() |
157 | { | 157 | { |
158 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(mAccountIdentifier) + Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::storage)) | 158 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(mAccountIdentifier) + Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::storage)) |
159 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 159 | .syncThen<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { |
160 | mImapIdentifier = resource.identifier(); | 160 | mImapIdentifier = resource.identifier(); |
161 | mImapServer = resource.getProperty("server").toString(); | 161 | mImapServer = resource.getProperty("server").toString(); |
162 | mImapUsername = resource.getProperty("username").toString(); | 162 | mImapUsername = resource.getProperty("username").toString(); |
163 | mImapPassword = resource.getProperty("password").toString(); | 163 | mImapPassword = resource.getProperty("password").toString(); |
164 | emit imapResourceChanged(); | 164 | emit imapResourceChanged(); |
165 | }, | 165 | }).onError([](const KAsync::Error &error) { |
166 | [](int errorCode, const QString &errorMessage) { | 166 | qWarning() << "Failed to find the imap resource: " << error.errorMessage; |
167 | qWarning() << "Failed to find the imap resource: " << errorMessage; | ||
168 | }).exec(); | 167 | }).exec(); |
169 | } | 168 | } |
170 | 169 | ||
171 | void AccountSettings::loadMaildirResource() | 170 | void AccountSettings::loadMaildirResource() |
172 | { | 171 | { |
173 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(mAccountIdentifier) + Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::storage)) | 172 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(mAccountIdentifier) + Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::storage)) |
174 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 173 | .syncThen<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { |
175 | mMaildirIdentifier = resource.identifier(); | 174 | mMaildirIdentifier = resource.identifier(); |
176 | auto path = resource.getProperty("path").toString(); | 175 | auto path = resource.getProperty("path").toString(); |
177 | if (mPath != path) { | 176 | if (mPath != path) { |
178 | mPath = path; | 177 | mPath = path; |
179 | emit pathChanged(); | 178 | emit pathChanged(); |
180 | } | 179 | } |
181 | }, | 180 | }).onError([](const KAsync::Error &error) { |
182 | [](int errorCode, const QString &errorMessage) { | 181 | qWarning() << "Failed to find the maildir resource: " << error.errorMessage; |
183 | qWarning() << "Failed to find the maildir resource: " << errorMessage; | ||
184 | }).exec(); | 182 | }).exec(); |
185 | } | 183 | } |
186 | 184 | ||
187 | void AccountSettings::loadMailtransportResource() | 185 | void AccountSettings::loadMailtransportResource() |
188 | { | 186 | { |
189 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(mAccountIdentifier) + Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::transport)) | 187 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(mAccountIdentifier) + Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::transport)) |
190 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 188 | .syncThen<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { |
191 | mMailtransportIdentifier = resource.identifier(); | 189 | mMailtransportIdentifier = resource.identifier(); |
192 | mSmtpServer = resource.getProperty("server").toString(); | 190 | mSmtpServer = resource.getProperty("server").toString(); |
193 | mSmtpUsername = resource.getProperty("username").toString(); | 191 | mSmtpUsername = resource.getProperty("username").toString(); |
194 | mSmtpPassword = resource.getProperty("password").toString(); | 192 | mSmtpPassword = resource.getProperty("password").toString(); |
195 | emit smtpResourceChanged(); | 193 | emit smtpResourceChanged(); |
196 | }, | 194 | }).onError([](const KAsync::Error &error) { |
197 | [](int errorCode, const QString &errorMessage) { | 195 | qWarning() << "Failed to find the smtp resource: " << error.errorMessage; |
198 | qWarning() << "Failed to find the smtp resource: " << errorMessage; | ||
199 | }).exec(); | 196 | }).exec(); |
200 | } | 197 | } |
201 | 198 | ||
@@ -203,14 +200,13 @@ void AccountSettings::loadIdentity() | |||
203 | { | 200 | { |
204 | //FIXME this assumes that we only ever have one identity per account | 201 | //FIXME this assumes that we only ever have one identity per account |
205 | Sink::Store::fetchOne<Sink::ApplicationDomain::Identity>(Sink::Query::AccountFilter(mAccountIdentifier)) | 202 | Sink::Store::fetchOne<Sink::ApplicationDomain::Identity>(Sink::Query::AccountFilter(mAccountIdentifier)) |
206 | .then<void, Sink::ApplicationDomain::Identity>([this](const Sink::ApplicationDomain::Identity &identity) { | 203 | .syncThen<void, Sink::ApplicationDomain::Identity>([this](const Sink::ApplicationDomain::Identity &identity) { |
207 | mIdentityIdentifier = identity.identifier(); | 204 | mIdentityIdentifier = identity.identifier(); |
208 | mUsername = identity.getProperty("username").toString(); | 205 | mUsername = identity.getProperty("username").toString(); |
209 | mEmailAddress = identity.getProperty("address").toString(); | 206 | mEmailAddress = identity.getProperty("address").toString(); |
210 | emit identityChanged(); | 207 | emit identityChanged(); |
211 | }, | 208 | }).onError([](const KAsync::Error &error) { |
212 | [](int errorCode, const QString &errorMessage) { | 209 | qWarning() << "Failed to find the identity resource: " << error.errorMessage; |
213 | qWarning() << "Failed to find the identity resource: " << errorMessage; | ||
214 | }).exec(); | 210 | }).exec(); |
215 | } | 211 | } |
216 | 212 | ||
@@ -224,21 +220,22 @@ static QByteArray saveResource(const QByteArray &accountIdentifier, const QByteA | |||
224 | for (const auto &pair : properties) { | 220 | for (const auto &pair : properties) { |
225 | resource.setProperty(pair.first, pair.second); | 221 | resource.setProperty(pair.first, pair.second); |
226 | } | 222 | } |
227 | Sink::Store::modify(resource).then<void>([](){}, [](int errorCode, const QString &errorMessage) { | 223 | Sink::Store::modify(resource) |
228 | qWarning() << "Error while modifying resource: " << errorMessage; | 224 | .onError([](const KAsync::Error &error) { |
229 | }) | 225 | qWarning() << "Error while modifying resource: " << error.errorMessage; |
230 | .exec(); | 226 | }) |
227 | .exec(); | ||
231 | } else { | 228 | } else { |
232 | auto resource = ResourceType::create(accountIdentifier); | 229 | auto resource = ResourceType::create(accountIdentifier); |
233 | auto newIdentifier = resource.identifier(); | 230 | auto newIdentifier = resource.identifier(); |
234 | for (const auto &pair : properties) { | 231 | for (const auto &pair : properties) { |
235 | resource.setProperty(pair.first, pair.second); | 232 | resource.setProperty(pair.first, pair.second); |
236 | } | 233 | } |
237 | Sink::Store::create(resource).template then<void>([]() {}, | 234 | Sink::Store::create(resource) |
238 | [](int errorCode, const QString &errorMessage) { | 235 | .onError([](const KAsync::Error &error) { |
239 | qWarning() << "Error while creating resource: " << errorMessage; | 236 | qWarning() << "Error while creating resource: " << error.errorMessage; |
240 | }) | 237 | }) |
241 | .exec(); | 238 | .exec(); |
242 | return newIdentifier; | 239 | return newIdentifier; |
243 | } | 240 | } |
244 | return identifier; | 241 | return identifier; |
@@ -275,8 +272,9 @@ void AccountSettings::saveIdentity() | |||
275 | Sink::ApplicationDomain::Identity identity(mMailtransportIdentifier); | 272 | Sink::ApplicationDomain::Identity identity(mMailtransportIdentifier); |
276 | identity.setProperty("username", mUsername); | 273 | identity.setProperty("username", mUsername); |
277 | identity.setProperty("address", mEmailAddress); | 274 | identity.setProperty("address", mEmailAddress); |
278 | Sink::Store::modify(identity).then<void>([](){}, [](int errorCode, const QString &errorMessage) { | 275 | Sink::Store::modify(identity) |
279 | qWarning() << "Error while modifying identity: " << errorMessage; | 276 | .onError([](const KAsync::Error &error) { |
277 | qWarning() << "Error while modifying identity: " << error.errorMessage; | ||
280 | }) | 278 | }) |
281 | .exec(); | 279 | .exec(); |
282 | } else { | 280 | } else { |
@@ -285,9 +283,9 @@ void AccountSettings::saveIdentity() | |||
285 | identity.setProperty("account", mAccountIdentifier); | 283 | identity.setProperty("account", mAccountIdentifier); |
286 | identity.setProperty("username", mUsername); | 284 | identity.setProperty("username", mUsername); |
287 | identity.setProperty("address", mEmailAddress); | 285 | identity.setProperty("address", mEmailAddress); |
288 | Sink::Store::create(identity).then<void>([]() {}, | 286 | Sink::Store::create(identity) |
289 | [](int errorCode, const QString &errorMessage) { | 287 | .onError([](const KAsync::Error &error) { |
290 | qWarning() << "Error while creating identity: " << errorMessage; | 288 | qWarning() << "Error while creating identity: " << error.errorMessage; |
291 | }) | 289 | }) |
292 | .exec(); | 290 | .exec(); |
293 | } | 291 | } |
@@ -299,9 +297,9 @@ void AccountSettings::removeResource(const QByteArray &identifier) | |||
299 | qWarning() << "We're missing an identifier"; | 297 | qWarning() << "We're missing an identifier"; |
300 | } else { | 298 | } else { |
301 | Sink::ApplicationDomain::SinkResource resource("", identifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 299 | Sink::ApplicationDomain::SinkResource resource("", identifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
302 | Sink::Store::remove(resource).template then<void>([]() {}, | 300 | Sink::Store::remove(resource) |
303 | [](int errorCode, const QString &errorMessage) { | 301 | .onError([](const KAsync::Error &error) { |
304 | qWarning() << "Error while removing resource: " << errorMessage; | 302 | qWarning() << "Error while removing resource: " << error.errorMessage; |
305 | }) | 303 | }) |
306 | .exec(); | 304 | .exec(); |
307 | } | 305 | } |
@@ -313,9 +311,9 @@ void AccountSettings::removeAccount() | |||
313 | qWarning() << "We're missing an identifier"; | 311 | qWarning() << "We're missing an identifier"; |
314 | } else { | 312 | } else { |
315 | Sink::ApplicationDomain::SinkAccount account("", mAccountIdentifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 313 | Sink::ApplicationDomain::SinkAccount account("", mAccountIdentifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
316 | Sink::Store::remove(account).then<void>([]() {}, | 314 | Sink::Store::remove(account) |
317 | [](int errorCode, const QString &errorMessage) { | 315 | .onError([](const KAsync::Error &error) { |
318 | qWarning() << "Error while removing account: " << errorMessage; | 316 | qWarning() << "Error while removing account: " << error.errorMessage; |
319 | }) | 317 | }) |
320 | .exec(); | 318 | .exec(); |
321 | } | 319 | } |
@@ -327,9 +325,9 @@ void AccountSettings::removeIdentity() | |||
327 | qWarning() << "We're missing an identifier"; | 325 | qWarning() << "We're missing an identifier"; |
328 | } else { | 326 | } else { |
329 | Sink::ApplicationDomain::Identity identity("", mIdentityIdentifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 327 | Sink::ApplicationDomain::Identity identity("", mIdentityIdentifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
330 | Sink::Store::remove(identity).then<void>([]() {}, | 328 | Sink::Store::remove(identity) |
331 | [](int errorCode, const QString &errorMessage) { | 329 | .onError([](const KAsync::Error &error) { |
332 | qWarning() << "Error while removing identity: " << errorMessage; | 330 | qWarning() << "Error while removing identity: " << error.errorMessage; |
333 | }) | 331 | }) |
334 | .exec(); | 332 | .exec(); |
335 | } | 333 | } |