diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 2f1949b..a720c6a 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -23,7 +23,7 @@ message (STATUS "Build date: ${CURRENT_DATE}") # install options option (USE_QT5 "Use Qt5 instead of Qt4" ON) -option (BUILD_DOCS "Build documentation" OFF) +option (BUILD_DOCS "Build documentation and install headers" ON) option (BUILD_GUI "Build GUI" ON) option (BUILD_LIBRARY "Build library" ON) option (BUILD_DATAENGINE "Build data engine" ON) diff --git a/sources/netctlgui/include/netctlgui/netctlinteract.h b/sources/netctlgui/include/netctlgui/netctlinteract.h index 37d61e0..1b6338e 100644 --- a/sources/netctlgui/include/netctlgui/netctlinteract.h +++ b/sources/netctlgui/include/netctlgui/netctlinteract.h @@ -14,6 +14,14 @@ * You should have received a copy of the GNU General Public License * * along with netctl-gui. If not, see http://www.gnu.org/licenses/ * ***************************************************************************/ +/** + * @file netctlinteract.h + * Header of netctlgui library + * @author Evgeniy Alekseev + * @copyright GPLv3 + * @bug https://github.com/arcan1s/netctl-gui/issues + */ + #ifndef NETCTLINTERACT_H #define NETCTLINTERACT_H @@ -23,60 +31,270 @@ #include +/** + * @brief The Netctl class interacts with netctl + */ class Netctl : public QObject { Q_OBJECT public: + /** + * @brief Netctl class constructor + * @param debugCmd show debug messages + * @param settings default settings. Needed keys are + * IFACE_DIR (path to directory with interfaces), + * PREFERED_IFACE (prefered interface for WiFi), + * NETCTL_PATH (path to netctl command), + * NETCTLAUTO_PATH (path to netctl-auto command), + * NETCTLAUTO_SERVICE (netctl-auto service name), + * PROFILE_DIR (path to directory which contains profiles), + * SUDO_PATH (path to sudo command), + * SYSTEMCTL_PATH (path to systemctl command) + */ explicit Netctl(const bool debugCmd = false, const QMap settings = QMap()); + /** + * @brief Netctl class destructor + */ ~Netctl(); // general information + /** + * @brief method which returns profile informations from netctl + * @return list of profiles. Available information is [NAME, DESCRIPTION, STATUS]: + * NAME is a profile name, + * DESCRIPTION is a profile description (see more details below), + * STATUS is a profile status (see more details below) + */ QList getProfileList(); + /** + * @brief method which returns profile informations from netctl-auto + * @return list of profiles. Available information is [NAME, DESCRIPTION, STATUS]: + * NAME is a profile name, + * DESCRIPTION is a profile description (see more details below), + * STATUS is a profile status (see more details below) + */ QList getProfileListFromNetctlAuto(); + /** + * @brief method which gets description from profile + * @param profile profile name + * @return profile description or "" + */ QString getProfileDescription(const QString profile); + /** + * @brief method which gets descriptions from profile list + * @param profileList profile names + * @return list of profile descriptions (if description is not available return "") + */ QStringList getProfileDescriptions(const QStringList profileList); + /** + * @brief method which gets profile status + * @param profile profile name + * @return profile status. It may be "active (enabled)", "active (static)", + * "inactive (enabled)", "inactive (static)" + */ QString getProfileStatus(const QString profile); + /** + * @brief method which gets statuses of profile list + * @param profileList profile names + * @return list of profile statuses. It may be "active (enabled)", "active (static)", + * "inactive (enabled)", "inactive (static)" + */ QStringList getProfileStatuses(const QStringList profileList); + /** + * @brief method which gets ESSID from profile + * @param profile profile name + * @return ESSID name or null string + */ QString getSsidFromProfile(const QString profile); + /** + * @brief method which checks if profile is active + * @param profile profile name + * @return false if profile is inactive + * @return true if profile is active + */ bool isProfileActive(const QString profile); + /** + * @brief method which checks if profile is enabled + * @param profile profile name + * @return false if profile is disabled + * @return true if profile is enabled + */ bool isProfileEnabled(const QString profile); + /** + * @brief method which checks if profile is active (netctl-auto) + * @param profile profile name + * @return false if profile is inactive + * @return true if profile is active + */ bool autoIsProfileActive(const QString profile); + /** + * @brief method which checks if profile is enabled (netctl-auto) + * @param profile profile name + * @return false if profile is disabled + * @return true if profile is enabled + */ bool autoIsProfileEnabled(const QString profile); + /** + * @brief method which checks netctl-auto autoload status + * @return false if netctl-auto is disabled + * @return true if netctl-auto is enabled + */ bool isNetctlAutoEnabled(); + /** + * @brief method which checks netctl-auto status + * @return false if netctl-auto is inactive + * @return true if netctl-auto is active + */ bool isNetctlAutoRunning(); public slots: // functions // netctl + /** + * @brief method which sets profile disabled or enabled + * @param profile profile name + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool enableProfile(const QString profile); + /** + * @brief method which restarts profile + * @param profile profile name + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool restartProfile(const QString profile); + /** + * @brief method which starts or stops profile + * @param profile profile name + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool startProfile(const QString profile); // netctl-auto + /** + * @brief method which sets all profiles disabled (netctl-auto) + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool autoDisableAllProfiles(); + /** + * @brief method which sets profile disabled or enabled (netctl-auto) + * @param profile profile name + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool autoEnableProfile(const QString profile); + /** + * @brief method which sets all profiles enabled (netctl-auto) + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool autoEnableAllProfiles(); + /** + * @brief method which switchs to profile (netctl-auto) + * @param profile profile name + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool autoStartProfile(const QString profile); // netctl-auto service + /** + * @brief method which sets netctl-auto service enabled or disabled + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool autoEnableService(); + /** + * @brief method which restarted netctl-auto service + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool autoRestartService(); + /** + * @brief method which starts or stops netctl-auto service + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool autoStartService(); private: + /** + * @brief show debug messages + */ bool debug; + /** + * @brief directory with interfaces. Default is "/sys/class/net/" + */ QDir *ifaceDirectory; + /** + * @brief prefered interface for WiFi. Default is "" + */ QString mainInterface; + /** + * @brief path to netctl command. Default is "/usr/bin/netctl" + */ QString netctlCommand; + /** + * @brief path to netctl-auto command. Default is "/usr/bin/netctl-auto" + */ QString netctlAutoCommand; + /** + * @brief netctl-auto service name. Default is "netctl-auto" + */ QString netctlAutoService; + /** + * @brief directory which contains profiles. Default is "/etc/netctl" + */ QDir *profileDirectory; + /** + * @brief path to sudo command. Default is "/usr/bin/kdesu" + */ QString sudoCommand; + /** + * @brief path to systemctl command. Default is "/usr/bin/systemctl" + */ QString systemctlCommand; // functions - QString getNetctlOutput(const bool sudo, const QString commandLine, const QString profile); + /** + * @brief method which calls netctl and returns its output + * @param sudo set true if sudo is needed + * @param commandLine command which will be passed to netctl + * @param profile profile name + * @return netctl output + */ + QString getNetctlOutput(const bool sudo, const QString commandLine, const QString profile = 0); + /** + * @brief method which gets interface list from PREFERED_IFACE and IFACE_DIR + * @return first element from interface list. If PREFERED_IFACE is not empty it will be first element + */ QString getWifiInterface(); - bool netctlCall(const bool sudo, const QString commandLine, const QString profile); + /** + * @brief method which calls netctl + * @param sudo set true if sudo is needed + * @param commandLine command which will be passed to netctl + * @param profile profile name + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ + bool netctlCall(const bool sudo, const QString commandLine, const QString profile = 0); + /** + * @brief method which calls netctl-auto + * @param sudo set true if sudo is needed + * @param commandLine command which will be passed to netctl-auto + * @param profile profile name + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool netctlAutoCall(const bool sudo, const QString commandLine, const QString profile = 0); + /** + * @brief method which calls systemctl associated with netctl-auto + * @param sudo set true if sudo is needed + * @param commandLine command which will be passed to systemctl + * @return false if components are not found or command exit code is not equal to 0 + * @return true if the method was completed without errors + */ bool systemctlCall(const bool sudo, const QString commandLine); }; diff --git a/sources/netctlgui/include/netctlgui/netctlprofile.h b/sources/netctlgui/include/netctlgui/netctlprofile.h index aafd893..4ce4c65 100644 --- a/sources/netctlgui/include/netctlgui/netctlprofile.h +++ b/sources/netctlgui/include/netctlgui/netctlprofile.h @@ -86,7 +86,7 @@ private: */ bool debug; /** - * @brief path to directory which contains profiles. Default is "/etc/netctl" + * @brief directory which contains profiles. Default is "/etc/netctl" */ QDir *profileDirectory; /** diff --git a/sources/netctlgui/include/netctlgui/wpasupinteract.h b/sources/netctlgui/include/netctlgui/wpasupinteract.h index b88139e..2a37b25 100644 --- a/sources/netctlgui/include/netctlgui/wpasupinteract.h +++ b/sources/netctlgui/include/netctlgui/wpasupinteract.h @@ -92,7 +92,7 @@ public slots: // functions /** * @brief method which scans WiFi networks - * @return list of profiles. Available information is [NAME, NETCTL_STATUS, SIGNAL, SECUITY]: + * @return list of essids. Available information is [NAME, NETCTL_STATUS, SIGNAL, SECUITY]: * NAME is WiFi point name or "", * NETCTL_STATUS may be "new", "exist (active)", "exist (inactive)", * SIGNAL is Wifi point signal, @@ -121,15 +121,6 @@ private: * @brief show debug messages */ bool debug; - CTRL_DIR (path to ctrl_directory), - * CTRL_GROUP (group which is owner of CTRL_DIR), - * IFACE_DIR (path to directory with interfaces), - * PREFERED_IFACE (prefered interface for WiFi), - * PID_FILE (wpa_supplicant PID file), - * SUDO_PATH (path to sudo command), - * WPACLI_PATH (path to wpa_cli command), - * WPA_DRIVERS (wpa_supplicant drivers comma separated), - * WPASUP_PATH (path to wpa_supplicant command) /** * @brief path to ctrl_directory. Defaults is "/run/wpa_supplicant_netctl-gui" */ @@ -139,7 +130,7 @@ private: */ QString ctrlGroup; /** - * @brief path to directory with interfaces. Default is "/sys/class/net/" + * @brief directory with interfaces. Default is "/sys/class/net/" */ QDir *ifaceDirectory; /** @@ -167,19 +158,19 @@ private: */ QString wpaSupPath; // functions + /** + * @brief method which calls wpa_cli and returns its output + * @param commandLine command which will be passed to wpa_cli + * @return wpa_cli output + */ + QString getWpaCliOutput(const QString commandLine); /** * @brief method which calls wpa_cli - * @param commandLine command which will be send to wpa_cli + * @param commandLine command which will be passed to wpa_cli * @return false if components are not found or command exit code is not equal to 0 * @return true if the method was completed without errors */ bool wpaCliCall(const QString commandLine); - /** - * @brief method which calls wpa_cli and returns its output - * @param commandLine command which will be send to wpa_cli - * @return wpa_cli output - */ - QString getWpaCliOutput(const QString commandLine); }; diff --git a/sources/netctlgui/src/netctlinteract.cpp b/sources/netctlgui/src/netctlinteract.cpp index 37f118c..d902076 100644 --- a/sources/netctlgui/src/netctlinteract.cpp +++ b/sources/netctlgui/src/netctlinteract.cpp @@ -14,6 +14,13 @@ * You should have received a copy of the GNU General Public License * * along with netctl-gui. If not, see http://www.gnu.org/licenses/ * ***************************************************************************/ +/** + * @file netctlinteract.cpp + * Source code of netctlgui library + * @author Evgeniy Alekseev + * @copyright GPLv3 + * @bug https://github.com/arcan1s/netctl-gui/issues + */ #include @@ -23,28 +30,53 @@ #include +/** + * @class Netctl + */ +/** + * @fn Netctl + */ Netctl::Netctl(const bool debugCmd, const QMap settings) : debug(debugCmd) { if (settings.contains(QString("IFACE_DIR"))) ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]); + else + ifaceDirectory = new QDir(QString("/sys/class/net/")); if (settings.contains(QString("PREFERED_IFACE"))) mainInterface = settings[QString("PREFERED_IFACE")]; + else + mainInterface = QString(""); if (settings.contains(QString("NETCTL_PATH"))) netctlCommand = settings[QString("NETCTL_PATH")]; + else + netctlCommand = QString("/usr/bin/netctl"); if (settings.contains(QString("NETCTLAUTO_PATH"))) netctlAutoCommand = settings[QString("NETCTLAUTO_PATH")]; + else + netctlAutoCommand = QString("/usr/bin/netctl-auto"); if (settings.contains(QString("NETCTLAUTO_SERVICE"))) netctlAutoService = settings[QString("NETCTLAUTO_SERVICE")]; + else + netctlAutoService = QString("netctl-auto"); if (settings.contains(QString("PROFILE_DIR"))) profileDirectory = new QDir(settings[QString("PROFILE_DIR")]); + else + profileDirectory = new QDir(QString("/etc/netctl/")); if (settings.contains(QString("SUDO_PATH"))) sudoCommand = settings[QString("SUDO_PATH")]; + else + sudoCommand = QString("/usr/bin/kdesu"); if (settings.contains(QString("SYSTEMCTL_PATH"))) systemctlCommand = settings[QString("SYSTEMCTL_PATH")]; + else + systemctlCommand = QString("/usr/bin/systemctl"); } +/** + * @fn ~Netctl + */ Netctl::~Netctl() { if (debug) qDebug() << "[Netctl]" << "[~Netctl]"; @@ -52,11 +84,14 @@ Netctl::~Netctl() if (ifaceDirectory != 0) delete ifaceDirectory; if (profileDirectory != 0) - delete profileDirectory; + delete profileDirectory; } // functions +/** + * @fn getNetctlOutput + */ QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, const QString profile) { if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]"; @@ -86,6 +121,9 @@ QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, cons } +/** + * @fn getWifiInterface + */ QString Netctl::getWifiInterface() { if (debug) qDebug() << "[Netctl]" << "[getInterfaceList]"; @@ -110,6 +148,9 @@ QString Netctl::getWifiInterface() } +/** + * @fn netctlCall + */ bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QString profile) { if (debug) qDebug() << "[Netctl]" << "[netctlCall]"; @@ -143,6 +184,9 @@ bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QStrin } +/** + * @fn netctlAutoCall + */ bool Netctl::netctlAutoCall(const bool sudo, const QString commandLine, const QString profile) { if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]"; @@ -177,6 +221,9 @@ bool Netctl::netctlAutoCall(const bool sudo, const QString commandLine, const QS } +/** + * @fn systemctlCall + */ bool Netctl::systemctlCall(const bool sudo, const QString commandLine) { if (debug) qDebug() << "[Netctl]" << "[systemctlCall]"; @@ -216,6 +263,9 @@ bool Netctl::systemctlCall(const bool sudo, const QString commandLine) // general information +/** + * @fn getProfileList + */ QList Netctl::getProfileList() { if (debug) qDebug() << "[Netctl]" << "[getProfileList]"; @@ -240,6 +290,9 @@ QList Netctl::getProfileList() } +/** + * @fn getProfileListFromNetctlAuto + */ QList Netctl::getProfileListFromNetctlAuto() { if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]"; @@ -267,6 +320,9 @@ QList Netctl::getProfileListFromNetctlAuto() } +/** + * @fn getProfileDescription + */ QString Netctl::getProfileDescription(const QString profileName) { if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]"; @@ -292,13 +348,15 @@ QString Netctl::getProfileDescription(const QString profileName) if (profile.atEnd()) break; } - description.remove(QChar('\'')); - description.remove(QChar('"')); + description.remove(QChar('\'')).remove(QChar('"')); return description; } +/** + * @fn getProfileDescriptions + */ QStringList Netctl::getProfileDescriptions(const QStringList profileList) { if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]"; @@ -328,8 +386,7 @@ QStringList Netctl::getProfileDescriptions(const QStringList profileList) if (profile.atEnd()) break; } - description.remove(QChar('\'')); - description.remove(QChar('"')); + description.remove(QChar('\'')).remove(QChar('"')); descriptions.append(description); } @@ -337,6 +394,9 @@ QStringList Netctl::getProfileDescriptions(const QStringList profileList) } +/** + * @fn getProfileStatus + */ QString Netctl::getProfileStatus(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[getProfileStatus]"; @@ -356,6 +416,9 @@ QString Netctl::getProfileStatus(const QString profile) } +/** + * @fn getProfileStatuses + */ QStringList Netctl::getProfileStatuses(const QStringList profileList) { if (debug) qDebug() << "[Netctl]" << "[getProfileStatuses]"; @@ -379,6 +442,9 @@ QStringList Netctl::getProfileStatuses(const QStringList profileList) } +/** + * @fn getSsidFromProfile + */ QString Netctl::getSsidFromProfile(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]"; @@ -405,13 +471,15 @@ QString Netctl::getSsidFromProfile(const QString profile) break; } profileFile.close(); - ssidName.remove(QChar('\'')); - ssidName.remove(QChar('"')); + ssidName.remove(QChar('\'')).remove(QChar('"')); return ssidName; } +/** + * @fn isProfileActive + */ bool Netctl::isProfileActive(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[isProfileActive]"; @@ -419,14 +487,16 @@ bool Netctl::isProfileActive(const QString profile) bool status = false; QString cmdOutput = getNetctlOutput(false, QString("status"), profile); - if (!cmdOutput.isEmpty()) - if (cmdOutput.contains(QString("Active: active"))) - status = true; + if (cmdOutput.contains(QString("Active: active"))) + status = true; return status; } +/** + * @fn isProfileEnabled + */ bool Netctl::isProfileEnabled(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[isProfileEnabled]"; @@ -436,6 +506,9 @@ bool Netctl::isProfileEnabled(const QString profile) } +/** + * @fn autoIsProfileActive + */ bool Netctl::autoIsProfileActive(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[autoIsProfileActive]"; @@ -453,6 +526,9 @@ bool Netctl::autoIsProfileActive(const QString profile) } +/** + * @fn autoIsProfileEnabled + */ bool Netctl::autoIsProfileEnabled(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[autoIsProfileEnabled]"; @@ -470,6 +546,9 @@ bool Netctl::autoIsProfileEnabled(const QString profile) } +/** + * @fn isNetctlAutoEnabled + */ bool Netctl::isNetctlAutoEnabled() { if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]"; @@ -499,6 +578,9 @@ bool Netctl::isNetctlAutoEnabled() } +/** + * @fn isNetctlAutoRunning + */ bool Netctl::isNetctlAutoRunning() { if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]"; @@ -529,6 +611,9 @@ bool Netctl::isNetctlAutoRunning() // functions +/** + * @fn enableProfile + */ bool Netctl::enableProfile(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[enableProfile]"; @@ -541,6 +626,9 @@ bool Netctl::enableProfile(const QString profile) } +/** + * @fn restartProfile + */ bool Netctl::restartProfile(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[restartProfile]"; @@ -550,6 +638,9 @@ bool Netctl::restartProfile(const QString profile) } +/** + * @fn startProfile + */ bool Netctl::startProfile(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[startProfile]"; @@ -562,6 +653,9 @@ bool Netctl::startProfile(const QString profile) } +/** + * @fn autoDisableAllProfiles + */ bool Netctl::autoDisableAllProfiles() { if (debug) qDebug() << "[Netctl]" << "[autoDisableAllProfiles]"; @@ -570,6 +664,9 @@ bool Netctl::autoDisableAllProfiles() } +/** + * @fn autoEnableProfile + */ bool Netctl::autoEnableProfile(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[autoEnableProfile]"; @@ -582,6 +679,9 @@ bool Netctl::autoEnableProfile(const QString profile) } +/** + * @fn autoEnableAllProfiles + */ bool Netctl::autoEnableAllProfiles() { if (debug) qDebug() << "[Netctl]" << "[autoEnableAllProfiles]"; @@ -590,6 +690,9 @@ bool Netctl::autoEnableAllProfiles() } +/** + * @fn autoStartProfile + */ bool Netctl::autoStartProfile(const QString profile) { if (debug) qDebug() << "[Netctl]" << "[autoStartProfile]"; @@ -602,6 +705,9 @@ bool Netctl::autoStartProfile(const QString profile) } +/** + * @fn autoEnableService + */ bool Netctl::autoEnableService() { if (debug) qDebug() << "[Netctl]" << "[autoEnableService]"; @@ -613,6 +719,9 @@ bool Netctl::autoEnableService() } +/** + * @fn autoRestartService + */ bool Netctl::autoRestartService() { if (debug) qDebug() << "[Netctl]" << "[autoRestartService]"; @@ -624,6 +733,9 @@ bool Netctl::autoRestartService() } +/** + * @fn autoStartService + */ bool Netctl::autoStartService() { if (debug) qDebug() << "[Netctl]" << "[autoStartService]"; diff --git a/sources/netctlgui/src/wpasupinteract.cpp b/sources/netctlgui/src/wpasupinteract.cpp index 81cb8cb..60642e6 100644 --- a/sources/netctlgui/src/wpasupinteract.cpp +++ b/sources/netctlgui/src/wpasupinteract.cpp @@ -320,6 +320,38 @@ bool WpaSup::stopWpaSupplicant() // functions +/** + * @fn getWpaCliOutput + */ +QString WpaSup::getWpaCliOutput(const QString commandLine) +{ + if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]"; + if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Command" << commandLine; + if (ctrlDir == 0) { + if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find directory"; + return QString(); + } + if (pidFile == 0) { + if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find PID file"; + return QString(); + } + if (wpaCliPath == 0) { + if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find wpa_cli"; + return QString(); + } + + QProcess command; + QString interface = getInterfaceList()[0]; + QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir + + QString(" -P ") + pidFile + QString(" ") + commandLine; + if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << commandText; + command.start(commandText); + command.waitForFinished(-1); + + return command.readAllStandardOutput(); +} + + /** * @fn wpaCliCall */ @@ -355,35 +387,3 @@ bool WpaSup::wpaCliCall(const QString commandLine) else return false; } - - -/** - * @fn getWpaCliOutput - */ -QString WpaSup::getWpaCliOutput(const QString commandLine) -{ - if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]"; - if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Command" << commandLine; - if (ctrlDir == 0) { - if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find directory"; - return QString(); - } - if (pidFile == 0) { - if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find PID file"; - return QString(); - } - if (wpaCliPath == 0) { - if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find wpa_cli"; - return QString(); - } - - QProcess command; - QString interface = getInterfaceList()[0]; - QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir + - QString(" -P ") + pidFile + QString(" ") + commandLine; - if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << commandText; - command.start(commandText); - command.waitForFinished(-1); - - return command.readAllStandardOutput(); -}