private void KeeFoxEntryUserControl_Load(object sender, EventArgs e) { bool kfNeverAutoFill = false; bool kfAlwaysAutoFill = false; bool kfNeverAutoSubmit = false; bool kfAlwaysAutoSubmit = false; this.checkBoxHideFromKeeFox.CheckedChanged += new System.EventHandler(this.checkBoxHideFromKeeFox_CheckedChanged); this.checkBoxBlockHostnameOnly.CheckedChanged += new System.EventHandler(this.checkBoxBlockHostnameOnly_CheckedChanged); foreach (ListViewItem existingLi in _advancedListView.Items) { if (existingLi.Text == "Hide from KeeFox" || existingLi.Text == "Hide from KPRPC") { removeAdvancedString("Hide from KeeFox"); checkBoxHideFromKeeFox.Checked = true; } else if (existingLi.Text == "KPRPC Block hostname-only match") { checkBoxBlockHostnameOnly.Checked = true; } else if (existingLi.Text == "KeeFox Never Auto Fill" || existingLi.Text == "KPRPC Never Auto Fill") { kfNeverAutoFill = true; } else if (existingLi.Text == "KeeFox Always Auto Fill" || existingLi.Text == "KPRPC Always Auto Fill") { kfAlwaysAutoFill = true; } else if (existingLi.Text == "KeeFox Never Auto Submit" || existingLi.Text == "KPRPC Never Auto Submit") { kfNeverAutoSubmit = true; } else if (existingLi.Text == "KeeFox Always Auto Submit" || existingLi.Text == "KPRPC Always Auto Submit") { kfAlwaysAutoSubmit = true; } else if ((existingLi.Text.StartsWith("Form field ") || existingLi.Text.StartsWith("KPRPC Form field ")) && existingLi.Text.EndsWith("type")) { string name = null; // extract name if (existingLi.Text.StartsWith("Form field ")) name = existingLi.Text.Substring(11,existingLi.Text.Length-16); else if (existingLi.Text.StartsWith("KPRPC Form field ")) name = existingLi.Text.Substring(17, existingLi.Text.Length - 22); string displayName = name; string type = existingLi.SubItems[1].Text; FormFieldType fft = Utilities.FormFieldTypeFromDisplay(type); string value = null; string id = null; int page = 1; // Grrrrr... can't find any way to request specific list item! //TODO2: cache a better data structure than .NET provides to speed up handling of many form fields foreach (ListViewItem internalLi in _advancedListView.Items) { if (internalLi.Text == "KPRPC Form field " + name + " value") value = internalLi.SubItems[1].Text; if (value == null && internalLi.Text == "Form field " + name + " value") value = internalLi.SubItems[1].Text; if (internalLi.Text == "KPRPC Form field " + name + " id") id = internalLi.SubItems[1].Text; if (id == null && internalLi.Text == "Form field " + name + " id") id = internalLi.SubItems[1].Text; if (internalLi.Text == "KPRPC Form field " + name + " page") page = int.Parse(internalLi.SubItems[1].Text); if (internalLi.Text == "Form field " + name + " page") page = int.Parse(internalLi.SubItems[1].Text); } // if value not found it's probably a standard KeePass data field if (value == null && fft == FormFieldType.FFTusername) displayName = "KeePass username"; else if (value == null && fft == FormFieldType.FFTpassword) displayName = "KeePass password"; fields.Add(name, new FormField(name, displayName, value, fft, id, page)); } else if (existingLi.Text == "KeeFox Priority" || existingLi.Text == "KPRPC Priority") { if (existingLi.Text == "KeeFox Priority") { changeAdvancedString("KPRPC Priority", existingLi.SubItems[1].Text, false); removeAdvancedString("KeeFox Priority"); } textBoxKeeFoxPriority.Text = existingLi.SubItems[1].Text; } else if (existingLi.Text == "KPRPC Alternative URLs" || existingLi.Text == "Alternative URLs") { foreach (string url in existingLi.SubItems[1].Text.Split(' ')) listNormalURLs.Add(url); if (existingLi.Text == "Alternative URLs") { changeAdvancedString("KPRPC Alternative URLs", existingLi.SubItems[1].Text, false); removeAdvancedString("Alternative URLs"); } } else if (existingLi.Text == "KPRPC Blocked URLs") { foreach (string url in existingLi.SubItems[1].Text.Split(' ')) listNormalBlockedURLs.Add(url); } else if (existingLi.Text == "KPRPC URL Regex match") { foreach (string url in existingLi.SubItems[1].Text.Split(' ')) listRegExURLs.Add(url); } else if (existingLi.Text == "KPRPC URL Regex block") { foreach (string url in existingLi.SubItems[1].Text.Split(' ')) listRegExBlockedURLs.Add(url); } else if (existingLi.Text == "Form HTTP realm" || existingLi.Text == "KPRPC HTTP realm" || existingLi.Text == "KPRPC form HTTP realm") { if (existingLi.Text == "Form HTTP realm") { changeAdvancedString("KPRPC HTTP realm", existingLi.SubItems[1].Text, false); removeAdvancedString("Form HTTP realm"); } if (existingLi.Text == "KPRPC form HTTP realm") { changeAdvancedString("KPRPC HTTP realm", existingLi.SubItems[1].Text, false); removeAdvancedString("KPRPC form HTTP realm"); } textBoxKeeFoxRealm.Text = existingLi.SubItems[1].Text; } } // find password... how? have to look through all fields again for ones with no value? likewise for username though could use FFTPusername type for that... bool standardPasswordFound = false; bool standardUsernameFound = false; foreach (FormField f in fields.Values) { string type = Utilities.FormFieldTypeToDisplay(f.Type, false); string value = f.Value; if (f.DisplayName == "KeePass username") { standardUsernameFound = true; value = f.DisplayName; } if (f.DisplayName == "KeePass password") { standardPasswordFound = true; value = f.DisplayName; } ListViewItem lvi = new ListViewItem(new string[] { f.Name, value, f.Id, type, f.Page.ToString() }); AddFieldListItem(lvi); } // if we didn't find specific details about the username and // password, we'll pre-populate the standard KeePass ones so // users can easily change thigns like page number and ID // we don't add them to the list of actual fields though - just the display list. if (!standardPasswordFound) { ListViewItem lvi = new ListViewItem(new string[] { "UNSPECIFIED password", "KeePass password", "UNSPECIFIED password id", "password", "1" }); AddFieldListItem(lvi); } if (!standardUsernameFound) { ListViewItem lvi = new ListViewItem(new string[] { "UNSPECIFIED username", "KeePass username", "UNSPECIFIED username id", "username", "1" }); AddFieldListItem(lvi); } ReadURLStrings(); comboBoxAutoSubmit.Text = "Use KeeFox setting"; comboBoxAutoFill.Text = "Use KeeFox setting"; // doesn't make sense for some of these values to co-exist so we'll tidy up while working out what we should default the GUI options to. // There are also implicit behaviours based on single option choices so we'll make them explicit now so that the GUI accurately reflects the // strings stored in the advanced tab if (kfNeverAutoFill) { currentBehaviour = EntryBehaviour.NeverAutoFillNeverAutoSubmit; } else if (kfAlwaysAutoSubmit) { currentBehaviour = EntryBehaviour.AlwaysAutoFillAlwaysAutoSubmit; } else if (kfAlwaysAutoFill && kfNeverAutoSubmit) { currentBehaviour = EntryBehaviour.AlwaysAutoFillNeverAutoSubmit; } else if (kfNeverAutoSubmit) { currentBehaviour = EntryBehaviour.NeverAutoSubmit; } else if (kfAlwaysAutoFill) { currentBehaviour = EntryBehaviour.AlwaysAutoFill; } else { currentBehaviour = EntryBehaviour.Default; } changeBehaviourState(currentBehaviour); this.comboBoxAutoSubmit.SelectedIndexChanged += new System.EventHandler(this.comboBoxAutoSubmit_SelectedIndexChanged); this.comboBoxAutoFill.SelectedIndexChanged += new System.EventHandler(this.comboBoxAutoFill_SelectedIndexChanged); this.textBoxKeeFoxPriority.TextChanged += new System.EventHandler(this.textBoxKeeFoxPriority_TextChanged); string realmTooltip = "Set this to the realm (what the \"site says\") in the HTTP authentication popup dialog box for a more accurate match"; toolTipRealm.SetToolTip(this.textBoxKeeFoxRealm, realmTooltip); toolTipRealm.SetToolTip(this.labelRealm, realmTooltip); }
private void changeBehaviourState(EntryBehaviour behav) { switch (behav) { case EntryBehaviour.AlwaysAutoFill: changeAdvancedString("KPRPC Always Auto Fill", "", false); removeAdvancedString("KPRPC Never Auto Fill"); removeAdvancedString("KPRPC Always Auto Submit"); removeAdvancedString("KPRPC Never Auto Submit"); removeAdvancedString("KeeFox Never Auto Fill"); removeAdvancedString("KeeFox Always Auto Submit"); removeAdvancedString("KeeFox Never Auto Submit"); comboBoxAutoFill.Text = "Always"; comboBoxAutoSubmit.Text = "Use KeeFox setting"; comboBoxAutoFill.Enabled = true; comboBoxAutoSubmit.Enabled = true; break; case EntryBehaviour.NeverAutoSubmit: changeAdvancedString("KPRPC Never Auto Submit", "", false); removeAdvancedString("KPRPC Always Auto Submit"); removeAdvancedString("KPRPC Always Auto Fill"); removeAdvancedString("KPRPC Never Auto Fill"); removeAdvancedString("KeeFox Always Auto Submit"); removeAdvancedString("KeeFox Always Auto Fill"); removeAdvancedString("KeeFox Never Auto Fill"); comboBoxAutoFill.Text = "Use KeeFox setting"; comboBoxAutoSubmit.Text = "Never"; comboBoxAutoFill.Enabled = true; comboBoxAutoSubmit.Enabled = true; break; case EntryBehaviour.AlwaysAutoFillAlwaysAutoSubmit: changeAdvancedString("KPRPC Always Auto Fill", "", false); changeAdvancedString("KPRPC Always Auto Submit", "", false); removeAdvancedString("KPRPC Never Auto Fill"); removeAdvancedString("KPRPC Never Auto Submit"); removeAdvancedString("KeeFox Never Auto Fill"); removeAdvancedString("KeeFox Never Auto Submit"); comboBoxAutoSubmit.Text = "Always"; comboBoxAutoFill.Text = "Always"; comboBoxAutoFill.Enabled = false; comboBoxAutoSubmit.Enabled = true; break; case EntryBehaviour.NeverAutoFillNeverAutoSubmit: changeAdvancedString("KPRPC Never Auto Fill", "", false); changeAdvancedString("KPRPC Never Auto Submit", "", false); removeAdvancedString("KPRPC Always Auto Fill"); removeAdvancedString("KPRPC Always Auto Submit"); removeAdvancedString("KeeFox Always Auto Fill"); removeAdvancedString("KeeFox Always Auto Submit"); comboBoxAutoFill.Text = "Never"; comboBoxAutoSubmit.Text = "Never"; comboBoxAutoSubmit.Enabled = false; comboBoxAutoFill.Enabled = true; break; case EntryBehaviour.AlwaysAutoFillNeverAutoSubmit: changeAdvancedString("KPRPC Always Auto Fill", "", false); changeAdvancedString("KPRPC Never Auto Submit", "", false); removeAdvancedString("KPRPC Never Auto Fill"); removeAdvancedString("KPRPC Always Auto Submit"); removeAdvancedString("KeeFox Never Auto Fill"); removeAdvancedString("KeeFox Always Auto Submit"); comboBoxAutoFill.Text = "Always"; comboBoxAutoSubmit.Text = "Never"; comboBoxAutoSubmit.Enabled = true; comboBoxAutoFill.Enabled = true; break; case EntryBehaviour.Default: removeAdvancedString("KeeFox Never Auto Fill"); removeAdvancedString("KeeFox Always Auto Fill"); removeAdvancedString("KeeFox Never Auto Submit"); removeAdvancedString("KeeFox Always Auto Submit"); removeAdvancedString("KPRPC Never Auto Fill"); removeAdvancedString("KPRPC Always Auto Fill"); removeAdvancedString("KPRPC Never Auto Submit"); removeAdvancedString("KPRPC Always Auto Submit"); comboBoxAutoFill.Text = "Use KeeFox setting"; comboBoxAutoSubmit.Text = "Use KeeFox setting"; comboBoxAutoSubmit.Enabled = true; comboBoxAutoFill.Enabled = true; break; } currentBehaviour = behav; }
private void changeBehaviourState(EntryBehaviour behav) { switch (behav) { case EntryBehaviour.AlwaysAutoFill: _conf.AlwaysAutoFill = true; _conf.AlwaysAutoSubmit = false; _conf.NeverAutoFill = false; _conf.NeverAutoSubmit = false; comboBoxAutoFill.Text = "Always"; comboBoxAutoSubmit.Text = "Use Kee setting"; comboBoxAutoFill.Enabled = true; comboBoxAutoSubmit.Enabled = true; break; case EntryBehaviour.NeverAutoSubmit: _conf.AlwaysAutoFill = false; _conf.AlwaysAutoSubmit = false; _conf.NeverAutoFill = false; _conf.NeverAutoSubmit = true; comboBoxAutoFill.Text = "Use Kee setting"; comboBoxAutoSubmit.Text = "Never"; comboBoxAutoFill.Enabled = true; comboBoxAutoSubmit.Enabled = true; break; case EntryBehaviour.AlwaysAutoFillAlwaysAutoSubmit: _conf.AlwaysAutoFill = true; _conf.AlwaysAutoSubmit = true; _conf.NeverAutoFill = false; _conf.NeverAutoSubmit = false; comboBoxAutoSubmit.Text = "Always"; comboBoxAutoFill.Text = "Always"; comboBoxAutoFill.Enabled = false; comboBoxAutoSubmit.Enabled = true; break; case EntryBehaviour.NeverAutoFillNeverAutoSubmit: _conf.AlwaysAutoFill = false; _conf.AlwaysAutoSubmit = false; _conf.NeverAutoFill = true; _conf.NeverAutoSubmit = true; comboBoxAutoFill.Text = "Never"; comboBoxAutoSubmit.Text = "Never"; comboBoxAutoSubmit.Enabled = false; comboBoxAutoFill.Enabled = true; break; case EntryBehaviour.AlwaysAutoFillNeverAutoSubmit: _conf.AlwaysAutoFill = true; _conf.AlwaysAutoSubmit = false; _conf.NeverAutoFill = false; _conf.NeverAutoSubmit = true; comboBoxAutoFill.Text = "Always"; comboBoxAutoSubmit.Text = "Never"; comboBoxAutoSubmit.Enabled = true; comboBoxAutoFill.Enabled = true; break; case EntryBehaviour.Default: _conf.AlwaysAutoFill = false; _conf.AlwaysAutoSubmit = false; _conf.NeverAutoFill = false; _conf.NeverAutoSubmit = false; comboBoxAutoFill.Text = "Use Kee setting"; comboBoxAutoSubmit.Text = "Use Kee setting"; comboBoxAutoSubmit.Enabled = true; comboBoxAutoFill.Enabled = true; break; } UpdateKPRPCJSON(_conf); currentBehaviour = behav; }
private void KeeFoxEntryUserControl_Load(object sender, EventArgs e) { bool kfNeverAutoFill = false; bool kfAlwaysAutoFill = false; bool kfNeverAutoSubmit = false; bool kfAlwaysAutoSubmit = false; this.checkBoxHideFromKeeFox.CheckedChanged += new System.EventHandler(this.checkBoxHideFromKeeFox_CheckedChanged); this.checkBoxBlockHostnameOnly.CheckedChanged += new System.EventHandler(this.checkBoxBlockHostnameOnly_CheckedChanged); if (_conf.Hide) { checkBoxHideFromKeeFox.Checked = true; } if (_conf.BlockHostnameOnlyMatch) { checkBoxBlockHostnameOnly.Checked = true; } if (_conf.NeverAutoFill) { kfNeverAutoFill = true; } if (_conf.AlwaysAutoFill) { kfAlwaysAutoFill = true; } if (_conf.NeverAutoSubmit) { kfNeverAutoSubmit = true; } if (_conf.AlwaysAutoSubmit) { kfAlwaysAutoSubmit = true; } if (_conf.Priority != 0) textBoxKeeFoxPriority.Text = _conf.Priority.ToString(); listNormalURLs = new List<string>(); listNormalBlockedURLs = new List<string>(); listRegExURLs = new List<string>(); listRegExBlockedURLs = new List<string>(); if (_conf.AltURLs != null) listNormalURLs.AddRange(_conf.AltURLs); if (_conf.BlockedURLs != null) listNormalBlockedURLs.AddRange(_conf.BlockedURLs); if (_conf.RegExURLs != null) listRegExURLs.AddRange(_conf.RegExURLs); if (_conf.RegExBlockedURLs != null) listRegExBlockedURLs.AddRange(_conf.RegExBlockedURLs); textBoxKeeFoxRealm.Text = _conf.HTTPRealm; bool standardPasswordFound = false; bool standardUsernameFound = false; // Read the list of form field objects and create ListViewItems for display to the user if (_conf.FormFieldList != null) { foreach (FormField ff in _conf.FormFieldList) { string type = Utilities.FormFieldTypeToDisplay(ff.Type, false); // Override display of standard variables string value = ff.Value; if (ff.Type == FormFieldType.FFTpassword) value = "********"; if (ff.DisplayName == "KeePass username") { standardUsernameFound = true; value = ff.DisplayName; } if (ff.DisplayName == "KeePass password") { standardPasswordFound = true; value = ff.DisplayName; } ListViewItem lvi = new ListViewItem(new string[] { ff.Name, value, ff.Id, type, ff.Page.ToString() }); lvi.Tag = ff; AddFieldListItem(lvi); } } // if we didn't find specific details about the username and // password, we'll pre-populate the standard KeePass ones so // users can easily change things like page number and ID // we don't add them to the list of actual fields though - just the display list. if (!standardPasswordFound) { ListViewItem lvi = new ListViewItem(new string[] { "", "{PASSWORD}", "", "password", "1" }); AddFieldListItem(lvi); } if (!standardUsernameFound) { ListViewItem lvi = new ListViewItem(new string[] { "", "{USERNAME}", "", "username", "1" }); AddFieldListItem(lvi); } ReadURLStrings(); comboBoxAutoSubmit.Text = "Use KeeFox setting"; comboBoxAutoFill.Text = "Use KeeFox setting"; // There are implicit behaviours based on single option choices so we'll make them explicit now so that the GUI accurately reflects the // strings stored in the advanced tab if (kfNeverAutoFill) currentBehaviour = EntryBehaviour.NeverAutoFillNeverAutoSubmit; else if (kfAlwaysAutoSubmit) currentBehaviour = EntryBehaviour.AlwaysAutoFillAlwaysAutoSubmit; else if (kfAlwaysAutoFill && kfNeverAutoSubmit) currentBehaviour = EntryBehaviour.AlwaysAutoFillNeverAutoSubmit; else if (kfNeverAutoSubmit) currentBehaviour = EntryBehaviour.NeverAutoSubmit; else if (kfAlwaysAutoFill) currentBehaviour = EntryBehaviour.AlwaysAutoFill; else currentBehaviour = EntryBehaviour.Default; changeBehaviourState(currentBehaviour); this.comboBoxAutoSubmit.SelectedIndexChanged += new System.EventHandler(this.comboBoxAutoSubmit_SelectedIndexChanged); this.comboBoxAutoFill.SelectedIndexChanged += new System.EventHandler(this.comboBoxAutoFill_SelectedIndexChanged); this.textBoxKeeFoxPriority.TextChanged += new System.EventHandler(this.textBoxKeeFoxPriority_TextChanged); string realmTooltip = "Set this to the realm (what the \"site says\") in the HTTP authentication popup dialog box for a more accurate match"; toolTipRealm.SetToolTip(this.textBoxKeeFoxRealm, realmTooltip); toolTipRealm.SetToolTip(this.labelRealm, realmTooltip); }
private void changeBehaviourState(EntryBehaviour behav) { switch (behav) { case EntryBehaviour.AlwaysAutoFill: _conf.AlwaysAutoFill = true; _conf.AlwaysAutoSubmit = false; _conf.NeverAutoFill = false; _conf.NeverAutoSubmit = false; comboBoxAutoFill.Text = "Always"; comboBoxAutoSubmit.Text = "Use KeeFox setting"; comboBoxAutoFill.Enabled = true; comboBoxAutoSubmit.Enabled = true; break; case EntryBehaviour.NeverAutoSubmit: _conf.AlwaysAutoFill = false; _conf.AlwaysAutoSubmit = false; _conf.NeverAutoFill = false; _conf.NeverAutoSubmit = true; comboBoxAutoFill.Text = "Use KeeFox setting"; comboBoxAutoSubmit.Text = "Never"; comboBoxAutoFill.Enabled = true; comboBoxAutoSubmit.Enabled = true; break; case EntryBehaviour.AlwaysAutoFillAlwaysAutoSubmit: _conf.AlwaysAutoFill = true; _conf.AlwaysAutoSubmit = true; _conf.NeverAutoFill = false; _conf.NeverAutoSubmit = false; comboBoxAutoSubmit.Text = "Always"; comboBoxAutoFill.Text = "Always"; comboBoxAutoFill.Enabled = false; comboBoxAutoSubmit.Enabled = true; break; case EntryBehaviour.NeverAutoFillNeverAutoSubmit: _conf.AlwaysAutoFill = false; _conf.AlwaysAutoSubmit = false; _conf.NeverAutoFill = true; _conf.NeverAutoSubmit = true; comboBoxAutoFill.Text = "Never"; comboBoxAutoSubmit.Text = "Never"; comboBoxAutoSubmit.Enabled = false; comboBoxAutoFill.Enabled = true; break; case EntryBehaviour.AlwaysAutoFillNeverAutoSubmit: _conf.AlwaysAutoFill = true; _conf.AlwaysAutoSubmit = false; _conf.NeverAutoFill = false; _conf.NeverAutoSubmit = true; comboBoxAutoFill.Text = "Always"; comboBoxAutoSubmit.Text = "Never"; comboBoxAutoSubmit.Enabled = true; comboBoxAutoFill.Enabled = true; break; case EntryBehaviour.Default: _conf.AlwaysAutoFill = false; _conf.AlwaysAutoSubmit = false; _conf.NeverAutoFill = false; _conf.NeverAutoSubmit = false; comboBoxAutoFill.Text = "Use KeeFox setting"; comboBoxAutoSubmit.Text = "Use KeeFox setting"; comboBoxAutoSubmit.Enabled = true; comboBoxAutoFill.Enabled = true; break; } UpdateKPRPCJSON(_conf); currentBehaviour = behav; }