Builds on windows again
This commit is contained in:
parent
33cf39b799
commit
bebb3391c3
160 changed files with 138 additions and 117 deletions
|
|
@ -1,179 +0,0 @@
|
|||
#include "ConnectionManagerWindow.h"
|
||||
#include "ui_ConnectionManagerWindow.h"
|
||||
//#include "mainwindow.h"
|
||||
#include "MasterController.h"
|
||||
#include <QDataWidgetMapper>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardItemModel>
|
||||
#include "ConnectionListModel.h"
|
||||
|
||||
ConnectionManagerWindow::ConnectionManagerWindow(MasterController *master, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::ConnectionManagerWindow)
|
||||
// , m_listModel(new ConnectionListModel(this))
|
||||
, m_masterController(master)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->listView->setModel(m_masterController->getConnectionListModel());
|
||||
|
||||
setupWidgetMappings();
|
||||
|
||||
connect(ui->listView->selectionModel(),
|
||||
SIGNAL(currentChanged(QModelIndex,QModelIndex)),
|
||||
this, SLOT(on_currentChanged(QModelIndex,QModelIndex)));
|
||||
}
|
||||
|
||||
|
||||
ConnectionManagerWindow::~ConnectionManagerWindow()
|
||||
{
|
||||
// m_listModel->save();
|
||||
|
||||
delete ui;
|
||||
// delete m_listModel;
|
||||
delete m_mapper;
|
||||
}
|
||||
|
||||
void ConnectionManagerWindow::on_actionAdd_Connection_triggered()
|
||||
{
|
||||
// ConnectionConfig c;
|
||||
// c.setName("new");
|
||||
//m_listModel->add(c);
|
||||
|
||||
auto clm = m_masterController->getConnectionListModel();
|
||||
clm->newItem();
|
||||
|
||||
// Select the new row
|
||||
auto idx = clm->index(clm->rowCount() - 1, 0);
|
||||
ui->listView->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::Select);
|
||||
}
|
||||
|
||||
void ConnectionManagerWindow::on_currentChanged(const QModelIndex ¤t,
|
||||
const QModelIndex &)
|
||||
{
|
||||
int currow = current.row();
|
||||
auto clm = m_masterController->getConnectionListModel();
|
||||
clm->save(prevSelection);
|
||||
m_mapper->setCurrentIndex(currow);
|
||||
prevSelection = currow;
|
||||
}
|
||||
|
||||
void ConnectionManagerWindow::on_actionDelete_connection_triggered()
|
||||
{
|
||||
auto ci = ui->listView->selectionModel()->currentIndex();
|
||||
if (ci.isValid()) {
|
||||
auto clm = m_masterController->getConnectionListModel();
|
||||
clm->removeRow(ci.row());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConnectionManagerWindow::setupWidgetMappings()
|
||||
{
|
||||
auto clm = m_masterController->getConnectionListModel();
|
||||
m_mapper = new QDataWidgetMapper(this);
|
||||
m_mapper->setModel(clm);
|
||||
m_mapper->addMapping(ui->edtName, 1);
|
||||
m_mapper->addMapping(ui->edtHost, 2);
|
||||
m_mapper->addMapping(ui->spinPort, 3);
|
||||
m_mapper->addMapping(ui->edtUser, 4);
|
||||
m_mapper->addMapping(ui->edtPassword, 5);
|
||||
m_mapper->addMapping(ui->edtDbname, 6);
|
||||
m_mapper->toFirst();
|
||||
}
|
||||
|
||||
void ConnectionManagerWindow::on_actionConnect_triggered()
|
||||
{
|
||||
auto ci = ui->listView->selectionModel()->currentIndex();
|
||||
m_masterController->openSqlWindowForConnection(ci.row());
|
||||
}
|
||||
|
||||
void ConnectionManagerWindow::on_actionQuit_application_triggered()
|
||||
{
|
||||
auto res = QMessageBox::question(this, "pglab",
|
||||
tr("Close ALL windows?"), QMessageBox::Yes, QMessageBox::No);
|
||||
if (res == QMessageBox::Yes) {
|
||||
QApplication::quit();
|
||||
}
|
||||
|
||||
//closeAllWindows();
|
||||
}
|
||||
|
||||
void ConnectionManagerWindow::on_actionBackup_database_triggered()
|
||||
{
|
||||
auto ci = ui->listView->selectionModel()->currentIndex();
|
||||
m_masterController->openBackupDlgForConnection(ci.row());
|
||||
}
|
||||
|
||||
void ConnectionManagerWindow::on_actionManage_server_triggered()
|
||||
{
|
||||
auto ci = ui->listView->selectionModel()->currentIndex();
|
||||
m_masterController->openServerWindowForConnection(ci.row());
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <botan/botan.h>
|
||||
//#include <botan/base64.h>
|
||||
//#include <botan/pbkdf.h>
|
||||
//#include <botan/block_cipher.h>
|
||||
//#include <botan/hex.h>
|
||||
#include <botan/cryptobox.h>
|
||||
|
||||
|
||||
void ConnectionManagerWindow::on_testButton_clicked()
|
||||
{
|
||||
std::string error = Botan::runtime_version_check(BOTAN_VERSION_MAJOR,
|
||||
BOTAN_VERSION_MINOR,
|
||||
BOTAN_VERSION_PATCH);
|
||||
if (error.empty()) {
|
||||
// Botan::AutoSeeded_RNG rng;
|
||||
// Botan::secure_vector<Botan::byte> salt =
|
||||
// //{ 0x3f, 0x0a, 0xb0, 0x11, 0x44, 0xfe, 0x9d, 0xf7, 0x85, 0xd3, 0x11, 0x38, 0xe2, 0xdf, 0x31, 0x42 };
|
||||
// rng.random_vec(16);
|
||||
// // salt should be random and saved with encrypted data so it can be used when we decrypt
|
||||
|
||||
// std::string password = "Hello kitty";
|
||||
// std::unique_ptr<Botan::PBKDF> pbkdf(Botan::get_pbkdf("PBKDF2(SHA-256)"));
|
||||
// Botan::OctetString aes256_key = pbkdf->derive_key(32, password, salt.data(), salt.size(), 10000);
|
||||
|
||||
// std::string plaintext("Your great-grandfather gave this watch to your granddad for good luck. Unfortunately, Dane's luck wasn't as good as his old man's.");
|
||||
// Botan::secure_vector<uint8_t> pt(plaintext.data(),plaintext.data()+plaintext.length());
|
||||
|
||||
// std::unique_ptr<Botan::Cipher_Mode> enc(Botan::get_cipher_mode("AES-256/CBC/PKCS7", Botan::ENCRYPTION));
|
||||
// enc->set_key(aes256_key);
|
||||
|
||||
// //generate fresh nonce (IV)
|
||||
// //std::unique_ptr<Botan::RandomNumberGenerator> rng(new Botan::AutoSeeded_RNG);
|
||||
// std::vector<uint8_t> iv(enc->default_nonce_length());
|
||||
// rng.randomize(iv.data(), iv.size());
|
||||
// enc->start(iv);
|
||||
// enc->finish(pt);
|
||||
// //std::cout << std::endl << enc->name() << " with iv " << Botan::hex_encode(iv) << std::endl << Botan::hex_encode(pt);
|
||||
|
||||
|
||||
//std::string s = aes256_key.as_string();// + "\n" + t.format_string();
|
||||
|
||||
std::string passphrase = "my passphrase";
|
||||
std::string plaintext("password1234");
|
||||
try {
|
||||
Botan::AutoSeeded_RNG rng;
|
||||
std::string encrypted = Botan::CryptoBox::encrypt((const uint8_t*)plaintext.data(), plaintext.length(), passphrase, rng);
|
||||
|
||||
std::string decrypted = Botan::CryptoBox::decrypt(encrypted, passphrase);
|
||||
|
||||
std::string s = encrypted + "\n" + decrypted;
|
||||
QMessageBox::information(this, "pglab",
|
||||
QString::fromUtf8(s.c_str()), QMessageBox::Yes);
|
||||
}
|
||||
catch (Botan::Decoding_Error &e) {
|
||||
QMessageBox::information(this, "pglab",
|
||||
tr("Failure to decrypt"), QMessageBox::Yes);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
QMessageBox ::information(this, "pglab",
|
||||
QString::fromUtf8(error.c_str()), QMessageBox::Yes);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue