/*************************************************************************** * 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 "dbusoperation.h" #include #include #include #include #include "version.h" QList parseOutputNetctl(const QList raw) { QList profileInfo; if (raw.isEmpty()) return profileInfo; QStringList list = raw[0].toStringList(); for (int i=0; i parseOutputWifi(const QList raw) { QList wifiInfo; if (raw.isEmpty()) return wifiInfo; QStringList list = raw[0].toStringList(); for (int i=0; i sendRequestToHelper(const QString path, const QString cmd, const QList args, const bool debug) { if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd; if (debug) qDebug() << PDEBUG << ":" << "args" << args; 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 arguments = response.arguments(); if (arguments.isEmpty()) if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage(); return arguments; } QList sendRequestToCtrl(const QString cmd, const bool debug) { if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd; return sendRequestToCtrlWithArgs(cmd, QList(), debug); } QList sendRequestToCtrlWithArgs(const QString cmd, const QList 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 sendRequestToLib(const QString cmd, const bool debug) { if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd; return sendRequestToLibWithArgs(cmd, QList(), debug); } QList sendRequestToLibWithArgs(const QString cmd, const QList 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); }