Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

HAL convenience library

A convenience library used to communicate with the HAL daemon using D-BUS. More...

Data Structures

struct  LibHalPropertySet_s
 Represents a set of properties. More...
struct  LibHalProperty_s
 Device property class. More...
struct  LibHalContext_s
 Context for connection to the HAL daemon. More...
struct  LibHalFunctions_s
 Big convenience chunk for all callback function pointers. More...
struct  LibHalPropertySetIterator_s
 Iterator for inspecting all properties. More...

Typedefs

typedef void(* LibHalIntegrateDBusIntoMainLoop )(LibHalContext *ctx, DBusConnection *dbus_connection)
 Type for function in application code that integrates a DBusConnection object into it's own mainloop.
typedef void(* LibHalDeviceAdded )(LibHalContext *ctx, const char *udi)
 Type for callback when a device is added.
typedef void(* LibHalDeviceRemoved )(LibHalContext *ctx, const char *udi)
 Type for callback when a device is removed.
typedef void(* LibHalNewCapability )(LibHalContext *ctx, const char *udi, const char *capability)
 Type for callback when a device got a new capability.
typedef void(* LibHalLostCapability )(LibHalContext *ctx, const char *udi, const char *capability)
 Type for callback when a device lost a capability.
typedef 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.
typedef void(* LibHalDeviceCondition )(LibHalContext *ctx, const char *udi, const char *condition_name, DBusMessage *message)
 Type for callback when a non-continuos condition occurs on a device.
typedef LibHalFunctions_s LibHalFunctions
 Big convenience chunk for all callback function pointers.

Functions

void hal_free_string_array (char **str_array)
 Frees a NULL-terminated array of strings.
void hal_free_string (char *str)
 Frees a nul-terminated string.
void hal_ctx_set_user_data (LibHalContext *ctx, void *user_data)
 Set user data for the context.
void * hal_ctx_get_user_data (LibHalContext *ctx)
 Get user data for the context.
LibHalPropertySet * hal_device_get_all_properties (LibHalContext *ctx, const char *udi)
 Retrieve all the properties on a device.
void hal_free_property_set (LibHalPropertySet *set)
 Free a property set earlier obtained with hal_device_get_all_properties().
void hal_psi_init (LibHalPropertySetIterator *iter, LibHalPropertySet *set)
 Initialize a property set iterator.
dbus_bool_t hal_psi_has_more (LibHalPropertySetIterator *iter)
 Determine whether there are more properties to iterate over.
void hal_psi_next (LibHalPropertySetIterator *iter)
 Advance iterator to next property.
int hal_psi_get_type (LibHalPropertySetIterator *iter)
 Get type of property.
char * hal_psi_get_key (LibHalPropertySetIterator *iter)
 Get the key of a property.
char * hal_psi_get_string (LibHalPropertySetIterator *iter)
 Get the value of a property of type string.
dbus_int32_t hal_psi_get_int (LibHalPropertySetIterator *iter)
 Get the value of a property of type integer.
dbus_uint64_t hal_psi_get_uint64 (LibHalPropertySetIterator *iter)
 Get the value of a property of type integer.
double hal_psi_get_double (LibHalPropertySetIterator *iter)
 Get the value of a property of type double.
dbus_bool_t hal_psi_get_bool (LibHalPropertySetIterator *iter)
 Get the value of a property of type bool.
LibHalContext * hal_initialize (const LibHalFunctions *cb_functions, dbus_bool_t use_cache)
 Initialize the HAL library.
int hal_shutdown (LibHalContext *ctx)
 Shutdown the HAL library.
char ** hal_get_all_devices (LibHalContext *ctx, int *num_devices)
 Get all devices in the Global Device List (GDL).
int hal_device_get_property_type (LibHalContext *ctx, const char *udi, const char *key)
 Query a property type of a device.
char * hal_device_get_property_string (LibHalContext *ctx, const char *udi, const char *key)
 Get the value of a property of type string.
dbus_int32_t hal_device_get_property_int (LibHalContext *ctx, const char *udi, const char *key)
 Get the value of a property of type integer.
