From 64937105c6a335357479c77b3726b26ebd61f0bd Mon Sep 17 00:00:00 2001 From: arcan1s Date: Tue, 5 Aug 2014 23:32:12 +0400 Subject: [PATCH] rewrite library to use task --- README.md | 1 - sources/3rdparty/task/taskadds.cpp | 34 ++ .../task/taskadds.h} | 52 +- sources/dataengine/netctl.cpp | 27 +- sources/dataengine/taskadds.cpp | 1 + sources/dataengine/taskadds.h | 1 + sources/netctlgui/docs.cmake | 1 - .../netctlgui/include/netctlgui/netctlgui.h | 2 - .../include/netctlgui/netctlinteract.h | 111 ++-- .../include/netctlgui/wpasupinteract.h | 33 +- sources/netctlgui/src/CMakeLists.txt | 1 - sources/netctlgui/src/main.cpp | 2 +- sources/netctlgui/src/netctlinteract.cpp | 482 ++++++------------ sources/netctlgui/src/netctlprofile.cpp | 28 +- sources/netctlgui/src/sleepthread.h | 1 - sources/netctlgui/src/taskadds.cpp | 1 + sources/netctlgui/src/taskadds.h | 1 + sources/netctlgui/src/wpasupinteract.cpp | 110 ++-- sources/plasmoid/netctl.cpp | 23 +- 19 files changed, 365 insertions(+), 547 deletions(-) create mode 100644 sources/3rdparty/task/taskadds.cpp rename sources/{netctlgui/include/netctlgui/sleepthread.h => 3rdparty/task/taskadds.h} (52%) create mode 120000 sources/dataengine/taskadds.cpp create mode 120000 sources/dataengine/taskadds.h delete mode 120000 sources/netctlgui/src/sleepthread.h create mode 120000 sources/netctlgui/src/taskadds.cpp create mode 120000 sources/netctlgui/src/taskadds.h diff --git a/README.md b/README.md index e00a7fd..b0bfdbe 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,6 @@ Additional information TODO (wish list) ---------------- -* refactoring of library (using QtNetwork module instead of some system calls) * refactoring of GUI according to library changes * rewrite changelog to more comfortable format diff --git a/sources/3rdparty/task/taskadds.cpp b/sources/3rdparty/task/taskadds.cpp new file mode 100644 index 0000000..b8a8165 --- /dev/null +++ b/sources/3rdparty/task/taskadds.cpp @@ -0,0 +1,34 @@ +/*************************************************************************** + * This file is part of netctl-gui * + * * + * netctl-gui is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * netctl-gui is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with netctl-gui. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "taskadds.h" + + +TaskResult runTask(const QString cmd) +{ + return Task::await( [ & ]() { + QProcess command; + command.start(cmd); + command.waitForFinished(-1); + TaskResult r; + r.exitCode = command.exitCode(); + r.output = command.readAllStandardOutput(); + + return r; + }); +} diff --git a/sources/netctlgui/include/netctlgui/sleepthread.h b/sources/3rdparty/task/taskadds.h similarity index 52% rename from sources/netctlgui/include/netctlgui/sleepthread.h rename to sources/3rdparty/task/taskadds.h index 5e825c1..6de905b 100644 --- a/sources/netctlgui/include/netctlgui/sleepthread.h +++ b/sources/3rdparty/task/taskadds.h @@ -14,54 +14,22 @@ * 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 sleepthread.h - * Header of netctlgui library - * @author Evgeniy Alekseev - * @copyright GPLv3 - * @bug https://github.com/arcan1s/netctl-gui/issues - */ -#ifndef SLEEPTHREAD_H -#define SLEEPTHREAD_H +#ifndef TASKADDS_H +#define TASKADDS_H -#include +#include + +#include "task.h" -/** - * @brief The SleepThread class is used for sleep current thread in WpaSup class - */ -class SleepThread : public QThread +struct TaskResult { - Q_OBJECT - -public: - /** - * @brief method which forces the current thread to sleep for usecs microseconds - * @param iSleepTime time in microseconds - */ - static void usleep(long iSleepTime) - { - QThread::usleep(iSleepTime); - } - /** - * @brief method which forces the current thread to sleep for usecs seconds - * @param iSleepTime time in seconds - */ - static void sleep(long iSleepTime) - { - QThread::sleep(iSleepTime); - } - /** - * @brief method which forces the current thread to sleep for usecs milliseconds - * @param iSleepTime time in milliseconds - */ - static void msleep(long iSleepTime) - { - QThread::msleep(iSleepTime); - } + int exitCode; + QByteArray output; }; +TaskResult runTask(const QString cmd); -#endif /* SLEEPTHREAD_H */ +#endif /* TASKADDS_H */ diff --git a/sources/dataengine/netctl.cpp b/sources/dataengine/netctl.cpp index 2baaac6..be2df76 100644 --- a/sources/dataengine/netctl.cpp +++ b/sources/dataengine/netctl.cpp @@ -15,9 +15,6 @@ * along with netctl-gui. If not, see http://www.gnu.org/licenses/ * ***************************************************************************/ -#include "netctl.h" -#include "task.h" - #include #include #include @@ -28,28 +25,8 @@ #include #include - -struct TaskResult -{ - int exitCode; - QByteArray output; -}; - - -TaskResult runTask(const QString cmd) -{ - return Task::await( [ & ]() { - QProcess command; - command.start(cmd); - command.waitForFinished(-1); - - TaskResult r; - r.exitCode = command.exitCode(); - r.output = command.readAllStandardOutput(); - - return r; - }); -} +#include "netctl.h" +#include "taskadds.h" Netctl::Netctl(QObject *parent, const QVariantList &args) diff --git a/sources/dataengine/taskadds.cpp b/sources/dataengine/taskadds.cpp new file mode 120000 index 0000000..97b06b2 --- /dev/null +++ b/sources/dataengine/taskadds.cpp @@ -0,0 +1 @@ +../3rdparty/task/taskadds.cpp \ No newline at end of file diff --git a/sources/dataengine/taskadds.h b/sources/dataengine/taskadds.h new file mode 120000 index 0000000..55b2cd9 --- /dev/null +++ b/sources/dataengine/taskadds.h @@ -0,0 +1 @@ +../3rdparty/task/taskadds.h \ No newline at end of file diff --git a/sources/netctlgui/docs.cmake b/sources/netctlgui/docs.cmake index ac54f73..97c5c4d 100644 --- a/sources/netctlgui/docs.cmake +++ b/sources/netctlgui/docs.cmake @@ -13,7 +13,6 @@ add_custom_target (oxygen-docs ALL COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT set (MAN_DIR ${CMAKE_CURRENT_BINARY_DIR}/docs/man/man3) install (FILES ${MAN_DIR}/Netctl.3 DESTINATION share/man/man3 RENAME ${SUBPROJECT}_Netctl.3) install (FILES ${MAN_DIR}/NetctlProfile.3 DESTINATION share/man/man3 RENAME ${SUBPROJECT}_NetctlProfile.3) -install (FILES ${MAN_DIR}/SleepThread.3 DESTINATION share/man/man3 RENAME ${SUBPROJECT}_SleepThread.3) install (FILES ${MAN_DIR}/WpaSup.3 DESTINATION share/man/man3 RENAME ${SUBPROJECT}_WpaSup.3) # html docs install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs/html DESTINATION share/doc/${SUBPROJECT}) diff --git a/sources/netctlgui/include/netctlgui/netctlgui.h b/sources/netctlgui/include/netctlgui/netctlgui.h index de2d69b..c146b20 100644 --- a/sources/netctlgui/include/netctlgui/netctlgui.h +++ b/sources/netctlgui/include/netctlgui/netctlgui.h @@ -28,8 +28,6 @@ #include "netctlinteract.h" #include "netctlprofile.h" -#include "sleepthread.h" #include "wpasupinteract.h" - #endif /* NETCTLGUI_H */ diff --git a/sources/netctlgui/include/netctlgui/netctlinteract.h b/sources/netctlgui/include/netctlgui/netctlinteract.h index fbc6844..7584c81 100644 --- a/sources/netctlgui/include/netctlgui/netctlinteract.h +++ b/sources/netctlgui/include/netctlgui/netctlinteract.h @@ -33,6 +33,23 @@ class NetctlProfile; +/** + * @struct netctlProfileInfo + * @brief netctl profile information structure + * @var netctlProfileInfo::name + * profile name + * @var netctlProfileInfo::description + * profile description + * @var netctlProfileInfo::status + * profile status + */ +typedef struct +{ + QString name; + QString description; + QString status; +} netctlProfileInfo; + /** * @brief The Netctl class interacts with netctl */ @@ -61,59 +78,35 @@ public: */ ~Netctl(); // general information - /** - * @brief method which gets interface list from PREFERED_IFACE and IFACE_DIR - * @return interface list. If PREFERED_IFACE is not empty it will be first element - */ - QStringList getInterfaceList(); /** * @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) + * @return list of profiles */ - QList getProfileList(); + 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) + * @return list of profiles from netctl-auto */ - QList getProfileListFromNetctlAuto(); + 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 returns "") - */ - QStringList getProfileDescriptions(const QStringList profileList); /** * @brief method which gets profile status - * @param profile profile name + * @param profile profile name * @return profile status. It may be "active (enabled)", "active (static)", - * "inactive (enabled)", "inactive (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 checks if profile is active - * @param profile profile name - * @return false if profile is inactive - * @return true if profile is active - */ + * @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 @@ -148,6 +141,11 @@ public: * @return true if netctl-auto is active */ bool isNetctlAutoRunning(); + /** + * @brief method which gets wireless interface list from PREFERED_IFACE and IFACE_DIR + * @return interface list. If PREFERED_IFACE is not empty it will be first element + */ + QStringList getWirelessInterfaceList(); public slots: // functions @@ -249,10 +247,6 @@ private: * @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" */ @@ -263,39 +257,26 @@ private: QString systemctlCommand; // functions /** - * @brief method which calls netctl and returns its output + * @brief method which calls command * @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 calls netctl - * @param sudo set true if sudo is needed - * @param commandLine command which will be passed to netctl - * @param profile profile name + * @param command command which will be called + * @param commandLine command which will be passed to command + * @param argument argument which will be passed to commandLine * @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); + bool cmdCall(const bool sudo, const QString command, + const QString commandLine, const QString argument = 0); /** - * @brief method which calls netctl-auto + * @brief method which calls command and returns its output * @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 + * @param command command which will be called + * @param commandLine command which will be passed to command + * @param argument argument which will be passed to commandLine + * @return command output */ - 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); + QString getCmdOutput(const bool sudo, const QString command, + const QString commandLine, const QString argument = 0); }; diff --git a/sources/netctlgui/include/netctlgui/wpasupinteract.h b/sources/netctlgui/include/netctlgui/wpasupinteract.h index 68bd5e6..3c05eec 100644 --- a/sources/netctlgui/include/netctlgui/wpasupinteract.h +++ b/sources/netctlgui/include/netctlgui/wpasupinteract.h @@ -34,6 +34,26 @@ class Netctl; class NetctlProfile; +/** + * @struct netctlWifiInfo + * @brief WiFi information structure + * @var netctlWifiInfo::name + * ESSID + * @var netctlWifiInfo::security + * may be "WPA2", "WEP", "WEP", "none" + * @var netctlWifiInfo::signal + * Wifi point signal + * @var netctlWifiInfo::status + * netctl status, may be "new", "exist (active)", "exist (inactive)" + */ +typedef struct +{ + QString name; + QString security; + QString signal; + QString status; +} netctlWifiInfo; + /** * @brief The WpaSup class interacts with wpa_supplicant */ @@ -86,13 +106,9 @@ public slots: // functions /** * @brief method which scans WiFi networks - * @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, - * SECURITY may be "WPA2", "WEP", "WEP", "none" + * @return list of essids */ - QList scanWifi(); + QList scanWifi(); /** * @brief method which calls wpa_supplicant * @return false if components are not found or command exit code is not equal to 0 @@ -154,6 +170,11 @@ private: * @return wpa_cli output */ QString getWpaCliOutput(const QString commandLine); + /** + * @brief method which will be called to sleep thread + * @param sec time interval, seconds + */ + bool waitForProcess(const int sec); /** * @brief method which calls wpa_cli * @param commandLine command which will be passed to wpa_cli diff --git a/sources/netctlgui/src/CMakeLists.txt b/sources/netctlgui/src/CMakeLists.txt index 51ff6a1..3f947ae 100644 --- a/sources/netctlgui/src/CMakeLists.txt +++ b/sources/netctlgui/src/CMakeLists.txt @@ -1,7 +1,6 @@ # set files file (GLOB SOURCES *.cpp) file (GLOB HEADERS *.h) -# set (HEADERS ${HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/task.h) # include_path include_directories (${SUBPROJECT_INCLUDE_DIR} diff --git a/sources/netctlgui/src/main.cpp b/sources/netctlgui/src/main.cpp index 45047c5..c52f729 100644 --- a/sources/netctlgui/src/main.cpp +++ b/sources/netctlgui/src/main.cpp @@ -23,7 +23,7 @@ */ -#include +#include "netctlgui.h" /** diff --git a/sources/netctlgui/src/netctlinteract.cpp b/sources/netctlgui/src/netctlinteract.cpp index ff8ba18..a7cb76a 100644 --- a/sources/netctlgui/src/netctlinteract.cpp +++ b/sources/netctlgui/src/netctlinteract.cpp @@ -24,34 +24,9 @@ #include -#include -#include #include "netctlgui.h" -#include "task.h" - - -struct TaskResult -{ - int exitCode; - QByteArray output; -}; - - -TaskResult runTask(const QString cmd) -{ - return Task::await( [ & ]() { - QProcess command; - command.start(cmd); - command.waitForFinished(-1); - - TaskResult r; - r.exitCode = command.exitCode(); - r.output = command.readAllStandardOutput(); - - return r; - }); -} +#include "taskadds.h" /** @@ -85,10 +60,6 @@ Netctl::Netctl(const bool debugCmd, const QMap settings) 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 @@ -111,212 +82,89 @@ Netctl::~Netctl() delete netctlProfile; if (ifaceDirectory != 0) delete ifaceDirectory; - if (profileDirectory != 0) - delete profileDirectory; } // functions /** - * @fn getNetctlOutput + * @fn cmdCall */ -QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, const QString profile) +bool Netctl::cmdCall(const bool sudo, const QString command, const QString commandLine, const QString argument) { - if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]"; - if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Command" << commandLine; - if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Profile" << profile; - if (netctlCommand == 0) { - if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Could not find netctl"; + if (debug) qDebug() << "[Netctl]" << "[cmdCall]"; + if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Command" << command; + if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Command line" << commandLine; + if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Argument" << argument; + if (command == 0) { + if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Could not find command"; + return false; + } + if ((sudo) && (sudoCommand == 0)) { + if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Could not find sudo"; + return false; + } + + QString cmd = QString(""); + if (sudo) cmd = sudoCommand + QString(" "); + cmd += command + QString(" ") + commandLine; + if (argument != 0) cmd += QString(" ") + argument; + if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Run cmd" << cmd; + TaskResult process = runTask(cmd); + if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Cmd returns" << process.exitCode; + + if (process.exitCode == 0) + return true; + else + return false; +} + + +/** + * @fn getCmdOutput + */ +QString Netctl::getCmdOutput(const bool sudo, const QString command, const QString commandLine, const QString argument) +{ + if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]"; + if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Command" << command; + if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Command line" << commandLine; + if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Argument" << argument; + if (command == 0) { + if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Could not find command"; return QString(); } if ((sudo) && (sudoCommand == 0)) { - if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Could not find sudo"; + if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Could not find sudo"; return QString(); } - QProcess command; - QString commandText; - if (sudo) - commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine + - QString(" ") + profile; - else - commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile; - if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Run cmd" << commandText; - command.start(commandText); - command.waitForFinished(-1); + QString cmd = QString(""); + if (sudo) cmd = sudoCommand + QString(" "); + cmd += command + QString(" ") + commandLine; + if (argument != 0) cmd += QString(" ") + argument; + if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Run cmd" << cmd; + TaskResult process = runTask(cmd); + if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Cmd returns" << process.exitCode; - return command.readAllStandardOutput(); -} - - -/** - * @fn netctlCall - */ -bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QString profile) -{ - if (debug) qDebug() << "[Netctl]" << "[netctlCall]"; - if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Command" << commandLine; - if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Profile" << profile; - if (netctlCommand == 0) { - if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Could not find netctl"; - return false; - } - if ((sudo) && (sudoCommand == 0)) { - if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Could not find sudo"; - return false; - } - - QProcess command; - QString commandText; - if (sudo) - commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine + - QString(" ") + profile; - else - commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile; - if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Run cmd" << commandText; - command.start(commandText); - command.waitForFinished(-1); - if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Cmd returns" << command.exitCode(); - - if (command.exitCode() == 0) - return true; - else - return false; -} - - -/** - * @fn netctlAutoCall - */ -bool Netctl::netctlAutoCall(const bool sudo, const QString commandLine, const QString profile) -{ - if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]"; - if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Command" << commandLine; - if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Profile" << profile; - if (netctlAutoCommand == 0) { - if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Could not find netctl-auto"; - return false; - } - if ((sudo) && (sudoCommand == 0)) { - if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Could not find sudo"; - return false; - } - - QProcess command; - QString commandText; - if (sudo) - commandText = sudoCommand + QString(" ") + netctlAutoCommand + QString(" ") + commandLine; - else - commandText = netctlAutoCommand + QString(" ") + commandLine; - if (profile != 0) - commandText = commandText + QString(" ") + profile; - if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Run cmd" << commandText; - command.start(commandText); - command.waitForFinished(-1); - if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Cmd returns" << command.exitCode(); - - if (command.exitCode() == 0) - return true; - else - return false; -} - - -/** - * @fn systemctlCall - */ -bool Netctl::systemctlCall(const bool sudo, const QString commandLine) -{ - if (debug) qDebug() << "[Netctl]" << "[systemctlCall]"; - if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Command" << commandLine; - if (netctlAutoService == 0) { - if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Could not find service"; - return false; - } - if ((sudo) && (sudoCommand == 0)) { - if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Could not find sudo"; - return false; - } - if (systemctlCommand == 0) { - if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Could not find systemctl"; - return false; - } - if (getInterfaceList().isEmpty()) { - if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Could not interface"; - return false; - } - - QProcess command; - QString commandText; - QString interface = getInterfaceList()[0]; - if (interface.isEmpty()) - return false; - if (sudo) - commandText = sudoCommand + QString(" ") + systemctlCommand + QString(" ") + commandLine + - QString(" ") + netctlAutoService + QString("@") + interface + QString(".service"); - else - commandText = systemctlCommand + QString(" ") + commandLine + QString(" ") + netctlAutoService + - QString("@") + interface + QString(".service"); - if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Run cmd" << commandText; - command.start(commandText); - command.waitForFinished(-1); - if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Cmd returns" << command.exitCode(); - - if (command.exitCode() == 0) - return true; - else - return false; + return process.output; } // general information -/** - * @fn getInterfaceList - */ -QStringList Netctl::getInterfaceList() -{ - if (debug) qDebug() << "[Netctl]" << "[getInterfaceList]"; - if (ifaceDirectory == 0) { - if (debug) qDebug() << "[Netctl]" << "[getInterfaceList]" << ":" << "Could not find directory"; - return QStringList(); - } - - QStringList interfaces; - if (!mainInterface.isEmpty()) - 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()) - interfaces.append(allInterfaces[i]); - } - - return interfaces; -} - - /** * @fn getProfileList */ -QList Netctl::getProfileList() +QList Netctl::getProfileList() { if (debug) qDebug() << "[Netctl]" << "[getProfileList]"; - if (profileDirectory == 0) { - if (debug) qDebug() << "[Netctl]" << "[getProfileList]" << ":" << "Could not find directory"; - return QList(); - } - QList fullProfilesInfo; - QStringList profiles = profileDirectory->entryList(QDir::Files); - QStringList descriptions = getProfileDescriptions(profiles); - QStringList statuses = getProfileStatuses(profiles); - for (int i=0; i fullProfilesInfo; + QStringList output = getCmdOutput(false, netctlCommand, QString("list")) + .split(QChar('\n'), QString::SkipEmptyParts); + for (int i=0; i Netctl::getProfileList() /** * @fn getProfileListFromNetctlAuto */ -QList Netctl::getProfileListFromNetctlAuto() +QList Netctl::getProfileListFromNetctlAuto() { if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]"; - if (netctlAutoCommand == 0) { - if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]" << ":" << "Could not find netctl-auto"; - return QList(); - } - QProcess command; - QString commandText = netctlAutoCommand + QString(" list"); - if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]" << ":" << "Run cmd" << commandText; - command.start(commandText); - command.waitForFinished(-1); - QStringList output = QString(command.readAllStandardOutput()).split(QChar('\n'), QString::SkipEmptyParts); - QList fullProfilesInfo; + QList fullProfilesInfo; + QStringList output = getCmdOutput(false, netctlAutoCommand, QString("list")) + .split(QChar('\n'), QString::SkipEmptyParts); for (int i=0; igetValueFromProfile(profileList[i], QString("Description"))); - - return descriptions; -} - - /** * @fn getProfileStatus */ @@ -412,32 +232,6 @@ QString Netctl::getProfileStatus(const QString profile) } -/** - * @fn getProfileStatuses - */ -QStringList Netctl::getProfileStatuses(const QStringList profileList) -{ - if (debug) qDebug() << "[Netctl]" << "[getProfileStatuses]"; - if (debug) qDebug() << "[Netctl]" << "[getProfileStatuses]" << ":" << "Profile list" << profileList; - - QStringList statuses; - for (int i=0; i profiles = getProfileListFromNetctlAuto(); + QList profiles = getProfileListFromNetctlAuto(); for (int i=0; i profiles = getProfileListFromNetctlAuto(); + QList profiles = getProfileListFromNetctlAuto(); for (int i=0; ientryList(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()) + interfaces.append(allInterfaces[i]); + } + + return interfaces; +} + + // functions /** * @fn enableProfile @@ -589,9 +390,9 @@ bool Netctl::enableProfile(const QString profile) if (debug) qDebug() << "[Netctl]" << "[enableProfile]" << ":" << "Profile" << profile; if (isProfileEnabled(profile)) - return netctlCall(true, QString("disable"), profile); + return cmdCall(true, netctlCommand, QString("disable"), profile); else - return netctlCall(true, QString("enable"), profile); + return cmdCall(true, netctlCommand, QString("enable"), profile); } @@ -603,7 +404,7 @@ bool Netctl::restartProfile(const QString profile) if (debug) qDebug() << "[Netctl]" << "[restartProfile]"; if (debug) qDebug() << "[Netctl]" << "[restartProfile]" << ":" << "Profile" << profile; - return netctlCall(true, QString("restart"), profile); + return cmdCall(true, netctlCommand, QString("restart"), profile); } @@ -616,9 +417,9 @@ bool Netctl::startProfile(const QString profile) if (debug) qDebug() << "[Netctl]" << "[startProfile]" << ":" << "Profile" << profile; if (isProfileActive(profile)) - return netctlCall(true, QString("stop"), profile); + return cmdCall(true, netctlCommand, QString("stop"), profile); else - return netctlCall(true, QString("start"), profile); + return cmdCall(true, netctlCommand, QString("start"), profile); } @@ -629,7 +430,7 @@ bool Netctl::autoDisableAllProfiles() { if (debug) qDebug() << "[Netctl]" << "[autoDisableAllProfiles]"; - return netctlAutoCall(false, QString("disable-all")); + return cmdCall(false, netctlAutoCommand, QString("disable-all")); } @@ -642,9 +443,9 @@ bool Netctl::autoEnableProfile(const QString profile) if (debug) qDebug() << "[Netctl]" << "[autoEnableProfile]" << ":" << "Profile" << profile; if (autoIsProfileEnabled(profile)) - return netctlAutoCall(false, QString("disable"), profile); + return cmdCall(false, netctlAutoCommand, QString("disable"), profile); else - return netctlAutoCall(false, QString("enable"), profile); + return cmdCall(false, netctlAutoCommand, QString("enable"), profile); } @@ -655,7 +456,7 @@ bool Netctl::autoEnableAllProfiles() { if (debug) qDebug() << "[Netctl]" << "[autoEnableAllProfiles]"; - return netctlAutoCall(false, QString("enable-all")); + return cmdCall(false, netctlAutoCommand, QString("enable-all")); } @@ -670,7 +471,7 @@ bool Netctl::autoStartProfile(const QString profile) if (autoIsProfileActive(profile)) return true; else - return netctlAutoCall(false, QString("switch-to"), profile); + return cmdCall(false, netctlAutoCommand, QString("switch-to"), profile); } @@ -680,11 +481,22 @@ bool Netctl::autoStartProfile(const QString profile) bool Netctl::autoEnableService() { if (debug) qDebug() << "[Netctl]" << "[autoEnableService]"; + if (netctlAutoService == 0) { + if (debug) qDebug() << "[Netctl]" << "[autoEnableService]" << ":" << "Could not find service"; + return false; + } + if (getWirelessInterfaceList().isEmpty()) { + if (debug) qDebug() << "[Netctl]" << "[autoEnableService]" << ":" << "Could not interface"; + return false; + } + + QString interface = getWirelessInterfaceList()[0]; + QString argument = netctlAutoService + QString("@") + interface + QString(".service"); if (isNetctlAutoEnabled()) - return systemctlCall(true, QString("disable")); + return cmdCall(true, systemctlCommand, QString("disable"), argument); else - return systemctlCall(true, QString("enable")); + return cmdCall(true, systemctlCommand, QString("enable"), argument); } @@ -694,9 +506,20 @@ bool Netctl::autoEnableService() bool Netctl::autoRestartService() { if (debug) qDebug() << "[Netctl]" << "[autoRestartService]"; + if (netctlAutoService == 0) { + if (debug) qDebug() << "[Netctl]" << "[autoRestartService]" << ":" << "Could not find service"; + return false; + } + if (getWirelessInterfaceList().isEmpty()) { + if (debug) qDebug() << "[Netctl]" << "[autoRestartService]" << ":" << "Could not interface"; + return false; + } + + QString interface = getWirelessInterfaceList()[0]; + QString argument = netctlAutoService + QString("@") + interface + QString(".service"); if (isNetctlAutoRunning()) - return systemctlCall(true, QString("restart")); + return cmdCall(true, systemctlCommand, QString("restart"), argument); else return true; } @@ -708,9 +531,20 @@ bool Netctl::autoRestartService() bool Netctl::autoStartService() { if (debug) qDebug() << "[Netctl]" << "[autoStartService]"; + if (netctlAutoService == 0) { + if (debug) qDebug() << "[Netctl]" << "[autoStartService]" << ":" << "Could not find service"; + return false; + } + if (getWirelessInterfaceList().isEmpty()) { + if (debug) qDebug() << "[Netctl]" << "[autoStartService]" << ":" << "Could not interface"; + return false; + } + + QString interface = getWirelessInterfaceList()[0]; + QString argument = netctlAutoService + QString("@") + interface + QString(".service"); if (isNetctlAutoRunning()) - return systemctlCall(true, QString("stop")); + return cmdCall(true, systemctlCommand, QString("stop"), argument); else - return systemctlCall(true, QString("start")); + return cmdCall(true, systemctlCommand, QString("start"), argument); } diff --git a/sources/netctlgui/src/netctlprofile.cpp b/sources/netctlgui/src/netctlprofile.cpp index 0fc314d..7e88e2c 100644 --- a/sources/netctlgui/src/netctlprofile.cpp +++ b/sources/netctlgui/src/netctlprofile.cpp @@ -26,10 +26,10 @@ #include #include #include -#include #include #include "netctlgui.h" +#include "taskadds.h" /** @@ -72,22 +72,21 @@ bool NetctlProfile::copyProfile(const QString oldPath) if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]"; if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Path" << oldPath; if (profileDirectory == 0) { - if (debug) qDebug() << "[NetctlProfile]" << "[profileDirectory]" << ":" << "Could not find directory"; + if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Could not find directory"; return false; } if (sudoCommand == 0) { - if (debug) qDebug() << "[NetctlProfile]" << "[profileDirectory]" << ":" << "Could not find sudo"; + if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Could not find sudo"; return false; } - QProcess command; QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName(); - QString commandText = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath; - if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << commandText; - command.start(commandText); - command.waitForFinished(-1); + QString cmd = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath; + if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << cmd; + TaskResult process = runTask(cmd); + if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Cmd returns" << process.exitCode; - if (command.exitCode() == 0) + if (process.exitCode == 0) return true; else return false; @@ -220,14 +219,13 @@ bool NetctlProfile::removeProfile(const QString profile) return false; } - QProcess command; QString profilePath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName(); - QString commandText = sudoCommand + QString(" /usr/bin/rm ") + profilePath; - if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << commandText; - command.start(commandText); - command.waitForFinished(-1); + QString cmd = sudoCommand + QString(" /usr/bin/rm ") + profilePath; + if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << cmd; + TaskResult process = runTask(cmd); + if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Cmd returns" << process.exitCode; - if (command.exitCode() == 0) + if (process.exitCode == 0) return true; else return false; diff --git a/sources/netctlgui/src/sleepthread.h b/sources/netctlgui/src/sleepthread.h deleted file mode 120000 index b5a7b6f..0000000 --- a/sources/netctlgui/src/sleepthread.h +++ /dev/null @@ -1 +0,0 @@ -../include/netctlgui/sleepthread.h \ No newline at end of file diff --git a/sources/netctlgui/src/taskadds.cpp b/sources/netctlgui/src/taskadds.cpp new file mode 120000 index 0000000..419d267 --- /dev/null +++ b/sources/netctlgui/src/taskadds.cpp @@ -0,0 +1 @@ +../../3rdparty/task/taskadds.cpp \ No newline at end of file diff --git a/sources/netctlgui/src/taskadds.h b/sources/netctlgui/src/taskadds.h new file mode 120000 index 0000000..1611105 --- /dev/null +++ b/sources/netctlgui/src/taskadds.h @@ -0,0 +1 @@ +../../3rdparty/task/taskadds.h \ No newline at end of file diff --git a/sources/netctlgui/src/wpasupinteract.cpp b/sources/netctlgui/src/wpasupinteract.cpp index 0233c69..61bc5c8 100644 --- a/sources/netctlgui/src/wpasupinteract.cpp +++ b/sources/netctlgui/src/wpasupinteract.cpp @@ -24,9 +24,9 @@ #include -#include #include "netctlgui.h" +#include "taskadds.h" /** @@ -69,10 +69,6 @@ WpaSup::WpaSup(const bool debugCmd, const QMap settings) wpaSupPath = settings[QString("WPASUP_PATH")]; else wpaSupPath = QString("/usr/bin/wpa_supplicant"); - - // terminate old loaded profile - if (QFile(pidFile).exists() || QDir(ctrlDir).exists()) - stopWpaSupplicant(); } @@ -108,10 +104,10 @@ QString WpaSup::existentProfile(const QString essid) } QString profileFile = QString(""); - QList profileList = netctlCommand->getProfileList(); + QList profileList = netctlCommand->getProfileList(); for (int i=0; igetValueFromProfile(profileList[i][0], QString("ESSID"))) - profileFile = profileList[i][0]; + if (essid == netctlProfile->getValueFromProfile(profileList[i].name, QString("ESSID"))) + profileFile = profileList[i].name; return profileFile; } @@ -134,10 +130,10 @@ bool WpaSup::isProfileActive(const QString essid) } QString profileFile; - QList profileList = netctlCommand->getProfileList(); + QList profileList = netctlCommand->getProfileList(); for (int i=0; igetValueFromProfile(profileList[i][0], QString("ESSID"))) { - profileFile = profileList[i][0]; + if (essid == netctlProfile->getValueFromProfile(profileList[i].name, QString("ESSID"))) { + profileFile = profileList[i].name; break; } @@ -162,9 +158,9 @@ bool WpaSup::isProfileExists(const QString essid) } bool exists = false; - QList profileList = netctlCommand->getProfileList(); + QList profileList = netctlCommand->getProfileList(); for (int i=0; igetValueFromProfile(profileList[i][0], QString("ESSID"))) { + if (essid == netctlProfile->getValueFromProfile(profileList[i].name, QString("ESSID"))) { exists = true; break; } @@ -176,18 +172,18 @@ bool WpaSup::isProfileExists(const QString essid) /** * @fn scanWifi */ -QList WpaSup::scanWifi() +QList WpaSup::scanWifi() { if (debug) qDebug() << "[WpaSup]" << "[scanWifi]"; - QList scanResults; + QList scanResults; if (!startWpaSupplicant()) { stopWpaSupplicant(); return scanResults; } if (!wpaCliCall(QString("scan"))) return scanResults; - SleepThread::sleep(3); + waitForProcess(3); QStringList rawOutput = getWpaCliOutput(QString("scan_results")).split(QChar('\n'), QString::SkipEmptyParts); // remove table header @@ -207,26 +203,26 @@ QList WpaSup::scanWifi() } for (int i=0; i 4) - wifiPoint.append(rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[4]); + wifiPoint.name = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[4]; else - wifiPoint.append(QString("")); + wifiPoint.name = QString(""); // profile status QString status; - if (isProfileExists(wifiPoint[0])) { + if (isProfileExists(wifiPoint.name)) { status = QString("exists"); - if (isProfileActive(wifiPoint[0])) + if (isProfileActive(wifiPoint.name)) status = status + QString(" (active)"); else status = status + QString(" (inactive)"); } else status = QString("new"); - wifiPoint.append(status); + wifiPoint.status = status; // point signal - wifiPoint.append(rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[2]); + wifiPoint.signal = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[2]; // point security QString security = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[3]; if (security.contains(QString("WPA2"))) @@ -237,7 +233,7 @@ QList WpaSup::scanWifi() security = QString("WEP"); else security = QString("none"); - wifiPoint.append(security); + wifiPoint.security = security; scanResults.append(wifiPoint); } stopWpaSupplicant(); @@ -280,25 +276,23 @@ bool WpaSup::startWpaSupplicant() if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find library"; return false; } - if (netctlCommand->getInterfaceList().isEmpty()) { + if (netctlCommand->getWirelessInterfaceList().isEmpty()) { if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find interfaces"; return false; } if (QFile(pidFile).exists()) return true; - QProcess command; - QString interface = netctlCommand->getInterfaceList()[0]; - QString commandText = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile + + QString interface = netctlCommand->getWirelessInterfaceList()[0]; + QString cmd = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile + QString(" -i ") + interface + QString(" -D ") + wpaDrivers + QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\""); - if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Run cmd" << commandText; - command.start(commandText); - command.waitForFinished(-1); - SleepThread::sleep(1); - if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Cmd returns" << command.exitCode(); + if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Run cmd" << cmd; + TaskResult process = runTask(cmd); + waitForProcess(1); + if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Cmd returns" << process.exitCode; - if (command.exitCode() == 0) + if (process.exitCode == 0) return true; else return false; @@ -340,20 +334,34 @@ QString WpaSup::getWpaCliOutput(const QString commandLine) if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find library"; return QString(); } - if (netctlCommand->getInterfaceList().isEmpty()) { + if (netctlCommand->getWirelessInterfaceList().isEmpty()) { if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find interfaces"; return QString(); } - QProcess command; - QString interface = netctlCommand->getInterfaceList()[0]; - QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir + + QString interface = netctlCommand->getWirelessInterfaceList()[0]; + QString cmd = 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); + if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << cmd; + TaskResult process = runTask(cmd); + if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Cmd returns" << process.exitCode; - return command.readAllStandardOutput(); + return process.output; +} + + +/** + * @fn waitForProcess + */ +bool WpaSup::waitForProcess(const int sec) +{ + if (debug) qDebug() << "[WpaSup]" << "[waitForProcess]"; + if (debug) qDebug() << "[WpaSup]" << "[waitForProcess]" << ":" << "Interval" << sec; + + QString cmd = QString("sleep %1").arg(QString::number(sec)); + runTask(cmd); + + return true; } @@ -380,22 +388,20 @@ bool WpaSup::wpaCliCall(const QString commandLine) if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find library"; return false; } - if (netctlCommand->getInterfaceList().isEmpty()) { + if (netctlCommand->getWirelessInterfaceList().isEmpty()) { if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find interfaces"; return false; } - QProcess command; - QString interface = netctlCommand->getInterfaceList()[0]; - QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir + + QString interface = netctlCommand->getWirelessInterfaceList()[0]; + QString cmd = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir + QString(" -P ") + pidFile + QString(" ") + commandLine; - if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Run cmd" << commandText; - command.start(commandText); - command.waitForFinished(-1); - SleepThread::sleep(1); - if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Cmd returns" << command.exitCode(); + if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << cmd; + TaskResult process = runTask(cmd); + waitForProcess(1); + if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Cmd returns" << process.exitCode; - if (command.exitCode() == 0) + if (process.exitCode == 0) return true; else return false; diff --git a/sources/plasmoid/netctl.cpp b/sources/plasmoid/netctl.cpp index e4dde79..8aeae7f 100644 --- a/sources/plasmoid/netctl.cpp +++ b/sources/plasmoid/netctl.cpp @@ -15,10 +15,6 @@ * along with netctl-gui. If not, see http://www.gnu.org/licenses/ * ***************************************************************************/ -#include "netctl.h" -#include -#include - #include #include #include @@ -32,7 +28,12 @@ #include #include -#include +#include "netctl.h" +#include "ui_about.h" +#include "ui_appearance.h" +#include "ui_dataengine.h" +#include "ui_widget.h" +#include "version.h" IconLabel::IconLabel(Netctl *wid, const bool debugCmd) @@ -68,8 +69,8 @@ Netctl::Netctl(QObject *parent, const QVariantList &args) else debug = false; - this->setBackgroundHints(DefaultBackground); - this->setHasConfigurationInterface(true); + setBackgroundHints(DefaultBackground); + setHasConfigurationInterface(true); connect(this, SIGNAL(activate()), this, SLOT(showGui())); // text format init formatLine.append(QString("")); @@ -112,7 +113,7 @@ void Netctl::init() // generate ui graphicsWidget = new QWidget(); graphicsWidget->setAttribute(Qt::WA_TranslucentBackground, true); - this->setWidget(graphicsWidget); + setWidget(graphicsWidget); // layouts layout = new QHBoxLayout(graphicsWidget); layout->setContentsMargins(1, 1, 1, 1); @@ -262,7 +263,7 @@ void Netctl::updateIcon() else icon = paths[QString("inactive")]; - this->setPopupIcon(KIcon(icon)); + setPopupIcon(KIcon(icon)); QPixmap iconPixmap; iconPixmap.load(icon); iconLabel->setPixmap(iconPixmap); @@ -279,7 +280,7 @@ void Netctl::updateInterface(bool setShown) else layout->removeWidget(textLabel); graphicsWidget->adjustSize(); - this->resize(1, 1); + resize(1, 1); } @@ -580,7 +581,7 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da info[QString("status")] = QString("(") + value + QString(")"); } - this->update(); + update(); }