]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Generate full 1284 device ID as needed (STR #3702)
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 11 Dec 2012 20:01:35 +0000 (20:01 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 11 Dec 2012 20:01:35 +0000 (20:01 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10748 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES.txt
backend/dnssd.c

index 3f46641592cbc15e894f40c430f043faa4f25ec8..38f8edf70a8f56b249f1d04204130830d991134a 100644 (file)
@@ -1,4 +1,4 @@
-CHANGES.txt - 1.7b1 - 2012-11-15
+CHANGES.txt - 1.7b1 - 2012-12-11
 --------------------------------
 
 CHANGES IN CUPS V1.7b1
@@ -6,6 +6,7 @@ CHANGES IN CUPS V1.7b1
        - Added new IPP APIs for checking values (STR #4167)
        - Added new IPP APis for adding and setting formatted strings.
        - Added new HTTP APIs to support basic server functionality via libcups.
+       - The dnssd backend now generates a 1284 device ID as needed (STR #3702)
        - CUPS now supports compressing and decompressing streamed data
          (STR #4168)
        - CUPS now supports higher-level PIN printing, external accounting
index 46c0f134711bf311f5e6a568fcc27e544a91e6d0..9cea92e037d2849655532afe16caa033699760c1 100644 (file)
@@ -1031,6 +1031,7 @@ query_callback(
                value[256],             /* Value string */
                make_and_model[512],    /* Manufacturer and model */
                model[256],             /* Model */
+               pdl[256],               /* PDL */
                device_id[2048];        /* 1284 device ID */
 
 
@@ -1079,6 +1080,7 @@ query_callback(
 
   device_id[0]      = '\0';
   make_and_model[0] = '\0';
+  pdl[0]            = '\0';
 
   strlcpy(model, "Unknown", sizeof(model));
 
@@ -1160,6 +1162,8 @@ query_callback(
       if ((ptr = strchr(model, ',')) != NULL)
        *ptr = '\0';
     }
+    else if (!_cups_strcasecmp(key, "pdl"))
+      strlcpy(pdl, value, sizeof(pdl));
     else if (!_cups_strcasecmp(key, "priority"))
       device->priority = atoi(value);
     else if ((device->type == CUPS_DEVICE_IPP ||
@@ -1204,6 +1208,46 @@ query_callback(
     }
   }
 
+  if (device_id[0] &&
+      !strstr(device_id, "CMD:") &&
+      !strstr(device_id, "COMMAND SET:") &&
+      (strstr(pdl, "application/pdf") ||
+       strstr(pdl, "application/postscript") ||
+       strstr(pdl, "application/vnd.hp-PCL") ||
+       strstr(pdl, "image/")))
+  {
+    value[0] = '\0';
+    if (strstr(pdl, "application/pdf"))
+      strlcat(value, ",PDF", sizeof(value));
+    if (strstr(pdl, "application/postscript"))
+      strlcat(value, ",PS", sizeof(value));
+    if (strstr(pdl, "application/vnd.hp-PCL"))
+      strlcat(value, ",PCL", sizeof(value));
+    for (ptr = strstr(pdl, "image/"); ptr; ptr = strstr(ptr, "image/"))
+    {
+      char *valptr = value + strlen(value);
+                                       /* Pointer into value */
+
+      if (valptr < (value + sizeof(value) - 1))
+        *valptr++ = ',';
+
+      ptr += 6;
+      while (isalnum(*ptr & 255) || *ptr == '-' || *ptr == '.')
+      {
+        if (isalnum(*ptr & 255) && valptr < (value + sizeof(value) - 1))
+          *valptr++ = toupper(*ptr++ & 255);
+        else
+          break;
+      }
+
+      *valptr = '\0';
+    }
+
+    ptr = device_id + strlen(device_id);
+    snprintf(ptr, sizeof(device_id) - (ptr - device_id), "CMD:%s;",
+            value + 1);
+  }
+
   if (device_id[0])
     device->device_id = strdup(device_id);
   else