summaryrefslogtreecommitdiff
path: root/camlibs/canon
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2008-05-16 21:49:48 +0000
committerMarcus Meissner <marcus@jet.franken.de>2008-05-16 21:49:48 +0000
commitb8e4923353667a015cc4713f8369c6e953b33810 (patch)
tree6866b05a7bd2a6824b06a292d5dea6999e1e8c8f /camlibs/canon
parentb1886bb096a798bbc22d91de9bd6fd972ef87c9b (diff)
downloadlibgphoto2-b8e4923353667a015cc4713f8369c6e953b33810.tar.gz
2008-05-16 Moreno Marzolla <moreno.marzolla@pd.infn.it>
* canon.c, library.c: Added beep and zoom configurations. * canon.c, library.c: Enable remote mode once in a session and close it in camera_exit. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@11145 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/canon')
-rw-r--r--camlibs/canon/ChangeLog8
-rw-r--r--camlibs/canon/canon.c30
-rw-r--r--camlibs/canon/library.c206
3 files changed, 158 insertions, 86 deletions
diff --git a/camlibs/canon/ChangeLog b/camlibs/canon/ChangeLog
index 73f16a665..c4ebf2b81 100644
--- a/camlibs/canon/ChangeLog
+++ b/camlibs/canon/ChangeLog
@@ -1,3 +1,11 @@
+2008-05-16 Moreno Marzolla <moreno.marzolla@pd.infn.it>
+
+ * canon.c, library.c: Added beep and zoom configurations.
+
+ * canon.c, library.c: Enable remote mode once in a session and
+ close it in camera_exit.
+
+
2008-05-12 Moreno Marzolla <moreno.marzolla@pd.infn.it>
* canon.c, canon.h, README.canon: Added some more configuration
diff --git a/camlibs/canon/canon.c b/camlibs/canon/canon.c
index a7f12ce4f..30c73b3ee 100644
--- a/camlibs/canon/canon.c
+++ b/camlibs/canon/canon.c
@@ -1167,11 +1167,13 @@ canon_int_capture_preview (Camera *camera, unsigned char **data, unsigned int *l
* Send a sequence of CONTROL_CAMERA commands.
*/
- gp_port_set_timeout (camera->port, 15000);
-
- status = canon_int_start_remote_control (camera, context);
- if ( status < 0 )
- return status;
+ if (!camera->pl->remote_control) {
+ gp_port_set_timeout (camera->port, 15000);
+
+ status = canon_int_start_remote_control (camera, context);
+ if ( status < 0 )
+ return status;
+ }
/*
* Set the captured image transfer mode. We have four options
@@ -1278,11 +1280,6 @@ canon_int_capture_preview (Camera *camera, unsigned char **data, unsigned int *l
}
- /* End release mode */
- status = canon_int_end_remote_control (camera, context);
- if ( status < 0 )
- return status;
-
break;
case GP_PORT_SERIAL:
return GP_ERROR_NOT_SUPPORTED;
@@ -1510,9 +1507,11 @@ canon_int_capture_image (Camera *camera, CameraFilePath *path,
gp_port_set_timeout (camera->port, 15000);
- status = canon_int_start_remote_control (camera, context);
- if ( status < 0 )
- return status;
+ if (!camera->pl->remote_control) {
+ status = canon_int_start_remote_control (camera, context);
+ if ( status < 0 )
+ return status;
+ }
/*
* Set the captured image transfer mode. We have four options
@@ -1620,11 +1619,6 @@ canon_int_capture_image (Camera *camera, CameraFilePath *path,
}
- /* End release mode */
- status = canon_int_end_remote_control (camera, context);
- if ( status < 0 )
- return status;
-
/* Now list all directories on the camera; this has
presumably added an image file. Find the difference
and decode to return real path and file names. */
diff --git a/camlibs/canon/library.c b/camlibs/canon/library.c
index 7ebdf70bc..25a5a05b5 100644
--- a/camlibs/canon/library.c
+++ b/camlibs/canon/library.c
@@ -481,8 +481,19 @@ canon_int_switch_camera_off (Camera *camera, GPContext *context)
static int
camera_exit (Camera *camera, GPContext *context)
{
- if (camera->port->type == GP_PORT_USB)
+ int res = 0;
+
+ if (camera->port->type == GP_PORT_USB)
canon_usb_unlock_keys (camera, context);
+
+ /* Turn off remote control if enabled (remote control only
+ * applies to USB cameras, but in case of serial connection
+ * remote_control should never be seen set here) */
+ if (camera->pl->remote_control) {
+ res = canon_int_end_remote_control (camera, context);
+ if (res != GP_OK)
+ return -1;
+ }
if (camera->pl) {
canon_int_switch_camera_off (camera, context);
@@ -1809,7 +1820,7 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
i++;
}
- /* Set an unknown shutter value if the
+ /* Set an unknown beep value if the
* camera is set to something weird */
if (menuval == -1) {
gp_widget_add_choice (t, _("Unknown"));
@@ -1885,12 +1896,6 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
gp_widget_append (section, t);
#endif /* CANON_EXPERIMENTAL_UPLOAD */
- if (camera->pl->remote_control) {
- res = canon_int_end_remote_control (camera, context);
- if (res != GP_OK)
- return GP_ERROR;
- };
-
return GP_OK;
}
@@ -1902,7 +1907,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
char *wvalue;
int i, val;
int res;
- unsigned char iso, shutter_speed, aperture, focus_mode;
+ unsigned char iso, shutter_speed, aperture, focus_mode, flash_mode, beep, zoom;
char str[16];
GP_DEBUG ("camera_set_config()");
@@ -1939,6 +1944,13 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
}
+ /* Enable remote control, if not already enabled */
+ if (!camera->pl->remote_control) {
+ res = canon_int_start_remote_control (camera, context);
+ if (res != GP_OK)
+ return -1;
+ }
+
gp_widget_get_child_by_label (window, _("ISO speed"), &w);
if (gp_widget_changed (w)) {
gp_widget_get_value (w, &wvalue);
@@ -1946,12 +1958,6 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_context_status (context, _("Camera unavailable"));
} else {
- if (!camera->pl->remote_control) {
- res = canon_int_start_remote_control (camera, context);
- if (res != GP_OK)
- return -1;
- }
-
/* Map the menu option setting to the camera binary value */
i = 0;
while (isoStateArray[i].label) {
@@ -1970,12 +1976,6 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
else
gp_context_status (context, _("Could not change ISO speed"));
}
-
- res = canon_int_end_remote_control (camera, context);
- if (res != GP_OK)
- return GP_ERROR;
- camera->pl->remote_control = 0;
-
}
}
@@ -1986,12 +1986,6 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_context_status (context, _("Camera unavailable"));
} else {
- if (!camera->pl->remote_control) {
- res = canon_int_start_remote_control (camera, context);
- if (res != GP_OK)
- return -1;
- }
-
/* Map the menu option setting to the camera binary value */
i = 0;
while (shutterSpeedStateArray[i].label) {
@@ -2010,12 +2004,6 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
else
gp_context_status (context, _("Could not change shutter speed"));
}
-
- res = canon_int_end_remote_control (camera, context);
- if (res != GP_OK)
- return GP_ERROR;
- camera->pl->remote_control = 0;
-
}
}
@@ -2026,12 +2014,6 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_context_status (context, _("Camera unavailable"));
} else {
- if (!camera->pl->remote_control) {
- res = canon_int_start_remote_control (camera, context);
- if (res != GP_OK)
- return -1;
- }
-
/* Map the menu option setting to the camera binary value */
i = 0;
while (apertureStateArray[i].label) {
@@ -2050,12 +2032,6 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
else
gp_context_status (context, _("Could not change aperture"));
}
-
- res = canon_int_end_remote_control (camera, context);
- if (res != GP_OK)
- return GP_ERROR;
- camera->pl->remote_control = 0;
-
}
}
@@ -2066,12 +2042,6 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_context_status (context, _("Camera unavailable"));
} else {
- if (!camera->pl->remote_control) {
- res = canon_int_start_remote_control (camera, context);
- if (res != GP_OK)
- return -1;
- }
-
/* Map the menu option setting to the camera binary value */
i = 0;
while (resolutionStateArray[i].label) {
@@ -2090,12 +2060,6 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
else
gp_context_status (context, _("Could not change resolution"));
}
-
- res = canon_int_end_remote_control (camera, context);
- if (res != GP_OK)
- return GP_ERROR;
- camera->pl->remote_control = 0;
-
}
}
@@ -2106,12 +2070,6 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_context_status (context, _("Camera unavailable"));
} else {
- if (!camera->pl->remote_control) {
- res = canon_int_start_remote_control (camera, context);
- if (res != GP_OK)
- return -1;
- }
-
/* Map the menu option setting to the camera binary value */
i = 0;
while (focusModeStateArray[i].label) {
@@ -2130,15 +2088,127 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
else
gp_context_status (context, _("Could not change focus mode"));
}
+ }
+ }
- res = canon_int_end_remote_control (camera, context);
- if (res != GP_OK)
- return GP_ERROR;
- camera->pl->remote_control = 0;
-
+ /* Beep */
+ gp_widget_get_child_by_label (window, _("Beep"), &w);
+ if (gp_widget_changed (w)) {
+ gp_widget_get_value (w, &wvalue);
+ if (!check_readiness (camera, context)) {
+ gp_context_status (context, _("Camera unavailable"));
+ } else {
+
+ /* Map the menu option setting to the camera binary value */
+ i = 0;
+ while (beepModeStateArray[i].label) {
+ if (strcmp (_(beepModeStateArray[i].label), wvalue) == 0) {
+ beep = beepModeStateArray[i].value;
+ break;
+ }
+ i++;
+ }
+
+ if (!beepModeStateArray[i].label) {
+ gp_context_status (context, _("Invalid beep mode setting"));
+ } else {
+ if (canon_int_set_beep (camera, beep, context) == GP_OK)
+ gp_context_status (context, _("Beep mode changed"));
+ else
+ gp_context_status (context, _("Could not change beep mode"));
+ }
}
}
+
+ /* Zoom */
+ gp_widget_get_child_by_label (window, _("Zoom"), &w);
+ if (gp_widget_changed (w)) {
+ gp_widget_get_value (w, &wvalue);
+ if (!check_readiness (camera, context)) {
+ gp_context_status (context, _("Camera unavailable"));
+ } else {
+
+ /* Map the menu option setting to the camera binary value */
+ i = 0;
+ while (zoomLevelStateArray[i].label) {
+ if (strcmp (_(zoomLevelStateArray[i].label), wvalue) == 0) {
+ zoom = zoomLevelStateArray[i].value;
+ break;
+ }
+ i++;
+ }
+
+ if (!zoomLevelStateArray[i].label) {
+ gp_context_status (context, _("Invalid zoom level"));
+ } else {
+ if (canon_int_set_zoom (camera, zoom, context) == GP_OK)
+ gp_context_status (context, _("Zoom level changed"));
+ else
+ gp_context_status (context, _("Could not change zoom level"));
+ }
+ }
+ }
+
+ /* Aperture */
+ gp_widget_get_child_by_label (window, _("Aperture"), &w);
+ if (gp_widget_changed (w)) {
+ gp_widget_get_value (w, &wvalue);
+ if (!check_readiness (camera, context)) {
+ gp_context_status (context, _("Camera unavailable"));
+ } else {
+
+ /* Map the menu option setting to the camera binary value */
+ i = 0;
+ while (apertureStateArray[i].label) {
+ if (strcmp (_(apertureStateArray[i].label), wvalue) == 0) {
+ aperture = apertureStateArray[i].value;
+ break;
+ }
+ i++;
+ }
+
+ if (!apertureStateArray[i].label) {
+ gp_context_status (context, _("Invalid aperture setting"));
+ } else {
+ if (canon_int_set_aperture (camera, aperture, context) == GP_OK)
+ gp_context_status (context, _("Aperture changed"));
+ else
+ gp_context_status (context, _("Could not change aperture"));
+ }
+ }
+ }
+
+ /* Flash mode */
+ gp_widget_get_child_by_label (window, _("Flash mode"), &w);
+ if (gp_widget_changed (w)) {
+ gp_widget_get_value (w, &wvalue);
+ if (!check_readiness (camera, context)) {
+ gp_context_status (context, _("Camera unavailable"));
+ } else {
+
+ /* Map the menu option setting to the camera binary value */
+ i = 0;
+ while (flashModeStateArray[i].label) {
+ if (strcmp (_(flashModeStateArray[i].label), wvalue) == 0) {
+ flash_mode = flashModeStateArray[i].value;
+ break;
+ }
+ i++;
+ }
+
+ if (!flashModeStateArray[i].label) {
+ gp_context_status (context, _("Invalid flash mode setting"));
+ } else {
+ if (canon_int_set_flash (camera, flash_mode, context) == GP_OK)
+ gp_context_status (context, _("Flash mode changed"));
+ else
+ gp_context_status (context, _("Could not change flash mode"));
+ }
+ }
+ }
+
+
gp_widget_get_child_by_label (window, _("Set camera date to PC date"), &w);
if (gp_widget_changed (w)) {
gp_widget_get_value (w, &wvalue);