/* DG_CONTROL/DAT_PENDINGXFERS/MSG_ENDXFER */ TW_UINT16 GPHOTO2_PendingXfersEndXfer (pTW_IDENTITY pOrigin, TW_MEMREF pData) { TW_UINT32 count; pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData; struct gphoto2_file *file; TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_ENDXFER\n"); if (activeDS.currentState != 6 && activeDS.currentState != 7) { activeDS.twCC = TWCC_SEQERROR; return TWRC_FAILURE; } count = 0; LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry ) { if (file->download) count++; } TRACE("count = %ld\n", count); pPendingXfers->Count = count; if (pPendingXfers->Count != 0) { activeDS.currentState = 6; } else { activeDS.currentState = 5; /* Notify the application that it can close the data source */ activeDS.pendingEvent.TWMessage = MSG_CLOSEDSREQ; /* close any Transferring dialog */ TransferringDialogBox(activeDS.progressWnd,-1); activeDS.progressWnd = 0; } activeDS.twCC = TWCC_SUCCESS; return TWRC_SUCCESS; }
/* DG_IMAGE/DAT_IMAGEMEMXFER/MSG_GET */ TW_UINT16 GPHOTO2_ImageMemXferGet (pTW_IDENTITY pOrigin, TW_MEMREF pData) { #ifdef HAVE_GPHOTO2 TW_UINT16 twRC = TWRC_SUCCESS; pTW_IMAGEMEMXFER pImageMemXfer = (pTW_IMAGEMEMXFER) pData; LPBYTE buffer; int readrows; unsigned int curoff; TRACE ("DG_IMAGE/DAT_IMAGEMEMXFER/MSG_GET\n"); if (activeDS.currentState < 6 || activeDS.currentState > 7) { activeDS.twCC = TWCC_SEQERROR; return TWRC_FAILURE; } TRACE("pImageMemXfer.Compression is %d\n", pImageMemXfer->Compression); if (activeDS.currentState == 6) { if (TWRC_SUCCESS != _get_image_and_startup_jpeg()) { FIXME("Failed to get an image\n"); activeDS.twCC = TWCC_SEQERROR; return TWRC_FAILURE; } if (!activeDS.progressWnd) activeDS.progressWnd = TransferringDialogBox(NULL,0); TransferringDialogBox(activeDS.progressWnd,0); activeDS.currentState = 7; } else { if (!activeDS.file) { activeDS.twCC = TWRC_SUCCESS; return TWRC_XFERDONE; } } if (pImageMemXfer->Memory.Flags & TWMF_HANDLE) { FIXME("Memory Handle, may not be locked correctly\n"); buffer = LocalLock(pImageMemXfer->Memory.TheMem); } else buffer = pImageMemXfer->Memory.TheMem; memset(buffer,0,pImageMemXfer->Memory.Length); curoff = 0; readrows = 0; pImageMemXfer->YOffset = activeDS.jd.output_scanline; pImageMemXfer->XOffset = 0; /* we do whole strips */ while ((activeDS.jd.output_scanline<activeDS.jd.output_height) && ((pImageMemXfer->Memory.Length - curoff) > activeDS.jd.output_width*activeDS.jd.output_components) ) { JSAMPROW row = buffer+curoff; int x = pjpeg_read_scanlines(&activeDS.jd,&row,1); if (x != 1) { FIXME("failed to read current scanline?\n"); break; } readrows++; curoff += activeDS.jd.output_width*activeDS.jd.output_components; } pImageMemXfer->Compression = TWCP_NONE; pImageMemXfer->BytesPerRow = activeDS.jd.output_components * activeDS.jd.output_width; pImageMemXfer->Rows = readrows; pImageMemXfer->Columns = activeDS.jd.output_width; /* we do whole strips */ pImageMemXfer->BytesWritten = curoff; TransferringDialogBox(activeDS.progressWnd,0); if (activeDS.jd.output_scanline == activeDS.jd.output_height) { pjpeg_finish_decompress(&activeDS.jd); pjpeg_destroy_decompress(&activeDS.jd); gp_file_unref (activeDS.file); activeDS.file = NULL; TRACE("xfer is done!\n"); /*TransferringDialogBox(activeDS.progressWnd, -1);*/ twRC = TWRC_XFERDONE; } activeDS.twCC = TWRC_SUCCESS; if (pImageMemXfer->Memory.Flags & TWMF_HANDLE) LocalUnlock(pImageMemXfer->Memory.TheMem); return twRC; #else return TWRC_FAILURE; #endif }