mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
edit dbus calls
TODO edit dbus call in netctlautowindow (create callbacks too)
This commit is contained in:
parent
25ca2ef1d9
commit
de0c1f208d
@ -8,7 +8,7 @@ ProjectRootRelative=./
|
|||||||
|
|
||||||
[CMake][CMake Build Directory 0]
|
[CMake][CMake Build Directory 0]
|
||||||
Build Directory Path=file:///home/arcanis/Documents/github/netctl-gui/build
|
Build Directory Path=file:///home/arcanis/Documents/github/netctl-gui/build
|
||||||
Build Type=Release
|
Build Type=Debug
|
||||||
CMake Binary=file:///usr/bin/cmake
|
CMake Binary=file:///usr/bin/cmake
|
||||||
Environment Profile=
|
Environment Profile=
|
||||||
Extra Arguments=
|
Extra Arguments=
|
||||||
|
@ -23,12 +23,11 @@
|
|||||||
|
|
||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
|
|
||||||
const bool debug)
|
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
QList<netctlProfileInfo> profileInfo;
|
QList<netctlProfileInfo> profileInfo;
|
||||||
if (raw.isEmpty()) return profileInfo;
|
if (raw.isEmpty()) return profileInfo;
|
||||||
QStringList list = raw[0].toStringList();
|
QStringList list = raw[0].toStringList();
|
||||||
@ -47,11 +46,8 @@ QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
|
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw)
|
||||||
const bool debug)
|
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
QList<netctlWifiInfo> wifiInfo;
|
QList<netctlWifiInfo> wifiInfo;
|
||||||
if (raw.isEmpty()) return wifiInfo;
|
if (raw.isEmpty()) return wifiInfo;
|
||||||
QStringList list = raw[0].toStringList();
|
QStringList list = raw[0].toStringList();
|
||||||
@ -71,28 +67,61 @@ QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
QList<QVariant> sendRequestToHelper(const QString path, const QString cmd,
|
||||||
const QString interface, const QString cmd,
|
const QList<QVariant> args, const bool debug)
|
||||||
const QList<QVariant> args, const bool system,
|
|
||||||
const bool debug)
|
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Service" << service;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Path" << path;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Interface" << interface;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "is system bus" << system;
|
|
||||||
|
|
||||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
QDBusConnection bus = QDBusConnection::systemBus();
|
||||||
if (system)
|
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, path,
|
||||||
bus = QDBusConnection::systemBus();
|
DBUS_HELPER_INTERFACE, cmd);
|
||||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
|
||||||
if (!args.isEmpty()) request.setArguments(args);
|
if (!args.isEmpty()) request.setArguments(args);
|
||||||
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||||
QList<QVariant> arguments = response.arguments();
|
QList<QVariant> arguments = response.arguments();
|
||||||
if (arguments.count() == 0)
|
if (arguments.isEmpty())
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||||
|
|
||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QVariant> sendRequestToCtrl(const QString cmd, const bool debug)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||||
|
|
||||||
|
return sendRequestToCtrlWithArgs(cmd, QList<QVariant>(), debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QVariant> sendRequestToCtrlWithArgs(const QString cmd, const QList<QVariant> args,
|
||||||
|
const bool debug)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||||
|
|
||||||
|
return sendRequestToHelper(DBUS_CTRL_PATH, cmd, args, debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QVariant> sendRequestToLib(const QString cmd, const bool debug)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||||
|
|
||||||
|
return sendRequestToLibWithArgs(cmd, QList<QVariant>(), debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QVariant> sendRequestToLibWithArgs(const QString cmd, const QList<QVariant> args,
|
||||||
|
const bool debug)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||||
|
|
||||||
|
return sendRequestToHelper(DBUS_LIB_PATH, cmd, args, debug);
|
||||||
|
}
|
||||||
|
@ -23,14 +23,16 @@
|
|||||||
|
|
||||||
#include <netctlgui/netctlgui.h>
|
#include <netctlgui/netctlgui.h>
|
||||||
|
|
||||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
|
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw);
|
||||||
|
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw);
|
||||||
|
QList<QVariant> sendRequestToHelper(const QString path, const QString cmd,
|
||||||
|
const QList<QVariant> args, const bool debug = false);
|
||||||
|
QList<QVariant> sendRequestToCtrl(const QString cmd, const bool debug = false);
|
||||||
|
QList<QVariant> sendRequestToCtrlWithArgs(const QString cmd, const QList<QVariant> args,
|
||||||
const bool debug = false);
|
const bool debug = false);
|
||||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
|
QList<QVariant> sendRequestToLib(const QString cmd, const bool debug = false);
|
||||||
|
QList<QVariant> sendRequestToLibWithArgs(const QString cmd, const QList<QVariant> args,
|
||||||
const bool debug = false);
|
const bool debug = false);
|
||||||
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
|
||||||
const QString interface, const QString cmd,
|
|
||||||
const QList<QVariant> args = QList<QVariant>(),
|
|
||||||
const bool system = true, const bool debug = false);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* DBUSOPERATION_H */
|
#endif /* DBUSOPERATION_H */
|
||||||
|
@ -43,7 +43,7 @@ bool existingSessionOperation(const QString operation)
|
|||||||
QDBusMessage response = bus.call(request);
|
QDBusMessage response = bus.call(request);
|
||||||
QList<QVariant> arguments = response.arguments();
|
QList<QVariant> arguments = response.arguments();
|
||||||
|
|
||||||
return (!arguments.isEmpty() && bool(arguments[0].toInt()));
|
return (!arguments.isEmpty() && arguments[0].toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,18 +169,14 @@ void MainWindow::updateMainTab()
|
|||||||
QList<netctlProfileInfo> profiles;
|
QList<netctlProfileInfo> profiles;
|
||||||
bool netctlAutoStatus = false;
|
bool netctlAutoStatus = false;
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
QList<QVariant> responce = sendRequestToLib(QString("isNetctlAutoActive"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
|
|
||||||
QList<QVariant>(), true, debug);
|
|
||||||
if (responce.isEmpty()) {
|
if (responce.isEmpty()) {
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
useHelper = false;
|
useHelper = false;
|
||||||
return updateMainTab();
|
return updateMainTab();
|
||||||
}
|
}
|
||||||
netctlAutoStatus = responce[0].toBool();
|
netctlAutoStatus = responce[0].toBool();
|
||||||
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
profiles = parseOutputNetctl(sendRequestToLib(QString("ProfileList"), debug));
|
||||||
DBUS_HELPER_INTERFACE, QString("ProfileList"),
|
|
||||||
QList<QVariant>(), true, debug), debug);
|
|
||||||
} else {
|
} else {
|
||||||
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
||||||
profiles = netctlCommand->getProfileList();
|
profiles = netctlCommand->getProfileList();
|
||||||
@ -272,9 +268,7 @@ void MainWindow::updateWifiTab()
|
|||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
QList<netctlWifiInfo> scanResults;
|
QList<netctlWifiInfo> scanResults;
|
||||||
if (useHelper)
|
if (useHelper)
|
||||||
scanResults = parseOutputWifi(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
scanResults = parseOutputWifi(sendRequestToCtrl(QString("WiFi"), debug));
|
||||||
DBUS_HELPER_INTERFACE, QString("WiFi"),
|
|
||||||
QList<QVariant>(), true, debug), debug);
|
|
||||||
else
|
else
|
||||||
scanResults = wpaCommand->scanWifi();
|
scanResults = wpaCommand->scanWifi();
|
||||||
|
|
||||||
@ -464,9 +458,7 @@ void MainWindow::mainTabRemoveProfile()
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrlWithArgs(QString("Remove"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Remove"),
|
|
||||||
args, true, debug);
|
|
||||||
if (responce.isEmpty()) {
|
if (responce.isEmpty()) {
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
useHelper = false;
|
useHelper = false;
|
||||||
@ -538,9 +530,7 @@ void MainWindow::mainTabStopAllProfiles()
|
|||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
bool status = false;
|
bool status = false;
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrl(QString("StolAll"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("StopAll"),
|
|
||||||
QList<QVariant>(), true, debug);
|
|
||||||
if (responce.isEmpty()) {
|
if (responce.isEmpty()) {
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
useHelper = false;
|
useHelper = false;
|
||||||
@ -608,9 +598,7 @@ void MainWindow::profileTabClear()
|
|||||||
ui->comboBox_profile->clear();
|
ui->comboBox_profile->clear();
|
||||||
QList<netctlProfileInfo> profiles;
|
QList<netctlProfileInfo> profiles;
|
||||||
if (useHelper)
|
if (useHelper)
|
||||||
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
profiles = parseOutputNetctl(sendRequestToLib(QString("ProfileList"), debug));
|
||||||
DBUS_HELPER_INTERFACE, QString("ProfileList"),
|
|
||||||
QList<QVariant>(), true, debug), debug);
|
|
||||||
else
|
else
|
||||||
profiles = netctlCommand->getProfileList();
|
profiles = netctlCommand->getProfileList();
|
||||||
for (int i=0; i<profiles.count(); i++)
|
for (int i=0; i<profiles.count(); i++)
|
||||||
@ -793,9 +781,7 @@ void MainWindow::profileTabCreateProfile()
|
|||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
args.append(settingsList);
|
args.append(settingsList);
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrlWithArgs(QString("Create"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Create"),
|
|
||||||
args, true, debug);
|
|
||||||
if (responce.isEmpty()) {
|
if (responce.isEmpty()) {
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
useHelper = false;
|
useHelper = false;
|
||||||
@ -826,9 +812,7 @@ void MainWindow::profileTabLoadProfile()
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToLibWithArgs(QString("Profile"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Profile"),
|
|
||||||
args, true, debug);
|
|
||||||
if (responce.isEmpty()) {
|
if (responce.isEmpty()) {
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
useHelper = false;
|
useHelper = false;
|
||||||
@ -893,9 +877,7 @@ void MainWindow::profileTabRemoveProfile()
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrlWithArgs(QString("Remove"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Remove"),
|
|
||||||
args, true, debug);
|
|
||||||
if (responce.isEmpty()) {
|
if (responce.isEmpty()) {
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
useHelper = false;
|
useHelper = false;
|
||||||
@ -996,9 +978,7 @@ void MainWindow::wifiTabStart()
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
QList<QVariant> responce = sendRequestToLibWithArgs(QString("ProfileByEssid"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("ProfileByEssid"),
|
|
||||||
args, true, debug);
|
|
||||||
if (responce.isEmpty()) {
|
if (responce.isEmpty()) {
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
useHelper = false;
|
useHelper = false;
|
||||||
|
@ -91,12 +91,8 @@ bool MainWindow::enableProfileSlot(const QString profile)
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
sendRequestToCtrlWithArgs(QString("Enable"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Enable"),
|
QList<QVariant> responce = sendRequestToLibWithArgs(QString("isProfileEnabled"), args, debug);
|
||||||
args, true, debug);
|
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
|
||||||
DBUS_HELPER_INTERFACE, QString("isProfileEnabled"),
|
|
||||||
args, true, debug);
|
|
||||||
if (responce.isEmpty())
|
if (responce.isEmpty())
|
||||||
current = netctlCommand->isProfileEnabled(profile);
|
current = netctlCommand->isProfileEnabled(profile);
|
||||||
else
|
else
|
||||||
@ -119,12 +115,8 @@ bool MainWindow::restartProfileSlot(const QString profile)
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
sendRequestToCtrlWithArgs(QString("Restart"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Restart"),
|
QList<QVariant> responce = sendRequestToLibWithArgs(QString("isProfileActive"), args, debug);
|
||||||
args, true, debug)[0].toBool();
|
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
|
||||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
|
||||||
args, true, debug);
|
|
||||||
if (responce.isEmpty())
|
if (responce.isEmpty())
|
||||||
current = netctlCommand->isProfileActive(profile);
|
current = netctlCommand->isProfileActive(profile);
|
||||||
else
|
else
|
||||||
@ -147,22 +139,14 @@ bool MainWindow::startProfileSlot(const QString profile)
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
QList<QVariant> responce = sendRequestToLib(QString("ActiveProfile"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("ActiveProfile"),
|
|
||||||
QList<QVariant>(), true, debug);
|
|
||||||
QStringList currentProfile;
|
QStringList currentProfile;
|
||||||
if (!responce.isEmpty()) currentProfile = responce[0].toString().split(QChar('|'));
|
if (!responce.isEmpty()) currentProfile = responce[0].toString().split(QChar('|'));
|
||||||
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
|
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
sendRequestToCtrlWithArgs(QString("Start"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Start"),
|
|
||||||
args, true, debug);
|
|
||||||
else
|
else
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
sendRequestToCtrlWithArgs(QString("SwitchTo"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("SwitchTo"),
|
responce = sendRequestToLibWithArgs(QString("isProfileActive"), args, debug);
|
||||||
args, true, debug);
|
|
||||||
responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
|
||||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
|
||||||
args, true, debug);
|
|
||||||
if (responce.isEmpty())
|
if (responce.isEmpty())
|
||||||
current = netctlCommand->isProfileActive(profile);
|
current = netctlCommand->isProfileActive(profile);
|
||||||
else
|
else
|
||||||
@ -185,9 +169,7 @@ bool MainWindow::stopAllProfilesSlot()
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (useHelper)
|
if (useHelper)
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
sendRequestToCtrl(QString("StolAll"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("StopAll"),
|
|
||||||
QList<QVariant>(), true, debug);
|
|
||||||
else
|
else
|
||||||
netctlCommand->stopAllProfiles();
|
netctlCommand->stopAllProfiles();
|
||||||
|
|
||||||
@ -202,9 +184,7 @@ bool MainWindow::switchToProfileSlot(const QString profile)
|
|||||||
|
|
||||||
bool netctlAutoStatus = false;
|
bool netctlAutoStatus = false;
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
QList<QVariant> responce = sendRequestToLib(QString("isNetctlAutoActive"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
|
|
||||||
QList<QVariant>(), true, debug);
|
|
||||||
if (!responce.isEmpty()) netctlAutoStatus = responce[0].toBool();
|
if (!responce.isEmpty()) netctlAutoStatus = responce[0].toBool();
|
||||||
} else
|
} else
|
||||||
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
||||||
@ -214,12 +194,8 @@ bool MainWindow::switchToProfileSlot(const QString profile)
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
sendRequestToCtrlWithArgs(QString("autoStart"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("autoStart"),
|
QList<QVariant> responce = sendRequestToLibWithArgs(QString("autoIsProfileActive"), args, debug);
|
||||||
args, true, debug);
|
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
|
||||||
DBUS_HELPER_INTERFACE, QString("autoIsProfileActive"),
|
|
||||||
args, true, debug);
|
|
||||||
if (responce.isEmpty())
|
if (responce.isEmpty())
|
||||||
current = netctlCommand->autoIsProfileActive(profile);
|
current = netctlCommand->autoIsProfileActive(profile);
|
||||||
else
|
else
|
||||||
@ -232,12 +208,8 @@ bool MainWindow::switchToProfileSlot(const QString profile)
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
sendRequestToCtrlWithArgs(QString("SwitchTo"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("SwitchTo"),
|
QList<QVariant> responce = sendRequestToLibWithArgs(QString("isProfileActive"), args, debug);
|
||||||
args, true, debug);
|
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
|
||||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
|
||||||
args, true, debug);
|
|
||||||
if (responce.isEmpty())
|
if (responce.isEmpty())
|
||||||
current = netctlCommand->isProfileActive(profile);
|
current = netctlCommand->isProfileActive(profile);
|
||||||
else
|
else
|
||||||
@ -309,9 +281,7 @@ bool MainWindow::forceStopHelper()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrl(QString("Close"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Close"),
|
|
||||||
QList<QVariant>(), true, debug);
|
|
||||||
|
|
||||||
return !responce.isEmpty();
|
return !responce.isEmpty();
|
||||||
}
|
}
|
||||||
@ -436,9 +406,7 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
|
|||||||
if (passwdWid != nullptr) delete passwdWid;
|
if (passwdWid != nullptr) delete passwdWid;
|
||||||
QStringList interfaces;
|
QStringList interfaces;
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
QList<QVariant> responce = sendRequestToLib(QString("WirelessInterfaces"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"),
|
|
||||||
QList<QVariant>(), true, debug);
|
|
||||||
if (responce.isEmpty())
|
if (responce.isEmpty())
|
||||||
interfaces = netctlCommand->getWirelessInterfaceList();
|
interfaces = netctlCommand->getWirelessInterfaceList();
|
||||||
else
|
else
|
||||||
@ -474,9 +442,7 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
|
|||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
args.append(settingsList);
|
args.append(settingsList);
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
sendRequestToCtrlWithArgs(QString("Create"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Create"),
|
|
||||||
args, true, debug);
|
|
||||||
} else {
|
} else {
|
||||||
QString profileTempName = netctlProfile->createProfile(profile, settings);
|
QString profileTempName = netctlProfile->createProfile(profile, settings);
|
||||||
netctlProfile->copyProfile(profileTempName);
|
netctlProfile->copyProfile(profileTempName);
|
||||||
@ -501,9 +467,7 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
sendRequestToCtrlWithArgs(QString("Remove"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Remove"),
|
|
||||||
args, true, debug);
|
|
||||||
} else
|
} else
|
||||||
netctlProfile->removeProfile(profile);
|
netctlProfile->removeProfile(profile);
|
||||||
break;
|
break;
|
||||||
|
@ -123,11 +123,14 @@ QStringList MainWindow::printInformation()
|
|||||||
output.append(QString("none"));
|
output.append(QString("none"));
|
||||||
output.append(QString("(none)"));
|
output.append(QString("(none)"));
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QStringList request = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
QList<QVariant> responce = sendRequestToLib(QString("Information"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Information"),
|
if (responce.isEmpty()) {
|
||||||
QList<QVariant>(), true, debug)[0].toStringList();
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
if (request.count() != 2) return output;
|
useHelper = false;
|
||||||
output = request;
|
return printInformation();
|
||||||
|
}
|
||||||
|
if (responce[0].toStringList().count() != 2) return output;
|
||||||
|
output = responce[0].toStringList();
|
||||||
} else {
|
} else {
|
||||||
if (netctlCommand->isNetctlAutoRunning()) {
|
if (netctlCommand->isNetctlAutoRunning()) {
|
||||||
output[0] = netctlCommand->autoGetActiveProfile();
|
output[0] = netctlCommand->autoGetActiveProfile();
|
||||||
@ -168,31 +171,34 @@ QStringList MainWindow::printTrayInformation()
|
|||||||
bool netctlAutoStatus = false;
|
bool netctlAutoStatus = false;
|
||||||
QList<netctlProfileInfo> profiles;
|
QList<netctlProfileInfo> profiles;
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
QList<QVariant> responce = sendRequestToLib(QString("ActiveProfile"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("ActiveProfile"),
|
if (responce.isEmpty()) {
|
||||||
QList<QVariant>(), true, debug)[0].toString();
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
useHelper = false;
|
||||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
|
return printTrayInformation();
|
||||||
QList<QVariant>(), true, debug)[0].toBool();
|
}
|
||||||
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
current = responce[0].toString();
|
||||||
DBUS_HELPER_INTERFACE, QString("ProfileList"),
|
responce = sendRequestToLib(QString("isNetctlAutoActive"), debug);
|
||||||
QList<QVariant>(), true, debug), debug);
|
if (responce.isEmpty()) {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
|
useHelper = false;
|
||||||
|
return printTrayInformation();
|
||||||
|
}
|
||||||
|
netctlAutoStatus = responce[0].toBool();
|
||||||
|
profiles = parseOutputNetctl(sendRequestToLib(QString("ProfileList"), debug));
|
||||||
if (netctlAutoStatus) {
|
if (netctlAutoStatus) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(current);
|
args.append(current);
|
||||||
enabled = QString::number(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
responce = sendRequestToLibWithArgs(QString("autoIsProfileEnabled"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("autoIsProfileEnabled"),
|
enabled = QString::number(!responce.isEmpty() && responce[0].toBool());
|
||||||
args, true, debug)[0].toBool());
|
|
||||||
} else {
|
} else {
|
||||||
QStringList currentProfiles = current.split(QChar('|'));
|
QStringList currentProfiles = current.split(QChar('|'));
|
||||||
QStringList enabledList;
|
QStringList enabledList;
|
||||||
for (int i=0; i<currentProfiles.count(); i++) {
|
for (int i=0; i<currentProfiles.count(); i++) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(currentProfiles[i]);
|
args.append(currentProfiles[i]);
|
||||||
enabledList.append(QString::number(
|
responce = sendRequestToLibWithArgs(QString("isProfileEnabled"), args, debug);
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
enabledList.append(QString::number(!responce.isEmpty() && responce[0].toBool()));
|
||||||
DBUS_HELPER_INTERFACE, QString("isProfileEnabled"),
|
|
||||||
args, true, debug)[0].toBool()));
|
|
||||||
enabled = enabledList.join(QChar('|'));
|
enabled = enabledList.join(QChar('|'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,11 +235,9 @@ bool MainWindow::isHelperActive()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrl(QString("Active"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Active"),
|
|
||||||
QList<QVariant>(), true, debug);
|
|
||||||
|
|
||||||
return (!responce.isEmpty() && bool(responce[0].toInt()));
|
return (!responce.isEmpty() && responce[0].toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -312,9 +316,7 @@ bool MainWindow::checkHelperStatus()
|
|||||||
|
|
||||||
if (useHelper) useHelper = isHelperActive();
|
if (useHelper) useHelper = isHelperActive();
|
||||||
if (useHelper)
|
if (useHelper)
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
sendRequestToCtrl(QString("Update"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("Update"),
|
|
||||||
QList<QVariant>(), true, debug);
|
|
||||||
else
|
else
|
||||||
configuration[QString("FORCE_SUDO")] = QString("true");
|
configuration[QString("FORCE_SUDO")] = QString("true");
|
||||||
if (isHelperServiceActive())
|
if (isHelperServiceActive())
|
||||||
|
@ -43,7 +43,7 @@ bool existingSessionOperation(const QString operation)
|
|||||||
QDBusMessage response = bus.call(request);
|
QDBusMessage response = bus.call(request);
|
||||||
QList<QVariant> arguments = response.arguments();
|
QList<QVariant> arguments = response.arguments();
|
||||||
|
|
||||||
return (!arguments.isEmpty() && bool(arguments[0].toInt()));
|
return (!arguments.isEmpty() && arguments[0].toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user