From: <pa...@us...> - 2003-02-02 20:13:05
|
Update of /cvsroot/gphoto/libgphoto2/camlibs/sierra In directory sc8-pr-cvs1:/tmp/cvs-serv16687 Modified Files: ChangeLog library.c library.h sierra.c Log Message: * library.c, library.h: added sierra_get_size * sierra.c: call sierra_get_size to get sizes via register 12 or 13, only call sierra_get_pic_info to get sizes for audio files. Treat 0 length file size as unsupported. Index: ChangeLog =================================================================== RCS file: /cvsroot/gphoto/libgphoto2/camlibs/sierra/ChangeLog,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- ChangeLog 30 Jan 2003 21:02:35 -0000 1.84 +++ ChangeLog 2 Feb 2003 20:12:57 -0000 1.85 @@ -1,3 +1,14 @@ +2003-02-03 Patrick Mansfield <pa...@us...> + + Idea based on a patch in a bug report from Valentin Rusu + <sou...@va...>, this should also fix other cameras + that do not return valid data for register 47. + + * library.c, library.h: added sierra_get_size + * sierra.c: call sierra_get_size to get sizes via register 12 or + 13, only call sierra_get_pic_info to get sizes for audio files. + Treat 0 length file size as unsupported. + 2003-01-30 Lutz Mller <lu...@us...> * sierra.h: SierraCamera is not needed any more. Index: library.c =================================================================== RCS file: /cvsroot/gphoto/libgphoto2/camlibs/sierra/library.c,v retrieving revision 1.113 retrieving revision 1.114 diff -u -d -r1.113 -r1.114 --- library.c 30 Jan 2003 21:02:38 -0000 1.113 +++ library.c 2 Feb 2003 20:12:58 -0000 1.114 @@ -1193,8 +1193,8 @@ int retries, r; static int in_function = 0; - GP_DEBUG ("sierra_get_string_register: reg %i, file number %i," - " ext protocol %x", reg, fnumber, + GP_DEBUG ("sierra_get_string_register: reg %i, file number %i, " + " total %d, ext protocol %x", reg, fnumber, total, camera->pl->use_extended_protocol); if (in_function != 0) { @@ -1468,5 +1468,13 @@ gp_context_error (context, _("Not implemented!")); return GP_ERROR; + return GP_OK; +} + +int sierra_get_size (Camera *camera, int reg, unsigned int n, int *value, + GPContext *context) +{ + CHECK (sierra_set_int_register (camera, 4, n, context)); + CHECK (sierra_get_int_register (camera, reg, value, context)); return GP_OK; } Index: library.h =================================================================== RCS file: /cvsroot/gphoto/libgphoto2/camlibs/sierra/library.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- library.h 15 Dec 2002 11:43:29 -0000 1.24 +++ library.h 2 Feb 2003 20:12:59 -0000 1.25 @@ -134,6 +134,8 @@ GPContext *context); int sierra_change_folder (Camera *camera, const char *folder, GPContext *context); +int sierra_get_size (Camera *camera, int reg, unsigned int n, + int *value, GPContext *context); int camera_start (Camera *camera, GPContext *context); int camera_stop (Camera *camera, GPContext *context); Index: sierra.c =================================================================== RCS file: /cvsroot/gphoto/libgphoto2/camlibs/sierra/sierra.c,v retrieving revision 1.159 retrieving revision 1.160 diff -u -d -r1.159 -r1.160 --- sierra.c 30 Jan 2003 21:02:36 -0000 1.159 +++ sierra.c 2 Feb 2003 20:12:59 -0000 1.160 @@ -444,7 +444,8 @@ int jpeg_size; const char *data, *mime_type; long int size; - SierraPicInfo info; + int download_size; + SierraPicInfo info; /* only for audio */ /* * Get the file number from the CameraFileSystem. @@ -475,16 +476,44 @@ /* * We need the file size in order to display progress information. - * Don't make this fatal, as some cameras (at least the - * "Agfa ePhoto307") don't seem to support this command (or better, - * return nothing). + * Since we _can_ run without progress information, make failures + * here not prevent the download - but the failure should still + * show up in any logs. + * + * Some cameras do not return anything useful for register 47, so + * only use it for audio and hope that always works - so if a + * camera can download audio, we are assuming it returns data for + * register 47. If that assumption is ever wrong, try using + * register 43 to get the audio size. */ - memset (&info, 0, sizeof (SierraPicInfo)); - sierra_get_pic_info (camera, n, &info, context); + download_size = 0; + switch (type) { + case GP_FILE_TYPE_PREVIEW: + case GP_FILE_TYPE_EXIF: + sierra_get_size(camera, 13, n, &download_size, context); + break; + case GP_FILE_TYPE_NORMAL: + sierra_get_size(camera, 12, n, &download_size, context); + break; + case GP_FILE_TYPE_AUDIO: + memset (&info, 0, sizeof (SierraPicInfo)); + sierra_get_pic_info (camera, n, &info, context); + download_size = info.size_audio; + break; + default: + return (GP_ERROR_NOT_SUPPORTED); + } /* Get the file */ CHECK_STOP (camera, sierra_get_string_register (camera, regd, n, - file, NULL, &(info.size_file), context)); + file, NULL, &download_size, context)); + if (download_size == 0) { + /* + * Assume a failure. At least coolpix 880 returns no error + * and no data when asked to download audio. + */ + return (GP_ERROR_NOT_SUPPORTED); + } CHECK (camera_stop (camera, context)); /* Now get the data and do some post-processing */ |