s3-printing: Convert print_driver_in_use.
authorSimo Sorce <idra@samba.org>
Mon, 26 Apr 2010 18:46:33 +0000 (14:46 -0400)
committerSimo Sorce <idra@samba.org>
Tue, 27 Jul 2010 14:27:10 +0000 (10:27 -0400)
Use spoolss_PrintInfo2 and winreg calls.

Signed-off-by: Jim McDonough <jmcd@samba.org>
source3/printing/nt_printing.c

index a36e40be7754fc47c2c8ac2826afe84e81edc7bc..0369ce8ed13072c40ad79d674d29baf8d5394e71 100644 (file)
@@ -4197,8 +4197,9 @@ bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
 {
        int snum;
        int n_services = lp_numservices();
-       NT_PRINTER_INFO_LEVEL *printer = NULL;
        bool in_use = False;
+       struct spoolss_PrinterInfo2 *pinfo2 = NULL;
+       WERROR result;
 
        if (!r) {
                return false;
@@ -4209,16 +4210,21 @@ bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
        /* loop through the printers.tdb and check for the drivername */
 
        for (snum=0; snum<n_services && !in_use; snum++) {
-               if ( !(lp_snum_ok(snum) && lp_print_ok(snum) ) )
+               if (!lp_snum_ok(snum) || !lp_print_ok(snum)) {
                        continue;
+               }
 
-               if ( !W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_servicename(snum))) )
-                       continue;
+               result = winreg_get_printer(mem_ctx, server_info, NULL,
+                                           lp_servicename(snum), &pinfo2);
+               if (!W_ERROR_IS_OK(result)) {
+                       continue; /* skip */
+               }
 
-               if (strequal(r->driver_name, printer->info_2->drivername))
+               if (strequal(r->driver_name, pinfo2->drivername)) {
                        in_use = True;
+               }
 
-               free_a_printer( &printer, 2 );
+               TALLOC_FREE(pinfo2);
        }
 
        DEBUG(10,("printer_driver_in_use: Completed search through ntprinters.tdb...\n"));