ReactOS 0.4.15-dev-7953-g1f49173
localui.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winreg.h"
#include "winuser.h"
#include "winspool.h"
#include "ddk/winsplp.h"
#include "wine/debug.h"
#include "localui.h"
Include dependency graph for localui.c:

Go to the source code of this file.

Classes

struct  tag_addportui_t
 
struct  tag_lptconfig_t
 

Typedefs

typedef struct tag_addportui_t addportui_t
 
typedef struct tag_lptconfig_t lptconfig_t
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (localui)
 
static INT_PTR CALLBACK dlgproc_lptconfig (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static LPWSTR strdupWW (LPCWSTR pPrefix, LPCWSTR pSuffix)
 
static BOOL dlg_configure_com (HANDLE hXcv, HWND hWnd, PCWSTR pPortName)
 
static BOOL dlg_configure_lpt (HANDLE hXcv, HWND hWnd)
 
static void dlg_port_already_exists (HWND hWnd, LPCWSTR portname)
 
static void dlg_invalid_portname (HWND hWnd, LPCWSTR portname)
 
static void dlg_nothingtoconfig (HWND hWnd)
 
static void dlg_win32error (HWND hWnd, DWORD lasterror)
 
static INT_PTR CALLBACK dlgproc_addport (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static DWORD get_type_from_name (LPCWSTR name)
 
static BOOL open_monitor_by_name (LPCWSTR pPrefix, LPCWSTR pPort, HANDLE *phandle)
 
static BOOL WINAPI localui_AddPortUI (PCWSTR pName, HWND hWnd, PCWSTR pMonitorName, PWSTR *ppPortName)
 
static BOOL WINAPI localui_ConfigurePortUI (PCWSTR pName, HWND hWnd, PCWSTR pPortName)
 
static BOOL WINAPI localui_DeletePortUI (PCWSTR pName, HWND hWnd, PCWSTR pPortName)
 
PMONITORUI WINAPI InitializePrintMonitorUI (void)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 

Variables

static HINSTANCE LOCALUI_hInstance
 
static const WCHAR cmd_AddPortW [] = {'A','d','d','P','o','r','t',0}
 
static const WCHAR cmd_ConfigureLPTPortCommandOKW []
 
static const WCHAR cmd_DeletePortW [] = {'D','e','l','e','t','e','P','o','r','t',0}
 
static const WCHAR cmd_GetDefaultCommConfigW []
 
static const WCHAR cmd_GetTransmissionRetryTimeoutW []
 
static const WCHAR cmd_PortIsValidW [] = {'P','o','r','t','I','s','V','a','l','i','d',0}
 
static const WCHAR cmd_SetDefaultCommConfigW []
 
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 Documentation

◆ addportui_t

◆ lptconfig_t

Function Documentation

◆ dlg_configure_com()

static BOOL dlg_configure_com ( HANDLE  hXcv,
HWND  hWnd,
PCWSTR  pPortName 
)
static

Definition at line 108 of file localui.c.

109{
110 COMMCONFIG cfg;
111 LPWSTR shortname;
113 DWORD dummy;
114 DWORD len;
115 BOOL res;
116
117 /* strip the colon (pPortName is never empty here) */
118 len = lstrlenW(pPortName);
119 shortname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
120 if (shortname) {
121 memcpy(shortname, pPortName, (len -1) * sizeof(WCHAR));
122 shortname[len-1] = '\0';
123
124 /* get current settings */
125 len = FIELD_OFFSET(COMMCONFIG, wcProviderData[1]);
128 (PBYTE) shortname,
129 (lstrlenW(shortname) +1) * sizeof(WCHAR),
130 (PBYTE) &cfg, len, &len, &status);
131
132 if (res && (status == ERROR_SUCCESS)) {
133 /* display the Dialog */
134 res = CommConfigDialogW(pPortName, hWnd, &cfg);
135 if (res) {
137 /* set new settings */
139 (PBYTE) &cfg, len,
140 (PBYTE) &dummy, 0, &len, &status);
141 }
142 }
143 HeapFree(GetProcessHeap(), 0, shortname);
144 return res;
145 }
146 return FALSE;
147}
HWND hWnd
Definition: settings.c:17
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI CommConfigDialogW(LPCWSTR lpszDevice, HWND hWnd, LPCOMMCONFIG lpCommConfig)
Definition: comm.c:1239
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLenum GLsizei len
Definition: glext.h:6722
static HANDLE hXcv
Definition: localmon.c:73
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BYTE * PBYTE
Definition: pedump.c:66
Definition: ps.c:97
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
static const WCHAR cmd_GetDefaultCommConfigW[]
Definition: localui.c:49
static const WCHAR cmd_SetDefaultCommConfigW[]
Definition: localui.c:56
WINBOOL WINAPI XcvDataW(HANDLE hXcv, PCWSTR pszDataName, PBYTE pInputData, DWORD cbInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded, PDWORD pdwStatus)
Definition: printers.c:487
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by localui_ConfigurePortUI().

