Esempio n. 1
0
        private void bCreateOpen_Click(object sender, EventArgs e)
        {
            cbUseDBForSeeds.Checked = true;
            PwDatabase db = m_dDB.ElementAt(lbDB.SelectedIndex).Key;

            RefreshHandler(db);
            DBAction dba = cbDBAction.SelectedItem as DBAction;

            if (dba == null)
            {
                return;
            }
            if ((dba.Action == ACTION_CREATE) || !m_handler.OTPDB_Exists)
            {
                m_handler.OTPDB_Create();
                if (m_handler.OTPDB_Exists)
                {
                    bDBSettings_Click(sender, e);
                }
            }
            else if (dba.Action == ACTION_OPEN)
            {
                m_handler.SetDB(db, true);
            }
            else if (dba.Action == ACTION_CLOSE)
            {
                m_handler.OTPDB_Close();
                OTPDAO.RemoveHandler(db.IOConnectionInfo.Path, true);
                OTPDAO.GetOTPHandler(db);
                OTPDAO.InitEntries(db);
                KeePassOTPColumnProvider.ForceUpdate = true;
            }
            else if (dba.Action == ACTION_DELETE)
            {
                m_handler.OTPDB_Remove();
                OTPDAO.RemoveHandler(db.IOConnectionInfo.Path, true);
                OTPDAO.InitEntries(db);
                KeePassOTPColumnProvider.ForceUpdate = true;
            }

            if (m_handler.OTPDB_Opened)
            {
                cbUseDBForSeeds.Checked = true;
                Config.UseDBForOTPSeeds(db, true);
                OTPDAO.GetOTPHandler(db);
                OTPDAO.InitEntries(db);
            }
            lbDB_SelectedIndexChanged(sender, e);
        }
Esempio n. 2
0
        private void cbUseDBForSeeds_CheckedChanged(object sender, EventArgs e)
        {
            PwDatabase db = m_dDB.ElementAt(lbDB.SelectedIndex).Key;

            if (!cbUseDBForSeeds.Checked)
            {
                OTPDAO.OTPHandler_DB h = OTPDAO.GetOTPHandler(db);
                if ((h != null) && h.OTPDB_Exists)
                {
                    DialogResult dr = DialogResult.None;
                    if (!h.HasEntries())
                    {
                        dr = DialogResult.Yes;
                    }
                    else
                    {
                        dr = MessageBox.Show(string.Format(PluginTranslate.ConfirmOTPDBDelete, DialogResult.Yes.ToString(), DialogResult.No.ToString()),
                                             PluginTranslate.PluginName,
                                             MessageBoxButtons.YesNoCancel,
                                             MessageBoxIcon.Question,
                                             MessageBoxDefaultButton.Button2);
                    }
                    if (dr == DialogResult.Cancel)
                    {
                        cbUseDBForSeeds.CheckedChanged -= cbUseDBForSeeds_CheckedChanged;
                        cbUseDBForSeeds.Checked         = true;
                        cbUseDBForSeeds.CheckedChanged += cbUseDBForSeeds_CheckedChanged;
                        return;
                    }
                    if (dr == DialogResult.Yes)
                    {
                        h.OTPDB_Remove();
                        OTPDAO.RemoveHandler(db.IOConnectionInfo.Path, true);
                        OTPDAO.InitEntries(db);
                    }
                    else if (dr == DialogResult.No)
                    {
                        h.OTPDB_Close();
                        OTPDAO.RemoveHandler(db.IOConnectionInfo.Path, true);
                        OTPDAO.InitEntries(db);
                    }
                }
            }
            m_dDB[db].UseOTPDB   = cbUseDBForSeeds.Checked;
            cbPreloadOTP.Enabled = cbUseDBForSeeds.Checked;
            DBAction_Init(db);
        }