hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Tue Aug 28 10:18:23 PDT 2007


 hald/device_info.c |   33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

New commits:
diff-tree 223efeb9ded17135935dc67cdaf4e64e98bfbcd2 (from 778987b83a36437419bdfab926a1e95e2ea03191)
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Aug 28 19:18:11 2007 +0200

    fix indirections in fdi files (prepend/append copy_property)
    
    This patch fixes indirections in the <prepend> and <append> merging directives
    for FDI files if they are used with type="copy_proptery" as it work already
    with <merge>.
    
    This allows such line:
    
    <append key="foo.bar" type="copy_property">@info.parent:foo2.bar2</append>
    
    Should also fix fd.o #9849.

diff --git a/hald/device_info.c b/hald/device_info.c
index 0ddf8f1..2404079 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -853,15 +853,38 @@ handle_merge (struct rule *rule, HalDevi
 			case MERGE_STRING:
 				strncpy (buf, value, sizeof (buf));
 				break;
-
 			case MERGE_COPY_PROPERTY:
-				hal_device_property_get_as_string (d, value, buf, sizeof (buf));
+			{
+				char udi_to_merge_from[HAL_PATH_MAX];
+				char prop_to_merge[HAL_PATH_MAX];
+
+				/* Resolve key paths like 'someudi/foo/bar/baz:prop.name'
+				 * '@prop.here.is.an.udi:with.prop.name'
+				 */
+				if (!resolve_udiprop_path (value,
+							   hal_device_get_udi (d),
+							   udi_to_merge_from, sizeof (udi_to_merge_from),
+							   prop_to_merge, sizeof (prop_to_merge))) {
+					HAL_ERROR (("Could not resolve keypath '%s' on udi '%s'", value, hal_device_get_udi (d)));
+				} else {
+					HalDevice *copyfrom;
+
+					copyfrom = hal_device_store_find (hald_get_gdl (), udi_to_merge_from);
+					if (copyfrom == NULL) {
+						copyfrom = hal_device_store_find (hald_get_tdl (), udi_to_merge_from);
+					}
+					if (copyfrom == NULL) {
+						HAL_ERROR (("Could not find device with udi '%s'", udi_to_merge_from));
+					} else {
+						hal_device_property_get_as_string (copyfrom, prop_to_merge, buf, sizeof (buf));
+					}
+				}
 				break;
-
+			}
 			default:
 				break;
 			}
-
+		
 			existing_string = hal_device_property_get_string (d, key);
 			if (existing_string != NULL) {
 				if (rule->rtype == RULE_APPEND) {
@@ -876,8 +899,8 @@ handle_merge (struct rule *rule, HalDevi
 			}
 
 			hal_device_property_set_string (d, key, buf2);
+		
 		}
-
 	} else if (rule->rtype == RULE_ADDSET) {
 
 		if (hal_device_property_get_type (d, key) != HAL_PROPERTY_TYPE_STRLIST &&


More information about the hal-commit mailing list