00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef KLEO_TQGPGMECRYPTOCONFIG_H
00034 #define KLEO_TQGPGMECRYPTOCONFIG_H
00035
00036 #include <kleo/cryptoconfig.h>
00037 #include <tqdict.h>
00038 #include <tqstringlist.h>
00039 #include <tqobject.h>
00040 #include <tqvariant.h>
00041 class KProcIO;
00042
00043 class QGpgMECryptoConfigComponent;
00044 class QGpgMECryptoConfigEntry;
00049 class QGpgMECryptoConfig : public TQObject, public Kleo::CryptoConfig {
00050
00051 Q_OBJECT
00052 TQ_OBJECT
00053 public:
00057 QGpgMECryptoConfig();
00058 virtual ~QGpgMECryptoConfig();
00059
00060 virtual TQStringList componentList() const;
00061
00062 virtual Kleo::CryptoConfigComponent* component( const TQString& name ) const;
00063
00064 virtual void clear();
00065 virtual void sync( bool runtime );
00066
00067 private slots:
00068 void slotCollectStdOut( KProcIO* proc );
00069 private:
00071 void runGpgConf( bool showErrors );
00072
00073 private:
00074 TQDict<QGpgMECryptoConfigComponent> mComponents;
00075 bool mParsed;
00076 };
00077
00078 class QGpgMECryptoConfigGroup;
00079
00081 class QGpgMECryptoConfigComponent : public TQObject, public Kleo::CryptoConfigComponent {
00082
00083 Q_OBJECT
00084 TQ_OBJECT
00085 public:
00086 QGpgMECryptoConfigComponent( QGpgMECryptoConfig*, const TQString& name, const TQString& description );
00087 ~QGpgMECryptoConfigComponent();
00088
00089 TQString name() const { return mName; }
00090 TQString iconName() const { return mName; }
00091 TQString description() const { return mDescription; }
00092 TQStringList groupList() const;
00093 Kleo::CryptoConfigGroup* group( const TQString& name ) const;
00094
00095 void sync( bool runtime );
00096
00097 private slots:
00098 void slotCollectStdOut( KProcIO* proc );
00099 private:
00100 void runGpgConf();
00101
00102 private:
00103 TQDict<QGpgMECryptoConfigGroup> mGroups;
00104 TQString mName;
00105 TQString mDescription;
00106 QGpgMECryptoConfigGroup* mCurrentGroup;
00107 TQString mCurrentGroupName;
00108 };
00109
00110 class QGpgMECryptoConfigGroup : public Kleo::CryptoConfigGroup {
00111
00112 public:
00113 QGpgMECryptoConfigGroup( const TQString & name, const TQString& description, int level );
00114 ~QGpgMECryptoConfigGroup() {}
00115
00116 TQString name() const { return mName; }
00117 TQString iconName() const { return TQString(); }
00118 TQString description() const { return mDescription; }
00119 Kleo::CryptoConfigEntry::Level level() const { return mLevel; }
00120 TQStringList entryList() const;
00121 Kleo::CryptoConfigEntry* entry( const TQString& name ) const;
00122
00123 private:
00124 friend class QGpgMECryptoConfigComponent;
00125 TQDict<QGpgMECryptoConfigEntry> mEntries;
00126 TQString mName;
00127 TQString mDescription;
00128 Kleo::CryptoConfigEntry::Level mLevel;
00129 };
00130
00131 class QGpgMECryptoConfigEntry : public Kleo::CryptoConfigEntry {
00132 public:
00133 QGpgMECryptoConfigEntry( const TQStringList& parsedLine );
00134 ~QGpgMECryptoConfigEntry();
00135
00136 TQString name() const { return mName; }
00137 TQString description() const { return mDescription; }
00138 bool isOptional() const;
00139 bool isReadOnly() const;
00140 bool isList() const;
00141 bool isRuntime() const;
00142 Level level() const { return static_cast<Level>( mLevel ); }
00143 ArgType argType() const { return static_cast<ArgType>( mArgType ); }
00144 bool isSet() const;
00145 bool boolValue() const;
00146 TQString stringValue() const;
00147 int intValue() const;
00148 unsigned int uintValue() const;
00149 KURL urlValue() const;
00150 unsigned int numberOfTimesSet() const;
00151 TQStringList stringValueList() const;
00152 TQValueList<int> intValueList() const;
00153 TQValueList<unsigned int> uintValueList() const;
00154 KURL::List urlValueList() const;
00155 void resetToDefault();
00156 void setBoolValue( bool );
00157 void setStringValue( const TQString& );
00158 void setIntValue( int );
00159 void setUIntValue( unsigned int );
00160 void setURLValue( const KURL& );
00161 void setNumberOfTimesSet( unsigned int );
00162 void setStringValueList( const TQStringList& );
00163 void setIntValueList( const TQValueList<int>& );
00164 void setUIntValueList( const TQValueList<unsigned int>& );
00165 void setURLValueList( const KURL::List& );
00166 bool isDirty() const { return mDirty; }
00167
00168 void setDirty( bool b );
00169 TQString outputString() const;
00170
00171 protected:
00172 bool isStringType() const;
00173 TQVariant stringToValue( const TQString& value, bool unescape ) const;
00174 TQString toString( bool escape ) const;
00175 private:
00176 TQString mName;
00177 TQString mDescription;
00178 TQVariant mDefaultValue;
00179 TQVariant mValue;
00180 uint mFlags : 8;
00181 uint mLevel : 3;
00182 uint mRealArgType : 6;
00183 uint mArgType : 3;
00184 uint mDirty : 1;
00185 uint mSet : 1;
00186 };
00187
00188 #endif