After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 670373 - modules/printing/cups/gtkprintbackendcups.c won't build with CUPS 1.6
modules/printing/cups/gtkprintbackendcups.c won't build with CUPS 1.6
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Printing
3.3.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-02-18 21:42 UTC by John Ralls
Modified: 2012-04-24 15:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The easy part of cups 1.6 accommodation (5.17 KB, patch)
2012-02-18 22:23 UTC, John Ralls
none Details | Review
More comprehensive than the predecessor (14.02 KB, patch)
2012-02-19 03:31 UTC, John Ralls
committed Details | Review
Refactoring Patch 1 (3.98 KB, patch)
2012-02-20 01:37 UTC, John Ralls
committed Details | Review
Refactoring Patch 2 (1.08 KB, patch)
2012-02-20 01:38 UTC, John Ralls
committed Details | Review
Refactoring Patch 3 (9.93 KB, patch)
2012-02-20 01:42 UTC, John Ralls
none Details | Review
Refactoring Patch 3 (10.22 KB, patch)
2012-02-20 01:58 UTC, John Ralls
committed Details | Review
Refactoring Patch 4 (10.69 KB, patch)
2012-02-20 01:59 UTC, John Ralls
committed Details | Review
Refactoring Patch 5 (7.79 KB, patch)
2012-02-20 02:00 UTC, John Ralls
committed Details | Review
Refactoring Patch 6 (3.56 KB, patch)
2012-02-20 02:03 UTC, John Ralls
committed Details | Review
Finally, the fix! (2.29 KB, patch)
2012-02-20 02:05 UTC, John Ralls
committed Details | Review
One more, some minor fixes in gtkcupsutils.c (2.59 KB, patch)
2012-02-20 02:06 UTC, John Ralls
committed Details | Review

Description John Ralls 2012-02-18 21:42:34 UTC
CUPS 1.6 (currently in development) deprecates most ppd functions and makes private most ipp structs, requiring the use of new accessor functions.

The deprecated functions used by gtkprintbackendcups.c are:
 ppdFindAttr()
 ppdFindCustomOption()
 ppdFirstCustomParam()
 ppdNextCustomParam()

The ipp structs used are ipp_t and ipp_attr_t (the former is used to retrieve instances of the latter). A few cases are trivial and can be solved either with macros or a brief ifdef block, but most of them are in cups_request_printer_list_cb, a convoluted 500+ line function which will require extensive refactoring to consolidate the ifdeffed blocks. I'll prepare a series of changesets with the simple changes, the refactoring (which I may break up into multiple changesets), and the final 1.6 ifdefs.
Comment 1 John Ralls 2012-02-18 22:23:23 UTC
Created attachment 207958 [details] [review]
The easy part of cups 1.6 accommodation

Adds a test for Cups-1.6 to configure which sets HAVE_CUPS_API_1_6.
Sets _PPD_DEPRECATED to empty to suppress the deprecated warnings from ppd.h
Creates some simple replacement macros to simulate the Cups 1.6 getter functions where that will work.
Replaces in place attribute search routines where they can be simply separated from the rest of the code.

As noted, this doesn't completely fix the problem.
Comment 2 John Ralls 2012-02-19 03:31:14 UTC
Created attachment 207968 [details] [review]
More comprehensive than the predecessor

Once I dug into cups_printer_list_cb() I found a bunch more opportunities for simple fixes. This gets all of them except the list iteration, which is implemented using the ipp_t argument in Cups 1.6 and so is less tractable.
Comment 3 John Ralls 2012-02-20 01:37:13 UTC
Created attachment 208010 [details] [review]
Refactoring Patch 1

Makes some static constant declarations file-scoped to enable extract-function refactorings.
Comment 4 John Ralls 2012-02-20 01:38:22 UTC
Created attachment 208011 [details] [review]
Refactoring Patch 2

Not really needed for Cups 1.6 fixes, but I don't like magic numbers.
Comment 5 John Ralls 2012-02-20 01:42:05 UTC
Created attachment 208012 [details] [review]
Refactoring Patch 3

Typedef struct PrinterSetupInfo to hold all of the many variables set from IPP Attributes and then passed to the GtkPrinter attributes, for easy passing to functions.
Comment 6 John Ralls 2012-02-20 01:58:25 UTC
Created attachment 208014 [details] [review]
Refactoring Patch 3

Realized I'd forgotten to free the PrinterSetupInfo.
Comment 7 John Ralls 2012-02-20 01:59:31 UTC
Created attachment 208015 [details] [review]
Refactoring Patch 4

Extract the first function, cups_printer_handle_attribute()
Comment 8 John Ralls 2012-02-20 02:00:24 UTC
Created attachment 208016 [details] [review]
Refactoring Patch 5

Extract the second function, cups_create_printer.
Comment 9 John Ralls 2012-02-20 02:03:10 UTC
Created attachment 208017 [details] [review]
Refactoring Patch 6

Move some variables out of the main part of the outer for loop into their scopes so that the declarations are out of the block that's going to be duplicated.

Besides, it's annoying to have variables declared outside of the scope they're needed in, especially in an overly-long function.
Comment 10 John Ralls 2012-02-20 02:05:27 UTC
Created attachment 208018 [details] [review]
Finally, the fix!

Set up the loop and increment it according to the Cups API version.
Comment 11 John Ralls 2012-02-20 02:06:57 UTC
Created attachment 208019 [details] [review]
One more, some minor fixes in gtkcupsutils.c
Comment 12 John Ralls 2012-02-20 02:07:40 UTC
The lot of them will need to be backported to 2.4 and 3.2.
Comment 13 John Ralls 2012-04-23 22:04:16 UTC
Comment on attachment 208019 [details] [review]
One more, some minor fixes in gtkcupsutils.c

Pushed to master, gtk-3-4, and gtk-2-24