• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

libkleo

  • sources
  • kde-4.14
  • kdepim
  • libkleo
  • backends
  • qgpgme
qgpgmecryptoconfig.h
Go to the documentation of this file.
1 /*
2  qgpgmecryptoconfig.h
3 
4  This file is part of libkleopatra, the KDE keymanagement library
5  Copyright (c) 2004 Klarälvdalens Datakonsult AB
6 
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.
11 
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.
16 
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
20 
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
30  your version.
31 */
32 
33 #ifndef KLEO_QGPGMECRYPTOCONFIG_H
34 #define KLEO_QGPGMECRYPTOCONFIG_H
35 
36 #include "kleo/kleo_export.h"
37 #include "kleo/cryptoconfig.h"
38 
39 #include <QHash>
40 #include <QStringList>
41 #include <QObject>
42 #include <QVariant>
43 #include <QPointer>
44 
45 #include <vector>
46 #include <utility>
47 
48 class QGpgMECryptoConfigComponent;
49 class QGpgMECryptoConfigEntry;
54 class KLEO_EXPORT QGpgMECryptoConfig : public QObject, public Kleo::CryptoConfig {
55 
56  Q_OBJECT
57 public:
58 
59  static QString gpgConfPath();
63  QGpgMECryptoConfig();
64  virtual ~QGpgMECryptoConfig();
65 
66  virtual QStringList componentList() const;
67 
68  virtual Kleo::CryptoConfigComponent* component( const QString& name ) const;
69 
70  virtual void clear();
71  virtual void sync( bool runtime );
72 
73 private slots:
74  void slotCollectStdOut();
75 private:
77  void runGpgConf( bool showErrors );
78 
79 private:
80  std::vector<std::pair<QString, QGpgMECryptoConfigComponent*> > mComponentsNaturalOrder;
81  QHash<QString, QGpgMECryptoConfigComponent*> mComponentsByName;
82  bool mParsed;
83 };
84 
85 class QGpgMECryptoConfigGroup;
86 
88 class QGpgMECryptoConfigComponent : public QObject, public Kleo::CryptoConfigComponent {
89 
90  Q_OBJECT
91 public:
92  QGpgMECryptoConfigComponent( QGpgMECryptoConfig*, const QString& name, const QString& description );
93  ~QGpgMECryptoConfigComponent();
94 
95  QString name() const { return mName; }
96  QString iconName() const { return mName; }
97  QString description() const { return mDescription; }
98  QStringList groupList() const;
99  Kleo::CryptoConfigGroup* group( const QString& name ) const;
100 
101  void sync( bool runtime );
102 
103 private slots:
104  void slotCollectStdOut();
105 private:
106  void runGpgConf();
107 
108 private:
109  std::vector< std::pair<QString,QGpgMECryptoConfigGroup*> > mGroupsNaturalOrder;
110  QHash<QString,QGpgMECryptoConfigGroup*> mGroupsByName;
111  QString mName;
112  QString mDescription;
113  QGpgMECryptoConfigGroup* mCurrentGroup; // during parsing
114  QString mCurrentGroupName; // during parsing
115 };
116 
117 class QGpgMECryptoConfigGroup : public Kleo::CryptoConfigGroup {
118 
119 public:
120  QGpgMECryptoConfigGroup( QGpgMECryptoConfigComponent* comp, const QString& name, const QString& description, int level );
121  ~QGpgMECryptoConfigGroup();
122 
123  QString name() const { return mName; }
124  QString iconName() const { return QString(); }
125  QString description() const { return mDescription; }
126  QString path() const { return mComponent->name() + QLatin1Char( '/' ) + mName ; }
127  Kleo::CryptoConfigEntry::Level level() const { return mLevel; }
128  QStringList entryList() const;
129  Kleo::CryptoConfigEntry* entry( const QString& name ) const;
130 
131 private:
132  friend class QGpgMECryptoConfigComponent; // it adds the entries
133  QPointer<QGpgMECryptoConfigComponent> mComponent;
134  std::vector< std::pair<QString,QGpgMECryptoConfigEntry*> > mEntriesNaturalOrder;
135  QHash<QString,QGpgMECryptoConfigEntry*> mEntriesByName;
136  QString mName;
137  QString mDescription;
138  Kleo::CryptoConfigEntry::Level mLevel;
139 };
140 
141 class QGpgMECryptoConfigEntry : public Kleo::CryptoConfigEntry {
142 public:
143  QGpgMECryptoConfigEntry( QGpgMECryptoConfigGroup * group, const QStringList& parsedLine );
144  ~QGpgMECryptoConfigEntry();
145 
146  QString name() const { return mName; }
147  QString description() const { return mDescription; }
148  QString path() const { return mGroup->path() + QLatin1Char( '/' ) + mName ; }
149  bool isOptional() const;
150  bool isReadOnly() const;
151  bool isList() const;
152  bool isRuntime() const;
153  Level level() const { return static_cast<Level>( mLevel ); }
154  ArgType argType() const { return static_cast<ArgType>( mArgType ); }
155  bool isSet() const;
156  bool boolValue() const;
157  QString stringValue() const;
158  int intValue() const;
159  unsigned int uintValue() const;
160  KUrl urlValue() const;
161  unsigned int numberOfTimesSet() const;
162  QStringList stringValueList() const;
163  std::vector<int> intValueList() const;
164  std::vector<unsigned int> uintValueList() const;
165  KUrl::List urlValueList() const;
166  void resetToDefault();
167  void setBoolValue( bool );
168  void setStringValue( const QString& );
169  void setIntValue( int );
170  void setUIntValue( unsigned int );
171  void setURLValue( const KUrl& );
172  void setNumberOfTimesSet( unsigned int );
173  void setStringValueList( const QStringList& );
174  void setIntValueList( const std::vector<int>& );
175  void setUIntValueList( const std::vector<unsigned int>& );
176  void setURLValueList( const KUrl::List& );
177  bool isDirty() const { return mDirty; }
178 
179  void setDirty( bool b );
180  QString outputString() const;
181 
182 protected:
183  bool isStringType() const;
184  QVariant stringToValue( const QString& value, bool unescape ) const;
185  QString toString( bool escape ) const;
186 private:
187  QGpgMECryptoConfigGroup * mGroup;
188  QString mName;
189  QString mDescription;
190  QVariant mDefaultValue;
191  QVariant mValue;
192  uint mFlags : 8; // bitfield with 8 bits
193  uint mLevel : 3; // max is 4 (2, in fact) -> 3 bits
194  uint mRealArgType : 6; // max is 33 -> 6 bits
195  uint mArgType : 3; // max is 6 (ArgType enum) -> 3 bits;
196  uint mDirty : 1;
197  uint mSet : 1;
198 };
199 
200 #endif /* KLEO_QGPGMECRYPTOCONFIG_H */
QGpgMECryptoConfigEntry::numberOfTimesSet
unsigned int numberOfTimesSet() const
Definition: qgpgmecryptoconfig.cpp:682
QGpgMECryptoConfigEntry::stringToValue
QVariant stringToValue(const QString &value, bool unescape) const
Definition: qgpgmecryptoconfig.cpp:516
QGpgMECryptoConfigEntry::stringValueList
QStringList stringValueList() const
Definition: qgpgmecryptoconfig.cpp:689
name
const char * name
Definition: kconfigbasedkeyfilter.cpp:126
QGpgMECryptoConfigComponent
For docu, see kleo/cryptoconfig.h.
Definition: qgpgmecryptoconfig.h:88
QGpgMECryptoConfigGroup::~QGpgMECryptoConfigGroup
~QGpgMECryptoConfigGroup()
Definition: qgpgmecryptoconfig.cpp:397
QGpgMECryptoConfigEntry::toString
QString toString(bool escape) const
Definition: qgpgmecryptoconfig.cpp:867
QGpgMECryptoConfigEntry::setDirty
void setDirty(bool b)
Definition: qgpgmecryptoconfig.cpp:926
QGpgMECryptoConfigEntry::isReadOnly
bool isReadOnly() const
Definition: qgpgmecryptoconfig.cpp:575
QGpgMECryptoConfigEntry::name
QString name() const
Definition: qgpgmecryptoconfig.h:146
QPointer< QGpgMECryptoConfigComponent >
QGpgMECryptoConfigEntry::setStringValueList
void setStringValueList(const QStringList &)
Definition: qgpgmecryptoconfig.cpp:815
QGpgMECryptoConfigGroup::path
QString path() const
Definition: qgpgmecryptoconfig.h:126
QGpgMECryptoConfigGroup::description
QString description() const
Definition: qgpgmecryptoconfig.h:125
QGpgMECryptoConfigEntry::intValue
int intValue() const
Definition: qgpgmecryptoconfig.cpp:607
QGpgMECryptoConfigEntry::path
QString path() const
Definition: qgpgmecryptoconfig.h:148
QGpgMECryptoConfigComponent::~QGpgMECryptoConfigComponent
~QGpgMECryptoConfigComponent()
Definition: qgpgmecryptoconfig.cpp:197
QGpgMECryptoConfigEntry::boolValue
bool boolValue() const
Definition: qgpgmecryptoconfig.cpp:595
QGpgMECryptoConfigEntry::setUIntValueList
void setUIntValueList(const std::vector< unsigned int > &)
Definition: qgpgmecryptoconfig.cpp:839
QGpgMECryptoConfigEntry::argType
ArgType argType() const
Definition: qgpgmecryptoconfig.h:154
QHash< QString, QGpgMECryptoConfigComponent * >
QObject
QGpgMECryptoConfigEntry::isStringType
bool isStringType() const
Definition: qgpgmecryptoconfig.cpp:918
QGpgMECryptoConfigEntry::setURLValue
void setURLValue(const KUrl &)
Definition: qgpgmecryptoconfig.cpp:795
QGpgMECryptoConfigEntry::setNumberOfTimesSet
void setNumberOfTimesSet(unsigned int)
Definition: qgpgmecryptoconfig.cpp:806
Level
Level
Definition: cryptoconfig.h:60
QGpgMECryptoConfigEntry::~QGpgMECryptoConfigEntry
~QGpgMECryptoConfigEntry()
Definition: qgpgmecryptoconfig.cpp:561
QGpgMECryptoConfigEntry::urlValueList
KUrl::List urlValueList() const
Definition: qgpgmecryptoconfig.cpp:722
QString
KLEO_EXPORT
#define KLEO_EXPORT
Definition: kleo_export.h:41
QStringList
cryptoconfig.h
QGpgMECryptoConfig
CryptoConfig implementation around the gpgconf command-line tool For method docu, see kleo/cryptoconf...
Definition: qgpgmecryptoconfig.h:54
QGpgMECryptoConfigEntry::isSet
bool isSet() const
Definition: qgpgmecryptoconfig.cpp:590
QLatin1Char
QGpgMECryptoConfigEntry::setIntValueList
void setIntValueList(const std::vector< int > &)
Definition: qgpgmecryptoconfig.cpp:825
QGpgMECryptoConfigEntry::stringValue
QString stringValue() const
Definition: qgpgmecryptoconfig.cpp:602
ArgType
ArgType
Type of the argument.
Definition: cryptoconfig.h:81
QGpgMECryptoConfigComponent::sync
void sync(bool runtime)
Definition: qgpgmecryptoconfig.cpp:305
QGpgMECryptoConfigEntry::uintValue
unsigned int uintValue() const
Definition: qgpgmecryptoconfig.cpp:614
QGpgMECryptoConfigGroup
Definition: qgpgmecryptoconfig.h:117
QGpgMECryptoConfigEntry::setStringValue
void setStringValue(const QString &)
Definition: qgpgmecryptoconfig.cpp:766
QGpgMECryptoConfigEntry::setUIntValue
void setUIntValue(unsigned int)
Definition: qgpgmecryptoconfig.cpp:788
QGpgMECryptoConfigEntry::isRuntime
bool isRuntime() const
Definition: qgpgmecryptoconfig.cpp:585
QGpgMECryptoConfigGroup::QGpgMECryptoConfigGroup
QGpgMECryptoConfigGroup(QGpgMECryptoConfigComponent *comp, const QString &name, const QString &description, int level)
Definition: qgpgmecryptoconfig.cpp:388
QGpgMECryptoConfigComponent::QGpgMECryptoConfigComponent
QGpgMECryptoConfigComponent(QGpgMECryptoConfig *, const QString &name, const QString &description)
Definition: qgpgmecryptoconfig.cpp:191
QGpgMECryptoConfigEntry
Definition: qgpgmecryptoconfig.h:141
QGpgMECryptoConfigGroup::name
QString name() const
Definition: qgpgmecryptoconfig.h:123
QGpgMECryptoConfigEntry::QGpgMECryptoConfigEntry
QGpgMECryptoConfigEntry(QGpgMECryptoConfigGroup *group, const QStringList &parsedLine)
Definition: qgpgmecryptoconfig.cpp:470
QGpgMECryptoConfigGroup::level
Kleo::CryptoConfigEntry::Level level() const
Definition: qgpgmecryptoconfig.h:127
QGpgMECryptoConfigEntry::isDirty
bool isDirty() const
Definition: qgpgmecryptoconfig.h:177
QGpgMECryptoConfigComponent::group
Kleo::CryptoConfigGroup * group(const QString &name) const
Definition: qgpgmecryptoconfig.cpp:300
QGpgMECryptoConfigEntry::urlValue
KUrl urlValue() const
Definition: qgpgmecryptoconfig.cpp:668
QGpgMECryptoConfigEntry::uintValueList
std::vector< unsigned int > uintValueList() const
Definition: qgpgmecryptoconfig.cpp:709
QGpgMECryptoConfigGroup::entryList
QStringList entryList() const
Definition: qgpgmecryptoconfig.cpp:404
QGpgMECryptoConfigEntry::description
QString description() const
Definition: qgpgmecryptoconfig.h:147
QGpgMECryptoConfigEntry::isList
bool isList() const
Definition: qgpgmecryptoconfig.cpp:580
QGpgMECryptoConfigGroup::entry
Kleo::CryptoConfigEntry * entry(const QString &name) const
Definition: qgpgmecryptoconfig.cpp:412
QGpgMECryptoConfigEntry::level
Level level() const
Definition: qgpgmecryptoconfig.h:153
kleo_export.h
QGpgMECryptoConfigComponent::iconName
QString iconName() const
Definition: qgpgmecryptoconfig.h:96
QGpgMECryptoConfigEntry::setBoolValue
void setBoolValue(bool)
Definition: qgpgmecryptoconfig.cpp:755
QGpgMECryptoConfigEntry::intValueList
std::vector< int > intValueList() const
Definition: qgpgmecryptoconfig.cpp:696
QGpgMECryptoConfigEntry::setURLValueList
void setURLValueList(const KUrl::List &)
Definition: qgpgmecryptoconfig.cpp:853
QGpgMECryptoConfigComponent::groupList
QStringList groupList() const
Definition: qgpgmecryptoconfig.cpp:292
QGpgMECryptoConfigEntry::isOptional
bool isOptional() const
Definition: qgpgmecryptoconfig.cpp:570
QGpgMECryptoConfigGroup::iconName
QString iconName() const
Definition: qgpgmecryptoconfig.h:124
QGpgMECryptoConfigEntry::setIntValue
void setIntValue(int)
Definition: qgpgmecryptoconfig.cpp:779
QGpgMECryptoConfigComponent::description
QString description() const
Definition: qgpgmecryptoconfig.h:97
QGpgMECryptoConfigEntry::outputString
QString outputString() const
Definition: qgpgmecryptoconfig.cpp:912
QGpgMECryptoConfigComponent::name
QString name() const
Definition: qgpgmecryptoconfig.h:95
QGpgMECryptoConfigEntry::resetToDefault
void resetToDefault()
Definition: qgpgmecryptoconfig.cpp:741
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkleo

Skip menu "libkleo"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal