Logo Search packages:      
Sourcecode: hal version File versions

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

Get the value of a property of type double.

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

Definition at line 1107 of file libhal.c.

References LibHalContext_s::connection.

Referenced by main(), and print_property().

      DBusError error;
      DBusMessage *message;
      DBusMessage *reply;
      DBusMessageIter iter;
      double 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 -1.0f;

      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 -1.0f;
      if (reply == NULL) {
            dbus_message_unref (message);
            return -1.0f;

      dbus_message_iter_init (reply, &iter);

      /* now analyze reply */
      if (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_NIL) {
            /* property didn't exist */
            fprintf (stderr,
                   "%s %d : property '%s' for device '%s' does not "
                   "exist\n", __FILE__, __LINE__, key, udi);
            dbus_message_unref (message);
            dbus_message_unref (reply);
            return -1.0f;
      } else if (dbus_message_iter_get_arg_type (&iter) !=
               DBUS_TYPE_DOUBLE) {
            fprintf (stderr,
                   "%s %d : property '%s' for device '%s' is not "
                   "of type double\n", __FILE__, __LINE__, key, udi);
            dbus_message_unref (message);
            dbus_message_unref (reply);
            return -1.0f;
      value = dbus_message_iter_get_double (&iter);

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

Generated by  Doxygen 1.6.0   Back to index