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