Printing bugfixes
Mike Hearn
mike at theoretic.com
Thu Jan 1 14:23:20 CST 2004
ChangeLog:
- Write out default printer name in the order used by WinME
- Support PRINTER_ENUM_DEFAULT
- Add FIXME for enumerating print providers
I'd appreciate somebody with a CUPs and lpr setup ensuring the order
change doesn't cause regressions. It appears correct to me, but as the
code worked before even though it looked like it shouldn't I might be
wrong.
Index: dlls/winspool/info.c
===================================================================
RCS file: /home/wine/wine/dlls/winspool/info.c,v
retrieving revision 1.88
diff -u -r1.88 info.c
--- dlls/winspool/info.c 27 Nov 2003 00:59:36 -0000 1.88
+++ dlls/winspool/info.c 18 Dec 2003 22:55:08 -0000
@@ -141,7 +141,7 @@
) {
char *buf = HeapAlloc(GetProcessHeap(),0,strlen(name)+strlen(devname)+strlen(",WINEPS,LPR:")+1);
- sprintf(buf,"%s,WINEPS,LPR:%s",devname,name);
+ sprintf(buf,"%s,WINEPS,LPR:%s",name,devname);
WriteProfileStringA("windows","device",buf);
HeapFree(GetProcessHeap(),0,buf);
}
@@ -422,6 +422,10 @@
return;
}
+ num = sizeof(PrinterName);
+ if (!GetDefaultPrinterW(PrinterName, &num))
+ WINSPOOL_SetDefaultPrinter("LPT1","Wine PostScript Driver", FALSE);
+
/* This ensures that all printer entries have a valid Name value. If causes
problems later if they don't. If one is found to be missed we create one
and set it equal to the name of the key */
@@ -2131,9 +2136,24 @@
if(lpdwNeeded)
*lpdwNeeded = 0;
- /* PRINTER_ENUM_DEFAULT is only supported under win9x, we behave like NT */
- if(dwType == PRINTER_ENUM_DEFAULT)
- return TRUE;
+ TRACE("dwType=%d, lpszName=%s, dwLevel=%d\n", (int)dwType, debugstr_w(lpszName), (int)dwLevel);
+
+ if (dwType & PRINTER_ENUM_DEFAULT) {
+ WCHAR default_name[255];
+ DWORD default_name_size = sizeof(default_name);
+
+ if (GetDefaultPrinterW(default_name, &default_name_size) == 0) {
+ ERR("Could not retrieve default printer\n");
+ return FALSE;
+ }
+
+ return WINSPOOL_EnumPrinters(PRINTER_ENUM_NAME, default_name, dwLevel, lpbPrinters, cbBuf, lpdwNeeded, lpdwReturned, unicode);
+ }
+
+ if ((dwType & PRINTER_ENUM_NAME) && (lpszName == NULL)) {
+ FIXME("We need to enumerate print providers here\n");
+ return FALSE;
+ }
if (dwType & PRINTER_ENUM_CONNECTIONS) {
FIXME("We dont handle PRINTER_ENUM_CONNECTIONS\n");
@@ -2193,6 +2213,12 @@
return FALSE;
}
TRACE("Printer %ld is %s\n", i, debugstr_w(PrinterName));
+
+ /* if we are looking for a specific printer and this isn't it, try the next */
+ if (dwType == PRINTER_ENUM_NAME) {
+ if (strcmpW(PrinterName, lpszName) != 0) continue;
+ }
+
if(RegOpenKeyW(hkeyPrinters, PrinterName, &hkeyPrinter) !=
ERROR_SUCCESS) {
ERR("Can't open key %s\n", debugstr_w(PrinterName));
@@ -3142,6 +3174,7 @@
}
*ptr = '\0';
+ TRACE("default printer is %s\n", name);
*namesize = strlen (name) + 1;
return TRUE;
}
More information about the wine-patches
mailing list