mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 23:47:21 +00:00
changed de configuration
This commit is contained in:
parent
1a7d3cb50a
commit
b1e455b976
@ -8,7 +8,7 @@ cmake_policy (SET CMP0015 NEW)
|
|||||||
project (netctl-plasmoid)
|
project (netctl-plasmoid)
|
||||||
set (PROJECT_VERSION_MAJOR 1)
|
set (PROJECT_VERSION_MAJOR 1)
|
||||||
set (PROJECT_VERSION_MINOR 0)
|
set (PROJECT_VERSION_MINOR 0)
|
||||||
set (PROJECT_VERSION_PATCH 2)
|
set (PROJECT_VERSION_PATCH 3)
|
||||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||||
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||||
|
|
||||||
|
@ -52,11 +52,11 @@ QStringList Netctl::sources() const
|
|||||||
bool Netctl::readConfiguration()
|
bool Netctl::readConfiguration()
|
||||||
{
|
{
|
||||||
// default configuration
|
// default configuration
|
||||||
checkExtIP = QString("false");
|
configuration[QString("CMD")] = QString("/usr/bin/netctl");
|
||||||
cmd = QString("/usr/bin/netctl");
|
configuration[QString("EXTIP")] = QString("false");
|
||||||
extIpCmd = QString("wget -qO- http://ifconfig.me/ip");
|
configuration[QString("EXTIPCMD")] = QString("wget -qO- http://ifconfig.me/ip");
|
||||||
ipCmd = QString("/usr/bin/ip");
|
configuration[QString("IPCMD")] = QString("/usr/bin/ip");
|
||||||
netDir = QString("/sys/class/net/");
|
configuration[QString("NETDIR")] = QString("/sys/class/net/");
|
||||||
|
|
||||||
QString fileStr;
|
QString fileStr;
|
||||||
// FIXME: define configuration file
|
// FIXME: define configuration file
|
||||||
@ -72,18 +72,10 @@ bool Netctl::readConfiguration()
|
|||||||
while (true) {
|
while (true) {
|
||||||
fileStr = QString(confFile.readLine());
|
fileStr = QString(confFile.readLine());
|
||||||
if (fileStr[0] != '#') {
|
if (fileStr[0] != '#') {
|
||||||
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) {
|
if (fileStr.contains(QString("=")))
|
||||||
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("EXTIP"))
|
configuration[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
|
||||||
checkExtIP = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
.remove(QString(" "))
|
||||||
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("CMD"))
|
.trimmed();
|
||||||
cmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
|
||||||
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("EXTIPCMD"))
|
|
||||||
extIpCmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
|
||||||
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("IPCMD"))
|
|
||||||
ipCmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
|
||||||
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("NETDIR"))
|
|
||||||
netDir = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (confFile.atEnd())
|
if (confFile.atEnd())
|
||||||
break;
|
break;
|
||||||
@ -107,7 +99,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
|||||||
QString value = QString("");
|
QString value = QString("");
|
||||||
|
|
||||||
if (source == QString("currentProfile")) {
|
if (source == QString("currentProfile")) {
|
||||||
command.start(cmd + QString(" list"));
|
command.start(configuration[QString("CMD")] + QString(" list"));
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
cmdOutput = command.readAllStandardOutput();
|
cmdOutput = command.readAllStandardOutput();
|
||||||
if (!cmdOutput.isEmpty()) {
|
if (!cmdOutput.isEmpty()) {
|
||||||
@ -121,8 +113,8 @@ bool Netctl::updateSourceEvent(const QString &source)
|
|||||||
setData(source, QString("value"), value);
|
setData(source, QString("value"), value);
|
||||||
}
|
}
|
||||||
else if (source == QString("extIp")) {
|
else if (source == QString("extIp")) {
|
||||||
if (checkExtIP == QString("true")) {
|
if (configuration[QString("EXTIP")] == QString("true")) {
|
||||||
command.start(extIpCmd);
|
command.start(configuration[QString("EXTIPCMD")]);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
cmdOutput = command.readAllStandardOutput();
|
cmdOutput = command.readAllStandardOutput();
|
||||||
if (!cmdOutput.isEmpty())
|
if (!cmdOutput.isEmpty())
|
||||||
@ -131,18 +123,18 @@ bool Netctl::updateSourceEvent(const QString &source)
|
|||||||
setData(source, QString("value"), value);
|
setData(source, QString("value"), value);
|
||||||
}
|
}
|
||||||
else if (source == QString("interfaces")) {
|
else if (source == QString("interfaces")) {
|
||||||
if (QDir(netDir).exists())
|
if (QDir(configuration[QString("NETDIR")]).exists())
|
||||||
value = QDir(netDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot).join(QString(","));
|
value = QDir(configuration[QString("NETDIR")]).entryList(QDir::Dirs | QDir::NoDotAndDotDot).join(QString(","));
|
||||||
setData(source, QString("value"), value);
|
setData(source, QString("value"), value);
|
||||||
}
|
}
|
||||||
else if (source == QString("intIp")) {
|
else if (source == QString("intIp")) {
|
||||||
if (QDir(netDir).exists()) {
|
if (QDir(configuration[QString("NETDIR")]).exists()) {
|
||||||
value = QString("127.0.0.1/8");
|
value = QString("127.0.0.1/8");
|
||||||
QStringList netDevices = QDir(netDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
QStringList netDevices = QDir(configuration[QString("NETDIR")]).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
for (int i=0; i<netDevices.count(); i++)
|
for (int i=0; i<netDevices.count(); i++)
|
||||||
if (netDevices[i] != QString("lo")) {
|
if (netDevices[i] != QString("lo")) {
|
||||||
cmdOutput = QString("");
|
cmdOutput = QString("");
|
||||||
command.start(ipCmd + QString(" addr show ") + netDevices[i]);
|
command.start(configuration[QString("IPCMD")] + QString(" addr show ") + netDevices[i]);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
cmdOutput = command.readAllStandardOutput();
|
cmdOutput = command.readAllStandardOutput();
|
||||||
if (!cmdOutput.isEmpty()) {
|
if (!cmdOutput.isEmpty()) {
|
||||||
@ -156,7 +148,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
|||||||
setData(source, QString("value"), value);
|
setData(source, QString("value"), value);
|
||||||
}
|
}
|
||||||
else if (source == QString("profiles")) {
|
else if (source == QString("profiles")) {
|
||||||
command.start(cmd + QString(" list"));
|
command.start(configuration[QString("CMD")] + QString(" list"));
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
cmdOutput = command.readAllStandardOutput();
|
cmdOutput = command.readAllStandardOutput();
|
||||||
QStringList list;
|
QStringList list;
|
||||||
@ -172,7 +164,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
|||||||
setData(source, QString("value"), value);
|
setData(source, QString("value"), value);
|
||||||
}
|
}
|
||||||
else if (source == QString("statusBool")) {
|
else if (source == QString("statusBool")) {
|
||||||
command.start(cmd + QString(" list"));
|
command.start(configuration[QString("CMD")] + QString(" list"));
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
cmdOutput = command.readAllStandardOutput();
|
cmdOutput = command.readAllStandardOutput();
|
||||||
value = QString("false");
|
value = QString("false");
|
||||||
@ -187,7 +179,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
|||||||
setData(source, QString("value"), value);
|
setData(source, QString("value"), value);
|
||||||
}
|
}
|
||||||
else if (source == QString("statusString")) {
|
else if (source == QString("statusString")) {
|
||||||
command.start(cmd + QString(" list"));
|
command.start(configuration[QString("CMD")] + QString(" list"));
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
cmdOutput = command.readAllStandardOutput();
|
cmdOutput = command.readAllStandardOutput();
|
||||||
QString currentProfile;
|
QString currentProfile;
|
||||||
@ -199,7 +191,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
command.start(cmd + QString(" status ") + currentProfile);
|
command.start(configuration[QString("CMD")] + QString(" status ") + currentProfile);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
cmdOutput = command.readAllStandardOutput();
|
cmdOutput = command.readAllStandardOutput();
|
||||||
if (!cmdOutput.isEmpty()) {
|
if (!cmdOutput.isEmpty()) {
|
||||||
|
@ -36,16 +36,17 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// configuration
|
// configuration
|
||||||
// enable check external IP
|
QMap<QString, QString> configuration;
|
||||||
QString checkExtIP;
|
// // enable check external IP
|
||||||
// path to netctl command
|
// QString checkExtIP;
|
||||||
QString cmd;
|
// // path to netctl command
|
||||||
// command to check external IP
|
// QString cmd;
|
||||||
QString extIpCmd;
|
// // command to check external IP
|
||||||
// path to ip command
|
// QString extIpCmd;
|
||||||
QString ipCmd;
|
// // path to ip command
|
||||||
// path to directory with network device configuration
|
// QString ipCmd;
|
||||||
QString netDir;
|
// // path to directory with network device configuration
|
||||||
|
// QString netDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user