Detlef Riekenberg : localui: Implement DeletePortUI.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Apr 18 06:58:45 CDT 2007
Module: wine
Branch: master
Commit: cecaf91d62809a8c7c68e988b7d066387feddc31
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cecaf91d62809a8c7c68e988b7d066387feddc31
Author: Detlef Riekenberg <wine.dev at web.de>
Date: Tue Apr 17 23:21:00 2007 +0200
localui: Implement DeletePortUI.
---
dlls/localui/Makefile.in | 2 +-
dlls/localui/localui.c | 76 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 75 insertions(+), 3 deletions(-)
diff --git a/dlls/localui/Makefile.in b/dlls/localui/Makefile.in
index f002e23..2250333 100644
--- a/dlls/localui/Makefile.in
+++ b/dlls/localui/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = localui.dll
-IMPORTS = kernel32
+IMPORTS = winspool kernel32
C_SRCS = \
localui.c
diff --git a/dlls/localui/localui.c b/dlls/localui/localui.c
index ae512e0..2153bcc 100644
--- a/dlls/localui/localui.c
+++ b/dlls/localui/localui.c
@@ -36,6 +36,50 @@ WINE_DEFAULT_DEBUG_CHANNEL(localui);
static HINSTANCE LOCALUI_hInstance;
+static const WCHAR cmd_DeletePortW[] = {'D','e','l','e','t','e','P','o','r','t',0};
+static const WCHAR XcvPortW[] = {',','X','c','v','P','o','r','t',' ',0};
+
+/*****************************************************
+ * strdupWW [internal]
+ */
+
+static LPWSTR strdupWW(LPCWSTR pPrefix, LPCWSTR pSuffix)
+{
+ LPWSTR ptr;
+ DWORD len;
+
+ len = lstrlenW(pPrefix) + lstrlenW(pSuffix) + 1;
+ ptr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (ptr) {
+ lstrcpyW(ptr, pPrefix);
+ lstrcatW(ptr, pSuffix);
+ }
+ return ptr;
+}
+
+/*****************************************************
+ * open_monitor_by_name [internal]
+ *
+ */
+static BOOL open_monitor_by_name(LPCWSTR pPrefix, LPCWSTR pPort, HANDLE * phandle)
+{
+ PRINTER_DEFAULTSW pd;
+ LPWSTR fullname;
+ BOOL res;
+
+ * phandle = 0;
+ TRACE("(%s,%s)\n", debugstr_w(pPrefix),debugstr_w(pPort) );
+
+ fullname = strdupWW(pPrefix, pPort);
+ pd.pDatatype = NULL;
+ pd.pDevMode = NULL;
+ pd.DesiredAccess = SERVER_ACCESS_ADMINISTER;
+
+ res = OpenPrinterW(fullname, phandle, &pd);
+ HeapFree(GetProcessHeap(), 0, fullname);
+ return res;
+}
+
/*****************************************************
* localui_AddPortUI [exported through MONITORUI]
*
@@ -94,11 +138,39 @@ static BOOL WINAPI localui_ConfigurePortUI(PCWSTR pName, HWND hWnd, PCWSTR pPort
* Success: TRUE
* Failure: FALSE
*
+ * NOTES
+ * Native localui does not allow to delete a COM / LPT - Port (ERROR_NOT_SUPPORTED)
+ *
*/
static BOOL WINAPI localui_DeletePortUI(PCWSTR pName, HWND hWnd, PCWSTR pPortName)
{
- FIXME("(%s, %p, %s) stub\n", debugstr_w(pName), hWnd, debugstr_w(pPortName));
- return TRUE;
+ HANDLE hXcv;
+ DWORD dummy;
+ DWORD needed;
+ DWORD status;
+
+ TRACE("(%s, %p, %s)\n", debugstr_w(pName), hWnd, debugstr_w(pPortName));
+
+ if ((!pPortName) || (!pPortName[0])) {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ if (open_monitor_by_name(XcvPortW, pPortName, &hXcv)) {
+ /* native localui tests here for LPT / COM - Ports and failed with
+ ERROR_NOT_SUPPORTED. */
+ if (XcvDataW(hXcv, cmd_DeletePortW, (LPBYTE) pPortName,
+ (lstrlenW(pPortName)+1) * sizeof(WCHAR), (LPBYTE) &dummy, 0, &needed, &status)) {
+
+ ClosePrinter(hXcv);
+ if (status != ERROR_SUCCESS) SetLastError(status);
+ return (status == ERROR_SUCCESS);
+ }
+ ClosePrinter(hXcv);
+ return FALSE;
+ }
+ SetLastError(ERROR_UNKNOWN_PORT);
+ return FALSE;
}
/*****************************************************
More information about the wine-cvs
mailing list