diff options
author | Ondrej Holy <oholy@redhat.com> | 2017-03-17 09:35:34 +0100 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2017-03-28 15:30:40 +0200 |
commit | b8a233345d4781b61b78cf768d76be84f4d217ba (patch) | |
tree | 14bde4575769df40d3bd289580db88479f6bbe6f | |
parent | d26dab60267704b10fae318e0a231f82d1554ebb (diff) | |
download | gvfs-b8a233345d4781b61b78cf768d76be84f4d217ba.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.c | 12 | ||||
-rw-r--r-- | common/gvfsgphoto2utils.h | 1 | ||||
-rw-r--r-- | daemon/gvfsbackendgphoto2.c | 9 |
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 07c42580..23f6a5ff 100644 --- a/daemon/gvfsbackendgphoto2.c +++ b/daemon/gvfsbackendgphoto2.c @@ -743,9 +743,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:")) @@ -772,10 +769,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 |