diff options
author | David Zeuthen <david@fubar.dk> | 2005-02-26 22:31:42 +0000 |
---|---|---|
committer | David Zeuthen <david@fubar.dk> | 2005-02-26 22:31:42 +0000 |
commit | daa3bacc8f4f3fbe5aa57c8b173918a32beddfa8 (patch) | |
tree | 707542ec015d27762d9caceda143774fefaf8472 /libhal-storage | |
parent | ff41ef5247205471ecf09addb767cc66817513d8 (diff) | |
download | hal-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
Diffstat (limited to 'libhal-storage')
-rw-r--r-- | libhal-storage/libhal-storage.c | 51 | ||||
-rw-r--r-- | libhal-storage/libhal-storage.h | 15 |
2 files changed, 46 insertions, 20 deletions
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 { |