]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blame - cups/patches/cups-cups-get-classes.patch
Move all packages to root.
[people/ms/ipfire-3.x.git] / cups / patches / cups-cups-get-classes.patch
CommitLineData
f92713d3
SS
1diff -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 */
9 #ifdef __APPLE__
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]
14 */
15
16+ get_classes = (op == CUPS_GET_PRINTERS);
17+
18 request = ippNewRequest(op);
19
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)
23 continue;
24
25+ if (get_classes &&
26+
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)) ||
31+
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.
39+ */
40+ get_classes = 0;
41+
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
46 continue;
47 }
48
49+ /*
50+ * If we sent a CUPS_GET_CLASSES request, check whether
51+ * CUPS_GET_PRINTERS already gave us this destination and exit
52+ * early if so.
53+ */
54+
55+ if (op == CUPS_GET_CLASSES)
56+ {
57+ int diff;
58+ cups_find_dest (printer_name, NULL, num_dests, *dests, 0, &diff);
59+ if (diff == 0)
60+ {
61+ /*
62+ * Found it. The CUPS server already gave us the classes in
63+ * its CUPS_GET_PRINTERS response.
64+ */
65+
66+ cupsFreeOptions(num_options, options);
67+ break;
68+ }
69+ }
70+
71 if ((dest = cups_add_dest(printer_name, NULL, &num_dests, dests)) != NULL)
72 {
73 dest->num_options = num_options;
74@@ -1955,6 +1997,16 @@ cups_get_sdests(http_t *http, /* I
75 }
76
77 /*
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.
81+ */
82+
83+ if (get_classes)
84+ num_dests = cups_get_sdests (http, CUPS_GET_CLASSES, name,
85+ num_dests, dests);
86+
87+ /*
88 * Return the count...
89 */
90