Logo Search packages:      
Sourcecode: hal version File versions

dbus_bool_t hal_agent_remove_device ( LibHalContext ctx,
const char *  udi 
)

This method can be invoked when a device is removed. The HAL daemon will shut down the device. Note that the device may still be in the device list if the Persistent property is set to true.

Note that the program invoking this method needs to run with super user privileges.

Parameters:
ctx The context for the connection to hald
udi The new unique device id.
Returns:
TRUE if the device was removed

Definition at line 1729 of file libhal.c.

References LibHalContext_s::connection.

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

      message = dbus_message_new_method_call ("org.freedesktop.Hal",
                                    "/org/freedesktop/Hal/Manager",
                                    "org.freedesktop.Hal.AgentManager",
                                    "Remove");
      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, udi);

      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 : 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_unref (message);
      dbus_message_unref (reply);
      return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index