Commit 6a339187 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move code here

parent d4d97885
cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.13.51")
set(PIM_VERSION "5.13.52")
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
......
......@@ -87,10 +87,15 @@ if (${Qca-qt5_FOUND})
dkim-verify/dkimmanagerrules.cpp
dkim-verify/dkimgeneraterulejob.cpp
dkim-verify/dkimauthenticationstatusinfoutil.cpp
dkim-verify/dkimcheckfulljob.cpp
dkim-verify/dkimcheckfulljob.cpp
dkim-verify/dkimauthenticationstatusinfoconverter.cpp
dkim-verify/dkimmanagerauthenticationserver.cpp
dkim-verify/dkimviewermenu.cpp
dkim-verify/dkimmanagerulescombobox.cpp
dkim-verify/dkimmanagerulesdialog.cpp
dkim-verify/dkimmanageruleswidget.cpp
dkim-verify/dkimruledialog.cpp
dkim-verify/dkimrulewidget.cpp
)
endif()
......@@ -384,6 +389,8 @@ if (${Qca-qt5_FOUND})
DKIMHeaderParser
DKIMManagerAuthenticationServer
DKIMViewerMenu
DKIMManageRulesDialog
DKIMManageRulesWidget
REQUIRED_HEADERS MessageViewer_dkimverify_HEADERS
PREFIX MessageViewer
RELATIVE dkim-verify
......
......@@ -35,3 +35,9 @@ add_messageviewer_dkim_verify_unittest(dkimcheckfulljobtest.cpp)
add_messageviewer_dkim_verify_unittest(dkimauthenticationstatusinfoconvertertest.cpp)
add_messageviewer_dkim_verify_unittest(dkimmanagerauthenticationservertest.cpp)
add_messageviewer_dkim_verify_unittest(dkimviewermenutest.cpp)
add_messageviewer_dkim_verify_unittest(dkimmanagerulescomboboxtest.cpp)
add_messageviewer_dkim_verify_unittest(dkimmanagerulesdialogtest.cpp)
add_messageviewer_dkim_verify_unittest(dkimmanageruleswidgettest.cpp)
add_messageviewer_dkim_verify_unittest(dkimruledialogtest.cpp)
add_messageviewer_dkim_verify_unittest(dkimrulewidgettest.cpp)
/*
Copyright (C) 2019-2020 Laurent Montel <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 "dkimmanagerulescomboboxtest.h"
#include "dkim-verify/dkimmanagerulescombobox.h"
#include <QTest>
QTEST_MAIN(DKIMManageRulesComboBoxTest)
DKIMManageRulesComboBoxTest::DKIMManageRulesComboBoxTest(QObject *parent)
: QObject(parent)
{
}
void DKIMManageRulesComboBoxTest::shouldHaveDefaultValues()
{
MessageViewer::DKIMManageRulesComboBox w;
QVERIFY(w.count() > 0);
}
void DKIMManageRulesComboBoxTest::shouldChangeIndex()
{
MessageViewer::DKIMManageRulesComboBox w;
w.setCurrentIndex(1);
QCOMPARE(w.ruleType(), MessageViewer::DKIMRule::RuleType::CanBeSigned);
}
/*
Copyright (C) 2019-2020 Laurent Montel <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 DKIMMANAGERULESCOMBOBOXTEST_H
#define DKIMMANAGERULESCOMBOBOXTEST_H
#include <QObject>
class DKIMManageRulesComboBoxTest : public QObject
{
Q_OBJECT
public:
explicit DKIMManageRulesComboBoxTest(QObject *parent = nullptr);
~DKIMManageRulesComboBoxTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
void shouldChangeIndex();
};
#endif // DKIMMANAGERULESCOMBOBOXTEST_H
/*
Copyright (C) 2019-2020 Laurent Montel <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 "dkimmanagerulesdialogtest.h"
#include "dkim-verify/dkimmanagerulesdialog.h"
#include "dkim-verify/dkimmanageruleswidget.h"
#include <QDialogButtonBox>
#include <QTest>
#include <QVBoxLayout>
QTEST_MAIN(DKIMManageRulesDialogTest)
DKIMManageRulesDialogTest::DKIMManageRulesDialogTest(QObject *parent)
: QObject(parent)
{
}
void DKIMManageRulesDialogTest::shouldHaveDefaultValues()
{
MessageViewer::DKIMManageRulesDialog w;
QVERIFY(!w.windowTitle().isEmpty());
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout);
MessageViewer::DKIMManageRulesWidget *mRulesWidget = w.findChild<MessageViewer::DKIMManageRulesWidget *>(QStringLiteral("mRulesWidget"));
QVERIFY(mRulesWidget);
QDialogButtonBox *buttonBox = w.findChild<QDialogButtonBox *>(QStringLiteral("buttonBox"));
QVERIFY(buttonBox);
QCOMPARE(buttonBox->standardButtons(), {QDialogButtonBox::Ok | QDialogButtonBox::Cancel});
}
/*
Copyright (C) 2019-2020 Laurent Montel <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 DKIMMANAGERULESDIALOGTEST_H
#define DKIMMANAGERULESDIALOGTEST_H
#include <QObject>
class DKIMManageRulesDialogTest : public QObject
{
Q_OBJECT
public:
explicit DKIMManageRulesDialogTest(QObject *parent = nullptr);
~DKIMManageRulesDialogTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
#endif // DKIMMANAGERULESDIALOGTEST_H
/*
Copyright (C) 2019-2020 Laurent Montel <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 "dkimmanageruleswidgettest.h"
#include "dkim-verify/dkimmanageruleswidget.h"
#include <KTreeWidgetSearchLine>
#include <QTest>
#include <QTreeWidget>
#include <QVBoxLayout>
QTEST_MAIN(DKIMManageRulesWidgetTest)
DKIMManageRulesWidgetTest::DKIMManageRulesWidgetTest(QObject *parent)
: QObject(parent)
{
}
void DKIMManageRulesWidgetTest::shouldHaveDefaultValues()
{
MessageViewer::DKIMManageRulesWidget w;
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->contentsMargins(), QMargins(0, 0, 0, 0));
QTreeWidget *mTreeWidget = w.findChild<QTreeWidget *>(QStringLiteral("treewidget"));
QVERIFY(mTreeWidget);
QVERIFY(!mTreeWidget->rootIsDecorated());
QVERIFY(mTreeWidget->alternatingRowColors());
KTreeWidgetSearchLine *searchLineEdit = w.findChild<KTreeWidgetSearchLine *>(QStringLiteral("searchlineedit"));
QVERIFY(searchLineEdit->isClearButtonEnabled());
}
/*
Copyright (C) 2019-2020 Laurent Montel <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 DKIMMANAGERULESWIDGETTEST_H
#define DKIMMANAGERULESWIDGETTEST_H
#include <QObject>
class DKIMManageRulesWidgetTest : public QObject
{
Q_OBJECT
public:
explicit DKIMManageRulesWidgetTest(QObject *parent = nullptr);
~DKIMManageRulesWidgetTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
#endif // DKIMMANAGERULESWIDGETTEST_H
/*
Copyright (C) 2019-2020 Laurent Montel <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 "dkimruledialogtest.h"
#include "dkim-verify/dkimruledialog.h"
#include "dkim-verify/dkimrulewidget.h"
#include <QDialogButtonBox>
#include <QTest>
#include <QVBoxLayout>
QTEST_MAIN(DKIMRuleDialogTest)
DKIMRuleDialogTest::DKIMRuleDialogTest(QObject *parent)
: QObject(parent)
{
}
void DKIMRuleDialogTest::shouldHaveDefaultValues()
{
MessageViewer::DKIMRuleDialog dlg;
QVERIFY(!dlg.windowTitle().isEmpty());
QVBoxLayout *mainLayout = dlg.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout);
MessageViewer::DKIMRuleWidget *rulewidget = dlg.findChild<MessageViewer::DKIMRuleWidget *>(QStringLiteral("rulewidget"));
QVERIFY(rulewidget);
QDialogButtonBox *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonBox"));
QVERIFY(buttonBox);
QCOMPARE(buttonBox->standardButtons(), {QDialogButtonBox::Ok | QDialogButtonBox::Cancel});
}
/*
Copyright (C) 2019-2020 Laurent Montel <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 DKIMRULEDIALOGTEST_H
#define DKIMRULEDIALOGTEST_H
#include <QObject>
class DKIMRuleDialogTest : public QObject
{
Q_OBJECT
public:
explicit DKIMRuleDialogTest(QObject *parent = nullptr);
~DKIMRuleDialogTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
#endif // DKIMRULEDIALOGTEST_H
/*
Copyright (C) 2019-2020 Laurent Montel <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 "dkimrulewidgettest.h"
#include "dkim-verify/dkimrulewidget.h"
#include "dkim-verify/dkimmanagerulescombobox.h"
#include <QCheckBox>
#include <QFormLayout>
#include <QLineEdit>
#include <QTest>
QTEST_MAIN(DKIMRuleWidgetTest)
DKIMRuleWidgetTest::DKIMRuleWidgetTest(QObject *parent)
: QObject(parent)
{
}
void DKIMRuleWidgetTest::shouldHaveDefaultValues()
{
MessageViewer::DKIMRuleWidget w;
QVERIFY(!w.rule().isValid());
QFormLayout *layout = w.findChild<QFormLayout *>(QStringLiteral("layout"));
QCOMPARE(layout->contentsMargins(), QMargins(0, 0, 0, 0));
QCheckBox *mEnabled = w.findChild<QCheckBox *>(QStringLiteral("enabled"));
QVERIFY(mEnabled);
QVERIFY(!mEnabled->text().isEmpty());
QVERIFY(!mEnabled->isChecked());
QLineEdit *mDomain = w.findChild<QLineEdit *>(QStringLiteral("domain"));
QVERIFY(mDomain);
QVERIFY(mDomain->text().isEmpty());
QVERIFY(mDomain->isClearButtonEnabled());
QLineEdit *mListId = w.findChild<QLineEdit *>(QStringLiteral("listid"));
QVERIFY(mListId);
QVERIFY(mListId->text().isEmpty());
QVERIFY(mListId->isClearButtonEnabled());
QLineEdit *mFrom = w.findChild<QLineEdit *>(QStringLiteral("from"));
QVERIFY(mFrom);
QVERIFY(mFrom->text().isEmpty());
QVERIFY(mFrom->isClearButtonEnabled());
QLineEdit *mSignatureDomainIdentifier = w.findChild<QLineEdit *>(QStringLiteral("signaturedomainidentifier"));
QVERIFY(mSignatureDomainIdentifier);
QVERIFY(mSignatureDomainIdentifier->text().isEmpty());
QVERIFY(mSignatureDomainIdentifier->isClearButtonEnabled());
MessageViewer::DKIMManageRulesComboBox *mRuleType = w.findChild<MessageViewer::DKIMManageRulesComboBox *>(QStringLiteral("ruletype"));
QVERIFY(mRuleType);
}
/*
Copyright (C) 2019-2020 Laurent Montel <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 DKIMRULEWIDGETTEST_H
#define DKIMRULEWIDGETTEST_H
#include <QObject>
class DKIMRuleWidgetTest : public QObject
{
Q_OBJECT
public:
explicit DKIMRuleWidgetTest(QObject *parent = nullptr);
~DKIMRuleWidgetTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
#endif // DKIMRULEWIDGETTEST_H
/*
Copyright (C) 2019-2020 Laurent Montel <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 "dkimmanagerulescombobox.h"
#include <KLocalizedString>
using namespace MessageViewer;
DKIMManageRulesComboBox::DKIMManageRulesComboBox(QWidget *parent)
: QComboBox(parent)
{
init();
}
DKIMManageRulesComboBox::~DKIMManageRulesComboBox()
{
}
void DKIMManageRulesComboBox::init()
{
addItem(i18n("Must be signed"), QVariant::fromValue(MessageViewer::DKIMRule::RuleType::MustBeSigned));
addItem(i18n("Can be signed"), QVariant::fromValue(MessageViewer::DKIMRule::RuleType::CanBeSigned));
addItem(i18n("Ignore if not signed"), QVariant::fromValue(MessageViewer::DKIMRule::RuleType::IgnoreEmailNotSigned));
}
MessageViewer::DKIMRule::RuleType DKIMManageRulesComboBox::ruleType() const
{
return currentData().value<MessageViewer::DKIMRule::RuleType>();
}
void DKIMManageRulesComboBox::setRuleType(MessageViewer::DKIMRule::RuleType type)
{
const int index = findData(QVariant::fromValue(type));
if (index != -1) {
setCurrentIndex(index);
}
}
/*
Copyright (C) 2019-2020 Laurent Montel <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 DKIMMANAGERULESCOMBOBOX_H
#define DKIMMANAGERULESCOMBOBOX_H
#include "messageviewer_private_export.h"
#include <MessageViewer/DKIMRule>
#include <QComboBox>
namespace MessageViewer {
class MESSAGEVIEWER_TESTS_EXPORT DKIMManageRulesComboBox : public QComboBox
{
Q_OBJECT
public:
explicit DKIMManageRulesComboBox(QWidget *parent = nullptr);
~DKIMManageRulesComboBox();
Q_REQUIRED_RESULT MessageViewer::DKIMRule::RuleType ruleType() const;
void setRuleType(MessageViewer::DKIMRule::RuleType type);
private:
void init();
};
}
#endif // DKIMMANAGERULESCOMBOBOX_H
/*
Copyright (C) 2019-2020 Laurent Montel <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