Skip to content

Commit

Permalink
Move UnlockOnActivity setting from database settings to global options.
Browse files Browse the repository at this point in the history
Fixes #62
  • Loading branch information
dlech committed Oct 23, 2013
1 parent 2789a17 commit 69e8ec7
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 103 deletions.
6 changes: 3 additions & 3 deletions KeeAgent/DatabaseSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses>

using System;

namespace KeeAgent
{
[Obsolete ("There are currently no database settings.")]
public class DatabaseSettings
{
public bool UnlockOnActivity { get; set; }

public DatabaseSettings()
{
UnlockOnActivity = true;
}
}
}
4 changes: 4 additions & 0 deletions KeeAgent/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ private static XmlSerializer DatabaseSettingsSerializer
get
{
if (mDatabaseSettingsSerializer == null) {
#pragma warning disable 618 // ignore use of obsolete type
mDatabaseSettingsSerializer = new XmlSerializer(typeof(DatabaseSettings));
#pragma warning restore 618
}
return mDatabaseSettingsSerializer;
}
}

[Obsolete ("There are currently no database settings.")]
public static DatabaseSettings GetKeeAgentSettings(this PwDatabase aDatabase)
{
var settingsString = aDatabase.CustomData.Get(cStringId);
Expand All @@ -78,6 +81,7 @@ public static DatabaseSettings GetKeeAgentSettings(this PwDatabase aDatabase)
return new DatabaseSettings();
}

