Skip to content

Commit

Permalink
Hide KeePass built-in password profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Rookiestyle committed Feb 25, 2023
1 parent 773e8a5 commit 45798bb
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 26 deletions.
6 changes: 5 additions & 1 deletion Translations/PasswordChangeAssistant.de.language.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Increment the TranslationVersion every time the translation file is updated
Also update the version.info file
-->
<TranslationVersion>10</TranslationVersion>
<TranslationVersion>11</TranslationVersion>
<item>
<key>OldPW</key>
<value>Altes Passwort:</value>
Expand Down Expand Up @@ -133,4 +133,8 @@ Du kannst das jederzeit in den Einstellungen ändern.</value>
<key>AutotypeDelay</key>
<value>Auto-Type Verzögerung (Sekunden)</value>
</item>
<item>
<key>HideBuiltInProfiles</key>
<value>Eingebaute Passwortprofile verbergen</value>
</item>
</Translation>
4 changes: 4 additions & 0 deletions Translations/PasswordChangeAssistant.template.language.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,8 @@ You can change this in the plugin's options anytime.</value>
<key>AutotypeDelay</key>
<value>Auto-Type delay (seconds)</value>
</item>
<item>
<key>HideBuiltInProfiles</key>
<value>Hide built-in password profiles</value>
</item>
</Translation>
28 changes: 28 additions & 0 deletions src/PasswordChangeAssistant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public override bool Initialize(IPluginHost host)
Tools.OptionsFormClosed += OptionsFormClosed;
m_host.PwGeneratorPool.Add(new PwProfile1PerSet());

if (Config.HideBuiltInProfiles) HideBuiltInProfiles();

return true;
}

Expand Down Expand Up @@ -128,6 +130,25 @@ private void OnPwGeneratorFormShown(object sender, EventArgs e)
PwProfile1PerSet.EnablePwGeneratorControls(sender, e);
}

private void HideBuiltInProfiles()
{
PwGeneratorUtil.BuiltInProfiles.Clear();
}

private void RestoreBuiltInProfiles()
{
var t = KeePass.Program.MainForm.GetType().Assembly.GetTypes().FirstOrDefault(x => x.FullName.Contains("PwGeneratorUtil"));
if (t == null) return;
var m_lBuiltIn = t.GetField("m_lBuiltIn", BindingFlags.NonPublic | BindingFlags.Static);
if (m_lBuiltIn != null)
{
m_lBuiltIn.SetValue(null, null);
return;
}
var m_AllocStandardProfiles = t.GetMethod("AllocStandardProfiles", BindingFlags.NonPublic | BindingFlags.Static);
if (m_AllocStandardProfiles != null) m_AllocStandardProfiles.Invoke(null, null);
}

private void OnFormClosed(object sender, FormClosedEventArgs e)
{
if (sender is PwGeneratorForm)
Expand Down Expand Up @@ -717,6 +738,7 @@ private void OptionsFormShown(object sender, Tools.OptionsFormsEventArgs e)
form.SetHomeDB(m_host.Database);
form.cbOpenUrlForPwChange.Checked = Config.OpenUrlForPwChange;
form.nupAutotypeDelay.Value = Config.AutotypeDelay;
form.cbHideBuiltInProfiles.Checked = Config.HideBuiltInProfiles;
Tools.AddPluginToOptionsForm(this, form);
}

Expand All @@ -733,6 +755,12 @@ private void OptionsFormClosed(object sender, Tools.OptionsFormsEventArgs e)
form.GetWorklist(out profilesDB, out profilesOther, out otherDB, out MoveProfiles);
Config.OpenUrlForPwChange = form.cbOpenUrlForPwChange.Checked;
Config.AutotypeDelay = (int)form.nupAutotypeDelay.Value;
if (Config.HideBuiltInProfiles != form.cbHideBuiltInProfiles.Checked)
{
Config.HideBuiltInProfiles = form.cbHideBuiltInProfiles.Checked;
if (Config.HideBuiltInProfiles) HideBuiltInProfiles();
else RestoreBuiltInProfiles();
}
form.Dispose();

