| netctlgui 1.4.7 Qt library which interacts with netctl

- Main Page
- Classes
- Files

- File List
- File Members

netctlinteract.h
Go to the documentation of this file.
1 /***************************************************************************
2 * This file is part of netctl-gui *
3 * *
4 * netctl-gui is free software: you can redistribute it and/or *
5 * modify it under the terms of the GNU General Public License as *
6 * published by the Free Software Foundation, either version 3 of the *
7 * License, or (at your option) any later version. *
8 * *
9 * netctl-gui is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
16 ***************************************************************************/
26 #ifndef NETCTLINTERACT_H
27 #define NETCTLINTERACT_H
28
29 #include <QDir>
30 #include <QMap>
31 #include <QObject>
32
33 #include "version.h"
34
35
36 class NetctlProfile;
37
58 typedef struct
59 {
60 QString name;
61 QString description;
62 QString essid;
63 QString interface;
64 QString type;
65 bool active = false;
66 bool enabled = false;
67 bool netctlAuto = false;
68 } netctlProfileInfo;
69
73 class Netctl : public QObject
74 {
75 Q_OBJECT
76
77 public:
92 explicit Netctl(const bool debugCmd = false,
93 const QMap<QString, QString> settings = QMap<QString, QString>());
97 ~Netctl();
98 // general information
103 QStringList getActiveProfile();
108 QString autoGetActiveProfile();
113 QList<netctlProfileInfo> getProfileList();
118 QList<netctlProfileInfo> getProfileListFromNetctlAuto();
124 Q_DECL_DEPRECATED QString getProfileDescription(const QString profile);
131 QString getProfileStatus(const QString profile);
138 bool isProfileActive(const QString profile);
145 bool isProfileEnabled(const QString profile);
152 bool autoIsProfileActive(const QString profile);
159 bool autoIsProfileEnabled(const QString profile);
165 bool isNetctlAutoEnabled();
171 bool isNetctlAutoRunning();
176 static QMap<QString, QString> getRecommendedConfiguration();
181 QStringList getWirelessInterfaceList();
182
183 public slots:
184 // functions
185 // netctl
192 bool enableProfile(const QString profile);
199 bool forceStartProfile(const QString profile);
206 bool forceStopProfile(const QString profile);
213 bool reenableProfile(const QString profile);
220 bool restartProfile(const QString profile);
227 bool startProfile(const QString profile);
233 bool stopAllProfiles();
240 bool switchToProfile(const QString profile);
241 // netctl-auto
247 bool autoDisableAllProfiles();
254 bool autoEnableProfile(const QString profile);
260 bool autoEnableAllProfiles();
267 bool autoStartProfile(const QString profile);
268 // netctl-auto service
274 bool autoEnableService();
280 bool autoRestartService();
286 bool autoStartService();
287
288 private:
292 NetctlProfile *netctlProfile = nullptr;
296 bool debug = false;
300 bool useSuid = true;
304 QDir *ifaceDirectory = nullptr;
308 QString mainInterface = QString(PREFERED_IFACE);
312 QString netctlCommand = QString(NETCTL_PATH);
316 QString netctlAutoCommand = QString(NETCTLAUTO_PATH);
320 QString netctlAutoService = QString(NETCTLAUTO_SERVICE);
324 QString sudoCommand = QString(SUDO_PATH);
328 QString systemctlCommand = QString(SYSTEMCTL_PATH);
329 // functions
339 bool cmdCall(const bool sudo, const QString command,
340 const QString commandLine, const QString argument = 0);
349 QString getCmdOutput(const bool sudo, const QString command,
350 const QString commandLine, const QString argument = 0);
351 };
352
353
354 #endif /* NETCTLINTERACT_H */
Netctl::getProfileStatus
QString getProfileStatus(const QString profile)
method which gets profile status
Netctl::getActiveProfile
QStringList getActiveProfile()
method which returns active profile name
netctlProfileInfo::name
QString name
Definition: netctlinteract.h:60
Netctl::autoIsProfileActive
bool autoIsProfileActive(const QString profile)
method which checks if profile is active (netctl-auto)
Netctl::autoEnableProfile
bool autoEnableProfile(const QString profile)
method which sets profile disabled or enabled (netctl-auto)
Netctl::forceStartProfile
bool forceStartProfile(const QString profile)
method which force starts profile
Netctl::restartProfile
bool restartProfile(const QString profile)
method which restarts profile
netctlProfileInfo::interface
QString interface
Definition: netctlinteract.h:63
netctlProfileInfo
netctl profile information structure
Definition: netctlinteract.h:58
Netctl::stopAllProfiles
bool stopAllProfiles()
method which stops all profiles
Netctl::getRecommendedConfiguration
static QMap< QString, QString > getRecommendedConfiguration()
method which check system configuration and return recommended values to keys
Netctl::autoEnableAllProfiles
bool autoEnableAllProfiles()
method which sets all profiles enabled (netctl-auto)
Netctl::autoStartProfile
bool autoStartProfile(const QString profile)
method which switchs to profile (netctl-auto)
Netctl::getProfileDescription
Q_DECL_DEPRECATED QString getProfileDescription(const QString profile)
method which gets description from profile
netctlProfileInfo::essid
QString essid
Definition: netctlinteract.h:62
Netctl::~Netctl
~Netctl()
Netctl class destructor.
netctlProfileInfo::type
QString type
Definition: netctlinteract.h:64
Netctl::enableProfile
bool enableProfile(const QString profile)
method which sets profile disabled or enabled
NetctlProfile
The NetctlProfile class interacts with netctl profiles.
Definition: netctlprofile.h:39
Netctl::isProfileActive
bool isProfileActive(const QString profile)
method which checks if profile is active
Netctl::isProfileEnabled
bool isProfileEnabled(const QString profile)
method which checks if profile is enabled
Netctl
The Netctl class interacts with netctl.
Definition: netctlinteract.h:73
Netctl::autoEnableService
bool autoEnableService()
method which sets netctl-auto service enabled or disabled
netctlProfileInfo::description
QString description
Definition: netctlinteract.h:61
Netctl::reenableProfile
bool reenableProfile(const QString profile)
method which reenables profile
Netctl::isNetctlAutoEnabled
bool isNetctlAutoEnabled()
method which checks netctl-auto autoload status
Netctl::getProfileList
QList< netctlProfileInfo > getProfileList()
method which returns profile informations from netctl
Netctl::startProfile
bool startProfile(const QString profile)
method which starts or stops profile
Netctl::getWirelessInterfaceList
QStringList getWirelessInterfaceList()
method which gets wireless interface list from PREFERED_IFACE and IFACE_DIR
Netctl::isNetctlAutoRunning
bool isNetctlAutoRunning()
method which checks netctl-auto status
Netctl::autoGetActiveProfile
QString autoGetActiveProfile()
method which returns active profile name from netctl-auto
Netctl::autoRestartService
bool autoRestartService()
method which restarted netctl-auto service
Netctl::Netctl
Netctl(const bool debugCmd=false, const QMap< QString, QString > settings=QMap< QString, QString >())
Netctl class constructor.
Netctl::forceStopProfile
bool forceStopProfile(const QString profile)
method which force stops profile
Netctl::getProfileListFromNetctlAuto
QList< netctlProfileInfo > getProfileListFromNetctlAuto()
method which returns profile informations from netctl-auto
Netctl::autoStartService
bool autoStartService()
method which starts or stops netctl-auto service
Netctl::autoIsProfileEnabled
bool autoIsProfileEnabled(const QString profile)
method which checks if profile is enabled (netctl-auto)
Netctl::autoDisableAllProfiles
bool autoDisableAllProfiles()
method which sets all profiles disabled (netctl-auto)
Netctl::switchToProfile
bool switchToProfile(const QString profile)
method which starts another profile