]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Improve IPP Everywhere support (Issue #4909)
authorMichael R Sweet <michaelrsweet@gmail.com>
Thu, 27 Oct 2016 19:53:47 +0000 (15:53 -0400)
committerMichael R Sweet <michaelrsweet@gmail.com>
Thu, 27 Oct 2016 19:53:47 +0000 (15:53 -0400)
CHANGES.txt
cups/ppd-cache.c

index b07da465a11a3bae80a44e0143fb2a003308afa1..17c291b207127354ac895eefae73728905e394c4 100644 (file)
@@ -1,9 +1,10 @@
-CHANGES.txt - 2.2.2 - 2016-10-21
+CHANGES.txt - 2.2.2 - 2016-10-27
 --------------------------------
 
 CHANGES IN CUPS V2.2.2
 
-       - Fixed some issues with IPP Everywhere printer support (Issue #4893)
+       - Fixed some issues with IPP Everywhere printer support (Issue #4893,
+         Issue #4909)
        - The cups-lpd program did not catch all legacy usage of ISO-8859-1
           (Issue #4899)
         - Fixed builds on systems without a working poll() implementation
index 11253d85734b88dd3772f7d32d94cda657f14ff7..83446d9dfde26e6f81a524a31efd18f7fd960418 100644 (file)
@@ -3159,19 +3159,32 @@ _ppdCreateFromIPP(char   *buffer,       /* I - Filename buffer */
     else
       strlcpy(ppdname, "Unknown", sizeof(ppdname));
   }
+  else if ((pwg = pwgMediaForPWG(ippGetString(ippFindAttribute(response, "media-default", IPP_TAG_ZERO), 0, NULL))) != NULL)
+    strlcpy(ppdname, pwg->ppd, sizeof(ppdname));
+  else
+    strlcpy(ppdname, "Unknown", sizeof(ppdname));
 
-  if ((attr = ippFindAttribute(response, "media-size-supported", IPP_TAG_BEGIN_COLLECTION)) != NULL)
+  if ((attr = ippFindAttribute(response, "media-size-supported", IPP_TAG_BEGIN_COLLECTION)) == NULL)
+    attr = ippFindAttribute(response, "media-supported", IPP_TAG_ZERO);
+  if (attr)
   {
     cupsFilePrintf(fp, "*OpenUI *PageSize: PickOne\n"
                       "*OrderDependency: 10 AnySetup *PageSize\n"
                        "*DefaultPageSize: %s\n", ppdname);
     for (i = 0, count = ippGetCount(attr); i < count; i ++)
     {
-      media_size = ippGetCollection(attr, i);
-      x_dim      = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
-      y_dim      = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
+      if (ippGetValueTag(attr) == IPP_TAG_BEGIN_COLLECTION)
+      {
+       media_size = ippGetCollection(attr, i);
+       x_dim      = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
+       y_dim      = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
 
-      if (x_dim && y_dim && (pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0))) != NULL)
+       pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0));
+      }
+      else
+        pwg = pwgMediaForPWG(ippGetString(attr, i, NULL));
+
+      if (pwg)
       {
         char   twidth[256],            /* Width string */
                tlength[256];           /* Length string */
@@ -3240,12 +3253,12 @@ _ppdCreateFromIPP(char   *buffer,       /* I - Filename buffer */
   * InputSlot...
   */
 
-  if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-source", IPP_TAG_KEYWORD)) != NULL)
+  if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-source", IPP_TAG_ZERO)) != NULL)
     pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
   else
     strlcpy(ppdname, "Unknown", sizeof(ppdname));
 
-  if ((attr = ippFindAttribute(response, "media-source-supported", IPP_TAG_KEYWORD)) != NULL && (count = ippGetCount(attr)) > 1)
+  if ((attr = ippFindAttribute(response, "media-source-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1)
   {
     static const char * const sources[][2] =
     {                                  /* "media-source" strings */
@@ -3322,12 +3335,12 @@ _ppdCreateFromIPP(char   *buffer,       /* I - Filename buffer */
   * MediaType...
   */
 
-  if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-type", IPP_TAG_KEYWORD)) != NULL)
+  if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-type", IPP_TAG_ZERO)) != NULL)
     pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
   else
     strlcpy(ppdname, "Unknown", sizeof(ppdname));
 
-  if ((attr = ippFindAttribute(response, "media-type-supported", IPP_TAG_KEYWORD)) != NULL && (count = ippGetCount(attr)) > 1)
+  if ((attr = ippFindAttribute(response, "media-type-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1)
   {
     static const char * const media_types[][2] =
     {                                  /* "media-type" strings */
@@ -3476,7 +3489,8 @@ _ppdCreateFromIPP(char   *buffer, /* I - Filename buffer */
 
   if ((attr = ippFindAttribute(response, "pwg-raster-document-type-supported", IPP_TAG_KEYWORD)) == NULL)
     if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD)) == NULL)
-      attr = ippFindAttribute(response, "print-color-mode-supported", IPP_TAG_KEYWORD);
+      if ((attr = ippFindAttribute(response, "print-color-mode-supported", IPP_TAG_KEYWORD)) == NULL)
+        attr = ippFindAttribute(response, "output-mode-supported", IPP_TAG_KEYWORD);
 
   if (attr)
   {
@@ -3987,6 +4001,12 @@ pwg_ppdize_name(const char *ipp, /* I - IPP keyword */
        *end;                           /* End of name buffer */
 
 
+  if (!ipp)
+  {
+    *name = '\0';
+    return;
+  }
+
   *name = (char)toupper(*ipp++);
 
   for (ptr = name + 1, end = name + namesize - 1; *ipp && ptr < end;)