home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / hal / libhal.h < prev   
Encoding:
C/C++ Source or Header  |  2008-10-04  |  28.1 KB  |  789 lines

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