Logo Search packages:      
Sourcecode: hal version File versions

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

Determine if a property on a device exists.

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

Definition at line 1841 of file libhal.c.

References LibHalContext_s::connection.

      DBusError error;
      DBusMessage *message;
      DBusMessage *reply;
      DBusMessageIter iter;
      dbus_bool_t value;

      message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
      if (message == NULL) {
            fprintf (stderr,
                   "%s %d : Couldn't allocate D-BUS message\n",
                   __FILE__, __LINE__);
            return FALSE;

      dbus_message_iter_init (message, &iter);
      dbus_message_iter_append_string (&iter, key);

      dbus_error_init (&error);
      reply = dbus_connection_send_with_reply_and_block (ctx->connection,
                                             message, -1,
      if (dbus_error_is_set (&error)) {
            fprintf (stderr, "%s %d : Error sending msg: %s\n",
                   __FILE__, __LINE__, error.message);
            dbus_message_unref (message);
            return FALSE;
      if (reply == NULL) {
            dbus_message_unref (message);
            return FALSE;

      dbus_message_iter_init (reply, &iter);

      /* now analyse reply */
      if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_BOOLEAN) {
            fprintf (stderr, "%s %d : expected a bool in reply to "
                   "PropertyExists\n", __FILE__, __LINE__);
            dbus_message_unref (message);
            dbus_message_unref (reply);
            return FALSE;

      value = dbus_message_iter_get_boolean (&iter);

      dbus_message_unref (message);
      dbus_message_unref (reply);
      return value;

Generated by  Doxygen 1.6.0   Back to index