File indexing completed on 2024-04-21 15:42:48
0001 /*************************************************************************** 0002 Provides an interface to the computer's hardware 0003 ------------------- 0004 begin : Die Jul 14 2015 0005 copyright : (C) 2015-2020 by Alexander Reinholdt 0006 email : alexander.reinholdt@kdemail.net 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * This program is free software; you can redistribute it and/or modify * 0011 * it under the terms of the GNU General Public License as published by * 0012 * the Free Software Foundation; either version 2 of the License, or * 0013 * (at your option) any later version. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, but * 0016 * WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0018 * General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program; if not, write to the * 0022 * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* 0023 * MA 02110-1335, USA * 0024 ***************************************************************************/ 0025 0026 #ifndef SMB4KHARDWAREINTERFACE_H 0027 #define SMB4KHARDWAREINTERFACE_H 0028 0029 // application specific includes 0030 #include "smb4kglobal.h" 0031 0032 // Qt includes 0033 #include <QObject> 0034 #include <QScopedPointer> 0035 #include <QUrl> 0036 #include <QNetworkConfigurationManager> 0037 #include <QNetworkSession> 0038 0039 class Smb4KHardwareInterfacePrivate; 0040 0041 /** 0042 * This class provides an interface to the computer's hardware. 0043 * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0044 * @since 2.0.0 0045 */ 0046 0047 class Q_DECL_EXPORT Smb4KHardwareInterface : public QObject 0048 { 0049 Q_OBJECT 0050 0051 friend class Smb4KHardwareInterfacePrivate; 0052 0053 public: 0054 /** 0055 * The constructor 0056 */ 0057 explicit Smb4KHardwareInterface(QObject *parent = 0); 0058 0059 /** 0060 * The destructor 0061 */ 0062 ~Smb4KHardwareInterface(); 0063 0064 /** 0065 * The static pointer to this class. 0066 * @returns a static pointer to this class 0067 */ 0068 static Smb4KHardwareInterface *self(); 0069 0070 /** 0071 * This function returns TRUE if the system is online and FALSE otherwise. 0072 * @returns TRUE if the system is online. 0073 */ 0074 bool isOnline() const; 0075 0076 /** 0077 * Inhibit shutdown and sleep. 0078 */ 0079 void inhibit(); 0080 0081 /** 0082 * Uninhibit shutdown and sleep. 0083 */ 0084 void uninhibit(); 0085 0086 #if defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) 0087 protected: 0088 /** 0089 * Reimplemented from QObject to check for mounts and unmounts on operating 0090 * systems that are not fully supported by Solid, yet. 0091 */ 0092 void timerEvent(QTimerEvent *e) override; 0093 #endif 0094 0095 Q_SIGNALS: 0096 /** 0097 * This signal is emitted when a network share is added to the system 0098 */ 0099 void networkShareAdded(); 0100 0101 /** 0102 * This signal is emitted when a network share is removed from the system 0103 */ 0104 void networkShareRemoved(); 0105 0106 /** 0107 * This signal is emitted when the network configuration was updated. 0108 */ 0109 void networkSessionInitialized(); 0110 0111 /** 0112 * This signal is emitted when the online state changed. 0113 */ 0114 void onlineStateChanged(bool online); 0115 0116 protected Q_SLOTS: 0117 /** 0118 * This slot is called by the QNetworkConfigurationManager::updateCompleted() 0119 * signal and sets up the network session. 0120 */ 0121 void slotNetworkConfigUpdated(); 0122 0123 /** 0124 * This slot is called by the QNetworkConfigurationManager::onlineStateChanged() 0125 * signal and is used to update the network configuration if necessary. 0126 */ 0127 void slotOnlineStateChanged(bool on); 0128 0129 /** 0130 * This slot is called when the state of the network connection changed. 0131 * It is connected to the QNetworkSession::stateChanged() signal. 0132 */ 0133 void slotConnectionStateChanged(QNetworkSession::State state); 0134 0135 /** 0136 * This slot is called when a device was added to the system. 0137 * @param udi the device UDI 0138 */ 0139 void slotDeviceAdded(const QString &udi); 0140 0141 /** 0142 * This slot is called when a device was removed from the system. 0143 * @param udi the device UDI 0144 */ 0145 void slotDeviceRemoved(const QString &udi); 0146 0147 private: 0148 QScopedPointer<Smb4KHardwareInterfacePrivate> d; 0149 }; 0150 0151 #endif