KWallet

kwalletfreedesktopcollection.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2021 Slava Aseev <nullptrnine@basealt.ru>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7#ifndef _KWALLETFREEDESKTOPCOLLECTION_H_
8#define _KWALLETFREEDESKTOPCOLLECTION_H_
9#include "kwalletfreedesktopattributes.h"
10#include "kwalletfreedesktopservice.h"
11
12#define FDO_SECRETS_COLLECTION_PATH FDO_SECRETS_SERVICE_OBJECT "/collection/"
13#define FDO_SECRETS_DEFAULT_DIR "Secret Service"
14#define FDO_KEY_MODIFIED QStringLiteral("$fdo_modified")
15#define FDO_KEY_CREATED QStringLiteral("$fdo_created")
16#define FDO_KEY_MIME QStringLiteral("$fdo_mime_type")
17#define FDO_KEY_XDG_SCHEMA QStringLiteral("xdg:schema")
18
19class KWalletFreedesktopItem;
20
21class KWalletFreedesktopCollection : public QObject, protected QDBusContext
22{
23 /* org.freedesktop.Secret.Collection properties */
24public:
25 Q_PROPERTY(qulonglong Created READ created)
26 qulonglong created() const;
27
28 Q_PROPERTY(qulonglong Modified READ modified)
29 qulonglong modified() const;
30
31 Q_PROPERTY(QList<QDBusObjectPath> Items READ items)
32 QList<QDBusObjectPath> items() const;
33
34 Q_PROPERTY(QString Label READ label WRITE setLabel)
35 const QString &label() const;
36 void setLabel(const QString &value);
37
38 Q_PROPERTY(bool Locked READ locked)
39 bool locked() const;
40
42
43public:
44 KWalletFreedesktopCollection(KWalletFreedesktopService *service, int handle, const QString &walletName, QDBusObjectPath objectPath);
45
46 KWalletFreedesktopCollection(const KWalletFreedesktopCollection &) = delete;
47 KWalletFreedesktopCollection &operator=(const KWalletFreedesktopCollection &) = delete;
48
49 KWalletFreedesktopCollection(KWalletFreedesktopCollection &&) = delete;
50 KWalletFreedesktopCollection &&operator=(KWalletFreedesktopCollection &&) = delete;
51
52 EntryLocation makeUniqueEntryLocation(const QString &label);
53 FdoUniqueLabel makeUniqueItemLabel(const QString &label);
54
55 QDBusObjectPath nextItemPath();
56
57 KWalletFreedesktopService *fdoService() const;
58 KWalletD *backend() const;
59 QDBusObjectPath fdoObjectPath() const;
60 const FdoUniqueLabel &uniqueLabel() const;
61 QString walletName() const;
62 int walletHandle() const;
63
64 KWalletFreedesktopItem *getItemByObjectPath(const QString &objectPath) const;
65 KWalletFreedesktopItem *findItemByEntryLocation(const EntryLocation &entryLocation) const;
66 KWalletFreedesktopItem &pushNewItem(FdoUniqueLabel label, const QDBusObjectPath &path);
67 KWalletFreedesktopAttributes &itemAttributes();
68 const KWalletFreedesktopAttributes &itemAttributes() const;
69
70 /* Emitters */
71 void onWalletChangeState(int handle);
72 void onItemCreated(const QDBusObjectPath &item);
73 void onItemChanged(const QDBusObjectPath &item);
74 void onItemDeleted(const QDBusObjectPath &item);
75 void onPropertiesChanged(const QVariantMap &properties);
76
77private:
78 KWalletFreedesktopItem &pushNewItem(const QString &label, const QDBusObjectPath &path);
79
80private:
81 KWalletFreedesktopService *m_service;
82 int m_handle;
83 FdoUniqueLabel m_uniqueLabel;
84 QDBusObjectPath m_objectPath;
85 KWalletFreedesktopAttributes m_itemAttribs;
86 std::map<QString, std::unique_ptr<KWalletFreedesktopItem>> m_items;
87 uint64_t m_itemCounter = 0;
88
89 /* Freedesktop API */
90
91 /* org.freedesktop.Secret.Collection methods */
92public Q_SLOTS:
93 QDBusObjectPath CreateItem(const PropertiesMap &properties, const FreedesktopSecret &secret, bool replace, QDBusObjectPath &prompt);
94 QDBusObjectPath Delete();
95 QList<QDBusObjectPath> SearchItems(const StrStrMap &attributes);
96
97 /* org.freedesktop.Secret.Service signals */
99 void ItemChanged(const QDBusObjectPath &item);
100 void ItemCreated(const QDBusObjectPath &item);
101 void ItemDeleted(const QDBusObjectPath &item);
102};
103
104#endif
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.