dbus_uint64_t hal_device_get_property_uint64 (LibHalContext *ctx, const char *udi, const char *key)
 Get the value of a property of type integer.
double hal_device_get_property_double (LibHalContext *ctx, const char *udi, const char *key)
 Get the value of a property of type double.
dbus_bool_t hal_device_get_property_bool (LibHalContext *ctx, const char *udi, const char *key)
 Get the value of a property of type bool.
int hal_device_set_property_helper (LibHalContext *ctx, const char *udi, const char *key, int type, const char *str_value, dbus_int32_t int_value, dbus_uint64_t uint64_value, double double_value, dbus_bool_t bool_value)
dbus_bool_t hal_device_set_property_string (LibHalContext *ctx, const char *udi, const char *key, const char *value)
 Set a property of type string.
dbus_bool_t hal_device_set_property_int (LibHalContext *ctx, const char *udi, const char *key, dbus_int32_t value)
 Set a property of type integer.
dbus_bool_t hal_device_set_property_uint64 (LibHalContext *ctx, const char *udi, const char *key, dbus_uint64_t value)
 Set a property of type integer.
dbus_bool_t hal_device_set_property_double (LibHalContext *ctx, const char *udi, const char *key, double value)
 Set a property of type double.
dbus_bool_t hal_device_set_property_bool (LibHalContext *ctx, const char *udi, const char *key, dbus_bool_t value)
 Set a property of type bool.
dbus_bool_t hal_device_remove_property (LibHalContext *ctx, const char *udi, const char *key)
 Remove a property.
dbus_bool_t hal_device_lock (LibHalContext *ctx, const char *udi, const char *reason_to_lock, char **reason_why_locked)
 Take an advisory lock on the device.
dbus_bool_t hal_device_unlock (LibHalContext *ctx, const char *udi)
 Release an advisory lock on the device.
char * hal_agent_new_device (LibHalContext *ctx)
 Create a new device object which will be hidden from applications until the CommitToGdl(), ie.
dbus_bool_t hal_agent_commit_to_gdl (LibHalContext *ctx, const char *temp_udi, const char *udi)
 When a hidden device have been built using the NewDevice method, ie.
dbus_bool_t hal_agent_remove_device (LibHalContext *ctx, const char *udi)
 This method can be invoked when a device is removed.
dbus_bool_t hal_device_exists (LibHalContext *ctx, const char *udi)
 Determine if a device exists.
dbus_bool_t hal_device_property_exists (LibHalContext *ctx, const char *udi, const char *key)
 Determine if a property on a device exists.
dbus_bool_t hal_agent_merge_properties (LibHalContext *ctx, const char *target_udi, const char *source_udi)
 Merge properties from one device to another.
dbus_bool_t hal_agent_device_matches (LibHalContext *ctx, const char *udi1, const char *udi2, const char *property_namespace)
 Check a set of properties for two devices matches.
void hal_device_print (LibHalContext *ctx, const char *udi)
 Print a device to stdout; useful for debugging.
char ** hal_manager_find_device_string_match (LibHalContext *ctx, const char *key, const char *value, int *num_devices)
 Find a device in the GDL where a single string property matches a given value.
dbus_bool_t hal_device_add_capability (LibHalContext *ctx, const char *udi, const char *capability)
 Assign a capability to a device.
dbus_bool_t hal_device_query_capability (LibHalContext *ctx, const char *udi, const char *capability)
 Check if a device got a capability.
char ** hal_find_device_by_capability (LibHalContext *ctx, const char *capability, int *num_devices)
 Find devices with a given capability.
int hal_device_property_watch_all (LibHalContext *ctx)
 Watch all devices, ie.
int hal_device_add_property_watch (LibHalContext *ctx, const char *udi)
 Add a watch on a device, so the device_property_changed callback is invoked when the properties on the given device changes.
int hal_device_remove_property_watch (LibHalContext *ctx, const char *udi)
 Remove a watch on a device.

Variables

