diff --git a/KeePassHttp.plgx b/KeePassHttp.plgx deleted file mode 100644 index 65d1352..0000000 Binary files a/KeePassHttp.plgx and /dev/null differ diff --git a/KeePassHttp/ConfigOpt.cs b/KeePassHttp/ConfigOpt.cs index 2ff8a22..1645f00 100644 --- a/KeePassHttp/ConfigOpt.cs +++ b/KeePassHttp/ConfigOpt.cs @@ -11,6 +11,7 @@ public class ConfigOpt const string AlwaysAllowAccessKey = "KeePassHttp_AlwaysAllowAccess"; const string AlwaysAllowUpdatesKey = "KeePassHttp_AlwaysAllowUpdates"; const string SearchInAllOpenedDatabasesKey = "KeePassHttp_SearchInAllOpenedDatabases"; + const string HideExpiredKey = "KeePassHttp_HideExpired"; const string MatchSchemesKey = "KeePassHttp_MatchSchemes"; const string ReturnStringFieldsKey = "KeePassHttp_ReturnStringFields"; const string ReturnStringFieldsWithKphOnlyKey = "KeePassHttp_ReturnStringFieldsWithKphOnly"; @@ -59,6 +60,11 @@ public bool SearchInAllOpenedDatabases set { _config.SetBool(SearchInAllOpenedDatabasesKey, value); } } + public bool HideExpired + { + get { return _config.GetBool(HideExpiredKey, false); } + set { _config.SetBool(HideExpiredKey, value); } + } public bool MatchSchemes { get { return _config.GetBool(MatchSchemesKey, false); } diff --git a/KeePassHttp/Handlers.cs b/KeePassHttp/Handlers.cs index 7983483..164c329 100644 --- a/KeePassHttp/Handlers.cs +++ b/KeePassHttp/Handlers.cs @@ -234,6 +234,23 @@ private IEnumerable FindMatchingEntries(Request r, Aes aes) result = from e in result where filterSchemes(e.entry) select e; } + Func hideExpired = delegate(PwEntry e) + { + DateTime dtNow = DateTime.UtcNow; + + if(e.Expires && (e.ExpiryTime <= dtNow)) + { + return false; + } + + return true; + }; + + if (configOpt.HideExpired) + { + result = from e in result where hideExpired(e.entry) select e; + } + return result; } diff --git a/KeePassHttp/OptionsForm.Designer.cs b/KeePassHttp/OptionsForm.Designer.cs index e5a8f0d..435b62a 100644 --- a/KeePassHttp/OptionsForm.Designer.cs +++ b/KeePassHttp/OptionsForm.Designer.cs @@ -34,6 +34,7 @@ private void InitializeComponent() this.tabPage1 = new System.Windows.Forms.TabPage(); this.SortByUsernameRadioButton = new System.Windows.Forms.RadioButton(); this.SortByTitleRadioButton = new System.Windows.Forms.RadioButton(); + this.hideExpiredCheckbox = new System.Windows.Forms.CheckBox(); this.matchSchemesCheckbox = new System.Windows.Forms.CheckBox(); this.removePermissionsButton = new System.Windows.Forms.Button(); this.unlockDatabaseCheckbox = new System.Windows.Forms.CheckBox(); @@ -105,6 +106,7 @@ private void InitializeComponent() // this.tabPage1.Controls.Add(this.SortByUsernameRadioButton); this.tabPage1.Controls.Add(this.SortByTitleRadioButton); + this.tabPage1.Controls.Add(this.hideExpiredCheckbox); this.tabPage1.Controls.Add(this.matchSchemesCheckbox); this.tabPage1.Controls.Add(this.removePermissionsButton); this.tabPage1.Controls.Add(this.unlockDatabaseCheckbox); @@ -122,7 +124,7 @@ private void InitializeComponent() // SortByUsernameRadioButton // this.SortByUsernameRadioButton.AutoSize = true; - this.SortByUsernameRadioButton.Location = new System.Drawing.Point(7, 124); + this.SortByUsernameRadioButton.Location = new System.Drawing.Point(7, 147); this.SortByUsernameRadioButton.Name = "SortByUsernameRadioButton"; this.SortByUsernameRadioButton.Size = new System.Drawing.Size(171, 17); this.SortByUsernameRadioButton.TabIndex = 19; @@ -133,18 +135,28 @@ private void InitializeComponent() // SortByTitleRadioButton // this.SortByTitleRadioButton.AutoSize = true; - this.SortByTitleRadioButton.Location = new System.Drawing.Point(7, 147); + this.SortByTitleRadioButton.Location = new System.Drawing.Point(7, 170); this.SortByTitleRadioButton.Name = "SortByTitleRadioButton"; this.SortByTitleRadioButton.Size = new System.Drawing.Size(141, 17); this.SortByTitleRadioButton.TabIndex = 18; this.SortByTitleRadioButton.TabStop = true; this.SortByTitleRadioButton.Text = "Sort found entries by &title"; this.SortByTitleRadioButton.UseVisualStyleBackColor = true; - // + // + // hideExpiredCheckbox + // + this.hideExpiredCheckbox.AutoSize = true; + this.hideExpiredCheckbox.Location = new System.Drawing.Point(7, 88); + this.hideExpiredCheckbox.Name = "hideExpiredCheckbox"; + this.hideExpiredCheckbox.Size = new System.Drawing.Size(256, 17); + this.hideExpiredCheckbox.TabIndex = 17; + this.hideExpiredCheckbox.Text = "Don't return e&xpired entries"; + this.hideExpiredCheckbox.UseVisualStyleBackColor = true; + // // matchSchemesCheckbox - // + // this.matchSchemesCheckbox.AutoSize = true; - this.matchSchemesCheckbox.Location = new System.Drawing.Point(7, 88); + this.matchSchemesCheckbox.Location = new System.Drawing.Point(7, 111); this.matchSchemesCheckbox.Name = "matchSchemesCheckbox"; this.matchSchemesCheckbox.Size = new System.Drawing.Size(375, 30); this.matchSchemesCheckbox.TabIndex = 17; @@ -157,7 +169,7 @@ private void InitializeComponent() this.removePermissionsButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.removePermissionsButton.ImageAlign = System.Drawing.ContentAlignment.TopLeft; - this.removePermissionsButton.Location = new System.Drawing.Point(14, 216); + this.removePermissionsButton.Location = new System.Drawing.Point(14, 239); this.removePermissionsButton.Name = "removePermissionsButton"; this.removePermissionsButton.Size = new System.Drawing.Size(372, 28); this.removePermissionsButton.TabIndex = 16; @@ -179,7 +191,7 @@ private void InitializeComponent() // this.removeButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.removeButton.Location = new System.Drawing.Point(14, 182); + this.removeButton.Location = new System.Drawing.Point(14, 205); this.removeButton.Name = "removeButton"; this.removeButton.Size = new System.Drawing.Size(372, 28); this.removeButton.TabIndex = 11; @@ -451,6 +463,7 @@ private void InitializeComponent() private System.Windows.Forms.Button okButton; private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.CheckBox hideExpiredCheckbox; private System.Windows.Forms.CheckBox matchSchemesCheckbox; private System.Windows.Forms.Button removePermissionsButton; private System.Windows.Forms.CheckBox unlockDatabaseCheckbox; diff --git a/KeePassHttp/OptionsForm.cs b/KeePassHttp/OptionsForm.cs index 171601a..b227650 100644 --- a/KeePassHttp/OptionsForm.cs +++ b/KeePassHttp/OptionsForm.cs @@ -41,6 +41,7 @@ private void OptionsForm_Load(object sender, EventArgs e) credAllowAccessCheckbox.Checked = _config.AlwaysAllowAccess; credAllowUpdatesCheckbox.Checked = _config.AlwaysAllowUpdates; credSearchInAllOpenedDatabases.Checked = _config.SearchInAllOpenedDatabases; + hideExpiredCheckbox.Checked = _config.HideExpired; matchSchemesCheckbox.Checked = _config.MatchSchemes; returnStringFieldsCheckbox.Checked = _config.ReturnStringFields; returnStringFieldsWithKphOnlyCheckBox.Checked = _config.ReturnStringFieldsWithKphOnly; @@ -60,6 +61,7 @@ private void okButton_Click(object sender, EventArgs e) _config.AlwaysAllowAccess = credAllowAccessCheckbox.Checked; _config.AlwaysAllowUpdates = credAllowUpdatesCheckbox.Checked; _config.SearchInAllOpenedDatabases = credSearchInAllOpenedDatabases.Checked; + _config.HideExpired = hideExpiredCheckbox.Checked; _config.MatchSchemes = matchSchemesCheckbox.Checked; _config.ReturnStringFields = returnStringFieldsCheckbox.Checked; _config.ReturnStringFieldsWithKphOnly = returnStringFieldsWithKphOnlyCheckBox.Checked;