mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Merge in JohnR's page count fixes.
Jeremy.
This commit is contained in:
parent
ad1e858d8e
commit
2e3133fbe5
@ -36,6 +36,7 @@ struct printjob {
|
||||
time_t starttime; /* when the job started spooling */
|
||||
int status; /* the status of this job */
|
||||
size_t size; /* the size of the job so far */
|
||||
int page_count; /* then number of pages so far */
|
||||
BOOL spooled; /* has it been sent to the spooler yet? */
|
||||
BOOL smbjob; /* set if the job is a SMB job */
|
||||
fstring filename; /* the filename used to spool the file */
|
||||
|
@ -506,6 +506,7 @@ typedef struct _print_queue_struct
|
||||
{
|
||||
int job;
|
||||
int size;
|
||||
int page_count;
|
||||
int status;
|
||||
int priority;
|
||||
time_t time;
|
||||
|
@ -796,12 +796,21 @@ write to a print file
|
||||
****************************************************************************/
|
||||
int print_job_write(int jobid, const char *buf, int size)
|
||||
{
|
||||
int fd;
|
||||
int return_code;
|
||||
struct printjob *pjob = print_job_find(jobid);
|
||||
|
||||
fd = print_job_fd(jobid);
|
||||
if (fd == -1) return -1;
|
||||
if (!pjob)
|
||||
return -1;
|
||||
/* don't allow another process to get this info - it is meaningless */
|
||||
if (pjob->pid != local_pid)
|
||||
return -1;
|
||||
|
||||
return write(fd, buf, size);
|
||||
return_code = write(pjob->fd, buf, size);
|
||||
if (return_code>0) {
|
||||
pjob->size += size;
|
||||
print_job_store(jobid, pjob);
|
||||
}
|
||||
return return_code;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -1043,6 +1052,23 @@ to open spool file %s.\n", pjob.filename));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Update the number of pages spooled to jobid
|
||||
****************************************************************************/
|
||||
|
||||
void print_job_endpage(int jobid)
|
||||
{
|
||||
struct printjob *pjob = print_job_find(jobid);
|
||||
if (!pjob)
|
||||
return;
|
||||
/* don't allow another process to get this info - it is meaningless */
|
||||
if (pjob->pid != local_pid)
|
||||
return;
|
||||
|
||||
pjob->page_count++;
|
||||
print_job_store(jobid, pjob);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Print a file - called on closing the file. This spools the job.
|
||||
If normal close is false then we're tearing down the jobs - treat as an
|
||||
@ -1137,6 +1163,7 @@ static int traverse_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void *
|
||||
|
||||
ts->queue[i].job = jobid;
|
||||
ts->queue[i].size = pjob.size;
|
||||
ts->queue[i].page_count = pjob.page_count;
|
||||
ts->queue[i].status = pjob.status;
|
||||
ts->queue[i].priority = 1;
|
||||
ts->queue[i].time = pjob.starttime;
|
||||
|
@ -2138,6 +2138,32 @@ static void spoolss_notify_job_size(int snum,
|
||||
data->notify_data.value[1]=0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* fill a notify_info_data with page info
|
||||
********************************************************************/
|
||||
static void spoolss_notify_total_pages(int snum,
|
||||
SPOOL_NOTIFY_INFO_DATA *data,
|
||||
print_queue_struct *queue,
|
||||
NT_PRINTER_INFO_LEVEL *printer,
|
||||
TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
data->notify_data.value[0]=queue->page_count;
|
||||
data->notify_data.value[1]=0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* fill a notify_info_data with pages printed info.
|
||||
********************************************************************/
|
||||
static void spoolss_notify_pages_printed(int snum,
|
||||
SPOOL_NOTIFY_INFO_DATA *data,
|
||||
print_queue_struct *queue,
|
||||
NT_PRINTER_INFO_LEVEL *printer,
|
||||
TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
data->notify_data.value[0]=0; /* Add code when back-end tracks this */
|
||||
data->notify_data.value[1]=0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Fill a notify_info_data with job position.
|
||||
********************************************************************/
|
||||
@ -2258,8 +2284,8 @@ struct s_notify_info_data_table notify_info_data_table[] =
|
||||
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time },
|
||||
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time },
|
||||
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", ONE_VALUE, spoolss_notify_job_time },
|
||||
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, NULL },
|
||||
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, NULL },
|
||||
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, spoolss_notify_total_pages },
|
||||
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, spoolss_notify_pages_printed },
|
||||
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", ONE_VALUE, spoolss_notify_job_size },
|
||||
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_BYTES_PRINTED, "JOB_NOTIFY_BYTES_PRINTED", ONE_VALUE, NULL },
|
||||
{ END, END, "", END, NULL }
|
||||
@ -4256,6 +4282,7 @@ WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO
|
||||
}
|
||||
|
||||
Printer->page_started=False;
|
||||
print_job_endpage(Printer->jobid);
|
||||
|
||||
return WERR_OK;
|
||||
}
|
||||
@ -5124,7 +5151,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue,
|
||||
job_info->status=nt_printj_status(queue->status);
|
||||
job_info->priority=queue->priority;
|
||||
job_info->position=position;
|
||||
job_info->totalpages=0;
|
||||
job_info->totalpages=queue->page_count;
|
||||
job_info->pagesprinted=0;
|
||||
|
||||
make_systemtime(&job_info->submitted, t);
|
||||
@ -5168,7 +5195,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
|
||||
job_info->position=position;
|
||||
job_info->starttime=0;
|
||||
job_info->untiltime=0;
|
||||
job_info->totalpages=0;
|
||||
job_info->totalpages=queue->page_count;
|
||||
job_info->size=queue->size;
|
||||
make_systemtime(&(job_info->submitted), t);
|
||||
job_info->timeelapsed=0;
|
||||
|
Loading…
Reference in New Issue
Block a user