]> git.pld-linux.org Git - packages/kde4-kde3support.git/blame - kdelibs-cups16.patch
- release 56 (by relup.sh)
[packages/kde4-kde3support.git] / kdelibs-cups16.patch
CommitLineData
ff726e68
JR
1diff -ur kdelibs-3.5.10/kdeprint/configure.in.in kdelibs-3.5.10-cups16/kdeprint/configure.in.in
2--- kdelibs-3.5.10/kdeprint/configure.in.in 2005-09-10 10:27:43.000000000 +0200
3+++ kdelibs-3.5.10-cups16/kdeprint/configure.in.in 2012-12-25 16:29:53.000000000 +0100
4@@ -84,6 +84,13 @@
5 if test "$ac_have_new_cups" = "yes"; then
6 AC_DEFINE(HAVE_CUPS_NO_PWD_CACHE, 1, CUPS doesn't have password caching)
7 fi
8+
9+ dnl check if CUPS is at least 1.6
10+ ac_have_new_cups="no"
11+ AC_CHECK_CUPS_VERSION(1.06)
12+ if test "$ac_have_new_cups" = "yes"; then
13+ AC_DEFINE(HAVE_CUPS_1_6, 1, CUPS is at least version 1.6)
14+ fi
15 fi
16 fi
17 LDFLAGS="$ac_LDFLAGS_save"
18diff -ur kdelibs-3.5.10/kdeprint/cups/cupsdconf2/cupsdconf.cpp kdelibs-3.5.10-cups16/kdeprint/cups/cupsdconf2/cupsdconf.cpp
19--- kdelibs-3.5.10/kdeprint/cups/cupsdconf2/cupsdconf.cpp 2005-10-10 17:06:30.000000000 +0200
20+++ kdelibs-3.5.10-cups16/kdeprint/cups/cupsdconf2/cupsdconf.cpp 2012-12-25 16:34:57.000000000 +0100
21@@ -629,26 +629,44 @@
22 cups_lang_t* lang = cupsLangDefault();
23 ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, cupsLangEncoding(lang));
24 ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, lang->language);
25+#ifdef HAVE_CUPS_1_6
26+ ippSetOperation(request_, CUPS_GET_PRINTERS);
27+#else // HAVE_CUPS_1_6
28 request_->request.op.operation_id = CUPS_GET_PRINTERS;
29+#endif // HAVE_CUPS_1_6
30 request_ = cupsDoRequest(http_, request_, "/printers/");
31 if (request_)
32 {
33 QString name;
34 int type(0);
35+#ifdef HAVE_CUPS_1_6
36+ ipp_attribute_t *attr = ippFirstAttribute(request_);
37+#else // HAVE_CUPS_1_6
38 ipp_attribute_t *attr = request_->attrs;
39+#endif // HAVE_CUPS_1_6
40 while (attr)
41 {
42 // check new printer (keep only local non-implicit printers)
43+#ifdef HAVE_CUPS_1_6
44+ if (!ippGetName(attr))
45+#else // HAVE_CUPS_1_6
46 if (!attr->name)
47+#endif // HAVE_CUPS_1_6
48 {
49 if (!(type & CUPS_PRINTER_REMOTE) && !(type & CUPS_PRINTER_IMPLICIT) && !name.isEmpty())
50 resources_.append(new CupsResource("/printers/"+name));
51 name = "";
52 type = 0;
53 }
54+#ifdef HAVE_CUPS_1_6
55+ else if (strcmp(ippGetName(attr), "printer-name") == 0) name = ippGetString(attr, 0, NULL);
56+ else if (strcmp(ippGetName(attr), "printer-type") == 0) type = ippGetInteger(attr, 0);
57+ attr = ippNextAttribute(request_);
58+#else // HAVE_CUPS_1_6
59 else if (strcmp(attr->name, "printer-name") == 0) name = attr->values[0].string.text;
60 else if (strcmp(attr->name, "printer-type") == 0) type = attr->values[0].integer;
61 attr = attr->next;
62+#endif // HAVE_CUPS_1_6
63 }
64 if (!(type & CUPS_PRINTER_REMOTE) && !(type & CUPS_PRINTER_IMPLICIT) && !name.isEmpty())
65 resources_.append(new CupsResource("/printers/"+name));
66@@ -658,26 +676,44 @@
67 request_ = ippNew();
68 ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, cupsLangEncoding(lang));
69 ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, lang->language);
70+#ifdef HAVE_CUPS_1_6
71+ ippSetOperation(request_, CUPS_GET_CLASSES);
72+#else // HAVE_CUPS_1_6
73 request_->request.op.operation_id = CUPS_GET_CLASSES;
74+#endif // HAVE_CUPS_1_6
75 request_ = cupsDoRequest(http_, request_, "/classes/");
76 if (request_)
77 {
78 QString name;
79 int type(0);
80+#ifdef HAVE_CUPS_1_6
81+ ipp_attribute_t *attr = ippFirstAttribute(request_);
82+#else // HAVE_CUPS_1_6
83 ipp_attribute_t *attr = request_->attrs;
84+#endif // HAVE_CUPS_1_6
85 while (attr)
86 {
87 // check new class (keep only local classes)
88+#ifdef HAVE_CUPS_1_6
89+ if (!ippGetName(attr))
90+#else // HAVE_CUPS_1_6
91 if (!attr->name)
92+#endif // HAVE_CUPS_1_6
93 {
94 if (!(type & CUPS_PRINTER_REMOTE) && !name.isEmpty())
95 resources_.append(new CupsResource("/classes/"+name));
96 name = "";
97 type = 0;
98 }
99+#ifdef HAVE_CUPS_1_6
100+ else if (strcmp(ippGetName(attr), "printer-name") == 0) name = ippGetString(attr, 0, NULL);
101+ else if (strcmp(ippGetName(attr), "printer-type") == 0) type = ippGetInteger(attr, 0);
102+ attr = ippNextAttribute(request_);
103+#else // HAVE_CUPS_1_6
104 else if (strcmp(attr->name, "printer-name") == 0) name = attr->values[0].string.text;
105 else if (strcmp(attr->name, "printer-type") == 0) type = attr->values[0].integer;
106 attr = attr->next;
107+#endif // HAVE_CUPS_1_6
108 }
109 if (!(type & CUPS_PRINTER_REMOTE) && !name.isEmpty())
110 resources_.append(new CupsResource("/classes/"+name));
111diff -ur kdelibs-3.5.10/kdeprint/cups/ipprequest.cpp kdelibs-3.5.10-cups16/kdeprint/cups/ipprequest.cpp
112--- kdelibs-3.5.10/kdeprint/cups/ipprequest.cpp 2007-10-08 11:52:10.000000000 +0200
113+++ kdelibs-3.5.10-cups16/kdeprint/cups/ipprequest.cpp 2012-12-25 16:55:53.000000000 +0100
114@@ -51,6 +51,58 @@
115 kdDebug(500) << "Null request" << endl;
116 return;
117 }
118+#ifdef HAVE_CUPS_1_6
119+ kdDebug(500) << "State = 0x" << QString::number(ippGetState(req), 16) << endl;
120+ kdDebug(500) << "ID = 0x" << QString::number(ippGetRequestId(req), 16) << endl;
121+ if (answer)
122+ {
123+ kdDebug(500) << "Status = 0x" << QString::number(ippGetStatusCode(req), 16) << endl;
124+ kdDebug(500) << "Status message = " << ippErrorString(ippGetStatusCode(req)) << endl;
125+ }
126+ else
127+ kdDebug(500) << "Operation = 0x" << QString::number(ippGetOperation(req), 16) << endl;
128+ int minorVersion;
129+ int majorVersion = ippGetVersion(req, &minorVersion);
130+ kdDebug(500) << "Version = " << (int)(majorVersion) << "." << (int)(minorVersion) << endl;
131+ kdDebug(500) << endl;
132+
133+ ipp_attribute_t *attr = ippFirstAttribute(req);
134+ while (attr)
135+ {
136+ QString s = QString::fromLatin1("%1 (0x%2) = ").arg(ippGetName(attr)).arg(ippGetValueTag(attr), 0, 16);
137+ for (int i=0;i<ippGetCount(attr);i++)
138+ {
139+ switch (ippGetValueTag(attr))
140+ {
141+ case IPP_TAG_INTEGER:
142+ case IPP_TAG_ENUM:
143+ s += ("0x"+QString::number(ippGetInteger(attr, i), 16));
144+ break;
145+ case IPP_TAG_BOOLEAN:
146+ s += (ippGetBoolean(attr, i) ? "true" : "false");
147+ break;
148+ case IPP_TAG_STRING:
149+ case IPP_TAG_TEXT:
150+ case IPP_TAG_NAME:
151+ case IPP_TAG_KEYWORD:
152+ case IPP_TAG_URI:
153+ case IPP_TAG_MIMETYPE:
154+ case IPP_TAG_NAMELANG:
155+ case IPP_TAG_TEXTLANG:
156+ case IPP_TAG_CHARSET:
157+ case IPP_TAG_LANGUAGE:
158+ s += ippGetString(attr, i, NULL);
159+ break;
160+ default:
161+ break;
162+ }
163+ if (i != (ippGetCount(attr)-1))
164+ s += ", ";
165+ }
166+ kdDebug(500) << s << endl;
167+ attr = ippNextAttribute(req);
168+ }
169+#else // HAVE_CUPS_1_6
170 kdDebug(500) << "State = 0x" << QString::number(req->state, 16) << endl;
171 kdDebug(500) << "ID = 0x" << QString::number(req->request.status.request_id, 16) << endl;
172 if (answer)
173@@ -99,6 +151,7 @@
174 kdDebug(500) << s << endl;
175 attr = attr->next;
176 }
177+#endif // HAVE_CUPS_1_6
178 }
179
180 QString errorString(int status)
181@@ -177,7 +230,11 @@
182 ipp_attribute_t *attr = ippAddStrings(request_,(ipp_tag_t)group,(ipp_tag_t)type,name.latin1(),(int)(values.count()),NULL,NULL);
183 int i(0);
184 for (QStringList::ConstIterator it=values.begin(); it != values.end(); ++it, i++)
185+#ifdef HAVE_CUPS_1_6
186+ ippSetString(request_, &attr, i, strdup((*it).local8Bit()));
187+#else // HAVE_CUPS_1_6
188 attr->values[i].string.text = strdup((*it).local8Bit());
189+#endif // HAVE_CUPS_1_6
190 }
191 }
192
193@@ -193,7 +250,11 @@
194 ipp_attribute_t *attr = ippAddIntegers(request_,(ipp_tag_t)group,(ipp_tag_t)type,name.latin1(),(int)(values.count()),NULL);
195 int i(0);
196 for (QValueList<int>::ConstIterator it=values.begin(); it != values.end(); ++it, i++)
197+#ifdef HAVE_CUPS_1_6
198+ ippSetInteger(request_, &attr, i, *it);
199+#else // HAVE_CUPS_1_6
200 attr->values[i].integer = *it;
201+#endif // HAVE_CUPS_1_6
202 }
203 }
204
205@@ -209,19 +270,32 @@
206 ipp_attribute_t *attr = ippAddBooleans(request_,(ipp_tag_t)group,name.latin1(),(int)(values.count()),NULL);
207 int i(0);
208 for (QValueList<bool>::ConstIterator it=values.begin(); it != values.end(); ++it, i++)
209+#ifdef HAVE_CUPS_1_6
210+ ippSetBoolean(request_, &attr, i, (char)(*it));
211+#else // HAVE_CUPS_1_6
212 attr->values[i].boolean = (char)(*it);
213+#endif // HAVE_CUPS_1_6
214 }
215 }
216
217 void IppRequest::setOperation(int op)
218 {
219+#ifdef HAVE_CUPS_1_6
220+ ippSetOperation(request_, (ipp_op_t)op);
221+ ippSetRequestId(request_, 1); // 0 is not RFC-compliant, should be at least 1
222+#else // HAVE_CUPS_1_6
223 request_->request.op.operation_id = (ipp_op_t)op;
224 request_->request.op.request_id = 1; // 0 is not RFC-compliant, should be at least 1
225+#endif // HAVE_CUPS_1_6
226 }
227
228 int IppRequest::status()
229 {
230+#ifdef HAVE_CUPS_1_6
231+ return (request_ ? ippGetStatusCode(request_) : (connect_ ? cupsLastError() : -2));
232+#else // HAVE_CUPS_1_6
233 return (request_ ? request_->request.status.status_code : (connect_ ? cupsLastError() : -2));
234+#endif // HAVE_CUPS_1_6
235 }
236
237 QString IppRequest::statusMessage()
238@@ -248,7 +322,11 @@
239 ipp_attribute_t *attr = ippFindAttribute(request_, name.latin1(), (ipp_tag_t)type);
240 if (attr)
241 {
242+#ifdef HAVE_CUPS_1_6
243+ value = ippGetInteger(attr, 0);
244+#else // HAVE_CUPS_1_6
245 value = attr->values[0].integer;
246+#endif // HAVE_CUPS_1_6
247 return true;
248 }
249 else return false;
250@@ -260,7 +338,11 @@
251 ipp_attribute_t *attr = ippFindAttribute(request_, name.latin1(), (ipp_tag_t)type);
252 if (attr)
253 {
254+#ifdef HAVE_CUPS_1_6
255+ value = QString::fromLocal8Bit(ippGetString(attr, 0, NULL));
256+#else // HAVE_CUPS_1_6
257 value = QString::fromLocal8Bit(attr->values[0].string.text);
258+#endif // HAVE_CUPS_1_6
259 return true;
260 }
261 else return false;
262@@ -273,8 +355,13 @@
263 values.clear();
264 if (attr)
265 {
266+#ifdef HAVE_CUPS_1_6
267+ for (int i=0;i<ippGetCount(attr);i++)
268+ values.append(QString::fromLocal8Bit(ippGetString(attr, i, NULL)));
269+#else // HAVE_CUPS_1_6
270 for (int i=0;i<attr->num_values;i++)
271 values.append(QString::fromLocal8Bit(attr->values[i].string.text));
272+#endif // HAVE_CUPS_1_6
273 return true;
274 }
275 else return false;
276@@ -286,7 +373,11 @@
277 ipp_attribute_t *attr = ippFindAttribute(request_, name.latin1(), IPP_TAG_BOOLEAN);
278 if (attr)
279 {
280+#ifdef HAVE_CUPS_1_6
281+ value = (bool)ippGetBoolean(attr, 0);
282+#else // HAVE_CUPS_1_6
283 value = (bool)attr->values[0].boolean;
284+#endif // HAVE_CUPS_1_6
285 return true;
286 }
287 else return false;
288@@ -338,10 +429,18 @@
289 }
290
291 /* No printers found */
292+#ifdef HAVE_CUPS_1_6
293+ if ( request_ && ippGetStatusCode(request_) == 0x406 )
294+#else // HAVE_CUPS_1_6
295 if ( request_ && request_->request.status.status_code == 0x406 )
296+#endif // HAVE_CUPS_1_6
297 return true;
298
299+#ifdef HAVE_CUPS_1_6
300+ if (!request_ || ippGetState(request_) == IPP_ERROR || (ippGetStatusCode(request_) & 0x0F00))
301+#else // HAVE_CUPS_1_6
302 if (!request_ || request_->state == IPP_ERROR || (request_->request.status.status_code & 0x0F00))
303+#endif // HAVE_CUPS_1_6
304 return false;
305
306
307@@ -356,14 +455,88 @@
308 output << "<tr><th bgcolor=\"dark blue\"><font color=\"white\">" << i18n("Attribute") << "</font></th>" << endl;
309 output << "<th bgcolor=\"dark blue\"><font color=\"white\">" << i18n("Values") << "</font></th></tr>" << endl;
310 // go to the first attribute of the specified group
311+#ifdef HAVE_CUPS_1_6
312+ ipp_attribute_t *attr = ippFirstAttribute(request_);
313+ while (attr && ippGetGroupTag(attr) != group)
314+ attr = ippNextAttribute(request_);
315+#else // HAVE_CUPS_1_6
316 ipp_attribute_t *attr = request_->attrs;
317 while (attr && attr->group_tag != group)
318 attr = attr->next;
319+#endif // HAVE_CUPS_1_6
320 // print each attribute
321- ipp_uchar_t *d;
322- QCString dateStr;
323- QDateTime dt;
324- bool bg(false);
325+ const ipp_uchar_t *d;
326+ QCString dateStr;
327+ QDateTime dt;
328+ bool bg(false);
329+#ifdef HAVE_CUPS_1_6
330+ while (attr && ippGetGroupTag(attr) == group)
331+ {
332+ output << " <tr bgcolor=\"" << (bg ? "#ffffd9" : "#ffffff") << "\">\n <td><b>" << ippGetName(attr) << "</b></td>\n <td>" << endl;
333+ bg = !bg;
334+ for (int i=0; i<ippGetCount(attr); i++)
335+ {
336+ switch (ippGetValueTag(attr))
337+ {
338+ case IPP_TAG_INTEGER:
339+ if (ippGetName(attr) && strstr(ippGetName(attr), "time"))
340+ {
341+ dt.setTime_t((unsigned int)(ippGetInteger(attr, i)));
342+ output << dt.toString();
343+ }
344+ else
345+ output << ippGetInteger(attr, i);
346+ break;
347+ case IPP_TAG_ENUM:
348+ output << "0x" << hex << ippGetInteger(attr, i) << dec;
349+ break;
350+ case IPP_TAG_BOOLEAN:
351+ output << (ippGetBoolean(attr, i) ? i18n("True") : i18n("False"));
352+ break;
353+ case IPP_TAG_STRING:
354+ case IPP_TAG_TEXTLANG:
355+ case IPP_TAG_NAMELANG:
356+ case IPP_TAG_TEXT:
357+ case IPP_TAG_NAME:
358+ case IPP_TAG_KEYWORD:
359+ case IPP_TAG_URI:
360+ case IPP_TAG_CHARSET:
361+ case IPP_TAG_LANGUAGE:
362+ case IPP_TAG_MIMETYPE:
363+ output << ippGetString(attr, i, NULL);
364+ break;
365+ case IPP_TAG_RESOLUTION:
366+ int xres;
367+ int yres;
368+ ipp_res_t units;
369+ xres = ippGetResolution(attr, i, &yres, &units);
370+ output << "( " << xres
371+ << ", " << yres << " )";
372+ break;
373+ case IPP_TAG_RANGE:
374+ int lowervalue;
375+ int uppervalue;
376+ lowervalue = ippGetRange(attr, i, &uppervalue);
377+ output << "[ " << (lowervalue > 0 ? lowervalue : 1)
378+ << ", " << (uppervalue > 0 ? uppervalue : 65535) << " ]";
379+ break;
380+ case IPP_TAG_DATE:
381+ d = ippGetDate(attr, i);
382+ dateStr.sprintf("%.4d-%.2d-%.2d, %.2d:%.2d:%.2d %c%.2d%.2d",
383+ d[0]*256+d[1], d[2], d[3],
384+ d[4], d[5], d[6],
385+ d[8], d[9], d[10]);
386+ output << dateStr;
387+ break;
388+ default:
389+ continue;
390+ }
391+ if (i < ippGetCount(attr)-1)
392+ output << "<br>";
393+ }
394+ output << "</td>\n </tr>" << endl;
395+ attr = ippNextAttribute(request_);
396+#else // HAVE_CUPS_1_6
397 while (attr && attr->group_tag == group)
398 {
399 output << " <tr bgcolor=\"" << (bg ? "#ffffd9" : "#ffffff") << "\">\n <td><b>" << attr->name << "</b></td>\n <td>" << endl;
400@@ -423,6 +596,7 @@
401 }
402 output << "</td>\n </tr>" << endl;
403 attr = attr->next;
404+#endif // HAVE_CUPS_1_6
405 }
406 // end table
407 output << "</table>" << endl;
408@@ -438,6 +612,59 @@
409 ipp_attribute_t *attr = first();
410 while (attr)
411 {
412+#ifdef HAVE_CUPS_1_6
413+ if (group != -1 && ippGetGroupTag(attr) != group)
414+ {
415+ attr = ippNextAttribute(request_);
416+ continue;
417+ }
418+ QString value;
419+ for (int i=0; i<ippGetCount(attr); i++)
420+ {
421+ switch (ippGetValueTag(attr))
422+ {
423+ case IPP_TAG_INTEGER:
424+ case IPP_TAG_ENUM:
425+ value.append(QString::number(ippGetInteger(attr, i))).append(",");
426+ break;
427+ case IPP_TAG_BOOLEAN:
428+ value.append((ippGetBoolean(attr, i) ? "true" : "false")).append(",");
429+ break;
430+ case IPP_TAG_RANGE:
431+ int lowervalue;
432+ int uppervalue;
433+ lowervalue = ippGetRange(attr, i, &uppervalue);
434+ if (lowervalue > 0)
435+ value.append(QString::number(lowervalue));
436+ if (lowervalue != uppervalue)
437+ {
438+ value.append("-");
439+ if (uppervalue > 0)
440+ value.append(QString::number(uppervalue));
441+ }
442+ value.append(",");
443+ break;
444+ case IPP_TAG_STRING:
445+ case IPP_TAG_TEXT:
446+ case IPP_TAG_NAME:
447+ case IPP_TAG_KEYWORD:
448+ case IPP_TAG_URI:
449+ case IPP_TAG_MIMETYPE:
450+ case IPP_TAG_NAMELANG:
451+ case IPP_TAG_TEXTLANG:
452+ case IPP_TAG_CHARSET:
453+ case IPP_TAG_LANGUAGE:
454+ value.append(QString::fromLocal8Bit(ippGetString(attr, i, NULL))).append(",");
455+ break;
456+ default:
457+ break;
458+ }
459+ }
460+ if (!value.isEmpty())
461+ value.truncate(value.length()-1);
462+ opts[QString::fromLocal8Bit(ippGetName(attr))] = value;
463+ attr = ippNextAttribute(request_);
464+#else // HAVE_CUPS_1_6
465 if (group != -1 && attr->group_tag != group)
466 {
467 attr = attr->next;
468@@ -486,6 +713,7 @@
469 value.truncate(value.length()-1);
470 opts[QString::fromLocal8Bit(attr->name)] = value;
471 attr = attr->next;
472+#endif // HAVE_CUPS_1_6
473 }
474 }
475 return opts;
476@@ -542,3 +770,11 @@
477 }
478 #endif
479 }
480+
481+#ifdef HAVE_CUPS_1_6
482+ipp_attribute_t* IppRequest::first()
483+{ return (request_ ? ippFirstAttribute(request_) : NULL); }
484+#else // HAVE_CUPS_1_6
485+ipp_attribute_t* IppRequest::first()
486+{ return (request_ ? request_->attrs : NULL); }
487+#endif // HAVE_CUPS_1_6
488diff -ur kdelibs-3.5.10/kdeprint/cups/ipprequest.h kdelibs-3.5.10-cups16/kdeprint/cups/ipprequest.h
489--- kdelibs-3.5.10/kdeprint/cups/ipprequest.h 2005-10-10 17:06:30.000000000 +0200
490+++ kdelibs-3.5.10-cups16/kdeprint/cups/ipprequest.h 2012-12-25 16:37:50.000000000 +0100
491@@ -27,6 +27,8 @@
492
493 #include <cups/ipp.h>
494
495+#include "config.h"
496+
497 class IppRequest
498 {
499 public:
500@@ -72,7 +74,10 @@
501 bool keyword(const QString& name, QStringList& value);
502 bool mime(const QString& name, QString& value);
503 ipp_attribute_t* first();
504+#ifndef HAVE_CUPS_1_6
505 ipp_attribute_t* last();
506+#endif // HAVE_CUPS_1_6
507+ ipp_t* request();
508 QMap<QString,QString> toMap(int group = -1);
509 void setMap(const QMap<QString,QString>& opts);
510
511@@ -178,11 +183,10 @@
512 inline bool IppRequest::doRequest(const QString& res)
513 { return doFileRequest(res); }
514
515-inline ipp_attribute_t* IppRequest::first()
516-{ return (request_ ? request_->attrs : NULL); }
517-
518+#ifndef HAVE_CUPS_1_6
519 inline ipp_attribute_t* IppRequest::last()
520 { return (request_ ? request_->last : NULL); }
521+#endif // HAVE_CUPS_1_6
522
523 inline void IppRequest::setHost(const QString& host)
524 { host_ = host; }
525@@ -193,4 +197,7 @@
526 inline void IppRequest::dump(int state)
527 { dump_ = state; }
528
529+inline ipp_t* IppRequest::request()
530+{ return request_; }
531+
532 #endif
533diff -ur kdelibs-3.5.10/kdeprint/cups/kmcupsjobmanager.cpp kdelibs-3.5.10-cups16/kdeprint/cups/kmcupsjobmanager.cpp
534--- kdelibs-3.5.10/kdeprint/cups/kmcupsjobmanager.cpp 2007-01-15 12:34:19.000000000 +0100
535+++ kdelibs-3.5.10-cups16/kdeprint/cups/kmcupsjobmanager.cpp 2012-12-25 16:34:57.000000000 +0100
536@@ -36,6 +36,8 @@
537 #include <kdebug.h>
538 #include <kurl.h>
539
540+#include "config.h"
541+
542 KMCupsJobManager::KMCupsJobManager(QObject *parent, const char *name, const QStringList & /*args*/)
543 : KMJobManager(parent,name)
544 {
545@@ -166,10 +168,79 @@
546 void KMCupsJobManager::parseListAnswer(IppRequest& req, KMPrinter *pr)
547 {
548 ipp_attribute_t *attr = req.first();
549+ ipp_attribute_t *nextAttr;
550 KMJob *job = new KMJob();
551 QString uri;
552 while (attr)
553 {
554+#ifdef HAVE_CUPS_1_6
555+ QString name(ippGetName(attr));
556+ if (name == "job-id") job->setId(ippGetInteger(attr, 0));
557+ else if (name == "job-uri") job->setUri(QString::fromLocal8Bit(ippGetString(attr, 0, NULL)));
558+ else if (name == "job-name") job->setName(QString::fromLocal8Bit(ippGetString(attr, 0, NULL)));
559+ else if (name == "job-state")
560+ {
561+ switch (ippGetInteger(attr, 0))
562+ {
563+ case IPP_JOB_PENDING:
564+ job->setState(KMJob::Queued);
565+ break;
566+ case IPP_JOB_HELD:
567+ job->setState(KMJob::Held);
568+ break;
569+ case IPP_JOB_PROCESSING:
570+ job->setState(KMJob::Printing);
571+ break;
572+ case IPP_JOB_STOPPED:
573+ job->setState(KMJob::Error);
574+ break;
575+ case IPP_JOB_CANCELLED:
576+ job->setState(KMJob::Cancelled);
577+ break;
578+ case IPP_JOB_ABORTED:
579+ job->setState(KMJob::Aborted);
580+ break;
581+ case IPP_JOB_COMPLETED:
582+ job->setState(KMJob::Completed);
583+ break;
584+ default:
585+ job->setState(KMJob::Unknown);
586+ break;
587+ }
588+ }
589+ else if (name == "job-k-octets") job->setSize(ippGetInteger(attr, 0));
590+ else if (name == "job-originating-user-name") job->setOwner(QString::fromLocal8Bit(ippGetString(attr, 0, NULL)));
591+ else if (name == "job-k-octets-completed") job->setProcessedSize(ippGetInteger(attr, 0));
592+ else if (name == "job-media-sheets") job->setPages(ippGetInteger(attr, 0));
593+ else if (name == "job-media-sheets-completed") job->setProcessedPages(ippGetInteger(attr, 0));
594+ else if (name == "job-printer-uri" && !pr->isRemote())
595+ {
596+ QString str(ippGetString(attr, 0, NULL));
597+ int p = str.findRev('/');
598+ if (p != -1)
599+ job->setPrinter(str.mid(p+1));
600+ }
601+ else if (name == "job-priority")
602+ {
603+ job->setAttribute(0, QString::fromLatin1("%1").arg(ippGetInteger(attr, 0), 3));
604+ }
605+ else if (name == "job-billing")
606+ {
607+ job->setAttributeCount(2);
608+ job->setAttribute(1, QString::fromLocal8Bit(ippGetString(attr, 0, NULL)));
609+ }
610+
611+ nextAttr = ippNextAttribute(req.request());
612+ if (name.isEmpty() || (!nextAttr))
613+ {
614+ if (job->printer().isEmpty())
615+ job->setPrinter(pr->printerName());
616+ job->setRemote(pr->isRemote());
617+ addJob(job); // don't use job after this call !!!
618+ job = new KMJob();
619+ }
620+ attr = nextAttr;
621+#else // HAVE_CUPS_1_6
622 QString name(attr->name);
623 if (name == "job-id") job->setId(attr->values[0].integer);
624 else if (name == "job-uri") job->setUri(QString::fromLocal8Bit(attr->values[0].string.text));
625@@ -236,6 +307,7 @@
626 }
627
628 attr = attr->next;
629+#endif // HAVE_CUPS_1_6
630 }
631 delete job;
632 }
633diff -ur kdelibs-3.5.10/kdeprint/cups/kmcupsmanager.cpp kdelibs-3.5.10-cups16/kdeprint/cups/kmcupsmanager.cpp
634--- kdelibs-3.5.10/kdeprint/cups/kmcupsmanager.cpp 2007-01-15 12:34:19.000000000 +0100
635+++ kdelibs-3.5.10-cups16/kdeprint/cups/kmcupsmanager.cpp 2012-12-25 16:34:57.000000000 +0100
636@@ -476,9 +476,59 @@
637 void KMCupsManager::processRequest(IppRequest* req)
638 {
639 ipp_attribute_t *attr = req->first();
640+ ipp_attribute_t *nextAttr;
641 KMPrinter *printer = new KMPrinter();
642 while (attr)
643 {
644+#ifdef HAVE_CUPS_1_6
645+ QString attrname(ippGetName(attr));
646+ if (attrname == "printer-name")
647+ {
648+ QString value = QString::fromLocal8Bit(ippGetString(attr, 0, NULL));
649+ printer->setName(value);
650+ printer->setPrinterName(value);
651+ }
652+ else if (attrname == "printer-type")
653+ {
654+ int value = ippGetInteger(attr, 0);
655+ printer->setType(0);
656+ printer->addType(((value & CUPS_PRINTER_CLASS) || (value & CUPS_PRINTER_IMPLICIT) ? KMPrinter::Class : KMPrinter::Printer));
657+ if ((value & CUPS_PRINTER_REMOTE)) printer->addType(KMPrinter::Remote);
658+ if ((value & CUPS_PRINTER_IMPLICIT)) printer->addType(KMPrinter::Implicit);
659+
660+ // convert printer-type attribute
661+ printer->setPrinterCap( ( value & CUPS_PRINTER_OPTIONS ) >> 2 );
662+ }
663+ else if (attrname == "printer-state")
664+ {
665+ switch (ippGetInteger(attr, 0))
666+ {
667+ case IPP_PRINTER_IDLE: printer->setState(KMPrinter::Idle); break;
668+ case IPP_PRINTER_PROCESSING: printer->setState(KMPrinter::Processing); break;
669+ case IPP_PRINTER_STOPPED: printer->setState(KMPrinter::Stopped); break;
670+ }
671+ }
672+ else if (attrname == "printer-uri-supported")
673+ {
674+ printer->setUri(KURL(ippGetString(attr, 0, NULL)));
675+ }
676+ else if (attrname == "printer-location")
677+ {
678+ printer->setLocation(QString::fromLocal8Bit(ippGetString(attr, 0, NULL)));
679+ }
680+ else if (attrname == "printer-is-accepting-jobs")
681+ {
682+ printer->setAcceptJobs(ippGetBoolean(attr, 0));
683+ }
684+
685+ nextAttr = ippNextAttribute(req->request());
686+ if (attrname.isEmpty() || (!nextAttr))
687+ {
688+ addPrinter(printer);
689+ printer = new KMPrinter();
690+ }
691+ attr = nextAttr;
692+#else // HAVE_CUPS_1_6
693 QString attrname(attr->name);
694 if (attrname == "printer-name")
695 {
696@@ -524,6 +574,7 @@
697 printer = new KMPrinter();
698 }
699 attr = attr->next;
700+#endif // HAVE_CUPS_1_6
701 }
702 delete printer;
703 }
704@@ -817,6 +868,7 @@
705 {
706 QStringList list;
707 IppRequest req;
708+ ipp_attribute_t *nextAttr;
709 req.setOperation(CUPS_GET_DEVICES);
710 if (req.doRequest("/"))
711 {
712@@ -824,6 +876,24 @@
713 ipp_attribute_t *attr = req.first();
714 while (attr)
715 {
716+#ifdef HAVE_CUPS_1_6
717+ QString attrname(ippGetName(attr));
718+ if (attrname == "device-info") desc = ippGetString(attr, 0, NULL);
719+ else if (attrname == "device-make-and-model") printer = ippGetString(attr, 0, NULL);
720+ else if (attrname == "device-uri") uri = ippGetString(attr, 0, NULL);
721+ else if ( attrname == "device-class" ) cl = ippGetString(attr, 0, NULL);
722+ nextAttr = ippNextAttribute(req.request());
723+ if (attrname.isEmpty() || (!nextAttr))
724+ {
725+ if (!uri.isEmpty())
726+ {
727+ if (printer == "Unknown") printer = QString::null;
728+ list << cl << uri << desc << printer;
729+ }
730+ uri = desc = printer = cl = QString::null;
731+ }
732+ attr = nextAttr;
733+#else // HAVE_CUPS_1_6
734 QString attrname(attr->name);
735 if (attrname == "device-info") desc = attr->values[0].string.text;
736 else if (attrname == "device-make-and-model") printer = attr->values[0].string.text;
737@@ -839,6 +909,7 @@
738 uri = desc = printer = cl = QString::null;
739 }
740 attr = attr->next;
741+#endif // HAVE_CUPS_1_6
742 }
743 }
744 return list;
745diff -ur kdelibs-3.5.10/kdeprint/cups/kmcupsuimanager.cpp kdelibs-3.5.10-cups16/kdeprint/cups/kmcupsuimanager.cpp
746--- kdelibs-3.5.10/kdeprint/cups/kmcupsuimanager.cpp 2006-10-01 19:33:43.000000000 +0200
747+++ kdelibs-3.5.10-cups16/kdeprint/cups/kmcupsuimanager.cpp 2012-12-25 16:34:57.000000000 +0100
748@@ -60,6 +60,8 @@
749 #include <kaction.h>
750 #include <kmessagebox.h>
751
752+#include "config.h"
753+
754 KMCupsUiManager::KMCupsUiManager(QObject *parent, const char *name, const QStringList & /*args*/)
755 : KMUiManager(parent,name)
756 {
757@@ -143,6 +145,24 @@
758 ipp_attribute_t *attr = req.first();
759 while (attr)
760 {
761+#ifdef HAVE_CUPS_1_6
762+ if (ippGetName(attr) && strcmp(ippGetName(attr),"device-uri") == 0)
763+ {
764+ if (strncmp(ippGetString(attr, 0, NULL),"socket",6) == 0) backend->enableBackend(KMWizard::TCP,true);
765+ else if (strncmp(ippGetString(attr, 0, NULL),"parallel",8) == 0) backend->enableBackend(KMWizard::Local,true);
766+ else if (strncmp(ippGetString(attr, 0, NULL),"serial",6) == 0) backend->enableBackend(KMWizard::Local,true);
767+ else if (strncmp(ippGetString(attr, 0, NULL),"smb",3) == 0) backend->enableBackend(KMWizard::SMB,true);
768+ else if (strncmp(ippGetString(attr, 0, NULL),"lpd",3) == 0) backend->enableBackend(KMWizard::LPD,true);
769+ else if (strncmp(ippGetString(attr, 0, NULL),"usb",3) == 0) backend->enableBackend(KMWizard::Local,true);
770+ else if (strncmp(ippGetString(attr, 0, NULL),"http",4) == 0 || strncmp(ippGetString(attr, 0, NULL),"ipp",3) == 0)
771+ {
772+ backend->enableBackend(KMWizard::IPP,true);
773+ backend->enableBackend(KMWizard::Custom+1,true);
774+ }
775+ else if (strncmp(ippGetString(attr, 0, NULL),"fax",3) == 0) backend->enableBackend(KMWizard::Custom+2,true);
776+ }
777+ attr = ippNextAttribute(req.request());
778+#else // HAVE_CUPS_1_6
779 if (attr->name && strcmp(attr->name,"device-uri") == 0)
780 {
781 if (strncmp(attr->values[0].string.text,"socket",6) == 0) backend->enableBackend(KMWizard::TCP,true);
782@@ -159,6 +179,7 @@
783 else if (strncmp(attr->values[0].string.text,"fax",3) == 0) backend->enableBackend(KMWizard::Custom+2,true);
784 }
785 attr = attr->next;
786+#endif // HAVE_CUPS_1_6
787 }
788 backend->enableBackend(KMWizard::Class, true);
789 backend->enableBackend(KMWizard::Custom+5, true);
790diff -ur kdelibs-3.5.10/kdeprint/cups/kmwfax.cpp kdelibs-3.5.10-cups16/kdeprint/cups/kmwfax.cpp
791--- kdelibs-3.5.10/kdeprint/cups/kmwfax.cpp 2007-01-15 12:34:19.000000000 +0100
792+++ kdelibs-3.5.10-cups16/kdeprint/cups/kmwfax.cpp 2012-12-25 16:34:57.000000000 +0100
793@@ -30,6 +30,8 @@
794 #include <kiconloader.h>
795 #include <kurl.h>
796
797+#include "config.h"
798+
799 KMWFax::KMWFax(QWidget *parent, const char *name)
800 : KMWizardPage(parent,name)
801 {
802@@ -55,11 +57,19 @@
803 ipp_attribute_t *attr = req.first();
804 while (attr)
805 {
806+#ifdef HAVE_CUPS_1_6
807+ if (ippGetName(attr) && strcmp(ippGetName(attr),"device-uri") == 0 && strncmp(ippGetString(attr, 0, NULL),"fax",3) == 0)
808+ {
809+ m_list->insertItem(SmallIcon("blockdevice"),QString::fromLatin1(ippGetString(attr, 0, NULL)));
810+ }
811+ attr = ippNextAttribute(req.request());
812+#else // HAVE_CUPS_1_6
813 if (attr->name && strcmp(attr->name,"device-uri") == 0 && strncmp(attr->values[0].string.text,"fax",3) == 0)
814 {
815 m_list->insertItem(SmallIcon("blockdevice"),QString::fromLatin1(attr->values[0].string.text));
816 }
817 attr = attr->next;
818+#endif // HAVE_CUPS_1_6
819 }
820 }
821 }
822diff -ur kdelibs-3.5.10/kdeprint/cups/kmwippselect.cpp kdelibs-3.5.10-cups16/kdeprint/cups/kmwippselect.cpp
823--- kdelibs-3.5.10/kdeprint/cups/kmwippselect.cpp 2007-01-15 12:34:19.000000000 +0100
824+++ kdelibs-3.5.10-cups16/kdeprint/cups/kmwippselect.cpp 2012-12-25 16:34:57.000000000 +0100
825@@ -29,6 +29,8 @@
826 #include <kdebug.h>
827 #include <kiconloader.h>
828
829+#include "config.h"
830+
831 KMWIppSelect::KMWIppSelect(QWidget *parent, const char *name)
832 : KMWizardPage(parent,name)
833 {
834@@ -83,9 +85,15 @@
835 ipp_attribute_t *attr = req.first();
836 while (attr)
837 {
838+#ifdef HAVE_CUPS_1_6
839+ if (ippGetName(attr) && strcmp(ippGetName(attr),"printer-name") == 0)
840+ m_list->insertItem(SmallIcon("kdeprint_printer"),QString::fromLatin1(ippGetString(attr, 0, NULL)));
841+ attr = ippNextAttribute(req.request());
842+#else // HAVE_CUPS_1_6
843 if (attr->name && strcmp(attr->name,"printer-name") == 0)
844 m_list->insertItem(SmallIcon("kdeprint_printer"),QString::fromLatin1(attr->values[0].string.text));
845 attr = attr->next;
846+#endif // HAVE_CUPS_1_6
847 }
848 m_list->sort();
849 }
This page took 0.239181 seconds and 4 git commands to generate.