118c2aff7Sartem /*************************************************************************** 218c2aff7Sartem * CVSID: $Id$ 318c2aff7Sartem * 418c2aff7Sartem * libhal.h : HAL daemon C convenience library headers 518c2aff7Sartem * 618c2aff7Sartem * Copyright (C) 2003 David Zeuthen, <david@fubar.dk> 7*44faeccfSartem * Copyright (C) 2007 Codethink Ltd. Author Rob Taylor <rob.taylor@codethink.co.uk> 818c2aff7Sartem * 918c2aff7Sartem * Licensed under the Academic Free License version 2.1 1018c2aff7Sartem * 1118c2aff7Sartem * This program is free software; you can redistribute it and/or modify 1218c2aff7Sartem * it under the terms of the GNU General Public License as published by 1318c2aff7Sartem * the Free Software Foundation; either version 2 of the License, or 1418c2aff7Sartem * (at your option) any later version. 1518c2aff7Sartem * 1618c2aff7Sartem * This program is distributed in the hope that it will be useful, 1718c2aff7Sartem * but WITHOUT ANY WARRANTY; without even the implied warranty of 1818c2aff7Sartem * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1918c2aff7Sartem * GNU General Public License for more details. 2018c2aff7Sartem * 2118c2aff7Sartem * You should have received a copy of the GNU General Public License 2218c2aff7Sartem * along with this program; if not, write to the Free Software 2318c2aff7Sartem * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 2418c2aff7Sartem * 2518c2aff7Sartem **************************************************************************/ 2618c2aff7Sartem 2718c2aff7Sartem #ifndef LIBHAL_H 2818c2aff7Sartem #define LIBHAL_H 2918c2aff7Sartem 3018c2aff7Sartem #include <dbus/dbus.h> 3118c2aff7Sartem 3218c2aff7Sartem #if defined(__cplusplus) 3318c2aff7Sartem extern "C" { 3418c2aff7Sartem #if 0 3518c2aff7Sartem } /* shut up emacs indenting */ 3618c2aff7Sartem #endif 3718c2aff7Sartem #endif 3818c2aff7Sartem 3918c2aff7Sartem #if defined(__GNUC__) 4018c2aff7Sartem #define LIBHAL_DEPRECATED __attribute__ ((deprecated)) 4118c2aff7Sartem #else 4218c2aff7Sartem #define LIBHAL_DEPRECATED 4318c2aff7Sartem #endif 4418c2aff7Sartem 4518c2aff7Sartem 4618c2aff7Sartem #define LIBHAL_FREE_DBUS_ERROR(_dbus_error_) \ 4718c2aff7Sartem do { \ 4818c2aff7Sartem if (dbus_error_is_set(_dbus_error_)) \ 4918c2aff7Sartem dbus_error_free (_dbus_error_); \ 5018c2aff7Sartem } while (0) 5118c2aff7Sartem 5218c2aff7Sartem 5318c2aff7Sartem /** 5418c2aff7Sartem * LIBHAL_CHECK_LIBHALCONTEXT: 5518c2aff7Sartem * @_ctx_: the context 5618c2aff7Sartem * @_ret_: what to use for return value if context is invalid 5718c2aff7Sartem * 5818c2aff7Sartem * Handy macro for checking whether a context is valid. 5918c2aff7Sartem */ 6018c2aff7Sartem #define LIBHAL_CHECK_LIBHALCONTEXT(_ctx_, _ret_) \ 6118c2aff7Sartem do { \ 6218c2aff7Sartem if (_ctx_ == NULL) { \ 6318c2aff7Sartem fprintf (stderr, \ 6418c2aff7Sartem "%s %d : LibHalContext *ctx is NULL\n", \ 6518c2aff7Sartem __FILE__, __LINE__); \ 6618c2aff7Sartem return _ret_; \ 6718c2aff7Sartem } \ 6818c2aff7Sartem } while(0) 6918c2aff7Sartem 7018c2aff7Sartem /** 7118c2aff7Sartem * LibHalPropertyType: 7218c2aff7Sartem * 7318c2aff7Sartem * Possible types for properties on hal device objects 7418c2aff7Sartem */ 7518c2aff7Sartem typedef enum { 7618c2aff7Sartem /** Used to report error condition */ 7718c2aff7Sartem LIBHAL_PROPERTY_TYPE_INVALID = DBUS_TYPE_INVALID, 7818c2aff7Sartem 7918c2aff7Sartem /** Type for 32-bit signed integer property */ 8018c2aff7Sartem LIBHAL_PROPERTY_TYPE_INT32 = DBUS_TYPE_INT32, 8118c2aff7Sartem 8218c2aff7Sartem /** Type for 64-bit unsigned integer property */ 8318c2aff7Sartem LIBHAL_PROPERTY_TYPE_UINT64 = DBUS_TYPE_UINT64, 8418c2aff7Sartem 8518c2aff7Sartem /** Type for double precision floating point property */ 8618c2aff7Sartem LIBHAL_PROPERTY_TYPE_DOUBLE = DBUS_TYPE_DOUBLE, 8718c2aff7Sartem 8818c2aff7Sartem /** Type for boolean property */ 8918c2aff7Sartem LIBHAL_PROPERTY_TYPE_BOOLEAN = DBUS_TYPE_BOOLEAN, 9018c2aff7Sartem 9118c2aff7Sartem /** Type for UTF-8 string property */ 9218c2aff7Sartem LIBHAL_PROPERTY_TYPE_STRING = DBUS_TYPE_STRING, 9318c2aff7Sartem 9418c2aff7Sartem /** Type for list of UTF-8 strings property */ 9518c2aff7Sartem LIBHAL_PROPERTY_TYPE_STRLIST = ((int) (DBUS_TYPE_STRING<<8)+('l')) 9618c2aff7Sartem } LibHalPropertyType; 9718c2aff7Sartem 9818c2aff7Sartem 9918c2aff7Sartem typedef struct LibHalContext_s LibHalContext; 10018c2aff7Sartem 10118c2aff7Sartem /** 10218c2aff7Sartem * LibHalIntegrateDBusIntoMainLoop: 10318c2aff7Sartem * @ctx: context for connection to hald 10418c2aff7Sartem * @dbus_connection: DBus connection to use in ctx 10518c2aff7Sartem * 10618c2aff7Sartem * Type for function in application code that integrates a 10718c2aff7Sartem * DBusConnection object into its own mainloop. 10818c2aff7Sartem */ 10918c2aff7Sartem typedef void (*LibHalIntegrateDBusIntoMainLoop) (LibHalContext *ctx, 11018c2aff7Sartem DBusConnection *dbus_connection); 11118c2aff7Sartem 11218c2aff7Sartem /** 11318c2aff7Sartem * LibHalDeviceAdded: 11418c2aff7Sartem * @ctx: context for connection to hald 11518c2aff7Sartem * @udi: the Unique Device Id 11618c2aff7Sartem * 11718c2aff7Sartem * Type for callback when a device is added. 11818c2aff7Sartem */ 11918c2aff7Sartem typedef void (*LibHalDeviceAdded) (LibHalContext *ctx, 12018c2aff7Sartem const char *udi); 12118c2aff7Sartem 12218c2aff7Sartem /** 12318c2aff7Sartem * LibHalDeviceRemoved: 12418c2aff7Sartem * @ctx: context for connection to hald 12518c2aff7Sartem * @udi: the Unique Device Id 12618c2aff7Sartem * 12718c2aff7Sartem * Type for callback when a device is removed. 12818c2aff7Sartem */ 12918c2aff7Sartem typedef void (*LibHalDeviceRemoved) (LibHalContext *ctx, 13018c2aff7Sartem const char *udi); 13118c2aff7Sartem 13218c2aff7Sartem /** 13318c2aff7Sartem * LibHalDeviceNewCapability: 13418c2aff7Sartem * @ctx: context for connection to hald 13518c2aff7Sartem * @udi: the Unique Device Id 13618c2aff7Sartem * @capability: capability of the device 13718c2aff7Sartem * 13818c2aff7Sartem * Type for callback when a device gains a new capability. 13918c2aff7Sartem * 14018c2aff7Sartem */ 14118c2aff7Sartem typedef void (*LibHalDeviceNewCapability) (LibHalContext *ctx, 14218c2aff7Sartem const char *udi, 14318c2aff7Sartem const char *capability); 14418c2aff7Sartem 14518c2aff7Sartem /** 14618c2aff7Sartem * LibHalDeviceLostCapability: 14718c2aff7Sartem * @ctx: context for connection to hald 14818c2aff7Sartem * @udi: the Unique Device Id 14918c2aff7Sartem * @capability: capability of the device 15018c2aff7Sartem * 15118c2aff7Sartem * Type for callback when a device loses a capability. 15218c2aff7Sartem * 15318c2aff7Sartem */ 15418c2aff7Sartem typedef void (*LibHalDeviceLostCapability) (LibHalContext *ctx, 15518c2aff7Sartem const char *udi, 15618c2aff7Sartem const char *capability); 15718c2aff7Sartem 15818c2aff7Sartem /** 15918c2aff7Sartem * LibHalDevicePropertyModified: 16018c2aff7Sartem * @ctx: context for connection to hald 16118c2aff7Sartem * @udi: the Unique Device Id 16218c2aff7Sartem * @key: name of the property that has changed 16318c2aff7Sartem * @is_removed: whether or not property was removed 16418c2aff7Sartem * @is_added: whether or not property was added 16518c2aff7Sartem * 16618c2aff7Sartem * Type for callback when a property of a device changes. 16718c2aff7Sartem */ 16818c2aff7Sartem typedef void (*LibHalDevicePropertyModified) (LibHalContext *ctx, 16918c2aff7Sartem const char *udi, 17018c2aff7Sartem const char *key, 17118c2aff7Sartem dbus_bool_t is_removed, 17218c2aff7Sartem dbus_bool_t is_added); 17318c2aff7Sartem 17418c2aff7Sartem /** 17518c2aff7Sartem * LibHalDeviceCondition: 17618c2aff7Sartem * @ctx: context for connection to hald 17718c2aff7Sartem * @udi: the Unique Device Id 17818c2aff7Sartem * @condition_name: name of the condition, e.g. ProcessorOverheating. Consult the HAL spec for details 17918c2aff7Sartem * @condition_detail: detail of condition 18018c2aff7Sartem * 18118c2aff7Sartem * Type for callback when a non-continuous condition occurs on a device. 18218c2aff7Sartem */ 18318c2aff7Sartem typedef void (*LibHalDeviceCondition) (LibHalContext *ctx, 18418c2aff7Sartem const char *udi, 18518c2aff7Sartem const char *condition_name, 18618c2aff7Sartem const char *condition_detail); 18718c2aff7Sartem 18818c2aff7Sartem 18918c2aff7Sartem /* Create a new context for a connection with hald */ 19018c2aff7Sartem LibHalContext *libhal_ctx_new (void); 19118c2aff7Sartem 19218c2aff7Sartem /* Enable or disable caching */ 19318c2aff7Sartem dbus_bool_t libhal_ctx_set_cache (LibHalContext *ctx, dbus_bool_t use_cache); 19418c2aff7Sartem 19518c2aff7Sartem /* Set DBus connection to use to talk to hald. */ 19618c2aff7Sartem dbus_bool_t libhal_ctx_set_dbus_connection (LibHalContext *ctx, DBusConnection *conn); 19718c2aff7Sartem 19818c2aff7Sartem /* Get DBus connection to use to talk to hald. */ 19918c2aff7Sartem DBusConnection *libhal_ctx_get_dbus_connection (LibHalContext *ctx); 20018c2aff7Sartem 20118c2aff7Sartem /* Set user data for the context */ 20218c2aff7Sartem dbus_bool_t libhal_ctx_set_user_data (LibHalContext *ctx, void *user_data); 20318c2aff7Sartem 20418c2aff7Sartem /* Get user data for the context */ 20518c2aff7Sartem void* libhal_ctx_get_user_data (LibHalContext *ctx); 20618c2aff7Sartem 20718c2aff7Sartem /* Set the callback for when a device is added */ 20818c2aff7Sartem dbus_bool_t libhal_ctx_set_device_added (LibHalContext *ctx, LibHalDeviceAdded callback); 20918c2aff7Sartem 21018c2aff7Sartem /* Set the callback for when a device is removed */ 21118c2aff7Sartem dbus_bool_t libhal_ctx_set_device_removed (LibHalContext *ctx, LibHalDeviceRemoved callback); 21218c2aff7Sartem 21318c2aff7Sartem /* Set the callback for when a device gains a new capability */ 21418c2aff7Sartem dbus_bool_t libhal_ctx_set_device_new_capability (LibHalContext *ctx, LibHalDeviceNewCapability callback); 21518c2aff7Sartem 21618c2aff7Sartem /* Set the callback for when a device loses a capability */ 21718c2aff7Sartem dbus_bool_t libhal_ctx_set_device_lost_capability (LibHalContext *ctx, LibHalDeviceLostCapability callback); 21818c2aff7Sartem 21918c2aff7Sartem /* Set the callback for when a property is modified on a device */ 22018c2aff7Sartem dbus_bool_t libhal_ctx_set_device_property_modified (LibHalContext *ctx, LibHalDevicePropertyModified callback); 22118c2aff7Sartem 22218c2aff7Sartem /* Set the callback for when a device emits a condition */ 22318c2aff7Sartem dbus_bool_t libhal_ctx_set_device_condition (LibHalContext *ctx, LibHalDeviceCondition callback); 22418c2aff7Sartem 22518c2aff7Sartem /* Initialize the connection to hald */ 22618c2aff7Sartem dbus_bool_t libhal_ctx_init (LibHalContext *ctx, DBusError *error); 22718c2aff7Sartem 22818c2aff7Sartem /* Shut down a connection to hald */ 22918c2aff7Sartem dbus_bool_t libhal_ctx_shutdown (LibHalContext *ctx, DBusError *error); 23018c2aff7Sartem 23118c2aff7Sartem /* Free a LibHalContext resource */ 23218c2aff7Sartem dbus_bool_t libhal_ctx_free (LibHalContext *ctx); 23318c2aff7Sartem 23418c2aff7Sartem /* Create an already initialized connection to hald */ 23518c2aff7Sartem LibHalContext *libhal_ctx_init_direct (DBusError *error); 23618c2aff7Sartem 23718c2aff7Sartem /* Get all devices in the Global Device List (GDL). */ 23818c2aff7Sartem char **libhal_get_all_devices (LibHalContext *ctx, int *num_devices, DBusError *error); 23918c2aff7Sartem 24018c2aff7Sartem /* Determine if a device exists. */ 24118c2aff7Sartem dbus_bool_t libhal_device_exists (LibHalContext *ctx, const char *udi, DBusError *error); 24218c2aff7Sartem 24318c2aff7Sartem /* Print a device to stdout; useful for debugging. */ 24418c2aff7Sartem dbus_bool_t libhal_device_print (LibHalContext *ctx, const char *udi, DBusError *error); 24518c2aff7Sartem 24618c2aff7Sartem /* Determine if a property on a device exists. */ 24718c2aff7Sartem dbus_bool_t libhal_device_property_exists (LibHalContext *ctx, 24818c2aff7Sartem const char *udi, 24918c2aff7Sartem const char *key, 25018c2aff7Sartem DBusError *error); 25118c2aff7Sartem 25218c2aff7Sartem /* Get the value of a property of type string. */ 25318c2aff7Sartem char *libhal_device_get_property_string (LibHalContext *ctx, 25418c2aff7Sartem const char *udi, 25518c2aff7Sartem const char *key, 25618c2aff7Sartem DBusError *error); 25718c2aff7Sartem 25818c2aff7Sartem /* Get the value of a property of type signed integer. */ 25918c2aff7Sartem dbus_int32_t libhal_device_get_property_int (LibHalContext *ctx, 26018c2aff7Sartem const char *udi, 26118c2aff7Sartem const char *key, 26218c2aff7Sartem DBusError *error); 26318c2aff7Sartem 26418c2aff7Sartem /* Get the value of a property of type unsigned integer. */ 26518c2aff7Sartem dbus_uint64_t libhal_device_get_property_uint64 (LibHalContext *ctx, 26618c2aff7Sartem const char *udi, 26718c2aff7Sartem const char *key, 26818c2aff7Sartem DBusError *error); 26918c2aff7Sartem 27018c2aff7Sartem /* Get the value of a property of type double. */ 27118c2aff7Sartem double libhal_device_get_property_double (LibHalContext *ctx, 27218c2aff7Sartem const char *udi, 27318c2aff7Sartem const char *key, 27418c2aff7Sartem DBusError *error); 27518c2aff7Sartem 27618c2aff7Sartem /* Get the value of a property of type bool. */ 27718c2aff7Sartem dbus_bool_t libhal_device_get_property_bool (LibHalContext *ctx, 27818c2aff7Sartem const char *udi, 27918c2aff7Sartem const char *key, 28018c2aff7Sartem DBusError *error); 28118c2aff7Sartem 28218c2aff7Sartem /* Get the value of a property of type string list. */ 28318c2aff7Sartem char **libhal_device_get_property_strlist (LibHalContext *ctx, 28418c2aff7Sartem const char *udi, 28518c2aff7Sartem const char *key, 28618c2aff7Sartem DBusError *error); 28718c2aff7Sartem 28818c2aff7Sartem /* Set a property of type string. */ 28918c2aff7Sartem dbus_bool_t libhal_device_set_property_string (LibHalContext *ctx, 29018c2aff7Sartem const char *udi, 29118c2aff7Sartem const char *key, 29218c2aff7Sartem const char *value, 29318c2aff7Sartem DBusError *error); 29418c2aff7Sartem 29518c2aff7Sartem /* Set a property of type signed integer. */ 29618c2aff7Sartem dbus_bool_t libhal_device_set_property_int (LibHalContext *ctx, 29718c2aff7Sartem const char *udi, 29818c2aff7Sartem const char *key, 29918c2aff7Sartem dbus_int32_t value, 30018c2aff7Sartem DBusError *error); 30118c2aff7Sartem 30218c2aff7Sartem /* Set a property of type unsigned integer. */ 30318c2aff7Sartem dbus_bool_t libhal_device_set_property_uint64 (LibHalContext *ctx, 30418c2aff7Sartem const char *udi, 30518c2aff7Sartem const char *key, 30618c2aff7Sartem dbus_uint64_t value, 30718c2aff7Sartem DBusError *error); 30818c2aff7Sartem 30918c2aff7Sartem /* Set a property of type double. */ 31018c2aff7Sartem dbus_bool_t libhal_device_set_property_double (LibHalContext *ctx, 31118c2aff7Sartem const char *udi, 31218c2aff7Sartem const char *key, 31318c2aff7Sartem double value, 31418c2aff7Sartem DBusError *error); 31518c2aff7Sartem 31618c2aff7Sartem /* Set a property of type bool. */ 31718c2aff7Sartem dbus_bool_t libhal_device_set_property_bool (LibHalContext *ctx, 31818c2aff7Sartem const char *udi, 31918c2aff7Sartem const char *key, 32018c2aff7Sartem dbus_bool_t value, 32118c2aff7Sartem DBusError *error); 32218c2aff7Sartem 32318c2aff7Sartem /* Append to a property of type strlist. */ 32418c2aff7Sartem dbus_bool_t libhal_device_property_strlist_append (LibHalContext *ctx, 32518c2aff7Sartem const char *udi, 32618c2aff7Sartem const char *key, 32718c2aff7Sartem const char *value, 32818c2aff7Sartem DBusError *error); 32918c2aff7Sartem 33018c2aff7Sartem /* Prepend to a property of type strlist. */ 33118c2aff7Sartem dbus_bool_t libhal_device_property_strlist_prepend (LibHalContext *ctx, 33218c2aff7Sartem const char *udi, 33318c2aff7Sartem const char *key, 33418c2aff7Sartem const char *value, 33518c2aff7Sartem DBusError *error); 33618c2aff7Sartem 33718c2aff7Sartem /* Remove a specified string from a property of type strlist. */ 33818c2aff7Sartem dbus_bool_t libhal_device_property_strlist_remove_index (LibHalContext *ctx, 33918c2aff7Sartem const char *udi, 34018c2aff7Sartem const char *key, 34118c2aff7Sartem unsigned int idx, 34218c2aff7Sartem DBusError *error); 34318c2aff7Sartem 34418c2aff7Sartem /* Remove a specified string from a property of type strlist. */ 34518c2aff7Sartem dbus_bool_t libhal_device_property_strlist_remove (LibHalContext *ctx, 34618c2aff7Sartem const char *udi, 34718c2aff7Sartem const char *key, 34818c2aff7Sartem const char *value, 34918c2aff7Sartem DBusError *error); 35018c2aff7Sartem 35118c2aff7Sartem /* Remove a property. */ 35218c2aff7Sartem dbus_bool_t libhal_device_remove_property (LibHalContext *ctx, 35318c2aff7Sartem const char *udi, 35418c2aff7Sartem const char *key, 35518c2aff7Sartem DBusError *error); 35618c2aff7Sartem 35718c2aff7Sartem /* Query a property type of a device. */ 35818c2aff7Sartem LibHalPropertyType libhal_device_get_property_type (LibHalContext *ctx, 35918c2aff7Sartem const char *udi, 36018c2aff7Sartem const char *key, 36118c2aff7Sartem DBusError *error); 36218c2aff7Sartem 36318c2aff7Sartem struct LibHalChangeSet_s; 36418c2aff7Sartem typedef struct LibHalChangeSet_s LibHalChangeSet; 36518c2aff7Sartem 36618c2aff7Sartem LibHalChangeSet *libhal_device_new_changeset (const char *udi); 36718c2aff7Sartem 36818c2aff7Sartem dbus_bool_t libhal_changeset_set_property_string (LibHalChangeSet *changeset, 36918c2aff7Sartem const char *key, 37018c2aff7Sartem const char *value); 37118c2aff7Sartem 37218c2aff7Sartem dbus_bool_t libhal_changeset_set_property_int (LibHalChangeSet *changeset, 37318c2aff7Sartem const char *key, 37418c2aff7Sartem dbus_int32_t value); 37518c2aff7Sartem 37618c2aff7Sartem dbus_bool_t libhal_changeset_set_property_uint64 (LibHalChangeSet *changeset, 37718c2aff7Sartem const char *key, 37818c2aff7Sartem dbus_uint64_t value); 37918c2aff7Sartem 38018c2aff7Sartem dbus_bool_t libhal_changeset_set_property_double (LibHalChangeSet *changeset, 38118c2aff7Sartem const char *key, 38218c2aff7Sartem double value); 38318c2aff7Sartem 38418c2aff7Sartem dbus_bool_t libhal_changeset_set_property_bool (LibHalChangeSet *changeset, 38518c2aff7Sartem const char *key, 38618c2aff7Sartem dbus_bool_t value); 38718c2aff7Sartem 38818c2aff7Sartem dbus_bool_t libhal_changeset_set_property_strlist (LibHalChangeSet *changeset, 38918c2aff7Sartem const char *key, 39018c2aff7Sartem const char **value); 39118c2aff7Sartem 39218c2aff7Sartem dbus_bool_t libhal_device_commit_changeset (LibHalContext *ctx, 39318c2aff7Sartem LibHalChangeSet *changeset, 39418c2aff7Sartem DBusError *error); 39518c2aff7Sartem 39618c2aff7Sartem void libhal_device_free_changeset (LibHalChangeSet *changeset); 39718c2aff7Sartem 39818c2aff7Sartem 39918c2aff7Sartem struct LibHalProperty_s; 40018c2aff7Sartem typedef struct LibHalProperty_s LibHalProperty; 40118c2aff7Sartem 40218c2aff7Sartem struct LibHalPropertySet_s; 40318c2aff7Sartem typedef struct LibHalPropertySet_s LibHalPropertySet; 40418c2aff7Sartem 40518c2aff7Sartem 40618c2aff7Sartem /* Retrieve all the properties on a device. */ 40718c2aff7Sartem LibHalPropertySet *libhal_device_get_all_properties (LibHalContext *ctx, 40818c2aff7Sartem const char *udi, 40918c2aff7Sartem DBusError *error); 41018c2aff7Sartem 41118c2aff7Sartem /* Free a property set earlier obtained with libhal_device_get_all_properties(). */ 41218c2aff7Sartem void libhal_free_property_set (LibHalPropertySet *set); 41318c2aff7Sartem 41418c2aff7Sartem /* Get the number of properties in a property set. */ 41518c2aff7Sartem unsigned int libhal_property_set_get_num_elems (LibHalPropertySet *set); 41618c2aff7Sartem 417*44faeccfSartem /* Get type of property. */ 418*44faeccfSartem LibHalPropertyType libhal_ps_get_type (const LibHalPropertySet *set, const char *key); 419*44faeccfSartem 420*44faeccfSartem /* Get the value of a property of type string. */ 421*44faeccfSartem const char *libhal_ps_get_string (const LibHalPropertySet *set, const char *key); 422*44faeccfSartem 423*44faeccfSartem /* Get the value of a property of type signed integer. */ 424*44faeccfSartem dbus_int32_t libhal_ps_get_int32 (const LibHalPropertySet *set, const char *key); 425*44faeccfSartem 426*44faeccfSartem /* Get the value of a property of type unsigned integer. */ 427*44faeccfSartem dbus_uint64_t libhal_ps_get_uint64 (const LibHalPropertySet *set, const char *key); 428*44faeccfSartem 429*44faeccfSartem /* Get the value of a property of type double. */ 430*44faeccfSartem double libhal_ps_get_double (const LibHalPropertySet *set, const char *key); 431*44faeccfSartem 432*44faeccfSartem /* Get the value of a property of type bool. */ 433*44faeccfSartem dbus_bool_t libhal_ps_get_bool (const LibHalPropertySet *set, const char *key); 434*44faeccfSartem 435*44faeccfSartem /* Get the value of a property of type string list. */ 436*44faeccfSartem const char * const *libhal_ps_get_strlist (const LibHalPropertySet *set, const char *key); 437*44faeccfSartem 438*44faeccfSartem 43918c2aff7Sartem /** 44018c2aff7Sartem * LibHalPropertySetIterator: 44118c2aff7Sartem * 44218c2aff7Sartem * Iterator for inspecting all properties. Do not access any members; 44318c2aff7Sartem * use the libhal_psi_* family of functions instead. 44418c2aff7Sartem */ 44518c2aff7Sartem struct LibHalPropertySetIterator_s { 44618c2aff7Sartem LibHalPropertySet *set; /**< Property set we are iterating over */ 44718c2aff7Sartem unsigned int idx; /**< Index into current element */ 44818c2aff7Sartem LibHalProperty *cur_prop; /**< Current property being visited */ 44918c2aff7Sartem void *reservered0; /**< Reserved for future use */ 45018c2aff7Sartem void *reservered1; /**< Reserved for future use */ 45118c2aff7Sartem }; 45218c2aff7Sartem 45318c2aff7Sartem 45418c2aff7Sartem typedef struct LibHalPropertySetIterator_s LibHalPropertySetIterator; 45518c2aff7Sartem 45618c2aff7Sartem /* Initialize a property set iterator. */ 45718c2aff7Sartem void libhal_psi_init (LibHalPropertySetIterator *iter, LibHalPropertySet *set); 45818c2aff7Sartem 45918c2aff7Sartem /* Determine whether there are more properties to iterate over */ 46018c2aff7Sartem dbus_bool_t libhal_psi_has_more (LibHalPropertySetIterator *iter); 46118c2aff7Sartem 46218c2aff7Sartem /* Advance iterator to next property. */ 46318c2aff7Sartem void libhal_psi_next (LibHalPropertySetIterator *iter); 46418c2aff7Sartem 46518c2aff7Sartem /* Get type of property. */ 46618c2aff7Sartem LibHalPropertyType libhal_psi_get_type (LibHalPropertySetIterator *iter); 46718c2aff7Sartem 46818c2aff7Sartem /* Get the key of a property. */ 46918c2aff7Sartem char *libhal_psi_get_key (LibHalPropertySetIterator *iter); 47018c2aff7Sartem 47118c2aff7Sartem /* Get the value of a property of type string. */ 47218c2aff7Sartem char *libhal_psi_get_string (LibHalPropertySetIterator *iter); 47318c2aff7Sartem 47418c2aff7Sartem /* Get the value of a property of type signed integer. */ 47518c2aff7Sartem dbus_int32_t libhal_psi_get_int (LibHalPropertySetIterator *iter); 47618c2aff7Sartem 47718c2aff7Sartem /* Get the value of a property of type unsigned integer. */ 47818c2aff7Sartem dbus_uint64_t libhal_psi_get_uint64 (LibHalPropertySetIterator *iter); 47918c2aff7Sartem 48018c2aff7Sartem /* Get the value of a property of type double. */ 48118c2aff7Sartem double libhal_psi_get_double (LibHalPropertySetIterator *iter); 48218c2aff7Sartem 48318c2aff7Sartem /* Get the value of a property of type bool. */ 48418c2aff7Sartem dbus_bool_t libhal_psi_get_bool (LibHalPropertySetIterator *iter); 48518c2aff7Sartem 48618c2aff7Sartem /* Get the value of a property of type string list. */ 48718c2aff7Sartem char **libhal_psi_get_strlist (LibHalPropertySetIterator *iter); 48818c2aff7Sartem 48918c2aff7Sartem /* Get the length of an array of strings */ 49018c2aff7Sartem unsigned int libhal_string_array_length (char **str_array); 49118c2aff7Sartem 49218c2aff7Sartem /* Frees a NULL-terminated array of strings. If passed NULL, does nothing. */ 49318c2aff7Sartem void libhal_free_string_array (char **str_array); 49418c2aff7Sartem 49518c2aff7Sartem /* Frees a nul-terminated string */ 49618c2aff7Sartem void libhal_free_string (char *str); 49718c2aff7Sartem 49818c2aff7Sartem /* Create a new device object which will be hidden from applications 49918c2aff7Sartem * until the CommitToGdl(), ie. libhal_device_commit_to_gdl(), method is called. 50018c2aff7Sartem */ 50118c2aff7Sartem char *libhal_new_device (LibHalContext *ctx, DBusError *error); 50218c2aff7Sartem 50318c2aff7Sartem /* When a hidden device has been built using the NewDevice method, ie. 50418c2aff7Sartem * libhal_new_device(), and the org.freedesktop.Hal.Device interface 50518c2aff7Sartem * this function will commit it to the global device list. 50618c2aff7Sartem */ 50718c2aff7Sartem dbus_bool_t libhal_device_commit_to_gdl (LibHalContext *ctx, 50818c2aff7Sartem const char *temp_udi, 50918c2aff7Sartem const char *udi, 51018c2aff7Sartem DBusError *error); 51118c2aff7Sartem 51218c2aff7Sartem /* This method can be invoked when a device is removed. The HAL daemon 51318c2aff7Sartem * will shut down the device. Note that the device may still be in the device 51418c2aff7Sartem * list if the Persistent property is set to true. 51518c2aff7Sartem */ 51618c2aff7Sartem dbus_bool_t libhal_remove_device (LibHalContext *ctx, 51718c2aff7Sartem const char *udi, 51818c2aff7Sartem DBusError *error); 51918c2aff7Sartem 52018c2aff7Sartem /* Merge properties from one device to another. */ 52118c2aff7Sartem dbus_bool_t libhal_merge_properties (LibHalContext *ctx, 52218c2aff7Sartem const char *target_udi, 52318c2aff7Sartem const char *source_udi, 52418c2aff7Sartem DBusError *error); 52518c2aff7Sartem 52618c2aff7Sartem /* Check a set of properties for two devices matches. */ 52718c2aff7Sartem dbus_bool_t libhal_device_matches (LibHalContext *ctx, 52818c2aff7Sartem const char *udi1, 52918c2aff7Sartem const char *udi2, 53018c2aff7Sartem const char *property_namespace, 53118c2aff7Sartem DBusError *error); 53218c2aff7Sartem 53318c2aff7Sartem /* Find a device in the GDL where a single string property matches a 53418c2aff7Sartem * given value. 53518c2aff7Sartem */ 53618c2aff7Sartem char **libhal_manager_find_device_string_match (LibHalContext *ctx, 53718c2aff7Sartem const char *key, 53818c2aff7Sartem const char *value, 53918c2aff7Sartem int *num_devices, 54018c2aff7Sartem DBusError *error); 54118c2aff7Sartem 54218c2aff7Sartem /* Assign a capability to a device. */ 54318c2aff7Sartem dbus_bool_t libhal_device_add_capability (LibHalContext *ctx, 54418c2aff7Sartem const char *udi, 54518c2aff7Sartem const char *capability, 54618c2aff7Sartem DBusError *error); 54718c2aff7Sartem 54818c2aff7Sartem /* Check if a device has a capability. The result is undefined if the 54918c2aff7Sartem * device doesn't exist. 55018c2aff7Sartem */ 55118c2aff7Sartem dbus_bool_t libhal_device_query_capability (LibHalContext *ctx, 55218c2aff7Sartem const char *udi, 55318c2aff7Sartem const char *capability, 55418c2aff7Sartem DBusError *error); 55518c2aff7Sartem 55618c2aff7Sartem /* Find devices with a given capability. */ 55718c2aff7Sartem char **libhal_find_device_by_capability (LibHalContext *ctx, 55818c2aff7Sartem const char *capability, 55918c2aff7Sartem int *num_devices, 56018c2aff7Sartem DBusError *error); 56118c2aff7Sartem 56218c2aff7Sartem /* Watch all devices, ie. the device_property_changed callback is 56318c2aff7Sartem * invoked when the properties on any device changes. 56418c2aff7Sartem */ 56518c2aff7Sartem dbus_bool_t libhal_device_property_watch_all (LibHalContext *ctx, 56618c2aff7Sartem DBusError *error); 56718c2aff7Sartem 56818c2aff7Sartem /* Add a watch on a device, so the device_property_changed callback is 56918c2aff7Sartem * invoked when the properties on the given device changes. 57018c2aff7Sartem */ 57118c2aff7Sartem dbus_bool_t libhal_device_add_property_watch (LibHalContext *ctx, 57218c2aff7Sartem const char *udi, 57318c2aff7Sartem DBusError *error); 57418c2aff7Sartem 57518c2aff7Sartem /* Remove a watch on a device */ 57618c2aff7Sartem dbus_bool_t libhal_device_remove_property_watch (LibHalContext *ctx, 57718c2aff7Sartem const char *udi, 57818c2aff7Sartem DBusError *error); 57918c2aff7Sartem 58018c2aff7Sartem /* Take an advisory lock on the device. */ 58118c2aff7Sartem dbus_bool_t libhal_device_lock (LibHalContext *ctx, 58218c2aff7Sartem const char *udi, 58318c2aff7Sartem const char *reason_to_lock, 58418c2aff7Sartem char **reason_why_locked, 58518c2aff7Sartem DBusError *error); 58618c2aff7Sartem 58718c2aff7Sartem /* Release an advisory lock on the device. */ 58818c2aff7Sartem dbus_bool_t libhal_device_unlock (LibHalContext *ctx, 58918c2aff7Sartem const char *udi, 59018c2aff7Sartem DBusError *error); 59118c2aff7Sartem 59218c2aff7Sartem dbus_bool_t libhal_device_rescan (LibHalContext *ctx, 59318c2aff7Sartem const char *udi, 59418c2aff7Sartem DBusError *error); 59518c2aff7Sartem 59618c2aff7Sartem dbus_bool_t libhal_device_reprobe (LibHalContext *ctx, 59718c2aff7Sartem const char *udi, 59818c2aff7Sartem DBusError *error); 59918c2aff7Sartem 60018c2aff7Sartem /* Emit a condition from a device (for hald helpers only) */ 60118c2aff7Sartem dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx, 60218c2aff7Sartem const char *udi, 60318c2aff7Sartem const char *condition_name, 60418c2aff7Sartem const char *condition_details, 60518c2aff7Sartem DBusError *error); 60618c2aff7Sartem 60718c2aff7Sartem /* Claim an interface for a device (for hald helpers only) */ 60818c2aff7Sartem dbus_bool_t libhal_device_claim_interface (LibHalContext *ctx, 60918c2aff7Sartem const char *udi, 61018c2aff7Sartem const char *interface_name, 61118c2aff7Sartem const char *introspection_xml, 61218c2aff7Sartem DBusError *error); 61318c2aff7Sartem 61418c2aff7Sartem /* hald waits for all addons to call this function before announcing the addon (for hald helpers only) */ 61518c2aff7Sartem dbus_bool_t libhal_device_addon_is_ready (LibHalContext *ctx, const char *udi, DBusError *error); 61618c2aff7Sartem 61718c2aff7Sartem 61818c2aff7Sartem #if defined(__cplusplus) 61918c2aff7Sartem } 62018c2aff7Sartem #endif 62118c2aff7Sartem 62218c2aff7Sartem #endif /* LIBHAL_H */ 623