mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
add debug flug
This commit is contained in:
parent
2bf1d0f78e
commit
028546540c
@ -21,12 +21,13 @@
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
ErrorWindow::ErrorWindow(QWidget *parent, const int messageNumber)
|
||||
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd, const int messageNumber)
|
||||
: QMainWindow(parent),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ErrorWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
qDebug() << "[ErrorWindow]" << "[ErrorWindow]" << ":" << "Initializate with error code" << messageNumber;
|
||||
if (debug) qDebug() << "[ErrorWindow]" << "[ErrorWindow]" << ":" << "Initializate with error code" << messageNumber;
|
||||
setMessage(messageNumber);
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,12 @@ class ErrorWindow : public QMainWindow
|
||||
|
||||
public:
|
||||
explicit ErrorWindow(QWidget *parent = 0,
|
||||
const bool debugCmd = false,
|
||||
const int messageNumber = 0);
|
||||
~ErrorWindow();
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
Ui::ErrorWindow *ui;
|
||||
void setMessage(const int mess);
|
||||
};
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "ipwidget.h"
|
||||
#include "ui_ipwidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
||||
|
@ -64,12 +64,14 @@ int main(int argc, char *argv[])
|
||||
helpMessage += QApplication::translate("MainWindow", " Evgeniy Alekseev aka arcanis\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " E-mail : esalexeev@gmail.com\n\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "Usage:\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "netctl-gui [ --default ] [ -t NUM | --tab NUM ] [ -h | --help]\n\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "netctl-gui [ --default ] [ -d | --debug ] [ -t NUM | --tab NUM ] [ -h | --help]\n\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "Parametrs:\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " --default - start with default settings\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " -d --debug - print debug information\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " -t NUM --tab NUM - open a tab with number NUM\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " -h --help - show this help and exit\n");
|
||||
bool defaultSettings = false;
|
||||
bool debug = false;
|
||||
int tabNumber = 1;
|
||||
|
||||
for (int i=1; i<argc; i++) {
|
||||
@ -86,6 +88,13 @@ int main(int argc, char *argv[])
|
||||
(argv[i][8] == 't') && (argv[i][9] == '\0')) {
|
||||
defaultSettings = true;
|
||||
}
|
||||
// debug
|
||||
else if (((argv[i][0] == '-') && (argv[i][1] == 'd') && (argv[i][2] == '\0')) ||
|
||||
((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 'd') &&
|
||||
(argv[i][3] == 'e') && (argv[i][4] == 'b') && (argv[i][5] == 'u') &&
|
||||
(argv[i][3] == 'g') && (argv[i][4] == '\0'))) {
|
||||
debug = true;
|
||||
}
|
||||
// tab number
|
||||
else if (((argv[i][0] == '-') && (argv[i][1] == 't') && (argv[i][2] == '\0')) ||
|
||||
((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 't') &&
|
||||
@ -100,7 +109,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow w(0, defaultSettings, tabNumber);
|
||||
MainWindow w(0, defaultSettings, debug, tabNumber);
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
@ -42,19 +42,21 @@
|
||||
#include "wirelesswidget.h"
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent, const bool defaultSettings, const int tabNum)
|
||||
MainWindow::MainWindow(QWidget *parent, const bool defaultSettings, const bool debugCmd, const int tabNum)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
ui(new Ui::MainWindow),
|
||||
debug(debugCmd)
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << QString("defaultSettings") << defaultSettings;
|
||||
qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << QString("tabNum") << tabNum;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "defaultSettings" << defaultSettings;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "tabNum" << tabNum;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "debug" << debug;
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->tabWidget->setCurrentIndex(tabNum-1);
|
||||
|
||||
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
|
||||
QDir::separator() + QString("netctl-gui.conf");
|
||||
settingsWin = new SettingsWindow(this, configPath);
|
||||
settingsWin = new SettingsWindow(this, debug, configPath);
|
||||
if (defaultSettings)
|
||||
settingsWin->setDefault();
|
||||
configuration = settingsWin->getSettings();
|
||||
@ -83,9 +85,9 @@ MainWindow::MainWindow(QWidget *parent, const bool defaultSettings, const int ta
|
||||
wirelessWid = new WirelessWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
||||
// backend
|
||||
netctlCommand = new Netctl(this, configuration);
|
||||
netctlProfile = new NetctlProfile(this, configuration);
|
||||
wpaCommand = new WpaSup(this, configuration);
|
||||
netctlCommand = new Netctl(this, debug, configuration);
|
||||
netctlProfile = new NetctlProfile(this, debug, configuration);
|
||||
wpaCommand = new WpaSup(this, debug, configuration);
|
||||
|
||||
createActions();
|
||||
updateTabs(ui->tabWidget->currentIndex());
|
||||
@ -129,10 +131,10 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all"))
|
||||
commandLine.append(configuration[QString("WPASUP_PATH")]);
|
||||
}
|
||||
QProcess command;
|
||||
qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Run cmd" << commandLine.join(QString(" "));
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Run cmd" << commandLine.join(QString(" "));
|
||||
command.start(commandLine.join(QString(" ")));
|
||||
command.waitForFinished(-1);
|
||||
qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (command.exitCode() != 0)
|
||||
return false;
|
||||
else
|
||||
@ -196,12 +198,12 @@ void MainWindow::updateTabs(const int tab)
|
||||
void MainWindow::updateMainTab()
|
||||
{
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin = new ErrorWindow(this, debug, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[MainWindow]" << "[updateMainTab]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[updateMainTab]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QList<QStringList> profiles = netctlCommand->getProfileList();;
|
||||
|
||||
@ -243,7 +245,7 @@ void MainWindow::updateMainTab()
|
||||
|
||||
void MainWindow::updateProfileTab()
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[updateProfileTab]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[updateProfileTab]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
profileTabClear();
|
||||
ui->tabWidget->setEnabled(true);
|
||||
@ -257,14 +259,14 @@ void MainWindow::updateWifiTab()
|
||||
{
|
||||
wifiTabSetEnabled(checkExternalApps(QString("wpasup")));
|
||||
if (!checkExternalApps(QString("wpasup"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin = new ErrorWindow(this, debug, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QStringList> scanResults = wpaCommand->scanWifi();
|
||||
|
||||
qDebug() << "[MainWindow]" << "[updateWifiTab]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[updateWifiTab]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
ui->tableWidget_wifi->setSortingEnabled(false);
|
||||
ui->tableWidget_wifi->selectRow(-1);
|
||||
@ -308,7 +310,7 @@ void MainWindow::updateWifiTab()
|
||||
// main tab slots
|
||||
void MainWindow::mainTabRemoveProfile()
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[mainTabRemoveProfile]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabRemoveProfile]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
// call netctlprofile
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
@ -324,14 +326,14 @@ void MainWindow::mainTabRemoveProfile()
|
||||
void MainWindow::mainTabEnableProfile()
|
||||
{
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin = new ErrorWindow(this, debug, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == 0)
|
||||
return;
|
||||
|
||||
qDebug() << "[MainWindow]" << "[mainTabEnableProfile]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabEnableProfile]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
netctlCommand->enableProfile(profile);
|
||||
@ -355,14 +357,14 @@ void MainWindow::mainTabEnableProfile()
|
||||
void MainWindow::mainTabRestartProfile()
|
||||
{
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin = new ErrorWindow(this, debug, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == 0)
|
||||
return;
|
||||
|
||||
qDebug() << "[MainWindow]" << "[mainTabRestartProfile]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabRestartProfile]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
netctlCommand->restartProfile(profile);
|
||||
@ -377,14 +379,14 @@ void MainWindow::mainTabRestartProfile()
|
||||
void MainWindow::mainTabStartProfile()
|
||||
{
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin = new ErrorWindow(this, debug, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == 0)
|
||||
return;
|
||||
|
||||
qDebug() << "[MainWindow]" << "[mainTabStartProfile]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabStartProfile]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
netctlCommand->startProfile(profile);
|
||||
@ -409,7 +411,7 @@ void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin = new ErrorWindow(this, debug, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
@ -420,7 +422,7 @@ void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[MainWindow]" << "[mainTabRefreshButtons]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabRefreshButtons]";
|
||||
ui->pushButton_mainEnable->setEnabled(true);
|
||||
ui->pushButton_mainStart->setEnabled(true);
|
||||
|
||||
@ -443,7 +445,7 @@ void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt
|
||||
// profile tab slots
|
||||
void MainWindow::profileTabBrowseProfile()
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[profileTabBrowseProfile]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabBrowseProfile]";
|
||||
QString filename = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
QApplication::translate("MainWindow", "Save profile as..."),
|
||||
@ -456,7 +458,7 @@ void MainWindow::profileTabBrowseProfile()
|
||||
|
||||
void MainWindow::profileTabChangeState(const QString current)
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[profileTabChangeState]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabChangeState]";
|
||||
if (current == QString("ethernet")) {
|
||||
generalWid->setShown(true);
|
||||
ipWid->setShown(true);
|
||||
@ -593,7 +595,7 @@ void MainWindow::profileTabChangeState(const QString current)
|
||||
|
||||
void MainWindow::profileTabClear()
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[profileTabClear]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabClear]";
|
||||
ui->lineEdit_profile->clear();
|
||||
|
||||
generalWid->clear();
|
||||
@ -615,17 +617,17 @@ void MainWindow::profileTabCreateProfile()
|
||||
{
|
||||
// error checking
|
||||
if (ui->lineEdit_profile->text().isEmpty()) {
|
||||
errorWin = new ErrorWindow(this, 3);
|
||||
errorWin = new ErrorWindow(this, debug, 3);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (generalWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 4);
|
||||
errorWin = new ErrorWindow(this, debug, 4);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (generalWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 5);
|
||||
errorWin = new ErrorWindow(this, debug, 5);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
@ -639,46 +641,46 @@ void MainWindow::profileTabCreateProfile()
|
||||
(generalWid->connectionType->currentText() == QString("vlan")) ||
|
||||
(generalWid->connectionType->currentText() == QString("macvlan"))) {
|
||||
if (ipWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 6);
|
||||
errorWin = new ErrorWindow(this, debug, 6);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (ipWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 6);
|
||||
errorWin = new ErrorWindow(this, debug, 6);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
||||
if (ethernetWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin = new ErrorWindow(this, debug, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("wireless")) {
|
||||
if (wirelessWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 8);
|
||||
errorWin = new ErrorWindow(this, debug, 8);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (wirelessWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 9);
|
||||
errorWin = new ErrorWindow(this, debug, 9);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (wirelessWid->isOk() == 3) {
|
||||
errorWin = new ErrorWindow(this, 10);
|
||||
errorWin = new ErrorWindow(this, debug, 10);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (wirelessWid->isOk() == 4) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin = new ErrorWindow(this, debug, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (wirelessWid->isOk() == 5) {
|
||||
errorWin = new ErrorWindow(this, 11);
|
||||
errorWin = new ErrorWindow(this, debug, 11);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
@ -687,34 +689,34 @@ void MainWindow::profileTabCreateProfile()
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("pppoe")) {
|
||||
if (pppoeWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin = new ErrorWindow(this, debug, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (pppoeWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 12);
|
||||
errorWin = new ErrorWindow(this, debug, 12);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (pppoeWid->isOk() == 3) {
|
||||
errorWin = new ErrorWindow(this, 13);
|
||||
errorWin = new ErrorWindow(this, debug, 13);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (pppoeWid->isOk() == 4) {
|
||||
errorWin = new ErrorWindow(this, 12);
|
||||
errorWin = new ErrorWindow(this, debug, 12);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
|
||||
if (mobileWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 14);
|
||||
errorWin = new ErrorWindow(this, debug, 14);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (mobileWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin = new ErrorWindow(this, debug, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
@ -723,32 +725,32 @@ void MainWindow::profileTabCreateProfile()
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
|
||||
if (tuntapWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 15);
|
||||
errorWin = new ErrorWindow(this, debug, 15);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (tuntapWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 15);
|
||||
errorWin = new ErrorWindow(this, debug, 15);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("vlan")) {
|
||||
if (ethernetWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin = new ErrorWindow(this, debug, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("macvlan")) {
|
||||
if (ethernetWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin = new ErrorWindow(this, debug, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "[MainWindow]" << "[profileTabCreateProfile]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabCreateProfile]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
// read settings
|
||||
QString profile = ui->lineEdit_profile->text();
|
||||
@ -846,7 +848,7 @@ void MainWindow::profileTabCreateProfile()
|
||||
|
||||
void MainWindow::profileTabLoadProfile()
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[profileTabLoadProfile]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabLoadProfile]";
|
||||
QString profile = ui->lineEdit_profile->text();
|
||||
QMap<QString, QString> settings = netctlProfile->getSettingsFromProfile(profile);
|
||||
|
||||
@ -916,7 +918,7 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
|
||||
if (!passwd.isEmpty())
|
||||
delete passwdWid;
|
||||
|
||||
qDebug() << "[MainWindow]" << "[connectToUnknownEssid]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[connectToUnknownEssid]";
|
||||
QMap<QString, QString> settings;
|
||||
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
|
||||
settings[QString("Interface")] = wpaCommand->getInterfaceList()[0];
|
||||
@ -958,7 +960,7 @@ void MainWindow::setHiddenName(const QString name)
|
||||
void MainWindow::wifiTabStart()
|
||||
{
|
||||
if (!checkExternalApps(QString("wpasup"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin = new ErrorWindow(this, debug, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
@ -977,7 +979,7 @@ void MainWindow::wifiTabStart()
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[MainWindow]" << "[wifiTabStart]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[wifiTabStart]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text();
|
||||
QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
|
||||
@ -1023,7 +1025,7 @@ void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
if (!checkExternalApps(QString("wpasup"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin = new ErrorWindow(this, debug, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
@ -1036,7 +1038,7 @@ void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[MainWindow]" << "[wifiTabRefreshButtons]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[wifiTabRefreshButtons]";
|
||||
ui->pushButton_wifiStart->setEnabled(true);
|
||||
QString item = ui->tableWidget_wifi->item(current->row(), 1)->text();
|
||||
if (checkState(QString("exists"), item)) {
|
||||
|
@ -52,6 +52,7 @@ class MainWindow : public QMainWindow
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0,
|
||||
const bool defaultSettings = false,
|
||||
const bool debugCmd = false,
|
||||
const int tabNum = 1);
|
||||
~MainWindow();
|
||||
Netctl *netctlCommand;
|
||||
@ -106,6 +107,7 @@ private:
|
||||
bool checkExternalApps(const QString apps);
|
||||
bool checkState(const QString state, const QString item);
|
||||
void createActions();
|
||||
bool debug;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
};
|
||||
|
@ -24,8 +24,9 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
Netctl::Netctl(MainWindow *wid, const QMap<QString, QString> settings)
|
||||
: parent(wid)
|
||||
Netctl::Netctl(MainWindow *wid, const bool debugCmd, const QMap<QString, QString> settings)
|
||||
: parent(wid),
|
||||
debug(debugCmd)
|
||||
{
|
||||
netctlCommand = settings[QString("NETCTL_PATH")];
|
||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||
@ -49,7 +50,7 @@ QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, cons
|
||||
QString(" ") + profile;
|
||||
else
|
||||
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
|
||||
qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Run cmd" << commandText;
|
||||
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
return command.readAllStandardOutput();
|
||||
@ -65,10 +66,10 @@ bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QStrin
|
||||
QString(" ") + profile;
|
||||
else
|
||||
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
|
||||
qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Run cmd" << commandText;
|
||||
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (command.exitCode() == 0)
|
||||
return true;
|
||||
else
|
||||
@ -101,7 +102,7 @@ QStringList Netctl::getProfileDescriptions(const QStringList profileList)
|
||||
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profileList[i];
|
||||
qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Check" << profileUrl;
|
||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Check" << profileUrl;
|
||||
QFile profile(profileUrl);
|
||||
QString fileStr;
|
||||
if (profile.open(QIODevice::ReadOnly))
|
||||
@ -152,7 +153,7 @@ QString Netctl::getSsidFromProfile(const QString profile)
|
||||
{
|
||||
QString ssidName = QString("");
|
||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
|
||||
qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Check" << profileUrl;
|
||||
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Check" << profileUrl;
|
||||
QFile profileFile(profileUrl);
|
||||
QString fileStr;
|
||||
if (!profileFile.open(QIODevice::ReadOnly))
|
||||
|
@ -31,6 +31,7 @@ class Netctl : public QObject
|
||||
|
||||
public:
|
||||
explicit Netctl(MainWindow *wid = 0,
|
||||
const bool debugCmd = false,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~Netctl();
|
||||
// general information
|
||||
@ -49,6 +50,7 @@ public slots:
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
bool debug;
|
||||
QString netctlCommand;
|
||||
QDir *profileDirectory;
|
||||
QString sudoCommand;
|
||||
|
@ -26,8 +26,9 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
NetctlProfile::NetctlProfile(MainWindow *wid, const QMap<QString, QString> settings)
|
||||
: parent(wid)
|
||||
NetctlProfile::NetctlProfile(MainWindow *wid, const bool debugCmd, const QMap<QString, QString> settings)
|
||||
: parent(wid),
|
||||
debug(debugCmd)
|
||||
{
|
||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
@ -45,7 +46,7 @@ bool NetctlProfile::copyProfile(const QString oldPath)
|
||||
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
|
||||
QProcess command;
|
||||
QString commandText = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
|
||||
qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << commandText;
|
||||
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
if (command.exitCode() == 0)
|
||||
@ -60,7 +61,7 @@ bool NetctlProfile::removeProfile(const QString profile)
|
||||
QString profilePath = profileDirectory->absolutePath() + QDir::separator() + profile;
|
||||
QProcess command;
|
||||
QString commandText = sudoCommand + QString(" /usr/bin/rm ") + profilePath;
|
||||
qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << commandText;
|
||||
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
if (command.exitCode() == 0)
|
||||
@ -77,7 +78,7 @@ QString NetctlProfile::createProfile(const QString profile, const QMap<QString,
|
||||
QString profileTempName = QDir::homePath() + QDir::separator() +
|
||||
QString(".cache") + QDir::separator() + QFileInfo(profile).fileName();
|
||||
QFile profileFile(profileTempName);
|
||||
qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName;
|
||||
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName;
|
||||
|
||||
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return profileTempName;
|
||||
@ -115,7 +116,7 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
||||
else
|
||||
profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
|
||||
QFile profileFile(profileUrl);
|
||||
qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Read from" << profileUrl;
|
||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Read from" << profileUrl;
|
||||
|
||||
if (!profileFile.open(QIODevice::ReadOnly))
|
||||
return settings;
|
||||
|
@ -31,6 +31,7 @@ class NetctlProfile : public QObject
|
||||
|
||||
public:
|
||||
explicit NetctlProfile(MainWindow *wid = 0,
|
||||
const bool debugCmd = false,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~NetctlProfile();
|
||||
bool copyProfile(const QString oldPath);
|
||||
@ -40,6 +41,7 @@ public:
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
bool debug;
|
||||
QDir *profileDirectory;
|
||||
QString sudoCommand;
|
||||
};
|
||||
|
@ -26,9 +26,10 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
SettingsWindow::SettingsWindow(MainWindow *wid, const QString configFile)
|
||||
SettingsWindow::SettingsWindow(MainWindow *wid, const bool debugCmd, const QString configFile)
|
||||
: QMainWindow(wid),
|
||||
parent(wid),
|
||||
debug(debugCmd),
|
||||
file(configFile),
|
||||
ui(new Ui::SettingsWindow)
|
||||
{
|
||||
@ -206,7 +207,7 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
@ -233,7 +234,7 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
||||
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
}
|
||||
|
||||
@ -257,7 +258,7 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
||||
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
@ -287,7 +288,7 @@ QMap<QString, QString> SettingsWindow::getSettings()
|
||||
configFile.close();
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
|
@ -34,6 +34,7 @@ class SettingsWindow : public QMainWindow
|
||||
|
||||
public:
|
||||
explicit SettingsWindow(MainWindow *wid = 0,
|
||||
const bool debugCmd = false,
|
||||
const QString configFile = QString(""));
|
||||
~SettingsWindow();
|
||||
QMap<QString, QString> getDefault();
|
||||
@ -57,6 +58,7 @@ private slots:
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
bool debug;
|
||||
QString file;
|
||||
Ui::SettingsWindow *ui;
|
||||
void createActions();
|
||||
|
@ -25,8 +25,9 @@
|
||||
#include "sleepthread.h"
|
||||
|
||||
|
||||
WpaSup::WpaSup(MainWindow *wid, const QMap<QString, QString> settings)
|
||||
: parent(wid)
|
||||
WpaSup::WpaSup(MainWindow *wid, const bool debugCmd, const QMap<QString, QString> settings)
|
||||
: parent(wid),
|
||||
debug(debugCmd)
|
||||
{
|
||||
ctrlDir = settings[QString("CTRL_DIR")];
|
||||
ctrlGroup = settings[QString("CTRL_GROUP")];
|
||||
@ -70,7 +71,7 @@ QStringList WpaSup::getInterfaceList()
|
||||
interfaces.append(mainInterface);
|
||||
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (int i=0; i<allInterfaces.count(); i++) {
|
||||
qDebug() << "[WpaSup]" << "[getInterfaceList]" << ":" << "Check directory"
|
||||
if (debug) qDebug() << "[WpaSup]" << "[getInterfaceList]" << ":" << "Check directory"
|
||||
<< ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + QDir::separator() + QString("wireless");
|
||||
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
|
||||
QDir::separator() + QString("wireless")).exists())
|
||||
@ -110,11 +111,11 @@ bool WpaSup::wpaCliCall(const QString commandLine)
|
||||
QProcess command;
|
||||
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
||||
QString(" -P ") + pidFile + QString(" ") + commandLine;
|
||||
qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Run cmd" << commandText;
|
||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
SleepThread::sleep(1);
|
||||
qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (command.exitCode() == 0)
|
||||
return true;
|
||||
else
|
||||
@ -128,7 +129,7 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
|
||||
QProcess command;
|
||||
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
||||
QString(" -P ") + pidFile + QString(" ") + commandLine;
|
||||
qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << commandText;
|
||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
return command.readAllStandardOutput();
|
||||
@ -213,11 +214,11 @@ bool WpaSup::startWpaSupplicant()
|
||||
QString commandText = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile +
|
||||
QString(" -i ") + interface + QString(" -D ") + wpaDrivers +
|
||||
QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\"");
|
||||
qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Run cmd" << commandText;
|
||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
SleepThread::sleep(1);
|
||||
qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (command.exitCode() != 0)
|
||||
return false;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ class WpaSup : public QObject
|
||||
|
||||
public:
|
||||
explicit WpaSup(MainWindow *wid = 0,
|
||||
const bool debugCmd = false,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~WpaSup();
|
||||
// general information
|
||||
@ -47,6 +48,7 @@ public slots:
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
bool debug;
|
||||
QString ctrlDir;
|
||||
QString ctrlGroup;
|
||||
QDir *ifaceDirectory;
|
||||
|
Loading…
Reference in New Issue
Block a user