netctlgui  1.4.5
Qt library which interacts with netctl
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 
56 typedef struct
57 {
58  QString name;
59  QString description;
60  QString essid;
61  QString interface;
62  QString type;
63  bool active = false;
64  bool enabled = false;
65  bool netctlAuto = false;
67 
71 class Netctl : public QObject
72 {
73  Q_OBJECT
74 
75 public:
90  explicit Netctl(const bool debugCmd = false,
91  const QMap<QString, QString> settings = QMap<QString, QString>());
95  ~Netctl();
96  // general information
101  QStringList getActiveProfile();
106  QString autoGetActiveProfile();
111  QList<netctlProfileInfo> getProfileList();
116  QList<netctlProfileInfo> getProfileListFromNetctlAuto();
122  Q_DECL_DEPRECATED QString getProfileDescription(const QString profile);
129  QString getProfileStatus(const QString profile);
136  bool isProfileActive(const QString profile);
143  bool isProfileEnabled(const QString profile);
150  bool autoIsProfileActive(const QString profile);
157  bool autoIsProfileEnabled(const QString profile);
163  bool isNetctlAutoEnabled();
169  bool isNetctlAutoRunning();
174  static QMap<QString, QString> getRecommendedConfiguration();
179  QStringList getWirelessInterfaceList();
180 
181 public slots:
182  // functions
183  // netctl
190  bool enableProfile(const QString profile);
197  bool forceStartProfile(const QString profile);
204  bool forceStopProfile(const QString profile);
211  bool reenableProfile(const QString profile);
218  bool restartProfile(const QString profile);
225  bool startProfile(const QString profile);
231  bool stopAllProfiles();
238  bool switchToProfile(const QString profile);
239  // netctl-auto
245  bool autoDisableAllProfiles();
252  bool autoEnableProfile(const QString profile);
258  bool autoEnableAllProfiles();
265  bool autoStartProfile(const QString profile);
266  // netctl-auto service
272  bool autoEnableService();
278  bool autoRestartService();
284  bool autoStartService();
285 
286 private:
290  NetctlProfile *netctlProfile = nullptr;
294  bool debug = false;
298  bool useSuid = true;
302  QDir *ifaceDirectory = nullptr;
306  QString mainInterface = QString("");
310  QString netctlCommand = QString("/usr/bin/netctl");
314  QString netctlAutoCommand = QString("/usr/bin/netctl-auto");
318  QString netctlAutoService = QString("netctl-auto");
322  QString sudoCommand = QString("/usr/bin/kdesu");
326  QString systemctlCommand = QString("/usr/bin/systemctl");
327  // functions
337  bool cmdCall(const bool sudo, const QString command,
338  const QString commandLine, const QString argument = 0);
347  QString getCmdOutput(const bool sudo, const QString command,
348  const QString commandLine, const QString argument = 0);
349 };
350 
351 
352 #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:58
bool autoIsProfileActive(const QString profile)
method which checks if profile is active (netctl-auto)
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
QString interface
Definition: netctlinteract.h:61
netctl profile information structure
Definition: netctlinteract.h:56
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 autoStartProfile(const QString profile)
method which switchs to profile (netctl-auto)
Q_DECL_DEPRECATED QString getProfileDescription(const QString profile)
method which gets description from profile
QString essid
Definition: netctlinteract.h:60
~Netctl()
Netctl class destructor.
QString type
Definition: netctlinteract.h:62
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:71
bool autoEnableService()
method which sets netctl-auto service enabled or disabled
QString description
Definition: netctlinteract.h:59
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