2
Copyright 2009 Will Stephenson <wstephenson@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) version 3, or any
8
later version accepted by the membership of KDE e.V. (or its
9
successor approved by the membership of KDE e.V.), which shall
10
act as a proxy defined in Section 6 of version 3 of the license.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public
18
License along with this library. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef CONNECTIONPERSISTENCE_H
22
#define CONNECTIONPERSISTENCE_H
26
#include <QtGui/qwindowdefs.h> // krazy:exclude=includes (for WId)
28
#include <KSharedConfig>
30
#include "knm_export.h"
36
class SettingPersistence;
38
class KNM_EXPORT ConnectionPersistence : public QObject
42
static const QString NETWORKMANAGEMENT_RCFILE;
43
static const QString CONNECTION_PERSISTENCE_PATH;
44
enum SecretStorageMode { Secure, PlainText };
48
enum type {NoError = 0, MissingContents, WalletDisabled, WalletNotFound, WalletOpenRefused };
51
* Work with an existing Connection
53
ConnectionPersistence(Connection *, KSharedConfig::Ptr config, SecretStorageMode mode = Secure);
55
* Deserialise a connection from the specified config file
57
ConnectionPersistence(KSharedConfig::Ptr config, SecretStorageMode mode = Secure);
59
~ConnectionPersistence();
61
Connection * connection() const;
63
// get/set the window ID used for focus stealing prevention
64
static void setWalletWid( WId wid ) {
68
static WId walletWid() {
73
// This assumes the connection has already been constructed with the uuid, type ctor
74
// and populated with all the Settings
77
* Trigger asynchronously loading this connection's secrets.
78
* You should connect to the @ref gotSecrets() signal before calling this method
79
* If the SecretStorageMode is PlainText, the signal will be emitted immediately!
84
* Emitted when secrets have become available
86
void loadSecretsResult(uint);
88
void walletOpenedForRead(bool);
90
SettingPersistence * persistenceFor(Setting *);
91
QString walletKeyFor(const Setting *) const;
93
static QString s_walletFolderName;
94
static WId s_walletWId;
96
QHash<Setting*, SettingPersistence*> m_persistences;
97
Connection * m_connection;
98
KSharedConfig::Ptr m_config;
99
SecretStorageMode m_storageMode;
104
#endif // CONNECTIONPERSISTENCE_H