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