Merge remote-tracking branch 'origin/Applications/18.12'

wilder
Laurent Montel 7 years ago
commit 35d3c50707
  1. 2
      CMakeLists.txt
  2. 55
      src/job/handleclickedurljob.cpp
  3. 33
      src/kmkernel.cpp

@ -66,7 +66,7 @@ find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED DBus Network Test Widget
set(LIBGRAVATAR_VERSION_LIB "5.10.40")
set(MAILCOMMON_LIB_VERSION_LIB "5.10.42")
set(KDEPIM_APPS_LIB_VERSION_LIB "5.10.40")
set(MESSAGELIB_LIB_VERSION_LIB "5.10.43")
set(MESSAGELIB_LIB_VERSION_LIB "5.10.45")
set(LIBKLEO_LIB_VERSION_LIB "5.10.40")
set(PIMCOMMON_LIB_VERSION_LIB "5.10.41")
set(LIBKDEPIM_LIB_VERSION_LIB "5.10.40")

@ -45,29 +45,38 @@ void HandleClickedUrlJob::start()
MessageHelper::initHeader(mMsg, KMKernel::self()->identityManager(), mIdentity);
mMsg->contentType()->setCharset("utf-8");
const QMap<QString, QString> fields = MessageCore::StringUtil::parseMailtoUrl(mUrl);
mMsg->to()->fromUnicodeString(fields.value(QStringLiteral("to")), "utf-8");
const QString subject = fields.value(QStringLiteral("subject"));
if (!subject.isEmpty()) {
mMsg->subject()->fromUnicodeString(subject, "utf-8");
}
const QString body = fields.value(QStringLiteral("body"));
if (!body.isEmpty()) {
mMsg->setBody(body.toUtf8());
}
const QString cc = fields.value(QStringLiteral("cc"));
if (!cc.isEmpty()) {
mMsg->cc()->fromUnicodeString(cc, "utf-8");
}
const QString bcc = fields.value(QStringLiteral("bcc"));
if (!bcc.isEmpty()) {
mMsg->bcc()->fromUnicodeString(bcc, "utf-8");
}
const QString attach = fields.value(QStringLiteral("attach"));
if (!attach.isEmpty()) {
qCDebug(KMAIL_LOG) << "Attachment not supported yet";
//TODO
const QList<QPair<QString, QString> > fields = MessageCore::StringUtil::parseMailtoUrl(mUrl);
for (int i = 0; i < fields.count(); ++i) {
const QPair<QString, QString> element = fields.at(i);
if (element.first == QStringLiteral("to")) {
mMsg->to()->fromUnicodeString(element.second, "utf-8");
} else if (element.first == QStringLiteral("subject")) {
const QString subject = element.second;
if (!subject.isEmpty()) {
mMsg->subject()->fromUnicodeString(subject, "utf-8");
}
} else if (element.first == QStringLiteral("body")) {
const QString body = element.second;
if (!body.isEmpty()) {
mMsg->setBody(body.toUtf8());
}
} else if (element.first == QStringLiteral("cc")) {
const QString cc = element.second;
if (!cc.isEmpty()) {
mMsg->cc()->fromUnicodeString(cc, "utf-8");
}
} else if (element.first == QStringLiteral("bcc")) {
const QString bcc = element.second;
if (!bcc.isEmpty()) {
mMsg->bcc()->fromUnicodeString(bcc, "utf-8");
}
} else if (element.first == QStringLiteral("attach")) {
const QString attach = element.second;
if (!attach.isEmpty()) {
qCDebug(KMAIL_LOG) << "Attachment not supported yet";
//TODO
}
}
}
TemplateParser::TemplateParserJob *parser = new TemplateParser::TemplateParserJob(mMsg, TemplateParser::TemplateParserJob::NewMessage, this);

@ -388,37 +388,38 @@ bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args
for (const QString &arg : parser.positionalArguments()) {
if (arg.startsWith(QLatin1String("mailto:"), Qt::CaseInsensitive)) {
const QUrl urlDecoded(QUrl::fromPercentEncoding(arg.toUtf8()));
QMap<QString, QString> values = MessageCore::StringUtil::parseMailtoUrl(urlDecoded);
const QList<QPair<QString, QString> > values = MessageCore::StringUtil::parseMailtoUrl(urlDecoded);
QString previousKey;
for (auto it = values.cbegin(), end = values.cend(); it != end; ++it) {
const QString key = it.key().toLower();
for (int i = 0; i < values.count(); ++i) {
const QPair<QString, QString> element = values.at(i);
const QString key = element.first.toLower();
if (key == QLatin1Literal("to")) {
if (!it->isEmpty()) {
to += *it + QStringLiteral(", ");
if (!element.second.isEmpty()) {
to += element.second + QStringLiteral(", ");
}
previousKey.clear();
} else if (key == QLatin1Literal("cc")) {
if (!it->isEmpty()) {
cc += *it + QStringLiteral(", ");
if (!element.second.isEmpty()) {
cc += element.second + QStringLiteral(", ");
}
previousKey.clear();
} else if (key == QLatin1Literal("bcc")) {
if (!it->isEmpty()) {
bcc += *it + QStringLiteral(", ");
if (!element.second.isEmpty()) {
bcc += element.second + QStringLiteral(", ");
}
previousKey.clear();
} else if (key == QLatin1Literal("subject")) {
subj = it.value();
subj = element.second;
previousKey.clear();
} else if (key == QLatin1Literal("body")) {
body = it.value();
body = element.second;
previousKey = key;
} else if (key == QLatin1Literal("in-reply-to")) {
inReplyTo = it.value();
inReplyTo = element.second;
previousKey.clear();
} else if (key == QLatin1Literal("attachment") || key == QLatin1Literal("attach")) {
if (!it->isEmpty()) {
attachURLs << makeAbsoluteUrl(*it, workingDir);
if (!element.second.isEmpty()) {
attachURLs << makeAbsoluteUrl(element.second, workingDir);
}
previousKey.clear();
} else {
@ -427,9 +428,9 @@ bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args
//QMap<QString, QString> parseMailtoUrl(const QUrl &url) parses correctly url
//But if we have a "&" unknown key we lost it.
if (previousKey == QLatin1Literal("body")) {
body += QLatin1Char('&') + key + QLatin1Char('=') + it.value();
body += QLatin1Char('&') + key + QLatin1Char('=') + element.second;
}
previousKey.clear();
//Don't clear previous key.
}
}
} else {

Loading…
Cancel
Save