Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 3a4f917d authored by Laurent Montel's avatar Laurent Montel 😁

Improve check support

parent def00ee6
......@@ -142,6 +142,7 @@ if (KDEPIM_BUILD_DESKTOP)
set(kmailprivate_editor_potentialphishingemail_SRCS
editor/potentialphishingemail/potentialphishingemailwarning.cpp
editor/potentialphishingemail/potentialphishingemailjob.cpp
editor/potentialphishingemail/potentialphishingdetaildialog.cpp
)
set(kmailprivate_dialogs_LIB_SRCS
dialog/archivefolderdialog.cpp
......
......@@ -178,6 +178,7 @@
#include <boost/shared_ptr.hpp>
#include <widgets/splittercollapser.h>
#include <Akonadi/Contact/ContactGroupExpandJob>
#include <editor/potentialphishingemail/potentialphishingemailjob.h>
using Sonnet::DictionaryComboBox;
using MailTransport::TransportManager;
......@@ -3025,7 +3026,7 @@ void KMComposeWin::confirmBeforeSend()
}
}
void KMComposeWin::slotCheckSendNow()
void KMComposeWin::slotCheckSendNowStep2()
{
if ( GlobalSettings::self()->confirmBeforeSend() ) {
confirmBeforeSend();
......@@ -3046,6 +3047,32 @@ void KMComposeWin::slotCheckSendNow()
}
}
void KMComposeWin::slotCheckSendNow()
{
PotentialPhishingEmailJob *job = new PotentialPhishingEmailJob(this);
QStringList lst;
lst << mComposerBase->to();
if (!mComposerBase->cc().isEmpty())
lst << mComposerBase->cc().split(QLatin1Char(','));
if (!mComposerBase->bcc().isEmpty())
lst << mComposerBase->bcc().split(QLatin1Char(','));
job->setEmails(lst);
connect(job, SIGNAL(potentialPhishingEmailsFound(QStringList)), this, SLOT(slotPotentialPhishingEmailsFound(QStringList)));
job->start();
}
void KMComposeWin::slotPotentialPhishingEmailsFound(const QStringList &list)
{
#if 1
slotCheckSendNowStep2();
#else
if (list.isEmpty()) {
slotCheckSendNowStep2();
} else {
//mPotentialPhishingEmailWarning->setWarningText();
}
#endif
}
bool KMComposeWin::checkRecipientNumber() const
{
......
......@@ -450,6 +450,8 @@ private slots:
void slotSnippetWidgetVisibilityChanged(bool b);
void slotOverwriteModeWasChanged(bool state);
void slotExpandGroupResult(KJob *job);
void slotCheckSendNowStep2();
void slotPotentialPhishingEmailsFound(const QStringList &list);
public: // kmcommand
// FIXME we need to remove these, but they're pure virtual in Composer.
void addAttach( KMime::Content *msgPart );
......
......@@ -4,3 +4,9 @@ set( kmail_potentialphishingemailjobtest_SRCS potentialphishingemailjobtest.cpp
kde4_add_unit_test( kmail_potentialphishingemailjobtest ${kmail_potentialphishingemailjobtest_SRCS})
target_link_libraries( kmail_potentialphishingemailjobtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDEPIMLIBS_KPIMUTILS_LIBS})
set( kmail_potentialphishingdetaildialogtest_SRCS potentialphishingdetaildialogtest.cpp ../potentialphishingdetaildialog.cpp )
kde4_add_unit_test( kmail_potentialphishingdetaildialogtest ${kmail_potentialphishingdetaildialogtest_SRCS})
target_link_libraries( kmail_potentialphishingdetaildialogtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} )
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "potentialphishingdetaildialogtest.h"
#include <qtest_kde.h>
PotentialPhishingDetailDialogTest::PotentialPhishingDetailDialogTest(QObject *parent)
: QObject(parent)
{
}
PotentialPhishingDetailDialogTest::~PotentialPhishingDetailDialogTest()
{
}
QTEST_KDEMAIN(PotentialPhishingDetailDialogTest, NoGUI)
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef POTENTIALPHISHINGDETAILDIALOGTEST_H
#define POTENTIALPHISHINGDETAILDIALOGTEST_H
#include <QObject>
class PotentialPhishingDetailDialogTest : public QObject
{
Q_OBJECT
public:
explicit PotentialPhishingDetailDialogTest(QObject *parent = 0);
~PotentialPhishingDetailDialogTest();
};
#endif // POTENTIALPHISHINGDETAILDIALOGTEST_H
......@@ -64,19 +64,11 @@ void PotentialPhishingEmailJobTest::shouldReturnPotentialPhishingEmails()
void PotentialPhishingEmailJobTest::shouldEmitSignal()
{
PotentialPhishingEmailJob *job = new PotentialPhishingEmailJob;
QSignalSpy spy(job, SIGNAL(potentialPhisingEmailsFound(QStringList)));
QSignalSpy spy(job, SIGNAL(potentialPhishingEmailsFound(QStringList)));
job->setEmails((QStringList() << QLatin1String("\"bla@kde.org\" <foo@kde.org>")));
job->start();
QCOMPARE(spy.count(), 1);
}
void PotentialPhishingEmailJobTest::shouldNotEmitSignalWhenPotentialPhishingNotFound()
{
PotentialPhishingEmailJob *job = new PotentialPhishingEmailJob;
QSignalSpy spy(job, SIGNAL(potentialPhisingEmailsFound(QStringList)));
job->setEmails((QStringList() << QLatin1String("<foo@kde.org>")));
job->start();
QCOMPARE(spy.count(), 0);
}
QTEST_KDEMAIN(PotentialPhishingEmailJobTest, NoGUI)
......@@ -35,7 +35,6 @@ private Q_SLOTS:
void shouldReturnPotentialPhishingEmails_data();
void shouldReturnPotentialPhishingEmails();
void shouldEmitSignal();
void shouldNotEmitSignalWhenPotentialPhishingNotFound();
};
#endif // POTENTIALPHISHINGEMAILJOBTEST_H
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "potentialphishingdetaildialog.h"
#include <KLocalizedString>
PotentialPhishingDetailDialog::PotentialPhishingDetailDialog(QWidget *parent)
: KDialog(parent)
{
}
PotentialPhishingDetailDialog::~PotentialPhishingDetailDialog()
{
}
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef POTENTIALPHISHINGDETAILDIALOG_H
#define POTENTIALPHISHINGDETAILDIALOG_H
#include <KDialog>
class PotentialPhishingDetailDialog : public KDialog
{
Q_OBJECT
public:
explicit PotentialPhishingDetailDialog(QWidget *parent=0);
~PotentialPhishingDetailDialog();
};
#endif // POTENTIALPHISHINGDETAILDIALOG_H
......@@ -59,9 +59,7 @@ bool PotentialPhishingEmailJob::start()
}
}
}
if (!mPotentialPhisingEmails.isEmpty()) {
Q_EMIT potentialPhisingEmailsFound(mPotentialPhisingEmails);
}
Q_EMIT potentialPhishingEmailsFound(mPotentialPhisingEmails);
deleteLater();
return true;
}
......
......@@ -36,7 +36,7 @@ public:
bool start();
Q_SIGNALS:
void potentialPhisingEmailsFound(const QStringList &emails);
void potentialPhishingEmailsFound(const QStringList &emails);
private:
QStringList mEmails;
......
......@@ -20,6 +20,7 @@
#include "potentialphishingemailwarning.h"
#include <KLocalizedString>
PotentialPhishingEmailWarning::PotentialPhishingEmailWarning(QWidget *parent)
: KMessageWidget(parent)
......@@ -28,6 +29,11 @@ PotentialPhishingEmailWarning::PotentialPhishingEmailWarning(QWidget *parent)
setCloseButtonVisible(true);
setMessageType(Warning);
setWordWrap(true);
//Add i18n in kf5
setText(QLatin1String("Some address mail seems a potential phishing email <a href=\"phishingdetails\">(Details...)</a>"));
connect(this, SIGNAL(linkActivated(QString)), SLOT(slotShowDetails(QString)));
}
PotentialPhishingEmailWarning::~PotentialPhishingEmailWarning()
......@@ -35,7 +41,17 @@ PotentialPhishingEmailWarning::~PotentialPhishingEmailWarning()
}
void PotentialPhishingEmailWarning::setWarningText(const QString &text)
void PotentialPhishingEmailWarning::slotShowDetails(const QString &link)
{
if (link == QLatin1String("phishingdetails")) {
Q_EMIT showDetails();
}
}
void PotentialPhishingEmailWarning::setPotentialPhisingEmail(const QStringList &lst)
{
animatedShow();
mPotentialPhishingEmails = lst;
if (!mPotentialPhishingEmails.isEmpty()) {
animatedShow();
}
}
......@@ -30,7 +30,14 @@ public:
explicit PotentialPhishingEmailWarning(QWidget *parent = 0);
~PotentialPhishingEmailWarning();
void setWarningText(const QString &text);
void setPotentialPhisingEmail(const QStringList &lst);
Q_SIGNALS:
void showDetails();
private slots:
void slotShowDetails(const QString &link);
private:
QStringList mPotentialPhishingEmails;
};
#endif // POTENTIALPHISHINGEMAILWARNING_H
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