[gvfs/mtp-backend: 24/64] MTP: Add support for using Representative Sample of Thumbnail fails.
- From: Philip Langdale <philipl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/mtp-backend: 24/64] MTP: Add support for using Representative Sample of Thumbnail fails.
- Date: Sat, 12 Jan 2013 04:36:09 +0000 (UTC)
commit 634086fe0ce6336440f2b4ca60b3c523eb477d4b
Author: Philip Langdale <philipl overt org>
Date: Sun Aug 19 14:13:25 2012 -0700
MTP: Add support for using Representative Sample of Thumbnail fails.
I have no idea if this really works, as I don't have a device
that uses it.
daemon/gvfsbackendmtp.c | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index 9e21084..f43c948 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -1135,7 +1135,7 @@ do_open_icon_for_read (GVfsBackend *backend,
int ret = LIBMTP_Get_Thumbnail(G_VFS_BACKEND_MTP(backend)->device, id,
&data, &size);
if (ret == 0) {
- g_print("File %u has sampledata: %u\n", id, size);
+ g_print("File %u has thumbnail: %u\n", id, size);
GByteArray *bytes = g_byte_array_sized_new(size);
g_byte_array_append(bytes, data, size);
free(data);
@@ -1143,12 +1143,24 @@ do_open_icon_for_read (GVfsBackend *backend,
g_vfs_job_open_for_read_set_handle (G_VFS_JOB_OPEN_FOR_READ(job), bytes);
g_vfs_job_succeeded (G_VFS_JOB (job));
} else {
- g_print("File %u has no thumbnail:\n", id);
- g_vfs_job_failed (G_VFS_JOB (job),
- G_IO_ERROR,
- G_IO_ERROR_NOT_FOUND,
- _("No thumbnail for entity '%s'"),
- icon_id);
+ LIBMTP_filesampledata_t *sample_data = LIBMTP_new_filesampledata_t();
+ ret = LIBMTP_Get_Representative_Sample(G_VFS_BACKEND_MTP(backend)->device, id, sample_data);
+ if (ret == 0) {
+ g_print("File %u has sampledata: %u\n", id, size);
+ GByteArray *bytes = g_byte_array_sized_new(sample_data->size);
+ g_byte_array_append(bytes, sample_data->data, sample_data->size);
+ LIBMTP_destroy_filesampledata_t(sample_data);
+ g_vfs_job_open_for_read_set_can_seek (G_VFS_JOB_OPEN_FOR_READ(job), FALSE);
+ g_vfs_job_open_for_read_set_handle (G_VFS_JOB_OPEN_FOR_READ(job), bytes);
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+ } else {
+ g_print("File %u has no thumbnail:\n", id);
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_FOUND,
+ _("No thumbnail for entity '%s'"),
+ icon_id);
+ }
}
} else {
g_vfs_job_failed (G_VFS_JOB (job),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]