mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
rewrite library to use pdebug
This commit is contained in:
parent
07e07ee777
commit
ec8fc79dd7
@ -963,10 +963,10 @@ void MainWindow::wifiTabContextualMenu(const QPoint &pos)
|
|||||||
// actions
|
// actions
|
||||||
QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos));
|
QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos));
|
||||||
if (action == refreshTable) {
|
if (action == refreshTable) {
|
||||||
if (debug) qDebug() << PDEBUG << "Refresh WiFi";
|
if (debug) qDebug() << PDEBUG << ":" << "Refresh WiFi";
|
||||||
updateWifiTab();
|
updateWifiTab();
|
||||||
} else if (action == startWifi) {
|
} else if (action == startWifi) {
|
||||||
if (debug) qDebug() << PDEBUG << "Start WiFi";
|
if (debug) qDebug() << PDEBUG << ":" << "Start WiFi";
|
||||||
wifiTabStart();
|
wifiTabStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "netctlgui.h"
|
#include "netctlgui.h"
|
||||||
|
#include "pdebug.h"
|
||||||
#include "taskadds.h"
|
#include "taskadds.h"
|
||||||
|
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
|
|||||||
*/
|
*/
|
||||||
Netctl::~Netctl()
|
Netctl::~Netctl()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[~Netctl]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (netctlProfile != nullptr) delete netctlProfile;
|
if (netctlProfile != nullptr) delete netctlProfile;
|
||||||
if (ifaceDirectory != nullptr) delete ifaceDirectory;
|
if (ifaceDirectory != nullptr) delete ifaceDirectory;
|
||||||
@ -83,12 +84,12 @@ Netctl::~Netctl()
|
|||||||
*/
|
*/
|
||||||
bool Netctl::cmdCall(const bool sudo, const QString command, const QString commandLine, const QString argument)
|
bool Netctl::cmdCall(const bool sudo, const QString command, const QString commandLine, const QString argument)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[cmdCall]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Command" << command;
|
if (debug) qDebug() << PDEBUG << ":" << "Command" << command;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Command line" << commandLine;
|
if (debug) qDebug() << PDEBUG << ":" << "Command line" << commandLine;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Argument" << argument;
|
if (debug) qDebug() << PDEBUG << ":" << "Argument" << argument;
|
||||||
if (command == 0) {
|
if (command == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Could not find command";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find command";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,11 +99,11 @@ bool Netctl::cmdCall(const bool sudo, const QString command, const QString comma
|
|||||||
cmd += command + QString(" ") + commandLine;
|
cmd += command + QString(" ") + commandLine;
|
||||||
if (argument != 0)
|
if (argument != 0)
|
||||||
cmd += QString(" \"") + argument + QString("\"");
|
cmd += QString(" \"") + argument + QString("\"");
|
||||||
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd, (useSuid && sudo));
|
TaskResult process = runTask(cmd, (useSuid && sudo));
|
||||||
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
if (process.exitCode != 0)
|
||||||
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
if (process.exitCode == 0)
|
if (process.exitCode == 0)
|
||||||
return true;
|
return true;
|
||||||
@ -116,12 +117,12 @@ bool Netctl::cmdCall(const bool sudo, const QString command, const QString comma
|
|||||||
*/
|
*/
|
||||||
QString Netctl::getCmdOutput(const bool sudo, const QString command, const QString commandLine, const QString argument)
|
QString Netctl::getCmdOutput(const bool sudo, const QString command, const QString commandLine, const QString argument)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Command" << command;
|
if (debug) qDebug() << PDEBUG << ":" << "Command" << command;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Command line" << commandLine;
|
if (debug) qDebug() << PDEBUG << ":" << "Command line" << commandLine;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Argument" << argument;
|
if (debug) qDebug() << PDEBUG << ":" << "Argument" << argument;
|
||||||
if (command == 0) {
|
if (command == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Could not find command";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find command";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,11 +132,11 @@ QString Netctl::getCmdOutput(const bool sudo, const QString command, const QStri
|
|||||||
cmd += command + QString(" ") + commandLine;
|
cmd += command + QString(" ") + commandLine;
|
||||||
if (argument != 0)
|
if (argument != 0)
|
||||||
cmd += QString(" \"") + argument + QString("\"");
|
cmd += QString(" \"") + argument + QString("\"");
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd, (useSuid && sudo));
|
TaskResult process = runTask(cmd, (useSuid && sudo));
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
if (process.exitCode != 0)
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
return process.output;
|
return process.output;
|
||||||
}
|
}
|
||||||
@ -147,7 +148,7 @@ QString Netctl::getCmdOutput(const bool sudo, const QString command, const QStri
|
|||||||
*/
|
*/
|
||||||
QString Netctl::getActiveProfile()
|
QString Netctl::getActiveProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getActiveProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QString profile = QString("");
|
QString profile = QString("");
|
||||||
QList<netctlProfileInfo> fullProfilesInfo = getProfileList();
|
QList<netctlProfileInfo> fullProfilesInfo = getProfileList();
|
||||||
@ -166,7 +167,7 @@ QString Netctl::getActiveProfile()
|
|||||||
*/
|
*/
|
||||||
QString Netctl::autoGetActiveProfile()
|
QString Netctl::autoGetActiveProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoGetActiveProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QString profile = QString("");
|
QString profile = QString("");
|
||||||
QList<netctlProfileInfo> fullProfilesInfo = getProfileListFromNetctlAuto();
|
QList<netctlProfileInfo> fullProfilesInfo = getProfileListFromNetctlAuto();
|
||||||
@ -185,7 +186,7 @@ QString Netctl::autoGetActiveProfile()
|
|||||||
*/
|
*/
|
||||||
QList<netctlProfileInfo> Netctl::getProfileList()
|
QList<netctlProfileInfo> Netctl::getProfileList()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileList]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QList<netctlProfileInfo> fullProfilesInfo;
|
QList<netctlProfileInfo> fullProfilesInfo;
|
||||||
QStringList output = getCmdOutput(false, netctlCommand, QString("list"))
|
QStringList output = getCmdOutput(false, netctlCommand, QString("list"))
|
||||||
@ -211,7 +212,7 @@ QList<netctlProfileInfo> Netctl::getProfileList()
|
|||||||
*/
|
*/
|
||||||
QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto()
|
QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QList<netctlProfileInfo> fullProfilesInfo;
|
QList<netctlProfileInfo> fullProfilesInfo;
|
||||||
QStringList output = getCmdOutput(false, netctlAutoCommand, QString("list"))
|
QStringList output = getCmdOutput(false, netctlAutoCommand, QString("list"))
|
||||||
@ -238,10 +239,10 @@ QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto()
|
|||||||
*/
|
*/
|
||||||
QString Netctl::getProfileDescription(const QString profile)
|
QString Netctl::getProfileDescription(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
if (netctlProfile == 0) {
|
if (netctlProfile == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Could not find library";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,8 +255,8 @@ QString Netctl::getProfileDescription(const QString profile)
|
|||||||
*/
|
*/
|
||||||
QString Netctl::getProfileStatus(const QString profile)
|
QString Netctl::getProfileStatus(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileStatus]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileStatus]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
QString status;
|
QString status;
|
||||||
if (isProfileActive(profile))
|
if (isProfileActive(profile))
|
||||||
@ -276,8 +277,8 @@ QString Netctl::getProfileStatus(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::isProfileActive(const QString profile)
|
bool Netctl::isProfileActive(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[isProfileActive]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[isProfileActive]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
QString output = getCmdOutput(false, netctlCommand, QString("status"), profile);
|
QString output = getCmdOutput(false, netctlCommand, QString("status"), profile);
|
||||||
@ -293,8 +294,8 @@ bool Netctl::isProfileActive(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::isProfileEnabled(const QString profile)
|
bool Netctl::isProfileEnabled(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[isProfileEnabled]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[isProfileEnabled]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
return cmdCall(false, netctlCommand, QString("is-enabled"), profile);
|
return cmdCall(false, netctlCommand, QString("is-enabled"), profile);
|
||||||
}
|
}
|
||||||
@ -305,8 +306,8 @@ bool Netctl::isProfileEnabled(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::autoIsProfileActive(const QString profile)
|
bool Netctl::autoIsProfileActive(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileActive]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileActive]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
|
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
|
||||||
@ -325,8 +326,8 @@ bool Netctl::autoIsProfileActive(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::autoIsProfileEnabled(const QString profile)
|
bool Netctl::autoIsProfileEnabled(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileEnabled]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileEnabled]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
|
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
|
||||||
@ -345,13 +346,13 @@ bool Netctl::autoIsProfileEnabled(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::isNetctlAutoEnabled()
|
bool Netctl::isNetctlAutoEnabled()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlAutoService == 0) {
|
if (netctlAutoService == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]" << ":" << "Could not find service";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find service";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getWirelessInterfaceList().isEmpty()) {
|
if (getWirelessInterfaceList().isEmpty()) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]" << ":" << "Could not interface";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interface";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,14 +368,14 @@ bool Netctl::isNetctlAutoEnabled()
|
|||||||
*/
|
*/
|
||||||
bool Netctl::isNetctlAutoRunning()
|
bool Netctl::isNetctlAutoRunning()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlAutoService == 0) {
|
if (netctlAutoService == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Could not find service";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find service";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QStringList interfaces = getWirelessInterfaceList();
|
QStringList interfaces = getWirelessInterfaceList();
|
||||||
if (interfaces.isEmpty()) {
|
if (interfaces.isEmpty()) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Could not interface";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interface";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,9 +391,9 @@ bool Netctl::isNetctlAutoRunning()
|
|||||||
*/
|
*/
|
||||||
QStringList Netctl::getWirelessInterfaceList()
|
QStringList Netctl::getWirelessInterfaceList()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getWirelessInterfaceList]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (ifaceDirectory == 0) {
|
if (ifaceDirectory == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getWirelessInterfaceList]" << ":" << "Could not find directory";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +402,7 @@ QStringList Netctl::getWirelessInterfaceList()
|
|||||||
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++) {
|
for (int i=0; i<allInterfaces.count(); i++) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getWirelessInterfaceList]" << ":" << "Check directory"
|
if (debug) qDebug() << PDEBUG << ":" << "Check directory"
|
||||||
<< ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + QDir::separator() + QString("wireless");
|
<< ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + QDir::separator() + QString("wireless");
|
||||||
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
|
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
|
||||||
QDir::separator() + QString("wireless")).exists())
|
QDir::separator() + QString("wireless")).exists())
|
||||||
@ -418,8 +419,8 @@ QStringList Netctl::getWirelessInterfaceList()
|
|||||||
*/
|
*/
|
||||||
bool Netctl::enableProfile(const QString profile)
|
bool Netctl::enableProfile(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[enableProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[enableProfile]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
if (isProfileEnabled(profile))
|
if (isProfileEnabled(profile))
|
||||||
return cmdCall(true, netctlCommand, QString("disable"), profile);
|
return cmdCall(true, netctlCommand, QString("disable"), profile);
|
||||||
@ -433,8 +434,8 @@ bool Netctl::enableProfile(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::restartProfile(const QString profile)
|
bool Netctl::restartProfile(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[restartProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[restartProfile]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
return cmdCall(true, netctlCommand, QString("restart"), profile);
|
return cmdCall(true, netctlCommand, QString("restart"), profile);
|
||||||
}
|
}
|
||||||
@ -445,8 +446,8 @@ bool Netctl::restartProfile(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::startProfile(const QString profile)
|
bool Netctl::startProfile(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[startProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[startProfile]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
if (isProfileActive(profile))
|
if (isProfileActive(profile))
|
||||||
return cmdCall(true, netctlCommand, QString("stop"), profile);
|
return cmdCall(true, netctlCommand, QString("stop"), profile);
|
||||||
@ -460,8 +461,8 @@ bool Netctl::startProfile(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::switchToProfile(const QString profile)
|
bool Netctl::switchToProfile(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[switchToProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[switchToProfile]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
if (isProfileActive(profile))
|
if (isProfileActive(profile))
|
||||||
return true;
|
return true;
|
||||||
@ -475,7 +476,7 @@ bool Netctl::switchToProfile(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::autoDisableAllProfiles()
|
bool Netctl::autoDisableAllProfiles()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoDisableAllProfiles]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return cmdCall(false, netctlAutoCommand, QString("disable-all"));
|
return cmdCall(false, netctlAutoCommand, QString("disable-all"));
|
||||||
}
|
}
|
||||||
@ -486,8 +487,8 @@ bool Netctl::autoDisableAllProfiles()
|
|||||||
*/
|
*/
|
||||||
bool Netctl::autoEnableProfile(const QString profile)
|
bool Netctl::autoEnableProfile(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoEnableProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoEnableProfile]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
if (autoIsProfileEnabled(profile))
|
if (autoIsProfileEnabled(profile))
|
||||||
return cmdCall(false, netctlAutoCommand, QString("disable"), profile);
|
return cmdCall(false, netctlAutoCommand, QString("disable"), profile);
|
||||||
@ -501,7 +502,7 @@ bool Netctl::autoEnableProfile(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::autoEnableAllProfiles()
|
bool Netctl::autoEnableAllProfiles()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoEnableAllProfiles]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return cmdCall(false, netctlAutoCommand, QString("enable-all"));
|
return cmdCall(false, netctlAutoCommand, QString("enable-all"));
|
||||||
}
|
}
|
||||||
@ -512,8 +513,8 @@ bool Netctl::autoEnableAllProfiles()
|
|||||||
*/
|
*/
|
||||||
bool Netctl::autoStartProfile(const QString profile)
|
bool Netctl::autoStartProfile(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoStartProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoStartProfile]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
if (autoIsProfileActive(profile))
|
if (autoIsProfileActive(profile))
|
||||||
return true;
|
return true;
|
||||||
@ -527,14 +528,14 @@ bool Netctl::autoStartProfile(const QString profile)
|
|||||||
*/
|
*/
|
||||||
bool Netctl::autoEnableService()
|
bool Netctl::autoEnableService()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoEnableService]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlAutoService == 0) {
|
if (netctlAutoService == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoEnableService]" << ":" << "Could not find service";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find service";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QStringList interfaces = getWirelessInterfaceList();
|
QStringList interfaces = getWirelessInterfaceList();
|
||||||
if (interfaces.isEmpty()) {
|
if (interfaces.isEmpty()) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoEnableService]" << ":" << "Could not interface";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interface";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,14 +554,14 @@ bool Netctl::autoEnableService()
|
|||||||
*/
|
*/
|
||||||
bool Netctl::autoRestartService()
|
bool Netctl::autoRestartService()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoRestartService]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlAutoService == 0) {
|
if (netctlAutoService == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoRestartService]" << ":" << "Could not find service";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find service";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QStringList interfaces = getWirelessInterfaceList();
|
QStringList interfaces = getWirelessInterfaceList();
|
||||||
if (interfaces.isEmpty()) {
|
if (interfaces.isEmpty()) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoRestartService]" << ":" << "Could not interface";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interface";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,14 +580,14 @@ bool Netctl::autoRestartService()
|
|||||||
*/
|
*/
|
||||||
bool Netctl::autoStartService()
|
bool Netctl::autoStartService()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoStartService]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (netctlAutoService == 0) {
|
if (netctlAutoService == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoStartService]" << ":" << "Could not find service";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find service";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QStringList interfaces = getWirelessInterfaceList();
|
QStringList interfaces = getWirelessInterfaceList();
|
||||||
if (interfaces.isEmpty()) {
|
if (interfaces.isEmpty()) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[autoStartService]" << ":" << "Could not interface";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interface";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
#include "netctlgui.h"
|
#include "netctlgui.h"
|
||||||
|
#include "pdebug.h"
|
||||||
#include "taskadds.h"
|
#include "taskadds.h"
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ NetctlProfile::NetctlProfile(const bool debugCmd, const QMap<QString, QString> s
|
|||||||
*/
|
*/
|
||||||
NetctlProfile::~NetctlProfile()
|
NetctlProfile::~NetctlProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[~NetctlProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (profileDirectory != nullptr) delete profileDirectory;
|
if (profileDirectory != nullptr) delete profileDirectory;
|
||||||
}
|
}
|
||||||
@ -72,20 +73,20 @@ NetctlProfile::~NetctlProfile()
|
|||||||
*/
|
*/
|
||||||
bool NetctlProfile::copyProfile(const QString oldPath)
|
bool NetctlProfile::copyProfile(const QString oldPath)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Path" << oldPath;
|
if (debug) qDebug() << PDEBUG << ":" << "Path" << oldPath;
|
||||||
if (profileDirectory == 0) {
|
if (profileDirectory == 0) {
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Could not find directory";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
|
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
|
||||||
QString cmd = sudoCommand + QString(" /usr/bin/mv \"") + oldPath + QString("\" \"") + newPath + QString("\"");
|
QString cmd = sudoCommand + QString(" /usr/bin/mv \"") + oldPath + QString("\" \"") + newPath + QString("\"");
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd, useSuid);
|
TaskResult process = runTask(cmd, useSuid);
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
if (process.exitCode != 0)
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
if (process.exitCode == 0)
|
if (process.exitCode == 0)
|
||||||
return true;
|
return true;
|
||||||
@ -99,12 +100,12 @@ bool NetctlProfile::copyProfile(const QString oldPath)
|
|||||||
*/
|
*/
|
||||||
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
|
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
QString profileTempName = QDir::homePath() + QString("/.cache/") + QFileInfo(profile).fileName();
|
QString profileTempName = QDir::homePath() + QString("/.cache/") + QFileInfo(profile).fileName();
|
||||||
QFile profileFile(profileTempName);
|
QFile profileFile(profileTempName);
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName;
|
if (debug) qDebug() << PDEBUG << ":" << "Save to" << profileTempName;
|
||||||
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
return profileTempName;
|
return profileTempName;
|
||||||
QTextStream out(&profileFile);
|
QTextStream out(&profileFile);
|
||||||
@ -136,21 +137,21 @@ QString NetctlProfile::createProfile(const QString profile, const QMap<QString,
|
|||||||
*/
|
*/
|
||||||
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
|
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
if (profileDirectory == 0) {
|
if (profileDirectory == 0) {
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Could not find directory";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
|
||||||
return QMap<QString, QString>();
|
return QMap<QString, QString>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// getting variables list
|
// getting variables list
|
||||||
// system variables
|
// system variables
|
||||||
QString cmd = QString("env -i bash -c \"set\"");
|
QString cmd = QString("env -i bash -c \"set\"");
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd, false);
|
TaskResult process = runTask(cmd, false);
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
if (process.exitCode != 0)
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "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"));
|
||||||
@ -160,11 +161,11 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
|||||||
QMap<QString, QString> settings;
|
QMap<QString, QString> settings;
|
||||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
|
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
|
||||||
cmd = QString("env -i bash -c \"source '") + profileUrl + QString("'; set\"");
|
cmd = QString("env -i bash -c \"source '") + profileUrl + QString("'; set\"");
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
process = runTask(cmd, false);
|
process = runTask(cmd, false);
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
if (process.exitCode != 0)
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "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'));
|
||||||
|
|
||||||
// gettings variables
|
// gettings variables
|
||||||
@ -178,7 +179,7 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
|||||||
keys[i] + QString("[$i]}; done\"");
|
keys[i] + QString("[$i]}; done\"");
|
||||||
process = runTask(cmd, false);
|
process = runTask(cmd, false);
|
||||||
settings[keys[i]] = process.output.trimmed();
|
settings[keys[i]] = process.output.trimmed();
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << keys[i] << "=" << settings[keys[i]];
|
if (debug) qDebug() << PDEBUG << ":" << keys[i] << "=" << settings[keys[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
@ -190,9 +191,9 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
|||||||
*/
|
*/
|
||||||
QString NetctlProfile::getValueFromProfile(const QString profile, const QString key)
|
QString NetctlProfile::getValueFromProfile(const QString profile, const QString key)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getValueFromProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getValueFromProfile]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getValueFromProfile]" << ":" << "Key" << key;
|
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
|
||||||
|
|
||||||
QMap<QString, QString> settings = getSettingsFromProfile(profile);
|
QMap<QString, QString> settings = getSettingsFromProfile(profile);
|
||||||
|
|
||||||
@ -208,20 +209,20 @@ QString NetctlProfile::getValueFromProfile(const QString profile, const QString
|
|||||||
*/
|
*/
|
||||||
bool NetctlProfile::removeProfile(const QString profile)
|
bool NetctlProfile::removeProfile(const QString profile)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
if (profileDirectory == 0) {
|
if (profileDirectory == 0) {
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Could not find directory";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString profilePath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
|
QString profilePath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
|
||||||
QString cmd = sudoCommand + QString(" /usr/bin/rm \"") + profilePath + QString("\"");
|
QString cmd = sudoCommand + QString(" /usr/bin/rm \"") + profilePath + QString("\"");
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd, useSuid);
|
TaskResult process = runTask(cmd, useSuid);
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
if (process.exitCode != 0)
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
if (process.exitCode == 0)
|
if (process.exitCode == 0)
|
||||||
return true;
|
return true;
|
||||||
|
1
sources/netctlgui/src/pdebug.h
Symbolic link
1
sources/netctlgui/src/pdebug.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../3rdparty/pdebug/pdebug.h
|
@ -26,6 +26,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "netctlgui.h"
|
#include "netctlgui.h"
|
||||||
|
#include "pdebug.h"
|
||||||
#include "taskadds.h"
|
#include "taskadds.h"
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ WpaSup::WpaSup(const bool debugCmd, const QMap<QString, QString> settings)
|
|||||||
*/
|
*/
|
||||||
WpaSup::~WpaSup()
|
WpaSup::~WpaSup()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[~WpaSup]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (netctlCommand != nullptr) delete netctlCommand;
|
if (netctlCommand != nullptr) delete netctlCommand;
|
||||||
if (netctlProfile != nullptr) delete netctlProfile;
|
if (netctlProfile != nullptr) delete netctlProfile;
|
||||||
@ -82,14 +83,14 @@ WpaSup::~WpaSup()
|
|||||||
*/
|
*/
|
||||||
QString WpaSup::existentProfile(const QString essid)
|
QString WpaSup::existentProfile(const QString essid)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]" << ":" << "ESSID" << essid;
|
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
||||||
if (netctlCommand == 0) {
|
if (netctlCommand == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]" << ":" << "Could not find library";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
if (netctlProfile == 0) {
|
if (netctlProfile == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]" << ":" << "Could not find library";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,14 +109,14 @@ QString WpaSup::existentProfile(const QString essid)
|
|||||||
*/
|
*/
|
||||||
bool WpaSup::isProfileActive(const QString essid)
|
bool WpaSup::isProfileActive(const QString essid)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]" << ":" << "ESSID" << essid;
|
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
||||||
if (netctlCommand == 0) {
|
if (netctlCommand == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]" << ":" << "Could not find library";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (netctlProfile == 0) {
|
if (netctlProfile == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]" << ":" << "Could not find library";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,14 +137,14 @@ bool WpaSup::isProfileActive(const QString essid)
|
|||||||
*/
|
*/
|
||||||
bool WpaSup::isProfileExists(const QString essid)
|
bool WpaSup::isProfileExists(const QString essid)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]" << ":" << "ESSID" << essid;
|
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
||||||
if (netctlCommand == 0) {
|
if (netctlCommand == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]" << ":" << "Could not find library";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (netctlProfile == 0) {
|
if (netctlProfile == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]" << ":" << "Could not find library";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ bool WpaSup::isProfileExists(const QString essid)
|
|||||||
*/
|
*/
|
||||||
QList<netctlWifiInfo> WpaSup::scanWifi()
|
QList<netctlWifiInfo> WpaSup::scanWifi()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[scanWifi]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QList<netctlWifiInfo> scanResults;
|
QList<netctlWifiInfo> scanResults;
|
||||||
if (!startWpaSupplicant()) {
|
if (!startWpaSupplicant()) {
|
||||||
@ -228,34 +229,34 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
|||||||
*/
|
*/
|
||||||
bool WpaSup::startWpaSupplicant()
|
bool WpaSup::startWpaSupplicant()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (ctrlDir == 0) {
|
if (ctrlDir == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find directory";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (ctrlGroup == 0) {
|
if (ctrlGroup == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find group";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find group";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pidFile == 0) {
|
if (pidFile == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find PID file";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find PID file";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (wpaDrivers == 0) {
|
if (wpaDrivers == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find drivers";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find drivers";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (wpaSupPath == 0) {
|
if (wpaSupPath == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find wpa_supplicant";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find wpa_supplicant";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (netctlCommand == 0) {
|
if (netctlCommand == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find library";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
||||||
if (interfaces.isEmpty()) {
|
if (interfaces.isEmpty()) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find interfaces";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find interfaces";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,12 +266,12 @@ bool WpaSup::startWpaSupplicant()
|
|||||||
QString cmd = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile +
|
QString cmd = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile +
|
||||||
QString(" -i ") + interface + QString(" -D ") + wpaDrivers +
|
QString(" -i ") + interface + QString(" -D ") + wpaDrivers +
|
||||||
QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\"");
|
QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\"");
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "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() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
if (process.exitCode != 0)
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
if (process.exitCode == 0)
|
if (process.exitCode == 0)
|
||||||
return true;
|
return true;
|
||||||
@ -284,7 +285,7 @@ bool WpaSup::startWpaSupplicant()
|
|||||||
*/
|
*/
|
||||||
bool WpaSup::stopWpaSupplicant()
|
bool WpaSup::stopWpaSupplicant()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[stopWpaSupplicant]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return wpaCliCall(QString("terminate"));
|
return wpaCliCall(QString("terminate"));
|
||||||
}
|
}
|
||||||
@ -296,38 +297,38 @@ bool WpaSup::stopWpaSupplicant()
|
|||||||
*/
|
*/
|
||||||
QString WpaSup::getWpaCliOutput(const QString commandLine)
|
QString WpaSup::getWpaCliOutput(const QString commandLine)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Command" << commandLine;
|
if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
|
||||||
if (ctrlDir == 0) {
|
if (ctrlDir == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find directory";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
if (pidFile == 0) {
|
if (pidFile == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find PID file";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find PID file";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
if (wpaCliPath == 0) {
|
if (wpaCliPath == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find wpa_cli";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find wpa_cli";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
if (netctlCommand == 0) {
|
if (netctlCommand == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find library";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
||||||
if (interfaces.isEmpty()) {
|
if (interfaces.isEmpty()) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find interfaces";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find interfaces";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString interface = interfaces[0];
|
QString interface = interfaces[0];
|
||||||
QString cmd = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
QString cmd = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
||||||
QString(" -P ") + pidFile + QString(" ") + commandLine;
|
QString(" -P ") + pidFile + QString(" ") + commandLine;
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd);
|
TaskResult process = runTask(cmd);
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
if (process.exitCode != 0)
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
return process.output;
|
return process.output;
|
||||||
}
|
}
|
||||||
@ -338,8 +339,8 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
|
|||||||
*/
|
*/
|
||||||
bool WpaSup::waitForProcess(const int sec)
|
bool WpaSup::waitForProcess(const int sec)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[waitForProcess]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[waitForProcess]" << ":" << "Interval" << sec;
|
if (debug) qDebug() << PDEBUG << ":" << "Interval" << sec;
|
||||||
|
|
||||||
QString cmd = QString("sleep %1").arg(QString::number(sec));
|
QString cmd = QString("sleep %1").arg(QString::number(sec));
|
||||||
runTask(cmd);
|
runTask(cmd);
|
||||||
@ -353,39 +354,39 @@ bool WpaSup::waitForProcess(const int sec)
|
|||||||
*/
|
*/
|
||||||
bool WpaSup::wpaCliCall(const QString commandLine)
|
bool WpaSup::wpaCliCall(const QString commandLine)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Command" << commandLine;
|
if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
|
||||||
if (ctrlDir == 0) {
|
if (ctrlDir == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find directory";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pidFile == 0) {
|
if (pidFile == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find PID file";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find PID file";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (wpaCliPath == 0) {
|
if (wpaCliPath == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find wpa_cli";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find wpa_cli";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (netctlCommand == 0) {
|
if (netctlCommand == 0) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find library";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
||||||
if (interfaces.isEmpty()) {
|
if (interfaces.isEmpty()) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find interfaces";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not find interfaces";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString interface = interfaces[0];
|
QString interface = interfaces[0];
|
||||||
QString cmd = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
QString cmd = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
||||||
QString(" -P ") + pidFile + QString(" ") + commandLine;
|
QString(" -P ") + pidFile + QString(" ") + commandLine;
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "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() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (process.exitCode != 0)
|
if (process.exitCode != 0)
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getWpaCliOutput]" << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
if (process.exitCode == 0)
|
if (process.exitCode == 0)
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user