//Update password profiles in active database
Expand Down
4 changes: 4 additions & 0 deletions src/PluginTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ public static class PluginTranslate
/// Auto-Type delay (seconds)
/// </summary>
public static readonly string AutotypeDelay = @"Auto-Type delay (seconds)";
/// <summary>
/// Hide built-in password profiles
/// </summary>
public static readonly string HideBuiltInProfiles = @"Hide built-in password profiles";
#endregion

#region NO changes in this area
Expand Down
6 changes: 3 additions & 3 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("rookiestyle")]
[assembly: AssemblyProduct ("KeePass Plugin")]
[assembly: AssemblyCopyright("Copyright 2021-2022")]
[assembly: AssemblyCopyright("Copyright 2021-2023")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
// This sets the default COM visibility of types in the assembly to invisible.
Expand All @@ -24,6 +24,6 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("2.15.1")]
[assembly: AssemblyFileVersion("2.15.1")]
[assembly: AssemblyVersion("2.16")]
[assembly: AssemblyFileVersion("2.16")]
[assembly: Guid ("5d5cc62b-d6f6-4e0b-a7ff-3d5ef21dd656")]
83 changes: 63 additions & 20 deletions src/PwProfSyncForm.Designer.cs

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

9 changes: 9 additions & 0 deletions src/PwProfSyncForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ public PwProfSyncForm()
cbOpenUrlForPwChange.Text = PluginTranslate.OpenUrlForPwChange;
lOpenUrlForPwChangeShift.Text = PluginTranslate.OpenUrlForPwChangeShift;
lAutotypeDelay.Text = PluginTranslate.AutotypeDelay;

gHideBuildInProfiles.Text = "Password Generator";
string strTypeName = typeof(KeePass.Forms.PwGeneratorForm).FullName;
foreach (KeePassLib.Translation.KPFormCustomization kpfc in KeePass.Program.Translation.Forms)
{
if (kpfc.FullName != strTypeName) continue;
gHideBuildInProfiles.Text = kpfc.Window.Text;
}
cbHideBuiltInProfiles.Text = PluginTranslate.HideBuiltInProfiles;
}

public void SetHomeDB(PwDatabase db)
Expand Down
7 changes: 7 additions & 0 deletions src/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public static class Config
public const string ProfileAutoGenerated = "PPS.Auto";
public const string ProfileConfig = "PPS.";
private const string _OpenUrlForPwChange = "PPS.OpenUrlForPwChange";
private const string _HideBuiltInProfiles = "PCA.HideBuiltInProfiles";
private const string _AutotypeDelay = "PCA.AutotypeDelay";

public static Version KP_Version_2_50 = new Version(2, 50);
Expand All @@ -204,6 +205,12 @@ public static bool OpenUrlForPwChange
set { KeePass.Program.Config.CustomConfig.SetBool(_OpenUrlForPwChange, value); }
}

public static bool HideBuiltInProfiles
{
get { return KeePass.Program.Config.CustomConfig.GetBool(_HideBuiltInProfiles, true); }
set { KeePass.Program.Config.CustomConfig.SetBool(_HideBuiltInProfiles, value); }
}

public static int AutotypeDelay
{
//https://github.com/Rookiestyle/PasswordChangeAssistant/issues/16
Expand Down
4 changes: 2 additions & 2 deletions version.info
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:
PasswordChangeAssistant:2.15.1
PasswordChangeAssistant!de:10
PasswordChangeAssistant:2.16
PasswordChangeAssistant!de:11
PasswordChangeAssistant!it:3
PasswordChangeAssistant!pt:7
PasswordChangeAssistant!ru:6
Expand Down

0 comments on commit 45798bb

Please sign in to comment.