summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2017-03-17 09:35:34 +0100
committerOndrej Holy <oholy@redhat.com>2017-03-23 11:24:16 +0100
commitf2f39758482a71eff4da399f47ae702ef1fa2857 (patch)
tree02975ba3e97bb296d3bc5971ed366228e4e4d3a2
parentfc0b1aeb035b0552918cc5f3ad1beb30f3062ec1 (diff)
downloadgvfs-f2f39758482a71eff4da399f47ae702ef1fa2857.tar.gz
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.
-rw-r--r--common/gvfsgphoto2utils.c12
-rw-r--r--common/gvfsgphoto2utils.h1
-rw-r--r--daemon/gvfsbackendgphoto2.c9
3 files changed, 15 insertions, 7 deletions
diff --git a/common/gvfsgphoto2utils.c b/common/gvfsgphoto2utils.c
index 8608e515..3b882e7c 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 d8f9d405..ab0ff1cc 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 d4d46a55..240b3266 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