Commit 529dd29c authored by Laurent Montel's avatar Laurent Montel 😁

Add bcc support

parent 247e0caf
......@@ -103,10 +103,22 @@ void ViewerPluginExternalScriptParseArgumentTest::shouldReturnBody()
QCOMPARE(parser.parse(lst), result);
}
void ViewerPluginExternalScriptParseArgumentTest::shouldReturnBcc()
{
ViewerPluginExternalScriptParseArgument parser;
KMime::Message::Ptr message(new KMime::Message);
initializeMessage(message);
parser.setMessage(message);
const QStringList lst = { QStringLiteral("%bcc") };
const QStringList result = { QStringLiteral("\"kde1@example.com\"") };
QCOMPARE(parser.parse(lst), result);
}
void ViewerPluginExternalScriptParseArgumentTest::initializeMessage(const KMime::Message::Ptr &msg)
{
QByteArray mail = "From: dfaure@example.com\n"
"To: kde@example.com\n"
"Bcc: kde1@example.com\n"
"Sender: dfaure@example.com\n"
"MIME-Version: 1.0\n"
"Date: 02 Jul 2010 23:58:21 -0000\n"
......
......@@ -38,6 +38,7 @@ private Q_SLOTS:
void shouldReturnTo();
void shouldReturnEmptyStrWhenArgumentIsNotDefined();
void shouldReturnBody();
void shouldReturnBcc();
};
#endif // VIEWERPLUGINEXTERNALSCRIPTPARSEARGUMENTTEST_H
......@@ -10,5 +10,5 @@ Arguments:
- %to returns "to"
- %cc returns "cc"
- %from returns "from"
- %bcc returns "bcc"
......@@ -47,6 +47,9 @@ QStringList ViewerPluginExternalScriptParseArgument::parse(const QStringList &sc
} else if (arg == QString::fromLatin1("%cc")) {
const KMime::Headers::Cc *const cc = mMessage ? mMessage->cc(false) : Q_NULLPTR;
newArguments << QStringLiteral("\"%1\"").arg(cc ? cc->asUnicodeString() : QString());
} else if (arg == QString::fromLatin1("%bcc")) {
const KMime::Headers::Bcc *const bcc = mMessage ? mMessage->bcc(false) : Q_NULLPTR;
newArguments << QStringLiteral("\"%1\"").arg(bcc ? bcc->asUnicodeString() : QString());
} else if (arg == QString::fromLatin1("%body")) {
const QByteArray body = mMessage ? mMessage->body() : Q_NULLPTR;
newArguments << QStringLiteral("\"%1\"").arg(QLatin1String(body));
......
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