Skip to content

Commit

Permalink
twain_32: Implement source selection dialog.
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Povirk <[email protected]>
Signed-off-by: Alexandre Julliard <[email protected]>
  • Loading branch information
Vincent Povirk authored and julliard committed Nov 17, 2017
1 parent b0fc60d commit 02d0d68
Show file tree
Hide file tree
Showing 54 changed files with 1,084 additions and 659 deletions.
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -18927,7 +18927,7 @@ wine_fn_config_dll tdi.sys enable_tdi_sys
wine_fn_config_dll toolhelp.dll16 enable_win16
wine_fn_config_dll traffic enable_traffic
wine_fn_config_dll twain.dll16 enable_win16
wine_fn_config_dll twain_32 enable_twain_32
wine_fn_config_dll twain_32 enable_twain_32 clean
wine_fn_config_test dlls/twain_32/tests twain_32_test
wine_fn_config_dll typelib.dll16 enable_win16
wine_fn_config_dll ucrtbase enable_ucrtbase implib
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3542,7 +3542,7 @@ WINE_CONFIG_DLL(tdi.sys)
WINE_CONFIG_DLL(toolhelp.dll16,enable_win16)
WINE_CONFIG_DLL(traffic)
WINE_CONFIG_DLL(twain.dll16,enable_win16)
WINE_CONFIG_DLL(twain_32)
WINE_CONFIG_DLL(twain_32,,[clean])
WINE_CONFIG_TEST(dlls/twain_32/tests)
WINE_CONFIG_DLL(typelib.dll16,enable_win16)
WINE_CONFIG_DLL(ucrtbase,,[implib])
Expand Down
2 changes: 2 additions & 0 deletions dlls/twain_32/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ IMPORTS = user32
C_SRCS = \
dsm_ctrl.c \
twain32_main.c

RC_SRCS = twain.rc
114 changes: 101 additions & 13 deletions dlls/twain_32/dsm_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "winuser.h"
#include "twain.h"
#include "twain_i.h"
#include "resource.h"
#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(twain);
Expand Down Expand Up @@ -345,24 +346,111 @@ TW_UINT16 TWAIN_OpenDS (pTW_IDENTITY pOrigin, TW_MEMREF pData)
return TWRC_SUCCESS;
}

typedef struct {
pTW_IDENTITY origin;
pTW_IDENTITY result;
} userselect_data;

INT_PTR CALLBACK userselect_dlgproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_INITDIALOG:
{
userselect_data *data = (userselect_data*)lparam;
int i;
HWND sourcelist;
BOOL any_devices = FALSE;

SetWindowLongPtrW(hwnd, DWLP_USER, (LONG_PTR)data);

sourcelist = GetDlgItem(hwnd, IDC_LISTSOURCE);

for (i=0; i<nrdevices; i++)
{
TW_IDENTITY *id = &devices[i].identity;
LRESULT index;

if ((id->SupportedGroups & data->origin->SupportedGroups) == 0)
continue;

index = SendMessageA(sourcelist, LB_ADDSTRING, 0, (LPARAM)id->ProductName);
SendMessageW(sourcelist, LB_SETITEMDATA, (WPARAM)index, (LPARAM)i);
any_devices = TRUE;
}

if (any_devices)
{
EnableWindow(GetDlgItem(hwnd, IDOK), TRUE);

/* FIXME: Select the supplied product name or default source. */
SendMessageW(sourcelist, LB_SETCURSEL, 0, 0);
}

return TRUE;
}
case WM_CLOSE:
EndDialog(hwnd, 0);
return TRUE;
case WM_COMMAND:
if (wparam == MAKEWPARAM(IDCANCEL, BN_CLICKED))
{
EndDialog(hwnd, 0);
return TRUE;
}
else if (wparam == MAKEWPARAM(IDOK, BN_CLICKED) ||
wparam == MAKEWPARAM(IDC_LISTSOURCE, LBN_DBLCLK))
{
userselect_data *data = (userselect_data*)GetWindowLongPtrW(hwnd, DWLP_USER);
HWND sourcelist;
LRESULT index;

sourcelist = GetDlgItem(hwnd, IDC_LISTSOURCE);

index = SendMessageW(sourcelist, LB_GETCURSEL, 0, 0);

if (index == LB_ERR)
return TRUE;

index = SendMessageW(sourcelist, LB_GETITEMDATA, (WPARAM)index, 0);

*data->result = devices[index].identity;

/* FIXME: Save this as the default source */

EndDialog(hwnd, 1);
return TRUE;
}
break;
}
return FALSE;
}

