mirror of
https://github.com/samba-team/samba.git
synced 2025-02-23 09:57:40 +03:00
s3-printing: simplify print_queue helper functions and return WERROR.
Guenther
This commit is contained in:
parent
4cbd0c77e4
commit
9966541f89
@ -4799,12 +4799,9 @@ bool print_job_end(int snum, uint32 jobid, enum file_close_type close_type);
|
||||
int print_queue_status(int snum,
|
||||
print_queue_struct **ppqueue,
|
||||
print_status_struct *status);
|
||||
bool print_queue_pause(struct auth_serversupplied_info *server_info, int snum,
|
||||
WERROR *errcode);
|
||||
bool print_queue_resume(struct auth_serversupplied_info *server_info, int snum,
|
||||
WERROR *errcode);
|
||||
bool print_queue_purge(struct auth_serversupplied_info *server_info, int snum,
|
||||
WERROR *errcode);
|
||||
WERROR print_queue_pause(struct auth_serversupplied_info *server_info, int snum);
|
||||
WERROR print_queue_resume(struct auth_serversupplied_info *server_info, int snum);
|
||||
WERROR print_queue_purge(struct auth_serversupplied_info *server_info, int snum);
|
||||
|
||||
/* The following definitions come from printing/printing_db.c */
|
||||
|
||||
|
@ -2797,16 +2797,14 @@ int print_queue_status(int snum,
|
||||
Pause a queue.
|
||||
****************************************************************************/
|
||||
|
||||
bool print_queue_pause(struct auth_serversupplied_info *server_info, int snum,
|
||||
WERROR *errcode)
|
||||
WERROR print_queue_pause(struct auth_serversupplied_info *server_info, int snum)
|
||||
{
|
||||
int ret;
|
||||
struct printif *current_printif = get_printer_fns( snum );
|
||||
|
||||
if (!print_access_check(server_info, snum,
|
||||
PRINTER_ACCESS_ADMINISTER)) {
|
||||
*errcode = WERR_ACCESS_DENIED;
|
||||
return False;
|
||||
return WERR_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
|
||||
@ -2817,8 +2815,7 @@ bool print_queue_pause(struct auth_serversupplied_info *server_info, int snum,
|
||||
unbecome_root();
|
||||
|
||||
if (ret != 0) {
|
||||
*errcode = WERR_INVALID_PARAM;
|
||||
return False;
|
||||
return WERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
/* force update the database */
|
||||
@ -2828,23 +2825,21 @@ bool print_queue_pause(struct auth_serversupplied_info *server_info, int snum,
|
||||
|
||||
notify_printer_status(snum, PRINTER_STATUS_PAUSED);
|
||||
|
||||
return True;
|
||||
return WERR_OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Resume a queue.
|
||||
****************************************************************************/
|
||||
|
||||
bool print_queue_resume(struct auth_serversupplied_info *server_info, int snum,
|
||||
WERROR *errcode)
|
||||
WERROR print_queue_resume(struct auth_serversupplied_info *server_info, int snum)
|
||||
{
|
||||
int ret;
|
||||
struct printif *current_printif = get_printer_fns( snum );
|
||||
|
||||
if (!print_access_check(server_info, snum,
|
||||
PRINTER_ACCESS_ADMINISTER)) {
|
||||
*errcode = WERR_ACCESS_DENIED;
|
||||
return False;
|
||||
return WERR_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
become_root();
|
||||
@ -2854,8 +2849,7 @@ bool print_queue_resume(struct auth_serversupplied_info *server_info, int snum,
|
||||
unbecome_root();
|
||||
|
||||
if (ret != 0) {
|
||||
*errcode = WERR_INVALID_PARAM;
|
||||
return False;
|
||||
return WERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
/* make sure the database is up to date */
|
||||
@ -2866,15 +2860,14 @@ bool print_queue_resume(struct auth_serversupplied_info *server_info, int snum,
|
||||
|
||||
notify_printer_status(snum, PRINTER_STATUS_OK);
|
||||
|
||||
return True;
|
||||
return WERR_OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Purge a queue - implemented by deleting all jobs that we can delete.
|
||||
****************************************************************************/
|
||||
|
||||
bool print_queue_purge(struct auth_serversupplied_info *server_info, int snum,
|
||||
WERROR *errcode)
|
||||
WERROR print_queue_purge(struct auth_serversupplied_info *server_info, int snum)
|
||||
{
|
||||
print_queue_struct *queue;
|
||||
print_status_struct status;
|
||||
@ -2908,5 +2901,5 @@ bool print_queue_purge(struct auth_serversupplied_info *server_info, int snum,
|
||||
|
||||
SAFE_FREE(queue);
|
||||
|
||||
return True;
|
||||
return WERR_OK;
|
||||
}
|
||||
|
@ -5730,20 +5730,14 @@ static WERROR control_printer(struct policy_handle *handle, uint32_t command,
|
||||
|
||||
switch (command) {
|
||||
case SPOOLSS_PRINTER_CONTROL_PAUSE:
|
||||
if (print_queue_pause(p->server_info, snum, &errcode)) {
|
||||
errcode = WERR_OK;
|
||||
}
|
||||
errcode = print_queue_pause(p->server_info, snum);
|
||||
break;
|
||||
case SPOOLSS_PRINTER_CONTROL_RESUME:
|
||||
case SPOOLSS_PRINTER_CONTROL_UNPAUSE:
|
||||
if (print_queue_resume(p->server_info, snum, &errcode)) {
|
||||
errcode = WERR_OK;
|
||||
}
|
||||
errcode = print_queue_resume(p->server_info, snum);
|
||||
break;
|
||||
case SPOOLSS_PRINTER_CONTROL_PURGE:
|
||||
if (print_queue_purge(p->server_info, snum, &errcode)) {
|
||||
errcode = WERR_OK;
|
||||
}
|
||||
errcode = print_queue_purge(p->server_info, snum);
|
||||
break;
|
||||
default:
|
||||
return WERR_UNKNOWN_LEVEL;
|
||||
|
@ -2869,23 +2869,20 @@ static bool api_WPrintQueueCtrl(connection_struct *conn,uint16 vuid,
|
||||
|
||||
switch (function) {
|
||||
case 74: /* Pause queue */
|
||||
if (print_queue_pause(conn->server_info, snum, &werr)) {
|
||||
errcode = NERR_Success;
|
||||
}
|
||||
werr = print_queue_pause(conn->server_info, snum);
|
||||
break;
|
||||
case 75: /* Resume queue */
|
||||
if (print_queue_resume(conn->server_info, snum, &werr)) {
|
||||
errcode = NERR_Success;
|
||||
}
|
||||
werr = print_queue_resume(conn->server_info, snum);
|
||||
break;
|
||||
case 103: /* Purge */
|
||||
if (print_queue_purge(conn->server_info, snum, &werr)) {
|
||||
errcode = NERR_Success;
|
||||
}
|
||||
werr = print_queue_purge(conn->server_info, snum);
|
||||
break;
|
||||
default:
|
||||
werr = WERR_NOT_SUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!W_ERROR_IS_OK(werr)) errcode = W_ERROR_V(werr);
|
||||
errcode = W_ERROR_V(werr);
|
||||
|
||||
out:
|
||||
SSVAL(*rparam,0,errcode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user