From 520cbc7a1058f65b1d63213010773e0d04c4b1e5 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Tue, 25 Aug 2020 14:57:28 +0200 Subject: [PATCH] driverless, libcupsfilters: Add "Fax" to printer model name when we work with the Fax part of it (cherry picked from commit c84e4295442d682613de175818e958e671f6c14a) --- cupsfilters/ppdgenerator.c | 27 ++++++++++++++++----------- utils/driverless.c | 15 ++++++++++----- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/cupsfilters/ppdgenerator.c b/cupsfilters/ppdgenerator.c index a905d8ea8..86c9f7f1f 100644 --- a/cupsfilters/ppdgenerator.c +++ b/cupsfilters/ppdgenerator.c @@ -1675,6 +1675,11 @@ ppdCreateFromIPP2(char *buffer, /* I - Filename buffer */ cupsFilePuts(fp, "*FileSystem: False\n"); cupsFilePuts(fp, "*PCFileName: \"drvless.ppd\"\n"); + if ((attr = ippFindAttribute(response, "ipp-features-supported", + IPP_TAG_KEYWORD))!= NULL && + ippContainsString(attr, "faxout")) + is_fax = 1; + if ((attr = ippFindAttribute(response, "printer-make-and-model", IPP_TAG_TEXT)) != NULL) strlcpy(make, ippGetString(attr, 0, NULL), sizeof(make)); @@ -1694,11 +1699,14 @@ ppdCreateFromIPP2(char *buffer, /* I - Filename buffer */ model = make; cupsFilePrintf(fp, "*Manufacturer: \"%s\"\n", make); - cupsFilePrintf(fp, "*ModelName: \"%s %s\"\n", make, model); - cupsFilePrintf(fp, "*Product: \"(%s %s)\"\n", make, model); - cupsFilePrintf(fp, "*NickName: \"%s %s, driverless, cups-filters %s\"\n", - make, model, VERSION); - cupsFilePrintf(fp, "*ShortNickName: \"%s %s\"\n", make, model); + cupsFilePrintf(fp, "*ModelName: \"%s %s%s\"\n", + make, model, (is_fax ? " Fax" : "")); + cupsFilePrintf(fp, "*Product: \"(%s %s%s)\"\n", + make, model, (is_fax ? " Fax" : "")); + cupsFilePrintf(fp, "*NickName: \"%s %s%s, driverless, cups-filters %s\"\n", + make, model, (is_fax ? " Fax" : ""), VERSION); + cupsFilePrintf(fp, "*ShortNickName: \"%s %s%s\"\n", + make, model, (is_fax ? " Fax" : "")); /* Which is the default output bin? */ if ((attr = ippFindAttribute(response, "output-bin-default", IPP_TAG_ZERO)) @@ -1912,16 +1920,13 @@ ppdCreateFromIPP2(char *buffer, /* I - Filename buffer */ } } } + /* * Fax */ - - if ((attr = ippFindAttribute(response, "ipp-features-supported", - IPP_TAG_KEYWORD))!= NULL && ippContainsString(attr, "faxout")){ - + + if (is_fax) cupsFilePuts(fp, "*cupsIPPFaxOut: True\n"); - is_fax = 1; - } /* Check for each CUPS/cups-filters-supported PDL, starting with the most desirable going to the least desirable. If a PDL requires a diff --git a/utils/driverless.c b/utils/driverless.c index 10980e0af..91d710a27 100644 --- a/utils/driverless.c +++ b/utils/driverless.c @@ -274,12 +274,12 @@ listPrintersInArray(int post_proc_pipe[], cups_array_t *service_uri_list_ipps, "MFG:%s;", txt_usb_mfg); } if (txt_usb_mdl[0] != '\0') { - strncpy(model, txt_usb_mdl, sizeof(model) - 1); - if (strlen(txt_usb_mdl) > 255) - model[255] = '\0'; + snprintf(model, sizeof(model) - 1, "%s%s", + txt_usb_mdl, (isFax ? " Fax" : "")); + model[255] = '\0'; ptr = device_id + strlen(device_id); snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), - "MDL:%s;", txt_usb_mdl); + "MDL:%s;", model); } else if (txt_product[0] != '\0') { if (txt_product[0] == '(') { /* Strip parenthesis... */ @@ -305,6 +305,9 @@ listPrintersInArray(int post_proc_pipe[], cups_array_t *service_uri_list_ipps, } if (!device_id[0] && strcasecmp(model, "Unknown")) { + if (isFax) + strncpy(model + strlen(model), " Fax", + sizeof(model) - strlen(model) - 1); if (make[0]) snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;", make, model); @@ -399,7 +402,9 @@ listPrintersInArray(int post_proc_pipe[], cups_array_t *service_uri_list_ipps, if (mode == 1) { /* Call with "list" argument (PPD generator in list mode) */ printf("\"%s%s\" en \"%s\" \"%s, %s, cups-filters " VERSION - "\" \"%s\"\n",((isFax)?"driverless-fax:":"driverless:") ,service_uri, make, make_and_model, driverless_info, device_id); + "\" \"%s\"\n", + ((isFax) ? "driverless-fax:" : "driverless:"), + service_uri, make, make_and_model, driverless_info, device_id); } else { /* Call without arguments and env variable "SOFTWARE" starting with "CUPS" (Backend in discovery mode) */ -- 2.47.3