Commit cc398c52 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add a new check "verify that we use same mailtransport as defined in identity"

parent d39a4638
......@@ -69,7 +69,7 @@ set(KDEPIMLIBS_LIB_VERSION "5.2.40")
set(GRAVATAR_LIB_VERSION "5.2.40")
set(INCIDENCEEDITOR_LIB_VERSION "5.2.40")
set(KTNEF_LIB_VERSION "5.2.40")
set(MESSAGELIB_LIB_VERSION "5.2.80")
set(MESSAGELIB_LIB_VERSION "5.2.82")
set(AKONADICALENDAR_LIB_VERSION "5.2.40")
find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED)
......
......@@ -42,6 +42,11 @@ void CheckBeforeSendConfigureWidgetTest::shouldHaveDefaultValue()
QCheckBox *mCheckPlainTextMail = w.findChild<QCheckBox *>(QStringLiteral("checkplaintext"));
QVERIFY(mCheckPlainTextMail);
QVERIFY(!mCheckPlainTextMail->text().isEmpty());
QCheckBox *mCheckMailTransport = w.findChild<QCheckBox *>(QStringLiteral("smtpdefinedinidentity"));
QVERIFY(mCheckMailTransport);
QVERIFY(!mCheckMailTransport->text().isEmpty());
}
QTEST_MAIN(CheckBeforeSendConfigureWidgetTest)
......@@ -34,6 +34,13 @@ CheckBeforeSendConfigureWidget::CheckBeforeSendConfigureWidget(QWidget *parent)
mCheckPlainTextMail->setObjectName(QStringLiteral("checkplaintext"));
connect(mCheckPlainTextMail, &QCheckBox::clicked, this, &CheckBeforeSendConfigureWidget::configureChanged);
mainLayout->addWidget(mCheckPlainTextMail);
mCheckMailTransport = new QCheckBox(i18n("Use SMTP defined in identity"), this);
mCheckMailTransport->setObjectName(QStringLiteral("smtpdefinedinidentity"));
connect(mCheckMailTransport, &QCheckBox::clicked, this, &CheckBeforeSendConfigureWidget::configureChanged);
mainLayout->addWidget(mCheckMailTransport);
mainLayout->addStretch(1);
}
......@@ -46,15 +53,18 @@ void CheckBeforeSendConfigureWidget::loadSettings()
{
KConfigGroup grp(KSharedConfig::openConfig(), "Check Before Send");
mCheckPlainTextMail->setChecked(grp.readEntry("SendPlainText", false));
mCheckMailTransport->setChecked(grp.readEntry("SmtpDefinedInIdentity", false));
}
void CheckBeforeSendConfigureWidget::saveSettings()
{
KConfigGroup grp(KSharedConfig::openConfig(), "Check Before Send");
grp.writeEntry("SendPlainText", mCheckPlainTextMail->isChecked());
grp.writeEntry("SmtpDefinedInIdentity", mCheckMailTransport->isChecked());
}
void CheckBeforeSendConfigureWidget::resetSettings()
{
mCheckPlainTextMail->setChecked(false);
mCheckMailTransport->setChecked(false);
}
......@@ -37,6 +37,7 @@ public:
private:
QCheckBox *mCheckPlainTextMail;
QCheckBox *mCheckMailTransport;
};
#endif // CHECKBEFORESENDCONFIGUREWIDGET_H
......@@ -23,10 +23,14 @@
#include <KConfigGroup>
#include <KSharedConfig>
#include <KLocalizedString>
#include <KIdentityManagement/Identity>
#include <KIdentityManagement/IdentityManager>
CheckBeforeSendInterface::CheckBeforeSendInterface(QObject *parent)
: MessageComposer::PluginEditorCheckBeforeSendInterface(parent),
mSendPlainText(false)
mIdentityManager(Q_NULLPTR),
mSendPlainText(false),
mCheckMailTransport(false)
{
reloadConfig();
}
......@@ -47,6 +51,19 @@ bool CheckBeforeSendInterface::exec(const MessageComposer::PluginEditorCheckBefo
}
}
}
if (mCheckMailTransport) {
if (!mIdentityManager) {
mIdentityManager = new KIdentityManagement::IdentityManager(true, this);
}
const KIdentityManagement::Identity identity = mIdentityManager->identityForUoid(params.identity());
if (identity.transport() != QString::number(params.transportId())) {
if (KMessageBox::No == KMessageBox::questionYesNo(parentWidget(), i18n("Do you want to send mail with a different SMTP that defined in current identity?"), i18n("Check SMTP server"))) {
return false;
} else {
return true;
}
}
}
return true;
}
......@@ -54,4 +71,5 @@ void CheckBeforeSendInterface::reloadConfig()
{
KConfigGroup grp(KSharedConfig::openConfig(), "Check Before Send");
mSendPlainText = grp.readEntry("SendPlainText", false);
mCheckMailTransport = grp.readEntry("SmtpDefinedInIdentity", false);
}
......@@ -21,7 +21,10 @@
#define CHECKBEFORESENDINTERFACE_H
#include <MessageComposer/PluginEditorCheckBeforeSendInterface>
namespace KIdentityManagement
{
class IdentityManager;
}
class CheckBeforeSendInterface : public MessageComposer::PluginEditorCheckBeforeSendInterface
{
Q_OBJECT
......@@ -34,7 +37,9 @@ public:
public Q_SLOTS:
void reloadConfig() Q_DECL_OVERRIDE;
private:
KIdentityManagement::IdentityManager *mIdentityManager;
bool mSendPlainText;
bool mCheckMailTransport;
};
#endif // CHECKBEFORESENDINTERFACE_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