hal/libhal-storage libhal-storage.c, 1.13, 1.14 libhal-storage.h,
1.8, 1.9
David Zeuthen
david at freedesktop.org
Sat Feb 26 14:31:44 PST 2005
Update of /cvs/hal/hal/libhal-storage
In directory gabe:/tmp/cvs-serv9653/libhal-storage
Modified Files:
libhal-storage.c libhal-storage.h
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: libhal-storage.c
===================================================================
RCS file: /cvs/hal/hal/libhal-storage/libhal-storage.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- libhal-storage.c 16 Feb 2005 21:25:35 -0000 1.13
+++ libhal-storage.c 26 Feb 2005 22:31:42 -0000 1.14
@@ -654,6 +654,8 @@
LibHalContext *hal_ctx;
+ char **capabilities;
+
char mount_options[MOUNT_OPTIONS_SIZE];
};
@@ -729,6 +731,7 @@
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 @@
}
+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 @@
#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 @@
LibHalPropertySet *properties;
LibHalPropertySetIterator it;
DBusError error;
+ unsigned int i;
drive = NULL;
properties = NULL;
@@ -848,6 +875,8 @@
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 @@
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);
}
}
Index: libhal-storage.h
===================================================================
RCS file: /cvs/hal/hal/libhal-storage/libhal-storage.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- libhal-storage.h 16 Feb 2005 18:45:19 -0000 1.8
+++ libhal-storage.h 26 Feb 2005 22:31:42 -0000 1.9
@@ -78,8 +78,9 @@
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 @@
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 @@
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 {
More information about the hal-commit
mailing list