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

Remove kwallet

parent 4db5ba06
Pipeline #41618 passed with stage
in 25 minutes and 32 seconds
......@@ -71,7 +71,7 @@ set(MESSAGELIB_LIB_VERSION "5.15.80")
set(LIBKLEO_LIB_VERSION "5.15.80")
set(PIMCOMMON_LIB_VERSION "5.15.80")
set(LIBKDEPIM_LIB_VERSION "5.15.80")
set(LIBKSIEVE_LIB_VERSION "5.15.80")
set(LIBKSIEVE_LIB_VERSION "5.16.42")
set(AKONADI_SEARCH_VERSION "5.15.80")
find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED)
......@@ -137,7 +137,6 @@ find_package(KF5TemplateParser ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5Tnef ${KTNEF_LIB_VERSION} CONFIG REQUIRED)
find_package(MailTransportDBusService CONFIG REQUIRED)
#it will replace kwallet support
find_package(Qt5Keychain CONFIG)
set_package_properties(Qt5Keychain PROPERTIES
DESCRIPTION "Provides support for secure credentials storage"
......
......@@ -357,6 +357,7 @@ target_link_libraries(kmailprivate
KF5::WebEngineViewer
KF5::SyntaxHighlighting
KF5::GuiAddons
qt5keychain
${kmail_userfeedback_LIB}
)
target_include_directories(kmailprivate PUBLIC $<TARGET_PROPERTY:KF5::MessageList,INTERFACE_INCLUDE_DIRECTORIES>)
......
......@@ -212,7 +212,7 @@ KMMainWidget::KMMainWidget(QWidget *parent, KXMLGUIClient *aGUIClient, KActionCo
mFolderTreeWidget = nullptr;
Akonadi::ControlGui::widgetNeedsAkonadi(this);
mFavoritesModel = nullptr;
mSievePasswordProvider = new KMSieveImapPasswordProvider(winId());
mSievePasswordProvider = new KMSieveImapPasswordProvider(this);
mVacationManager = new KSieveUi::VacationManager(mSievePasswordProvider, this);
connect(mVacationManager, &KSieveUi::VacationManager::updateVacationScriptStatus, this, qOverload<bool, const QString &>(&KMMainWidget::updateVacationScriptStatus));
......
......@@ -5,37 +5,55 @@
*/
#include "kmsieveimappasswordprovider.h"
#include <KWallet>
#include <memory>
KMSieveImapPasswordProvider::KMSieveImapPasswordProvider(WId wid)
: mWid(wid)
#include "kmail_debug.h"
using namespace QKeychain;
KMSieveImapPasswordProvider::KMSieveImapPasswordProvider(QObject *parent)
: KSieveUi::SieveImapPasswordProvider(parent)
{
}
QString KMSieveImapPasswordProvider::password(const QString &identifier)
KMSieveImapPasswordProvider::~KMSieveImapPasswordProvider()
{
return walletPassword(identifier);
}
QString KMSieveImapPasswordProvider::sieveCustomPassword(const QString &identifier)
void KMSieveImapPasswordProvider::passwords(const QString &identifier)
{
return walletPassword(QStringLiteral("custom_sieve_") + identifier);
mIdentifier = identifier;
auto readJob = new ReadPasswordJob(QStringLiteral("imap"), this);
connect(readJob, &Job::finished, this, &KMSieveImapPasswordProvider::readSieveServerPasswordFinished);
readJob->setKey(mIdentifier + QStringLiteral("rc"));
readJob->start();
}
QString KMSieveImapPasswordProvider::walletPassword(const QString &identifier)
void KMSieveImapPasswordProvider::readSieveServerPasswordFinished(QKeychain::Job *baseJob)
{
std::unique_ptr<KWallet::Wallet> wallet(KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), mWid));
if (wallet) {
if (wallet->hasFolder(QStringLiteral("imap"))) {
QString pwd;
wallet->setFolder(QStringLiteral("imap"));
wallet->readPassword(identifier + QStringLiteral("rc"), pwd);
return pwd;
}
auto *job = qobject_cast<ReadPasswordJob *>(baseJob);
Q_ASSERT(job);
if (job->error()) {
qCWarning(KMAIL_LOG) << "An error occurred while reading password: " << job->errorString();
} else {
mSievePassword = job->textData();
}
return {};
auto readJob = new ReadPasswordJob(QStringLiteral("imap"), this);
connect(readJob, &Job::finished, this, &KMSieveImapPasswordProvider::readSieveServerCustomPasswordFinished);
readJob->setKey(QStringLiteral("custom_sieve_") + mIdentifier + QStringLiteral("rc"));
readJob->start();
}
void KMSieveImapPasswordProvider::readSieveServerCustomPasswordFinished(QKeychain::Job *baseJob)
{
auto *job = qobject_cast<ReadPasswordJob *>(baseJob);
Q_ASSERT(job);
if (job->error()) {
qCWarning(KMAIL_LOG) << "An error occurred while reading password: " << job->errorString();
} else {
mSieveCustomPassword = job->textData();
}
Q_EMIT passwordsRequested(mSievePassword, mSieveCustomPassword);
//Don't store it.
mSievePassword.clear();
mSieveCustomPassword.clear();
}
......@@ -8,21 +8,23 @@
#define KMSIEVEIMAPPASSWORDPROVIDER_H
#include "kmail_private_export.h"
#include <KSieveUi/SieveImapPasswordProvider>
#include <QWidget> // for WId
#include <qt5keychain/keychain.h>
class KMAILTESTS_TESTS_EXPORT KMSieveImapPasswordProvider : public KSieveUi::SieveImapPasswordProvider
{
Q_OBJECT
public:
KMSieveImapPasswordProvider(WId wid);
explicit KMSieveImapPasswordProvider(QObject *parent = nullptr);
~KMSieveImapPasswordProvider() override;
Q_REQUIRED_RESULT QString password(const QString &identifier) override;
Q_REQUIRED_RESULT QString sieveCustomPassword(const QString &identifier) override;
void passwords(const QString &identifier) override;
private:
void readSieveServerPasswordFinished(QKeychain::Job *baseJob);
void readSieveServerCustomPasswordFinished(QKeychain::Job *baseJob);
Q_REQUIRED_RESULT QString walletPassword(const QString &identifier);
const WId mWid;
QString mIdentifier;
QString mSievePassword;
QString mSieveCustomPassword;
};
#endif
......@@ -5,6 +5,6 @@ target_link_libraries(sievedebugdialog
KF5::KSieveUi
KF5::AkonadiCore
KF5::SyntaxHighlighting
KF5::Wallet
kmailprivate
qt5keychain
)
......@@ -4,6 +4,6 @@ target_link_libraries(sievemanagerdialog
KF5::KSieve
KF5::KSieveUi
KF5::AkonadiCore
KF5::Wallet
kmailprivate
qt5keychain
)
......@@ -3,5 +3,5 @@ set(vacation_multi_server_SRCS
)
add_executable(vacationmultiservertest ${vacation_multi_server_SRCS} )
target_link_libraries(vacationmultiservertest KF5::KSieveUi KF5::KSieve KF5::I18n KF5::AkonadiCore KF5::Wallet kmailprivate)
target_link_libraries(vacationmultiservertest KF5::KSieveUi KF5::KSieve KF5::I18n KF5::AkonadiCore qt5keychain kmailprivate)
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