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>
|
||||
|
||||
|
||||
class WpaSup;
|
||||
class NetctlProfile;
|
||||
|
||||
/**
|
||||
* @brief The Netctl class interacts with netctl
|
||||
@ -85,13 +85,13 @@ public:
|
||||
/**
|
||||
* @brief method which gets description from profile
|
||||
* @param profile profile name
|
||||
* @return profile description or "<unknown>"
|
||||
* @return profile description or ""
|
||||
*/
|
||||
QString getProfileDescription(const QString profile);
|
||||
/**
|
||||
* @brief method which gets descriptions from profile list
|
||||
* @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);
|
||||
/**
|
||||
@ -221,6 +221,10 @@ public slots:
|
||||
bool autoStartService();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief NetctlProfile class
|
||||
*/
|
||||
NetctlProfile *netctlProfile;
|
||||
/**
|
||||
* @brief show debug messages
|
||||
*/
|
||||
|
@ -39,6 +39,8 @@
|
||||
Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
|
||||
: debug(debugCmd)
|
||||
{
|
||||
netctlProfile = new NetctlProfile(debug, settings);
|
||||
|
||||
if (settings.contains(QString("IFACE_DIR")))
|
||||
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
|
||||
else
|
||||
@ -81,6 +83,8 @@ Netctl::~Netctl()
|
||||
{
|
||||
if (debug) qDebug() << "[Netctl]" << "[~Netctl]";
|
||||
|
||||
if (netctlProfile != 0)
|
||||
delete netctlProfile;
|
||||
if (ifaceDirectory != 0)
|
||||
delete ifaceDirectory;
|
||||
if (profileDirectory != 0)
|
||||
@ -333,32 +337,12 @@ QString Netctl::getProfileDescription(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]";
|
||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Profile" << profile;
|
||||
if (profileDirectory == 0) {
|
||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Could not find directory";
|
||||
if (netctlProfile == 0) {
|
||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Could not find library";
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString description = QString("<unknown>");
|
||||
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;
|
||||
return netctlProfile->getValueFromProfile(profile, QString("Description"));
|
||||
}
|
||||
|
||||
|
||||
@ -369,35 +353,14 @@ QStringList Netctl::getProfileDescriptions(const QStringList profileList)
|
||||
{
|
||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]";
|
||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Profile list" << profileList;
|
||||
if (profileDirectory == 0) {
|
||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Could not find directory";
|
||||
if (netctlProfile == 0) {
|
||||
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Could not find library";
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QStringList descriptions;
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
QString description = QString("<unknown>");
|
||||
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);
|
||||
}
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
descriptions.append(netctlProfile->getValueFromProfile(profileList[i], QString("Description")));
|
||||
|
||||
return descriptions;
|
||||
}
|
||||
|
@ -98,6 +98,14 @@ QString WpaSup::existentProfile(const QString essid)
|
||||
{
|
||||
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]";
|
||||
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("");
|
||||
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]" << ":" << "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;
|
||||
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]" << ":" << "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;
|
||||
QList<QStringList> profileList = netctlCommand->getProfileList();
|
||||
@ -252,6 +276,10 @@ bool WpaSup::startWpaSupplicant()
|
||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find wpa_supplicant";
|
||||
return false;
|
||||
}
|
||||
if (netctlCommand == 0) {
|
||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find library";
|
||||
return false;
|
||||
}
|
||||
if (netctlCommand->getInterfaceList().isEmpty()) {
|
||||
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find interfaces";
|
||||
return false;
|
||||
@ -308,6 +336,10 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
|
||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find wpa_cli";
|
||||
return QString();
|
||||
}
|
||||
if (netctlCommand == 0) {
|
||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find library";
|
||||
return QString();
|
||||
}
|
||||
if (netctlCommand->getInterfaceList().isEmpty()) {
|
||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find interfaces";
|
||||
return QString();
|
||||
@ -344,6 +376,10 @@ bool WpaSup::wpaCliCall(const QString commandLine)
|
||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find wpa_cli";
|
||||
return false;
|
||||
}
|
||||
if (netctlCommand == 0) {
|
||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find library";
|
||||
return false;
|
||||
}
|
||||
if (netctlCommand->getInterfaceList().isEmpty()) {
|
||||
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find interfaces";
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user