diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2017-04-15 17:22:26 +0200 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2017-04-15 17:22:26 +0200 |
commit | 32c5ca6fe8709f83e41fa1a7cc5471be193277b4 (patch) | |
tree | e4184722715bce5f36dd05ac1a2af58fb3bbf7dd | |
parent | d8262b7ed917a4d41446a40c145f967a430f1a95 (diff) | |
download | libgphoto2-32c5ca6fe8709f83e41fa1a7cc5471be193277b4.tar.gz |
handle capturetarget not existing for EOS gracefully
-rw-r--r-- | camlibs/ptp2/config.c | 105 |
1 files changed, 55 insertions, 50 deletions
diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index 9f49a73c4..c812d1911 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -69,6 +69,57 @@ #define SET_CONTEXT(camera, ctx) ((PTPData *) camera->pl->params.data)->context = ctx +int +have_prop(Camera *camera, uint16_t vendor, uint16_t prop) { + unsigned int i; + + /* prop 0 matches */ + if (!prop && (camera->pl->params.deviceinfo.VendorExtensionID==vendor)) + return 1; + + if ( ((prop & 0x7000) == 0x5000) || + (NIKON_1(&camera->pl->params) && ((prop & 0xf000) == 0xf000)) + ) { /* properties */ + for (i=0; i<camera->pl->params.deviceinfo.DevicePropertiesSupported_len; i++) { + if (prop != camera->pl->params.deviceinfo.DevicePropertiesSupported[i]) + continue; + if ((prop & 0xf000) == 0x5000) { /* generic property */ + if (!vendor || (camera->pl->params.deviceinfo.VendorExtensionID==vendor)) + return 1; + } + if (camera->pl->params.deviceinfo.VendorExtensionID==vendor) + return 1; + } + } + if ((prop & 0x7000) == 0x1000) { /* commands */ + for (i=0; i<camera->pl->params.deviceinfo.OperationsSupported_len; i++) { + if (prop != camera->pl->params.deviceinfo.OperationsSupported[i]) + continue; + if ((prop & 0xf000) == 0x1000) /* generic property */ + return 1; + if (camera->pl->params.deviceinfo.VendorExtensionID==vendor) + return 1; + } + } + return 0; +} + +static int +have_eos_prop(Camera *camera, uint16_t vendor, uint16_t prop) { + unsigned int i; + + /* The special Canon EOS property set gets special treatment. */ + if ((camera->pl->params.deviceinfo.VendorExtensionID != PTP_VENDOR_CANON) || + (vendor != PTP_VENDOR_CANON) + ) + return 0; + for (i=0;i<camera->pl->params.nrofcanon_props;i++) + if (camera->pl->params.canon_props[i].proptype == prop) + return 1; + return 0; +} + + static int camera_prepare_chdk_capture(Camera *camera, GPContext *context) { PTPParams *params = &camera->pl->params; @@ -270,6 +321,10 @@ camera_canon_eos_update_capture_target(Camera *camera, GPContext *context, int v int cardval = -1; memset(&dpd,0,sizeof(dpd)); + if (!have_eos_prop(camera, PTP_VENDOR_CANON, PTP_DPC_CANON_EOS_CaptureDestination) ) { + GP_LOG_D ("No CaptureDestination property?"); + return GP_OK; + } C_PTP (ptp_canon_eos_getdevicepropdesc (params,PTP_DPC_CANON_EOS_CaptureDestination, &dpd)); /* Look for the correct value of the card mode */ @@ -526,56 +581,6 @@ nikon_wait_busy(PTPParams *params, int waitms, int timeout) { return res; } -int -have_prop(Camera *camera, uint16_t vendor, uint16_t prop) { - unsigned int i; - - /* prop 0 matches */ - if (!prop && (camera->pl->params.deviceinfo.VendorExtensionID==vendor)) - return 1; - - if ( ((prop & 0x7000) == 0x5000) || - (NIKON_1(&camera->pl->params) && ((prop & 0xf000) == 0xf000)) - ) { /* properties */ - for (i=0; i<camera->pl->params.deviceinfo.DevicePropertiesSupported_len; i++) { - if (prop != camera->pl->params.deviceinfo.DevicePropertiesSupported[i]) - continue; - if ((prop & 0xf000) == 0x5000) { /* generic property */ - if (!vendor || (camera->pl->params.deviceinfo.VendorExtensionID==vendor)) - return 1; - } - if (camera->pl->params.deviceinfo.VendorExtensionID==vendor) - return 1; - } - } - if ((prop & 0x7000) == 0x1000) { /* commands */ - for (i=0; i<camera->pl->params.deviceinfo.OperationsSupported_len; i++) { - if (prop != camera->pl->params.deviceinfo.OperationsSupported[i]) - continue; - if ((prop & 0xf000) == 0x1000) /* generic property */ - return 1; - if (camera->pl->params.deviceinfo.VendorExtensionID==vendor) - return 1; - } - } - return 0; -} - -static int -have_eos_prop(Camera *camera, uint16_t vendor, uint16_t prop) { - unsigned int i; - - /* The special Canon EOS property set gets special treatment. */ - if ((camera->pl->params.deviceinfo.VendorExtensionID != PTP_VENDOR_CANON) || - (vendor != PTP_VENDOR_CANON) - ) - return 0; - for (i=0;i<camera->pl->params.nrofcanon_props;i++) - if (camera->pl->params.canon_props[i].proptype == prop) - return 1; - return 0; -} - struct submenu; #define CONFIG_GET_ARGS Camera *camera, CameraWidget **widget, struct submenu* menu, PTPDevicePropDesc *dpd #define CONFIG_GET_NAMES camera, widget, menu, dpd |