Commit 2d3742ac authored by David Faure's avatar David Faure
Browse files

KMail: support passing --cc/--bcc multiple times

This will be useful so that the upcoming KMailClientLauncherJob
doesn't need the splitEmailAddressList fork and can just deal with
a list of CC emails directly.

Drive by: simplify --attach handling using range-for.
Testing for "--" (end of options) is unnecessary, QCommandLineParser
handles that.
parent acfa81ac
Pipeline #68570 passed with stage
in 23 minutes and 8 seconds
......@@ -9,8 +9,12 @@ static void kmail_options(QCommandLineParser *parser)
QList<QCommandLineOption> options;
options << QCommandLineOption(QStringList() << QStringLiteral("s") << QStringLiteral("subject"), i18n("Set subject of message"), QStringLiteral("subject"))
<< QCommandLineOption(QStringList() << QStringLiteral("c") << QStringLiteral("cc"), i18n("Send CC: to 'address'"), QStringLiteral("address"))
<< QCommandLineOption(QStringList() << QStringLiteral("b") << QStringLiteral("bcc"), i18n("Send BCC: to 'address'"), QStringLiteral("address"))
<< QCommandLineOption(QStringList() << QStringLiteral("c") << QStringLiteral("cc"),
i18n("Send CC: to 'address'. This can be repeated"),
QStringLiteral("address"))
<< QCommandLineOption(QStringList() << QStringLiteral("b") << QStringLiteral("bcc"),
i18n("Send BCC: to 'address'. This can be repeated"),
QStringLiteral("address"))
<< QCommandLineOption(QStringList() << QStringLiteral("r") << QStringLiteral("replyTo"),
i18n("Set replyTo to 'address'"),
QStringLiteral("address"))
......
......@@ -330,14 +330,16 @@ bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args
}
}
if (parser.isSet(QStringLiteral("cc"))) {
const QStringList ccList = parser.values(QStringLiteral("cc"));
if (!ccList.isEmpty()) {
mailto = true;
cc = parser.value(QStringLiteral("cc"));
cc = ccList.join(QStringLiteral(", "));
}
if (parser.isSet(QStringLiteral("bcc"))) {
const QStringList bccList = parser.values(QStringLiteral("bcc"));
if (!bccList.isEmpty()) {
mailto = true;
bcc = parser.value(QStringLiteral("bcc"));
bcc = bccList.join(QStringLiteral(", "));
}
if (parser.isSet(QStringLiteral("replyTo"))) {
......@@ -359,12 +361,9 @@ bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args
const QStringList attachList = parser.values(QStringLiteral("attach"));
if (!attachList.isEmpty()) {
mailto = true;
QStringList::ConstIterator end = attachList.constEnd();
for (QStringList::ConstIterator it = attachList.constBegin(); it != end; ++it) {
if (!(*it).isEmpty()) {
if ((*it) != QLatin1String("--")) {
attachURLs.append(makeAbsoluteUrl(*it, workingDir));
}
for (const QString &attach : attachList) {
if (!attach.isEmpty()) {
attachURLs.append(makeAbsoluteUrl(attach, workingDir));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment