From: Bernd Herd codeberg@herdsoft.com
If ADF is enabled and not filled with paper, display an error message to the user and allow a retry.
Also displays paper jammed message and cover open message.
Added german translation for error messages and progress dialog elements --- dlls/sane.ds/ds_image.c | 74 ++++++++++++++++++++++++++++++++++++++--- dlls/sane.ds/resource.h | 4 +++ dlls/sane.ds/sane.rc | 4 +++ dlls/sane.ds/ui.c | 22 ++++++++---- dlls/sane.ds/unixlib.c | 8 +++-- po/de.po | 24 +++++++++++++ 6 files changed, 121 insertions(+), 15 deletions(-)
diff --git a/dlls/sane.ds/ds_image.c b/dlls/sane.ds/ds_image.c index 27662ffc358..0909d8813dd 100644 --- a/dlls/sane.ds/ds_image.c +++ b/dlls/sane.ds/ds_image.c @@ -27,6 +27,24 @@
WINE_DEFAULT_DEBUG_CHANNEL(twain);
+/* Sane result codes from sane.h */ +typedef enum +{ + SANE_STATUS_GOOD = 0, /* everything A-OK */ + SANE_STATUS_UNSUPPORTED, /* operation is not supported */ + SANE_STATUS_CANCELLED, /* operation was cancelled */ + SANE_STATUS_DEVICE_BUSY, /* device is busy; try again later */ + SANE_STATUS_INVAL, /* data is invalid (includes no dev at open) */ + SANE_STATUS_EOF, /* no more data available (end-of-file) */ + SANE_STATUS_JAMMED, /* document feeder jammed */ + SANE_STATUS_NO_DOCS, /* document feeder out of documents */ + SANE_STATUS_COVER_OPEN, /* scanner cover is open */ + SANE_STATUS_IO_ERROR, /* error during device I/O */ + SANE_STATUS_NO_MEM, /* out of memory */ + SANE_STATUS_ACCESS_DENIED /* access to resource has been denied */ +} +SANE_Status; +
/* transition from state 6 to state 7. * @@ -42,6 +60,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(twain); TW_UINT16 SANE_Start(void) { TW_UINT16 twRC = TWRC_SUCCESS; + SANE_Status status; + TRACE("SANE_Start currentState:%d\n", activeDS.currentState); if (activeDS.currentState != 6) { @@ -53,8 +73,52 @@ TW_UINT16 SANE_Start(void) /* Open progress dialog */ activeDS.progressWnd = ScanningDialogBox(activeDS.progressWnd,0);
- /* Start the scan process in sane */ - if (SANE_CALL( start_device, NULL )) + do + { + /* Start the scan process in sane */ + status = SANE_CALL( start_device, NULL ); + + if (status == SANE_STATUS_GOOD) + { + twRC = TWRC_SUCCESS; + } + else if (!activeDS.capIndicators && !activeDS.ShowUI) + { + twRC = TWRC_FAILURE; + } + else + { + WCHAR szCaption[256]; + WCHAR szMessage[1024]; + + LoadStringW( SANE_instance, IDS_CAPTION, szCaption, ARRAY_SIZE( szCaption ) ); + switch (status) + { + case SANE_STATUS_NO_DOCS: + LoadStringW( SANE_instance, IDS_NO_DOCS, szMessage, ARRAY_SIZE( szMessage ) ); + twRC = + activeDS.scannedImages!=0 ? TWRC_FAILURE : + MessageBoxW(activeDS.progressWnd, szMessage, szCaption, MB_ICONWARNING | MB_RETRYCANCEL)==IDCANCEL ? TWRC_FAILURE :TWRC_CHECKSTATUS; + break; + case SANE_STATUS_JAMMED: + LoadStringW( SANE_instance, IDS_JAMMED, szMessage, ARRAY_SIZE( szMessage ) ); + twRC = + MessageBoxW(activeDS.progressWnd, szMessage, szCaption, MB_ICONWARNING | MB_RETRYCANCEL)==IDCANCEL ? TWRC_FAILURE :TWRC_CHECKSTATUS; + break; + case SANE_STATUS_COVER_OPEN: + LoadStringW( SANE_instance, IDS_COVER_OPEN, szMessage, ARRAY_SIZE( szMessage ) ); + twRC = + MessageBoxW(activeDS.progressWnd, szMessage, szCaption, MB_ICONWARNING | MB_RETRYCANCEL)==IDCANCEL ? TWRC_FAILURE :TWRC_CHECKSTATUS; + break; + default: + twRC = TWRC_FAILURE; + } + } + } + while (twRC == TWRC_CHECKSTATUS); + + /* If starting the scan failed, cancel scan job */ + if (twRC != TWRC_SUCCESS) { activeDS.progressWnd = ScanningDialogBox(activeDS.progressWnd, -1); activeDS.twCC = TWCC_OPERATIONERROR; @@ -72,7 +136,7 @@ TW_UINT16 SANE_Start(void)
if (activeDS.progressWnd) { - char szFormat[20]; + WCHAR szFormat[20]; int sid_format;
switch (activeDS.frame_params.format) @@ -82,9 +146,9 @@ TW_UINT16 SANE_Start(void) default: sid_format=IDS_UNKNOWN; }
- LoadStringA( SANE_instance, sid_format, szFormat, ARRAY_SIZE( szFormat ) ); + LoadStringW( SANE_instance, sid_format, szFormat, ARRAY_SIZE( szFormat ) );
- SetDlgItemTextA(activeDS.progressWnd, IDC_RESOLUTION, szFormat); + SetDlgItemTextW(activeDS.progressWnd, IDC_RESOLUTION, szFormat); }
TRACE("Acquiring image %dx%dx%d bits (format=%d last=%d) from sane...\n" diff --git a/dlls/sane.ds/resource.h b/dlls/sane.ds/resource.h index f52e7956e4b..8b792f362c5 100644 --- a/dlls/sane.ds/resource.h +++ b/dlls/sane.ds/resource.h @@ -36,3 +36,7 @@ #define IDS_COLOUR 0x502 #define IDS_LINEART 0x503 #define IDS_UNKNOWN 0x504 +#define IDS_CAPTION 0x505 +#define IDS_NO_DOCS 0x506 +#define IDS_JAMMED 0x507 +#define IDS_COVER_OPEN 0x508 diff --git a/dlls/sane.ds/sane.rc b/dlls/sane.ds/sane.rc index cc2a44302ab..216ce49c082 100644 --- a/dlls/sane.ds/sane.rc +++ b/dlls/sane.ds/sane.rc @@ -41,6 +41,10 @@ BEGIN IDS_COLOUR,"Color" IDS_LINEART,"LineArt" IDS_UNKNOWN,"Unknown" + IDS_CAPTION,"Scanning" + IDS_NO_DOCS,"The Automatic Document Feeder (ADF) is empty. Please insert the sheets to be scanned." + IDS_JAMMED,"The scanner reports a paper jam. Check for additional informations on device display." + IDS_COVER_OPEN,"The scanner cover is open. Please close the scanner." END
diff --git a/dlls/sane.ds/ui.c b/dlls/sane.ds/ui.c index d8d38e1f980..c269a700d23 100644 --- a/dlls/sane.ds/ui.c +++ b/dlls/sane.ds/ui.c @@ -1186,9 +1186,16 @@ static INT_PTR CALLBACK ScanningProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM { case WM_INITDIALOG: { - SetDlgItemTextA(hwnd, IDC_MANUFACTURER , activeDS.identity.Manufacturer); - SetDlgItemTextA(hwnd, IDC_PRODUCTFAMILY, activeDS.identity.ProductFamily); - SetDlgItemTextA(hwnd, IDC_PRODUCTNAME , activeDS.identity.ProductName); + WCHAR buffer[34]; + MultiByteToWideChar( CP_UNIXCP, 0, activeDS.identity.Manufacturer, -1, buffer, ARRAY_SIZE(buffer) ); + SetDlgItemTextW(hwnd, IDC_MANUFACTURER , buffer); + + MultiByteToWideChar( CP_UNIXCP, 0, activeDS.identity.ProductFamily, -1, buffer, ARRAY_SIZE(buffer) ); + SetDlgItemTextW(hwnd, IDC_PRODUCTFAMILY, buffer); + + MultiByteToWideChar( CP_UNIXCP, 0, activeDS.identity.ProductName, -1, buffer, ARRAY_SIZE(buffer) ); + SetDlgItemTextW(hwnd, IDC_PRODUCTNAME , buffer); + SetDlgItemInt(hwnd, IDC_PAGE, activeDS.scannedImages+1, TRUE); } break; @@ -1199,6 +1206,7 @@ static INT_PTR CALLBACK ScanningProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case IDCANCEL: WARN("User cancelled\n"); activeDS.userCancelled = TRUE; + break; } } } @@ -1233,15 +1241,15 @@ HWND ScanningDialogBox(HWND dialog, LONG progress) tickLast = tickNow;
/* Update progress bar */ - SendDlgItemMessageA(dialog, IDC_PROGRESS, PBM_SETPOS, progress, 0); + SendDlgItemMessageW(dialog, IDC_PROGRESS, PBM_SETPOS, progress, 0);
/* Perform message handling */ - while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) + while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { - if (!IsDialogMessageA(dialog, &msg)) + if (!IsDialogMessageW(dialog, &msg)) { TranslateMessage(&msg); - DispatchMessageA(&msg); + DispatchMessageW(&msg); } } } diff --git a/dlls/sane.ds/unixlib.c b/dlls/sane.ds/unixlib.c index 9531c758746..011a00d07b7 100644 --- a/dlls/sane.ds/unixlib.c +++ b/dlls/sane.ds/unixlib.c @@ -299,10 +299,12 @@ static NTSTATUS start_device( void *args ) if (status != SANE_STATUS_GOOD) { TRACE("sane_start returns %s\n", sane_strstatus(status)); - return STATUS_DEVICE_NOT_CONNECTED; } - device_started = TRUE; - return STATUS_SUCCESS; + else + { + device_started = TRUE; + } + return status; }
static NTSTATUS cancel_device( void *args ) diff --git a/po/de.po b/po/de.po index 8c6b6d6e218..18f602f7dac 100644 --- a/po/de.po +++ b/po/de.po @@ -9696,6 +9696,30 @@ msgstr "Scanne" msgid "SCANNING... Please Wait" msgstr "SCANNE... Bitte warten"
+msgid "Manufacturer:" +msgstr "Hersteller:" + +msgid "Productfamily:" +msgstr "Produktfamilie:" + +msgid "Productname:" +msgstr "Produktname:" + +msgid "Resolution:" +msgstr "Auflösung:" + +msgid "LineArt" +msgstr "S/W" + +msgid "The Automatic Document Feeder (ADF) is empty. Please insert the sheets to be scanned." +msgstr "Der Automatische Vorlageneinzug (ADF) ist leer. Bitte legen Sie die zu scannenden Blätter ein." + +msgid "The scanner reports a paper jam. Check for additional informations on device display." +msgstr "Der Scanner meldet einen Papierstau. Prüfen Sie, ob das Gerät weitere Informationen anzeigt." + +msgid "The scanner cover is open. Please close the scanner." +msgstr "Die Scanner-Abdeckung ist offen. Bitte schließen Sie den Scanner." + #: dlls/sane.ds/sane.rc:31 msgctxt "unit: pixels" msgid "px"