netctlgui  1.3.0
Qt library which interacts with netctl
 All Classes Files Functions Variables
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 
34 class NetctlProfile;
35 
48 typedef struct
49 {
50  QString name;
51  QString description;
52  bool active;
53  bool enabled;
55 
59 class Netctl : public QObject
60 {
61  Q_OBJECT
62 
63 public:
78  explicit Netctl(const bool debugCmd = false,
79  const QMap<QString, QString> settings = QMap<QString, QString>());
83  ~Netctl();
84  // general information
89  QStringList getActiveProfile();
94  QString autoGetActiveProfile();
99  QList<netctlProfileInfo> getProfileList();
104  QList<netctlProfileInfo> getProfileListFromNetctlAuto();
110  QString getProfileDescription(const QString profile);
117  QString getProfileStatus(const QString profile);
124  bool isProfileActive(const QString profile);
131  bool isProfileEnabled(const QString profile);
138  bool autoIsProfileActive(const QString profile);
145  bool autoIsProfileEnabled(const QString profile);
151  bool isNetctlAutoEnabled();
157  bool isNetctlAutoRunning();
162  static QMap<QString, QString> getRecommendedConfiguration();
167  QStringList getWirelessInterfaceList();
168 
169 public slots:
170  // functions
171  // netctl
178  bool enableProfile(const QString profile);
185  bool forceStartProfile(const QString profile);
192  bool forceStopProfile(const QString profile);
199  bool reenableProfile(const QString profile);
206  bool restartProfile(const QString profile);
213  bool startProfile(const QString profile);
219  bool stopAllProfiles();
226  bool switchToProfile(const QString profile);
227  // netctl-auto
233  bool autoDisableAllProfiles();
240  bool autoEnableProfile(const QString profile);
246  bool autoEnableAllProfiles();
253  bool autoStartProfile(const QString profile);
254  // netctl-auto service
260  bool autoEnableService();
266  bool autoRestartService();
272  bool autoStartService();
273 
274 private:
278  NetctlProfile *netctlProfile = nullptr;
282  bool debug = false;
286  bool useSuid = true;
290  QDir *ifaceDirectory = nullptr;
294  QString mainInterface = QString("");
298  QString netctlCommand = QString("/usr/bin/netctl");
302  QString netctlAutoCommand = QString("/usr/bin/netctl-auto");
306  QString netctlAutoService = QString("netctl-auto");
310  QString sudoCommand = QString("/usr/bin/kdesu");
314  QString systemctlCommand = QString("/usr/bin/systemctl");
315  // functions
325  bool cmdCall(const bool sudo, const QString command,
326  const QString commandLine, const QString argument = 0);
335  QString getCmdOutput(const bool sudo, const QString command,
336  const QString commandLine, const QString argument = 0);
337 };
338 
339 
340 #endif /* NETCTLINTERACT_H */
QString getProfileStatus(const QString profile)
method which gets profile status
QStringList getActiveProfile()
method which returns active profile name
QString name
Definition: netctlinteract.h:50
bool autoIsProfileActive(const QString profile)
method which checks if profile is active (netctl-auto)
bool active
Definition: netctlinteract.h:52
bool autoEnableProfile(const QString profile)
method which sets profile disabled or enabled (netctl-auto)
bool forceStartProfile(const QString profile)
method which force starts profile
bool restartProfile(const QString profile)
method which restarts profile
netctl profile information structure
Definition: netctlinteract.h:48
bool stopAllProfiles()
method which stops all profiles
static QMap< QString, QString > getRecommendedConfiguration()
method which check system configuration and return recommended values to keys
bool autoEnableAllProfiles()
method which sets all profiles enabled (netctl-auto)
bool enabled
Definition: netctlinteract.h:53
bool autoStartProfile(const QString profile)
method which switchs to profile (netctl-auto)
~Netctl()
Netctl class destructor.
bool enableProfile(const QString profile)
method which sets profile disabled or enabled
The NetctlProfile class interacts with netctl profiles.
Definition: netctlprofile.h:37
bool isProfileActive(const QString profile)
method which checks if profile is active
bool isProfileEnabled(const QString profile)
method which checks if profile is enabled
The Netctl class interacts with netctl.
Definition: netctlinteract.h:59
bool autoEnableService()
method which sets netctl-auto service enabled or disabled
QString getProfileDescription(const QString profile)
method which gets description from profile
QString description
Definition: netctlinteract.h:51
bool reenableProfile(const QString profile)
method which reenables profile
bool isNetctlAutoEnabled()
method which checks netctl-auto autoload status
QList< netctlProfileInfo > getProfileList()
method which returns profile informations from netctl
bool startProfile(const QString profile)
method which starts or stops profile
QStringList getWirelessInterfaceList()
method which gets wireless interface list from PREFERED_IFACE and IFACE_DIR
bool isNetctlAutoRunning()
method which checks netctl-auto status
QString autoGetActiveProfile()
method which returns active profile name from netctl-auto
bool autoRestartService()
method which restarted netctl-auto service
Netctl(const bool debugCmd=false, const QMap< QString, QString > settings=QMap< QString, QString >())
Netctl class constructor.
bool forceStopProfile(const QString profile)
method which force stops profile
QList< netctlProfileInfo > getProfileListFromNetctlAuto()
method which returns profile informations from netctl-auto
bool autoStartService()
method which starts or stops netctl-auto service
bool autoIsProfileEnabled(const QString profile)
method which checks if profile is enabled (netctl-auto)
bool autoDisableAllProfiles()
method which sets all profiles disabled (netctl-auto)
bool switchToProfile(const QString profile)
method which starts another profile