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 TQt library by Trolltech AS, Norway (or with modified versions 00024 of TQt that use the same license as TQt), 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 TQt. 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_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; // during parsing 00107 TQString mCurrentGroupName; // during parsing 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; // it adds the entries 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; // bitfield with 8 bits 00181 uint mLevel : 3; // max is 4 (2, in fact) -> 3 bits 00182 uint mRealArgType : 6; // max is 33 -> 6 bits 00183 uint mArgType : 3; // max is 6 (ArgType enum) -> 3 bits; 00184 uint mDirty : 1; 00185 uint mSet : 1; 00186 }; 00187 00188 #endif /* KLEO_TQGPGMECRYPTOCONFIG_H */