diff options
author | Jeremy Allison <jra@samba.org> | 2002-05-09 19:54:47 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-05-09 19:54:47 +0000 |
commit | 059da8fb3b7197bd6a9bfe57940a96a2546e63a5 (patch) | |
tree | 2a9321487a1e4dd0903e40216df90c0a82a387ca /source3/rpc_server | |
parent | 909bb7a0551b54a18540b50c5e5159738c76b3c9 (diff) | |
download | samba-059da8fb3b7197bd6a9bfe57940a96a2546e63a5.tar.gz samba-059da8fb3b7197bd6a9bfe57940a96a2546e63a5.tar.bz2 samba-059da8fb3b7197bd6a9bfe57940a96a2546e63a5.zip |
Merged in printing fixes... There were many missing !
Jeremy
(This used to be commit 32fa089adead6ff3279172fd36560f4f9e2aeef0)
Diffstat (limited to 'source3/rpc_server')
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 112 |
1 files changed, 111 insertions, 1 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d6ce065548..8419152cf2 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -37,6 +37,15 @@ #define PRINTER_HANDLE_IS_PRINTER 0 #define PRINTER_HANDLE_IS_PRINTSERVER 1 +/* Table to map the driver version */ +/* to OS */ +char * drv_ver_to_os[] = { + "WIN9X", /* driver version/cversion 0 */ + "", /* unused ? */ + "WINNT", /* driver version/cversion 2 */ + "WIN2K", /* driver version/cversion 3 */ +}; + struct table_node { char *long_archi; char *short_archi; @@ -760,6 +769,69 @@ static BOOL srv_spoolss_sendnotify(char* printer_name, uint32 high, uint32 low, } /******************************************************************** + Send a message to ourself about new driver being installed + so we can upgrade the information for each printer bound to this + driver +********************************************************************/ + +static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) +{ + int len = strlen(drivername); + + if (!len) + return False; + + DEBUG(10,("srv_spoolss_drv_upgrade_printer: Sending message about driver upgrade [%s]\n", + drivername)); + + message_send_pid(sys_getpid(), MSG_PRINTER_DRVUPGRADE, drivername, len+1, False); + return True; +} + +/********************************************************************** + callback to receive a MSG_PRINTER_DRVUPGRADE message and interate + over all printers, upgrading ones as neessary +**********************************************************************/ + +void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) +{ + fstring drivername; + int snum; + int n_services = lp_numservices(); + + len = MIN(len,sizeof(drivername)-1); + strncpy(drivername, buf, len); + + DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername )); + + /* Iterate the printer list */ + + for (snum=0; snum<n_services; snum++) { + if (lp_snum_ok(snum) && lp_print_ok(snum) ) { + WERROR result; + NT_PRINTER_INFO_LEVEL *printer = NULL; + + result = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(result)) + continue; + + if (printer && printer->info_2 && !strcmp(drivername, printer->info_2->drivername)) { + DEBUG(6,("Updating printer [%s]\n", printer->info_2->printername)); + /* all we care about currently is the change_id */ + result = mod_a_printer(*printer, 2); + if (!W_ERROR_IS_OK(result)) { + DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n", + dos_errstr(result))); + } + } + free_a_printer(&printer, 2); + } + } + + /* all done */ +} + +/******************************************************************** Copy routines used by convert_to_openprinterex() *******************************************************************/ @@ -6462,7 +6534,8 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, WERROR err = WERR_OK; NT_PRINTER_DRIVER_INFO_LEVEL driver; struct current_user user; - + fstring driver_name; + ZERO_STRUCT(driver); get_current_user(&user, p); @@ -6489,6 +6562,43 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, goto done; } + /* BEGIN_ADMIN_LOG */ + switch(level) { + case 3: + sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", + driver.info_3->name,drv_ver_to_os[driver.info_3->cversion],uidtoname(user.uid)); + fstrcpy(driver_name, driver.info_3->name); + break; + case 6: + sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", + driver.info_6->name,drv_ver_to_os[driver.info_6->version],uidtoname(user.uid)); + fstrcpy(driver_name, driver.info_6->name); + break; + } + /* END_ADMIN_LOG */ + + /* + * I think this is where he DrvUpgradePrinter() hook would be + * be called in a driver's interface DLL on a Windows NT 4.0/2k + * server. Right now, we just need to send ourselves a message + * to update each printer bound to this driver. --jerry + */ + + if (!srv_spoolss_drv_upgrade_printer(driver_name)) { + DEBUG(0,("_spoolss_addprinterdriver: Failed to send message about upgrading driver [%s]!\n", + driver_name)); + } + + /* if driver is not 9x, delete existing driver init data */ + + if ((level == 3 && driver.info_3->cversion != 0) || + (level == 6 && driver.info_6->version != 0)) { + if (!del_driver_init(driver_name)) + DEBUG(3,("_spoolss_addprinterdriver: del_driver_init(%s) failed!\n", driver_name)); + } else { + DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for 9x driver [%s]\n", driver_name)); + } + done: free_a_printer_driver(driver, level); return err; |