liblazy
Defines | Functions
Liblazy - D-Bus methods provided for convenience

Defines

#define LIBLAZY_ERROR_GENERAL   -1
#define LIBLAZY_ERROR_INVALID_ARGUMENT   -2
#define LIBLAZY_ERROR_HAL_NOT_READY   -10
#define LIBLAZY_ERROR_HAL_NO_SUCH_PROPERTY   -11
#define LIBLAZY_ERROR_DBUS_NOT_READY   -20
#define LIBLAZY_ERROR_DBUS_NO_REPLY   -21
#define LIBLAZY_ERROR_DBUS_ERROR_IS_SET   -22

Functions

void liblazy_free_string (char *string)
 free a string
void liblazy_free_strlist (char **strlist)
 free a null terminated array of strings
int liblazy_dbus_system_send_method_call (const char *destination, const char *path, const char *interface, const char *method, DBusMessage **reply, int first_arg_type,...)
 send a method call to the system bus
int liblazy_dbus_session_send_method_call (const char *destination, const char *path, const char *interface, const char *method, DBusMessage **reply, int first_arg_type,...)
 send a method call to the session bus
int liblazy_dbus_system_send_signal (const char *path, const char *interface, const char *name, int first_arg_type,...)
 send a signal over the system bus
int liblazy_dbus_session_send_signal (const char *path, const char *interface, const char *name, int first_arg_type,...)
 send a signal over the session bus
int liblazy_dbus_message_get_basic_arg (DBusMessage *message, int type, void *arg, int no)
 get an argument from a DBusMessage
int liblazy_dbus_message_get_strlist_arg (DBusMessage *message, char ***strlist, int no)
 get a array argument from a DBusMessage as a string list
void liblazy_dbus_system_use_private_connection (int use_private)
 use a private connection for system bus messages
int liblazy_hal_get_property_int (const char *udi, const char *property, int *value)
 get integer property from HAL
int liblazy_hal_get_property_bool (const char *udi, const char *property, int *value)
 get boolean property from HAL
int liblazy_hal_get_property_string (const char *udi, const char *property, char **value)
 get string property from HAL
int liblazy_hal_get_property_strlist (const char *udi, const char *property, char ***strlist)
 get string list property from HAL
int liblazy_hal_query_capability (const char *udi, const char *capability)
 check if a device has a capability
int liblazy_hal_find_device_by_capability (const char *capability, char ***strlist)
 find devices with a given capability
int liblazy_hal_find_device_by_string_match (const char *key, const char *value, char ***strlist)
 find devices with given key and value
int liblazy_hal_is_caller_privileged (const char *privilege)
 check if a user possesses a privilege

Define Documentation

#define LIBLAZY_ERROR_DBUS_NO_REPLY   -21
#define LIBLAZY_ERROR_DBUS_NOT_READY   -20
#define LIBLAZY_ERROR_GENERAL   -1
#define LIBLAZY_ERROR_HAL_NOT_READY   -10

Function Documentation

int liblazy_dbus_message_get_basic_arg ( DBusMessage *  message,
int  type,
void *  arg,
int  no 
)

get an argument from a DBusMessage

Parameters:
messagethe DBusMessage to get the argument from
typethe type of the argument
arga location to store the argument
noa number specifying the n'th argument of the given type
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References LIBLAZY_ERROR_GENERAL, and LIBLAZY_ERROR_INVALID_ARGUMENT.

Referenced by liblazy_hal_get_property(), liblazy_hal_is_caller_privileged(), and liblazy_hal_property_exists().

int liblazy_dbus_message_get_strlist_arg ( DBusMessage *  message,
char ***  strlist,
int  no 
)

get a array argument from a DBusMessage as a string list

Parameters:
messagethe message to get the argument from
strlista pointer to a string array to store the result
strlistpointer to array of strings to store the result. Has to be freed with liblazy_free_strlist
noa number specifying the n'th string array in the reply
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References liblazy_dbus_get_strlist_from_array(), LIBLAZY_ERROR_GENERAL, and LIBLAZY_ERROR_INVALID_ARGUMENT.

Referenced by liblazy_hal_get_property_strlist(), and liblazy_hal_get_strlist_manager().

int liblazy_dbus_session_send_method_call ( const char *  destination,
const char *  path,
const char *  interface,
const char *  method,
DBusMessage **  reply,
int  first_arg_type,
  ... 
)

send a method call to the session bus

sends a method call to the session bus. The call blocks if a reply is given. If the call shouldn't block, give NULL for the reply

Parameters:
destinationthe destination to send to
paththe object path to send to
interfacethe interface to send to
methodthe method to send
replya DBusMessage to store the reply or NULL if the call shouldn't block
first_arg_typea DBUS_TYPE_* of the fist argument
...variable argument list finished with DBUS_TYPE_INVALID
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References liblazy_dbus_send_method_call().

int liblazy_dbus_session_send_signal ( const char *  path,
const char *  interface,
const char *  name,
int  first_arg_type,
  ... 
)

send a signal over the session bus

sends a signal over the session bus. The call blocks if a reply is given. If the call shouldn't block, give NULL for the reply

Parameters:
paththe object path to send to
interfacethe interface to send to
namethe name of the signal
first_arg_typea DBUS_TYPE_* of the fist argument
...variable argument list finished with DBUS_TYPE_INVALID
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References liblazy_dbus_send_signal().

int liblazy_dbus_system_send_method_call ( const char *  destination,
const char *  path,
const char *  interface,
const char *  method,
DBusMessage **  reply,
int  first_arg_type,
  ... 
)

send a method call to the system bus

sends a method call to the system bus. The call blocks if a reply is given. If the call shouldn't block, give NULL for the reply

Parameters:
destinationthe destination to send to
paththe object path to send to
interfacethe interface to send to
methodthe method to send
replya DBusMessage to store the reply or NULL if the call shouldn't block
first_arg_typea DBUS_TYPE_* of the fist argument
...variable argument list finished with DBUS_TYPE_INVALID
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References liblazy_dbus_send_method_call().

Referenced by liblazy_hal_get_property(), liblazy_hal_get_property_strlist(), liblazy_hal_is_caller_privileged(), and liblazy_hal_property_exists().

int liblazy_dbus_system_send_signal ( const char *  path,
const char *  interface,
const char *  name,
int  first_arg_type,
  ... 
)

send a signal over the system bus

sends a signal over the system bus. The call blocks if a reply is given. If the call shouldn't block, give NULL for the reply

Parameters:
paththe object path to send to
interfacethe interface to send to
namethe name of the signal
first_arg_typea DBUS_TYPE_* of the fist argument
...variable argument list finished with DBUS_TYPE_INVALID
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References liblazy_dbus_send_signal().

void liblazy_dbus_system_use_private_connection ( int  use_private)

use a private connection for system bus messages

Call this function with a boolean value to tell the library whether to use a private connection for system bus messages (liblazy_dbus_system*). Defaults to false. If a private connection is used, the libarary creates a new connection on _every_ call and immediately closes it. So this should be used very carefully. Only use if your application does very rare dbus calls and doesn't have a mainloop to listen if D-Bus died but still should be able to survive D-Bus restarts.

Parameters:
use_privat1 if the library should use a private connection, 0 otherwise

References dbus_system_use_private_connection.

void liblazy_free_string ( char *  string)

free a string

Parameters:
stringthe string to free
void liblazy_free_strlist ( char **  strlist)

free a null terminated array of strings

Parameters:
strlistthe string list to free

Referenced by liblazy_hal_query_capability().

int liblazy_hal_find_device_by_capability ( const char *  capability,
char ***  strlist 
)

find devices with a given capability

Parameters:
capabilitythe capability the devices should have
strlistpointer to array of strings to store the result. Has to be freed with liblazy_free_strlist
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References liblazy_hal_get_strlist_manager().

int liblazy_hal_find_device_by_string_match ( const char *  key,
const char *  value,
char ***  strlist 
)

find devices with given key and value

Parameters:
keythe key to match against
valuethe value to match against
strlistpointer to array of strings to store the result. Has to be freed with liblazy_free_strlist
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References liblazy_hal_get_strlist_manager().

int liblazy_hal_get_property_bool ( const char *  udi,
const char *  property,
int *  value 
)

get boolean property from HAL

fetches one boolean value from HAL.

Parameters:
udithe device to fetch the value from
propertythe property to fetch
valuelocation to store the result
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References LIBLAZY_ERROR_HAL_NO_SUCH_PROPERTY, liblazy_hal_get_property(), and liblazy_hal_property_exists().

int liblazy_hal_get_property_int ( const char *  udi,
const char *  property,
int *  value 
)

get integer property from HAL

fetches one interger value from HAL.

Parameters:
udithe device to fetch the value from
propertythe property to fetch
valuelocation to store the result
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References LIBLAZY_ERROR_HAL_NO_SUCH_PROPERTY, liblazy_hal_get_property(), and liblazy_hal_property_exists().

int liblazy_hal_get_property_string ( const char *  udi,
const char *  property,
char **  value 
)

get string property from HAL

fetches one string value from HAL.

Parameters:
udithe device to fetch the value from
propertythe property to fetch
valuelocation to store the result
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References LIBLAZY_ERROR_HAL_NO_SUCH_PROPERTY, liblazy_hal_get_property(), and liblazy_hal_property_exists().

int liblazy_hal_get_property_strlist ( const char *  udi,
const char *  property,
char ***  strlist 
)

get string list property from HAL

fetches a string list value from HAL.

Parameters:
udithe device to fetch the value from
propertythe property to fetch
strlistpointer to array of strings to store the result. Has to be freed with liblazy_free_strlist
Returns:
0 on success, LIBLAZY_ERROR_* on failure

References DBUS_HAL_DEVICE_INTERFACE, DBUS_HAL_SERVICE, liblazy_dbus_message_get_strlist_arg(), liblazy_dbus_system_send_method_call(), LIBLAZY_ERROR_HAL_NO_SUCH_PROPERTY, LIBLAZY_ERROR_INVALID_ARGUMENT, and liblazy_hal_property_exists().

Referenced by liblazy_hal_query_capability().

int liblazy_hal_is_caller_privileged ( const char *  privilege)

check if a user possesses a privilege

Check if the caller possesses the given privilege on the default device '/org/freedesktop/Hal/devices/computer'

Parameters:
privilegethe privilege to check for
Returns:
1 if the caller is privileged, 0 if not, and LIBLAZY_ERROR_* on failure

References DBUS_HAL_COMPUTER_PATH, DBUS_HAL_DEVICE_INTERFACE, DBUS_HAL_SERVICE, liblazy_dbus_message_get_basic_arg(), liblazy_dbus_system_send_method_call(), LIBLAZY_ERROR_DBUS_NOT_READY, and LIBLAZY_ERROR_INVALID_ARGUMENT.

int liblazy_hal_query_capability ( const char *  udi,
const char *  capability 
)

check if a device has a capability

Parameters:
udithe device to query on
capabilitythe capability to query for
Returns:
1 if the device possesses the capability, 0 if not and LIBLAZY_ERROR_* on failure

References LIBLAZY_ERROR_INVALID_ARGUMENT, liblazy_free_strlist(), and liblazy_hal_get_property_strlist().