summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <david@fubar.dk>2005-02-26 22:31:42 +0000
committerDavid Zeuthen <david@fubar.dk>2005-02-26 22:31:42 +0000
commitdaa3bacc8f4f3fbe5aa57c8b173918a32beddfa8 (patch)
tree707542ec015d27762d9caceda143774fefaf8472
parentff41ef5247205471ecf09addb767cc66817513d8 (diff)
downloadhal-daa3bacc8f4f3fbe5aa57c8b173918a32beddfa8.tar.gz
Add new LibHalDriveType entries for ZIP, JAZ and FLASH_KEY - the latter
represents a USB memory stick. 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 Fixup type for LibHalDeviceCondition 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 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 New file New file New file
-rw-r--r--ChangeLog31
-rw-r--r--fdi/information/10freedesktop/10-usb-card-readers.fdi32
-rw-r--r--fdi/information/10freedesktop/10-usb-music-players.fdi40
-rw-r--r--fdi/information/10freedesktop/10-usb-zip-drives.fdi19
-rw-r--r--hald/device.c69
-rw-r--r--libhal-storage/libhal-storage.c51
-rw-r--r--libhal-storage/libhal-storage.h15
-rw-r--r--libhal/libhal.c83
-rw-r--r--libhal/libhal.h2
9 files changed, 228 insertions, 114 deletions
diff --git a/ChangeLog b/ChangeLog
index 3e0c99e9..d2bb2b04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2005-02-26 David Zeuthen <davidz@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
+
2005-02-25 David Zeuthen <davidz@redhat.com>
* hald/linux2/probing/probe-pc-floppy.c: New file; test for floppy
diff --git a/fdi/information/10freedesktop/10-usb-card-readers.fdi b/fdi/information/10freedesktop/10-usb-card-readers.fdi
new file mode 100644
index 00000000..cc4b6c9a
--- /dev/null
+++ b/fdi/information/10freedesktop/10-usb-card-readers.fdi
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->
+
+<deviceinfo version="0.2">
+ <device>
+
+ <!-- Generic catch all -->
+ <match key="storage.bus" string="usb">
+ <match key="storage.model" contains="HS-CF">
+ <merge key="storage.drive_type" type="string">compact_flash</merge>
+ </match>
+ <match key="storage.model" contains="HS-MS">
+ <merge key="storage.drive_type" type="string">memory_stick</merge>
+ </match>
+ <match key="storage.model" contains="HS-SM">
+ <merge key="storage.drive_type" type="string">smart_media</merge>
+ </match>
+ <match key="storage.model" contains="HS-SD/MMC">
+ <merge key="storage.drive_type" type="string">sd_mmc</merge>
+ </match>
+ </match>
+
+ <!-- Lexar CF Reader -->
+ <match key="storage.bus" string="usb">
+ <match key="@storage.physical_device:usb.vendor_id" int="0x05dc">
+ <match key="@storage.physical_device:usb.product_id" int="0x0002">
+ <merge key="storage.drive_type" type="string">compact_flash</merge>
+ </match>
+ </match>
+ </match>
+
+ </device>
+</deviceinfo>
diff --git a/fdi/information/10freedesktop/10-usb-music-players.fdi b/fdi/information/10freedesktop/10-usb-music-players.fdi
new file mode 100644
index 00000000..61e99f3e
--- /dev/null
+++ b/fdi/information/10freedesktop/10-usb-music-players.fdi
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->
+
+<deviceinfo version="0.2">
+ <device>
+
+ <!-- Apple iPod - TODO: use USB ids to determine exact output formats -->
+ <match key="info.category" string="storage">
+ <match key="storage.vendor" contains="Apple">
+ <match key="storage.model" contains="iPod">
+ <append key="info.capabilities" type="strlist">portable_audio_player</append>
+ <merge key="portable_audio_player.access_method" type="string">storage</merge>
+ <merge key="portable_audio_player.database_type" type="string">ipod</merge>
+ <merge key="portable_audio_player.storage_device" type="copy_property">info.udi</merge>
+ <append key="portable_audio_player.output_formats" type="strlist">audio/mpeg</append>
+ <append key="portable_audio_player.output_formats" type="strlist">audio/x-mp3</append>
+ <append key="portable_audio_player.output_formats" type="strlist">audio/aac</append>
+ <merge key="storage.requires_eject" type="bool">true</merge>
+ </match>
+ </match>
+ </match>
+
+ <!-- Jetflash MP3 Player -->
+ <match key="info.category" string="storage">
+ <match key="@storage.physical_device:info.bus" string="usb">
+ <match key="@storage.physical_device:usb.vendor_id" int="0x066f">
+ <match key="@storage.physical_device:usb.product_id" int="0x8000">
+ <append key="info.capabilities" type="strlist">portable_audio_player</append>
+ <merge key="portable_audio_player.access_method" type="string">storage</merge>
+ <merge key="portable_audio_player.database_type" type="string">flat</merge>
+ <merge key="portable_audio_player.storage_device" type="copy_property">info.udi</merge>
+ <append key="portable_audio_player.output_formats" type="strlist">audio/mpeg</append>
+ <append key="portable_audio_player.output_formats" type="strlist">audio/x-ms-wma</append>
+ <append key="portable_audio_player.input_formats" type="strlist">audio/x-wav</append>
+ </match>
+ </match>
+ </match>
+ </match>
+
+ </device>
+</deviceinfo>
diff --git a/fdi/information/10freedesktop/10-usb-zip-drives.fdi b/fdi/information/10freedesktop/10-usb-zip-drives.fdi
new file mode 100644
index 00000000..c532b3f4
--- /dev/null
+++ b/fdi/information/10freedesktop/10-usb-zip-drives.fdi
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->
+
+<deviceinfo version="0.2">
+ <device>
+
+ <!-- USB Zip Drives -->
+ <match key="storage.bus" string="usb">
+ <match key="storage.drive_type" string="disk">
+ <match key="storage.vendor" string="IOMEGA">
+ <match key="storage.model" contains_ncase="ZIP">
+ <merge key="storage.drive_type" type="string">zip</merge>
+ <merge key="storage.requires_eject" type="bool">true</merge>
+ </match>
+ </match>
+ </match>
+ </match>
+
+ </device>
+</deviceinfo>
diff --git a/hald/device.c b/hald/device.c
index eecb2082..e17088cc 100644
--- a/hald/device.c
+++ b/hald/device.c
@@ -253,8 +253,8 @@ hal_device_merge_with_rewrite (HalDevice *target,
void
hal_device_merge (HalDevice *target, HalDevice *source)
{
- const char *caps;
GSList *iter;
+ GSList *caps;
/* device_property_atomic_update_begin (); */
@@ -316,17 +316,10 @@ hal_device_merge (HalDevice *target, HalDevice *source)
/* 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 @@ hal_device_set_udi (HalDevice *device, const char *udi)
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 @@ hal_device_property_strlist_add (HalDevice *device,
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 @@ hal_device_property_strlist_add (HalDevice *device,
g_signal_emit (device, signals[PROPERTY_CHANGED], 0,
key, FALSE, TRUE);
+
+ res = TRUE;
}
- return TRUE;
+out:
+ return res;
}
gboolean
diff --git a/libhal-storage/libhal-storage.c b/libhal-storage/libhal-storage.c
index 8b89c2e7..7fbe32d0 100644
--- a/libhal-storage/libhal-storage.c
+++ b/libhal-storage/libhal-storage.c
@@ -654,6 +654,8 @@ struct LibHalDrive_s {
LibHalContext *hal_ctx;
+ char **capabilities;
+
char mount_options[MOUNT_OPTIONS_SIZE];
};
@@ -729,6 +731,7 @@ libhal_drive_free (LibHalDrive *drive)
libhal_free_string (drive->firmware_version);
libhal_free_string (drive->desired_mount_point);
libhal_free_string (drive->mount_filesystem);
+ libhal_free_string_array (drive->capabilities);
}
@@ -754,6 +757,28 @@ libhal_volume_free (LibHalVolume *vol)
}
+static char **
+my_strvdup (char **strv)
+{
+ unsigned int num_elems;
+ unsigned int i;
+ char **res;
+
+ for (num_elems = 0; strv[num_elems] != NULL; num_elems++)
+ ;
+
+ res = calloc (num_elems + 1, sizeof (char*));
+ if (res == NULL)
+ goto out;
+
+ for (i = 0; i < num_elems; i++)
+ res[i] = strdup (strv[i]);
+ res[i] = NULL;
+
+out:
+ return res;
+}
+
/* ok, hey, so this is a bit ugly */
#define LIBHAL_PROP_EXTRACT_BEGIN if (FALSE)
@@ -762,6 +787,7 @@ libhal_volume_free (LibHalVolume *vol)
#define LIBHAL_PROP_EXTRACT_STRING(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_STRING) _where_ = (libhal_psi_get_string (&it) != NULL && strlen (libhal_psi_get_string (&it)) > 0) ? strdup (libhal_psi_get_string (&it)) : NULL
#define LIBHAL_PROP_EXTRACT_BOOL(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_BOOLEAN) _where_ = libhal_psi_get_bool (&it)
#define LIBHAL_PROP_EXTRACT_BOOL_BITFIELD(_property_, _where_, _field_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_BOOLEAN) _where_ |= libhal_psi_get_bool (&it) ? _field_ : 0
+#define LIBHAL_PROP_EXTRACT_STRLIST(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_STRLIST) _where_ = my_strvdup (libhal_psi_get_strlist (&it))
/** Given a UDI for a HAL device of capability 'storage', this
* function retrieves all the relevant properties into convenient
@@ -779,6 +805,7 @@ libhal_drive_from_udi (LibHalContext *hal_ctx, const char *udi)
LibHalPropertySet *properties;
LibHalPropertySetIterator it;
DBusError error;
+ unsigned int i;
drive = NULL;
properties = NULL;
@@ -848,6 +875,8 @@ libhal_drive_from_udi (LibHalContext *hal_ctx, const char *udi)
LIBHAL_PROP_EXTRACT_BOOL ("storage.no_partitions_hint", drive->no_partitions_hint);
+ LIBHAL_PROP_EXTRACT_STRLIST ("info.capabilities", drive->capabilities);
+
LIBHAL_PROP_EXTRACT_END;
}
@@ -872,33 +901,27 @@ libhal_drive_from_udi (LibHalContext *hal_ctx, const char *udi)
drive->type = LIBHAL_DRIVE_TYPE_SMART_MEDIA;
} else if (strcmp (drive->type_textual, "sd_mmc") == 0) {
drive->type = LIBHAL_DRIVE_TYPE_SD_MMC;
-/*
} else if (strcmp (drive->type_textual, "zip") == 0) {
drive->type = LIBHAL_DRIVE_TYPE_ZIP;
} else if (strcmp (drive->type_textual, "jaz") == 0) {
drive->type = LIBHAL_DRIVE_TYPE_JAZ;
-*/
+ } else if (strcmp (drive->type_textual, "flashkey") == 0) {
+ drive->type = LIBHAL_DRIVE_TYPE_FLASHKEY;
} else {
drive->type = LIBHAL_DRIVE_TYPE_DISK;
}
}
- /* check if physical device is a camera or mp3 player */
- if (drive->physical_device != NULL) {
- char *category;
- DBusError err1;
-
- dbus_error_init (&err1);
- category = libhal_device_get_property_string (hal_ctx, drive->physical_device, "info.category", &err1);
- if (category != NULL) {
- if (strcmp (category, "portable_audio_player") == 0) {
+ if (drive->capabilities != NULL) {
+ for (i = 0; drive->capabilities[i] != NULL; i++) {
+ if (strcmp (drive->capabilities[i], "portable_audio_player") == 0) {
drive->type = LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER;
- } else if (strcmp (category, "camera") == 0) {
+ break;
+ } else if (strcmp (drive->capabilities[i], "camera") == 0) {
drive->type = LIBHAL_DRIVE_TYPE_CAMERA;
+ break;
}
-
- libhal_free_string (category);
}
}
diff --git a/libhal-storage/libhal-storage.h b/libhal-storage/libhal-storage.h
index d79d5a78..0f46b22d 100644
--- a/libhal-storage/libhal-storage.h
+++ b/libhal-storage/libhal-storage.h
@@ -78,8 +78,9 @@ typedef enum {
LIBHAL_STORAGE_ICON_DRIVE_SD_MMC = 0x10800,
LIBHAL_STORAGE_ICON_DRIVE_CAMERA = 0x10900,
LIBHAL_STORAGE_ICON_DRIVE_PORTABLE_AUDIO_PLAYER = 0x10a00,
-/* LIBHAL_STORAGE_ICON_DRIVE_ZIP = 0x10b00,
- LIBHAL_STORAGE_ICON_DRIVE_JAZ = 0x10c00,*/
+ LIBHAL_STORAGE_ICON_DRIVE_ZIP = 0x10b00,
+ LIBHAL_STORAGE_ICON_DRIVE_JAZ = 0x10c00,
+ LIBHAL_STORAGE_ICON_DRIVE_FLASH_KEY = 0x10d00,
LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK = 0x20000,
LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IDE = 0x20001,
@@ -108,8 +109,9 @@ typedef enum {
LIBHAL_STORAGE_ICON_VOLUME_SD_MMC = 0x20800,
LIBHAL_STORAGE_ICON_VOLUME_CAMERA = 0x20900,
LIBHAL_STORAGE_ICON_VOLUME_PORTABLE_AUDIO_PLAYER = 0x20a00,
-/* LIBHAL_STORAGE_ICON_VOLUME_ZIP = 0x10b00,
- LIBHAL_STORAGE_ICON_VOLUME_JAZ = 0x10c00,*/
+ LIBHAL_STORAGE_ICON_VOLUME_ZIP = 0x20b00,
+ LIBHAL_STORAGE_ICON_VOLUME_JAZ = 0x20c00,
+ LIBHAL_STORAGE_ICON_VOLUME_FLASH_KEY = 0x20d00,
LIBHAL_STORAGE_ICON_DISC_CDROM = 0x30000,
LIBHAL_STORAGE_ICON_DISC_CDR = 0x30001,
@@ -158,9 +160,10 @@ typedef enum {
LIBHAL_DRIVE_TYPE_SMART_MEDIA = 0x07,
LIBHAL_DRIVE_TYPE_SD_MMC = 0x08,
LIBHAL_DRIVE_TYPE_CAMERA = 0x09,
- LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER = 0x0a/*,
+ LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER = 0x0a,
LIBHAL_DRIVE_TYPE_ZIP = 0x0b,
- LIBHAL_DRIVE_TYPE_JAZ = 0x0c*/
+ LIBHAL_DRIVE_TYPE_JAZ = 0x0c,
+ LIBHAL_DRIVE_TYPE_FLASHKEY = 0x0d
} LibHalDriveType;
typedef enum {
diff --git a/libhal/libhal.c b/libhal/libhal.c
index 13cea89a..1e3aac42 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -648,7 +648,7 @@ filter_func (DBusConnection * connection,
object_path = dbus_message_get_path (message);
- /*printf("*** in filter_func, object_path=%s\n", object_path); */
+ /*printf("*** in filter_func, object_path=%s\n", object_path);*/
if (dbus_message_is_signal (message, "org.freedesktop.Hal.Manager",
"DeviceAdded")) {
@@ -659,13 +659,9 @@ filter_func (DBusConnection * connection,
if (ctx->device_added != NULL) {
ctx->device_added (ctx, udi);
}
- dbus_free (udi);
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- } else
- if (dbus_message_is_signal
- (message, "org.freedesktop.Hal.Manager",
- "DeviceRemoved")) {
+ } else if (dbus_message_is_signal (message, "org.freedesktop.Hal.Manager", "DeviceRemoved")) {
char *udi;
if (dbus_message_get_args (message, &error,
DBUS_TYPE_STRING, &udi,
@@ -673,13 +669,9 @@ filter_func (DBusConnection * connection,
if (ctx->device_removed != NULL) {
ctx->device_removed (ctx, udi);
}
- dbus_free (udi);
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- } else
- if (dbus_message_is_signal
- (message, "org.freedesktop.Hal.Manager",
- "NewCapability")) {
+ } else if (dbus_message_is_signal (message, "org.freedesktop.Hal.Manager","NewCapability")) {
char *udi;
char *capability;
if (dbus_message_get_args (message, &error,
@@ -687,36 +679,25 @@ filter_func (DBusConnection * connection,
DBUS_TYPE_STRING, &capability,
DBUS_TYPE_INVALID)) {
if (ctx->device_new_capability != NULL) {
- ctx->device_new_capability (ctx,
- udi,
- capability);
+ ctx->device_new_capability (ctx, udi, capability);
}
- dbus_free (udi);
- dbus_free (capability);
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- } else
- if (dbus_message_is_signal
- (message, "org.freedesktop.Hal.Device", "Condition")) {
- if (ctx->device_condition != NULL) {
- DBusMessageIter iter;
- char *condition_name;
-
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_get_basic (&iter, &condition_name);
-
- ctx->device_condition (ctx,
- object_path,
- condition_name,
- message);
-
- dbus_free (condition_name);
+ } else if (dbus_message_is_signal (message, "org.freedesktop.Hal.Device", "Condition")) {
+ char *udi;
+ char *condition_name;
+ char *condition_detail;
+ if (dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &udi,
+ DBUS_TYPE_STRING, &condition_name,
+ DBUS_TYPE_STRING, &condition_detail,
+ DBUS_TYPE_INVALID)) {
+ if (ctx->device_new_capability != NULL) {
+ ctx->device_condition (ctx, udi, condition_name, condition_detail);
+ }
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- } else
- if (dbus_message_is_signal
- (message, "org.freedesktop.Hal.Device",
- "PropertyModified")) {
+ } else if (dbus_message_is_signal (message, "org.freedesktop.Hal.Device", "PropertyModified")) {
if (ctx->device_property_modified != NULL) {
int i;
char *key;
@@ -742,19 +723,19 @@ filter_func (DBusConnection * connection,
dbus_message_iter_get_basic (&iter_struct, &removed);
dbus_message_iter_next (&iter_struct);
dbus_message_iter_get_basic (&iter_struct, &added);
-
+
ctx->device_property_modified (ctx,
object_path,
key, removed,
added);
-
+
dbus_message_iter_next (&iter_array);
}
-
+
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -2550,15 +2531,25 @@ libhal_device_add_capability (LibHalContext *ctx,
* otherwise FALSE
*/
dbus_bool_t
-libhal_device_query_capability (LibHalContext *ctx,
- const char *udi, const char *capability, DBusError *error)
+libhal_device_query_capability (LibHalContext *ctx, const char *udi, const char *capability, DBusError *error)
{
+ char **caps;
+ unsigned int i;
dbus_bool_t ret;
- char *caps;
- caps = libhal_device_get_property_string (ctx, udi, "info.capabilities", error);
- ret = (caps != NULL && strstr (caps, capability) != NULL);
- libhal_free_string (caps);
+ ret = FALSE;
+
+ caps = libhal_device_get_property_strlist (ctx, udi, "info.capabilities", error);
+ if (caps != NULL) {
+ for (i = 0; caps[i] != NULL; i++) {
+ if (strcmp (caps[i], capability) == 0) {
+ ret = TRUE;
+ break;
+ }
+ }
+ libhal_free_string_array (caps);
+ }
+
return ret;
}
diff --git a/libhal/libhal.h b/libhal/libhal.h
index 3f198688..215242f7 100644
--- a/libhal/libhal.h
+++ b/libhal/libhal.h
@@ -134,7 +134,7 @@ typedef void (*LibHalDevicePropertyModified) (LibHalContext *ctx,
typedef void (*LibHalDeviceCondition) (LibHalContext *ctx,
const char *udi,
const char *condition_name,
- DBusMessage *message);
+ const char *condition_detail);
LibHalContext *libhal_ctx_new (void);