dbus_bool_t hal_already_initialized_once = FALSE

Detailed Description

A convenience library used to communicate with the HAL daemon using D-BUS.


Typedef Documentation

typedef void(* LibHalDeviceAdded)(LibHalContext *ctx, const char *udi)
 

Type for callback when a device is added.

Parameters:
udi Unique Device Id

Definition at line 58 of file libhal.h.

typedef void(* LibHalDeviceCondition)(LibHalContext *ctx, const char *udi, const char *condition_name, DBusMessage *message)
 

Type for callback when a non-continuos condition occurs on a device.

Parameters:
udi Unique Device Id
condition_name Name of the condition, e.g. ProcessorOverheating. Consult the HAL spec for possible conditions
message D-BUS message with variable parameters depending on condition

Definition at line 106 of file libhal.h.

typedef 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.

Parameters:
udi Unique Device Id
key Name of the property that has changed
is_removed Property removed
is_added Property added

Definition at line 91 of file libhal.h.

typedef void(* LibHalDeviceRemoved)(LibHalContext *ctx, const char *udi)
 

Type for callback when a device is removed.

Parameters:
udi Unique Device Id

Definition at line 64 of file libhal.h.

typedef struct LibHalFunctions_s LibHalFunctions
 

Big convenience chunk for all callback function pointers.

Every function pointer can be set to NULL to indicate that the callback is not requested.

Referenced by hal_initialize().

typedef void(* LibHalIntegrateDBusIntoMainLoop)(LibHalContext *ctx, DBusConnection *dbus_connection)
 

Type for function in application code that integrates a DBusConnection object into it's own mainloop.

Parameters:
udi Unique Device Id

Definition at line 50 of file libhal.h.

typedef void(* LibHalLostCapability)(LibHalContext *ctx, const char *udi, const char *capability)
 

Type for callback when a device lost a capability.

Parameters:
udi Unique Device Id
capability Capability of the device

Definition at line 80 of file libhal.h.

typedef void(* LibHalNewCapability)(LibHalContext *ctx, const char *udi, const char *capability)
 

Type for callback when a device got a new capability.

Parameters:
udi Unique Device Id
capability Capability of the device

Definition at line 71 of file libhal.h.


Function Documentation

dbus_bool_t hal_agent_commit_to_gdl LibHalContext *  ctx,
const char *  temp_udi,
const char *  udi
 

When a hidden device have been built using the NewDevice method, ie.

hal_agent_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.

Parameters:
ctx The context for the connection to hald
temp_udi The tempoary unique device id as returned by hal_agent_new_device()
udi The new unique device id.
Returns:
FALSE if the given unique device id is already in use.

Definition at line 1671 of file libhal.c.

dbus_bool_t hal_agent_device_matches LibHalContext *  ctx,
const char *  udi1,
const char *  udi2,
const char *  property_namespace
 

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.

Parameters:
ctx The context for the connection to hald
udi1 Unique Device Id for device 1
udi2 Unique Device Id for device 2
property_namespace Namespace for set of devices, e.g. "usb"
Returns:
TRUE if all properties starting with the given namespace parameter from one device is in the other and have the same value.

Definition at line 1970 of file libhal.c.

dbus_bool_t hal_agent_merge_properties LibHalContext *  ctx,
const char *  target_udi,
const char *  source_udi
 

Merge properties from one device to another.

Parameters:
ctx The context for the connection to hald
target_udi Unique device id of target device to merge to
source_udi Unique device id of device to merge from
Returns:
TRUE if the properties was merged

Definition at line 1904 of file libhal.c.

char * hal_agent_new_device LibHalContext *  ctx  ) 
 

Create a new device object which will be hidden from applications until the CommitToGdl(), ie.

hal_agent_commit_to_gdl(), method is called.

Note that the program invoking this method needs to run with super user privileges.

Parameters:
ctx The context for the connection to hald
Returns:
Tempoary device unique id or NULL if there was a problem. This string must be freed by the caller.

Todo:
FIXME cleanup

Definition at line 1589 of file libhal.c.

