Commit ab3c0c58 authored by Albert Astals Cid's avatar Albert Astals Cid

Implement the new libksieve password provider class

Differential Revision: https://phabricator.kde.org/D6208
parent cd954038
......@@ -69,7 +69,7 @@ set(MESSAGELIB_LIB_VERSION_LIB "5.5.49")
set(LIBKLEO_LIB_VERSION_LIB "5.5.40")
set(PIMCOMMON_LIB_VERSION_LIB "5.5.41")
set(LIBKDEPIM_LIB_VERSION_LIB "5.5.42")
set(LIBKSIEVE_LIB_VERSION_LIB "5.5.40")
set(LIBKSIEVE_LIB_VERSION_LIB "5.5.47")
find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED)
......
......@@ -169,6 +169,7 @@ set(kmailprivate_checkindexing_LIB_SRCS
set(kmailprivate_sieveimapinstanceinterface_LIB_SRCS
sieveimapinterface/kmailsieveimapinstanceinterface.cpp
sieveimapinterface/kmsieveimappasswordprovider.cpp
)
set(kmail_common_SRCS)
......
......@@ -52,6 +52,7 @@
#include "kpimtextedit/texttospeech.h"
#include "job/markallmessagesasreadinfolderandsubfolderjob.h"
#include "job/removeduplicatemessageinfolderandsubfolderjob.h"
#include "sieveimapinterface/kmsieveimappasswordprovider.h"
#if !defined(NDEBUG)
#include <KSieveUi/SieveDebugDialog>
using KSieveUi::SieveDebugDialog;
......@@ -249,7 +250,8 @@ KMMainWidget::KMMainWidget(QWidget *parent, KXMLGUIClient *aGUIClient, KActionCo
mPreferHtmlLoadExtAction = nullptr;
Akonadi::ControlGui::widgetNeedsAkonadi(this);
mFavoritesModel = nullptr;
mVacationManager = new KSieveUi::VacationManager(this);
mSievePasswordProvider = new KMSieveImapPasswordProvider(winId());
mVacationManager = new KSieveUi::VacationManager(mSievePasswordProvider, this);
connect(mVacationManager, SIGNAL(updateVacationScriptStatus(bool,QString)), SLOT(updateVacationScriptStatus(bool,QString)));
mToolbarActionSeparator = new QAction(this);
......@@ -402,6 +404,7 @@ void KMMainWidget::destruct()
clearCurrentFolder();
delete mMoveOrCopyToDialog;
delete mSelectFromAllFoldersDialog;
delete mSievePasswordProvider;
disconnect(kmkernel->folderCollectionMonitor(), SIGNAL(itemAdded(Akonadi::Item,Akonadi::Collection)), this, nullptr);
disconnect(kmkernel->folderCollectionMonitor(), SIGNAL(itemRemoved(Akonadi::Item)), this, nullptr);
......@@ -1308,7 +1311,7 @@ void KMMainWidget::slotManageSieveScripts()
return;
}
mManageSieveDialog = new KSieveUi::ManageSieveScriptsDialog;
mManageSieveDialog = new KSieveUi::ManageSieveScriptsDialog(mSievePasswordProvider);
connect(mManageSieveDialog.data(), &KSieveUi::ManageSieveScriptsDialog::finished, this, &KMMainWidget::slotCheckVacation);
mManageSieveDialog->show();
}
......@@ -2249,7 +2252,7 @@ void KMMainWidget::slotDebugSieve()
return;
}
mSieveDebugDialog = new KSieveUi::SieveDebugDialog(this);
mSieveDebugDialog = new KSieveUi::SieveDebugDialog(mSievePasswordProvider, this);
mSieveDebugDialog->exec();
delete mSieveDebugDialog;
#endif
......
......@@ -78,6 +78,7 @@ class FolderShortcutActionManager;
namespace KSieveUi {
class SieveDebugDialog;
class SieveImapPasswordProvider;
class ManageSieveScriptsDialog;
class VacationManager;
}
......@@ -656,6 +657,7 @@ private:
QTimer mCheckMailTimer;
KSieveUi::SieveImapPasswordProvider *mSievePasswordProvider;
QPointer<MailCommon::FolderSelectionDialog> mMoveOrCopyToDialog;
QPointer<MailCommon::FolderSelectionDialog> mSelectFromAllFoldersDialog;
QAction *mServerSideSubscription;
......
/*
Copyright (c) 2017 Albert Astals Cid <aacid@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "kmsieveimappasswordprovider.h"
#include <kwallet.h>
#include <memory>
KMSieveImapPasswordProvider::KMSieveImapPasswordProvider(WId wid)
: m_wid(wid)
{
}
QString KMSieveImapPasswordProvider::password(const QString &identifier)
{
return walletPassword(identifier);
}
QString KMSieveImapPasswordProvider::sieveCustomPassword(const QString &identifier)
{
return walletPassword(QStringLiteral("custom_sieve_") + identifier);
}
QString KMSieveImapPasswordProvider::walletPassword(const QString &identifier)
{
std::unique_ptr<KWallet::Wallet> wallet(KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), m_wid));
if (wallet) {
if (wallet->hasFolder(QStringLiteral("imap"))) {
QString pwd;
wallet->setFolder(QStringLiteral("imap"));
wallet->readPassword(identifier + QStringLiteral("rc"), pwd);
return pwd;
}
}
return QString();
}
/*
Copyright (c) 2017 Albert Astals Cid <aacid@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef KMSIEVEIMAPPASSWORDPROVIDER_H
#define KMSIEVEIMAPPASSWORDPROVIDER_H
#include <ksieveui/sieveimappasswordprovider.h>
#include <QWidget> // for WId
class KMSieveImapPasswordProvider : public KSieveUi::SieveImapPasswordProvider
{
public:
KMSieveImapPasswordProvider(WId wid);
QString password(const QString &identifier) override;
QString sieveCustomPassword(const QString &identifier) override;
private:
QString walletPassword(const QString &identifier);
WId m_wid;
};
#endif
add_executable(sievedebugdialog sievedebugdialog.cpp ../../../sieveimapinterface/kmailsieveimapinstanceinterface.cpp)
add_executable(sievedebugdialog sievedebugdialog.cpp ../../../sieveimapinterface/kmailsieveimapinstanceinterface.cpp ../../../sieveimapinterface/kmsieveimappasswordprovider.cpp)
target_link_libraries(sievedebugdialog
KF5::KSieve
KF5::KSieveUi
KF5::AkonadiCore
KF5::SyntaxHighlighting
KF5::Wallet
)
......@@ -20,6 +20,7 @@
#include <KSieveUi/SieveDebugDialog>
#include <KSieveUi/SieveImapInstanceInterfaceManager>
#include "../../../sieveimapinterface/kmailsieveimapinstanceinterface.h"
#include "../../../sieveimapinterface/kmsieveimappasswordprovider.h"
#include <QApplication>
......@@ -31,7 +32,8 @@ int main(int argc, char **argv)
QApplication::setApplicationVersion(QStringLiteral("1.0"));
KSieveUi::SieveImapInstanceInterfaceManager::self()->setSieveImapInstanceInterface(new KMailSieveImapInstanceInterface);
KSieveUi::SieveDebugDialog *dlg = new KSieveUi::SieveDebugDialog;
KMSieveImapPasswordProvider provider(0);
KSieveUi::SieveDebugDialog *dlg = new KSieveUi::SieveDebugDialog(&provider);
dlg->exec();
delete dlg;
return 0;
......
add_executable(sievemanagerdialog sievemanagerdialog.cpp ../../../sieveimapinterface/kmailsieveimapinstanceinterface.cpp)
add_executable(sievemanagerdialog sievemanagerdialog.cpp ../../../sieveimapinterface/kmailsieveimapinstanceinterface.cpp ../../../sieveimapinterface/kmsieveimappasswordprovider.cpp)
target_link_libraries(sievemanagerdialog
KF5::KSieve
KF5::KSieveUi
KF5::AkonadiCore
KF5::Wallet
)
......@@ -20,6 +20,7 @@
#include <KSieveUi/ManageSieveScriptsDialog>
#include <KSieveUi/SieveImapInstanceInterfaceManager>
#include "../../../sieveimapinterface/kmailsieveimapinstanceinterface.h"
#include "../../../sieveimapinterface/kmsieveimappasswordprovider.h"
#include <QApplication>
int main(int argc, char **argv)
......@@ -29,7 +30,8 @@ int main(int argc, char **argv)
QApplication::setApplicationVersion(QStringLiteral("1.0"));
KSieveUi::SieveImapInstanceInterfaceManager::self()->setSieveImapInstanceInterface(new KMailSieveImapInstanceInterface);
KSieveUi::ManageSieveScriptsDialog *dlg = new KSieveUi::ManageSieveScriptsDialog;
KMSieveImapPasswordProvider provider(0);
KSieveUi::ManageSieveScriptsDialog *dlg = new KSieveUi::ManageSieveScriptsDialog(&provider);
dlg->show();
return app.exec();
}
set(vacation_multi_server_SRCS
main.cpp
../../../sieveimapinterface/kmailsieveimapinstanceinterface.cpp
../../../sieveimapinterface/kmsieveimappasswordprovider.cpp
)
add_executable(vacationmultiservertest ${vacation_multi_server_SRCS} )
target_link_libraries(vacationmultiservertest KF5::KSieveUi KF5::KSieve KF5::I18n KF5::AkonadiCore)
target_link_libraries(vacationmultiservertest KF5::KSieveUi KF5::KSieve KF5::I18n KF5::AkonadiCore KF5::Wallet)
......@@ -25,6 +25,7 @@
#include <KSieveUi/MultiImapVacationManager>
#include <KSieveUi/SieveImapInstanceInterfaceManager>
#include "../../../sieveimapinterface/kmailsieveimapinstanceinterface.h"
#include "../../../sieveimapinterface/kmsieveimappasswordprovider.h"
int main(int argc, char **argv)
{
QApplication app(argc, argv);
......@@ -45,7 +46,8 @@ int main(int argc, char **argv)
app.setQuitOnLastWindowClosed(true);
KSieveUi::SieveImapInstanceInterfaceManager::self()->setSieveImapInstanceInterface(new KMailSieveImapInstanceInterface);
KSieveUi::MultiImapVacationManager manager;
KMSieveImapPasswordProvider provider(0);
KSieveUi::MultiImapVacationManager manager(&provider);
KSieveUi::MultiImapVacationDialog dlg(&manager);
QObject::connect(&dlg, &KSieveUi::MultiImapVacationDialog::okClicked, &app, &QApplication::quit);
QObject::connect(&dlg, &KSieveUi::MultiImapVacationDialog::cancelClicked, &app, &QApplication::quit);
......
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