1 diff -up cups-1.4rc1/cups/dest.c.cups-get-classes cups-1.4rc1/cups/dest.c
2 --- cups-1.4rc1/cups/dest.c.cups-get-classes 2009-05-13 22:39:17.000000000 +0100
3 +++ cups-1.4rc1/cups/dest.c 2009-07-28 22:17:40.285709944 +0100
4 @@ -1735,6 +1735,7 @@ cups_get_sdests(http_t *http, /* I
5 char uri[1024]; /* printer-uri value */
6 int num_options; /* Number of options */
7 cups_option_t *options; /* Options */
8 + int get_classes; /* Whether we need to fetch class */
10 char media_default[41]; /* Default paper size */
11 #endif /* __APPLE__ */
12 @@ -1791,6 +1792,8 @@ cups_get_sdests(http_t *http, /* I
13 * printer-uri [for IPP_GET_PRINTER_ATTRIBUTES]
16 + get_classes = (op == CUPS_GET_PRINTERS);
18 request = ippNewRequest(op);
20 ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
21 @@ -1848,6 +1851,23 @@ cups_get_sdests(http_t *http, /* I
22 attr->value_tag != IPP_TAG_URI)
27 + /* Is this a class? */
28 + ((attr->value_tag == IPP_TAG_ENUM &&
29 + !strcmp(attr->name, "printer-type") &&
30 + (attr->values[0].integer & CUPS_PRINTER_CLASS)) ||
32 + /* Or, is this an attribute from CUPS 1.2 or later? */
33 + !strcmp(attr->name, "auth-info-required") ||
34 + !strncmp(attr->name, "marker-", 7) ||
35 + !strcmp(attr->name, "printer-commands") ||
36 + !strcmp(attr->name, "printer-is-shared")))
37 + /* We are talking to a recent enough CUPS server that
38 + * CUPS_GET_PRINTERS returns classes as well.
42 if (!strcmp(attr->name, "auth-info-required") ||
43 !strcmp(attr->name, "device-uri") ||
44 !strcmp(attr->name, "marker-change-time") ||
45 @@ -1939,6 +1959,28 @@ cups_get_sdests(http_t *http, /* I
50 + * If we sent a CUPS_GET_CLASSES request, check whether
51 + * CUPS_GET_PRINTERS already gave us this destination and exit
55 + if (op == CUPS_GET_CLASSES)
58 + cups_find_dest (printer_name, NULL, num_dests, *dests, 0, &diff);
62 + * Found it. The CUPS server already gave us the classes in
63 + * its CUPS_GET_PRINTERS response.
66 + cupsFreeOptions(num_options, options);
71 if ((dest = cups_add_dest(printer_name, NULL, &num_dests, dests)) != NULL)
73 dest->num_options = num_options;
74 @@ -1955,6 +1997,16 @@ cups_get_sdests(http_t *http, /* I
78 + * If this is a CUPS_GET_PRINTERS request but we didn't see any
79 + * classes we might be talking to an older CUPS server that requires
80 + * CUPS_GET_CLASSES as well.
84 + num_dests = cups_get_sdests (http, CUPS_GET_CLASSES, name,