private PluginConfig(AceCustomConfig customConfig) { IsConfigured = new BooleanEntry(Constantes.OptionIsConfigured, false, customConfig); IsEnabled = new BooleanEntry(Constantes.OptionIsEnabled, true, customConfig); DatabaseLocation = new ProtectedStringEntry(Constantes.OptionDatabse, "", customConfig); Password = new ProtectedStringEntry(Constantes.OptionPassword, "", customConfig); }
private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); this.Text = IopDefs.ProductName + " Options"; AceCustomConfig cfg = IOProtocolExtExt.Host.CustomConfig; ulong uTimeout = cfg.GetULong(IopDefs.OptTimeout, 0); m_cbTimeout.Checked = (uTimeout > 0); if (uTimeout > 0) { try { m_numTimeout.Value = uTimeout; } catch (Exception) { Debug.Assert(false); } } m_cbFtpsImplicit.Checked = cfg.GetBool(IopDefs.OptFtpsImplicit, false); m_cbFtpsExplicitSsl.Checked = cfg.GetBool(IopDefs.OptFtpsExplicitSsl, false); m_cbFtpsExplicitTls.Checked = cfg.GetBool(IopDefs.OptFtpsExplicitTls, false); m_tbPrivateKey.Text = cfg.GetString(IopDefs.OptSshPrivateKey, ""); EnableControlsEx(); }
private void OnBtnOK(object sender, EventArgs e) { AceCustomConfig cfg = IOProtocolExtExt.Host.CustomConfig; cfg.SetULong(IopDefs.OptTimeout, (m_cbTimeout.Checked ? (ulong)m_numTimeout.Value : 0UL)); CfgSetBool(cfg, IopDefs.OptFtpsImplicit, m_cbFtpsImplicit.Checked, false); CfgSetBool(cfg, IopDefs.OptFtpsExplicitSsl, m_cbFtpsExplicitSsl.Checked, false); CfgSetBool(cfg, IopDefs.OptFtpsExplicitTls, m_cbFtpsExplicitTls.Checked, false); }
public void Initialize(AceCustomConfig customConfig) { if (customConfig == null) throw new ArgumentNullException("customConfig"); if (_customConfig != null) throw new InvalidOperationException("Settings have initialized already"); _customConfig = customConfig; UpgradeConfig(); }
/// <summary>An AceCustomConfig extension method that gets an enum.</summary> /// <typeparam name="T">Generic enum parameter.</typeparam> /// <param name="config">The AceCustomConfig instance to act on.</param> /// <param name="strID">The key identifier.</param> /// <param name="eDefault">The default value.</param> /// <returns>The enum value.</returns> public static T GetEnum<T>(this AceCustomConfig config, string strID, T eDefault) where T : struct, IConvertible { Contract.Requires(typeof(T).IsEnum); var value = config.GetLong(strID, -1); if (value == -1) { return eDefault; } return (T)(object)(int)value; }
private static void CfgSetBool(AceCustomConfig cfg, string strKey, bool bValue, bool bDefault) { if (bValue != bDefault) { cfg.SetBool(strKey, bValue); } else { try { cfg.SetString(strKey, null); } catch (Exception) { Debug.Assert(false); cfg.SetBool(strKey, bValue); } } }
public Configuration(AceCustomConfig config) { _config = config; if (_config.GetString(KeyIdName, null) != null) { return; } _config.SetString(KeyIdName, ""); _config.SetString(ApplicationKeyName, ""); _config.SetBool(SyncOnSaveName, false); _config.SetBool(SyncOnLoadName, false); }
private static KeeTrayTOTPExt CreatePluginHostMock(out Mock <IPluginHost> host) { var plugin = new KeeTrayTOTPExt(); host = new Mock <IPluginHost>(MockBehavior.Strict); var keepassForm = new MainForm(); host.SetupGet(c => c.MainWindow).Returns(keepassForm); var customConfig = new AceCustomConfig(); host.SetupGet(c => c.CustomConfig).Returns(customConfig); var columnProviderPool = new ColumnProviderPool(); host.SetupGet(c => c.ColumnProviderPool).Returns(columnProviderPool); return(plugin); }
private static (KeeTrayTOTPExt, IPluginHost) CreateInitializedPlugin() { var plugin = new KeeTrayTOTPExt(); var pluginHost = new Mock <IPluginHost>(MockBehavior.Strict); var keepassForm = new MainForm(); pluginHost.SetupGet(c => c.MainWindow).Returns(keepassForm); var customConfig = new AceCustomConfig(); pluginHost.SetupGet(c => c.CustomConfig).Returns(customConfig); var columnProviderPool = new ColumnProviderPool(); pluginHost.SetupGet(c => c.ColumnProviderPool).Returns(columnProviderPool); plugin.Initialize(pluginHost.Object); return(plugin, pluginHost.Object); }
private static string AddCommonOpenOptions(string strOpenCmd, string strSessionUrl) { if (string.IsNullOrEmpty(strOpenCmd)) { return(strOpenCmd); } if (strSessionUrl == null) { Debug.Assert(false); return(strOpenCmd); } AceCustomConfig cfg = IOProtocolExtExt.Host.CustomConfig; string str = strOpenCmd; ulong uTimeout = cfg.GetULong(IopDefs.OptTimeout, 0); if (uTimeout > 0) { str += (" -timeout=" + uTimeout.ToString()); } if (strSessionUrl.StartsWith("ftps:", StrUtil.CaseIgnoreCmp)) { if (cfg.GetBool(IopDefs.OptFtpsImplicit, false)) { str += " -implicit"; } if (cfg.GetBool(IopDefs.OptFtpsExplicitSsl, false)) { str += " -explicitssl"; } if (cfg.GetBool(IopDefs.OptFtpsExplicitTls, false)) { str += " -explicittls"; } } return(str); }
public Config(AceCustomConfig config) { _config = config; }
private string AddCommonOpenOptions(string strOpenCmd, string strSessionUrl) { if (string.IsNullOrEmpty(strOpenCmd)) { return(strOpenCmd); } if (strSessionUrl == null) { Debug.Assert(false); return(strOpenCmd); } AceCustomConfig cfg = IOProtocolExtExt.Host.CustomConfig; string str = strOpenCmd; ulong uTimeout = cfg.GetULong(IopDefs.OptTimeout, 0); if (uTimeout > 0) { str += (" -timeout=" + uTimeout.ToString()); } if (strSessionUrl.StartsWith("ftps:", StrUtil.CaseIgnoreCmp)) { if (cfg.GetBool(IopDefs.OptFtpsImplicit, false)) { str += " -implicit"; } if (cfg.GetBool(IopDefs.OptFtpsExplicitSsl, false)) { str += " -explicitssl"; } if (cfg.GetBool(IopDefs.OptFtpsExplicitTls, false)) { str += " -explicittls"; } } if (strSessionUrl.StartsWith("scp:", StrUtil.CaseIgnoreCmp)) { string strPrivateKey = cfg.GetString(IopDefs.OptSshPrivateKey, ""); if (!string.IsNullOrEmpty(strPrivateKey)) { str += " -privatekey=" + strPrivateKey; } } // if(!string.IsNullOrEmpty(strHostKey)) // str += " -hostkey=\"" + strHostKey + "\""; str += " -hostkey=*"; string strRawCfg = string.Empty; try { Uri uriProxy = GetProxyUri(strSessionUrl, false); if (uriProxy == null) { uriProxy = GetProxyUri(strSessionUrl, true); } if (uriProxy != null) { strRawCfg += " ProxyMethod=3"; if (!string.IsNullOrEmpty(uriProxy.Host)) { strRawCfg += " ProxyHost=" + EncodeParam(uriProxy.Host); } if (uriProxy.Port > 0) { strRawCfg += " ProxyPort=" + uriProxy.Port.ToString(); } string strPrxUserName = null, strPrxPassword = null; ICredentials iCred = m_prx.Credentials; NetworkCredential nc = (iCred as NetworkCredential); if ((nc == null) && (iCred != null)) { nc = iCred.GetCredential(uriProxy, "Basic"); } if (nc != null) { strPrxUserName = nc.UserName; strPrxPassword = nc.Password; } if (!string.IsNullOrEmpty(strPrxUserName)) { strRawCfg += " ProxyUsername="******" ProxyPassword="******" ProxyMethod=3"; if (!string.IsNullOrEmpty(strPrxHost)) { strRawCfg += " ProxyHost=" + EncodeParam(strPrxHost); } if (!string.IsNullOrEmpty(strPrxPort)) { strRawCfg += " ProxyPort=" + EncodeParam(strPrxPort); } if (!string.IsNullOrEmpty(strPrxUserName)) { strRawCfg += " ProxyUsername="******" ProxyPassword="******" -rawsettings " + strRawCfg; } return(str); }
public Configuration(AceCustomConfig aceCustomConfig) { config = aceCustomConfig; }
public AbstractConfigEntry(string ID, T defaultValue, AceCustomConfig customConfig) { _ID = MakeUserConfigID(ID); _defaultValue = defaultValue; _customConfig = customConfig; }
/// <summary>An AceCustomConfig extension method that sets an enum.</summary> /// <typeparam name="T">Generic enum parameter.</typeparam> /// <param name="config">The AceCustomConfig instance to act on.</param> /// <param name="strID">The key identifier.</param> /// <param name="eValue">The value.</param> public static void SetEnum <T>(this AceCustomConfig config, string strID, T eValue) where T : struct, IConvertible { Contract.Requires(typeof(T).IsEnum); config.SetLong(strID, (int)(object)eValue); }
public ProtectedStringEntry(string strID, string defaultValue, AceCustomConfig customConfig) : base(strID, defaultValue, customConfig) { }
//--------------------------------------------------------------------------------------------------- // Class Constructors //--------------------------------------------------------------------------------------------------- public SAPLogonOpt(AceCustomConfig config) { m_config = config; }
public PCRConfig(IPluginHost host) { m_config = host.CustomConfig; }
public AppConfig(AceCustomConfig appConfig) { aceCustomConfig = appConfig; }
public static void SetCurrentTransliterationName(this AceCustomConfig customConfig, string name) { customConfig.SetString("CurrentTransliteration", name); }
public BooleanEntry(string strID, bool defaultValue, AceCustomConfig customConfig) : base(strID, defaultValue, customConfig) { }
static Config() { m_conf = KeePass.Program.Config.CustomConfig; }
public Settings(AceCustomConfig keepassCustomConfig) { this._keePassCustomConfig = keepassCustomConfig; }
public KP2faC_Config(IPluginHost host) { m_config = host.CustomConfig; }
public static PluginConfig Init(AceCustomConfig customConfig) { Instance = new PluginConfig(customConfig); return(Instance); }
public KPCIDConfig(IPluginHost host) { m_config = host.CustomConfig; }
public PreferencesAdapter(AceCustomConfig config) { Config = config; }
public KPSimpleBackupConfig(AceCustomConfig customConfig) { this.customConfig = customConfig; }
public static string GetCurrentTransliterationName(this AceCustomConfig customConfig, string defaultValue = "") { return(customConfig.GetString("CurrentTransliteration", defaultValue)); }