◆ dlg_configure_lpt()

static BOOL dlg_configure_lpt ( HANDLE  hXcv,
HWND  hWnd 
)
static

Definition at line 155 of file localui.c.

156{
158 BOOL res;
159
160
161 data.hXcv = hXcv;
162
165
166 TRACE("got %u with %u\n", res, GetLastError());
167
169 return res;
170}
#define SetLastError(x)
Definition: compat.h:752
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define LPTCONFIG_DIALOG
Definition: localui.h:31
#define TRACE(s)
Definition: solgame.cpp:4
static INT_PTR CALLBACK dlgproc_lptconfig(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: localui.c:343
static HINSTANCE LOCALUI_hInstance
Definition: localui.c:42
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LPARAM
Definition: windef.h:208
#define ERROR_CANCELLED
Definition: winerror.h:726
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by localui_ConfigurePortUI().

◆ dlg_invalid_portname()

static void dlg_invalid_portname ( HWND  hWnd,
LPCWSTR  portname 
)
static

Definition at line 202 of file localui.c.

203{
204 WCHAR res_PortW[IDS_LOCALPORT_MAXLEN];
205 WCHAR res_InvalidNameW[IDS_INVALIDNAME_MAXLEN];
207 DWORD len;
208
209 res_PortW[0] = '\0';
210 res_InvalidNameW[0] = '\0';
213
214 len = lstrlenW(portname) + IDS_INVALIDNAME_MAXLEN;
215 message = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
216 if (message) {
217 message[0] = '\0';
218 swprintf(message, res_InvalidNameW, portname);
219 MessageBoxW(hWnd, message, res_PortW, MB_OK | MB_ICONERROR);
221 }
222}
#define swprintf
Definition: precomp.h:40
#define IDS_LOCALPORT
Definition: localui.h:35
#define IDS_INVALIDNAME
Definition: localui.h:36
#define IDS_INVALIDNAME_MAXLEN
Definition: localui.h:42
#define IDS_LOCALPORT_MAXLEN
Definition: localui.h:41
Definition: tftpd.h:60
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:787
#define MB_OK
Definition: winuser.h:790

Referenced by dlgproc_addport().

◆ dlg_nothingtoconfig()

static void dlg_nothingtoconfig ( HWND  hWnd)
static

Definition at line 229 of file localui.c.

230{
231 WCHAR res_PortW[IDS_LOCALPORT_MAXLEN];
232 WCHAR res_nothingW[IDS_NOTHINGTOCONFIG_MAXLEN];
233
234 res_PortW[0] = '\0';
235 res_nothingW[0] = '\0';
238
239 MessageBoxW(hWnd, res_nothingW, res_PortW, MB_OK | MB_ICONINFORMATION);
240}
#define IDS_NOTHINGTOCONFIG
Definition: localui.h:38
#define IDS_NOTHINGTOCONFIG_MAXLEN
Definition: localui.h:44
#define MB_ICONINFORMATION
Definition: winuser.h:802

Referenced by localui_ConfigurePortUI().

◆ dlg_port_already_exists()

static void dlg_port_already_exists ( HWND  hWnd,
LPCWSTR  portname 
)
static

Definition at line 176 of file localui.c.

177{
178 WCHAR res_PortW[IDS_LOCALPORT_MAXLEN];
179 WCHAR res_PortExistsW[IDS_PORTEXISTS_MAXLEN];
181 DWORD len;
182
183 res_PortW[0] = '\0';
184 res_PortExistsW[0] = '\0';
187
188 len = lstrlenW(portname) + IDS_PORTEXISTS_MAXLEN + 1;
189 message = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
190 if (message) {
191 message[0] = '\0';
192 swprintf(message, res_PortExistsW, portname);
193 MessageBoxW(hWnd, message, res_PortW, MB_OK | MB_ICONERROR);
195 }
196}
#define IDS_PORTEXISTS
Definition: localui.h:37
#define IDS_PORTEXISTS_MAXLEN
Definition: localui.h:43

Referenced by localui_AddPortUI().

◆ dlg_win32error()

static void dlg_win32error ( HWND  hWnd,
DWORD  lasterror 
)
static

Definition at line 246 of file localui.c.

247{
248 WCHAR res_PortW[IDS_LOCALPORT_MAXLEN];
250 DWORD res;
251
252 res_PortW[0] = '\0';
254
255
257 NULL, lasterror, 0, (LPWSTR) &message, 0, NULL);
258
259 if (res > 0) {
260 MessageBoxW(hWnd, message, res_PortW, MB_OK | MB_ICONERROR);
262 }
263}
#define NULL
Definition: types.h:112
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:419

