diff options
author | David Zeuthen <david@fubar.dk> | 2003-12-03 01:52:34 +0000 |
---|---|---|
committer | David Zeuthen <david@fubar.dk> | 2003-12-03 01:52:34 +0000 |
commit | e54922f0b07c8e8bd845ac82445a11e384fe0e79 (patch) | |
tree | 5843bbf5227d5d1e2ad0a643b97e688c7e401a62 /hald | |
parent | 14cf3e928ebd192c89ecbcb7ec0c1fb154dc5f18 (diff) |
new directory with tools/hal-device-manager split into many files
Set Capability and Category properties
new function (process_input_proc_info): Set Capability and Category
properties
Set some properties under the volume namespace
Set Capability and Category properties; set MAC address under namespace
ethernet for Ethernet net devices
Set Capability and Category properties (pci_add_caps_from_class): new
function
Set Capability and Category properties (usb_add_caps_from_class): new
function
new function (filter_function): Add call
Convert from d-bus string array. (hal_manager_find_device_string_match):
Convert from d-bus string array. (hal_device_add_capability): new
function (hal_device_query_capability): new function
(hal_find_device_by_capability): new function
Add prototypes
Diffstat (limited to 'hald')
-rw-r--r-- | hald/main.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/hald/main.c b/hald/main.c index e1ad7a0a..793fc7a3 100644 --- a/hald/main.c +++ b/hald/main.c @@ -1016,6 +1016,75 @@ static DBusHandlerResult manager_find_device_string_match( return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } + +/** Find devices in the GDL with a given capability. + * + * <pre> + * array{object_reference} Manager.FindDeviceByCapability(string capability) + * </pre> + * + * @param connection D-BUS connection + * @param message Message + * @return What to do with the message + */ +static DBusHandlerResult manager_find_device_by_capability( + DBusConnection* connection, + DBusMessage* message) +{ + DBusMessage* reply; + DBusMessageIter iter; + DBusMessageIter iter_array; + DBusError error; + const char* capability; + HalDeviceIterator iter_device; + int type; + HalDevice* device; + + LOG_TRACE(("entering")); + + dbus_error_init(&error); + if( !dbus_message_get_args(message, &error, + DBUS_TYPE_STRING, &capability, + DBUS_TYPE_INVALID) ) + { + raise_syntax(connection, message, "Manager.FindDeviceByCapability"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + reply = dbus_message_new_method_return(message); + if( reply==NULL ) + DIE(("No memory")); + + dbus_message_iter_init(reply, &iter); + dbus_message_iter_append_array(&iter, &iter_array, DBUS_TYPE_STRING); + + for(ds_device_iter_begin(&iter_device); + ds_device_iter_has_more(&iter_device); + ds_device_iter_next(&iter_device)) + { + device = ds_device_iter_get(&iter_device); + + if( !device->in_gdl ) + continue; + + type = ds_property_get_type(device, "Capabilities"); + if( type==DBUS_TYPE_STRING ) + { + if( strstr(ds_property_get_string(device, "Capabilities"), + capability)!=NULL ) + dbus_message_iter_append_string(&iter_array, device->udi); + } + } + + if( !dbus_connection_send(connection, reply, NULL) ) + DIE(("No memory")); + + dbus_message_unref (reply); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + + /** Determine if a device exists. * * <pre> @@ -1499,6 +1568,15 @@ static DBusHandlerResult filter_function(DBusConnection* connection, return manager_find_device_string_match(connection, message); } else if( dbus_message_is_method_call(message, + "org.freedesktop.Hal.Manager", + "FindDeviceByCapability") && + strcmp(dbus_message_get_path(message), + "/org/freedesktop/Hal/Manager")==0 ) + { + return manager_find_device_by_capability(connection, message); + } + + else if( dbus_message_is_method_call(message, "org.freedesktop.Hal.AgentManager", "NewDevice") && strcmp(dbus_message_get_path(message), |