summaryrefslogtreecommitdiff
path: root/camlibs/canon
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2012-03-17 21:57:49 +0000
committerMarcus Meissner <marcus@jet.franken.de>2012-03-17 21:57:49 +0000
commitc152b5bb56824b83fc96dad8f326e658635228bd (patch)
tree5f4f061738afc369b7be2dcd789ea08913e3f13f /camlibs/canon
parent23ec5d1395c89aa80a7f6607ddfb047dfe0f9785 (diff)
downloadlibgphoto2-c152b5bb56824b83fc96dad8f326e658635228bd.tar.gz
keep directory state at cameraprivatelib level
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@13920 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/canon')
-rw-r--r--camlibs/canon/canon.h3
-rw-r--r--camlibs/canon/usb.c22
2 files changed, 14 insertions, 11 deletions
diff --git a/camlibs/canon/canon.h b/camlibs/canon/canon.h
index 442f30c77..d3e6d4422 100644
--- a/camlibs/canon/canon.h
+++ b/camlibs/canon/canon.h
@@ -494,6 +494,9 @@ struct _CameraPrivateLibrary
char *cached_drive; /* usually something like C: */
int cached_ready; /* whether the camera is ready to rock */
+
+ unsigned char *directory_state; /* directory content state for wait_for_event */
+
long image_key, thumb_length, image_length; /* For immediate download of captured image */
long image_b_key, image_b_length; /* For immediate download of secondary captured image */
int capture_step; /* To record progress in interrupt
diff --git a/camlibs/canon/usb.c b/camlibs/canon/usb.c
index 530ab04e5..da537cbad 100644
--- a/camlibs/canon/usb.c
+++ b/camlibs/canon/usb.c
@@ -1001,13 +1001,14 @@ canon_usb_wait_for_event (Camera *camera, int timeout,
GPContext *context)
{
unsigned char buf2[0x40]; /* for reading from interrupt endpoint */
- unsigned char *initial_state = NULL, *final_state = NULL; /* For comparing
- * before/after
- * directories */
- unsigned int initial_state_len, final_state_len;
- int status;
-
- status = canon_usb_list_all_dirs ( camera, &initial_state, &initial_state_len, context );
+ unsigned char *final_state = NULL; /* For comparing
+ * before/after
+ * directories */
+ unsigned int directory_state_len, final_state_len;
+ int status = GP_OK;
+
+ if (!camera->pl->directory_state)
+ status = canon_usb_list_all_dirs ( camera, &camera->pl->directory_state, &directory_state_len, context );
if (status < GP_OK) {
gp_log (GP_LOG_DEBUG, "canon/usb.c", "canon_usb_wait_for_event: status %d", status);
return status;
@@ -1030,22 +1031,21 @@ canon_usb_wait_for_event (Camera *camera, int timeout,
if (status < GP_OK)
return status;
/* Find new file name in camera directory */
- canon_int_find_new_image ( camera, initial_state, final_state, path );
+ canon_int_find_new_image ( camera, camera->pl->directory_state, final_state, path );
if (path->folder[0] != '/') {
free (path);
*eventtype = GP_EVENT_UNKNOWN;
*eventdata = malloc(strlen("Failed to get added filename?")+1);
strcpy (*eventdata, "Failed to get added filename?");
}
- free ( initial_state );
- free ( final_state );
+ free ( camera->pl->directory_state );
+ camera->pl->directory_state = final_state;
return GP_OK;
}
default:
*eventtype = GP_EVENT_UNKNOWN;
*eventdata = malloc(strlen("Unknown CANON event 0x01 0x02 0x03 0x04 0x05")+1);
sprintf (*eventdata,"Unknown CANON event 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",buf2[0],buf2[1],buf2[2],buf2[3],buf2[4]);
- free (initial_state);
return GP_OK;
}
return GP_OK;