2
qgpgmenewcryptoconfig.h
4
This file is part of libkleopatra, the KDE keymanagement library
5
Copyright (c) 2010 Klarälvdalens Datakonsult AB
7
Libkleopatra is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License as
9
published by the Free Software Foundation; either version 2 of the
10
License, or (at your option) any later version.
12
Libkleopatra 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
General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
In addition, as a special exception, the copyright holders give
22
permission to link the code of this program with any edition of
23
the Qt library by Trolltech AS, Norway (or with modified versions
24
of Qt that use the same license as Qt), and distribute linked
25
combinations including the two. You must obey the GNU General
26
Public License in all respects for all of the code used other than
27
Qt. If you modify this file, you may extend this exception to
28
your version of the file, but you are not obligated to do so. If
29
you do not wish to do so, delete this exception statement from
33
#ifndef KLEO_QGPGMENEWCRYPTOCONFIG_H
34
#define KLEO_QGPGMENEWCRYPTOCONFIG_H
36
#include "kleo/kleo_export.h"
37
#include "kleo/cryptoconfig.h"
40
#include <QStringList>
45
#include <gpgme++/configuration.h>
47
#include <boost/shared_ptr.hpp>
48
#include <boost/weak_ptr.hpp>
49
#include <boost/enable_shared_from_this.hpp>
54
class QGpgMENewCryptoConfig;
55
class QGpgMENewCryptoConfigComponent;
56
class QGpgMENewCryptoConfigGroup;
57
class QGpgMENewCryptoConfigEntry;
59
class QGpgMENewCryptoConfigEntry : public Kleo::CryptoConfigEntry {
61
QGpgMENewCryptoConfigEntry( const boost::shared_ptr<QGpgMENewCryptoConfigGroup> & group, const GpgME::Configuration::Option & option );
62
~QGpgMENewCryptoConfigEntry();
64
/* reimp */ QString name() const;
65
/* reimp */ QString description() const;
66
/* reimp */ QString path() const;
67
/* reimp */ bool isOptional() const;
68
/* reimp */ bool isReadOnly() const;
69
/* reimp */ bool isList() const;
70
/* reimp */ bool isRuntime() const;
71
/* reimp */ Level level() const;
72
/* reimp */ ArgType argType() const;
73
/* reimp */ bool isSet() const;
74
/* reimp */ bool boolValue() const;
75
/* reimp */ QString stringValue() const;
76
/* reimp */ int intValue() const;
77
/* reimp */ unsigned int uintValue() const;
78
/* reimp */ KUrl urlValue() const;
79
/* reimp */ unsigned int numberOfTimesSet() const;
80
/* reimp */ QStringList stringValueList() const;
81
/* reimp */ std::vector<int> intValueList() const;
82
/* reimp */ std::vector<unsigned int> uintValueList() const;
83
/* reimp */ KUrl::List urlValueList() const;
84
/* reimp */ void resetToDefault();
85
/* reimp */ void setBoolValue( bool );
86
/* reimp */ void setStringValue( const QString& );
87
/* reimp */ void setIntValue( int );
88
/* reimp */ void setUIntValue( unsigned int );
89
/* reimp */ void setURLValue( const KUrl& );
90
/* reimp */ void setNumberOfTimesSet( unsigned int );
91
/* reimp */ void setStringValueList( const QStringList& );
92
/* reimp */ void setIntValueList( const std::vector<int>& );
93
/* reimp */ void setUIntValueList( const std::vector<unsigned int>& );
94
/* reimp */ void setURLValueList( const KUrl::List& );
95
/* reimp */ bool isDirty() const;
98
void setDirty( bool b );
99
QString outputString() const;
102
bool isStringType() const;
103
QVariant stringToValue( const QString& value, bool unescape ) const;
104
QString toString( bool escape ) const;
107
boost::weak_ptr<QGpgMENewCryptoConfigGroup> m_group;
108
GpgME::Configuration::Option m_option;
111
class QGpgMENewCryptoConfigGroup : public Kleo::CryptoConfigGroup {
113
QGpgMENewCryptoConfigGroup( const boost::shared_ptr<QGpgMENewCryptoConfigComponent> & parent, const GpgME::Configuration::Option & option );
114
~QGpgMENewCryptoConfigGroup();
116
/* reimp */ QString name() const;
117
/* reimp */ QString iconName() const { return QString(); }
118
/* reimp */ QString description() const;
119
/* reimp */ QString path() const;
120
/* reimp */ Kleo::CryptoConfigEntry::Level level() const;
121
/* reimp */ QStringList entryList() const;
122
/* reimp */ QGpgMENewCryptoConfigEntry * entry( const QString & name ) const;
125
friend class QGpgMENewCryptoConfigComponent; // it adds the entries
126
boost::weak_ptr<QGpgMENewCryptoConfigComponent> m_component;
127
GpgME::Configuration::Option m_option;
128
QStringList m_entryNames;
129
QHash< QString, boost::shared_ptr<QGpgMENewCryptoConfigEntry> > m_entriesByName;
132
/// For docu, see kleo/cryptoconfig.h
133
class QGpgMENewCryptoConfigComponent : public Kleo::CryptoConfigComponent, public boost::enable_shared_from_this<QGpgMENewCryptoConfigComponent> {
135
QGpgMENewCryptoConfigComponent();
136
~QGpgMENewCryptoConfigComponent();
138
void setComponent( const GpgME::Configuration::Component & component );
140
/* reimp */ QString name() const;
141
/* reimp */ QString iconName() const { return name(); }
142
/* reimp */ QString description() const;
143
/* reimp */ QStringList groupList() const;
144
/* reimp */ QGpgMENewCryptoConfigGroup * group( const QString & name ) const;
146
/* reimp */ void sync( bool runtime );
149
GpgME::Configuration::Component m_component;
150
QHash< QString, boost::shared_ptr<QGpgMENewCryptoConfigGroup> > m_groupsByName;
154
* CryptoConfig implementation around the gpgconf command-line tool
155
* For method docu, see kleo/cryptoconfig.h
157
class KLEO_EXPORT QGpgMENewCryptoConfig : public Kleo::CryptoConfig {
162
QGpgMENewCryptoConfig();
163
~QGpgMENewCryptoConfig();
165
/* reimp */ QStringList componentList() const;
167
/* reimp */ QGpgMENewCryptoConfigComponent* component( const QString & name ) const;
169
/* reimp */ void clear();
170
/* reimp */ void sync( bool runtime );
173
/// @param showErrors if true, a messagebox will be shown if e.g. gpgconf wasn't found
174
void reloadConfiguration( bool showErrors );
177
QHash< QString, boost::shared_ptr<QGpgMENewCryptoConfigComponent> > m_componentsByName;
181
#endif /* KLEO_QGPGMENEWCRYPTOCONFIG_H */