/* DG_CONTROL/DAT_IDENTITY/MSG_USERSELECT */
TW_UINT16 TWAIN_UserSelect (pTW_IDENTITY pOrigin, TW_MEMREF pData)
{
pTW_IDENTITY selected = (pTW_IDENTITY)pData;
userselect_data param = {pOrigin, pData};
HWND parent = DSM_parent;

TRACE("DG_CONTROL/DAT_IDENTITY/MSG_USERSELECT SupportedGroups=0x%x ProductName=%s\n",
selected->SupportedGroups, wine_dbgstr_a(selected->ProductName));
TRACE("DG_CONTROL/DAT_IDENTITY/MSG_USERSELECT SupportedGroups=0x%x ProductName=%s\n",
pOrigin->SupportedGroups, wine_dbgstr_a(param.result->ProductName));

twain_autodetect();
if (!nrdevices) {
TRACE("<-- TWRC_FAILURE\n");
DSM_twCC = TWCC_OPERATIONERROR;
return TWRC_FAILURE;
}
*selected = devices[0].identity;
TRACE("<-- %s\n", wine_dbgstr_a(selected->ProductName));
DSM_twCC = TWCC_SUCCESS;
return TWRC_SUCCESS;
twain_autodetect();

if (!IsWindow(parent))
parent = NULL;

if (DialogBoxParamW(DSM_hinstance, MAKEINTRESOURCEW(DLG_USERSELECT),
parent, userselect_dlgproc, (LPARAM)&param) == 0)
{
TRACE("canceled\n");
DSM_twCC = TWCC_SUCCESS;
return TWRC_CANCEL;
}

TRACE("<-- %s\n", wine_dbgstr_a(param.result->ProductName));
DSM_twCC = TWCC_SUCCESS;
return TWRC_SUCCESS;
}

/* DG_CONTROL/DAT_PARENT/MSG_CLOSEDSM */
Expand Down
24 changes: 24 additions & 0 deletions dlls/twain_32/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2017 Vincent Povirk for CodeWeavers
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/

#include <windef.h>
#include <winuser.h>

#define DLG_USERSELECT 1

#define IDC_LISTSOURCE 1001
33 changes: 33 additions & 0 deletions dlls/twain_32/twain.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2017 Vincent Povirk for CodeWeavers
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/

#include "resource.h"

#pragma makedep po

LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT

DLG_USERSELECT DIALOG 0, 0, 140, 140
STYLE DS_MODALFRAME | DS_3DLOOK | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP | DS_NOIDLEMSG
FONT 8, "MS Shell Dlg"
CAPTION "Select Source"
{
LISTBOX IDC_LISTSOURCE, 7, 7, 126, 104
DEFPUSHBUTTON "OK", IDOK, 29, 118, 50, 15, BS_DEFPUSHBUTTON|WS_TABSTOP|WS_DISABLED
PUSHBUTTON "Cancel", IDCANCEL, 83, 118, 50, 15
}
18 changes: 18 additions & 0 deletions dlls/twain_32/twain32_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@

WINE_DEFAULT_DEBUG_CHANNEL(twain);

extern HINSTANCE DSM_hinstance;

