Logo Search packages:      
Sourcecode: hal version File versions

dbus_bool_t hal_device_add_capability ( LibHalContext ctx,
const char *  udi,
const char *  capability 
)

Assign a capability to a device.

Parameters:
ctx The context for the connection to hald
udi Unique Device Id
capability Capability name
Returns:
TRUE if the capability was added, FALSE if the device didn't exist

Definition at line 2178 of file libhal.c.

References LibHalContext_s::connection.

Referenced by block_class_pre_process(), input_class_pre_process(), net_class_pre_process(), pcmcia_socket_class_pre_process(), printer_class_pre_process(), scsi_generic_class_pre_process(), and usb_add_caps_from_class().

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

      message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
                                    "org.freedesktop.Hal.Device",
                                    "AddCapability");
      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, capability);

      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 FALSE;
      }

      if (reply == NULL) {
            dbus_message_unref (message);
            return FALSE;
      }

      dbus_message_unref (reply);
      dbus_message_unref (message);
      return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index