File indexing completed on 2025-03-23 04:28:11
0001 /* 0002 0003 SPDX-FileCopyrightText: 2005-2009 Sebastian Trueg <trueg@k3b.org> 0004 SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef _K3B_HAL_CONNECTION_H_ 0010 #define _K3B_HAL_CONNECTION_H_ 0011 0012 #include <config-k3b.h> 0013 0014 #include "k3bdevice_export.h" 0015 0016 #include <QObject> 0017 #include <QMap> 0018 #include <QStringList> 0019 0020 0021 namespace K3b { 0022 namespace Device { 0023 0024 class Device; 0025 0026 /** 0027 * This is a simple HAL/DBUS wrapper. 0028 * 0029 * It only provides methods to lock and unlock a device since Solid does not provide those. 0030 */ 0031 class LIBK3BDEVICE_EXPORT HalConnection : public QObject 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 /** 0037 * Use instance() to get the single global object 0038 */ 0039 explicit HalConnection( QObject* = 0 ); 0040 ~HalConnection(); 0041 0042 /** 0043 * Creates a new singleton HalConnection object or returns the already existing one. 0044 * A newly created HalConnection will emit newDevice signals for all devices in the HAL 0045 * manager. However, since one cannot be sure if this is the first time the HalConnection 0046 * is created it is recommended to connect to the signals and query the list of current 0047 * devices. 0048 * 0049 * \return An instance of the singleton HalConnection object. 0050 */ 0051 static HalConnection* instance(); 0052 0053 /** 0054 * Error codes named as the HAL daemon raises them 0055 */ 0056 enum ErrorCode { 0057 org_freedesktop_Hal_Success = 0, //*< The operation was successful. This code does not match any in HAL 0058 org_freedesktop_Hal_CommunicationError, //*< DBus communication error. This code does not match any in HAL 0059 org_freedesktop_Hal_NoSuchDevice, 0060 org_freedesktop_Hal_DeviceAlreadyLocked, 0061 org_freedesktop_Hal_DeviceNotLocked, 0062 org_freedesktop_Hal_Device_InterfaceAlreadyLocked, 0063 org_freedesktop_Hal_Device_InterfaceNotLocked, 0064 org_freedesktop_Hal_PermissionDenied, 0065 org_freedesktop_Hal_Device_Volume_NoSuchDevice, 0066 org_freedesktop_Hal_Device_Volume_PermissionDenied, 0067 org_freedesktop_Hal_Device_Volume_AlreadyMounted, 0068 org_freedesktop_Hal_Device_Volume_InvalidMountOption, 0069 org_freedesktop_Hal_Device_Volume_UnknownFilesystemType, 0070 org_freedesktop_Hal_Device_Volume_InvalidMountpoint, 0071 org_freedesktop_Hal_Device_Volume_MountPointNotAvailable, 0072 org_freedesktop_Hal_Device_Volume_PermissionDeniedByPolicy, 0073 org_freedesktop_Hal_Device_Volume_InvalidUnmountOption, 0074 org_freedesktop_Hal_Device_Volume_InvalidEjectOption, 0075 org_freedesktop_Hal_Unknown //*< Unknown error. This code does not match any in HAL 0076 }; 0077 0078 public Q_SLOTS: 0079 /** 0080 * Lock the device in HAL 0081 * 0082 * Be aware that once the method returns the HAL daemon has not necessarily 0083 * finished the procedure yet. 0084 * 0085 * \param dev The device to lock 0086 * \return An error code 0087 * 0088 * \see ErrorCode 0089 */ 0090 ErrorCode lock( Device* ); 0091 0092 /** 0093 * Unlock a previously locked device in HAL 0094 * 0095 * Be aware that once the method returns the HAL daemon has not necessarily 0096 * finished the procedure yet. 0097 * 0098 * \param dev The device to lock 0099 * \return An error code 0100 * 0101 * \see ErrorCode 0102 */ 0103 ErrorCode unlock( Device* ); 0104 0105 private: 0106 class Private; 0107 Private* d; 0108 }; 0109 } 0110 } 0111 0112 #endif