mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-28 04:59:58 +00:00
end work on interfaces
This commit is contained in:
@ -203,6 +203,7 @@ QList<netctlProfileInfo> Netctl::getProfileList()
|
||||
profileInfo.essid = profileValues[2];
|
||||
profileInfo.interface = profileValues[3];
|
||||
profileInfo.type = profileValues[0];
|
||||
profileInfo.netctlAuto = false;
|
||||
fullProfilesInfo.append(profileInfo);
|
||||
}
|
||||
|
||||
@ -227,12 +228,18 @@ QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto()
|
||||
profileInfo.enabled = (output[i][0] != QChar('!'));
|
||||
// external
|
||||
QStringList keys;
|
||||
keys.append(QString("Connection"));
|
||||
keys.append(QString("Description"));
|
||||
keys.append(QString("ESSID"));
|
||||
keys.append(QString("Interface"));
|
||||
QStringList profileValues = netctlProfile->getValuesFromProfile(profileInfo.name,
|
||||
keys);
|
||||
profileInfo.description = profileValues[0];
|
||||
profileInfo.description = profileValues[1];
|
||||
profileInfo.essid = profileValues[2];
|
||||
profileInfo.interface = profileValues[3];
|
||||
profileInfo.type = profileValues[0];
|
||||
profileInfo.essid = profileValues[1];
|
||||
profileInfo.netctlAuto = true;
|
||||
fullProfilesInfo.append(profileInfo);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
#include <netctlgui/netctlinterface.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
@ -89,10 +89,11 @@ InterfaceAnswer NetctlInterface::connectToEssid(const QString essid, QMap<QStrin
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
if (wpaCommand->existentProfile(essid).isEmpty())
|
||||
QString profile = wpaCommand->existentProfile(essid);
|
||||
if (profile.isEmpty())
|
||||
return connectToUnknownEssid(essid, settings);
|
||||
else
|
||||
return connectToKnownEssid(essid);
|
||||
return startProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
@ -187,6 +188,24 @@ InterfaceAnswer NetctlInterface::enableProfile(const QString profile)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn removeProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::removeProfile(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlProfile == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
if (netctlProfile->removeProfile(profile))
|
||||
return InterfaceAnswer::True;
|
||||
else
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn restartProfile
|
||||
*/
|
||||
@ -266,3 +285,67 @@ InterfaceAnswer NetctlInterface::switchToProfile(const QString profile)
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn information
|
||||
*/
|
||||
netctlInformation NetctlInterface::information()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return netctlInformation();
|
||||
}
|
||||
|
||||
netctlInformation info;
|
||||
info.netctlAuto = netctlCommand->isNetctlAutoRunning();
|
||||
info.netctlProfiles = netctlCommand->getProfileList();
|
||||
if (info.netctlAuto) info.netctlAutoProfiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn profileSettings
|
||||
*/
|
||||
QMap<QString, QString> NetctlInterface::profileSettings(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlProfile == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return QMap<QString, QString>();
|
||||
}
|
||||
|
||||
return netctlProfile->getSettingsFromProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn status
|
||||
*/
|
||||
netctlCurrent NetctlInterface::status()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return netctlCurrent();
|
||||
}
|
||||
|
||||
netctlCurrent current;
|
||||
current.netctlAuto = netctlCommand->isNetctlAutoRunning();
|
||||
QList<netctlProfileInfo> profiles;
|
||||
if (current.netctlAuto)
|
||||
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||
else
|
||||
profiles = netctlCommand->getProfileList();
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
current.profiles.append(profiles[i].name);
|
||||
if (!profiles[i].active) continue;
|
||||
current.current.append(profiles[i].name);
|
||||
current.enables.append(profiles[i].enabled);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
Reference in New Issue
Block a user