hal/hald hald_dbus.c,1.12,1.13
David Zeuthen
david at freedesktop.org
Sun Sep 19 09:32:17 PDT 2004
Update of /cvs/hal/hal/hald
In directory gabe:/tmp/cvs-serv15910/hald
Modified Files:
hald_dbus.c
Log Message:
2004-09-19 David Zeuthen <david at fubar.dk>
* hald/hald_dbus.c (agent_device_matches): Removed
(agent_merge_properties): Removed
(agent_manager_remove): Removed
(agent_manager_commit_to_gdl): Removed
(agent_manager_new_device): Removed
(filter_function): Removed all the AgentManager methods
(raise_udi_in_use): Removed
* doc/spec/hal-spec.xml.in: Add docs for info.locked. Remove section
about HAL agents as they are now gone. Fixed up renaming of scsi_device
to scsi.
* doc/spec/hal-arch.dia: Remove HAL Agents
* doc/spec/hal-linux26.dia: Update diagram since we now use a local
socket from hal.hotplug and hal.dev helpers.
* examples/locking.py: New file; shows how to use locking
Index: hald_dbus.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald_dbus.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- hald_dbus.c 19 Sep 2004 13:47:52 -0000 1.12
+++ hald_dbus.c 19 Sep 2004 16:32:15 -0000 1.13
@@ -75,32 +75,6 @@
dbus_message_unref (reply);
}
-/** Raise the org.freedesktop.Hal.UdiInUse error
- *
- * @param connection D-Bus connection
- * @param in_reply_to message to report error on
- * @param udi Unique device id that is already in use
- */
-static void
-raise_udi_in_use (DBusConnection * connection,
- DBusMessage * in_reply_to, const char *udi)
-{
- char buf[512];
- DBusMessage *reply;
-
- snprintf (buf, 511, "Unique device id '%s' is already in use",
- udi);
- HAL_WARNING ((buf));
- reply = dbus_message_new_error (in_reply_to,
- "org.freedesktop.Hal.UdiInUse",
- buf);
- if (reply == NULL)
- DIE (("No memory"));
- if (!dbus_connection_send (connection, reply, NULL))
- DIE (("No memory"));
- dbus_message_unref (reply);
-}
-
/** Raise the org.freedesktop.Hal.NoSuchProperty error
*
* @param connection D-Bus connection
@@ -1721,343 +1695,6 @@
-/** @} */
-
-
-/**
- * @defgroup AgentManagerInterface D-BUS interface org.freedesktop.Hal.AgentManager
- * @ingroup HalDaemon
- * @brief D-BUS interface for creating/destroying device objects
- *
- * @{
- */
-
-/** Create a new device object which will be hidden from applications
- * until the CommitToGdl() method is called. Returns an object that implements
- * the org.freedesktop.Hal.Device interface.
- *
- * <pre>
- * object_reference AgentManager.NewDevice()
- * </pre>
- *
- * @param connection D-BUS connection
- * @param message Message
- * @return What to do with the message
- */
-DBusHandlerResult
-agent_manager_new_device (DBusConnection * connection,
- DBusMessage * message)
-{
- HalDevice *d;
- DBusMessage *reply;
- DBusMessageIter iter;
- const char *udi;
-
- HAL_TRACE (("entering"));
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- DIE (("No memory"));
-
- d = hal_device_new ();
- udi = hal_device_get_udi (d);
-
- HAL_TRACE (("udi=%s", udi));
-
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_string (&iter, udi);
-
- if (!dbus_connection_send (connection, reply, NULL))
- DIE (("No memory"));
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-/** When a hidden device have been built (using the Device interface),
- * a HAL agent can commit it to the global device list using this method.
- *
- * This means that the device object will be visible to desktop applications
- * and the HAL daemon will possibly attempt to boot the device (depending
- * on the property RequireEnable).
- *
- * The parameter given is the new unique-device-id, which should determined
- * from bus-specific information.
- *
- * <pre>
- * void AgentManager.CommitToGdl(object_reference device,
- * string new_object_name)
- *
- * raises org.freedesktop.Hal.NoSuchDevice
- * raises org.freedesktop.Hal.UdiInUse
- * </pre>
- *
- * @param connection D-BUS connection
- * @param message Message
- * @return What to do with the message
- */
-DBusHandlerResult
-agent_manager_commit_to_gdl (DBusConnection * connection,
- DBusMessage * message)
-{
- DBusMessage *reply;
- DBusError error;
- HalDevice *d;
- const char *old_udi;
- const char *new_udi;
-
- dbus_error_init (&error);
- if (!dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &old_udi,
- DBUS_TYPE_STRING, &new_udi,
- DBUS_TYPE_INVALID)) {
- raise_syntax (connection, message, "CommitToGdl");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- HAL_TRACE (("entering, old_udi=%s, new_udi=%s", old_udi, new_udi));
-
- d = hal_device_store_find (hald_get_gdl (), old_udi);
- if (d == NULL) {
- raise_no_such_device (connection, message, old_udi);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- if (hal_device_store_find (hald_get_gdl (), new_udi) != NULL) {
- raise_udi_in_use (connection, message, new_udi);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- /* add to the GDL */
- hal_device_store_add (hald_get_gdl (), d);
-
- /* Ok, send out a signal on the Manager interface that we added
- * this device to the gdl */
- /*manager_send_signal_device_added(new_udi); */
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- DIE (("No memory"));
-
- if (!dbus_connection_send (connection, reply, NULL))
- DIE (("No memory"));
-
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-
-/** If a HAL agent determines that a device have been removed, this method
- * can be called such that the HAL daemon can shutdown and possibly remove
- * the device from the global device list (depending on the property
- * Persistent).
- *
- * <pre>
- * void AgentManager.Remove(object_reference device,
- * string new_object_name)
- *
- * raises org.freedesktop.Hal.NoSuchDevice
- * </pre>
- *
- * @param connection D-BUS connection
- * @param message Message
- * @return What to do with the message
- */
-DBusHandlerResult
-agent_manager_remove (DBusConnection * connection, DBusMessage * message)
-{
- DBusMessage *reply;
- DBusError error;
- HalDevice *d;
- const char *udi;
-
- dbus_error_init (&error);
- if (!dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &udi,
- DBUS_TYPE_INVALID)) {
- raise_syntax (connection, message, "Remove");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- HAL_INFO (("entering, udi=%s", udi));
-
- d = hal_device_store_find (hald_get_gdl (), udi);
- if (d == NULL) {
- raise_no_such_device (connection, message, udi);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- g_object_unref (d);
-
- /* Ok, send out a signal on the Manager interface that we removed
- * this device from the gdl */
- /*
- manager_send_signal_device_removed(udi);
- */
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- DIE (("No memory"));
-
- if (!dbus_connection_send (connection, reply, NULL))
- DIE (("No memory"));
-
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-
-
-/** Merge properties one device to another.
- *
- * <pre>
- * void AgentManager.MergeProperties(object_reference target,
- * object_reference source)
- *
- * raises org.freedesktop.Hal.NoSuchDevice
- * </pre>
- *
- * @param connection D-BUS connection
- * @param message Message
- * @return What to do with the message
- */
-DBusHandlerResult
-agent_merge_properties (DBusConnection * connection, DBusMessage * message)
-{
- DBusMessage *reply;
- DBusError error;
- HalDevice *target_d;
- HalDevice *source_d;
- const char *target_udi;
- const char *source_udi;
-
- dbus_error_init (&error);
- if (!dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &target_udi,
- DBUS_TYPE_STRING, &source_udi,
- DBUS_TYPE_INVALID)) {
- raise_syntax (connection, message, "MergeProperties");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- HAL_TRACE (("entering, target_udi=%s, source_udi=%s",
- target_udi, source_udi));
-
- target_d = hal_device_store_find (hald_get_gdl (), target_udi);
- if (target_d == NULL)
- target_d = hal_device_store_find (hald_get_tdl (), target_udi);
-
- if (target_d == NULL) {
- raise_no_such_device (connection, message, target_udi);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- source_d = hal_device_store_find (hald_get_gdl (), source_udi);
- if (source_d == NULL)
- source_d = hal_device_store_find (hald_get_tdl (), source_udi);
-
- if (source_d == NULL) {
- raise_no_such_device (connection, message, source_udi);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- hal_device_merge (target_d, source_d);
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- DIE (("No memory"));
-
- if (!dbus_connection_send (connection, reply, NULL))
- DIE (("No memory"));
-
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-
-/** 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.
- *
- * <pre>
- * void AgentManager.DeviceMatches(object_reference device1,
- * object_reference device,
- * string namespace)
- *
- * raises org.freedesktop.Hal.NoSuchDevice
- * </pre>
- *
- * @param connection D-BUS connection
- * @param message Message
- * @return What to do with the message
- */
-DBusHandlerResult
-agent_device_matches (DBusConnection * connection, DBusMessage * message)
-{
- DBusMessage *reply;
- DBusError error;
- HalDevice *d1;
- HalDevice *d2;
- const char *udi1;
- const char *udi2;
- const char *namespace;
- dbus_bool_t rc;
- DBusMessageIter iter;
-
- dbus_error_init (&error);
- if (!dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &udi1,
- DBUS_TYPE_STRING, &udi2,
- DBUS_TYPE_STRING, &namespace,
- DBUS_TYPE_INVALID)) {
- raise_syntax (connection, message, "DeviceMatches");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- HAL_TRACE (("entering, udi1=%s, udi2=%s, namespace=%s",
- udi1, udi2, namespace));
-
- d1 = hal_device_store_find (hald_get_gdl (), udi1);
- if (d1 == NULL)
- d1 = hal_device_store_find (hald_get_tdl (), udi1);
-
- if (d1 == NULL) {
- raise_no_such_device (connection, message, udi1);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- d2 = hal_device_store_find (hald_get_gdl (), udi2);
- if (d2 == NULL)
- d2 = hal_device_store_find (hald_get_tdl (), udi2);
-
- if (d2 == NULL) {
- raise_no_such_device (connection, message, udi2);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- rc = hal_device_matches (d1, d2, namespace);
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- DIE (("No memory"));
-
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_boolean (&iter, rc);
-
- if (!dbus_connection_send (connection, reply, NULL))
- DIE (("No memory"));
-
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
static gboolean
reinit_dbus (gpointer user_data)
{
@@ -2157,39 +1794,6 @@
}
else if (dbus_message_is_method_call (message,
- "org.freedesktop.Hal.AgentManager",
- "NewDevice") &&
- strcmp (dbus_message_get_path (message),
- "/org/freedesktop/Hal/Manager") == 0) {
- return agent_manager_new_device (connection, message);
- } else if (dbus_message_is_method_call (message,
- "org.freedesktop.Hal.AgentManager",
- "CommitToGdl") &&
- strcmp (dbus_message_get_path (message),
- "/org/freedesktop/Hal/Manager") == 0) {
- return agent_manager_commit_to_gdl (connection, message);
- } else if (dbus_message_is_method_call (message,
- "org.freedesktop.Hal.AgentManager",
- "Remove") &&
- strcmp (dbus_message_get_path (message),
- "/org/freedesktop/Hal/Manager") == 0) {
- return agent_manager_remove (connection, message);
- } else if (dbus_message_is_method_call (message,
- "org.freedesktop.Hal.AgentManager",
- "MergeProperties") &&
- strcmp (dbus_message_get_path (message),
- "/org/freedesktop/Hal/Manager") == 0) {
- return agent_merge_properties (connection, message);
- } else if (dbus_message_is_method_call (message,
- "org.freedesktop.Hal.AgentManager",
- "DeviceMatches") &&
- strcmp (dbus_message_get_path (message),
- "/org/freedesktop/Hal/Manager") == 0) {
- return agent_device_matches (connection, message);
- }
-
-
- else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"GetAllProperties")) {
return device_get_all_properties (connection, message);
More information about the hal-commit
mailing list