1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/hal/HalContext.h
11 * \brief Hardware abstaction layer library wrapper.
13 #ifndef ZYPP_TARGET_HAL_HALCONTEXT_H
14 #define ZYPP_TARGET_HAL_HALCONTEXT_H
16 #include "zypp/target/hal/HalException.h"
17 #include "zypp/base/PtrTypes.h"
22 //////////////////////////////////////////////////////////////////////
24 { ////////////////////////////////////////////////////////////////////
25 ////////////////////////////////////////////////////////////////////
27 { //////////////////////////////////////////////////////////////////
28 //////////////////////////////////////////////////////////////////
30 { ////////////////////////////////////////////////////////////////
33 // -------------------------------------------------------------
35 * Forward declarations.
42 class HalContext_Impl;
46 ////////////////////////////////////////////////////////////////
48 // CLASS NAME : HalContext
50 /** Hardware abstaction layer context.
52 * Hal context wrapper. It manages the dbus connection and is
53 * the entry point to query drives, volumes and other information.
55 * @todo: wrap more functions.
61 zypp::RW_pointer<HalContext_Impl>::unspecified_bool_type bool_type;
63 HalContext(bool autoconnect=false);
64 HalContext(const HalContext &context);
68 operator=(const HalContext &context);
71 * Verifies if the context is initialized.
73 operator bool_type() const;
81 * Retrieve UDI's of all devices.
82 * \return Vector with device UDI's.
84 std::vector<std::string>
85 getAllDevices() const;
88 * Construct a HalDrive object for the specified UDI.
89 * \param The \p udi of the drive.
90 * \return The HalDrive object.
93 getDriveFromUDI(const std::string &udi) const;
96 * Construct a HalVolume object for the specified UDI.
97 * \param The \p udi of the volume.
98 * \return The HalVolume object.
101 getVolumeFromUDI(const std::string &udi) const;
104 getVolumeFromDeviceFile(const std::string &device_file) const;
107 * Retrieve UDI's of all devices with a capability.
108 * \param The \p capability name
109 * \return Vector with device UDI's.
111 std::vector<std::string>
112 findDevicesByCapability(const std::string &capability) const;
115 getDevicePropertyBool (const std::string &udi,
116 const std::string &key) const;
119 getDevicePropertyInt32 (const std::string &udi,
120 const std::string &key) const;
123 getDevicePropertyUInt64(const std::string &udi,
124 const std::string &key) const;
127 getDevicePropertyDouble(const std::string &udi,
128 const std::string &key) const;
131 getDevicePropertyString(const std::string &udi,
132 const std::string &key) const;
135 setDevicePropertyBool (const std::string &udi,
136 const std::string &key,
140 setDevicePropertyInt32 (const std::string &udi,
141 const std::string &key,
145 setDevicePropertyUInt64(const std::string &udi,
146 const std::string &key,
150 setDevicePropertyDouble(const std::string &udi,
151 const std::string &key,
155 setDevicePropertyString(const std::string &udi,
156 const std::string &key,
157 const std::string &value);
160 removeDeviceProperty(const std::string &udi,
161 const std::string &key);
165 zypp::RW_pointer<HalContext_Impl> h_impl;
169 ////////////////////////////////////////////////////////////////
171 // CLASS NAME : HalDrive
173 /** Hardware abstaction layer storage drive object.
175 * @todo: wrap more functions.
181 zypp::RW_pointer<HalDrive_Impl>::unspecified_bool_type bool_type;
184 HalDrive(const HalDrive &drive);
188 operator=(const HalDrive &drive);
190 operator bool_type() const;
199 * \return The drive's device file name.
202 getDeviceFile() const;
205 * \return The drive's device file major number.
208 getDeviceMajor() const;
211 * \return The drive's device minor number.
214 getDeviceMinor() const;
217 * \return True, if drive uses removable media.
220 usesRemovableMedia() const;
223 ** Returns the media type names supported by the drive.
225 ** Since hal does not implement a textual form here, we
226 ** are using the drive type and property names from
227 ** "storage.cdrom.*" namespace:
228 ** cdrom, cdr, cdrw, dvd, dvdr, dvdrw, dvdram,
229 ** dvdplusr, dvdplusrw, dvdplusrdl
231 ** FIXME: Should we provide own LibHalDriveCdromCaps?
233 std::vector<std::string>
234 getCdromCapabilityNames() const;
237 * Retrieve UDI's of all volumes of this drive.
238 * \return Vector with volume UDI's.
240 std::vector<std::string>
241 findAllVolumes() const;
244 friend class HalContext;
246 HalDrive(HalDrive_Impl *impl);
248 zypp::RW_pointer<HalDrive_Impl> d_impl;
252 ////////////////////////////////////////////////////////////////
254 // CLASS NAME : HalVolume
256 /** Hardware abstaction layer storage volume object.
258 * @todo: wrap more functions.
264 zypp::RW_pointer<HalVolume_Impl>::unspecified_bool_type bool_type;
267 HalVolume(const HalVolume &volume);
271 operator=(const HalVolume &volume);
273 operator bool_type() const;
279 * \return The Volume drive's device file name.
282 getDeviceFile() const;
285 * \return The Volume drive's device major number.
288 getDeviceMajor() const;
291 * \return The Volume drive's device minor number.
294 getDeviceMinor() const;
306 * \return The filesystem name on the volume.
312 * \return The filesystem usage purpose.
318 * \return The mount point of the volume.
321 getMountPoint() const;
324 friend class HalContext;
325 friend class HalDrive;
326 HalVolume(HalVolume_Impl *impl);
328 zypp::RW_pointer<HalVolume_Impl> v_impl;
332 ////////////////////////////////////////////////////////////////
334 //////////////////////////////////////////////////////////////////
335 //////////////////////////////////////////////////////////////////
336 } // namespace target
337 ////////////////////////////////////////////////////////////////////
338 ////////////////////////////////////////////////////////////////////
340 //////////////////////////////////////////////////////////////////////
342 #endif // ZYPP_TARGET_HAL_HALCONTEXT_H
345 ** vim: set ts=2 sts=2 sw=2 ai et: