[PATCH 3/6] libhal support for addon singletons
Rob Taylor
rob.taylor at codethink.co.uk
Fri Jun 22 07:47:30 PDT 2007
Adds api to libhal for supporting addon singletons:
- libhal_device_singleton_addon_is_ready for singletons to signal readyness.
- libhal_ctx_set_singleton_device_added and
libhal_ctx_set_singleton_device_removed for setting a callback on singleton
DeviceAdded/Removed. The properties of the new device are passed as a
LibHalPropertySet to the callback.
- a number of direct accessors for properties in a LibHalPropertySet
---
libhal/libhal.c | 496 ++++++++++++++++++++++++++++++++++++++++++++-----------
libhal/libhal.h | 64 +++++++-
2 files changed, 458 insertions(+), 102 deletions(-)
diff --git a/libhal/libhal.c b/libhal/libhal.c
index fb9800a..db4603b 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -4,6 +4,8 @@
* libhal.c : HAL daemon C convenience library
*
* Copyright (C) 2003 David Zeuthen, <david at fubar.dk>
+ * Copyright (C) 2006 Sjoerd Simons, <sjoerd at luon.net>
+ * Copyright (C) 2007 Codethink Ltd. Author Rob Taylor <rob.taylor at codethink.co.uk>
*
* Licensed under the Academic Free License version 2.1
*
@@ -258,6 +260,12 @@ struct LibHalContext_s {
/** An interface lock is released */
LibHalInterfaceLockReleased interface_lock_released;
+ /** Singleton device added */
+ LibHalSingletonDeviceAdded singleton_device_added;
+
+ /** Singleton device removed*/
+ LibHalSingletonDeviceRemoved singleton_device_removed;
+
void *user_data; /**< User data */
};
@@ -383,66 +391,17 @@ libhal_property_fill_value_from_variant (LibHalProperty *p, DBusMessageIter *var
return TRUE;
}
-/**
- * libhal_device_get_all_properties:
- * @ctx: the context for the connection to hald
- * @udi: the Unique id of device
- * @error: pointer to an initialized dbus error object for returning errors or NULL
- *
- * Retrieve all the properties on a device.
- *
- * Returns: An object represent all properties. Must be freed with libhal_free_property_set().
- */
-LibHalPropertySet *
-libhal_device_get_all_properties (LibHalContext *ctx, const char *udi, DBusError *error)
-{
- DBusMessage *message;
- DBusMessage *reply;
- DBusMessageIter reply_iter;
- DBusMessageIter dict_iter;
+static LibHalPropertySet *
+get_property_set (DBusMessageIter *iter)
+{
LibHalPropertySet *result;
LibHalProperty *p_last;
- DBusError _error;
-
- LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
- LIBHAL_CHECK_PARAM_VALID(udi, "*udi", NULL);
-
- message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
- "org.freedesktop.Hal.Device",
- "GetAllProperties");
-
- if (message == NULL) {
- fprintf (stderr,
- "%s %d : Couldn't allocate D-BUS message\n",
- __FILE__, __LINE__);
- return NULL;
- }
-
- dbus_error_init (&_error);
- reply = dbus_connection_send_with_reply_and_block (ctx->connection,
- message, -1,
- &_error);
-
- dbus_move_error (&_error, error);
- if (error != NULL && dbus_error_is_set (error)) {
- fprintf (stderr,
- "%s %d : %s\n",
- __FILE__, __LINE__, error->message);
-
- dbus_message_unref (message);
- return NULL;
- }
-
- if (reply == NULL) {
- dbus_message_unref (message);
- return NULL;
- }
-
- dbus_message_iter_init (reply, &reply_iter);
+ DBusMessageIter dict_iter;
result = malloc (sizeof (LibHalPropertySet));
if (result == NULL)
goto oom;
+
/*
result->properties = malloc(sizeof(LibHalProperty)*result->num_properties);
if( result->properties==NULL )
@@ -455,16 +414,14 @@ libhal_device_get_all_properties (LibHalContext *ctx, const char *udi, DBusError
result->properties_head = NULL;
result->num_properties = 0;
- if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_ARRAY &&
- dbus_message_iter_get_element_type (&reply_iter) != DBUS_TYPE_DICT_ENTRY) {
+ if (dbus_message_iter_get_arg_type (iter) != DBUS_TYPE_ARRAY &&
+ dbus_message_iter_get_element_type (iter) != DBUS_TYPE_DICT_ENTRY) {
fprintf (stderr, "%s %d : error, expecting an array of dict entries\n",
__FILE__, __LINE__);
- dbus_message_unref (message);
- dbus_message_unref (reply);
return NULL;
}
- dbus_message_iter_recurse (&reply_iter, &dict_iter);
+ dbus_message_iter_recurse (iter, &dict_iter);
p_last = NULL;
@@ -511,9 +468,6 @@ libhal_device_get_all_properties (LibHalContext *ctx, const char *udi, DBusError
dbus_message_iter_next (&dict_iter);
}
- dbus_message_unref (message);
- dbus_message_unref (reply);
-
return result;
oom:
@@ -525,6 +479,69 @@ oom:
}
/**
+ * libhal_device_get_all_properties:
+ * @ctx: the context for the connection to hald
+ * @udi: the Unique id of device
+ * @error: pointer to an initialized dbus error object for returning errors or NULL
+ *
+ * Retrieve all the properties on a device.
+ *
+ * Returns: An object represent all properties. Must be freed with libhal_free_property_set().
+ */
+LibHalPropertySet *
+libhal_device_get_all_properties (LibHalContext *ctx, const char *udi, DBusError *error)
+{
+ DBusMessage *message;
+ DBusMessage *reply;
+ DBusMessageIter reply_iter;
+ LibHalPropertySet *result;
+ DBusError _error;
+
+ LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
+ LIBHAL_CHECK_PARAM_VALID(udi, "*udi", NULL);
+
+ message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
+ "org.freedesktop.Hal.Device",
+ "GetAllProperties");
+
+ if (message == NULL) {
+ fprintf (stderr,
+ "%s %d : Couldn't allocate D-BUS message\n",
+ __FILE__, __LINE__);
+ return NULL;
+ }
+
+ dbus_error_init (&_error);
+ reply = dbus_connection_send_with_reply_and_block (ctx->connection,
+ message, -1,
+ &_error);
+
+ dbus_move_error (&_error, error);
+ if (error != NULL && dbus_error_is_set (error)) {
+ fprintf (stderr,
+ "%s %d : %s\n",
+ __FILE__, __LINE__, error->message);
+
+ dbus_message_unref (message);
+ return NULL;
+ }
+
+ if (reply == NULL) {
+ dbus_message_unref (message);
+ return NULL;
+ }
+
+ dbus_message_iter_init (reply, &reply_iter);
+
+ result = get_property_set (&reply_iter);
+
+ dbus_message_unref (message);
+ dbus_message_unref (reply);
+
+ return result;
+}
+
+/**
* libhal_property_set_sort:
* @set: property-set to sort
*
@@ -616,9 +633,150 @@ libhal_property_set_get_num_elems (LibHalPropertySet *set)
return num_elems;
}
+static LibHalProperty *
+property_set_lookup (const LibHalPropertySet *set, const char *key)
+{
+ LibHalProperty *p;
+
+ for (p = set->properties_head; p != NULL; p = p->next) {
+ if (strcmp (p->key, key) == 0)
+ return p;
+ }
+ return NULL;
+}
+
+/**
+ * libhal_ps_get_type:
+ * @set: property set
+ * @key: name of property to inspect
+ *
+ * Get the type of a given property.
+ *
+ * Returns: the #LibHalPropertyType of the given property,
+ * LIBHAL_PROPERTY_TYPE_INVALID if property is not in the set
+ */
+LibHalPropertyType
+libhal_ps_get_type (const LibHalPropertySet *set, const char *key)
+{
+ LibHalProperty *p = property_set_lookup (set, key);
+ if (p) return p->type;
+ else return LIBHAL_PROPERTY_TYPE_INVALID;
+}
+
+/**
+ * libhal_ps_get_string:
+ * @set: property set
+ * @key: name of property to inspect
+ *
+ * Get the value of a property of type string.
+ *
+ * Returns: 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
+ */
+const char *
+libhal_ps_get_string (const LibHalPropertySet *set, const char *key)
+{
+ LibHalProperty *p = property_set_lookup (set, key);
+ if (p && p->type == LIBHAL_PROPERTY_TYPE_STRING)
+ return p->v.str_value;
+ else return NULL;
+}
+
+/**
+ * libhal_ps_get_int:
+ * @set: property set
+ * @key: name of property to inspect
+ *
+ * Get the value of a property of type signed integer.
+ *
+ * Returns: property value (32-bit signed integer)
+ */
+dbus_int32_t
+libhal_ps_get_int32 (const LibHalPropertySet *set, const char *key)
+{
+ LibHalProperty *p = property_set_lookup (set, key);
+ if (p && p->type == LIBHAL_PROPERTY_TYPE_INT32)
+ return p->v.int_value;
+ else return 0;
+}
+
+/**
+ * libhal_ps_get_uint64:
+ * @set: property set
+ * @key: name of property to inspect
+ *
+ * Get the value of a property of type unsigned integer.
+ *
+ * Returns: property value (64-bit unsigned integer)
+ */
+dbus_uint64_t
+libhal_ps_get_uint64 (const LibHalPropertySet *set, const char *key)
+{
+ LibHalProperty *p = property_set_lookup (set, key);
+ if (p && p->type == LIBHAL_PROPERTY_TYPE_UINT64)
+ return p->v.uint64_value;
+ else return 0;
+}
+
+/**
+ * libhal_ps_get_double:
+ * @set: property set
+ * @key: name of property to inspect
+ *
+ * Get the value of a property of type double.
+ *
+ * Returns: property value (IEEE754 double precision float)
+ */
+double
+libhal_ps_get_double (const LibHalPropertySet *set, const char *key)
+{
+ LibHalProperty *p = property_set_lookup (set, key);
+ if (p && p->type == LIBHAL_PROPERTY_TYPE_DOUBLE)
+ return p->v.double_value;
+ else return 0.0;
+}
+
+/**
+ * libhal_ps_get_bool:
+ * @set: property set
+ * @key: name of property to inspect
+ *
+ * Get the value of a property of type bool.
+ *
+ * Returns: property value (bool)
+ */
+dbus_bool_t
+libhal_ps_get_bool (const LibHalPropertySet *set, const char *key)
+{
+ LibHalProperty *p = property_set_lookup (set, key);
+ if (p && p->type == LIBHAL_PROPERTY_TYPE_BOOLEAN)
+ return p->v.bool_value;
+ else return FALSE;
+}
+
+/**
+ * libhal_ps_get_strlist:
+ * @set: property set
+ * @key: name of property to inspect
+ *
+ * Get the value of a property of type string list.
+ *
+ * Returns: pointer to array of strings, this is owned by the property set
+ */
+const char *const *
+libhal_ps_get_strlist (const LibHalPropertySet *set, const char *key)
+{
+ LibHalProperty *p = property_set_lookup (set, key);
+ if (p && p->type == LIBHAL_PROPERTY_TYPE_STRLIST)
+ return (const char *const *) p->v.strlist_value;
+ else return NULL;
+}
+
/**
* libhal_psi_init:
+ * 1;3B
* @iter: iterator object
* @set: property set to iterate over
*
@@ -780,6 +938,56 @@ libhal_psi_get_strlist (LibHalPropertySetIterator * iter)
return iter->cur_prop->v.strlist_value;
}
+static DBusHandlerResult
+singleton_device_changed (LibHalContext *ctx, DBusConnection *connection, DBusMessage *msg, dbus_bool_t added)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ LibHalPropertySet *set;
+ const char *udi;
+
+ dbus_message_iter_init (msg, &iter);
+
+ /* First should be the device UDI */
+ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
+ goto malformed;
+
+ dbus_message_iter_get_basic (&iter, &udi);
+
+ dbus_message_iter_next (&iter);
+
+ /* then the property set*/
+ set = get_property_set (&iter);
+
+ if (!set)
+ goto malformed;
+ if (added)
+ (ctx->singleton_device_added)(ctx, udi, set);
+ else
+ (ctx->singleton_device_removed)(ctx, udi, set);
+
+ libhal_free_property_set (set);
+
+ reply = dbus_message_new_method_return (msg);
+ if (reply == NULL)
+ goto oom;
+
+ if (!dbus_connection_send (connection, reply, NULL)) {
+ dbus_message_unref (reply);
+ goto oom;
+ }
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+
+malformed:
+ fprintf (stderr, "%s %d : singlton device changed message malformed\n", __FILE__, __LINE__);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+oom:
+ fprintf (stderr, "%s %d : error allocating memory\n", __FILE__, __LINE__);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
static DBusHandlerResult
filter_func (DBusConnection * connection,
@@ -796,7 +1004,12 @@ filter_func (DBusConnection * connection,
object_path = dbus_message_get_path (message);
- /*printf("*** in filter_func, object_path=%s\n", object_path);*/
+ /*fprintf (stderr, "*** libhal filer_func: connection=%p obj_path=%s interface=%s method=%s\n",
+ connection,
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message));
+ */
if (dbus_message_is_signal (message, "org.freedesktop.Hal.Manager",
"DeviceAdded")) {
@@ -952,8 +1165,20 @@ filter_func (DBusConnection * connection,
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ } else if (dbus_message_is_method_call (message,
+ "org.freedesktop.Hal.SingletonAddon",
+ "DeviceAdded") &&
+ strcmp (dbus_message_get_path (message),
+ "/org/freedesktop/Hal/SingletonAddon") == 0) {
+ return singleton_device_changed (ctx, connection, message, TRUE);
+ } else if (dbus_message_is_method_call (message,
+ "org.freedesktop.Hal.SingletonAddon",
+ "DeviceRemoved") &&
+ strcmp (dbus_message_get_path (message),
+ "/org/freedesktop/Hal/SingletonAddon") == 0) {
+ return singleton_device_changed (ctx, connection, message, FALSE);
}
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -3187,6 +3412,11 @@ libhal_ctx_init_direct (DBusError *error)
goto out;
}
+ if (!dbus_connection_add_filter (ctx->connection, filter_func, ctx, NULL)) {
+ return FALSE;
+ }
+
+
ctx->is_initialized = TRUE;
ctx->is_direct = TRUE;
@@ -3361,6 +3591,42 @@ libhal_ctx_set_device_condition (LibHalContext *ctx, LibHalDeviceCondition callb
}
/**
+ * libhal_ctx_set_singleton_device_added:
+ * @ctx: the context for the connection to hald
+ * @callback: the function to call when a device emits a condition
+ *
+ * Set the callback for when a singleton should handle a new device
+ *
+ * Returns: TRUE if callback was successfully set, FALSE otherwise
+ */
+dbus_bool_t
+libhal_ctx_set_singleton_device_added (LibHalContext *ctx, LibHalSingletonDeviceAdded callback)
+{
+ LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+
+ ctx->singleton_device_added = callback;
+ return TRUE;
+}
+
+/**
+ * libhal_ctx_set_singleton_device_removed:
+ * @ctx: the context for the connection to hald
+ * @callback: the function to call when a device emits a condition
+ *
+ * Set the callback for when a singleton should discard a device
+ *
+ * Returns: TRUE if callback was successfully set, FALSE otherwise
+ */
+dbus_bool_t
+libhal_ctx_set_singleton_device_removed (LibHalContext *ctx, LibHalSingletonDeviceRemoved callback)
+{
+ LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+
+ ctx->singleton_device_removed = callback;
+ return TRUE;
+}
+
+/**
* libhal_string_array_length:
* @str_array: array of strings to consider
*
@@ -3554,20 +3820,30 @@ dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx,
error);
if (error != NULL && dbus_error_is_set (error)) {
+ fprintf (stderr,
+ "%s %d : Failure sending D-BUS message: %s: %s\n",
+ __FILE__, __LINE__, error->name, error->message);
dbus_message_unref (message);
return FALSE;
}
dbus_message_unref (message);
- if (reply == NULL)
+ if (reply == NULL) {
+ fprintf (stderr,
+ "%s %d : Got no reply\n",
+ __FILE__, __LINE__);
return FALSE;
+ }
dbus_message_iter_init (reply, &reply_iter);
if (dbus_message_iter_get_arg_type (&reply_iter) !=
DBUS_TYPE_BOOLEAN) {
dbus_message_unref (message);
dbus_message_unref (reply);
+ fprintf (stderr,
+ "%s %d : Malformed reply\n",
+ __FILE__, __LINE__);
return FALSE;
}
dbus_message_iter_get_basic (&reply_iter, &result);
@@ -3577,35 +3853,27 @@ dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx,
return result;
}
-/**
- * libhal_device_addon_is_ready:
- * @ctx: the context for the connection to hald
- * @udi: the Unique Device Id
- * @error: pointer to an initialized dbus error object for returning errors or NULL
- *
- * 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.
- *
- * Returns: TRUE if the HAL daemon received the message, FALSE otherwise
- */
-dbus_bool_t
-libhal_device_addon_is_ready (LibHalContext *ctx, const char *udi, DBusError *error)
+static dbus_bool_t
+addon_is_ready(LibHalContext *ctx, const char *identifier,
+ dbus_bool_t singleton, DBusError *error)
{
DBusMessage *message;
DBusMessageIter iter;
- DBusMessageIter reply_iter;
DBusMessage *reply;
- dbus_bool_t result;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
- LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
- message = dbus_message_new_method_call ("org.freedesktop.Hal",
- udi,
+ if (singleton) {
+ message = dbus_message_new_method_call ("org.freedesktop.Hal",
+ "/org/freedesktop/Hal/Manager",
+ "org.freedesktop.Hal.Manager",
+ "SingletonAddonIsReady");
+ } else {
+ message = dbus_message_new_method_call ("org.freedesktop.Hal",
+ identifier,
"org.freedesktop.Hal.Device",
"AddonIsReady");
+ }
if (message == NULL) {
fprintf (stderr,
@@ -3615,7 +3883,9 @@ libhal_device_addon_is_ready (LibHalContext *ctx, const char *udi, DBusError *er
}
dbus_message_iter_init_append (message, &iter);
-
+
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &identifier);
+
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
@@ -3630,19 +3900,55 @@ libhal_device_addon_is_ready (LibHalContext *ctx, const char *udi, DBusError *er
if (reply == NULL)
return FALSE;
- dbus_message_iter_init (reply, &reply_iter);
- if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_BOOLEAN) {
- dbus_message_unref (message);
- dbus_message_unref (reply);
- return FALSE;
- }
- dbus_message_iter_get_basic (&reply_iter, &result);
-
dbus_message_unref (reply);
- return result;
+ return TRUE;
+}
+
+
+/**
+ * libhal_device_addon_is_ready:
+ * @ctx: the context for the connection to hald
+ * @udi: the Unique Device Id this addon is handling
+ * @error: pointer to an initialized dbus error object for returning errors or NULL
+ *
+ * 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.
+ *
+ * Returns: TRUE if the HAL daemon received the message, FALSE otherwise
+ */
+dbus_bool_t
+libhal_device_addon_is_ready (LibHalContext *ctx,
+ const char *udi,
+ DBusError *error)
+{
+ return addon_is_ready (ctx, udi, FALSE, error);
}
/**
+ * libhal_device_singleton_addon_is_ready:
+ * @ctx: the context for the connection to hald
+ * @commandline: commandline singleton was started with
+ * @error: pointer to an initialized dbus error object for returning errors or NULL
+ *
+ * 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.
+ *
+ * Returns: TRUE if the HAL daemon received the message, FALSE otherwise
+ */
+dbus_bool_t
+libhal_device_singleton_addon_is_ready (LibHalContext *ctx,
+ const char *command_line,
+ DBusError *error)
+{
+ return addon_is_ready (ctx, command_line, TRUE, error);
+}
+
+
+/**
* libhal_device_claim_interface:
* @ctx: the context for the connection to hald
* @udi: the Unique Device Id
diff --git a/libhal/libhal.h b/libhal/libhal.h
index f050d3b..3597ade 100644
--- a/libhal/libhal.h
+++ b/libhal/libhal.h
@@ -4,6 +4,7 @@
* libhal.h : HAL daemon C convenience library headers
*
* Copyright (C) 2003 David Zeuthen, <david at fubar.dk>
+ * Copyright (C) 2007 Codethink Ltd. Author Rob Taylor <rob.taylor at codethink.co.uk>
*
* Licensed under the Academic Free License version 2.1
*
@@ -103,6 +104,9 @@ typedef enum {
typedef struct LibHalContext_s LibHalContext;
+typedef struct LibHalProperty_s LibHalProperty;
+typedef struct LibHalPropertySet_s LibHalPropertySet;
+
/**
* LibHalIntegrateDBusIntoMainLoop:
@@ -251,6 +255,30 @@ typedef void (*LibHalInterfaceLockReleased) (LibHalContext *ctx,
const char *lock_owner,
int num_locks);
+/**
+ * LibHalSingletonDeviceAdded:
+ * @ctx: context for connection to hald
+ * @udi: the Unique Device Id
+ * @properties: the device's properties
+ *
+ * Type for callback for addon singletons when a device is added
+ */
+typedef void (*LibHalSingletonDeviceAdded) (LibHalContext *ctx,
+ const char *udi,
+ const LibHalPropertySet *properties);
+
+/**
+ * LibHalSingletonDeviceRemoved:
+ * @ctx: context for connection to hald
+ * @udi: the Unique Device Id
+ * @properties: the device's properties
+ *
+ * Type for callback for addon singletons when a device is added
+ */
+typedef void (*LibHalSingletonDeviceRemoved) (LibHalContext *ctx,
+ const char *udi,
+ const LibHalPropertySet *properties);
+
/* Create a new context for a connection with hald */
@@ -301,6 +329,12 @@ dbus_bool_t libhal_ctx_set_interface_lock_acquired (LibHalContext *ctx, LibHa
/* Set the callback for when an interface lock is released */
dbus_bool_t libhal_ctx_set_interface_lock_released (LibHalContext *ctx, LibHalInterfaceLockReleased callback);
+/* Set the callback for addon singleton device added */
+dbus_bool_t libhal_ctx_set_singleton_device_added (LibHalContext *ctx, LibHalSingletonDeviceAdded callback);
+
+/* Set the callback for addon singleton device removed*/
+dbus_bool_t libhal_ctx_set_singleton_device_removed (LibHalContext *ctx, LibHalSingletonDeviceRemoved callback);
+
/* Initialize the connection to hald */
dbus_bool_t libhal_ctx_init (LibHalContext *ctx, DBusError *error);
@@ -475,13 +509,6 @@ dbus_bool_t libhal_device_commit_changeset (LibHalContext *ctx,
void libhal_device_free_changeset (LibHalChangeSet *changeset);
-struct LibHalProperty_s;
-typedef struct LibHalProperty_s LibHalProperty;
-
-struct LibHalPropertySet_s;
-typedef struct LibHalPropertySet_s LibHalPropertySet;
-
-
/* Retrieve all the properties on a device. */
LibHalPropertySet *libhal_device_get_all_properties (LibHalContext *ctx,
const char *udi,
@@ -497,6 +524,28 @@ void libhal_free_property_set (LibHalPropertySet *set);
/* Get the number of properties in a property set. */
unsigned int libhal_property_set_get_num_elems (LibHalPropertySet *set);
+/* Get type of property. */
+LibHalPropertyType libhal_ps_get_type (const LibHalPropertySet *set, const char *key);
+
+/* Get the value of a property of type string. */
+const char *libhal_ps_get_string (const LibHalPropertySet *set, const char *key);
+
+/* Get the value of a property of type signed integer. */
+dbus_int32_t libhal_ps_get_int32 (const LibHalPropertySet *set, const char *key);
+
+/* Get the value of a property of type unsigned integer. */
+dbus_uint64_t libhal_ps_get_uint64 (const LibHalPropertySet *set, const char *key);
+
+/* Get the value of a property of type double. */
+double libhal_ps_get_double (const LibHalPropertySet *set, const char *key);
+
+/* Get the value of a property of type bool. */
+dbus_bool_t libhal_ps_get_bool (const LibHalPropertySet *set, const char *key);
+
+/* Get the value of a property of type string list. */
+const char * const *libhal_ps_get_strlist (const LibHalPropertySet *set, const char *key);
+
+
/**
* LibHalPropertySetIterator:
*
@@ -675,6 +724,7 @@ dbus_bool_t libhal_device_claim_interface (LibHalContext *ctx,
/* hald waits for all addons to call this function before announcing the addon (for hald helpers only) */
dbus_bool_t libhal_device_addon_is_ready (LibHalContext *ctx, const char *udi, DBusError *error);
+dbus_bool_t libhal_device_singleton_addon_is_ready (LibHalContext *ctx, const char *command_line, DBusError *error);
/* Take a mandatory lock on an interface on a device. */
dbus_bool_t libhal_device_acquire_interface_lock (LibHalContext *ctx,
--
1.5.2-rc3.GIT
--------------010609010103020107060701
Content-Type: text/x-patch;
name*0="0004-convert-libhal-to-use-a-hashtable-for-property-sets.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename*0="0004-convert-libhal-to-use-a-hashtable-for-property-sets.pat";
filename*1="ch"
More information about the hal
mailing list