From: mike Date: Tue, 9 Apr 2013 19:26:08 +0000 (+0000) Subject: The scheduler now supports PPD lookups for classes (STR #4296) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45c2e588a7477a166dfe27a3a780c00b2ba95c40;p=thirdparty%2Fcups.git The scheduler now supports PPD lookups for classes (STR #4296) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10943 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/CHANGES.txt b/CHANGES.txt index 5d1b8c38f8..3ce9b9bebc 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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) diff --git a/scheduler/client.c b/scheduler/client.c index 057ad2f3a1..2dbb7ff41e 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -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);