Huw Davies : winspool: Set the printer status of old printers to indicate that they should check for driver updates .
Alexandre Julliard
julliard at winehq.org
Tue Jun 12 13:36:32 CDT 2012
Module: wine
Branch: master
Commit: 0ef0ce2938fcdb45dd5ca4a735ae10a9e22c89cc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0ef0ce2938fcdb45dd5ca4a735ae10a9e22c89cc
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Jun 12 09:42:48 2012 +0100
winspool: Set the printer status of old printers to indicate that they should check for driver updates.
---
dlls/winspool.drv/info.c | 61 +++++++++++++++++++++++++---------------------
1 files changed, 33 insertions(+), 28 deletions(-)
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index 022041c..a5ccf49 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -420,6 +420,36 @@ static int multi_sz_lenA(const char *str)
return ptr - str + 1;
}
+/*****************************************************************************
+ * get_dword_from_reg
+ *
+ * Return DWORD associated with name from hkey.
+ */
+static DWORD get_dword_from_reg( HKEY hkey, const WCHAR *name )
+{
+ DWORD sz = sizeof(DWORD), type, value = 0;
+ LONG ret;
+
+ ret = RegQueryValueExW( hkey, name, 0, &type, (LPBYTE)&value, &sz );
+
+ if (ret != ERROR_SUCCESS)
+ {
+ WARN( "Got ret = %d on name %s\n", ret, debugstr_w(name) );
+ return 0;
+ }
+ if (type != REG_DWORD)
+ {
+ ERR( "Got type %d\n", type );
+ return 0;
+ }
+ return value;
+}
+
+static inline DWORD set_reg_DWORD( HKEY hkey, const WCHAR *keyname, const DWORD value )
+{
+ return RegSetValueExW( hkey, keyname, 0, REG_DWORD, (const BYTE*)&value, sizeof(value) );
+}
+
static void
WINSPOOL_SetDefaultPrinter(const char *devname, const char *name, BOOL force) {
char qbuf[200];
@@ -738,12 +768,15 @@ static BOOL CUPS_LoadPrinters(void)
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
and continue */
TRACE("Printer already exists\n");
/* overwrite old LPR:* port */
RegSetValueExW(hkeyPrinter, PortW, 0, REG_SZ, (LPBYTE)port, (lstrlenW(port) + 1) * sizeof(WCHAR));
RegDeleteValueW(hkeyPrinter, May_Delete_Value);
+ /* flag that the PPD file should be checked for an update */
+ set_reg_DWORD( hkeyPrinter, StatusW, status | PRINTER_STATUS_DRIVER_UPDATE_NEEDED );
RegCloseKey(hkeyPrinter);
} else {
BOOL added_driver = FALSE;
@@ -990,11 +1023,6 @@ PRINTCAP_LoadPrinters(void) {
return hadprinter;
}
-static inline DWORD set_reg_DWORD(HKEY hkey, const WCHAR *keyname, const DWORD value)
-{
- return RegSetValueExW(hkey, keyname, 0, REG_DWORD, (const BYTE*)&value, sizeof(value));
-}
-
static inline DWORD set_reg_szW(HKEY hkey, const WCHAR *keyname, const WCHAR *value)
{
if (value)
@@ -3593,29 +3621,6 @@ BOOL WINAPI ResetPrinterW(HANDLE hPrinter, LPPRINTER_DEFAULTSW pDefault)
}
/*****************************************************************************
- * get_dword_from_reg
- *
- * Return DWORD associated with name from hkey.
- */
-static DWORD get_dword_from_reg( HKEY hkey, const WCHAR *name )
-{
- DWORD sz = sizeof(DWORD), type, value = 0;
- LONG ret;
-
- ret = RegQueryValueExW( hkey, name, 0, &type, (LPBYTE)&value, &sz );
-
- if(ret != ERROR_SUCCESS) {
- WARN("Got ret = %d on name %s\n", ret, debugstr_w(name));
- return 0;
- }
- if(type != REG_DWORD) {
- ERR("Got type %d\n", type);
- return 0;
- }
- return value;
-}
-
-/*****************************************************************************
* get_filename_from_reg [internal]
*
* Get ValueName from hkey storing result in out
More information about the wine-cvs
mailing list