BOOL WINAPI DllMain (HINSTANCE hinstance, DWORD reason, LPVOID reserved)
{
TRACE("%p,%x,%p\n", hinstance, reason, reserved);

switch (reason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstance);
DSM_hinstance = hinstance;
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

/* A helper function that looks up a destination identity in the active
source list */
static activeDS *TWAIN_LookupSource (const TW_IDENTITY *pDest)
Expand Down
2 changes: 2 additions & 0 deletions dlls/twain_32/twain_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ TW_UINT16 DSM_twCC DECLSPEC_HIDDEN; /* current condition code of Sou

activeDS *activeSources DECLSPEC_HIDDEN; /* list of active data sources */

HINSTANCE DSM_hinstance DECLSPEC_HIDDEN;

/* Implementation of operation triplets (From Application to Source Manager) */
extern TW_UINT16 TWAIN_CloseDS
(pTW_IDENTITY pOrigin, TW_MEMREF pData) DECLSPEC_HIDDEN;
Expand Down
34 changes: 20 additions & 14 deletions po/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ msgstr "معلومات الدّعم"
#: dinput.rc:46 ieframe.rc:96 localui.rc:44 localui.rc:57 mpr.rc:49
#: msacm32.rc:53 mshtml.rc:47 mshtml.rc:57 msvfw32.rc:36 oledlg.rc:62
#: oledlg.rc:94 serialui.rc:41 setupapi.rc:59 shell32.rc:276 shell32.rc:300
#: shell32.rc:322 shell32.rc:341 shlwapi.rc:44 user32.rc:83 user32.rc:98
#: wininet.rc:51 wininet.rc:71 winspool.rc:42 net.rc:47 notepad.rc:117
#: oleview.rc:161 oleview.rc:174 progman.rc:106 progman.rc:124 progman.rc:142
#: progman.rc:158 progman.rc:180 progman.rc:199 progman.rc:216 regedit.rc:296
#: regedit.rc:307 regedit.rc:320 regedit.rc:336 regedit.rc:349 regedit.rc:362
#: taskmgr.rc:442 taskmgr.rc:517 winecfg.rc:214 winecfg.rc:224
#: shell32.rc:322 shell32.rc:341 shlwapi.rc:44 twain.rc:32 user32.rc:83
#: user32.rc:98 wininet.rc:51 wininet.rc:71 winspool.rc:42 net.rc:47
#: notepad.rc:117 oleview.rc:161 oleview.rc:174 progman.rc:106 progman.rc:124
#: progman.rc:142 progman.rc:158 progman.rc:180 progman.rc:199 progman.rc:216
#: regedit.rc:296 regedit.rc:307 regedit.rc:320 regedit.rc:336 regedit.rc:349
#: regedit.rc:362 taskmgr.rc:442 taskmgr.rc:517 winecfg.rc:214 winecfg.rc:224
#: wineconsole.rc:135 winefile.rc:128 winefile.rc:151 winefile.rc:181
#: winemine.rc:73 winemine.rc:84 winemine.rc:98 wordpad.rc:215 wordpad.rc:226
#: wordpad.rc:244 wordpad.rc:257
Expand Down Expand Up @@ -141,14 +141,14 @@ msgstr "&تثبيت"
#: localui.rc:45 localui.rc:58 mpr.rc:50 msacm32.rc:54 mshtml.rc:48
#: mshtml.rc:58 msvfw32.rc:37 oledlg.rc:63 oledlg.rc:95 serialui.rc:42
#: setupapi.rc:42 setupapi.rc:60 shell32.rc:277 shell32.rc:301 shell32.rc:312
#: shell32.rc:342 shlwapi.rc:45 user32.rc:84 user32.rc:99 wininet.rc:52
#: wininet.rc:72 winspool.rc:43 notepad.rc:118 oleview.rc:162 oleview.rc:175
#: progman.rc:107 progman.rc:125 progman.rc:143 progman.rc:159 progman.rc:181
#: progman.rc:200 progman.rc:217 regedit.rc:297 regedit.rc:308 regedit.rc:321
#: regedit.rc:337 regedit.rc:350 regedit.rc:363 taskmgr.rc:443 taskmgr.rc:518
#: wineboot.rc:34 winecfg.rc:215 winecfg.rc:225 wineconsole.rc:136
#: winefile.rc:129 winefile.rc:152 winefile.rc:182 winemine.rc:99
#: wordpad.rc:216 wordpad.rc:227 wordpad.rc:245 wordpad.rc:258
#: shell32.rc:342 shlwapi.rc:45 twain.rc:33 user32.rc:84 user32.rc:99
#: wininet.rc:52 wininet.rc:72 winspool.rc:43 notepad.rc:118 oleview.rc:162
#: oleview.rc:175 progman.rc:107 progman.rc:125 progman.rc:143 progman.rc:159
#: progman.rc:181 progman.rc:200 progman.rc:217 regedit.rc:297 regedit.rc:308
#: regedit.rc:321 regedit.rc:337 regedit.rc:350 regedit.rc:363 taskmgr.rc:443
#: taskmgr.rc:518 wineboot.rc:34 winecfg.rc:215 winecfg.rc:225
#: wineconsole.rc:136 winefile.rc:129 winefile.rc:152 winefile.rc:182
#: winemine.rc:99 wordpad.rc:216 wordpad.rc:227 wordpad.rc:245 wordpad.rc:258
msgid "Cancel"
msgstr "ألغِ"

Expand Down Expand Up @@ -9039,6 +9039,12 @@ msgctxt "time unit: seconds"
msgid " sec"
msgstr "ثا"

#: twain.rc:29
#, fuzzy
#| msgid "New Folder"
msgid "Select Source"
msgstr "مجلد جديد"

#: urlmon.rc:32 wininet.rc:77
msgid "Security Warning"
msgstr "تحذير أمني"
Expand Down
37 changes: 23 additions & 14 deletions po/bg.po
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ msgstr "Информация"
#: dinput.rc:46 ieframe.rc:96 localui.rc:44 localui.rc:57 mpr.rc:49
#: msacm32.rc:53 mshtml.rc:47 mshtml.rc:57 msvfw32.rc:36 oledlg.rc:62
#: oledlg.rc:94 serialui.rc:41 setupapi.rc:59 shell32.rc:276 shell32.rc:300
#: shell32.rc:322 shell32.rc:341 shlwapi.rc:44 user32.rc:83 user32.rc:98
#: wininet.rc:51 wininet.rc:71 winspool.rc:42 net.rc:47 notepad.rc:117
#: oleview.rc:161 oleview.rc:174 progman.rc:106 progman.rc:124 progman.rc:142
#: progman.rc:158 progman.rc:180 progman.rc:199 progman.rc:216 regedit.rc:296
#: regedit.rc:307 regedit.rc:320 regedit.rc:336 regedit.rc:349 regedit.rc:362
#: taskmgr.rc:442 taskmgr.rc:517 winecfg.rc:214 winecfg.rc:224
#: shell32.rc:322 shell32.rc:341 shlwapi.rc:44 twain.rc:32 user32.rc:83
#: user32.rc:98 wininet.rc:51 wininet.rc:71 winspool.rc:42 net.rc:47
#: notepad.rc:117 oleview.rc:161 oleview.rc:174 progman.rc:106 progman.rc:124
#: progman.rc:142 progman.rc:158 progman.rc:180 progman.rc:199 progman.rc:216
#: regedit.rc:296 regedit.rc:307 regedit.rc:320 regedit.rc:336 regedit.rc:349
#: regedit.rc:362 taskmgr.rc:442 taskmgr.rc:517 winecfg.rc:214 winecfg.rc:224
#: wineconsole.rc:135 winefile.rc:128 winefile.rc:151 winefile.rc:181
#: winemine.rc:73 winemine.rc:84 winemine.rc:98 wordpad.rc:215 wordpad.rc:226
#: wordpad.rc:244 wordpad.rc:257
Expand Down Expand Up @@ -149,14 +149,14 @@ msgstr "Инсталирай"
#: localui.rc:45 localui.rc:58 mpr.rc:50 msacm32.rc:54 mshtml.rc:48
#: mshtml.rc:58 msvfw32.rc:37 oledlg.rc:63 oledlg.rc:95 serialui.rc:42
#: setupapi.rc:42 setupapi.rc:60 shell32.rc:277 shell32.rc:301 shell32.rc:312
#: shell32.rc:342 shlwapi.rc:45 user32.rc:84 user32.rc:99 wininet.rc:52
#: wininet.rc:72 winspool.rc:43 notepad.rc:118 oleview.rc:162 oleview.rc:175
#: progman.rc:107 progman.rc:125 progman.rc:143 progman.rc:159 progman.rc:181
#: progman.rc:200 progman.rc:217 regedit.rc:297 regedit.rc:308 regedit.rc:321
#: regedit.rc:337 regedit.rc:350 regedit.rc:363 taskmgr.rc:443 taskmgr.rc:518
#: wineboot.rc:34 winecfg.rc:215 winecfg.rc:225 wineconsole.rc:136
#: winefile.rc:129 winefile.rc:152 winefile.rc:182 winemine.rc:99
#: wordpad.rc:216 wordpad.rc:227 wordpad.rc:245 wordpad.rc:258
#: shell32.rc:342 shlwapi.rc:45 twain.rc:33 user32.rc:84 user32.rc:99
#: wininet.rc:52 wininet.rc:72 winspool.rc:43 notepad.rc:118 oleview.rc:162
#: oleview.rc:175 progman.rc:107 progman.rc:125 progman.rc:143 progman.rc:159
#: progman.rc:181 progman.rc:200 progman.rc:217 regedit.rc:297 regedit.rc:308
#: regedit.rc:321 regedit.rc:337 regedit.rc:350 regedit.rc:363 taskmgr.rc:443
#: taskmgr.rc:518 wineboot.rc:34 winecfg.rc:215 winecfg.rc:225
#: wineconsole.rc:136 winefile.rc:129 winefile.rc:152 winefile.rc:182
#: winemine.rc:99 wordpad.rc:216 wordpad.rc:227 wordpad.rc:245 wordpad.rc:258
msgid "Cancel"
msgstr "Отмени"

Expand Down Expand Up @@ -9100,6 +9100,15 @@ msgctxt "time unit: seconds"
msgid " sec"
msgstr ""

#: twain.rc:29
#, fuzzy
msgid "Select Source"
msgstr ""
"#-#-#-#-# bg.po (Wine) #-#-#-#-#\n"
"Маркирай &всичко\n"
"#-#-#-#-# bg.po (Wine) #-#-#-#-#\n"
"&Маркирай всичко"

#: urlmon.rc:32 wininet.rc:77
msgid "Security Warning"
msgstr ""
Expand Down
Loading

0 comments on commit 02d0d68

Please sign in to comment.