Referenced by dlgproc_addport().

◆ dlgproc_addport()

static INT_PTR CALLBACK dlgproc_addport ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 269 of file localui.c.

270{
273 DWORD dummy;
274 DWORD len;
275 DWORD res;
276
277 switch(msg)
278 {
279 case WM_INITDIALOG:
281 return TRUE;
282
283 case WM_COMMAND:
285 {
287 /* length in WCHAR, without the '\0' */
289 data->portname = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
290
291 if (!data->portname) {
293 return TRUE;
294 }
295 /* length is in WCHAR, including the '\0' */
296 GetDlgItemTextW(hwnd, ADDPORT_EDIT, data->portname, len + 1);
298 res = XcvDataW( data->hXcv, cmd_PortIsValidW, (PBYTE) data->portname,
299 (lstrlenW(data->portname) + 1) * sizeof(WCHAR),
300 (PBYTE) &dummy, 0, &len, &status);
301
302 TRACE("got %u with status %u\n", res, status);
303 if (res && (status == ERROR_SUCCESS)) {
304 /* The caller must free data->portname */
306 return TRUE;
307 }
308
309 if (res && (status == ERROR_INVALID_NAME)) {
310 dlg_invalid_portname(hwnd, data->portname);
311 HeapFree(GetProcessHeap(), 0, data->portname);
312 data->portname = NULL;
313 return TRUE;
314 }
315
317 HeapFree(GetProcessHeap(), 0, data->portname);
318 data->portname = NULL;
319 return TRUE;
320 }
321
323 {
325 return TRUE;
326 }
327 return FALSE;
328 }
329 return FALSE;
330}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
#define msg(x)
Definition: auth_time.c:54
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_NAME
Definition: compat.h:103
#define ADDPORT_EDIT
Definition: localui.h:29
static void dlg_invalid_portname(HWND hWnd, LPCWSTR portname)
Definition: localui.c:202
static void dlg_win32error(HWND hWnd, DWORD lasterror)
Definition: localui.c:246
static const WCHAR cmd_PortIsValidW[]
Definition: localui.c:55
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define MAKEWPARAM(l, h)
Definition: winuser.h:4009
#define WM_GETTEXTLENGTH
Definition: winuser.h:1619
#define DWLP_USER
Definition: winuser.h:872
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define IDOK
Definition: winuser.h:830
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BN_CLICKED
Definition: winuser.h:1925
#define SetWindowLongPtrW
Definition: winuser.h:5346
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by localui_AddPortUI().

◆ dlgproc_lptconfig()

static INT_PTR CALLBACK dlgproc_lptconfig ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 343 of file localui.c.

