Hardware authentication for Linux using ordinary USB Flash Drives.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

793 lines
28 KiB

13 years ago
  1. /***************************************************************************
  2. * CVSID: $Id$
  3. *
  4. * libhal.h : HAL daemon C convenience library headers
  5. *
  6. * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
  7. * Copyright (C) 2007 Codethink Ltd. Author Rob Taylor <rob.taylor@codethink.co.uk>
  8. *
  9. * Licensed under the Academic Free License version 2.1
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. **************************************************************************/
  26. #ifndef LIBHAL_H
  27. #define LIBHAL_H
  28. #ifndef DBUS_API_SUBJECT_TO_CHANGE
  29. #define DBUS_API_SUBJECT_TO_CHANGE
  30. #endif
  31. #include <dbus/dbus.h>
  32. #if defined(__cplusplus)
  33. extern "C" {
  34. #if 0
  35. } /* shut up emacs indenting */
  36. #endif
  37. #endif
  38. #if defined(__GNUC__)
  39. #define LIBHAL_DEPRECATED __attribute__ ((deprecated))
  40. #else
  41. #define LIBHAL_DEPRECATED
  42. #endif
  43. /**
  44. * LIBHAL_LIBHAL_FREE_DBUS_ERROR:
  45. * @_dbus_error_: the DBusError
  46. *
  47. * Handy macro for checking whether a DBusError is set and free the error if
  48. * the error is set.
  49. */
  50. #define LIBHAL_FREE_DBUS_ERROR(_dbus_error_) \
  51. do { \
  52. if (dbus_error_is_set(_dbus_error_)) \
  53. dbus_error_free (_dbus_error_); \
  54. } while (0)
  55. /**
  56. * LIBHAL_CHECK_LIBHALCONTEXT:
  57. * @_ctx_: the context
  58. * @_ret_: what to use for return value if context is invalid
  59. *
  60. * Handy macro for checking whether a context is valid.
  61. */
  62. #define LIBHAL_CHECK_LIBHALCONTEXT(_ctx_, _ret_) \
  63. do { \
  64. if (_ctx_ == NULL) { \
  65. fprintf (stderr, \
  66. "%s %d : LibHalContext *ctx is NULL\n", \
  67. __FILE__, __LINE__); \
  68. return _ret_; \
  69. } \
  70. } while(0)
  71. /**
  72. * LibHalPropertyType:
  73. *
  74. * Possible types for properties on hal device objects
  75. */
  76. typedef enum {
  77. /** Used to report error condition */
  78. LIBHAL_PROPERTY_TYPE_INVALID = DBUS_TYPE_INVALID,
  79. /** Type for 32-bit signed integer property */
  80. LIBHAL_PROPERTY_TYPE_INT32 = DBUS_TYPE_INT32,
  81. /** Type for 64-bit unsigned integer property */
  82. LIBHAL_PROPERTY_TYPE_UINT64 = DBUS_TYPE_UINT64,
  83. /** Type for double precision floating point property */
  84. LIBHAL_PROPERTY_TYPE_DOUBLE = DBUS_TYPE_DOUBLE,
  85. /** Type for boolean property */
  86. LIBHAL_PROPERTY_TYPE_BOOLEAN = DBUS_TYPE_BOOLEAN,
  87. /** Type for UTF-8 string property */
  88. LIBHAL_PROPERTY_TYPE_STRING = DBUS_TYPE_STRING,
  89. /** Type for list of UTF-8 strings property */
  90. LIBHAL_PROPERTY_TYPE_STRLIST = ((int) (DBUS_TYPE_STRING<<8)+('l'))
  91. } LibHalPropertyType;
  92. typedef struct LibHalContext_s LibHalContext;
  93. typedef struct LibHalProperty_s LibHalProperty;
  94. typedef struct LibHalPropertySet_s LibHalPropertySet;
  95. /**
  96. * LibHalIntegrateDBusIntoMainLoop:
  97. * @ctx: context for connection to hald
  98. * @dbus_connection: DBus connection to use in ctx
  99. *
  100. * Type for function in application code that integrates a
  101. * DBusConnection object into its own mainloop.
  102. */
  103. typedef void (*LibHalIntegrateDBusIntoMainLoop) (LibHalContext *ctx,
  104. DBusConnection *dbus_connection);
  105. /**
  106. * LibHalDeviceAdded:
  107. * @ctx: context for connection to hald
  108. * @udi: the Unique Device Id
  109. *
  110. * Type for callback when a device is added.
  111. */
  112. typedef void (*LibHalDeviceAdded) (LibHalContext *ctx,
  113. const char *udi);
  114. /**
  115. * LibHalDeviceRemoved:
  116. * @ctx: context for connection to hald
  117. * @udi: the Unique Device Id
  118. *
  119. * Type for callback when a device is removed.
  120. */
  121. typedef void (*LibHalDeviceRemoved) (LibHalContext *ctx,
  122. const char *udi);
  123. /**
  124. * LibHalDeviceNewCapability:
  125. * @ctx: context for connection to hald
  126. * @udi: the Unique Device Id
  127. * @capability: capability of the device
  128. *
  129. * Type for callback when a device gains a new capability.
  130. *
  131. */
  132. typedef void (*LibHalDeviceNewCapability) (LibHalContext *ctx,
  133. const char *udi,
  134. const char *capability);
  135. /**
  136. * LibHalDeviceLostCapability:
  137. * @ctx: context for connection to hald
  138. * @udi: the Unique Device Id
  139. * @capability: capability of the device
  140. *
  141. * Type for callback when a device loses a capability.
  142. *
  143. */
  144. typedef void (*LibHalDeviceLostCapability) (LibHalContext *ctx,
  145. const char *udi,
  146. const char *capability);
  147. /**
  148. * LibHalDevicePropertyModified:
  149. * @ctx: context for connection to hald
  150. * @udi: the Unique Device Id
  151. * @key: name of the property that has changed
  152. * @is_removed: whether or not property was removed
  153. * @is_added: whether or not property was added
  154. *
  155. * Type for callback when a property of a device changes.
  156. */
  157. typedef void (*LibHalDevicePropertyModified) (LibHalContext *ctx,
  158. const char *udi,
  159. const char *key,
  160. dbus_bool_t is_removed,
  161. dbus_bool_t is_added);
  162. /**
  163. * LibHalDeviceCondition:
  164. * @ctx: context for connection to hald
  165. * @udi: the Unique Device Id
  166. * @condition_name: name of the condition, e.g. ProcessorOverheating. Consult the HAL spec for details
  167. * @condition_detail: detail of condition
  168. *
  169. * Type for callback when a non-continuous condition occurs on a device.
  170. */
  171. typedef void (*LibHalDeviceCondition) (LibHalContext *ctx,
  172. const char *udi,
  173. const char *condition_name,
  174. const char *condition_detail);
  175. /**
  176. * LibHalGlobalInterfaceLockAcquired:
  177. * @ctx: context for connection to hald
  178. * @interface_name: the name of the interface
  179. * @lock_owner: what service acquired the lock
  180. * @num_locks: number of locks on the interface
  181. *
  182. * Type for callback when someone acquires a global lock.
  183. */
  184. typedef void (*LibHalGlobalInterfaceLockAcquired) (LibHalContext *ctx,
  185. const char *interface_name,
  186. const char *lock_owner,
  187. int num_locks);
  188. /**
  189. * LibHalGlobalInterfaceLockReleased:
  190. * @ctx: context for connection to hald
  191. * @interface_name: the name of the interface
  192. * @lock_owner: what service released the lock
  193. * @num_locks: number of locks on the interface
  194. *
  195. * Type for callback when someone releases a global lock.
  196. */
  197. typedef void (*LibHalGlobalInterfaceLockReleased) (LibHalContext *ctx,
  198. const char *interface_name,
  199. const char *lock_owner,
  200. int num_locks);
  201. /**
  202. * LibHalInterfaceLockAcquired:
  203. * @ctx: context for connection to hald
  204. * @udi: the Unique Device Id
  205. * @interface_name: the name of the interface
  206. * @lock_owner: what service acquired the lock
  207. * @num_locks: number of locks on the interface
  208. *
  209. * Type for callback when someone acquires a lock on a device.
  210. */
  211. typedef void (*LibHalInterfaceLockAcquired) (LibHalContext *ctx,
  212. const char *udi,
  213. const char *interface_name,
  214. const char *lock_owner,
  215. int num_locks);
  216. /**
  217. * LibHalInterfaceLockReleased:
  218. * @ctx: context for connection to hald
  219. * @udi: the Unique Device Id
  220. * @interface_name: the name of the interface
  221. * @lock_owner: what service released the lock
  222. * @num_locks: number of locks on the interface
  223. *
  224. * Type for callback when someone acquires a lock on a device.
  225. */
  226. typedef void (*LibHalInterfaceLockReleased) (LibHalContext *ctx,
  227. const char *udi,
  228. const char *interface_name,
  229. const char *lock_owner,
  230. int num_locks);
  231. /**
  232. * LibHalSingletonDeviceAdded:
  233. * @ctx: context for connection to hald
  234. * @udi: the Unique Device Id
  235. * @properties: the device's properties
  236. *
  237. * Type for callback for addon singletons when a device is added
  238. */
  239. typedef void (*LibHalSingletonDeviceAdded) (LibHalContext *ctx,
  240. const char *udi,
  241. const LibHalPropertySet *properties);
  242. /**
  243. * LibHalSingletonDeviceRemoved:
  244. * @ctx: context for connection to hald
  245. * @udi: the Unique Device Id
  246. * @properties: the device's properties
  247. *
  248. * Type for callback for addon singletons when a device is added
  249. */
  250. typedef void (*LibHalSingletonDeviceRemoved) (LibHalContext *ctx,
  251. const char *udi,
  252. const LibHalPropertySet *properties);
  253. /* Create a new context for a connection with hald */
  254. LibHalContext *libhal_ctx_new (void);
  255. /* Enable or disable caching */
  256. dbus_bool_t libhal_ctx_set_cache (LibHalContext *ctx, dbus_bool_t use_cache);
  257. /* Set DBus connection to use to talk to hald. */
  258. dbus_bool_t libhal_ctx_set_dbus_connection (LibHalContext *ctx, DBusConnection *conn);
  259. /* Get DBus connection to use to talk to hald. */
  260. DBusConnection *libhal_ctx_get_dbus_connection (LibHalContext *ctx);
  261. /* Set user data for the context */
  262. dbus_bool_t libhal_ctx_set_user_data (LibHalContext *ctx, void *user_data);
  263. /* Get user data for the context */
  264. void* libhal_ctx_get_user_data (LibHalContext *ctx);
  265. /* Set the callback for when a device is added */
  266. dbus_bool_t libhal_ctx_set_device_added (LibHalContext *ctx, LibHalDeviceAdded callback);
  267. /* Set the callback for when a device is removed */
  268. dbus_bool_t libhal_ctx_set_device_removed (LibHalContext *ctx, LibHalDeviceRemoved callback);
  269. /* Set the callback for when a device gains a new capability */
  270. dbus_bool_t libhal_ctx_set_device_new_capability (LibHalContext *ctx, LibHalDeviceNewCapability callback);
  271. /* Set the callback for when a device loses a capability */
  272. dbus_bool_t libhal_ctx_set_device_lost_capability (LibHalContext *ctx, LibHalDeviceLostCapability callback);
  273. /* Set the callback for when a property is modified on a device */
  274. dbus_bool_t libhal_ctx_set_device_property_modified (LibHalContext *ctx, LibHalDevicePropertyModified callback);
  275. /* Set the callback for when a device emits a condition */
  276. dbus_bool_t libhal_ctx_set_device_condition (LibHalContext *ctx, LibHalDeviceCondition callback);
  277. /* Set the callback for when a global interface lock is acquired */
  278. dbus_bool_t libhal_ctx_set_global_interface_lock_acquired (LibHalContext *ctx, LibHalGlobalInterfaceLockAcquired callback);
  279. /* Set the callback for when a global interface lock is released */
  280. dbus_bool_t libhal_ctx_set_global_interface_lock_released (LibHalContext *ctx, LibHalGlobalInterfaceLockReleased callback);
  281. /* Set the callback for when an interface lock is acquired */
  282. dbus_bool_t libhal_ctx_set_interface_lock_acquired (LibHalContext *ctx, LibHalInterfaceLockAcquired callback);
  283. /* Set the callback for when an interface lock is released */
  284. dbus_bool_t libhal_ctx_set_interface_lock_released (LibHalContext *ctx, LibHalInterfaceLockReleased callback);
  285. /* Set the callback for addon singleton device added */
  286. dbus_bool_t libhal_ctx_set_singleton_device_added (LibHalContext *ctx, LibHalSingletonDeviceAdded callback);
  287. /* Set the callback for addon singleton device removed*/
  288. dbus_bool_t libhal_ctx_set_singleton_device_removed (LibHalContext *ctx, LibHalSingletonDeviceRemoved callback);
  289. /* Initialize the connection to hald */
  290. dbus_bool_t libhal_ctx_init (LibHalContext *ctx, DBusError *error);
  291. /* Shut down a connection to hald */
  292. dbus_bool_t libhal_ctx_shutdown (LibHalContext *ctx, DBusError *error);
  293. /* Free a LibHalContext resource */
  294. dbus_bool_t libhal_ctx_free (LibHalContext *ctx);
  295. /* Create an already initialized connection to hald */
  296. LibHalContext *libhal_ctx_init_direct (DBusError *error);
  297. /* Get all devices in the Global Device List (GDL). */
  298. char **libhal_get_all_devices (LibHalContext *ctx, int *num_devices, DBusError *error);
  299. /* Determine if a device exists. */
  300. dbus_bool_t libhal_device_exists (LibHalContext *ctx, const char *udi, DBusError *error);
  301. /* Print a device to stdout; useful for debugging. */
  302. dbus_bool_t libhal_device_print (LibHalContext *ctx, const char *udi, DBusError *error);
  303. /* Determine if a property on a device exists. */
  304. dbus_bool_t libhal_device_property_exists (LibHalContext *ctx,
  305. const char *udi,
  306. const char *key,
  307. DBusError *error);
  308. /* Get the value of a property of type string. */
  309. char *libhal_device_get_property_string (LibHalContext *ctx,
  310. const char *udi,
  311. const char *key,
  312. DBusError *error);
  313. /* Get the value of a property of type signed integer. */
  314. dbus_int32_t libhal_device_get_property_int (LibHalContext *ctx,
  315. const char *udi,
  316. const char *key,
  317. DBusError *error);
  318. /* Get the value of a property of type unsigned integer. */
  319. dbus_uint64_t libhal_device_get_property_uint64 (LibHalContext *ctx,
  320. const char *udi,
  321. const char *key,
  322. DBusError *error);
  323. /* Get the value of a property of type double. */
  324. double libhal_device_get_property_double (LibHalContext *ctx,
  325. const char *udi,
  326. const char *key,
  327. DBusError *error);
  328. /* Get the value of a property of type bool. */
  329. dbus_bool_t libhal_device_get_property_bool (LibHalContext *ctx,
  330. const char *udi,
  331. const char *key,
  332. DBusError *error);
  333. /* Get the value of a property of type string list. */
  334. char **libhal_device_get_property_strlist (LibHalContext *ctx,
  335. const char *udi,
  336. const char *key,
  337. DBusError *error);
  338. /* Set a property of type string. */
  339. dbus_bool_t libhal_device_set_property_string (LibHalContext *ctx,
  340. const char *udi,
  341. const char *key,
  342. const char *value,
  343. DBusError *error);
  344. /* Set a property of type signed integer. */
  345. dbus_bool_t libhal_device_set_property_int (LibHalContext *ctx,
  346. const char *udi,
  347. const char *key,
  348. dbus_int32_t value,
  349. DBusError *error);
  350. /* Set a property of type unsigned integer. */
  351. dbus_bool_t libhal_device_set_property_uint64 (LibHalContext *ctx,
  352. const char *udi,
  353. const char *key,
  354. dbus_uint64_t value,
  355. DBusError *error);
  356. /* Set a property of type double. */
  357. dbus_bool_t libhal_device_set_property_double (LibHalContext *ctx,
  358. const char *udi,
  359. const char *key,
  360. double value,
  361. DBusError *error);
  362. /* Set a property of type bool. */
  363. dbus_bool_t libhal_device_set_property_bool (LibHalContext *ctx,
  364. const char *udi,
  365. const char *key,
  366. dbus_bool_t value,
  367. DBusError *error);
  368. /* Append to a property of type strlist. */
  369. dbus_bool_t libhal_device_property_strlist_append (LibHalContext *ctx,
  370. const char *udi,
  371. const char *key,
  372. const char *value,
  373. DBusError *error);
  374. /* Prepend to a property of type strlist. */
  375. dbus_bool_t libhal_device_property_strlist_prepend (LibHalContext *ctx,
  376. const char *udi,
  377. const char *key,
  378. const char *value,
  379. DBusError *error);
  380. /* Remove a specified string from a property of type strlist. */
  381. dbus_bool_t libhal_device_property_strlist_remove_index (LibHalContext *ctx,
  382. const char *udi,
  383. const char *key,
  384. unsigned int idx,
  385. DBusError *error);
  386. /* Remove a specified string from a property of type strlist. */
  387. dbus_bool_t libhal_device_property_strlist_remove (LibHalContext *ctx,
  388. const char *udi,
  389. const char *key,
  390. const char *value,
  391. DBusError *error);
  392. /* Remove a property. */
  393. dbus_bool_t libhal_device_remove_property (LibHalContext *ctx,
  394. const char *udi,
  395. const char *key,
  396. DBusError *error);
  397. /* Query a property type of a device. */
  398. LibHalPropertyType libhal_device_get_property_type (LibHalContext *ctx,
  399. const char *udi,
  400. const char *key,
  401. DBusError *error);
  402. struct LibHalChangeSet_s;
  403. typedef struct LibHalChangeSet_s LibHalChangeSet;
  404. LibHalChangeSet *libhal_device_new_changeset (const char *udi);
  405. dbus_bool_t libhal_changeset_set_property_string (LibHalChangeSet *changeset,
  406. const char *key,
  407. const char *value);
  408. dbus_bool_t libhal_changeset_set_property_int (LibHalChangeSet *changeset,
  409. const char *key,
  410. dbus_int32_t value);
  411. dbus_bool_t libhal_changeset_set_property_uint64 (LibHalChangeSet *changeset,
  412. const char *key,
  413. dbus_uint64_t value);
  414. dbus_bool_t libhal_changeset_set_property_double (LibHalChangeSet *changeset,
  415. const char *key,
  416. double value);
  417. dbus_bool_t libhal_changeset_set_property_bool (LibHalChangeSet *changeset,
  418. const char *key,
  419. dbus_bool_t value);
  420. dbus_bool_t libhal_changeset_set_property_strlist (LibHalChangeSet *changeset,
  421. const char *key,
  422. const char **value);
  423. dbus_bool_t libhal_device_commit_changeset (LibHalContext *ctx,
  424. LibHalChangeSet *changeset,
  425. DBusError *error);
  426. void libhal_device_free_changeset (LibHalChangeSet *changeset);
  427. /* Retrieve all the properties on a device. */
  428. LibHalPropertySet *libhal_device_get_all_properties (LibHalContext *ctx,
  429. const char *udi,
  430. DBusError *error);
  431. /* Get all devices and their properties */
  432. dbus_bool_t libhal_get_all_devices_with_properties (LibHalContext *ctx,
  433. int *out_num_devices,
  434. char ***out_udi,
  435. LibHalPropertySet ***out_properties,
  436. DBusError *error);
  437. /* sort all properties according to property name */
  438. void libhal_property_set_sort (LibHalPropertySet *set);
  439. /* Free a property set earlier obtained with libhal_device_get_all_properties(). */
  440. void libhal_free_property_set (LibHalPropertySet *set);
  441. /* Get the number of properties in a property set. */
  442. unsigned int libhal_property_set_get_num_elems (LibHalPropertySet *set);
  443. /* Get type of property. */
  444. LibHalPropertyType libhal_ps_get_type (const LibHalPropertySet *set, const char *key);
  445. /* Get the value of a property of type string. */
  446. const char *libhal_ps_get_string (const LibHalPropertySet *set, const char *key);
  447. /* Get the value of a property of type signed integer. */
  448. dbus_int32_t libhal_ps_get_int32 (const LibHalPropertySet *set, const char *key);
  449. /* Get the value of a property of type unsigned integer. */
  450. dbus_uint64_t libhal_ps_get_uint64 (const LibHalPropertySet *set, const char *key);
  451. /* Get the value of a property of type double. */
  452. double libhal_ps_get_double (const LibHalPropertySet *set, const char *key);
  453. /* Get the value of a property of type bool. */
  454. dbus_bool_t libhal_ps_get_bool (const LibHalPropertySet *set, const char *key);
  455. /* Get the value of a property of type string list. */
  456. const char * const *libhal_ps_get_strlist (const LibHalPropertySet *set, const char *key);
  457. /**
  458. * LibHalPropertySetIterator:
  459. *
  460. * Iterator for inspecting all properties. Do not access any members;
  461. * use the libhal_psi_* family of functions instead.
  462. */
  463. struct LibHalPropertySetIterator_s {
  464. LibHalPropertySet *set; /**< Property set we are iterating over */
  465. unsigned int idx; /**< Index into current element */
  466. LibHalProperty *cur_prop; /**< Current property being visited */
  467. void *reservered0; /**< Reserved for future use */
  468. void *reservered1; /**< Reserved for future use */
  469. };
  470. typedef struct LibHalPropertySetIterator_s LibHalPropertySetIterator;
  471. /* Initialize a property set iterator. */
  472. void libhal_psi_init (LibHalPropertySetIterator *iter, LibHalPropertySet *set);
  473. /* Determine whether there are more properties to iterate over */
  474. dbus_bool_t libhal_psi_has_more (LibHalPropertySetIterator *iter);
  475. /* Advance iterator to next property. */
  476. void libhal_psi_next (LibHalPropertySetIterator *iter);
  477. /* Get type of property. */
  478. LibHalPropertyType libhal_psi_get_type (LibHalPropertySetIterator *iter);
  479. /* Get the key of a property. */
  480. char *libhal_psi_get_key (LibHalPropertySetIterator *iter);
  481. /* Get the value of a property of type string. */
  482. char *libhal_psi_get_string (LibHalPropertySetIterator *iter);
  483. /* Get the value of a property of type signed integer. */
  484. dbus_int32_t libhal_psi_get_int (LibHalPropertySetIterator *iter);
  485. /* Get the value of a property of type unsigned integer. */
  486. dbus_uint64_t libhal_psi_get_uint64 (LibHalPropertySetIterator *iter);
  487. /* Get the value of a property of type double. */
  488. double libhal_psi_get_double (LibHalPropertySetIterator *iter);
  489. /* Get the value of a property of type bool. */
  490. dbus_bool_t libhal_psi_get_bool (LibHalPropertySetIterator *iter);
  491. /* Get the value of a property of type string list. */
  492. char **libhal_psi_get_strlist (LibHalPropertySetIterator *iter);
  493. /* Get the length of an array of strings */
  494. unsigned int libhal_string_array_length (char **str_array);
  495. /* Frees a NULL-terminated array of strings. If passed NULL, does nothing. */
  496. void libhal_free_string_array (char **str_array);
  497. /* Frees a nul-terminated string */
  498. void libhal_free_string (char *str);
  499. /* Create a new device object which will be hidden from applications
  500. * until the CommitToGdl(), ie. libhal_device_commit_to_gdl(), method is called.
  501. */
  502. char *libhal_new_device (LibHalContext *ctx, DBusError *error);
  503. /* When a hidden device has been built using the NewDevice method, ie.
  504. * libhal_new_device(), and the org.freedesktop.Hal.Device interface
  505. * this function will commit it to the global device list.
  506. */
  507. dbus_bool_t libhal_device_commit_to_gdl (LibHalContext *ctx,
  508. const char *temp_udi,
  509. const char *udi,
  510. DBusError *error);
  511. /* This method can be invoked when a device is removed. The HAL daemon
  512. * will shut down the device. Note that the device may still be in the device
  513. * list if the Persistent property is set to true.
  514. */
  515. dbus_bool_t libhal_remove_device (LibHalContext *ctx,
  516. const char *udi,
  517. DBusError *error);
  518. /* Merge properties from one device to another. */
  519. dbus_bool_t libhal_merge_properties (LibHalContext *ctx,
  520. const char *target_udi,
  521. const char *source_udi,
  522. DBusError *error);
  523. /* Check a set of properties for two devices matches. */
  524. dbus_bool_t libhal_device_matches (LibHalContext *ctx,
  525. const char *udi1,
  526. const char *udi2,
  527. const char *property_namespace,
  528. DBusError *error);
  529. /* Find a device in the GDL where a single string property matches a
  530. * given value.
  531. */
  532. char **libhal_manager_find_device_string_match (LibHalContext *ctx,
  533. const char *key,
  534. const char *value,
  535. int *num_devices,
  536. DBusError *error);
  537. /* Assign a capability to a device. */
  538. dbus_bool_t libhal_device_add_capability (LibHalContext *ctx,
  539. const char *udi,
  540. const char *capability,
  541. DBusError *error);
  542. /* Check if a device has a capability. The result is undefined if the
  543. * device doesn't exist.
  544. */
  545. dbus_bool_t libhal_device_query_capability (LibHalContext *ctx,
  546. const char *udi,
  547. const char *capability,
  548. DBusError *error);
  549. /* Find devices with a given capability. */
  550. char **libhal_find_device_by_capability (LibHalContext *ctx,
  551. const char *capability,
  552. int *num_devices,
  553. DBusError *error);
  554. /* Watch all devices, ie. the device_property_changed callback is
  555. * invoked when the properties on any device changes.
  556. */
  557. dbus_bool_t libhal_device_property_watch_all (LibHalContext *ctx,
  558. DBusError *error);
  559. /* Remove a watch of all devices.
  560. */
  561. dbus_bool_t libhal_device_property_remove_watch_all (LibHalContext *ctx,
  562. DBusError *error);
  563. /* Add a watch on a device, so the device_property_changed callback is
  564. * invoked when the properties on the given device changes.
  565. */
  566. dbus_bool_t libhal_device_add_property_watch (LibHalContext *ctx,
  567. const char *udi,
  568. DBusError *error);
  569. /* Remove a watch on a device */
  570. dbus_bool_t libhal_device_remove_property_watch (LibHalContext *ctx,
  571. const char *udi,
  572. DBusError *error);
  573. /* Take an advisory lock on the device. */
  574. dbus_bool_t libhal_device_lock (LibHalContext *ctx,
  575. const char *udi,
  576. const char *reason_to_lock,
  577. char **reason_why_locked,
  578. DBusError *error);
  579. /* Release an advisory lock on the device. */
  580. dbus_bool_t libhal_device_unlock (LibHalContext *ctx,
  581. const char *udi,
  582. DBusError *error);
  583. dbus_bool_t libhal_device_rescan (LibHalContext *ctx,
  584. const char *udi,
  585. DBusError *error);
  586. dbus_bool_t libhal_device_reprobe (LibHalContext *ctx,
  587. const char *udi,
  588. DBusError *error);
  589. /* Emit a condition from a device (for hald helpers only) */
  590. dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx,
  591. const char *udi,
  592. const char *condition_name,
  593. const char *condition_details,
  594. DBusError *error);
  595. /* Claim an interface for a device (for hald helpers only) */
  596. dbus_bool_t libhal_device_claim_interface (LibHalContext *ctx,
  597. const char *udi,
  598. const char *interface_name,
  599. const char *introspection_xml,
  600. DBusError *error);
  601. /* hald waits for all addons to call this function before announcing the addon (for hald helpers only) */
  602. dbus_bool_t libhal_device_addon_is_ready (LibHalContext *ctx, const char *udi, DBusError *error);
  603. dbus_bool_t libhal_device_singleton_addon_is_ready (LibHalContext *ctx, const char *command_line, DBusError *error);
  604. /* Take a mandatory lock on an interface on a device. */
  605. dbus_bool_t libhal_device_acquire_interface_lock (LibHalContext *ctx,
  606. const char *udi,
  607. const char *interface,
  608. dbus_bool_t exclusive,
  609. DBusError *error);
  610. /* Release a mandatory lock on an interface on a device. */
  611. dbus_bool_t libhal_device_release_interface_lock (LibHalContext *ctx,
  612. const char *udi,
  613. const char *interface,
  614. DBusError *error);
  615. /* Take a mandatory lock on an interface (the lock affects all devices the caller have access to). */
  616. dbus_bool_t libhal_acquire_global_interface_lock (LibHalContext *ctx,
  617. const char *interface,
  618. dbus_bool_t exclusive,
  619. DBusError *error);
  620. /* Release a mandatory lock on an interface (affects all devices the caller have access to). */
  621. dbus_bool_t libhal_release_global_interface_lock (LibHalContext *ctx,
  622. const char *interface,
  623. DBusError *error);
  624. /* Determine if a given caller is locked out of a given interface on a given device */
  625. dbus_bool_t libhal_device_is_caller_locked_out (LibHalContext *ctx,
  626. const char *udi,
  627. const char *interface,
  628. const char *caller,
  629. DBusError *error);
  630. /* Determines whether a determines other processes than the caller holds a lock on the given device. */
  631. dbus_bool_t libhal_device_is_locked_by_others (LibHalContext *ctx,
  632. const char *udi,
  633. const char *interface,
  634. DBusError *error);
  635. /* Determine if a given caller is privileged (requires HAL to be built with PolicyKit support) */
  636. char* libhal_device_is_caller_privileged (LibHalContext *ctx,
  637. const char *udi,
  638. const char *action,
  639. const char *caller,
  640. DBusError *error);
  641. #if defined(__cplusplus)
  642. }
  643. #endif
  644. #endif /* LIBHAL_H */