mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-07 11:05:45 +00:00
add control interface
This commit is contained in:
108
sources/gui/src/controladaptor.cpp
Normal file
108
sources/gui/src/controladaptor.cpp
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "controladaptor.h"
|
||||||
|
|
||||||
|
|
||||||
|
ControlAdaptor::ControlAdaptor(QObject *parent, const QMap<QString, QString> configuration)
|
||||||
|
: QDBusAbstractAdaptor(parent)
|
||||||
|
{
|
||||||
|
netctlCommand = new Netctl(false, configuration);
|
||||||
|
netctlProfile = new NetctlProfile(false, configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ControlAdaptor::~ControlAdaptor()
|
||||||
|
{
|
||||||
|
delete netctlCommand;
|
||||||
|
delete netctlProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// netctlCommand
|
||||||
|
bool ControlAdaptor::autoDisableAll()
|
||||||
|
{
|
||||||
|
return netctlCommand->autoDisableAllProfiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlAdaptor::autoEnable(const QString profile)
|
||||||
|
{
|
||||||
|
return netctlCommand->autoEnableProfile(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlAdaptor::autoEnableAll()
|
||||||
|
{
|
||||||
|
return netctlCommand->autoEnableAllProfiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlAdaptor::autoStart(const QString profile)
|
||||||
|
{
|
||||||
|
return netctlCommand->autoStartProfile(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlAdaptor::autoServiceEnable()
|
||||||
|
{
|
||||||
|
return netctlCommand->autoEnableService();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlAdaptor::autoServiceRestart()
|
||||||
|
{
|
||||||
|
return netctlCommand->autoRestartService();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlAdaptor::autoServiceStart()
|
||||||
|
{
|
||||||
|
return netctlCommand->autoStartService();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlAdaptor::Enable(const QString profile)
|
||||||
|
{
|
||||||
|
return netctlCommand->enableProfile(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlAdaptor::Restart(const QString profile)
|
||||||
|
{
|
||||||
|
return netctlCommand->restartProfile(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlAdaptor::Start(const QString profile)
|
||||||
|
{
|
||||||
|
return netctlCommand->startProfile(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlAdaptor::SwitchTo(const QString profile)
|
||||||
|
{
|
||||||
|
return netctlCommand->switchToProfile(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// netctlProfile
|
||||||
|
bool ControlAdaptor::Remove(const QString profile)
|
||||||
|
{
|
||||||
|
return netctlProfile->removeProfile(profile);
|
||||||
|
}
|
58
sources/gui/src/controladaptor.h
Normal file
58
sources/gui/src/controladaptor.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONTROLADAPTOR_H
|
||||||
|
#define CONTROLADAPTOR_H
|
||||||
|
|
||||||
|
#include <QDBusAbstractAdaptor>
|
||||||
|
|
||||||
|
#include <netctlgui/netctlgui.h>
|
||||||
|
|
||||||
|
|
||||||
|
class ControlAdaptor : public QDBusAbstractAdaptor
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.netctlgui")
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ControlAdaptor(QObject *parent = 0,
|
||||||
|
const QMap<QString, QString> configuration = QMap<QString, QString>());
|
||||||
|
~ControlAdaptor();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
// netctlCommand
|
||||||
|
bool autoDisableAll();
|
||||||
|
bool autoEnable(const QString profile);
|
||||||
|
bool autoEnableAll();
|
||||||
|
bool autoStart(const QString profile);
|
||||||
|
bool autoServiceEnable();
|
||||||
|
bool autoServiceRestart();
|
||||||
|
bool autoServiceStart();
|
||||||
|
bool Enable(const QString profile);
|
||||||
|
bool Restart(const QString profile);
|
||||||
|
bool Start(const QString profile);
|
||||||
|
bool SwitchTo(const QString profile);
|
||||||
|
// netctlProfile
|
||||||
|
bool Remove(const QString profile);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Netctl *netctlCommand;
|
||||||
|
NetctlProfile *netctlProfile;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* CONTROLADAPTOR_H */
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "aboutwindow.h"
|
#include "aboutwindow.h"
|
||||||
#include "bridgewidget.h"
|
#include "bridgewidget.h"
|
||||||
|
#include "controladaptor.h"
|
||||||
#include "errorwindow.h"
|
#include "errorwindow.h"
|
||||||
#include "ethernetwidget.h"
|
#include "ethernetwidget.h"
|
||||||
#include "generalwidget.h"
|
#include "generalwidget.h"
|
||||||
@ -370,6 +371,10 @@ void MainWindow::createDBusSession()
|
|||||||
new NetctlAdaptor(this, configuration),
|
new NetctlAdaptor(this, configuration),
|
||||||
QDBusConnection::ExportAllContents))
|
QDBusConnection::ExportAllContents))
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register library object";
|
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register library object";
|
||||||
|
if (!bus.registerObject(QString(DBUS_CONTROL_PATH),
|
||||||
|
new ControlAdaptor(this, configuration),
|
||||||
|
QDBusConnection::ExportAllContents))
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register control object";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#define PROJECT_BUILD_PLASMOID "@BUILD_PLASMOID@"
|
#define PROJECT_BUILD_PLASMOID "@BUILD_PLASMOID@"
|
||||||
#define PROJECT_USE_QT5 "@USE_QT5@"
|
#define PROJECT_USE_QT5 "@USE_QT5@"
|
||||||
|
|
||||||
|
#define DBUS_CONTROL_PATH "/ctrl"
|
||||||
#define DBUS_INTERFACE "org.freedesktop.netctlgui"
|
#define DBUS_INTERFACE "org.freedesktop.netctlgui"
|
||||||
#define DBUS_LIB_PATH "/netctl"
|
#define DBUS_LIB_PATH "/netctl"
|
||||||
#define DBUS_OBJECT_PATH "/netctlgui"
|
#define DBUS_OBJECT_PATH "/netctlgui"
|
||||||
|
Reference in New Issue
Block a user