hal: Branch 'master'
Danny Kukawka
dkukawka at kemper.freedesktop.org
Thu Aug 31 09:56:39 PDT 2006
doc/spec/hal-spec-fdi-files.xml | 4 ++--
hald/device.c | 20 ++++++++++++++++++++
hald/device.h | 3 ++-
hald/device_info.c | 25 +++++++++++++++++++------
4 files changed, 43 insertions(+), 9 deletions(-)
New commits:
diff-tree cf4fa80cc891f9a254b3d47fd98eea834503a473 (from bacb7b433d27381efd490b6e8bd6a3be4a8e6e92)
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Thu Aug 31 18:53:09 2006 +0200
add support for attribute 'empty' for strlist to <match> tag
Added support for attribute 'empty' for type 'strlist' (currently
only for type 'string') within the <match> tag of fdi-files. This
should allow such kind of constructs:
[...]
<remove key="info.callouts.add" type="strlist">blah</remove>
<match key="info.callouts.add" empty="true">
<remove key="info.callouts.add"></remove>
</match>
[...]
diff --git a/doc/spec/hal-spec-fdi-files.xml b/doc/spec/hal-spec-fdi-files.xml
index ba4f1af..07411ad 100644
--- a/doc/spec/hal-spec-fdi-files.xml
+++ b/doc/spec/hal-spec-fdi-files.xml
@@ -89,7 +89,7 @@
</listitem>
<listitem>
<para>
- <literal>empty</literal> - can only be used on string properties
+ <literal>empty</literal> - can only be used on string or strlist properties
with 'true' and 'false'.
The semantics for 'true' is to match only when the string is non-empty.
</para>
@@ -203,7 +203,7 @@
The <literal><remove></literal>, directive require only a key and can be used with all keys.
For <literal>strlist</literal> there is additionally a special syntax to remove a item from the
string list. For example to remove item 'bla' from property 'foo.bar':
- <literal><remove key="foo.bar" type="strlist">bla</merge></literal>
+ <literal><remove key="foo.bar" type="strlist">bla</remove></literal>
</para>
<para>
Device Information files are stored in the following standard hierachy with the following default
diff --git a/hald/device.c b/hald/device.c
index a1d91f7..ea7cf08 100644
--- a/hald/device.c
+++ b/hald/device.c
@@ -1294,3 +1294,23 @@ hal_device_property_strlist_remove (HalD
return TRUE;
}
+
+gboolean
+hal_device_property_strlist_is_empty (HalDevice *device,
+ const char *key)
+{
+ GSList *strlist;
+
+ if ( hal_device_has_property (device, key)) {
+ strlist = hal_device_property_get_strlist (device, key);
+ if (strlist == NULL )
+ return TRUE;
+
+ if (g_slist_length (strlist) > 0)
+ return FALSE;
+ else
+ return TRUE;
+ }
+ return FALSE;
+}
+
diff --git a/hald/device.h b/hald/device.h
index 590ee03..c31353f 100644
--- a/hald/device.h
+++ b/hald/device.h
@@ -173,7 +173,8 @@ gboolean hal_device_property_strlis
gboolean hal_device_property_strlist_remove (HalDevice *device,
const char *key,
const char *value);
-
+gboolean hal_device_property_strlist_is_empty (HalDevice *device,
+ const char *key);
gboolean hal_device_property_remove (HalDevice *device,
const char *key);
diff --git a/hald/device_info.c b/hald/device_info.c
index 5803719..b181321 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -460,19 +460,32 @@ handle_match (ParsingContext * pc, const
return TRUE;
}
} else if (strcmp (attr[2], "empty") == 0) {
+ int type;
dbus_bool_t is_empty = TRUE;
dbus_bool_t should_be_empty = TRUE;
+
if (strcmp (attr[3], "false") == 0)
should_be_empty = FALSE;
- if (hal_device_property_get_type (d, prop_to_check) != HAL_PROPERTY_TYPE_STRING)
+ type = hal_device_property_get_type (d, prop_to_check);
+ switch (type) {
+ case HAL_PROPERTY_TYPE_STRING:
+ if (hal_device_has_property (d, prop_to_check))
+ if (strlen (hal_device_property_get_string (d, prop_to_check)) > 0)
+ is_empty = FALSE;
+ break;
+ case HAL_PROPERTY_TYPE_STRLIST:
+ if (hal_device_has_property (d, prop_to_check))
+ if (!hal_device_property_strlist_is_empty(d, prop_to_check))
+ is_empty = FALSE;
+ break;
+ default:
+ /* explicit fallthrough */
return FALSE;
-
- if (hal_device_has_property (d, prop_to_check))
- if (strlen (hal_device_property_get_string (d, prop_to_check)) > 0)
- is_empty = FALSE;
-
+ break;
+ }
+
if (should_be_empty) {
if (is_empty)
return TRUE;
More information about the hal-commit
mailing list