diff options
Diffstat (limited to 'framework/mail/actions/mailactions.cpp')
-rw-r--r-- | framework/mail/actions/mailactions.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/framework/mail/actions/mailactions.cpp b/framework/mail/actions/mailactions.cpp new file mode 100644 index 00000000..dab0533e --- /dev/null +++ b/framework/mail/actions/mailactions.cpp | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include <actions/context.h> | ||
20 | #include <actions/actionhandler.h> | ||
21 | |||
22 | #include "../mailtransport.h" | ||
23 | #include <KMime/Message> | ||
24 | #include <QByteArray> | ||
25 | #include <QVariant> | ||
26 | #include <QDebug> | ||
27 | |||
28 | using namespace Kube; | ||
29 | |||
30 | static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", | ||
31 | [](Context *context) -> bool { | ||
32 | auto username = context->property("username").value<QByteArray>(); | ||
33 | auto password = context->property("password").value<QByteArray>(); | ||
34 | auto server = context->property("server").value<QByteArray>(); | ||
35 | auto message = context->property("message").value<KMime::Message::Ptr>(); | ||
36 | return !username.isEmpty() && !password.isEmpty() && !server.isEmpty() && message; | ||
37 | }, | ||
38 | [](Context *context) { | ||
39 | auto username = context->property("username").value<QByteArray>(); | ||
40 | auto password = context->property("password").value<QByteArray>(); | ||
41 | auto server = context->property("server").value<QByteArray>(); | ||
42 | //For ssl use "smtps://mainserver.example.net | ||
43 | QByteArray cacert; // = "/path/to/certificate.pem"; | ||
44 | auto message = context->property("message").value<KMime::Message::Ptr>(); | ||
45 | qWarning() << "Sending a mail: "; | ||
46 | MailTransport::sendMessage(message, server, username, password, cacert); | ||
47 | } | ||
48 | ); | ||