]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
The scheduler now supports PPD lookups for classes (STR #4296)
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 9 Apr 2013 19:26:08 +0000 (19:26 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 9 Apr 2013 19:26:08 +0000 (19:26 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10943 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES.txt
scheduler/client.c

index 5d1b8c38f8e8e5de605fca8dab0c6e21fa50377e..3ce9b9bebc178c5e61bf7c983f260b0316161244 100644 (file)
@@ -1,8 +1,9 @@
-CHANGES.txt - 1.7b1 - 2013-04-03
+CHANGES.txt - 1.7b1 - 2013-04-09
 --------------------------------
 
 CHANGES IN CUPS V1.7b1
 
+       - The scheduler now supports PPD lookups for classes (STR #4296)
        - The cupsfilter program did not set the FINAL_CONTENT_TYPE
          environment variable for filters.
        - Added a new "-x" option to the cancel command (STR #4103)
index 057ad2f3a167a6cd21839d2dc12c76efefbd1ef5..2dbb7ff41e2d2bd554e31a2f541e719051e91f96 100644 (file)
@@ -1302,7 +1302,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
       {
        case HTTP_STATE_GET_SEND :
             if ((!strncmp(con->uri, "/ppd/", 5) ||
-                !strncmp(con->uri, "/printers/", 10)) &&
+                !strncmp(con->uri, "/printers/", 10) ||
+                !strncmp(con->uri, "/classes/", 9)) &&
                !strcmp(con->uri + strlen(con->uri) - 4, ".ppd"))
            {
             /*
@@ -1314,8 +1315,36 @@ cupsdReadClient(cupsd_client_t *con)     /* I - Client to read from */
 
              if (!strncmp(con->uri, "/ppd/", 5))
                p = cupsdFindPrinter(con->uri + 5);
-             else
+             else if (!strncmp(con->uri, "/printers/", 10))
                p = cupsdFindPrinter(con->uri + 10);
+             else
+             {
+               p = cupsdFindClass(con->uri + 9);
+
+               if (p)
+               {
+                 int i;                /* Looping var */
+
+                 for (i = 0; i < p->num_printers; i ++)
+                 {
+                   if (!(p->printers[i]->type & CUPS_PRINTER_CLASS))
+                   {
+                     char ppdname[1024];/* PPD filename */
+
+                     snprintf(ppdname, sizeof(ppdname), "%s/ppd/%s.ppd",
+                              ServerRoot, p->printers[i]->name);
+                     if (!access(ppdname, 0))
+                     {
+                       p = p->printers[i];
+                       break;
+                     }
+                   }
+                 }
+
+                  if (i >= p->num_printers)
+                    p = NULL;
+               }
+             }
 
              if (p)
              {
@@ -1349,7 +1378,33 @@ cupsdReadClient(cupsd_client_t *con)     /* I - Client to read from */
               else if (!strncmp(con->uri, "/printers/", 10))
                 p = cupsdFindPrinter(con->uri + 10);
               else
-                p = cupsdFindClass(con->uri + 9);
+              {
+               p = cupsdFindClass(con->uri + 9);
+
+               if (p)
+               {
+                 int i;                /* Looping var */
+
+                 for (i = 0; i < p->num_printers; i ++)
+                 {
+                   if (!(p->printers[i]->type & CUPS_PRINTER_CLASS))
+                   {
+                     char ppdname[1024];/* PPD filename */
+
+                     snprintf(ppdname, sizeof(ppdname), "%s/ppd/%s.ppd",
+                              ServerRoot, p->printers[i]->name);
+                     if (!access(ppdname, 0))
+                     {
+                       p = p->printers[i];
+                       break;
+                     }
+                   }
+                 }
+
+                  if (i >= p->num_printers)
+                    p = NULL;
+               }
+             }
 
               if (p)
                snprintf(con->uri, sizeof(con->uri), "/icons/%s.png", p->name);