Huw Davies : winspool: Skip scanner-only devices.

Alexandre Julliard julliard at winehq.org
Fri Sep 14 10:54:22 CDT 2012


Module: wine
Branch: master
Commit: 2f3d13a49ded38b5905797881981494a61ad093c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2f3d13a49ded38b5905797881981494a61ad093c

Author: Huw Davies <huw at codeweavers.com>
Date:   Fri Sep 14 13:40:10 2012 +0100

winspool: Skip scanner-only devices.

---

 dlls/winspool.drv/info.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index 38266c9..7509a8e 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -857,6 +857,20 @@ static WCHAR *get_cups_option( const char *name, int num_options, cups_option_t
     return ret;
 }
 
+static cups_ptype_t get_cups_printer_type( const cups_dest_t *dest )
+{
+    WCHAR *type = get_cups_option( "printer-type", dest->num_options, dest->options ), *end;
+    cups_ptype_t ret = 0;
+
+    if (type && *type)
+    {
+        ret = (cups_ptype_t)strtoulW( type, &end, 10 );
+        if (*end) ret = 0;
+    }
+    HeapFree( GetProcessHeap(), 0, type );
+    return ret;
+}
+
 static BOOL CUPS_LoadPrinters(void)
 {
     int	                  i, nrofdests;
@@ -868,6 +882,7 @@ static BOOL CUPS_LoadPrinters(void)
     char    loaderror[256];
     WCHAR   nameW[MAX_PATH];
     HANDLE  added_printer;
+    cups_ptype_t printer_type;
 
     cupshandle = wine_dlopen(SONAME_LIBCUPS, RTLD_NOW, loaderror, sizeof(loaderror));
     if (!cupshandle) {
@@ -893,12 +908,20 @@ static BOOL CUPS_LoadPrinters(void)
     TRACE("Found %d CUPS %s:\n", nrofdests, (nrofdests == 1) ? "printer" : "printers");
     for (i=0;i<nrofdests;i++) {
         MultiByteToWideChar(CP_UNIXCP, 0, dests[i].name, -1, nameW, sizeof(nameW) / sizeof(WCHAR));
+        printer_type = get_cups_printer_type( dests + i );
+
+        TRACE( "Printer %d: %s. printer_type %x\n", i, debugstr_w(nameW), printer_type );
+
+        if (printer_type & 0x2000000 /* CUPS_PRINTER_SCANNER */)
+        {
+            TRACE( "skipping scanner-only device\n" );
+            continue;
+        }
 
         port = HeapAlloc(GetProcessHeap(), 0, sizeof(CUPS_Port) + lstrlenW(nameW) * sizeof(WCHAR));
         lstrcpyW(port, CUPS_Port);
         lstrcatW(port, nameW);
 
-        TRACE("Printer %d: %s\n", i, debugstr_w(nameW));
         if(RegOpenKeyW(hkeyPrinters, nameW, &hkeyPrinter) == ERROR_SUCCESS) {
             DWORD status = get_dword_from_reg( hkeyPrinter, StatusW );
             /* Printer already in registry, delete the tag added in WINSPOOL_LoadSystemPrinters




More information about the wine-cvs mailing list