Skip to content

Commit

Permalink
Adds option to force using entry Title as key Comment
Browse files Browse the repository at this point in the history
  • Loading branch information
KuttKatrea committed Jan 4, 2024
1 parent cd00a4b commit fb208fe
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion KeeAgent/KeeAgentExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public sealed partial class KeeAgentExt : Plugin
pluginNamespace + ".UserPicksKeyOnRequestIdentities";
const string ignoreMissingExternalKeyFilesName = pluginNamespace + ".IgnoreMissingExternalKeyFilesName";
const string disableKeyDecryptionProgressBarName = pluginNamespace + ".DisableKeyDecryptionProgressBar";
const string useTitleAsComment = pluginNamespace + ".UseTitleAsComment";
const string keyFilePathSprPlaceholder = @"{KEEAGENT:KEYFILEPATH}";
const string identFileOptSprPlaceholder = @"{KEEAGENT:IDENTFILEOPT}";
const string groupMenuItemName = "KeeAgentGroupMenuItem";
Expand Down Expand Up @@ -646,6 +647,7 @@ private void LoadOptions()
config.GetBool(userPicksKeyOnRequestIdentitiesOptionName, false);
Options.IgnoreMissingExternalKeyFiles = config.GetBool(ignoreMissingExternalKeyFilesName, false);
Options.DisableKeyDecryptionProgressBar = config.GetBool(disableKeyDecryptionProgressBarName, false);
Options.UseTitleAsComment = config.GetBool(useTitleAsComment, false);

string defaultLogFileNameValue = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
Expand Down Expand Up @@ -1058,7 +1060,7 @@ private void SprEngine_FilterCompile(object sender, SprEventArgs e)
try {
var key = entry.GetSshKey(this.Options.DisableKeyDecryptionProgressBar);

if (String.IsNullOrEmpty(key.Comment)) {
if (Options.UseTitleAsComment || String.IsNullOrEmpty(key.Comment)) {
key.Comment = entry.Strings.GetSafe("Title").ReadString();
}

Expand Down
5 changes: 5 additions & 0 deletions KeeAgent/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,10 @@ public Options()
/// When <c>true</c>, we will not display a progress bar during SSH key decryption.
/// </summary>
public bool DisableKeyDecryptionProgressBar { get; set; }

/// <summary>
/// When <c>true</c>, use the entry's title as the key's comment.
/// </summary>
public static bool UseTitleAsComment { get; set; }
}
}
9 changes: 9 additions & 0 deletions 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 @@ -221,4 +221,7 @@
<data name="OptionUseWindowsOpenSshPipe" xml:space="preserve">
<value>Enable agent for Windows OpenSSH</value>
</data>
<data name="OptionUseTitleAsComment" xml:space="preserve">
<value>Use entry Title as key Comment</value>
</data>
</root>
3 changes: 3 additions & 0 deletions KeeAgent/UI/OptionsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public OptionsPanel(KeeAgentExt ext)
optionsList.CreateItem(ext.Options, "DisableKeyDecryptionProgressBar",
optionsGroup, Translatable.OptionDisableKeyDecryptionProgressBar);

optionsList.CreateItem(ext.Options, "UseTitleAsComment",
optionsGroup, Translatable.OptionUseTitleAsComment);

var agentModeOptionsGroup = new ListViewGroup("agentMode",
"Agent Mode Options (no effect in Client Mode)");
customListViewEx.Groups.Add(agentModeOptionsGroup);
Expand Down

0 comments on commit fb208fe

Please sign in to comment.