diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/mailtransportresource/mailtransportresource.cpp | 21 | ||||
-rw-r--r-- | examples/mailtransportresource/mailtransportresource.h | 10 |
2 files changed, 13 insertions, 18 deletions
diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp index 3d6f8e4..1d90adf 100644 --- a/examples/mailtransportresource/mailtransportresource.cpp +++ b/examples/mailtransportresource/mailtransportresource.cpp | |||
@@ -41,6 +41,13 @@ | |||
41 | 41 | ||
42 | using namespace Sink; | 42 | using namespace Sink; |
43 | 43 | ||
44 | struct Settings { | ||
45 | QString server; | ||
46 | QString username; | ||
47 | QString cacert; | ||
48 | bool testMode; | ||
49 | }; | ||
50 | |||
44 | class MailtransportPreprocessor : public Sink::Preprocessor | 51 | class MailtransportPreprocessor : public Sink::Preprocessor |
45 | { | 52 | { |
46 | public: | 53 | public: |
@@ -91,7 +98,7 @@ public: | |||
91 | 98 | ||
92 | } | 99 | } |
93 | 100 | ||
94 | KAsync::Job<void> send(const ApplicationDomain::Mail &mail, const MailtransportResource::Settings &settings) | 101 | KAsync::Job<void> send(const ApplicationDomain::Mail &mail, const Settings &settings) |
95 | { | 102 | { |
96 | return KAsync::start([=] { | 103 | return KAsync::start([=] { |
97 | if (!syncStore().readValue(mail.identifier()).isEmpty()) { | 104 | if (!syncStore().readValue(mail.identifier()).isEmpty()) { |
@@ -122,7 +129,7 @@ public: | |||
122 | if (settings.server.contains("smtps")) { | 129 | if (settings.server.contains("smtps")) { |
123 | options |= MailTransport::UseTls; | 130 | options |= MailTransport::UseTls; |
124 | } | 131 | } |
125 | if (!MailTransport::sendMessage(msg, settings.server.toUtf8(), settings.username.toUtf8(), settings.password.toUtf8(), settings.cacert.toUtf8(), options)) { | 132 | if (!MailTransport::sendMessage(msg, settings.server.toUtf8(), settings.username.toUtf8(), secret().toUtf8(), settings.cacert.toUtf8(), options)) { |
126 | SinkWarning() << "Failed to send message: " << mail; | 133 | SinkWarning() << "Failed to send message: " << mail; |
127 | emitNotification(Notification::Warning, ApplicationDomain::SyncError, "Failed to send message.", {}, {mail.identifier()}); | 134 | emitNotification(Notification::Warning, ApplicationDomain::SyncError, "Failed to send message.", {}, {mail.identifier()}); |
128 | emitNotification(Notification::Warning, ApplicationDomain::TransmissionError, "Failed to send message.", {}, {mail.identifier()}); | 135 | emitNotification(Notification::Warning, ApplicationDomain::TransmissionError, "Failed to send message.", {}, {mail.identifier()}); |
@@ -193,7 +200,7 @@ public: | |||
193 | 200 | ||
194 | public: | 201 | public: |
195 | QByteArray mResourceInstanceIdentifier; | 202 | QByteArray mResourceInstanceIdentifier; |
196 | MailtransportResource::Settings mSettings; | 203 | Settings mSettings; |
197 | }; | 204 | }; |
198 | 205 | ||
199 | class MailtransportInspector : public Sink::Inspector { | 206 | class MailtransportInspector : public Sink::Inspector { |
@@ -225,15 +232,13 @@ MailtransportResource::MailtransportResource(const Sink::ResourceContext &resour | |||
225 | : Sink::GenericResource(resourceContext) | 232 | : Sink::GenericResource(resourceContext) |
226 | { | 233 | { |
227 | auto config = ResourceConfig::getConfiguration(resourceContext.instanceId()); | 234 | auto config = ResourceConfig::getConfiguration(resourceContext.instanceId()); |
228 | mSettings = {config.value("server").toString(), | 235 | |
236 | auto synchronizer = QSharedPointer<MailtransportSynchronizer>::create(resourceContext); | ||
237 | synchronizer->mSettings = {config.value("server").toString(), | ||
229 | config.value("username").toString(), | 238 | config.value("username").toString(), |
230 | config.value("cacert").toString(), | 239 | config.value("cacert").toString(), |
231 | config.value("password").toString(), | ||
232 | config.value("testmode").toBool() | 240 | config.value("testmode").toBool() |
233 | }; | 241 | }; |
234 | |||
235 | auto synchronizer = QSharedPointer<MailtransportSynchronizer>::create(resourceContext); | ||
236 | synchronizer->mSettings = mSettings; | ||
237 | setupSynchronizer(synchronizer); | 242 | setupSynchronizer(synchronizer); |
238 | setupInspector(QSharedPointer<MailtransportInspector>::create(resourceContext)); | 243 | setupInspector(QSharedPointer<MailtransportInspector>::create(resourceContext)); |
239 | 244 | ||
diff --git a/examples/mailtransportresource/mailtransportresource.h b/examples/mailtransportresource/mailtransportresource.h index 531fcd5..b10011d 100644 --- a/examples/mailtransportresource/mailtransportresource.h +++ b/examples/mailtransportresource/mailtransportresource.h | |||
@@ -26,16 +26,6 @@ class MailtransportResource : public Sink::GenericResource | |||
26 | { | 26 | { |
27 | public: | 27 | public: |
28 | MailtransportResource(const Sink::ResourceContext &resourceContext); | 28 | MailtransportResource(const Sink::ResourceContext &resourceContext); |
29 | |||
30 | struct Settings { | ||
31 | QString server; | ||
32 | QString username; | ||
33 | QString cacert; | ||
34 | QString password; | ||
35 | bool testMode; | ||
36 | }; | ||
37 | private: | ||
38 | Settings mSettings; | ||
39 | }; | 29 | }; |
40 | 30 | ||
41 | class MailtransportResourceFactory : public Sink::ResourceFactory | 31 | class MailtransportResourceFactory : public Sink::ResourceFactory |