diff options
Diffstat (limited to 'accounts/maildir/maildirsettings.cpp')
-rw-r--r-- | accounts/maildir/maildirsettings.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
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() | |||
105 | if (!mIdentifier.isEmpty()) { | 105 | if (!mIdentifier.isEmpty()) { |
106 | Sink::ApplicationDomain::SinkResource resource(mIdentifier); | 106 | Sink::ApplicationDomain::SinkResource resource(mIdentifier); |
107 | resource.setProperty("path", mPath); | 107 | resource.setProperty("path", mPath); |
108 | Sink::Store::modify(resource).exec(); | 108 | Sink::Store::modify(resource).then<void>([](){}, [](int errorCode, const QString &errorMessage) { |
109 | qWarning() << "Error while modifying resource: " << errorMessage; | ||
110 | }) | ||
111 | .exec(); | ||
109 | } else { | 112 | } else { |
110 | const auto resourceIdentifier = "org.kde.maildir." + QUuid::createUuid().toByteArray(); | 113 | const auto resourceIdentifier = "org.kde.maildir." + QUuid::createUuid().toByteArray(); |
111 | mIdentifier = resourceIdentifier; | 114 | mIdentifier = resourceIdentifier; |
@@ -114,31 +117,39 @@ void MaildirSettings::save() | |||
114 | resource.setProperty("path", property("path")); | 117 | resource.setProperty("path", property("path")); |
115 | resource.setProperty("identifier", resourceIdentifier); | 118 | resource.setProperty("identifier", resourceIdentifier); |
116 | resource.setProperty("type", "org.kde.maildir"); | 119 | resource.setProperty("type", "org.kde.maildir"); |
117 | Sink::Store::create(resource).exec(); | 120 | Sink::Store::create(resource).then<void>([this, resourceIdentifier]() { |
118 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | 121 | Q_ASSERT(!mAccountIdentifier.isEmpty()); |
119 | Kube::Account account(mAccountIdentifier); | 122 | Kube::Account account(mAccountIdentifier); |
120 | account.setProperty("maildirResource", resourceIdentifier); | 123 | account.setProperty("maildirResource", resourceIdentifier); |
121 | account.save(); | 124 | account.save(); |
122 | //TODO deal with errors while creating | 125 | }, |
126 | [](int errorCode, const QString &errorMessage) { | ||
127 | qWarning() << "Error while creating resource: " << errorMessage; | ||
128 | }) | ||
129 | .exec(); | ||
123 | } | 130 | } |
124 | } | 131 | } |
125 | 132 | ||
126 | void MaildirSettings::remove() | 133 | void MaildirSettings::remove() |
127 | { | 134 | { |
128 | if (!mIdentifier.isEmpty()) { | 135 | if (mIdentifier.isEmpty()) { |
129 | qWarning() << "We're missing an identifier"; | 136 | qWarning() << "We're missing an identifier"; |
130 | } else { | 137 | } else { |
131 | Sink::ApplicationDomain::SinkResource resource(mIdentifier); | 138 | Sink::ApplicationDomain::SinkResource resource("", mIdentifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
132 | Sink::Store::remove(resource).exec(); | 139 | Sink::Store::remove(resource).then<void>([this]() { |
133 | Kube::Account account(mAccountIdentifier); | 140 | Kube::Account account(mAccountIdentifier); |
134 | account.remove(); | 141 | account.remove(); |
135 | 142 | ||
136 | Kube::Settings settings("accounts"); | 143 | Kube::Settings settings("accounts"); |
137 | auto accounts = settings.property("accounts").toStringList(); | 144 | auto accounts = settings.property("accounts").toStringList(); |
138 | accounts.removeAll(mAccountIdentifier); | 145 | accounts.removeAll(mAccountIdentifier); |
139 | settings.setProperty("accounts", accounts); | 146 | settings.setProperty("accounts", accounts); |
140 | settings.save(); | 147 | settings.save(); |
141 | //TODO deal with errors while removing | 148 | }, |
149 | [](int errorCode, const QString &errorMessage) { | ||
150 | qWarning() << "Error while removing resource: " << errorMessage; | ||
151 | }) | ||
152 | .exec(); | ||
142 | } | 153 | } |
143 | } | 154 | } |
144 | 155 | ||