X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=scheduler%2Fprinters.c;h=b0298c0ec382991293a4204f32b58202bd9a5bad;hb=4220952d4d4e3b02701326ea2189a71ab3529a5f;hp=1823e697f47012a20c72e3655ea3cb443ba6e229;hpb=54afec335014303dba3c6eabe5393adce9e660ad;p=thirdparty%2Fcups.git diff --git a/scheduler/printers.c b/scheduler/printers.c index 1823e697f..b0298c0ec 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -1,7 +1,7 @@ /* * "$Id: printers.c 7968 2008-09-19 23:03:01Z mike $" * - * Printer routines for the Common UNIX Printing System (CUPS). + * Printer routines for the CUPS scheduler. * * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. @@ -309,6 +309,7 @@ cupsdCreateCommonData(void) IPP_GET_PRINTER_ATTRIBUTES, IPP_HOLD_JOB, IPP_RELEASE_JOB, + IPP_RESTART_JOB, IPP_PAUSE_PRINTER, IPP_RESUME_PRINTER, IPP_PURGE_JOBS, @@ -326,6 +327,9 @@ cupsdCreateCommonData(void) IPP_DISABLE_PRINTER, IPP_HOLD_NEW_JOBS, IPP_RELEASE_HELD_NEW_JOBS, + IPP_CANCEL_JOBS, + IPP_CANCEL_MY_JOBS, + IPP_CLOSE_JOB, CUPS_GET_DEFAULT, CUPS_GET_PRINTERS, CUPS_ADD_PRINTER, @@ -359,10 +363,10 @@ cupsdCreateCommonData(void) static const char * const media_col_supported[] = { /* media-col-supported values */ "media-bottom-margin", - "media-color", "media-left-margin", "media-right-margin", "media-size", + "media-source", "media-top-margin", "media-type" }; @@ -405,6 +409,7 @@ cupsdCreateCommonData(void) { /* job-creation-attributes-supported */ "copies", "finishings", + "ipp-attribute-fidelity", "job-hold-until", "job-name", "job-priority", @@ -443,6 +448,18 @@ cupsdCreateCommonData(void) "printer-info", "printer-location" }; + static const char * const which_jobs[] = + { /* which-jobs-supported values */ + "completed", + "not-completed", + "aborted", + "all", + "canceled", + "pending", + "pending-held", + "processing", + "processing-stopped" + }; if (CommonData) @@ -486,6 +503,10 @@ cupsdCreateCommonData(void) "ipp-versions-supported", sizeof(versions) / sizeof(versions[0]), NULL, versions); + /* ippget-event-life */ + ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, + "ippget-event-life", 15); + /* job-creation-attributes-supported */ ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD | IPP_TAG_COPY, "job-creation-attributes-supported", @@ -497,6 +518,9 @@ cupsdCreateCommonData(void) "job-hold-until-supported", sizeof(holds) / sizeof(holds[0]), NULL, holds); + /* job-ids-supported */ + ippAddBoolean(CommonData, IPP_TAG_PRINTER, "job-ids-supported", 1); + /* job-priority-supported */ ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "job-priority-supported", 100); @@ -661,6 +685,11 @@ cupsdCreateCommonData(void) /* server-is-sharing-printers */ ippAddBoolean(CommonData, IPP_TAG_PRINTER, "server-is-sharing-printers", BrowseLocalProtocols != 0 && Browsing); + + /* which-jobs-supported */ + ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD | IPP_TAG_COPY, + "which-jobs-supported", + sizeof(which_jobs) / sizeof(which_jobs[0]), NULL, which_jobs); } @@ -2654,8 +2683,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ int /* O - 1 if something changed, 0 otherwise */ cupsdSetPrinterReasons( - cupsd_printer_t *p, /* I - Printer */ - const char *s) /* I - Reasons strings */ + cupsd_printer_t *p, /* I - Printer */ + const char *s) /* I - Reasons strings */ { int i, /* Looping var */ changed = 0; /* Did something change? */ @@ -3464,12 +3493,10 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */ cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-hold-until-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-priority-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-sheets-default")); - cupsArrayAdd(CommonDefaults, _cupsStrAlloc("media-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("media-col-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("number-up-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("orientation-requested-default")); - cupsArrayAdd(CommonDefaults, _cupsStrAlloc("sides-default")); } /* @@ -3975,11 +4002,11 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ * Check to see if the cache is up-to-date... */ - snprintf(cache_name, sizeof(cache_name), "%s/%s.ipp2", CacheDir, p->name); + snprintf(cache_name, sizeof(cache_name), "%s/%s.ipp3", CacheDir, p->name); if (stat(cache_name, &cache_info)) cache_info.st_mtime = 0; - snprintf(pwg_name, sizeof(pwg_name), "%s/%s.pwg", CacheDir, p->name); + snprintf(pwg_name, sizeof(pwg_name), "%s/%s.pwg2", CacheDir, p->name); if (stat(pwg_name, &pwg_info)) pwg_info.st_mtime = 0; @@ -4166,19 +4193,23 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ if (pwgsize) { + ipp_t *col; /* Collection value */ + input_slot = ppdFindMarkedChoice(ppd, "InputSlot"); media_type = ppdFindMarkedChoice(ppd, "MediaType"); + col = new_media_col(pwgsize, + input_slot ? + _pwgGetSource(p->pwg, + input_slot->choice) : + NULL, + media_type ? + _pwgGetType(p->pwg, + media_type->choice) : + NULL); ippAddCollection(p->ppd_attrs, IPP_TAG_PRINTER, "media-col-default", - new_media_col(pwgsize, - input_slot ? - _pwgGetSource(p->pwg, - input_slot->choice) : - NULL, - media_type ? - _pwgGetType(p->pwg, - media_type->choice) : - NULL)); + col); + ippDelete(col); } /* @@ -4426,22 +4457,58 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ * Output bin... */ - if ((output_bin = ppdFindOption(ppd, "OutputBin")) != NULL) + if (p->pwg && p->pwg->num_bins > 0) { attr = ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, - "output-bin-supported", output_bin->num_choices, + "output-bin-supported", p->pwg->num_bins, NULL, NULL); if (attr != NULL) { for (i = 0, val = attr->values; - i < output_bin->num_choices; + i < p->pwg->num_bins; i ++, val ++) - val->string.text = _cupsStrAlloc(output_bin->choices[i].choice); + val->string.text = _cupsStrAlloc(p->pwg->bins[i].pwg); } + if ((output_bin = ppdFindOption(ppd, "OutputBin")) != NULL) + { + for (i = 0; i < p->pwg->num_bins; i ++) + if (!strcmp(p->pwg->bins[i].ppd, output_bin->defchoice)) + break; + + if (i >= p->pwg->num_bins) + i = 0; + + ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, + "output-bin-default", NULL, p->pwg->bins[i].pwg); + } + else + ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, + "output-bin-default", NULL, p->pwg->bins[0].pwg); + } + else if (((ppd_attr = ppdFindAttr(ppd, "DefaultOutputOrder", + NULL)) != NULL && + !strcasecmp(ppd_attr->value, "Reverse")) || + (!ppd_attr && ppd->manufacturer && /* EPSON "compatibility heuristic" */ + !strcasecmp(ppd->manufacturer, "epson"))) + { + /* + * Report that this printer has a single output bin that leaves pages face + * up. + */ + + ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, + "output-bin-supported", NULL, "face-up"); + ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, + "output-bin-default", NULL, "face-up"); + } + else + { + ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, + "output-bin-supported", NULL, "face-down"); ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, - "output-bin-default", NULL, output_bin->defchoice); + "output-bin-default", NULL, "face-down"); } /* @@ -4468,14 +4535,9 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ i < resolution->num_choices; i ++, choice ++) { - xdpi = (int)strtol(choice->choice, (char **)&resptr, 10); - if (resptr > choice->choice && xdpi > 0) - { - if (*resptr == 'x') - ydpi = (int)strtol(resptr + 1, (char **)&resptr, 10); - else - ydpi = xdpi; - } + xdpi = ydpi = (int)strtol(choice->choice, (char **)&resptr, 10); + if (resptr > choice->choice && xdpi > 0 && *resptr == 'x') + ydpi = (int)strtol(resptr + 1, (char **)&resptr, 10); if (xdpi <= 0 || ydpi <= 0) { @@ -4502,7 +4564,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ * Just the DefaultResolution to report... */ - xdpi = (int)strtol(ppd_attr->value, (char **)&resptr, 10); + xdpi = ydpi = (int)strtol(ppd_attr->value, (char **)&resptr, 10); if (resptr > ppd_attr->value && xdpi > 0) { if (*resptr == 'x') @@ -4568,6 +4630,13 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "sides-default", NULL, "one-sided"); } + else + { + ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, + "sides-supported", NULL, "one-sided"); + ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, + "sides-default", NULL, "one-sided"); + } if (ppdFindOption(ppd, "Collate") != NULL) p->type |= CUPS_PRINTER_COLLATE; @@ -4975,8 +5044,9 @@ new_media_col(_pwg_size_t *size, /* I - media-size/margin values */ "x-dimension", size->width); ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "y-dimension", size->length); - ippAddCollection(media_col, IPP_TAG_PRINTER, "media-size", media_size); + ippDelete(media_size); + ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-bottom-margin", size->bottom); ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,