mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-07 11:05:45 +00:00
end work on interfaces
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
# set files
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp)
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp)
|
||||
file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.h)
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <QTextCodec>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <listmap/listmap.h>
|
||||
|
||||
#include "netctlhelper.h"
|
||||
#include "version.h"
|
||||
|
||||
@ -80,11 +82,7 @@ QStringList ControlAdaptor::FindSettings()
|
||||
for (int i=0; i<librarySettings.keys().count(); i++)
|
||||
configuration[librarySettings.keys()[i]] = librarySettings[librarySettings.keys()[i]];
|
||||
|
||||
QStringList settingsList;
|
||||
for (int i=0; i<configuration.keys().count(); i++)
|
||||
settingsList.append(QString("%1==%2").arg(configuration.keys()[i]).arg(configuration[configuration.keys()[i]]));
|
||||
|
||||
return settingsList;
|
||||
return mapToList(configuration);
|
||||
}
|
||||
|
||||
|
||||
@ -229,14 +227,7 @@ bool ControlAdaptor::SwitchTo(const QString profile)
|
||||
// netctlProfile
|
||||
bool ControlAdaptor::Create(const QString profile, const QStringList settingsList)
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
for (int i=0; i<settingsList.count(); i++) {
|
||||
if (!settingsList[i].contains(QString("=="))) continue;
|
||||
QString key = settingsList[i].split(QString("=="))[0];
|
||||
QString value = settingsList[i].split(QString("=="))[1];
|
||||
settings[key] = value;
|
||||
}
|
||||
QString temporaryProfile = netctlProfile->createProfile(profile, settings);
|
||||
QString temporaryProfile = netctlProfile->createProfile(profile, listToMap(settingsList));
|
||||
|
||||
return netctlProfile->copyProfile(temporaryProfile);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public slots:
|
||||
// wpaCommand
|
||||
QString CurrentWiFi();
|
||||
QStringList VerboseWiFi();
|
||||
Q_DECL_DEPRECATED QStringList WiFi();
|
||||
QStringList WiFi();
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <QTextCodec>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <listmap/listmap.h>
|
||||
|
||||
#include "netctlhelper.h"
|
||||
#include "version.h"
|
||||
|
||||
@ -38,6 +40,7 @@ InterfaceAdaptor::~InterfaceAdaptor()
|
||||
}
|
||||
|
||||
|
||||
// control slots
|
||||
int InterfaceAdaptor::autoEnable(const QString profile)
|
||||
{
|
||||
return netctlInterface->autoEnableProfile(profile);
|
||||
@ -46,15 +49,7 @@ int InterfaceAdaptor::autoEnable(const QString profile)
|
||||
|
||||
int InterfaceAdaptor::Create(const QString profile, const QStringList settingsList)
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
for (int i=0; i<settingsList.count(); i++) {
|
||||
if (!settingsList[i].contains(QString("=="))) continue;
|
||||
QString key = settingsList[i].split(QString("=="))[0];
|
||||
QString value = settingsList[i].split(QString("=="))[1];
|
||||
settings[key] = value;
|
||||
}
|
||||
|
||||
return netctlInterface->createProfile(profile, settings);
|
||||
return netctlInterface->createProfile(profile, listToMap(settingsList));
|
||||
}
|
||||
|
||||
|
||||
@ -66,15 +61,7 @@ int InterfaceAdaptor::Enable(const QString profile)
|
||||
|
||||
int InterfaceAdaptor::Essid(const QString essid, QStringList settingsList)
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
for (int i=0; i<settingsList.count(); i++) {
|
||||
if (!settingsList[i].contains(QString("=="))) continue;
|
||||
QString key = settingsList[i].split(QString("=="))[0];
|
||||
QString value = settingsList[i].split(QString("=="))[1];
|
||||
settings[key] = value;
|
||||
}
|
||||
|
||||
return netctlInterface->connectToEssid(essid, settings);
|
||||
return netctlInterface->connectToEssid(essid, listToMap(settingsList));
|
||||
}
|
||||
|
||||
|
||||
@ -84,6 +71,12 @@ int InterfaceAdaptor::KnownEssid(const QString essid)
|
||||
}
|
||||
|
||||
|
||||
int InterfaceAdaptor::Remove(const QString profile)
|
||||
{
|
||||
return netctlInterface->removeProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
int InterfaceAdaptor::Restart(const QString profile)
|
||||
{
|
||||
return netctlInterface->restartProfile(profile);
|
||||
@ -110,13 +103,55 @@ int InterfaceAdaptor::SwitchTo(const QString profile)
|
||||
|
||||
int InterfaceAdaptor::UnknownEssid(const QString essid, QStringList settingsList)
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
for (int i=0; i<settingsList.count(); i++) {
|
||||
if (!settingsList[i].contains(QString("=="))) continue;
|
||||
QString key = settingsList[i].split(QString("=="))[0];
|
||||
QString value = settingsList[i].split(QString("=="))[1];
|
||||
settings[key] = value;
|
||||
return netctlInterface->connectToUnknownEssid(essid, listToMap(settingsList));
|
||||
}
|
||||
|
||||
|
||||
// information
|
||||
QStringList InterfaceAdaptor::Information()
|
||||
{
|
||||
netctlInformation information = netctlInterface->information();
|
||||
QStringList info;
|
||||
info.append(QString::number(information.netctlAuto));
|
||||
|
||||
QList<netctlProfileInfo> profiles = information.netctlProfiles;
|
||||
profiles.append(information.netctlAutoProfiles);
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
QStringList profileInfo;
|
||||
profileInfo.append(profiles[i].name);
|
||||
profileInfo.append(profiles[i].description);
|
||||
profileInfo.append(profiles[i].type);
|
||||
profileInfo.append(profiles[i].interface);
|
||||
profileInfo.append(profiles[i].essid);
|
||||
profileInfo.append(QString::number(profiles[i].active));
|
||||
profileInfo.append(QString::number(profiles[i].enabled));
|
||||
profileInfo.append(QString::number(profiles[i].netctlAuto));
|
||||
info.append(profileInfo.join(QChar('|')));
|
||||
}
|
||||
|
||||
return netctlInterface->connectToUnknownEssid(essid, settings);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
QStringList InterfaceAdaptor::Profile(const QString profile)
|
||||
{
|
||||
QMap<QString, QString> settings = netctlInterface->profileSettings(profile);
|
||||
|
||||
return mapToList(settings);
|
||||
}
|
||||
|
||||
|
||||
QStringList InterfaceAdaptor::Status()
|
||||
{
|
||||
netctlCurrent current = netctlInterface->status();
|
||||
QStringList info;
|
||||
info.append(QString::number(current.netctlAuto));
|
||||
info.append(current.profiles.join(QChar('|')));
|
||||
info.append(current.current.join(QChar('|')));
|
||||
QStringList enables;
|
||||
for (int i=0; i<current.enables.count(); i++)
|
||||
enables.append(QString::number(current.enables[i]));
|
||||
info.append(enables.join(QChar('|')));
|
||||
|
||||
return info;
|
||||
}
|
||||
|
@ -35,17 +35,22 @@ public:
|
||||
~InterfaceAdaptor();
|
||||
|
||||
public slots:
|
||||
// interface
|
||||
// control slots
|
||||
int autoEnable(const QString profile);
|
||||
int Create(const QString profile, const QStringList settingsList);
|
||||
int Enable(const QString profile);
|
||||
int Essid(const QString essid, QStringList settingsList);
|
||||
int KnownEssid(const QString essid);
|
||||
int Remove(const QString profile);
|
||||
int Restart(const QString profile);
|
||||
int Start(const QString profile);
|
||||
int StopAll();
|
||||
int SwitchTo(const QString profile);
|
||||
int UnknownEssid(const QString essid, QStringList settingsList);
|
||||
// information
|
||||
QStringList Information();
|
||||
QStringList Profile(const QString profile);
|
||||
QStringList Status();
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "netctladaptor.h"
|
||||
|
||||
#include <listmap/listmap.h>
|
||||
|
||||
|
||||
NetctlAdaptor::NetctlAdaptor(QObject *parent, const bool debugCmd, const QMap<QString, QString> configuration)
|
||||
: QDBusAbstractAdaptor(parent),
|
||||
@ -142,6 +144,7 @@ QStringList NetctlAdaptor::netctlVerboseProfileList()
|
||||
profileInfo.append(profilesInfo[i].essid);
|
||||
profileInfo.append(QString::number(profilesInfo[i].active));
|
||||
profileInfo.append(QString::number(profilesInfo[i].enabled));
|
||||
profileInfo.append(QString::number(profilesInfo[i].netctlAuto));
|
||||
info.append(profileInfo.join(QChar('|')));
|
||||
}
|
||||
|
||||
@ -187,6 +190,7 @@ QStringList NetctlAdaptor::VerboseProfileList()
|
||||
profileInfo.append(profilesInfo[i].essid);
|
||||
profileInfo.append(QString::number(profilesInfo[i].active));
|
||||
profileInfo.append(QString::number(profilesInfo[i].enabled));
|
||||
profileInfo.append(QString::number(profilesInfo[i].netctlAuto));
|
||||
info.append(profileInfo.join(QChar('|')));
|
||||
}
|
||||
|
||||
@ -198,11 +202,8 @@ QStringList NetctlAdaptor::VerboseProfileList()
|
||||
QStringList NetctlAdaptor::Profile(const QString profile)
|
||||
{
|
||||
QMap<QString, QString> settings = netctlProfile->getSettingsFromProfile(profile);
|
||||
QStringList settingsList;
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
settingsList.append(QString("%1==%2").arg(settings.keys()[i]).arg(settings[settings.keys()[i]]));
|
||||
|
||||
return settingsList;
|
||||
return mapToList(settings);
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ public slots:
|
||||
QString netctlActiveProfile();
|
||||
QStringList netctlProfileList();
|
||||
QStringList netctlVerboseProfileList();
|
||||
Q_DECL_DEPRECATED QStringList ProfileList();
|
||||
QStringList ProfileList();
|
||||
QStringList VerboseProfileList();
|
||||
// netctlProfile
|
||||
QStringList Profile(const QString profile);
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QSettings>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <listmap/listmap.h>
|
||||
#include <netctlgui/netctlgui.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
@ -57,11 +58,7 @@ QStringList NetctlHelper::printSettings()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList settingsList;
|
||||
for (int i=0; i<configuration.keys().count(); i++)
|
||||
settingsList.append(QString("%1==%2").arg(configuration.keys()[i]).arg(configuration[configuration.keys()[i]]));
|
||||
|
||||
return settingsList;
|
||||
return mapToList(configuration);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user