File indexing completed on 2024-11-24 03:41:06
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2021 Slava Aseev <nullptrnine@basealt.ru> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 #ifndef _KWALLETFREEDESKTOPPROMPT_H_ 0008 #define _KWALLETFREEDESKTOPPROMPT_H_ 0009 0010 #include "kwalletfreedesktopservice.h" 0011 0012 #define FDO_SECRET_SERVICE_PROMPT_PATH FDO_SECRETS_SERVICE_OBJECT "/prompt/" 0013 0014 class KWalletD; 0015 0016 enum class PromptType { 0017 Open, 0018 Create, 0019 }; 0020 0021 class KWalletFreedesktopPrompt : public QObject, protected FDO_DBUS_CONTEXT 0022 { 0023 Q_OBJECT 0024 0025 struct CollectionProperties { 0026 QString collectionLabel; 0027 QDBusObjectPath objectPath; 0028 QString alias; 0029 }; 0030 0031 public: 0032 KWalletFreedesktopPrompt(KWalletFreedesktopService *service, QDBusObjectPath objectPath, PromptType type, QString responseBusName); 0033 0034 KWalletFreedesktopPrompt(const KWalletFreedesktopPrompt &) = delete; 0035 KWalletFreedesktopPrompt &operator=(const KWalletFreedesktopPrompt &) = delete; 0036 0037 KWalletFreedesktopPrompt(KWalletFreedesktopPrompt &&) = delete; 0038 KWalletFreedesktopPrompt &operator=(KWalletFreedesktopPrompt &&) = delete; 0039 0040 KWalletFreedesktopService *fdoService() const; 0041 KWalletD *backend() const; 0042 QDBusObjectPath fdoObjectPath() const; 0043 0044 void subscribeForWalletAsyncOpened(); 0045 void appendProperties(const QString &label, const QDBusObjectPath &objectPath = QDBusObjectPath("/"), const QString &alias = {}); 0046 0047 public Q_SLOTS: 0048 void walletAsyncOpened(int transactionId, int walletHandle); 0049 0050 private: 0051 KWalletFreedesktopService *m_service; 0052 QDBusObjectPath m_objectPath; 0053 PromptType m_type; 0054 QSet<int> m_transactionIds; 0055 QList<QDBusObjectPath> m_result; 0056 QList<CollectionProperties> m_propertiesList; 0057 std::map<int, CollectionProperties> m_transactionIdToCollectionProperties; 0058 QString m_responseBusName; 0059 0060 /* Freedesktop API */ 0061 0062 /* org.freedesktop.Secret.Prompt methods */ 0063 public Q_SLOTS: 0064 void Dismiss(); 0065 void Prompt(const QString &window_id); 0066 0067 /* org.freedesktop.Secret.Prompt signals */ 0068 Q_SIGNALS: 0069 /* Emitted manually now */ 0070 void Completed(bool dismissed, const QDBusVariant &result); 0071 }; 0072 0073 #endif