certmanager/lib

qgpgmecryptoconfig.h

00001 /*
00002     qgpgmecryptoconfig.h
00003 
00004     This file is part of libkleopatra, the KDE keymanagement library
00005     Copyright (c) 2004 Klarälvdalens Datakonsult AB
00006 
00007     Libkleopatra is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU General Public License as
00009     published by the Free Software Foundation; either version 2 of the
00010     License, or (at your option) any later version.
00011 
00012     Libkleopatra is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021     In addition, as a special exception, the copyright holders give
00022     permission to link the code of this program with any edition of
00023     the Qt library by Trolltech AS, Norway (or with modified versions
00024     of Qt that use the same license as Qt), and distribute linked
00025     combinations including the two.  You must obey the GNU General
00026     Public License in all respects for all of the code used other than
00027     Qt.  If you modify this file, you may extend this exception to
00028     your version of the file, but you are not obligated to do so.  If
00029     you do not wish to do so, delete this exception statement from
00030     your version.
00031 */
00032 
00033 #ifndef KLEO_QGPGMECRYPTOCONFIG_H
00034 #define KLEO_QGPGMECRYPTOCONFIG_H
00035 
00036 #include <kleo/cryptoconfig.h>
00037 #include <qdict.h>
00038 #include <qstringlist.h>
00039 #include <qobject.h>
00040 #include <qvariant.h>
00041 class KProcIO;
00042 
00043 class QGpgMECryptoConfigComponent;
00044 class QGpgMECryptoConfigEntry;
00049 class QGpgMECryptoConfig : public QObject, public Kleo::CryptoConfig {
00050 
00051   Q_OBJECT
00052 public:
00056   QGpgMECryptoConfig();
00057   virtual ~QGpgMECryptoConfig();
00058 
00059   virtual QStringList componentList() const;
00060 
00061   virtual Kleo::CryptoConfigComponent* component( const QString& name ) const;
00062 
00063   virtual void clear();
00064   virtual void sync( bool runtime );
00065 
00066 private slots:
00067   void slotCollectStdOut( KProcIO* proc );
00068 private:
00070   void runGpgConf( bool showErrors );
00071 
00072 private:
00073   QDict<QGpgMECryptoConfigComponent> mComponents;
00074   bool mParsed;
00075 };
00076 
00077 class QGpgMECryptoConfigGroup;
00078 
00080 class QGpgMECryptoConfigComponent : public QObject, public Kleo::CryptoConfigComponent {
00081 
00082   Q_OBJECT
00083 public:
00084   QGpgMECryptoConfigComponent( QGpgMECryptoConfig*, const QString& name, const QString& description );
00085   ~QGpgMECryptoConfigComponent();
00086 
00087   QString name() const { return mName; }
00088   QString iconName() const { return mName; }
00089   QString description() const { return mDescription; }
00090   QStringList groupList() const;
00091   Kleo::CryptoConfigGroup* group( const QString& name ) const;
00092 
00093   void sync( bool runtime );
00094 
00095 private slots:
00096   void slotCollectStdOut( KProcIO* proc );
00097 private:
00098   void runGpgConf();
00099 
00100 private:
00101   QDict<QGpgMECryptoConfigGroup> mGroups;
00102   QString mName;
00103   QString mDescription;
00104   QGpgMECryptoConfigGroup* mCurrentGroup; // during parsing
00105   QString mCurrentGroupName; // during parsing
00106 };
00107 
00108 class QGpgMECryptoConfigGroup : public Kleo::CryptoConfigGroup {
00109 
00110 public:
00111   QGpgMECryptoConfigGroup( const QString & name, const QString& description, int level );
00112   ~QGpgMECryptoConfigGroup() {}
00113 
00114   QString name() const { return mName; }
00115   QString iconName() const { return QString::null; }
00116   QString description() const { return mDescription; }
00117   Kleo::CryptoConfigEntry::Level level() const { return mLevel; }
00118   QStringList entryList() const;
00119   Kleo::CryptoConfigEntry* entry( const QString& name ) const;
00120 
00121 private:
00122   friend class QGpgMECryptoConfigComponent; // it adds the entries
00123   QDict<QGpgMECryptoConfigEntry> mEntries;
00124   QString mName;
00125   QString mDescription;
00126   Kleo::CryptoConfigEntry::Level mLevel;
00127 };
00128 
00129 class QGpgMECryptoConfigEntry : public Kleo::CryptoConfigEntry {
00130 public:
00131   QGpgMECryptoConfigEntry( const QStringList& parsedLine );
00132   ~QGpgMECryptoConfigEntry();
00133 
00134   QString name() const { return mName; }
00135   QString description() const { return mDescription; }
00136   bool isOptional() const;
00137   bool isList() const;
00138   bool isRuntime() const;
00139   Level level() const { return static_cast<Level>( mLevel ); }
00140   ArgType argType() const { return static_cast<ArgType>( mArgType ); }
00141   bool isSet() const;
00142   bool boolValue() const;
00143   QString stringValue() const;
00144   int intValue() const;
00145   unsigned int uintValue() const;
00146   KURL urlValue() const;
00147   unsigned int numberOfTimesSet() const;
00148   QStringList stringValueList() const;
00149   QValueList<int> intValueList() const;
00150   QValueList<unsigned int> uintValueList() const;
00151   KURL::List urlValueList() const;
00152   void resetToDefault();
00153   void setBoolValue( bool );
00154   void setStringValue( const QString& );
00155   void setIntValue( int );
00156   void setUIntValue( unsigned int );
00157   void setURLValue( const KURL& );
00158   void setNumberOfTimesSet( unsigned int );
00159   void setStringValueList( const QStringList& );
00160   void setIntValueList( const QValueList<int>& );
00161   void setUIntValueList( const QValueList<unsigned int>& );
00162   void setURLValueList( const KURL::List& );
00163   bool isDirty() const { return mDirty; }
00164 
00165   void setDirty( bool b );
00166   QString outputString() const;
00167 
00168 protected:
00169   bool isStringType() const;
00170   QVariant stringToValue( const QString& value, bool unescape ) const;
00171   QString toString( bool escape ) const;
00172 private:
00173   QString mName;
00174   QString mDescription;
00175   QVariant mDefaultValue;
00176   QVariant mValue;
00177   uint mFlags : 7; // bitfield with 7 bits
00178   uint mLevel : 3; // max is 4 (2, in fact) -> 3 bits
00179   uint mRealArgType : 6; // max is 33 -> 6 bits
00180   uint mArgType : 3; // max is 6 (ArgType enum) -> 3 bits;
00181   uint mDirty : 1;
00182   uint mSet : 1;
00183 };
00184 
00185 #endif /* KLEO_QGPGMECRYPTOCONFIG_H */
KDE Home | KDE Accessibility Home | Description of Access Keys