qgpgmecryptoconfig.h
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 TQt library by Trolltech AS, Norway (or with modified versions
24  of TQt that use the same license as TQt), 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  TQt. 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_TQGPGMECRYPTOCONFIG_H
34 #define KLEO_TQGPGMECRYPTOCONFIG_H
35 
36 #include <kleo/cryptoconfig.h>
37 #include <tqdict.h>
38 #include <tqstringlist.h>
39 #include <tqobject.h>
40 #include <tqvariant.h>
41 class KProcIO;
42 
44 class QGpgMECryptoConfigEntry;
49 class QGpgMECryptoConfig : public TQObject, public Kleo::CryptoConfig {
50 
51  TQ_OBJECT
52 
53 public:
58  virtual ~QGpgMECryptoConfig();
59 
60  virtual TQStringList componentList() const;
61 
62  virtual Kleo::CryptoConfigComponent* component( const TQString& name ) const;
63 
64  virtual void clear();
65  virtual void sync( bool runtime );
66 
67 private slots:
68  void slotCollectStdOut( KProcIO* proc );
69 private:
71  void runGpgConf( bool showErrors );
72 
73 private:
74  TQDict<QGpgMECryptoConfigComponent> mComponents;
75  bool mParsed;
76 };
77 
78 class QGpgMECryptoConfigGroup;
79 
82 
83  TQ_OBJECT
84 
85 public:
86  QGpgMECryptoConfigComponent( QGpgMECryptoConfig*, const TQString& name, const TQString& description );
88 
89  TQString name() const { return mName; }
90  TQString iconName() const { return mName; }
91  TQString description() const { return mDescription; }
92  TQStringList groupList() const;
93  Kleo::CryptoConfigGroup* group( const TQString& name ) const;
94 
95  void sync( bool runtime );
96 
97 private slots:
98  void slotCollectStdOut( KProcIO* proc );
99 private:
100  void runGpgConf();
101 
102 private:
103  TQDict<QGpgMECryptoConfigGroup> mGroups;
104  TQString mName;
105  TQString mDescription;
106  QGpgMECryptoConfigGroup* mCurrentGroup; // during parsing
107  TQString mCurrentGroupName; // during parsing
108 };
109 
110 class QGpgMECryptoConfigGroup : public Kleo::CryptoConfigGroup {
111 
112 public:
113  QGpgMECryptoConfigGroup( const TQString & name, const TQString& description, int level );
114  ~QGpgMECryptoConfigGroup() {}
115 
116  TQString name() const { return mName; }
117  TQString iconName() const { return TQString(); }
118  TQString description() const { return mDescription; }
119  Kleo::CryptoConfigEntry::Level level() const { return mLevel; }
120  TQStringList entryList() const;
121  Kleo::CryptoConfigEntry* entry( const TQString& name ) const;
122 
123 private:
124  friend class QGpgMECryptoConfigComponent; // it adds the entries
125  TQDict<QGpgMECryptoConfigEntry> mEntries;
126  TQString mName;
127  TQString mDescription;
129 };
130 
131 class QGpgMECryptoConfigEntry : public Kleo::CryptoConfigEntry {
132 public:
133  QGpgMECryptoConfigEntry( const TQStringList& parsedLine );
134  ~QGpgMECryptoConfigEntry();
135 
136  TQString name() const { return mName; }
137  TQString description() const { return mDescription; }
138  bool isOptional() const;
139  bool isReadOnly() const;
140  bool isList() const;
141  bool isRuntime() const;
142  Level level() const { return static_cast<Level>( mLevel ); }
143  ArgType argType() const { return static_cast<ArgType>( mArgType ); }
144  bool isSet() const;
145  bool boolValue() const;
146  TQString stringValue() const;
147  int intValue() const;
148  unsigned int uintValue() const;
149  KURL urlValue() const;
150  unsigned int numberOfTimesSet() const;
151  TQStringList stringValueList() const;
152  TQValueList<int> intValueList() const;
153  TQValueList<unsigned int> uintValueList() const;
154  KURL::List urlValueList() const;
155  void resetToDefault();
156  void setBoolValue( bool );
157  void setStringValue( const TQString& );
158  void setIntValue( int );
159  void setUIntValue( unsigned int );
160  void setURLValue( const KURL& );
161  void setNumberOfTimesSet( unsigned int );
162  void setStringValueList( const TQStringList& );
163  void setIntValueList( const TQValueList<int>& );
164  void setUIntValueList( const TQValueList<unsigned int>& );
165  void setURLValueList( const KURL::List& );
166  bool isDirty() const { return mDirty; }
167 
168  void setDirty( bool b );
169  TQString outputString() const;
170 
171 protected:
172  bool isStringType() const;
173  TQVariant stringToValue( const TQString& value, bool unescape ) const;
174  TQString toString( bool escape ) const;
175 private:
176  TQString mName;
177  TQString mDescription;
178  TQVariant mDefaultValue;
179  TQVariant mValue;
180  uint mFlags : 8; // bitfield with 8 bits
181  uint mLevel : 3; // max is 4 (2, in fact) -> 3 bits
182  uint mRealArgType : 6; // max is 33 -> 6 bits
183  uint mArgType : 3; // max is 6 (ArgType enum) -> 3 bits;
184  uint mDirty : 1;
185  uint mSet : 1;
186 };
187 
188 #endif /* KLEO_TQGPGMECRYPTOCONFIG_H */
virtual TQStringList componentList() const
Returns the list of known components (e.g.
TQString description() const
Return user-visible description of this component.
For docu, see kleo/cryptoconfig.h.
Main interface to crypto configuration.
Definition: cryptoconfig.h:334
Crypto config for one component (e.g.
Definition: cryptoconfig.h:295
Group containing a set of config options.
Definition: cryptoconfig.h:252
virtual Kleo::CryptoConfigComponent * component(const TQString &name) const
CryptoConfigEntry * entry(const TQString &componentName, const TQString &groupName, const TQString &entryName) const
Convenience method to get hold of a single configuration entry when its component, group and name are known.
Definition: cryptoconfig.h:360
virtual void sync(bool runtime)
Write back changes.
TQString iconName() const
Return the name of the icon for this component.
CryptoConfig implementation around the gpgconf command-line tool For method docu, see kleo/cryptoconf...
Description of a single option.
Definition: cryptoconfig.h:49
QGpgMECryptoConfig()
Constructor.
virtual void clear()
Tells the CryptoConfig to discard any cached information, including all components, groups and entries.
TQString name() const
Return the internal name of this component.