Fix Tabs
This commit is contained in:
135
main.cpp
135
main.cpp
@ -1,12 +1,10 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
|
||||||
// Main sets up the Application/GUI, and tries to retrieveLogin()
|
// Main sets up the Application/GUI, and tries to retrieveLogin()
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
QApplication app(argc,argv);
|
QApplication app(argc,argv);
|
||||||
QWidget *window = new QWidget;
|
QWidget *window = new QWidget;
|
||||||
|
|
||||||
|
|
||||||
domainLE = new QLineEdit;
|
domainLE = new QLineEdit;
|
||||||
tokenUsername = new QLineEdit;
|
tokenUsername = new QLineEdit;
|
||||||
tokenCode = new QLineEdit;
|
tokenCode = new QLineEdit;
|
||||||
@ -43,7 +41,6 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
QObject::connect(&loginBtn, &QPushButton::released, tryLogin);
|
QObject::connect(&loginBtn, &QPushButton::released, tryLogin);
|
||||||
|
|
||||||
|
|
||||||
window->setLayout(vboxLayout);
|
window->setLayout(vboxLayout);
|
||||||
window->show();
|
window->show();
|
||||||
return app.exec();
|
return app.exec();
|
||||||
@ -52,25 +49,25 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// walletOpen() returns a pointer to the kwallet, or throws an error if the wallet is unable to open.
|
// walletOpen() returns a pointer to the kwallet, or throws an error if the wallet is unable to open.
|
||||||
KWallet::Wallet* walletOpen() {
|
KWallet::Wallet* walletOpen() {
|
||||||
KWallet::Wallet *wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Synchronous);
|
KWallet::Wallet *wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Synchronous);
|
||||||
if (wallet->hasFolder(KWallet::Wallet::FormDataFolder())) {
|
if (wallet->hasFolder(KWallet::Wallet::FormDataFolder())) {
|
||||||
|
if (!wallet->setFolder(KWallet::Wallet::FormDataFolder())) {
|
||||||
|
std::cout << "Wallet folder could not be set." << std::endl;
|
||||||
|
throw -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cout << "Wallet did not have folder, creating." << std::endl;
|
||||||
|
if(wallet->createFolder(KWallet::Wallet::FormDataFolder())) {
|
||||||
if (!wallet->setFolder(KWallet::Wallet::FormDataFolder())) {
|
if (!wallet->setFolder(KWallet::Wallet::FormDataFolder())) {
|
||||||
std::cout << "Wallet folder could not be set." << std::endl;
|
std::cout << "Wallet folder could not be set." << std::endl;
|
||||||
throw -1;
|
throw -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Wallet did not have folder, creating." << std::endl;
|
std::cout << "Could not create folder." << std::endl;
|
||||||
if(wallet->createFolder(KWallet::Wallet::FormDataFolder())) {
|
throw -1;
|
||||||
if (!wallet->setFolder(KWallet::Wallet::FormDataFolder())) {
|
|
||||||
std::cout << "Wallet folder could not be set." << std::endl;
|
|
||||||
throw -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
std::cout << "Could not create folder." << std::endl;
|
|
||||||
throw -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return wallet;
|
}
|
||||||
|
return wallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve login information from kwallet using walletOpen() or die
|
// retrieve login information from kwallet using walletOpen() or die
|
||||||
@ -80,19 +77,19 @@ void retrieveLogin() {
|
|||||||
} catch (int e) {
|
} catch (int e) {
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
QMap<QString, QString> map;
|
QMap<QString, QString> map;
|
||||||
if (wallet->readMap("http://rsa-vdi.nightmare.haus/#authInfo", map) == 0) {
|
if (wallet->readMap("http://rsa-vdi.nightmare.haus/#authInfo", map) == 0) {
|
||||||
domainLE->setText(map[QString("domain")]);
|
domainLE->setText(map[QString("domain")]);
|
||||||
tokenUsername->setText(map[QString("tokenUsername")]);
|
tokenUsername->setText(map[QString("tokenUsername")]);
|
||||||
ntUsername->setText(map[QString("ntUsername")]);
|
ntUsername->setText(map[QString("ntUsername")]);
|
||||||
ntPassword->setText(map[QString("ntPassword")]);
|
ntPassword->setText(map[QString("ntPassword")]);
|
||||||
authSystemLE->setText(map[QString("authSystem")]);
|
authSystemLE->setText(map[QString("authSystem")]);
|
||||||
if (tokenUsername->text().length() > 0) {
|
if (tokenUsername->text().length() > 0) {
|
||||||
rememberCredentials->setChecked(true);
|
rememberCredentials->setChecked(true);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
std::cout << "Error loading from wallet, is it populated?" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
std::cout << "Error loading from wallet, is it populated?" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// save login information to kwallet using walletOpen() or die
|
// save login information to kwallet using walletOpen() or die
|
||||||
void saveLogin() {
|
void saveLogin() {
|
||||||
@ -101,17 +98,16 @@ void saveLogin() {
|
|||||||
} catch (int e) {
|
} catch (int e) {
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
QMap<QString, QString> map;
|
QMap<QString, QString> map;
|
||||||
map[QString("domain")] = domainLE->text();
|
map[QString("domain")] = domainLE->text();
|
||||||
map[QString("tokenUsername")] = tokenUsername->text();
|
map[QString("tokenUsername")] = tokenUsername->text();
|
||||||
map[QString("ntUsername")] = ntUsername->text();
|
map[QString("ntUsername")] = ntUsername->text();
|
||||||
map[QString("ntPassword")] = ntPassword->text();
|
map[QString("ntPassword")] = ntPassword->text();
|
||||||
map[QString("authSystem")] = authSystemLE->text();
|
map[QString("authSystem")] = authSystemLE->text();
|
||||||
|
|
||||||
if (!wallet->writeMap("http://rsa-vdi.nightmare.haus/#authInfo", map)) {
|
|
||||||
std::cout << "Error writing to Wallet!" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!wallet->writeMap("http://rsa-vdi.nightmare.haus/#authInfo", map)) {
|
||||||
|
std::cout << "Error writing to Wallet!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,37 +129,36 @@ void tryLogin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -q, --nonInteractive Connect automatically if enough values are given on the command line.
|
||||||
// -q, --nonInteractive Connect automatically if enough values are given on the command line.
|
QString command = "vmware-view -q";
|
||||||
QString command = "vmware-view -q";
|
if (domainLE->text().length() > 0) {
|
||||||
if (domainLE->text().length() > 0) {
|
// -s, --serverURL=<broker URL> Specify connection broker.
|
||||||
// -s, --serverURL=<broker URL> Specify connection broker.
|
command += " -s \'" + domainLE->text() + "\'";
|
||||||
command += " -s \'" + domainLE->text() + "\'";
|
}
|
||||||
}
|
if (authSystemLE->text().length() > 0) {
|
||||||
if (authSystemLE->text().length() > 0) {
|
// -d, --domainName=<domain name> Specify domain for password authentication
|
||||||
// -d, --domainName=<domain name> Specify domain for password authentication
|
command += " -d \'" + authSystemLE->text() + "\'";
|
||||||
command += " -d \'" + authSystemLE->text() + "\'";
|
}
|
||||||
}
|
if (tokenUsername->text().length() > 0) {
|
||||||
if (tokenUsername->text().length() > 0) {
|
// -t, --tokenUserName=<token user name> Specify user name for RSA or Radius authentication.
|
||||||
// -t, --tokenUserName=<token user name> Specify user name for RSA or Radius authentication.
|
command += " -t \'" + tokenUsername->text() + "\'";
|
||||||
command += " -t \'" + tokenUsername->text() + "\'";
|
}
|
||||||
}
|
if (tokenCode->text().length() > 0 ) {
|
||||||
if (tokenCode->text().length() > 0 ) {
|
// -c, --passcode=<passcode> Specify passcode for RSA or Radius authentication.
|
||||||
// -c, --passcode=<passcode> Specify passcode for RSA or Radius authentication.
|
command += " -c \'" + tokenCode->text() + "\'";
|
||||||
command += " -c \'" + tokenCode->text() + "\'";
|
}
|
||||||
}
|
if (ntUsername->text().length() > 0) {
|
||||||
if (ntUsername->text().length() > 0) {
|
// -u, --userName=<user name> Specify user name for password authentication.
|
||||||
// -u, --userName=<user name> Specify user name for password authentication.
|
command += " -u \'" + ntUsername->text() + "\'";
|
||||||
command += " -u \'" + ntUsername->text() + "\'";
|
}
|
||||||
}
|
if (ntPassword->text().length() > 0) {
|
||||||
if (ntPassword->text().length() > 0) {
|
//-p, --password=<password> Specify password for password authentication.
|
||||||
//-p, --password=<password> Specify password for password authentication.
|
command += " -p \'" + ntPassword->text() + "\'";
|
||||||
command += " -p \'" + ntPassword->text() + "\'";
|
}
|
||||||
}
|
if (debug) {
|
||||||
if (debug) {
|
std::cout << command.toStdString() << std::endl;
|
||||||
std::cout << command.toStdString() << std::endl;
|
} else {
|
||||||
} else {
|
system(command.toStdString().c_str());
|
||||||
system(command.toStdString().c_str());
|
}
|
||||||
}
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user