Logo Search packages:      
Sourcecode: hal version File versions

int hal_device_get_property_type ( LibHalContext ctx,
const char *  udi,
const char *  key 
)

Query a property type of a device.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
key Name of the property
Returns:
One of DBUS_TYPE_STRING, DBUS_TYPE_INT32, DBUS_TYPE_UINT64, DBUS_TYPE_BOOL, DBUS_TYPE_DOUBLE or DBUS_TYPE_NIL if the property didn't exist.

Definition at line 826 of file libhal.c.

References LibHalContext_s::connection.

Referenced by main(), and print_property().

{
      DBusError error;
      DBusMessage *message;
      DBusMessage *reply;
      DBusMessageIter iter;
      int type;

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

      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,
                                             &error);
      if (dbus_error_is_set (&error)) {
            fprintf (stderr, "%s %d : %s raised\n\"%s\"\n\n", __FILE__,
                   __LINE__, error.name, error.message);
            dbus_message_unref (message);
            return DBUS_TYPE_NIL;
      }
      if (reply == NULL) {
            dbus_message_unref (message);
            return DBUS_TYPE_NIL;
      }

      dbus_message_iter_init (reply, &iter);
      type = dbus_message_iter_get_int32 (&iter);

      dbus_message_unref (message);
      dbus_message_unref (reply);

      return type;
}


Generated by  Doxygen 1.6.0   Back to index