Top | ![]() |
![]() |
![]() |
![]() |
#define | DBUS_API_SUBJECT_TO_CHANGE |
#define | LIBHAL_DEPRECATED |
enum | LibHalPropertyType |
typedef | LibHalContext |
typedef | LibHalProperty |
typedef | LibHalPropertySet |
struct | LibHalChangeSet_s |
typedef | LibHalChangeSet |
typedef | LibHalPropertySetIterator |
#define LIBHAL_CHECK_LIBHALCONTEXT(_ctx_, _ret_)
Handy macro for checking whether a context is valid.
void (*LibHalIntegrateDBusIntoMainLoop) (LibHalContext *ctx
,DBusConnection *dbus_connection
);
Type for function in application code that integrates a DBusConnection object into its own mainloop.
void (*LibHalDeviceAdded) (LibHalContext *ctx
,const char *udi
);
Type for callback when a device is added.
void (*LibHalDeviceRemoved) (LibHalContext *ctx
,const char *udi
);
Type for callback when a device is removed.
void (*LibHalDeviceNewCapability) (LibHalContext *ctx
,const char *udi
,const char *capability
);
Type for callback when a device gains a new capability.
void (*LibHalDeviceLostCapability) (LibHalContext *ctx
,const char *udi
,const char *capability
);
Type for callback when a device loses a capability.
void (*LibHalDevicePropertyModified) (LibHalContext *ctx
,const char *udi
,const char *key
,dbus_bool_t is_removed
,dbus_bool_t is_added
);
Type for callback when a property of a device changes.
void (*LibHalDeviceCondition) (LibHalContext *ctx
,const char *udi
,const char *condition_name
,const char *condition_detail
);
Type for callback when a non-continuous condition occurs on a device.
void (*LibHalGlobalInterfaceLockAcquired) (LibHalContext *ctx
,const char *interface_name
,const char *lock_owner
,int num_locks
);
Type for callback when someone acquires a global lock.
void (*LibHalGlobalInterfaceLockReleased) (LibHalContext *ctx
,const char *interface_name
,const char *lock_owner
,int num_locks
);
Type for callback when someone releases a global lock.
void (*LibHalInterfaceLockAcquired) (LibHalContext *ctx
,const char *udi
,const char *interface_name
,const char *lock_owner
,int num_locks
);
Type for callback when someone acquires a lock on a device.
void (*LibHalInterfaceLockReleased) (LibHalContext *ctx
,const char *udi
,const char *interface_name
,const char *lock_owner
,int num_locks
);
Type for callback when someone acquires a lock on a device.
void (*LibHalSingletonDeviceAdded) (LibHalContext *ctx
,const char *udi
,const LibHalPropertySet *properties
);
Type for callback for addon singletons when a device is added
void (*LibHalSingletonDeviceRemoved) (LibHalContext *ctx
,const char *udi
,const LibHalPropertySet *properties
);
Type for callback for addon singletons when a device is added
dbus_bool_t libhal_ctx_set_cache (LibHalContext *ctx
,dbus_bool_t use_cache
);
Enable or disable caching. Note: Caching is not actually implemented yet.
dbus_bool_t libhal_ctx_set_dbus_connection (LibHalContext *ctx
,DBusConnection *conn
);
Set DBus connection to use to talk to hald.
DBusConnection *
libhal_ctx_get_dbus_connection (LibHalContext *ctx
);
Get DBus connection used for talking to hald.
dbus_bool_t libhal_ctx_set_user_data (LibHalContext *ctx
,void *user_data
);
Set user data for the context.
void *
libhal_ctx_get_user_data (LibHalContext *ctx
);
Get user data for the context.
dbus_bool_t libhal_ctx_set_device_added (LibHalContext *ctx
,LibHalDeviceAdded callback
);
Set the callback for when a device is added
dbus_bool_t libhal_ctx_set_device_removed (LibHalContext *ctx
,LibHalDeviceRemoved callback
);
Set the callback for when a device is removed.
dbus_bool_t libhal_ctx_set_device_new_capability (LibHalContext *ctx
,LibHalDeviceNewCapability callback
);
Set the callback for when a device gains a new capability.
dbus_bool_t libhal_ctx_set_device_lost_capability (LibHalContext *ctx
,LibHalDeviceLostCapability callback
);
Set the callback for when a device loses a capability
dbus_bool_t libhal_ctx_set_device_property_modified (LibHalContext *ctx
,LibHalDevicePropertyModified callback
);
Set the callback for when a property is modified on a device.
dbus_bool_t libhal_ctx_set_device_condition (LibHalContext *ctx
,LibHalDeviceCondition callback
);
Set the callback for when a device emits a condition
dbus_bool_t libhal_ctx_set_global_interface_lock_acquired (LibHalContext *ctx
,LibHalGlobalInterfaceLockAcquired callback
);
Set the callback for when a global interface lock is acquired.
dbus_bool_t libhal_ctx_set_global_interface_lock_released (LibHalContext *ctx
,LibHalGlobalInterfaceLockReleased callback
);
Set the callback for when a global interface lock is released.
dbus_bool_t libhal_ctx_set_interface_lock_acquired (LibHalContext *ctx
,LibHalInterfaceLockAcquired callback
);
Set the callback for when an interface lock is acquired.
dbus_bool_t libhal_ctx_set_interface_lock_released (LibHalContext *ctx
,LibHalInterfaceLockReleased callback
);
Set the callback for when an interface lock is released.
dbus_bool_t libhal_ctx_set_singleton_device_added (LibHalContext *ctx
,LibHalSingletonDeviceAdded callback
);
Set the callback for when a singleton should handle a new device
dbus_bool_t libhal_ctx_set_singleton_device_removed (LibHalContext *ctx
,LibHalSingletonDeviceRemoved callback
);
Set the callback for when a singleton should discard a device
dbus_bool_t libhal_ctx_init (LibHalContext *ctx
,DBusError *error
);
Initialize the connection to hald.
dbus_bool_t libhal_ctx_shutdown (LibHalContext *ctx
,DBusError *error
);
Shut down a connection to hald.
LibHalContext *
libhal_ctx_init_direct (DBusError *error
);
Create an already initialized connection to hald. This function should only be used by HAL helpers.
char ** libhal_get_all_devices (LibHalContext *ctx
,int *num_devices
,DBusError *error
);
Get all devices in the Global Device List (GDL).
ctx |
the context for the connection to hald |
|
num_devices |
the number of devices will be stored here |
|
error |
pointer to an initialized dbus error object for returning errors or NULL |
An array of device identifiers terminated with NULL. It is
the responsibility of the caller to free with
libhal_free_string_array()
. If an error occurs NULL is returned.
dbus_bool_t libhal_device_exists (LibHalContext *ctx
,const char *udi
,DBusError *error
);
Determine if a device exists.
dbus_bool_t libhal_device_print (LibHalContext *ctx
,const char *udi
,DBusError *error
);
Print a device to stdout; useful for debugging.
dbus_bool_t libhal_device_property_exists (LibHalContext *ctx
,const char *udi
,const char *key
,DBusError *error
);
Determine if a property on a device exists.
char * libhal_device_get_property_string (LibHalContext *ctx
,const char *udi
,const char *key
,DBusError *error
);
Get the value of a property of type string.
ctx |
the context for the connection to hald |
|
udi |
the Unique Device Id |
|
key |
the name of the property |
|
error |
pointer to an initialized dbus error object for returning errors or NULL |
UTF8 nul-terminated string. The caller is responsible for
freeing this string with the function libhal_free_string()
. Returns
NULL if the property didn't exist or we are OOM.
dbus_int32_t libhal_device_get_property_int (LibHalContext *ctx
,const char *udi
,const char *key
,DBusError *error
);
Get the value of a property of type integer.
dbus_uint64_t libhal_device_get_property_uint64 (LibHalContext *ctx
,const char *udi
,const char *key
,DBusError *error
);
Get the value of a property of type signed integer.
double libhal_device_get_property_double (LibHalContext *ctx
,const char *udi
,const char *key
,DBusError *error
);
Get the value of a property of type double.
dbus_bool_t libhal_device_get_property_bool (LibHalContext *ctx
,const char *udi
,const char *key
,DBusError *error
);
Get the value of a property of type bool.
char ** libhal_device_get_property_strlist (LibHalContext *ctx
,const char *udi
,const char *key
,DBusError *error
);
Get the value of a property of type string list.
ctx |
the context for the connection to hald |
|
udi |
unique Device Id |
|
key |
name of the property |
|
error |
pointer to an initialized dbus error object for returning errors or NULL |
Array of pointers to UTF8 nul-terminated strings
terminated by NULL. The caller is responsible for freeing this
string array with the function libhal_free_string_array()
. Returns
NULL if the property didn't exist or we are OOM
dbus_bool_t libhal_device_set_property_string (LibHalContext *ctx
,const char *udi
,const char *key
,const char *value
,DBusError *error
);
Set a property of type string.
dbus_bool_t libhal_device_set_property_int (LibHalContext *ctx
,const char *udi
,const char *key
,dbus_int32_t value
,DBusError *error
);
Set a property of type signed integer.
dbus_bool_t libhal_device_set_property_uint64 (LibHalContext *ctx
,const char *udi
,const char *key
,dbus_uint64_t value
,DBusError *error
);
Set a property of type unsigned integer.
dbus_bool_t libhal_device_set_property_double (LibHalContext *ctx
,const char *udi
,const char *key
,double value
,DBusError *error
);
Set a property of type double.
dbus_bool_t libhal_device_set_property_bool (LibHalContext *ctx
,const char *udi
,const char *key
,dbus_bool_t value
,DBusError *error
);
Set a property of type bool.
dbus_bool_t libhal_device_property_strlist_append (LibHalContext *ctx
,const char *udi
,const char *key
,const char *value
,DBusError *error
);
Append to a property of type strlist.
dbus_bool_t libhal_device_property_strlist_prepend (LibHalContext *ctx
,const char *udi
,const char *key
,const char *value
,DBusError *error
);
Prepend to a property of type strlist.
dbus_bool_t libhal_device_property_strlist_remove_index (LibHalContext *ctx
,const char *udi
,const char *key
,unsigned int idx
,DBusError *error
);
Remove a specified string from a property of type strlist.
dbus_bool_t libhal_device_property_strlist_remove (LibHalContext *ctx
,const char *udi
,const char *key
,const char *value
,DBusError *error
);
Remove a specified string from a property of type strlist.
dbus_bool_t libhal_device_remove_property (LibHalContext *ctx
,const char *udi
,const char *key
,DBusError *error
);
Remove a property.
LibHalPropertyType libhal_device_get_property_type (LibHalContext *ctx
,const char *udi
,const char *key
,DBusError *error
);
Query a property type of a device.
LibHalChangeSet *
libhal_device_new_changeset (const char *udi
);
Request a new changeset object. Used for changing multiple properties at once. Useful when performance is critical and also for atomically updating several properties.
dbus_bool_t libhal_changeset_set_property_string (LibHalChangeSet *changeset
,const char *key
,const char *value
);
Set a property.
dbus_bool_t libhal_changeset_set_property_int (LibHalChangeSet *changeset
,const char *key
,dbus_int32_t value
);
Set a property.
dbus_bool_t libhal_changeset_set_property_uint64 (LibHalChangeSet *changeset
,const char *key
,dbus_uint64_t value
);
Set a property.
dbus_bool_t libhal_changeset_set_property_double (LibHalChangeSet *changeset
,const char *key
,double value
);
Set a property.
dbus_bool_t libhal_changeset_set_property_bool (LibHalChangeSet *changeset
,const char *key
,dbus_bool_t value
);
Set a property.
dbus_bool_t libhal_changeset_set_property_strlist (LibHalChangeSet *changeset
,const char *key
,const char **value
);
Set a property.
dbus_bool_t libhal_device_commit_changeset (LibHalContext *ctx
,LibHalChangeSet *changeset
,DBusError *error
);
Commit a changeset to the daemon.
void
libhal_device_free_changeset (LibHalChangeSet *changeset
);
Free a changeset.
LibHalPropertySet * libhal_device_get_all_properties (LibHalContext *ctx
,const char *udi
,DBusError *error
);
Retrieve all the properties on a device.
dbus_bool_t libhal_get_all_devices_with_properties (LibHalContext *ctx
,int *out_num_devices
,char ***out_udi
,LibHalPropertySet ***out_properties
,DBusError *error
);
Get all devices in the hal database as well as all properties for each device.
Return: TRUE
if success; FALSE
and error
will be set.
out_num_devices |
Return location for number of devices |
|
out_udi |
Return location for array of of udi's. Caller should free this with |
|
out_properties |
Return location for array of LibHalPropertySet objects. Caller should free each one of them with |
|
error |
Return location for error |
void
libhal_property_set_sort (LibHalPropertySet *set
);
Sort all properties according to property name.
void
libhal_free_property_set (LibHalPropertySet *set
);
Free a property set earlier obtained with libhal_device_get_all_properties()
.
unsigned int
libhal_property_set_get_num_elems (LibHalPropertySet *set
);
Get the number of properties in a property set.
LibHalPropertyType libhal_ps_get_type (const LibHalPropertySet *set
,const char *key
);
Get the type of a given property.
the LibHalPropertyType of the given property, LIBHAL_PROPERTY_TYPE_INVALID if property is not in the set
const char * libhal_ps_get_string (const LibHalPropertySet *set
,const char *key
);
Get the value of a property of type string.
UTF8 nul-terminated string. This pointer is only valid
until libhal_free_property_set()
is invoked on the property set
this property belongs to. NULL if property is not in the set or not a string
dbus_int32_t libhal_ps_get_int32 (const LibHalPropertySet *set
,const char *key
);
dbus_uint64_t libhal_ps_get_uint64 (const LibHalPropertySet *set
,const char *key
);
Get the value of a property of type unsigned integer.
double libhal_ps_get_double (const LibHalPropertySet *set
,const char *key
);
Get the value of a property of type double.
dbus_bool_t libhal_ps_get_bool (const LibHalPropertySet *set
,const char *key
);
Get the value of a property of type bool.
void libhal_psi_init (LibHalPropertySetIterator *iter
,LibHalPropertySet *set
);
Initialize a property set iterator.
dbus_bool_t
libhal_psi_has_more (LibHalPropertySetIterator *iter
);
Determine whether there are more properties to iterate over.
void
libhal_psi_next (LibHalPropertySetIterator *iter
);
Advance iterator to next property.
LibHalPropertyType
libhal_psi_get_type (LibHalPropertySetIterator *iter
);
Get type of property.
char *
libhal_psi_get_key (LibHalPropertySetIterator *iter
);
Get the key of a property.
ASCII nul-terminated string. This pointer is only valid
until libhal_free_property_set()
is invoked on the property set
this property belongs to.
char *
libhal_psi_get_string (LibHalPropertySetIterator *iter
);
Get the value of a property of type string.
UTF8 nul-terminated string. This pointer is only valid
until libhal_free_property_set()
is invoked on the property set
this property belongs to.
dbus_int32_t
libhal_psi_get_int (LibHalPropertySetIterator *iter
);
Get the value of a property of type signed integer.
dbus_uint64_t
libhal_psi_get_uint64 (LibHalPropertySetIterator *iter
);
Get the value of a property of type unsigned integer.
double
libhal_psi_get_double (LibHalPropertySetIterator *iter
);
Get the value of a property of type double.
dbus_bool_t
libhal_psi_get_bool (LibHalPropertySetIterator *iter
);
Get the value of a property of type bool.
char **
libhal_psi_get_strlist (LibHalPropertySetIterator *iter
);
Get the value of a property of type string list.
unsigned int
libhal_string_array_length (char **str_array
);
Get the length of an array of strings.
void
libhal_free_string_array (char **str_array
);
Frees a NULL-terminated array of strings. If passed NULL, does nothing.
char * libhal_new_device (LibHalContext *ctx
,DBusError *error
);
Create a new device object which will be hidden from applications
until the CommitToGdl()
, ie. libhal_device_commit_to_gdl()
, method
is called. Note that the program invoking this method needs to run
with super user privileges.
dbus_bool_t libhal_device_commit_to_gdl (LibHalContext *ctx
,const char *temp_udi
,const char *udi
,DBusError *error
);
When a hidden device has been built using the NewDevice method,
ie. libhal_new_device()
, and the org.freedesktop.Hal.Device
interface this function will commit it to the global device list.
This means that the device object will be visible to applications and the HAL daemon will possibly attempt to boot the device (depending on the property RequireEnable).
Note that the program invoking this method needs to run with super user privileges.
ctx |
the context for the connection to hald |
|
temp_udi |
the temporary unique device id as returned by |
|
udi |
the new unique device id. |
|
error |
pointer to an initialized dbus error object for returning errors or NULL |
dbus_bool_t libhal_remove_device (LibHalContext *ctx
,const char *udi
,DBusError *error
);
This method can be invoked when a device is removed. The HAL daemon will shut down the device. Note that the device may still be in the device list if the Persistent property is set to true.
Note that the program invoking this method needs to run with super user privileges.
dbus_bool_t libhal_merge_properties (LibHalContext *ctx
,const char *target_udi
,const char *source_udi
,DBusError *error
);
Merge properties from one device to another.
dbus_bool_t libhal_device_matches (LibHalContext *ctx
,const char *udi1
,const char *udi2
,const char *property_namespace
,DBusError *error
);
Check a set of properties for two devices matches.
Checks that all properties where keys, starting with a given value (namespace), of the first device is in the second device and that they got the same value and type.
Note that the other inclusion isn't tested, so there could be properties (from the given namespace) in the second device not present in the first device.
char ** libhal_manager_find_device_string_match (LibHalContext *ctx
,const char *key
,const char *value
,int *num_devices
,DBusError *error
);
Find a device in the GDL where a single string property matches a given value.
dbus_bool_t libhal_device_add_capability (LibHalContext *ctx
,const char *udi
,const char *capability
,DBusError *error
);
Assign a capability to a device.
dbus_bool_t libhal_device_query_capability (LibHalContext *ctx
,const char *udi
,const char *capability
,DBusError *error
);
Check if a device has a capability. The result is undefined if the device doesn't exist.
char ** libhal_find_device_by_capability (LibHalContext *ctx
,const char *capability
,int *num_devices
,DBusError *error
);
Find devices with a given capability.
dbus_bool_t libhal_device_property_watch_all (LibHalContext *ctx
,DBusError *error
);
Watch all devices, ie. the device_property_changed callback is invoked when the properties on any device changes.
dbus_bool_t libhal_device_property_remove_watch_all (LibHalContext *ctx
,DBusError *error
);
dbus_bool_t libhal_device_add_property_watch (LibHalContext *ctx
,const char *udi
,DBusError *error
);
Add a watch on a device, so the device_property_changed callback is invoked when the properties on the given device changes.
The application itself is responsible for deleting the watch, using libhal_device_remove_property_watch, if the device is removed.
dbus_bool_t libhal_device_remove_property_watch (LibHalContext *ctx
,const char *udi
,DBusError *error
);
Remove a watch on a device.
dbus_bool_t libhal_device_lock (LibHalContext *ctx
,const char *udi
,const char *reason_to_lock
,char **reason_why_locked
,DBusError *error
);
Take an advisory lock on the device.
ctx |
the context for the connection to hald |
|
udi |
the Unique Device Id |
|
reason_to_lock |
a user-presentable reason why the device is locked. |
|
reason_why_locked |
a pointer to store the reason why the device cannot be locked on failure, or NULL |
|
error |
pointer to an initialized dbus error object for returning errors or NULL |
dbus_bool_t libhal_device_unlock (LibHalContext *ctx
,const char *udi
,DBusError *error
);
Release an advisory lock on the device.
dbus_bool_t libhal_device_rescan (LibHalContext *ctx
,const char *udi
,DBusError *error
);
TODO document me.
dbus_bool_t libhal_device_reprobe (LibHalContext *ctx
,const char *udi
,DBusError *error
);
TODO document me.
dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx
,const char *udi
,const char *condition_name
,const char *condition_details
,DBusError *error
);
Emit a condition from a device. Can only be used from hald helpers.
dbus_bool_t libhal_device_claim_interface (LibHalContext *ctx
,const char *udi
,const char *interface_name
,const char *introspection_xml
,DBusError *error
);
Claim an interface for a device. All messages to this interface will be forwarded to the helper. Can only be used from hald helpers.
ctx |
the context for the connection to hald |
|
udi |
the Unique Device Id |
|
interface_name |
Name of interface to claim, e.g. org.freedesktop.Hal.Device.FoobarKindOfThing |
|
introspection_xml |
Introspection XML containing what would be inside the interface XML tag |
|
error |
pointer to an initialized dbus error object for returning errors or NULL |
dbus_bool_t libhal_device_addon_is_ready (LibHalContext *ctx
,const char *udi
,DBusError *error
);
HAL addon's must call this method when they are done initializing the device object. The HAL daemon will wait for all addon's to call this.
Can only be used from hald helpers.
dbus_bool_t libhal_device_singleton_addon_is_ready (LibHalContext *ctx
,const char *command_line
,DBusError *error
);
HAL singleton addon's must call this method when they are done initializing the device object. The HAL daemon will wait for all addon's to call this.
Can only be used from hald helpers.
dbus_bool_t libhal_device_acquire_interface_lock (LibHalContext *ctx
,const char *udi
,const char *interface
,dbus_bool_t exclusive
,DBusError *error
);
Releases a lock on an interface for a specific device.
dbus_bool_t libhal_device_release_interface_lock (LibHalContext *ctx
,const char *udi
,const char *interface
,DBusError *error
);
Acquires a lock on an interface for a specific device.
dbus_bool_t libhal_acquire_global_interface_lock (LibHalContext *ctx
,const char *interface
,dbus_bool_t exclusive
,DBusError *error
);
Acquires a global lock on an interface.
dbus_bool_t libhal_release_global_interface_lock (LibHalContext *ctx
,const char *interface
,DBusError *error
);
Releases a global lock on an interface.
dbus_bool_t libhal_device_is_caller_locked_out (LibHalContext *ctx
,const char *udi
,const char *interface
,const char *caller
,DBusError *error
);
Determines whether a given process on the system message bus is locked out from an interface on a specific device. Only HAL helpers are privileged to use this method.
dbus_bool_t libhal_device_is_locked_by_others (LibHalContext *ctx
,const char *udi
,const char *interface
,DBusError *error
);
Determines whether a determines other processes than the caller holds a lock on the given device.
char * libhal_device_is_caller_privileged (LibHalContext *ctx
,const char *udi
,const char *action
,const char *caller
,DBusError *error
);
Determines if a given caller have a given privilege on a given device. Will always error out if HAL is not built with PolicyKit support.
ctx |
the context for the connection to hald |
|
udi |
the Unique id of device |
|
action |
the action to check for |
|
caller |
the caller to check for |
|
error |
pointer to an initialized dbus error object for returning errors |
The textual reply from PolicyKit. See the PolicyKitResult
enumeration in the PolicyKit documentation for details. The caller
is responsible for freeing this string with the function
libhal_free_string()
.
typedef struct LibHalContext_s LibHalContext;
Context for connection to the HAL daemon. Opaque, use the libhal_ctx_*() family of functions to access it.
typedef struct LibHalPropertySet_s LibHalPropertySet;
Represents a set of properties. Opaque; use the libhal_property_set_*() family of functions to access it.