mirror of
				https://github.com/arcan1s/netctl-gui.git
				synced 2025-11-03 23:13:41 +00:00 
			
		
		
		
	refactoring of library part
This commit is contained in:
		@ -59,8 +59,7 @@ Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
 | 
			
		||||
    if (settings.contains(QString("SYSTEMCTL_PATH")))
 | 
			
		||||
        systemctlCommand = settings[QString("SYSTEMCTL_PATH")];
 | 
			
		||||
    if (settings.contains(QString("FORCE_SUDO")))
 | 
			
		||||
        if (settings[QString("FORCE_SUDO")] == QString("true"))
 | 
			
		||||
            useSuid = false;
 | 
			
		||||
        useSuid = (settings[QString("FORCE_SUDO")] != QString("true"));
 | 
			
		||||
 | 
			
		||||
    if (useSuid)
 | 
			
		||||
        sudoCommand = QString("");
 | 
			
		||||
@ -89,27 +88,24 @@ bool Netctl::cmdCall(const bool sudo, const QString command, const QString comma
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Command" << command;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Command line" << commandLine;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Argument" << argument;
 | 
			
		||||
    if (command == 0) {
 | 
			
		||||
    if (command.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find command";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString cmd = QString("");
 | 
			
		||||
    if (sudo)
 | 
			
		||||
        cmd = sudoCommand + QString(" ");
 | 
			
		||||
    cmd += command + QString(" ") + commandLine;
 | 
			
		||||
    if (argument != 0)
 | 
			
		||||
        cmd += QString(" \"") + argument + QString("\"");
 | 
			
		||||
        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;
 | 
			
		||||
 | 
			
		||||
    if (process.exitCode == 0)
 | 
			
		||||
        return true;
 | 
			
		||||
    else
 | 
			
		||||
        return false;
 | 
			
		||||
    return (process.exitCode == 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -122,17 +118,17 @@ QString Netctl::getCmdOutput(const bool sudo, const QString command, const QStri
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Command" << command;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Command line" << commandLine;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Argument" << argument;
 | 
			
		||||
    if (command == 0) {
 | 
			
		||||
    if (command.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find command";
 | 
			
		||||
        return QString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString cmd = QString("");
 | 
			
		||||
    if (sudo)
 | 
			
		||||
        cmd = sudoCommand + QString(" ");
 | 
			
		||||
    cmd += command + QString(" ") + commandLine;
 | 
			
		||||
    if (argument != 0)
 | 
			
		||||
        cmd += QString(" \"") + argument + QString("\"");
 | 
			
		||||
        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;
 | 
			
		||||
@ -194,10 +190,7 @@ QList<netctlProfileInfo> Netctl::getProfileList()
 | 
			
		||||
        netctlProfileInfo profileInfo;
 | 
			
		||||
        profileInfo.name = output[i].mid(2, -1);
 | 
			
		||||
        profileInfo.description = getProfileDescription(profileInfo.name);
 | 
			
		||||
        if (output[i][0] == QChar('*'))
 | 
			
		||||
            profileInfo.active = true;
 | 
			
		||||
        else
 | 
			
		||||
            profileInfo.active = false;
 | 
			
		||||
        profileInfo.active = (output[i][0] == QChar('*'));
 | 
			
		||||
        profileInfo.enabled = isProfileEnabled(profileInfo.name);
 | 
			
		||||
        fullProfilesInfo.append(profileInfo);
 | 
			
		||||
    }
 | 
			
		||||
@ -220,12 +213,8 @@ QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto()
 | 
			
		||||
        netctlProfileInfo profileInfo;
 | 
			
		||||
        profileInfo.name = output[i].mid(2, -1);
 | 
			
		||||
        profileInfo.description = getProfileDescription(profileInfo.name);
 | 
			
		||||
        profileInfo.active = false;
 | 
			
		||||
        profileInfo.enabled = true;
 | 
			
		||||
        if (output[i][0] == QChar('*'))
 | 
			
		||||
            profileInfo.active = true;
 | 
			
		||||
        else if (output[i][0] == QChar('!'))
 | 
			
		||||
            profileInfo.enabled = false;
 | 
			
		||||
        profileInfo.active = (output[i][0] == QChar('*'));
 | 
			
		||||
        profileInfo.enabled = (output[i][0] != QChar('!'));
 | 
			
		||||
        fullProfilesInfo.append(profileInfo);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -279,12 +268,9 @@ bool Netctl::isProfileActive(const QString profile)
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
 | 
			
		||||
 | 
			
		||||
    bool status = false;
 | 
			
		||||
    QString output = getCmdOutput(false, netctlCommand, QString("status"), profile);
 | 
			
		||||
    if (output.contains(QString("Active: active")))
 | 
			
		||||
        status = true;
 | 
			
		||||
 | 
			
		||||
    return status;
 | 
			
		||||
    return (output.contains(QString("Active: active")));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -346,17 +332,17 @@ bool Netctl::autoIsProfileEnabled(const QString profile)
 | 
			
		||||
bool Netctl::isNetctlAutoEnabled()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (netctlAutoService == 0) {
 | 
			
		||||
    if (netctlAutoService.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find service";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (getWirelessInterfaceList().isEmpty()) {
 | 
			
		||||
    QStringList interfaces = getWirelessInterfaceList();
 | 
			
		||||
    if (interfaces.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not interface";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString interface = getWirelessInterfaceList()[0];
 | 
			
		||||
    QString argument = netctlAutoService + QString("@") + interface + QString(".service");
 | 
			
		||||
    QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
 | 
			
		||||
 | 
			
		||||
    return cmdCall(false, systemctlCommand, QString("is-enabled"), argument);
 | 
			
		||||
}
 | 
			
		||||
@ -368,7 +354,7 @@ bool Netctl::isNetctlAutoEnabled()
 | 
			
		||||
bool Netctl::isNetctlAutoRunning()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (netctlAutoService == 0) {
 | 
			
		||||
    if (netctlAutoService.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find service";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@ -378,8 +364,7 @@ bool Netctl::isNetctlAutoRunning()
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString interface = interfaces[0];
 | 
			
		||||
    QString argument = netctlAutoService + QString("@") + interface + QString(".service");
 | 
			
		||||
    QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
 | 
			
		||||
 | 
			
		||||
    return cmdCall(false, systemctlCommand, QString("is-active"), argument);
 | 
			
		||||
}
 | 
			
		||||
@ -391,7 +376,6 @@ bool Netctl::isNetctlAutoRunning()
 | 
			
		||||
QMap<QString, QString> Netctl::getRecommendedConfiguration()
 | 
			
		||||
{
 | 
			
		||||
    QMap<QString, QString> settings;
 | 
			
		||||
    QString cmd;
 | 
			
		||||
    TaskResult process;
 | 
			
		||||
    QStringList recommended;
 | 
			
		||||
    // force sudo
 | 
			
		||||
@ -401,8 +385,7 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
 | 
			
		||||
    recommended.append(QString("netctlgui-helper"));
 | 
			
		||||
    recommended.append(QString("netctlgui-helper-suid"));
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("FORCE_SUDO")] = QString("false");
 | 
			
		||||
            break;
 | 
			
		||||
@ -430,8 +413,7 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
 | 
			
		||||
    recommended.clear();
 | 
			
		||||
    recommended.append("netctl");
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("NETCTL_PATH")] = process.output.trimmed();
 | 
			
		||||
            break;
 | 
			
		||||
@ -443,8 +425,7 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
 | 
			
		||||
    recommended.clear();
 | 
			
		||||
    recommended.append("netctl-auto");
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("NETCTLAUTO_PATH")] = process.output.trimmed();
 | 
			
		||||
            break;
 | 
			
		||||
@ -474,8 +455,7 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
 | 
			
		||||
    recommended.append("kdesu");
 | 
			
		||||
    recommended.append("gksu");
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("SUDO_PATH")] = process.output.trimmed();
 | 
			
		||||
            break;
 | 
			
		||||
@ -487,8 +467,7 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
 | 
			
		||||
    recommended.clear();
 | 
			
		||||
    recommended.append("systemctl");
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("SYSTEMCTL_PATH")] = process.output.trimmed();
 | 
			
		||||
            break;
 | 
			
		||||
@ -505,7 +484,7 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
 | 
			
		||||
QStringList Netctl::getWirelessInterfaceList()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (ifaceDirectory == 0) {
 | 
			
		||||
    if (ifaceDirectory == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
 | 
			
		||||
        return QStringList();
 | 
			
		||||
    }
 | 
			
		||||
@ -515,10 +494,11 @@ QStringList Netctl::getWirelessInterfaceList()
 | 
			
		||||
        interfaces.append(mainInterface);
 | 
			
		||||
    QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
 | 
			
		||||
    for (int i=0; i<allInterfaces.count(); i++) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Check directory"
 | 
			
		||||
                 << ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + QDir::separator() + QString("wireless");
 | 
			
		||||
        if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
 | 
			
		||||
                 QDir::separator() + QString("wireless")).exists())
 | 
			
		||||
        QString dir = QString("%1%2%3%2wireless").arg(ifaceDirectory->path())
 | 
			
		||||
                                                 .arg(QDir::separator())
 | 
			
		||||
                                                 .arg(allInterfaces[i]);
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Check directory" << dir;
 | 
			
		||||
        if (QDir(dir).exists())
 | 
			
		||||
            interfaces.append(allInterfaces[i]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -624,10 +604,8 @@ bool Netctl::switchToProfile(const QString profile)
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
 | 
			
		||||
 | 
			
		||||
    if (isProfileActive(profile))
 | 
			
		||||
        return true;
 | 
			
		||||
    else
 | 
			
		||||
        return cmdCall(true, netctlCommand, QString("switch-to"), profile);
 | 
			
		||||
    return ((isProfileActive(profile)) ||
 | 
			
		||||
            (cmdCall(true, netctlCommand, QString("switch-to"), profile)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -676,10 +654,8 @@ bool Netctl::autoStartProfile(const QString profile)
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
 | 
			
		||||
 | 
			
		||||
    if (autoIsProfileActive(profile))
 | 
			
		||||
        return true;
 | 
			
		||||
    else
 | 
			
		||||
        return cmdCall(false, netctlAutoCommand, QString("switch-to"), profile);
 | 
			
		||||
    return ((autoIsProfileActive(profile)) ||
 | 
			
		||||
            (cmdCall(false, netctlAutoCommand, QString("switch-to"), profile)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -689,7 +665,7 @@ bool Netctl::autoStartProfile(const QString profile)
 | 
			
		||||
bool Netctl::autoEnableService()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (netctlAutoService == 0) {
 | 
			
		||||
    if (netctlAutoService.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find service";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@ -699,8 +675,7 @@ bool Netctl::autoEnableService()
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString interface = interfaces[0];
 | 
			
		||||
    QString argument = netctlAutoService + QString("@") + interface + QString(".service");
 | 
			
		||||
    QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
 | 
			
		||||
 | 
			
		||||
    if (isNetctlAutoEnabled())
 | 
			
		||||
        return cmdCall(true, systemctlCommand, QString("disable"), argument);
 | 
			
		||||
@ -715,7 +690,7 @@ bool Netctl::autoEnableService()
 | 
			
		||||
bool Netctl::autoRestartService()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (netctlAutoService == 0) {
 | 
			
		||||
    if (netctlAutoService.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find service";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@ -725,13 +700,10 @@ bool Netctl::autoRestartService()
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString interface = interfaces[0];
 | 
			
		||||
    QString argument = netctlAutoService + QString("@") + interface + QString(".service");
 | 
			
		||||
    QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
 | 
			
		||||
 | 
			
		||||
    if (isNetctlAutoRunning())
 | 
			
		||||
        return cmdCall(true, systemctlCommand, QString("restart"), argument);
 | 
			
		||||
    else
 | 
			
		||||
        return true;
 | 
			
		||||
    return ((!isNetctlAutoRunning()) ||
 | 
			
		||||
            (cmdCall(true, systemctlCommand, QString("restart"), argument)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -741,7 +713,7 @@ bool Netctl::autoRestartService()
 | 
			
		||||
bool Netctl::autoStartService()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (netctlAutoService == 0) {
 | 
			
		||||
    if (netctlAutoService.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find service";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@ -751,8 +723,7 @@ bool Netctl::autoStartService()
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString interface = interfaces[0];
 | 
			
		||||
    QString argument = netctlAutoService + QString("@") + interface + QString(".service");
 | 
			
		||||
    QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
 | 
			
		||||
 | 
			
		||||
    if (isNetctlAutoRunning())
 | 
			
		||||
        return cmdCall(true, systemctlCommand, QString("stop"), argument);
 | 
			
		||||
 | 
			
		||||
@ -50,8 +50,7 @@ NetctlProfile::NetctlProfile(const bool debugCmd, const QMap<QString, QString> s
 | 
			
		||||
    if (settings.contains(QString("SUDO_PATH")))
 | 
			
		||||
        sudoCommand = settings[QString("SUDO_PATH")];
 | 
			
		||||
    if (settings.contains(QString("FORCE_SUDO")))
 | 
			
		||||
        if (settings[QString("FORCE_SUDO")] == QString("true"))
 | 
			
		||||
            useSuid = false;
 | 
			
		||||
        useSuid = (settings[QString("FORCE_SUDO")] != QString("true"));
 | 
			
		||||
 | 
			
		||||
    if (useSuid)
 | 
			
		||||
        sudoCommand = QString("");
 | 
			
		||||
@ -76,23 +75,24 @@ bool NetctlProfile::copyProfile(const QString oldPath)
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Path" << oldPath;
 | 
			
		||||
    if (profileDirectory == 0) {
 | 
			
		||||
    if (profileDirectory == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
 | 
			
		||||
    QString cmd = sudoCommand + QString(" /usr/bin/mv \"") + oldPath + QString("\" \"") + newPath + QString("\"");
 | 
			
		||||
    QString newPath = QString("%1%2%3").arg(profileDirectory->absolutePath())
 | 
			
		||||
                                       .arg(QDir::separator())
 | 
			
		||||
                                       .arg(QFileInfo(oldPath).fileName());
 | 
			
		||||
    QString cmd = QString("%1 /usr/bin/mv \"%2\" \"%3\"").arg(sudoCommand)
 | 
			
		||||
                                                         .arg(oldPath)
 | 
			
		||||
                                                         .arg(newPath);
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
 | 
			
		||||
    TaskResult process = runTask(cmd, useSuid);
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
 | 
			
		||||
    if (process.exitCode != 0)
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
 | 
			
		||||
 | 
			
		||||
    if (process.exitCode == 0)
 | 
			
		||||
        return true;
 | 
			
		||||
    else
 | 
			
		||||
        return false;
 | 
			
		||||
    return (process.exitCode == 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -104,7 +104,9 @@ QString NetctlProfile::createProfile(const QString profile, const QMap<QString,
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
 | 
			
		||||
 | 
			
		||||
    QString profileTempName = QDir::tempPath() + QDir::separator() + QFileInfo(profile).fileName();
 | 
			
		||||
    QString profileTempName = QString("%1%2%3").arg(QDir::tempPath())
 | 
			
		||||
                                               .arg(QDir::separator())
 | 
			
		||||
                                               .arg(QFileInfo(profile).fileName());
 | 
			
		||||
    QFile profileFile(profileTempName);
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Save to" << profileTempName;
 | 
			
		||||
    if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
 | 
			
		||||
@ -123,7 +125,7 @@ QString NetctlProfile::createProfile(const QString profile, const QMap<QString,
 | 
			
		||||
                (settings.keys()[i] == QString("DNSOptions")) ||
 | 
			
		||||
                (settings.keys()[i] == QString("ScanFrequencies")) ||
 | 
			
		||||
                (settings.keys()[i] == QString("WPAConfigSection")))
 | 
			
		||||
            out << QString("(") + settings[settings.keys()[i]] << QString(")") << endl;
 | 
			
		||||
            out << QString("(%1)").arg(settings[settings.keys()[i]]) << endl;
 | 
			
		||||
        else
 | 
			
		||||
            out << settings[settings.keys()[i]] << endl;
 | 
			
		||||
    }
 | 
			
		||||
@ -139,7 +141,6 @@ QString NetctlProfile::createProfile(const QString profile, const QMap<QString,
 | 
			
		||||
QMap<QString, QString> NetctlProfile::getRecommendedConfiguration()
 | 
			
		||||
{
 | 
			
		||||
    QMap<QString, QString> settings;
 | 
			
		||||
    QString cmd;
 | 
			
		||||
    TaskResult process;
 | 
			
		||||
    QStringList recommended;
 | 
			
		||||
    // force sudo
 | 
			
		||||
@ -149,8 +150,7 @@ QMap<QString, QString> NetctlProfile::getRecommendedConfiguration()
 | 
			
		||||
    recommended.append(QString("netctlgui-helper"));
 | 
			
		||||
    recommended.append(QString("netctlgui-helper-suid"));
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("FORCE_SUDO")] = QString("false");
 | 
			
		||||
            break;
 | 
			
		||||
@ -177,8 +177,7 @@ QMap<QString, QString> NetctlProfile::getRecommendedConfiguration()
 | 
			
		||||
    recommended.append("kdesu");
 | 
			
		||||
    recommended.append("gksu");
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("SUDO_PATH")] = process.output.trimmed();
 | 
			
		||||
            break;
 | 
			
		||||
@ -196,7 +195,7 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
 | 
			
		||||
    if (profileDirectory == 0) {
 | 
			
		||||
    if (profileDirectory == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
 | 
			
		||||
        return QMap<QString, QString>();
 | 
			
		||||
    }
 | 
			
		||||
@ -216,8 +215,10 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
 | 
			
		||||
        systemVariables.append(output[i].split(QChar('='))[0]);
 | 
			
		||||
    // profile variables
 | 
			
		||||
    QMap<QString, QString> settings;
 | 
			
		||||
    QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
 | 
			
		||||
    cmd = QString("env -i bash -c \"source '") + profileUrl + QString("'; set\"");
 | 
			
		||||
    QString profileUrl = QString("%1%2%3").arg(profileDirectory->absolutePath())
 | 
			
		||||
                                          .arg(QDir::separator())
 | 
			
		||||
                                          .arg(QFileInfo(profile).fileName());
 | 
			
		||||
    cmd = QString("env -i bash -c \"source '%1'; set\"").arg(profileUrl);
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
 | 
			
		||||
    process = runTask(cmd, false);
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
 | 
			
		||||
@ -231,9 +232,7 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
 | 
			
		||||
        if (!systemVariables.contains(output[i].split(QChar('='))[0]))
 | 
			
		||||
            keys.append(output[i].split(QChar('='))[0]);
 | 
			
		||||
    for (int i=0; i<keys.count(); i++){
 | 
			
		||||
        cmd = QString("env -i bash -c \"source '") + profileUrl +
 | 
			
		||||
                QString("'; for i in ${!") + keys[i] + QString("[@]}; do echo ${") +
 | 
			
		||||
                keys[i] + QString("[$i]}; done\"");
 | 
			
		||||
        cmd = QString("env -i bash -c \"source '%1'; for i in ${!%2[@]}; do echo ${%2[$i]}; done\"").arg(profileUrl).arg(keys[i]);
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        settings[keys[i]] = process.output.trimmed();
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << keys[i] << "=" << settings[keys[i]];
 | 
			
		||||
@ -254,10 +253,7 @@ QString NetctlProfile::getValueFromProfile(const QString profile, const QString
 | 
			
		||||
 | 
			
		||||
    QMap<QString, QString> settings = getSettingsFromProfile(profile);
 | 
			
		||||
 | 
			
		||||
    if (settings.contains(key))
 | 
			
		||||
        return settings[key];
 | 
			
		||||
    else
 | 
			
		||||
        return QString();
 | 
			
		||||
    return settings[key];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -268,21 +264,20 @@ bool NetctlProfile::removeProfile(const QString profile)
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
 | 
			
		||||
    if (profileDirectory == 0) {
 | 
			
		||||
    if (profileDirectory == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString profilePath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
 | 
			
		||||
    QString cmd = sudoCommand + QString(" /usr/bin/rm \"") + profilePath + QString("\"");
 | 
			
		||||
    QString profilePath = QString("%1%2%3").arg(profileDirectory->absolutePath())
 | 
			
		||||
                                           .arg(QDir::separator())
 | 
			
		||||
                                           .arg(QFileInfo(profile).fileName());
 | 
			
		||||
    QString cmd = QString("%1 /usr/bin/rm \"%2\"").arg(sudoCommand).arg(profilePath);
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
 | 
			
		||||
    TaskResult process = runTask(cmd, useSuid);
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
 | 
			
		||||
    if (process.exitCode != 0)
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
 | 
			
		||||
 | 
			
		||||
    if (process.exitCode == 0)
 | 
			
		||||
        return true;
 | 
			
		||||
    else
 | 
			
		||||
        return false;
 | 
			
		||||
    return (process.exitCode == 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -58,8 +58,7 @@ WpaSup::WpaSup(const bool debugCmd, const QMap<QString, QString> settings)
 | 
			
		||||
    if (settings.contains(QString("WPASUP_PATH")))
 | 
			
		||||
        wpaSupPath = settings[QString("WPASUP_PATH")];
 | 
			
		||||
    if (settings.contains(QString("FORCE_SUDO")))
 | 
			
		||||
        if (settings[QString("FORCE_SUDO")] == QString("true"))
 | 
			
		||||
            useSuid = false;
 | 
			
		||||
        useSuid = (settings[QString("FORCE_SUDO")] != QString("true"));
 | 
			
		||||
 | 
			
		||||
    if (useSuid)
 | 
			
		||||
        sudoCommand = QString("");
 | 
			
		||||
@ -86,11 +85,11 @@ QString WpaSup::existentProfile(const QString essid)
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
 | 
			
		||||
    if (netctlCommand == 0) {
 | 
			
		||||
    if (netctlCommand == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
 | 
			
		||||
        return QString();
 | 
			
		||||
    }
 | 
			
		||||
    if (netctlProfile == 0) {
 | 
			
		||||
    if (netctlProfile == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
 | 
			
		||||
        return QString();
 | 
			
		||||
    }
 | 
			
		||||
@ -112,7 +111,6 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
 | 
			
		||||
{
 | 
			
		||||
    QMap<QString, QString> settings;
 | 
			
		||||
    int size = 99;
 | 
			
		||||
    QString cmd;
 | 
			
		||||
    TaskResult process;
 | 
			
		||||
    QStringList recommended;
 | 
			
		||||
    // ctrl directory
 | 
			
		||||
@ -142,8 +140,7 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
 | 
			
		||||
    recommended.append(QString("netctlgui-helper"));
 | 
			
		||||
    recommended.append(QString("netctlgui-helper-suid"));
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("FORCE_SUDO")] = QString("false");
 | 
			
		||||
            break;
 | 
			
		||||
@ -160,8 +157,7 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
 | 
			
		||||
    recommended.append("kdesu");
 | 
			
		||||
    recommended.append("gksu");
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("SUDO_PATH")] = process.output.trimmed();
 | 
			
		||||
            break;
 | 
			
		||||
@ -173,8 +169,7 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
 | 
			
		||||
    recommended.clear();
 | 
			
		||||
    recommended.append("wpa_cli");
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("WPACLI_PATH")] = process.output.trimmed();
 | 
			
		||||
            break;
 | 
			
		||||
@ -189,8 +184,7 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
 | 
			
		||||
    recommended.clear();
 | 
			
		||||
    recommended.append("wpa_supplicant");
 | 
			
		||||
    for (int i=0; i<recommended.count(); i++) {
 | 
			
		||||
        cmd = QString("which ") + recommended[i];
 | 
			
		||||
        process = runTask(cmd, false);
 | 
			
		||||
        process = runTask(QString("which %1").arg(recommended[i]), false);
 | 
			
		||||
        if (process.exitCode == 0) {
 | 
			
		||||
            settings[QString("WPASUP_PATH")] = process.output.trimmed();
 | 
			
		||||
            break;
 | 
			
		||||
@ -208,11 +202,11 @@ bool WpaSup::isProfileActive(const QString essid)
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
 | 
			
		||||
    if (netctlCommand == 0) {
 | 
			
		||||
    if (netctlCommand == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (netctlProfile == 0) {
 | 
			
		||||
    if (netctlProfile == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@ -236,11 +230,11 @@ bool WpaSup::isProfileExists(const QString essid)
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
 | 
			
		||||
    if (netctlCommand == 0) {
 | 
			
		||||
    if (netctlCommand == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (netctlProfile == 0) {
 | 
			
		||||
    if (netctlProfile == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@ -269,8 +263,7 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
 | 
			
		||||
        stopWpaSupplicant();
 | 
			
		||||
        return scanResults;
 | 
			
		||||
    }
 | 
			
		||||
    if (!wpaCliCall(QString("scan")))
 | 
			
		||||
        return scanResults;
 | 
			
		||||
    if (!wpaCliCall(QString("scan"))) return scanResults;
 | 
			
		||||
    waitForProcess(3);
 | 
			
		||||
 | 
			
		||||
    QStringList rawOutput = getWpaCliOutput(QString("scan_results")).split(QChar('\n'), QString::SkipEmptyParts);
 | 
			
		||||
@ -278,22 +271,22 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
 | 
			
		||||
    rawOutput.removeFirst();
 | 
			
		||||
    // remove duplicates
 | 
			
		||||
    QStringList rawList;
 | 
			
		||||
    QStringList names;
 | 
			
		||||
    for (int i=0; i<rawOutput.count(); i++) {
 | 
			
		||||
        bool exist = false;
 | 
			
		||||
        if (rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts).count() > 4)
 | 
			
		||||
            for (int j=0; j<rawList.count(); j++)
 | 
			
		||||
                if (rawList[j].split(QChar('\t'), QString::SkipEmptyParts).count() > 4)
 | 
			
		||||
                    if (rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts)[4] ==
 | 
			
		||||
                            rawList[j].split(QChar('\t'), QString::SkipEmptyParts)[4])
 | 
			
		||||
                        exist = true;
 | 
			
		||||
        if (!exist)
 | 
			
		||||
        if (rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts).count() == 4) {
 | 
			
		||||
            rawList.append(rawOutput[i]);
 | 
			
		||||
            continue;
 | 
			
		||||
        } else if (rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts).count() == 5) {
 | 
			
		||||
            if (names.contains(rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts)[4])) continue;
 | 
			
		||||
            names.append(rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts)[4]);
 | 
			
		||||
            rawList.append(rawOutput[i]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (int i=0; i<rawList.count(); i++) {
 | 
			
		||||
        netctlWifiInfo wifiPoint;
 | 
			
		||||
        // point name
 | 
			
		||||
        if (rawList[i].split(QChar('\t'), QString::SkipEmptyParts).count() > 4)
 | 
			
		||||
        if (rawList[i].split(QChar('\t'), QString::SkipEmptyParts).count() == 5)
 | 
			
		||||
            wifiPoint.name = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[4];
 | 
			
		||||
        else
 | 
			
		||||
            wifiPoint.name = QString("<hidden>");
 | 
			
		||||
@ -327,27 +320,27 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
 | 
			
		||||
bool WpaSup::startWpaSupplicant()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (ctrlDir == 0) {
 | 
			
		||||
    if (ctrlDir.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (ctrlGroup == 0) {
 | 
			
		||||
    if (ctrlGroup.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find group";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (pidFile == 0) {
 | 
			
		||||
    if (pidFile.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find PID file";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (wpaDrivers == 0) {
 | 
			
		||||
    if (wpaDrivers.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find drivers";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (wpaSupPath == 0) {
 | 
			
		||||
    if (wpaSupPath.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find wpa_supplicant";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (netctlCommand == 0) {
 | 
			
		||||
    if (netctlCommand == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@ -357,12 +350,10 @@ bool WpaSup::startWpaSupplicant()
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (QFile(pidFile).exists())
 | 
			
		||||
        return true;
 | 
			
		||||
    QString interface = interfaces[0];
 | 
			
		||||
    QString cmd = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile +
 | 
			
		||||
            QString(" -i ") + interface + QString(" -D ") + wpaDrivers +
 | 
			
		||||
            QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\"");
 | 
			
		||||
    if (QFile(pidFile).exists()) return true;
 | 
			
		||||
    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(wpaDrivers).arg(ctrlDir).arg(ctrlGroup);
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
 | 
			
		||||
    TaskResult process = runTask(cmd, useSuid);
 | 
			
		||||
    waitForProcess(1);
 | 
			
		||||
@ -370,10 +361,7 @@ bool WpaSup::startWpaSupplicant()
 | 
			
		||||
    if (process.exitCode != 0)
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
 | 
			
		||||
 | 
			
		||||
    if (process.exitCode == 0)
 | 
			
		||||
        return true;
 | 
			
		||||
    else
 | 
			
		||||
        return false;
 | 
			
		||||
    return (process.exitCode == 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -396,19 +384,19 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
 | 
			
		||||
    if (ctrlDir == 0) {
 | 
			
		||||
    if (ctrlDir.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
 | 
			
		||||
        return QString();
 | 
			
		||||
    }
 | 
			
		||||
    if (pidFile == 0) {
 | 
			
		||||
    if (pidFile.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find PID file";
 | 
			
		||||
        return QString();
 | 
			
		||||
    }
 | 
			
		||||
    if (wpaCliPath == 0) {
 | 
			
		||||
    if (wpaCliPath.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find wpa_cli";
 | 
			
		||||
        return QString();
 | 
			
		||||
    }
 | 
			
		||||
    if (netctlCommand == 0) {
 | 
			
		||||
    if (netctlCommand == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
 | 
			
		||||
        return QString();
 | 
			
		||||
    }
 | 
			
		||||
@ -453,19 +441,19 @@ bool WpaSup::wpaCliCall(const QString commandLine)
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
 | 
			
		||||
    if (ctrlDir == 0) {
 | 
			
		||||
    if (ctrlDir.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (pidFile == 0) {
 | 
			
		||||
    if (pidFile.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find PID file";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (wpaCliPath == 0) {
 | 
			
		||||
    if (wpaCliPath.isEmpty()) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find wpa_cli";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (netctlCommand == 0) {
 | 
			
		||||
    if (netctlCommand == nullptr) {
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@ -485,8 +473,5 @@ bool WpaSup::wpaCliCall(const QString commandLine)
 | 
			
		||||
    if (process.exitCode != 0)
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
 | 
			
		||||
 | 
			
		||||
    if (process.exitCode == 0)
 | 
			
		||||
        return true;
 | 
			
		||||
    else
 | 
			
		||||
        return false;
 | 
			
		||||
    return (process.exitCode == 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user