/* Below contributed by Ben Hague <*****@*****.**> */ static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { int result; if (camera->pl->device_type==SOUNDVISION_AGFACL18) result=agfa_capture(camera->pl,path); else if (camera->pl->device_type==SOUNDVISION_TIGERFASTFLICKS) { result=tiger_capture(camera->pl,path); } else return GP_ERROR_NOT_SUPPORTED; if (result < GP_OK) return result; soundvision_get_file_list(camera->pl); /* For some reason last taken picture is first on tiger? */ /* Might be last on Agfa. Who knows. Craziness. */ if (camera->pl->num_pictures<1) return GP_ERROR; strcpy (path->name,camera->pl->file_list); strcpy (path->folder, "/"); /* gp_filesystem_append (camera->fs, path->folder, path->name, context);*/ return GP_OK; }
static int delete_file_func (CameraFilesystem *fs, const char *folder, const char *filename, void *data, GPContext *context) { Camera *camera = data; GP_DEBUG("Deleting '%s' in '%s'...",filename,folder); soundvision_delete_picture(camera->pl,filename); /* Update our file list */ if (soundvision_get_file_list(camera->pl)<0) return GP_ERROR; return GP_OK; }
static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { Camera *camera=data; int i; char temp_file[14]; GP_DEBUG ("camera_file_list %s\n", folder); if (soundvision_get_file_list(camera->pl) < 0) { GP_DEBUG ("Could not soundvision_file_list!"); return GP_ERROR; } for(i=0; i < camera->pl->num_pictures; i++) { strncpy(temp_file,camera->pl->file_list+(13*i),12); temp_file[12]=0; gp_list_append (list, temp_file, NULL); } return GP_OK; }
/* Yet uploaded file never appears. Why?? */ int tiger_upload_file(CameraPrivateLibrary *dev, const char *filename, const char *data, long size) { int result=0; char return_value[4]; uint32_t our_size; char *our_data=NULL; /* When we upload, the first 3 bytes are little-endian */ /* File-size followed by the actual file */ our_size=size+4; our_data=calloc(our_size,sizeof(char)); if (our_data==NULL) { goto upload_error; } htole32a(&our_data[0],size); memcpy(our_data+4,data,size); GP_DEBUG("File: %s Size=%ld\n",filename,size); /* for(result=0;result<our_size;result++) { printf("%x ",our_data[result]); } */ result=tiger_set_pc_mode(dev); if (result<0) goto upload_error; result=soundvision_get_revision(dev,NULL); if (result<0) goto upload_error; result=soundvision_send_command(SOUNDVISION_GET_MEM_FREE,0,dev); if (result<0) goto upload_error; result=soundvision_read(dev, &return_value, sizeof(return_value)); if (result<0) goto upload_error; result=soundvision_send_command(SOUNDVISION_PUT_FILE,size,dev); if (result<0) goto upload_error; result=soundvision_read(dev, &return_value, sizeof(return_value)); if (result<0) goto upload_error; result=gp_port_write(dev->gpdev,our_data,our_size); if (result<0) goto upload_error; free(our_data); our_data=NULL; #if 0 /* Some traces show the following, though most likely */ /* this is just the windows driver updating the file list */ result=soundvision_photos_taken(dev); result=soundvision_get_file_list(dev); result=soundvision_send_command(SOUNDVISION_GET_PIC_SIZE,0,dev); if (result<0) goto upload_error; result=soundvision_read(dev, &return_value, sizeof(return_value)); if (result<0) goto upload_error; result=soundvision_send_file_command("000VINCE.JPG",dev); result=soundvision_read(dev, &return_value, sizeof(return_value)); if (result<0) goto upload_error; result=soundvision_send_command(SOUNDVISION_DONE_TRANSACTION,0,dev); if (result<0) goto upload_error; #endif return GP_OK; upload_error: if (our_data!=NULL) free(our_data); GP_DEBUG("Error in tiger_upload_file"); return result; }