/*************************************************************************** * 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" #include #include #include #include "netctlhelper.h" #include "version.h" ControlAdaptor::ControlAdaptor(NetctlHelper *parent, const bool debugCmd, const QMap configuration) : QDBusAbstractAdaptor(parent), debug(debugCmd), helper(parent) { netctlCommand = new Netctl(debug, configuration); netctlProfile = new NetctlProfile(debug, configuration); wpaCommand = new WpaSup(debug, configuration); } ControlAdaptor::~ControlAdaptor() { if (netctlCommand != nullptr) delete netctlCommand; if (netctlProfile != nullptr) delete netctlProfile; if (wpaCommand != nullptr) delete wpaCommand; } // helper bool ControlAdaptor::Active() { return true; } QString ControlAdaptor::ApiDocs() { return (QString("%1netctl-gui-dbus-api.html").arg(QString(DOCS_PATH))); } bool ControlAdaptor::Close() { helper->quitHelper(); return true; } QStringList ControlAdaptor::FindSettings() { QMap configuration; // apply settings from Netctl class QMap librarySettings = netctlCommand->getRecommendedConfiguration(); for (int i=0; igetRecommendedConfiguration(); for (int i=0; igetRecommendedConfiguration(); for (int i=0; itoUnicode(ponyFile.readAll()); ponyFile.close(); return pony; } QString ControlAdaptor::SecurityDocs() { return (QString("%1netctl-gui-security-notes.html").arg(QString(DOCS_PATH))); } bool ControlAdaptor::SelfDestruct(const QString approve) { if (approve == QString("Yes please")) return SelfDestruct(approve); return false; } QStringList ControlAdaptor::Settings() { return helper->printSettings(); } QStringList ControlAdaptor::UIDs() { QStringList uids; uids.append(QString::number(getuid())); uids.append(QString::number(geteuid())); return uids; } bool ControlAdaptor::Update() { helper->updateConfiguration(); return true; } // 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::forceStart(const QString profile) { return netctlCommand->forceStartProfile(profile); } bool ControlAdaptor::forceStop(const QString profile) { return netctlCommand->forceStopProfile(profile); } bool ControlAdaptor::Reenable(const QString profile) { return netctlCommand->reenableProfile(profile); } bool ControlAdaptor::Restart(const QString profile) { return netctlCommand->restartProfile(profile); } bool ControlAdaptor::Start(const QString profile) { return netctlCommand->startProfile(profile); } bool ControlAdaptor::StopAll() { return netctlCommand->stopAllProfiles(); } bool ControlAdaptor::SwitchTo(const QString profile) { return netctlCommand->switchToProfile(profile); } // netctlProfile bool ControlAdaptor::Create(const QString profile, const QStringList settingsList) { QString temporaryProfile = netctlProfile->createProfile(profile, listToMap(settingsList)); return netctlProfile->copyProfile(temporaryProfile); } bool ControlAdaptor::Remove(const QString profile) { return netctlProfile->removeProfile(profile); } // wpaCommand QString ControlAdaptor::CurrentWiFi() { netctlWifiInfo wifiPoint = wpaCommand->current(); QStringList point; point.append(wifiPoint.name); point.append(wifiPoint.security); point.append(QString::number(wifiPoint.type)); QStringList freqList; for (int j=0; j wifiPoints; wifiPoints.append(wpaCommand->current()); wifiPoints.append(wpaCommand->scanWifi()); QStringList info; for (int i=0; i wifiPoints = wpaCommand->scanWifi(); QStringList info; for (int i=0; i