00001
00002
00003
00004 #include "kgpgsettings.h"
00005
00006 #include <kglobal.h>
00007 #include <QtCore/QFile>
00008
00009 class KGpgSettingsHelper
00010 {
00011 public:
00012 KGpgSettingsHelper() : q(0) {}
00013 ~KGpgSettingsHelper() { delete q; }
00014 KGpgSettings *q;
00015 };
00016 K_GLOBAL_STATIC(KGpgSettingsHelper, s_globalKGpgSettings)
00017 KGpgSettings *KGpgSettings::self()
00018 {
00019 if (!s_globalKGpgSettings->q) {
00020 new KGpgSettings;
00021 s_globalKGpgSettings->q->readConfig();
00022 }
00023
00024 return s_globalKGpgSettings->q;
00025 }
00026
00027 KGpgSettings::KGpgSettings( )
00028 : KConfigSkeleton( QLatin1String( "kgpgrc" ) )
00029 {
00030 Q_ASSERT(!s_globalKGpgSettings->q);
00031 s_globalKGpgSettings->q = this;
00032 setCurrentGroup( QLatin1String( "Decryption" ) );
00033
00034 KConfigSkeleton::ItemString *itemCustomDecrypt;
00035 itemCustomDecrypt = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "custom_decrypt" ), mCustomDecrypt );
00036 addItem( itemCustomDecrypt, QLatin1String( "CustomDecrypt" ) );
00037
00038 setCurrentGroup( QLatin1String( "Encryption" ) );
00039
00040 KConfigSkeleton::ItemString *itemCustomEncryptionOptions;
00041 itemCustomEncryptionOptions = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "custom_option" ), mCustomEncryptionOptions );
00042 addItem( itemCustomEncryptionOptions, QLatin1String( "CustomEncryptionOptions" ) );
00043 KConfigSkeleton::ItemBool *itemAllowCustomEncryptionOptions;
00044 itemAllowCustomEncryptionOptions = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "allow_custom_option" ), mAllowCustomEncryptionOptions, false );
00045 addItem( itemAllowCustomEncryptionOptions, QLatin1String( "AllowCustomEncryptionOptions" ) );
00046 KConfigSkeleton::ItemString *itemFileEncryptionKey;
00047 itemFileEncryptionKey = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "file key" ), mFileEncryptionKey );
00048 addItem( itemFileEncryptionKey, QLatin1String( "FileEncryptionKey" ) );
00049 KConfigSkeleton::ItemBool *itemEncryptFilesTo;
00050 itemEncryptFilesTo = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "encrypt_files_to" ), mEncryptFilesTo, false );
00051 addItem( itemEncryptFilesTo, QLatin1String( "EncryptFilesTo" ) );
00052 KConfigSkeleton::ItemBool *itemAsciiArmor;
00053 itemAsciiArmor = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "Ascii_armor" ), mAsciiArmor, true );
00054 addItem( itemAsciiArmor, QLatin1String( "AsciiArmor" ) );
00055 KConfigSkeleton::ItemBool *itemAllowUntrustedKeys;
00056 itemAllowUntrustedKeys = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "Allow_untrusted_keys" ), mAllowUntrustedKeys, false );
00057 addItem( itemAllowUntrustedKeys, QLatin1String( "AllowUntrustedKeys" ) );
00058 KConfigSkeleton::ItemBool *itemHideUserID;
00059 itemHideUserID = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "Hide_user_ID" ), mHideUserID, false );
00060 addItem( itemHideUserID, QLatin1String( "HideUserID" ) );
00061 KConfigSkeleton::ItemBool *itemPgpCompatibility;
00062 itemPgpCompatibility = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "PGP_compatibility" ), mPgpCompatibility, false );
00063 addItem( itemPgpCompatibility, QLatin1String( "PgpCompatibility" ) );
00064 KConfigSkeleton::ItemBool *itemPgpExtension;
00065 itemPgpExtension = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "Pgp_extension" ), mPgpExtension, false );
00066 addItem( itemPgpExtension, QLatin1String( "PgpExtension" ) );
00067
00068 setCurrentGroup( QLatin1String( "GPG Settings" ) );
00069
00070 KConfigSkeleton::ItemPath *itemGpgConfigPath;
00071 itemGpgConfigPath = new KConfigSkeleton::ItemPath( currentGroup(), QLatin1String( "gpg_config_path" ), mGpgConfigPath );
00072 addItem( itemGpgConfigPath, QLatin1String( "GpgConfigPath" ) );
00073 KConfigSkeleton::ItemPath *itemGpgBinaryPath;
00074 itemGpgBinaryPath = new KConfigSkeleton::ItemPath( currentGroup(), QLatin1String( "gpg_bin_path" ), mGpgBinaryPath, QLatin1String( "gpg" ) );
00075 addItem( itemGpgBinaryPath, QLatin1String( "GpgBinaryPath" ) );
00076 KConfigSkeleton::ItemString *itemGroups;
00077 itemGroups = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "Groups" ), mGroups );
00078 addItem( itemGroups, QLatin1String( "Groups" ) );
00079
00080 setCurrentGroup( QLatin1String( "General Options" ) );
00081
00082 QList<KConfigSkeleton::ItemEnum::Choice> valuesPhotoProperties;
00083 {
00084 KConfigSkeleton::ItemEnum::Choice choice;
00085 choice.name = QLatin1String( "Disable" );
00086 valuesPhotoProperties.append( choice );
00087 }
00088 {
00089 KConfigSkeleton::ItemEnum::Choice choice;
00090 choice.name = QLatin1String( "Small" );
00091 valuesPhotoProperties.append( choice );
00092 }
00093 {
00094 KConfigSkeleton::ItemEnum::Choice choice;
00095 choice.name = QLatin1String( "Medium" );
00096 valuesPhotoProperties.append( choice );
00097 }
00098 {
00099 KConfigSkeleton::ItemEnum::Choice choice;
00100 choice.name = QLatin1String( "Big" );
00101 valuesPhotoProperties.append( choice );
00102 }
00103 KConfigSkeleton::ItemEnum *itemPhotoProperties;
00104 itemPhotoProperties = new KConfigSkeleton::ItemEnum( currentGroup(), QLatin1String( "photo properties" ), mPhotoProperties, valuesPhotoProperties, EnumPhotoProperties::Disable );
00105 addItem( itemPhotoProperties, QLatin1String( "PhotoProperties" ) );
00106 KConfigSkeleton::ItemBool *itemFirstRun;
00107 itemFirstRun = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "First run" ), mFirstRun, true );
00108 addItem( itemFirstRun, QLatin1String( "FirstRun" ) );
00109 KConfigSkeleton::ItemSize *itemEditorGeometry;
00110 itemEditorGeometry = new KConfigSkeleton::ItemSize( currentGroup(), QLatin1String( "Geometry" ), mEditorGeometry );
00111 addItem( itemEditorGeometry, QLatin1String( "EditorGeometry" ) );
00112 KConfigSkeleton::ItemBool *itemShowTrust;
00113 itemShowTrust = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "show_trust" ), mShowTrust, true );
00114 addItem( itemShowTrust, QLatin1String( "ShowTrust" ) );
00115 KConfigSkeleton::ItemBool *itemShowExpi;
00116 itemShowExpi = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "show_expi" ), mShowExpi, true );
00117 addItem( itemShowExpi, QLatin1String( "ShowExpi" ) );
00118 KConfigSkeleton::ItemBool *itemShowSize;
00119 itemShowSize = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "show_size" ), mShowSize, true );
00120 addItem( itemShowSize, QLatin1String( "ShowSize" ) );
00121 KConfigSkeleton::ItemBool *itemShowCreat;
00122 itemShowCreat = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "show_creat" ), mShowCreat, true );
00123 addItem( itemShowCreat, QLatin1String( "ShowCreat" ) );
00124 KConfigSkeleton::ItemBool *itemShowSecret;
00125 itemShowSecret = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "show_secret" ), mShowSecret, false );
00126 addItem( itemShowSecret, QLatin1String( "ShowSecret" ) );
00127 KConfigSkeleton::ItemBool *itemHideExRev;
00128 itemHideExRev = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "hide_disabled" ), mHideExRev, true );
00129 addItem( itemHideExRev, QLatin1String( "HideExRev" ) );
00130
00131 setCurrentGroup( QLatin1String( "User Interface" ) );
00132
00133 KConfigSkeleton::ItemBool *itemUseMouseSelection;
00134 itemUseMouseSelection = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "selection_clipboard" ), mUseMouseSelection, false );
00135 addItem( itemUseMouseSelection, QLatin1String( "UseMouseSelection" ) );
00136 KConfigSkeleton::ItemBool *itemAutoStart;
00137 itemAutoStart = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "AutoStart" ), mAutoStart, false );
00138 addItem( itemAutoStart, QLatin1String( "AutoStart" ) );
00139 KConfigSkeleton::ItemBool *itemRemoteFileWarn;
00140 itemRemoteFileWarn = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "remote_file_warn" ), mRemoteFileWarn, false );
00141 addItem( itemRemoteFileWarn, QLatin1String( "RemoteFileWarn" ) );
00142 QList<KConfigSkeleton::ItemEnum::Choice> valuesLeftClick;
00143 {
00144 KConfigSkeleton::ItemEnum::Choice choice;
00145 choice.name = QLatin1String( "KeyManager" );
00146 valuesLeftClick.append( choice );
00147 }
00148 {
00149 KConfigSkeleton::ItemEnum::Choice choice;
00150 choice.name = QLatin1String( "Editor" );
00151 valuesLeftClick.append( choice );
00152 }
00153 KConfigSkeleton::ItemEnum *itemLeftClick;
00154 itemLeftClick = new KConfigSkeleton::ItemEnum( currentGroup(), QLatin1String( "left_click" ), mLeftClick, valuesLeftClick );
00155 addItem( itemLeftClick, QLatin1String( "LeftClick" ) );
00156 QList<KConfigSkeleton::ItemEnum::Choice> valuesEncryptedDropEvent;
00157 {
00158 KConfigSkeleton::ItemEnum::Choice choice;
00159 choice.name = QLatin1String( "DecryptAndSave" );
00160 valuesEncryptedDropEvent.append( choice );
00161 }
00162 {
00163 KConfigSkeleton::ItemEnum::Choice choice;
00164 choice.name = QLatin1String( "DecryptAndOpen" );
00165 valuesEncryptedDropEvent.append( choice );
00166 }
00167 {
00168 KConfigSkeleton::ItemEnum::Choice choice;
00169 choice.name = QLatin1String( "Ask" );
00170 valuesEncryptedDropEvent.append( choice );
00171 }
00172 KConfigSkeleton::ItemEnum *itemEncryptedDropEvent;
00173 itemEncryptedDropEvent = new KConfigSkeleton::ItemEnum( currentGroup(), QLatin1String( "encrypted_drop_event" ), mEncryptedDropEvent, valuesEncryptedDropEvent );
00174 addItem( itemEncryptedDropEvent, QLatin1String( "EncryptedDropEvent" ) );
00175 QList<KConfigSkeleton::ItemEnum::Choice> valuesUnencryptedDropEvent;
00176 {
00177 KConfigSkeleton::ItemEnum::Choice choice;
00178 choice.name = QLatin1String( "Encrypt" );
00179 valuesUnencryptedDropEvent.append( choice );
00180 }
00181 {
00182 KConfigSkeleton::ItemEnum::Choice choice;
00183 choice.name = QLatin1String( "Sign" );
00184 valuesUnencryptedDropEvent.append( choice );
00185 }
00186 {
00187 KConfigSkeleton::ItemEnum::Choice choice;
00188 choice.name = QLatin1String( "Ask" );
00189 valuesUnencryptedDropEvent.append( choice );
00190 }
00191 KConfigSkeleton::ItemEnum *itemUnencryptedDropEvent;
00192 itemUnencryptedDropEvent = new KConfigSkeleton::ItemEnum( currentGroup(), QLatin1String( "unencrypted_drop_event" ), mUnencryptedDropEvent, valuesUnencryptedDropEvent );
00193 addItem( itemUnencryptedDropEvent, QLatin1String( "UnencryptedDropEvent" ) );
00194 QList<KConfigSkeleton::ItemEnum::Choice> valuesSignMenu;
00195 {
00196 KConfigSkeleton::ItemEnum::Choice choice;
00197 choice.name = QLatin1String( "Disabled" );
00198 valuesSignMenu.append( choice );
00199 }
00200 {
00201 KConfigSkeleton::ItemEnum::Choice choice;
00202 choice.name = QLatin1String( "AllFiles" );
00203 valuesSignMenu.append( choice );
00204 }
00205 KConfigSkeleton::ItemEnum *itemSignMenu;
00206 itemSignMenu = new KConfigSkeleton::ItemEnum( currentGroup(), QLatin1String( "sign_menu" ), mSignMenu, valuesSignMenu, EnumSignMenu::Disabled );
00207 addItem( itemSignMenu, QLatin1String( "SignMenu" ) );
00208 QList<KConfigSkeleton::ItemEnum::Choice> valuesDecryptMenu;
00209 {
00210 KConfigSkeleton::ItemEnum::Choice choice;
00211 choice.name = QLatin1String( "Disabled" );
00212 valuesDecryptMenu.append( choice );
00213 }
00214 {
00215 KConfigSkeleton::ItemEnum::Choice choice;
00216 choice.name = QLatin1String( "AllFiles" );
00217 valuesDecryptMenu.append( choice );
00218 }
00219 {
00220 KConfigSkeleton::ItemEnum::Choice choice;
00221 choice.name = QLatin1String( "EncryptedFiles" );
00222 valuesDecryptMenu.append( choice );
00223 }
00224 KConfigSkeleton::ItemEnum *itemDecryptMenu;
00225 itemDecryptMenu = new KConfigSkeleton::ItemEnum( currentGroup(), QLatin1String( "decrypt_menu" ), mDecryptMenu, valuesDecryptMenu, EnumDecryptMenu::Disabled );
00226 addItem( itemDecryptMenu, QLatin1String( "DecryptMenu" ) );
00227 KConfigSkeleton::ItemBool *itemShowSystray;
00228 itemShowSystray = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "systray_icon" ), mShowSystray, true );
00229 addItem( itemShowSystray, QLatin1String( "ShowSystray" ) );
00230
00231 setCurrentGroup( QLatin1String( "TipOfDay" ) );
00232
00233 KConfigSkeleton::ItemBool *itemShowTipOfDay;
00234 itemShowTipOfDay = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "RunOnStart" ), mShowTipOfDay, true );
00235 addItem( itemShowTipOfDay, QLatin1String( "ShowTipOfDay" ) );
00236
00237 setCurrentGroup( QLatin1String( "Key Colors" ) );
00238
00239 KConfigSkeleton::ItemColor *itemColorGood;
00240 itemColorGood = new KConfigSkeleton::ItemColor( currentGroup(), QLatin1String( "color_good" ), mColorGood, QColor( 144,255,0 ) );
00241 addItem( itemColorGood, QLatin1String( "ColorGood" ) );
00242 KConfigSkeleton::ItemColor *itemColorRev;
00243 itemColorRev = new KConfigSkeleton::ItemColor( currentGroup(), QLatin1String( "color_revoked" ), mColorRev, QColor( 30,30,30 ) );
00244 addItem( itemColorRev, QLatin1String( "ColorRev" ) );
00245 KConfigSkeleton::ItemColor *itemColorUnknown;
00246 itemColorUnknown = new KConfigSkeleton::ItemColor( currentGroup(), QLatin1String( "color_unknown" ), mColorUnknown, QColor( 255,255,255 ) );
00247 addItem( itemColorUnknown, QLatin1String( "ColorUnknown" ) );
00248 KConfigSkeleton::ItemColor *itemColorBad;
00249 itemColorBad = new KConfigSkeleton::ItemColor( currentGroup(), QLatin1String( "color_bad" ), mColorBad, QColor( 172,0,0 ) );
00250 addItem( itemColorBad, QLatin1String( "ColorBad" ) );
00251 KConfigSkeleton::ItemColor *itemColorUltimate;
00252 itemColorUltimate = new KConfigSkeleton::ItemColor( currentGroup(), QLatin1String( "color_ultimate" ), mColorUltimate, QColor( 68,0,255 ) );
00253 addItem( itemColorUltimate, QLatin1String( "ColorUltimate" ) );
00254 KConfigSkeleton::ItemColor *itemColorMarginal;
00255 itemColorMarginal = new KConfigSkeleton::ItemColor( currentGroup(), QLatin1String( "color_marginal" ), mColorMarginal, QColor( 255,255,0 ) );
00256 addItem( itemColorMarginal, QLatin1String( "ColorMarginal" ) );
00257 KConfigSkeleton::ItemColor *itemColorExpired;
00258 itemColorExpired = new KConfigSkeleton::ItemColor( currentGroup(), QLatin1String( "color_expired" ), mColorExpired, QColor( 150,150,150 ) );
00259 addItem( itemColorExpired, QLatin1String( "ColorExpired" ) );
00260
00261 setCurrentGroup( QLatin1String( "Text Font" ) );
00262
00263 KConfigSkeleton::ItemFont *itemFont;
00264 itemFont = new KConfigSkeleton::ItemFont( currentGroup(), QLatin1String( "KEditFont" ), mFont, KGlobalSettings::fixedFont() );
00265 addItem( itemFont, QLatin1String( "Font" ) );
00266
00267 setCurrentGroup( QLatin1String( "Key Servers" ) );
00268
00269 KConfigSkeleton::ItemBool *itemUseProxy;
00270 itemUseProxy = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "use_proxy" ), mUseProxy, false );
00271 addItem( itemUseProxy, QLatin1String( "UseProxy" ) );
00272 }
00273
00274 KGpgSettings::~KGpgSettings()
00275 {
00276 }
00277