From af3c4d3201aae0bd280efb4e0be70a2f8ec8c4e1 Mon Sep 17 00:00:00 2001 From: Patrick Mansfield Date: Sun, 7 Jul 2002 05:26:35 +0000 Subject: [PATCH] * sierra.c: Output summary with warning if no memory card present. * library.c: Check for memory card before capture or listing. * sierra-desc.c: add extern round() rather than a complete hack. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@4824 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/sierra/ChangeLog | 6 ++++++ camlibs/sierra/library.c | 12 ++++++++++++ camlibs/sierra/sierra-desc.c | 7 +++++-- camlibs/sierra/sierra.c | 10 +++++----- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/camlibs/sierra/ChangeLog b/camlibs/sierra/ChangeLog index 410ab0a55..00f8dac2c 100644 --- a/camlibs/sierra/ChangeLog +++ b/camlibs/sierra/ChangeLog @@ -1,3 +1,9 @@ +2002-07-06 Patrick Mansfield + + * sierra.c: Output summary with warning if no memory card present. + * library.c: Check for memory card before capture or listing. + * sierra-desc.c: add extern round() rather than a complete hack. + 2002-07-05 Lutz Müller Patch by Thomas Reitelbach : diff --git a/camlibs/sierra/library.c b/camlibs/sierra/library.c index e22e14b22..9e6f7d6b8 100644 --- a/camlibs/sierra/library.c +++ b/camlibs/sierra/library.c @@ -133,6 +133,12 @@ int sierra_list_files (Camera *camera, const char *folder, CameraList *list, GPC GP_DEBUG ("Listing files in folder '%s'...", folder); + CHECK (sierra_get_int_register (camera, 51, &i, context)); + if (i == 1) { + gp_context_error (context, _("No memory card present")); + return (GP_ERROR_NOT_SUPPORTED); + } + /* We need to change to the folder first */ CHECK (sierra_change_folder (camera, folder, context)); @@ -1279,6 +1285,12 @@ sierra_capture (Camera *camera, CameraCaptureType type, if (type != GP_CAPTURE_IMAGE) return (GP_ERROR_NOT_SUPPORTED); + CHECK (sierra_get_int_register (camera, 51, &n, context)); + if (n == 1) { + gp_context_error (context, _("No memory card present")); + return (GP_ERROR_NOT_SUPPORTED); + } + /* Send to the camera the capture request and wait for the completion */ CHECK (sierra_action (camera, SIERRA_ACTION_CAPTURE, context)); diff --git a/camlibs/sierra/sierra-desc.c b/camlibs/sierra/sierra-desc.c index 1e8666b27..093069317 100644 --- a/camlibs/sierra/sierra-desc.c +++ b/camlibs/sierra/sierra-desc.c @@ -23,8 +23,6 @@ #include #include -/* XXX hack hack how do we define this via gcc? For use with round() */ -#define __USE_ISOC99 1 #include #include @@ -55,6 +53,11 @@ #define GP_MODULE "sierra" +/* + * For some reason, round() does not get a prototype from math.h. + */ +extern double round(double x); + static int camera_cam_desc_get_value (ValueNameType *val_name_p, CameraWidgetType widge, u_int32_t reg_len, void *buff, int mask, diff --git a/camlibs/sierra/sierra.c b/camlibs/sierra/sierra.c index b9e33b90f..bd0d077a8 100644 --- a/camlibs/sierra/sierra.c +++ b/camlibs/sierra/sierra.c @@ -1766,17 +1766,17 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context) CHECK (camera_start (camera, context)); + strcpy(buf, ""); + /* At least on PhotoPC 3000z, if no card is present near all retrieved info are either unreadable or invalid... */ if (sierra_get_int_register(camera, 51, &value, context) >= 0) if (value == 1) { - strcpy (buf, _("NO MEMORY CARD PRESENT\n")); + strcpy (buf, _("Note: no memory card present, some" + " values may be invalid\n")); strcpy (summary->text, buf); - return (camera_stop (camera, context)); } - strcpy(buf, ""); - /* Get all the string-related info */ ret = sierra_get_string_register (camera, 27, 0, NULL, t, &value, context); if (ret >= 0) @@ -1810,7 +1810,7 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context) /* Get date */ if (sierra_get_int_register (camera, 2, &value, context) >= 0) - sprintf (buf, _("%sDate: %s\n"), buf, + sprintf (buf, _("%sDate: %s"), buf, ctime ((time_t*) &value)); strcpy (summary->text, buf);