[gvfs] gphoto2: Fix x-content-types setup



commit f2f39758482a71eff4da399f47ae702ef1fa2857
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Mar 17 09:35:34 2017 +0100

    gphoto2: Fix x-content-types setup
    
    Commit 60f96c8 broke x-content-types setup, because is_media_player is
    always FALSE. Let's introduce g_vfs_backend_set_x_content_types helper
    and set x-content-types properly.
    
    This issue was revealed by coverity scan.

 common/gvfsgphoto2utils.c   |   12 ++++++++++++
 common/gvfsgphoto2utils.h   |    1 +
 daemon/gvfsbackendgphoto2.c |    9 ++-------
 3 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/common/gvfsgphoto2utils.c b/common/gvfsgphoto2utils.c
index 8608e51..3b882e7 100644
--- a/common/gvfsgphoto2utils.c
+++ b/common/gvfsgphoto2utils.c
@@ -140,3 +140,15 @@ g_vfs_get_volume_symbolic_icon (GUdevDevice *device)
   else
     return g_strdup ("camera-photo-symbolic");
 }
+
+char **
+g_vfs_get_x_content_types (GUdevDevice *device)
+{
+  char *camera_x_content_types[] = {"x-content/image-dcf", NULL};
+  char *media_player_x_content_types[] = {"x-content/audio-player", NULL};
+
+  if (g_udev_device_has_property (device, "ID_MEDIA_PLAYER"))
+    return g_strdupv (media_player_x_content_types);
+  else
+    return g_strdupv (camera_x_content_types);
+}
diff --git a/common/gvfsgphoto2utils.h b/common/gvfsgphoto2utils.h
index d8f9d40..ab0ff1c 100644
--- a/common/gvfsgphoto2utils.h
+++ b/common/gvfsgphoto2utils.h
@@ -26,5 +26,6 @@
 char * g_vfs_get_volume_name (GUdevDevice *device, const char *device_id);
 char * g_vfs_get_volume_icon (GUdevDevice *device);
 char * g_vfs_get_volume_symbolic_icon (GUdevDevice *device);
+char **g_vfs_get_x_content_types (GUdevDevice *device);
 
 #endif
diff --git a/daemon/gvfsbackendgphoto2.c b/daemon/gvfsbackendgphoto2.c
index d4d46a5..240b326 100644
--- a/daemon/gvfsbackendgphoto2.c
+++ b/daemon/gvfsbackendgphoto2.c
@@ -696,9 +696,6 @@ setup_for_device (GVfsBackendGphoto2 *gphoto2_backend)
 {
   gchar *devname;
   char *comma;
-  gboolean is_media_player = FALSE;
-  char *camera_x_content_types[] = {"x-content/image-dcf", NULL};
-  char *media_player_x_content_types[] = {"x-content/audio-player", NULL};
 
   /* turn usb:001,041 string into an udev device name */
   if (!g_str_has_prefix (gphoto2_backend->gphoto2_port, "usb:"))
@@ -725,10 +722,8 @@ setup_for_device (GVfsBackendGphoto2 *gphoto2_backend)
   else
       g_debug ("-> did not find matching udev device\n");
 
-  if (is_media_player)
-      g_vfs_backend_set_x_content_types (G_VFS_BACKEND (gphoto2_backend), media_player_x_content_types);
-  else
-      g_vfs_backend_set_x_content_types (G_VFS_BACKEND (gphoto2_backend), camera_x_content_types);
+  g_vfs_backend_set_x_content_types (G_VFS_BACKEND (gphoto2_backend),
+                                     g_vfs_get_x_content_types (gphoto2_backend->udev_device));
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]