File indexing completed on 2024-04-28 16:55:44
0001 /* 0002 * SPDX-FileCopyrightText: 2017 Red Hat Inc 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 * 0006 * SPDX-FileCopyrightText: 2017 Jan Grulich <jgrulich@redhat.com> 0007 */ 0008 0009 #include "email.h" 0010 #include "email_debug.h" 0011 0012 #include <QUrl> 0013 0014 #include <KEMailClientLauncherJob> 0015 0016 EmailPortal::EmailPortal(QObject *parent) 0017 : QDBusAbstractAdaptor(parent) 0018 { 0019 } 0020 0021 EmailPortal::~EmailPortal() 0022 { 0023 } 0024 0025 uint EmailPortal::ComposeEmail(const QDBusObjectPath &handle, const QString &app_id, const QString &window, const QVariantMap &options, QVariantMap &results) 0026 { 0027 Q_UNUSED(results) 0028 0029 qCDebug(XdgDesktopPortalKdeEmail) << "ComposeEmail called with parameters:"; 0030 qCDebug(XdgDesktopPortalKdeEmail) << " handle: " << handle.path(); 0031 qCDebug(XdgDesktopPortalKdeEmail) << " app_id: " << app_id; 0032 qCDebug(XdgDesktopPortalKdeEmail) << " window: " << window; 0033 qCDebug(XdgDesktopPortalKdeEmail) << " options: " << options; 0034 0035 const QStringList addresses = options.contains(QStringLiteral("address")) ? options.value(QStringLiteral("address")).toStringList() 0036 : options.value(QStringLiteral("addresses")).toStringList(); 0037 0038 KEMailClientLauncherJob job; 0039 job.setTo(addresses); 0040 job.setCc(options.value(QStringLiteral("cc")).toStringList()); 0041 job.setBcc(options.value(QStringLiteral("bcc")).toStringList()); 0042 job.setSubject(options.value(QStringLiteral("subject")).toString()); 0043 job.setBody(options.value(QStringLiteral("body")).toString()); 0044 0045 const QStringList attachmentStrings = options.value(QStringLiteral("attachments")).toStringList(); 0046 QList<QUrl> attachments; 0047 for (const QString &attachment : attachmentStrings) { 0048 attachments << QUrl(attachment); 0049 } 0050 job.setAttachments(attachments); 0051 0052 return job.exec(); 0053 }