gphoto.ds: Implemented a libgphoto2 import driver, based on the sane.ds driver.
Wrote a GUI import dialog. With help from Aric Stewart.
This commit is contained in:
parent
125efed86a
commit
40e7ef3a1d
32
configure.ac
32
configure.ac
|
@ -565,6 +565,37 @@ then
|
|||
CPPFLAGS="$ac_save_CPPFLAGS"
|
||||
fi
|
||||
|
||||
dnl **** Check for libgphoto2 ****
|
||||
AC_CHECK_PROG(gphoto2_devel,gphoto2-config,gphoto2-config,no)
|
||||
AC_CHECK_PROG(gphoto2port_devel,gphoto2-port-config,gphoto2-port-config,no)
|
||||
AC_SUBST(GPHOTO2LIBS,"")
|
||||
AC_SUBST(GPHOTO2INCL,"")
|
||||
if test "$gphoto2_devel" != "no" -a "$gphoto2port_devel" != "no"
|
||||
then
|
||||
GPHOTO2INCL="`$gphoto2_devel --cflags` `$gphoto2port_devel --cflags`"
|
||||
GPHOTO2LIBS=""
|
||||
for i in `$gphoto2_devel --libs` `$gphoto2port_devel --libs`
|
||||
do
|
||||
case "$i" in
|
||||
-L/usr/lib|-L/usr/lib64) ;;
|
||||
-L*|-l*) GPHOTO2LIBS="$GPHOTO2LIBS $i";;
|
||||
esac
|
||||
done
|
||||
ac_save_CPPFLAGS="$CPPFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CPPFLAGS="$CPPFLAGS $GPHOTO2INCL"
|
||||
LIBS="$LIBS $GPHOTO2LIBS"
|
||||
AC_CHECK_HEADER(gphoto2-camera.h,
|
||||
[AC_CHECK_LIB(gphoto2,gp_camera_new,
|
||||
[AC_DEFINE(HAVE_GPHOTO2, 1, [Define if we have libgphoto2 development environment])],
|
||||
[GPHOTO2LIBS=""
|
||||
GPHOTO2INCL=""])],
|
||||
[GPHOTO2LIBS=""
|
||||
GPHOTO2INCL=""])
|
||||
LIBS="$ac_save_LIBS"
|
||||
CPPFLAGS="$ac_save_CPPFLAGS"
|
||||
fi
|
||||
|
||||
dnl **** Check for the ICU library ****
|
||||
if test "$ac_cv_header_unicode_ubidi_h" = "yes"
|
||||
then
|
||||
|
@ -1549,6 +1580,7 @@ dlls/gdi/Makefile
|
|||
dlls/gdi/tests/Makefile
|
||||
dlls/glu32/Makefile
|
||||
dlls/glut32/Makefile
|
||||
dlls/gphoto2.ds/Makefile
|
||||
dlls/hhctrl.ocx/Makefile
|
||||
dlls/iccvid/Makefile
|
||||
dlls/icmp/Makefile
|
||||
|
|
|
@ -60,6 +60,7 @@ BASEDIRS = \
|
|||
dswave \
|
||||
dxdiagn \
|
||||
gdi \
|
||||
gphoto2.ds \
|
||||
hhctrl.ocx \
|
||||
iccvid \
|
||||
icmp \
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Makefile
|
||||
rsrc.res
|
|
@ -0,0 +1,22 @@
|
|||
TOPSRCDIR = @top_srcdir@
|
||||
TOPOBJDIR = ../..
|
||||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
MODULE = gphoto2.ds
|
||||
IMPORTS = comctl32 user32 gdi32 kernel32 ntdll
|
||||
EXTRALIBS = @GPHOTO2LIBS@
|
||||
EXTRAINCL = @GPHOTO2INCL@
|
||||
|
||||
C_SRCS = \
|
||||
capability.c \
|
||||
ds_ctrl.c \
|
||||
ds_image.c \
|
||||
gphoto2_main.c \
|
||||
ui.c
|
||||
|
||||
RC_SRCS = \
|
||||
rsrc.rc
|
||||
|
||||
@MAKE_DLL_RULES@
|
||||
|
||||
### Dependencies:
|
|
@ -0,0 +1,553 @@
|
|||
/*
|
||||
* Copyright 2000 Corel Corporation
|
||||
* Copyright 2006 Marcus Meissner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "twain.h"
|
||||
#include "gphoto2_i.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(twain);
|
||||
|
||||
static TW_UINT16 GPHOTO2_ICAPXferMech (pTW_CAPABILITY,TW_UINT16);
|
||||
static TW_UINT16 GPHOTO2_ICAPPixelType (pTW_CAPABILITY,TW_UINT16);
|
||||
static TW_UINT16 GPHOTO2_ICAPPixelFlavor (pTW_CAPABILITY,TW_UINT16);
|
||||
static TW_UINT16 GPHOTO2_ICAPBitDepth (pTW_CAPABILITY,TW_UINT16);
|
||||
static TW_UINT16 GPHOTO2_ICAPUnits (pTW_CAPABILITY,TW_UINT16);
|
||||
|
||||
TW_UINT16 GPHOTO2_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action)
|
||||
{
|
||||
TW_UINT16 twCC = TWCC_SUCCESS;
|
||||
|
||||
TRACE("capability=%d action=%d\n", pCapability->Cap, action);
|
||||
|
||||
switch (pCapability->Cap)
|
||||
{
|
||||
case CAP_DEVICEEVENT:
|
||||
case CAP_ALARMS:
|
||||
case CAP_ALARMVOLUME:
|
||||
case ACAP_AUDIOFILEFORMAT:
|
||||
case ACAP_XFERMECH:
|
||||
case ICAP_AUTOMATICBORDERDETECTION:
|
||||
case ICAP_AUTOMATICDESKEW:
|
||||
case ICAP_AUTODISCARDBLANKPAGES:
|
||||
case ICAP_AUTOMATICROTATE:
|
||||
case ICAP_FLIPROTATION:
|
||||
case CAP_AUTOMATICCAPTURE:
|
||||
case CAP_TIMEBEFOREFIRSTCAPTURE:
|
||||
case CAP_TIMEBETWEENCAPTURES:
|
||||
case CAP_AUTOSCAN:
|
||||
case CAP_CLEARBUFFERS:
|
||||
case CAP_MAXBATCHBUFFERS:
|
||||
case ICAP_BARCODEDETECTIONENABLED:
|
||||
case ICAP_SUPPORTEDBARCODETYPES:
|
||||
case ICAP_BARCODEMAXSEARCHPRIORITIES:
|
||||
case ICAP_BARCODESEARCHPRIORITIES:
|
||||
case ICAP_BARCODESEARCHMODE:
|
||||
case ICAP_BARCODEMAXRETRIES:
|
||||
case ICAP_BARCODETIMEOUT:
|
||||
case CAP_EXTENDEDCAPS:
|
||||
case CAP_SUPPORTEDCAPS:
|
||||
case ICAP_FILTER:
|
||||
case ICAP_GAMMA:
|
||||
case ICAP_PLANARCHUNKY:
|
||||
case ICAP_BITORDERCODES:
|
||||
case ICAP_CCITTKFACTOR:
|
||||
case ICAP_JPEGPIXELTYPE:
|
||||
/*case ICAP_JPEGQUALITY:*/
|
||||
case ICAP_PIXELFLAVORCODES:
|
||||
case ICAP_TIMEFILL:
|
||||
case CAP_DEVICEONLINE:
|
||||
case CAP_DEVICETIMEDATE:
|
||||
case CAP_SERIALNUMBER:
|
||||
case ICAP_EXPOSURETIME:
|
||||
case ICAP_FLASHUSED2:
|
||||
case ICAP_IMAGEFILTER:
|
||||
case ICAP_LAMPSTATE:
|
||||
case ICAP_LIGHTPATH:
|
||||
case ICAP_NOISEFILTER:
|
||||
case ICAP_OVERSCAN:
|
||||
case ICAP_PHYSICALHEIGHT:
|
||||
case ICAP_PHYSICALWIDTH:
|
||||
case ICAP_ZOOMFACTOR:
|
||||
case CAP_PRINTER:
|
||||
case CAP_PRINTERENABLED:
|
||||
case CAP_PRINTERINDEX:
|
||||
case CAP_PRINTERMODE:
|
||||
case CAP_PRINTERSTRING:
|
||||
case CAP_PRINTERSUFFIX:
|
||||
case CAP_AUTHOR:
|
||||
case CAP_CAPTION:
|
||||
case CAP_TIMEDATE:
|
||||
case ICAP_AUTOBRIGHT:
|
||||
case ICAP_BRIGHTNESS:
|
||||
case ICAP_CONTRAST:
|
||||
case ICAP_HIGHLIGHT:
|
||||
case ICAP_ORIENTATION:
|
||||
case ICAP_ROTATION:
|
||||
case ICAP_SHADOW:
|
||||
case ICAP_XSCALING:
|
||||
case ICAP_YSCALING:
|
||||
case ICAP_BITDEPTHREDUCTION:
|
||||
case ICAP_BITORDER:
|
||||
case ICAP_CUSTHALFTONE:
|
||||
case ICAP_HALFTONES:
|
||||
case ICAP_THRESHOLD:
|
||||
case CAP_LANGUAGE:
|
||||
case ICAP_FRAMES:
|
||||
case ICAP_MAXFRAMES:
|
||||
case ICAP_SUPPORTEDSIZES:
|
||||
case CAP_AUTOFEED:
|
||||
case CAP_CLEARPAGE:
|
||||
case CAP_FEEDERALIGNMENT:
|
||||
case CAP_FEEDERENABLED:
|
||||
case CAP_FEEDERLOADED:
|
||||
case CAP_FEEDERORDER:
|
||||
case CAP_FEEDPAGE:
|
||||
case CAP_PAPERBINDING:
|
||||
case CAP_PAPERDETECTABLE:
|
||||
case CAP_REACQUIREALLOWED:
|
||||
case CAP_REWINDPAGE:
|
||||
case ICAP_PATCHCODEDETECTIONENABLED:
|
||||
case ICAP_SUPPORTEDPATCHCODETYPES:
|
||||
case ICAP_PATCHCODEMAXSEARCHPRIORITIES:
|
||||
case ICAP_PATCHCODESEARCHPRIORITIES:
|
||||
case ICAP_PATCHCODESEARCHMODE:
|
||||
case ICAP_PATCHCODEMAXRETRIES:
|
||||
case ICAP_PATCHCODETIMEOUT:
|
||||
case CAP_BATTERYMINUTES:
|
||||
case CAP_BATTERYPERCENTAGE:
|
||||
case CAP_POWERDOWNTIME:
|
||||
case CAP_POWERSUPPLY:
|
||||
case ICAP_XNATIVERESOLUTION:
|
||||
case ICAP_XRESOLUTION:
|
||||
case ICAP_YNATIVERESOLUTION:
|
||||
case ICAP_YRESOLUTION:
|
||||
twCC = TWCC_CAPUNSUPPORTED;
|
||||
break;
|
||||
case CAP_XFERCOUNT:
|
||||
/* This is a required capability that every source need to
|
||||
support but we haven't implemented yet. */
|
||||
twCC = TWCC_SUCCESS;
|
||||
break;
|
||||
/*case ICAP_COMPRESSION:*/
|
||||
case ICAP_IMAGEFILEFORMAT:
|
||||
case ICAP_TILES:
|
||||
twCC = TWCC_CAPUNSUPPORTED;
|
||||
break;
|
||||
case ICAP_XFERMECH:
|
||||
twCC = GPHOTO2_ICAPXferMech (pCapability, action);
|
||||
break;
|
||||
case ICAP_PIXELTYPE:
|
||||
twCC = GPHOTO2_ICAPPixelType (pCapability, action);
|
||||
break;
|
||||
case ICAP_PIXELFLAVOR:
|
||||
twCC = GPHOTO2_ICAPPixelFlavor (pCapability, action);
|
||||
break;
|
||||
case ICAP_BITDEPTH:
|
||||
twCC = GPHOTO2_ICAPBitDepth (pCapability, action);
|
||||
break;
|
||||
case ICAP_UNITS:
|
||||
twCC = GPHOTO2_ICAPUnits (pCapability, action);
|
||||
break;
|
||||
case ICAP_UNDEFINEDIMAGESIZE:
|
||||
case CAP_CAMERAPREVIEWUI:
|
||||
case CAP_ENABLEDSUIONLY:
|
||||
case CAP_INDICATORS:
|
||||
case CAP_UICONTROLLABLE:
|
||||
twCC = TWCC_CAPUNSUPPORTED;
|
||||
break;
|
||||
|
||||
case ICAP_COMPRESSION:
|
||||
twCC = TWCC_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
twCC = TWRC_FAILURE;
|
||||
break;
|
||||
}
|
||||
return twCC;
|
||||
}
|
||||
|
||||
static TW_BOOL GPHOTO2_OneValueSet32 (pTW_CAPABILITY pCapability, TW_UINT32 value)
|
||||
{
|
||||
pCapability->hContainer = (TW_HANDLE)GlobalAlloc (0, sizeof(TW_ONEVALUE));
|
||||
|
||||
TRACE("-> %ld\n", value);
|
||||
|
||||
if (pCapability->hContainer)
|
||||
{
|
||||
pTW_ONEVALUE pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
|
||||
pVal->ItemType = TWTY_UINT32;
|
||||
pVal->Item = value;
|
||||
GlobalUnlock ((HGLOBAL) pCapability->hContainer);
|
||||
pCapability->ConType = TWON_ONEVALUE;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static TW_BOOL GPHOTO2_OneValueSet16 (pTW_CAPABILITY pCapability, TW_UINT16 value)
|
||||
{
|
||||
pCapability->hContainer = (TW_HANDLE)GlobalAlloc (0, sizeof(TW_ONEVALUE));
|
||||
|
||||
TRACE("-> %d\n", value);
|
||||
|
||||
if (pCapability->hContainer)
|
||||
{
|
||||
pTW_ONEVALUE pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
|
||||
pVal->ItemType = TWTY_UINT16;
|
||||
pVal->Item = value;
|
||||
GlobalUnlock ((HGLOBAL) pCapability->hContainer);
|
||||
pCapability->ConType = TWON_ONEVALUE;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static TW_BOOL GPHOTO2_EnumSet16 (pTW_CAPABILITY pCapability, int nrofvalues, TW_UINT16 *values, int current, int def)
|
||||
{
|
||||
pTW_ENUMERATION pVal;
|
||||
pCapability->hContainer = (TW_HANDLE)GlobalAlloc (0, sizeof(TW_ENUMERATION) + nrofvalues * sizeof(TW_UINT16));
|
||||
|
||||
if (!pCapability->hContainer)
|
||||
return FALSE;
|
||||
|
||||
pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
|
||||
pVal->ItemType = TWTY_UINT16;
|
||||
pVal->NumItems = nrofvalues;
|
||||
memcpy(pVal->ItemList, values, sizeof(TW_UINT16)*nrofvalues);
|
||||
pVal->CurrentIndex = current;
|
||||
pVal->DefaultIndex = def;
|
||||
pCapability->ConType = TWON_ENUMERATION;
|
||||
GlobalUnlock ((HGLOBAL) pCapability->hContainer);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static TW_BOOL GPHOTO2_EnumGet16 (pTW_CAPABILITY pCapability, int *nrofvalues, TW_UINT16 **values)
|
||||
{
|
||||
pTW_ENUMERATION pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
|
||||
|
||||
if (!pVal)
|
||||
return FALSE;
|
||||
*nrofvalues = pVal->NumItems;
|
||||
*values = HeapAlloc( GetProcessHeap(), 0, sizeof(TW_UINT16)*pVal->NumItems);
|
||||
memcpy (*values, pVal->ItemList, sizeof(TW_UINT16)*(*nrofvalues));
|
||||
FIXME("Current Index %ld, Default Index %ld\n", pVal->CurrentIndex, pVal->DefaultIndex);
|
||||
GlobalUnlock ((HGLOBAL) pCapability->hContainer);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static TW_BOOL GPHOTO2_OneValueGet32 (pTW_CAPABILITY pCapability, TW_UINT32 *pValue)
|
||||
{
|
||||
pTW_ONEVALUE pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
|
||||
|
||||
if (pVal)
|
||||
{
|
||||
*pValue = pVal->Item;
|
||||
GlobalUnlock ((HGLOBAL) pCapability->hContainer);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static TW_BOOL GPHOTO2_OneValueGet16 (pTW_CAPABILITY pCapability, TW_UINT16 *pValue)
|
||||
{
|
||||
pTW_ONEVALUE pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
|
||||
|
||||
if (pVal)
|
||||
{
|
||||
*pValue = pVal->Item;
|
||||
GlobalUnlock ((HGLOBAL) pCapability->hContainer);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* ICAP_XFERMECH */
|
||||
static TW_UINT16 GPHOTO2_ICAPXferMech (pTW_CAPABILITY pCapability, TW_UINT16 action)
|
||||
{
|
||||
TRACE("ICAP_XFERMECH, action %d\n", action);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case MSG_GET:
|
||||
if (!GPHOTO2_OneValueSet32 (pCapability, activeDS.capXferMech))
|
||||
return TWCC_LOWMEMORY;
|
||||
return TWCC_SUCCESS;
|
||||
case MSG_SET:
|
||||
if (pCapability->ConType == TWON_ONEVALUE)
|
||||
{
|
||||
TW_UINT32 xfermechtemp = 0;
|
||||
|
||||
if (!GPHOTO2_OneValueGet32 (pCapability, &xfermechtemp))
|
||||
return TWCC_LOWMEMORY;
|
||||
activeDS.capXferMech = xfermechtemp;
|
||||
TRACE("xfermech is %ld\n", xfermechtemp);
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
else if (pCapability->ConType == TWON_ENUMERATION)
|
||||
{
|
||||
|
||||
}
|
||||
FIXME("GET FAILED\n");
|
||||
break;
|
||||
case MSG_GETCURRENT:
|
||||
if (!GPHOTO2_OneValueSet32 (pCapability, activeDS.capXferMech))
|
||||
return TWCC_LOWMEMORY;
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
if (!GPHOTO2_OneValueSet32 (pCapability, TWSX_NATIVE))
|
||||
return TWCC_LOWMEMORY;
|
||||
break;
|
||||
case MSG_RESET:
|
||||
activeDS.capXferMech = TWSX_NATIVE;
|
||||
break;
|
||||
}
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
|
||||
/* ICAP_PIXELTYPE */
|
||||
static TW_UINT16 GPHOTO2_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 action)
|
||||
{
|
||||
TRACE("Action %d\n", action);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case MSG_GET:
|
||||
if ((pCapability->ConType == TWON_DONTCARE16) ||
|
||||
(pCapability->ConType == TWON_ONEVALUE)
|
||||
) {
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, activeDS.pixeltype))
|
||||
return TWCC_LOWMEMORY;
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
FIXME("Unknown container type %x in MSG_GET\n", pCapability->ConType);
|
||||
return TWCC_CAPBADOPERATION;
|
||||
case MSG_SET:
|
||||
if (pCapability->ConType == TWON_ONEVALUE)
|
||||
{
|
||||
TW_UINT16 pixeltype = 0;
|
||||
|
||||
if (!GPHOTO2_OneValueGet16 (pCapability, &pixeltype))
|
||||
return TWCC_LOWMEMORY;
|
||||
activeDS.pixeltype = pixeltype;
|
||||
FIXME("pixeltype changed to %d!\n", pixeltype);
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
FIXME("set not done\n");
|
||||
if (pCapability->ConType == TWON_ENUMERATION) {
|
||||
TW_UINT16 *values = NULL;
|
||||
int i, nrofvalues = 0;
|
||||
|
||||
if (!GPHOTO2_EnumGet16 (pCapability, &nrofvalues, &values))
|
||||
return TWCC_LOWMEMORY;
|
||||
for (i=0;i<nrofvalues;i++)
|
||||
FIXME("SET PixelType %d:%d\n", i, values[i]);
|
||||
HeapFree (GetProcessHeap(), 0, values);
|
||||
}
|
||||
break;
|
||||
case MSG_GETCURRENT:
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, activeDS.pixeltype)) {
|
||||
FIXME("Failed one value set in GETCURRENT, contype %d!\n", pCapability->ConType);
|
||||
return TWCC_LOWMEMORY;
|
||||
}
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, TWPT_RGB)) {
|
||||
FIXME("Failed onevalue set in GETDEFAULT!\n");
|
||||
return TWCC_LOWMEMORY;
|
||||
}
|
||||
break;
|
||||
case MSG_RESET:
|
||||
activeDS.pixeltype = TWPT_RGB;
|
||||
break;
|
||||
}
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
|
||||
/* ICAP_PIXELFLAVOR */
|
||||
static TW_UINT16 GPHOTO2_ICAPPixelFlavor (pTW_CAPABILITY pCapability, TW_UINT16 action)
|
||||
{
|
||||
TRACE("Action %d\n", action);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case MSG_GET:
|
||||
if ((pCapability->ConType == TWON_DONTCARE16) ||
|
||||
(pCapability->ConType == TWON_ONEVALUE)
|
||||
) {
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, TWPF_CHOCOLATE))
|
||||
return TWCC_LOWMEMORY;
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
if (!pCapability->ConType) {
|
||||
TW_UINT16 arr[2];
|
||||
arr[0] = TWPF_CHOCOLATE;
|
||||
arr[1] = TWPF_VANILLA;
|
||||
|
||||
if (!GPHOTO2_EnumSet16 (pCapability, 2, arr, 1, 1))
|
||||
return TWCC_LOWMEMORY;
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
FIXME("MSG_GET container type %x unhandled\n", pCapability->ConType);
|
||||
return TWCC_BADVALUE;
|
||||
case MSG_SET:
|
||||
if (pCapability->ConType == TWON_ONEVALUE)
|
||||
{
|
||||
TW_UINT16 pixelflavor = 0;
|
||||
|
||||
if (!GPHOTO2_OneValueGet16 (pCapability, &pixelflavor))
|
||||
return TWCC_LOWMEMORY;
|
||||
activeDS.pixelflavor = pixelflavor;
|
||||
FIXME("pixelflavor is %d\n", pixelflavor);
|
||||
}
|
||||
break;
|
||||
case MSG_GETCURRENT:
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, activeDS.pixelflavor))
|
||||
return TWCC_LOWMEMORY;
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, TWPF_CHOCOLATE))
|
||||
return TWCC_LOWMEMORY;
|
||||
break;
|
||||
case MSG_RESET:
|
||||
break;
|
||||
}
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
|
||||
/* ICAP_BITDEPTH */
|
||||
static TW_UINT16 GPHOTO2_ICAPBitDepth (pTW_CAPABILITY pCapability, TW_UINT16 action)
|
||||
{
|
||||
TRACE("Action %d\n", action);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case MSG_GET:
|
||||
if ((pCapability->ConType == TWON_DONTCARE16) ||
|
||||
(pCapability->ConType == TWON_ONEVALUE)
|
||||
) {
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, 24))
|
||||
return TWCC_LOWMEMORY;
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
FIXME("MSG_GET container type %x unhandled\n", pCapability->ConType);
|
||||
return TWCC_SUCCESS;
|
||||
case MSG_SET:
|
||||
if (pCapability->ConType == TWON_ONEVALUE) {
|
||||
TW_UINT16 bitdepth = 0;
|
||||
|
||||
if (!GPHOTO2_OneValueGet16 (pCapability, &bitdepth))
|
||||
return TWCC_LOWMEMORY;
|
||||
if (bitdepth != 24)
|
||||
return TWCC_BADVALUE;
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
if (pCapability->ConType == TWON_ENUMERATION)
|
||||
{
|
||||
int i, nrofvalues = 0;
|
||||
TW_UINT16 *values = NULL;
|
||||
|
||||
if (!GPHOTO2_EnumGet16 (pCapability, &nrofvalues, &values))
|
||||
return TWCC_LOWMEMORY;
|
||||
for (i=0;i<nrofvalues;i++)
|
||||
FIXME("SET: enum element %d = %d\n", i, values[i]);
|
||||
HeapFree (GetProcessHeap(), 0, values);
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
FIXME("Unhandled container type %d in MSG_SET\n", pCapability->ConType);
|
||||
break;
|
||||
case MSG_GETCURRENT:
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, 24))
|
||||
return TWCC_LOWMEMORY;
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, 24))
|
||||
return TWCC_LOWMEMORY;
|
||||
break;
|
||||
case MSG_RESET:
|
||||
break;
|
||||
}
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
|
||||
/* ICAP_UNITS */
|
||||
static TW_UINT16 GPHOTO2_ICAPUnits (pTW_CAPABILITY pCapability, TW_UINT16 action)
|
||||
{
|
||||
TRACE("Action %d\n", action);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case MSG_GET:
|
||||
if ((pCapability->ConType == TWON_DONTCARE16) ||
|
||||
(pCapability->ConType == TWON_ONEVALUE)
|
||||
) {
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, TWUN_PIXELS))
|
||||
return TWCC_LOWMEMORY;
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
FIXME("MSG_GET container type %x unhandled\n", pCapability->ConType);
|
||||
return TWCC_SUCCESS;
|
||||
case MSG_SET:
|
||||
if (pCapability->ConType == TWON_ONEVALUE) {
|
||||
TW_UINT16 units = 0;
|
||||
|
||||
if (!GPHOTO2_OneValueGet16 (pCapability, &units))
|
||||
return TWCC_LOWMEMORY;
|
||||
FIXME("SET to type %d, stub.\n", units);
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
if (pCapability->ConType == TWON_ENUMERATION)
|
||||
{
|
||||
int i, nrofvalues = 0;
|
||||
TW_UINT16 *values = NULL;
|
||||
|
||||
if (!GPHOTO2_EnumGet16 (pCapability, &nrofvalues, &values))
|
||||
return TWCC_LOWMEMORY;
|
||||
for (i=0;i<nrofvalues;i++)
|
||||
FIXME("SET: enum element %d = %d\n", i, values[i]);
|
||||
HeapFree (GetProcessHeap(), 0, values);
|
||||
return TWCC_SUCCESS;
|
||||
}
|
||||
FIXME("Unhandled container type %d in MSG_SET\n", pCapability->ConType);
|
||||
break;
|
||||
case MSG_GETCURRENT:
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, TWUN_INCHES))
|
||||
return TWCC_LOWMEMORY;
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
if (!GPHOTO2_OneValueSet16 (pCapability, TWUN_PIXELS))
|
||||
return TWCC_LOWMEMORY;
|
||||
break;
|
||||
case MSG_RESET:
|
||||
break;
|
||||
}
|
||||
return TWCC_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,610 @@
|
|||
/*
|
||||
* Copyright 2000 Corel Corporation
|
||||
* Copyright 2006 Marcus Meissner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "twain.h"
|
||||
#include "gphoto2_i.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(twain);
|
||||
|
||||
static void
|
||||
load_filesystem(const char *folder) {
|
||||
#ifdef HAVE_GPHOTO2
|
||||
int i, count, ret;
|
||||
CameraList *list;
|
||||
|
||||
ret = gp_list_new (&list);
|
||||
if (ret < GP_OK)
|
||||
return;
|
||||
ret = gp_camera_folder_list_files (activeDS.camera, folder, list, activeDS.context);
|
||||
if (ret < GP_OK) {
|
||||
gp_list_free (list);
|
||||
return;
|
||||
}
|
||||
count = gp_list_count (list);
|
||||
if (count < GP_OK) {
|
||||
gp_list_free (list);
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
const char *name;
|
||||
struct gphoto2_file *gpfile;
|
||||
|
||||
ret = gp_list_get_name (list, i, &name);
|
||||
if (ret < GP_OK)
|
||||
continue;
|
||||
gpfile = malloc(sizeof(struct gphoto2_file));
|
||||
if (!gpfile)
|
||||
continue;
|
||||
TRACE("adding %s/%s\n", folder, name);
|
||||
gpfile->folder = strdup(folder);
|
||||
gpfile->filename = strdup(name);
|
||||
gpfile->download = FALSE;
|
||||
list_add_head( &activeDS.files, &gpfile->entry );
|
||||
}
|
||||
gp_list_reset (list);
|
||||
|
||||
ret = gp_camera_folder_list_folders (activeDS.camera, folder, list, activeDS.context);
|
||||
if (ret < GP_OK) {
|
||||
FIXME("list_folders failed\n");
|
||||
gp_list_free (list);
|
||||
return;
|
||||
}
|
||||
count = gp_list_count (list);
|
||||
if (count < GP_OK) {
|
||||
FIXME("list_folders failed\n");
|
||||
gp_list_free (list);
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
const char *name;
|
||||
char *newfolder;
|
||||
ret = gp_list_get_name (list, i, &name);
|
||||
if (ret < GP_OK)
|
||||
continue;
|
||||
TRACE("recursing into %s\n", name);
|
||||
newfolder = malloc(strlen(folder)+1+strlen(name)+1);
|
||||
if (!strcmp(folder,"/"))
|
||||
sprintf (newfolder, "/%s", name);
|
||||
else
|
||||
sprintf (newfolder, "%s/%s", folder, name);
|
||||
load_filesystem (newfolder); /* recurse ... happily */
|
||||
}
|
||||
gp_list_free (list);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_CAPABILITY/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_CapabilityGet (pTW_IDENTITY pOrigin, TW_MEMREF pData)
|
||||
{
|
||||
pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
|
||||
|
||||
TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_GET\n");
|
||||
if (activeDS.currentState < 4 || activeDS.currentState > 7) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
activeDS.twCC = GPHOTO2_SaneCapability (pCapability, MSG_GET);
|
||||
return (activeDS.twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_CAPABILITY/MSG_GETCURRENT */
|
||||
TW_UINT16 GPHOTO2_CapabilityGetCurrent (pTW_IDENTITY pOrigin, TW_MEMREF pData)
|
||||
{
|
||||
pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
|
||||
|
||||
TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_GETCURRENT\n");
|
||||
|
||||
if (activeDS.currentState < 4 || activeDS.currentState > 7) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
activeDS.twCC = GPHOTO2_SaneCapability (pCapability, MSG_GETCURRENT);
|
||||
return (activeDS.twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_CAPABILITY/MSG_GETDEFAULT */
|
||||
TW_UINT16 GPHOTO2_CapabilityGetDefault (pTW_IDENTITY pOrigin, TW_MEMREF pData)
|
||||
{
|
||||
pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
|
||||
|
||||
TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_GETDEFAULT\n");
|
||||
if (activeDS.currentState < 4 || activeDS.currentState > 7) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
activeDS.twCC = GPHOTO2_SaneCapability (pCapability, MSG_GETDEFAULT);
|
||||
return (activeDS.twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_CAPABILITY/MSG_QUERYSUPPORT */
|
||||
TW_UINT16 GPHOTO2_CapabilityQuerySupport (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_CAPABILITY/MSG_RESET */
|
||||
TW_UINT16 GPHOTO2_CapabilityReset (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
|
||||
|
||||
TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_RESET\n");
|
||||
|
||||
if (activeDS.currentState < 4 || activeDS.currentState > 7) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
activeDS.twCC = GPHOTO2_SaneCapability (pCapability, MSG_RESET);
|
||||
return (activeDS.twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_CAPABILITY/MSG_SET */
|
||||
TW_UINT16 GPHOTO2_CapabilitySet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
|
||||
|
||||
TRACE ("DG_CONTROL/DAT_CAPABILITY/MSG_SET\n");
|
||||
|
||||
if (activeDS.currentState != 4) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
activeDS.twCC = GPHOTO2_SaneCapability (pCapability, MSG_SET);
|
||||
return (activeDS.twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_CUSTOMDSDATA/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_CustomDSDataGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_CUSTOMDSDATA/MSG_SET */
|
||||
TW_UINT16 GPHOTO2_CustomDSDataSet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_AUTOMATICCAPTUREDIRECTORY */
|
||||
TW_UINT16 GPHOTO2_AutomaticCaptureDirectory (pTW_IDENTITY pOrigin,
|
||||
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_CHANGEDIRECTORY */
|
||||
TW_UINT16 GPHOTO2_ChangeDirectory (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_COPY */
|
||||
TW_UINT16 GPHOTO2_FileSystemCopy (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_CREATEDIRECTORY */
|
||||
TW_UINT16 GPHOTO2_CreateDirectory (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_DELETE */
|
||||
TW_UINT16 GPHOTO2_FileSystemDelete (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_FORMATMEDIA */
|
||||
TW_UINT16 GPHOTO2_FormatMedia (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_GETCLOSE */
|
||||
TW_UINT16 GPHOTO2_FileSystemGetClose (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_GETFIRSTFILE */
|
||||
TW_UINT16 GPHOTO2_FileSystemGetFirstFile (pTW_IDENTITY pOrigin,
|
||||
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_GETINFO */
|
||||
TW_UINT16 GPHOTO2_FileSystemGetInfo (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_GETNEXTFILE */
|
||||
TW_UINT16 GPHOTO2_FileSystemGetNextFile (pTW_IDENTITY pOrigin,
|
||||
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_FILESYSTEM/MSG_RENAME */
|
||||
TW_UINT16 GPHOTO2_FileSystemRename (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_EVENT/MSG_PROCESSEVENT */
|
||||
TW_UINT16 GPHOTO2_ProcessEvent (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
TW_UINT16 twRC = TWRC_SUCCESS;
|
||||
pTW_EVENT pEvent = (pTW_EVENT) pData;
|
||||
|
||||
TRACE("DG_CONTROL/DAT_EVENT/MSG_PROCESSEVENT\n");
|
||||
|
||||
if (activeDS.currentState < 5 || activeDS.currentState > 7) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
if (activeDS.pendingEvent.TWMessage != MSG_NULL) {
|
||||
pEvent->TWMessage = activeDS.pendingEvent.TWMessage;
|
||||
activeDS.pendingEvent.TWMessage = MSG_NULL;
|
||||
twRC = TWRC_SUCCESS;
|
||||
} else {
|
||||
pEvent->TWMessage = MSG_NULL; /* no message to the application */
|
||||
twRC = TWRC_NOTDSEVENT;
|
||||
}
|
||||
activeDS.twCC = TWCC_SUCCESS;
|
||||
return twRC;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_PASSTHRU/MSG_PASSTHRU */
|
||||
TW_UINT16 GPHOTO2_PassThrough (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* 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 Transfering dialog */
|
||||
TransferingDialogBox(activeDS.progressWnd,-1);
|
||||
activeDS.progressWnd = 0;
|
||||
}
|
||||
activeDS.twCC = TWCC_SUCCESS;
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_PENDINGXFERS/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_PendingXfersGet (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_GET\n");
|
||||
|
||||
if (activeDS.currentState < 4 || 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;
|
||||
activeDS.twCC = TWCC_SUCCESS;
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_PENDINGXFERS/MSG_RESET */
|
||||
TW_UINT16 GPHOTO2_PendingXfersReset (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData;
|
||||
|
||||
TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_RESET\n");
|
||||
|
||||
if (activeDS.currentState != 6) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
pPendingXfers->Count = 0;
|
||||
activeDS.currentState = 5;
|
||||
activeDS.twCC = TWCC_SUCCESS;
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_PENDINGXFERS/MSG_STOPFEEDER */
|
||||
TW_UINT16 GPHOTO2_PendingXfersStopFeeder (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_SETUPFILEXFER/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_SetupFileXferGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_SETUPXFER/MSG_GETDEFAULT */
|
||||
TW_UINT16 GPHOTO2_SetupFileXferGetDefault (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/* DG_CONTROL/DAT_SETUPFILEXFER/MSG_RESET */
|
||||
TW_UINT16 GPHOTO2_SetupFileXferReset (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_SETUPFILEXFER/MSG_SET */
|
||||
TW_UINT16 GPHOTO2_SetupFileXferSet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_SetupFileXfer2Get (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_GETDEFAULT */
|
||||
TW_UINT16 GPHOTO2_SetupFileXfer2GetDefault (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_RESET */
|
||||
TW_UINT16 GPHOTO2_SetupFileXfer2Reset (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_SET */
|
||||
TW_UINT16 GPHOTO2_SetupFileXfer2Set (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_SETUPMEMXFER/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_SetupMemXferGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
pTW_SETUPMEMXFER pSetupMemXfer = (pTW_SETUPMEMXFER)pData;
|
||||
|
||||
TRACE("DG_CONTROL/DAT_SETUPMEMXFER/MSG_GET\n");
|
||||
/* Guessing */
|
||||
pSetupMemXfer->MinBufSize = 20000;
|
||||
pSetupMemXfer->MaxBufSize = 80000;
|
||||
pSetupMemXfer->Preferred = 40000;
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_STATUS/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_GetDSStatus (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
pTW_STATUS pSourceStatus = (pTW_STATUS) pData;
|
||||
|
||||
TRACE ("DG_CONTROL/DAT_STATUS/MSG_GET\n");
|
||||
pSourceStatus->ConditionCode = activeDS.twCC;
|
||||
/* Reset the condition code */
|
||||
activeDS.twCC = TWCC_SUCCESS;
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_USERINTERFACE/MSG_DISABLEDS */
|
||||
TW_UINT16 GPHOTO2_DisableDSUserInterface (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
TRACE ("DG_CONTROL/DAT_USERINTERFACE/MSG_DISABLEDS\n");
|
||||
|
||||
if (activeDS.currentState != 5) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
activeDS.currentState = 4;
|
||||
activeDS.twCC = TWCC_SUCCESS;
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDS */
|
||||
TW_UINT16 GPHOTO2_EnableDSUserInterface (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
pTW_USERINTERFACE pUserInterface = (pTW_USERINTERFACE) pData;
|
||||
|
||||
load_filesystem("/");
|
||||
|
||||
TRACE ("DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDS\n");
|
||||
if (activeDS.currentState != 4) {
|
||||
FIXME("Sequence error %d\n", activeDS.currentState);
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
activeDS.hwndOwner = pUserInterface->hParent;
|
||||
if (pUserInterface->ShowUI)
|
||||
{
|
||||
BOOL rc;
|
||||
activeDS.currentState = 5; /* Transitions to state 5 */
|
||||
rc = DoCameraUI();
|
||||
if (!rc) {
|
||||
activeDS.pendingEvent.TWMessage = MSG_CLOSEDSREQ;
|
||||
} else {
|
||||
/* FIXME: The GUI should have marked the files to download... */
|
||||
activeDS.pendingEvent.TWMessage = MSG_XFERREADY;
|
||||
activeDS.currentState = 6; /* Transitions to state 6 directly */
|
||||
}
|
||||
} else {
|
||||
/* no UI will be displayed, so source is ready to transfer data */
|
||||
activeDS.pendingEvent.TWMessage = MSG_XFERREADY;
|
||||
activeDS.currentState = 6; /* Transitions to state 6 directly */
|
||||
}
|
||||
activeDS.hwndOwner = pUserInterface->hParent;
|
||||
activeDS.twCC = TWCC_SUCCESS;
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDSUIONLY */
|
||||
TW_UINT16 GPHOTO2_EnableDSUIOnly (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
TRACE("DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDSUIONLY\n");
|
||||
|
||||
if (activeDS.currentState != 4) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
/* FIXME: we should replace xscanimage with our own UI */
|
||||
FIXME ("not implemented!\n");
|
||||
activeDS.currentState = 5;
|
||||
activeDS.twCC = TWCC_SUCCESS;
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_XFERGROUP/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_XferGroupGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_CONTROL/DAT_XFERGROUP/MSG_SET */
|
||||
TW_UINT16 GPHOTO2_XferGroupSet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
return TWRC_FAILURE;
|
||||
}
|
|
@ -0,0 +1,673 @@
|
|||
/*
|
||||
* Copyright 2000 Corel Corporation
|
||||
* Copyright 2006 Marcus Meissner
|
||||
* Copyright 2006 CodeWeavers, Aric Stewart
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
#include "wine/library.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
#include "twain.h"
|
||||
#include "gphoto2_i.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(twain);
|
||||
|
||||
#ifdef HAVE_GPHOTO2
|
||||
static void *libjpeg_handle;
|
||||
#define MAKE_FUNCPTR(f) static typeof(f) * p##f
|
||||
MAKE_FUNCPTR(jpeg_std_error);
|
||||
MAKE_FUNCPTR(jpeg_CreateDecompress);
|
||||
MAKE_FUNCPTR(jpeg_read_header);
|
||||
MAKE_FUNCPTR(jpeg_start_decompress);
|
||||
MAKE_FUNCPTR(jpeg_read_scanlines);
|
||||
MAKE_FUNCPTR(jpeg_finish_decompress);
|
||||
MAKE_FUNCPTR(jpeg_destroy_decompress);
|
||||
#undef MAKE_FUNCPTR
|
||||
|
||||
static void *load_libjpeg(void)
|
||||
{
|
||||
if((libjpeg_handle = wine_dlopen(SONAME_LIBJPEG, RTLD_NOW, NULL, 0)) != NULL) {
|
||||
|
||||
#define LOAD_FUNCPTR(f) \
|
||||
if((p##f = wine_dlsym(libjpeg_handle, #f, NULL, 0)) == NULL) { \
|
||||
libjpeg_handle = NULL; \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
LOAD_FUNCPTR(jpeg_std_error);
|
||||
LOAD_FUNCPTR(jpeg_CreateDecompress);
|
||||
LOAD_FUNCPTR(jpeg_read_header);
|
||||
LOAD_FUNCPTR(jpeg_start_decompress);
|
||||
LOAD_FUNCPTR(jpeg_read_scanlines);
|
||||
LOAD_FUNCPTR(jpeg_finish_decompress);
|
||||
LOAD_FUNCPTR(jpeg_destroy_decompress);
|
||||
#undef LOAD_FUNCPTR
|
||||
}
|
||||
return libjpeg_handle;
|
||||
}
|
||||
|
||||
|
||||
/* for the jpeg decompressor source manager. */
|
||||
static void _jpeg_init_source(j_decompress_ptr cinfo) { }
|
||||
|
||||
static boolean _jpeg_fill_input_buffer(j_decompress_ptr cinfo) {
|
||||
ERR("(), should not get here.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void _jpeg_skip_input_data(j_decompress_ptr cinfo,long num_bytes) {
|
||||
TRACE("Skipping %ld bytes...\n", num_bytes);
|
||||
cinfo->src->next_input_byte += num_bytes;
|
||||
cinfo->src->bytes_in_buffer -= num_bytes;
|
||||
}
|
||||
|
||||
static boolean _jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired) {
|
||||
ERR("(desired=%d), should not get here.\n",desired);
|
||||
return FALSE;
|
||||
}
|
||||
static void _jpeg_term_source(j_decompress_ptr cinfo) { }
|
||||
#endif
|
||||
|
||||
/* DG_IMAGE/DAT_CIECOLOR/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_CIEColorGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_EXTIMAGEINFO/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_ExtImageInfoGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_GRAYRESPONSE/MSG_RESET */
|
||||
TW_UINT16 GPHOTO2_GrayResponseReset (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_GRAYRESPONSE/MSG_SET */
|
||||
TW_UINT16 GPHOTO2_GrayResponseSet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_IMAGEFILEXFER/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_ImageFileXferGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GPHOTO2
|
||||
static TW_UINT16 _get_image_and_startup_jpeg() {
|
||||
const char *folder = NULL, *filename = NULL;
|
||||
struct gphoto2_file *file;
|
||||
const unsigned char *filedata;
|
||||
unsigned long filesize;
|
||||
int ret;
|
||||
|
||||
if (activeDS.file) /* Already loaded. */
|
||||
return TWRC_SUCCESS;
|
||||
|
||||
if(!libjpeg_handle) {
|
||||
if(!load_libjpeg()) {
|
||||
FIXME("Failed reading JPEG because unable to find %s\n", SONAME_LIBJPEG);
|
||||
filedata = NULL;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry ) {
|
||||
if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg")) {
|
||||
filename = file->filename;
|
||||
folder = file->folder;
|
||||
TRACE("downloading %s/%s\n", folder, filename);
|
||||
if (file->download) {
|
||||
file->download = FALSE; /* mark as done */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
gp_file_new (&activeDS.file);
|
||||
ret = gp_camera_file_get(activeDS.camera, folder, filename, GP_FILE_TYPE_NORMAL,
|
||||
activeDS.file, activeDS.context);
|
||||
if (ret < GP_OK) {
|
||||
FIXME("Failed to get file?\n");
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
ret = gp_file_get_data_and_size (activeDS.file, (const char**)&filedata, &filesize);
|
||||
if (ret < GP_OK) {
|
||||
FIXME("Failed to get file data?\n");
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* This is basically so we can use in-memory data for jpeg decompression.
|
||||
* We need to have all the functions.
|
||||
*/
|
||||
activeDS.xjsm.next_input_byte = filedata;
|
||||
activeDS.xjsm.bytes_in_buffer = filesize;
|
||||
activeDS.xjsm.init_source = _jpeg_init_source;
|
||||
activeDS.xjsm.fill_input_buffer = _jpeg_fill_input_buffer;
|
||||
activeDS.xjsm.skip_input_data = _jpeg_skip_input_data;
|
||||
activeDS.xjsm.resync_to_restart = _jpeg_resync_to_restart;
|
||||
activeDS.xjsm.term_source = _jpeg_term_source;
|
||||
|
||||
activeDS.jd.err = pjpeg_std_error(&activeDS.jerr);
|
||||
/* jpeg_create_decompress is a macro that expands to jpeg_CreateDecompress - see jpeglib.h
|
||||
* jpeg_create_decompress(&jd); */
|
||||
pjpeg_CreateDecompress(&activeDS.jd, JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_decompress_struct));
|
||||
activeDS.jd.src = &activeDS.xjsm;
|
||||
ret=pjpeg_read_header(&activeDS.jd,TRUE);
|
||||
activeDS.jd.out_color_space = JCS_RGB;
|
||||
pjpeg_start_decompress(&activeDS.jd);
|
||||
if (ret != JPEG_HEADER_OK) {
|
||||
ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret);
|
||||
gp_file_unref (activeDS.file);
|
||||
activeDS.file = NULL;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* DG_IMAGE/DAT_IMAGEINFO/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_ImageInfoGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
#ifdef HAVE_GPHOTO2
|
||||
pTW_IMAGEINFO pImageInfo = (pTW_IMAGEINFO) pData;
|
||||
|
||||
TRACE("DG_IMAGE/DAT_IMAGEINFO/MSG_GET\n");
|
||||
|
||||
if (activeDS.currentState != 6 && activeDS.currentState != 7) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
if (TWRC_SUCCESS != _get_image_and_startup_jpeg()) {
|
||||
FIXME("Failed to get an image\n");
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
if (activeDS.currentState == 6)
|
||||
{
|
||||
/* return general image description information about the image about to be transferred */
|
||||
TRACE("Getting parameters\n");
|
||||
}
|
||||
TRACE("activeDS.jd.output_width = %d\n", activeDS.jd.output_width);
|
||||
TRACE("activeDS.jd.output_height = %d\n", activeDS.jd.output_height);
|
||||
pImageInfo->Compression = TWCP_NONE;
|
||||
pImageInfo->SamplesPerPixel = 3;
|
||||
pImageInfo->BitsPerSample[0]= 8;
|
||||
pImageInfo->BitsPerSample[1]= 8;
|
||||
pImageInfo->BitsPerSample[2]= 8;
|
||||
pImageInfo->PixelType = TWPT_RGB;
|
||||
pImageInfo->Planar = FALSE; /* R-G-B is chunky! */
|
||||
pImageInfo->XResolution.Whole = -1;
|
||||
pImageInfo->XResolution.Frac = 0;
|
||||
pImageInfo->YResolution.Whole = -1;
|
||||
pImageInfo->YResolution.Frac = 0;
|
||||
pImageInfo->ImageWidth = activeDS.jd.output_width;
|
||||
pImageInfo->ImageLength = activeDS.jd.output_height;
|
||||
pImageInfo->BitsPerPixel = 24;
|
||||
return TWRC_SUCCESS;
|
||||
#else
|
||||
return TWRC_FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_ImageLayoutGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_GETDEFAULT */
|
||||
TW_UINT16 GPHOTO2_ImageLayoutGetDefault (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_RESET */
|
||||
TW_UINT16 GPHOTO2_ImageLayoutReset (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_SET */
|
||||
TW_UINT16 GPHOTO2_ImageLayoutSet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* 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 = TransferingDialogBox(NULL,0);
|
||||
TransferingDialogBox(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;
|
||||
|
||||
TransferingDialogBox(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");
|
||||
|
||||
/*TransferingDialogBox(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
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_IMAGENATIVEXFER/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_ImageNativeXferGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
#ifdef HAVE_GPHOTO2
|
||||
pTW_UINT32 pHandle = (pTW_UINT32) pData;
|
||||
HBITMAP hDIB;
|
||||
BITMAPINFO bmpInfo;
|
||||
LPBYTE bits, oldbits;
|
||||
JSAMPROW samprow, oldsamprow;
|
||||
HDC dc;
|
||||
|
||||
FIXME("DG_IMAGE/DAT_IMAGENATIVEXFER/MSG_GET: implemented, but expect program crash due to DIB.\n");
|
||||
|
||||
/* NOTE NOTE NOTE NOTE NOTE NOTE NOTE
|
||||
*
|
||||
* While this is a mandatory transfer mode and this function
|
||||
* is correctly implemented and fully works, the calling program
|
||||
* will likely crash after calling.
|
||||
*
|
||||
* Reason is that there is a lot of example code that does:
|
||||
* bmpinfo = (LPBITMAPINFOHEADER)GlobalLock(hBITMAP); ... pointer access to bmpinfo
|
||||
*
|
||||
* Our current HBITMAP handles do not support getting GlobalLocked -> App Crash
|
||||
*
|
||||
* This needs a GDI Handle rewrite, at least for DIB sections.
|
||||
* - Marcus
|
||||
*/
|
||||
if (activeDS.currentState != 6) {
|
||||
activeDS.twCC = TWCC_SEQERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
if (TWRC_SUCCESS != _get_image_and_startup_jpeg()) {
|
||||
FIXME("Failed to get an image\n");
|
||||
activeDS.twCC = TWCC_OPERATIONERROR;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
TRACE("Acquiring image %dx%dx%d bits from gphoto.\n",
|
||||
activeDS.jd.output_width, activeDS.jd.output_height,
|
||||
activeDS.jd.output_components*8);
|
||||
ZeroMemory (&bmpInfo, sizeof (BITMAPINFO));
|
||||
bmpInfo.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
|
||||
bmpInfo.bmiHeader.biWidth = activeDS.jd.output_width;
|
||||
bmpInfo.bmiHeader.biHeight = -activeDS.jd.output_height;
|
||||
bmpInfo.bmiHeader.biPlanes = 1;
|
||||
bmpInfo.bmiHeader.biBitCount = activeDS.jd.output_components*8;
|
||||
bmpInfo.bmiHeader.biCompression = BI_RGB;
|
||||
bmpInfo.bmiHeader.biSizeImage = 0;
|
||||
bmpInfo.bmiHeader.biXPelsPerMeter = 0;
|
||||
bmpInfo.bmiHeader.biYPelsPerMeter = 0;
|
||||
bmpInfo.bmiHeader.biClrUsed = 0;
|
||||
bmpInfo.bmiHeader.biClrImportant = 0;
|
||||
hDIB = CreateDIBSection ((dc = GetDC(activeDS.hwndOwner)), &bmpInfo,
|
||||
DIB_RGB_COLORS, (LPVOID)&bits, 0, 0);
|
||||
if (!hDIB) {
|
||||
FIXME("Failed creating DIB.\n");
|
||||
gp_file_unref (activeDS.file);
|
||||
activeDS.file = NULL;
|
||||
activeDS.twCC = TWCC_LOWMEMORY;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
samprow = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,activeDS.jd.output_width*activeDS.jd.output_components);
|
||||
oldbits = bits;
|
||||
oldsamprow = samprow;
|
||||
while ( activeDS.jd.output_scanline<activeDS.jd.output_height ) {
|
||||
int i, x = pjpeg_read_scanlines(&activeDS.jd,&samprow,1);
|
||||
if (x != 1) {
|
||||
FIXME("failed to read current scanline?\n");
|
||||
break;
|
||||
}
|
||||
/* We have to convert from RGB to BGR, see MSDN/ BITMAPINFOHEADER */
|
||||
for(i=0;i<activeDS.jd.output_width;i++,samprow+=activeDS.jd.output_components) {
|
||||
*(bits++) = *(samprow+2);
|
||||
*(bits++) = *(samprow+1);
|
||||
*(bits++) = *(samprow);
|
||||
}
|
||||
bits = (LPBYTE)(((UINT_PTR)bits + 3) & ~3);
|
||||
samprow = oldsamprow;
|
||||
}
|
||||
bits = oldbits;
|
||||
HeapFree (GetProcessHeap(), 0, samprow);
|
||||
gp_file_unref (activeDS.file);
|
||||
activeDS.file = NULL;
|
||||
ReleaseDC (activeDS.hwndOwner, dc);
|
||||
*pHandle = (TW_UINT32)hDIB;
|
||||
activeDS.twCC = TWCC_SUCCESS;
|
||||
activeDS.currentState = 7;
|
||||
return TWRC_XFERDONE;
|
||||
#else
|
||||
return TWRC_FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_JPEGCompressionGet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_GETDEFAULT */
|
||||
TW_UINT16 GPHOTO2_JPEGCompressionGetDefault (pTW_IDENTITY pOrigin,
|
||||
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_RESET */
|
||||
TW_UINT16 GPHOTO2_JPEGCompressionReset (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_SET */
|
||||
TW_UINT16 GPHOTO2_JPEGCompressionSet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_PALETTE8/MSG_GET */
|
||||
TW_UINT16 GPHOTO2_Palette8Get (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_PALETTE8/MSG_GETDEFAULT */
|
||||
TW_UINT16 GPHOTO2_Palette8GetDefault (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_PALETTE8/MSG_RESET */
|
||||
TW_UINT16 GPHOTO2_Palette8Reset (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_PALETTE8/MSG_SET */
|
||||
TW_UINT16 GPHOTO2_Palette8Set (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_RGBRESPONSE/MSG_RESET */
|
||||
TW_UINT16 GPHOTO2_RGBResponseReset (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* DG_IMAGE/DAT_RGBRESPONSE/MSG_SET */
|
||||
TW_UINT16 GPHOTO2_RGBResponseSet (pTW_IDENTITY pOrigin,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
FIXME ("stub!\n");
|
||||
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GPHOTO2
|
||||
TW_UINT16
|
||||
_get_gphoto2_file_as_DIB(
|
||||
const char *folder, const char *filename, CameraFileType type,
|
||||
HWND hwnd, HBITMAP *hDIB
|
||||
) {
|
||||
const unsigned char *filedata;
|
||||
unsigned long filesize;
|
||||
int ret;
|
||||
CameraFile *file;
|
||||
struct jpeg_source_mgr xjsm;
|
||||
struct jpeg_decompress_struct jd;
|
||||
struct jpeg_error_mgr jerr;
|
||||
HDC dc;
|
||||
BITMAPINFO bmpInfo;
|
||||
LPBYTE bits, oldbits;
|
||||
JSAMPROW samprow, oldsamprow;
|
||||
|
||||
if(!libjpeg_handle) {
|
||||
if(!load_libjpeg()) {
|
||||
FIXME("Failed reading JPEG because unable to find %s\n", SONAME_LIBJPEG);
|
||||
filedata = NULL;
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
gp_file_new (&file);
|
||||
ret = gp_camera_file_get(activeDS.camera, folder, filename, type, file, activeDS.context);
|
||||
if (ret < GP_OK) {
|
||||
FIXME("Failed to get file?\n");
|
||||
gp_file_unref (file);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
ret = gp_file_get_data_and_size (file, (const char**)&filedata, &filesize);
|
||||
if (ret < GP_OK) {
|
||||
FIXME("Failed to get file data?\n");
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
/* FIXME: Actually we might get other types than JPEG ... But only handle JPEG for now */
|
||||
if (filedata[0] != 0xff) {
|
||||
ERR("File %s/%s might not be JPEG, cannot decode!\n", folder, filename);
|
||||
}
|
||||
|
||||
/* This is basically so we can use in-memory data for jpeg decompression.
|
||||
* We need to have all the functions.
|
||||
*/
|
||||
xjsm.next_input_byte = filedata;
|
||||
xjsm.bytes_in_buffer = filesize;
|
||||
xjsm.init_source = _jpeg_init_source;
|
||||
xjsm.fill_input_buffer = _jpeg_fill_input_buffer;
|
||||
xjsm.skip_input_data = _jpeg_skip_input_data;
|
||||
xjsm.resync_to_restart = _jpeg_resync_to_restart;
|
||||
xjsm.term_source = _jpeg_term_source;
|
||||
|
||||
jd.err = pjpeg_std_error(&jerr);
|
||||
/* jpeg_create_decompress is a macro that expands to jpeg_CreateDecompress - see jpeglib.h
|
||||
* jpeg_create_decompress(&jd); */
|
||||
pjpeg_CreateDecompress(&jd, JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_decompress_struct));
|
||||
jd.src = &xjsm;
|
||||
ret=pjpeg_read_header(&jd,TRUE);
|
||||
jd.out_color_space = JCS_RGB;
|
||||
pjpeg_start_decompress(&jd);
|
||||
if (ret != JPEG_HEADER_OK) {
|
||||
ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret);
|
||||
gp_file_unref (file);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
ZeroMemory (&bmpInfo, sizeof (BITMAPINFO));
|
||||
bmpInfo.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
|
||||
bmpInfo.bmiHeader.biWidth = jd.output_width;
|
||||
bmpInfo.bmiHeader.biHeight = -jd.output_height;
|
||||
bmpInfo.bmiHeader.biPlanes = 1;
|
||||
bmpInfo.bmiHeader.biBitCount = jd.output_components*8;
|
||||
bmpInfo.bmiHeader.biCompression = BI_RGB;
|
||||
bmpInfo.bmiHeader.biSizeImage = 0;
|
||||
bmpInfo.bmiHeader.biXPelsPerMeter = 0;
|
||||
bmpInfo.bmiHeader.biYPelsPerMeter = 0;
|
||||
bmpInfo.bmiHeader.biClrUsed = 0;
|
||||
bmpInfo.bmiHeader.biClrImportant = 0;
|
||||
*hDIB = CreateDIBSection ((dc = GetDC(hwnd)), &bmpInfo, DIB_RGB_COLORS, (LPVOID)&bits, 0, 0);
|
||||
if (!*hDIB) {
|
||||
FIXME("Failed creating DIB.\n");
|
||||
gp_file_unref (file);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
samprow = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,jd.output_width*jd.output_components);
|
||||
oldbits = bits;
|
||||
oldsamprow = samprow;
|
||||
while ( jd.output_scanline<jd.output_height ) {
|
||||
int i, x = pjpeg_read_scanlines(&jd,&samprow,1);
|
||||
if (x != 1) {
|
||||
FIXME("failed to read current scanline?\n");
|
||||
break;
|
||||
}
|
||||
/* We have to convert from RGB to BGR, see MSDN/ BITMAPINFOHEADER */
|
||||
for(i=0;i<jd.output_width;i++,samprow+=jd.output_components) {
|
||||
*(bits++) = *(samprow+2);
|
||||
*(bits++) = *(samprow+1);
|
||||
*(bits++) = *(samprow);
|
||||
}
|
||||
bits = (LPBYTE)(((UINT_PTR)bits + 3) & ~3);
|
||||
samprow = oldsamprow;
|
||||
}
|
||||
if (hwnd) ReleaseDC (hwnd, dc);
|
||||
HeapFree (GetProcessHeap(), 0, samprow);
|
||||
gp_file_unref (file);
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1 @@
|
|||
@ stdcall DS_Entry(ptr long long long ptr)
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* English resources for Twain
|
||||
*
|
||||
* Copyright 2006 CodeWeavers, Aric Stewart
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
|
||||
|
||||
IDD_CAMERAUI DIALOG DISCARDABLE 0, 0, 372, 273
|
||||
STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP | WS_VISIBLE |
|
||||
WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Files on Camera"
|
||||
MENU 20545
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CONTROL "List1",IDC_LIST1,"SysListView32", LVS_ICON | WS_BORDER |
|
||||
WS_TABSTOP,7,7,358,229
|
||||
DEFPUSHBUTTON "Import Selected",IDC_IMPORT,225,252,56,14
|
||||
PUSHBUTTON "Import All",IDC_IMPORTALL,7,252,52,14
|
||||
PUSHBUTTON "Exit",IDC_EXIT,295,252,50,14
|
||||
END
|
||||
|
||||
IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 186, 46
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_CENTER | DS_SETFOREGROUND
|
||||
CAPTION "Transferring"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Transferring.... Please Wait",IDC_STATIC,53,19,85,8
|
||||
END
|
||||
|
||||
IDD_CONNECTING DIALOG DISCARDABLE 0, 0, 280, 116
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU| WS_VISIBLE | DS_CENTER
|
||||
CAPTION "Connecting to camera"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CONTROL "",IDC_BITMAP,"Static",SS_BITMAP|SS_CENTERIMAGE,4,4,110,110
|
||||
LTEXT "Connecting to camera... Please Wait",IDC_STATIC,128,58,
|
||||
116,8
|
||||
END
|
|
@ -0,0 +1,260 @@
|
|||
/*
|
||||
* Copyright 2000 Corel Corporation
|
||||
* Copyright 2006 Marcus Meissner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _TWAIN32_H
|
||||
#define _TWAIN32_H
|
||||
|
||||
#ifndef __WINE_CONFIG_H
|
||||
# error You must include config.h first
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_JPEGLIB_H)
|
||||
# warning "ghoto2 in twain needs jpeg development headers"
|
||||
# undef HAVE_GPHOTO2
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GPHOTO2
|
||||
/* Hack for gphoto2, who changes behaviour when WIN32 is set. */
|
||||
#undef WIN32
|
||||
#include <gphoto2/gphoto2-camera.h>
|
||||
#define WIN32
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_JPEGLIB_H
|
||||
/* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
|
||||
# define XMD_H
|
||||
# define UINT8 JPEG_UINT8
|
||||
# define UINT16 JPEG_UINT16
|
||||
# undef FAR
|
||||
# include <jpeglib.h>
|
||||
# undef UINT16
|
||||
# ifndef SONAME_LIBJPEG
|
||||
# define SONAME_LIBJPEG "libjpeg.so"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "twain.h"
|
||||
|
||||
#include "wine/list.h"
|
||||
|
||||
extern HINSTANCE GPHOTO2_instance;
|
||||
|
||||
struct gphoto2_file {
|
||||
struct list entry;
|
||||
|
||||
char *folder;
|
||||
char *filename;
|
||||
BOOL download; /* flag for downloading, set by GUI or so */
|
||||
};
|
||||
|
||||
/* internal information about an active data source */
|
||||
struct tagActiveDS
|
||||
{
|
||||
TW_IDENTITY identity; /* identity */
|
||||
TW_UINT16 currentState; /* current state */
|
||||
TW_EVENT pendingEvent; /* pending event to be sent to
|
||||
application */
|
||||
TW_UINT16 twCC; /* condition code */
|
||||
HWND hwndOwner; /* window handle of the app */
|
||||
HWND progressWnd; /* window handle of the scanning window */
|
||||
|
||||
#ifdef HAVE_GPHOTO2
|
||||
Camera *camera;
|
||||
GPContext *context;
|
||||
#endif
|
||||
|
||||
/* Capabiblities */
|
||||
TW_UINT32 capXferMech; /* ICAP_XFERMECH */
|
||||
TW_UINT16 pixeltype; /* ICAP_PIXELTYPE */
|
||||
TW_UINT16 pixelflavor; /* ICAP_PIXELFLAVOR */
|
||||
|
||||
struct list files;
|
||||
|
||||
/* Download and decode JPEG STATE */
|
||||
#ifdef HAVE_GPHOTO2
|
||||
CameraFile *file;
|
||||
#endif
|
||||
#ifdef HAVE_JPEGLIB_H
|
||||
struct jpeg_source_mgr xjsm;
|
||||
struct jpeg_decompress_struct jd;
|
||||
struct jpeg_error_mgr jerr;
|
||||
#endif
|
||||
} activeDS;
|
||||
|
||||
/* Helper functions */
|
||||
extern TW_UINT16 GPHOTO2_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action);
|
||||
|
||||
/* */
|
||||
extern TW_UINT16 GPHOTO2_ControlGroupHandler (
|
||||
pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
|
||||
extern TW_UINT16 GPHOTO2_ImageGroupHandler (
|
||||
pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
|
||||
extern TW_UINT16 GPHOTO2_AudioGroupHandler (
|
||||
pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
|
||||
extern TW_UINT16 GPHOTO2_SourceManagerHandler (
|
||||
pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
|
||||
|
||||
/* Implementation of operation triplets
|
||||
* From Application to Source (Control Information) */
|
||||
TW_UINT16 GPHOTO2_CapabilityGet (pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_CapabilityGetCurrent
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_CapabilityGetDefault
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_CapabilityQuerySupport
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_CapabilityReset
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_CapabilitySet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_CustomDSDataGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_CustomDSDataSet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_AutomaticCaptureDirectory
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ChangeDirectory
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_FileSystemCopy
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_CreateDirectory
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_FileSystemDelete
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_FormatMedia
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_FileSystemGetClose
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_FileSystemGetFirstFile
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_FileSystemGetInfo
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_FileSystemGetNextFile
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_FileSystemRename
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ProcessEvent
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_PassThrough
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_PendingXfersEndXfer
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_PendingXfersGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_PendingXfersReset
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_PendingXfersStopFeeder
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_SetupFileXferGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_SetupFileXferGetDefault
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_SetupFileXferReset
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_SetupFileXferSet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_SetupFileXfer2Get
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_SetupFileXfer2GetDefault
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_SetupFileXfer2Reset
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_SetupFileXfer2Set
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_SetupMemXferGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_GetDSStatus
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_DisableDSUserInterface
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_EnableDSUserInterface
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_EnableDSUIOnly
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_XferGroupGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_XferGroupSet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
|
||||
/* Implementation of operation triplets
|
||||
* From Application to Source (Image Information) */
|
||||
TW_UINT16 GPHOTO2_CIEColorGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ExtImageInfoGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_GrayResponseReset
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_GrayResponseSet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ImageFileXferGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ImageInfoGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ImageLayoutGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ImageLayoutGetDefault
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ImageLayoutReset
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ImageLayoutSet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ImageMemXferGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_ImageNativeXferGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_JPEGCompressionGet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_JPEGCompressionGetDefault
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_JPEGCompressionReset
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_JPEGCompressionSet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_Palette8Get
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_Palette8GetDefault
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_Palette8Reset
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_Palette8Set
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_RGBResponseReset
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
TW_UINT16 GPHOTO2_RGBResponseSet
|
||||
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
|
||||
|
||||
/* UI function */
|
||||
BOOL DoCameraUI();
|
||||
HWND TransferingDialogBox(HWND dialog, DWORD progress);
|
||||
|
||||
#ifdef HAVE_GPHOTO2
|
||||
/* Helper function for GUI */
|
||||
TW_UINT16
|
||||
_get_gphoto2_file_as_DIB(
|
||||
const char *folder, const char *filename, CameraFileType type,
|
||||
HWND hwnd, HBITMAP *hDIB
|
||||
);
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,676 @@
|
|||
/*
|
||||
* SANE.DS functions
|
||||
*
|
||||
* Copyright 2000 Shi Quan He <shiquan@cyberdude.com>
|
||||
* Copyright 2006 Marcus Meissner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "twain.h"
|
||||
#include "gphoto2_i.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(twain);
|
||||
|
||||
HINSTANCE GPHOTO2_instance;
|
||||
|
||||
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
|
||||
|
||||
switch (fdwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
GPHOTO2_instance = hinstDLL;
|
||||
DisableThreadLibraryCalls(hinstDLL);
|
||||
#ifdef HAVE_GPHOTO2
|
||||
activeDS.context = gp_context_new ();
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
GPHOTO2_instance = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GPHOTO2
|
||||
static TW_UINT16 GPHOTO2_GetIdentity( pTW_IDENTITY, pTW_IDENTITY);
|
||||
static TW_UINT16 GPHOTO2_OpenDS( pTW_IDENTITY, pTW_IDENTITY);
|
||||
#endif
|
||||
|
||||
TW_UINT16 GPHOTO2_SourceControlHandler (
|
||||
pTW_IDENTITY pOrigin,
|
||||
TW_UINT16 DAT,
|
||||
TW_UINT16 MSG,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
TW_UINT16 twRC = TWRC_SUCCESS;
|
||||
|
||||
switch (DAT)
|
||||
{
|
||||
case DAT_IDENTITY:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_CLOSEDS:
|
||||
#ifdef HAVE_GPHOTO2
|
||||
if (activeDS.camera) {
|
||||
gp_camera_free (activeDS.camera);
|
||||
activeDS.camera = NULL;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case MSG_GET:
|
||||
#ifdef HAVE_GPHOTO2
|
||||
twRC = GPHOTO2_GetIdentity(pOrigin,(pTW_IDENTITY)pData);
|
||||
#else
|
||||
twRC = TWRC_FAILURE;
|
||||
#endif
|
||||
break;
|
||||
case MSG_OPENDS:
|
||||
#ifdef HAVE_GPHOTO2
|
||||
twRC = GPHOTO2_OpenDS(pOrigin,(pTW_IDENTITY)pData);
|
||||
#else
|
||||
twRC = TWRC_FAILURE;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DAT_CAPABILITY:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_GET:
|
||||
twRC = GPHOTO2_CapabilityGet (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETCURRENT:
|
||||
twRC = GPHOTO2_CapabilityGetCurrent (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
twRC = GPHOTO2_CapabilityGetDefault (pOrigin, pData);
|
||||
break;
|
||||
case MSG_QUERYSUPPORT:
|
||||
twRC = GPHOTO2_CapabilityQuerySupport (pOrigin, pData);
|
||||
break;
|
||||
case MSG_RESET:
|
||||
twRC = GPHOTO2_CapabilityReset (pOrigin, pData);
|
||||
break;
|
||||
case MSG_SET:
|
||||
twRC = GPHOTO2_CapabilitySet (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
FIXME("unrecognized opertion triplet\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case DAT_CUSTOMDSDATA:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_GET:
|
||||
twRC = GPHOTO2_CustomDSDataGet (pOrigin, pData);
|
||||
break;
|
||||
case MSG_SET:
|
||||
twRC = GPHOTO2_CustomDSDataSet (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case DAT_FILESYSTEM:
|
||||
switch (MSG)
|
||||
{
|
||||
/*case MSG_AUTOMATICCAPTUREDIRECTORY:
|
||||
twRC = GPHOTO2_AutomaticCaptureDirectory
|
||||
(pOrigin, pData);
|
||||
break;*/
|
||||
case MSG_CHANGEDIRECTORY:
|
||||
twRC = GPHOTO2_ChangeDirectory (pOrigin, pData);
|
||||
break;
|
||||
/*case MSG_COPY:
|
||||
twRC = GPHOTO2_FileSystemCopy (pOrigin, pData);
|
||||
break;*/
|
||||
case MSG_CREATEDIRECTORY:
|
||||
twRC = GPHOTO2_CreateDirectory (pOrigin, pData);
|
||||
break;
|
||||
case MSG_DELETE:
|
||||
twRC = GPHOTO2_FileSystemDelete (pOrigin, pData);
|
||||
break;
|
||||
case MSG_FORMATMEDIA:
|
||||
twRC = GPHOTO2_FormatMedia (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETCLOSE:
|
||||
twRC = GPHOTO2_FileSystemGetClose (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETFIRSTFILE:
|
||||
twRC = GPHOTO2_FileSystemGetFirstFile (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETINFO:
|
||||
twRC = GPHOTO2_FileSystemGetInfo (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETNEXTFILE:
|
||||
twRC = GPHOTO2_FileSystemGetNextFile (pOrigin, pData);
|
||||
break;
|
||||
case MSG_RENAME:
|
||||
twRC = GPHOTO2_FileSystemRename (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case DAT_EVENT:
|
||||
if (MSG == MSG_PROCESSEVENT)
|
||||
twRC = GPHOTO2_ProcessEvent (pOrigin, pData);
|
||||
else
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
|
||||
case DAT_PASSTHRU:
|
||||
if (MSG == MSG_PASSTHRU)
|
||||
twRC = GPHOTO2_PassThrough (pOrigin, pData);
|
||||
else
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
|
||||
case DAT_PENDINGXFERS:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_ENDXFER:
|
||||
twRC = GPHOTO2_PendingXfersEndXfer (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GET:
|
||||
twRC = GPHOTO2_PendingXfersGet (pOrigin, pData);
|
||||
break;
|
||||
case MSG_RESET:
|
||||
twRC = GPHOTO2_PendingXfersReset (pOrigin, pData);
|
||||
break;
|
||||
/*case MSG_STOPFEEDER:
|
||||
twRC = GPHOTO2_PendingXfersStopFeeder (pOrigin, pData);
|
||||
break;*/
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
}
|
||||
break;
|
||||
|
||||
case DAT_SETUPFILEXFER:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_GET:
|
||||
twRC = GPHOTO2_SetupFileXferGet (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
twRC = GPHOTO2_SetupFileXferGetDefault (pOrigin, pData);
|
||||
break;
|
||||
case MSG_RESET:
|
||||
twRC = GPHOTO2_SetupFileXferReset (pOrigin, pData);
|
||||
break;
|
||||
case MSG_SET:
|
||||
twRC = GPHOTO2_SetupFileXferSet (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
/*case DAT_SETUPFILEXFER2:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_GET:
|
||||
twRC = GPHOTO2_SetupFileXfer2Get (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
twRC = GPHOTO2_SetupFileXfer2GetDefault (pOrigin, pData);
|
||||
break;
|
||||
case MSG_RESET:
|
||||
twRC = GPHOTO2_SetupFileXfer2Reset (pOrigin, pData);
|
||||
break;
|
||||
case MSG_SET:
|
||||
twRC = GPHOTO2_SetupFileXfer2Set (pOrigin, pData);
|
||||
break;
|
||||
}
|
||||
break;*/
|
||||
case DAT_SETUPMEMXFER:
|
||||
if (MSG == MSG_GET)
|
||||
twRC = GPHOTO2_SetupMemXferGet (pOrigin, pData);
|
||||
else
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
|
||||
case DAT_STATUS:
|
||||
if (MSG == MSG_GET)
|
||||
twRC = GPHOTO2_GetDSStatus (pOrigin, pData);
|
||||
else
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
|
||||
case DAT_USERINTERFACE:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_DISABLEDS:
|
||||
twRC = GPHOTO2_DisableDSUserInterface (pOrigin, pData);
|
||||
break;
|
||||
case MSG_ENABLEDS:
|
||||
twRC = GPHOTO2_EnableDSUserInterface (pOrigin, pData);
|
||||
break;
|
||||
case MSG_ENABLEDSUIONLY:
|
||||
twRC = GPHOTO2_EnableDSUIOnly (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case DAT_XFERGROUP:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_GET:
|
||||
twRC = GPHOTO2_XferGroupGet (pOrigin, pData);
|
||||
break;
|
||||
case MSG_SET:
|
||||
twRC = GPHOTO2_XferGroupSet (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("code unknown: %d\n", DAT);
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
return twRC;
|
||||
}
|
||||
|
||||
|
||||
TW_UINT16 GPHOTO2_ImageGroupHandler (
|
||||
pTW_IDENTITY pOrigin,
|
||||
TW_UINT16 DAT,
|
||||
TW_UINT16 MSG,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
TW_UINT16 twRC = TWRC_SUCCESS;
|
||||
|
||||
switch (DAT)
|
||||
{
|
||||
case DAT_CIECOLOR:
|
||||
if (MSG == MSG_GET)
|
||||
twRC = GPHOTO2_CIEColorGet (pOrigin, pData);
|
||||
else
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
|
||||
case DAT_EXTIMAGEINFO:
|
||||
if (MSG == MSG_GET)
|
||||
twRC = GPHOTO2_ExtImageInfoGet (pOrigin, pData);
|
||||
else
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
|
||||
case DAT_GRAYRESPONSE:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_RESET:
|
||||
twRC = GPHOTO2_GrayResponseReset (pOrigin, pData);
|
||||
break;
|
||||
case MSG_SET:
|
||||
twRC = GPHOTO2_GrayResponseSet (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
activeDS.twCC = TWCC_BADPROTOCOL;
|
||||
FIXME("unrecognized operation triplet\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DAT_IMAGEFILEXFER:
|
||||
if (MSG == MSG_GET)
|
||||
twRC = GPHOTO2_ImageFileXferGet (pOrigin, pData);
|
||||
else
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
|
||||
case DAT_IMAGEINFO:
|
||||
if (MSG == MSG_GET)
|
||||
twRC = GPHOTO2_ImageInfoGet (pOrigin, pData);
|
||||
else
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
|
||||
case DAT_IMAGELAYOUT:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_GET:
|
||||
twRC = GPHOTO2_ImageLayoutGet (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
twRC = GPHOTO2_ImageLayoutGetDefault (pOrigin, pData);
|
||||
break;
|
||||
case MSG_RESET:
|
||||
twRC = GPHOTO2_ImageLayoutReset (pOrigin, pData);
|
||||
break;
|
||||
case MSG_SET:
|
||||
twRC = GPHOTO2_ImageLayoutSet (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
activeDS.twCC = TWCC_BADPROTOCOL;
|
||||
ERR("unrecognized operation triplet\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case DAT_IMAGEMEMXFER:
|
||||
if (MSG == MSG_GET)
|
||||
twRC = GPHOTO2_ImageMemXferGet (pOrigin, pData);
|
||||
else
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
|
||||
case DAT_IMAGENATIVEXFER:
|
||||
if (MSG == MSG_GET)
|
||||
twRC = GPHOTO2_ImageNativeXferGet (pOrigin, pData);
|
||||
else
|
||||
twRC = TWRC_FAILURE;
|
||||
break;
|
||||
|
||||
case DAT_JPEGCOMPRESSION:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_GET:
|
||||
twRC = GPHOTO2_JPEGCompressionGet (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
twRC = GPHOTO2_JPEGCompressionGetDefault (pOrigin, pData);
|
||||
break;
|
||||
case MSG_RESET:
|
||||
twRC = GPHOTO2_JPEGCompressionReset (pOrigin, pData);
|
||||
break;
|
||||
case MSG_SET:
|
||||
twRC = GPHOTO2_JPEGCompressionSet (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
activeDS.twCC = TWCC_BADPROTOCOL;
|
||||
WARN("unrecognized operation triplet\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case DAT_PALETTE8:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_GET:
|
||||
twRC = GPHOTO2_Palette8Get (pOrigin, pData);
|
||||
break;
|
||||
case MSG_GETDEFAULT:
|
||||
twRC = GPHOTO2_Palette8GetDefault (pOrigin, pData);
|
||||
break;
|
||||
case MSG_RESET:
|
||||
twRC = GPHOTO2_Palette8Reset (pOrigin, pData);
|
||||
break;
|
||||
case MSG_SET:
|
||||
twRC = GPHOTO2_Palette8Set (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
activeDS.twCC = TWCC_BADPROTOCOL;
|
||||
WARN("unrecognized operation triplet\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case DAT_RGBRESPONSE:
|
||||
switch (MSG)
|
||||
{
|
||||
case MSG_RESET:
|
||||
twRC = GPHOTO2_RGBResponseReset (pOrigin, pData);
|
||||
break;
|
||||
case MSG_SET:
|
||||
twRC = GPHOTO2_RGBResponseSet (pOrigin, pData);
|
||||
break;
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
activeDS.twCC = TWCC_BADPROTOCOL;
|
||||
WARN("unrecognized operation triplet\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
twRC = TWRC_FAILURE;
|
||||
activeDS.twCC = TWCC_BADPROTOCOL;
|
||||
FIXME("unrecognized DG type %d\n", DAT);
|
||||
}
|
||||
return twRC;
|
||||
}
|
||||
|
||||
/* Main entry point for the TWAIN library */
|
||||
TW_UINT16 WINAPI
|
||||
DS_Entry ( pTW_IDENTITY pOrigin,
|
||||
TW_UINT32 DG,
|
||||
TW_UINT16 DAT,
|
||||
TW_UINT16 MSG,
|
||||
TW_MEMREF pData)
|
||||
{
|
||||
TW_UINT16 twRC = TWRC_SUCCESS; /* Return Code */
|
||||
|
||||
TRACE("(DG=%ld DAT=%d MSG=%d)\n", DG, DAT, MSG);
|
||||
|
||||
switch (DG)
|
||||
{
|
||||
case DG_CONTROL:
|
||||
twRC = GPHOTO2_SourceControlHandler (pOrigin,DAT,MSG,pData);
|
||||
break;
|
||||
case DG_IMAGE:
|
||||
twRC = GPHOTO2_ImageGroupHandler (pOrigin,DAT,MSG,pData);
|
||||
break;
|
||||
case DG_AUDIO:
|
||||
FIXME("The audio group of entry codes is not implemented.\n");
|
||||
default:
|
||||
activeDS.twCC = TWCC_BADPROTOCOL;
|
||||
twRC = TWRC_FAILURE;
|
||||
}
|
||||
|
||||
return twRC;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GPHOTO2
|
||||
static GPPortInfoList *port_list;
|
||||
static int curcamera;
|
||||
static CameraList *detected_cameras;
|
||||
static CameraAbilitiesList *abilities_list;
|
||||
|
||||
static TW_UINT16
|
||||
gphoto2_auto_detect() {
|
||||
int result, count;
|
||||
|
||||
if (detected_cameras && (gp_list_count (detected_cameras) == 0)) {
|
||||
/* Reload if previously no cameras, we might detect new ones. */
|
||||
TRACE("Reloading portlist trying to detect cameras.\n");
|
||||
if (port_list) {
|
||||
gp_port_info_list_free (port_list);
|
||||
port_list = NULL;
|
||||
}
|
||||
}
|
||||
if (!port_list) {
|
||||
TRACE("Auto detecting gphoto cameras.\n");
|
||||
TRACE("Loading ports...\n");
|
||||
if (gp_port_info_list_new (&port_list) < GP_OK)
|
||||
return TWRC_FAILURE;
|
||||
result = gp_port_info_list_load (port_list);
|
||||
if (result < 0) {
|
||||
gp_port_info_list_free (port_list);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
count = gp_port_info_list_count (port_list);
|
||||
if (count <= 0)
|
||||
return TWRC_FAILURE;
|
||||
if (gp_list_new (&detected_cameras) < GP_OK)
|
||||
return TWRC_FAILURE;
|
||||
if (!abilities_list) { /* Load only once per program start */
|
||||
gp_abilities_list_new (&abilities_list);
|
||||
TRACE("Loading cameras...\n");
|
||||
gp_abilities_list_load (abilities_list, NULL);
|
||||
}
|
||||
TRACE("Detecting cameras...\n");
|
||||
gp_abilities_list_detect (abilities_list, port_list, detected_cameras, NULL);
|
||||
curcamera = 0;
|
||||
TRACE("%d cameras detected\n", gp_list_count(detected_cameras));
|
||||
}
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
|
||||
static TW_UINT16
|
||||
GPHOTO2_GetIdentity( pTW_IDENTITY pOrigin, pTW_IDENTITY self) {
|
||||
int count;
|
||||
const char *cname, *pname;
|
||||
|
||||
if (TWRC_SUCCESS != gphoto2_auto_detect())
|
||||
return TWRC_FAILURE;
|
||||
|
||||
count = gp_list_count (detected_cameras);
|
||||
if (count < GP_OK) {
|
||||
gp_list_free (detected_cameras);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
TRACE("%d cameras detected.\n", count);
|
||||
self->ProtocolMajor = TWON_PROTOCOLMAJOR;
|
||||
self->ProtocolMinor = TWON_PROTOCOLMINOR;
|
||||
lstrcpynA (self->Manufacturer, "The Wine Team", sizeof(self->Manufacturer) - 1);
|
||||
lstrcpynA (self->ProductFamily, "GPhoto2 Camera", sizeof(self->ProductFamily) - 1);
|
||||
|
||||
if (!count) { /* No camera detected. But we need to return an IDENTITY anyway. */
|
||||
lstrcpynA (self->ProductName, "GPhoto2 Camera", sizeof(self->ProductName) - 1);
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
gp_list_get_name (detected_cameras, curcamera, &cname);
|
||||
gp_list_get_value (detected_cameras, curcamera, &pname);
|
||||
if (count == 1) /* Normal case, only one camera. */
|
||||
snprintf (self->ProductName, sizeof(self->ProductName), "%s", cname);
|
||||
else
|
||||
snprintf (self->ProductName, sizeof(self->ProductName), "%s@%s", cname, pname);
|
||||
curcamera = (curcamera+1) % count;
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
|
||||
static TW_UINT16
|
||||
GPHOTO2_OpenDS( pTW_IDENTITY pOrigin, pTW_IDENTITY self) {
|
||||
int ret, m, p, count, i;
|
||||
CameraAbilities a;
|
||||
GPPortInfo info;
|
||||
const char *model, *port;
|
||||
|
||||
if (TWRC_SUCCESS != gphoto2_auto_detect())
|
||||
return TWRC_FAILURE;
|
||||
|
||||
if (lstrcmpA(self->ProductFamily,"GPhoto2 Camera")) {
|
||||
FIXME("identity passed is not a gphoto camera, but %s!?!\n", self->ProductFamily);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
count = gp_list_count (detected_cameras);
|
||||
if (!count) {
|
||||
ERR("No camera found by autodetection. Returning failure.\n");
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
if (!lstrcmpA (self->ProductName, "GPhoto2 Camera")) {
|
||||
TRACE("Potential undetected camera. Just using the first autodetected one.\n");
|
||||
i = 0;
|
||||
} else {
|
||||
for (i=0;i<count;i++) {
|
||||
const char *cname, *pname;
|
||||
TW_STR32 name;
|
||||
|
||||
gp_list_get_name (detected_cameras, i, &cname);
|
||||
gp_list_get_value (detected_cameras, i, &pname);
|
||||
if (!lstrcmpA(self->ProductName,cname))
|
||||
break;
|
||||
snprintf(name, sizeof(name), "%s", cname);
|
||||
if (!lstrcmpA(self->ProductName,name))
|
||||
break;
|
||||
snprintf(name, sizeof(name), "%s@%s", cname, pname);
|
||||
if (!lstrcmpA(self->ProductName,name))
|
||||
break;
|
||||
}
|
||||
if (i == count) {
|
||||
TRACE("Camera %s not found in autodetected list. Using first entry.\n", self->ProductName);
|
||||
i=0;
|
||||
}
|
||||
}
|
||||
gp_list_get_name (detected_cameras, i, &model);
|
||||
gp_list_get_value (detected_cameras, i, &port);
|
||||
TRACE("model %s, port %s\n", model, port);
|
||||
ret = gp_camera_new (&activeDS.camera);
|
||||
if (ret < GP_OK) {
|
||||
ERR("gp_camera_new: %d\n", ret);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
m = gp_abilities_list_lookup_model (abilities_list, model);
|
||||
if (m < GP_OK) {
|
||||
FIXME("Model %s not found, %d!\n", model, m);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
ret = gp_abilities_list_get_abilities (abilities_list, m, &a);
|
||||
if (ret < GP_OK) {
|
||||
FIXME("gp_camera_list_get_abilities failed? %d\n", ret);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
ret = gp_camera_set_abilities (activeDS.camera, a);
|
||||
if (ret < GP_OK) {
|
||||
FIXME("gp_camera_set_abilities failed? %d\n", ret);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
|
||||
p = gp_port_info_list_lookup_path (port_list, port);
|
||||
if (p < GP_OK) {
|
||||
FIXME("port %s not in portlist?\n", port);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
ret = gp_port_info_list_get_info (port_list, p, &info);
|
||||
if (ret < GP_OK) {
|
||||
FIXME("could not get portinfo for port %s?\n", port);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
ret = gp_camera_set_port_info (activeDS.camera, info);
|
||||
if (ret < GP_OK) {
|
||||
FIXME("could not set portinfo for port %s to camera?\n", port);
|
||||
return TWRC_FAILURE;
|
||||
}
|
||||
list_init( &(activeDS.files) );
|
||||
activeDS.currentState = 4;
|
||||
activeDS.twCC = TWRC_SUCCESS;
|
||||
activeDS.pixelflavor = TWPF_CHOCOLATE;
|
||||
activeDS.pixeltype = TWPT_RGB;
|
||||
activeDS.capXferMech = TWSX_MEMORY;
|
||||
TRACE("OK!\n");
|
||||
return TWRC_SUCCESS;
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Twain resource definitions
|
||||
*
|
||||
* Copyright 2006 CodeWeavers, Aric Stewart
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define IDD_DIALOG1 0x400
|
||||
#define IDD_CAMERAUI 0x401
|
||||
#define IDD_CONNECTING 0x402
|
||||
|
||||
#define IDC_STATIC 999
|
||||
#define IDC_LIST1 1000
|
||||
#define IDC_IMPORT 1001
|
||||
#define IDC_IMPORTALL 1002
|
||||
#define IDC_EXIT 1003
|
||||
#define IDC_BITMAP 1004
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Top level resource file for Twain
|
||||
*
|
||||
* Copyright 2006 CodeWeavers, Aric Stewart
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "winnls.h"
|
||||
#include "commctrl.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "gphoto2_En.rc"
|
|
@ -0,0 +1,257 @@
|
|||
/*
|
||||
* TWAIN32 Options UI
|
||||
*
|
||||
* Copyright 2006 CodeWeavers, Aric Stewart
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "winnls.h"
|
||||
#include "wingdi.h"
|
||||
#include "commctrl.h"
|
||||
#include "prsht.h"
|
||||
#include "twain.h"
|
||||
#include "gphoto2_i.h"
|
||||
#include "wine/debug.h"
|
||||
#include "resource.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(twain);
|
||||
|
||||
static HBITMAP static_bitmap;
|
||||
|
||||
static INT_PTR CALLBACK ConnectingProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void PopulateListView(HWND List)
|
||||
{
|
||||
struct gphoto2_file *file;
|
||||
LVITEMA item;
|
||||
int index = 0;
|
||||
|
||||
LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
|
||||
{
|
||||
if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg"))
|
||||
{
|
||||
memset(&item,0,sizeof(item));
|
||||
item.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE ;
|
||||
item.iItem = index;
|
||||
item.pszText = file->filename;
|
||||
item.iImage = index;
|
||||
item.lParam= (LPARAM)file;
|
||||
|
||||
SendMessageA(List, LVM_INSERTITEMA,0,(LPARAM)&item);
|
||||
index ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PopulateImageList(HIMAGELIST *iList, HWND list)
|
||||
{
|
||||
struct gphoto2_file *file;
|
||||
INT rc;
|
||||
HWND progress_dialog;
|
||||
|
||||
progress_dialog =
|
||||
CreateDialogW(GPHOTO2_instance,(LPWSTR)MAKEINTRESOURCE(IDD_CONNECTING),
|
||||
NULL, ConnectingProc);
|
||||
|
||||
LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
|
||||
{
|
||||
if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg"))
|
||||
{
|
||||
HBITMAP bitmap;
|
||||
BITMAP bmpInfo;
|
||||
|
||||
#ifdef HAVE_GPHOTO2
|
||||
_get_gphoto2_file_as_DIB(file->folder, file->filename,
|
||||
GP_FILE_TYPE_PREVIEW, 0, &bitmap);
|
||||
#else
|
||||
bitmap = 0;
|
||||
#endif
|
||||
GetObjectA(bitmap,sizeof(BITMAP),(LPVOID)&bmpInfo);
|
||||
|
||||
if (*iList == 0)
|
||||
{
|
||||
*iList = ImageList_Create(bmpInfo.bmWidth,
|
||||
bmpInfo.bmHeight,ILC_COLOR24, 10,10);
|
||||
|
||||
SendMessageW(list, LVM_SETICONSPACING, 0,
|
||||
MAKELONG(bmpInfo.bmWidth+6, bmpInfo.bmHeight+15) ); }
|
||||
|
||||
rc = ImageList_Add(*iList, bitmap, 0);
|
||||
|
||||
DeleteObject(static_bitmap);
|
||||
static_bitmap = bitmap;
|
||||
SendMessageW(GetDlgItem(progress_dialog,IDC_BITMAP),STM_SETIMAGE,
|
||||
IMAGE_BITMAP, (LPARAM)static_bitmap);
|
||||
RedrawWindow(progress_dialog,NULL,NULL,RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);
|
||||
}
|
||||
}
|
||||
EndDialog(progress_dialog,0);
|
||||
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
HIMAGELIST ilist = 0;
|
||||
HWND list = GetDlgItem(hwnd,IDC_LIST1);
|
||||
EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
|
||||
|
||||
PopulateImageList(&ilist,list);
|
||||
|
||||
SendMessageA(list, LVM_SETIMAGELIST,LVSIL_NORMAL,(LPARAM)ilist);
|
||||
PopulateListView(list);
|
||||
}
|
||||
break;
|
||||
case WM_NOTIFY:
|
||||
if (((LPNMHDR)lParam)->code == LVN_ITEMCHANGED)
|
||||
{
|
||||
HWND list = GetDlgItem(hwnd,IDC_LIST1);
|
||||
int count = SendMessageA(list,LVM_GETSELECTEDCOUNT,0,0);
|
||||
if (count > 0)
|
||||
EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),TRUE);
|
||||
else
|
||||
EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
|
||||
}
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch LOWORD(wParam)
|
||||
{
|
||||
case IDC_EXIT:
|
||||
EndDialog(hwnd,0);
|
||||
break;
|
||||
case IDC_IMPORT:
|
||||
{
|
||||
HWND list = GetDlgItem(hwnd,IDC_LIST1);
|
||||
int count = SendMessageA(list,LVM_GETSELECTEDCOUNT,0,0);
|
||||
int i;
|
||||
|
||||
if (count ==0)
|
||||
{
|
||||
EndDialog(hwnd,0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
count = SendMessageA(list,LVM_GETITEMCOUNT,0,0);
|
||||
for ( i = 0; i < count; i++)
|
||||
{
|
||||
INT state = 0x00000000;
|
||||
|
||||
state = SendMessageA(list,LVM_GETITEMSTATE,i,
|
||||
LVIS_SELECTED);
|
||||
|
||||
if (state)
|
||||
{
|
||||
LVITEMA item;
|
||||
struct gphoto2_file *file;
|
||||
|
||||
memset(&item,0,sizeof(item));
|
||||
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = i;
|
||||
|
||||
SendMessageA(list,LVM_GETITEMA,0,(LPARAM)&item);
|
||||
|
||||
file = (struct gphoto2_file*)item.lParam;
|
||||
file->download = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
EndDialog(hwnd,1);
|
||||
}
|
||||
break;
|
||||
case IDC_IMPORTALL:
|
||||
{
|
||||
HWND list = GetDlgItem(hwnd,IDC_LIST1);
|
||||
int count = SendMessageA(list,LVM_GETITEMCOUNT,0,0);
|
||||
int i;
|
||||
|
||||
if (count ==0)
|
||||
{
|
||||
EndDialog(hwnd,0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for ( i = 0; i < count; i++)
|
||||
{
|
||||
LVITEMA item;
|
||||
struct gphoto2_file *file;
|
||||
|
||||
memset(&item,0,sizeof(item));
|
||||
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = i;
|
||||
|
||||
SendMessageA(list,LVM_GETITEMA,0,(LPARAM)&item);
|
||||
|
||||
file = (struct gphoto2_file*)item.lParam;
|
||||
file->download = TRUE;
|
||||
}
|
||||
|
||||
EndDialog(hwnd,1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL DoCameraUI()
|
||||
{
|
||||
return DialogBoxW(GPHOTO2_instance,
|
||||
(LPWSTR)MAKEINTRESOURCE(IDD_CAMERAUI),NULL, DialogProc);
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK ProgressProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
||||
lParam)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HWND TransferingDialogBox(HWND dialog, DWORD progress)
|
||||
{
|
||||
if (!dialog)
|
||||
dialog = CreateDialogW(GPHOTO2_instance,
|
||||
(LPWSTR)MAKEINTRESOURCE(IDD_DIALOG1), NULL, ProgressProc);
|
||||
|
||||
if (progress == -1)
|
||||
{
|
||||
EndDialog(dialog,0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RedrawWindow(dialog,NULL,NULL,
|
||||
RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);
|
||||
|
||||
return dialog;
|
||||
}
|
|
@ -221,6 +221,9 @@
|
|||
/* Define to 1 if you have the <GL/gl.h> header file. */
|
||||
#undef HAVE_GL_GL_H
|
||||
|
||||
/* Define if we have libgphoto2 development environment */
|
||||
#undef HAVE_GPHOTO2
|
||||
|
||||
/* Define to 1 if you have the <hal/libhal.h> header file. */
|
||||
#undef HAVE_HAL_LIBHAL_H
|
||||
|
||||
|
|
Loading…
Reference in New Issue