GPGOptions


Inherits From:
NSObject
Declared In:
GPGOptions.h


Class Description

GPGOptions class allows you to retrieve options used by GnuPG, as defined in GPGPreferences, from GnuPG configuration file, read by the executable.

You can also set options and save them, though this should be the job of GPGPreferences only.

Options are defined by a name, a state (active or not), and, optionally (sic), a value.

Some options (keyserver-options) can have sub-options too.


Symbolic Constants

Synopsis:

GPGOPTIONS_H  


Instance Variables

NSMutableArray *optionFileLines;
NSMutableArray *optionNames;
NSMutableArray *optionValues;
NSMutableArray *optionStates;
NSMutableArray *optionLineNumbers;
BOOL hasModifications;

optionFileLinesNo description.
optionNamesNo description.
optionValuesNo description.
optionStatesNo description.
optionLineNumbersNo description.
hasModificationsNo description.


Method Types

File locations
+ gpgPath
+ optionsFilename
GnuPG version
+ gnupgVersion
GnuPG home directory
+ homeDirectory
+ setHomeDirectory:
+ homeDirectoryChanged
HTTP proxy
+ httpProxy
+ setHttpProxy:
+ httpProxyChanged
Setting options
- setOptionValue:atIndex:
- setEmptyOptionValueAtIndex:
- setOptionName:atIndex:
- setOptionState:atIndex:
- addOptionNamed:
- insertOptionNamed:atIndex:
- removeOptionAtIndex:
- moveOptionsAtIndexes:toIndex:
Getting options
- optionNames
- optionValues
- optionStates
- optionValueForName:
- setOptionValue:forName:
- setEmptyOptionValueForName:
- optionStateForName:
- setOptionState:forName:
Sub-options
- subOptionState:forName:
- setSubOption:state:forName:
Loading and saving options
- reloadOptions
- saveOptions
Getting inactive and active options
- allOptionValuesForName:
- activeOptionValuesForName:


Class Methods

gnupgVersion

+ (NSString *)gnupgVersion

Returns current GnuPG version, or raises an exception when GnuPG executable cannot be found or returned an error.


gpgPath

+ (NSString *)gpgPath

Returns the expected location of GnuPG. Currently hardcoded to /usr/local/bin/gpg, due to libgpgme.


homeDirectory

+ (NSString *)homeDirectory

Returns the home directory used by GnuPG, as configured by user. Maybe user will need to logout and login to get it active, due to the use of environment variable GNUPGHOME.


homeDirectoryChanged

+ (BOOL)homeDirectoryChanged

Returns whether user changed GnuPG's home directory, i.e. +homeDirectory is equal or not to {+currentHomeDirectory}.


httpProxy

+ (NSString *)httpProxy

Returns the HTTP proxy used by GnuPG, when connecting to key servers. Maybe user will need to logout and login to get it active, due to the use of environment variable http_proxy.


httpProxyChanged

+ (BOOL)httpProxyChanged

Returns whether user changed GnuPG's HTTP proxy, i.e. +httpProxy is equal or not to +currentHttpProxy.


optionsFilename

+ (NSString *)optionsFilename

Returns the full path name to GnuPG configuration file. It depends on GnuPG version. If user changed GnuPG's home directory without logging out and in, returned value might be not yet valid.

Raises an exception when GnuPG version cannot be found out.


setHomeDirectory:

+ (void)setHomeDirectory:(NSString *)homeDirectory

Sets the home directory for GnuPG. Maybe user will need to logout and login to get it active, due to the use of environment variable GNUPGHOME.


setHttpProxy:

+ (void)setHttpProxy:(NSString *)httpProxy

Sets the HTTP proxy to be used by GnuPG, when connecting to key servers. Maybe user will need to logout and login to get it active, due to the use of environment variable http_proxy.


Instance Methods

activeOptionValuesForName:

- (NSArray *)activeOptionValuesForName:(NSString *)name

Returns all values set for this option name, providing that option is active. First value is the used value, in case no more than one value is considered by GnuPG.


addOptionNamed:

- (void)addOptionNamed:(NSString *)name

Adds a new option named name, not active, with an empty value.


allOptionValuesForName:

- (NSArray *)allOptionValuesForName:(NSString *)name


insertOptionNamed:atIndex:

- (void)insertOptionNamed:(NSString *)name atIndex:(unsigned)index


moveOptionsAtIndexes:toIndex:

- (unsigned)moveOptionsAtIndexes:(NSArray *)indexes toIndex:(unsigned)index

Reorders options at indexes to new index. Returns new index.


optionNames

- (NSArray *)optionNames

Returns all option names, active or not. The same option name can appear multiple times.


optionStateForName:

- (BOOL)optionStateForName:(NSString *)name


optionStates

- (NSArray *)optionStates

Returns all option states as an array of NSNumber instances (boolean values). There are as many option states as option names returned by -optionNames.


optionValueForName:

- (NSString *)optionValueForName:(NSString *)name

Returns the option value named name, used by GnuPG. In case of multiple occurences of the a named option, returns the used one. Note that option might be inactive!


optionValues

- (NSArray *)optionValues

Returns all option values, active or not. There are as many option values as option names returned by -optionNames.


reloadOptions

- (void)reloadOptions

Re-reads GnuPG's configuration file. If user changed GnuPG's home directory without logging out and in, options might be not yet active, and changes won't be taken in account before logging out and in.


removeOptionAtIndex:

- (void)removeOptionAtIndex:(unsigned)index


saveOptions

- (void)saveOptions

Save options by writing file back. Note that if user changed GnuPG's home directory without logging out and in, new options might be not yet valid.


setEmptyOptionValueAtIndex:

- (void)setEmptyOptionValueAtIndex:(unsigned)index


setEmptyOptionValueForName:

- (void)setEmptyOptionValueForName:(NSString *)name


setOptionName:atIndex:

- (void)setOptionName:(NSString *)name atIndex:(unsigned)index


setOptionState:atIndex:

- (void)setOptionState:(BOOL)flag atIndex:(unsigned)index


setOptionState:forName:

- (void)setOptionState:(BOOL)state forName:(NSString *)name


setOptionValue:atIndex:

- (void)setOptionValue:(NSString *)value atIndex:(unsigned)index


setOptionValue:forName:

- (void)setOptionValue:(NSString *)value forName:(NSString *)name


setSubOption:state:forName:

- (void)setSubOption:(NSString *)subOptionName state:(BOOL)state forName:(NSString *)optionName

Sets subOptionName sub-option's state, in option named optionName.


subOptionState:forName:

- (BOOL)subOptionState:(NSString *)subOptionName forName:(NSString *)optionName

Returns subOptionName sub-option's state, in option named optionName.


Version 1.1 Copyright ©2005 by Mac GPG Project. All Rights Reserved. Sun Jan 23 16:54:42 2005