mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-10 04:15:52 +00:00
rewrite tables
This commit is contained in:
@ -150,6 +150,44 @@ QString Netctl::getCmdOutput(const bool sudo, const QString command, const QStri
|
||||
|
||||
|
||||
// general information
|
||||
/**
|
||||
* @fn getActiveProfile
|
||||
*/
|
||||
QString Netctl::getActiveProfile()
|
||||
{
|
||||
if (debug) qDebug() << "[Netctl]" << "[getActiveProfile]";
|
||||
|
||||
QString profile = QString("");
|
||||
QList<netctlProfileInfo> fullProfilesInfo = getProfileList();
|
||||
for (int i=0; i<fullProfilesInfo.count(); i++)
|
||||
if (fullProfilesInfo[i].active) {
|
||||
profile = fullProfilesInfo[i].name;
|
||||
break;
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoGetActiveProfile
|
||||
*/
|
||||
QString Netctl::autoGetActiveProfile()
|
||||
{
|
||||
if (debug) qDebug() << "[Netctl]" << "[autoGetActiveProfile]";
|
||||
|
||||
QString profile = QString("");
|
||||
QList<netctlProfileInfo> fullProfilesInfo = getProfileListFromNetctlAuto();
|
||||
for (int i=0; i<fullProfilesInfo.count(); i++)
|
||||
if (fullProfilesInfo[i].active) {
|
||||
profile = fullProfilesInfo[i].name;
|
||||
break;
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getProfileList
|
||||
*/
|
||||
@ -164,7 +202,10 @@ QList<netctlProfileInfo> Netctl::getProfileList()
|
||||
netctlProfileInfo profileInfo;
|
||||
profileInfo.name = output[i].mid(2, -1);
|
||||
profileInfo.description = getProfileDescription(profileInfo.name);
|
||||
profileInfo.active = isProfileActive(profileInfo.name);
|
||||
if (output[i][0] == QChar('*'))
|
||||
profileInfo.active = true;
|
||||
else
|
||||
profileInfo.active = false;
|
||||
profileInfo.enabled = isProfileEnabled(profileInfo.name);
|
||||
fullProfilesInfo.append(profileInfo);
|
||||
}
|
||||
@ -187,8 +228,12 @@ QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto()
|
||||
netctlProfileInfo profileInfo;
|
||||
profileInfo.name = output[i].mid(2, -1);
|
||||
profileInfo.description = getProfileDescription(profileInfo.name);
|
||||
profileInfo.active = autoIsProfileActive(profileInfo.name);
|
||||
profileInfo.enabled = autoIsProfileEnabled(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;
|
||||
fullProfilesInfo.append(profileInfo);
|
||||
}
|
||||
|
||||
@ -320,12 +365,8 @@ bool Netctl::isNetctlAutoEnabled()
|
||||
|
||||
QString interface = getWirelessInterfaceList()[0];
|
||||
QString argument = netctlAutoService + QString("@") + interface + QString(".service");
|
||||
QString output = getCmdOutput(false, systemctlCommand, QString("is-enabled"), argument).trimmed();
|
||||
|
||||
if (output == QString("enabled"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return cmdCall(false, systemctlCommand, QString("is-enabled"), argument);
|
||||
}
|
||||
|
||||
|
||||
@ -346,12 +387,8 @@ bool Netctl::isNetctlAutoRunning()
|
||||
|
||||
QString interface = getWirelessInterfaceList()[0];
|
||||
QString argument = netctlAutoService + QString("@") + interface + QString(".service");
|
||||
QString output = getCmdOutput(false, systemctlCommand, QString("is-active"), argument).trimmed();
|
||||
|
||||
if (output == QString("active"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return cmdCall(false, systemctlCommand, QString("is-active"), argument);
|
||||
}
|
||||
|
||||
|
||||
@ -425,6 +462,21 @@ bool Netctl::startProfile(const QString profile)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn switchToProfile
|
||||
*/
|
||||
bool Netctl::switchToProfile(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << "[Netctl]" << "[switchToProfile]";
|
||||
if (debug) qDebug() << "[Netctl]" << "[switchToProfile]" << ":" << "Profile" << profile;
|
||||
|
||||
if (isProfileActive(profile))
|
||||
return true;
|
||||
else
|
||||
return cmdCall(true, netctlCommand, QString("switch-to"), profile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoDisableAllProfiles
|
||||
*/
|
||||
|
@ -210,17 +210,8 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
||||
else
|
||||
wifiPoint.name = QString("<hidden>");
|
||||
// profile status
|
||||
QString status;
|
||||
if (isProfileExists(wifiPoint.name)) {
|
||||
status = QString("exists");
|
||||
if (isProfileActive(wifiPoint.name))
|
||||
status = status + QString(" (active)");
|
||||
else
|
||||
status = status + QString(" (inactive)");
|
||||
}
|
||||
else
|
||||
status = QString("new");
|
||||
wifiPoint.status = status;
|
||||
wifiPoint.active = isProfileActive(wifiPoint.name);
|
||||
wifiPoint.exists = isProfileExists(wifiPoint.name);
|
||||
// point signal
|
||||
wifiPoint.signal = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[2];
|
||||
// point security
|
||||
|
Reference in New Issue
Block a user