Commit 1d061397 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Prepare to use qtkeychain

parent e7ca5026
Pipeline #40356 canceled with stage
......@@ -19,11 +19,12 @@
#include "serversievelistwidget.h"
#include "serversievesettingsdialog.h"
#include "sieveserversettings.h"
#include <KLocalizedString>
#include <QListWidgetItem>
#include <QPointer>
#include <KWallet>
ServerSieveListWidget::ServerSieveListWidget(QWidget *parent)
: QListWidget(parent)
......@@ -56,7 +57,24 @@ void ServerSieveListWidget::writeConfig()
}
}
SieveEditorUtil::writeServerSieveConfig(lstServerConfig);
SieveEditorUtil::deletePasswords(mNeedToRemovePasswordInWallet);
}
void ServerSieveListWidget::deletePasswords()
{
if (!mNeedToRemovePasswordInWallet.isEmpty()) {
KWallet::Wallet *wallet = SieveServerSettings::self()->wallet();
if (wallet && wallet->isOpen()) {
if (wallet->hasFolder(QStringLiteral("sieveeditor"))) {
wallet->setFolder(QStringLiteral("sieveeditor"));
for (const QString &identifier : mNeedToRemovePasswordInWallet) {
//TODO move to qtkeychain
if (wallet->hasEntry(identifier)) {
wallet->removeEntry(identifier);
}
}
}
}
}
}
void ServerSieveListWidget::modifyServerConfig()
......
......@@ -52,6 +52,7 @@ public Q_SLOTS:
void modifyServerConfig();
private:
void deletePasswords();
QStringList mNeedToRemovePasswordInWallet;
};
......
......@@ -87,6 +87,7 @@ bool SieveEditorUtil::SieveServerConfig::operator ==(const SieveEditorUtil::Siev
QVector<SieveEditorUtil::SieveServerConfig> SieveEditorUtil::readServerSieveConfig()
{
//TODO move to async
QVector<SieveServerConfig> lstConfig;
KSharedConfigPtr cfg = KSharedConfig::openConfig();
QRegularExpression re(QStringLiteral("^ServerSieve (.+)$"));
......@@ -233,23 +234,6 @@ void SieveEditorUtil::addServerSieveConfig(const SieveEditorUtil::SieveServerCon
cfg->sync();
}
void SieveEditorUtil::deletePasswords(const QStringList &identifiers)
{
if (!identifiers.isEmpty()) {
KWallet::Wallet *wallet = SieveServerSettings::self()->wallet();
if (wallet && wallet->isOpen()) {
if (wallet->hasFolder(QStringLiteral("sieveeditor"))) {
wallet->setFolder(QStringLiteral("sieveeditor"));
for (const QString &identifier : identifiers) {
if (wallet->hasEntry(identifier)) {
wallet->removeEntry(identifier);
}
}
}
}
}
}
QDebug operator <<(QDebug d, const SieveEditorUtil::SieveServerConfig &settings)
{
d << "sieveSettings " << settings.sieveSettings;
......
......@@ -66,7 +66,6 @@ QVector<SieveServerConfig> readServerSieveConfig();
void writeServerSieveConfig(const QVector<SieveEditorUtil::SieveServerConfig> &lstConfig);
void addServerSieveConfig(const SieveEditorUtil::SieveServerConfig &conf);
void writeSieveSettings(KWallet::Wallet *wallet, const KSharedConfigPtr &cfg, const SieveEditorUtil::SieveServerConfig &conf, int index);
void deletePasswords(const QStringList &identifiers);
QString sievePasswordIdentifier(const QString &userName, const QString &serverName);
QString imapPasswordIdentifier(const QString &userName, const QString &serverName);
}
......
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