2 Unix SMB/Netbios implementation.
4 printing backend routines
5 Copyright (C) Tim Potter, 2002
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * Print notification routines
28 static void send_spoolss_notify2_msg(struct spoolss_notify_msg *msg)
34 /* Let's not waste any time with this */
36 if (lp_disable_spoolss())
39 /* Flatten data into a message */
46 len += tdb_pack(buf + len, buflen - len, "f", msg->printer);
48 len += tdb_pack(buf + len, buflen - len, "ddddd",
49 msg->type, msg->field, msg->id, msg->len, msg->flags);
54 len += tdb_pack(buf + len, buflen - len, "dd",
55 msg->notify.value[0], msg->notify.value[1]);
57 len += tdb_pack(buf + len, buflen - len, "B",
58 msg->len, msg->notify.data);
61 buf = Realloc(buf, len);
68 tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0);
71 DEBUG(3, ("Failed to open connections database in send_spoolss_notify2_msg\n"));
75 message_send_all(tdb, MSG_PRINTER_NOTIFY2, buf,
82 static void send_notify_field_values(const char *printer_name, uint32 type,
83 uint32 field, uint32 id, uint32 value1,
84 uint32 value2, uint32 flags)
86 struct spoolss_notify_msg msg;
90 fstrcpy(msg.printer, printer_name);
94 msg.notify.value[0] = value1;
95 msg.notify.value[1] = value2;
98 send_spoolss_notify2_msg(&msg);
101 static void send_notify_field_buffer(const char *printer_name, uint32 type,
102 uint32 field, uint32 id, uint32 len,
105 struct spoolss_notify_msg msg;
109 fstrcpy(msg.printer, printer_name);
114 msg.notify.data = buffer;
116 send_spoolss_notify2_msg(&msg);
119 /* Send a message that the printer status has changed */
121 void notify_printer_status_byname(char *printer_name, uint32 status)
123 /* Printer status stored in value1 */
125 send_notify_field_values(printer_name, PRINTER_NOTIFY_TYPE,
126 PRINTER_NOTIFY_STATUS, 0,
130 void notify_printer_status(int snum, uint32 status)
132 char *printer_name = PRINTERNAME(snum);
135 notify_printer_status_byname(printer_name, status);
138 void notify_job_status_byname(char *printer_name, uint32 jobid, uint32 status,
141 /* Job id stored in id field, status in value1 */
143 send_notify_field_values(printer_name, JOB_NOTIFY_TYPE,
144 JOB_NOTIFY_STATUS, jobid,
148 void notify_job_status(int snum, uint32 jobid, uint32 status)
150 char *printer_name = PRINTERNAME(snum);
152 notify_job_status_byname(printer_name, jobid, status, 0);
155 void notify_job_total_bytes(int snum, uint32 jobid, uint32 size)
157 char *printer_name = PRINTERNAME(snum);
159 /* Job id stored in id field, status in value1 */
161 send_notify_field_values(printer_name, JOB_NOTIFY_TYPE,
162 JOB_NOTIFY_TOTAL_BYTES, jobid,
166 void notify_job_total_pages(int snum, uint32 jobid, uint32 pages)
168 char *printer_name = PRINTERNAME(snum);
170 /* Job id stored in id field, status in value1 */
172 send_notify_field_values(printer_name, JOB_NOTIFY_TYPE,
173 JOB_NOTIFY_TOTAL_PAGES, jobid,
177 void notify_job_username(int snum, uint32 jobid, char *name)
179 char *printer_name = PRINTERNAME(snum);
181 send_notify_field_buffer(
182 printer_name, JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME,
183 jobid, strlen(name) + 1, name);
186 void notify_job_name(int snum, uint32 jobid, char *name)
188 char *printer_name = PRINTERNAME(snum);
190 send_notify_field_buffer(
191 printer_name, JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT,
192 jobid, strlen(name) + 1, name);
195 void notify_job_submitted(int snum, uint32 jobid, time_t submitted)
197 char *printer_name = PRINTERNAME(snum);
199 send_notify_field_buffer(
200 printer_name, JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED,
201 jobid, sizeof(submitted), (char *)&submitted);
204 void notify_printer_delete(char *printer_name)
208 void notify_printer_add(char *printer_name)
212 void notify_printer_driver(int num, char *driver_name)
216 void notify_printer_comment(int num, char *comment)
220 void notify_printer_sharename(int num, char *share_name)
224 void notify_printer_port(int num, char *port_name)
228 void notify_printer_location(int num, char *location)