dbus_bool_t hal_agent_remove_device LibHalContext *  ctx,
const char *  udi
 

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.

Parameters:
ctx The context for the connection to hald
udi The new unique device id.
Returns:
TRUE if the device was removed

Definition at line 1729 of file libhal.c.

void * hal_ctx_get_user_data LibHalContext *  ctx  ) 
 

Get user data for the context.

Parameters:
ctx The context for the connection to hald
Returns:
Opaque pointer stored through hal_ctx_set_user_data or NULL if not set

Definition at line 150 of file libhal.c.

void hal_ctx_set_user_data LibHalContext *  ctx,
void *  user_data
 

Set user data for the context.

Parameters:
ctx The context for the connection to hald
user_data Opaque pointer

Definition at line 138 of file libhal.c.

dbus_bool_t hal_device_add_capability LibHalContext *  ctx,
const char *  udi,
const char *  capability
 

Assign a capability to a device.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
capability Capability name
Returns:
TRUE if the capability was added, FALSE if the device didn't exist

Definition at line 2178 of file libhal.c.

int hal_device_add_property_watch LibHalContext *  ctx,
const char *  udi
 

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 hal_device_remove_property_watch, if the device is removed.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
Returns:
Zero if the operation succeeded, otherwise non-zero

Definition at line 2367 of file libhal.c.

dbus_bool_t hal_device_exists LibHalContext *  ctx,
const char *  udi
 

Determine if a device exists.

Parameters:
ctx The context for the connection to hald
udi Unique device id.
Returns:
TRUE if the device exists

Definition at line 1777 of file libhal.c.

LibHalPropertySet * hal_device_get_all_properties LibHalContext *  ctx,
const char *  udi
 

Retrieve all the properties on a device.

Parameters:
ctx The context for the connection to hald
udi Unique id of device
Returns:
An object represent all properties. Must be freed with hal_free_property_set

Todo:
FIXME cleanup

FIXME cleanup

FIXME cleanup

report error

Definition at line 164 of file libhal.c.

Referenced by hal_device_print(), hal_drive_from_udi(), and hal_volume_from_udi().

dbus_bool_t hal_device_get_property_bool LibHalContext *  ctx,
const char *  udi,
const char *  key
 

Get the value of a property of type bool.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
Returns:
Truth value

Definition at line 1178 of file libhal.c.

double hal_device_get_property_double LibHalContext *  ctx,
const char *  udi,
const char *  key
 

Get the value of a property of type double.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
Returns:
IEEE754 double precision float

Definition at line 1107 of file libhal.c.

dbus_int32_t hal_device_get_property_int LibHalContext *  ctx,
const char *  udi,
const char *  key
 

Get the value of a property of type integer.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
Returns:
32-bit signed integer

Definition at line 963 of file libhal.c.

char * hal_device_get_property_string LibHalContext *  ctx,
const char *  udi,
const char *  key
 

Get the value of a property of type string.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
Returns:
UTF8 nul-terminated string. The caller is responsible for freeing this string with the function hal_free_string(). Returns NULL if the property didn't exist or we are OOM

Todo:
FIXME cleanup

Definition at line 883 of file libhal.c.

Referenced by hal_device_query_capability(), hal_drive_from_device_file(), and hal_drive_from_udi().

int hal_device_get_property_type LibHalContext *  ctx,
const char *  udi,
const char *  key
 

Query a property type of a device.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
Returns:
One of DBUS_TYPE_STRING, DBUS_TYPE_INT32, DBUS_TYPE_UINT64, DBUS_TYPE_BOOL, DBUS_TYPE_DOUBLE or DBUS_TYPE_NIL if the property didn't exist.

Definition at line 826 of file libhal.c.

dbus_uint64_t hal_device_get_property_uint64 LibHalContext *  ctx,
const char *  udi,
const char *  key
 

Get the value of a property of type integer.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
Returns:
64-bit unsigned integer

Definition at line 1035 of file libhal.c.

dbus_bool_t hal_device_lock LibHalContext *  ctx,
const char *  udi,
const char *  reason_to_lock,
char **  reason_why_locked
 

Take an advisory lock on the device.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
reason_to_lock A user-presentable reason why the device is locked.l
reason_why_locked A pointer to store the reason why the device cannot be locked on failure, or NULL
Returns:
TRUE if the lock was obtained, FALSE otherwise

Definition at line 1465 of file libhal.c.

void hal_device_print LibHalContext *  ctx,
const char *  udi
 

Print a device to stdout; useful for debugging.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id

Definition at line 2034 of file libhal.c.

References hal_device_get_all_properties(), hal_free_property_set(), hal_psi_get_bool(), hal_psi_get_double(), hal_psi_get_int(), hal_psi_get_key(), hal_psi_get_string(), hal_psi_get_type(), hal_psi_get_uint64(), hal_psi_has_more(), hal_psi_init(), and hal_psi_next().

dbus_bool_t hal_device_property_exists LibHalContext *  ctx,
const char *  udi,
const char *  key
 

Determine if a property on a device exists.

Parameters:
ctx The context for the connection to hald
udi Unique device id.
key Name of the property
Returns:
TRUE if the device exists

Definition at line 1841 of file libhal.c.

int hal_device_property_watch_all LibHalContext *  ctx  ) 
 

Watch all devices, ie.

the device_property_changed callback is invoked when the properties on any device changes.

Parameters:
ctx The context for the connection to hald
Returns:
Zero if the operation succeeded, otherwise non-zero

Definition at line 2335 of file libhal.c.

dbus_bool_t hal_device_query_capability LibHalContext *  ctx,
const char *  udi,
const char *  capability
 

Check if a device got a capability.

The result is undefined if the device doesn't exist.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
capability Capability name
Returns:
TRUE if the device got the capability, otherwise FALSE

Definition at line 2230 of file libhal.c.

References hal_device_get_property_string().

Referenced by hal_drive_from_device_file(), hal_drive_from_udi(), hal_volume_from_device_file(), and hal_volume_from_udi().

dbus_bool_t hal_device_remove_property LibHalContext *  ctx,
const char *  udi,
const char *  key
 

Remove a property.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
Returns:
TRUE if the property was set, FALSE if the device didn't exist

Definition at line 1443 of file libhal.c.

References hal_device_set_property_helper().

int hal_device_remove_property_watch LibHalContext *  ctx,
const char *  udi
 

Remove a watch on a device.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
Returns:
Zero if the operation succeeded, otherwise non-zero

Definition at line 2398 of file libhal.c.

dbus_bool_t hal_device_set_property_bool LibHalContext *  ctx,
const char *  udi,
const char *  key,
dbus_bool_t  value
 

Set a property of type bool.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
value Value of the property
Returns:
TRUE if the property was set, FALSE if the device didn't exist or the property had a different type.

Definition at line 1425 of file libhal.c.

References hal_device_set_property_helper().

dbus_bool_t hal_device_set_property_double LibHalContext *  ctx,
const char *  udi,
const char *  key,
double  value
 

Set a property of type double.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
value Value of the property
Returns:
TRUE if the property was set, FALSE if the device didn't exist or the property had a different type.

Definition at line 1406 of file libhal.c.

References hal_device_set_property_helper().

int hal_device_set_property_helper LibHalContext *  ctx,
const char *  udi,
const char *  key,
int  type,
const char *  str_value,
dbus_int32_t  int_value,
dbus_uint64_t  uint64_value,
double  double_value,
dbus_bool_t  bool_value
[static]
 

Todo:
sanity check incoming params

Definition at line 1244 of file libhal.c.

Referenced by hal_device_remove_property(), hal_device_set_property_bool(), hal_device_set_property_double(), hal_device_set_property_int(), hal_device_set_property_string(), and hal_device_set_property_uint64().

dbus_bool_t hal_device_set_property_int LibHalContext *  ctx,
const char *  udi,
const char *  key,
dbus_int32_t  value
 

Set a property of type integer.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
value Value of the property
Returns:
TRUE if the property was set, FALSE if the device didn't exist or the property had a different type.

Definition at line 1368 of file libhal.c.

References hal_device_set_property_helper().

dbus_bool_t hal_device_set_property_string LibHalContext *  ctx,
const char *  udi,
const char *  key,
const char *  value
 

Set a property of type string.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
value Value of the property; a UTF8 string
Returns:
TRUE if the property was set, FALSE if the device didn't exist or the property had a different type.

Definition at line 1348 of file libhal.c.

References hal_device_set_property_helper().

dbus_bool_t hal_device_set_property_uint64 LibHalContext *  ctx,
const char *  udi,
const char *  key,
dbus_uint64_t  value
 

Set a property of type integer.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
value Value of the property
Returns:
TRUE if the property was set, FALSE if the device didn't exist or the property had a different type.

Definition at line 1387 of file libhal.c.

References hal_device_set_property_helper().

dbus_bool_t hal_device_unlock LibHalContext *  ctx,
const char *  udi
 

Release an advisory lock on the device.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
Returns:
TRUE if the device was successfully unlocked, FALSE otherwise

Definition at line 1535 of file libhal.c.

char ** hal_find_device_by_capability LibHalContext *  ctx,
const char *  capability,
int *  num_devices
 

Find devices with a given capability.

Parameters:
ctx The context for the connection to hald
capability Capability name
num_devices Pointer to store number of devices
Returns:
UDI of devices; free with hal_free_string_array()

Todo:
Handle OOM better

Handle OOM better

Definition at line 2253 of file libhal.c.

void hal_free_property_set LibHalPropertySet *  set  ) 
 

Free a property set earlier obtained with hal_device_get_all_properties().

Parameters:
set Property-set to free

Definition at line 311 of file libhal.c.

Referenced by hal_device_print(), hal_drive_from_udi(), and hal_volume_from_udi().

void hal_free_string char *  str  ) 
 

Frees a nul-terminated string.

Parameters:
str The nul-terminated sting to free

Todo:
implement for UTF8

Definition at line 86 of file libhal.c.

Referenced by hal_drive_free(), hal_drive_from_device_file(), hal_drive_from_udi(), hal_volume_free(), and hal_volume_from_udi().

void hal_free_string_array char **  str_array  ) 
 

Frees a NULL-terminated array of strings.

If passed NULL, does nothing.

Parameters:
str_array The array to be freed

Definition at line 69 of file libhal.c.

Referenced by hal_drive_from_device_file(), and hal_volume_from_device_file().

char ** hal_get_all_devices LibHalContext *  ctx,
int *  num_devices
 

Get all devices in the Global Device List (GDL).

Parameters:
ctx The context for the connection to hald
num_devices The number of devices will be stored here
Returns:
An array of device identifiers terminated with NULL. It is the responsibility of the caller to free with hal_free_string_array(). If an error occurs NULL is returned.

Todo:
Handle OOM better

FIXME cleanup

Definition at line 738 of file libhal.c.

LibHalContext * hal_initialize const LibHalFunctions cb_functions,
dbus_bool_t  use_cache
 

Initialize the HAL library.

Parameters:
cb_functions Callback functions. If this is set top NULL then the library will not listen for notifications.
use_cache Retrieve all device information and cache it. This is expensive both in terms of memory (there may be 50 device objects with 20 properties each) and in terms of processing power (your process will be woken up every time a property is changed). Use with caution. NOTE NOTE NOTE: Caching isn't actually implemented yet, this is just a placeholder to preserve API compatibility.
Returns:
A LibHalContext object if succesful, and NULL if an error occured

Todo:
clean up

clean up

Definition at line 608 of file libhal.c.

References LibHalFunctions, and LibHalFunctions_s::main_loop_integration.

char ** hal_manager_find_device_string_match LibHalContext *  ctx,
const char *  key,
const char *  value,
int *  num_devices
 

Find a device in the GDL where a single string property matches a given value.

