Merge remote-tracking branch 'origin/KDE/4.14'

Conflicts:
	kmail/CMakeLists.txt
	kmail/editor/kmcomposewin.cpp
	libkdepim/CMakeLists.txt
	libkdepim/addressline/addresseelineedit.cpp
	libkdepim/addressline/addresseelineedit.h
	messagecomposer/composer/composerviewbase.cpp
wilder-work
Montel Laurent 11 years ago
commit 7651eca35a
  1. 5
      CMakeLists.txt
  2. 22
      editor/kmcomposewin.cpp
  3. 4
      editor/kmcomposewin.h
  4. 6
      editor/potentialphishingemail/autotests/CMakeLists.txt
  5. 63
      editor/potentialphishingemail/autotests/potentialphishingemailjobtest.cpp
  6. 39
      editor/potentialphishingemail/autotests/potentialphishingemailjobtest.h
  7. 67
      editor/potentialphishingemail/potentialphishingemailjob.cpp
  8. 46
      editor/potentialphishingemail/potentialphishingemailjob.h
  9. 41
      editor/potentialphishingemail/potentialphisingemailwarning.cpp
  10. 36
      editor/potentialphishingemail/potentialphisingemailwarning.h

@ -140,6 +140,9 @@ if (KDEPIM_BUILD_DESKTOP)
warningwidgets/externaleditorwarning.cpp
warningwidgets/attachmentmissingwarning.cpp
)
set(kmailprivate_editor_potentialphishingemail_SRCS
editor/potentialphishingemail/potentialphisingemailwarning.cpp
)
set(kmailprivate_dialogs_LIB_SRCS
dialog/archivefolderdialog.cpp
dialog/addemailtoexistingcontactdialog.cpp
@ -210,6 +213,7 @@ if (KDEPIM_BUILD_DESKTOP)
${kmailprivate_identity_LIB_SRCS}
${kmailprivate_editor_LIB_SRCS}
${kmailprivate_followupreminder_LIB_SRCS}
${kmailprivate_editor_potentialphishingemail_SRCS}
)
# TODO PORT
@ -354,6 +358,7 @@ generate_export_header(kmailprivate BASE_NAME kmail)
if (BUILD_TESTING)
add_subdirectory(mailmerge/autotests/)
add_subdirectory(folderarchive/autotests/)
add_subdirectory(editor/potentialphishingemail/autotests)
endif()
########### install files ###############

