winspool: Start support for XcvMonitor and XcvPort in OpenPrinter.

This commit is contained in:
Detlef Riekenberg 2007-01-05 01:09:13 +01:00 committed by Alexandre Julliard
parent 58d1e2fa4d
commit f85b02b6ad
1 changed files with 51 additions and 17 deletions

View File

@ -116,6 +116,7 @@ typedef struct {
typedef struct { typedef struct {
LPWSTR name; LPWSTR name;
LPWSTR printername; LPWSTR printername;
monitor_t *pm;
jobqueue_t *queue; jobqueue_t *queue;
started_doc_t *doc; started_doc_t *doc;
} opened_printer_t; } opened_printer_t;
@ -234,6 +235,8 @@ static const WCHAR deviceW[] = {'d','e','v','i','c','e',0};
static const WCHAR devicesW[] = {'d','e','v','i','c','e','s',0}; static const WCHAR devicesW[] = {'d','e','v','i','c','e','s',0};
static const WCHAR windowsW[] = {'w','i','n','d','o','w','s',0}; static const WCHAR windowsW[] = {'w','i','n','d','o','w','s',0};
static const WCHAR emptyStringW[] = {0}; static const WCHAR emptyStringW[] = {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};
static const WCHAR May_Delete_Value[] = {'W','i','n','e','M','a','y','D','e','l','e','t','e','M','e',0}; static const WCHAR May_Delete_Value[] = {'W','i','n','e','M','a','y','D','e','l','e','t','e','M','e',0};
@ -1154,7 +1157,7 @@ static DWORD monitor_loadall(void)
* On failure, NULL is returned * On failure, NULL is returned
*/ */
static monitor_t * monitor_load_by_port(LPWSTR portname) static monitor_t * monitor_load_by_port(LPCWSTR portname)
{ {
HKEY hroot; HKEY hroot;
HKEY hport; HKEY hport;
@ -1375,6 +1378,7 @@ static HANDLE get_opened_printer_entry(LPCWSTR name, LPPRINTER_DEFAULTSW pDefaul
LPCWSTR printername; LPCWSTR printername;
HKEY hkeyPrinters; HKEY hkeyPrinters;
HKEY hkeyPrinter; HKEY hkeyPrinter;
DWORD len;
servername = get_servername_from_name(name); servername = get_servername_from_name(name);
if (servername) { if (servername) {
@ -1446,23 +1450,53 @@ static HANDLE get_opened_printer_entry(LPCWSTR name, LPPRINTER_DEFAULTSW pDefaul
} }
if (printername) { if (printername) {
len = sizeof(XcvMonitorW)/sizeof(WCHAR) - 1;
/* Does the Printer exist? */ if (strncmpW(printername, XcvMonitorW, len) == 0) {
if (RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) != ERROR_SUCCESS) { /* OpenPrinter(",XcvMonitor " detected */
ERR("Can't create Printers key\n"); TRACE(",XcvMonitor: %s\n", debugstr_w(&printername[len]));
handle = 0; printer->pm = monitor_load(&printername[len], NULL);
goto end; if (printer->pm == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
handle = 0;
goto end;
}
} }
if (RegOpenKeyW(hkeyPrinters, printername, &hkeyPrinter) != ERROR_SUCCESS) { else
WARN("Printer not found in Registry: '%s'\n", debugstr_w(printername)); {
len = sizeof(XcvPortW)/sizeof(WCHAR) - 1;
if (strncmpW( printername, XcvPortW, len) == 0) {
/* OpenPrinter(",XcvPort " detected */
TRACE(",XcvPort: %s\n", debugstr_w(&printername[len]));
printer->pm = monitor_load_by_port(&printername[len]);
if (printer->pm == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
handle = 0;
goto end;
}
}
}
if (printer->pm) {
FIXME("pm->pfnXcvOpenPort not implemented\n");
}
else
{
/* Does the Printer exist? */
if (RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) != ERROR_SUCCESS) {
ERR("Can't create Printers key\n");
handle = 0;
goto end;
}
if (RegOpenKeyW(hkeyPrinters, printername, &hkeyPrinter) != ERROR_SUCCESS) {
WARN("Printer not found in Registry: '%s'\n", debugstr_w(printername));
RegCloseKey(hkeyPrinters);
SetLastError(ERROR_INVALID_PRINTER_NAME);
handle = 0;
goto end;
}
RegCloseKey(hkeyPrinter);
RegCloseKey(hkeyPrinters); RegCloseKey(hkeyPrinters);
SetLastError(ERROR_INVALID_PRINTER_NAME);
handle = 0;
goto end;
} }
RegCloseKey(hkeyPrinter);
RegCloseKey(hkeyPrinters);
} }
else else
{ {
@ -1489,6 +1523,7 @@ end:
LeaveCriticalSection(&printer_handles_cs); LeaveCriticalSection(&printer_handles_cs);
if (!handle && printer) { if (!handle && printer) {
/* Something failed: Free all resources */ /* Something failed: Free all resources */
monitor_unload(printer->pm);
HeapFree(GetProcessHeap(), 0, printer->printername); HeapFree(GetProcessHeap(), 0, printer->printername);
HeapFree(GetProcessHeap(), 0, printer->name); HeapFree(GetProcessHeap(), 0, printer->name);
if (!queue) HeapFree(GetProcessHeap(), 0, printer->queue); if (!queue) HeapFree(GetProcessHeap(), 0, printer->queue);
@ -1916,8 +1951,6 @@ BOOL WINAPI OpenPrinterA(LPSTR lpPrinterName,HANDLE *phPrinter,
* *
* BUGS * BUGS
*| Printer-Object not supported *| Printer-Object not supported
*| XcvMonitor not supported
*| XcvPort not supported
*| pDefaults is ignored *| pDefaults is ignored
* *
*/ */
@ -2879,6 +2912,7 @@ BOOL WINAPI ClosePrinter(HANDLE hPrinter)
} }
HeapFree(GetProcessHeap(), 0, printer->queue); HeapFree(GetProcessHeap(), 0, printer->queue);
} }
monitor_unload(printer->pm);
HeapFree(GetProcessHeap(), 0, printer->printername); HeapFree(GetProcessHeap(), 0, printer->printername);
HeapFree(GetProcessHeap(), 0, printer->name); HeapFree(GetProcessHeap(), 0, printer->name);
HeapFree(GetProcessHeap(), 0, printer); HeapFree(GetProcessHeap(), 0, printer);