Huw Davies : winspool: Set the printer description from the cups printer-info option.
Alexandre Julliard
julliard at winehq.org
Fri Jun 15 13:34:40 CDT 2012
Module: wine
Branch: master
Commit: 5875185e342d0b574a60a5a0ee80025025d87333
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5875185e342d0b574a60a5a0ee80025025d87333
Author: Huw Davies <huw at codeweavers.com>
Date: Fri Jun 15 12:53:54 2012 +0100
winspool: Set the printer description from the cups printer-info option.
---
dlls/winspool.drv/info.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index 1a09195..e27d007 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -721,6 +721,7 @@ static void *cupshandle;
DO_FUNC(cupsFreeDests); \
DO_FUNC(cupsFreeOptions); \
DO_FUNC(cupsGetDests); \
+ DO_FUNC(cupsGetOption); \
DO_FUNC(cupsGetPPD); \
DO_FUNC(cupsParseOptions); \
DO_FUNC(cupsPrintFile);
@@ -778,8 +779,21 @@ static BOOL get_cups_ppd( const char *printer_name, const WCHAR *ppd )
return get_fallback_ppd( printer_name, ppd );
}
-static WCHAR comment_cups[] = {'W','I','N','E','P','S',' ','P','r','i','n','t','e','r',
- ' ','u','s','i','n','g',' ','C','U','P','S',0};
+static WCHAR *get_cups_option( const char *name, int num_options, cups_option_t *options )
+{
+ const char *value;
+ WCHAR *ret;
+ int len;
+
+ value = pcupsGetOption( name, num_options, options );
+ if (!value) return NULL;
+
+ len = MultiByteToWideChar( CP_UNIXCP, 0, value, -1, NULL, 0 );
+ ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+ if (ret) MultiByteToWideChar( CP_UNIXCP, 0, value, -1, ret, len );
+
+ return ret;
+}
static BOOL CUPS_LoadPrinters(void)
{
@@ -852,7 +866,7 @@ static BOOL CUPS_LoadPrinters(void)
pi2.pDatatype = rawW;
pi2.pPrintProcessor = WinPrintW;
pi2.pDriverName = nameW;
- pi2.pComment = comment_cups;
+ pi2.pComment = get_cups_option( "printer-info", dests[i].num_options, dests[i].options );
pi2.pLocation = emptyStringW;
pi2.pPortName = port;
pi2.pParameters = emptyStringW;
@@ -863,8 +877,10 @@ static BOOL CUPS_LoadPrinters(void)
if (added_printer) ClosePrinter( added_printer );
else if (GetLastError() != ERROR_PRINTER_ALREADY_EXISTS)
ERR( "printer '%s' not added by AddPrinter (error %d)\n", debugstr_w(nameW), GetLastError() );
+
+ HeapFree( GetProcessHeap(), 0, pi2.pComment );
}
- HeapFree(GetProcessHeap(),0,port);
+ HeapFree( GetProcessHeap(), 0, port );
hadprinter = TRUE;
if (dests[i].is_default) {
More information about the wine-cvs
mailing list