void MainWindow::close_database() { QByteArray ba; if (!dbfile.isEmpty()) { ba += db::intToData(size().width()); ba += db::intToData(size().height()); ba += db::intToData(tabView->currentIndex()); db mydb(dbfile); mydb.set((const unsigned char *)ba.constData(), ba.size(), 1, setting, "mw_geometry"); } setItemEnabled(false); dbindex->clear(); keyView->setModel(NULL); reqView->setModel(NULL); certView->setModel(NULL); tempView->setModel(NULL); crlView->setModel(NULL); if (crls) delete(crls); if (reqs) delete(reqs); if (certs) delete(certs); if (temps) delete(temps); if (keys) delete(keys); reqs = NULL; certs = NULL; temps = NULL; keys = NULL; pki_evp::passwd.cleanse(); pki_evp::passwd = QByteArray(); if (!crls) return; crls = NULL; try { db mydb(dbfile); mydb.shrink( DBFLAG_OUTDATED | DBFLAG_DELETED ); } catch (errorEx &err) { MainWindow::Error(err); } pkcs11::remove_libs(); enableTokenMenu(pkcs11::loaded()); }
void MainWindow::setOptions() { Options *opt = new Options(this); opt->setStringOpt(string_opt); opt->setupPkcs11Provider(pkcs11path); if (!opt->exec()) { delete opt; enableTokenMenu(pkcs11::loaded()); return; } QString alg = opt->hashAlgo->currentHashName(); db mydb(dbfile); mydb.set((const unsigned char *)CCHAR(alg), alg.length()+1, 1, setting, "default_hash"); hashBox::setDefault(alg); mandatory_dn = opt->getDnString(); mydb.set((const unsigned char *)CCHAR(mandatory_dn), mandatory_dn.length()+1, 1, setting, "mandatory_dn"); if (opt->getStringOpt() != string_opt) { string_opt = opt->getStringOpt(); ASN1_STRING_set_default_mask_asc((char *)CCHAR(string_opt)); mydb.set((const unsigned char *)CCHAR(string_opt), string_opt.length()+1, 1, setting,"string_opt"); } QString newpath = opt->getPkcs11Provider(); if (newpath != pkcs11path) { pkcs11path = newpath; mydb.set((const unsigned char *) CCHAR(pkcs11path), pkcs11path.length()+1, 1,setting, "pkcs11path"); } enableTokenMenu(pkcs11::loaded()); delete opt; }
void MainWindow::close_database() { QByteArray ba; if (!dbfile.isEmpty()) { ba += db::intToData(size().width()); ba += db::intToData(size().height()); ba += db::intToData(tabView->currentIndex()); db mydb(dbfile); mydb.set((const unsigned char *)ba.constData(), ba.size(), 1, setting, "mw_geometry"); } setItemEnabled(false); statusBar()->removeWidget(searchEdit); dbindex->clear(); keyView->setModel(); reqView->setModel(); certView->setModel(); tempView->setModel(); crlView->setModel(); if (crls) delete(crls); if (reqs) delete(reqs); if (certs) delete(certs); if (temps) delete(temps); if (keys) delete(keys); reqs = NULL; certs = NULL; temps = NULL; keys = NULL; pki_evp::passwd.cleanse(); pki_evp::passwd = QByteArray(); if (!crls) return; crls = NULL; try { int ret; db mydb(dbfile); ret = mydb.shrink( DBFLAG_OUTDATED | DBFLAG_DELETED ); if (ret == 1) XCA_INFO(tr("Errors detected and repaired while deleting outdated items from the database. A backup file was created")); if (ret == 2) XCA_INFO(tr("Removing deleted or outdated items from the database failed.")); } catch (errorEx &err) { MainWindow::Error(err); } update_history(dbfile); pkcs11::remove_libs(); enableTokenMenu(pkcs11::loaded()); dbfile.clear(); }