344{
346 WCHAR bufferW[16];
348 DWORD dummy;
349 DWORD len;
350 DWORD res;
351
352
353 switch(msg)
354 {
355 case WM_INITDIALOG:
357 data = (lptconfig_t *) lparam;
358
359 /* Get current setting */
360 data->value = 45;
363 (PBYTE) &dummy, 0,
364 (PBYTE) &data->value, sizeof(data->value), &len, &status);
365
366 TRACE("got %u with status %u\n", res, status);
367
368 /* Set current setting as the initial value in the Dialog */
370 return TRUE;
371
372 case WM_COMMAND:
374 {
376
377 status = FALSE;
379 /* length is in WCHAR, including the '\0' */
380 GetDlgItemTextW(hwnd, LPTCONFIG_EDIT, bufferW, ARRAY_SIZE(bufferW));
381 TRACE("got %s and %u (translated: %u)\n", debugstr_w(bufferW), res, status);
382
383 /* native localui.dll use the same limits */
384 if ((res > 0) && (res < 1000000) && status) {
385 swprintf(bufferW, fmt_uW, res);
387 (PBYTE) bufferW,
388 (lstrlenW(bufferW) +1) * sizeof(WCHAR),
389 (PBYTE) &dummy, 0, &len, &status);
390
391 TRACE("got %u with status %u\n", res, status);
393 return TRUE;
394 }
395
396 /* Set initial value and rerun the Dialog */
398 return TRUE;
399 }
400
402 {
404 return TRUE;
405 }
406 return FALSE;
407 }
408 return FALSE;
409}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define debugstr_w
Definition: kernel32.h:32
#define LPTCONFIG_EDIT
Definition: localui.h:33
char * value
Definition: compiler.c:67
static const WCHAR fmt_uW[]
Definition: localui.c:60
static const WCHAR cmd_ConfigureLPTPortCommandOKW[]
Definition: localui.c:45
static const WCHAR cmd_GetTransmissionRetryTimeoutW[]
Definition: localui.c:52
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)

Referenced by dlg_configure_lpt().

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 682 of file localui.c.

683{
684 TRACE("(%p, %d, %p)\n",hinstDLL, fdwReason, lpvReserved);
685
686 switch(fdwReason)
687 {
689 DisableThreadLibraryCalls( hinstDLL );
690 LOCALUI_hInstance = hinstDLL;
691 break;
692 }
693 return TRUE;
694}
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static IN DWORD IN LPVOID lpvReserved

◆ get_type_from_name()

static DWORD get_type_from_name ( LPCWSTR  name)
static

Definition at line 417 of file localui.c.

418{
419 HANDLE hfile;
420
422 return PORT_IS_LPT;
423
425 return PORT_IS_COM;
426
428 return PORT_IS_FILE;
429
430 if (name[0] == '/')
431 return PORT_IS_UNIXNAME;
432
433 if (name[0] == '|')
434 return PORT_IS_PIPE;
435
437 return PORT_IS_CUPS;
438
440 return PORT_IS_LPR;
441
442 /* Must be a file or a directory. Does the file exist ? */
444 TRACE("%p for OPEN_EXISTING on %s\n", hfile, debugstr_w(name));
445 if (hfile == INVALID_HANDLE_VALUE) {
446 /* Can we create the file? */
448 TRACE("%p for OPEN_ALWAYS\n", hfile);
449 }
450 if (hfile != INVALID_HANDLE_VALUE) {
451 CloseHandle(hfile);
452 return PORT_IS_FILENAME;
453 }
454 /* We can't use the name. use GetLastError() for the reason */
455 return PORT_IS_UNKNOWN;
456}
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define wcsicmp
Definition: compat.h:15
#define PORT_IS_LPR
Definition: localui.h:59
#define PORT_IS_CUPS
Definition: localui.h:58
#define FILE_FLAG_DELETE_ON_CLOSE
Definition: disk.h:42
#define OPEN_ALWAYS
Definition: disk.h:70
#define GENERIC_WRITE
Definition: nt_native.h:90
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define PORT_IS_LPT
Definition: spoolss.h:15
#define PORT_IS_COM
Definition: spoolss.h:16
#define PORT_IS_FILE
Definition: spoolss.h:17
#define PORT_IS_PIPE
Definition: spoolss.h:21
#define PORT_IS_FILENAME
Definition: spoolss.h:18
#define PORT_IS_UNKNOWN
Definition: spoolss.h:14
#define PORT_IS_UNIXNAME
Definition: spoolss.h:20
Definition: name.c:39
static const WCHAR portname_LPT[]
Definition: localui.c:61
static const WCHAR portname_CUPS[]
Definition: localui.c:64
static const WCHAR portname_LPR[]
Definition: localui.c:65
static const WCHAR portname_FILE[]
Definition: localui.c:63
static const WCHAR portname_COM[]
Definition: localui.c:62

