summaryrefslogtreecommitdiff
path: root/hald
diff options
context:
space:
mode:
authorDavid Zeuthen <david@fubar.dk>2003-12-08 22:01:44 +0000
committerDavid Zeuthen <david@fubar.dk>2003-12-08 22:01:44 +0000
commit656008dee085d23daf65dab8356e49d018cc305d (patch)
tree6db1a15440971ed1b5c7e433e8e9655bcc64514e /hald
parent6a751c825d0b08ad1b879c704b45b1562df7f5cd (diff)
s/volume./block./ (udev_filter_func): new function for filtering D-BUS
messages from udev (setup_udev_listener): setup filter for udev messages (hal_monitor_enter): Listen to D-BUS messages Use global sysfs path (device_hotplug_add): Use global sysfs path (device_hotplug_remove): Use global sysfs path (drivers_collect): Use global sysfs path (mainloop_integration): Save D-BUS connection object for later use (main): Get sysfs mount path once and for all Add dbus_connection and sysfs_mount_path as extern variables new function (filter_function): add check for Device.QueryCapability Minor formatting stuff Crude example of volume manager now that we got udev integration in place. It doesn't really mount anything but prints out when it should mount. You'll need a very recent udev from BitKeeper with D-BUS enabled (got the patch accepted today)
Diffstat (limited to 'hald')
-rw-r--r--hald/main.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/hald/main.c b/hald/main.c
index 65790c1c..5229767b 100644
--- a/hald/main.c
+++ b/hald/main.c
@@ -1135,6 +1135,73 @@ static DBusHandlerResult device_property_exists(DBusConnection* connection,
}
+/** Determine if a device got a capability
+ *
+ * <pre>
+ * bool Device.QueryCapability(string capability_name)
+ *
+ * raises org.freedesktop.Hal.NoSuchDevice,
+ * </pre>
+ *
+ * @param connection D-BUS connection
+ * @param message Message
+ * @return What to do with the message
+ */
+static DBusHandlerResult device_query_capability(DBusConnection* connection,
+ DBusMessage* message)
+{
+ dbus_bool_t rc;
+ const char* udi;
+ const char* caps;
+ char* capability;
+ HalDevice* d;
+ DBusMessage *reply;
+ DBusError error;
+ DBusMessageIter iter;
+
+ LOG_TRACE(("entering"));
+
+ udi = dbus_message_get_path(message);
+
+ d = ds_device_find(udi);
+ if( d==NULL )
+ {
+ raise_no_such_device(connection, message, udi);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ dbus_error_init(&error);
+ if( !dbus_message_get_args(message, &error,
+ DBUS_TYPE_STRING, &capability,
+ DBUS_TYPE_INVALID) )
+ {
+ raise_syntax(connection, message, "QueryCapability");
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ reply = dbus_message_new_method_return(message);
+ if( reply==NULL )
+ DIE(("No memory"));
+
+ rc = FALSE;
+ caps = ds_property_get_string(d, "Capabilities");
+ if( caps!=NULL )
+ {
+ if( strstr(caps, capability)!=NULL )
+ rc = TRUE;
+ }
+
+ 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_NOT_YET_HANDLED;
+}
+
+
/** Enable a device.
*
* <pre>
@@ -1846,6 +1913,12 @@ static DBusHandlerResult filter_function(DBusConnection* connection,
{
return device_add_capability(connection, message);
}
+ else if( dbus_message_is_method_call(message,
+ "org.freedesktop.Hal.Device",
+ "QueryCapability") )
+ {
+ return device_query_capability(connection, message);
+ }
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}