summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-02-27 00:13:56 +0000
committerGerald Carter <jerry@samba.org>2002-02-27 00:13:56 +0000
commitfe0c5bf5121152c1493000482feaa1e031116eb6 (patch)
tree0f66b1c5bce530168077d25d6993699a90cbf501
parent50cfb990c5a77f8679fb60573cbb003a8d72779c (diff)
downloadsamba-fe0c5bf5121152c1493000482feaa1e031116eb6.tar.gz
samba-fe0c5bf5121152c1493000482feaa1e031116eb6.tar.xz
samba-fe0c5bf5121152c1493000482feaa1e031116eb6.zip
* Fix the printer change notify code to fill in the
SPOOL_NOTIFY_INFO correctly on driver changes. * modify srv_spoolss_sendnotify() to pass in the printer name as well * do not reset the devmode when we change the driver for a printer (observed behavior on both NT and 2k) * removed some old commented out code we need to fix the cli_spoolss_notify code to use talloc for better maintainability....
-rw-r--r--source/include/proto.h12
-rwxr-xr-xsource/include/rpc_spoolss.h1
-rw-r--r--source/printing/nt_printing.c14
-rw-r--r--source/rpc_client/cli_spoolss_notify.c121
-rw-r--r--source/rpc_parse/parse_spoolss.c85
-rw-r--r--source/rpc_server/srv_spoolss_nt.c92
6 files changed, 256 insertions, 69 deletions
diff --git a/source/include/proto.h b/source/include/proto.h
index 789cf69d819..4159b570d47 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -2428,7 +2428,8 @@ BOOL spoolss_disconnect_from_client( struct cli_state *cli);
BOOL spoolss_connect_to_client( struct cli_state *cli, char *remote_machine);
BOOL cli_spoolss_reply_open_printer(struct cli_state *cli, char *printer, uint32 localprinter, uint32 type, WERROR *status, POLICY_HND *handle);
BOOL cli_spoolss_reply_rrpcn(struct cli_state *cli, POLICY_HND *handle,
- uint32 change_low, uint32 change_high, WERROR *status);
+ char* printername, uint32 change_low, uint32 change_high,
+ WERROR *status);
BOOL cli_spoolss_reply_close_printer(struct cli_state *cli, POLICY_HND *handle,
WERROR *status);
@@ -3692,7 +3693,8 @@ BOOL make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER *q_u, POLICY_HN
BOOL spoolss_io_q_replycloseprinter(char *desc, SPOOL_Q_REPLYCLOSEPRINTER *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_replycloseprinter(char *desc, SPOOL_R_REPLYCLOSEPRINTER *r_u, prs_struct *ps, int depth);
BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
- uint32 change_low, uint32 change_high);
+ uint32 change_low, uint32 change_high,
+ SPOOL_NOTIFY_INFO *info);
BOOL spoolss_io_q_reply_rrpcn(char *desc, SPOOL_Q_REPLY_RRPCN *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_reply_rrpcn(char *desc, SPOOL_R_REPLY_RRPCN *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_getprinterdataex(char *desc, SPOOL_Q_GETPRINTERDATAEX *q_u, prs_struct *ps, int depth);
@@ -3992,6 +3994,12 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER
SPOOL_R_DELETEPRINTERDRIVER *r_u);
WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPOOL_R_GETPRINTERDATA *r_u);
WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNEX *r_u);
+void spoolss_notify_driver_name(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx);
+void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id);
WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u);
WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_R_ENUMPRINTERS *r_u);
WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GETPRINTER *r_u);
diff --git a/source/include/rpc_spoolss.h b/source/include/rpc_spoolss.h
index 9ed83b18d8a..17bc651f566 100755
--- a/source/include/rpc_spoolss.h
+++ b/source/include/rpc_spoolss.h
@@ -55,7 +55,6 @@
#define SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFICATION0x3e
#define SPOOLSS_SPOOLERINIT 0x3f
#define SPOOLSS_RESETPRINTEREX 0x40
-#define SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFICATION 0x42
#define SPOOLSS_DELETEPRINTERDATAEX 0x51
#define SPOOLSS_DELETEPRINTERDRIVEREX 0x54
#define SPOOLSS_ADDPRINTERDRIVEREX 0x59
diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c
index ac37d594d5d..ed5af053481 100644
--- a/source/printing/nt_printing.c
+++ b/source/printing/nt_printing.c
@@ -2868,7 +2868,7 @@ static uint32 set_driver_init_2(NT_PRINTER_INFO_LEVEL_2 *info_ptr)
kbuf.dsize = strlen(key)+1;
dbuf = tdb_fetch(tdb_drivers, kbuf);
- if (!dbuf.dptr) {
+ if (!dbuf.dptr) {
/*
* When changing to a driver that has no init info in the tdb, remove
* the previous drivers init info and leave the new on blank.
@@ -2889,11 +2889,23 @@ static uint32 set_driver_init_2(NT_PRINTER_INFO_LEVEL_2 *info_ptr)
ZERO_STRUCT(info.devmode->devicename);
fstrcpy(info.devmode->devicename, info_ptr->printername);
+#if 0 /* JERRY */
+ /*
+ * NT/2k does not change the Device Mode of a printer
+ * when changing the driver. This makes no sense to me
+ * but it just the way it goes. However, printer data
+ * should be deleted and reset so I'm leaving that in.
+ * --jerry
+ */
+
/*
* Bind the saved DEVMODE to the new the printer.
*/
free_nt_devicemode(&info_ptr->devmode);
info_ptr->devmode = info.devmode;
+#else
+ free_nt_devicemode(&info.devmode);
+#endif
DEBUG(10,("set_driver_init_2: Set printer [%s] init DEVMODE for driver [%s]\n",
info_ptr->printername, info_ptr->drivername));
diff --git a/source/rpc_client/cli_spoolss_notify.c b/source/rpc_client/cli_spoolss_notify.c
index 7b5ba84dbb6..3d37caefd29 100644
--- a/source/rpc_client/cli_spoolss_notify.c
+++ b/source/rpc_client/cli_spoolss_notify.c
@@ -182,59 +182,144 @@ BOOL cli_spoolss_reply_open_printer(struct cli_state *cli, char *printer, uint32
return True;
}
+/**********************************************************************
+ Release the memory held by a SPOOL_NOTIFY_INFO_DATA
+ *********************************************************************/
+
+static void free_notify_data(SPOOL_NOTIFY_INFO_DATA *data, uint32 len)
+{
+ uint32 i;
+
+ if (!data)
+ return;
+
+ for (i=0; i<len; i++)
+ {
+ if (data[i].size == POINTER)
+ SAFE_FREE(data[i].notify_data.data.string);
+
+ }
+
+ SAFE_FREE(data);
+}
+
/***************************************************************************
do a reply open printer
****************************************************************************/
BOOL cli_spoolss_reply_rrpcn(struct cli_state *cli, POLICY_HND *handle,
- uint32 change_low, uint32 change_high, WERROR *status)
+ char* printername, uint32 change_low, uint32 change_high,
+ WERROR *status)
{
prs_struct rbuf;
prs_struct buf;
+
+ SPOOL_NOTIFY_INFO notify_info;
+ SPOOL_NOTIFY_INFO_DATA *notify_data = NULL, *data;
+ uint32 idx = 0;
+
+ WERROR result;
+
+ NT_PRINTER_INFO_LEVEL *printer = NULL;
SPOOL_Q_REPLY_RRPCN q_s;
SPOOL_R_REPLY_RRPCN r_s;
prs_init(&buf, 1024, cli->mem_ctx, MARSHALL);
prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL );
+
+ ZERO_STRUCT(notify_info);
+
+ /* lookup the printer if we have a name */
+
+ if (*printername) {
+ result = get_a_printer(&printer, 2, printername);
+ if (! W_ERROR_IS_OK(result)) {
+ *status = result;
+ goto done;
+ }
+ }
- /* create and send a MSRPC command with api */
-/*
+ /*
+ * See comments in _spoolss_setprinter() about PRINTER_CHANGE_XXX
+ * events. --jerry
+ */
+
+ /* Did the driver change? */
+
+ if (change_low & PRINTER_CHANGE_SET_PRINTER_DRIVER) {
+ change_low &= ~PRINTER_CHANGE_SET_PRINTER_DRIVER;
+ DEBUG(10,("cli_spoolss_reply_rrpcn: PRINTER_CHANGE_SET_PRINTER_DRIVER set on [%s][%d]\n",
+ printername, idx));
+ if ((data=Realloc(notify_data, (idx+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) {
+ DEBUG(0,("cli_spoolss_reply_rrpcn: Realloc() failed with size [%d]!\n",
+ (idx+1)*sizeof(SPOOL_NOTIFY_INFO_DATA)));
+ *status = WERR_NOMEM;
+ goto done;
+ }
+ notify_data = data;
+
+ memset(notify_data+idx, 0x0, sizeof(SPOOL_NOTIFY_INFO_DATA));
+
+ /*
+ * 'id' (last param here) is undefined when type == PRINTER_NOTIFY_TYPE
+ * See PRINTER_NOTIFY_INFO_DATA entries in MSDN
+ * --jerry
+ */
+ construct_info_data(notify_data+idx, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, 0x00);
+
+ spoolss_notify_driver_name(-1, notify_data+idx, NULL, printer, cli->mem_ctx);
+ idx++;
+ }
+
+
+#if 0 /* JERRY -- do not delete */
DEBUG(4,("cli_spoolss_reply_open_printer: srv:%s acct:%s sc: %d mc: %s clnt %s %x\n",
cli->srv_name_slash, cli->mach_acct, sec_chan_type, global_myname,
credstr(new_clnt_cred.challenge.data), new_clnt_cred.timestamp.time));
-*/
+#endif
+
+ /* create and send a MSRPC command with api */
+
/* store the parameters */
- make_spoolss_q_reply_rrpcn(&q_s, handle, change_low, change_high);
+
+ notify_info.flags = 0x00000200;
+ notify_info.count = idx;
+ notify_info.data = notify_data;
+
+ make_spoolss_q_reply_rrpcn(&q_s, handle, change_low, change_high, &notify_info);
/* turn parameters into data stream */
if(!spoolss_io_q_reply_rrpcn("", &q_s, &buf, 0)) {
DEBUG(0,("cli_spoolss_reply_rrpcn: Error : failed to marshall SPOOL_Q_REPLY_RRPCN struct.\n"));
- prs_mem_free(&buf);
- prs_mem_free(&rbuf);
- return False;
+ *status = WERR_BADFUNC;
+ goto done;
}
/* send the data on \PIPE\ */
if (!rpc_api_pipe_req(cli, SPOOLSS_RRPCN, &buf, &rbuf)) {
- prs_mem_free(&buf);
- prs_mem_free(&rbuf);
- return False;
+ DEBUG(0,("cli_spoolss_reply_rrpcn: SPOOLSS_RRPCN failed!\n"));
+ *status = WERR_BADFUNC;
+ goto done;
}
- prs_mem_free(&buf);
/* turn data stream into parameters*/
if(!spoolss_io_r_reply_rrpcn("", &r_s, &rbuf, 0)) {
- prs_mem_free(&rbuf);
- return False;
+ DEBUG(0,("cli_spoolss_reply_rrpcn: Error : failed to unmarshall SPOOL_R_REPLY_RRPCN struct.\n"));
+ *status = WERR_BADFUNC;
+ goto done;
}
-
- prs_mem_free(&rbuf);
- *status=r_s.status;
+ *status = r_s.status;
- return True;
+done:
+ prs_mem_free(&buf);
+ prs_mem_free(&rbuf);
+ free_a_printer(&printer, 2);
+ free_notify_data(notify_data, idx);
+
+ return W_ERROR_IS_OK(*status);
}
/***************************************************************************
diff --git a/source/rpc_parse/parse_spoolss.c b/source/rpc_parse/parse_spoolss.c
index 94bf6f906b7..4c38f4d4303 100644
--- a/source/rpc_parse/parse_spoolss.c
+++ b/source/rpc_parse/parse_spoolss.c
@@ -6154,12 +6154,79 @@ BOOL spoolss_io_r_replycloseprinter(char *desc, SPOOL_R_REPLYCLOSEPRINTER *r_u,
return True;
}
+#if 0 /* JERRY - not currently used but could be :-) */
+
+/*******************************************************************
+ Deep copy a SPOOL_NOTIFY_INFO_DATA structure
+ ******************************************************************/
+static BOOL copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA *dst,
+ SPOOL_NOTIFY_INFO_DATA *src, int n)
+{
+ int i;
+
+ memcpy(dst, src, sizeof(SPOOL_NOTIFY_INFO_DATA)*n);
+
+ for (i=0; i<n; i++) {
+ int len;
+ uint16 *s = NULL;
+
+ if (src->size != POINTER)
+ continue;
+ len = src->notify_data.data.length;
+ s = malloc(sizeof(uint16)*len);
+ if (s == NULL) {
+ DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
+ return False;
+ }
+
+ memcpy(s, src->notify_data.data.string, len*2);
+ dst->notify_data.data.string = s;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Deep copy a SPOOL_NOTIFY_INFO structure
+ ******************************************************************/
+static BOOL copy_spool_notify_info(SPOOL_NOTIFY_INFO *dst, SPOOL_NOTIFY_INFO *src)
+{
+ if (!dst) {
+ DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
+ return False;
+ }
+
+ dst->version = src->version;
+ dst->flags = src->flags;
+ dst->count = src->count;
+
+ if (dst->count)
+ {
+ dst->data = malloc(dst->count * sizeof(SPOOL_NOTIFY_INFO_DATA));
+
+ DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
+ dst->count));
+
+ if (dst->data == NULL) {
+ DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
+ dst->count));
+ return False;
+ }
+
+ return (copy_spool_notify_info_data(dst->data, src->data, src->count));
+ }
+
+ return True;
+}
+#endif /* JERRY */
+
/*******************************************************************
* init a structure.
********************************************************************/
BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
- uint32 change_low, uint32 change_high)
+ uint32 change_low, uint32 change_high,
+ SPOOL_NOTIFY_INFO *info)
{
if (q_u == NULL)
return False;
@@ -6175,8 +6242,20 @@ BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
q_u->info_ptr=1;
q_u->info.version=2;
- q_u->info.flags=PRINTER_NOTIFY_INFO_DISCARDED;
- q_u->info.count=0;
+
+ if (info->count) {
+ DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
+ info->count));
+ q_u->info.version = info->version;
+ q_u->info.flags = info->flags;
+ q_u->info.count = info->count;
+ /* pointer field - be careful! */
+ q_u->info.data = info->data;
+ }
+ else {
+ q_u->info.flags=PRINTER_NOTIFY_INFO_DISCARDED;
+ q_u->info.count=0;
+ }
return True;
}
diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c
index e543bf5f9e5..613d516971f 100644
--- a/source/rpc_server/srv_spoolss_nt.c
+++ b/source/rpc_server/srv_spoolss_nt.c
@@ -435,7 +435,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename)
* anymore, so I've simplified this loop greatly. Here
* we are just verifying that the printer name is a valid
* printer service defined in smb.conf
- * --jerry [Fri Feb 15 11:17:46 CST 2002]
+ * --jerry [Fri Feb 15 11:17:46 CST 2002]
*/
for (snum=0; snum<n_services; snum++) {
@@ -582,7 +582,7 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size
high = IVAL(msg,4);
fstrcpy(printer_name, buf_ptr + sizeof(msg));
- DEBUG(10,("srv_spoolss_receive_message: Got message printer change name [%s] low=0x%x high=0x%x\n",
+ DEBUG(10,("srv_spoolss_receive_message: Got message printer change [queue = %s] low=0x%x high=0x%x\n",
printer_name, (unsigned int)low, (unsigned int)high ));
/* Iterate the printer list */
@@ -593,14 +593,28 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size
*/
if (find_printer->notify.client_connected==True) {
- DEBUG(10,("srv_spoolss_receive_message: printerserver [%s]\n", find_printer->dev.printerservername ));
- if (*printer_name && !strequal(printer_name, find_printer->dev.handlename)) {
+
+ if (find_printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER)
+ DEBUG(10,("srv_spoolss_receive_message: printserver [%s]\n", find_printer->dev.printerservername ));
+ else
+ DEBUG(10,("srv_spoolss_receive_message: printer [%s]\n", find_printer->dev.handlename));
+
+ /*
+ * if handle is a printer, only send if the printer_name matches.
+ * ...else if handle is a printerserver, send to all
+ */
+
+ if (*printer_name && (find_printer->printer_type==PRINTER_HANDLE_IS_PRINTER)
+ && !strequal(printer_name, find_printer->dev.handlename))
+ {
DEBUG(10,("srv_spoolss_receive_message: ignoring message sent to %s [%s]\n",
printer_name, find_printer->dev.handlename ));
continue;
}
- if (cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, low, high, &status))
+ /* issue the client call */
+
+ if (cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, printer_name, low, high, &status))
DEBUG(10,("srv_spoolss_receive_message: cli_spoolss_reply_rrpcn status = 0x%x\n",
(unsigned int)W_ERROR_V(status)));
else
@@ -613,16 +627,22 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size
Send a notify event.
****************************************************************************/
-static BOOL srv_spoolss_sendnotify(uint32 high, uint32 low)
+static BOOL srv_spoolss_sendnotify(char* printer_name, uint32 high, uint32 low)
{
- char msg[10];
+ char msg[8 + sizeof(fstring)];
ZERO_STRUCT(msg);
+
SIVAL(msg,0,low);
SIVAL(msg,4,high);
- DEBUG(10,("srv_spoolss_sendnotify: printer change low=0x%x high=0x%x\n", low, high));
+ fstrcpy(&msg[8], printer_name);
+
+ DEBUG(10,("srv_spoolss_sendnotify: printer change low=0x%x high=0x%x [%s]\n",
+ low, high, printer_name));
- message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, msg, sizeof(msg), False);
+ message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, msg, 8 + strlen(printer_name) + 1,
+ False);
+
return True;
}
@@ -1013,7 +1033,7 @@ WERROR _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL
update_c_setprinter(FALSE);
if (W_ERROR_IS_OK(result)) {
- srv_spoolss_sendnotify(0, PRINTER_CHANGE_DELETE_PRINTER);
+ srv_spoolss_sendnotify(Printer->dev.handlename, 0, PRINTER_CHANGE_DELETE_PRINTER);
}
return result;
@@ -1502,10 +1522,9 @@ static void spoolss_notify_port_name(int snum,
/*******************************************************************
* fill a notify_info_data with the printername
- * jfmxxxx: it's incorrect, should be lp_printerdrivername()
* but it doesn't exist, have to see what to do
********************************************************************/
-static void spoolss_notify_driver_name(int snum,
+void spoolss_notify_driver_name(int snum,
SPOOL_NOTIFY_INFO_DATA *data,
print_queue_struct *queue,
NT_PRINTER_INFO_LEVEL *printer,
@@ -1560,7 +1579,6 @@ static void spoolss_notify_comment(int snum,
/*******************************************************************
* fill a notify_info_data with the comment
- * jfm:xxxx incorrect, have to create a new smb.conf option
* location = "Room 1, floor 2, building 3"
********************************************************************/
static void spoolss_notify_location(int snum,
@@ -1600,8 +1618,6 @@ static void spoolss_notify_devmode(int snum,
/*******************************************************************
* fill a notify_info_data with the separator file name
- * jfm:xxxx just return no file could add an option to smb.conf
- * separator file = "separator.txt"
********************************************************************/
static void spoolss_notify_sepfile(int snum,
SPOOL_NOTIFY_INFO_DATA *data,
@@ -2167,7 +2183,7 @@ static int search_notify(uint16 type, uint16 field, int *value)
/****************************************************************************
****************************************************************************/
-static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id)
+void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id)
{
info_data->type = type;
info_data->field = field;
@@ -2220,7 +2236,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int
current_data=&info->data[info->count];
- construct_info_data(current_data, type, field, id);
+ construct_info_data(current_data, type, field, id);
DEBUG(10,("construct_notify_printer_info: calling [%s] snum=%d printername=[%s])\n",
notify_info_data_table[j].name, snum, printer->info_2->printername ));
@@ -4652,6 +4668,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL;
Printer_entry *Printer = find_printer_index_by_hnd(p, handle);
WERROR result;
+ uint32 notify_flag = PRINTER_CHANGE_SET_PRINTER;
DEBUG(8,("update_printer\n"));
@@ -4767,18 +4784,27 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
* lookup previously saved driver initialization info, which is then
* bound to the printer, simulating what happens in the Windows arch.
*/
- if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername))
+ if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)){
set_driver_init(printer, 2);
+ notify_flag |= PRINTER_CHANGE_SET_PRINTER_DRIVER;
+ }
}
/* Update printer info */
result = mod_a_printer(*printer, 2);
- done:
+done:
+ /*
+ * It appears that if the PrinterName had changed, we should
+ * set this to PRINTER_CHANGE_ADD_PRINTER. This was observed
+ * between 2k -> 2k. Otherwise a PRINTER_CHANGE_SET_PRINTER
+ * event is ok. --jerry
+ */
+ srv_spoolss_sendnotify(printer->info_2->printername, 0, notify_flag);
+
free_a_printer(&printer, 2);
free_a_printer(&old_printer, 2);
- srv_spoolss_sendnotify(0, PRINTER_CHANGE_SET_PRINTER);
return result;
}
@@ -5987,11 +6013,12 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
return WERR_ACCESS_DENIED;
}
+ srv_spoolss_sendnotify(printer->info_2->printername, 0, PRINTER_CHANGE_ADD_PRINTER);
+
free_a_printer(&printer,2);
update_c_setprinter(False);
- srv_spoolss_sendnotify(0, PRINTER_CHANGE_ADD_PRINTER);
return WERR_OK;
}
@@ -6383,24 +6410,6 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP
convert_specific_param(&param, value , type, data, real_len);
-#if 0
- /* JRA. W2K always changes changeid. */
-
- if (get_specific_param(*printer, 2, param->value, &old_param.data,
- &old_param.type, (uint32 *)&old_param.data_len)) {
-
- if (param->type == old_param.type &&
- param->data_len == old_param.data_len &&
- memcmp(param->data, old_param.data,
- old_param.data_len) == 0) {
-
- DEBUG(3, ("setprinterdata hasn't changed\n"));
- status = WERR_OK;
- goto done;
- }
- }
-#endif
-
unlink_specific_param_if_exist(printer->info_2, param);
/*
@@ -6425,11 +6434,6 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP
free_nt_printer_param(&param);
SAFE_FREE(old_param.data);
-#if 0
- /* Is this correct. JRA ? */
- srv_spoolss_sendnotify(0, PRINTER_CHANGE_SET_PRINTER);
-#endif
-
return status;
}