diff options
-rw-r--r-- | accounts/maildir/maildirsettings.cpp | 16 | ||||
-rw-r--r-- | framework/domain/actions/sinkactions.cpp | 7 |
2 files changed, 9 insertions, 14 deletions
diff --git a/accounts/maildir/maildirsettings.cpp b/accounts/maildir/maildirsettings.cpp index 96b75a1e..c66f9729 100644 --- a/accounts/maildir/maildirsettings.cpp +++ b/accounts/maildir/maildirsettings.cpp | |||
@@ -57,7 +57,7 @@ void MaildirSettings::setAccountIdentifier(const QByteArray &id) | |||
57 | emit changed(); | 57 | emit changed(); |
58 | }).exec(); | 58 | }).exec(); |
59 | 59 | ||
60 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::PropertyFilter("account", QVariant::fromValue(id)) + Sink::Query::PropertyFilter("type", QString("org.kde.maildir"))) | 60 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(id) + Sink::Query::CapabilityFilter("storage")) |
61 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 61 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { |
62 | mIdentifier = resource.identifier(); | 62 | mIdentifier = resource.identifier(); |
63 | auto path = resource.getProperty("path").toString(); | 63 | auto path = resource.getProperty("path").toString(); |
@@ -70,7 +70,7 @@ void MaildirSettings::setAccountIdentifier(const QByteArray &id) | |||
70 | qWarning() << "Failed to find the maildir resource: " << errorMessage; | 70 | qWarning() << "Failed to find the maildir resource: " << errorMessage; |
71 | }).exec(); | 71 | }).exec(); |
72 | 72 | ||
73 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::PropertyFilter("account", QVariant::fromValue(id)) + Sink::Query::PropertyFilter("type", QString("org.kde.mailtransport"))) | 73 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::AccountFilter(id) + Sink::Query::CapabilityFilter("transport")) |
74 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | 74 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { |
75 | mMailtransportIdentifier = resource.identifier(); | 75 | mMailtransportIdentifier = resource.identifier(); |
76 | mSmtpServer = resource.getProperty("server").toString(); | 76 | mSmtpServer = resource.getProperty("server").toString(); |
@@ -83,7 +83,7 @@ void MaildirSettings::setAccountIdentifier(const QByteArray &id) | |||
83 | }).exec(); | 83 | }).exec(); |
84 | 84 | ||
85 | //FIXME this assumes that we only ever have one identity per account | 85 | //FIXME this assumes that we only ever have one identity per account |
86 | Sink::Store::fetchOne<Sink::ApplicationDomain::Identity>(Sink::Query::PropertyFilter("account", QVariant::fromValue(id))) | 86 | Sink::Store::fetchOne<Sink::ApplicationDomain::Identity>(Sink::Query::AccountFilter(id)) |
87 | .then<void, Sink::ApplicationDomain::Identity>([this](const Sink::ApplicationDomain::Identity &identity) { | 87 | .then<void, Sink::ApplicationDomain::Identity>([this](const Sink::ApplicationDomain::Identity &identity) { |
88 | mIdentityIdentifier = identity.identifier(); | 88 | mIdentityIdentifier = identity.identifier(); |
89 | mUsername = identity.getProperty("username").toString(); | 89 | mUsername = identity.getProperty("username").toString(); |
@@ -176,11 +176,9 @@ void MaildirSettings::save() | |||
176 | }) | 176 | }) |
177 | .exec(); | 177 | .exec(); |
178 | } else { | 178 | } else { |
179 | auto resource = Sink::ApplicationDomain::ApplicationDomainType::createEntity<Sink::ApplicationDomain::SinkResource>(); | 179 | auto resource = Sink::ApplicationDomain::MaildirResource::create(mAccountIdentifier); |
180 | mIdentifier = resource.identifier(); | ||
181 | resource.setProperty("path", property("path")); | 180 | resource.setProperty("path", property("path")); |
182 | resource.setProperty("type", "org.kde.maildir"); | 181 | mIdentifier = resource.identifier(); |
183 | resource.setProperty("account", mAccountIdentifier); | ||
184 | Sink::Store::create(resource).then<void>([]() {}, | 182 | Sink::Store::create(resource).then<void>([]() {}, |
185 | [](int errorCode, const QString &errorMessage) { | 183 | [](int errorCode, const QString &errorMessage) { |
186 | qWarning() << "Error while creating resource: " << errorMessage; | 184 | qWarning() << "Error while creating resource: " << errorMessage; |
@@ -198,10 +196,8 @@ void MaildirSettings::save() | |||
198 | }) | 196 | }) |
199 | .exec(); | 197 | .exec(); |
200 | } else { | 198 | } else { |
201 | auto resource = Sink::ApplicationDomain::ApplicationDomainType::createEntity<Sink::ApplicationDomain::SinkResource>(); | 199 | auto resource = Sink::ApplicationDomain::MailtransportResource::create(mAccountIdentifier); |
202 | mMailtransportIdentifier = resource.identifier(); | 200 | mMailtransportIdentifier = resource.identifier(); |
203 | resource.setProperty("type", "org.kde.mailtransport"); | ||
204 | resource.setProperty("account", mAccountIdentifier); | ||
205 | resource.setProperty("server", mSmtpServer); | 201 | resource.setProperty("server", mSmtpServer); |
206 | resource.setProperty("username", mSmtpUsername); | 202 | resource.setProperty("username", mSmtpUsername); |
207 | resource.setProperty("password", mSmtpPassword); | 203 | resource.setProperty("password", mSmtpPassword); |
diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index e8f1824b..354a5aca 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp | |||
@@ -85,8 +85,8 @@ static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", | |||
85 | qWarning() << "Sending a mail: "; | 85 | qWarning() << "Sending a mail: "; |
86 | 86 | ||
87 | Sink::Query query; | 87 | Sink::Query query; |
88 | query += Sink::Query::PropertyFilter("type", "org.kde.mailtransport"); | 88 | query += Sink::Query::CapabilityFilter("transport"); |
89 | query += Sink::Query::PropertyFilter("account", QVariant::fromValue(accountId)); | 89 | query += Sink::Query::AccountFilter(accountId); |
90 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(query) | 90 | Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(query) |
91 | .then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([=](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { | 91 | .then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([=](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { |
92 | if (!resources.isEmpty()) { | 92 | if (!resources.isEmpty()) { |
@@ -120,8 +120,7 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", | |||
120 | 120 | ||
121 | if (existingMail.identifier().isEmpty()) { | 121 | if (existingMail.identifier().isEmpty()) { |
122 | Sink::Query query; | 122 | Sink::Query query; |
123 | //TODO replace with capability filter | 123 | query += Sink::Query::CapabilityFilter("drafts"); |
124 | query += Sink::Query::PropertyFilter("type", "org.kde.maildir"); | ||
125 | query += Sink::Query::AccountFilter(accountId); | 124 | query += Sink::Query::AccountFilter(accountId); |
126 | return Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(query) | 125 | return Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(query) |
127 | .then<void, KAsync::Job<void>, Sink::ApplicationDomain::SinkResource>([=](const Sink::ApplicationDomain::SinkResource &resource) -> KAsync::Job<void> { | 126 | .then<void, KAsync::Job<void>, Sink::ApplicationDomain::SinkResource>([=](const Sink::ApplicationDomain::SinkResource &resource) -> KAsync::Job<void> { |