summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-06-23 07:20:29 +0200
committerMontel Laurent <[email protected]>2016-06-23 07:20:29 +0200
commit018270c108c1d7f6641ef6ce49fb0568d3debd21 (patch)
tree76584d8837224c9e0e46e092f34faaba4d4cf430
parentd575a1db310f5091d9b0d0cd9e51a2ae43b23279 (diff)
Add job
-rw-r--r--kmail/editorsendcheckplugins/checkbeforesend/CMakeLists.txt1
-rw-r--r--kmail/editorsendcheckplugins/checkbeforesend/autotests/CMakeLists.txt5
-rw-r--r--kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp69
-rw-r--r--kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.h39
-rw-r--r--kmail/editorsendcheckplugins/checkbeforesend/checkbeforesendinterface.cpp22
-rw-r--r--kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp47
-rw-r--r--kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.h42
7 files changed, 222 insertions, 3 deletions
diff --git a/kmail/editorsendcheckplugins/checkbeforesend/CMakeLists.txt b/kmail/editorsendcheckplugins/checkbeforesend/CMakeLists.txt
index 9febd9f..a037bb3 100644
--- a/kmail/editorsendcheckplugins/checkbeforesend/CMakeLists.txt
+++ b/kmail/editorsendcheckplugins/checkbeforesend/CMakeLists.txt
@@ -3,6 +3,7 @@ set(kmail_checkbeforesendeditorplugin_SRCS
checkbeforesendinterface.cpp
checkbeforesendconfigurewidget.cpp
checkduplicateemailsdialog.cpp
+ checkduplicateemailsjob.cpp
)
ecm_qt_declare_logging_category(kmail_checkbeforesendeditorplugin_SRCS HEADER checkbeforesendplugin_debug.h IDENTIFIER KMAIL_EDITOR_checkbeforesend_PLUGIN_LOG CATEGORY_NAME log_kmail_checkbeforesendplugin)
diff --git a/kmail/editorsendcheckplugins/checkbeforesend/autotests/CMakeLists.txt b/kmail/editorsendcheckplugins/checkbeforesend/autotests/CMakeLists.txt
index 1366a8b..9220a30 100644
--- a/kmail/editorsendcheckplugins/checkbeforesend/autotests/CMakeLists.txt
+++ b/kmail/editorsendcheckplugins/checkbeforesend/autotests/CMakeLists.txt
@@ -12,7 +12,8 @@ macro(add_kmail_checkbeforesend_unittest _source _additional)
endmacro ()
-add_kmail_checkbeforesend_unittest(checkbeforesendplugintest.cpp "../checkbeforesendplugin.cpp;../checkbeforesendinterface.cpp;../checkbeforesendconfigurewidget.cpp")
-add_kmail_checkbeforesend_unittest(checkbeforesendinterfacetest.cpp "../checkbeforesendinterface.cpp")
+add_kmail_checkbeforesend_unittest(checkbeforesendplugintest.cpp "../checkduplicateemailsjob.cpp;../checkduplicateemailsdialog.cpp;../checkbeforesendplugin.cpp;../checkbeforesendinterface.cpp;../checkbeforesendconfigurewidget.cpp")
+add_kmail_checkbeforesend_unittest(checkbeforesendinterfacetest.cpp "../checkduplicateemailsjob.cpp;../checkduplicateemailsdialog.cpp;../checkbeforesendinterface.cpp")
add_kmail_checkbeforesend_unittest(checkbeforesendconfigurewidgettest.cpp "../checkbeforesendconfigurewidget.cpp")
add_kmail_checkbeforesend_unittest(checkduplicateemailsdialogtest.cpp "../checkduplicateemailsdialog.cpp")
+add_kmail_checkbeforesend_unittest(checkduplicateemailsjobtest.cpp "../checkduplicateemailsjob.cpp")
diff --git a/kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp b/kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp
new file mode 100644
index 0000000..3339af3
--- /dev/null
+++ b/kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 2016 Montel Laurent <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "checkduplicateemailsjobtest.h"
+#include "../checkduplicateemailsjob.h"
+#include <QTest>
+#include <QStringList>
+
+CheckDuplicateEmailsJobTest::CheckDuplicateEmailsJobTest(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+CheckDuplicateEmailsJobTest::~CheckDuplicateEmailsJobTest()
+{
+
+}
+
+void CheckDuplicateEmailsJobTest::shouldHaveDefaultValue()
+{
+ CheckDuplicateEmailsJob job;
+ QVERIFY(job.result().isEmpty());
+}
+
+void CheckDuplicateEmailsJobTest::shouldReturnEmptyListWhenEmailsListIsEmpty()
+{
+ CheckDuplicateEmailsJob job;
+ QStringList listEmails;
+ job.setEmails(listEmails);
+ job.start();
+ QVERIFY(job.result().isEmpty());
+}
+
+void CheckDuplicateEmailsJobTest::shouldReturnEmails_data()
+{
+ QTest::addColumn<QStringList>("emails");
+ QTest::addColumn<QMap<QString, int> >("result");
+ QTest::newRow("empty") << QStringList() << QMap<QString, int>();
+}
+
+void CheckDuplicateEmailsJobTest::shouldReturnEmails()
+{
+ QFETCH(QStringList, emails);
+ typedef QMap<QString, int> mapEmails;
+ QFETCH(mapEmails, result);
+ CheckDuplicateEmailsJob job;
+ job.setEmails(emails);
+ job.start();
+ QCOMPARE(job.result(), result);
+}
+
+QTEST_MAIN(CheckDuplicateEmailsJobTest)
diff --git a/kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.h b/kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.h
new file mode 100644
index 0000000..e75c893
--- /dev/null
+++ b/kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.h
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 2016 Montel Laurent <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CHECKDUPLICATEEMAILSJOBTEST_H
+#define CHECKDUPLICATEEMAILSJOBTEST_H
+
+#include <QObject>
+
+class CheckDuplicateEmailsJobTest : public QObject
+{
+ Q_OBJECT
+public:
+ explicit CheckDuplicateEmailsJobTest(QObject *parent = Q_NULLPTR);
+ ~CheckDuplicateEmailsJobTest();
+
+private Q_SLOTS:
+ void shouldHaveDefaultValue();
+ void shouldReturnEmptyListWhenEmailsListIsEmpty();
+ void shouldReturnEmails_data();
+ void shouldReturnEmails();
+};
+
+#endif // CHECKDUPLICATEEMAILSJOBTEST_H
diff --git a/kmail/editorsendcheckplugins/checkbeforesend/checkbeforesendinterface.cpp b/kmail/editorsendcheckplugins/checkbeforesend/checkbeforesendinterface.cpp
index f0e238c..14008d7 100644
--- a/kmail/editorsendcheckplugins/checkbeforesend/checkbeforesendinterface.cpp
+++ b/kmail/editorsendcheckplugins/checkbeforesend/checkbeforesendinterface.cpp
@@ -18,6 +18,8 @@
*/
#include "checkbeforesendinterface.h"
+#include "checkduplicateemailsjob.h"
+#include "checkduplicateemailsdialog.h"
#include <KMessageBox>
#include <KConfigGroup>
@@ -26,6 +28,8 @@
#include <KIdentityManagement/Identity>
#include <KIdentityManagement/IdentityManager>
+#include <QPointer>
+
CheckBeforeSendInterface::CheckBeforeSendInterface(QObject *parent)
: MessageComposer::PluginEditorCheckBeforeSendInterface(parent),
mIdentityManager(Q_NULLPTR),
@@ -66,7 +70,23 @@ bool CheckBeforeSendInterface::exec(const MessageComposer::PluginEditorCheckBefo
}
}
if (mCheckDuplicateEmails) {
- //TODO
+ const QStringList lst{ params.bccAddresses(), params.toAddresses(), params.ccAddresses() };
+ if (!lst.isEmpty()) {
+ CheckDuplicateEmailsJob job;
+ job.setEmails(lst);
+ job.start();
+ const QMap<QString, int> results = job.result();
+ if (!results.isEmpty()) {
+ QPointer<CheckDuplicateEmailsDialog> dlg = new CheckDuplicateEmailsDialog(parentWidget());
+ if (dlg->exec()) {
+ delete dlg;
+ return true;
+ } else {
+ delete dlg;
+ return false;
+ }
+ }
+ }
}
return true;
}
diff --git a/kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp b/kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp
new file mode 100644
index 0000000..9692992
--- /dev/null
+++ b/kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp
@@ -0,0 +1,47 @@
+/*
+ Copyright (C) 2016 Montel Laurent <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#include "checkduplicateemailsjob.h"
+
+CheckDuplicateEmailsJob::CheckDuplicateEmailsJob()
+{
+
+}
+
+CheckDuplicateEmailsJob::~CheckDuplicateEmailsJob()
+{
+
+}
+
+void CheckDuplicateEmailsJob::start()
+{
+ mResult.clear();
+ if (mEmails.isEmpty()) {
+ return;
+ }
+}
+
+void CheckDuplicateEmailsJob::setEmails(const QStringList &list)
+{
+ mEmails = list;
+}
+
+QMap<QString, int> CheckDuplicateEmailsJob::result() const
+{
+ return mResult;
+}
diff --git a/kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.h b/kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.h
new file mode 100644
index 0000000..2d3b0a7
--- /dev/null
+++ b/kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2016 Montel Laurent <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CHECKDUPLICATEEMAILSJOB_H
+#define CHECKDUPLICATEEMAILSJOB_H
+
+#include <QMap>
+#include <QStringList>
+
+class CheckDuplicateEmailsJob
+{
+public:
+ CheckDuplicateEmailsJob();
+ ~CheckDuplicateEmailsJob();
+
+ void start();
+
+ void setEmails(const QStringList &list);
+ QMap<QString, int> result() const;
+
+private:
+ QStringList mEmails;
+ QMap<QString, int> mResult;
+};
+
+#endif // CHECKDUPLICATEEMAILSJOB_H