Lines Matching full:job

37 static int	add_file(cupsd_client_t *con, cupsd_job_t *job,
41 static void add_job_subscriptions(cupsd_client_t *con, cupsd_job_t *job);
42 static void add_job_uuid(cupsd_job_t *job);
48 cupsd_job_t *job);
59 static int copy_banner(cupsd_client_t *con, cupsd_job_t *job,
65 cupsd_job_t *job,
107 static void save_auth_info(cupsd_client_t *con, cupsd_job_t *job,
124 static int validate_user(cupsd_job_t *job, cupsd_client_t *con, const char *owner, char *username, …
139 ipp_attribute_t *uri = NULL; /* Printer or job URI attribute */ in cupsdProcessIPPRequest()
241 * printer-uri/job-uri in cupsdProcessIPPRequest()
273 …else if ((attr = ippFindAttribute(con->request, "job-uri", IPP_TAG_URI)) != NULL && attr->group_ta… in cupsdProcessIPPRequest()
311 * attributes-natural-language, and printer-uri/job-uri are required in cupsdProcessIPPRequest()
332 cupsdLogMessage(CUPSD_LOG_ERROR, "Missing printer-uri, job-uri, or ppd-name attribute."); in cupsdProcessIPPRequest()
334 …cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL, "%04X %s Missing printer-uri, job-uri, or ppd-… in cupsdProcessIPPRequest()
693 * 'cupsdTimeoutJob()' - Timeout a job waiting on job files.
697 cupsdTimeoutJob(cupsd_job_t *job) /* I - Job to timeout */ in cupsdTimeoutJob() argument
700 ipp_attribute_t *attr; /* job-sheets attribute */ in cupsdTimeoutJob()
704 job->pending_timeout = 0; in cupsdTimeoutJob()
710 if (!cupsdLoadJob(job)) in cupsdTimeoutJob()
713 printer = cupsdFindDest(job->dest); in cupsdTimeoutJob()
714 attr = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME); in cupsdTimeoutJob()
723 cupsdLogJob(job, CUPSD_LOG_INFO, "Adding end banner page \"%s\".", in cupsdTimeoutJob()
726 if ((kbytes = copy_banner(NULL, job, attr->values[1].string.text)) < 0) in cupsdTimeoutJob()
729 cupsdUpdateQuota(printer, job->username, 0, kbytes); in cupsdTimeoutJob()
831 int need_restart_job; /* Need to restart job? */ in add_class()
1093 if (need_restart_job && pclass->job) in add_class()
1096 * Reset the current job to a "pending" status... in add_class()
1099 cupsdSetJobState(pclass->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE, in add_class()
1100 "Job restarted because the class was modified."); in add_class()
1129 * 'add_file()' - Add a file to a job.
1134 cupsd_job_t *job, /* I - Job to add to */ in add_file() argument
1143 "add_file(con=%p[%d], job=%d, filetype=%s/%s, " in add_file()
1144 "compression=%d)", con, con ? con->number : -1, job->id, in add_file()
1148 * Add the file to the job... in add_file()
1151 if (job->num_files == 0) in add_file()
1158 compressions = (int *)realloc(job->compressions, in add_file()
1159 (size_t)(job->num_files + 1) * sizeof(int)); in add_file()
1160 filetypes = (mime_type_t **)realloc(job->filetypes, in add_file()
1161 (size_t)(job->num_files + 1) * in add_file()
1166 job->compressions = compressions; in add_file()
1169 job->filetypes = filetypes; in add_file()
1173 cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE, in add_file()
1174 "Job aborted because the scheduler ran out of memory."); in add_file()
1183 job->compressions[job->num_files] = compression; in add_file()
1184 job->filetypes[job->num_files] = filetype; in add_file()
1186 job->num_files ++; in add_file()
1188 job->dirty = 1; in add_file()
1196 * 'add_job()' - Add a job to a print queue.
1199 static cupsd_job_t * /* O - Job object */
1207 const char *mandatory; /* Current mandatory job attribute */ in add_job()
1209 int priority; /* Job priority */ in add_job()
1210 cupsd_job_t *job; /* Current job */ in add_job() local
1211 char job_uri[HTTP_MAX_URI]; /* Job URI */ in add_job()
1224 "job-detailed-status-messages", in add_job()
1225 "job-document-access-errors", in add_job()
1226 "job-id", in add_job()
1227 "job-impressions-completed", in add_job()
1228 "job-k-octets-completed", in add_job()
1229 "job-media-sheets-completed", in add_job()
1230 "job-pages-completed", in add_job()
1231 "job-printer-up-time", in add_job()
1232 "job-printer-uri", in add_job()
1233 "job-state", in add_job()
1234 "job-state-message", in add_job()
1235 "job-state-reasons", in add_job()
1236 "job-uri", in add_job()
1308 * Validate job template attributes; for now just document-format, in add_job()
1309 * copies, job-sheets, number-up, page-ranges, mandatory attributes, and in add_job()
1321 …send_ipp_status(con, IPP_BAD_REQUEST, _("The '%s' Job Status attribute cannot be supplied in a job in add_job()
1325 …cupsdLogMessage(CUPSD_LOG_INFO, "Unexpected '%s' Job Status attribute in a job creation request.",… in add_job()
1381 if ((attr = ippFindAttribute(con->request, "job-sheets", in add_job()
1387 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-sheets value type.")); in add_job()
1394 _("Too many job-sheets values (%d > 2)."), in add_job()
1403 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-sheets value \"%s\"."), in add_job()
1516 * Create the job and set things up... in add_job()
1519 if ((attr = ippFindAttribute(con->request, "job-priority", in add_job()
1524 if ((val = cupsGetOption("job-priority", printer->num_options, in add_job()
1530 ippAddInteger(con->request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-priority", in add_job()
1534 if ((attr = ippFindAttribute(con->request, "job-name", IPP_TAG_ZERO)) == NULL) in add_job()
1535 ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL, "Untitled"); in add_job()
1541 _("Bad job-name value: Wrong type or count.")); in add_job()
1551 ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL, "Untitled"); in add_job()
1555 send_ipp_status(con, IPP_ATTRIBUTES, _("Bad job-name value: %s"), in add_job()
1567 ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL, "Untitled"); in add_job()
1572 if ((job = cupsdAddJob(priority, printer->name)) == NULL) in add_job()
1575 _("Unable to add job for destination \"%s\"."), in add_job()
1580 job->dtype = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE); in add_job()
1581 job->attrs = con->request; in add_job()
1582 job->dirty = 1; in add_job()
1583 con->request = ippNewRequest(job->attrs->request.op.operation_id); in add_job()
1587 add_job_uuid(job); in add_job()
1588 apply_printer_defaults(printer, job); in add_job()
1592 cupsdSetString(&job->username, con->username); in add_job()
1595 ippSetString(job->attrs, &attr, 0, con->username); in add_job()
1603 cupsdSetString(&job->username, attr->values[0].string.text); in add_job()
1606 cupsdSetString(&job->username, "anonymous"); in add_job()
1609 ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, in add_job()
1610 "job-originating-user-name", NULL, job->username); in add_job()
1613 ippSetGroupTag(job->attrs, &attr, IPP_TAG_JOB); in add_job()
1614 ippSetName(job->attrs, &attr, "job-originating-user-name"); in add_job()
1619 save_auth_info(con, job, auth_info); in add_job()
1626 ippDeleteAttribute(job->attrs, auth_info); in add_job()
1629 if ((attr = ippFindAttribute(con->request, "job-name", IPP_TAG_NAME)) != NULL) in add_job()
1630 cupsdSetString(&(job->name), attr->values[0].string.text); in add_job()
1632 if ((attr = ippFindAttribute(job->attrs, "job-originating-host-name", in add_job()
1636 * Request contains a job-originating-host-name attribute; validate it... in add_job()
1648 ippDeleteAttribute(job->attrs, attr); in add_job()
1649 …ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-originating-host-name", NULL, con->http->… in add_job()
1652 ippSetGroupTag(job->attrs, &attr, IPP_TAG_JOB); in add_job()
1657 * No job-originating-host-name attribute, so use the hostname from in add_job()
1661 ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, in add_job()
1662 "job-originating-host-name", NULL, con->http->hostname); in add_job()
1665 ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, "date-time-at-completed"); in add_job()
1666 ippAddDate(job->attrs, IPP_TAG_JOB, "date-time-at-creation", ippTimeToDate(time(NULL))); in add_job()
1667 ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, "date-time-at-processing"); in add_job()
1668 ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, "time-at-completed"); in add_job()
1669 ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "time-at-creation", time(NULL)); in add_job()
1670 ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, "time-at-processing"); in add_job()
1673 * Add remaining job attributes... in add_job()
1676 ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id); in add_job()
1677 job->state = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_ENUM, in add_job()
1678 "job-state", IPP_JOB_STOPPED); in add_job()
1679 job->state_value = (ipp_jstate_t)job->state->values[0].integer; in add_job()
1680 job->reasons = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, in add_job()
1681 "job-state-reasons", NULL, "job-incoming"); in add_job()
1682job->impressions = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-impressions-comple… in add_job()
1683 job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, in add_job()
1684 "job-media-sheets-completed", 0); in add_job()
1685 ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri", NULL, in add_job()
1688 if ((attr = ippFindAttribute(job->attrs, "job-k-octets", IPP_TAG_INTEGER)) != NULL) in add_job()
1691 ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-k-octets", 0); in add_job()
1693 if ((attr = ippFindAttribute(job->attrs, "job-hold-until", in add_job()
1695 attr = ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_NAME); in add_job()
1698 if ((val = cupsGetOption("job-hold-until", printer->num_options, in add_job()
1702 attr = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, in add_job()
1703 "job-hold-until", NULL, val); in add_job()
1713 cupsdSetJobHoldUntil(job, ippGetString(attr, 0, NULL), 0); in add_job()
1715 cupsdSetJobHoldUntil(job, "indefinite", 0); in add_job()
1717 job->state->values[0].integer = IPP_JOB_HELD; in add_job()
1718 job->state_value = IPP_JOB_HELD; in add_job()
1720 ippSetString(job->attrs, &job->reasons, 0, "job-held-on-create"); in add_job()
1725 * Hold job until specified time... in add_job()
1728 cupsdSetJobHoldUntil(job, attr->values[0].string.text, 0); in add_job()
1730 job->state->values[0].integer = IPP_JOB_HELD; in add_job()
1731 job->state_value = IPP_JOB_HELD; in add_job()
1733 ippSetString(job->attrs, &job->reasons, 0, "job-hold-until-specified"); in add_job()
1735 else if (job->attrs->request.op.operation_id == IPP_CREATE_JOB) in add_job()
1737 job->hold_until = time(NULL) + MultipleOperationTimeout; in add_job()
1738 job->state->values[0].integer = IPP_JOB_HELD; in add_job()
1739 job->state_value = IPP_JOB_HELD; in add_job()
1743 job->state->values[0].integer = IPP_JOB_PENDING; in add_job()
1744 job->state_value = IPP_JOB_PENDING; in add_job()
1746 ippSetString(job->attrs, &job->reasons, 0, "none"); in add_job()
1752 * Add job sheets options... in add_job()
1755 if ((attr = ippFindAttribute(job->attrs, "job-sheets", in add_job()
1759 "Adding default job-sheets values \"%s,%s\"...", in add_job()
1762 attr = ippAddStrings(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-sheets", in add_job()
1764 ippSetString(job->attrs, &attr, 0, printer->job_sheets[0]); in add_job()
1765 ippSetString(job->attrs, &attr, 1, printer->job_sheets[1]); in add_job()
1768 job->job_sheets = attr; in add_job()
1791 ippSetString(job->attrs, &attr, 0, Classification); in add_job()
1793 cupsdLogJob(job, CUPSD_LOG_NOTICE, "CLASSIFICATION FORCED " in add_job()
1794 "job-sheets=\"%s,none\", " in add_job()
1795 "job-originating-user-name=\"%s\"", in add_job()
1796 Classification, job->username); in add_job()
1808 ippSetString(job->attrs, &attr, 1, attr->values[0].string.text); in add_job()
1810 cupsdLogJob(job, CUPSD_LOG_NOTICE, "CLASSIFICATION FORCED " in add_job()
1811 "job-sheets=\"%s,%s\", " in add_job()
1812 "job-originating-user-name=\"%s\"", in add_job()
1814 attr->values[1].string.text, job->username); in add_job()
1823 cupsdLogJob(job, CUPSD_LOG_NOTICE, in add_job()
1825 "job-sheets=\"%s\", " in add_job()
1826 "job-originating-user-name=\"%s\"", in add_job()
1827 attr->values[0].string.text, job->username); in add_job()
1829 cupsdLogJob(job, CUPSD_LOG_NOTICE, in add_job()
1831 "job-sheets=\"%s,%s\",fffff " in add_job()
1832 "job-originating-user-name=\"%s\"", in add_job()
1834 attr->values[1].string.text, job->username); in add_job()
1848 ippSetString(job->attrs, &attr, 0, Classification); in add_job()
1849 ippSetString(job->attrs, &attr, 1, Classification); in add_job()
1855 ippSetString(job->attrs, &attr, 0, Classification); in add_job()
1859 ippSetString(job->attrs, &attr, 1, Classification); in add_job()
1863 cupsdLogJob(job, CUPSD_LOG_NOTICE, in add_job()
1865 "job-sheets=\"%s,%s\", " in add_job()
1866 "job-originating-user-name=\"%s\"", in add_job()
1868 attr->values[1].string.text, job->username); in add_job()
1870 cupsdLogJob(job, CUPSD_LOG_NOTICE, in add_job()
1872 "job-sheets=\"%s\", " in add_job()
1873 "job-originating-user-name=\"%s\"", in add_job()
1874 Classification, job->username); in add_job()
1884 cupsdLogJob(job, CUPSD_LOG_INFO, "Adding start banner page \"%s\".", in add_job()
1887 if ((kbytes = copy_banner(con, job, attr->values[0].string.text)) < 0) in add_job()
1889 cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE, in add_job()
1890 "Aborting job because the start banner could not be " in add_job()
1895 cupsdUpdateQuota(printer, job->username, 0, kbytes); in add_job()
1898 else if ((attr = ippFindAttribute(job->attrs, "job-sheets", in add_job()
1900 job->job_sheets = attr; in add_job()
1906 …ALL, job_uri, sizeof(job_uri), "ipp", NULL, con->clientname, con->clientport, "/jobs/%d", job->id); in add_job()
1907 ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL, job_uri); in add_job()
1909 ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id); in add_job()
1911 ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", (int)job->state_value); in add_job()
1912 ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_TEXT, "job-state-message", NULL, ""); in add_job()
1913 …ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, job->reasons-… in add_job()
1918 * Add any job subscriptions... in add_job()
1921 add_job_subscriptions(con, job); in add_job()
1924 * Set all but the first two attributes to the job attributes group... in add_job()
1927 for (attr = job->attrs->attrs->next->next; attr; attr = attr->next) in add_job()
1931 * Fire the "job created" event... in add_job()
1934 cupsdAddEvent(CUPSD_EVENT_JOB_CREATED, printer, job, "Job created."); in add_job()
1937 * Return the new job... in add_job()
1940 return (job); in add_job()
1945 * 'add_job_subscriptions()' - Add any subscriptions for a job.
1951 cupsd_job_t *job) /* I - Newly created job */ in add_job_subscriptions() argument
1970 for (attr = job->attrs->attrs; attr; attr = attr->next) in add_job_subscriptions()
2099 "used with job subscriptions.")); in add_job_subscriptions()
2115 if ((sub = cupsdAddSubscription(mask, cupsdFindDest(job->dest), job, in add_job_subscriptions()
2120 cupsdSetString(&sub->owner, job->username); in add_job_subscriptions()
2133 cupsdLogMessage(CUPSD_LOG_DEBUG, "Added subscription %d for job %d", in add_job_subscriptions()
2134 sub->id, job->id); in add_job_subscriptions()
2144 * Remove all of the subscription attributes from the job request... in add_job_subscriptions()
2150 for (attr = job->attrs->attrs, prev = NULL; attr; attr = next) in add_job_subscriptions()
2166 job->attrs->attrs = next; in add_job_subscriptions()
2172 job->attrs->last = prev; in add_job_subscriptions()
2173 job->attrs->current = prev; in add_job_subscriptions()
2178 * 'add_job_uuid()' - Add job-uuid attribute to a job.
2184 add_job_uuid(cupsd_job_t *job) /* I - Job */ in add_job_uuid() argument
2186 char uuid[64]; /* job-uuid string */ in add_job_uuid()
2190 * Add a job-uuid attribute if none exists... in add_job_uuid()
2193 if (!ippFindAttribute(job->attrs, "job-uuid", IPP_TAG_URI)) in add_job_uuid()
2194 ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-uuid", NULL, in add_job_uuid()
2195 httpAssembleUUID(ServerName, RemotePort, job->dest, job->id, in add_job_uuid()
2223 need_restart_job, /* Need to restart job? */ in add_printer()
2827 if (need_restart_job && printer->job) in add_printer()
2830 * Restart the current job... in add_printer()
2833 cupsdSetJobState(printer->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE, in add_printer()
2834 "Job restarted because the printer was modified."); in add_printer()
2887 * 'add_queued_job_count()' - Add the "queued-job-count" attribute for
2905 "queued-job-count", count); in add_queued_job_count()
2910 * 'apply_printer_defaults()' - Apply printer default options to a job.
2916 cupsd_job_t *job) /* I - Job */ in apply_printer_defaults() argument
2924 cupsdLogJob(job, CUPSD_LOG_DEBUG, "Applying default options..."); in apply_printer_defaults()
2928 * job object... in apply_printer_defaults()
2935 if (!ippFindAttribute(job->attrs, option->name, IPP_TAG_ZERO)) in apply_printer_defaults()
2937 …if (!strcmp(option->name, "print-quality") && ippFindAttribute(job->attrs, "cupsPrintQuality", IPP… in apply_printer_defaults()
2940 cupsdLogJob(job, CUPSD_LOG_DEBUG, "Adding default %s=%s", option->name, option->value); in apply_printer_defaults()
2946 * Encode these options as attributes in the job object... in apply_printer_defaults()
2949 cupsEncodeOptions2(job->attrs, num_options, options, IPP_TAG_JOB); in apply_printer_defaults()
2955 * 'authenticate_job()' - Set job authentication info.
2960 ipp_attribute_t *uri) /* I - Job URI */ in authenticate_job()
2962 ipp_attribute_t *attr, /* job-id attribute */ in authenticate_job()
2964 int jobid; /* Job ID */ in authenticate_job()
2965 cupsd_job_t *job; /* Current job */ in authenticate_job() local
2987 * See if we have a job URI or a printer URI... in authenticate_job()
2993 * Got a printer URI; see if we also have a job-id attribute... in authenticate_job()
2996 if ((attr = ippFindAttribute(con->request, "job-id", in authenticate_job()
3000 _("Got a printer-uri attribute but no job-id.")); in authenticate_job()
3009 * Got a job URI; parse it to get the job ID... in authenticate_job()
3022 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."), in authenticate_job()
3031 * See if the job exists... in authenticate_job()
3034 if ((job = cupsdFindJob(jobid)) == NULL) in authenticate_job()
3040 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid); in authenticate_job()
3045 * See if the job has been completed... in authenticate_job()
3048 if (job->state_value != IPP_JOB_HELD) in authenticate_job()
3055 _("Job #%d is not held for authentication."), in authenticate_job()
3068 cupsd_printer_t *printer; /* Job destination */ in authenticate_job()
3075 printer = cupsdFindDest(job->dest); in authenticate_job()
3087 * See if the job is owned by the requesting user... in authenticate_job()
3090 if (!validate_user(job, con, job->username, username, sizeof(username))) in authenticate_job()
3093 cupsdFindDest(job->dest)); in authenticate_job()
3098 * Save the authentication information for this job... in authenticate_job()
3101 save_auth_info(con, job, auth_info); in authenticate_job()
3104 * Reset the job-hold-until value to "no-hold"... in authenticate_job()
3107 if ((attr = ippFindAttribute(job->attrs, "job-hold-until", in authenticate_job()
3109 attr = ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_NAME); in authenticate_job()
3113 ippSetValueTag(job->attrs, &attr, IPP_TAG_KEYWORD); in authenticate_job()
3114 ippSetString(job->attrs, &attr, 0, "no-hold"); in authenticate_job()
3118 * Release the job and return... in authenticate_job()
3121 cupsdReleaseJob(job); in authenticate_job()
3123 cupsdAddEvent(CUPSD_EVENT_JOB_STATE, NULL, job, "Job authenticated by user"); in authenticate_job()
3125 cupsdLogJob(job, CUPSD_LOG_INFO, "Authenticated by \"%s\".", con->username); in authenticate_job()
3137 ipp_attribute_t *uri) /* I - Job or Printer URI */ in cancel_all_jobs()
3152 ipp_attribute_t *job_ids; /* job-ids attribute */ in cancel_all_jobs()
3153 cupsd_job_t *job; /* Job */ in cancel_all_jobs() local
3214 job_ids = ippFindAttribute(con->request, "job-ids", IPP_TAG_INTEGER); in cancel_all_jobs()
3264 if ((job = cupsdFindJob(job_ids->values[i].integer)) == NULL) in cancel_all_jobs()
3268 _cups_strcasecmp(job->username, username)) in cancel_all_jobs()
3274 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), in cancel_all_jobs()
3281 job = cupsdFindJob(job_ids->values[i].integer); in cancel_all_jobs()
3283 cupsdSetJobState(job, IPP_JOB_CANCELED, purge, in cancel_all_jobs()
3284 purge == CUPSD_JOB_PURGE ? "Job purged by user." : in cancel_all_jobs()
3285 "Job canceled by user."); in cancel_all_jobs()
3322 if ((job = cupsdFindJob(job_ids->values[i].integer)) == NULL || in cancel_all_jobs()
3323 _cups_strcasecmp(job->dest, printer->name)) in cancel_all_jobs()
3327 _cups_strcasecmp(job->username, username)) in cancel_all_jobs()
3333 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), in cancel_all_jobs()
3340 job = cupsdFindJob(job_ids->values[i].integer); in cancel_all_jobs()
3342 cupsdSetJobState(job, IPP_JOB_CANCELED, purge, in cancel_all_jobs()
3343 purge == CUPSD_JOB_PURGE ? "Job purged by user." : in cancel_all_jobs()
3344 "Job canceled by user."); in cancel_all_jobs()
3373 * 'cancel_job()' - Cancel a print job.
3378 ipp_attribute_t *uri) /* I - Job or Printer URI */ in cancel_job()
3381 int jobid; /* Job ID */ in cancel_job()
3387 cupsd_job_t *job; /* Job information */ in cancel_job() local
3390 cupsd_jobaction_t purge; /* Purge the job? */ in cancel_job()
3397 * See if we have a job URI or a printer URI... in cancel_job()
3403 * Got a printer URI; see if we also have a job-id attribute... in cancel_job()
3406 if ((attr = ippFindAttribute(con->request, "job-id", in cancel_job()
3410 _("Got a printer-uri attribute but no job-id.")); in cancel_job()
3417 * Find the current job on the specified printer... in cancel_job()
3435 for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); in cancel_job()
3436 job; in cancel_job()
3437 job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) in cancel_job()
3438 if (job->state_value <= IPP_JOB_PROCESSING && in cancel_job()
3439 !_cups_strcasecmp(job->dest, printer->name)) in cancel_job()
3442 if (job) in cancel_job()
3443 jobid = job->id; in cancel_job()
3450 for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); in cancel_job()
3451 job; in cancel_job()
3452 job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) in cancel_job()
3453 if (job->state_value == IPP_JOB_STOPPED && in cancel_job()
3454 !_cups_strcasecmp(job->dest, printer->name)) in cancel_job()
3457 if (job) in cancel_job()
3458 jobid = job->id; in cancel_job()
3471 * Got a job URI; parse it to get the job ID... in cancel_job()
3484 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."), in cancel_job()
3493 * Look for the "purge-job" attribute... in cancel_job()
3496 if ((attr = ippFindAttribute(con->request, "purge-job", in cancel_job()
3503 * See if the job exists... in cancel_job()
3506 if ((job = cupsdFindJob(jobid)) == NULL) in cancel_job()
3512 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid); in cancel_job()
3517 * See if the job is owned by the requesting user... in cancel_job()
3520 if (!validate_user(job, con, job->username, username, sizeof(username))) in cancel_job()
3523 cupsdFindDest(job->dest)); in cancel_job()
3528 * See if the job is already completed, canceled, or aborted; if so, in cancel_job()
3532 if (job->state_value >= IPP_JOB_CANCELED && purge != CUPSD_JOB_PURGE) in cancel_job()
3534 switch (job->state_value) in cancel_job()
3538 _("Job #%d is already canceled - can\'t cancel."), in cancel_job()
3544 _("Job #%d is already aborted - can\'t cancel."), in cancel_job()
3550 _("Job #%d is already completed - can\'t cancel."), in cancel_job()
3559 * Cancel the job and return... in cancel_job()
3562 cupsdSetJobState(job, IPP_JOB_CANCELED, purge, in cancel_job()
3563 purge == CUPSD_JOB_PURGE ? "Job purged by \"%s\"" : in cancel_job()
3564 "Job canceled by \"%s\"", in cancel_job()
3569 cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Purged by \"%s\".", jobid, in cancel_job()
3572 cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Canceled by \"%s\".", jobid, in cancel_job()
3685 uuid_t usr_uuid; /* UUID for job requesting user */ in check_quotas()
3712 * Check global active job limits for printers and users... in check_quotas()
3754 * Get UUID for job requesting user... in check_quotas()
3908 * 'close_job()' - Close a multi-file job.
3915 cupsd_job_t *job; /* Job */ in close_job() local
3918 /* Job URI */ in close_job()
3926 * See if we have a job URI or a printer URI... in close_job()
3932 * job-uri is not supported by Close-Job! in close_job()
3936 _("Close-Job doesn't support the job-uri attribute.")); in close_job()
3941 * Got a printer URI; see if we also have a job-id attribute... in close_job()
3944 if ((attr = ippFindAttribute(con->request, "job-id", in close_job()
3948 _("Got a printer-uri attribute but no job-id.")); in close_job()
3952 if ((job = cupsdFindJob(attr->values[0].integer)) == NULL) in close_job()
3958 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), in close_job()
3964 * See if the job is owned by the requesting user... in close_job()
3967 if (!validate_user(job, con, job->username, username, sizeof(username))) in close_job()
3970 cupsdFindDest(job->dest)); in close_job()
3978 if (cupsdTimeoutJob(job)) in close_job()
3981 if (job->state_value == IPP_JOB_STOPPED) in close_job()
3983 job->state->values[0].integer = IPP_JOB_PENDING; in close_job()
3984 job->state_value = IPP_JOB_PENDING; in close_job()
3986 else if (job->state_value == IPP_JOB_HELD) in close_job()
3988 if ((attr = ippFindAttribute(job->attrs, "job-hold-until", in close_job()
3990 attr = ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_NAME); in close_job()
3994 job->state->values[0].integer = IPP_JOB_PENDING; in close_job()
3995 job->state_value = IPP_JOB_PENDING; in close_job()
3999 job->dirty = 1; in close_job()
4007 con->clientname, con->clientport, "/jobs/%d", job->id); in close_job()
4008 ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL, in close_job()
4011 ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id); in close_job()
4013 ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", (int)job->state_value); in close_job()
4018 * Start the job if necessary... in close_job()
4058 !strcmp(fromattr->name, "job-authorization-uri") || in copy_attrs()
4059 !strcmp(fromattr->name, "job-password") || in copy_attrs()
4060 !strcmp(fromattr->name, "job-password-encryption") || in copy_attrs()
4061 !strcmp(fromattr->name, "job-printer-uri")) in copy_attrs()
4070 * job-id attribute regardless of the security settings for IPP in copy_attrs()
4073 * The job-printer-uri attribute is handled by copy_job_attrs(). in copy_attrs()
4078 if (strcmp(fromattr->name, "job-id")) in copy_attrs()
4104 * specified job.
4109 cupsd_job_t *job, /* I - Job information */ in copy_banner() argument
4114 char filename[1024]; /* Job filename */ in copy_banner()
4125 "copy_banner(con=%p[%d], job=%p[%d], name=\"%s\")", in copy_banner()
4126 con, con ? con->number : -1, job, job->id, in copy_banner()
4138 * Open the banner and job files... in copy_banner()
4141 if (add_file(con, job, banner->filetype, 0)) in copy_banner()
4144 snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot, job->id, in copy_banner()
4145 job->num_files); in copy_banner()
4149 "Unable to create banner job file %s - %s", in copy_banner()
4151 job->num_files --; in copy_banner()
4162 strlcpy(attrname, job->attrs->attrs->next->values[0].string.text, in copy_banner()
4207 job->num_files --; in copy_banner()
4253 cupsFilePuts(out, job->dest); in copy_banner()
4256 else if ((attr = ippFindAttribute(job->attrs, s, IPP_TAG_ZERO)) == NULL) in copy_banner()
4373 job->koctets += kbytes; in copy_banner()
4375 if ((attr = ippFindAttribute(job->attrs, "job-k-octets", IPP_TAG_INTEGER)) != NULL) in copy_banner()
4726 * 'copy_job_attrs()' - Copy job attributes.
4731 cupsd_job_t *job, /* I - Job */ in copy_job_attrs() argument
4735 char job_uri[HTTP_MAX_URI]; /* Job URI */ in copy_job_attrs()
4739 * Send the requested attributes for each job... in copy_job_attrs()
4747 "number-of-documents", job->num_files); in copy_job_attrs()
4749 if ((!exclude || !cupsArrayFind(exclude, "job-media-progress")) && in copy_job_attrs()
4750 (!ra || cupsArrayFind(ra, "job-media-progress"))) in copy_job_attrs()
4752 "job-media-progress", job->progress); in copy_job_attrs()
4754 if ((!exclude || !cupsArrayFind(exclude, "job-more-info")) && in copy_job_attrs()
4755 (!ra || cupsArrayFind(ra, "job-more-info"))) in copy_job_attrs()
4759 job->id); in copy_job_attrs()
4761 "job-more-info", NULL, job_uri); in copy_job_attrs()
4764 if (job->state_value > IPP_JOB_PROCESSING && in copy_job_attrs()
4765 (!exclude || !cupsArrayFind(exclude, "job-preserved")) && in copy_job_attrs()
4766 (!ra || cupsArrayFind(ra, "job-preserved"))) in copy_job_attrs()
4767 ippAddBoolean(con->response, IPP_TAG_JOB, "job-preserved", in copy_job_attrs()
4768 job->num_files > 0); in copy_job_attrs()
4770 if ((!exclude || !cupsArrayFind(exclude, "job-printer-up-time")) && in copy_job_attrs()
4771 (!ra || cupsArrayFind(ra, "job-printer-up-time"))) in copy_job_attrs()
4773 "job-printer-up-time", time(NULL)); in copy_job_attrs()
4776 if (!ra || cupsArrayFind(ra, "job-printer-uri")) in copy_job_attrs()
4780 (job->dtype & CUPS_PRINTER_CLASS) ? "/classes/%s" : in copy_job_attrs()
4782 job->dest); in copy_job_attrs()
4784 "job-printer-uri", NULL, job_uri); in copy_job_attrs()
4787 if (!ra || cupsArrayFind(ra, "job-uri")) in copy_job_attrs()
4791 job->id); in copy_job_attrs()
4793 "job-uri", NULL, job_uri); in copy_job_attrs()
4796 if (job->attrs) in copy_job_attrs()
4798 copy_attrs(con->response, job->attrs, ra, IPP_TAG_JOB, 0, exclude); in copy_job_attrs()
4803 * Generate attributes from the job structure... in copy_job_attrs()
4806 if (job->completed_time && (!ra || cupsArrayFind(ra, "date-time-at-completed"))) in copy_job_attrs()
4807 …ippAddDate(con->response, IPP_TAG_JOB, "date-time-at-completed", ippTimeToDate(job->completed_time… in copy_job_attrs()
4809 if (job->creation_time && (!ra || cupsArrayFind(ra, "date-time-at-creation"))) in copy_job_attrs()
4810 …ippAddDate(con->response, IPP_TAG_JOB, "date-time-at-creation", ippTimeToDate(job->creation_time)); in copy_job_attrs()
4812 if (!ra || cupsArrayFind(ra, "job-id")) in copy_job_attrs()
4813 ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id); in copy_job_attrs()
4815 if (!ra || cupsArrayFind(ra, "job-k-octets")) in copy_job_attrs()
4816 ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-k-octets", job->koctets); in copy_job_attrs()
4818 if (job->name && (!ra || cupsArrayFind(ra, "job-name"))) in copy_job_attrs()
4819 ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL, job->name); in copy_job_attrs()
4821 if (job->username && (!ra || cupsArrayFind(ra, "job-originating-user-name"))) in copy_job_attrs()
4822 …ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_NAME, "job-originating-user-name", NULL, job->use… in copy_job_attrs()
4824 if (!ra || cupsArrayFind(ra, "job-state")) in copy_job_attrs()
4825 ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", (int)job->state_value); in copy_job_attrs()
4827 if (!ra || cupsArrayFind(ra, "job-state-reasons")) in copy_job_attrs()
4829 switch (job->state_value) in copy_job_attrs()
4834 …ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-aborted-… in copy_job_attrs()
4837 …ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-canceled… in copy_job_attrs()
4840 …ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-complete… in copy_job_attrs()
4845 if (job->completed_time && (!ra || cupsArrayFind(ra, "time-at-completed"))) in copy_job_attrs()
4846 …ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "time-at-completed", (int)job->complete… in copy_job_attrs()
4848 if (job->creation_time && (!ra || cupsArrayFind(ra, "time-at-creation"))) in copy_job_attrs()
4849 …ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "time-at-creation", (int)job->creation_… in copy_job_attrs()
4941 "abort-job", in copy_printer_attrs()
4942 "retry-current-job", in copy_printer_attrs()
4943 "retry-job", in copy_printer_attrs()
4948 …PRINTER, IPP_CONST_TAG(IPP_TAG_NAME), "printer-error-policy-supported", NULL, "retry-current-job"); in copy_printer_attrs()
5032 if (!ra || cupsArrayFind(ra, "queued-job-count")) in copy_printer_attrs()
5113 (!sub->job && (!ra || cupsArrayFind(ra, "notify-lease-duration")))) in copy_subscription_attrs()
5143 if (sub->job && (!ra || cupsArrayFind(ra, "notify-job-id"))) in copy_subscription_attrs()
5145 "notify-job-id", sub->job->id); in copy_subscription_attrs()
5172 cupsd_job_t *job; /* New job */ in create_job() local
5201 * Check for invalid Create-Job attributes and log a warning or error depending in create_job()
5214 "Create-Job request."), forbidden_attrs[i]); in create_job()
5219 "Unexpected '%s' operation attribute in a Create-Job " in create_job()
5224 * Create the job object... in create_job()
5227 if ((job = add_job(con, printer, NULL)) == NULL) in create_job()
5230 job->pending_timeout = 1; in create_job()
5233 * Save and log the job... in create_job()
5236 cupsdLogJob(job, CUPSD_LOG_INFO, "Queued on \"%s\" by \"%s\".", in create_job()
5237 job->dest, job->username); in create_job()
5599 cupsd_job_t *job; /* Job */ in create_subscriptions() local
5600 int jobid; /* Job ID */ in create_subscriptions()
5840 else if (!strcmp(attr->name, "notify-job-id") && in create_subscriptions()
5907 if ((job = cupsdFindJob(jobid)) == NULL) in create_subscriptions()
5909 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), in create_subscriptions()
5915 job = NULL; in create_subscriptions()
5917 if ((sub = cupsdAddSubscription(mask, printer, job, recipient, 0)) == NULL) in create_subscriptions()
5924 if (job) in create_subscriptions()
5925 cupsdLogMessage(CUPSD_LOG_DEBUG, "Added subscription #%d for job %d.", in create_subscriptions()
5926 sub->id, job->id); in create_subscriptions()
6212 * 'get_document()' - Get a copy of a job file.
6217 ipp_attribute_t *uri) /* I - Job URI */ in get_document()
6221 int jobid; /* Job ID */ in get_document()
6223 cupsd_job_t *job; /* Current job */ in get_document() local
6237 * See if we have a job URI or a printer URI... in get_document()
6243 * Got a printer URI; see if we also have a job-id attribute... in get_document()
6246 if ((attr = ippFindAttribute(con->request, "job-id", in get_document()
6250 _("Got a printer-uri attribute but no job-id.")); in get_document()
6259 * Got a job URI; parse it to get the job ID... in get_document()
6272 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."), in get_document()
6281 * See if the job exists... in get_document()
6284 if ((job = cupsdFindJob(jobid)) == NULL) in get_document()
6290 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid); in get_document()
6299 job->username)) != HTTP_OK) in get_document()
6317 if ((docnum = attr->values[0].integer) < 1 || docnum > job->num_files || in get_document()
6321 _("Document #%d does not exist in job #%d."), docnum, in get_document()
6331 "Unable to open document %d in job %d - %s", docnum, jobid, in get_document()
6334 _("Unable to open document #%d in job #%d."), docnum, in get_document()
6341 cupsdLoadJob(job); in get_document()
6343 snprintf(format, sizeof(format), "%s/%s", job->filetypes[docnum - 1]->super, in get_document()
6344 job->filetypes[docnum - 1]->type); in get_document()
6350 if ((attr = ippFindAttribute(job->attrs, "document-name", in get_document()
6358 * 'get_job_attrs()' - Get job attributes.
6363 ipp_attribute_t *uri) /* I - Job URI */ in get_job_attrs()
6367 int jobid; /* Job ID */ in get_job_attrs()
6368 cupsd_job_t *job; /* Current job */ in get_job_attrs() local
6384 * See if we have a job URI or a printer URI... in get_job_attrs()
6390 * Got a printer URI; see if we also have a job-id attribute... in get_job_attrs()
6393 if ((attr = ippFindAttribute(con->request, "job-id", in get_job_attrs()
6397 _("Got a printer-uri attribute but no job-id.")); in get_job_attrs()
6406 * Got a job URI; parse it to get the job ID... in get_job_attrs()
6419 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."), in get_job_attrs()
6428 * See if the job exists... in get_job_attrs()
6431 if ((job = cupsdFindJob(jobid)) == NULL) in get_job_attrs()
6437 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid); in get_job_attrs()
6445 if ((printer = job->printer) == NULL) in get_job_attrs()
6446 printer = cupsdFindDest(job->dest); in get_job_attrs()
6453 if ((status = cupsdCheckPolicy(policy, con, job->username)) != HTTP_OK) in get_job_attrs()
6459 exclude = cupsdGetPrivateAttrs(policy, con, printer, job->username); in get_job_attrs()
6465 cupsdLoadJob(job); in get_job_attrs()
6468 copy_job_attrs(con, job, ra, exclude); in get_job_attrs()
6493 int job_comparison; /* Job comparison */ in get_jobs()
6494 ipp_jstate_t job_state; /* job-state value */ in get_jobs()
6495 int first_job_id = 1, /* First job ID */ in get_jobs()
6499 need_load_job = 0; /* Do we need to load the job? */ in get_jobs()
6500 const char *job_attr; /* Job attribute requested */ in get_jobs()
6501 ipp_attribute_t *job_ids; /* job-ids attribute */ in get_jobs()
6502 cupsd_job_t *job; /* Current job pointer */ in get_jobs() local
6504 cups_array_t *list; /* Which job list... */ in get_jobs()
6581 job_ids = ippFindAttribute(con->request, "job-ids", IPP_TAG_INTEGER); in get_jobs()
6591 _("The %s attribute cannot be provided with job-ids."), in get_jobs()
6671 _("The %s attribute cannot be provided with job-ids."), in get_jobs()
6684 _("The %s attribute cannot be provided with job-ids."), in get_jobs()
6691 else if ((attr = ippFindAttribute(con->request, "first-job-id", IPP_TAG_INTEGER)) != NULL) in get_jobs()
6696 _("The %s attribute cannot be provided with job-ids."), in get_jobs()
6697 "first-job-id"); in get_jobs()
6711 _("The %s attribute cannot be provided with job-ids."), in get_jobs()
6722 if (strcmp(job_attr, "job-id") && in get_jobs()
6723 strcmp(job_attr, "job-k-octets") && in get_jobs()
6724 strcmp(job_attr, "job-media-progress") && in get_jobs()
6725 strcmp(job_attr, "job-more-info") && in get_jobs()
6726 strcmp(job_attr, "job-name") && in get_jobs()
6727 strcmp(job_attr, "job-originating-user-name") && in get_jobs()
6728 strcmp(job_attr, "job-preserved") && in get_jobs()
6729 strcmp(job_attr, "job-printer-up-time") && in get_jobs()
6730 strcmp(job_attr, "job-printer-uri") && in get_jobs()
6731 strcmp(job_attr, "job-state") && in get_jobs()
6732 strcmp(job_attr, "job-state-reasons") && in get_jobs()
6733 strcmp(job_attr, "job-uri") && in get_jobs()
6745 * Limit expensive Get-Jobs for job history to 500 jobs... in get_jobs()
6774 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), in get_jobs()
6781 job = cupsdFindJob(job_ids->values[i].integer); in get_jobs()
6783 if (need_load_job && !job->attrs) in get_jobs()
6785 cupsdLoadJob(job); in get_jobs()
6787 if (!job->attrs) in get_jobs()
6789 cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: No attributes for job %d", job->id); in get_jobs()
6797 exclude = cupsdGetPrivateAttrs(job->printer ? in get_jobs()
6798 job->printer->op_policy_ptr : in get_jobs()
6799 policy, con, job->printer, in get_jobs()
6800 job->username); in get_jobs()
6802 copy_job_attrs(con, job, ra, exclude); in get_jobs()
6808 job = (cupsd_job_t *)cupsArrayIndex(list, first_index - 1); in get_jobs()
6810 job = (cupsd_job_t *)cupsArrayFirst(list); in get_jobs()
6812 for (count = 0; (limit <= 0 || count < limit) && job; job = (cupsd_job_t *)cupsArrayNext(list)) in get_jobs()
6819 "get_jobs: job->id=%d, dest=\"%s\", username=\"%s\", " in get_jobs()
6820 "state_value=%d, attrs=%p", job->id, job->dest, in get_jobs()
6821 job->username, job->state_value, job->attrs); in get_jobs()
6823 if (!job->dest || !job->username) in get_jobs()
6824 cupsdLoadJob(job); in get_jobs()
6826 if (!job->dest || !job->username) in get_jobs()
6829 if ((dest && strcmp(job->dest, dest)) && in get_jobs()
6830 (!job->printer || !dest || strcmp(job->printer->name, dest))) in get_jobs()
6832 if ((job->dtype & dmask) != dtype && in get_jobs()
6833 (!job->printer || (job->printer->type & dmask) != dtype)) in get_jobs()
6836 if ((job_comparison < 0 && job->state_value > job_state) || in get_jobs()
6837 (job_comparison == 0 && job->state_value != job_state) || in get_jobs()
6838 (job_comparison > 0 && job->state_value < job_state)) in get_jobs()
6841 if (job->id < first_job_id) in get_jobs()
6844 if (need_load_job && !job->attrs) in get_jobs()
6846 cupsdLoadJob(job); in get_jobs()
6848 if (!job->attrs) in get_jobs()
6850 cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: No attributes for job %d", job->id); in get_jobs()
6855 if (username[0] && _cups_strcasecmp(username, job->username)) in get_jobs()
6863 exclude = cupsdGetPrivateAttrs(job->printer ? in get_jobs()
6864 job->printer->op_policy_ptr : in get_jobs()
6865 policy, con, job->printer, in get_jobs()
6866 job->username); in get_jobs()
6868 copy_job_attrs(con, job, ra, exclude); in get_jobs()
6951 if (sub->job && sub->job->state_value == IPP_JOB_PROCESSING && in get_notifications()
6954 else if (sub->job && sub->job->state_value >= IPP_JOB_STOPPED) in get_notifications()
7698 ipp_attribute_t *uri) /* I - Printer/job URI */ in get_subscriptions()
7716 cupsd_job_t *job; /* Job pointer */ in get_subscriptions() local
7740 job = NULL; in get_subscriptions()
7745 job = cupsdFindJob(atoi(resource + 6)); in get_subscriptions()
7747 if (!job) in get_subscriptions()
7749 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), in get_subscriptions()
7764 else if ((attr = ippFindAttribute(con->request, "notify-job-id", in get_subscriptions()
7767 job = cupsdFindJob(attr->values[0].integer); in get_subscriptions()
7769 if (!job) in get_subscriptions()
7771 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), in get_subscriptions()
7777 job = NULL; in get_subscriptions()
7827 if ((!printer || sub->dest == printer) && (!job || sub->job == job) && in get_subscriptions()
7873 * 'hold_job()' - Hold a print job.
7878 ipp_attribute_t *uri) /* I - Job or Printer URI */ in hold_job()
7880 ipp_attribute_t *attr; /* Current job-hold-until */ in hold_job()
7882 int jobid; /* Job ID */ in hold_job()
7888 cupsd_job_t *job; /* Job information */ in hold_job() local
7895 * See if we have a job URI or a printer URI... in hold_job()
7901 * Got a printer URI; see if we also have a job-id attribute... in hold_job()
7904 if ((attr = ippFindAttribute(con->request, "job-id", in hold_job()
7908 _("Got a printer-uri attribute but no job-id.")); in hold_job()
7917 * Got a job URI; parse it to get the job ID... in hold_job()
7931 _("Bad job-uri \"%s\"."), in hold_job()
7940 * See if the job exists... in hold_job()
7943 if ((job = cupsdFindJob(jobid)) == NULL) in hold_job()
7949 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid); in hold_job()
7954 * See if the job is owned by the requesting user... in hold_job()
7957 if (!validate_user(job, con, job->username, username, sizeof(username))) in hold_job()
7960 cupsdFindDest(job->dest)); in hold_job()
7965 * See if the job is in a state that allows holding... in hold_job()
7968 if (job->state_value > IPP_JOB_STOPPED) in hold_job()
7975 _("Job #%d is finished and cannot be altered."), in hold_job()
7976 job->id); in hold_job()
7981 * Hold the job and return... in hold_job()
7984 if ((attr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_ZERO)) != NULL) in hold_job()
7988 …send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Unsupported 'job-hold-until' value.… in hold_job()
7995 cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, cupsdFindDest(job->dest), job, in hold_job()
7996 "Job job-hold-until value changed by user."); in hold_job()
8001 cupsdSetJobHoldUntil(job, when, 1); in hold_job()
8002 cupsdSetJobState(job, IPP_JOB_HELD, CUPSD_JOB_DEFAULT, "Job held by \"%s\".", in hold_job()
8076 * 'move_job()' - Move a job to a new destination.
8081 ipp_attribute_t *uri) /* I - Job URI */ in move_job()
8085 int jobid; /* Job ID */ in move_job()
8086 cupsd_job_t *job; /* Current job */ in move_job() local
8106 if ((attr = ippFindAttribute(con->request, "job-printer-uri", in move_job()
8110 * Need job-printer-uri... in move_job()
8114 _("job-printer-uri attribute missing.")); in move_job()
8130 * See if we have a job URI or a printer URI... in move_job()
8140 * Got a printer URI; see if we also have a job-id attribute... in move_job()
8143 if ((attr = ippFindAttribute(con->request, "job-id", in move_job()
8162 job = NULL; in move_job()
8167 * Otherwise, just move a single job... in move_job()
8170 if ((job = cupsdFindJob(attr->values[0].integer)) == NULL) in move_job()
8177 _("Job #%d does not exist."), attr->values[0].integer); in move_job()
8183 * Job found, initialize source pointers... in move_job()
8194 * Got a job URI; parse it to get the job ID... in move_job()
8203 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."), in move_job()
8209 * See if the job exists... in move_job()
8214 if ((job = cupsdFindJob(jobid)) == NULL) in move_job()
8220 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid); in move_job()
8226 * Job found, initialize source pointers... in move_job()
8239 job ? job->username : NULL)) != HTTP_OK) in move_job()
8246 * Now move the job or jobs... in move_job()
8249 if (job) in move_job()
8252 * See if the job has been completed... in move_job()
8255 if (job->state_value > IPP_JOB_STOPPED) in move_job()
8262 _("Job #%d is finished and cannot be altered."), in move_job()
8263 job->id); in move_job()
8268 * See if the job is owned by the requesting user... in move_job()
8271 if (!validate_user(job, con, job->username, username, sizeof(username))) in move_job()
8274 cupsdFindDest(job->dest)); in move_job()
8279 * Move the job to a different printer or class... in move_job()
8282 cupsdMoveJob(job, dprinter); in move_job()
8290 for (job = (cupsd_job_t *)cupsArrayFirst(Jobs); in move_job()
8291 job; in move_job()
8292 job = (cupsd_job_t *)cupsArrayNext(Jobs)) in move_job()
8295 * See if the job is pointing at the source printer or has not been in move_job()
8299 if (_cups_strcasecmp(job->dest, src) || in move_job()
8300 job->state_value > IPP_JOB_STOPPED) in move_job()
8304 * See if the job can be moved by the requesting user... in move_job()
8307 if (!validate_user(job, con, job->username, username, sizeof(username))) in move_job()
8311 * Move the job to a different printer or class... in move_job()
8314 cupsdMoveJob(job, dprinter); in move_job()
8415 cupsd_job_t *job; /* New job */ in print_job() local
8416 char filename[1024]; /* Job filename */ in print_job()
8544 cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job ???] Auto-typing file..."); in print_job()
8554 cupsdLogMessage(CUPSD_LOG_INFO, "[Job ???] Request file type is %s/%s.", in print_job()
8598 * Read any embedded job ticket info from PS files... in print_job()
8607 * Create the job object... in print_job()
8610 if ((job = add_job(con, printer, filetype)) == NULL) in print_job()
8622 cupsdUpdateQuota(printer, job->username, 0, kbytes); in print_job()
8624 job->koctets += kbytes; in print_job()
8626 if ((attr = ippFindAttribute(job->attrs, "job-k-octets", IPP_TAG_INTEGER)) != NULL) in print_job()
8630 * Add the job file... in print_job()
8633 if (add_file(con, job, filetype, compression)) in print_job()
8636 snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot, job->id, job->num_files); in print_job()
8639 …cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to rename job document file \"%s\": %s", filename, strer… in print_job()
8641 send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to rename job document file.")); in print_job()
8651 if (cupsdTimeoutJob(job)) in print_job()
8655 * Log and save the job... in print_job()
8658 cupsdLogJob(job, CUPSD_LOG_INFO, in print_job()
8660 filetype->super, filetype->type, job->username); in print_job()
8661 cupsdLogJob(job, CUPSD_LOG_DEBUG, "hold_until=%d", (int)job->hold_until); in print_job()
8662 cupsdLogJob(job, CUPSD_LOG_INFO, "Queued on \"%s\" by \"%s\".", in print_job()
8663 job->dest, job->username); in print_job()
8666 * Start the job if possible... in print_job()
8674 * 'read_job_ticket()' - Read a job ticket embedded in a print file.
8677 * file using the Print-Job operation. It doesn't work for Create-Job +
8678 * Send-File, since the job attributes need to be set at job creation
8679 * time for banners to work. The embedded job ticket stuff is here
8683 * The format of a job ticket is simple:
8692 * Job ticket lines must appear immediately after the first line that
8694 * stops looking for job ticket info when it finds a line that does not begin
8697 * The maximum length of a job ticket line, including the prefix, is
8701 * case a malicious user tries anything. Since the job ticket is read
8702 * prior to attribute validation in print_job(), job ticket attributes
8715 *attr2, /* Job attribute */ in read_job_ticket()
8716 *prev2; /* Previous job attribute */ in read_job_ticket()
8726 "Unable to open print file for job ticket - %s", in read_job_ticket()
8738 "Unable to read from print file for job ticket - %s", in read_job_ticket()
8747 * Not a DSC-compliant file, so no job ticket info will be available... in read_job_ticket()
8755 * Read job ticket info from the file... in read_job_ticket()
8804 !strcmp(attr->name, "job-impressions-completed") || in read_job_ticket()
8805 !strcmp(attr->name, "job-media-sheets-completed") || in read_job_ticket()
8806 !strncmp(attr->name, "job-k-octets", 12) || in read_job_ticket()
8807 !strcmp(attr->name, "job-id") || in read_job_ticket()
8808 !strcmp(attr->name, "job-originating-host-name") || in read_job_ticket()
8809 !strcmp(attr->name, "job-originating-user-name") || in read_job_ticket()
8810 !strcmp(attr->name, "job-pages-completed") || in read_job_ticket()
8811 !strcmp(attr->name, "job-printer-uri") || in read_job_ticket()
8812 !strncmp(attr->name, "job-state", 9) || in read_job_ticket()
8813 !strcmp(attr->name, "job-uri") || in read_job_ticket()
9013 * 'release_job()' - Release a held print job.
9018 ipp_attribute_t *uri) /* I - Job or Printer URI */ in release_job()
9021 int jobid; /* Job ID */ in release_job()
9027 cupsd_job_t *job; /* Job information */ in release_job() local
9034 * See if we have a job URI or a printer URI... in release_job()
9040 * Got a printer URI; see if we also have a job-id attribute... in release_job()
9043 if ((attr = ippFindAttribute(con->request, "job-id", in release_job()
9047 _("Got a printer-uri attribute but no job-id.")); in release_job()
9056 * Got a job URI; parse it to get the job ID... in release_job()
9069 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."), in release_job()
9078 * See if the job exists... in release_job()
9081 if ((job = cupsdFindJob(jobid)) == NULL) in release_job()
9087 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid); in release_job()
9092 * See if job is "held"... in release_job()
9095 if (job->state_value != IPP_JOB_HELD) in release_job()
9101 send_ipp_status(con, IPP_NOT_POSSIBLE, _("Job #%d is not held."), jobid); in release_job()
9106 * See if the job is owned by the requesting user... in release_job()
9109 if (!validate_user(job, con, job->username, username, sizeof(username))) in release_job()
9112 cupsdFindDest(job->dest)); in release_job()
9117 * Reset the job-hold-until value to "no-hold"... in release_job()
9120 if ((attr = ippFindAttribute(job->attrs, "job-hold-until", in release_job()
9122 attr = ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_NAME); in release_job()
9126 ippSetValueTag(job->attrs, &attr, IPP_TAG_KEYWORD); in release_job()
9127 ippSetString(job->attrs, &attr, 0, "no-hold"); in release_job()
9129 cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, cupsdFindDest(job->dest), job, in release_job()
9130 "Job job-hold-until value changed by user."); in release_job()
9131 ippSetString(job->attrs, &job->reasons, 0, "none"); in release_job()
9135 * Release the job and return... in release_job()
9138 cupsdReleaseJob(job); in release_job()
9140 cupsdAddEvent(CUPSD_EVENT_JOB_STATE, cupsdFindDest(job->dest), job, in release_job()
9141 "Job released by user."); in release_job()
9143 cupsdLogJob(job, CUPSD_LOG_INFO, "Released by \"%s\".", username); in release_job()
9184 if (sub->job) in renew_subscription()
9187 * Job subscriptions cannot be renewed... in renew_subscription()
9191 _("Job subscriptions cannot be renewed.")); in renew_subscription()
9237 * 'restart_job()' - Restart an old print job.
9242 ipp_attribute_t *uri) /* I - Job or Printer URI */ in restart_job()
9245 int jobid; /* Job ID */ in restart_job()
9246 cupsd_job_t *job; /* Job information */ in restart_job() local
9258 * See if we have a job URI or a printer URI... in restart_job()
9264 * Got a printer URI; see if we also have a job-id attribute... in restart_job()
9267 if ((attr = ippFindAttribute(con->request, "job-id", in restart_job()
9271 _("Got a printer-uri attribute but no job-id.")); in restart_job()
9280 * Got a job URI; parse it to get the job ID... in restart_job()
9293 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."), in restart_job()
9302 * See if the job exists... in restart_job()
9305 if ((job = cupsdFindJob(jobid)) == NULL) in restart_job()
9311 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid); in restart_job()
9316 * See if job is in any of the "completed" states... in restart_job()
9319 if (job->state_value <= IPP_JOB_PROCESSING) in restart_job()
9325 send_ipp_status(con, IPP_NOT_POSSIBLE, _("Job #%d is not complete."), in restart_job()
9331 * See if we have retained the job files... in restart_job()
9334 cupsdLoadJob(job); in restart_job()
9336 if (!job->attrs || job->num_files == 0) in restart_job()
9343 _("Job #%d cannot be restarted - no files."), jobid); in restart_job()
9348 * See if the job is owned by the requesting user... in restart_job()
9351 if (!validate_user(job, con, job->username, username, sizeof(username))) in restart_job()
9354 cupsdFindDest(job->dest)); in restart_job()
9359 * See if the job-hold-until attribute is specified... in restart_job()
9362 if ((attr = ippFindAttribute(con->request, "job-hold-until", in restart_job()
9364 attr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_NAME); in restart_job()
9369 * Return the job to a held state... in restart_job()
9372 cupsdLogJob(job, CUPSD_LOG_DEBUG, in restart_job()
9373 "Restarted by \"%s\" with job-hold-until=%s.", in restart_job()
9375 cupsdSetJobHoldUntil(job, attr->values[0].string.text, 1); in restart_job()
9376 cupsdSetJobState(job, IPP_JOB_HELD, CUPSD_JOB_DEFAULT, in restart_job()
9377 "Job restarted by user with job-hold-until=%s", in restart_job()
9383 * Restart the job... in restart_job()
9386 cupsdRestartJob(job); in restart_job()
9390 cupsdLogJob(job, CUPSD_LOG_INFO, "Restarted by \"%s\".", username); in restart_job()
9397 * 'save_auth_info()' - Save authentication information for a job.
9403 cupsd_job_t *job, /* I - Job */ in save_auth_info() argument
9407 char filename[1024]; /* Job authentication filename */ in save_auth_info()
9408 cups_file_t *fp; /* Job authentication file */ in save_auth_info()
9415 * a job so that it can be used to authenticate with a remote host. in save_auth_info()
9429 * Print-Job, Create-Job, or CUPS-Authenticate-Job operation is in save_auth_info()
9432 * This information is deleted after a job is completed or canceled, in save_auth_info()
9439 if ((dest = cupsdFindDest(job->dest)) == NULL) in save_auth_info()
9446 snprintf(filename, sizeof(filename), "%s/a%05d", RequestRoot, job->id); in save_auth_info()
9461 i < (int)(sizeof(job->auth_env) / sizeof(job->auth_env[0])); in save_auth_info()
9463 cupsdClearString(job->auth_env + i); in save_auth_info()
9473 i < (int)(sizeof(job->auth_env) / sizeof(job->auth_env[0])); in save_auth_info()
9486 cupsdSetStringf(job->auth_env + i, "AUTH_USERNAME=%s", in save_auth_info()
9489 cupsdSetStringf(job->auth_env + i, "AUTH_DOMAIN=%s", in save_auth_info()
9492 cupsdSetStringf(job->auth_env + i, "AUTH_PASSWORD=%s", in save_auth_info()
9495 cupsdSetStringf(job->auth_env + i, "AUTH_NEGOTIATE=%s", in save_auth_info()
9512 cupsdSetStringf(job->auth_env + 0, "AUTH_USERNAME=%s", in save_auth_info()
9518 cupsdSetStringf(job->auth_env + 1, "AUTH_PASSWORD=%s", in save_auth_info()
9530 cupsdSetStringf(job->auth_env + 0, "AUTH_USERNAME=%s", con->username); in save_auth_info()
9539 cupsdSetStringf(job->auth_env + 1, "AUTH_PASSWORD=%s", con->password); in save_auth_info()
9546 cupsdSetStringf(&job->auth_uid, "AUTH_UID=%d", (int)con->gss_uid); in save_auth_info()
9575 ipp_attribute_t *jformat; /* Job's document-format attribute */ in send_document()
9577 int jobid; /* Job ID number */ in send_document()
9578 cupsd_job_t *job; /* Current job */ in send_document() local
9580 /* Job URI */ in send_document()
9597 char filename[1024]; /* Job filename */ in send_document()
9602 int start_job; /* Start the job? */ in send_document()
9609 * See if we have a job URI or a printer URI... in send_document()
9615 * Got a printer URI; see if we also have a job-id attribute... in send_document()
9618 if ((attr = ippFindAttribute(con->request, "job-id", in send_document()
9622 _("Got a printer-uri attribute but no job-id.")); in send_document()
9631 * Got a job URI; parse it to get the job ID... in send_document()
9644 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."), in send_document()
9653 * See if the job exists... in send_document()
9656 if ((job = cupsdFindJob(jobid)) == NULL) in send_document()
9662 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid); in send_document()
9666 printer = cupsdFindDest(job->dest); in send_document()
9669 * See if the job is owned by the requesting user... in send_document()
9672 if (!validate_user(job, con, job->username, username, sizeof(username))) in send_document()
9675 cupsdFindDest(job->dest)); in send_document()
9724 * used to close an "open" job by RFC 2911, section 3.3.2. in send_document()
9727 if (job->num_files > 0 && attr->values[0].boolean) in send_document()
9738 cupsdLoadJob(job); in send_document()
9755 …ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format-supplied", NULL, ippGetSt… in send_document()
9791 cupsdLogJob(job, CUPSD_LOG_DEBUG, "Auto-typing file..."); in send_document()
9802 cupsdLogJob(job, CUPSD_LOG_DEBUG, "Request file type is %s/%s.", in send_document()
9806 …ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format-detected", NULL, mimetype… in send_document()
9821 if ((jformat = ippFindAttribute(job->attrs, "document-format", in send_document()
9823 ippSetString(job->attrs, &jformat, 0, mimetype); in send_document()
9825 ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_MIMETYPE, in send_document()
9857 * Add the file to the job... in send_document()
9860 if (add_file(con, job, filetype, compression)) in send_document()
9864 …ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "document-name-supplied", NULL, ippGetString(a… in send_document()
9871 cupsdUpdateQuota(printer, job->username, 0, kbytes); in send_document()
9873 job->koctets += kbytes; in send_document()
9875 if ((attr = ippFindAttribute(job->attrs, "job-k-octets", IPP_TAG_INTEGER)) != NULL) in send_document()
9878 snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot, job->id, job->num_files); in send_document()
9881 …cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to rename job document file \"%s\": %s", filename, strer… in send_document()
9883 send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to rename job document file.")); in send_document()
9889 cupsdLogJob(job, CUPSD_LOG_INFO, "File of type %s/%s queued by \"%s\".", in send_document()
9890 filetype->super, filetype->type, job->username); in send_document()
9893 * Start the job if this is the last document... in send_document()
9906 if (cupsdTimeoutJob(job)) in send_document()
9909 if (job->state_value == IPP_JOB_STOPPED) in send_document()
9911 job->state->values[0].integer = IPP_JOB_PENDING; in send_document()
9912 job->state_value = IPP_JOB_PENDING; in send_document()
9914 ippSetString(job->attrs, &job->reasons, 0, "none"); in send_document()
9916 else if (job->state_value == IPP_JOB_HELD) in send_document()
9918 if ((attr = ippFindAttribute(job->attrs, "job-hold-until", in send_document()
9920 attr = ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_NAME); in send_document()
9924 job->state->values[0].integer = IPP_JOB_PENDING; in send_document()
9925 job->state_value = IPP_JOB_PENDING; in send_document()
9927 ippSetString(job->attrs, &job->reasons, 0, "none"); in send_document()
9930 ippSetString(job->attrs, &job->reasons, 0, "job-hold-until-specified"); in send_document()
9933 job->dirty = 1; in send_document()
9940 if ((attr = ippFindAttribute(job->attrs, "job-hold-until", in send_document()
9942 attr = ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_NAME); in send_document()
9946 job->state->values[0].integer = IPP_JOB_HELD; in send_document()
9947 job->state_value = IPP_JOB_HELD; in send_document()
9948 job->hold_until = time(NULL) + MultipleOperationTimeout; in send_document()
9950 ippSetString(job->attrs, &job->reasons, 0, "job-incoming"); in send_document()
9952 job->dirty = 1; in send_document()
9964 ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL, job_uri); in send_document()
9966 ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", jobid); in send_document()
9968 ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", (int)job->state_value); in send_document()
9969 …ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, job->reasons-… in send_document()
9974 * Start the job if necessary... in send_document()
9997 uri = ippFindAttribute(con->request, "job-uri", IPP_TAG_URI); in send_http_error()
10184 * 'set_job_attrs()' - Set job attributes.
10189 ipp_attribute_t *uri) /* I - Job URI */ in set_job_attrs()
10192 *attr2; /* Job attribute */ in set_job_attrs()
10193 int jobid; /* Job ID */ in set_job_attrs()
10194 cupsd_job_t *job; /* Current job */ in set_job_attrs() local
10218 * See if we have a job URI or a printer URI... in set_job_attrs()
10224 * Got a printer URI; see if we also have a job-id attribute... in set_job_attrs()
10227 if ((attr = ippFindAttribute(con->request, "job-id", in set_job_attrs()
10231 _("Got a printer-uri attribute but no job-id.")); in set_job_attrs()
10240 * Got a job URI; parse it to get the job ID... in set_job_attrs()
10253 send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."), in set_job_attrs()
10262 * See if the job exists... in set_job_attrs()
10265 if ((job = cupsdFindJob(jobid)) == NULL) in set_job_attrs()
10271 send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid); in set_job_attrs()
10276 * See if the job has been completed... in set_job_attrs()
10279 if (job->state_value > IPP_JOB_STOPPED) in set_job_attrs()
10286 _("Job #%d is finished and cannot be altered."), jobid); in set_job_attrs()
10291 * See if the job is owned by the requesting user... in set_job_attrs()
10294 if (!validate_user(job, con, job->username, username, sizeof(username))) in set_job_attrs()
10297 cupsdFindDest(job->dest)); in set_job_attrs()
10305 cupsdLoadJob(job); in set_job_attrs()
10320 !strcmp(attr->name, "job-detailed-status-messages") || in set_job_attrs()
10321 !strcmp(attr->name, "job-document-access-errors") || in set_job_attrs()
10322 !strcmp(attr->name, "job-id") || in set_job_attrs()
10323 !strcmp(attr->name, "job-impressions-completed") || in set_job_attrs()
10324 !strcmp(attr->name, "job-k-octets-completed") || in set_job_attrs()
10325 !strcmp(attr->name, "job-media-sheets-completed") || in set_job_attrs()
10326 !strcmp(attr->name, "job-originating-host-name") || in set_job_attrs()
10327 !strcmp(attr->name, "job-originating-user-name") || in set_job_attrs()
10328 !strcmp(attr->name, "job-pages-completed") || in set_job_attrs()
10329 !strcmp(attr->name, "job-printer-up-time") || in set_job_attrs()
10330 !strcmp(attr->name, "job-printer-uri") || in set_job_attrs()
10331 !strcmp(attr->name, "job-sheets") || in set_job_attrs()
10332 !strcmp(attr->name, "job-state-message") || in set_job_attrs()
10333 !strcmp(attr->name, "job-state-reasons") || in set_job_attrs()
10334 !strcmp(attr->name, "job-uri") || in set_job_attrs()
10359 if (!strcmp(attr->name, "job-hold-until")) in set_job_attrs()
10362 /* job-hold-until value */ in set_job_attrs()
10366 …send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Unsupported 'job-hold-until' value.… in set_job_attrs()
10371 cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-hold-until to %s", when); in set_job_attrs()
10372 cupsdSetJobHoldUntil(job, when, 0); in set_job_attrs()
10376 cupsdReleaseJob(job); in set_job_attrs()
10380 cupsdSetJobState(job, IPP_JOB_HELD, CUPSD_JOB_DEFAULT, "Job held by \"%s\".", username); in set_job_attrs()
10384 else if (!strcmp(attr->name, "job-priority")) in set_job_attrs()
10387 * Change the job priority... in set_job_attrs()
10392 send_ipp_status(con, IPP_REQUEST_VALUE, _("Bad job-priority value.")); in set_job_attrs()
10397 else if (job->state_value >= IPP_JOB_PROCESSING) in set_job_attrs()
10400 _("Job is completed and cannot be changed.")); in set_job_attrs()
10405 cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-priority to %d", in set_job_attrs()
10407 cupsdSetJobPriority(job, attr->values[0].integer); in set_job_attrs()
10414 else if (!strcmp(attr->name, "job-state")) in set_job_attrs()
10417 * Change the job state... in set_job_attrs()
10422 send_ipp_status(con, IPP_REQUEST_VALUE, _("Bad job-state value.")); in set_job_attrs()
10433 if (job->state_value > IPP_JOB_HELD) in set_job_attrs()
10436 _("Job state cannot be changed.")); in set_job_attrs()
10441 cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-state to %d", in set_job_attrs()
10443 …cupsdSetJobState(job, (ipp_jstate_t)attr->values[0].integer, CUPSD_JOB_DEFAULT, "Job state changed… in set_job_attrs()
10450 if (job->state_value != (ipp_jstate_t)attr->values[0].integer) in set_job_attrs()
10453 _("Job state cannot be changed.")); in set_job_attrs()
10461 if (job->state_value > IPP_JOB_PROCESSING) in set_job_attrs()
10464 _("Job state cannot be changed.")); in set_job_attrs()
10469 cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-state to %d", in set_job_attrs()
10471 cupsdSetJobState(job, (ipp_jstate_t)attr->values[0].integer, in set_job_attrs()
10473 "Job state changed by \"%s\"", username); in set_job_attrs()
10482 else if ((attr2 = ippFindAttribute(job->attrs, attr->name, in set_job_attrs()
10489 if (job->attrs->prev) in set_job_attrs()
10490 job->attrs->prev->next = attr2->next; in set_job_attrs()
10492 job->attrs->attrs = attr2->next; in set_job_attrs()
10494 if (job->attrs->last == attr2) in set_job_attrs()
10495 job->attrs->last = job->attrs->prev; in set_job_attrs()
10503 ippCopyAttribute(job->attrs, attr, 0); in set_job_attrs()
10511 if ((attr2 = ippFindAttribute(job->attrs, attr->name, in set_job_attrs()
10514 if (job->attrs->prev) in set_job_attrs()
10515 job->attrs->prev->next = attr2->next; in set_job_attrs()
10517 job->attrs->attrs = attr2->next; in set_job_attrs()
10519 if (attr2 == job->attrs->last) in set_job_attrs()
10520 job->attrs->last = job->attrs->prev; in set_job_attrs()
10533 ippCopyAttribute(job->attrs, attr, 0); in set_job_attrs()
10540 * Save the job... in set_job_attrs()
10543 job->dirty = 1; in set_job_attrs()
10552 cupsdFindDest(job->dest), job, in set_job_attrs()
10553 "Job priority changed by user."); in set_job_attrs()
10556 cupsdAddEvent(CUPSD_EVENT_JOB_STATE, cupsdFindDest(job->dest), job, in set_job_attrs()
10557 job->state_value == IPP_JOB_HELD ? in set_job_attrs()
10558 "Job held by user." : "Job restarted by user."); in set_job_attrs()
10561 cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, cupsdFindDest(job->dest), job, in set_job_attrs()
10562 "Job options changed by user."); in set_job_attrs()
10703 if (!strcmp(attr->name, "job-sheets-default")) in set_printer_defaults()
10713 * Only allow job-sheets-default to be set when running without a in set_printer_defaults()
10755 else if (!strcmp(attr->name, "job-quota-period")) in set_printer_defaults()
10760 cupsdLogMessage(CUPSD_LOG_DEBUG, "Setting job-quota-period to %d...", in set_printer_defaults()
10766 else if (!strcmp(attr->name, "job-k-limit")) in set_printer_defaults()
10771 cupsdLogMessage(CUPSD_LOG_DEBUG, "Setting job-k-limit to %d...", in set_printer_defaults()
10777 else if (!strcmp(attr->name, "job-page-limit")) in set_printer_defaults()
10782 cupsdLogMessage(CUPSD_LOG_DEBUG, "Setting job-page-limit to %d...", in set_printer_defaults()
10817 if (strcmp(attr->values[0].string.text, "retry-current-job") && in set_printer_defaults()
10819 (strcmp(attr->values[0].string.text, "abort-job") && in set_printer_defaults()
10820 strcmp(attr->values[0].string.text, "retry-job") && in set_printer_defaults()
11249 *name; /* Job-name attribute */ in validate_job()
11315 * Is the job-hold-until value valid? in validate_job()
11318 …if ((attr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_ZERO)) != NULL && ((ippGetVal… in validate_job()
11320 …send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Unsupported 'job-hold-until' value.… in validate_job()
11326 * Is the job-name valid? in validate_job()
11329 if ((name = ippFindAttribute(con->request, "job-name", IPP_TAG_ZERO)) != NULL) in validate_job()
11336 send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Unsupported 'job-name' value.")); in validate_job()
11342 cupsdLogMessage(CUPSD_LOG_WARN, "Unsupported 'job-name' value, deleting from request."); in validate_job()
11435 validate_user(cupsd_job_t *job, /* I - Job */ in validate_user() argument
11437 const char *owner, /* I - Owner of job/resource */ in validate_user()
11441 cupsd_printer_t *printer; /* Printer for job */ in validate_user()
11444 …essage(CUPSD_LOG_DEBUG2, "validate_user(job=%d, con=%d, owner=\"%s\", username=%p, userlen=" CUPS_… in validate_user()
11463 printer = cupsdFindDest(job->dest); in validate_user()