Conflicts: kmail/CMakeLists.txt kmail/editor/kmcomposewin.cpp libkdepim/CMakeLists.txt libkdepim/addressline/addresseelineedit.cpp libkdepim/addressline/addresseelineedit.h messagecomposer/composer/composerviewbase.cppwilder-work
commit
7651eca35a
10 changed files with 319 additions and 10 deletions
@ -0,0 +1,6 @@ |
||||
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) |
||||
|
||||
set( kmail_potentialphishingemailjobtest_SRCS potentialphishingemailjobtest.cpp ../potentialphishingemailjob.cpp ) |
||||
kde4_add_unit_test( kmail_potentialphishingemailjobtest ${kmail_potentialphishingemailjobtest_SRCS}) |
||||
target_link_libraries( kmail_potentialphishingemailjobtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDEPIMLIBS_KPIMUTILS_LIBS}) |
||||
|
||||
@ -0,0 +1,63 @@ |
||||
/*
|
||||
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 "potentialphishingemailjobtest.h" |
||||
#include "../potentialphishingemailjob.h" |
||||
#include <qtest_kde.h> |
||||
#include <QStringList> |
||||
|
||||
PotentialPhishingEmailJobTest::PotentialPhishingEmailJobTest(QObject *parent) |
||||
: QObject(parent) |
||||
{ |
||||
|
||||
} |
||||
|
||||
PotentialPhishingEmailJobTest::~PotentialPhishingEmailJobTest() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void PotentialPhishingEmailJobTest::shouldNotStartIfNoEmails() |
||||
{ |
||||
PotentialPhishingEmailJob *job = new PotentialPhishingEmailJob; |
||||
QVERIFY(!job->start()); |
||||
QVERIFY(job->potentialPhisingEmails().isEmpty()); |
||||
} |
||||
|
||||
void PotentialPhishingEmailJobTest::shouldReturnPotentialPhishingEmails_data() |
||||
{ |
||||
QTest::addColumn<QStringList>("listEmails"); |
||||
QTest::addColumn<bool>("hasPotentialPhishing"); |
||||
QTest::newRow("NoPotentialPhishing") << (QStringList() << QLatin1String("foo@kde.org")) << false; |
||||
QTest::newRow("HasPotentialPhishing") << (QStringList() << QLatin1String("\"bla@kde.org\" <foo@kde.org>")) << true; |
||||
} |
||||
|
||||
void PotentialPhishingEmailJobTest::shouldReturnPotentialPhishingEmails() |
||||
{ |
||||
QFETCH( QStringList, listEmails ); |
||||
QFETCH( bool, hasPotentialPhishing ); |
||||
PotentialPhishingEmailJob *job = new PotentialPhishingEmailJob; |
||||
job->setEmails(listEmails); |
||||
QVERIFY(job->start()); |
||||
QCOMPARE(job->potentialPhisingEmails().isEmpty(), !hasPotentialPhishing); |
||||
|
||||
} |
||||
|
||||
QTEST_KDEMAIN(PotentialPhishingEmailJobTest, NoGUI) |
||||
@ -0,0 +1,39 @@ |
||||
/*
|
||||
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 POTENTIALPHISHINGEMAILJOBTEST_H |
||||
#define POTENTIALPHISHINGEMAILJOBTEST_H |
||||
|
||||
#include <QObject> |
||||
|
||||
class PotentialPhishingEmailJobTest : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit PotentialPhishingEmailJobTest(QObject *parent = 0); |
||||
~PotentialPhishingEmailJobTest(); |
||||
|
||||
private Q_SLOTS: |
||||
void shouldNotStartIfNoEmails(); |
||||
void shouldReturnPotentialPhishingEmails_data(); |
||||
void shouldReturnPotentialPhishingEmails(); |
||||
}; |
||||
|
||||
#endif // POTENTIALPHISHINGEMAILJOBTEST_H
|
||||
@ -0,0 +1,67 @@ |
||||
/*
|
||||
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 "potentialphishingemailjob.h" |
||||
#include <KPIMUtils/Email> |
||||
#include <QDebug> |
||||
PotentialPhishingEmailJob::PotentialPhishingEmailJob(QObject *parent) |
||||
: QObject(parent) |
||||
{ |
||||
|
||||
} |
||||
|
||||
PotentialPhishingEmailJob::~PotentialPhishingEmailJob() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void PotentialPhishingEmailJob::setEmails(const QStringList &emails) |
||||
{ |
||||
mEmails = emails; |
||||
} |
||||
|
||||
QStringList PotentialPhishingEmailJob::potentialPhisingEmails() const |
||||
{ |
||||
return mPotentialPhisingEmails; |
||||
} |
||||
|
||||
bool PotentialPhishingEmailJob::start() |
||||
{ |
||||
mPotentialPhisingEmails.clear(); |
||||
if (mEmails.isEmpty()) { |
||||
deleteLater(); |
||||
return false; |
||||
} |
||||
Q_FOREACH(const QString &addr, mEmails) { |
||||
QString tname, temail; |
||||
KPIMUtils::extractEmailAddressAndName( addr, temail, tname ); // ignore return value
|
||||
// which is always false
|
||||
if (tname.contains(QLatin1String("@"))) { //Potential address
|
||||
if (temail != tname) { |
||||
mPotentialPhisingEmails.append(addr); |
||||
} |
||||
} |
||||
} |
||||
|
||||
Q_EMIT potentialPhisingEmailsFound(mPotentialPhisingEmails); |
||||
deleteLater(); |
||||
return true; |
||||
} |
||||
|
||||
@ -0,0 +1,46 @@ |
||||
/*
|
||||
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 POTENTIALPHISHINGEMAILJOB_H |
||||
#define POTENTIALPHISHINGEMAILJOB_H |
||||
|
||||
#include <QObject> |
||||
#include <QStringList> |
||||
|
||||
class PotentialPhishingEmailJob : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit PotentialPhishingEmailJob(QObject *parent = 0); |
||||
~PotentialPhishingEmailJob(); |
||||
|
||||
void setEmails(const QStringList &emails); |
||||
QStringList potentialPhisingEmails() const; |
||||
bool start(); |
||||
|
||||
Q_SIGNALS: |
||||
void potentialPhisingEmailsFound(const QStringList &emails); |
||||
|
||||
private: |
||||
QStringList mEmails; |
||||
QStringList mPotentialPhisingEmails; |
||||
}; |
||||
|
||||
#endif // POTENTIALPHISHINGEMAILJOB_H
|
||||
@ -0,0 +1,41 @@ |
||||
/*
|
||||
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 "potentialphisingemailwarning.h" |
||||
|
||||
PotentialPhisingEmailWarning::PotentialPhisingEmailWarning(QWidget *parent) |
||||
: KMessageWidget(parent) |
||||
{ |
||||
setVisible(false); |
||||
setCloseButtonVisible(true); |
||||
setMessageType(Warning); |
||||
setWordWrap(true); |
||||
} |
||||
|
||||
PotentialPhisingEmailWarning::~PotentialPhisingEmailWarning() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void PotentialPhisingEmailWarning::setWarningText(const QString &text) |
||||
{ |
||||
animatedShow(); |
||||
} |
||||
@ -0,0 +1,36 @@ |
||||
/*
|
||||
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 POTENTIALPHISINGEMAILWARNING_H |
||||
#define POTENTIALPHISINGEMAILWARNING_H |
||||
|
||||
#include <KMessageWidget> |
||||
|
||||
class PotentialPhisingEmailWarning : public KMessageWidget |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit PotentialPhisingEmailWarning(QWidget *parent = 0); |
||||
~PotentialPhisingEmailWarning(); |
||||
|
||||
void setWarningText(const QString &text); |
||||
}; |
||||
|
||||
#endif // POTENTIALPHISINGEMAILWARNING_H
|
||||
Loading…
Reference in new issue