-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple otp datasets in Google Authenticator import
- Loading branch information
1 parent
29f34b0
commit 4d4dffc
Showing
11 changed files
with
316 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
142 changes: 142 additions & 0 deletions
142
src/GoogleAuthenticatorImport/GoogleAuthenticatorImportSelection.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
src/GoogleAuthenticatorImport/GoogleAuthenticatorImportSelection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using KeePass.Resources; | ||
using KeePassLib.Security; | ||
using PluginTranslation; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace KeePassOTP | ||
{ | ||
public partial class GoogleAuthenticatorImportSelection : Form | ||
{ | ||
private List<GoogleAuthenticatorImport.OtpParameters> m_Entries = null; | ||
public GoogleAuthenticatorImport.OtpParameters SelectedEntry | ||
{ | ||
get | ||
{ | ||
if (lvEntries.CheckedIndices.Count != 1) return null; | ||
return m_Entries[lvEntries.CheckedIndices[0]]; | ||
} | ||
} | ||
|
||
public GoogleAuthenticatorImportSelection() | ||
{ | ||
InitializeComponent(); | ||
|
||
Text = PluginTranslate.PluginName; | ||
bOK.Text = KPRes.Ok; | ||
bCancel.Text = KPRes.Cancel; | ||
lDesc.Text = PluginTranslate.SelectSingleEntry; | ||
chIssuer.Text = PluginTranslate.Issuer; | ||
chLabel.Text = KPRes.UserName; | ||
} | ||
|
||
public void InitEx(List<GoogleAuthenticatorImport.OtpParameters> lEntries) | ||
{ | ||
m_Entries = lEntries; | ||
lvEntries.Items.Clear(); | ||
foreach (var otp in m_Entries) | ||
{ | ||
ListViewItem lvi = new ListViewItem(); | ||
lvi.Text = otp.Issuer; | ||
string label = string.IsNullOrEmpty(otp.Issuer) ? otp.Name : otp.Name.Remove(0, otp.Issuer.Length + 1); | ||
lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, label)); | ||
lvEntries.Items.Add(lvi); | ||
} | ||
} | ||
|
||
private void lvEntries_ItemChecked(object sender, ItemCheckedEventArgs e) | ||
{ | ||
lvEntries.ItemChecked -= lvEntries_ItemChecked; | ||
foreach (ListViewItem lvi in lvEntries.Items) | ||
lvi.Checked = lvi.Index == e.Item.Index && e.Item.Checked; | ||
lvEntries.ItemChecked += lvEntries_ItemChecked; | ||
bOK.Enabled = lvEntries.CheckedItems.Count == 1; | ||
} | ||
|
||
private void GoogleAuthenticatorImportSelection_Shown(object sender, EventArgs e) | ||
{ | ||
chIssuer.Width = chLabel.Width = lvEntries.ClientSize.Width / 2; | ||
lvEntries.Items[0].Checked = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.