From dd240d06dc35c50239dec91dcf043f8d4c990953 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 15 Mar 2016 16:51:55 +0100 Subject: Fixed and tested maildirsettings. --- accounts/maildir/maildirsettings.cpp | 49 ++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'accounts/maildir/maildirsettings.cpp') diff --git a/accounts/maildir/maildirsettings.cpp b/accounts/maildir/maildirsettings.cpp index c8b892d7..1d48fc24 100644 --- a/accounts/maildir/maildirsettings.cpp +++ b/accounts/maildir/maildirsettings.cpp @@ -105,7 +105,10 @@ void MaildirSettings::save() if (!mIdentifier.isEmpty()) { Sink::ApplicationDomain::SinkResource resource(mIdentifier); resource.setProperty("path", mPath); - Sink::Store::modify(resource).exec(); + Sink::Store::modify(resource).then([](){}, [](int errorCode, const QString &errorMessage) { + qWarning() << "Error while modifying resource: " << errorMessage; + }) + .exec(); } else { const auto resourceIdentifier = "org.kde.maildir." + QUuid::createUuid().toByteArray(); mIdentifier = resourceIdentifier; @@ -114,31 +117,39 @@ void MaildirSettings::save() resource.setProperty("path", property("path")); resource.setProperty("identifier", resourceIdentifier); resource.setProperty("type", "org.kde.maildir"); - Sink::Store::create(resource).exec(); - Q_ASSERT(!mAccountIdentifier.isEmpty()); - Kube::Account account(mAccountIdentifier); - account.setProperty("maildirResource", resourceIdentifier); - account.save(); - //TODO deal with errors while creating + Sink::Store::create(resource).then([this, resourceIdentifier]() { + Q_ASSERT(!mAccountIdentifier.isEmpty()); + Kube::Account account(mAccountIdentifier); + account.setProperty("maildirResource", resourceIdentifier); + account.save(); + }, + [](int errorCode, const QString &errorMessage) { + qWarning() << "Error while creating resource: " << errorMessage; + }) + .exec(); } } void MaildirSettings::remove() { - if (!mIdentifier.isEmpty()) { + if (mIdentifier.isEmpty()) { qWarning() << "We're missing an identifier"; } else { - Sink::ApplicationDomain::SinkResource resource(mIdentifier); - Sink::Store::remove(resource).exec(); - Kube::Account account(mAccountIdentifier); - account.remove(); - - Kube::Settings settings("accounts"); - auto accounts = settings.property("accounts").toStringList(); - accounts.removeAll(mAccountIdentifier); - settings.setProperty("accounts", accounts); - settings.save(); - //TODO deal with errors while removing + Sink::ApplicationDomain::SinkResource resource("", mIdentifier, 0, QSharedPointer::create()); + Sink::Store::remove(resource).then([this]() { + Kube::Account account(mAccountIdentifier); + account.remove(); + + Kube::Settings settings("accounts"); + auto accounts = settings.property("accounts").toStringList(); + accounts.removeAll(mAccountIdentifier); + settings.setProperty("accounts", accounts); + settings.save(); + }, + [](int errorCode, const QString &errorMessage) { + qWarning() << "Error while removing resource: " << errorMessage; + }) + .exec(); } } -- cgit v1.2.3