File indexing completed on 2024-11-17 04:44:59

0001 /*
0002     SPDX-FileCopyrightText: 2017-2018 Krzysztof Nowicki <krissn@op.pl>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #ifdef EWSSETTINGS_UNITTEST
0010 #include "ewssettings_ut_mock.h"
0011 #else
0012 #include "ewssettingsbase.h"
0013 #endif
0014 
0015 #include <QPointer>
0016 #include <QTimer>
0017 
0018 namespace KWallet
0019 {
0020 class Wallet;
0021 }
0022 
0023 class EwsAbstractAuth;
0024 
0025 class EwsSettings : public EwsSettingsBase
0026 {
0027     Q_OBJECT
0028     Q_CLASSINFO("D-Bus Interface", "org.kde.Akonadi.Ews.Wallet")
0029 public:
0030     explicit EwsSettings(WId windowId);
0031     ~EwsSettings() override;
0032 
0033     void requestPassword();
0034     void requestMap();
0035 
0036     EwsAbstractAuth *loadAuth(QObject *parent);
0037 public Q_SLOTS:
0038     Q_SCRIPTABLE void setPassword(const QString &password);
0039     Q_SCRIPTABLE void setMap(const QMap<QString, QString> &map);
0040     Q_SCRIPTABLE void setTestPassword(const QString &password);
0041 Q_SIGNALS:
0042     void passwordRequestFinished(const QString &password);
0043     void mapRequestFinished(const QMap<QString, QString> &map);
0044 private Q_SLOTS:
0045     void onWalletOpened(bool success);
0046 
0047 private:
0048     QString readPassword() const;
0049     QMap<QString, QString> readMap() const;
0050     void satisfyPasswordReadRequest(bool success);
0051     void satisfyPasswordWriteRequest(bool success);
0052     void satisfyMapReadRequest(bool success);
0053     void satisfyMapWriteRequest(bool success);
0054     bool requestWalletOpen();
0055     WId mWindowId;
0056 
0057     QString mPassword;
0058     bool mPasswordReadPending = false;
0059     bool mPasswordWritePending = false;
0060 
0061     QMap<QString, QString> mMap;
0062     bool mMapReadPending = false;
0063     bool mMapWritePending = false;
0064 
0065     QPointer<KWallet::Wallet> mWallet;
0066     QTimer mWalletTimer;
0067 };