localui: Use wide-char string literals.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2020-10-09 19:20:09 +02:00 committed by Alexandre Julliard
parent 82a7936c02
commit 3503fb0eef
2 changed files with 23 additions and 54 deletions

View File

@ -38,32 +38,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(localui);
static HINSTANCE LOCALUI_hInstance;
static const WCHAR cmd_AddPortW[] = {'A','d','d','P','o','r','t',0};
static const WCHAR cmd_ConfigureLPTPortCommandOKW[] = {'C','o','n','f','i','g','u','r','e',
'L','P','T','P','o','r','t',
'C','o','m','m','a','n','d','O','K',0};
static const WCHAR cmd_DeletePortW[] = {'D','e','l','e','t','e','P','o','r','t',0};
static const WCHAR cmd_GetDefaultCommConfigW[] = {'G','e','t',
'D','e','f','a','u','l','t',
'C','o','m','m','C','o','n','f','i','g',0};
static const WCHAR cmd_GetTransmissionRetryTimeoutW[] = {'G','e','t',
'T','r','a','n','s','m','i','s','s','i','o','n',
'R','e','t','r','y','T','i','m','e','o','u','t',0};
static const WCHAR cmd_PortIsValidW[] = {'P','o','r','t','I','s','V','a','l','i','d',0};
static const WCHAR cmd_SetDefaultCommConfigW[] = {'S','e','t',
'D','e','f','a','u','l','t',
'C','o','m','m','C','o','n','f','i','g',0};
static const WCHAR fmt_uW[] = {'%','u',0};
static const WCHAR portname_LPT[] = {'L','P','T',0};
static const WCHAR portname_COM[] = {'C','O','M',0};
static const WCHAR portname_FILE[] = {'F','I','L','E',':',0};
static const WCHAR portname_CUPS[] = {'C','U','P','S',':',0};
static const WCHAR portname_LPR[] = {'L','P','R',':',0};
static const WCHAR XcvMonitorW[] = {',','X','c','v','M','o','n','i','t','o','r',' ',0};
static const WCHAR XcvPortW[] = {',','X','c','v','P','o','r','t',' ',0};
/*****************************************************/
typedef struct tag_addportui_t {
@ -121,7 +95,7 @@ static BOOL dlg_configure_com(HANDLE hXcv, HWND hWnd, PCWSTR pPortName)
/* get current settings */
len = FIELD_OFFSET(COMMCONFIG, wcProviderData[1]);
status = ERROR_SUCCESS;
res = XcvDataW( hXcv, cmd_GetDefaultCommConfigW,
res = XcvDataW( hXcv, L"GetDefaultCommConfig",
(PBYTE) shortname,
(lstrlenW(shortname) +1) * sizeof(WCHAR),
(PBYTE) &cfg, len, &len, &status);
@ -132,7 +106,7 @@ static BOOL dlg_configure_com(HANDLE hXcv, HWND hWnd, PCWSTR pPortName)
if (res) {
status = ERROR_SUCCESS;
/* set new settings */
res = XcvDataW(hXcv, cmd_SetDefaultCommConfigW,
res = XcvDataW(hXcv, L"SetDefaultCommConfig",
(PBYTE) &cfg, len,
(PBYTE) &dummy, 0, &len, &status);
}
@ -292,7 +266,7 @@ static INT_PTR CALLBACK dlgproc_addport(HWND hwnd, UINT msg, WPARAM wparam, LPAR
/* length is in WCHAR, including the '\0' */
GetDlgItemTextW(hwnd, ADDPORT_EDIT, data->portname, len + 1);
status = ERROR_SUCCESS;
res = XcvDataW( data->hXcv, cmd_PortIsValidW, (PBYTE) data->portname,
res = XcvDataW( data->hXcv, L"PortIsValid", (BYTE *) data->portname,
(lstrlenW(data->portname) + 1) * sizeof(WCHAR),
(PBYTE) &dummy, 0, &len, &status);
@ -356,7 +330,7 @@ static INT_PTR CALLBACK dlgproc_lptconfig(HWND hwnd, UINT msg, WPARAM wparam, LP
/* Get current setting */
data->value = 45;
status = ERROR_SUCCESS;
res = XcvDataW( data->hXcv, cmd_GetTransmissionRetryTimeoutW,
res = XcvDataW( data->hXcv, L"GetTransmissionRetryTimeout",
(PBYTE) &dummy, 0,
(PBYTE) &data->value, sizeof(data->value), &len, &status);
@ -379,8 +353,8 @@ static INT_PTR CALLBACK dlgproc_lptconfig(HWND hwnd, UINT msg, WPARAM wparam, LP
/* native localui.dll use the same limits */
if ((res > 0) && (res < 1000000) && status) {
swprintf(bufferW, ARRAY_SIZE(bufferW), fmt_uW, res);
res = XcvDataW( data->hXcv, cmd_ConfigureLPTPortCommandOKW,
swprintf(bufferW, ARRAY_SIZE(bufferW), L"%u", res);
res = XcvDataW( data->hXcv, L"ConfigureLPTPortCommandOK",
(PBYTE) bufferW,
(lstrlenW(bufferW) +1) * sizeof(WCHAR),
(PBYTE) &dummy, 0, &len, &status);
@ -415,13 +389,13 @@ static DWORD get_type_from_name(LPCWSTR name)
{
HANDLE hfile;
if (!wcsnicmp(name, portname_LPT, ARRAY_SIZE(portname_LPT) -1))
if (!wcsnicmp(name, L"LPT", ARRAY_SIZE(L"LPT") -1))
return PORT_IS_LPT;
if (!wcsnicmp(name, portname_COM, ARRAY_SIZE(portname_COM) -1))
if (!wcsnicmp(name, L"COM", ARRAY_SIZE(L"COM") -1))
return PORT_IS_COM;
if (!wcsicmp(name, portname_FILE))
if (!wcsicmp(name, L"FILE:"))
return PORT_IS_FILE;
if (name[0] == '/')
@ -430,10 +404,10 @@ static DWORD get_type_from_name(LPCWSTR name)
if (name[0] == '|')
return PORT_IS_PIPE;
if (!wcsncmp(name, portname_CUPS, ARRAY_SIZE(portname_CUPS) -1))
if (!wcsncmp(name, L"CUPS:", ARRAY_SIZE(L"CUPS:") -1))
return PORT_IS_CUPS;
if (!wcsncmp(name, portname_LPR, ARRAY_SIZE(portname_LPR) -1))
if (!wcsncmp(name, L"LPR:", ARRAY_SIZE(L"LPR:") -1))
return PORT_IS_LPR;
/* Must be a file or a directory. Does the file exist ? */
@ -508,7 +482,7 @@ static BOOL WINAPI localui_AddPortUI(PCWSTR pName, HWND hWnd, PCWSTR pMonitorNam
TRACE( "(%s, %p, %s, %p) (*ppPortName: %p)\n", debugstr_w(pName), hWnd,
debugstr_w(pMonitorName), ppPortName, ppPortName ? *ppPortName : NULL);
if (open_monitor_by_name(XcvMonitorW, pMonitorName, &hXcv)) {
if (open_monitor_by_name(L",XcvMonitor ", pMonitorName, &hXcv)) {
ZeroMemory(&data, sizeof(addportui_t));
data.hXcv = hXcv;
@ -520,7 +494,7 @@ static BOOL WINAPI localui_AddPortUI(PCWSTR pName, HWND hWnd, PCWSTR pMonitorNam
if (ppPortName) *ppPortName = NULL;
if (res) {
res = XcvDataW(hXcv, cmd_AddPortW, (PBYTE) data.portname,
res = XcvDataW(hXcv, L"AddPort", (BYTE *) data.portname,
(lstrlenW(data.portname)+1) * sizeof(WCHAR),
(PBYTE) &dummy, 0, &needed, &status);
@ -572,7 +546,7 @@ static BOOL WINAPI localui_ConfigurePortUI(PCWSTR pName, HWND hWnd, PCWSTR pPort
DWORD res;
TRACE("(%s, %p, %s)\n", debugstr_w(pName), hWnd, debugstr_w(pPortName));
if (open_monitor_by_name(XcvPortW, pPortName, &hXcv)) {
if (open_monitor_by_name(L",XcvPort ", pPortName, &hXcv)) {
res = get_type_from_name(pPortName);
switch(res)
@ -631,10 +605,10 @@ static BOOL WINAPI localui_DeletePortUI(PCWSTR pName, HWND hWnd, PCWSTR pPortNam
return FALSE;
}
if (open_monitor_by_name(XcvPortW, pPortName, &hXcv)) {
if (open_monitor_by_name(L",XcvPort ", pPortName, &hXcv)) {
/* native localui tests here for LPT / COM - Ports and failed with
ERROR_NOT_SUPPORTED. */
if (XcvDataW(hXcv, cmd_DeletePortW, (LPBYTE) pPortName,
if (XcvDataW(hXcv, L"DeletePort", (BYTE *) pPortName,
(lstrlenW(pPortName)+1) * sizeof(WCHAR), (LPBYTE) &dummy, 0, &needed, &status)) {
ClosePrinter(hXcv);

View File

@ -43,13 +43,8 @@ static PMONITORUI pui;
static BOOL (WINAPI *pAddPortUI)(PCWSTR, HWND, PCWSTR, PWSTR *);
static BOOL (WINAPI *pConfigurePortUI)(PCWSTR, HWND, PCWSTR);
static BOOL (WINAPI *pDeletePortUI)(PCWSTR, HWND, PCWSTR);
static const WCHAR does_not_existW[] = {'d','o','e','s','_','n','o','t','_','e','x','i','s','t',0};
static const WCHAR emptyW[] = {0};
static const CHAR fmt_comA[] = {'C','O','M','%','u',':',0};
static const CHAR fmt_lptA[] = {'L','P','T','%','u',':',0};
static const WCHAR localportW[] = {'L','o','c','a','l',' ','P','o','r','t',0};
static const WCHAR portname_fileW[] = {'F','I','L','E',':',0};
static LPBYTE pi_buffer;
static DWORD pi_numports;
@ -148,14 +143,14 @@ static void test_AddPortUI(void)
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
SetLastError(0xdeadbeef);
res = pAddPortUI(NULL, NULL, emptyW, NULL);
res = pAddPortUI(NULL, NULL, L"", NULL);
ok( !res &&
((GetLastError() == ERROR_UNKNOWN_PORT) || (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
"got %d with %u (expected '0' with: ERROR_UNKNOWN_PORT or "
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
SetLastError(0xdeadbeef);
res = pAddPortUI(NULL, NULL, does_not_existW, NULL);
res = pAddPortUI(NULL, NULL, L"does_not_exist", NULL);
ok( !res &&
((GetLastError() == ERROR_UNKNOWN_PORT) || (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
"got %d with %u (expected '0' with: ERROR_UNKNOWN_PORT or "
@ -172,7 +167,7 @@ static void test_AddPortUI(void)
* - When the new port starts with "COM" or "LPT",
* FALSE is returned with ERROR_NOT_SUPPORTED on windows
*/
res = pAddPortUI(NULL, NULL, localportW, &new_portname);
res = pAddPortUI(NULL, NULL, L"Local Port", &new_portname);
ok( res ||
(GetLastError() == ERROR_CANCELLED) ||
(GetLastError() == ERROR_ACCESS_DENIED) ||
@ -205,7 +200,7 @@ static void test_ConfigurePortUI(void)
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
SetLastError(0xdeadbeef);
res = pConfigurePortUI(NULL, NULL, emptyW);
res = pConfigurePortUI(NULL, NULL, L"");
ok( !res &&
((GetLastError() == ERROR_UNKNOWN_PORT) || (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
"got %d with %u (expected '0' with: ERROR_UNKNOWN_PORT or "
@ -213,7 +208,7 @@ static void test_ConfigurePortUI(void)
SetLastError(0xdeadbeef);
res = pConfigurePortUI(NULL, NULL, does_not_existW);
res = pConfigurePortUI(NULL, NULL, L"does_not_exist");
ok( !res &&
((GetLastError() == ERROR_UNKNOWN_PORT) || (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
"got %d with %u (expected '0' with: ERROR_UNKNOWN_PORT or "
@ -258,7 +253,7 @@ static void test_ConfigurePortUI(void)
if (winetest_interactive && file_present) {
SetLastError(0xdeadbeef);
res = pConfigurePortUI(NULL, NULL, portname_fileW);
res = pConfigurePortUI(NULL, NULL, L"FILE:");
ok( !res &&
((GetLastError() == ERROR_CANCELLED) || (GetLastError() == ERROR_ACCESS_DENIED)),
"got %d with %u (expected '0' with: ERROR_CANCELLED or "
@ -300,7 +295,7 @@ START_TEST(localui)
/* find installed ports */
/* "FILE:" */
file_present = find_portinfo2(portname_fileW);
file_present = find_portinfo2(L"FILE:");
if (!pi_numports) /* Nothing to test without a port */
return;