[Obsolete ("There are currently no database settings.")]
public static void SetKeeAgentSettings(this PwDatabase aDatabase,
DatabaseSettings aSettings)
{
Expand Down
19 changes: 4 additions & 15 deletions KeeAgent/KeeAgentExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public sealed partial class KeeAgentExt : Plugin
private const string cLogginEnabledOptionName = cPluginNamespace + ".LoggingEnabled";
private const string cLogFileNameOptionName = cPluginNamespace + ".LogFileName";
private const string cAgentModeOptionName = cPluginNamespace + ".AgentMode";
private const string cUnlockOnActivityOptionName = cPluginNamespace + ".UnlockOnActivity";

public Options Options { get; private set; }

Expand Down Expand Up @@ -327,6 +328,7 @@ private void LoadOptions()
Options.AlwaysConfirm = config.GetBool(cAlwaysConfirmOptionName, false);
Options.ShowBalloon = config.GetBool(cShowBalloonOptionName, true);
Options.LoggingEnabled = config.GetBool(cLogginEnabledOptionName, false);
Options.UnlockOnActivity = config.GetBool (cUnlockOnActivityOptionName, true);

string defaultLogFileNameValue = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
Expand Down Expand Up @@ -397,18 +399,6 @@ private void WindowAddedHandler(object aSender,
pwEntryForm.FormClosing += PwEntryForm_FormClosing;
}

/* Add KeeAgent tab to Database Settings dialog */
var databaseSettingForm = aEventArgs.Form as DatabaseSettingsForm;
if (databaseSettingForm != null) {
databaseSettingForm.Shown +=
delegate(object sender, EventArgs args)
{
var dbSettingsPanel =
new DatabaseSettingsPanel(mPluginHost.MainWindow.ActiveDatabase);
databaseSettingForm.AddTab(dbSettingsPanel);
};
}

/* Add KeeAgent tab to Options dialog */
var optionsForm = aEventArgs.Form as OptionsForm;
if (optionsForm != null) {
Expand Down Expand Up @@ -560,12 +550,11 @@ private void Pageant_MessageReceived(object aSender,
if (thread.Join(1000)) {
mainWindow.Invoke((MethodInvoker)delegate()
{
foreach (var document in mainWindow.DocumentManager.Documents) {
if (Options.UnlockOnActivity) {
foreach (var document in mainWindow.DocumentManager.Documents) {
if (mainWindow.IsFileLocked(document)) {
if (document.Database.GetKeeAgentSettings().UnlockOnActivity) {
mainWindow.OpenDatabase(document.LockedIoc, null, false);
}
break;
}
}
});
Expand Down
5 changes: 5 additions & 0 deletions KeeAgent/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@ public Options()
/// Specifies which mode to run the agent in.
/// </summary>
public AgentMode AgentMode { get; set; }

/// <summary>
/// When true, all databases will be unlocked when an SSH key is requested (Agent mode only).
/// </summary>
public bool UnlockOnActivity { get; set; }
}
}
4 changes: 2 additions & 2 deletions KeeAgent/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion ("0.4.1.0")]
[assembly: AssemblyFileVersion ("0.4.1.0")]
[assembly: AssemblyVersion ("0.4.1.1")]
[assembly: AssemblyFileVersion ("0.4.1.1")]
11 changes: 10 additions & 1 deletion KeeAgent/Translatable.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions KeeAgent/Translatable.resx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@
<data name="OptionsMenuItem" xml:space="preserve">
<value>Options...</value>
</data>
<data name="OptionUnlockOnActivity" xml:space="preserve">
<value>Unlock all databases when a client sends a request</value>
</data>
<data name="StatusLocked" xml:space="preserve">
<value>KeeAgent is Locked</value>
</data>
Expand Down
85 changes: 36 additions & 49 deletions KeeAgent/UI/DatabaseSettingsPanel.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions KeeAgent/UI/DatabaseSettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

namespace KeeAgent.UI
{
[Obsolete ("There are currently no database settings.")]
public partial class DatabaseSettingsPanel : UserControl
{

Expand Down
36 changes: 3 additions & 33 deletions KeeAgent/UI/DatabaseSettingsPanel.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,45 +117,14 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="mUnlockOnAgentActivityCheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<metadata name="mDatabaseSettingsBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="mUnlockOnAgentActivityCheckBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="mUnlockOnAgentActivityCheckBox.Location" type="System.Drawing.Point, System.Drawing">
<value>9, 22</value>
</data>
<data name="mUnlockOnAgentActivityCheckBox.Size" type="System.Drawing.Size, System.Drawing">
<value>219, 17</value>
</data>
<data name="mUnlockOnAgentActivityCheckBox.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="mUnlockOnAgentActivityCheckBox.Text" xml:space="preserve">
<value>Unlock Database On SSH Agent Activity</value>
</data>
<data name="&gt;&gt;mUnlockOnAgentActivityCheckBox.Name" xml:space="preserve">
<value>mUnlockOnAgentActivityCheckBox</value>
</data>
<data name="&gt;&gt;mUnlockOnAgentActivityCheckBox.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;mUnlockOnAgentActivityCheckBox.Parent" xml:space="preserve">
<value>mAgentModeGroupBox</value>
</data>
<data name="&gt;&gt;mUnlockOnAgentActivityCheckBox.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="mAgentModeGroupBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="mAgentModeGroupBox.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 6</value>
</data>
Expand All @@ -165,6 +134,7 @@
<data name="mAgentModeGroupBox.Size" type="System.Drawing.Size, System.Drawing">
<value>455, 53</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="mAgentModeGroupBox.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
Expand All @@ -175,7 +145,7 @@
<value>mAgentModeGroupBox</value>
</data>
<data name="&gt;&gt;mAgentModeGroupBox.Type" xml:space="preserve">
<value>KeeAgent.UI.GroupBoxEx, KeeAgent, Version=0.3.10.0, Culture=neutral, PublicKeyToken=null</value>
<value>KeeAgent.UI.GroupBoxEx, KeeAgent, Version=0.4.1.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;mAgentModeGroupBox.Parent" xml:space="preserve">
<value>$this</value>
Expand Down
2 changes: 2 additions & 0 deletions KeeAgent/UI/OptionsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public OptionsPanel(KeeAgentExt aExt)
Translatable.OptionShowBalloon);
//mOptionsList.CreateItem(aExt.Options, "LoggingEnabled", optionsGroup,
// Translatable.optionLoggingEnabled);
mOptionsList.CreateItem (aExt.Options, "UnlockOnActivity", agentModeOptionsGroup,
Translatable.OptionUnlockOnActivity);
columnHeader.Width = customListViewEx.ClientRectangle.Width -
UIUtil.GetVScrollBarWidth() - 1;
mOptionsList.UpdateData(false);
Expand Down

0 comments on commit 69e8ec7

Please sign in to comment.