diff --git a/sources/gui/src/errorwindow.cpp b/sources/gui/src/errorwindow.cpp index af5f47e..d4cf561 100644 --- a/sources/gui/src/errorwindow.cpp +++ b/sources/gui/src/errorwindow.cpp @@ -35,10 +35,11 @@ ErrorWindow::~ErrorWindow() } -QStringList ErrorWindow::getMessage(const int mess) +QStringList ErrorWindow::getMessage(const int mess, const QString custom) { if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]"; if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]" << ":" << "Message" << mess; + if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]" << ":" << "Custom message" << custom; QString message, title; switch(mess) { @@ -123,6 +124,8 @@ QStringList ErrorWindow::getMessage(const int mess) message = QApplication::translate("ErrorWindow", "Unknown error"); break; } + if (!custom.isEmpty()) + message = custom; QStringList fullMessage; fullMessage.append(title); @@ -168,13 +171,14 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess) } -void ErrorWindow::showWindow(const int mess, const QString sender) +void ErrorWindow::showWindow(const int mess, const QString sender, const QString custom) { if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]"; if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Message" << mess; if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Sender" << sender; + if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Custom message" << custom; - QStringList message = getMessage(mess); + QStringList message = getMessage(mess, custom); QMessageBox messageBox; messageBox.setText(message[0]); messageBox.setInformativeText(message[1]); diff --git a/sources/gui/src/errorwindow.h b/sources/gui/src/errorwindow.h index c1bbcab..ad0d2c8 100644 --- a/sources/gui/src/errorwindow.h +++ b/sources/gui/src/errorwindow.h @@ -33,11 +33,12 @@ public: public slots: void showWindow(const int mess = 0, - const QString sender = QString()); + const QString sender = QString(), + const QString custom = QString()); private: bool debug; - QStringList getMessage(const int mess); + QStringList getMessage(const int mess, const QString custom = QString()); QMessageBox::Icon getIcon(const int mess); }; diff --git a/sources/gui/src/main.cpp b/sources/gui/src/main.cpp index e929ce0..4b1eae3 100644 --- a/sources/gui/src/main.cpp +++ b/sources/gui/src/main.cpp @@ -42,7 +42,7 @@ bool restoreExistSession() QString("Restore")); QDBusMessage response = bus.call(request); QList arguments = response.arguments(); - return ((arguments.size() == 1) && arguments[0].toBool()); + return !arguments.isEmpty(); } diff --git a/sources/gui/src/mainactions.cpp b/sources/gui/src/mainactions.cpp index fbbabbe..87ec7fc 100644 --- a/sources/gui/src/mainactions.cpp +++ b/sources/gui/src/mainactions.cpp @@ -129,7 +129,10 @@ bool MainWindow::forceStartHelper() TaskResult process = runTask(cmd, false); if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Cmd returns" << process.exitCode; - return isHelperActive(); + if (process.exitCode == 0) + return true; + else + return false; } @@ -138,12 +141,10 @@ bool MainWindow::forceStopHelper() if (debug) qDebug() << "[MainWindow]" << "[forceStartHelper]"; QList responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, - DBUS_HELPER_INTERFACE, QString("Close")); + DBUS_HELPER_INTERFACE, QString("Close"), + QList(), true); - if (responce.size() == 1) - return true; - else - return false; + return !responce.isEmpty(); } @@ -184,12 +185,19 @@ void MainWindow::connectToUnknownEssid(const QString passwd) if (passwdWid != 0) delete passwdWid; - if (netctlCommand->getWirelessInterfaceList().isEmpty()) + QStringList interfaces; + if (useHelper) + interfaces = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"), + QList(), true)[0].toStringList(); + else + interfaces = netctlCommand->getWirelessInterfaceList(); + if (interfaces.isEmpty()) return; QMap settings; settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'"); - settings[QString("Interface")] = netctlCommand->getWirelessInterfaceList()[0]; + settings[QString("Interface")] = interfaces[0]; settings[QString("Connection")] = QString("wireless"); QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 2)->text(); if (security.contains(QString("WPA"))) @@ -209,10 +217,33 @@ void MainWindow::connectToUnknownEssid(const QString passwd) QString profile = QString("netctl-gui-") + settings[QString("ESSID")]; profile.remove(QChar('"')).remove(QChar('\'')); - QString profileTempName = netctlProfile->createProfile(profile, settings); - if (netctlProfile->copyProfile(profileTempName)) + bool status = false; + if (useHelper) { + QStringList settingsList; + for (int i=0; i args; + args.append(profile); + args.append(settingsList); + sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, + DBUS_HELPER_INTERFACE, QString("Create"), + args, true); + args.clear(); + args.append(profile); + sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, + DBUS_HELPER_INTERFACE, QString("Start"), + args, true); + status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isProfileActive"), + args, true)[0].toBool(); + } + else { + QString profileTempName = netctlProfile->createProfile(profile, settings); + netctlProfile->copyProfile(profileTempName); netctlCommand->startProfile(profile); - if (netctlCommand->isProfileActive(profile)) + status = netctlCommand->isProfileActive(profile); + } + if (status) ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); else ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); @@ -335,20 +366,27 @@ void MainWindow::mainTabEnableProfile() return; ui->tabWidget->setDisabled(true); + bool previous = !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty(); + bool current; QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); - netctlCommand->enableProfile(profile); - if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) { - if (netctlCommand->isProfileEnabled(profile)) - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); - else - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); + if (useHelper) { + QList args; + args.append(profile); + sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, + DBUS_HELPER_INTERFACE, QString("Enable"), + args, true); + current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isProfileEnabled"), + args, true)[0].toBool(); } else { - if (netctlCommand->isProfileEnabled(profile)) - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); - else - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); + netctlCommand->enableProfile(profile); + current = netctlCommand->isProfileEnabled(profile); } + if (current != previous) + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); + else + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); updateMainTab(); } @@ -361,7 +399,17 @@ void MainWindow::mainTabRemoveProfile() ui->tabWidget->setDisabled(true); // call netctlprofile QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); - if (netctlProfile->removeProfile(profile)) + bool status; + if (useHelper) { + QList args; + args.append(profile); + status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, + DBUS_HELPER_INTERFACE, QString("Remove"), + args, true)[0].toBool(); + } + else + status = netctlProfile->removeProfile(profile); + if (status) ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); else ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); @@ -380,8 +428,22 @@ void MainWindow::mainTabRestartProfile() ui->tabWidget->setDisabled(true); QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); - netctlCommand->restartProfile(profile); - if (netctlCommand->isProfileActive(profile)) + bool status = false; + if (useHelper) { + QList args; + args.append(profile); + sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, + DBUS_HELPER_INTERFACE, QString("Restart"), + args, true)[0].toBool(); + status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isProfileActive"), + args, true)[0].toBool(); + } + else { + netctlCommand->restartProfile(profile); + status = netctlCommand->isProfileActive(profile); + } + if (status) ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); else ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); @@ -399,24 +461,27 @@ void MainWindow::mainTabStartProfile() return; ui->tabWidget->setDisabled(true); + bool previous = !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty(); + bool current; QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); - if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) { - netctlCommand->startProfile(profile); - if (netctlCommand->isProfileActive(profile)) - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); - else - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); + if (useHelper) { + QList args; + args.append(profile); + sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, + DBUS_HELPER_INTERFACE, QString("Start"), + args, true); + current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isProfileActive"), + args, true)[0].toBool(); } else { - if (netctlCommand->getActiveProfile().isEmpty()) - netctlCommand->startProfile(profile); - else - netctlCommand->switchToProfile(profile); - if (netctlCommand->isProfileActive(profile)) - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); - else - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); + netctlCommand->startProfile(profile); + current = netctlCommand->isProfileActive(profile); } + if (current != previous) + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); + else + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); updateMainTab(); } @@ -594,7 +659,13 @@ void MainWindow::profileTabClear() if (debug) qDebug() << "[MainWindow]" << "[profileTabClear]"; ui->comboBox_profile->clear(); - QList profiles = netctlCommand->getProfileList(); + QList profiles; + if (useHelper) + profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("ProfileList"), + QList(), true)); + else + profiles = netctlCommand->getProfileList(); for (int i=0; icomboBox_profile->addItem(profiles[i].name); ui->comboBox_profile->setCurrentIndex(-1); @@ -776,8 +847,23 @@ void MainWindow::profileTabCreateProfile() } // call netctlprofile - QString profileTempName = netctlProfile->createProfile(profile, settings); - if (netctlProfile->copyProfile(profileTempName)) + bool status = false; + if (useHelper) { + QStringList settingsList; + for (int i=0; i args; + args.append(profile); + args.append(settingsList); + status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, + DBUS_HELPER_INTERFACE, QString("Create"), + args, true)[0].toBool(); + } + else { + QString profileTempName = netctlProfile->createProfile(profile, settings); + status = netctlProfile->copyProfile(profileTempName); + } + if (status) ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); else ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); @@ -793,7 +879,24 @@ void MainWindow::profileTabLoadProfile() QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName(); if (profile.isEmpty()) return; - QMap settings = netctlProfile->getSettingsFromProfile(profile); + QMap settings; + if (useHelper) { + QList args; + args.append(profile); + QStringList settingsList = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("Profile"), + args, true)[0].toStringList(); + for (int i=0; igetSettingsFromProfile(profile); + + + if (settings.isEmpty()) return errorWin->showWindow(17, QString("[MainWindow] : [profileTabLoadProfile]")); @@ -848,7 +951,17 @@ void MainWindow::profileTabRemoveProfile() ui->tabWidget->setDisabled(true); // call netctlprofile QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName(); - if (netctlProfile->removeProfile(profile)) + bool status = false; + if (useHelper) { + QList args; + args.append(profile); + status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, + DBUS_HELPER_INTERFACE, QString("Remove"), + args, true)[0].toBool(); + } + else + status = netctlProfile->removeProfile(profile); + if (status) ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); else ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); @@ -947,20 +1060,32 @@ void MainWindow::wifiTabStart() hiddenNetwork = false; QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text(); if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 4)->text().isEmpty()) { - QString profileName = wpaCommand->existentProfile(profile); - netctlCommand->startProfile(profileName); - if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text().isEmpty()) { - if (netctlCommand->isProfileActive(profileName)) - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); - else - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); + bool previous = !ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text().isEmpty(); + bool current; + if (useHelper) { + QList args; + args.append(profile); + QString profileName = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("ProfileByEssid"), + args, true)[0].toString(); + args.clear(); + args.append(profileName); + sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, + DBUS_HELPER_INTERFACE, QString("Start"), + args, true); + current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isProfileActive"), + args, true)[0].toBool(); } else { - if (netctlCommand->isProfileActive(profileName)) - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); - else - ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); + QString profileName = wpaCommand->existentProfile(profile); + netctlCommand->startProfile(profileName); + current = netctlCommand->isProfileActive(profileName); } + if (current != previous) + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); + else + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); } else { QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text(); diff --git a/sources/gui/src/mainwindow.cpp b/sources/gui/src/mainwindow.cpp index 9bcfa27..d4be4d5 100644 --- a/sources/gui/src/mainwindow.cpp +++ b/sources/gui/src/mainwindow.cpp @@ -123,7 +123,8 @@ QString MainWindow::getInformation() QString status; if (useHelper) { QStringList request = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("Information"))[0].toStringList(); + DBUS_HELPER_INTERFACE, QString("Information"), + QList(), true)[0].toStringList(); profile = request[0]; status = request[1]; } @@ -162,12 +163,10 @@ bool MainWindow::isHelperActive() if (debug) qDebug() << "[MainWindow]" << "[isHelperActive]"; QList responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, - DBUS_HELPER_INTERFACE, QString("Active")); + DBUS_HELPER_INTERFACE, QString("Active"), + QList(), true); - if (responce.size() == 1) - return true; - else - return false; + return (!responce.isEmpty()); } @@ -376,27 +375,40 @@ void MainWindow::deleteObjects() QList MainWindow::sendDBusRequest(const QString service, const QString path, const QString interface, const QString cmd, - bool system) + const QList args, bool system) { if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]"; if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Service" << service; if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Path" << path; if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Interface" << interface; if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "cmd" << cmd; + if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "args" << args; if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "is system bus" << system; QList arguments; + QDBusMessage response; if (system) { QDBusConnection bus = QDBusConnection::systemBus(); QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd); - QDBusMessage response = bus.call(request); - arguments = response.arguments(); + if (!args.isEmpty()) + request.setArguments(args); + response = bus.call(request); } else { QDBusConnection bus = QDBusConnection::sessionBus(); QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd); - QDBusMessage response = bus.call(request); - arguments = response.arguments(); + if (!args.isEmpty()) + request.setArguments(args); + response = bus.call(request); + } + arguments = response.arguments(); + if ((arguments.size() == 0) && + (service != DBUS_HELPER_SERVICE) && + (path != DBUS_CONTROL_PATH) && + (interface != DBUS_HELPER_INTERFACE) && + (cmd != QString("Active"))) { + if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Error message" << response.errorMessage(); + errorWin->showWindow(0, QString("[MainWindow] : [sendDBusRequest]"), response.errorMessage()); } return arguments; @@ -506,6 +518,7 @@ void MainWindow::updateConfiguration(const QMap args) delete settingsWin; createObjects(); + if (useHelper) useHelper = isHelperActive(); setTab(args[QString("tab")].toInt() - 1); createActions(); setIconsToTabs(); @@ -669,13 +682,21 @@ void MainWindow::updateMainTab() return errorWin->showWindow(1, QString("[MainWindow] : [updateMainTab]")); ui->tabWidget->setDisabled(true); - ui->widget_netctlAuto->setHidden(!netctlCommand->isNetctlAutoRunning()); QList profiles; - if (useHelper) + bool netctlAutoStatus = false; + if (useHelper) { + netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"), + QList(), true)[0].toBool(); profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("ProfileList"))); - else + DBUS_HELPER_INTERFACE, QString("ProfileList"), + QList(), true)); + } + else { + netctlAutoStatus = netctlCommand->isNetctlAutoRunning(); profiles = netctlCommand->getProfileList(); + } + ui->widget_netctlAuto->setHidden(!netctlAutoStatus); ui->tableWidget_main->setSortingEnabled(false); ui->tableWidget_main->selectRow(-1); @@ -759,8 +780,9 @@ void MainWindow::updateWifiTab() ui->tabWidget->setDisabled(true); QList scanResults; if (useHelper) - scanResults = parseOutputWifi(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("WiFi"))); + scanResults = parseOutputWifi(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH, + DBUS_HELPER_INTERFACE, QString("WiFi"), + QList(), true)); else scanResults = wpaCommand->scanWifi(); diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h index 8256899..cfc7842 100644 --- a/sources/gui/src/mainwindow.h +++ b/sources/gui/src/mainwindow.h @@ -147,6 +147,7 @@ private: void keyPressEvent(QKeyEvent *pressedKey); QList sendDBusRequest(const QString service, const QString path, const QString interface, const QString cmd, + const QList args = QList(), const bool system = true); void setIconsToTabs(); QString configPath; diff --git a/sources/helper/src/controladaptor.cpp b/sources/helper/src/controladaptor.cpp index df0c453..edf75a5 100644 --- a/sources/helper/src/controladaptor.cpp +++ b/sources/helper/src/controladaptor.cpp @@ -27,6 +27,7 @@ ControlAdaptor::ControlAdaptor(NetctlHelper *parent, const QMap settings; + for (int i=0; icreateProfile(profile, settings); + + return netctlProfile->copyProfile(temporaryProfile); +} + + bool ControlAdaptor::Remove(const QString profile) { return netctlProfile->removeProfile(profile); } + + +// wpaCommand +QStringList ControlAdaptor::WiFi() +{ + QList wifiPoints = wpaCommand->scanWifi(); + QStringList info; + for (int i=0; i arguments = response.arguments(); - return ((arguments.size() == 1) && arguments[0].toBool()); + return !arguments.isEmpty(); } int main(int argc, char *argv[]) { -// setuid(getuid()); -// qDebug() << getuid(); -// qDebug() << geteuid(); // detach from console bool isDaemon = true; for (int i=0; i settings = netctlProfile->getSettingsFromProfile(profile); QStringList settingsList; for (int i=0; iquit(); } diff --git a/sources/netctlgui/src/netctlinteract.cpp b/sources/netctlgui/src/netctlinteract.cpp index 24937d5..5015bbf 100644 --- a/sources/netctlgui/src/netctlinteract.cpp +++ b/sources/netctlgui/src/netctlinteract.cpp @@ -364,12 +364,13 @@ bool Netctl::isNetctlAutoRunning() if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Could not find service"; return false; } - if (getWirelessInterfaceList().isEmpty()) { + QStringList interfaces = getWirelessInterfaceList(); + if (interfaces.isEmpty()) { if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Could not interface"; return false; } - QString interface = getWirelessInterfaceList()[0]; + QString interface = interfaces[0]; QString argument = netctlAutoService + QString("@") + interface + QString(".service"); return cmdCall(false, systemctlCommand, QString("is-active"), argument); @@ -523,12 +524,13 @@ bool Netctl::autoEnableService() if (debug) qDebug() << "[Netctl]" << "[autoEnableService]" << ":" << "Could not find service"; return false; } - if (getWirelessInterfaceList().isEmpty()) { + QStringList interfaces = getWirelessInterfaceList(); + if (interfaces.isEmpty()) { if (debug) qDebug() << "[Netctl]" << "[autoEnableService]" << ":" << "Could not interface"; return false; } - QString interface = getWirelessInterfaceList()[0]; + QString interface = interfaces[0]; QString argument = netctlAutoService + QString("@") + interface + QString(".service"); if (isNetctlAutoEnabled()) @@ -548,12 +550,13 @@ bool Netctl::autoRestartService() if (debug) qDebug() << "[Netctl]" << "[autoRestartService]" << ":" << "Could not find service"; return false; } - if (getWirelessInterfaceList().isEmpty()) { + QStringList interfaces = getWirelessInterfaceList(); + if (interfaces.isEmpty()) { if (debug) qDebug() << "[Netctl]" << "[autoRestartService]" << ":" << "Could not interface"; return false; } - QString interface = getWirelessInterfaceList()[0]; + QString interface = interfaces[0]; QString argument = netctlAutoService + QString("@") + interface + QString(".service"); if (isNetctlAutoRunning()) @@ -573,12 +576,13 @@ bool Netctl::autoStartService() if (debug) qDebug() << "[Netctl]" << "[autoStartService]" << ":" << "Could not find service"; return false; } - if (getWirelessInterfaceList().isEmpty()) { + QStringList interfaces = getWirelessInterfaceList(); + if (interfaces.isEmpty()) { if (debug) qDebug() << "[Netctl]" << "[autoStartService]" << ":" << "Could not interface"; return false; } - QString interface = getWirelessInterfaceList()[0]; + QString interface = interfaces[0]; QString argument = netctlAutoService + QString("@") + interface + QString(".service"); if (isNetctlAutoRunning()) diff --git a/sources/netctlgui/src/wpasupinteract.cpp b/sources/netctlgui/src/wpasupinteract.cpp index 89c3930..21401bf 100644 --- a/sources/netctlgui/src/wpasupinteract.cpp +++ b/sources/netctlgui/src/wpasupinteract.cpp @@ -253,14 +253,15 @@ bool WpaSup::startWpaSupplicant() if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find library"; return false; } - if (netctlCommand->getWirelessInterfaceList().isEmpty()) { + QStringList interfaces = netctlCommand->getWirelessInterfaceList(); + if (interfaces.isEmpty()) { if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find interfaces"; return false; } if (QFile(pidFile).exists()) return true; - QString interface = netctlCommand->getWirelessInterfaceList()[0]; + QString interface = interfaces[0]; QString cmd = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile + QString(" -i ") + interface + QString(" -D ") + wpaDrivers + QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\""); @@ -311,12 +312,13 @@ QString WpaSup::getWpaCliOutput(const QString commandLine) if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find library"; return QString(); } - if (netctlCommand->getWirelessInterfaceList().isEmpty()) { + QStringList interfaces = netctlCommand->getWirelessInterfaceList(); + if (interfaces.isEmpty()) { if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find interfaces"; return QString(); } - QString interface = netctlCommand->getWirelessInterfaceList()[0]; + QString interface = interfaces[0]; QString cmd = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir + QString(" -P ") + pidFile + QString(" ") + commandLine; if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << cmd; @@ -365,12 +367,13 @@ bool WpaSup::wpaCliCall(const QString commandLine) if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find library"; return false; } - if (netctlCommand->getWirelessInterfaceList().isEmpty()) { + QStringList interfaces = netctlCommand->getWirelessInterfaceList(); + if (interfaces.isEmpty()) { if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find interfaces"; return false; } - QString interface = netctlCommand->getWirelessInterfaceList()[0]; + QString interface = interfaces[0]; QString cmd = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir + QString(" -P ") + pidFile + QString(" ") + commandLine; if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << cmd;