Logo Search packages:      
Sourcecode: hal version File versions

dbus_bool_t hal_agent_commit_to_gdl ( LibHalContext ctx,
const char *  temp_udi,
const char *  udi 
)

When a hidden device have been built using the NewDevice method, ie. hal_agent_new_device(), and the org.freedesktop.Hal.Device interface this function will commit it to the global device list.

This means that the device object will be visible to applications and the HAL daemon will possibly attempt to boot the device (depending on the property RequireEnable).

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

Parameters:
ctx The context for the connection to hald
temp_udi The tempoary unique device id as returned by hal_agent_new_device()
udi The new unique device id.
Returns:
FALSE if the given unique device id is already in use.

Definition at line 1671 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",
                                    "CommitToGdl");
      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, temp_udi);
      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)) {
            if (dbus_error_has_name
                (&error, "org.freedesktop.Hal.UdiInUse"))
                  return FALSE;
            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