diff --git a/sources/gui/src/mainwindow.cpp b/sources/gui/src/mainwindow.cpp index e34358f..b340b06 100644 --- a/sources/gui/src/mainwindow.cpp +++ b/sources/gui/src/mainwindow.cpp @@ -363,11 +363,11 @@ void MainWindow::createDBusSession() if (!bus.registerService(QString(DBUS_SERVICE))) if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register service"; if (!bus.registerObject(QString(DBUS_OBJECT_PATH), - new NetctlGuiAdaptor(this, debug), + new NetctlGuiAdaptor(this), QDBusConnection::ExportAllContents)) if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register GUI object"; if (!bus.registerObject(QString(DBUS_LIB_PATH), - new NetctlAdaptor(this, debug, configuration), + new NetctlAdaptor(this, configuration), QDBusConnection::ExportAllContents)) if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register library object"; } diff --git a/sources/gui/src/netctladaptor.cpp b/sources/gui/src/netctladaptor.cpp index ad5089e..e2b2a93 100644 --- a/sources/gui/src/netctladaptor.cpp +++ b/sources/gui/src/netctladaptor.cpp @@ -16,33 +16,139 @@ ***************************************************************************/ -#include - -#include #include "netctladaptor.h" -NetctlAdaptor::NetctlAdaptor(QObject *parent, const bool debugCmd, const QMap configuration) - : QDBusAbstractAdaptor(parent), - debug(debugCmd) +NetctlAdaptor::NetctlAdaptor(QObject *parent, const QMap configuration) + : QDBusAbstractAdaptor(parent) { - netctlCommand = new Netctl(debug, configuration); - netctlProfile = new NetctlProfile(debug, configuration); - wpaCommand = new WpaSup(debug, configuration); + netctlCommand = new Netctl(false, configuration); + netctlProfile = new NetctlProfile(false, configuration); + wpaCommand = new WpaSup(false, configuration); } NetctlAdaptor::~NetctlAdaptor() { - if (debug) qDebug() << "[NetctlAdaptor]" << "[~NetctlAdaptor]"; - delete netctlCommand; delete netctlProfile; delete wpaCommand; } -QString NetctlAdaptor::Information() +// netctlCommand +QString NetctlAdaptor::ActiveProfile() { - if (debug) qDebug() << "[NetctlAdaptor]" << "[Information]"; + if (netctlCommand->isNetctlAutoRunning()) + return netctlCommand->autoGetActiveProfile(); + else + return netctlCommand->getActiveProfile(); +} + + +QString NetctlAdaptor::ActiveProfileStatus() +{ + if (netctlCommand->isNetctlAutoRunning()) + return QString("netctl-auto"); + else + return netctlCommand->getProfileStatus(ActiveProfile()); +} + + +bool NetctlAdaptor::autoIsProfileActive(const QString profile) +{ + return netctlCommand->autoIsProfileActive(profile); +} + + +bool NetctlAdaptor::autoIsProfileEnabled(const QString profile) +{ + return netctlCommand->autoIsProfileEnabled(profile); +} + + +QStringList NetctlAdaptor::Information() +{ + QStringList output; + output.append(QString("Profile: %1").arg(ActiveProfile())); + output.append(QString("Status: %1").arg(ActiveProfileStatus())); + + return output; +} + + +bool NetctlAdaptor::isProfileActive(const QString profile) +{ + return netctlCommand->isProfileActive(profile); +} + + +bool NetctlAdaptor::isProfileEnabled(const QString profile) +{ + return netctlCommand->isProfileEnabled(profile); +} + + +QStringList NetctlAdaptor::ProfileList() +{ + QList profilesInfo; + if (netctlCommand->isNetctlAutoRunning()) + profilesInfo = netctlCommand->getProfileListFromNetctlAuto(); + else + profilesInfo = netctlCommand->getProfileList(); + QStringList info; + for (int i=0; i settings = netctlProfile->getSettingsFromProfile(profile); + QStringList settingsList; + for (int i=0; i configuration = QMap()); ~NetctlAdaptor(); public slots: - QString Information(); + // netctlCommand + QString ActiveProfile(); + QString ActiveProfileStatus(); + bool autoIsProfileActive(const QString profile); + bool autoIsProfileEnabled(const QString profile); + QStringList Information(); + bool isProfileActive(const QString profile); + bool isProfileEnabled(const QString profile); + QStringList ProfileList(); + // netctlProfile + QStringList Profile(const QString profile); + QString ProfileValue(const QString profile, const QString key); + // wpaCommand + QString ProfileByEssid(const QString essid); + QStringList WiFi(); private: - bool debug; Netctl *netctlCommand; NetctlProfile *netctlProfile; WpaSup *wpaCommand; diff --git a/sources/gui/src/netctlguiadaptor.cpp b/sources/gui/src/netctlguiadaptor.cpp index 2e2ca7a..1d48b5b 100644 --- a/sources/gui/src/netctlguiadaptor.cpp +++ b/sources/gui/src/netctlguiadaptor.cpp @@ -16,15 +16,12 @@ ***************************************************************************/ -#include - #include "mainwindow.h" #include "netctlguiadaptor.h" -NetctlGuiAdaptor::NetctlGuiAdaptor(MainWindow *parent, const bool debugCmd) +NetctlGuiAdaptor::NetctlGuiAdaptor(MainWindow *parent) : QDBusAbstractAdaptor(parent), - debug(debugCmd), mainWindow(parent) { } @@ -32,14 +29,11 @@ NetctlGuiAdaptor::NetctlGuiAdaptor(MainWindow *parent, const bool debugCmd) NetctlGuiAdaptor::~NetctlGuiAdaptor() { - if (debug) qDebug() << "[NetctlGuiAdaptor]" << "[~NetctlGuiAdaptor]"; } bool NetctlGuiAdaptor::Close() { - if (debug) qDebug() << "[NetctlGuiAdaptor]" << "[Close]"; - mainWindow->closeMainWindow(); return true; } @@ -47,16 +41,12 @@ bool NetctlGuiAdaptor::Close() QString NetctlGuiAdaptor::Information() { - if (debug) qDebug() << "[NetctlGuiAdaptor]" << "[Information]"; - return mainWindow->getInformation(); } bool NetctlGuiAdaptor::RestoreWindow() { - if (debug) qDebug() << "[NetctlGuiAdaptor]" << "[RestoreWindow]"; - mainWindow->show(); return true; } @@ -64,16 +54,12 @@ bool NetctlGuiAdaptor::RestoreWindow() QStringList NetctlGuiAdaptor::Settings() { - if (debug) qDebug() << "[NetctlGuiAdaptor]" << "[Settings]"; - return mainWindow->getSettings(); } bool NetctlGuiAdaptor::ShowAbout() { - if (debug) qDebug() << "[NetctlGuiAdaptor]" << "[ShowAbout]"; - mainWindow->showAboutWindow(); return true; } @@ -81,8 +67,6 @@ bool NetctlGuiAdaptor::ShowAbout() bool NetctlGuiAdaptor::ShowMain() { - if (debug) qDebug() << "[NetctlGuiAdaptor]" << "[ShowMain]"; - mainWindow->showMainWindow(); return true; } @@ -90,8 +74,6 @@ bool NetctlGuiAdaptor::ShowMain() bool NetctlGuiAdaptor::ShowNetctlAuto() { - if (debug) qDebug() << "[NetctlGuiAdaptor]" << "[ShowNetctlAuto]"; - mainWindow->showNetctlAutoWindow(); return true; } @@ -99,8 +81,6 @@ bool NetctlGuiAdaptor::ShowNetctlAuto() bool NetctlGuiAdaptor::ShowSettings() { - if (debug) qDebug() << "[NetctlGuiAdaptor]" << "[ShowSettings]"; - mainWindow->showSettingsWindow(); return true; } diff --git a/sources/gui/src/netctlguiadaptor.h b/sources/gui/src/netctlguiadaptor.h index 6f838ad..ec5ef78 100644 --- a/sources/gui/src/netctlguiadaptor.h +++ b/sources/gui/src/netctlguiadaptor.h @@ -27,11 +27,10 @@ class MainWindow; class NetctlGuiAdaptor : public QDBusAbstractAdaptor { Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.netctlgui.netctlgui") + Q_CLASSINFO("D-Bus Interface", "org.freedesktop.netctlgui") public: - explicit NetctlGuiAdaptor(MainWindow *parent = 0, - const bool debugCmd = false); + explicit NetctlGuiAdaptor(MainWindow *parent = 0); ~NetctlGuiAdaptor(); public slots: @@ -45,7 +44,6 @@ public slots: bool ShowSettings(); private: - bool debug; MainWindow *mainWindow; }; diff --git a/sources/netctlgui/src/netctlinteract.cpp b/sources/netctlgui/src/netctlinteract.cpp index 002c8d4..ad7fc42 100644 --- a/sources/netctlgui/src/netctlinteract.cpp +++ b/sources/netctlgui/src/netctlinteract.cpp @@ -336,11 +336,11 @@ bool Netctl::autoIsProfileEnabled(const QString profile) if (debug) qDebug() << "[Netctl]" << "[autoIsProfileEnabled]"; if (debug) qDebug() << "[Netctl]" << "[autoIsProfileEnabled]" << ":" << "Profile" << profile; - bool status = true; + bool status = false; QList profiles = getProfileListFromNetctlAuto(); for (int i=0; i