Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #401 from d3agle/master
Browse files Browse the repository at this point in the history
Improved PW Recovery user notification of no results + redundancy
  • Loading branch information
MaxXor committed Sep 20, 2015
2 parents 7f4cab6 + 1164f19 commit c71acd1
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions Server/Forms/FrmPasswordRecovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public partial class FrmPasswordRecovery : Form
{
private readonly Client[] _clients;
private readonly object _addingLock = new object();
private readonly RecoveredAccount _noResultsFound;

public FrmPasswordRecovery(Client[] connectedClients)
{
Expand All @@ -25,9 +26,17 @@ public FrmPasswordRecovery(Client[] connectedClients)
}

InitializeComponent();
this.Text = WindowHelper.GetWindowTitle("Password Recovery", _clients.Length);
Text = WindowHelper.GetWindowTitle("Password Recovery", _clients.Length);

txtFormat.Text = Settings.SaveFormat;

_noResultsFound = new RecoveredAccount()
{
Application = "No Results Found",
URL = "N/A",
Username = "N/A",
Password = "N/A"
};
}

private void FrmPasswordRecovery_Load(object sender, EventArgs e)
Expand Down Expand Up @@ -76,7 +85,7 @@ public void AddPasswords(RecoveredAccount[] accounts, string identification)
if (lvg == null) //Create new group
{
lvg = new ListViewGroup { Name = acc.Application.Replace(" ", string.Empty), Header = acc.Application };
this.Invoke(new MethodInvoker(() => lstPasswords.Groups.Add(lvg))); //Add the new group
Invoke(new MethodInvoker(() => lstPasswords.Groups.Add(lvg))); //Add the new group
}

lvi.Group = lvg;
Expand All @@ -87,8 +96,25 @@ public void AddPasswords(RecoveredAccount[] accounts, string identification)
UpdateRecoveryCount();
}

if (accounts.Length == 0)
MessageBox.Show("Could not recover anything!", "Password Recovery", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (accounts.Length == 0) //No accounts found
{
var lvi = new ListViewItem { Tag = _noResultsFound, Text = identification };

lvi.SubItems.Add(_noResultsFound.URL); // URL
lvi.SubItems.Add(_noResultsFound.Username); // User
lvi.SubItems.Add(_noResultsFound.Password); // Pass

var lvg = GetGroupFromApplication(_noResultsFound.Application);

if (lvg == null) //Create new group
{
lvg = new ListViewGroup { Name = _noResultsFound.Application, Header = _noResultsFound.Application };
Invoke(new MethodInvoker(() => lstPasswords.Groups.Add(lvg))); //Add the new group
}

lvi.Group = lvg;
Invoke(new MethodInvoker(() => { lstPasswords.Items.Add(lvi); }));
}
}
catch
{
Expand Down Expand Up @@ -139,7 +165,7 @@ private StringBuilder GetLoginData(bool selected = false)
private ListViewGroup GetGroupFromApplication(string app)
{
ListViewGroup lvg = null;
this.Invoke(new MethodInvoker(delegate
Invoke(new MethodInvoker(delegate
{
foreach (var @group in lstPasswords.Groups.Cast<ListViewGroup>().Where(@group => @group.Header == app))
{
Expand Down

0 comments on commit c71acd1

Please sign in to comment.