summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <[email protected]>2017-06-15 22:10:21 +0200
committerAlbert Astals Cid <[email protected]>2017-06-15 22:11:23 +0200
commit8f9f19a88f9e90a9786f05f458af980b84d69625 (patch)
treeed27ae8019379d8d485c2f196ea71c64cb58d367
parent8e8d4316e8e11c0a182118f475a2e387a01e2117 (diff)
Introduce the password provider class
Instead of using the dbus interface of resuces to get the passwords Differential Revision: https://phabricator.kde.org/D6207
-rw-r--r--src/ksieveui/CMakeLists.txt1
-rw-r--r--src/ksieveui/debug/sievedebugdialog.cpp7
-rw-r--r--src/ksieveui/debug/sievedebugdialog.h6
-rw-r--r--src/ksieveui/managesievescriptsdialog.cpp4
-rw-r--r--src/ksieveui/managesievescriptsdialog.h3
-rw-r--r--src/ksieveui/util/abstractakonadiimapsettinginterface.cpp12
-rw-r--r--src/ksieveui/util/abstractakonadiimapsettinginterface.h2
-rw-r--r--src/ksieveui/util/akonadiimapsettinginterface.cpp23
-rw-r--r--src/ksieveui/util/akonadiimapsettinginterface.h2
-rw-r--r--src/ksieveui/util/autotests/akonadiimapsettinginterfacetest.cpp12
-rw-r--r--src/ksieveui/util/autotests/akonadiimapsettinginterfacetest.h2
-rw-r--r--src/ksieveui/util/autotests/utilmethodtest.cpp27
-rw-r--r--src/ksieveui/util/sieveimappasswordprovider.h39
-rw-r--r--src/ksieveui/util/util.cpp15
-rw-r--r--src/ksieveui/util/util_p.h5
-rw-r--r--src/ksieveui/vacation/multiimapvacationmanager.cpp5
-rw-r--r--src/ksieveui/vacation/multiimapvacationmanager.h4
-rw-r--r--src/ksieveui/vacation/vacation.cpp5
-rw-r--r--src/ksieveui/vacation/vacation.h4
-rw-r--r--src/ksieveui/vacation/vacationmanager.cpp4
-rw-r--r--src/ksieveui/vacation/vacationmanager.h3
-rw-r--r--src/ksieveui/widgets/custommanagesievewidget.cpp5
-rw-r--r--src/ksieveui/widgets/custommanagesievewidget.h6
23 files changed, 113 insertions, 83 deletions
diff --git a/src/ksieveui/CMakeLists.txt b/src/ksieveui/CMakeLists.txt
index aa5651d..4909d01 100644
--- a/src/ksieveui/CMakeLists.txt
+++ b/src/ksieveui/CMakeLists.txt
@@ -268,6 +268,7 @@ ecm_generate_headers(ksieveui_Camelcaseutil_HEADERS
HEADER_NAMES
Util
SieveImapAccountSettings
+ SieveImapPasswordProvider
REQUIRED_HEADERS ksieveui_util_HEADERS
PREFIX KSieveUi
RELATIVE util
diff --git a/src/ksieveui/debug/sievedebugdialog.cpp b/src/ksieveui/debug/sievedebugdialog.cpp
index 9e0f436..b4eaa1f 100644
--- a/src/ksieveui/debug/sievedebugdialog.cpp
+++ b/src/ksieveui/debug/sievedebugdialog.cpp
@@ -32,9 +32,10 @@
using namespace KSieveUi;
-SieveDebugDialog::SieveDebugDialog(QWidget *parent)
+SieveDebugDialog::SieveDebugDialog(SieveImapPasswordProvider* passwordProvider, QWidget *parent)
: QDialog(parent)
, mSieveJob(nullptr)
+ , mPasswordProvider(passwordProvider)
, mShutDownJob(nullptr)
{
setWindowTitle(i18n("Sieve Diagnostics"));
@@ -121,7 +122,7 @@ void SieveDebugDialog::slotDiagNextAccount()
mEdit->editor()->appendPlainText(i18n("------------------------------------------------------------\n"));
// Detect URL for this IMAP account
- const KSieveUi::Util::AccountInfo info = KSieveUi::Util::fullAccountInfo(ident);
+ const KSieveUi::Util::AccountInfo info = KSieveUi::Util::fullAccountInfo(ident, mPasswordProvider);
const QUrl url = info.sieveUrl;
if (!url.isValid()) {
mEdit->editor()->appendPlainText(i18n("(Account does not support Sieve)\n\n"));
@@ -158,7 +159,7 @@ void SieveDebugDialog::slotDiagNextScript()
mEdit->editor()->appendPlainText(i18n("Contents of script '%1':\n", scriptFile));
- const KSieveUi::Util::AccountInfo info = KSieveUi::Util::fullAccountInfo(mResourceIdentifier.first());
+ const KSieveUi::Util::AccountInfo info = KSieveUi::Util::fullAccountInfo(mResourceIdentifier.first(), mPasswordProvider);
mUrl = info.sieveUrl;
mUrl = mUrl.adjusted(QUrl::RemoveFilename);
diff --git a/src/ksieveui/debug/sievedebugdialog.h b/src/ksieveui/debug/sievedebugdialog.h
index b673592..4293e14 100644
--- a/src/ksieveui/debug/sievedebugdialog.h
+++ b/src/ksieveui/debug/sievedebugdialog.h
@@ -29,6 +29,9 @@ namespace KPIMTextEdit {
class PlainTextEditorWidget;
}
namespace KSieveUi {
+
+class SieveImapPasswordProvider;
+
/**
* Diagnostic info for Sieve. Only compiled when debug is enabled, it is
* not useful enough for non-developers to have this in releases.
@@ -37,7 +40,7 @@ class KSIEVEUI_EXPORT SieveDebugDialog : public QDialog
{
Q_OBJECT
public:
- explicit SieveDebugDialog(QWidget *parent = nullptr);
+ explicit SieveDebugDialog(SieveImapPasswordProvider* passwordProvider, QWidget *parent = nullptr);
~SieveDebugDialog();
Q_SIGNALS:
@@ -58,6 +61,7 @@ private:
QUrl mUrl;
KSyntaxHighlighting::Repository mRepo;
+ SieveImapPasswordProvider* mPasswordProvider;
KPIMTextEdit::PlainTextEditorWidget *mEdit;
QStringList mResourceIdentifier;
QStringList mScriptList;
diff --git a/src/ksieveui/managesievescriptsdialog.cpp b/src/ksieveui/managesievescriptsdialog.cpp
index a01c995..6467c49 100644
--- a/src/ksieveui/managesievescriptsdialog.cpp
+++ b/src/ksieveui/managesievescriptsdialog.cpp
@@ -76,7 +76,7 @@ public:
bool mWasActive : 1;
};
-ManageSieveScriptsDialog::ManageSieveScriptsDialog(QWidget *parent)
+ManageSieveScriptsDialog::ManageSieveScriptsDialog(SieveImapPasswordProvider *passwordProvider, QWidget *parent)
: QDialog(parent)
, d(new KSieveUi::ManageSieveScriptsDialogPrivate)
{
@@ -93,7 +93,7 @@ ManageSieveScriptsDialog::ManageSieveScriptsDialog(QWidget *parent)
vlay->setSpacing(0);
vlay->setMargin(0);
- d->mTreeView = new CustomManageSieveWidget(frame);
+ d->mTreeView = new CustomManageSieveWidget(passwordProvider, frame);
connect(d->mTreeView, &CustomManageSieveWidget::editScript, this, &ManageSieveScriptsDialog::slotEditScript);
connect(d->mTreeView, &CustomManageSieveWidget::newScript, this, &ManageSieveScriptsDialog::slotNewScript);
connect(d->mTreeView, &CustomManageSieveWidget::updateButtons, this, &ManageSieveScriptsDialog::slotUpdateButtons);
diff --git a/src/ksieveui/managesievescriptsdialog.h b/src/ksieveui/managesievescriptsdialog.h
index d8010ba..e9c7fb6 100644
--- a/src/ksieveui/managesievescriptsdialog.h
+++ b/src/ksieveui/managesievescriptsdialog.h
@@ -33,12 +33,13 @@ class SieveJob;
namespace KSieveUi {
class SieveEditor;
class ManageSieveScriptsDialogPrivate;
+class SieveImapPasswordProvider;
class KSIEVEUI_EXPORT ManageSieveScriptsDialog : public QDialog
{
Q_OBJECT
public:
- explicit ManageSieveScriptsDialog(QWidget *parent = nullptr);
+ explicit ManageSieveScriptsDialog(SieveImapPasswordProvider* passwordProvider, QWidget *parent = nullptr);
~ManageSieveScriptsDialog();
Q_SIGNALS:
diff --git a/src/ksieveui/util/abstractakonadiimapsettinginterface.cpp b/src/ksieveui/util/abstractakonadiimapsettinginterface.cpp
index 9ece687..94f0da3 100644
--- a/src/ksieveui/util/abstractakonadiimapsettinginterface.cpp
+++ b/src/ksieveui/util/abstractakonadiimapsettinginterface.cpp
@@ -84,18 +84,6 @@ QString AbstractAkonadiImapSettingInterface::sieveAlternateUrl() const
return {};
}
-QString AbstractAkonadiImapSettingInterface::password(const QString &identifier) const
-{
- Q_UNUSED(identifier);
- return {};
-}
-
-QString AbstractAkonadiImapSettingInterface::sieveCustomPassword(const QString &identifier) const
-{
- Q_UNUSED(identifier);
- return {};
-}
-
int AbstractAkonadiImapSettingInterface::imapPort() const
{
return -1;
diff --git a/src/ksieveui/util/abstractakonadiimapsettinginterface.h b/src/ksieveui/util/abstractakonadiimapsettinginterface.h
index 8f9d66b..c9d4980 100644
--- a/src/ksieveui/util/abstractakonadiimapsettinginterface.h
+++ b/src/ksieveui/util/abstractakonadiimapsettinginterface.h
@@ -40,8 +40,6 @@ public:
virtual int alternateAuthentication() const;
virtual int authentication() const;
virtual QString sieveAlternateUrl() const;
- virtual QString password(const QString &identifier) const;
- virtual QString sieveCustomPassword(const QString &identifier) const;
virtual int imapPort() const;
};
}
diff --git a/src/ksieveui/util/akonadiimapsettinginterface.cpp b/src/ksieveui/util/akonadiimapsettinginterface.cpp
index 25b8850..294d466 100644
--- a/src/ksieveui/util/akonadiimapsettinginterface.cpp
+++ b/src/ksieveui/util/akonadiimapsettinginterface.cpp
@@ -96,29 +96,6 @@ QString KSieveUi::AkonadiImapSettingInterface::sieveAlternateUrl() const
return mInterface->sieveAlternateUrl();
}
-QString AkonadiImapSettingInterface::sieveCustomPassword(const QString &identifier) const
-{
- QString pwd;
- QDBusInterface resourceSettings(QLatin1String("org.freedesktop.Akonadi.Resource.") + identifier, QStringLiteral("/Settings"), QStringLiteral("org.kde.Akonadi.Imap.Wallet"));
- QDBusReply<QString> replyPass = resourceSettings.call(QStringLiteral("sieveCustomPassword"));
- if (replyPass.isValid()) {
- pwd = replyPass;
- }
- return pwd;
-}
-
-QString AkonadiImapSettingInterface::password(const QString &identifier) const
-{
- QDBusInterface resourceSettings(QLatin1String("org.freedesktop.Akonadi.Resource.") + identifier, QStringLiteral("/Settings"), QStringLiteral("org.kde.Akonadi.Imap.Wallet"));
-
- QString pwd;
- QDBusReply<QString> replyPass = resourceSettings.call(QStringLiteral("password"));
- if (replyPass.isValid()) {
- pwd = replyPass;
- }
- return pwd;
-}
-
int KSieveUi::AkonadiImapSettingInterface::imapPort() const
{
return mInterface->imapPort();
diff --git a/src/ksieveui/util/akonadiimapsettinginterface.h b/src/ksieveui/util/akonadiimapsettinginterface.h
index ee8a952..57affd1 100644
--- a/src/ksieveui/util/akonadiimapsettinginterface.h
+++ b/src/ksieveui/util/akonadiimapsettinginterface.h
@@ -43,8 +43,6 @@ public:
int alternateAuthentication() const override;
int authentication() const override;
QString sieveAlternateUrl() const override;
- QString password(const QString &identifier) const override;
- QString sieveCustomPassword(const QString &identifier) const override;
int imapPort() const override;
private:
diff --git a/src/ksieveui/util/autotests/akonadiimapsettinginterfacetest.cpp b/src/ksieveui/util/autotests/akonadiimapsettinginterfacetest.cpp
index b97f34b..532c264 100644
--- a/src/ksieveui/util/autotests/akonadiimapsettinginterfacetest.cpp
+++ b/src/ksieveui/util/autotests/akonadiimapsettinginterfacetest.cpp
@@ -89,18 +89,6 @@ int AkonadiImapSettingInterfaceTest::alternateAuthentication() const
return mData.alternateAuthentication;
}
-QString AkonadiImapSettingInterfaceTest::password(const QString &identifier) const
-{
- Q_UNUSED(identifier);
- return mData.password;
-}
-
-QString AkonadiImapSettingInterfaceTest::sieveCustomPassword(const QString &identifier) const
-{
- Q_UNUSED(identifier);
- return mData.sieveCustomPassword;
-}
-
int AkonadiImapSettingInterfaceTest::imapPort() const
{
return mData.imapPort;
diff --git a/src/ksieveui/util/autotests/akonadiimapsettinginterfacetest.h b/src/ksieveui/util/autotests/akonadiimapsettinginterfacetest.h
index 90e7b24..8a59677 100644
--- a/src/ksieveui/util/autotests/akonadiimapsettinginterfacetest.h
+++ b/src/ksieveui/util/autotests/akonadiimapsettinginterfacetest.h
@@ -58,8 +58,6 @@ public:
int alternateAuthentication() const override;
int authentication() const override;
QString sieveAlternateUrl() const override;
- QString password(const QString &identifier) const override;
- QString sieveCustomPassword(const QString &identifier) const override;
int imapPort() const override;
private:
AkonadiImapSettingInterfaceDataTest mData;
diff --git a/src/ksieveui/util/autotests/utilmethodtest.cpp b/src/ksieveui/util/autotests/utilmethodtest.cpp
index 22bce3c..070e419 100644
--- a/src/ksieveui/util/autotests/utilmethodtest.cpp
+++ b/src/ksieveui/util/autotests/utilmethodtest.cpp
@@ -22,9 +22,31 @@
#include "imapresourcesettings.h"
#include "akonadiimapsettinginterfacetest.h"
#include "../abstractakonadiimapsettinginterface.h"
+#include "../sieveimappasswordprovider.h"
#include <KSieveUi/SieveImapAccountSettings>
#include <QTest>
+class DataImapPasswordProvider : public KSieveUi::SieveImapPasswordProvider
+{
+public:
+ DataImapPasswordProvider(AkonadiImapSettingInterfaceDataTest *data)
+ : mData(data)
+ {
+ }
+
+ QString password(const QString &/*identifier*/) override
+ {
+ return mData->password;
+ }
+
+ QString sieveCustomPassword(const QString &/*identifier*/) override
+ {
+ return mData->sieveCustomPassword;
+ }
+
+ AkonadiImapSettingInterfaceDataTest *mData;
+};
+
UtilMethodTest::UtilMethodTest(QObject *parent)
: QObject(parent)
{
@@ -33,7 +55,7 @@ UtilMethodTest::UtilMethodTest(QObject *parent)
void UtilMethodTest::shouldReturnEmptyInfo()
{
std::unique_ptr<KSieveUi::AbstractAkonadiImapSettingInterface> interface(new KSieveUi::AbstractAkonadiImapSettingInterface);
- KSieveUi::Util::AccountInfo info = KSieveUi::Util::findAccountInfo(QStringLiteral("foo"), false, interface);
+ KSieveUi::Util::AccountInfo info = KSieveUi::Util::findAccountInfo(QStringLiteral("dummy"), {}, false, interface);
QVERIFY(!info.sieveImapAccountSettings.isValid());
}
@@ -521,7 +543,8 @@ void UtilMethodTest::shouldAssignValue()
QFETCH(bool, useVacationFile);
std::unique_ptr<KSieveUi::AbstractAkonadiImapSettingInterface> interface(new AkonadiImapSettingInterfaceTest(data));
- const KSieveUi::Util::AccountInfo info = KSieveUi::Util::findAccountInfo(QStringLiteral("foo"), useVacationFile, interface);
+ std::unique_ptr<DataImapPasswordProvider> provider(new DataImapPasswordProvider(&data));
+ const KSieveUi::Util::AccountInfo info = KSieveUi::Util::findAccountInfo(QStringLiteral("foo"), provider.get(), useVacationFile, interface);
QCOMPARE(info.sieveImapAccountSettings.isValid(), sieveImapAccountValid);
QCOMPARE(info, accountInfo);
}
diff --git a/src/ksieveui/util/sieveimappasswordprovider.h b/src/ksieveui/util/sieveimappasswordprovider.h
new file mode 100644
index 0000000..9587b28
--- /dev/null
+++ b/src/ksieveui/util/sieveimappasswordprovider.h
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 2017 Albert Astals Cid <[email protected]>
+
+ 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 SIEVEIMAPPASSWORDPROVIDER_H
+#define SIEVEIMAPPASSWORDPROVIDER_H
+
+#include "ksieveui_export.h"
+
+class QString;
+
+namespace KSieveUi
+{
+
+class KSIEVEUI_EXPORT SieveImapPasswordProvider
+{
+public:
+ virtual ~SieveImapPasswordProvider() = default;
+ virtual QString password(const QString &identifier) = 0;
+ virtual QString sieveCustomPassword(const QString &identifier) = 0;
+};
+
+}
+#endif
diff --git a/src/ksieveui/util/util.cpp b/src/ksieveui/util/util.cpp
index b0cb161..3355e9c 100644
--- a/src/ksieveui/util/util.cpp
+++ b/src/ksieveui/util/util.cpp
@@ -41,6 +41,7 @@
#include "libksieve_debug.h"
#include <PimCommon/PimUtil>
#include "imapresourcesettings.h"
+#include "sieveimappasswordprovider.h"
#include "sieve-vacation.h"
#include "sieveimapinstance/sieveimapinstanceinterfacemanager.h"
#include "sieveimapinstance/sieveimapinstance.h"
@@ -52,15 +53,15 @@
using namespace KSieveUi;
-KSieveUi::Util::AccountInfo KSieveUi::Util::fullAccountInfo(const QString &identifier, bool withVacationFileName)
+KSieveUi::Util::AccountInfo KSieveUi::Util::fullAccountInfo(const QString &identifier, SieveImapPasswordProvider *provider, bool withVacationFileName)
{
std::unique_ptr<OrgKdeAkonadiImapSettingsInterface> interfaceImap(PimCommon::Util::createImapSettingsInterface(identifier));
std::unique_ptr<KSieveUi::AbstractAkonadiImapSettingInterface> interface(new KSieveUi::AkonadiImapSettingInterface(interfaceImap));
- KSieveUi::Util::AccountInfo accountInfo = KSieveUi::Util::findAccountInfo(identifier, withVacationFileName, interface);
+ KSieveUi::Util::AccountInfo accountInfo = KSieveUi::Util::findAccountInfo(identifier, provider, withVacationFileName, interface);
return accountInfo;
}
-KSieveUi::Util::AccountInfo KSieveUi::Util::findAccountInfo(const QString &identifier, bool withVacationFileName, std::unique_ptr<KSieveUi::AbstractAkonadiImapSettingInterface> &interface)
+KSieveUi::Util::AccountInfo KSieveUi::Util::findAccountInfo(const QString &identifier, SieveImapPasswordProvider *provider, bool withVacationFileName, std::unique_ptr<KSieveUi::AbstractAkonadiImapSettingInterface> &interface)
{
KSieveUi::Util::AccountInfo accountInfo;
if (!interface) {
@@ -90,7 +91,7 @@ KSieveUi::Util::AccountInfo KSieveUi::Util::findAccountInfo(const QString &ident
u.setHost(server);
u.setUserName(userName);
- const QString pwd = interface->password(identifier);
+ const QString pwd = provider->password(identifier);
u.setPassword(pwd);
accountInfo.sieveImapAccountSettings.setPassword(pwd);
accountInfo.sieveImapAccountSettings.setPort(interface->imapPort());
@@ -155,7 +156,7 @@ KSieveUi::Util::AccountInfo KSieveUi::Util::findAccountInfo(const QString &ident
accountInfo.sieveImapAccountSettings.setServerName(server);
accountInfo.sieveImapAccountSettings.setUserName(userName);
accountInfo.sieveImapAccountSettings.setAuthenticationType(static_cast<SieveImapAccountSettings::AuthenticationMode>((int)interface->authentication()));
- const QString pwd = interface->password(identifier);
+ const QString pwd = provider->password(identifier);
accountInfo.sieveImapAccountSettings.setPassword(pwd);
accountInfo.sieveImapAccountSettings.setPort(interface->imapPort());
@@ -208,10 +209,10 @@ KSieveUi::Util::AccountInfo KSieveUi::Util::findAccountInfo(const QString &ident
const QString resultCustomAuthentication = interface->sieveCustomAuthentification();
if (resultCustomAuthentication == QLatin1String("ImapUserPassword")) {
u.setUserName(interface->userName());
- const QString pwd = interface->password(identifier);
+ const QString pwd = provider->password(identifier);
u.setPassword(pwd);
} else if (resultCustomAuthentication == QLatin1String("CustomUserPassword")) {
- const QString pwd = interface->sieveCustomPassword(identifier);
+ const QString pwd = provider->sieveCustomPassword(identifier);
u.setPassword(pwd);
u.setUserName(interface->sieveCustomUsername());
} else {
diff --git a/src/ksieveui/util/util_p.h b/src/ksieveui/util/util_p.h
index 871346d..aff33e6 100644
--- a/src/ksieveui/util/util_p.h
+++ b/src/ksieveui/util/util_p.h
@@ -50,6 +50,7 @@ class QStringList;
namespace KSieveUi {
class AbstractAkonadiImapSettingInterface;
+class SieveImapPasswordProvider;
/**
* The Util namespace contains a collection of helper functions use in
* various places.
@@ -79,11 +80,11 @@ bool hasKep14Support(const QStringList &sieveCapabilities, const QStringList &av
*/
bool isKep14ProtectedName(const QString &scriptName);
-KSIEVEUI_TESTS_EXPORT KSieveUi::Util::AccountInfo findAccountInfo(const QString &identifier, bool withVacationFileName, std::unique_ptr<KSieveUi::AbstractAkonadiImapSettingInterface> &interface);
+KSIEVEUI_TESTS_EXPORT KSieveUi::Util::AccountInfo findAccountInfo(const QString &identifier, SieveImapPasswordProvider *provider, bool withVacationFileName, std::unique_ptr<KSieveUi::AbstractAkonadiImapSettingInterface> &interface);
/**
* Returns all sieve account info with the given @p identifier.
*/
-KSIEVEUI_TESTS_EXPORT KSieveUi::Util::AccountInfo fullAccountInfo(const QString &identifier, bool withVacationFileName = true);
+KSIEVEUI_TESTS_EXPORT KSieveUi::Util::AccountInfo fullAccountInfo(const QString &identifier, SieveImapPasswordProvider *provider, bool withVacationFileName = true);
}
}
diff --git a/src/ksieveui/vacation/multiimapvacationmanager.cpp b/src/ksieveui/vacation/multiimapvacationmanager.cpp
index ed716c9..1c1f47b 100644
--- a/src/ksieveui/vacation/multiimapvacationmanager.cpp
+++ b/src/ksieveui/vacation/multiimapvacationmanager.cpp
@@ -28,8 +28,9 @@
#include "libksieve_debug.h"
using namespace KSieveUi;
-MultiImapVacationManager::MultiImapVacationManager(QObject *parent)
+MultiImapVacationManager::MultiImapVacationManager(SieveImapPasswordProvider* passwordProvider, QObject *parent)
: QObject(parent)
+ , mPasswordProvider(passwordProvider)
, mNumberOfJobs(0)
, mCheckInProgress(false)
{
@@ -48,7 +49,7 @@ QMap <QString, QUrl> MultiImapVacationManager::serverList() const
continue;
}
- const KSieveUi::Util::AccountInfo info = KSieveUi::Util::fullAccountInfo(instance.identifier());
+ const KSieveUi::Util::AccountInfo info = KSieveUi::Util::fullAccountInfo(instance.identifier(), mPasswordProvider);
const QUrl url = info.sieveUrl;
if (!url.isEmpty()) {
list.insert(instance.name(), url);
diff --git a/src/ksieveui/vacation/multiimapvacationmanager.h b/src/ksieveui/vacation/multiimapvacationmanager.h
index 88a0ba7..3f647af 100644
--- a/src/ksieveui/vacation/multiimapvacationmanager.h
+++ b/src/ksieveui/vacation/multiimapvacationmanager.h
@@ -30,11 +30,12 @@ class QUrl;
namespace KSieveUi {
class CheckKolabKep14SupportJob;
class VacationCheckJob;
+class SieveImapPasswordProvider;
class KSIEVEUI_EXPORT MultiImapVacationManager : public QObject
{
Q_OBJECT
public:
- explicit MultiImapVacationManager(QObject *parent = nullptr);
+ explicit MultiImapVacationManager(SieveImapPasswordProvider* passwordProvider, QObject *parent = nullptr);
~MultiImapVacationManager();
void checkVacation();
@@ -51,6 +52,7 @@ private Q_SLOTS:
void slotCheckKep14Ended(KSieveUi::CheckKolabKep14SupportJob *job, bool success);
private:
+ SieveImapPasswordProvider* mPasswordProvider;
int mNumberOfJobs;
bool mCheckInProgress;
diff --git a/src/ksieveui/vacation/vacation.cpp b/src/ksieveui/vacation/vacation.cpp
index cda30cd..9a91adc 100644
--- a/src/ksieveui/vacation/vacation.cpp
+++ b/src/ksieveui/vacation/vacation.cpp
@@ -27,8 +27,9 @@
using namespace KSieveUi;
-Vacation::Vacation(QObject *parent, bool checkOnly, const QUrl &url)
+Vacation::Vacation(SieveImapPasswordProvider* passwordProvider, QObject *parent, bool checkOnly, const QUrl &url)
: QObject(parent)
+ , mPasswordProvider(passwordProvider)
, mSieveJob(nullptr)
, mDialog(nullptr)
, mWasActive(false)
@@ -76,7 +77,7 @@ QUrl Vacation::findURL(QString &serverName) const
continue;
}
- const KSieveUi::Util::AccountInfo info = KSieveUi::Util::fullAccountInfo(instance.identifier());
+ const KSieveUi::Util::AccountInfo info = KSieveUi::Util::fullAccountInfo(instance.identifier(), mPasswordProvider);
const QUrl url = info.sieveUrl;
if (!url.isEmpty()) {
serverName = instance.name();
diff --git a/src/ksieveui/vacation/vacation.h b/src/ksieveui/vacation/vacation.h
index bb7b729..5e024bc 100644
--- a/src/ksieveui/vacation/vacation.h
+++ b/src/ksieveui/vacation/vacation.h
@@ -26,13 +26,14 @@ class SieveJob;
namespace KSieveUi {
class VacationDialog;
+class SieveImapPasswordProvider;
class Vacation : public QObject
{
Q_OBJECT
public:
- explicit Vacation(QObject *parent = nullptr, bool checkonly = false, const QUrl &url = QUrl());
+ explicit Vacation(SieveImapPasswordProvider* passwordProvider, QObject *parent = nullptr, bool checkonly = false, const QUrl &url = QUrl());
virtual ~Vacation();
bool isUsable() const;
@@ -58,6 +59,7 @@ protected Q_SLOTS:
void slotPutInactiveResult(KManageSieve::SieveJob *, bool);
protected:
// IO:
+ SieveImapPasswordProvider* mPasswordProvider;
KManageSieve::SieveJob *mSieveJob;
QUrl mUrl;
QString mServerName;
diff --git a/src/ksieveui/vacation/vacationmanager.cpp b/src/ksieveui/vacation/vacationmanager.cpp
index 64342f2..8271db0 100644
--- a/src/ksieveui/vacation/vacationmanager.cpp
+++ b/src/ksieveui/vacation/vacationmanager.cpp
@@ -44,11 +44,11 @@ public:
bool mQuestionAsked;
};
-VacationManager::VacationManager(QWidget *parent)
+VacationManager::VacationManager(SieveImapPasswordProvider* passwordProvider, QWidget *parent)
: QObject(parent)
, d(new KSieveUi::VacationManagerPrivate(parent))
{
- d->mCheckVacation = new KSieveUi::MultiImapVacationManager(this);
+ d->mCheckVacation = new KSieveUi::MultiImapVacationManager(passwordProvider, this);
connect(d->mCheckVacation.data(), &KSieveUi::MultiImapVacationManager::scriptActive, this, &VacationManager::updateVacationScriptStatus);
connect(d->mCheckVacation.data(), &KSieveUi::MultiImapVacationManager::scriptActive, this, &VacationManager::slotUpdateVacationScriptStatus);
}
diff --git a/src/ksieveui/vacation/vacationmanager.h b/src/ksieveui/vacation/vacationmanager.h
index 624765f..a225d23 100644
--- a/src/ksieveui/vacation/vacationmanager.h
+++ b/src/ksieveui/vacation/vacationmanager.h
@@ -27,11 +27,12 @@ class QWidget;
namespace KSieveUi {
class VacationManagerPrivate;
class SieveImapInstanceInterface;
+class SieveImapPasswordProvider;
class KSIEVEUI_EXPORT VacationManager : public QObject
{
Q_OBJECT
public:
- explicit VacationManager(QWidget *parent);
+ explicit VacationManager(SieveImapPasswordProvider* passwordProvider, QWidget *parent);
~VacationManager();
void checkVacation();
diff --git a/src/ksieveui/widgets/custommanagesievewidget.cpp b/src/ksieveui/widgets/custommanagesievewidget.cpp
index 4f0098f..54d893d 100644
--- a/src/ksieveui/widgets/custommanagesievewidget.cpp
+++ b/src/ksieveui/widgets/custommanagesievewidget.cpp
@@ -27,8 +27,9 @@
using namespace KSieveUi;
-CustomManageSieveWidget::CustomManageSieveWidget(QWidget *parent)
+CustomManageSieveWidget::CustomManageSieveWidget(SieveImapPasswordProvider* passwordProvider, QWidget *parent)
: KSieveUi::ManageSieveWidget(parent)
+ , mPasswordProvider(passwordProvider)
{
}
@@ -50,7 +51,7 @@ bool CustomManageSieveWidget::refreshList()
last = new SieveTreeWidgetItem(treeView(), last);
last->setIcon(0, QIcon::fromTheme(QStringLiteral("network-server")));
- const KSieveUi::Util::AccountInfo info = KSieveUi::Util::fullAccountInfo(type.identifier(), false);
+ const KSieveUi::Util::AccountInfo info = KSieveUi::Util::fullAccountInfo(type.identifier(), mPasswordProvider, false);
const QUrl u = info.sieveUrl;
if (u.isEmpty()) {
QTreeWidgetItem *item = new QTreeWidgetItem(last);
diff --git a/src/ksieveui/widgets/custommanagesievewidget.h b/src/ksieveui/widgets/custommanagesievewidget.h
index 388316e..6c08cf9 100644
--- a/src/ksieveui/widgets/custommanagesievewidget.h
+++ b/src/ksieveui/widgets/custommanagesievewidget.h
@@ -21,15 +21,19 @@
#include <widgets/managesievewidget.h>
namespace KSieveUi {
+class SieveImapPasswordProvider;
class CustomManageSieveWidget : public KSieveUi::ManageSieveWidget
{
Q_OBJECT
public:
- explicit CustomManageSieveWidget(QWidget *parent = nullptr);
+ explicit CustomManageSieveWidget(SieveImapPasswordProvider* passwordProvider, QWidget *parent = nullptr);
virtual ~CustomManageSieveWidget();
protected:
bool refreshList() override;
+
+private:
+ SieveImapPasswordProvider* mPasswordProvider;
};
}