Alexandre Julliard : mountmgr: Add a helper function for parsing UDisks media compatibility.
Alexandre Julliard
julliard at winehq.org
Wed Jun 13 16:08:33 CDT 2012
Module: wine
Branch: master
Commit: 2f86012373b1247235165f8ff16cafda97a97d48
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2f86012373b1247235165f8ff16cafda97a97d48
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Jun 13 17:36:55 2012 +0200
mountmgr: Add a helper function for parsing UDisks media compatibility.
---
dlls/mountmgr.sys/dbus.c | 43 +++++++++++++++++++++++++++----------------
1 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/dlls/mountmgr.sys/dbus.c b/dlls/mountmgr.sys/dbus.c
index 608efd0..3571bf4 100644
--- a/dlls/mountmgr.sys/dbus.c
+++ b/dlls/mountmgr.sys/dbus.c
@@ -140,6 +140,11 @@ static LONG WINAPI assert_fault(EXCEPTION_POINTERS *eptr)
return EXCEPTION_CONTINUE_SEARCH;
}
+static inline int starts_with( const char *str, const char *prefix )
+{
+ return !strncmp( str, prefix, strlen(prefix) );
+}
+
static GUID *parse_uuid( GUID *guid, const char *str )
{
/* standard uuid format */
@@ -199,6 +204,27 @@ static const char *udisks_next_dict_entry( DBusMessageIter *iter, DBusMessageIte
return name;
}
+static enum device_type udisks_parse_media_compatibility( DBusMessageIter *iter )
+{
+ DBusMessageIter media;
+ enum device_type drive_type = DEVICE_UNKNOWN;
+
+ p_dbus_message_iter_recurse( iter, &media );
+ while (p_dbus_message_iter_get_arg_type( &media ) == DBUS_TYPE_STRING)
+ {
+ const char *media_type;
+ p_dbus_message_iter_get_basic( &media, &media_type );
+ if (starts_with( media_type, "optical_dvd" ))
+ drive_type = DEVICE_DVD;
+ if (starts_with( media_type, "floppy" ))
+ drive_type = DEVICE_FLOPPY;
+ else if (starts_with( media_type, "optical_" ) && drive_type == DEVICE_UNKNOWN)
+ drive_type = DEVICE_CDROM;
+ p_dbus_message_iter_next( &media );
+ }
+ return drive_type;
+}
+
/* UDisks callback for new device */
static void udisks_new_device( const char *udi )
{
@@ -246,22 +272,7 @@ static void udisks_new_device( const char *udi )
else if (!strcmp( name, "IdType" ))
p_dbus_message_iter_get_basic( &variant, &type );
else if (!strcmp( name, "DriveMediaCompatibility" ))
- {
- DBusMessageIter media;
- p_dbus_message_iter_recurse( &variant, &media );
- while (p_dbus_message_iter_get_arg_type( &media ) == DBUS_TYPE_STRING)
- {
- const char *media_type;
- p_dbus_message_iter_get_basic( &media, &media_type );
- if (!strncmp( media_type, "optical_dvd", 11 ))
- drive_type = DEVICE_DVD;
- if (!strncmp( media_type, "floppy", 6 ))
- drive_type = DEVICE_FLOPPY;
- else if (!strncmp( media_type, "optical_", 8 ) && drive_type == DEVICE_UNKNOWN)
- drive_type = DEVICE_CDROM;
- p_dbus_message_iter_next( &media );
- }
- }
+ drive_type = udisks_parse_media_compatibility( &variant );
else if (!strcmp( name, "DeviceMountPaths" ))
{
DBusMessageIter paths;
More information about the wine-cvs
mailing list