Commit 74e51449 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make it works

parent d773003c
......@@ -27,6 +27,7 @@
#include <KIdentityManagement/IdentityManager>
#include <KIdentityManagement/Identity>
#include <MessageComposer/AliasesExpandJob>
ConfirmAddressInterface::ConfirmAddressInterface(QObject *parent)
: MessageComposer::PluginEditorCheckBeforeSendInterface(parent),
......@@ -51,18 +52,56 @@ bool ConfirmAddressInterface::exec(const MessageComposer::PluginEditorCheckBefor
if (settings.mDomains.isEmpty() && settings.mWhiteLists.isEmpty()) {
return true;
}
qDebug() << " params.addresses() "<<params.addresses();
QStringList emails;
#if 0
MessageComposer::AliasesExpandJob job(params.addresses().join(QStringLiteral(", ")), params.defaultDomain(), this);
if (job.exec()) {
emails = job.emailAddressOnly();
}
#endif
emails = params.addresses();
#ifdef USE_PLUGIN
QPointer<ConfirmAddressDialog> dlg = new ConfirmAddressDialog(parentWidget());
//TODO use params
if (dlg->exec()) {
return true;
qDebug() << " emails "<<emails;
qDebug()<< "settings.mDomains :"<<settings.mDomains << " settings.mWhiteLists"<<settings.mWhiteLists;
QStringList invalidEmails;
QStringList validEmails;
bool foundValidEmail = false;
Q_FOREACH (const QString &email, emails) {
Q_FOREACH(const QString &domain, settings.mDomains) {
if (email.contains(domain)) {
validEmails.append(email);
foundValidEmail = true;
break;
}
}
if (!foundValidEmail) {
Q_FOREACH(const QString &whiteEmail, settings.mWhiteLists) {
if (email.contains(whiteEmail)) {
validEmails.append(email);
foundValidEmail = true;
break;
}
}
}
if (!foundValidEmail) {
invalidEmails.append(email);
}
}
if (!invalidEmails.isEmpty()) {
QPointer<ConfirmAddressDialog> dlg = new ConfirmAddressDialog(parentWidget());
dlg->setValidAddresses(validEmails);
dlg->setInvalidAddresses(invalidEmails);
if (dlg->exec()) {
delete dlg;
return true;
} else {
delete dlg;
return false;
}
} else {
return false;
return true;
}
#else
return true;
#endif
} else {
return true;
}
......
......@@ -47,11 +47,13 @@ ConfirmAddressWidget::~ConfirmAddressWidget()
void ConfirmAddressWidget::setValidAddresses(const QStringList &addresses)
{
qDebug()<<" void ConfirmAddressWidget::setValidAddresses(const QStringList &addresses)"<<addresses;
createAddressItems(addresses, true);
}
void ConfirmAddressWidget::setInvalidAddresses(const QStringList &addresses)
{
qDebug()<<" void ConfirmAddressWidget::setInvalidAddresses(const QStringList &addresses)"<<addresses;
createAddressItems(addresses, false);
}
......@@ -62,5 +64,6 @@ void ConfirmAddressWidget::createAddressItems(const QStringList &address, bool v
if (!valid) {
item->setTextColor(Qt::red);
}
mListEmails->addItem(item);
}
}
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