mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 23:47:21 +00:00
small edit
This commit is contained in:
parent
4600aae8bc
commit
6cba836d98
@ -31,7 +31,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
class WpaSup;
|
class NetctlProfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The Netctl class interacts with netctl
|
* @brief The Netctl class interacts with netctl
|
||||||
@ -85,13 +85,13 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief method which gets description from profile
|
* @brief method which gets description from profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
* @return profile description or "<unknown>"
|
* @return profile description or ""
|
||||||
*/
|
*/
|
||||||
QString getProfileDescription(const QString profile);
|
QString getProfileDescription(const QString profile);
|
||||||
/**
|
/**
|
||||||
* @brief method which gets descriptions from profile list
|
* @brief method which gets descriptions from profile list
|
||||||
* @param profileList profile names
|
* @param profileList profile names
|
||||||
* @return list of profile descriptions (if description is not available return "<unknown>")
|
* @return list of profile descriptions (if description is not available returns "")
|
||||||
*/
|
*/
|
||||||
QStringList getProfileDescriptions(const QStringList profileList);
|
QStringList getProfileDescriptions(const QStringList profileList);
|
||||||
/**
|
/**
|
||||||
@ -221,6 +221,10 @@ public slots:
|
|||||||
bool autoStartService();
|
bool autoStartService();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* @brief NetctlProfile class
|
||||||
|
*/
|
||||||
|
NetctlProfile *netctlProfile;
|
||||||
/**
|
/**
|
||||||
* @brief show debug messages
|
* @brief show debug messages
|
||||||
*/
|
*/
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
|
Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
|
||||||
: debug(debugCmd)
|
: debug(debugCmd)
|
||||||
{
|
{
|
||||||
|
netctlProfile = new NetctlProfile(debug, settings);
|
||||||
|
|
||||||
if (settings.contains(QString("IFACE_DIR")))
|
if (settings.contains(QString("IFACE_DIR")))
|
||||||
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
|
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
|
||||||
else
|
else
|
||||||
@ -81,6 +83,8 @@ Netctl::~Netctl()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[~Netctl]";
|
if (debug) qDebug() << "[Netctl]" << "[~Netctl]";
|
||||||
|
|
||||||
|
if (netctlProfile != 0)
|
||||||
|
delete netctlProfile;
|
||||||
if (ifaceDirectory != 0)
|
if (ifaceDirectory != 0)
|
||||||
delete ifaceDirectory;
|
delete ifaceDirectory;
|
||||||
if (profileDirectory != 0)
|
if (profileDirectory != 0)
|
||||||
@ -333,32 +337,12 @@ QString Netctl::getProfileDescription(const QString profile)
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]";
|
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]";
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Profile" << profile;
|
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Profile" << profile;
|
||||||
if (profileDirectory == 0) {
|
if (netctlProfile == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Could not find directory";
|
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Could not find library";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString description = QString("<unknown>");
|
return netctlProfile->getValueFromProfile(profile, QString("Description"));
|
||||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
|
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Check" << profileUrl;
|
|
||||||
QFile profileFile(profileUrl);
|
|
||||||
QString fileStr;
|
|
||||||
if (!profileFile.open(QIODevice::ReadOnly))
|
|
||||||
return description;
|
|
||||||
while (true) {
|
|
||||||
fileStr = QString(profileFile.readLine());
|
|
||||||
if (fileStr.isEmpty()) continue;
|
|
||||||
if (fileStr[0] == QChar('#')) continue;
|
|
||||||
if (fileStr.split(QChar('='), QString::SkipEmptyParts).count() == 2)
|
|
||||||
if (fileStr.split(QChar('='), QString::SkipEmptyParts)[0] == QString("Description"))
|
|
||||||
description = fileStr.split(QChar('='), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
if (profileFile.atEnd())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
profileFile.close();
|
|
||||||
description.remove(QChar('\'')).remove(QChar('"'));
|
|
||||||
|
|
||||||
return description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -369,35 +353,14 @@ QStringList Netctl::getProfileDescriptions(const QStringList profileList)
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]";
|
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]";
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Profile list" << profileList;
|
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Profile list" << profileList;
|
||||||
if (profileDirectory == 0) {
|
if (netctlProfile == 0) {
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Could not find directory";
|
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Could not find library";
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList descriptions;
|
QStringList descriptions;
|
||||||
for (int i=0; i<profileList.count(); i++) {
|
for (int i=0; i<profileList.count(); i++)
|
||||||
QString description = QString("<unknown>");
|
descriptions.append(netctlProfile->getValueFromProfile(profileList[i], QString("Description")));
|
||||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profileList[i];
|
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Check" << profileUrl;
|
|
||||||
QFile profileFile(profileUrl);
|
|
||||||
QString fileStr;
|
|
||||||
if (!profileFile.open(QIODevice::ReadOnly)) {
|
|
||||||
descriptions.append(description);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
while (true) {
|
|
||||||
fileStr = QString(profileFile.readLine());
|
|
||||||
if (fileStr[0] == QChar('#')) continue;
|
|
||||||
if (fileStr.split(QChar('='), QString::SkipEmptyParts).count() == 2)
|
|
||||||
if (fileStr.split(QChar('='), QString::SkipEmptyParts)[0] == QString("Description"))
|
|
||||||
description = fileStr.split(QChar('='), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
if (profileFile.atEnd())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
profileFile.close();
|
|
||||||
description.remove(QChar('\'')).remove(QChar('"'));
|
|
||||||
descriptions.append(description);
|
|
||||||
}
|
|
||||||
|
|
||||||
return descriptions;
|
return descriptions;
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,14 @@ QString WpaSup::existentProfile(const QString essid)
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]";
|
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]";
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]" << ":" << "ESSID" << essid;
|
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]" << ":" << "ESSID" << essid;
|
||||||
|
if (netctlCommand == 0) {
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]" << ":" << "Could not find library";
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
if (netctlProfile == 0) {
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]" << ":" << "Could not find library";
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
QString profileFile = QString("");
|
QString profileFile = QString("");
|
||||||
QList<QStringList> profileList = netctlCommand->getProfileList();
|
QList<QStringList> profileList = netctlCommand->getProfileList();
|
||||||
@ -116,6 +124,14 @@ bool WpaSup::isProfileActive(const QString essid)
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]";
|
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]";
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]" << ":" << "ESSID" << essid;
|
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]" << ":" << "ESSID" << essid;
|
||||||
|
if (netctlCommand == 0) {
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]" << ":" << "Could not find library";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (netctlProfile == 0) {
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]" << ":" << "Could not find library";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString profileFile;
|
QString profileFile;
|
||||||
QList<QStringList> profileList = netctlCommand->getProfileList();
|
QList<QStringList> profileList = netctlCommand->getProfileList();
|
||||||
@ -136,6 +152,14 @@ bool WpaSup::isProfileExists(const QString essid)
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]";
|
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]";
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]" << ":" << "ESSID" << essid;
|
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]" << ":" << "ESSID" << essid;
|
||||||
|
if (netctlCommand == 0) {
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]" << ":" << "Could not find library";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (netctlProfile == 0) {
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]" << ":" << "Could not find library";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
QList<QStringList> profileList = netctlCommand->getProfileList();
|
QList<QStringList> profileList = netctlCommand->getProfileList();
|
||||||
@ -252,6 +276,10 @@ bool WpaSup::startWpaSupplicant()
|
|||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find wpa_supplicant";
|
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find wpa_supplicant";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (netctlCommand == 0) {
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find library";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (netctlCommand->getInterfaceList().isEmpty()) {
|
if (netctlCommand->getInterfaceList().isEmpty()) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find interfaces";
|
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find interfaces";
|
||||||
return false;
|
return false;
|
||||||
@ -308,6 +336,10 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
|
|||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find wpa_cli";
|
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find wpa_cli";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
if (netctlCommand == 0) {
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find library";
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
if (netctlCommand->getInterfaceList().isEmpty()) {
|
if (netctlCommand->getInterfaceList().isEmpty()) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find interfaces";
|
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find interfaces";
|
||||||
return QString();
|
return QString();
|
||||||
@ -344,6 +376,10 @@ bool WpaSup::wpaCliCall(const QString commandLine)
|
|||||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find wpa_cli";
|
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find wpa_cli";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (netctlCommand == 0) {
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find library";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (netctlCommand->getInterfaceList().isEmpty()) {
|
if (netctlCommand->getInterfaceList().isEmpty()) {
|
||||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find interfaces";
|
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find interfaces";
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user