private void LoadOptions()
{
Options = new Options();
var config = pluginHost.CustomConfig;
Options.AlwaysConfirm = config.GetBool(alwaysConfirmOptionName, false);
Options.ShowBalloon = config.GetBool(showBalloonOptionName, true);
Options.LoggingEnabled = config.GetBool(logginEnabledOptionName, false);
Options.UnlockOnActivity = config.GetBool(unlockOnActivityOptionName, true);
Options.UseCygwinSocket = config.GetBool(useCygwinSocketOptionName, false);
Options.CygwinSocketPath = config.GetString(cygwinSocketPathOptionName);
Options.UseMsysSocket = config.GetBool(useMsysSocketOptionName, false);
Options.MsysSocketPath = config.GetString(msysSocketPathOptionName);
Options.UnixSocketPath = config.GetString(unixSocketPathOptionName);
Options.UserPicksKeyOnRequestIdentities =
config.GetBool(userPicksKeyOnRequestIdentitiesOptionName, false);
Options.IgnoreMissingExternalKeyFiles = config.GetBool(ignoreMissingExternalKeyFilesName, false);
string defaultLogFileNameValue = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"KeeAgent.log");
string configFileLogFileNameValue =
config.GetString(logFileNameOptionName);
if (string.IsNullOrEmpty(configFileLogFileNameValue)) {
Options.LogFileName = defaultLogFileNameValue;
} else {
Options.LogFileName = configFileLogFileNameValue;
}
AgentMode configAgentMode;
if (Enum.TryParse<AgentMode>(config.GetString(agentModeOptionName),
out configAgentMode)) {
Options.AgentMode = configAgentMode;
} else {
Options.AgentMode = AgentMode.Auto;
}
/* the Notification option is obsolete, so we read it and then clear it. */
NotificationOptions configFileNotificationValue;
if (Enum.TryParse<NotificationOptions>(config
.GetString(notificationOptionName), out configFileNotificationValue)) {
switch (configFileNotificationValue) {
case NotificationOptions.AlwaysAsk:
case NotificationOptions.AskOnce:
Options.AlwaysConfirm = true;
break;
case NotificationOptions.Never:
Options.ShowBalloon = false;
break;
}
config.SetString(notificationOptionName, string.Empty);
}
}