diff --git a/src/email.cpp b/src/email.cpp index 5918247..397cd4e 100644 --- a/src/email.cpp +++ b/src/email.cpp @@ -1,56 +1,60 @@ /* * Copyright © 2017 Red Hat, Inc * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . * * Authors: * Jan Grulich */ #include "email.h" #include #include #include Q_LOGGING_CATEGORY(XdgDesktopPortalKdeEmail, "xdg-desktop-portal-kde-email") EmailPortal::EmailPortal(QObject *parent) : QDBusAbstractAdaptor(parent) { } EmailPortal::~EmailPortal() { } uint EmailPortal::ComposeEmail(const QDBusObjectPath &handle, const QString &app_id, const QString &window, const QVariantMap &options, QVariantMap &results) { Q_UNUSED(results) qCDebug(XdgDesktopPortalKdeEmail) << "ComposeEmail called with parameters:"; qCDebug(XdgDesktopPortalKdeEmail) << " handle: " << handle.path(); qCDebug(XdgDesktopPortalKdeEmail) << " app_id: " << app_id; qCDebug(XdgDesktopPortalKdeEmail) << " window: " << window; qCDebug(XdgDesktopPortalKdeEmail) << " options: " << options; - // TODO attachements - const QString mailtoUrl = QStringLiteral("mailto:%1?subject=%2&body=%3").arg(options.value(QLatin1String("address")).toString()) - .arg(options.value(QLatin1String("subject")).toString()) - .arg(options.value(QLatin1String("body")).toString()); - qCDebug(XdgDesktopPortalKdeEmail) << "Mailto url: " << mailtoUrl; - + QString attachmentString; + const QStringList attachments = options.value(QLatin1String("attachments")).toStringList(); + Q_FOREACH (const QString &attachment, attachments) { + attachmentString += QStringLiteral("&attachment=%1").arg(attachment); + } + + const QString mailtoUrl = QStringLiteral("mailto:%1?subject=%2&body=%3%4").arg(options.value(QLatin1String("address")).toString()) + .arg(options.value(QLatin1String("subject")).toString()) + .arg(options.value(QLatin1String("body")).toString()) + .arg(attachmentString); return QDesktopServices::openUrl(QUrl(mailtoUrl)); }