summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/settings/accountsettings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/domain/settings/accountsettings.cpp')
-rw-r--r--framework/src/domain/settings/accountsettings.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/framework/src/domain/settings/accountsettings.cpp b/framework/src/domain/settings/accountsettings.cpp
index 9f2bcd12..232f7aba 100644
--- a/framework/src/domain/settings/accountsettings.cpp
+++ b/framework/src/domain/settings/accountsettings.cpp
@@ -61,10 +61,12 @@ void AccountSettings::setAccountIdentifier(const QByteArray &id)
61 mCardDavServer = QString(); 61 mCardDavServer = QString();
62 mCardDavUsername = QString(); 62 mCardDavUsername = QString();
63 mCardDavPassword = QString(); 63 mCardDavPassword = QString();
64 mPath = QString();
64 emit changed(); 65 emit changed();
65 emit imapResourceChanged(); 66 emit imapResourceChanged();
66 emit smtpResourceChanged(); 67 emit smtpResourceChanged();
67 emit cardDavResourceChanged(); 68 emit cardDavResourceChanged();
69 emit pathChanged();
68 70
69 load(); 71 load();
70 72
@@ -158,7 +160,7 @@ void AccountSettings::saveAccount()
158 }) 160 })
159 .exec().waitForFinished(); 161 .exec().waitForFinished();
160 } else { 162 } else {
161 qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; 163 qDebug() << "Saving account " << mAccountIdentifier;
162 Q_ASSERT(!mAccountIdentifier.isEmpty()); 164 Q_ASSERT(!mAccountIdentifier.isEmpty());
163 SinkAccount account(mAccountIdentifier); 165 SinkAccount account(mAccountIdentifier);
164 account.setAccountType(mAccountType); 166 account.setAccountType(mAccountType);
@@ -182,12 +184,14 @@ void AccountSettings::loadAccount()
182 mIcon = account.getIcon(); 184 mIcon = account.getIcon();
183 mName = account.getName(); 185 mName = account.getName();
184 emit changed(); 186 emit changed();
187 }).onError([](const KAsync::Error &error) {
188 qWarning() << "Failed to load the account: " << error.errorMessage;
185 }).exec().waitForFinished(); 189 }).exec().waitForFinished();
186} 190}
187 191
188void AccountSettings::loadImapResource() 192void AccountSettings::loadImapResource()
189{ 193{
190 Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) 194 Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).filter<SinkResource::ResourceType>("sink.imap"))
191 .then([this](const SinkResource &resource) { 195 .then([this](const SinkResource &resource) {
192 mImapIdentifier = resource.identifier(); 196 mImapIdentifier = resource.identifier();
193 mImapServer = resource.getProperty("server").toString(); 197 mImapServer = resource.getProperty("server").toString();
@@ -195,28 +199,25 @@ void AccountSettings::loadImapResource()
195 mImapPassword = resource.getProperty("password").toString(); 199 mImapPassword = resource.getProperty("password").toString();
196 emit imapResourceChanged(); 200 emit imapResourceChanged();
197 }).onError([](const KAsync::Error &error) { 201 }).onError([](const KAsync::Error &error) {
198 qWarning() << "Failed to find the imap resource: " << error.errorMessage; 202 qWarning() << "Failed to load the imap resource: " << error.errorMessage;
199 }).exec().waitForFinished(); 203 }).exec().waitForFinished();
200} 204}
201 205
202void AccountSettings::loadMaildirResource() 206void AccountSettings::loadMaildirResource()
203{ 207{
204 Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) 208 Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).filter<SinkResource::ResourceType>("sink.maildir"))
205 .then([this](const SinkResource &resource) { 209 .then([this](const SinkResource &resource) {
206 mMaildirIdentifier = resource.identifier(); 210 mMaildirIdentifier = resource.identifier();
207 auto path = resource.getProperty("path").toString(); 211 mPath = resource.getProperty("path").toString();
208 if (mPath != path) { 212 emit pathChanged();
209 mPath = path;
210 emit pathChanged();
211 }
212 }).onError([](const KAsync::Error &error) { 213 }).onError([](const KAsync::Error &error) {
213 SinkWarning() << "Failed to find the maildir resource: " << error.errorMessage; 214 SinkWarning() << "Failed to load the maildir resource: " << error.errorMessage;
214 }).exec().waitForFinished(); 215 }).exec().waitForFinished();
215} 216}
216 217
217void AccountSettings::loadMailtransportResource() 218void AccountSettings::loadMailtransportResource()
218{ 219{
219 Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport)) 220 Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).filter<SinkResource::ResourceType>("sink.mailtransport"))
220 .then([this](const SinkResource &resource) { 221 .then([this](const SinkResource &resource) {
221 mMailtransportIdentifier = resource.identifier(); 222 mMailtransportIdentifier = resource.identifier();
222 mSmtpServer = resource.getProperty("server").toString(); 223 mSmtpServer = resource.getProperty("server").toString();
@@ -224,7 +225,7 @@ void AccountSettings::loadMailtransportResource()
224 mSmtpPassword = resource.getProperty("password").toString(); 225 mSmtpPassword = resource.getProperty("password").toString();
225 emit smtpResourceChanged(); 226 emit smtpResourceChanged();
226 }).onError([](const KAsync::Error &error) { 227 }).onError([](const KAsync::Error &error) {
227 SinkWarning() << "Failed to find the smtp resource: " << error.errorMessage; 228 SinkWarning() << "Failed to load the smtp resource: " << error.errorMessage;
228 }).exec().waitForFinished(); 229 }).exec().waitForFinished();
229} 230}
230 231
@@ -238,13 +239,13 @@ void AccountSettings::loadIdentity()
238 mEmailAddress = identity.getAddress(); 239 mEmailAddress = identity.getAddress();
239 emit identityChanged(); 240 emit identityChanged();
240 }).onError([](const KAsync::Error &error) { 241 }).onError([](const KAsync::Error &error) {
241 SinkWarning() << "Failed to find the identity resource: " << error.errorMessage; 242 SinkWarning() << "Failed to load the identity: " << error.errorMessage;
242 }).exec().waitForFinished(); 243 }).exec().waitForFinished();
243} 244}
244 245
245void AccountSettings::loadCardDavResource() 246void AccountSettings::loadCardDavResource()
246{ 247{
247 Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Contact::storage)) 248 Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier).filter<SinkResource::ResourceType>("sink.dav"))
248 .then([this](const SinkResource &resource) { 249 .then([this](const SinkResource &resource) {
249 mCardDavIdentifier = resource.identifier(); 250 mCardDavIdentifier = resource.identifier();
250 mCardDavServer = resource.getProperty("server").toString(); 251 mCardDavServer = resource.getProperty("server").toString();
@@ -252,7 +253,7 @@ void AccountSettings::loadCardDavResource()
252 mCardDavPassword = resource.getProperty("password").toString(); 253 mCardDavPassword = resource.getProperty("password").toString();
253 emit cardDavResourceChanged(); 254 emit cardDavResourceChanged();
254 }).onError([](const KAsync::Error &error) { 255 }).onError([](const KAsync::Error &error) {
255 qWarning() << "Failed to find the CardDAV resource: " << error.errorMessage; 256 qWarning() << "Failed to load the CardDAV resource: " << error.errorMessage;
256 }).exec().waitForFinished(); 257 }).exec().waitForFinished();
257} 258}
258 259