mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
some library refactoring
This commit is contained in:
parent
5efb25dca3
commit
d2714dca02
2
sources/3rdparty/task
vendored
2
sources/3rdparty/task
vendored
@ -1 +1 @@
|
|||||||
Subproject commit d2798204a1a84a23a9510aeda73d5b9b75d2c8eb
|
Subproject commit dd52af08c9d6a2c8652d2d5e21bc2a433efb497a
|
@ -290,12 +290,12 @@ small {
|
|||||||
</tr>
|
</tr>
|
||||||
<!-- general information -->
|
<!-- general information -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>QString ActiveProfile()</td>
|
<td>QStringList ActiveProfile()</td>
|
||||||
<td>returns active profile from netctl or netctl-auto</td>
|
<td>returns active profile from netctl or netctl-auto</td>
|
||||||
<td>no</td>
|
<td>no</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>QString ActiveProfileStatus()</td>
|
<td>QStringList ActiveProfileStatus()</td>
|
||||||
<td>returns active profile status from netctl or netctl-auto. May be <code>netctl-auto</code>, <code>active (enabled)</code>, <code>active (static)</code>, <code>inactive (enabled)</code>, <code>inactive (static)</code></td>
|
<td>returns active profile status from netctl or netctl-auto. May be <code>netctl-auto</code>, <code>active (enabled)</code>, <code>active (static)</code>, <code>inactive (enabled)</code>, <code>inactive (static)</code></td>
|
||||||
<td>no</td>
|
<td>no</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -305,7 +305,7 @@ small {
|
|||||||
<td>no</td>
|
<td>no</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>QString netctlActiveProfile()</td>
|
<td>QStringList netctlActiveProfile()</td>
|
||||||
<td>returns active profile from netctl even if netctl-auto is running</td>
|
<td>returns active profile from netctl even if netctl-auto is running</td>
|
||||||
<td>no</td>
|
<td>no</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -39,25 +39,25 @@ NetctlAdaptor::~NetctlAdaptor()
|
|||||||
|
|
||||||
|
|
||||||
// netctlCommand
|
// netctlCommand
|
||||||
QString NetctlAdaptor::ActiveProfile()
|
QStringList NetctlAdaptor::ActiveProfile()
|
||||||
{
|
{
|
||||||
if (isNetctlAutoActive())
|
if (isNetctlAutoActive())
|
||||||
return netctlCommand->autoGetActiveProfile();
|
return netctlCommand->autoGetActiveProfile();
|
||||||
else
|
else
|
||||||
return netctlCommand->getActiveProfile().join(QChar('|'));
|
return netctlCommand->getActiveProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString NetctlAdaptor::ActiveProfileStatus()
|
QStringList NetctlAdaptor::ActiveProfileStatus()
|
||||||
{
|
{
|
||||||
if (isNetctlAutoActive())
|
if (isNetctlAutoActive())
|
||||||
return QString("netctl-auto");
|
return QStringList() << QString("netctl-auto");
|
||||||
else {
|
else {
|
||||||
QStringList status;
|
QStringList status;
|
||||||
QStringList profiles = ActiveProfile().split(QChar('|'));
|
QStringList profiles = ActiveProfile();
|
||||||
for (int i=0; i<profiles.count(); i++)
|
for (int i=0; i<profiles.count(); i++)
|
||||||
status.append(netctlCommand->getProfileStatus(profiles[i]));
|
status.append(netctlCommand->getProfileStatus(profiles[i]));
|
||||||
return status.join(QChar('|'));
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,9 +108,9 @@ bool NetctlAdaptor::isProfileEnabled(const QString profile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString NetctlAdaptor::netctlActiveProfile()
|
QStringList NetctlAdaptor::netctlActiveProfile()
|
||||||
{
|
{
|
||||||
return netctlCommand->getActiveProfile().join(QChar('|'));
|
return netctlCommand->getActiveProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// netctlCommand
|
// netctlCommand
|
||||||
QString ActiveProfile();
|
QStringList ActiveProfile();
|
||||||
QString ActiveProfileStatus();
|
QStringList ActiveProfileStatus();
|
||||||
bool autoIsProfileActive(const QString profile);
|
bool autoIsProfileActive(const QString profile);
|
||||||
bool autoIsProfileEnabled(const QString profile);
|
bool autoIsProfileEnabled(const QString profile);
|
||||||
QStringList Information();
|
QStringList Information();
|
||||||
@ -46,7 +46,7 @@ public slots:
|
|||||||
bool isNetctlAutoEnabled();
|
bool isNetctlAutoEnabled();
|
||||||
bool isProfileActive(const QString profile);
|
bool isProfileActive(const QString profile);
|
||||||
bool isProfileEnabled(const QString profile);
|
bool isProfileEnabled(const QString profile);
|
||||||
QString netctlActiveProfile();
|
QStringList netctlActiveProfile();
|
||||||
QStringList netctlProfileList();
|
QStringList netctlProfileList();
|
||||||
QStringList netctlVerboseProfileList();
|
QStringList netctlVerboseProfileList();
|
||||||
QStringList ProfileList();
|
QStringList ProfileList();
|
||||||
|
@ -30,10 +30,9 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
|
|
||||||
class NetctlProfile;
|
class NetctlProfile;
|
||||||
|
struct TaskResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct netctlProfileInfo
|
* @struct netctlProfileInfo
|
||||||
@ -94,81 +93,75 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Netctl class destructor
|
* @brief Netctl class destructor
|
||||||
*/
|
*/
|
||||||
~Netctl();
|
virtual ~Netctl();
|
||||||
// general information
|
// general information
|
||||||
/**
|
/**
|
||||||
* @brief method which returns active profile name
|
* @brief method which returns active profile name
|
||||||
* @return profile name or ""
|
* @return Netctl::getActiveProfileTemplate()
|
||||||
*/
|
*/
|
||||||
QStringList getActiveProfile();
|
QStringList getActiveProfile() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which returns active profile name from netctl-auto
|
* @brief method which returns active profile name from netctl-auto
|
||||||
* @return profile name or ""
|
* @return Netctl::getActiveProfileTemplate()
|
||||||
*/
|
*/
|
||||||
QString autoGetActiveProfile();
|
QStringList autoGetActiveProfile() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which returns profile informations from netctl
|
* @brief method which returns profile informations from netctl
|
||||||
* @return list of profiles
|
* @return Netctl::getProfileListTemplate()
|
||||||
*/
|
*/
|
||||||
QList<netctlProfileInfo> getProfileList();
|
QList<netctlProfileInfo> getProfileList() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which returns profile informations from netctl-auto
|
* @brief method which returns profile informations from netctl-auto
|
||||||
* @return list of profiles from netctl-auto
|
* @return Netctl::getProfileListTemplate()
|
||||||
*/
|
*/
|
||||||
QList<netctlProfileInfo> getProfileListFromNetctlAuto();
|
QList<netctlProfileInfo> getProfileListFromNetctlAuto() const;
|
||||||
/**
|
|
||||||
* @brief method which gets description from profile
|
|
||||||
* @param profile profile name
|
|
||||||
* @return profile description or ""
|
|
||||||
*/
|
|
||||||
Q_DECL_DEPRECATED QString getProfileDescription(const QString profile);
|
|
||||||
/**
|
/**
|
||||||
* @brief method which gets profile status
|
* @brief method which gets profile status
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return profile status. It may be "active (enabled)", "active (static)",
|
* @return profile status. It may be "active (enabled)", "active (static)",
|
||||||
* "inactive (enabled)", "inactive (static)"
|
* "inactive (enabled)", "inactive (static)"
|
||||||
*/
|
*/
|
||||||
QString getProfileStatus(const QString profile);
|
QString getProfileStatus(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which checks if profile is active
|
* @brief method which checks if profile is active
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if profile is inactive
|
* @return false if profile is inactive
|
||||||
* @return true if profile is active
|
* @return true if profile is active
|
||||||
*/
|
*/
|
||||||
bool isProfileActive(const QString profile);
|
bool isProfileActive(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which checks if profile is enabled
|
* @brief method which checks if profile is enabled
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if profile is disabled
|
* @return false if profile is disabled
|
||||||
* @return true if profile is enabled
|
* @return true if profile is enabled
|
||||||
*/
|
*/
|
||||||
bool isProfileEnabled(const QString profile);
|
bool isProfileEnabled(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which checks if profile is active (netctl-auto)
|
* @brief method which checks if profile is active (netctl-auto)
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if profile is inactive
|
* @return false if profile is inactive
|
||||||
* @return true if profile is active
|
* @return true if profile is active
|
||||||
*/
|
*/
|
||||||
bool autoIsProfileActive(const QString profile);
|
bool autoIsProfileActive(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which checks if profile is enabled (netctl-auto)
|
* @brief method which checks if profile is enabled (netctl-auto)
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if profile is disabled
|
* @return false if profile is disabled
|
||||||
* @return true if profile is enabled
|
* @return true if profile is enabled
|
||||||
*/
|
*/
|
||||||
bool autoIsProfileEnabled(const QString profile);
|
bool autoIsProfileEnabled(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which checks netctl-auto autoload status
|
* @brief method which checks netctl-auto autoload status
|
||||||
* @return false if netctl-auto is disabled
|
* @return false if netctl-auto is disabled
|
||||||
* @return true if netctl-auto is enabled
|
* @return true if netctl-auto is enabled
|
||||||
*/
|
*/
|
||||||
bool isNetctlAutoEnabled();
|
bool isNetctlAutoEnabled() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which checks netctl-auto status
|
* @brief method which checks netctl-auto status
|
||||||
* @return false if netctl-auto is inactive
|
* @return false if netctl-auto is inactive
|
||||||
* @return true if netctl-auto is active
|
* @return true if netctl-auto is active
|
||||||
*/
|
*/
|
||||||
bool isNetctlAutoRunning();
|
bool isNetctlAutoRunning() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which check system configuration and return recommended values to keys
|
* @brief method which check system configuration and return recommended values to keys
|
||||||
* @return recommended parametrs
|
* @return recommended parametrs
|
||||||
@ -178,7 +171,7 @@ public:
|
|||||||
* @brief method which gets wireless interface list from PREFERED_IFACE and IFACE_DIR
|
* @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
|
* @return interface list. If PREFERED_IFACE is not empty it will be first element
|
||||||
*/
|
*/
|
||||||
QStringList getWirelessInterfaceList();
|
QStringList getWirelessInterfaceList() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// functions
|
// functions
|
||||||
@ -189,101 +182,101 @@ public slots:
|
|||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool enableProfile(const QString profile);
|
bool enableProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which force starts profile
|
* @brief method which force starts profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool forceStartProfile(const QString profile);
|
bool forceStartProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which force stops profile
|
* @brief method which force stops profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool forceStopProfile(const QString profile);
|
bool forceStopProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which reenables profile
|
* @brief method which reenables profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool reenableProfile(const QString profile);
|
bool reenableProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which restarts profile
|
* @brief method which restarts profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool restartProfile(const QString profile);
|
bool restartProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which starts or stops profile
|
* @brief method which starts or stops profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool startProfile(const QString profile);
|
bool startProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which stops all profiles
|
* @brief method which stops all profiles
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool stopAllProfiles();
|
bool stopAllProfiles() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which starts another profile
|
* @brief method which starts another profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool switchToProfile(const QString profile);
|
bool switchToProfile(const QString profile) const;
|
||||||
// netctl-auto
|
// netctl-auto
|
||||||
/**
|
/**
|
||||||
* @brief method which sets all profiles disabled (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 false if components are not found or command exit code is not equal to 0
|
||||||
* @return true if the method was completed without errors
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool autoDisableAllProfiles();
|
bool autoDisableAllProfiles() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which sets profile disabled or enabled (netctl-auto)
|
* @brief method which sets profile disabled or enabled (netctl-auto)
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool autoEnableProfile(const QString profile);
|
bool autoEnableProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which sets all profiles enabled (netctl-auto)
|
* @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 false if components are not found or command exit code is not equal to 0
|
||||||
* @return true if the method was completed without errors
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool autoEnableAllProfiles();
|
bool autoEnableAllProfiles() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which switchs to profile (netctl-auto)
|
* @brief method which switchs to profile (netctl-auto)
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool autoStartProfile(const QString profile);
|
bool autoStartProfile(const QString profile) const;
|
||||||
// netctl-auto service
|
// netctl-auto service
|
||||||
/**
|
/**
|
||||||
* @brief method which sets netctl-auto service enabled or disabled
|
* @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 false if components are not found or command exit code is not equal to 0
|
||||||
* @return true if the method was completed without errors
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool autoEnableService();
|
bool autoEnableService() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which restarted netctl-auto service
|
* @brief method which restarted netctl-auto service
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool autoRestartService();
|
bool autoRestartService() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which starts or stops netctl-auto service
|
* @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 false if components are not found or command exit code is not equal to 0
|
||||||
* @return true if the method was completed without errors
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool autoStartService();
|
bool autoStartService() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@ -297,7 +290,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @brief use RootProcess instead of QProcess. Default is true
|
* @brief use RootProcess instead of QProcess. Default is true
|
||||||
*/
|
*/
|
||||||
bool useSuid = true;
|
bool useSuid;
|
||||||
/**
|
/**
|
||||||
* @brief directory with interfaces. Default is "/sys/class/net/"
|
* @brief directory with interfaces. Default is "/sys/class/net/"
|
||||||
*/
|
*/
|
||||||
@ -305,27 +298,27 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @brief prefered interface for WiFi. Default is ""
|
* @brief prefered interface for WiFi. Default is ""
|
||||||
*/
|
*/
|
||||||
QString mainInterface = QString(PREFERED_IFACE);
|
QString mainInterface;
|
||||||
/**
|
/**
|
||||||
* @brief path to netctl command. Default is "netctl"
|
* @brief path to netctl command. Default is "netctl"
|
||||||
*/
|
*/
|
||||||
QString netctlCommand = QString(NETCTL_PATH);
|
QString netctlCommand;
|
||||||
/**
|
/**
|
||||||
* @brief path to netctl-auto command. Default is "netctl-auto"
|
* @brief path to netctl-auto command. Default is "netctl-auto"
|
||||||
*/
|
*/
|
||||||
QString netctlAutoCommand = QString(NETCTLAUTO_PATH);
|
QString netctlAutoCommand;
|
||||||
/**
|
/**
|
||||||
* @brief netctl-auto service name. Default is "netctl-auto"
|
* @brief netctl-auto service name. Default is "netctl-auto"
|
||||||
*/
|
*/
|
||||||
QString netctlAutoService = QString(NETCTLAUTO_SERVICE);
|
QString netctlAutoService;
|
||||||
/**
|
/**
|
||||||
* @brief path to sudo command. Default is "kdesu"
|
* @brief path to sudo command. Default is "kdesu"
|
||||||
*/
|
*/
|
||||||
QString sudoCommand = QString(SUDO_PATH);
|
QString sudoCommand;
|
||||||
/**
|
/**
|
||||||
* @brief path to systemctl command. Default is "systemctl"
|
* @brief path to systemctl command. Default is "systemctl"
|
||||||
*/
|
*/
|
||||||
QString systemctlCommand = QString(SYSTEMCTL_PATH);
|
QString systemctlCommand;
|
||||||
// functions
|
// functions
|
||||||
/**
|
/**
|
||||||
* @brief method which calls command
|
* @brief method which calls command
|
||||||
@ -333,21 +326,22 @@ private:
|
|||||||
* @param command command which will be called
|
* @param command command which will be called
|
||||||
* @param commandLine command which will be passed to command
|
* @param commandLine command which will be passed to command
|
||||||
* @param argument argument which will be passed to commandLine
|
* @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 process object
|
||||||
* @return true if the method was completed without errors
|
|
||||||
*/
|
*/
|
||||||
bool cmdCall(const bool sudo, const QString command,
|
TaskResult cmdCall(const bool sudo, const QString command,
|
||||||
const QString commandLine, const QString argument = 0);
|
const QString commandLine, const QString argument = QString()) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which calls command and returns its output
|
* @brief method which parse output for profile data
|
||||||
* @param sudo set true if sudo is needed
|
* @param data profile list data
|
||||||
* @param command command which will be called
|
* @return list of active profiles if any
|
||||||
* @param commandLine command which will be passed to command
|
|
||||||
* @param argument argument which will be passed to commandLine
|
|
||||||
* @return command output
|
|
||||||
*/
|
*/
|
||||||
QString getCmdOutput(const bool sudo, const QString command,
|
QStringList getActiveProfileTemplate(const QList<netctlProfileInfo> data) const;
|
||||||
const QString commandLine, const QString argument = 0);
|
/**
|
||||||
|
* @brief get profile list from sources
|
||||||
|
* @param isAuto use netctl-auto instead of netctl
|
||||||
|
* @return profile list
|
||||||
|
*/
|
||||||
|
QList<netctlProfileInfo> getProfileListTemplate(const bool isAuto) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief NetctlInterface class destructor
|
* @brief NetctlInterface class destructor
|
||||||
*/
|
*/
|
||||||
~NetctlInterface();
|
virtual ~NetctlInterface();
|
||||||
// control methods
|
// control methods
|
||||||
/**
|
/**
|
||||||
* @brief method which creates and copies profile
|
* @brief method which creates and copies profile
|
||||||
@ -120,7 +120,7 @@ public:
|
|||||||
* @return InterfaceAnswer::True if profile is created
|
* @return InterfaceAnswer::True if profile is created
|
||||||
* @return InterfaceAnswer::Error if an error occurs
|
* @return InterfaceAnswer::Error if an error occurs
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer createProfile(const QString profile, const QMap<QString, QString> settings);
|
InterfaceAnswer createProfile(const QString profile, const QMap<QString, QString> settings) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which connects to ESSID
|
* @brief method which connects to ESSID
|
||||||
* @remark netctl independ
|
* @remark netctl independ
|
||||||
@ -130,7 +130,7 @@ public:
|
|||||||
* @return InterfaceAnswer::True if profile is active
|
* @return InterfaceAnswer::True if profile is active
|
||||||
* @return InterfaceAnswer::Error if an error occurs
|
* @return InterfaceAnswer::Error if an error occurs
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer connectToEssid(const QString essid, QMap<QString, QString> settings);
|
InterfaceAnswer connectToEssid(const QString essid, QMap<QString, QString> settings) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which connects to existent profile by ESSID
|
* @brief method which connects to existent profile by ESSID
|
||||||
* @remark netctl independ
|
* @remark netctl independ
|
||||||
@ -139,7 +139,7 @@ public:
|
|||||||
* @return InterfaceAnswer::True if profile is active
|
* @return InterfaceAnswer::True if profile is active
|
||||||
* @return InterfaceAnswer::Error if an error occurs
|
* @return InterfaceAnswer::Error if an error occurs
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer connectToKnownEssid(const QString essid);
|
InterfaceAnswer connectToKnownEssid(const QString essid) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which creates wireless profile and connects to it
|
* @brief method which creates wireless profile and connects to it
|
||||||
* @remark netctl independ
|
* @remark netctl independ
|
||||||
@ -149,7 +149,7 @@ public:
|
|||||||
* @return InterfaceAnswer::True if profile is active
|
* @return InterfaceAnswer::True if profile is active
|
||||||
* @return InterfaceAnswer::Error if an error occurs
|
* @return InterfaceAnswer::Error if an error occurs
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer connectToUnknownEssid(const QString essid, QMap<QString, QString> settings);
|
InterfaceAnswer connectToUnknownEssid(const QString essid, QMap<QString, QString> settings) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which enables or disables selected profile and returns its status
|
* @brief method which enables or disables selected profile and returns its status
|
||||||
* @remark netctl only
|
* @remark netctl only
|
||||||
@ -158,7 +158,7 @@ public:
|
|||||||
* @return InterfaceAnswer::True if profile is enabled
|
* @return InterfaceAnswer::True if profile is enabled
|
||||||
* @return InterfaceAnswer::Error if an error occurs
|
* @return InterfaceAnswer::Error if an error occurs
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer enableProfile(const QString profile);
|
InterfaceAnswer enableProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which removes selected profile
|
* @brief method which removes selected profile
|
||||||
* @remark netctl independ
|
* @remark netctl independ
|
||||||
@ -166,7 +166,7 @@ public:
|
|||||||
* @return InterfaceAnswer::True if profile does not exists anymore
|
* @return InterfaceAnswer::True if profile does not exists anymore
|
||||||
* @return InterfaceAnswer::Error if an error occurs
|
* @return InterfaceAnswer::Error if an error occurs
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer removeProfile(const QString profile);
|
InterfaceAnswer removeProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which restarts selected profile and returns its status
|
* @brief method which restarts selected profile and returns its status
|
||||||
* @remark netctl only
|
* @remark netctl only
|
||||||
@ -175,7 +175,7 @@ public:
|
|||||||
* @return InterfaceAnswer::True if profile is active
|
* @return InterfaceAnswer::True if profile is active
|
||||||
* @return InterfaceAnswer::Error if an error occurs
|
* @return InterfaceAnswer::Error if an error occurs
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer restartProfile(const QString profile);
|
InterfaceAnswer restartProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which starts/stops or switchs to selected profile and returns its status
|
* @brief method which starts/stops or switchs to selected profile and returns its status
|
||||||
* @remark netctl only
|
* @remark netctl only
|
||||||
@ -184,14 +184,14 @@ public:
|
|||||||
* @return InterfaceAnswer::True if profile is active
|
* @return InterfaceAnswer::True if profile is active
|
||||||
* @return InterfaceAnswer::Error if an error occurs
|
* @return InterfaceAnswer::Error if an error occurs
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer startProfile(const QString profile);
|
InterfaceAnswer startProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which stops all profiles
|
* @brief method which stops all profiles
|
||||||
* @remark netctl only
|
* @remark netctl only
|
||||||
* @return InterfaceAnswer::True if there are no errors
|
* @return InterfaceAnswer::True if there are no errors
|
||||||
* @return InterfaceAnswer::Error if an error occurs
|
* @return InterfaceAnswer::Error if an error occurs
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer stopAllProfiles();
|
InterfaceAnswer stopAllProfiles() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which switchs to selected profile and returns its status
|
* @brief method which switchs to selected profile and returns its status
|
||||||
* @remark both netctl and netctl-auto
|
* @remark both netctl and netctl-auto
|
||||||
@ -200,26 +200,26 @@ public:
|
|||||||
* @return InterfaceAnswer::True if profile is active
|
* @return InterfaceAnswer::True if profile is active
|
||||||
* @return InterfaceAnswer::Error if an error occurs
|
* @return InterfaceAnswer::Error if an error occurs
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer switchToProfile(const QString profile);
|
InterfaceAnswer switchToProfile(const QString profile) const;
|
||||||
// information
|
// information
|
||||||
/**
|
/**
|
||||||
* @brief method which returns general information
|
* @brief method which returns general information
|
||||||
* @remark both netctl and netctl-auto
|
* @remark both netctl and netctl-auto
|
||||||
* @return netctlInformation structure
|
* @return netctlInformation structure
|
||||||
*/
|
*/
|
||||||
netctlInformation information();
|
netctlInformation information() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which reads settings from profile
|
* @brief method which reads settings from profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return settings from profile
|
* @return settings from profile
|
||||||
*/
|
*/
|
||||||
QMap<QString, QString> profileSettings(const QString profile);
|
QMap<QString, QString> profileSettings(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which returns current status
|
* @brief method which returns current status
|
||||||
* @remark both netctl and netctl-auto
|
* @remark both netctl and netctl-auto
|
||||||
* @return netctlCurrent structure
|
* @return netctlCurrent structure
|
||||||
*/
|
*/
|
||||||
netctlCurrent status();
|
netctlCurrent status() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -30,8 +30,6 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The NetctlProfile class interacts with netctl profiles
|
* @brief The NetctlProfile class interacts with netctl profiles
|
||||||
@ -54,21 +52,21 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Netctl class destructor
|
* @brief Netctl class destructor
|
||||||
*/
|
*/
|
||||||
~NetctlProfile();
|
virtual ~NetctlProfile();
|
||||||
/**
|
/**
|
||||||
* @brief method which copies temporary profile to PROFILE_DIR
|
* @brief method which copies temporary profile to PROFILE_DIR
|
||||||
* @param oldPath path to temprorary profile
|
* @param oldPath path to temprorary profile
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool copyProfile(const QString oldPath);
|
bool copyProfile(const QString oldPath) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which creates temporary profile
|
* @brief method which creates temporary profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @param settings profile configuration. All available keys will be printed to the profile
|
* @param settings profile configuration. All available keys will be printed to the profile
|
||||||
* @return temporary profile name
|
* @return temporary profile name
|
||||||
*/
|
*/
|
||||||
QString createProfile(const QString profile, const QMap<QString, QString> settings);
|
QString createProfile(const QString profile, const QMap<QString, QString> settings) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which check system configuration and return recommended values to keys
|
* @brief method which check system configuration and return recommended values to keys
|
||||||
* @return recommended parametrs
|
* @return recommended parametrs
|
||||||
@ -79,28 +77,28 @@ public:
|
|||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return settings from profile
|
* @return settings from profile
|
||||||
*/
|
*/
|
||||||
QMap<QString, QString> getSettingsFromProfile(const QString profile);
|
QMap<QString, QString> getSettingsFromProfile(const QString profile) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which return value from profile by key
|
* @brief method which return value from profile by key
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @param key required key
|
* @param key required key
|
||||||
* @return value by key
|
* @return value by key
|
||||||
*/
|
*/
|
||||||
QString getValueFromProfile(const QString profile, const QString key);
|
QString getValueFromProfile(const QString profile, const QString key) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which return values from profile by keys
|
* @brief method which return values from profile by keys
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @param keys required keys
|
* @param keys required keys
|
||||||
* @return values by keys
|
* @return values by keys
|
||||||
*/
|
*/
|
||||||
QStringList getValuesFromProfile(const QString profile, const QStringList keys);
|
QStringList getValuesFromProfile(const QString profile, const QStringList keys) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which removes profile
|
* @brief method which removes profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool removeProfile(const QString profile);
|
bool removeProfile(const QString profile) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@ -110,7 +108,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @brief use RootProcess instead of QProcess. Default is true
|
* @brief use RootProcess instead of QProcess. Default is true
|
||||||
*/
|
*/
|
||||||
bool useSuid = true;
|
bool useSuid;
|
||||||
/**
|
/**
|
||||||
* @brief directory which contains profiles. Default is "/etc/netctl"
|
* @brief directory which contains profiles. Default is "/etc/netctl"
|
||||||
*/
|
*/
|
||||||
@ -118,7 +116,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @brief path to sudo command. Default is "kdesu"
|
* @brief path to sudo command. Default is "kdesu"
|
||||||
*/
|
*/
|
||||||
QString sudoCommand = QString(SUDO_PATH);
|
QString sudoCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
|
|
||||||
class Netctl;
|
class Netctl;
|
||||||
class NetctlProfile;
|
class NetctlProfile;
|
||||||
@ -113,14 +111,14 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief WpaSup class destructor
|
* @brief WpaSup class destructor
|
||||||
*/
|
*/
|
||||||
~WpaSup();
|
virtual ~WpaSup();
|
||||||
// general information
|
// general information
|
||||||
/**
|
/**
|
||||||
* @brief method which gets profile name by ESSID
|
* @brief method which gets profile name by ESSID
|
||||||
* @param essid ESSID name
|
* @param essid ESSID name
|
||||||
* @return profile name
|
* @return profile name
|
||||||
*/
|
*/
|
||||||
QString existentProfile(const QString essid);
|
QString existentProfile(const QString essid) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which check system configuration and return recommended values to keys
|
* @brief method which check system configuration and return recommended values to keys
|
||||||
* @return recommended parametrs
|
* @return recommended parametrs
|
||||||
@ -132,14 +130,7 @@ public:
|
|||||||
* @return false if profile is inactive
|
* @return false if profile is inactive
|
||||||
* @return true if profile is active
|
* @return true if profile is active
|
||||||
*/
|
*/
|
||||||
bool isProfileActive(const QString essid);
|
bool isProfileActive(const QString essid) const;
|
||||||
/**
|
|
||||||
* @brief method which checks profile existence by ESSID
|
|
||||||
* @param essid ESSID name
|
|
||||||
* @return false if profile does not exist
|
|
||||||
* @return true if profile exists
|
|
||||||
*/
|
|
||||||
Q_DECL_DEPRECATED bool isProfileExists(const QString essid);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// functions
|
// functions
|
||||||
@ -147,24 +138,24 @@ public slots:
|
|||||||
* @brief method which returns active point information
|
* @brief method which returns active point information
|
||||||
* @return current point information
|
* @return current point information
|
||||||
*/
|
*/
|
||||||
netctlWifiInfo current();
|
netctlWifiInfo current() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which scans WiFi networks
|
* @brief method which scans WiFi networks
|
||||||
* @return list of essids
|
* @return list of essids
|
||||||
*/
|
*/
|
||||||
QList<netctlWifiInfo> scanWifi();
|
QList<netctlWifiInfo> scanWifi() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which calls wpa_supplicant
|
* @brief method which calls wpa_supplicant
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool startWpaSupplicant();
|
bool startWpaSupplicant() const;
|
||||||
/**
|
/**
|
||||||
* @brief method which send TERMINATE signal to wpa_supplicant
|
* @brief method which send TERMINATE signal to wpa_supplicant
|
||||||
* @return false if components are not found or command exit code is not equal to 0
|
* @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
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool stopWpaSupplicant();
|
bool stopWpaSupplicant() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@ -182,54 +173,54 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @brief use RootProcess instead of QProcess. Default is true
|
* @brief use RootProcess instead of QProcess. Default is true
|
||||||
*/
|
*/
|
||||||
bool useSuid = true;
|
bool useSuid;
|
||||||
/**
|
/**
|
||||||
* @brief path to ctrl_directory. Defaults is "/run/wpa_supplicant"
|
* @brief path to ctrl_directory. Defaults is "/run/wpa_supplicant"
|
||||||
*/
|
*/
|
||||||
QString ctrlDir = QString(CTRL_DIR);
|
QString ctrlDir;
|
||||||
/**
|
/**
|
||||||
* @brief group which is owner of CTRL_DIR. Default is "users"
|
* @brief group which is owner of CTRL_DIR. Default is "users"
|
||||||
*/
|
*/
|
||||||
QString ctrlGroup = QString(CTRL_GROUP);
|
QString ctrlGroup;
|
||||||
/**
|
/**
|
||||||
* @brief wpa_supplicant PID file. $i is interface. Default is "/run/wpa_supplicant_$i.pid"
|
* @brief wpa_supplicant PID file. $i is interface. Default is "/run/wpa_supplicant_$i.pid"
|
||||||
*/
|
*/
|
||||||
QString pidFile = QString(PID_FILE);
|
QString pidFile;
|
||||||
/**
|
/**
|
||||||
* @brief path to sudo command. Default is "kdesu"
|
* @brief path to sudo command. Default is "kdesu"
|
||||||
*/
|
*/
|
||||||
QString sudoCommand = QString(SUDO_PATH);
|
QString sudoCommand;
|
||||||
/**
|
/**
|
||||||
* @brief path to wpa_cli command. Default is "wpa_cli"
|
* @brief path to wpa_cli command. Default is "wpa_cli"
|
||||||
*/
|
*/
|
||||||
QString wpaCliPath = QString(WPACLI_PATH);
|
QString wpaCliPath;
|
||||||
/**
|
/**
|
||||||
* @brief wpa_supplicant drivers comma separated. Default is "nl80211,wext"
|
* @brief wpa_supplicant drivers comma separated. Default is "nl80211,wext"
|
||||||
*/
|
*/
|
||||||
QString wpaDrivers = QString(WPA_DRIVERS);
|
QString wpaDrivers;
|
||||||
/**
|
/**
|
||||||
* @brief path to wpa_supplicant command. Default is "wpa_supplicant"
|
* @brief path to wpa_supplicant command. Default is "wpa_supplicant"
|
||||||
*/
|
*/
|
||||||
QString wpaSupPath = QString(WPASUP_PATH);
|
QString wpaSupPath;
|
||||||
// functions
|
// functions
|
||||||
/**
|
/**
|
||||||
* @brief method which calls wpa_cli and returns its output
|
* @brief method which calls wpa_cli and returns its output
|
||||||
* @param commandLine command which will be passed to wpa_cli
|
* @param commandLine command which will be passed to wpa_cli
|
||||||
* @return wpa_cli output
|
* @return wpa_cli output
|
||||||
*/
|
*/
|
||||||
QString getWpaCliOutput(const QString commandLine);
|
QString getWpaCliOutput(const QString commandLine) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which will be called to sleep thread
|
* @brief method which will be called to sleep thread
|
||||||
* @param sec time interval, seconds
|
* @param sec time interval, seconds
|
||||||
*/
|
*/
|
||||||
bool waitForProcess(const int sec);
|
bool waitForProcess(const int sec) const;
|
||||||
/**
|
/**
|
||||||
* @brief method which calls wpa_cli
|
* @brief method which calls wpa_cli
|
||||||
* @param commandLine command which will be passed 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 false if components are not found or command exit code is not equal to 0
|
||||||
* @return true if the method was completed without errors
|
* @return true if the method was completed without errors
|
||||||
*/
|
*/
|
||||||
bool wpaCliCall(const QString commandLine);
|
bool wpaCliCall(const QString commandLine) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
#include <task/taskadds.h>
|
#include <task/taskadds.h>
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Netctl
|
* @class Netctl
|
||||||
@ -42,27 +44,16 @@ Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
|
|||||||
{
|
{
|
||||||
netctlProfile = new NetctlProfile(debug, settings);
|
netctlProfile = new NetctlProfile(debug, settings);
|
||||||
|
|
||||||
if (settings.contains(QString("IFACE_DIR")))
|
ifaceDirectory = new QDir(settings.value(QString("IFACE_DIR"), QString(IFACE_DIR)));
|
||||||
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
|
mainInterface = settings.value(QString("PREFERED_IFACE"), QString(PREFERED_IFACE));
|
||||||
else
|
netctlCommand = settings.value(QString("NETCTL_PATH"), QString(NETCTL_PATH));
|
||||||
ifaceDirectory = new QDir(QString(IFACE_DIR));
|
netctlAutoCommand = settings.value(QString("NETCTLAUTO_PATH"), QString(NETCTLAUTO_PATH));
|
||||||
if (settings.contains(QString("PREFERED_IFACE")))
|
netctlAutoService = settings.value(QString("NETCTLAUTO_SERVICE"), QString(NETCTLAUTO_SERVICE));
|
||||||
mainInterface = settings[QString("PREFERED_IFACE")];
|
sudoCommand = settings.value(QString("SUDO_PATH"), QString(SUDO_PATH));
|
||||||
if (settings.contains(QString("NETCTL_PATH")))
|
systemctlCommand = settings.value(QString("SYSTEMCTL_PATH"), QString(SYSTEMCTL_PATH));
|
||||||
netctlCommand = settings[QString("NETCTL_PATH")];
|
useSuid = (settings.value(QString("FORCE_SUDO"), QString("true")) != QString("true"));
|
||||||
if (settings.contains(QString("NETCTLAUTO_PATH")))
|
|
||||||
netctlAutoCommand = settings[QString("NETCTLAUTO_PATH")];
|
|
||||||
if (settings.contains(QString("NETCTLAUTO_SERVICE")))
|
|
||||||
netctlAutoService = settings[QString("NETCTLAUTO_SERVICE")];
|
|
||||||
if (settings.contains(QString("SUDO_PATH")))
|
|
||||||
sudoCommand = settings[QString("SUDO_PATH")];
|
|
||||||
if (settings.contains(QString("SYSTEMCTL_PATH")))
|
|
||||||
systemctlCommand = settings[QString("SYSTEMCTL_PATH")];
|
|
||||||
if (settings.contains(QString("FORCE_SUDO")))
|
|
||||||
useSuid = (settings[QString("FORCE_SUDO")] != QString("true"));
|
|
||||||
|
|
||||||
if (useSuid)
|
if (useSuid) sudoCommand = QString("");
|
||||||
sudoCommand = QString("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -78,207 +69,61 @@ Netctl::~Netctl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// functions
|
|
||||||
/**
|
|
||||||
* @fn cmdCall
|
|
||||||
*/
|
|
||||||
bool Netctl::cmdCall(const bool sudo, const QString command, const QString commandLine, const QString argument)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Command" << command;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Command line" << commandLine;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Argument" << argument;
|
|
||||||
if (command.isEmpty()) {
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find command";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString cmd = QString("");
|
|
||||||
if (sudo)
|
|
||||||
cmd = QString("%1 ").arg(sudoCommand);
|
|
||||||
cmd += QString("%1 %2").arg(command).arg(commandLine);
|
|
||||||
if (!argument.isEmpty())
|
|
||||||
cmd += QString(" \"%1\"").arg(argument);
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
|
||||||
TaskResult process = runTask(cmd, (useSuid && sudo));
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
|
||||||
|
|
||||||
return (process.exitCode == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fn getCmdOutput
|
|
||||||
*/
|
|
||||||
QString Netctl::getCmdOutput(const bool sudo, const QString command, const QString commandLine, const QString argument)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Command" << command;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Command line" << commandLine;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Argument" << argument;
|
|
||||||
if (command.isEmpty()) {
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find command";
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString cmd = QString("");
|
|
||||||
if (sudo)
|
|
||||||
cmd = QString("%1 ").arg(sudoCommand);
|
|
||||||
cmd += QString("%1 %2").arg(command).arg(commandLine);
|
|
||||||
if (!argument.isEmpty())
|
|
||||||
cmd += QString(" \"%1\"").arg(argument);
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
|
||||||
TaskResult process = runTask(cmd, (useSuid && sudo));
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
|
||||||
|
|
||||||
return process.output;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// general information
|
// general information
|
||||||
/**
|
/**
|
||||||
* @fn getActiveProfile
|
* @fn getActiveProfile
|
||||||
*/
|
*/
|
||||||
QStringList Netctl::getActiveProfile()
|
QStringList Netctl::getActiveProfile() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QStringList profile;
|
return getActiveProfileTemplate(getProfileList());
|
||||||
QList<netctlProfileInfo> fullProfilesInfo = getProfileList();
|
|
||||||
for (int i=0; i<fullProfilesInfo.count(); i++)
|
|
||||||
if (fullProfilesInfo[i].active)
|
|
||||||
profile.append(fullProfilesInfo[i].name);
|
|
||||||
|
|
||||||
return profile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn autoGetActiveProfile
|
* @fn autoGetActiveProfile
|
||||||
*/
|
*/
|
||||||
QString Netctl::autoGetActiveProfile()
|
QStringList Netctl::autoGetActiveProfile() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QString profile = QString("");
|
return getActiveProfileTemplate(getProfileListFromNetctlAuto());
|
||||||
QList<netctlProfileInfo> fullProfilesInfo = getProfileListFromNetctlAuto();
|
|
||||||
for (int i=0; i<fullProfilesInfo.count(); i++)
|
|
||||||
if (fullProfilesInfo[i].active) {
|
|
||||||
profile = fullProfilesInfo[i].name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return profile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn getProfileList
|
* @fn getProfileList
|
||||||
*/
|
*/
|
||||||
QList<netctlProfileInfo> Netctl::getProfileList()
|
QList<netctlProfileInfo> Netctl::getProfileList() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QList<netctlProfileInfo> fullProfilesInfo;
|
return getProfileListTemplate(false);
|
||||||
QStringList output = getCmdOutput(false, netctlCommand, QString("list"))
|
|
||||||
.split(QChar('\n'), QString::SkipEmptyParts);
|
|
||||||
for (int i=0; i<output.count(); i++) {
|
|
||||||
netctlProfileInfo profileInfo;
|
|
||||||
profileInfo.name = output[i].mid(2, -1);
|
|
||||||
profileInfo.active = (output[i][0] == QChar('*'));
|
|
||||||
profileInfo.enabled = isProfileEnabled(profileInfo.name);
|
|
||||||
// external
|
|
||||||
QStringList keys;
|
|
||||||
keys.append(QString("Connection"));
|
|
||||||
keys.append(QString("Description"));
|
|
||||||
keys.append(QString("ESSID"));
|
|
||||||
keys.append(QString("Interface"));
|
|
||||||
QStringList profileValues = netctlProfile->getValuesFromProfile(profileInfo.name,
|
|
||||||
keys);
|
|
||||||
profileInfo.description = profileValues[1];
|
|
||||||
profileInfo.essid = profileValues[2];
|
|
||||||
profileInfo.interface = profileValues[3];
|
|
||||||
profileInfo.type = profileValues[0];
|
|
||||||
profileInfo.netctlAuto = false;
|
|
||||||
fullProfilesInfo.append(profileInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fullProfilesInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn getProfileListFromNetctlAuto
|
* @fn getProfileListFromNetctlAuto
|
||||||
*/
|
*/
|
||||||
QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto()
|
QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QList<netctlProfileInfo> fullProfilesInfo;
|
return getProfileListTemplate(true);
|
||||||
QStringList output = getCmdOutput(false, netctlAutoCommand, QString("list"))
|
|
||||||
.split(QChar('\n'), QString::SkipEmptyParts);
|
|
||||||
for (int i=0; i<output.count(); i++) {
|
|
||||||
netctlProfileInfo profileInfo;
|
|
||||||
profileInfo.name = output[i].mid(2, -1);
|
|
||||||
profileInfo.active = (output[i][0] == QChar('*'));
|
|
||||||
profileInfo.enabled = (output[i][0] != QChar('!'));
|
|
||||||
// external
|
|
||||||
QStringList keys;
|
|
||||||
keys.append(QString("Connection"));
|
|
||||||
keys.append(QString("Description"));
|
|
||||||
keys.append(QString("ESSID"));
|
|
||||||
keys.append(QString("Interface"));
|
|
||||||
QStringList profileValues = netctlProfile->getValuesFromProfile(profileInfo.name,
|
|
||||||
keys);
|
|
||||||
profileInfo.description = profileValues[1];
|
|
||||||
profileInfo.essid = profileValues[2];
|
|
||||||
profileInfo.interface = profileValues[3];
|
|
||||||
profileInfo.type = profileValues[0];
|
|
||||||
profileInfo.netctlAuto = true;
|
|
||||||
fullProfilesInfo.append(profileInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fullProfilesInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fn getProfileDescription
|
|
||||||
*/
|
|
||||||
QString Netctl::getProfileDescription(const QString profile)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
|
||||||
if (netctlProfile == 0) {
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return netctlProfile->getValueFromProfile(profile, QString("Description"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn getProfileStatus
|
* @fn getProfileStatus
|
||||||
*/
|
*/
|
||||||
QString Netctl::getProfileStatus(const QString profile)
|
QString Netctl::getProfileStatus(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
QString status;
|
QString status = isProfileActive(profile) ? QString("active") : QString("inactive");
|
||||||
if (isProfileActive(profile))
|
status += isProfileEnabled(profile) ? QString(" (enabled)") : QString(" (static)");
|
||||||
status = QString("active");
|
|
||||||
else
|
|
||||||
status = QString("inactive");
|
|
||||||
if (isProfileEnabled(profile))
|
|
||||||
status += QString(" (enabled)");
|
|
||||||
else
|
|
||||||
status += QString(" (static)");
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -287,42 +132,40 @@ QString Netctl::getProfileStatus(const QString profile)
|
|||||||
/**
|
/**
|
||||||
* @fn isProfileActive
|
* @fn isProfileActive
|
||||||
*/
|
*/
|
||||||
bool Netctl::isProfileActive(const QString profile)
|
bool Netctl::isProfileActive(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
QString output = getCmdOutput(false, netctlCommand, QString("status"), profile);
|
return cmdCall(false, netctlCommand, QString("status"), profile).status();
|
||||||
|
|
||||||
return (output.contains(QString("Active: active")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn isProfileEnabled
|
* @fn isProfileEnabled
|
||||||
*/
|
*/
|
||||||
bool Netctl::isProfileEnabled(const QString profile)
|
bool Netctl::isProfileEnabled(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
return cmdCall(false, netctlCommand, QString("is-enabled"), profile);
|
return cmdCall(false, netctlCommand, QString("is-enabled"), profile).status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn autoIsProfileActive
|
* @fn autoIsProfileActive
|
||||||
*/
|
*/
|
||||||
bool Netctl::autoIsProfileActive(const QString profile)
|
bool Netctl::autoIsProfileActive(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
|
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
|
||||||
for (int i=0; i<profiles.count(); i++) {
|
foreach(netctlProfileInfo profileInfo, profiles) {
|
||||||
if (profiles[i].name == profile) continue;
|
if (profileInfo.name != profile) continue;
|
||||||
status = profiles[i].active;
|
status = profileInfo.active;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,16 +176,16 @@ bool Netctl::autoIsProfileActive(const QString profile)
|
|||||||
/**
|
/**
|
||||||
* @fn autoIsProfileEnabled
|
* @fn autoIsProfileEnabled
|
||||||
*/
|
*/
|
||||||
bool Netctl::autoIsProfileEnabled(const QString profile)
|
bool Netctl::autoIsProfileEnabled(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
|
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
|
||||||
for (int i=0; i<profiles.count(); i++) {
|
foreach(netctlProfileInfo profileInfo, profiles) {
|
||||||
if (profiles[i].name == profile) continue;
|
if (profileInfo.name != profile) continue;
|
||||||
status = profiles[i].enabled;
|
status = profileInfo.enabled;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +196,7 @@ bool Netctl::autoIsProfileEnabled(const QString profile)
|
|||||||
/**
|
/**
|
||||||
* @fn isNetctlAutoEnabled
|
* @fn isNetctlAutoEnabled
|
||||||
*/
|
*/
|
||||||
bool Netctl::isNetctlAutoEnabled()
|
bool Netctl::isNetctlAutoEnabled() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlAutoService.isEmpty()) {
|
if (netctlAutoService.isEmpty()) {
|
||||||
@ -366,16 +209,16 @@ bool Netctl::isNetctlAutoEnabled()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
|
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces.first());
|
||||||
|
|
||||||
return cmdCall(false, systemctlCommand, QString("is-enabled"), argument);
|
return cmdCall(false, systemctlCommand, QString("is-enabled"), argument).status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn isNetctlAutoRunning
|
* @fn isNetctlAutoRunning
|
||||||
*/
|
*/
|
||||||
bool Netctl::isNetctlAutoRunning()
|
bool Netctl::isNetctlAutoRunning() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlAutoService.isEmpty()) {
|
if (netctlAutoService.isEmpty()) {
|
||||||
@ -388,9 +231,9 @@ bool Netctl::isNetctlAutoRunning()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
|
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces.first());
|
||||||
|
|
||||||
return cmdCall(false, systemctlCommand, QString("is-active"), argument);
|
return cmdCall(false, systemctlCommand, QString("is-active"), argument).status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -408,9 +251,9 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
|||||||
recommended.clear();
|
recommended.clear();
|
||||||
recommended.append(QString("netctlgui-helper"));
|
recommended.append(QString("netctlgui-helper"));
|
||||||
recommended.append(QString("netctlgui-helper-suid"));
|
recommended.append(QString("netctlgui-helper-suid"));
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("FORCE_SUDO")] = QString("false");
|
settings[QString("FORCE_SUDO")] = QString("false");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -436,9 +279,9 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
|||||||
settings[QString("NETCTL_PATH")] = QString("");
|
settings[QString("NETCTL_PATH")] = QString("");
|
||||||
recommended.clear();
|
recommended.clear();
|
||||||
recommended.append("netctl");
|
recommended.append("netctl");
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("NETCTL_PATH")] = process.output.trimmed();
|
settings[QString("NETCTL_PATH")] = process.output.trimmed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -448,9 +291,9 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
|||||||
settings[QString("NETCTLAUTO_PATH")] = QString("");
|
settings[QString("NETCTLAUTO_PATH")] = QString("");
|
||||||
recommended.clear();
|
recommended.clear();
|
||||||
recommended.append("netctl-auto");
|
recommended.append("netctl-auto");
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("NETCTLAUTO_PATH")] = process.output.trimmed();
|
settings[QString("NETCTLAUTO_PATH")] = process.output.trimmed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -478,9 +321,9 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
|||||||
recommended.append("sudo");
|
recommended.append("sudo");
|
||||||
recommended.append("kdesu");
|
recommended.append("kdesu");
|
||||||
recommended.append("gksu");
|
recommended.append("gksu");
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("SUDO_PATH")] = process.output.trimmed();
|
settings[QString("SUDO_PATH")] = process.output.trimmed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -490,9 +333,9 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
|||||||
settings[QString("SYSTEMCTL_PATH")] = QString("");
|
settings[QString("SYSTEMCTL_PATH")] = QString("");
|
||||||
recommended.clear();
|
recommended.clear();
|
||||||
recommended.append("systemctl");
|
recommended.append("systemctl");
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("SYSTEMCTL_PATH")] = process.output.trimmed();
|
settings[QString("SYSTEMCTL_PATH")] = process.output.trimmed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -505,7 +348,7 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
|||||||
/**
|
/**
|
||||||
* @fn getWirelessInterfaceList
|
* @fn getWirelessInterfaceList
|
||||||
*/
|
*/
|
||||||
QStringList Netctl::getWirelessInterfaceList()
|
QStringList Netctl::getWirelessInterfaceList() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (ifaceDirectory == nullptr) {
|
if (ifaceDirectory == nullptr) {
|
||||||
@ -517,11 +360,11 @@ QStringList Netctl::getWirelessInterfaceList()
|
|||||||
if (!mainInterface.isEmpty())
|
if (!mainInterface.isEmpty())
|
||||||
interfaces.append(mainInterface);
|
interfaces.append(mainInterface);
|
||||||
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
for (int i=0; i<allInterfaces.count(); i++) {
|
foreach(QString interface, allInterfaces) {
|
||||||
QString dir = QString("%1/%2/wireless").arg(ifaceDirectory->path()).arg(allInterfaces[i]);
|
QString dir = QString("%1/%2/wireless").arg(ifaceDirectory->path()).arg(interface);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Check directory" << dir;
|
if (debug) qDebug() << PDEBUG << ":" << "Check directory" << dir;
|
||||||
if (QDir(dir).exists())
|
if (QDir(dir).exists())
|
||||||
interfaces.append(allInterfaces[i]);
|
interfaces.append(interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return interfaces;
|
return interfaces;
|
||||||
@ -532,159 +375,156 @@ QStringList Netctl::getWirelessInterfaceList()
|
|||||||
/**
|
/**
|
||||||
* @fn enableProfile
|
* @fn enableProfile
|
||||||
*/
|
*/
|
||||||
bool Netctl::enableProfile(const QString profile)
|
bool Netctl::enableProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
if (isProfileEnabled(profile))
|
return cmdCall(true, netctlCommand,
|
||||||
return cmdCall(true, netctlCommand, QString("disable"), profile);
|
isProfileEnabled(profile) ? QString("disable") : QString("enable"),
|
||||||
else
|
profile).status();
|
||||||
return cmdCall(true, netctlCommand, QString("enable"), profile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn forceStartProfile
|
* @fn forceStartProfile
|
||||||
*/
|
*/
|
||||||
bool Netctl::forceStartProfile(const QString profile)
|
bool Netctl::forceStartProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
return cmdCall(true, netctlCommand, QString("start"), profile);
|
return cmdCall(true, netctlCommand, QString("start"), profile).status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn forceStopProfile
|
* @fn forceStopProfile
|
||||||
*/
|
*/
|
||||||
bool Netctl::forceStopProfile(const QString profile)
|
bool Netctl::forceStopProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
return cmdCall(true, netctlCommand, QString("stop"), profile);
|
return cmdCall(true, netctlCommand, QString("stop"), profile).status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn reenableProfile
|
* @fn reenableProfile
|
||||||
*/
|
*/
|
||||||
bool Netctl::reenableProfile(const QString profile)
|
bool Netctl::reenableProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
return cmdCall(true, netctlCommand, QString("reenable"), profile);
|
return cmdCall(true, netctlCommand, QString("reenable"), profile).status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn restartProfile
|
* @fn restartProfile
|
||||||
*/
|
*/
|
||||||
bool Netctl::restartProfile(const QString profile)
|
bool Netctl::restartProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
return cmdCall(true, netctlCommand, QString("restart"), profile);
|
return cmdCall(true, netctlCommand, QString("restart"), profile).status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn startProfile
|
* @fn startProfile
|
||||||
*/
|
*/
|
||||||
bool Netctl::startProfile(const QString profile)
|
bool Netctl::startProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
if (isProfileActive(profile))
|
return cmdCall(true, netctlCommand,
|
||||||
return cmdCall(true, netctlCommand, QString("stop"), profile);
|
isProfileActive(profile) ? QString("stop") : QString("start"),
|
||||||
else
|
profile).status();
|
||||||
return cmdCall(true, netctlCommand, QString("start"), profile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn stopAllProfiles
|
* @fn stopAllProfiles
|
||||||
*/
|
*/
|
||||||
bool Netctl::stopAllProfiles()
|
bool Netctl::stopAllProfiles() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return cmdCall(true, netctlCommand, QString("stop-all"));
|
return cmdCall(true, netctlCommand, QString("stop-all")).status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn switchToProfile
|
* @fn switchToProfile
|
||||||
*/
|
*/
|
||||||
bool Netctl::switchToProfile(const QString profile)
|
bool Netctl::switchToProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
return ((isProfileActive(profile)) ||
|
return ((isProfileActive(profile)) ||
|
||||||
(cmdCall(true, netctlCommand, QString("switch-to"), profile)));
|
(cmdCall(true, netctlCommand, QString("switch-to"), profile)).status());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn autoDisableAllProfiles
|
* @fn autoDisableAllProfiles
|
||||||
*/
|
*/
|
||||||
bool Netctl::autoDisableAllProfiles()
|
bool Netctl::autoDisableAllProfiles() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return cmdCall(false, netctlAutoCommand, QString("disable-all"));
|
return cmdCall(false, netctlAutoCommand, QString("disable-all")).status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn autoEnableProfile
|
* @fn autoEnableProfile
|
||||||
*/
|
*/
|
||||||
bool Netctl::autoEnableProfile(const QString profile)
|
bool Netctl::autoEnableProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
if (autoIsProfileEnabled(profile))
|
return cmdCall(false, netctlAutoCommand,
|
||||||
return cmdCall(false, netctlAutoCommand, QString("disable"), profile);
|
autoIsProfileEnabled(profile) ? QString("disable") : QString("enable"),
|
||||||
else
|
profile).status();
|
||||||
return cmdCall(false, netctlAutoCommand, QString("enable"), profile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn autoEnableAllProfiles
|
* @fn autoEnableAllProfiles
|
||||||
*/
|
*/
|
||||||
bool Netctl::autoEnableAllProfiles()
|
bool Netctl::autoEnableAllProfiles() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return cmdCall(false, netctlAutoCommand, QString("enable-all"));
|
return cmdCall(false, netctlAutoCommand, QString("enable-all")).status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn autoStartProfile
|
* @fn autoStartProfile
|
||||||
*/
|
*/
|
||||||
bool Netctl::autoStartProfile(const QString profile)
|
bool Netctl::autoStartProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
return ((autoIsProfileActive(profile)) ||
|
return ((autoIsProfileActive(profile)) ||
|
||||||
(cmdCall(false, netctlAutoCommand, QString("switch-to"), profile)));
|
(cmdCall(false, netctlAutoCommand, QString("switch-to"), profile)).status());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn autoEnableService
|
* @fn autoEnableService
|
||||||
*/
|
*/
|
||||||
bool Netctl::autoEnableService()
|
bool Netctl::autoEnableService() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlAutoService.isEmpty()) {
|
if (netctlAutoService.isEmpty()) {
|
||||||
@ -697,19 +537,18 @@ bool Netctl::autoEnableService()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
|
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces.first());
|
||||||
|
|
||||||
if (isNetctlAutoEnabled())
|
return cmdCall(true, systemctlCommand,
|
||||||
return cmdCall(true, systemctlCommand, QString("disable"), argument);
|
isNetctlAutoEnabled() ? QString("disable") : QString("enable"),
|
||||||
else
|
argument).status();
|
||||||
return cmdCall(true, systemctlCommand, QString("enable"), argument);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn autoRestartService
|
* @fn autoRestartService
|
||||||
*/
|
*/
|
||||||
bool Netctl::autoRestartService()
|
bool Netctl::autoRestartService() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlAutoService.isEmpty()) {
|
if (netctlAutoService.isEmpty()) {
|
||||||
@ -722,17 +561,17 @@ bool Netctl::autoRestartService()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
|
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces.first());
|
||||||
|
|
||||||
return ((!isNetctlAutoRunning()) ||
|
return ((!isNetctlAutoRunning()) ||
|
||||||
(cmdCall(true, systemctlCommand, QString("restart"), argument)));
|
(cmdCall(true, systemctlCommand, QString("restart"), argument)).status());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn autoStartService
|
* @fn autoStartService
|
||||||
*/
|
*/
|
||||||
bool Netctl::autoStartService()
|
bool Netctl::autoStartService() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlAutoService.isEmpty()) {
|
if (netctlAutoService.isEmpty()) {
|
||||||
@ -745,10 +584,87 @@ bool Netctl::autoStartService()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
|
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces.first());
|
||||||
|
|
||||||
if (isNetctlAutoRunning())
|
return cmdCall(true, systemctlCommand,
|
||||||
return cmdCall(true, systemctlCommand, QString("stop"), argument);
|
isNetctlAutoRunning() ? QString("stop") : QString("start"),
|
||||||
else
|
argument).status();
|
||||||
return cmdCall(true, systemctlCommand, QString("start"), argument);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// functions
|
||||||
|
/**
|
||||||
|
* @fn cmdCall
|
||||||
|
*/
|
||||||
|
TaskResult Netctl::cmdCall(const bool sudo, const QString command,
|
||||||
|
const QString commandLine, const QString argument) const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Command" << command;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Command line" << commandLine;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Argument" << argument;
|
||||||
|
|
||||||
|
QString cmd = QString("");
|
||||||
|
if (sudo) cmd = QString("%1 ").arg(sudoCommand);
|
||||||
|
cmd += QString("%1 %2").arg(command).arg(commandLine);
|
||||||
|
if (!argument.isEmpty()) cmd += QString(" \"%1\"").arg(argument);
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
|
TaskResult process = runTask(cmd, (useSuid && sudo));
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
|
return process;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn getActiveProfileTemplate
|
||||||
|
*/
|
||||||
|
QStringList Netctl::getActiveProfileTemplate(const QList<netctlProfileInfo> data) const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QStringList profiles;
|
||||||
|
foreach(netctlProfileInfo profile, data) {
|
||||||
|
if (!profile.active) continue;
|
||||||
|
profiles.append(profile.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return profiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn getProfileListTemplate
|
||||||
|
*/
|
||||||
|
QList<netctlProfileInfo> Netctl::getProfileListTemplate(const bool isAuto) const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QList<netctlProfileInfo> fullProfilesInfo;
|
||||||
|
QStringList output = QString(cmdCall(false, isAuto ? netctlAutoCommand : netctlCommand,
|
||||||
|
QString("list")).output)
|
||||||
|
.split(QChar('\n'), QString::SkipEmptyParts);
|
||||||
|
foreach(QString profile, output) {
|
||||||
|
netctlProfileInfo profileInfo;
|
||||||
|
profileInfo.name = profile.mid(2, -1);
|
||||||
|
profileInfo.active = (profile[0] == QChar('*'));
|
||||||
|
profileInfo.enabled = isAuto ? (profile[0] != QChar('!')) : isProfileEnabled(profileInfo.name);
|
||||||
|
// external
|
||||||
|
QStringList keys;
|
||||||
|
keys.append(QString("Connection"));
|
||||||
|
keys.append(QString("Description"));
|
||||||
|
keys.append(QString("ESSID"));
|
||||||
|
keys.append(QString("Interface"));
|
||||||
|
QStringList profileValues = netctlProfile->getValuesFromProfile(profileInfo.name,
|
||||||
|
keys);
|
||||||
|
profileInfo.description = profileValues[1];
|
||||||
|
profileInfo.essid = profileValues[2];
|
||||||
|
profileInfo.interface = profileValues[3];
|
||||||
|
profileInfo.type = profileValues[0];
|
||||||
|
profileInfo.netctlAuto = isAuto;
|
||||||
|
fullProfilesInfo.append(profileInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fullProfilesInfo;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,8 @@ NetctlInterface::~NetctlInterface()
|
|||||||
/**
|
/**
|
||||||
* @fn connectToEssid
|
* @fn connectToEssid
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer NetctlInterface::connectToEssid(const QString essid, QMap<QString, QString> settings)
|
InterfaceAnswer NetctlInterface::connectToEssid(const QString essid,
|
||||||
|
QMap<QString, QString> settings) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -83,7 +84,7 @@ InterfaceAnswer NetctlInterface::connectToEssid(const QString essid, QMap<QStrin
|
|||||||
/**
|
/**
|
||||||
* @fn connectToKnownEssid
|
* @fn connectToKnownEssid
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer NetctlInterface::connectToKnownEssid(const QString essid)
|
InterfaceAnswer NetctlInterface::connectToKnownEssid(const QString essid) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -105,7 +106,8 @@ InterfaceAnswer NetctlInterface::connectToKnownEssid(const QString essid)
|
|||||||
/**
|
/**
|
||||||
* @fn connectToUnknownEssid
|
* @fn connectToUnknownEssid
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer NetctlInterface::connectToUnknownEssid(const QString essid, QMap<QString, QString> settings)
|
InterfaceAnswer NetctlInterface::connectToUnknownEssid(const QString essid,
|
||||||
|
QMap<QString, QString> settings) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -121,7 +123,7 @@ InterfaceAnswer NetctlInterface::connectToUnknownEssid(const QString essid, QMap
|
|||||||
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
||||||
if (interfaces.isEmpty()) return InterfaceAnswer::Error;
|
if (interfaces.isEmpty()) return InterfaceAnswer::Error;
|
||||||
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
|
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
|
||||||
settings[QString("Interface")] = interfaces[0];
|
settings[QString("Interface")] = interfaces.first();
|
||||||
settings[QString("Connection")] = QString("wireless");
|
settings[QString("Connection")] = QString("wireless");
|
||||||
settings[QString("ESSID")] = QString("'%1'").arg(essid);
|
settings[QString("ESSID")] = QString("'%1'").arg(essid);
|
||||||
settings[QString("IP")] = QString("dhcp");
|
settings[QString("IP")] = QString("dhcp");
|
||||||
@ -139,7 +141,8 @@ InterfaceAnswer NetctlInterface::connectToUnknownEssid(const QString essid, QMap
|
|||||||
/**
|
/**
|
||||||
* @fn createProfile
|
* @fn createProfile
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer NetctlInterface::createProfile(const QString profile, const QMap<QString, QString> settings)
|
InterfaceAnswer NetctlInterface::createProfile(const QString profile,
|
||||||
|
const QMap<QString, QString> settings) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -157,7 +160,7 @@ InterfaceAnswer NetctlInterface::createProfile(const QString profile, const QMap
|
|||||||
/**
|
/**
|
||||||
* @fn enableProfile
|
* @fn enableProfile
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer NetctlInterface::enableProfile(const QString profile)
|
InterfaceAnswer NetctlInterface::enableProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -174,7 +177,7 @@ InterfaceAnswer NetctlInterface::enableProfile(const QString profile)
|
|||||||
/**
|
/**
|
||||||
* @fn removeProfile
|
* @fn removeProfile
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer NetctlInterface::removeProfile(const QString profile)
|
InterfaceAnswer NetctlInterface::removeProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlProfile == nullptr) {
|
if (netctlProfile == nullptr) {
|
||||||
@ -189,7 +192,7 @@ InterfaceAnswer NetctlInterface::removeProfile(const QString profile)
|
|||||||
/**
|
/**
|
||||||
* @fn restartProfile
|
* @fn restartProfile
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer NetctlInterface::restartProfile(const QString profile)
|
InterfaceAnswer NetctlInterface::restartProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -206,7 +209,7 @@ InterfaceAnswer NetctlInterface::restartProfile(const QString profile)
|
|||||||
/**
|
/**
|
||||||
* @fn startProfile
|
* @fn startProfile
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer NetctlInterface::startProfile(const QString profile)
|
InterfaceAnswer NetctlInterface::startProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -227,7 +230,7 @@ InterfaceAnswer NetctlInterface::startProfile(const QString profile)
|
|||||||
/**
|
/**
|
||||||
* @fn stopAllProfiles
|
* @fn stopAllProfiles
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer NetctlInterface::stopAllProfiles()
|
InterfaceAnswer NetctlInterface::stopAllProfiles() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -242,7 +245,7 @@ InterfaceAnswer NetctlInterface::stopAllProfiles()
|
|||||||
/**
|
/**
|
||||||
* @fn switchToProfile
|
* @fn switchToProfile
|
||||||
*/
|
*/
|
||||||
InterfaceAnswer NetctlInterface::switchToProfile(const QString profile)
|
InterfaceAnswer NetctlInterface::switchToProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -267,7 +270,7 @@ InterfaceAnswer NetctlInterface::switchToProfile(const QString profile)
|
|||||||
/**
|
/**
|
||||||
* @fn information
|
* @fn information
|
||||||
*/
|
*/
|
||||||
netctlInformation NetctlInterface::information()
|
netctlInformation NetctlInterface::information() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -288,7 +291,7 @@ netctlInformation NetctlInterface::information()
|
|||||||
/**
|
/**
|
||||||
* @fn profileSettings
|
* @fn profileSettings
|
||||||
*/
|
*/
|
||||||
QMap<QString, QString> NetctlInterface::profileSettings(const QString profile)
|
QMap<QString, QString> NetctlInterface::profileSettings(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlProfile == nullptr) {
|
if (netctlProfile == nullptr) {
|
||||||
@ -303,7 +306,7 @@ QMap<QString, QString> NetctlInterface::profileSettings(const QString profile)
|
|||||||
/**
|
/**
|
||||||
* @fn status
|
* @fn status
|
||||||
*/
|
*/
|
||||||
netctlCurrent NetctlInterface::status()
|
netctlCurrent NetctlInterface::status() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlCommand == nullptr) {
|
if (netctlCommand == nullptr) {
|
||||||
@ -318,11 +321,11 @@ netctlCurrent NetctlInterface::status()
|
|||||||
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||||
else
|
else
|
||||||
profiles = netctlCommand->getProfileList();
|
profiles = netctlCommand->getProfileList();
|
||||||
for (int i=0; i<profiles.count(); i++) {
|
foreach(netctlProfileInfo profile, profiles) {
|
||||||
current.profiles.append(profiles[i].name);
|
current.profiles.append(profile.name);
|
||||||
if (!profiles[i].active) continue;
|
if (!profile.active) continue;
|
||||||
current.current.append(profiles[i].name);
|
current.current.append(profile.name);
|
||||||
current.enables.append(profiles[i].enabled);
|
current.enables.append(profile.enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
return current;
|
return current;
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
#include <task/taskadds.h>
|
#include <task/taskadds.h>
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class NetctlProfile
|
* @class NetctlProfile
|
||||||
@ -43,17 +45,11 @@
|
|||||||
NetctlProfile::NetctlProfile(const bool debugCmd, const QMap<QString, QString> settings)
|
NetctlProfile::NetctlProfile(const bool debugCmd, const QMap<QString, QString> settings)
|
||||||
: debug(debugCmd)
|
: debug(debugCmd)
|
||||||
{
|
{
|
||||||
if (settings.contains(QString("PROFILE_DIR")))
|
profileDirectory = new QDir(settings.value(QString("PROFILE_DIR"), QString(PROFILE_DIR)));
|
||||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
sudoCommand = settings.value(QString("SUDO_PATH"), QString(SUDO_PATH));
|
||||||
else
|
useSuid = (settings.value(QString("FORCE_SUDO"), QString("true")) != QString("true"));
|
||||||
profileDirectory = new QDir(QString(PROFILE_DIR));
|
|
||||||
if (settings.contains(QString("SUDO_PATH")))
|
|
||||||
sudoCommand = settings[QString("SUDO_PATH")];
|
|
||||||
if (settings.contains(QString("FORCE_SUDO")))
|
|
||||||
useSuid = (settings[QString("FORCE_SUDO")] != QString("true"));
|
|
||||||
|
|
||||||
if (useSuid)
|
if (useSuid) sudoCommand = QString("");
|
||||||
sudoCommand = QString("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,7 +67,7 @@ NetctlProfile::~NetctlProfile()
|
|||||||
/**
|
/**
|
||||||
* @fn copyProfile
|
* @fn copyProfile
|
||||||
*/
|
*/
|
||||||
bool NetctlProfile::copyProfile(const QString oldPath)
|
bool NetctlProfile::copyProfile(const QString oldPath) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Path" << oldPath;
|
if (debug) qDebug() << PDEBUG << ":" << "Path" << oldPath;
|
||||||
@ -87,17 +83,16 @@ bool NetctlProfile::copyProfile(const QString oldPath)
|
|||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd, useSuid);
|
TaskResult process = runTask(cmd, useSuid);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
return (process.exitCode == 0);
|
return process.status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn createProfile
|
* @fn createProfile
|
||||||
*/
|
*/
|
||||||
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
|
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
@ -108,22 +103,22 @@ QString NetctlProfile::createProfile(const QString profile, const QMap<QString,
|
|||||||
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
return profileTempName;
|
return profileTempName;
|
||||||
QTextStream out(&profileFile);
|
QTextStream out(&profileFile);
|
||||||
for (int i=0; i<settings.keys().count(); i++) {
|
foreach(QString key, settings.keys()) {
|
||||||
out << settings.keys()[i] << QString("=");
|
out << key << QString("=");
|
||||||
if ((settings.keys()[i] == QString("BindsToInterfaces")) ||
|
if ((key == QString("BindsToInterfaces")) ||
|
||||||
(settings.keys()[i] == QString("After")) ||
|
(key == QString("After")) ||
|
||||||
(settings.keys()[i] == QString("Address")) ||
|
(key == QString("Address")) ||
|
||||||
(settings.keys()[i] == QString("Routes")) ||
|
(key == QString("Routes")) ||
|
||||||
(settings.keys()[i] == QString("Address6")) ||
|
(key == QString("Address6")) ||
|
||||||
(settings.keys()[i] == QString("Routes6")) ||
|
(key == QString("Routes6")) ||
|
||||||
(settings.keys()[i] == QString("IPCustom")) ||
|
(key == QString("IPCustom")) ||
|
||||||
(settings.keys()[i] == QString("DNS")) ||
|
(key == QString("DNS")) ||
|
||||||
(settings.keys()[i] == QString("DNSOptions")) ||
|
(key == QString("DNSOptions")) ||
|
||||||
(settings.keys()[i] == QString("ScanFrequencies")) ||
|
(key == QString("ScanFrequencies")) ||
|
||||||
(settings.keys()[i] == QString("WPAConfigSection")))
|
(key == QString("WPAConfigSection")))
|
||||||
out << QString("(%1)").arg(settings[settings.keys()[i]]) << endl;
|
out << QString("(%1)").arg(settings[key]) << endl;
|
||||||
else
|
else
|
||||||
out << settings[settings.keys()[i]] << endl;
|
out << settings[key] << endl;
|
||||||
}
|
}
|
||||||
profileFile.close();
|
profileFile.close();
|
||||||
|
|
||||||
@ -145,9 +140,9 @@ QMap<QString, QString> NetctlProfile::getRecommendedConfiguration()
|
|||||||
recommended.clear();
|
recommended.clear();
|
||||||
recommended.append(QString("netctlgui-helper"));
|
recommended.append(QString("netctlgui-helper"));
|
||||||
recommended.append(QString("netctlgui-helper-suid"));
|
recommended.append(QString("netctlgui-helper-suid"));
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("FORCE_SUDO")] = QString("false");
|
settings[QString("FORCE_SUDO")] = QString("false");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -172,9 +167,9 @@ QMap<QString, QString> NetctlProfile::getRecommendedConfiguration()
|
|||||||
recommended.append("sudo");
|
recommended.append("sudo");
|
||||||
recommended.append("kdesu");
|
recommended.append("kdesu");
|
||||||
recommended.append("gksu");
|
recommended.append("gksu");
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("SUDO_PATH")] = process.output.trimmed();
|
settings[QString("SUDO_PATH")] = process.output.trimmed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -187,7 +182,7 @@ QMap<QString, QString> NetctlProfile::getRecommendedConfiguration()
|
|||||||
/**
|
/**
|
||||||
* @fn getSettingsFromProfile
|
* @fn getSettingsFromProfile
|
||||||
*/
|
*/
|
||||||
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
|
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
@ -202,13 +197,12 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
|||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd, false);
|
TaskResult process = runTask(cmd, false);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
QStringList output = QString(process.output).trimmed().split(QChar('\n'));
|
QStringList output = QString(process.output).trimmed().split(QChar('\n'));
|
||||||
QStringList systemVariables;
|
QStringList systemVariables;
|
||||||
systemVariables.append(QString("PIPESTATUS"));
|
systemVariables.append(QString("PIPESTATUS"));
|
||||||
for (int i=0; i<output.count(); i++)
|
foreach(QString str, output)
|
||||||
systemVariables.append(output[i].split(QChar('='))[0]);
|
systemVariables.append(str.split(QChar('=')).first());
|
||||||
// profile variables
|
// profile variables
|
||||||
QMap<QString, QString> settings;
|
QMap<QString, QString> settings;
|
||||||
QString profileUrl = QString("%1/%2").arg(profileDirectory->absolutePath()).arg(QFileInfo(profile).fileName());
|
QString profileUrl = QString("%1/%2").arg(profileDirectory->absolutePath()).arg(QFileInfo(profile).fileName());
|
||||||
@ -216,20 +210,19 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
|||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
process = runTask(cmd, false);
|
process = runTask(cmd, false);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
output = QString(process.output).trimmed().split(QChar('\n'));
|
output = QString(process.output).trimmed().split(QChar('\n'));
|
||||||
|
|
||||||
// read variables
|
// read variables
|
||||||
QStringList keys;
|
QStringList keys;
|
||||||
for (int i=0; i<output.count(); i++)
|
foreach(QString str, output)
|
||||||
if (!systemVariables.contains(output[i].split(QChar('='))[0]))
|
if (!systemVariables.contains(str.split(QChar('=')).first()))
|
||||||
keys.append(output[i].split(QChar('='))[0]);
|
keys.append(str.split(QChar('=')).first());
|
||||||
for (int i=0; i<keys.count(); i++){
|
foreach(QString key, keys) {
|
||||||
cmd = QString("env -i bash -c \"source '%1'; for i in ${!%2[@]}; do echo ${%2[$i]}; done\"").arg(profileUrl).arg(keys[i]);
|
cmd = QString("env -i bash -c \"source '%1'; for i in ${!%2[@]}; do echo ${%2[$i]}; done\"").arg(profileUrl).arg(key);
|
||||||
process = runTask(cmd, false);
|
process = runTask(cmd, false);
|
||||||
settings[keys[i]] = process.output.trimmed();
|
settings[key] = process.output.trimmed();
|
||||||
if (debug) qDebug() << PDEBUG << ":" << keys[i] << "=" << settings[keys[i]];
|
if (debug) qDebug() << PDEBUG << ":" << key << "=" << settings[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
@ -239,20 +232,20 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
|||||||
/**
|
/**
|
||||||
* @fn getValueFromProfile
|
* @fn getValueFromProfile
|
||||||
*/
|
*/
|
||||||
QString NetctlProfile::getValueFromProfile(const QString profile, const QString key)
|
QString NetctlProfile::getValueFromProfile(const QString profile, const QString key) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
|
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
|
||||||
|
|
||||||
return getValuesFromProfile(profile, QStringList() << key)[0];
|
return getValuesFromProfile(profile, QStringList() << key).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn getValuesFromProfile
|
* @fn getValuesFromProfile
|
||||||
*/
|
*/
|
||||||
QStringList NetctlProfile::getValuesFromProfile(const QString profile, const QStringList keys)
|
QStringList NetctlProfile::getValuesFromProfile(const QString profile, const QStringList keys) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
@ -260,8 +253,8 @@ QStringList NetctlProfile::getValuesFromProfile(const QString profile, const QSt
|
|||||||
|
|
||||||
QMap<QString, QString> settings = getSettingsFromProfile(profile);
|
QMap<QString, QString> settings = getSettingsFromProfile(profile);
|
||||||
QStringList values;
|
QStringList values;
|
||||||
for (int i=0; i<keys.count(); i++)
|
foreach(QString key, keys)
|
||||||
values.append(settings[keys[i]]);
|
values.append(settings[key]);
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
@ -270,7 +263,7 @@ QStringList NetctlProfile::getValuesFromProfile(const QString profile, const QSt
|
|||||||
/**
|
/**
|
||||||
* @fn removeProfile
|
* @fn removeProfile
|
||||||
*/
|
*/
|
||||||
bool NetctlProfile::removeProfile(const QString profile)
|
bool NetctlProfile::removeProfile(const QString profile) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
@ -284,8 +277,7 @@ bool NetctlProfile::removeProfile(const QString profile)
|
|||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd, useSuid);
|
TaskResult process = runTask(cmd, useSuid);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
return (process.exitCode == 0);
|
return process.status();
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
#include <task/taskadds.h>
|
#include <task/taskadds.h>
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class WpaSup
|
* @class WpaSup
|
||||||
@ -43,25 +45,16 @@ WpaSup::WpaSup(const bool debugCmd, const QMap<QString, QString> settings)
|
|||||||
netctlCommand = new Netctl(debug, settings);
|
netctlCommand = new Netctl(debug, settings);
|
||||||
netctlProfile = new NetctlProfile(debug, settings);
|
netctlProfile = new NetctlProfile(debug, settings);
|
||||||
|
|
||||||
if (settings.contains(QString("CTRL_DIR")))
|
ctrlDir = settings.value(QString("CTRL_DIR"), QString(CTRL_DIR));
|
||||||
ctrlDir = settings[QString("CTRL_DIR")];
|
ctrlGroup = settings.value(QString("CTRL_GROUP"), QString(CTRL_GROUP));
|
||||||
if (settings.contains(QString("CTRL_GROUP")))
|
pidFile = settings.value(QString("PID_FILE"), QString(PID_FILE));
|
||||||
ctrlGroup = settings[QString("CTRL_GROUP")];
|
sudoCommand = settings.value(QString("SUDO_PATH"), QString(SUDO_PATH));
|
||||||
if (settings.contains(QString("PID_FILE")))
|
wpaCliPath = settings.value(QString("WPACLI_PATH"), QString(WPACLI_PATH));
|
||||||
pidFile = settings[QString("PID_FILE")];
|
wpaDrivers = settings.value(QString("WPA_DRIVERS"), QString(WPA_DRIVERS));
|
||||||
if (settings.contains(QString("SUDO_PATH")))
|
wpaSupPath = settings.value(QString("WPASUP_PATH"), QString(WPASUP_PATH));
|
||||||
sudoCommand = settings[QString("SUDO_PATH")];
|
useSuid = (settings.value(QString("FORCE_SUDO"), QString("true")) != QString("true"));
|
||||||
if (settings.contains(QString("WPACLI_PATH")))
|
|
||||||
wpaCliPath = settings[QString("WPACLI_PATH")];
|
|
||||||
if (settings.contains(QString("WPA_DRIVERS")))
|
|
||||||
wpaDrivers = settings[QString("WPA_DRIVERS")];
|
|
||||||
if (settings.contains(QString("WPASUP_PATH")))
|
|
||||||
wpaSupPath = settings[QString("WPASUP_PATH")];
|
|
||||||
if (settings.contains(QString("FORCE_SUDO")))
|
|
||||||
useSuid = (settings[QString("FORCE_SUDO")] != QString("true"));
|
|
||||||
|
|
||||||
if (useSuid)
|
if (useSuid) sudoCommand = QString("");
|
||||||
sudoCommand = QString("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +74,7 @@ WpaSup::~WpaSup()
|
|||||||
/**
|
/**
|
||||||
* @fn existentProfile
|
* @fn existentProfile
|
||||||
*/
|
*/
|
||||||
QString WpaSup::existentProfile(const QString essid)
|
QString WpaSup::existentProfile(const QString essid) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
||||||
@ -94,11 +87,11 @@ QString WpaSup::existentProfile(const QString essid)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString profileFile = QString("");
|
QString profileFile;
|
||||||
QList<netctlProfileInfo> profileList = netctlCommand->getProfileList();
|
QList<netctlProfileInfo> profileList = netctlCommand->getProfileList();
|
||||||
for (int i=0; i<profileList.count(); i++) {
|
foreach(netctlProfileInfo profile, profileList) {
|
||||||
if (essid != profileList[i].essid) continue;
|
if (essid != profile.essid) continue;
|
||||||
profileFile = profileList[i].name;
|
profileFile = profile.name;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,16 +114,16 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
|||||||
// ctrl group
|
// ctrl group
|
||||||
// check group list and find out 'network', 'users', 'root'
|
// check group list and find out 'network', 'users', 'root'
|
||||||
settings[QString("CTRL_GROUP")] = QString("");
|
settings[QString("CTRL_GROUP")] = QString("");
|
||||||
gid_t gtpList[99];
|
gid_t gtpList[size];
|
||||||
int grpSize = getgroups(size, gtpList);
|
int grpSize = getgroups(size, gtpList);
|
||||||
recommended.clear();
|
recommended.clear();
|
||||||
recommended.append("network");
|
recommended.append("network");
|
||||||
recommended.append("users");
|
recommended.append("users");
|
||||||
recommended.append("root");
|
recommended.append("root");
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
for (int j=0; j<grpSize; j++)
|
for (int i=0; i<grpSize; i++)
|
||||||
if (recommended[i] == QString(getgrgid(gtpList[j])->gr_name)) {
|
if (rec == QString(getgrgid(gtpList[i])->gr_name)) {
|
||||||
settings[QString("CTRL_GROUP")] = recommended[i];
|
settings[QString("CTRL_GROUP")] = rec;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!settings[QString("CTRL_GROUP")].isEmpty()) break;
|
if (!settings[QString("CTRL_GROUP")].isEmpty()) break;
|
||||||
@ -141,9 +134,9 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
|||||||
recommended.clear();
|
recommended.clear();
|
||||||
recommended.append(QString("netctlgui-helper"));
|
recommended.append(QString("netctlgui-helper"));
|
||||||
recommended.append(QString("netctlgui-helper-suid"));
|
recommended.append(QString("netctlgui-helper-suid"));
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("FORCE_SUDO")] = QString("false");
|
settings[QString("FORCE_SUDO")] = QString("false");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -158,9 +151,9 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
|||||||
recommended.append("sudo");
|
recommended.append("sudo");
|
||||||
recommended.append("kdesu");
|
recommended.append("kdesu");
|
||||||
recommended.append("gksu");
|
recommended.append("gksu");
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("SUDO_PATH")] = process.output.trimmed();
|
settings[QString("SUDO_PATH")] = process.output.trimmed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -170,9 +163,9 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
|||||||
settings[QString("WPACLI_PATH")] = QString("true");
|
settings[QString("WPACLI_PATH")] = QString("true");
|
||||||
recommended.clear();
|
recommended.clear();
|
||||||
recommended.append("wpa_cli");
|
recommended.append("wpa_cli");
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("WPACLI_PATH")] = process.output.trimmed();
|
settings[QString("WPACLI_PATH")] = process.output.trimmed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -185,9 +178,9 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
|||||||
settings[QString("WPASUP_PATH")] = QString("true");
|
settings[QString("WPASUP_PATH")] = QString("true");
|
||||||
recommended.clear();
|
recommended.clear();
|
||||||
recommended.append("wpa_supplicant");
|
recommended.append("wpa_supplicant");
|
||||||
for (int i=0; i<recommended.count(); i++) {
|
foreach(QString rec, recommended) {
|
||||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
process = runTask(QString("which %1").arg(rec), false);
|
||||||
if (process.exitCode == 0) {
|
if (process.status()) {
|
||||||
settings[QString("WPASUP_PATH")] = process.output.trimmed();
|
settings[QString("WPASUP_PATH")] = process.output.trimmed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -200,7 +193,7 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
|||||||
/**
|
/**
|
||||||
* @fn isProfileActive
|
* @fn isProfileActive
|
||||||
*/
|
*/
|
||||||
bool WpaSup::isProfileActive(const QString essid)
|
bool WpaSup::isProfileActive(const QString essid) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
||||||
@ -213,50 +206,14 @@ bool WpaSup::isProfileActive(const QString essid)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString profileFile;
|
return netctlCommand->isProfileActive(existentProfile(essid));
|
||||||
QList<netctlProfileInfo> profileList = netctlCommand->getProfileList();
|
|
||||||
for (int i=0; i<profileList.count(); i++) {
|
|
||||||
if (essid != profileList[i].essid) continue;
|
|
||||||
profileFile = profileList[i].name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return netctlCommand->isProfileActive(profileFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fn isProfileExists
|
|
||||||
*/
|
|
||||||
bool WpaSup::isProfileExists(const QString essid)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
|
||||||
if (netctlCommand == nullptr) {
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (netctlProfile == nullptr) {
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool exists = false;
|
|
||||||
QList<netctlProfileInfo> profileList = netctlCommand->getProfileList();
|
|
||||||
for (int i=0; i<profileList.count(); i++) {
|
|
||||||
if (essid != profileList[i].essid) continue;
|
|
||||||
exists = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return exists;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn current
|
* @fn current
|
||||||
*/
|
*/
|
||||||
netctlWifiInfo WpaSup::current()
|
netctlWifiInfo WpaSup::current() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (pidFile.isEmpty()) {
|
if (pidFile.isEmpty()) {
|
||||||
@ -269,7 +226,7 @@ netctlWifiInfo WpaSup::current()
|
|||||||
return netctlWifiInfo();
|
return netctlWifiInfo();
|
||||||
}
|
}
|
||||||
QString _pidFile = pidFile;
|
QString _pidFile = pidFile;
|
||||||
_pidFile.replace(QString("$i"), interfaces[0]);
|
_pidFile.replace(QString("$i"), interfaces.first());
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "PID file" << _pidFile << QFile(_pidFile).exists();
|
if (debug) qDebug() << PDEBUG << ":" << "PID file" << _pidFile << QFile(_pidFile).exists();
|
||||||
|
|
||||||
netctlWifiInfo current;
|
netctlWifiInfo current;
|
||||||
@ -278,21 +235,21 @@ netctlWifiInfo WpaSup::current()
|
|||||||
if (!rawText.contains(QString("wpa_state=COMPLETED\n"))) return current;
|
if (!rawText.contains(QString("wpa_state=COMPLETED\n"))) return current;
|
||||||
|
|
||||||
QStringList rawList = rawText.split(QChar('\n'), QString::SkipEmptyParts);
|
QStringList rawList = rawText.split(QChar('\n'), QString::SkipEmptyParts);
|
||||||
for (int i=0; i<rawList.count(); i++) {
|
foreach(QString element, rawList) {
|
||||||
QStringList line = rawList[i].split(QChar('='));
|
QStringList line = element.split(QChar('='));
|
||||||
if (line.count() != 2) continue;
|
if (line.count() != 2) continue;
|
||||||
if (line[0] == QString("bssid"))
|
if (line.at(0) == QString("bssid"))
|
||||||
current.macs.append(line[1]);
|
current.macs.append(line.at(1));
|
||||||
else if (line[0] == QString("freq")) {
|
else if (line.at(0) == QString("freq")) {
|
||||||
if ((line[1].toInt() >= 5000) && (line[1].toInt() < 6000))
|
if ((line.at(1).toInt() >= 5000) && (line.at(1).toInt() < 6000))
|
||||||
current.type = PointType::FiveG;
|
current.type = PointType::FiveG;
|
||||||
else if ((line[1].toInt() < 5000) && (line[1].toInt() > 2000))
|
else if ((line.at(1).toInt() < 5000) && (line.at(1).toInt() > 2000))
|
||||||
current.type = PointType::TwoG;
|
current.type = PointType::TwoG;
|
||||||
current.frequencies.append(line[1].toInt());
|
current.frequencies.append(line.at(1).toInt());
|
||||||
} else if (line[0] == QString("ssid"))
|
} else if (line.at(0) == QString("ssid"))
|
||||||
current.name = line[1];
|
current.name = line.at(1);
|
||||||
else if (line[0] == QString("key_mgmt")) {
|
else if (line.at(0) == QString("key_mgmt")) {
|
||||||
QString security = line[1];
|
QString security = line.at(1);
|
||||||
if (security.contains(QString("WPA2")))
|
if (security.contains(QString("WPA2")))
|
||||||
security = QString("WPA2");
|
security = QString("WPA2");
|
||||||
else if (security.contains(QString("WPA")))
|
else if (security.contains(QString("WPA")))
|
||||||
@ -316,7 +273,7 @@ netctlWifiInfo WpaSup::current()
|
|||||||
/**
|
/**
|
||||||
* @fn scanWifi
|
* @fn scanWifi
|
||||||
*/
|
*/
|
||||||
QList<netctlWifiInfo> WpaSup::scanWifi()
|
QList<netctlWifiInfo> WpaSup::scanWifi() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (pidFile.isEmpty()) {
|
if (pidFile.isEmpty()) {
|
||||||
@ -329,7 +286,7 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
|||||||
return QList<netctlWifiInfo>();
|
return QList<netctlWifiInfo>();
|
||||||
}
|
}
|
||||||
QString _pidFile = pidFile;
|
QString _pidFile = pidFile;
|
||||||
_pidFile.replace(QString("$i"), interfaces[0]);
|
_pidFile.replace(QString("$i"), interfaces.first());
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "PID file" << _pidFile << QFile(_pidFile).exists();
|
if (debug) qDebug() << PDEBUG << ":" << "PID file" << _pidFile << QFile(_pidFile).exists();
|
||||||
|
|
||||||
bool terminateOnExit = (!QFile(_pidFile).exists());
|
bool terminateOnExit = (!QFile(_pidFile).exists());
|
||||||
@ -353,25 +310,25 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
|||||||
else
|
else
|
||||||
profiles = netctlCommand->getProfileList();
|
profiles = netctlCommand->getProfileList();
|
||||||
// iterate by wifi output
|
// iterate by wifi output
|
||||||
for (int i=0; i<rawList.count(); i++) {
|
foreach(QString element, rawList) {
|
||||||
QStringList line = rawList[i].split(QChar('\t'));
|
QStringList line = element.split(QChar('\t'));
|
||||||
if (line.count() != 5) continue;
|
if (line.count() != 5) continue;
|
||||||
QString name = line[4];
|
QString name = line.at(4);
|
||||||
if (name.isEmpty()) name = QString("<hidden>");
|
if (name.isEmpty()) name = QString("<hidden>");
|
||||||
// append mac and frequency if exists
|
// append mac and frequency if exists
|
||||||
int index = names.indexOf(name);
|
int index = names.indexOf(name);
|
||||||
if ((name != QString("<hidden>")) && (index > -1)) {
|
if ((name != QString("<hidden>")) && (index > -1)) {
|
||||||
scanResults[index].frequencies.append(line[1].toInt());
|
scanResults[index].frequencies.append(line.at(1).toInt());
|
||||||
scanResults[index].macs.append(line[0]);
|
scanResults[index].macs.append(line.at(0));
|
||||||
if (scanResults[index].signal < line[2].toInt())
|
if (scanResults[index].signal < line.at(2).toInt())
|
||||||
scanResults[index].signal = line[2].toInt();
|
scanResults[index].signal = line.at(2).toInt();
|
||||||
// check type
|
// check type
|
||||||
if ((line[1].toInt() >= 5000) && (line[1].toInt() < 6000)) {
|
if ((line.at(1).toInt() >= 5000) && (line.at(1).toInt() < 6000)) {
|
||||||
if (scanResults[index].type == PointType::None)
|
if (scanResults[index].type == PointType::None)
|
||||||
scanResults[index].type = PointType::FiveG;
|
scanResults[index].type = PointType::FiveG;
|
||||||
else if (scanResults[index].type == PointType::TwoG)
|
else if (scanResults[index].type == PointType::TwoG)
|
||||||
scanResults[index].type = PointType::TwoAndFiveG;
|
scanResults[index].type = PointType::TwoAndFiveG;
|
||||||
} else if ((line[1].toInt() < 5000) && (line[1].toInt() > 2000)) {
|
} else if ((line.at(1).toInt() < 5000) && (line.at(1).toInt() > 2000)) {
|
||||||
if (scanResults[index].type == PointType::None)
|
if (scanResults[index].type == PointType::None)
|
||||||
scanResults[index].type = PointType::TwoG;
|
scanResults[index].type = PointType::TwoG;
|
||||||
else if (scanResults[index].type == PointType::FiveG)
|
else if (scanResults[index].type == PointType::FiveG)
|
||||||
@ -388,28 +345,28 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
|||||||
netctlProfileInfo profile;
|
netctlProfileInfo profile;
|
||||||
profile.name = QString("");
|
profile.name = QString("");
|
||||||
profile.active = false;
|
profile.active = false;
|
||||||
for (int j=0; j<profiles.count(); j++) {
|
foreach(netctlProfileInfo pr, profiles) {
|
||||||
if (wifiPoint.name != profiles[j].essid) continue;
|
if (wifiPoint.name != pr.essid) continue;
|
||||||
profile = profiles[j];
|
profile = pr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wifiPoint.active = profile.active;
|
wifiPoint.active = profile.active;
|
||||||
wifiPoint.exists = (!profile.name.isEmpty());
|
wifiPoint.exists = (!profile.name.isEmpty());
|
||||||
// mac
|
// mac
|
||||||
wifiPoint.macs.append(line[0]);
|
wifiPoint.macs.append(line.at(0));
|
||||||
// frequencies
|
// frequencies
|
||||||
wifiPoint.frequencies.append(line[1].toInt());
|
wifiPoint.frequencies.append(line.at(1).toInt());
|
||||||
// type
|
// type
|
||||||
// check type
|
// check type
|
||||||
if ((line[1].toInt() >= 5000) && (line[1].toInt() < 6000)) {
|
if ((line.at(1).toInt() >= 5000) && (line.at(1).toInt() < 6000)) {
|
||||||
wifiPoint.type = PointType::FiveG;
|
wifiPoint.type = PointType::FiveG;
|
||||||
} else if ((line[1].toInt() < 5000) && (line[1].toInt() > 2000)) {
|
} else if ((line.at(1).toInt() < 5000) && (line.at(1).toInt() > 2000)) {
|
||||||
wifiPoint.type = PointType::TwoG;
|
wifiPoint.type = PointType::TwoG;
|
||||||
}
|
}
|
||||||
// point signal
|
// point signal
|
||||||
wifiPoint.signal = line[2].toInt();
|
wifiPoint.signal = line.at(2).toInt();
|
||||||
// point security
|
// point security
|
||||||
QString security = line[3];
|
QString security = line.at(3);
|
||||||
if (security.contains(QString("WPA2")))
|
if (security.contains(QString("WPA2")))
|
||||||
security = QString("WPA2");
|
security = QString("WPA2");
|
||||||
else if (security.contains(QString("WPA")))
|
else if (security.contains(QString("WPA")))
|
||||||
@ -433,7 +390,7 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
|||||||
/**
|
/**
|
||||||
* @fn startWpaSupplicant
|
* @fn startWpaSupplicant
|
||||||
*/
|
*/
|
||||||
bool WpaSup::startWpaSupplicant()
|
bool WpaSup::startWpaSupplicant() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (ctrlDir.isEmpty()) {
|
if (ctrlDir.isEmpty()) {
|
||||||
@ -466,28 +423,27 @@ bool WpaSup::startWpaSupplicant()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QString _pidFile = pidFile;
|
QString _pidFile = pidFile;
|
||||||
_pidFile.replace(QString("$i"), interfaces[0]);
|
_pidFile.replace(QString("$i"), interfaces.first());
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "PID file" << _pidFile << QFile(_pidFile).exists();
|
if (debug) qDebug() << PDEBUG << ":" << "PID file" << _pidFile << QFile(_pidFile).exists();
|
||||||
|
|
||||||
if (QFile(_pidFile).exists()) return (QFileInfo(ctrlDir).group() == ctrlGroup);
|
if (QFile(_pidFile).exists()) return (QFileInfo(ctrlDir).group() == ctrlGroup);
|
||||||
QString cmd = QString("%1 %2 -B -P \"%3\" -i %4 -D %5 -C \"DIR=%6 GROUP=%7\"")
|
QString cmd = QString("%1 %2 -B -P \"%3\" -i %4 -D %5 -C \"DIR=%6 GROUP=%7\"")
|
||||||
.arg(sudoCommand).arg(wpaSupPath).arg(_pidFile).arg(interfaces[0])
|
.arg(sudoCommand).arg(wpaSupPath).arg(_pidFile).arg(interfaces.first())
|
||||||
.arg(wpaDrivers).arg(ctrlDir).arg(ctrlGroup);
|
.arg(wpaDrivers).arg(ctrlDir).arg(ctrlGroup);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd, useSuid);
|
TaskResult process = runTask(cmd, useSuid);
|
||||||
waitForProcess(1);
|
waitForProcess(1);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
return (process.exitCode == 0);
|
return process.status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn stopWpaSupplicant
|
* @fn stopWpaSupplicant
|
||||||
*/
|
*/
|
||||||
bool WpaSup::stopWpaSupplicant()
|
bool WpaSup::stopWpaSupplicant() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -499,7 +455,7 @@ bool WpaSup::stopWpaSupplicant()
|
|||||||
/**
|
/**
|
||||||
* @fn getWpaCliOutput
|
* @fn getWpaCliOutput
|
||||||
*/
|
*/
|
||||||
QString WpaSup::getWpaCliOutput(const QString commandLine)
|
QString WpaSup::getWpaCliOutput(const QString commandLine) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
|
if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
|
||||||
@ -517,11 +473,10 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString cmd = QString("%1 -i %2 -p %3 %4").arg(wpaCliPath).arg(interfaces[0]).arg(ctrlDir).arg(commandLine);
|
QString cmd = QString("%1 -i %2 -p %3 %4").arg(wpaCliPath).arg(interfaces.first()).arg(ctrlDir).arg(commandLine);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd);
|
TaskResult process = runTask(cmd);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
return process.output;
|
return process.output;
|
||||||
@ -531,7 +486,7 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
|
|||||||
/**
|
/**
|
||||||
* @fn waitForProcess
|
* @fn waitForProcess
|
||||||
*/
|
*/
|
||||||
bool WpaSup::waitForProcess(const int sec)
|
bool WpaSup::waitForProcess(const int sec) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Interval" << sec;
|
if (debug) qDebug() << PDEBUG << ":" << "Interval" << sec;
|
||||||
@ -546,7 +501,7 @@ bool WpaSup::waitForProcess(const int sec)
|
|||||||
/**
|
/**
|
||||||
* @fn wpaCliCall
|
* @fn wpaCliCall
|
||||||
*/
|
*/
|
||||||
bool WpaSup::wpaCliCall(const QString commandLine)
|
bool WpaSup::wpaCliCall(const QString commandLine) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
|
if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
|
||||||
@ -564,13 +519,12 @@ bool WpaSup::wpaCliCall(const QString commandLine)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString cmd = QString("%1 -i %2 -p %3 %4").arg(wpaCliPath).arg(interfaces[0]).arg(ctrlDir).arg(commandLine);
|
QString cmd = QString("%1 -i %2 -p %3 %4").arg(wpaCliPath).arg(interfaces.first()).arg(ctrlDir).arg(commandLine);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd);
|
TaskResult process = runTask(cmd);
|
||||||
waitForProcess(1);
|
waitForProcess(1);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
return (process.exitCode == 0);
|
return process.status();
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ void TestNetctl::test_getActiveProfile()
|
|||||||
QStringList result = netctl->getActiveProfile();
|
QStringList result = netctl->getActiveProfile();
|
||||||
QStringList dbus;
|
QStringList dbus;
|
||||||
if (helper)
|
if (helper)
|
||||||
dbus = sendDBusRequest(QString("/netctl"), QString("netctlActiveProfile"))[0].toString().split(QChar('|'));
|
dbus = sendDBusRequest(QString("/netctl"), QString("netctlActiveProfile"))[0].toStringList();
|
||||||
netctl->startProfile(QString("netctlgui-test-dummy"));
|
netctl->startProfile(QString("netctlgui-test-dummy"));
|
||||||
delete netctl;
|
delete netctl;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user