summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-10-26 21:43:13 +0000
committerJeremy Allison <jra@samba.org>2000-10-26 21:43:13 +0000
commitb5ac72cc646a981469ee65305da83f273c4cd093 (patch)
tree06908888538dec9a1c19136e660040fa30426a0b /source3/printing
parent01e0d3879ef5de24a6addd0ce00bf3d4de518f7f (diff)
downloadsamba-b5ac72cc646a981469ee65305da83f273c4cd093.tar.gz
samba-b5ac72cc646a981469ee65305da83f273c4cd093.tar.bz2
samba-b5ac72cc646a981469ee65305da83f273c4cd093.zip
Sorry JF - no billable hours :-). I fixed the "stream of events" problem
with PCL drivers. The problem was we were updating the changeid on every SETPRINTERDATA/DELETEPRINTERDATA call. We should not do this, we should just update the 'setprinter' called count. We update the changeid on calls to SETPRINTER/ADDPRINTER/ADDPRINTEREX etc. Also fixed the correct returning of the create time on printers. Jeremy. (This used to be commit 521f09829fd329f87b3d19e8871e2b989c98a58e)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c56
1 files changed, 42 insertions, 14 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 48bab48b3c..9d4a7f2030 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1230,14 +1230,12 @@ uint32 del_a_printer(char *sharename)
/****************************************************************************
****************************************************************************/
-static uint32 add_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
+static uint32 update_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
{
pstring key;
char *buf;
int buflen, len, ret;
TDB_DATA kbuf, dbuf;
- NTTIME time_nt;
- time_t time_unix = time(NULL);
/*
* in addprinter: no servername and the printer is the name
@@ -1264,10 +1262,6 @@ static uint32 add_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
* behind a SAMBA share.
*/
- unix_to_nt_time(&time_nt, time_unix);
- info->changeid=time_nt.low;
- info->c_setprinter++;
-
buf = NULL;
buflen = 0;
@@ -1684,6 +1678,7 @@ static uint32 get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstrin
info.untiltime = 0; /* Minutes since 12:00am GMT */
info.priority = 1;
info.default_priority = 1;
+ info.setuptime = (uint32)time(NULL);
if ((info.devmode = construct_nt_devicemode(info.printername)) == NULL)
goto fail;
@@ -1725,12 +1720,8 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
kbuf.dsize = strlen(key)+1;
dbuf = tdb_fetch(tdb, kbuf);
-#if 1 /* JRATEST */
if (!dbuf.dptr)
return get_a_printer_2_default(info_ptr, sharename);
-#else
- if (!dbuf.dptr) return 1;
-#endif
len += tdb_unpack(dbuf.dptr+len, dbuf.dsize-len, "dddddddddddfffffPfffff",
&info.attributes,
@@ -1762,9 +1753,7 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
len += unpack_devicemode(&info.devmode,dbuf.dptr+len, dbuf.dsize-len);
len += unpack_specifics(&info.specific,dbuf.dptr+len, dbuf.dsize-len);
-#if 1 /* JRATEST */
nt_printing_getsec(sharename, &info.secdesc_buf);
-#endif /* JRATEST */
safe_free(dbuf.dptr);
*info_ptr=memdup(&info, sizeof(info));
@@ -1859,7 +1848,36 @@ void get_printer_subst_params(int snum, fstring *printername, fstring *sharename
*/
/****************************************************************************
+ Modify a printer. This is called from SETPRINTERDATA/DELETEPRINTERDATA.
****************************************************************************/
+
+uint32 mod_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
+{
+ uint32 success;
+
+ dump_a_printer(printer, level);
+
+ switch (level)
+ {
+ case 2:
+ {
+ printer.info_2->c_setprinter++;
+ success=update_a_printer_2(printer.info_2);
+ break;
+ }
+ default:
+ success=1;
+ break;
+ }
+
+ return (success);
+}
+
+/****************************************************************************
+ Add a printer. This is called from ADDPRINTER(EX) and also SETPRINTER.
+ We split this out from mod_a_printer as it updates the id's and timestamps.
+****************************************************************************/
+
uint32 add_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{
uint32 success;
@@ -1870,7 +1888,17 @@ uint32 add_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{
case 2:
{
- success=add_a_printer_2(printer.info_2);
+ /*
+ * Update the changestamp.
+ * Note we must *not* do this in mod_a_printer().
+ */
+ NTTIME time_nt;
+ time_t time_unix = time(NULL);
+ unix_to_nt_time(&time_nt, time_unix);
+ printer.info_2->changeid=time_nt.low;
+
+ printer.info_2->c_setprinter++;
+ success=update_a_printer_2(printer.info_2);
break;
}
default: