diff --git a/sources/gui/src/errorwindow.cpp b/sources/gui/src/errorwindow.cpp index a49609d..a015d2a 100644 --- a/sources/gui/src/errorwindow.cpp +++ b/sources/gui/src/errorwindow.cpp @@ -21,12 +21,13 @@ #include -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); } diff --git a/sources/gui/src/errorwindow.h b/sources/gui/src/errorwindow.h index 9a52b78..b5f8387 100644 --- a/sources/gui/src/errorwindow.h +++ b/sources/gui/src/errorwindow.h @@ -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); }; diff --git a/sources/gui/src/ipwidget.cpp b/sources/gui/src/ipwidget.cpp index 2a8d34d..5baddce 100644 --- a/sources/gui/src/ipwidget.cpp +++ b/sources/gui/src/ipwidget.cpp @@ -18,7 +18,6 @@ #include "ipwidget.h" #include "ui_ipwidget.h" -#include #include diff --git a/sources/gui/src/main.cpp b/sources/gui/src/main.cpp index 5440163..611e907 100644 --- a/sources/gui/src/main.cpp +++ b/sources/gui/src/main.cpp @@ -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; isetupUi(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 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 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 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 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)) { diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h index 56ddc8d..24a643a 100644 --- a/sources/gui/src/mainwindow.h +++ b/sources/gui/src/mainwindow.h @@ -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 configuration; }; diff --git a/sources/gui/src/netctlinteract.cpp b/sources/gui/src/netctlinteract.cpp index 5a70605..446203f 100644 --- a/sources/gui/src/netctlinteract.cpp +++ b/sources/gui/src/netctlinteract.cpp @@ -24,8 +24,9 @@ #include "mainwindow.h" -Netctl::Netctl(MainWindow *wid, const QMap settings) - : parent(wid) +Netctl::Netctl(MainWindow *wid, const bool debugCmd, const QMap 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; iabsolutePath() + 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)) diff --git a/sources/gui/src/netctlinteract.h b/sources/gui/src/netctlinteract.h index 0262ec0..f0410cc 100644 --- a/sources/gui/src/netctlinteract.h +++ b/sources/gui/src/netctlinteract.h @@ -31,6 +31,7 @@ class Netctl : public QObject public: explicit Netctl(MainWindow *wid = 0, + const bool debugCmd = false, const QMap settings = QMap()); ~Netctl(); // general information @@ -49,6 +50,7 @@ public slots: private: MainWindow *parent; + bool debug; QString netctlCommand; QDir *profileDirectory; QString sudoCommand; diff --git a/sources/gui/src/netctlprofile.cpp b/sources/gui/src/netctlprofile.cpp index d91068d..369ac14 100644 --- a/sources/gui/src/netctlprofile.cpp +++ b/sources/gui/src/netctlprofile.cpp @@ -26,8 +26,9 @@ #include "mainwindow.h" -NetctlProfile::NetctlProfile(MainWindow *wid, const QMap settings) - : parent(wid) +NetctlProfile::NetctlProfile(MainWindow *wid, const bool debugCmd, const QMap 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 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; diff --git a/sources/gui/src/netctlprofile.h b/sources/gui/src/netctlprofile.h index ad4d2ed..7236ee5 100644 --- a/sources/gui/src/netctlprofile.h +++ b/sources/gui/src/netctlprofile.h @@ -31,6 +31,7 @@ class NetctlProfile : public QObject public: explicit NetctlProfile(MainWindow *wid = 0, + const bool debugCmd = false, const QMap settings = QMap()); ~NetctlProfile(); bool copyProfile(const QString oldPath); @@ -40,6 +41,7 @@ public: private: MainWindow *parent; + bool debug; QDir *profileDirectory; QString sudoCommand; }; diff --git a/sources/gui/src/settingswindow.cpp b/sources/gui/src/settingswindow.cpp index edca15a..85e025e 100644 --- a/sources/gui/src/settingswindow.cpp +++ b/sources/gui/src/settingswindow.cpp @@ -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 SettingsWindow::readSettings() settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text(); for (int i=0; i getDefault(); @@ -57,6 +58,7 @@ private slots: private: MainWindow *parent; + bool debug; QString file; Ui::SettingsWindow *ui; void createActions(); diff --git a/sources/gui/src/wpasupinteract.cpp b/sources/gui/src/wpasupinteract.cpp index ea5e349..d76f087 100644 --- a/sources/gui/src/wpasupinteract.cpp +++ b/sources/gui/src/wpasupinteract.cpp @@ -25,8 +25,9 @@ #include "sleepthread.h" -WpaSup::WpaSup(MainWindow *wid, const QMap settings) - : parent(wid) +WpaSup::WpaSup(MainWindow *wid, const bool debugCmd, const QMap 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; ipath() + 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; } diff --git a/sources/gui/src/wpasupinteract.h b/sources/gui/src/wpasupinteract.h index 7940627..a80a542 100644 --- a/sources/gui/src/wpasupinteract.h +++ b/sources/gui/src/wpasupinteract.h @@ -31,6 +31,7 @@ class WpaSup : public QObject public: explicit WpaSup(MainWindow *wid = 0, + const bool debugCmd = false, const QMap settings = QMap()); ~WpaSup(); // general information @@ -47,6 +48,7 @@ public slots: private: MainWindow *parent; + bool debug; QString ctrlDir; QString ctrlGroup; QDir *ifaceDirectory;