Parameters:
ctx The context for the connection to hald
key Name of the property
value Value to match
num_devices Pointer to store number of devices
Returns:
UDI of devices; free with hal_free_string_array()

Todo:
Handle OOM better

Handle OOM better

Definition at line 2092 of file libhal.c.

Referenced by hal_drive_from_device_file(), and hal_volume_from_device_file().

dbus_bool_t hal_psi_get_bool LibHalPropertySetIterator *  iter  ) 
 

Get the value of a property of type bool.

Parameters:
iter Iterator object
Returns:
Truth value

Definition at line 443 of file libhal.c.

Referenced by hal_device_print().

double hal_psi_get_double LibHalPropertySetIterator *  iter  ) 
 

Get the value of a property of type double.

Parameters:
iter Iterator object
Returns:
IEEE754 double precision float

Definition at line 432 of file libhal.c.

Referenced by hal_device_print().

dbus_int32_t hal_psi_get_int LibHalPropertySetIterator *  iter  ) 
 

Get the value of a property of type integer.

Parameters:
iter Iterator object
Returns:
32-bit signed integer

Definition at line 410 of file libhal.c.

Referenced by hal_device_print().

char * hal_psi_get_key LibHalPropertySetIterator *  iter  ) 
 

Get the key of a property.

Parameters:
iter Iterator object
Returns:
ASCII nul-terminated string. This pointer is only valid until hal_free_property_set() is invoked on the property set this property belongs to

Definition at line 385 of file libhal.c.

Referenced by hal_device_print(), hal_drive_from_udi(), and hal_volume_from_udi().

char * hal_psi_get_string LibHalPropertySetIterator *  iter  ) 
 

Get the value of a property of type string.

Parameters:
iter Iterator object
Returns:
UTF8 nul-terminated string. This pointer is only valid until hal_free_property_set() is invoked on the property set this property belongs to

Definition at line 399 of file libhal.c.

Referenced by hal_device_print().

int hal_psi_get_type LibHalPropertySetIterator *  iter  ) 
 

Get type of property.

Parameters:
iter Iterator object
Returns:
One of DBUS_TYPE_STRING, DBUS_TYPE_INT32, DBUS_TYPE_UINT64, DBUS_TYPE_BOOL, DBUS_TYPE_DOUBLE

Definition at line 371 of file libhal.c.

Referenced by hal_device_print(), hal_drive_from_udi(), and hal_volume_from_udi().

dbus_uint64_t hal_psi_get_uint64 LibHalPropertySetIterator *  iter  ) 
 

Get the value of a property of type integer.

Parameters:
iter Iterator object
Returns:
64-bit unsigned integer

Definition at line 421 of file libhal.c.

Referenced by hal_device_print().

dbus_bool_t hal_psi_has_more LibHalPropertySetIterator *  iter  ) 
 

Determine whether there are more properties to iterate over.

Parameters:
iter Iterator object
Returns:
TRUE if there are more properties

Definition at line 348 of file libhal.c.

Referenced by hal_device_print(), hal_drive_from_udi(), and hal_volume_from_udi().

void hal_psi_init LibHalPropertySetIterator *  iter,
LibHalPropertySet *  set
 

Initialize a property set iterator.

Parameters:
iter Iterator object
set Property set

Definition at line 335 of file libhal.c.

Referenced by hal_device_print(), hal_drive_from_udi(), and hal_volume_from_udi().

void hal_psi_next LibHalPropertySetIterator *  iter  ) 
 

Advance iterator to next property.

Parameters:
iter Iterator object

Definition at line 358 of file libhal.c.

Referenced by hal_device_print(), hal_drive_from_udi(), and hal_volume_from_udi().

int hal_shutdown LibHalContext *  ctx  ) 
 

Shutdown the HAL library.

All resources allocated are freed.

Parameters:
ctx The context for the connection to hald
Returns:
Zero if the shutdown went well, otherwise non-zero if an error occured

Definition at line 687 of file libhal.c.


Generated on Wed Aug 13 16:57:56 2008 for HAL by  doxygen 1.3.9.1