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

Allow to show when we stored it

parent 4f744a83
Pipeline #53177 passed with stage
in 41 minutes and 46 seconds
......@@ -109,13 +109,13 @@ void DKIMCheckFullJob::storeKey(const QString &key, const QString &domain, const
void DKIMCheckFullJob::storeInKeyManager(const QString &key, const QString &domain, const QString &selector, bool verify)
{
const MessageViewer::KeyInfo info{key, selector, domain};
const MessageViewer::KeyInfo info{key, selector, domain, QDateTime::currentDateTime()};
if (verify) {
const QString keyStored = MessageViewer::DKIMManagerKey::self()->keyValue(selector, domain);
if (!keyStored.isEmpty()) {
if (keyStored != key) {
qDebug() << "storeInKeyManager : keyStored " << keyStored << " key " << key;
qDebug() << "domain " << domain << " selector " << selector;
// qDebug() << "storeInKeyManager : keyStored " << keyStored << " key " << key;
// qDebug() << "domain " << domain << " selector " << selector;
if (KMessageBox::No
== KMessageBox::warningYesNo(nullptr,
i18n("Stored DKIM key is different from the current one. Do you want to store this one too?"),
......
......@@ -84,7 +84,8 @@ void DKIMManagerKey::loadKeys()
const QString selector = group.readEntry(QStringLiteral("Selector"), QString());
const QString domain = group.readEntry(QStringLiteral("Domain"), QString());
const QString key = group.readEntry(QStringLiteral("Key"), QString());
mKeys.append(KeyInfo{key, selector, domain});
const QDateTime storedAt = QDateTime::fromString(group.readEntry(QStringLiteral("StoredAt"), QString()), Qt::ISODate);
mKeys.append(KeyInfo{key, selector, domain, storedAt});
}
}
......@@ -103,6 +104,7 @@ void DKIMManagerKey::saveKeys()
group.writeEntry(QStringLiteral("Selector"), info.selector);
group.writeEntry(QStringLiteral("Domain"), info.domain);
group.writeEntry(QStringLiteral("Key"), info.keyValue);
group.writeEntry(QStringLiteral("StoredAt"), info.storedAtDateTime.toString(Qt::ISODate));
}
}
......@@ -127,5 +129,6 @@ QDebug operator<<(QDebug d, const KeyInfo &t)
d << " keyvalue " << t.keyValue;
d << " selector " << t.selector;
d << " domain " << t.domain;
d << " storedAtDateTime " << t.storedAtDateTime;
return d;
}
......@@ -10,6 +10,7 @@
#include "config-messageviewer.h"
#include "messageviewer_export.h"
#include <KSharedConfig>
#include <QDateTime>
#include <QObject>
#include <QVector>
namespace QCA
......@@ -27,16 +28,18 @@ struct MESSAGEVIEWER_EXPORT KeyInfo {
{
}
KeyInfo(const QString &key, const QString &sel, const QString &dom)
KeyInfo(const QString &key, const QString &sel, const QString &dom, const QDateTime &storedAt = {})
: keyValue(key)
, selector(sel)
, domain(dom)
, storedAtDateTime(storedAt)
{
}
QString keyValue;
QString selector;
QString domain;
QDateTime storedAtDateTime;
Q_REQUIRED_RESULT bool operator==(const KeyInfo &) const;
Q_REQUIRED_RESULT bool operator!=(const KeyInfo &) const;
};
......
......@@ -28,7 +28,7 @@ DKIMManagerKeyWidget::DKIMManagerKeyWidget(QWidget *parent)
mTreeWidget->setObjectName(QStringLiteral("treewidget"));
mTreeWidget->setRootIsDecorated(false);
mTreeWidget->setHeaderLabels({i18n("SDID"), i18n("Selector"), i18n("DKIM Key")});
mTreeWidget->setHeaderLabels({i18n("SDID"), i18n("Selector"), i18n("DKIM Key"), i18n("Inserted")});
mTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
mTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
mTreeWidget->setAlternatingRowColors(true);
......@@ -104,6 +104,7 @@ void DKIMManagerKeyWidget::loadKeys()
item->setText(0, key.domain);
item->setText(1, key.selector);
item->setText(2, key.keyValue);
item->setText(3, key.storedAtDateTime.toString());
item->setToolTip(2, key.keyValue);
}
}
......@@ -114,7 +115,7 @@ void DKIMManagerKeyWidget::saveKeys()
lst.reserve(mTreeWidget->topLevelItemCount());
for (int i = 0, total = mTreeWidget->topLevelItemCount(); i < total; ++i) {
QTreeWidgetItem *item = mTreeWidget->topLevelItem(i);
const MessageViewer::KeyInfo info{item->text(2), item->text(1), item->text(0)};
const MessageViewer::KeyInfo info{item->text(2), item->text(1), item->text(0), QDateTime::fromString(item->text(3))};
lst.append(info);
}
DKIMManagerKey::self()->saveKeys(lst);
......
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