Example #1
0
        private void KeeEntryUserControl_Load(object sender, EventArgs e)
        {
            bool kfNeverAutoFill    = false;
            bool kfAlwaysAutoFill   = false;
            bool kfNeverAutoSubmit  = false;
            bool kfAlwaysAutoSubmit = false;

            if (_conf == null)
            {
                return;
            }

            this.checkBoxHideFromKee.CheckedChanged += new System.EventHandler(this.checkBoxHideFromKee_CheckedChanged);

            if (_conf.Hide)
            {
                checkBoxHideFromKee.Checked = true;
            }
            if (_conf.GetMatchAccuracyMethod() == MatchAccuracyMethod.Exact)
            {
                radioButton3.Checked = true;
            }
            else if (_conf.GetMatchAccuracyMethod() == MatchAccuracyMethod.Hostname)
            {
                radioButton2.Checked = true;
            }
            else
            {
                radioButton1.Checked = true;
            }
            RadioButton defaultRadioButton = null;

            switch (_dbConf.DefaultMatchAccuracy)
            {
            case MatchAccuracyMethod.Exact: defaultRadioButton = radioButton3; break;

            case MatchAccuracyMethod.Hostname: defaultRadioButton = radioButton2; break;

            case MatchAccuracyMethod.Domain: defaultRadioButton = radioButton1; break;
            }
            toolTipRealm.SetToolTip(defaultRadioButton, "This is the default behaviour for new entries. Change in the Database Settings dialog.");

            if (_conf.NeverAutoFill)
            {
                kfNeverAutoFill = true;
            }
            if (_conf.AlwaysAutoFill)
            {
                kfAlwaysAutoFill = true;
            }
            if (_conf.NeverAutoSubmit)
            {
                kfNeverAutoSubmit = true;
            }
            if (_conf.AlwaysAutoSubmit)
            {
                kfAlwaysAutoSubmit = true;
            }
            if (_conf.Priority != 0)
            {
                textBoxKeePriority.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);
            }

            textBoxKeeRealm.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;
                    }
                    if (ff.Type == FormFieldType.FFTcheckbox)
                    {
                        value = ff.Value == "KEEFOX_CHECKED_FLAG_TRUE" ? "Enabled" : "Disabled";
                    }
                    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[] { "", "KeePass password", "", "password", "1" });
                AddFieldListItem(lvi);
            }
            if (!standardUsernameFound)
            {
                ListViewItem lvi = new ListViewItem(new string[] { "", "KeePass username", "", "username", "1" });
                AddFieldListItem(lvi);
            }

            ReadURLStrings();

            comboBoxAutoSubmit.Text = "Use Kee setting";
            comboBoxAutoFill.Text   = "Use Kee 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.textBoxKeePriority.TextChanged          += new System.EventHandler(this.textBoxKeePriority_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.textBoxKeeRealm, realmTooltip);
            toolTipRealm.SetToolTip(this.labelRealm, realmTooltip);
        }