wok view xfprint/stuff/xfprint-4.6.1-cups-1.6.patch @ rev 19446
dillo: add stuff/fltk-1.3.3.u
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Oct 15 18:21:21 2016 +0200 (2016-10-15) |
parents | |
children |
line source
1 >From 2b5b2efdf2ce8233933c1304dc00c271303a4d92 Mon Sep 17 00:00:00 2001
2 From: Matt Philips <matt.philips@timesys.com>
3 Date: Fri, 19 Apr 2013 14:31:37 -0400
4 Subject: [PATCH] Use CUPS-1.6 IPP API getter/setter functions
6 CUPS 1.6 makes various structures private and introduces these ippGet
7 and ippSet functions for all of the fields in these structures.
8 http://www.cups.org/str.php?L3928
10 We define our own accessors when building against CUPS < 1.6.
12 Based on work by Jiri Popelka <jpopelka@redhat.com> at
13 https://bugzilla.gnome.org/show_bug.cgi?id=679759
14 ---
15 printing-systems/cups/cups.c | 64 +++++++++++++++++-----------
16 1 file changed, 38 insertions(+), 26 deletions(-)
18 diff --git a/printing-systems/cups/cups.c b/xfprint-4.6.1/printing-systems/cups/cups.c
19 index 96b30d1..9d5df01 100644
20 --- a/printing-systems/cups/cups.c
21 +++ b/printing-systems/cups/cups.c
22 @@ -44,6 +44,37 @@ G_MODULE_EXPORT const gchar version[] = VERSION;
23 G_MODULE_EXPORT const gchar author[] = "Jean-François Wauthy";
24 G_MODULE_EXPORT const gchar homepage[] = "http://www.xfce.org";
26 +/* fix for cups 1.6 incompatibility */
27 +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
28 +#define HAVE_CUPS_1_6 1
29 +#endif
30 +
31 +#ifndef HAVE_CUPS_1_6
32 +#define ippGetState(request) request->state
33 +#define ippGetInteger(attr, element) attr->values[element].integer
34 +#define ippGetString(attr, element, language) attr->values[element].string.text
35 +#define ippNewRequest(operation_id) cups_request_new(operation_id)
36 +
37 +static ipp_t *
38 +cups_request_new (int operation_id)
39 +{
40 + ipp_t *request;
41 + cups_lang_t *language;
42 +
43 + language = cupsLangDefault ();
44 + request = ippNew ();
45 + request->request.op.operation_id = operation_id;
46 + request->request.op.request_id = 1;
47 +
48 + ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, "utf-8");
49 +
50 + ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language);
51 + cupsLangFree (language);
52 +
53 + return request;
54 +}
55 +#endif
56 +
57 static GtkActionEntry printer_list_action_entries[] = {
58 {"set-default-printer", GTK_STOCK_PRINT, N_("Set as default printer"), NULL,
59 N_("Set as default CUPS printer"), G_CALLBACK (action_set_default_printer_cb),},
60 @@ -126,25 +157,6 @@ cups_password_cb (const char *prompt)
61 }
63 static ipp_t *
64 -cups_request_new (int operation_id)
65 -{
66 - ipp_t *request;
67 - cups_lang_t *language;
68 -
69 - language = cupsLangDefault ();
70 - request = ippNew ();
71 - request->request.op.operation_id = operation_id;
72 - request->request.op.request_id = 1;
73 -
74 - ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, "utf-8");
75 -
76 - ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language);
77 - cupsLangFree (language);
78 -
79 - return request;
80 -}
81 -
82 -static ipp_t *
83 cups_request_new_for_printer (int operation_id, const gchar * printer)
84 {
85 ipp_t *request;
86 @@ -160,7 +172,7 @@ cups_request_new_for_printer (int operation_id, const gchar * printer)
87 }
89 printer_uri = g_strdup_printf ("ipp://%s/printers/%s", server, printer);
90 - request = cups_request_new (operation_id);
91 + request = ippNewRequest (operation_id);
93 ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer_uri);
95 @@ -242,24 +254,24 @@ get_printers ()
97 if (!request)
98 continue;
99 - if (request->state == IPP_ERROR || request->state == IPP_IDLE) {
100 + if (ippGetState (request) == IPP_ERROR || ippGetState (request) == IPP_IDLE) {
101 ippDelete (request);
102 continue;
103 }
105 attr = ippFindAttribute (request, "printer-info", IPP_TAG_TEXT);
106 - if (!attr || strlen (attr->values[0].string.text) == 0) {
107 + if (!attr || strlen (ippGetString (attr, 0, NULL)) == 0) {
108 attr = ippFindAttribute (request, "printer-make-and-model", IPP_TAG_TEXT);
109 if (attr)
110 - printer->alias = g_strdup (attr->values[0].string.text);
111 + printer->alias = g_strdup (ippGetString (attr, 0, NULL));
112 else
113 printer->alias = g_strdup ("");
114 }
115 else
116 - printer->alias = g_strdup (attr->values[0].string.text);
117 + printer->alias = g_strdup (ippGetString (attr, 0, NULL));
119 attr = ippFindAttribute (request, "printer-type", IPP_TAG_ENUM);
120 - if (attr && (attr->values[0].integer & CUPS_PRINTER_CLASS))
121 + if (attr && (ippGetInteger (attr, 0) & CUPS_PRINTER_CLASS))
122 printer->type = PRINTER_TYPE_CLASS;
123 else
124 printer->type = PRINTER_TYPE_PRINTER;
125 @@ -309,7 +321,7 @@ get_printer_state (const gchar * printer)
126 ipp_attribute_t *attr = ippFindAttribute (request, "printer-state",
127 IPP_TAG_ENUM);
128 if (attr)
129 - switch (attr->values[0].integer) {
130 + switch (ippGetInteger (attr, 0)) {
131 case IPP_PRINTER_IDLE:
132 state = PRINTER_STATE_IDLE;
133 break;
134 --
135 1.7.9.5