Skip to content

Commit

Permalink
Update raster path to count copies properly (Issue #265)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Aug 2, 2023
1 parent 8f9f09c commit d7d8e02
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions pappl/job-process.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ _papplJobProcessRaster(
unsigned page = 0, // Current page
x, // Current column
y; // Current line
int job_pages_per_set;
// "job-pages-per-set" value, if any
unsigned next_copy; // Next copy boundary


// Start processing the job...
Expand All @@ -611,7 +614,21 @@ _papplJobProcessRaster(
goto complete_job;
}

if ((header_pages = header.cupsInteger[CUPS_RASTER_PWG_TotalPageCount]) > 0)
if ((job_pages_per_set = ippGetInteger(ippFindAttribute(job->attrs, "job-pages-per-set", IPP_TAG_INTEGER), 0)) > 0)
{
// Use the job-pages-per-set value to set the number of impressions...
papplJobSetImpressions(job, job_pages_per_set);

// Track copies at page boundaries...
next_copy = (unsigned)job_pages_per_set;
}
else
{
// Don't track copies...
next_copy = 0;
}

if ((header_pages = header.cupsInteger[CUPS_RASTER_PWG_TotalPageCount]) > 0 && job_pages_per_set == 0)
papplJobSetImpressions(job, (int)header.cupsInteger[CUPS_RASTER_PWG_TotalPageCount]);

options = papplJobCreatePrintOptions(job, (unsigned)job->impressions, header.cupsBitsPerPixel > 8);
Expand Down Expand Up @@ -807,8 +824,17 @@ _papplJobProcessRaster(
break;
}

if (page == next_copy)
{
// Report a completed copy...
papplJobSetCopiesCompleted(job, 1);
next_copy += (unsigned)job_pages_per_set;
}

if (job->is_canceled)
{
break;
}
else if (y < header.cupsHeight)
{
papplLogJob(job, PAPPL_LOGLEVEL_ERROR, "Unable to read page from raster stream from client - %s", cupsGetErrorString());
Expand All @@ -818,11 +844,15 @@ _papplJobProcessRaster(
}
while (cupsRasterReadHeader(ras, &header));

papplJobSetCopiesCompleted(job, 1);
if (next_copy == 0)
{
// Not tracking copies so record this as a single completed copy...
papplJobSetCopiesCompleted(job, 1);
}

if (!(printer->driver_data.rendjob_cb)(job, options, job->printer->device))
job->state = IPP_JSTATE_ABORTED;
else if (header_pages == 0)
else if (header_pages == 0 && job_pages_per_set == 0)
papplJobSetImpressions(job, (int)page);

complete_job:
Expand Down

0 comments on commit d7d8e02

Please sign in to comment.