diff options
author | David Zeuthen <davidz@redhat.com> | 2006-09-10 17:28:34 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2006-09-10 17:28:34 -0400 |
commit | 18413734b1da6c14a0851e34d77db96f6a4ef9bb (patch) | |
tree | 930395c667e5518610ab6c22c4970835830317af /libhal | |
parent | ed71e4e6769b8f359f7626f788a38db5f63faca8 (diff) |
require addons to call libhal_device_addon_is_ready() to make device visible
Also fixup some .gitignore files and prune the TODO for finished items.
Diffstat (limited to 'libhal')
-rw-r--r-- | libhal/libhal.c | 64 | ||||
-rw-r--r-- | libhal/libhal.h | 3 |
2 files changed, 67 insertions, 0 deletions
diff --git a/libhal/libhal.c b/libhal/libhal.c index 0627aaad..a577829c 100644 --- a/libhal/libhal.c +++ b/libhal/libhal.c @@ -3379,6 +3379,70 @@ dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx, } /** + * 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) +{ + DBusMessage *message; + DBusMessageIter iter; + DBusMessageIter reply_iter; + DBusMessage *reply; + dbus_bool_t result; + + LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); + + message = dbus_message_new_method_call ("org.freedesktop.Hal", + udi, + "org.freedesktop.Hal.Device", + "AddonIsReady"); + + if (message == NULL) { + fprintf (stderr, + "%s %d : Couldn't allocate D-BUS message\n", + __FILE__, __LINE__); + return FALSE; + } + + dbus_message_iter_init_append (message, &iter); + + reply = dbus_connection_send_with_reply_and_block (ctx->connection, + message, -1, + error); + + if (dbus_error_is_set (error)) { + dbus_message_unref (message); + return FALSE; + } + + dbus_message_unref (message); + + 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; +} + +/** * 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 ab00e576..9962da1e 100644 --- a/libhal/libhal.h +++ b/libhal/libhal.h @@ -593,6 +593,9 @@ dbus_bool_t libhal_device_claim_interface (LibHalContext *ctx, const char *introspection_xml, DBusError *error); +/* 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); + #if defined(__cplusplus) } |