Logo Search packages:      
Sourcecode: hal version File versions

dbus_bool_t hal_agent_device_matches ( LibHalContext ctx,
const char *  udi1,
const char *  udi2,
const char *  property_namespace 

Check a set of properties for two devices matches.

Checks that all properties where keys, starting with a given value (namespace), of the first device is in the second device and that they got the same value and type.

Note that the other inclusion isn't tested, so there could be properties (from the given namespace) in the second device not present in the first device.

ctx The context for the connection to hald
udi1 Unique Device Id for device 1
udi2 Unique Device Id for device 2
property_namespace Namespace for set of devices, e.g. "usb"
TRUE if all properties starting with the given namespace parameter from one device is in the other and have the same value.

Definition at line 1970 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",
      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, udi1);
      dbus_message_iter_append_string (&iter, udi2);
      dbus_message_iter_append_string (&iter, property_namespace);

      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;
      /* now analyse reply */
      dbus_message_iter_init (reply, &iter);
      if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_BOOLEAN) {
            fprintf (stderr,
                   "%s %d : expected a bool in reply to DeviceMatches\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