summaryrefslogtreecommitdiff
path: root/source3/utils/smbcontrol.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-11-26 00:01:56 +0000
committerGerald Carter <jerry@samba.org>2002-11-26 00:01:56 +0000
commit585e8a8c02f78a072b98f681fda5748c3d9924ab (patch)
tree0e18ced080883cb8270e4c21b332f65caeca835a /source3/utils/smbcontrol.c
parent793cfe497e5a29b5e49388fc81a679cb2f9d90c7 (diff)
downloadsamba-585e8a8c02f78a072b98f681fda5748c3d9924ab.tar.gz
samba-585e8a8c02f78a072b98f681fda5748c3d9924ab.tar.bz2
samba-585e8a8c02f78a072b98f681fda5748c3d9924ab.zip
[print notify fixes from APP_HEAD]
* fixing change notify on print server handle * adding change notify support into smbcontrol for sending comment changes, etc... All part of CR 1159/1160 (This used to be commit 256d8c27cdc6f802f3bfba44593b07014f6ae10a)
Diffstat (limited to 'source3/utils/smbcontrol.c')
-rw-r--r--source3/utils/smbcontrol.c54
1 files changed, 49 insertions, 5 deletions
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 034de91ce0..933cabdb4b 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -42,7 +42,7 @@ static struct {
{"dmalloc-mark", MSG_REQ_DMALLOC_MARK },
{"dmalloc-log-changed", MSG_REQ_DMALLOC_LOG_CHANGED },
{"shutdown", MSG_SHUTDOWN },
- {"change_id", MSG_PRINTER_DRVUPGRADE},
+ {"drvupgrade", MSG_PRINTER_DRVUPGRADE},
{NULL, -1}
};
@@ -50,6 +50,12 @@ time_t timeout_start;
#define MAX_WAIT 10
+/* we need these because we link to printing*.o */
+
+void become_root(void) {}
+void unbecome_root(void) {}
+
+
static void usage(BOOL doexit)
{
int i;
@@ -250,6 +256,7 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
int i, n, v;
int mtype;
BOOL retval=False;
+ BOOL check_notify_msgs = False;
mtype = parse_type(msg_name);
if (mtype == -1) {
@@ -360,9 +367,7 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
break;
/* Send a notification message to a printer */
- /* NB. None of these currently work due to changes in the printing notify mechanisms. */
-#if 0
case MSG_PRINTER_NOTIFY2: {
char *cmd;
@@ -380,6 +385,8 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
cmd = params[0];
+ check_notify_msgs = True;
+
/* Pause a print queue */
if (strequal(cmd, "queuepause")) {
@@ -421,6 +428,7 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
notify_job_status_byname(
params[1], jobid, JOB_STATUS_PAUSED,
SPOOLSS_NOTIFY_MSG_UNIX_JOBID);
+ break;
}
/* Resume a print job */
@@ -438,6 +446,7 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
notify_job_status_byname(
params[1], jobid, JOB_STATUS_QUEUED,
SPOOLSS_NOTIFY_MSG_UNIX_JOBID);
+ break;
}
/* Delete a print job */
@@ -461,10 +470,40 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
JOB_STATUS_DELETED,
SPOOLSS_NOTIFY_MSG_UNIX_JOBID);
}
-
+
+ /* printer change notify */
+
+ if (strequal(cmd, "printer")) {
+ int attribute = -1;
+
+ if (!params[1] || !params[2] || !params[3]) {
+ fprintf(stderr, "printer command requires an and attribute name and value!\n");
+ fprintf(stderr, "supported attributes:\n");
+ fprintf(stderr, "\tcomment:\n");
+ fprintf(stderr, "\tport:\n");
+ fprintf(stderr, "\tdriver:\n");
+ return False;
+ }
+ if ( strequal(params[2], "comment") )
+ attribute = PRINTER_NOTIFY_COMMENT;
+ else if ( strequal(params[2], "port") )
+ attribute = PRINTER_NOTIFY_PORT_NAME;
+ else if ( strequal(params[2], "driver") )
+ attribute = PRINTER_NOTIFY_DRIVER_NAME;
+
+ if ( attribute == -1 ) {
+ fprintf(stderr, "bad attribute!\n");
+ return False;
+ }
+
+ notify_printer_byname( params[1], attribute, params[3]);
+
+ break;
+ }
+
break;
}
-#endif
+
case MSG_SMB_FORCE_TDIS:
if (!strequal(dest, "smbd")) {
@@ -563,6 +602,11 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
break;
}
+ /* check if we have any pending print notify messages */
+
+ if ( check_notify_msgs )
+ print_notify_send_messages();
+
return (True);
}