]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
driverless, libcupsfilters: Add "Fax" to printer model name when we work with the...
authorTill Kamppeter <till.kamppeter@gmail.com>
Tue, 25 Aug 2020 12:57:28 +0000 (14:57 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Tue, 25 Aug 2020 15:26:26 +0000 (17:26 +0200)
(cherry picked from commit c84e4295442d682613de175818e958e671f6c14a)

cupsfilters/ppdgenerator.c
utils/driverless.c

index a905d8ea859eeb8e6993e50318e444b1a81c85e6..86c9f7f1fd48b73fbe488c436d456d1944355dff 100644 (file)
@@ -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
index 10980e0af9996e00bff38fc02a92c2e8e9c07692..91d710a27d404e0fd1b3e96aff2cf4856f4ebec3 100644 (file)
@@ -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) */