hal/hald device.c,1.14,1.15
David Zeuthen
david at freedesktop.org
Sat Feb 26 14:31:44 PST 2005
- Previous message: hal/fdi/information/10freedesktop 10-usb-card-readers.fdi, NONE,
1.1 10-usb-music-players.fdi, NONE, 1.1 10-usb-zip-drives.fdi,
NONE, 1.1
- Next message: hal/libhal libhal.c,1.42,1.43 libhal.h,1.23,1.24
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/hal/hal/hald
In directory gabe:/tmp/cvs-serv9653/hald
Modified Files:
device.c
Log Message:
2005-02-26 David Zeuthen <davidz at redhat.com>
* libhal-storage/libhal-storage.h: Add new LibHalDriveType entries
for ZIP, JAZ and FLASH_KEY - the latter represents a USB memory stick.
* libhal-storage/libhal-storage.c (my_strvdup): New function
(libhal_drive_from_udi): Fixup new detection of cameras and
musicplayers. Also handle storage.drive_type zip, jaz and flash_key
and convert to LibHalDriveType as appropriate
* libhal/libhal.h: Fixup type for LibHalDeviceCondition
* libhal/libhal.c (filter_func): Fix up condition handling now that
it's a name and details string rather than a whole DBusMessage trailing
off. Fix up a bunch of free's due to new memory ownership semantics
in the new D-BUS
(libhal_device_query_capability): Handle this now that capabilities
is a strlist
* hald/device.c (hal_device_merge): info.capabilities is now a strlist
(hal_device_add_capability): -do-
(hal_device_has_capability): -do-
(hal_device_property_strlist_add): Return whether element was actually
added
* fdi/information/10freedesktop/10-usb-zip-drives.fdi: New file
* fdi/information/10freedesktop/10-usb-music-players.fdi: New file
* fdi/information/10freedesktop/10-usb-card-readers.fdi: New file
Index: device.c
===================================================================
RCS file: /cvs/hal/hal/hald/device.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- device.c 24 Feb 2005 16:50:34 -0000 1.14
+++ device.c 26 Feb 2005 22:31:42 -0000 1.15
@@ -253,8 +253,8 @@
void
hal_device_merge (HalDevice *target, HalDevice *source)
{
- const char *caps;
GSList *iter;
+ GSList *caps;
/* device_property_atomic_update_begin (); */
@@ -316,17 +316,10 @@
/* device_property_atomic_update_end (); */
- caps = hal_device_property_get_string (source, "info.capabilities");
- if (caps != NULL) {
- char **split_caps, **iter;
-
- split_caps = g_strsplit (caps, " ", 0);
- for (iter = split_caps; *iter != NULL; iter++) {
- if (!hal_device_has_capability (target, *iter))
- hal_device_add_capability (target, *iter);
- }
-
- g_strfreev (split_caps);
+ caps = hal_device_property_get_strlist (source, "info.capabilities");
+ for (iter = caps; iter != NULL; iter = iter->next) {
+ if (!hal_device_has_capability (target, iter->data))
+ hal_device_add_capability (target, iter->data);
}
}
@@ -411,54 +404,29 @@
void
hal_device_add_capability (HalDevice *device, const char *capability)
{
- const char *caps;
-
- caps = hal_device_property_get_string (device, "info.capabilities");
-
- if (caps == NULL) {
- hal_device_property_set_string (device, "info.capabilities",
- capability);
- } else {
- if (hal_device_has_capability (device, capability))
- return;
- else {
- char *tmp;
-
- tmp = g_strconcat (caps, " ", capability, NULL);
-
- hal_device_property_set_string (device,
- "info.capabilities",
- tmp);
-
- g_free (tmp);
- }
- }
-
- g_signal_emit (device, signals[CAPABILITY_ADDED], 0, capability);
+ if (hal_device_property_strlist_add (device, "info.capabilities", capability))
+ g_signal_emit (device, signals[CAPABILITY_ADDED], 0, capability);
}
gboolean
hal_device_has_capability (HalDevice *device, const char *capability)
{
- const char *caps;
- char **split_caps, **iter;
+ GSList *caps;
+ GSList *iter;
gboolean matched = FALSE;
- caps = hal_device_property_get_string (device, "info.capabilities");
+ caps = hal_device_property_get_strlist (device, "info.capabilities");
if (caps == NULL)
return FALSE;
- split_caps = g_strsplit (caps, " ", 0);
- for (iter = split_caps; *iter != NULL; iter++) {
- if (strcmp (*iter, capability) == 0) {
+ for (iter = caps; iter != NULL; iter = iter->next) {
+ if (strcmp (iter->data, capability) == 0) {
matched = TRUE;
break;
}
}
- g_strfreev (split_caps);
-
return matched;
}
@@ -1201,15 +1169,19 @@
const char *value)
{
HalProperty *prop;
+ gboolean res;
+
+ res = FALSE;
/* check if property already exists */
prop = hal_device_property_find (device, key);
if (prop != NULL) {
if (hal_property_get_type (prop) != HAL_PROPERTY_TYPE_STRLIST)
- return FALSE;
+ goto out;
- if (hal_property_strlist_add (prop, value)) {
+ res = hal_property_strlist_add (prop, value);
+ if (res) {
g_signal_emit (device, signals[PROPERTY_CHANGED], 0,
key, FALSE, FALSE);
}
@@ -1222,9 +1194,12 @@
g_signal_emit (device, signals[PROPERTY_CHANGED], 0,
key, FALSE, TRUE);
+
+ res = TRUE;
}
- return TRUE;
+out:
+ return res;
}
gboolean
- Previous message: hal/fdi/information/10freedesktop 10-usb-card-readers.fdi, NONE,
1.1 10-usb-music-players.fdi, NONE, 1.1 10-usb-zip-drives.fdi,
NONE, 1.1
- Next message: hal/libhal libhal.c,1.42,1.43 libhal.h,1.23,1.24
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the hal-commit
mailing list