Referenced by localui_ConfigurePortUI().

◆ InitializePrintMonitorUI()

PMONITORUI WINAPI InitializePrintMonitorUI ( void  )

Definition at line 665 of file localui.c.

666{
667 static MONITORUI mymonitorui =
668 {
669 sizeof(MONITORUI),
673 };
674
675 TRACE("=> %p\n", &mymonitorui);
676 return &mymonitorui;
677}
struct _MONITORUI MONITORUI
static BOOL WINAPI localui_ConfigurePortUI(PCWSTR pName, HWND hWnd, PCWSTR pPortName)
Definition: localui.c:572
static BOOL WINAPI localui_DeletePortUI(PCWSTR pName, HWND hWnd, PCWSTR pPortName)
Definition: localui.c:623
static BOOL WINAPI localui_AddPortUI(PCWSTR pName, HWND hWnd, PCWSTR pMonitorName, PWSTR *ppPortName)
Definition: localui.c:502

◆ localui_AddPortUI()

static BOOL WINAPI localui_AddPortUI ( PCWSTR  pName,
HWND  hWnd,
PCWSTR  pMonitorName,
PWSTR ppPortName 
)
static

Definition at line 502 of file localui.c.

503{
505 HANDLE hXcv;
506 DWORD needed;
507 DWORD dummy;
509 DWORD res = FALSE;
510
511 TRACE( "(%s, %p, %s, %p) (*ppPortName: %p)\n", debugstr_w(pName), hWnd,
512 debugstr_w(pMonitorName), ppPortName, ppPortName ? *ppPortName : NULL);
513
514 if (open_monitor_by_name(XcvMonitorW, pMonitorName, &hXcv)) {
515
516 ZeroMemory(&data, sizeof(addportui_t));
517 data.hXcv = hXcv;
520
521 TRACE("got %u with %u for %s\n", res, GetLastError(), debugstr_w(data.portname));
522
523 if (ppPortName) *ppPortName = NULL;
524
525 if (res) {
526 res = XcvDataW(hXcv, cmd_AddPortW, (PBYTE) data.portname,
527 (lstrlenW(data.portname)+1) * sizeof(WCHAR),
528 (PBYTE) &dummy, 0, &needed, &status);
529
530 TRACE("got %u with status %u\n", res, status);
531 if (res && (status == ERROR_SUCCESS) && ppPortName) {
532 /* Native localui uses GlobalAlloc also.
533 The caller must GlobalFree the buffer */
534 *ppPortName = GlobalAlloc(GPTR, (lstrlenW(data.portname)+1) * sizeof(WCHAR));
535 if (*ppPortName) lstrcpyW(*ppPortName, data.portname);
536 }
537
538 if (res && (status == ERROR_ALREADY_EXISTS)) {
540 /* Native localui also return "TRUE" from AddPortUI in this case */
541 }
542
543 HeapFree(GetProcessHeap(), 0, data.portname);
544 }
545 else
546 {
548 }
550 }
551
552 TRACE("=> %u with %u\n", res, GetLastError());
553 return res;
554}
#define lstrcpyW
Definition: compat.h:749
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define ADDPORT_DIALOG
Definition: localui.h:28
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
static LPSTR pName
Definition: security.c:75
static void dlg_port_already_exists(HWND hWnd, LPCWSTR portname)
Definition: localui.c:176
static const WCHAR XcvMonitorW[]
Definition: localui.c:67
static BOOL open_monitor_by_name(LPCWSTR pPrefix, LPCWSTR pPort, HANDLE *phandle)
Definition: localui.c:462
static INT_PTR CALLBACK dlgproc_addport(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: localui.c:269
static const WCHAR cmd_AddPortW[]
Definition: localui.c:44
#define ZeroMemory
Definition: winbase.h:1712
#define GPTR
Definition: winbase.h:296
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176

Referenced by InitializePrintMonitorUI().

◆ localui_ConfigurePortUI()

static BOOL WINAPI localui_ConfigurePortUI ( PCWSTR  pName,
HWND  hWnd,
PCWSTR  pPortName 
)
static

Definition at line 572 of file localui.c.

573{
574 HANDLE hXcv;
575 DWORD res;
576
577 TRACE("(%s, %p, %s)\n", debugstr_w(pName), hWnd, debugstr_w(pPortName));
578 if (open_monitor_by_name(XcvPortW, pPortName, &hXcv)) {
579
580 res = get_type_from_name(pPortName);
581 switch(res)
582 {
583
584 case PORT_IS_COM:
585 res = dlg_configure_com(hXcv, hWnd, pPortName);
586 break;
587
588 case PORT_IS_LPT:
590 break;
591
592 default:
595 res = FALSE;
596 }
597
599 return res;
600 }
601 return FALSE;
602
603}
static void dlg_nothingtoconfig(HWND hWnd)
Definition: localui.c:229
static BOOL dlg_configure_lpt(HANDLE hXcv, HWND hWnd)
Definition: localui.c:155
static BOOL dlg_configure_com(HANDLE hXcv, HWND hWnd, PCWSTR pPortName)
Definition: localui.c:108
static const WCHAR XcvPortW[]
Definition: localui.c:68
static DWORD get_type_from_name(LPCWSTR name)
Definition: localui.c:417

Referenced by InitializePrintMonitorUI().

◆ localui_DeletePortUI()

static BOOL WINAPI localui_DeletePortUI ( PCWSTR  pName,
HWND  hWnd,
PCWSTR  pPortName 
)
static

Definition at line 623 of file localui.c.

624{
625 HANDLE hXcv;
626 DWORD dummy;
627 DWORD needed;
629
630 TRACE("(%s, %p, %s)\n", debugstr_w(pName), hWnd, debugstr_w(pPortName));
631
632 if ((!pPortName) || (!pPortName[0])) {
634 return FALSE;
635 }
636
637 if (open_monitor_by_name(XcvPortW, pPortName, &hXcv)) {
638 /* native localui tests here for LPT / COM - Ports and failed with
639 ERROR_NOT_SUPPORTED. */
640 if (XcvDataW(hXcv, cmd_DeletePortW, (LPBYTE) pPortName,
641 (lstrlenW(pPortName)+1) * sizeof(WCHAR), (LPBYTE) &dummy, 0, &needed, &status)) {
642
645 return (status == ERROR_SUCCESS);
646 }
648 return FALSE;
649 }
651 return FALSE;
652}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
unsigned char * LPBYTE
Definition: typedefs.h:53
static const WCHAR cmd_DeletePortW[]
Definition: localui.c:48
#define ERROR_UNKNOWN_PORT
Definition: winerror.h:1103

Referenced by InitializePrintMonitorUI().

◆ open_monitor_by_name()

static BOOL open_monitor_by_name ( LPCWSTR  pPrefix,
LPCWSTR  pPort,
HANDLE phandle 
)
static

Definition at line 462 of file localui.c.

463{
466 BOOL res;
467
468 * phandle = 0;
469 TRACE("(%s,%s)\n", debugstr_w(pPrefix),debugstr_w(pPort) );
470
471 fullname = strdupWW(pPrefix, pPort);
472 pd.pDatatype = NULL;
473 pd.pDevMode = NULL;
475
476 res = OpenPrinterW(fullname, phandle, &pd);
478 return res;
479}
const char * fullname
Definition: shader.c:1766
LPDEVMODEW pDevMode
Definition: winspool.h:862
ACCESS_MASK DesiredAccess
Definition: winspool.h:863
static LPWSTR strdupWW(LPCWSTR pPrefix, LPCWSTR pSuffix)
Definition: localui.c:89
#define SERVER_ACCESS_ADMINISTER
Definition: winspool.h:1366
WINBOOL WINAPI OpenPrinterW(LPWSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSW pDefault)
Definition: printers.c:2653

Referenced by localui_AddPortUI(), localui_ConfigurePortUI(), and localui_DeletePortUI().

◆ strdupWW()

static LPWSTR strdupWW ( LPCWSTR  pPrefix,
LPCWSTR  pSuffix 
)
static

Definition at line 89 of file localui.c.

90{
91 LPWSTR ptr;
92 DWORD len;
93
94 len = lstrlenW(pPrefix) + (pSuffix ? lstrlenW(pSuffix) : 0) + 1;
95 ptr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
96 if (ptr) {
97 lstrcpyW(ptr, pPrefix);
98 if (pSuffix) lstrcatW(ptr, pSuffix);
99 }
100 return ptr;
101}
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static PVOID ptr
Definition: dispmode.c:27

Referenced by open_monitor_by_name().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( localui  )

Variable Documentation

◆ cmd_AddPortW

const WCHAR cmd_AddPortW[] = {'A','d','d','P','o','r','t',0}
static

Definition at line 44 of file localui.c.

Referenced by localui_AddPortUI().

◆ cmd_ConfigureLPTPortCommandOKW

const WCHAR cmd_ConfigureLPTPortCommandOKW[]
static
Initial value:
= {'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}

Definition at line 45 of file localui.c.

Referenced by dlgproc_lptconfig().

◆ cmd_DeletePortW

const WCHAR cmd_DeletePortW[] = {'D','e','l','e','t','e','P','o','r','t',0}
static

Definition at line 48 of file localui.c.

Referenced by localui_DeletePortUI().

◆ cmd_GetDefaultCommConfigW

const WCHAR cmd_GetDefaultCommConfigW[]
static
Initial value:
= {'G','e','t',
'D','e','f','a','u','l','t',
'C','o','m','m','C','o','n','f','i','g',0}

Definition at line 49 of file localui.c.

Referenced by dlg_configure_com().

◆ cmd_GetTransmissionRetryTimeoutW

const WCHAR cmd_GetTransmissionRetryTimeoutW[]
static
Initial value:
= {'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}

Definition at line 52 of file localui.c.

Referenced by dlgproc_lptconfig().

◆ cmd_PortIsValidW

const WCHAR cmd_PortIsValidW[] = {'P','o','r','t','I','s','V','a','l','i','d',0}
static

Definition at line 55 of file localui.c.

Referenced by dlgproc_addport().

◆ cmd_SetDefaultCommConfigW

const WCHAR cmd_SetDefaultCommConfigW[]
static
Initial value:
= {'S','e','t',
'D','e','f','a','u','l','t',
'C','o','m','m','C','o','n','f','i','g',0}

Definition at line 56 of file localui.c.

Referenced by dlg_configure_com().

◆ fmt_uW

const WCHAR fmt_uW[] = {'%','u',0}
static

Definition at line 60 of file localui.c.

Referenced by dlgproc_lptconfig().

◆ LOCALUI_hInstance

◆ portname_COM

const WCHAR portname_COM[] = {'C','O','M',0}
static

Definition at line 62 of file localui.c.

Referenced by get_type_from_name().

◆ portname_CUPS

const WCHAR portname_CUPS[] = {'C','U','P','S',':',0}
static

Definition at line 64 of file localui.c.

Referenced by get_type_from_name().

◆ portname_FILE

const WCHAR portname_FILE[] = {'F','I','L','E',':',0}
static

Definition at line 63 of file localui.c.

Referenced by get_type_from_name().

◆ portname_LPR

const WCHAR portname_LPR[] = {'L','P','R',':',0}
static

Definition at line 65 of file localui.c.

Referenced by get_type_from_name().

◆ portname_LPT

const WCHAR portname_LPT[] = {'L','P','T',0}
static

Definition at line 61 of file localui.c.

Referenced by get_type_from_name().

◆ XcvMonitorW

const WCHAR XcvMonitorW[] = {',','X','c','v','M','o','n','i','t','o','r',' ',0}
static

Definition at line 67 of file localui.c.

Referenced by localui_AddPortUI().

◆ XcvPortW

const WCHAR XcvPortW[] = {',','X','c','v','P','o','r','t',' ',0}
static

Definition at line 68 of file localui.c.

Referenced by localui_ConfigurePortUI(), and localui_DeletePortUI().