winspool: Implement AddPortEx.

This commit is contained in:
Detlef Riekenberg 2007-06-04 00:23:55 +02:00 committed by Alexandre Julliard
parent 60cde93337
commit 0c71799d02
2 changed files with 116 additions and 19 deletions

View File

@ -6091,11 +6091,75 @@ BOOL WINAPI AddPortW(LPWSTR pName, HWND hWnd, LPWSTR pMonitorName)
* See AddPortExW. * See AddPortExW.
* *
*/ */
BOOL WINAPI AddPortExA(HANDLE hMonitor, LPSTR pName, DWORD Level, LPBYTE lpBuffer, LPSTR lpMonitorName) BOOL WINAPI AddPortExA(LPSTR pName, DWORD level, LPBYTE pBuffer, LPSTR pMonitorName)
{ {
FIXME("(%p, %s, %d, %p, %s), stub!\n",hMonitor, debugstr_a(pName), Level, PORT_INFO_2W pi2W;
lpBuffer, debugstr_a(lpMonitorName)); PORT_INFO_2A * pi2A;
return FALSE; LPWSTR nameW = NULL;
LPWSTR monitorW = NULL;
DWORD len;
BOOL res;
pi2A = (PORT_INFO_2A *) pBuffer;
TRACE("(%s, %d, %p, %s): %s\n", debugstr_a(pName), level, pBuffer,
debugstr_a(pMonitorName), debugstr_a(pi2A ? pi2A->pPortName : NULL));
if ((level < 1) || (level > 2)) {
SetLastError(ERROR_INVALID_LEVEL);
return FALSE;
}
if (!pi2A) {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (pName) {
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
}
if (pMonitorName) {
len = MultiByteToWideChar(CP_ACP, 0, pMonitorName, -1, NULL, 0);
monitorW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, pMonitorName, -1, monitorW, len);
}
ZeroMemory(&pi2W, sizeof(PORT_INFO_2W));
if (pi2A->pPortName) {
len = MultiByteToWideChar(CP_ACP, 0, pi2A->pPortName, -1, NULL, 0);
pi2W.pPortName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, pi2A->pPortName, -1, pi2W.pPortName, len);
}
if (level > 1) {
if (pi2A->pMonitorName) {
len = MultiByteToWideChar(CP_ACP, 0, pi2A->pMonitorName, -1, NULL, 0);
pi2W.pMonitorName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, pi2A->pMonitorName, -1, pi2W.pMonitorName, len);
}
if (pi2A->pDescription) {
len = MultiByteToWideChar(CP_ACP, 0, pi2A->pDescription, -1, NULL, 0);
pi2W.pDescription = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, pi2A->pDescription, -1, pi2W.pDescription, len);
}
pi2W.fPortType = pi2A->fPortType;
pi2W.Reserved = pi2A->Reserved;
}
res = AddPortExW(nameW, level, (LPBYTE) &pi2W, monitorW);
HeapFree(GetProcessHeap(), 0, nameW);
HeapFree(GetProcessHeap(), 0, monitorW);
HeapFree(GetProcessHeap(), 0, pi2W.pPortName);
HeapFree(GetProcessHeap(), 0, pi2W.pMonitorName);
HeapFree(GetProcessHeap(), 0, pi2W.pDescription);
return res;
} }
/****************************************************************************** /******************************************************************************
@ -6104,25 +6168,60 @@ BOOL WINAPI AddPortExA(HANDLE hMonitor, LPSTR pName, DWORD Level, LPBYTE lpBuffe
* Add a Port for a specific Monitor, without presenting a user interface * Add a Port for a specific Monitor, without presenting a user interface
* *
* PARAMS * PARAMS
* hMonitor [I] Handle from InitializePrintMonitor2()
* pName [I] Servername or NULL (local Computer) * pName [I] Servername or NULL (local Computer)
* Level [I] Structure-Level (1 or 2) for lpBuffer * level [I] Structure-Level (1 or 2) for pBuffer
* lpBuffer [I] PTR to: PORT_INFO_1 or PORT_INFO_2 * pBuffer [I] PTR to: PORT_INFO_1 or PORT_INFO_2
* lpMonitorName [I] Name of the Monitor that manage the Port or NULL * pMonitorName [I] Name of the Monitor that manage the Port
* *
* RETURNS * RETURNS
* Success: TRUE * Success: TRUE
* Failure: FALSE * Failure: FALSE
* *
* BUGS
* only a Stub
*
*/ */
BOOL WINAPI AddPortExW(HANDLE hMonitor, LPWSTR pName, DWORD Level, LPBYTE lpBuffer, LPWSTR lpMonitorName) BOOL WINAPI AddPortExW(LPWSTR pName, DWORD level, LPBYTE pBuffer, LPWSTR pMonitorName)
{ {
FIXME("(%p, %s, %d, %p, %s), stub!\n", hMonitor, debugstr_w(pName), Level, PORT_INFO_2W * pi2;
lpBuffer, debugstr_w(lpMonitorName)); monitor_t * pm;
return FALSE; DWORD res = FALSE;
pi2 = (PORT_INFO_2W *) pBuffer;
TRACE("(%s, %d, %p, %s): %s %s %s\n", debugstr_w(pName), level, pBuffer,
debugstr_w(pMonitorName), debugstr_w(pi2 ? pi2->pPortName : NULL),
debugstr_w(((level > 1) && pi2) ? pi2->pMonitorName : NULL),
debugstr_w(((level > 1) && pi2) ? pi2->pDescription : NULL));
if ((level < 1) || (level > 2)) {
SetLastError(ERROR_INVALID_LEVEL);
return FALSE;
}
if (!pi2) {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
/* we need a valid Monitorname */
if (!pMonitorName) {
SetLastError(RPC_X_NULL_REF_POINTER);
return FALSE;
}
if (!pMonitorName[0]) {
SetLastError(ERROR_NOT_SUPPORTED);
return FALSE;
}
/* load the Monitor */
pm = monitor_load(pMonitorName, NULL);
if (!pm) return FALSE;
if (pm->monitor && pm->monitor->pfnAddPortEx) {
res = pm->monitor->pfnAddPortEx(pName, level, pBuffer, pMonitorName);
TRACE("got %u with %u\n", res, GetLastError());
}
monitor_unload(pm);
return res;
} }
/****************************************************************************** /******************************************************************************

View File

@ -1349,10 +1349,8 @@ BOOL WINAPI AddPortA(LPSTR pName, HWND hWnd, LPSTR pMonitorName);
BOOL WINAPI AddPortW(LPWSTR pName, HWND hWnd, LPWSTR pMonitorName); BOOL WINAPI AddPortW(LPWSTR pName, HWND hWnd, LPWSTR pMonitorName);
#define AddPort WINELIB_NAME_AW(AddPort) #define AddPort WINELIB_NAME_AW(AddPort)
BOOL WINAPI AddPortExA(HANDLE hMonitor, LPSTR pName, DWORD Level, BOOL WINAPI AddPortExA(LPSTR, DWORD, LPBYTE, LPSTR);
LPBYTE lpBuffer, LPSTR lpMonitorName); BOOL WINAPI AddPortExW(LPWSTR, DWORD, LPBYTE, LPWSTR);
BOOL WINAPI AddPortExW(HANDLE hMonitor, LPWSTR pName, DWORD Level,
LPBYTE lpBuffer, LPWSTR lpMonitorName);
#define AddPortEx WINELIB_NAME_AW(AddPortEx) #define AddPortEx WINELIB_NAME_AW(AddPortEx)
BOOL WINAPI ConfigurePortA(LPSTR pName, HWND hWnd, LPSTR pPortName); BOOL WINAPI ConfigurePortA(LPSTR pName, HWND hWnd, LPSTR pPortName);