@ -63,6 +63,7 @@
#include "followupreminder/followupremindercreatejob.h"
#include "agents/followupreminderagent/followupreminderutil.h"
#include "pimcommon/util/vcardutil.h"
#include "editor/potentialphishingemail/potentialphisingemailwarning.h"
#include "libkdepim/progresswidget/statusbarprogresswidget.h"
#include "libkdepim/progresswidget/progressstatusbarwidget.h"
@ -426,6 +427,9 @@ KMComposeWin::KMComposeWin(const KMime::Message::Ptr &aMsg, bool lastSignState,
connect(mAttachmentMissing, &AttachmentMissingWarning::explicitClosedMissingAttachment, this, &KMComposeWin::slotExplicitClosedMissingAttachment);
v->addWidget(mAttachmentMissing);
mPotentialPhishingEmailWarning = new PotentialPhisingEmailWarning(this);
v->addWidget(mPotentialPhishingEmailWarning);
if (GlobalSettings::self()->showForgottenAttachmentWarning()) {
m_verifyMissingAttachment = new QTimer(this);
m_verifyMissingAttachment->setSingleShot(true);
@ -691,7 +695,7 @@ bool KMComposeWin::canSignEncryptAttachments() const
return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
}
void KMComposeWin::slotView(void)
void KMComposeWin::slotUpdateView( void )
{
if (!mDone) {
return; // otherwise called from rethinkFields during the construction
@ -1281,29 +1285,29 @@ void KMComposeWin::setupActions(void)
mAllFieldsAction = new KToggleAction(i18n("&All Fields"), this);
actionCollection()->addAction(QLatin1String("show_all_fields"), mAllFieldsAction);
connect(mAllFieldsAction, &KToggleAction::triggered, this, &KMComposeWin::slotView);
connect(mAllFieldsAction, &KToggleAction::triggered, this, &KMComposeWin::slotUpdateView);
mIdentityAction = new KToggleAction(i18n("&Identity"), this);
actionCollection()->addAction(QLatin1String("show_identity"), mIdentityAction);
connect(mIdentityAction, &KToggleAction::triggered, this, &KMComposeWin::slotView);
connect(mIdentityAction, &KToggleAction::triggered, this, &KMComposeWin::slotUpdateView);
mDictionaryAction = new KToggleAction(i18n("&Dictionary"), this);
actionCollection()->addAction(QLatin1String("show_dictionary"), mDictionaryAction);
connect(mDictionaryAction, &KToggleAction::triggered, this, &KMComposeWin::slotView);
connect(mDictionaryAction, &KToggleAction::triggered, this, &KMComposeWin::slotUpdateView);
mFccAction = new KToggleAction(i18n("&Sent-Mail Folder"), this);
actionCollection()->addAction(QLatin1String("show_fcc"), mFccAction);
connect(mFccAction, &KToggleAction::triggered, this, &KMComposeWin::slotView);
connect(mFccAction, &KToggleAction::triggered, this, &KMComposeWin::slotUpdateView);
mTransportAction = new KToggleAction(i18n("&Mail Transport"), this);
actionCollection()->addAction(QLatin1String("show_transport"), mTransportAction);
connect(mTransportAction, &KToggleAction::triggered, this, &KMComposeWin::slotView);
connect(mTransportAction, &KToggleAction::triggered, this, &KMComposeWin::slotUpdateView);
mFromAction = new KToggleAction(i18n("&From"), this);
actionCollection()->addAction(QLatin1String("show_from"), mFromAction);
connect(mFromAction, &KToggleAction::triggered, this, &KMComposeWin::slotView);
connect(mFromAction, &KToggleAction::triggered, this, &KMComposeWin::slotUpdateView);
mReplyToAction = new KToggleAction(i18n("&Reply To"), this);
actionCollection()->addAction(QLatin1String("show_reply_to"), mReplyToAction);
connect(mReplyToAction, &KToggleAction::triggered, this, &KMComposeWin::slotView);
connect(mReplyToAction, &KToggleAction::triggered, this, &KMComposeWin::slotUpdateView);
mSubjectAction = new KToggleAction(
i18nc("@action:inmenu Show the subject in the composer window.", "S&ubject"), this);
actionCollection()->addAction(QLatin1String("show_subject"), mSubjectAction);
connect(mSubjectAction, &KToggleAction::triggered, this, &KMComposeWin::slotView);
connect(mSubjectAction, &KToggleAction::triggered, this, &KMComposeWin::slotUpdateView);
//end of checkable
mAppendSignature = new QAction(i18n("Append S&ignature"), this);

@ -70,6 +70,7 @@ class ExternalEditorWarning;
class KActionMenu;
class CryptoStateIndicatorWidget;
class StatusBarLabelToggledState;
class PotentialPhisingEmailWarning;
namespace boost
{
@ -401,7 +402,7 @@ private Q_SLOTS:
*/
void slotSignToggled(bool);
void slotView();
void slotUpdateView();
/**
* Update composer field to reflect new identity
@ -707,6 +708,7 @@ private:
KToggleAction *mFollowUpToggleAction;
StatusBarLabelToggledState *mStatusBarLabelToggledOverrideMode;
StatusBarLabelToggledState *mStatusBarLabelSpellCheckingChangeMode;
PotentialPhisingEmailWarning *mPotentialPhishingEmailWarning;
};
#endif

@ -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…
Cancel
Save