From 9d52a2d47f2e23525844ea362299da22ffcc2e3e Mon Sep 17 00:00:00 2001 From: Lutz Mueller Date: Tue, 4 Dec 2001 20:24:20 +0000 Subject: [PATCH] =?UTF-8?q?2001-12-04=20=20Lutz=20M=EF=BF=BDller=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * libgphoto2: Support for GP_FILE_TYPE_EXIF. Not that there is not support for it in the frontends (yet). git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@3380 67ed7778-7388-44ab-90cf-0a291f65f57c --- ChangeLog | 5 ++++ camlibs/konica/library.c | 44 +++++++++++++++++++++++++++++++----- libgphoto2/gphoto2-file.h | 3 ++- libgphoto2/gphoto2-filesys.c | 20 ++++++++++++++++ 4 files changed, 65 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4120fe2cc..0bcd9527c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-12-04 Lutz Müller + + * libgphoto2: Support for GP_FILE_TYPE_EXIF. Not that there is not + support for it in the frontends (yet). + 2001-12-04 Lutz Müller * libgphoto2/gphoto2-camera.c: Don't exit the camera if it is diff --git a/camlibs/konica/library.c b/camlibs/konica/library.c index 4fdcc1a58..5b6effe59 100644 --- a/camlibs/konica/library.c +++ b/camlibs/konica/library.c @@ -115,7 +115,8 @@ static int localization_file_read (Camera* camera, const char* file_name, unsigned char** data, long int* data_size); static int -get_info (Camera *camera, unsigned int n, CameraFileInfo *info) +get_info (Camera *camera, unsigned int n, CameraFileInfo *info, + CameraFile *file) { unsigned long image_id; unsigned int buffer_size, exif_size; @@ -126,7 +127,6 @@ get_info (Camera *camera, unsigned int n, CameraFileInfo *info) CHECK (camera, k_get_image_information (camera->port, camera->pl->image_id_long, n, &image_id, &exif_size, &protected, &buffer, &buffer_size)); - free (buffer); info->audio.fields = GP_FILE_INFO_NONE; @@ -143,6 +143,19 @@ get_info (Camera *camera, unsigned int n, CameraFileInfo *info) snprintf (info->file.name, sizeof (info->file.name), "%06i.jpeg", (int) image_id); + if (file) { + gp_file_set_type (file, GP_FILE_TYPE_EXIF); + gp_file_set_name (file, info->file.name); + + /* Make a JPEG file out of it (for parser) */ + gp_file_append (file, "\xff\xd8", 2); + gp_file_append (file, buffer, buffer_size); + gp_file_append (file, "\x01", 1); + gp_file_append (file, "\xff\xda", 2); + gp_file_append (file, "\x00\x02", 2); + } + free (buffer); + return (GP_OK); } @@ -150,10 +163,12 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data) { + CameraFile *file; CameraFileInfo info; KStatus status; unsigned int i; Camera *camera = data; + int result; /* * We can't get the filename from the camera. @@ -164,7 +179,12 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, for (i = 0; i < status.pictures; i++) { /* Get information */ - CHECK (camera, get_info (camera, i + 1, &info)); + gp_file_new (&file); + result = get_info (camera, i + 1, &info, file); + if (result < 0) { + gp_file_unref (file); + return (result); + } /* * Append directly to the filesystem instead of to the list, @@ -172,6 +192,8 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, */ gp_filesystem_append (camera->fs, folder, info.file.name); gp_filesystem_set_info_noop (camera->fs, folder, info); + gp_filesystem_set_file_noop (camera->fs, folder, file); + gp_file_unref (file); } return (GP_OK); @@ -352,13 +374,23 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, void *data) { Camera *camera = data; - int n; + CameraFile *file; + int n, result; /* We need image numbers starting with 1 */ - CHECK (camera, n = gp_filesystem_number (camera->fs, folder, filename)); + n = gp_filesystem_number (camera->fs, folder, filename); + if (n < 0) + return (n); n++; - CHECK (camera, get_info (camera, n, info)); + gp_file_new (&file); + result = get_info (camera, n, info, file); + if (result < 0) { + gp_file_unref (file); + return (result); + } + gp_filesystem_set_file_noop (fs, folder, file); + gp_file_unref (file); return (GP_OK); } diff --git a/libgphoto2/gphoto2-file.h b/libgphoto2/gphoto2-file.h index 02fd7784d..c02d35fb7 100644 --- a/libgphoto2/gphoto2-file.h +++ b/libgphoto2/gphoto2-file.h @@ -38,7 +38,8 @@ typedef enum { GP_FILE_TYPE_PREVIEW, GP_FILE_TYPE_NORMAL, GP_FILE_TYPE_RAW, - GP_FILE_TYPE_AUDIO + GP_FILE_TYPE_AUDIO, + GP_FILE_TYPE_EXIF } CameraFileType; /* Internals are private */ diff --git a/libgphoto2/gphoto2-filesys.c b/libgphoto2/gphoto2-filesys.c index cb3f99701..6a49c2104 100644 --- a/libgphoto2/gphoto2-filesys.c +++ b/libgphoto2/gphoto2-filesys.c @@ -58,6 +58,7 @@ typedef struct { CameraFile *normal; CameraFile *raw; CameraFile *audio; + CameraFile *exif; } CameraFilesystemFile; typedef struct { @@ -129,6 +130,10 @@ delete_all_files (CameraFilesystem *fs, int x) gp_file_unref (fs->folder[x].file[y].audio); fs->folder[x].file[y].audio = NULL; } + if (fs->folder[x].file[y].exif) { + gp_file_unref (fs->folder[x].file[y].exif); + fs->folder[x].file[y].exif = NULL; + } } free (fs->folder[x].file); @@ -533,6 +538,10 @@ delete_file (CameraFilesystem *fs, int x, int y) gp_file_unref (fs->folder[x].file[y].audio); fs->folder[x].file[y].audio = NULL; } + if (fs->folder[x].file[y].exif) { + gp_file_unref (fs->folder[x].file[y].exif); + fs->folder[x].file[y].exif = NULL; + } /* Move all files behind one position up */ if (y < fs->folder[x].count - 1) @@ -1244,6 +1253,11 @@ gp_filesystem_get_file (CameraFilesystem *fs, const char *folder, return (gp_file_copy (file, fs->folder[x].file[y].audio)); break; + case GP_FILE_TYPE_EXIF: + if (fs->folder[x].file[y].exif) + return (gp_file_copy (file, + fs->folder[x].file[y].exif)); + break; default: gp_log (GP_LOG_ERROR, "gphoto2-filesystem", _("Unknown file type %i"), type); @@ -1396,6 +1410,12 @@ gp_filesystem_set_file_noop (CameraFilesystem *fs, const char *folder, fs->folder[x].file[y].audio = file; gp_file_ref (file); break; + case GP_FILE_TYPE_EXIF: + if (fs->folder[x].file[y].exif) + gp_file_unref (fs->folder[x].file[y].exif); + fs->folder[x].file[y].exif = file; + gp_file_ref (file); + break; default: gp_log (GP_LOG_ERROR, "gphoto2-filesystem", _("Unknown file type %i"), type);