diff options
author | Martin Jansa <Martin.Jansa@gmail.com> | 2012-12-23 11:48:49 +0100 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2012-12-23 13:03:18 +0100 |
commit | 797d4aa8d54593f02d626c5eb646ee72de691deb (patch) | |
tree | 88e214709d13d541a616e6e8ff6ca30fe59aa01d /meta-gnome/recipes-gnome/gnome/libgnomecups | |
parent | c012d759c305b3e4f9ef5954cf3a80143c1fe55f (diff) | |
download | meta-openembedded-797d4aa8d54593f02d626c5eb646ee72de691deb.tar.gz |
libgnomecups: fix build with cups-1.6 from oe-core
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-gnome/recipes-gnome/gnome/libgnomecups')
-rw-r--r-- | meta-gnome/recipes-gnome/gnome/libgnomecups/libgnomecups-0.2.3-cups-1.6.patch | 288 |
1 files changed, 288 insertions, 0 deletions
diff --git a/meta-gnome/recipes-gnome/gnome/libgnomecups/libgnomecups-0.2.3-cups-1.6.patch b/meta-gnome/recipes-gnome/gnome/libgnomecups/libgnomecups-0.2.3-cups-1.6.patch new file mode 100644 index 0000000000..dba60ca691 --- /dev/null +++ b/meta-gnome/recipes-gnome/gnome/libgnomecups/libgnomecups-0.2.3-cups-1.6.patch | |||
@@ -0,0 +1,288 @@ | |||
1 | Imported from gentoo: | ||
2 | http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-print/libgnomecups/files/libgnomecups-0.2.3-cups-1.6.patch | ||
3 | |||
4 | From ae783efde4fa69578651994505462f02b8639220 Mon Sep 17 00:00:00 2001 | ||
5 | From: Alexandre Rostovtsev <tetromino@gentoo.org> | ||
6 | Date: Tue, 7 Aug 2012 06:53:09 -0400 | ||
7 | Subject: [PATCH] Use CUPS-1.6 IPP API getter/setter functions | ||
8 | |||
9 | CUPS 1.6 makes various structures private and introduces these ippGet | ||
10 | and ippSet functions for all of the fields in these structures. | ||
11 | http://www.cups.org/str.php?L3928 | ||
12 | |||
13 | We define our own accessors when building against CUPS < 1.6. | ||
14 | |||
15 | Based on work by Jiri Popelka <jpopelka@redhat.com> at | ||
16 | https://bugzilla.gnome.org/show_bug.cgi?id=679759 | ||
17 | --- | ||
18 | libgnomecups/gnome-cups-printer.c | 48 +++++++++++++++++++++++++++++------- | ||
19 | libgnomecups/gnome-cups-queue.c | 43 +++++++++++++++++++++++++++------ | ||
20 | libgnomecups/gnome-cups-request.c | 44 ++++++++++++++++++++++++++++----- | ||
21 | 3 files changed, 110 insertions(+), 25 deletions(-) | ||
22 | |||
23 | diff --git a/libgnomecups/gnome-cups-printer.c b/libgnomecups/gnome-cups-printer.c | ||
24 | index c924af0..f5e1ef7 100644 | ||
25 | --- a/libgnomecups/gnome-cups-printer.c | ||
26 | +++ b/libgnomecups/gnome-cups-printer.c | ||
27 | @@ -37,6 +37,34 @@ | ||
28 | |||
29 | #define UPDATE_TIMEOUT 5000 | ||
30 | |||
31 | +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5) | ||
32 | +#define HAVE_CUPS_1_6 1 | ||
33 | +#endif | ||
34 | + | ||
35 | +#ifndef HAVE_CUPS_1_6 | ||
36 | +#define ippGetCount(attr) attr->num_values | ||
37 | +#define ippGetName(attr) attr->name | ||
38 | +#define ippGetInteger(attr, element) attr->values[element].integer | ||
39 | +#define ippGetString(attr, element, language) attr->values[element].string.text | ||
40 | + | ||
41 | +static ipp_attribute_t * | ||
42 | +ippFirstAttribute(ipp_t *ipp) | ||
43 | +{ | ||
44 | + if (!ipp) | ||
45 | + return (NULL); | ||
46 | + return (ipp->current = ipp->attrs); | ||
47 | +} | ||
48 | + | ||
49 | +static ipp_attribute_t * | ||
50 | +ippNextAttribute(ipp_t *ipp) | ||
51 | +{ | ||
52 | + if (!ipp || !ipp->current) | ||
53 | + return (NULL); | ||
54 | + return (ipp->current = ipp->current->next); | ||
55 | +} | ||
56 | +#endif | ||
57 | + | ||
58 | + | ||
59 | struct _GnomeCupsPPDFile { | ||
60 | char name[1]; | ||
61 | }; | ||
62 | @@ -173,9 +201,9 @@ map_reasons (GnomeCupsPrinter *printer, | ||
63 | printer->details->state_reasons = NULL; | ||
64 | |||
65 | /* cf. RFC2911 4.4.12 */ | ||
66 | - for (i = 0; i < attr->num_values; i++) { | ||
67 | + for (i = 0; i < ippGetCount (attr); i++) { | ||
68 | const char *p; | ||
69 | - const char *keyword = attr->values [i].string.text; | ||
70 | + const char *keyword = ippGetString (attr, i, NULL); | ||
71 | |||
72 | reason = g_new (GnomeCupsPrinterReason, 1); | ||
73 | |||
74 | @@ -224,8 +252,8 @@ gnome_cups_printer_get_info (GnomeCupsPrinter *printer) | ||
75 | return printer->details->info; | ||
76 | } | ||
77 | |||
78 | -#define MAP_INT(v,a) {if (!g_ascii_strcasecmp (attr->name, (a))) { if ((v) != attr->values[0].integer) { changed = TRUE; } (v) = attr->values[0].integer; }} | ||
79 | -#define MAP_STRING(v,a) {if (!g_ascii_strcasecmp (attr->name, (a))) { if (!v || strcmp (v, attr->values[0].string.text)) { g_free (v); changed = TRUE; (v) = g_strdup (attr->values[0].string.text); }}} | ||
80 | +#define MAP_INT(v,a) {if (!g_ascii_strcasecmp (ippGetName (attr), (a))) { if ((v) != ippGetInteger (attr, 0)) { changed = TRUE; } (v) = ippGetInteger (attr, 0); }} | ||
81 | +#define MAP_STRING(v,a) {if (!g_ascii_strcasecmp (ippGetName (attr), (a))) { if (!v || strcmp (v, ippGetString (attr, 0, NULL))) { g_free (v); changed = TRUE; (v) = g_strdup (ippGetString (attr, 0, NULL)); }}} | ||
82 | |||
83 | static void | ||
84 | attributes_update_cb (guint id, | ||
85 | @@ -243,14 +271,14 @@ attributes_update_cb (guint id, | ||
86 | changed = FALSE; | ||
87 | |||
88 | if (!error && response) { | ||
89 | - for (attr = response->attrs; attr != NULL; attr = attr->next) { | ||
90 | - if (!attr->name) { | ||
91 | + for (attr = ippFirstAttribute (response); attr != NULL; attr = ippNextAttribute (response)) { | ||
92 | + if (!ippGetName (attr)) { | ||
93 | continue; | ||
94 | } | ||
95 | - if (!g_ascii_strcasecmp (attr->name, "attributes-charset") || !strcmp (attr->name, "attributes-charset")) { | ||
96 | + if (!g_ascii_strcasecmp (ippGetName (attr), "attributes-charset") || !strcmp (ippGetName (attr), "attributes-charset")) { | ||
97 | continue; | ||
98 | } | ||
99 | - if (!g_ascii_strcasecmp (attr->name, "printer-state-reasons")) { | ||
100 | + if (!g_ascii_strcasecmp (ippGetName (attr), "printer-state-reasons")) { | ||
101 | map_reasons (printer, attr); | ||
102 | } | ||
103 | MAP_INT (printer->details->state, "printer-state"); | ||
104 | @@ -570,7 +598,7 @@ get_default (void) | ||
105 | |||
106 | attr = ippFindAttribute (response, "printer-name", IPP_TAG_NAME); | ||
107 | if (attr) { | ||
108 | - name = g_strdup (attr->values[0].string.text); | ||
109 | + name = g_strdup (ippGetString (attr, 0, NULL)); | ||
110 | } else { | ||
111 | name = NULL; | ||
112 | } | ||
113 | @@ -698,7 +726,7 @@ get_printer_names (void) | ||
114 | attr = ippFindAttribute (response, "printer-name", IPP_TAG_NAME); | ||
115 | while (attr) { | ||
116 | ret = g_list_prepend (ret, | ||
117 | - g_strdup (attr->values[0].string.text)); | ||
118 | + g_strdup (ippGetString (attr, 0, NULL))); | ||
119 | |||
120 | attr = ippFindNextAttribute (response, | ||
121 | "printer-name", | ||
122 | diff --git a/libgnomecups/gnome-cups-queue.c b/libgnomecups/gnome-cups-queue.c | ||
123 | index 9f98ed9..298db42 100644 | ||
124 | --- a/libgnomecups/gnome-cups-queue.c | ||
125 | +++ b/libgnomecups/gnome-cups-queue.c | ||
126 | @@ -15,6 +15,33 @@ | ||
127 | |||
128 | #define UPDATE_TIMEOUT 3000 | ||
129 | |||
130 | +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5) | ||
131 | +#define HAVE_CUPS_1_6 1 | ||
132 | +#endif | ||
133 | + | ||
134 | +#ifndef HAVE_CUPS_1_6 | ||
135 | +#define ippGetName(attr) attr->name | ||
136 | +#define ippGetInteger(attr, element) attr->values[element].integer | ||
137 | +#define ippGetString(attr, element, language) attr->values[element].string.text | ||
138 | + | ||
139 | +static ipp_attribute_t * | ||
140 | +ippFirstAttribute(ipp_t *ipp) | ||
141 | +{ | ||
142 | + if (!ipp) | ||
143 | + return (NULL); | ||
144 | + return (ipp->current = ipp->attrs); | ||
145 | +} | ||
146 | + | ||
147 | +static ipp_attribute_t * | ||
148 | +ippNextAttribute(ipp_t *ipp) | ||
149 | +{ | ||
150 | + if (!ipp || !ipp->current) | ||
151 | + return (NULL); | ||
152 | + return (ipp->current = ipp->current->next); | ||
153 | +} | ||
154 | +#endif | ||
155 | + | ||
156 | + | ||
157 | struct _GnomeCupsQueueDetails { | ||
158 | char *queue_name; | ||
159 | GList *jobs; | ||
160 | @@ -199,8 +226,8 @@ finish_job (GnomeCupsJob *job) | ||
161 | job->size = job->size * 1024; | ||
162 | } | ||
163 | |||
164 | -#define MAP_STR(dest, src) { if (!g_ascii_strcasecmp (attr->name, (src))) { if ((dest) != NULL) g_free (dest); (dest) = g_strdup (attr->values[0].string.text);}} | ||
165 | -#define MAP_INT(dest, src) { if (!g_ascii_strcasecmp (attr->name, (src))) { (dest) = attr->values[0].integer; } } | ||
166 | +#define MAP_STR(dest, src) { if (!g_ascii_strcasecmp (ippGetName (attr), (src))) { if ((dest) != NULL) g_free (dest); (dest) = g_strdup (ippGetString (attr, 0, NULL));}} | ||
167 | +#define MAP_INT(dest, src) { if (!g_ascii_strcasecmp (ippGetName (attr), (src))) { (dest) = ippGetInteger (attr, 0); } } | ||
168 | |||
169 | static void | ||
170 | get_jobs_cb (guint id, | ||
171 | @@ -231,8 +258,8 @@ get_jobs_cb (guint id, | ||
172 | |||
173 | if (response) { | ||
174 | job = g_new0 (GnomeCupsJob, 1); | ||
175 | - for (attr = response->attrs; attr != NULL; attr = attr->next) { | ||
176 | - if (attr->name == NULL) { | ||
177 | + for (attr = ippFirstAttribute (response); attr != NULL; attr = ippNextAttribute (response)) { | ||
178 | + if (ippGetName (attr) == NULL) { | ||
179 | if (job->name) { | ||
180 | finish_job (job); | ||
181 | jobs = g_list_prepend (jobs, job); | ||
182 | @@ -244,7 +271,7 @@ get_jobs_cb (guint id, | ||
183 | continue; | ||
184 | } | ||
185 | |||
186 | - if (!g_ascii_strcasecmp (attr->name, "attributes-charset") || !g_ascii_strcasecmp (attr->name, "attributes-charset")) { | ||
187 | + if (!g_ascii_strcasecmp (ippGetName (attr), "attributes-charset") || !g_ascii_strcasecmp (ippGetName (attr), "attributes-charset")) { | ||
188 | continue; | ||
189 | |||
190 | } | ||
191 | @@ -355,8 +382,8 @@ gnome_cups_queue_get_job_nocache (GnomeCupsQueue *queue, | ||
192 | |||
193 | if (response) { | ||
194 | job = g_new0 (GnomeCupsJob, 1); | ||
195 | - for (attr = response->attrs; attr != NULL; attr = attr->next) { | ||
196 | - if (attr->name == NULL) { | ||
197 | + for (attr = ippFirstAttribute (response); attr != NULL; attr = ippNextAttribute (response)) { | ||
198 | + if (ippGetName (attr) == NULL) { | ||
199 | if (job->name) { | ||
200 | finish_job (job); | ||
201 | } else { | ||
202 | @@ -366,7 +393,7 @@ gnome_cups_queue_get_job_nocache (GnomeCupsQueue *queue, | ||
203 | break; | ||
204 | } | ||
205 | |||
206 | - if (!g_ascii_strcasecmp (attr->name, "attributes-charset") || !g_ascii_strcasecmp (attr->name, "attributes-charset")) { | ||
207 | + if (!g_ascii_strcasecmp (ippGetName (attr), "attributes-charset") || !g_ascii_strcasecmp (ippGetName (attr), "attributes-charset")) { | ||
208 | continue; | ||
209 | } | ||
210 | |||
211 | diff --git a/libgnomecups/gnome-cups-request.c b/libgnomecups/gnome-cups-request.c | ||
212 | index c94f623..13f0948 100644 | ||
213 | --- a/libgnomecups/gnome-cups-request.c | ||
214 | +++ b/libgnomecups/gnome-cups-request.c | ||
215 | @@ -19,6 +19,36 @@ | ||
216 | #define STOP_UNUSED_THREADS_TIMEOUT 60 | ||
217 | #define CLOSE_UNUSED_CONNECTIONS_TIMEOUT 30 | ||
218 | |||
219 | +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5) | ||
220 | +#define HAVE_CUPS_1_6 1 | ||
221 | +#endif | ||
222 | + | ||
223 | +#ifndef HAVE_CUPS_1_6 | ||
224 | +#define ippGetCount(attr) attr->num_values | ||
225 | +#define ippGetValueTag(attr) attr->value_tag | ||
226 | +#define ippGetName(attr) attr->name | ||
227 | +#define ippGetBoolean(attr, element) attr->values[element].boolean | ||
228 | +#define ippGetInteger(attr, element) attr->values[element].integer | ||
229 | +#define ippGetString(attr, element, language) attr->values[element].string.text | ||
230 | + | ||
231 | +static ipp_attribute_t * | ||
232 | +ippFirstAttribute(ipp_t *ipp) | ||
233 | +{ | ||
234 | + if (!ipp) | ||
235 | + return (NULL); | ||
236 | + return (ipp->current = ipp->attrs); | ||
237 | +} | ||
238 | + | ||
239 | +static ipp_attribute_t * | ||
240 | +ippNextAttribute(ipp_t *ipp) | ||
241 | +{ | ||
242 | + if (!ipp || !ipp->current) | ||
243 | + return (NULL); | ||
244 | + return (ipp->current = ipp->current->next); | ||
245 | +} | ||
246 | +#endif | ||
247 | + | ||
248 | + | ||
249 | typedef struct | ||
250 | { | ||
251 | GMutex *mutex; | ||
252 | @@ -276,14 +306,14 @@ dump_request (ipp_t const *req) | ||
253 | unsigned i; | ||
254 | ipp_attribute_t *attr; | ||
255 | |||
256 | - for (attr = req->attrs; attr != NULL; attr = attr->next) { | ||
257 | - g_print ("%s", attr->name); | ||
258 | - for (i = 0 ; i < attr->num_values ; i++) { | ||
259 | + for (attr = ippFirstAttribute (req); attr != NULL; attr = ippNextAttribute (req)) { | ||
260 | + g_print ("%s", ippGetName (attr)); | ||
261 | + for (i = 0 ; i < ippGetCount (attr) ; i++) { | ||
262 | g_print ("\t[%d] = ", i); | ||
263 | - switch (attr->value_tag & ~IPP_TAG_COPY) { | ||
264 | + switch (ippGetValueTag (attr) & ~IPP_TAG_COPY) { | ||
265 | case IPP_TAG_INTEGER: | ||
266 | case IPP_TAG_ENUM: | ||
267 | - g_print ("%d\n", attr->values[i].integer); | ||
268 | + g_print ("%d\n", ippGetInteger (attr, i)); | ||
269 | break; | ||
270 | |||
271 | case IPP_TAG_STRING: | ||
272 | @@ -294,11 +324,11 @@ dump_request (ipp_t const *req) | ||
273 | case IPP_TAG_CHARSET: | ||
274 | case IPP_TAG_LANGUAGE: | ||
275 | case IPP_TAG_MIMETYPE: | ||
276 | - g_print ("'%s'\n", attr->values[i].string.text); | ||
277 | + g_print ("'%s'\n", ippGetString (attr, i, NULL)); | ||
278 | break; | ||
279 | |||
280 | case IPP_TAG_BOOLEAN: | ||
281 | - g_print ("%s\n", (int)attr->values[i].boolean ? "true" : "false"); | ||
282 | + g_print ("%s\n", (int)ippGetBoolean (attr, i) ? "true" : "false"); | ||
283 | break; | ||
284 | |||
285 | default: | ||
286 | -- | ||
287 | 1.7.8.6 | ||
288 | |||