summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-06-23 07:53:18 +0200
committerMontel Laurent <[email protected]>2016-06-23 07:53:18 +0200
commitf69606156411bf5a362dcc3510d74435b6b376c6 (patch)
tree8567a8b995a3a0b9a571ad9eea42619906b52e54
parent6fdf0005e9d2ae3dc30c78d467efd1b142b5d46a (diff)
Extract emails
-rw-r--r--kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp40
-rw-r--r--kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp11
2 files changed, 28 insertions, 23 deletions
diff --git a/kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp b/kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp
index 116ebef..99d41a2 100644
--- a/kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp
+++ b/kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp
@@ -55,38 +55,38 @@ void CheckDuplicateEmailsJobTest::shouldReturnEmails_data()
QTest::newRow("empty") << QStringList() << QMap<QString, int>();
QStringList lst;
- lst.append(QStringLiteral("foo"));
- lst.append(QStringLiteral("bla"));
- lst.append(QStringLiteral("blo"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
QTest::newRow("emptyresultbutnotemptylist") << lst << QMap<QString, int>();
lst.clear();
- lst.append(QStringLiteral("foo"));
- lst.append(QStringLiteral("foo"));
- lst.append(QStringLiteral("blo"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
QMap<QString, int> result;
- result.insert(QStringLiteral("foo"), 2);
+ result.insert(QStringLiteral("[email protected]"), 2);
QTest::newRow("oneduplicateemails") << lst << result;
lst.clear();
- lst.append(QStringLiteral("foo"));
- lst.append(QStringLiteral("foo"));
- lst.append(QStringLiteral("blo"));
- lst.append(QStringLiteral("blo"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
result.clear();
- result.insert(QStringLiteral("foo"), 2);
- result.insert(QStringLiteral("blo"), 2);
+ result.insert(QStringLiteral("[email protected]"), 2);
+ result.insert(QStringLiteral("[email protected]"), 2);
QTest::newRow("twoduplicateemails") << lst << result;
lst.clear();
- lst.append(QStringLiteral("foo"));
- lst.append(QStringLiteral("foo"));
- lst.append(QStringLiteral("foo"));
- lst.append(QStringLiteral("blo"));
- lst.append(QStringLiteral("blo"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
+ lst.append(QStringLiteral("[email protected]"));
result.clear();
- result.insert(QStringLiteral("foo"), 3);
- result.insert(QStringLiteral("blo"), 2);
+ result.insert(QStringLiteral("[email protected]"), 3);
+ result.insert(QStringLiteral("[email protected]"), 2);
QTest::newRow("twoduplicateemailswithdifferentvalue") << lst << result;
}
diff --git a/kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp b/kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp
index 17d286a..0726666 100644
--- a/kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp
+++ b/kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp
@@ -17,6 +17,8 @@
Boston, MA 02110-1301, USA.
*/
#include "checkduplicateemailsjob.h"
+#include <KEmailAddress>
+#include <QDebug>
CheckDuplicateEmailsJob::CheckDuplicateEmailsJob()
{
@@ -36,11 +38,14 @@ void CheckDuplicateEmailsJob::start()
}
QMap<QString, int> results;
Q_FOREACH(const QString &email, mEmails) {
- int val = results.value(email, 0);
+ QString tname, temail;
+ KEmailAddress::extractEmailAddressAndName(email, temail, tname); // ignore return value
+
+ int val = results.value(temail, 0);
if (val == 0) {
- results.insert(email, val+1);
+ results.insert(temail, val+1);
} else {
- results[email] = val+1;
+ results[temail] = val+1;
}
}
QMapIterator<QString, int> i(results);