[gtk-osx] [Bug 670373] Patch Gtk for Cups 1.6
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-osx] [Bug 670373] Patch Gtk for Cups 1.6
- Date: Sun, 4 Mar 2012 22:28:36 +0000 (UTC)
commit 6760a5ce3db00723028afefb4f0b4881384d841d
Author: John Ralls <jralls ceridwen us>
Date: Sun Mar 4 14:27:38 2012 -0800
[Bug 670373] Patch Gtk for Cups 1.6
modulesets-stable/gtk-osx.modules | 19 +-
...modules-printing-cups-gtkprintbackendcups.patch | 332 ++++++++++++++++++++
...modules-printing-cups-gtkprintbackendcups.patch | 331 +++++++++++++++++++
...sons-and-reasons_desc-arrays-to-file-leve.patch | 102 ++++++
...sons-and-reasons_desc-arrays-to-file-leve.patch | 101 ++++++
.../0003-gtk2-Create-enum-PrinterStateLevel.patch | 31 ++
.../0003-gtk3-Create-enum-PrinterStateLevel.patch | 31 ++
...act-printer-setup-variables-into-a-struct.patch | 256 +++++++++++++++
...act-printer-setup-variables-into-a-struct.patch | 253 +++++++++++++++
...ct-function-cups_printer_handle_attribute.patch | 282 +++++++++++++++++
...ct-function-cups_printer_handle_attribute.patch | 282 +++++++++++++++++
...gtk2-Extract-Function-cups_create_printer.patch | 222 +++++++++++++
...gtk3-Extract-Function-cups_create_printer.patch | 238 ++++++++++++++
...ariable-declarations-into-the-scopes-in-w.patch | 98 ++++++
...ariable-declarations-into-the-scopes-in-w.patch | 98 ++++++
...modules-printing-cups-gtkprintbackendcups.patch | 64 ++++
...modules-printing-cups-gtkprintbackendcups.patch | 62 ++++
...modules-printing-cups-gtkprintbackendcups.patch | 73 +++++
...modules-printing-cups-gtkprintbackendcups.patch | 73 +++++
19 files changed, 2947 insertions(+), 1 deletions(-)
---
diff --git a/modulesets-stable/gtk-osx.modules b/modulesets-stable/gtk-osx.modules
index 4b99c4e..a02fe8a 100644
--- a/modulesets-stable/gtk-osx.modules
+++ b/modulesets-stable/gtk-osx.modules
@@ -184,7 +184,16 @@
<patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0006-Bug-658722-Drag-and-Drop-sometimes-stops-working.patch" strip="1"/>
<patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0008-Implement-GtkDragSourceOwner-pasteboardChangedOwner.patch" strip="1"/>
<patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/gtk+-Bug-655065-autotestkeywords-ldadd.patch" strip="1"/>
- </branch>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0001-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0002-gtk2-Extract-reasons-and-reasons_desc-arrays-to-file-leve.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0003-gtk2-Create-enum-PrinterStateLevel.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0004-gtk2-Extract-printer-setup-variables-into-a-struct.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0005-gtk2-Extract-function-cups_printer_handle_attribute.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0006-gtk2-Extract-Function-cups_create_printer.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0007-gtk2-Move-some-variable-declarations-into-the-scopes-in-w.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0008-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0009-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch" strip="1"/>
+ </branch>
<dependencies>
<dep package="glib"/>
<dep package="pango"/>
@@ -202,6 +211,14 @@
<branch module="gtk+/3.2/gtk+-3.2.3.tar.xz" version="3.2.3"
hash="sha256:e2cf20f2510ebbc7be122a1a33dd1f472a7d06aaf16b4f2a63eb048cd9141d3d">
<patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0001-Bug-571582-GtkSelection-implementation-for-quartz.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0002-gtk3-Extract-reasons-and-reasons_desc-arrays-to-file-leve.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0003-gtk3-Create-enum-PrinterStateLevel.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0004-gtk3-Extract-printer-setup-variables-into-a-struct.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0005-gtk3-Extract-function-cups_printer_handle_attribute.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0006-gtk3-Extract-Function-cups_create_printer.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0007-gtk3-Move-some-variable-declarations-into-the-scopes-in-w.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0008-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch" strip="1"/>
+ <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0009-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch" strip="1"/>
</branch>
<dependencies>
<dep package="glib-gtk3"/>
diff --git a/patches/0001-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch b/patches/0001-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch
new file mode 100644
index 0000000..df73840
--- /dev/null
+++ b/patches/0001-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch
@@ -0,0 +1,332 @@
+From bf8d9699ec228a8dd67c1bd1a84c38c398ba0b09 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 25 Feb 2012 17:43:18 -0800
+Subject: [PATCH 1/9] [Bug 670373] modules/printing/cups/gtkprintbackendcups.c
+ won't build with CUPS 1.6
+
+ The first, simple changes. Turns off the deprecation warnings and
+ substitutes macros and short ifdef blocks where feasible.
+---
+ configure.in | 6 +
+ modules/printbackends/cups/gtkprintbackendcups.c | 146 +++++++++++++---------
+ 2 files changed, 93 insertions(+), 59 deletions(-)
+
+diff --git a/configure.in b/configure.in
+index dff4588..288ad0c 100644
+--- a/configure.in
++++ b/configure.in
+@@ -1473,6 +1473,12 @@ else
+ AC_DEFINE(HAVE_CUPS_API_1_2, 1,
+ [Define to 1 if CUPS 1.2 API is available])
+ fi
++ if test $CUPS_API_MAJOR -gt 1 -o \
++ $CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -ge 6; then
++ AC_DEFINE(HAVE_CUPS_API_1_6, 1,
++ [Define to 1 if CUPS 1.6 API is available])
++
++ fi
+
+ AC_SUBST(CUPS_API_MAJOR)
+ AC_SUBST(CUPS_API_MINOR)
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 59914ba..283a0ff 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -30,6 +30,13 @@
+ #include <sys/stat.h>
+ #include <stdlib.h>
+ #include <time.h>
++/* Cups 1.6 deprecates ppdFindAttr(), ppdFindCustomOption(),
++ * ppdFirstCustomParam(), and ppdNextCustomParam() among others. This
++ * turns off the warning so that it will compile.
++ */
++#ifdef HAVE_CUPS_API_1_6
++# define _PPD_DEPRECATED
++#endif
+
+ #include <cups/cups.h>
+ #include <cups/language.h>
+@@ -235,7 +242,22 @@ pb_module_create (void)
+ {
+ return gtk_print_backend_cups_new ();
+ }
+-
++/* CUPS 1.6 Getter/Setter Functions CUPS 1.6 makes private most of the
++ * IPP structures and enforces access via new getter functions, which
++ * are unfortunately not available in earlier versions. We define
++ * below those getter functions as macros for use when building
++ * against earlier CUPS versions.
++ */
++#ifndef HAVE_CUPS_API_1_6
++#define ippGetOperation(ipp_request) ipp_request->request.op.operation_id
++#define ippGetInteger(attr, index) attr->values[index].integer
++#define ippGetBoolean(attr, index) attr->values[index].boolean
++#define ippGetString(attr, index, foo) attr->values[index].string.text
++#define ippGetValueTag(attr) attr->value_tag
++#define ippGetName(attr) attr->name
++#define ippGetCount(attr) attr->num_values
++#define ippGetGroupTag(attr) attr->group_tag
++#endif
+ /*
+ * GtkPrintBackendCups
+ */
+@@ -463,7 +485,7 @@ cups_print_cb (GtkPrintBackendCups *print_backend,
+ ipp_t *response = gtk_cups_result_get_response (result);
+
+ if ((attr = ippFindAttribute (response, "job-id", IPP_TAG_INTEGER)) != NULL)
+- job_id = attr->values[0].integer;
++ job_id = ippGetInteger (attr, 0);
+
+ if (!gtk_print_job_get_track_print_status (ps->job) || job_id == 0)
+ gtk_print_job_set_status (ps->job, GTK_PRINT_STATUS_FINISHED);
+@@ -900,7 +922,7 @@ request_password (gpointer data)
+
+ dispatch->backend->authentication_lock = TRUE;
+
+- switch (dispatch->request->ipp_request->request.op.operation_id)
++ switch (ippGetOperation (dispatch->request->ipp_request))
+ {
+ case IPP_PRINT_JOB:
+ if (job_title != NULL && printer_name != NULL)
+@@ -928,7 +950,7 @@ request_password (gpointer data)
+ break;
+ default:
+ /* work around gcc warning about 0 not being a value for this enum */
+- if (dispatch->request->ipp_request->request.op.operation_id == 0)
++ if (ippGetOperation (dispatch->request->ipp_request) == 0)
+ prompt = g_strdup_printf ( _("Authentication is required to get a file from %s"), hostname);
+ else
+ prompt = g_strdup_printf ( _("Authentication is required on %s"), hostname);
+@@ -1516,10 +1538,15 @@ cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
+ }
+
+ data->counter++;
+-
++
+ response = gtk_cups_result_get_response (result);
+
+ state = 0;
++
++#ifdef HAVE_CUPS_API_1_6
++ attr = ippFindAttribute (response, "job-state", IPP_TAG_INTEGER);
++ state = ippGetInteger (attr, 0);
++#else
+ for (attr = response->attrs; attr != NULL; attr = attr->next)
+ {
+ if (!attr->name)
+@@ -1527,7 +1554,8 @@ cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
+
+ _CUPS_MAP_ATTR_INT (attr, state, "job-state");
+ }
+-
++#endif
++
+ done = FALSE;
+ switch (state)
+ {
+@@ -1760,53 +1788,53 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ gboolean is_accepting_jobs = TRUE;
+ gboolean default_printer = FALSE;
+ gboolean got_printer_type = FALSE;
+- gchar *default_cover_before = NULL;
+- gchar *default_cover_after = NULL;
++ const gchar *default_cover_before = NULL;
++ const gchar *default_cover_after = NULL;
+ gboolean remote_printer = FALSE;
+ gchar **auth_info_required = NULL;
+
+ /* Skip leading attributes until we hit a printer...
+ */
+- while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
++ while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
+ attr = attr->next;
+
+ if (attr == NULL)
+ break;
+
+- while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
++ while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
+ {
+- if (strcmp (attr->name, "printer-name") == 0 &&
+- attr->value_tag == IPP_TAG_NAME)
+- printer_name = attr->values[0].string.text;
+- else if (strcmp (attr->name, "printer-uri-supported") == 0 &&
+- attr->value_tag == IPP_TAG_URI)
+- printer_uri = attr->values[0].string.text;
+- else if (strcmp (attr->name, "member-uris") == 0 &&
+- attr->value_tag == IPP_TAG_URI)
+- member_uris = attr->values[0].string.text;
+- else if (strcmp (attr->name, "printer-location") == 0)
+- location = attr->values[0].string.text;
+- else if (strcmp (attr->name, "printer-info") == 0)
+- description = attr->values[0].string.text;
+- else if (strcmp (attr->name, "printer-state-message") == 0)
+- state_msg = attr->values[0].string.text;
+- else if (strcmp (attr->name, "printer-state-reasons") == 0)
++ if (strcmp (ippGetName (attr), "printer-name") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_NAME)
++ printer_name = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-uri-supported") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_URI)
++ printer_uri = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "member-uris") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_URI)
++ member_uris = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-location") == 0)
++ location = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-info") == 0)
++ description = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-state-message") == 0)
++ state_msg = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-state-reasons") == 0)
+ /* Store most important reason to reason_msg and set
+ its importance at printer_state_reason_level */
+ {
+- for (i = 0; i < attr->num_values; i++)
++ for (i = 0; i < ippGetCount (attr); i++)
+ {
+- if (strcmp (attr->values[i].string.text, "none") != 0)
++ if (strcmp (ippGetString (attr, i, NULL), "none") != 0)
+ {
+ /* Sets is_paused flag for paused printer. */
+- if (strcmp (attr->values[i].string.text, "paused") == 0)
++ if (strcmp (ippGetString (attr, i, NULL), "paused") == 0)
+ {
+ is_paused = TRUE;
+ }
+
+ interested_in = FALSE;
+ for (j = 0; j < G_N_ELEMENTS (reasons); j++)
+- if (strncmp (attr->values[i].string.text, reasons[j], strlen (reasons[j])) == 0)
++ if (strncmp (ippGetString (attr, i, NULL), reasons[j], strlen (reasons[j])) == 0)
+ {
+ interested_in = TRUE;
+ break;
+@@ -1814,87 +1842,87 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ if (interested_in)
+ {
+- if (g_str_has_suffix (attr->values[i].string.text, "-report"))
++ if (g_str_has_suffix (ippGetString (attr, i, NULL), "-report"))
+ {
+ if (printer_state_reason_level <= 1)
+ {
+- reason_msg = attr->values[i].string.text;
++ reason_msg = ippGetString (attr, i, NULL);
+ printer_state_reason_level = 1;
+ }
+ }
+- else if (g_str_has_suffix (attr->values[i].string.text, "-warning"))
++ else if (g_str_has_suffix (ippGetString (attr, i, NULL), "-warning"))
+ {
+ if (printer_state_reason_level <= 2)
+ {
+- reason_msg = attr->values[i].string.text;
++ reason_msg = ippGetString (attr, i, NULL);
+ printer_state_reason_level = 2;
+- }
++ }
+ }
+ else /* It is error in the case of no suffix. */
+ {
+- reason_msg = attr->values[i].string.text;
++ reason_msg = ippGetString (attr, i, NULL);
+ printer_state_reason_level = 3;
+ }
+ }
+ }
+ }
+ }
+- else if (strcmp (attr->name, "printer-state") == 0)
+- state = attr->values[0].integer;
+- else if (strcmp (attr->name, "queued-job-count") == 0)
+- job_count = attr->values[0].integer;
+- else if (strcmp (attr->name, "printer-is-accepting-jobs") == 0)
++ else if (strcmp (ippGetName (attr), "printer-state") == 0)
++ state = ippGetInteger (attr, 0);
++ else if (strcmp (ippGetName (attr), "queued-job-count") == 0)
++ job_count = ippGetInteger (attr, 0);
++ else if (strcmp (ippGetName (attr), "printer-is-accepting-jobs") == 0)
+ {
+- if (attr->values[0].boolean == 1)
++ if (ippGetBoolean (attr, 0) == 1)
+ is_accepting_jobs = TRUE;
+ else
+ is_accepting_jobs = FALSE;
+ }
+- else if (strcmp (attr->name, "job-sheets-supported") == 0)
++ else if (strcmp (ippGetName (attr), "job-sheets-supported") == 0)
+ {
+ if (cups_backend->covers == NULL)
+ {
+- cups_backend->number_of_covers = attr->num_values;
++ cups_backend->number_of_covers = ippGetCount (attr);
+ cups_backend->covers = g_new (char *, cups_backend->number_of_covers + 1);
+ for (i = 0; i < cups_backend->number_of_covers; i++)
+- cups_backend->covers[i] = g_strdup (attr->values[i].string.text);
++ cups_backend->covers[i] = g_strdup (ippGetString (attr, i, NULL));
+ cups_backend->covers[cups_backend->number_of_covers] = NULL;
+ }
+ }
+- else if (strcmp (attr->name, "job-sheets-default") == 0)
++ else if (strcmp (ippGetName (attr), "job-sheets-default") == 0)
+ {
+- if (attr->num_values == 2)
++ if (ippGetCount (attr) == 2)
+ {
+- default_cover_before = attr->values[0].string.text;
+- default_cover_after = attr->values[1].string.text;
++ default_cover_before = ippGetString (attr, 0, NULL);
++ default_cover_after = ippGetString (attr, 1, NULL);
+ }
+ }
+- else if (strcmp (attr->name, "printer-type") == 0)
++ else if (strcmp (ippGetName (attr), "printer-type") == 0)
+ {
+ got_printer_type = TRUE;
+- if (attr->values[0].integer & 0x00020000)
++ if (ippGetInteger (attr, 0) & 0x00020000)
+ default_printer = TRUE;
+ else
+ default_printer = FALSE;
+
+- if (attr->values[0].integer & 0x00000002)
++ if (ippGetInteger (attr, 0) & 0x00000002)
+ remote_printer = TRUE;
+ else
+ remote_printer = FALSE;
+ }
+- else if (strcmp (attr->name, "auth-info-required") == 0)
++ else if (strcmp (ippGetName (attr), "auth-info-required") == 0)
+ {
+- if (strcmp (attr->values[0].string.text, "none") != 0)
++ if (strcmp (ippGetString (attr, 0, NULL), "none") != 0)
+ {
+- auth_info_required = g_new0 (gchar *, attr->num_values + 1);
+- for (i = 0; i < attr->num_values; i++)
+- auth_info_required[i] = g_strdup (attr->values[i].string.text);
++ auth_info_required = g_new0 (gchar *, ippGetCount (attr) + 1);
++ for (i = 0; i < ippGetCount (attr); i++)
++ auth_info_required[i] = g_strdup (ippGetString (attr, i, NULL));
+ }
+ }
+ else
+ {
+ GTK_NOTE (PRINTING,
+- g_print ("CUPS Backend: Attribute %s ignored", attr->name));
++ g_print ("CUPS Backend: Attribute %s ignored", ippGetName (attr)));
+ }
+
+ attr = attr->next;
+@@ -2707,7 +2735,7 @@ cups_request_default_printer_cb (GtkPrintBackendCups *print_backend,
+ response = gtk_cups_result_get_response (result);
+
+ if ((attr = ippFindAttribute (response, "printer-name", IPP_TAG_NAME)) != NULL)
+- print_backend->default_printer = g_strdup (attr->values[0].string.text);
++ print_backend->default_printer = g_strdup (ippGetString (attr, 0, NULL));
+
+ print_backend->got_default_printer = TRUE;
+
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0001-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch b/patches/0001-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch
new file mode 100644
index 0000000..0734772
--- /dev/null
+++ b/patches/0001-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch
@@ -0,0 +1,331 @@
+From 3c586545f528e18ef2a9fa9e2ff17fc369e3a38f Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 18 Feb 2012 14:16:27 -0800
+Subject: [PATCH 1/9] [Bug 670373] modules/printing/cups/gtkprintbackendcups.c
+ won't build with CUPS 1.6
+
+The first, simple changes. Turns off the deprecation warnings and substitutes macros and short ifdef blocks where feasible.
+---
+ configure.in | 6 +
+ modules/printbackends/cups/gtkprintbackendcups.c | 146 +++++++++++++---------
+ 2 files changed, 93 insertions(+), 59 deletions(-)
+
+diff --git a/configure.in b/configure.in
+index 75761d5..85c5960 100644
+--- a/configure.in
++++ b/configure.in
+@@ -1473,6 +1473,12 @@ else
+ AC_DEFINE(HAVE_CUPS_API_1_2, 1,
+ [Define to 1 if CUPS 1.2 API is available])
+ fi
++ if test $CUPS_API_MAJOR -gt 1 -o \
++ $CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -ge 6; then
++ AC_DEFINE(HAVE_CUPS_API_1_6, 1,
++ [Define to 1 if CUPS 1.6 API is available])
++
++ fi
+
+ AC_SUBST(CUPS_API_MAJOR)
+ AC_SUBST(CUPS_API_MINOR)
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 79d66cd..12c6ab6 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -30,6 +30,13 @@
+ #include <sys/stat.h>
+ #include <stdlib.h>
+ #include <time.h>
++/* Cups 1.6 deprecates ppdFindAttr(), ppdFindCustomOption(),
++ * ppdFirstCustomParam(), and ppdNextCustomParam() among others. This
++ * turns off the warning so that it will compile.
++ */
++#ifdef HAVE_CUPS_API_1_6
++# define _PPD_DEPRECATED
++#endif
+
+ #include <cups/cups.h>
+ #include <cups/language.h>
+@@ -235,7 +242,22 @@ pb_module_create (void)
+ {
+ return gtk_print_backend_cups_new ();
+ }
+-
++/* CUPS 1.6 Getter/Setter Functions CUPS 1.6 makes private most of the
++ * IPP structures and enforces access via new getter functions, which
++ * are unfortunately not available in earlier versions. We define
++ * below those getter functions as macros for use when building
++ * against earlier CUPS versions.
++ */
++#ifndef HAVE_CUPS_API_1_6
++#define ippGetOperation(ipp_request) ipp_request->request.op.operation_id
++#define ippGetInteger(attr, index) attr->values[index].integer
++#define ippGetBoolean(attr, index) attr->values[index].boolean
++#define ippGetString(attr, index, foo) attr->values[index].string.text
++#define ippGetValueTag(attr) attr->value_tag
++#define ippGetName(attr) attr->name
++#define ippGetCount(attr) attr->num_values
++#define ippGetGroupTag(attr) attr->group_tag
++#endif
+ /*
+ * GtkPrintBackendCups
+ */
+@@ -463,7 +485,7 @@ cups_print_cb (GtkPrintBackendCups *print_backend,
+ ipp_t *response = gtk_cups_result_get_response (result);
+
+ if ((attr = ippFindAttribute (response, "job-id", IPP_TAG_INTEGER)) != NULL)
+- job_id = attr->values[0].integer;
++ job_id = ippGetInteger (attr, 0);
+
+ if (!gtk_print_job_get_track_print_status (ps->job) || job_id == 0)
+ gtk_print_job_set_status (ps->job, GTK_PRINT_STATUS_FINISHED);
+@@ -900,7 +922,7 @@ request_password (gpointer data)
+
+ dispatch->backend->authentication_lock = TRUE;
+
+- switch (dispatch->request->ipp_request->request.op.operation_id)
++ switch (ippGetOperation (dispatch->request->ipp_request))
+ {
+ case IPP_PRINT_JOB:
+ if (job_title != NULL && printer_name != NULL)
+@@ -928,7 +950,7 @@ request_password (gpointer data)
+ break;
+ default:
+ /* work around gcc warning about 0 not being a value for this enum */
+- if (dispatch->request->ipp_request->request.op.operation_id == 0)
++ if (ippGetOperation (dispatch->request->ipp_request) == 0)
+ prompt = g_strdup_printf ( _("Authentication is required to get a file from %s"), hostname);
+ else
+ prompt = g_strdup_printf ( _("Authentication is required on %s"), hostname);
+@@ -1516,10 +1538,15 @@ cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
+ }
+
+ data->counter++;
+-
++
+ response = gtk_cups_result_get_response (result);
+
+ state = 0;
++
++#ifdef HAVE_CUPS_API_1_6
++ attr = ippFindAttribute (response, "job-state", IPP_TAG_INTEGER);
++ state = ippGetInteger (attr, 0);
++#else
+ for (attr = response->attrs; attr != NULL; attr = attr->next)
+ {
+ if (!attr->name)
+@@ -1527,7 +1554,8 @@ cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
+
+ _CUPS_MAP_ATTR_INT (attr, state, "job-state");
+ }
+-
++#endif
++
+ done = FALSE;
+ switch (state)
+ {
+@@ -1760,53 +1788,53 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ gboolean is_accepting_jobs = TRUE;
+ gboolean default_printer = FALSE;
+ gboolean got_printer_type = FALSE;
+- gchar *default_cover_before = NULL;
+- gchar *default_cover_after = NULL;
++ const gchar *default_cover_before = NULL;
++ const gchar *default_cover_after = NULL;
+ gboolean remote_printer = FALSE;
+ gchar **auth_info_required = NULL;
+
+ /* Skip leading attributes until we hit a printer...
+ */
+- while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
++ while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
+ attr = attr->next;
+
+ if (attr == NULL)
+ break;
+
+- while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
++ while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
+ {
+- if (strcmp (attr->name, "printer-name") == 0 &&
+- attr->value_tag == IPP_TAG_NAME)
+- printer_name = attr->values[0].string.text;
+- else if (strcmp (attr->name, "printer-uri-supported") == 0 &&
+- attr->value_tag == IPP_TAG_URI)
+- printer_uri = attr->values[0].string.text;
+- else if (strcmp (attr->name, "member-uris") == 0 &&
+- attr->value_tag == IPP_TAG_URI)
+- member_uris = attr->values[0].string.text;
+- else if (strcmp (attr->name, "printer-location") == 0)
+- location = attr->values[0].string.text;
+- else if (strcmp (attr->name, "printer-info") == 0)
+- description = attr->values[0].string.text;
+- else if (strcmp (attr->name, "printer-state-message") == 0)
+- state_msg = attr->values[0].string.text;
+- else if (strcmp (attr->name, "printer-state-reasons") == 0)
++ if (strcmp (ippGetName (attr), "printer-name") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_NAME)
++ printer_name = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-uri-supported") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_URI)
++ printer_uri = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "member-uris") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_URI)
++ member_uris = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-location") == 0)
++ location = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-info") == 0)
++ description = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-state-message") == 0)
++ state_msg = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-state-reasons") == 0)
+ /* Store most important reason to reason_msg and set
+ its importance at printer_state_reason_level */
+ {
+- for (i = 0; i < attr->num_values; i++)
++ for (i = 0; i < ippGetCount (attr); i++)
+ {
+- if (strcmp (attr->values[i].string.text, "none") != 0)
++ if (strcmp (ippGetString (attr, i, NULL), "none") != 0)
+ {
+ /* Sets is_paused flag for paused printer. */
+- if (strcmp (attr->values[i].string.text, "paused") == 0)
++ if (strcmp (ippGetString (attr, i, NULL), "paused") == 0)
+ {
+ is_paused = TRUE;
+ }
+
+ interested_in = FALSE;
+ for (j = 0; j < G_N_ELEMENTS (reasons); j++)
+- if (strncmp (attr->values[i].string.text, reasons[j], strlen (reasons[j])) == 0)
++ if (strncmp (ippGetString (attr, i, NULL), reasons[j], strlen (reasons[j])) == 0)
+ {
+ interested_in = TRUE;
+ break;
+@@ -1814,87 +1842,87 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ if (interested_in)
+ {
+- if (g_str_has_suffix (attr->values[i].string.text, "-report"))
++ if (g_str_has_suffix (ippGetString (attr, i, NULL), "-report"))
+ {
+ if (printer_state_reason_level <= 1)
+ {
+- reason_msg = attr->values[i].string.text;
++ reason_msg = ippGetString (attr, i, NULL);
+ printer_state_reason_level = 1;
+ }
+ }
+- else if (g_str_has_suffix (attr->values[i].string.text, "-warning"))
++ else if (g_str_has_suffix (ippGetString (attr, i, NULL), "-warning"))
+ {
+ if (printer_state_reason_level <= 2)
+ {
+- reason_msg = attr->values[i].string.text;
++ reason_msg = ippGetString (attr, i, NULL);
+ printer_state_reason_level = 2;
+- }
++ }
+ }
+ else /* It is error in the case of no suffix. */
+ {
+- reason_msg = attr->values[i].string.text;
++ reason_msg = ippGetString (attr, i, NULL);
+ printer_state_reason_level = 3;
+ }
+ }
+ }
+ }
+ }
+- else if (strcmp (attr->name, "printer-state") == 0)
+- state = attr->values[0].integer;
+- else if (strcmp (attr->name, "queued-job-count") == 0)
+- job_count = attr->values[0].integer;
+- else if (strcmp (attr->name, "printer-is-accepting-jobs") == 0)
++ else if (strcmp (ippGetName (attr), "printer-state") == 0)
++ state = ippGetInteger (attr, 0);
++ else if (strcmp (ippGetName (attr), "queued-job-count") == 0)
++ job_count = ippGetInteger (attr, 0);
++ else if (strcmp (ippGetName (attr), "printer-is-accepting-jobs") == 0)
+ {
+- if (attr->values[0].boolean == 1)
++ if (ippGetBoolean (attr, 0) == 1)
+ is_accepting_jobs = TRUE;
+ else
+ is_accepting_jobs = FALSE;
+ }
+- else if (strcmp (attr->name, "job-sheets-supported") == 0)
++ else if (strcmp (ippGetName (attr), "job-sheets-supported") == 0)
+ {
+ if (cups_backend->covers == NULL)
+ {
+- cups_backend->number_of_covers = attr->num_values;
++ cups_backend->number_of_covers = ippGetCount (attr);
+ cups_backend->covers = g_new (char *, cups_backend->number_of_covers + 1);
+ for (i = 0; i < cups_backend->number_of_covers; i++)
+- cups_backend->covers[i] = g_strdup (attr->values[i].string.text);
++ cups_backend->covers[i] = g_strdup (ippGetString (attr, i, NULL));
+ cups_backend->covers[cups_backend->number_of_covers] = NULL;
+ }
+ }
+- else if (strcmp (attr->name, "job-sheets-default") == 0)
++ else if (strcmp (ippGetName (attr), "job-sheets-default") == 0)
+ {
+- if (attr->num_values == 2)
++ if (ippGetCount (attr) == 2)
+ {
+- default_cover_before = attr->values[0].string.text;
+- default_cover_after = attr->values[1].string.text;
++ default_cover_before = ippGetString (attr, 0, NULL);
++ default_cover_after = ippGetString (attr, 1, NULL);
+ }
+ }
+- else if (strcmp (attr->name, "printer-type") == 0)
++ else if (strcmp (ippGetName (attr), "printer-type") == 0)
+ {
+ got_printer_type = TRUE;
+- if (attr->values[0].integer & 0x00020000)
++ if (ippGetInteger (attr, 0) & 0x00020000)
+ default_printer = TRUE;
+ else
+ default_printer = FALSE;
+
+- if (attr->values[0].integer & 0x00000002)
++ if (ippGetInteger (attr, 0) & 0x00000002)
+ remote_printer = TRUE;
+ else
+ remote_printer = FALSE;
+ }
+- else if (strcmp (attr->name, "auth-info-required") == 0)
++ else if (strcmp (ippGetName (attr), "auth-info-required") == 0)
+ {
+- if (strcmp (attr->values[0].string.text, "none") != 0)
++ if (strcmp (ippGetString (attr, 0, NULL), "none") != 0)
+ {
+- auth_info_required = g_new0 (gchar *, attr->num_values + 1);
+- for (i = 0; i < attr->num_values; i++)
+- auth_info_required[i] = g_strdup (attr->values[i].string.text);
++ auth_info_required = g_new0 (gchar *, ippGetCount (attr) + 1);
++ for (i = 0; i < ippGetCount (attr); i++)
++ auth_info_required[i] = g_strdup (ippGetString (attr, i, NULL));
+ }
+ }
+ else
+ {
+ GTK_NOTE (PRINTING,
+- g_print ("CUPS Backend: Attribute %s ignored", attr->name));
++ g_print ("CUPS Backend: Attribute %s ignored", ippGetName (attr)));
+ }
+
+ attr = attr->next;
+@@ -2707,7 +2737,7 @@ cups_request_default_printer_cb (GtkPrintBackendCups *print_backend,
+ response = gtk_cups_result_get_response (result);
+
+ if ((attr = ippFindAttribute (response, "printer-name", IPP_TAG_NAME)) != NULL)
+- print_backend->default_printer = g_strdup (attr->values[0].string.text);
++ print_backend->default_printer = g_strdup (ippGetString (attr, 0, NULL));
+
+ print_backend->got_default_printer = TRUE;
+
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0002-gtk2-Extract-reasons-and-reasons_desc-arrays-to-file-leve.patch b/patches/0002-gtk2-Extract-reasons-and-reasons_desc-arrays-to-file-leve.patch
new file mode 100644
index 0000000..0b70b42
--- /dev/null
+++ b/patches/0002-gtk2-Extract-reasons-and-reasons_desc-arrays-to-file-leve.patch
@@ -0,0 +1,102 @@
+From 330a278dd3f1b29dc4a29b80ee389691fdd81fe7 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 25 Feb 2012 17:44:13 -0800
+Subject: [PATCH 2/9] Extract reasons and reasons_desc arrays to file level
+
+So that they can be used from more than one function. Rename them to
+avoid naming conflicts.
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 70 +++++++++++-----------
+ 1 files changed, 36 insertions(+), 34 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 283a0ff..875c080 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -1679,6 +1679,42 @@ find_printer (GtkPrinter *printer,
+ printer_name = gtk_printer_get_name (printer);
+ return g_ascii_strcasecmp (printer_name, find_name);
+ }
++/* Printer messages we're interested in */
++static const char * const printer_messages[] =
++ {
++ "toner-low",
++ "toner-empty",
++ "developer-low",
++ "developer-empty",
++ "marker-supply-low",
++ "marker-supply-empty",
++ "cover-open",
++ "door-open",
++ "media-low",
++ "media-empty",
++ "offline",
++ "other"
++ };
++/* Our translatable versions of the printer messages */
++static const char * printer_strings[] =
++ {
++ N_("Printer '%s' is low on toner."),
++ N_("Printer '%s' has no toner left."),
++ /* Translators: "Developer" like on photo development context */
++ N_("Printer '%s' is low on developer."),
++ /* Translators: "Developer" like on photo development context */
++ N_("Printer '%s' is out of developer."),
++ /* Translators: "marker" is one color bin of the printer */
++ N_("Printer '%s' is low on at least one marker supply."),
++ /* Translators: "marker" is one color bin of the printer */
++ N_("Printer '%s' is out of at least one marker supply."),
++ N_("The cover is open on printer '%s'."),
++ N_("The door is open on printer '%s'."),
++ N_("Printer '%s' is low on paper."),
++ N_("Printer '%s' is out of paper."),
++ N_("Printer '%s' is currently offline."),
++ N_("There is a problem on printer '%s'.")
++ };
+
+ static void
+ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+@@ -1750,40 +1786,6 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ gint printer_state_reason_level = 0; /* 0 - none, 1 - report, 2 - warning, 3 - error */
+ gboolean interested_in = FALSE;
+ gboolean found = FALSE;
+- static const char * const reasons[] = /* Reasons we're interested in */
+- {
+- "toner-low",
+- "toner-empty",
+- "developer-low",
+- "developer-empty",
+- "marker-supply-low",
+- "marker-supply-empty",
+- "cover-open",
+- "door-open",
+- "media-low",
+- "media-empty",
+- "offline",
+- "other"
+- };
+- static const char * reasons_descs[] =
+- {
+- N_("Printer '%s' is low on toner."),
+- N_("Printer '%s' has no toner left."),
+- /* Translators: "Developer" like on photo development context */
+- N_("Printer '%s' is low on developer."),
+- /* Translators: "Developer" like on photo development context */
+- N_("Printer '%s' is out of developer."),
+- /* Translators: "marker" is one color bin of the printer */
+- N_("Printer '%s' is low on at least one marker supply."),
+- /* Translators: "marker" is one color bin of the printer */
+- N_("Printer '%s' is out of at least one marker supply."),
+- N_("The cover is open on printer '%s'."),
+- N_("The door is open on printer '%s'."),
+- N_("Printer '%s' is low on paper."),
+- N_("Printer '%s' is out of paper."),
+- N_("Printer '%s' is currently offline."),
+- N_("There is a problem on printer '%s'.")
+- };
+ gboolean is_paused = FALSE;
+ gboolean is_accepting_jobs = TRUE;
+ gboolean default_printer = FALSE;
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0002-gtk3-Extract-reasons-and-reasons_desc-arrays-to-file-leve.patch b/patches/0002-gtk3-Extract-reasons-and-reasons_desc-arrays-to-file-leve.patch
new file mode 100644
index 0000000..f27bd9e
--- /dev/null
+++ b/patches/0002-gtk3-Extract-reasons-and-reasons_desc-arrays-to-file-leve.patch
@@ -0,0 +1,101 @@
+From 0822a32530945c9df43f7224b6a9167674529fdb Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 19 Feb 2012 13:14:36 -0800
+Subject: [PATCH 2/9] Extract reasons and reasons_desc arrays to file level
+
+So that they can be used from more than one function. Rename them to avoid naming conflicts.
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 70 +++++++++++-----------
+ 1 files changed, 36 insertions(+), 34 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 12c6ab6..88c7137 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -1692,6 +1692,42 @@ find_printer (GtkPrinter *printer,
+ printer_name = gtk_printer_get_name (printer);
+ return g_ascii_strcasecmp (printer_name, find_name);
+ }
++/* Printer messages we're interested in */
++static const char * const printer_messages[] =
++ {
++ "toner-low",
++ "toner-empty",
++ "developer-low",
++ "developer-empty",
++ "marker-supply-low",
++ "marker-supply-empty",
++ "cover-open",
++ "door-open",
++ "media-low",
++ "media-empty",
++ "offline",
++ "other"
++ };
++/* Our translatable versions of the printer messages */
++static const char * printer_strings[] =
++ {
++ N_("Printer '%s' is low on toner."),
++ N_("Printer '%s' has no toner left."),
++ /* Translators: "Developer" like on photo development context */
++ N_("Printer '%s' is low on developer."),
++ /* Translators: "Developer" like on photo development context */
++ N_("Printer '%s' is out of developer."),
++ /* Translators: "marker" is one color bin of the printer */
++ N_("Printer '%s' is low on at least one marker supply."),
++ /* Translators: "marker" is one color bin of the printer */
++ N_("Printer '%s' is out of at least one marker supply."),
++ N_("The cover is open on printer '%s'."),
++ N_("The door is open on printer '%s'."),
++ N_("Printer '%s' is low on paper."),
++ N_("Printer '%s' is out of paper."),
++ N_("Printer '%s' is currently offline."),
++ N_("There is a problem on printer '%s'.")
++ };
+
+ static void
+ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+@@ -1763,40 +1799,6 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ gint printer_state_reason_level = 0; /* 0 - none, 1 - report, 2 - warning, 3 - error */
+ gboolean interested_in = FALSE;
+ gboolean found = FALSE;
+- static const char * const reasons[] = /* Reasons we're interested in */
+- {
+- "toner-low",
+- "toner-empty",
+- "developer-low",
+- "developer-empty",
+- "marker-supply-low",
+- "marker-supply-empty",
+- "cover-open",
+- "door-open",
+- "media-low",
+- "media-empty",
+- "offline",
+- "other"
+- };
+- static const char * reasons_descs[] =
+- {
+- N_("Printer '%s' is low on toner."),
+- N_("Printer '%s' has no toner left."),
+- /* Translators: "Developer" like on photo development context */
+- N_("Printer '%s' is low on developer."),
+- /* Translators: "Developer" like on photo development context */
+- N_("Printer '%s' is out of developer."),
+- /* Translators: "marker" is one color bin of the printer */
+- N_("Printer '%s' is low on at least one marker supply."),
+- /* Translators: "marker" is one color bin of the printer */
+- N_("Printer '%s' is out of at least one marker supply."),
+- N_("The cover is open on printer '%s'."),
+- N_("The door is open on printer '%s'."),
+- N_("Printer '%s' is low on paper."),
+- N_("Printer '%s' is out of paper."),
+- N_("Printer '%s' is currently offline."),
+- N_("There is a problem on printer '%s'.")
+- };
+ gboolean is_paused = FALSE;
+ gboolean is_accepting_jobs = TRUE;
+ gboolean default_printer = FALSE;
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0003-gtk2-Create-enum-PrinterStateLevel.patch b/patches/0003-gtk2-Create-enum-PrinterStateLevel.patch
new file mode 100644
index 0000000..15d242d
--- /dev/null
+++ b/patches/0003-gtk2-Create-enum-PrinterStateLevel.patch
@@ -0,0 +1,31 @@
+From f11bc5f5e865950d4b2ed99c9a20332e5d2c5b0d Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 25 Feb 2012 17:45:04 -0800
+Subject: [PATCH 3/9] Create enum PrinterStateLevel
+
+Fixes "magic number" in printer_state_reason_level.
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 7 +++++++
+ 1 files changed, 7 insertions(+), 0 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 875c080..ed138fd 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -1716,6 +1716,13 @@ static const char * printer_strings[] =
+ N_("There is a problem on printer '%s'.")
+ };
+
++typedef enum
++ {
++ GTK_PRINTER_STATE_LEVEL_NONE = 0,
++ GTK_PRINTER_STATE_LEVEL_INFO = 1,
++ GTK_PRINTER_STATE_LEVEL_WARNING = 2,
++ GTK_PRINTER_STATE_LEVEL_ERROR = 3
++ } PrinterStateLevel;
+ static void
+ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ GtkCupsResult *result,
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0003-gtk3-Create-enum-PrinterStateLevel.patch b/patches/0003-gtk3-Create-enum-PrinterStateLevel.patch
new file mode 100644
index 0000000..5d87fb7
--- /dev/null
+++ b/patches/0003-gtk3-Create-enum-PrinterStateLevel.patch
@@ -0,0 +1,31 @@
+From 6333a3724e1e93b96077c0ce4eb3e01aeb6da453 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 19 Feb 2012 13:15:40 -0800
+Subject: [PATCH 3/9] Create enum PrinterStateLevel
+
+Fixes "magic number" in printer_state_reason_level.
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 7 +++++++
+ 1 files changed, 7 insertions(+), 0 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 88c7137..fab3f40 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -1729,6 +1729,13 @@ static const char * printer_strings[] =
+ N_("There is a problem on printer '%s'.")
+ };
+
++typedef enum
++ {
++ GTK_PRINTER_STATE_LEVEL_NONE = 0,
++ GTK_PRINTER_STATE_LEVEL_INFO = 1,
++ GTK_PRINTER_STATE_LEVEL_WARNING = 2,
++ GTK_PRINTER_STATE_LEVEL_ERROR = 3
++ } PrinterStateLevel;
+ static void
+ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ GtkCupsResult *result,
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0004-gtk2-Extract-printer-setup-variables-into-a-struct.patch b/patches/0004-gtk2-Extract-printer-setup-variables-into-a-struct.patch
new file mode 100644
index 0000000..b9ef8c8
--- /dev/null
+++ b/patches/0004-gtk2-Extract-printer-setup-variables-into-a-struct.patch
@@ -0,0 +1,256 @@
+From d72449b440363b0d1d06823fbf704f5ef8cd1717 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 25 Feb 2012 17:47:19 -0800
+Subject: [PATCH 4/9] Extract printer setup variables into a struct
+
+So that it can be passed as a single parameter to functions as we
+extract-function to make cups_request_printer_list_cb more manageable.
+
+Note that not all of the affected variables are changed in this
+changeset. Those are in extracted functions and will be addressed in the
+next two changes.
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 123 ++++++++++++----------
+ 1 files changed, 67 insertions(+), 56 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index ed138fd..5ec918c 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -1723,6 +1723,28 @@ typedef enum
+ GTK_PRINTER_STATE_LEVEL_WARNING = 2,
+ GTK_PRINTER_STATE_LEVEL_ERROR = 3
+ } PrinterStateLevel;
++
++typedef struct
++{
++ const gchar *printer_name;
++ const gchar *printer_uri;
++ const gchar *member_uris;
++ const gchar *location;
++ const gchar *description;
++ const gchar *state_msg;
++ const gchar *reason_msg;
++ PrinterStateLevel reason_level;
++ gint state;
++ gint job_count;
++ gboolean is_paused;
++ gboolean is_accepting_jobs;
++ const gchar *default_cover_before;
++ const gchar *default_cover_after;
++ gboolean default_printer;
++ gboolean got_printer_type;
++ gboolean remote_printer;
++ gchar **auth_info_required;
++} PrinterSetupInfo;
+ static void
+ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ GtkCupsResult *result,
+@@ -1775,32 +1797,14 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ for (attr = response->attrs; attr != NULL; attr = attr->next)
+ {
+ GtkPrinter *printer;
+- const gchar *printer_name = NULL;
+- const gchar *printer_uri = NULL;
+- const gchar *member_uris = NULL;
+- const gchar *location = NULL;
+- const gchar *description = NULL;
+- const gchar *state_msg = NULL;
+- gint state = 0;
+- gint job_count = 0;
+ gboolean status_changed = FALSE;
+ GList *node;
+ gint i,j;
+- const gchar *reason_msg = NULL;
+ gchar *reason_msg_desc = NULL;
+ gchar *tmp_msg = NULL;
+ gchar *tmp_msg2 = NULL;
+- gint printer_state_reason_level = 0; /* 0 - none, 1 - report, 2 - warning, 3 - error */
+- gboolean interested_in = FALSE;
+ gboolean found = FALSE;
+- gboolean is_paused = FALSE;
+- gboolean is_accepting_jobs = TRUE;
+- gboolean default_printer = FALSE;
+- gboolean got_printer_type = FALSE;
+- const gchar *default_cover_before = NULL;
+- const gchar *default_cover_after = NULL;
+- gboolean remote_printer = FALSE;
+- gchar **auth_info_required = NULL;
++ PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo);
+
+ /* Skip leading attributes until we hit a printer...
+ */
+@@ -1937,8 +1941,8 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ attr = attr->next;
+ }
+
+- if (printer_name == NULL ||
+- (printer_uri == NULL && member_uris == NULL))
++ if (info->printer_name == NULL ||
++ (info->printer_uri == NULL && info->member_uris == NULL))
+ {
+ if (attr == NULL)
+ break;
+@@ -1946,19 +1950,19 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ continue;
+ }
+
+- if (got_printer_type)
++ if (info->got_printer_type)
+ {
+- if (default_printer && !cups_backend->got_default_printer)
++ if (info->default_printer && !cups_backend->got_default_printer)
+ {
+- if (!remote_printer)
++ if (!info->remote_printer)
+ {
+ cups_backend->got_default_printer = TRUE;
+- cups_backend->default_printer = g_strdup (printer_name);
++ cups_backend->default_printer = g_strdup (info->printer_name);
+ }
+ else
+ {
+ if (remote_default_printer == NULL)
+- remote_default_printer = g_strdup (printer_name);
++ remote_default_printer = g_strdup (info->printer_name);
+ }
+ }
+ }
+@@ -1969,10 +1973,13 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ }
+
+ /* remove name from checklist if it was found */
+- node = g_list_find_custom (removed_printer_checklist, printer_name, (GCompareFunc) find_printer);
+- removed_printer_checklist = g_list_delete_link (removed_printer_checklist, node);
++ node = g_list_find_custom (removed_printer_checklist,
++ info->printer_name,
++ (GCompareFunc) find_printer);
++ removed_printer_checklist = g_list_delete_link (removed_printer_checklist,
++ node);
+
+- printer = gtk_print_backend_find_printer (backend, printer_name);
++ printer = gtk_print_backend_find_printer (backend, info->printer_name);
+ if (!printer)
+ {
+ GtkPrinterCups *cups_printer;
+@@ -2064,10 +2071,10 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ else
+ g_object_ref (printer);
+
+- GTK_PRINTER_CUPS (printer)->remote = remote_printer;
++ GTK_PRINTER_CUPS (printer)->remote = info->remote_printer;
+
+- gtk_printer_set_is_paused (printer, is_paused);
+- gtk_printer_set_is_accepting_jobs (printer, is_accepting_jobs);
++ gtk_printer_set_is_paused (printer, info->is_paused);
++ gtk_printer_set_is_accepting_jobs (printer, info->is_accepting_jobs);
+
+ if (!gtk_printer_is_active (printer))
+ {
+@@ -2090,57 +2097,60 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ cups_request_printer_info (cups_backend, gtk_printer_get_name (printer));
+ #endif
+
+- GTK_PRINTER_CUPS (printer)->state = state;
+- status_changed = gtk_printer_set_job_count (printer, job_count);
+- status_changed |= gtk_printer_set_location (printer, location);
+- status_changed |= gtk_printer_set_description (printer, description);
++ GTK_PRINTER_CUPS (printer)->state = info->state;
++ status_changed = gtk_printer_set_job_count (printer, info->job_count);
++ status_changed |= gtk_printer_set_location (printer, info->location);
++ status_changed |= gtk_printer_set_description (printer,
++ info->description);
+
+- if (state_msg != NULL && strlen (state_msg) == 0)
++ if (info->state_msg != NULL && strlen (info->state_msg) == 0)
+ {
+- if (is_paused && !is_accepting_jobs)
++ if (info->is_paused && !info->is_accepting_jobs)
+ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Paused ; Rejecting Jobs"));
+- if (is_paused && is_accepting_jobs)
++ if (info->is_paused && info->is_accepting_jobs)
+ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Paused"));
+- if (!is_paused && !is_accepting_jobs)
++ if (!info->is_paused && !info->is_accepting_jobs)
+ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Rejecting Jobs"));
+
+ if (tmp_msg2 != NULL)
+- state_msg = tmp_msg2;
++ info->state_msg = tmp_msg2;
+ }
+
+ /* Set description of the reason and combine it with printer-state-message. */
+- if ( (reason_msg != NULL))
++ if ( (info->reason_msg != NULL))
+ {
+- for (i = 0; i < G_N_ELEMENTS (reasons); i++)
++ for (i = 0; i < G_N_ELEMENTS (printer_messages); i++)
+ {
+- if (strncmp (reason_msg, reasons[i], strlen (reasons[i])) == 0)
++ if (strncmp (info->reason_msg, printer_messages[i],
++ strlen (printer_messages[i])) == 0)
+ {
+- reason_msg_desc = g_strdup_printf (reasons_descs[i], printer_name);
++ reason_msg_desc = g_strdup_printf (printer_strings[i],
++ info->printer_name);
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found)
+- printer_state_reason_level = 0;
++ info->reason_level = GTK_PRINTER_STATE_LEVEL_NONE;
+
+- if (printer_state_reason_level >= 2)
++ if (info->reason_level >= GTK_PRINTER_STATE_LEVEL_WARNING)
+ {
+- if (strlen (state_msg) == 0)
+- state_msg = reason_msg_desc;
++ if (strlen (info->state_msg) == 0)
++ info->state_msg = reason_msg_desc;
+ else
+ {
+- tmp_msg = g_strjoin (" ; ", state_msg, reason_msg_desc, NULL);
+- state_msg = tmp_msg;
++ tmp_msg = g_strjoin (" ; ", info->state_msg, reason_msg_desc, NULL);
++ info->state_msg = tmp_msg;
+ }
+ }
+ }
+
+- status_changed |= gtk_printer_set_state_message (printer, state_msg);
+- status_changed |= gtk_printer_set_is_accepting_jobs (printer, is_accepting_jobs);
++ status_changed |= gtk_printer_set_state_message (printer, info->state_msg);
++ status_changed |= gtk_printer_set_is_accepting_jobs (printer, info->is_accepting_jobs);
+
+ if (tmp_msg != NULL)
+ g_free (tmp_msg);
+@@ -2153,9 +2163,9 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ /* Set printer icon according to importance
+ (none, report, warning, error - report is omitted). */
+- if (printer_state_reason_level == 3)
++ if (info->reason_level == 3)
+ gtk_printer_set_icon_name (printer, "gtk-print-error");
+- else if (printer_state_reason_level == 2)
++ else if (info->reason_level == 2)
+ gtk_printer_set_icon_name (printer, "gtk-print-warning");
+ else if (gtk_printer_is_paused (printer))
+ gtk_printer_set_icon_name (printer, "gtk-print-paused");
+@@ -2168,7 +2178,8 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ /* The ref is held by GtkPrintBackend, in add_printer() */
+ g_object_unref (printer);
+-
++ g_slice_free (PrinterSetupInfo, info);
++
+ if (attr == NULL)
+ break;
+ }
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0004-gtk3-Extract-printer-setup-variables-into-a-struct.patch b/patches/0004-gtk3-Extract-printer-setup-variables-into-a-struct.patch
new file mode 100644
index 0000000..944373f
--- /dev/null
+++ b/patches/0004-gtk3-Extract-printer-setup-variables-into-a-struct.patch
@@ -0,0 +1,253 @@
+From 766446e4948f7e764902b58f21e6a74c29f4348d Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 19 Feb 2012 13:19:11 -0800
+Subject: [PATCH 4/9] Extract printer setup variables into a struct
+
+So that it can be passed as a single parameter to functions as we extract-function to make cups_request_printer_list_cb more manageable.
+
+Note that not all of the affected variables are changed in this changeset. Those are in extracted functions and will be addressed in the next two changes.
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 123 ++++++++++++----------
+ 1 files changed, 67 insertions(+), 56 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index fab3f40..17f3ddc 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -1736,6 +1736,28 @@ typedef enum
+ GTK_PRINTER_STATE_LEVEL_WARNING = 2,
+ GTK_PRINTER_STATE_LEVEL_ERROR = 3
+ } PrinterStateLevel;
++
++typedef struct
++{
++ const gchar *printer_name;
++ const gchar *printer_uri;
++ const gchar *member_uris;
++ const gchar *location;
++ const gchar *description;
++ const gchar *state_msg;
++ const gchar *reason_msg;
++ PrinterStateLevel reason_level;
++ gint state;
++ gint job_count;
++ gboolean is_paused;
++ gboolean is_accepting_jobs;
++ const gchar *default_cover_before;
++ const gchar *default_cover_after;
++ gboolean default_printer;
++ gboolean got_printer_type;
++ gboolean remote_printer;
++ gchar **auth_info_required;
++} PrinterSetupInfo;
+ static void
+ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ GtkCupsResult *result,
+@@ -1788,32 +1810,14 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ for (attr = response->attrs; attr != NULL; attr = attr->next)
+ {
+ GtkPrinter *printer;
+- const gchar *printer_name = NULL;
+- const gchar *printer_uri = NULL;
+- const gchar *member_uris = NULL;
+- const gchar *location = NULL;
+- const gchar *description = NULL;
+- const gchar *state_msg = NULL;
+- gint state = 0;
+- gint job_count = 0;
+ gboolean status_changed = FALSE;
+ GList *node;
+ gint i,j;
+- const gchar *reason_msg = NULL;
+ gchar *reason_msg_desc = NULL;
+ gchar *tmp_msg = NULL;
+ gchar *tmp_msg2 = NULL;
+- gint printer_state_reason_level = 0; /* 0 - none, 1 - report, 2 - warning, 3 - error */
+- gboolean interested_in = FALSE;
+ gboolean found = FALSE;
+- gboolean is_paused = FALSE;
+- gboolean is_accepting_jobs = TRUE;
+- gboolean default_printer = FALSE;
+- gboolean got_printer_type = FALSE;
+- const gchar *default_cover_before = NULL;
+- const gchar *default_cover_after = NULL;
+- gboolean remote_printer = FALSE;
+- gchar **auth_info_required = NULL;
++ PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo);
+
+ /* Skip leading attributes until we hit a printer...
+ */
+@@ -1950,8 +1954,8 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ attr = attr->next;
+ }
+
+- if (printer_name == NULL ||
+- (printer_uri == NULL && member_uris == NULL))
++ if (info->printer_name == NULL ||
++ (info->printer_uri == NULL && info->member_uris == NULL))
+ {
+ if (attr == NULL)
+ break;
+@@ -1959,19 +1963,19 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ continue;
+ }
+
+- if (got_printer_type)
++ if (info->got_printer_type)
+ {
+- if (default_printer && !cups_backend->got_default_printer)
++ if (info->default_printer && !cups_backend->got_default_printer)
+ {
+- if (!remote_printer)
++ if (!info->remote_printer)
+ {
+ cups_backend->got_default_printer = TRUE;
+- cups_backend->default_printer = g_strdup (printer_name);
++ cups_backend->default_printer = g_strdup (info->printer_name);
+ }
+ else
+ {
+ if (remote_default_printer == NULL)
+- remote_default_printer = g_strdup (printer_name);
++ remote_default_printer = g_strdup (info->printer_name);
+ }
+ }
+ }
+@@ -1982,10 +1986,13 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ }
+
+ /* remove name from checklist if it was found */
+- node = g_list_find_custom (removed_printer_checklist, printer_name, (GCompareFunc) find_printer);
+- removed_printer_checklist = g_list_delete_link (removed_printer_checklist, node);
++ node = g_list_find_custom (removed_printer_checklist,
++ info->printer_name,
++ (GCompareFunc) find_printer);
++ removed_printer_checklist = g_list_delete_link (removed_printer_checklist,
++ node);
+
+- printer = gtk_print_backend_find_printer (backend, printer_name);
++ printer = gtk_print_backend_find_printer (backend, info->printer_name);
+ if (!printer)
+ {
+ GtkPrinterCups *cups_printer;
+@@ -2083,10 +2090,10 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ else
+ g_object_ref (printer);
+
+- GTK_PRINTER_CUPS (printer)->remote = remote_printer;
++ GTK_PRINTER_CUPS (printer)->remote = info->remote_printer;
+
+- gtk_printer_set_is_paused (printer, is_paused);
+- gtk_printer_set_is_accepting_jobs (printer, is_accepting_jobs);
++ gtk_printer_set_is_paused (printer, info->is_paused);
++ gtk_printer_set_is_accepting_jobs (printer, info->is_accepting_jobs);
+
+ if (!gtk_printer_is_active (printer))
+ {
+@@ -2109,57 +2116,60 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ cups_request_printer_info (cups_backend, gtk_printer_get_name (printer));
+ #endif
+
+- GTK_PRINTER_CUPS (printer)->state = state;
+- status_changed = gtk_printer_set_job_count (printer, job_count);
+- status_changed |= gtk_printer_set_location (printer, location);
+- status_changed |= gtk_printer_set_description (printer, description);
++ GTK_PRINTER_CUPS (printer)->state = info->state;
++ status_changed = gtk_printer_set_job_count (printer, info->job_count);
++ status_changed |= gtk_printer_set_location (printer, info->location);
++ status_changed |= gtk_printer_set_description (printer,
++ info->description);
+
+- if (state_msg != NULL && strlen (state_msg) == 0)
++ if (info->state_msg != NULL && strlen (info->state_msg) == 0)
+ {
+- if (is_paused && !is_accepting_jobs)
++ if (info->is_paused && !info->is_accepting_jobs)
+ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Paused ; Rejecting Jobs"));
+- if (is_paused && is_accepting_jobs)
++ if (info->is_paused && info->is_accepting_jobs)
+ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Paused"));
+- if (!is_paused && !is_accepting_jobs)
++ if (!info->is_paused && !info->is_accepting_jobs)
+ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Rejecting Jobs"));
+
+ if (tmp_msg2 != NULL)
+- state_msg = tmp_msg2;
++ info->state_msg = tmp_msg2;
+ }
+
+ /* Set description of the reason and combine it with printer-state-message. */
+- if ( (reason_msg != NULL))
++ if ( (info->reason_msg != NULL))
+ {
+- for (i = 0; i < G_N_ELEMENTS (reasons); i++)
++ for (i = 0; i < G_N_ELEMENTS (printer_messages); i++)
+ {
+- if (strncmp (reason_msg, reasons[i], strlen (reasons[i])) == 0)
++ if (strncmp (info->reason_msg, printer_messages[i],
++ strlen (printer_messages[i])) == 0)
+ {
+- reason_msg_desc = g_strdup_printf (reasons_descs[i], printer_name);
++ reason_msg_desc = g_strdup_printf (printer_strings[i],
++ info->printer_name);
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found)
+- printer_state_reason_level = 0;
++ info->reason_level = GTK_PRINTER_STATE_LEVEL_NONE;
+
+- if (printer_state_reason_level >= 2)
++ if (info->reason_level >= GTK_PRINTER_STATE_LEVEL_WARNING)
+ {
+- if (strlen (state_msg) == 0)
+- state_msg = reason_msg_desc;
++ if (strlen (info->state_msg) == 0)
++ info->state_msg = reason_msg_desc;
+ else
+ {
+- tmp_msg = g_strjoin (" ; ", state_msg, reason_msg_desc, NULL);
+- state_msg = tmp_msg;
++ tmp_msg = g_strjoin (" ; ", info->state_msg, reason_msg_desc, NULL);
++ info->state_msg = tmp_msg;
+ }
+ }
+ }
+
+- status_changed |= gtk_printer_set_state_message (printer, state_msg);
+- status_changed |= gtk_printer_set_is_accepting_jobs (printer, is_accepting_jobs);
++ status_changed |= gtk_printer_set_state_message (printer, info->state_msg);
++ status_changed |= gtk_printer_set_is_accepting_jobs (printer, info->is_accepting_jobs);
+
+ if (tmp_msg != NULL)
+ g_free (tmp_msg);
+@@ -2172,9 +2182,9 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ /* Set printer icon according to importance
+ (none, report, warning, error - report is omitted). */
+- if (printer_state_reason_level == 3)
++ if (info->reason_level == GTK_PRINTER_STATE_LEVEL_ERROR)
+ gtk_printer_set_icon_name (printer, "printer-error");
+- else if (printer_state_reason_level == 2)
++ else if (info->reason_level == GTK_PRINTER_STATE_LEVEL_WARNING)
+ gtk_printer_set_icon_name (printer, "printer-warning");
+ else if (gtk_printer_is_paused (printer))
+ gtk_printer_set_icon_name (printer, "printer-paused");
+@@ -2187,7 +2197,8 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ /* The ref is held by GtkPrintBackend, in add_printer() */
+ g_object_unref (printer);
+-
++ g_slice_free (PrinterSetupInfo, info);
++
+ if (attr == NULL)
+ break;
+ }
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0005-gtk2-Extract-function-cups_printer_handle_attribute.patch b/patches/0005-gtk2-Extract-function-cups_printer_handle_attribute.patch
new file mode 100644
index 0000000..4410729
--- /dev/null
+++ b/patches/0005-gtk2-Extract-function-cups_printer_handle_attribute.patch
@@ -0,0 +1,282 @@
+From ce133d00fdb641ea53edb385567d863730b10813 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 25 Feb 2012 17:48:06 -0800
+Subject: [PATCH 5/9] Extract function cups_printer_handle_attribute
+
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 252 +++++++++++-----------
+ 1 files changed, 130 insertions(+), 122 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 5ec918c..8bd68bc 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -1745,6 +1745,135 @@ typedef struct
+ gboolean remote_printer;
+ gchar **auth_info_required;
+ } PrinterSetupInfo;
++
++static void
++cups_printer_handle_attribute (GtkPrintBackendCups *cups_backend,
++ ipp_attribute_t *attr,
++ PrinterSetupInfo *info)
++{
++ gint i,j;
++
++ if (strcmp (ippGetName (attr), "printer-name") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_NAME)
++ info->printer_name = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-uri-supported") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_URI)
++ info->printer_uri = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "member-uris") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_URI)
++ info->member_uris = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-location") == 0)
++ info->location = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-info") == 0)
++ info->description = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-state-message") == 0)
++ info->state_msg = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-state-reasons") == 0)
++ /* Store most important reason to reason_msg and set
++ its importance at printer_state_reason_level */
++ {
++ for (i = 0; i < ippGetCount (attr); i++)
++ {
++ gboolean interested_in = FALSE;
++ if (strcmp (ippGetString (attr, i, NULL), "none") == 0)
++ continue;
++ /* Sets is_paused flag for paused printer. */
++ if (strcmp (ippGetString (attr, i, NULL), "paused") == 0)
++ {
++ info->is_paused = TRUE;
++ }
++
++ for (j = 0; j < G_N_ELEMENTS (printer_messages); j++)
++ if (strncmp (ippGetString (attr, i, NULL), printer_messages[j], strlen (printer_messages[j])) == 0)
++ {
++ interested_in = TRUE;
++ break;
++ }
++
++ if (!interested_in)
++ continue;
++ if (g_str_has_suffix (ippGetString (attr, i, NULL), "-report"))
++ {
++ if (info->reason_level <= GTK_PRINTER_STATE_LEVEL_INFO)
++ {
++ info->reason_msg = ippGetString (attr, i, NULL);
++ info->reason_level = GTK_PRINTER_STATE_LEVEL_INFO;
++ }
++ }
++ else if (g_str_has_suffix (ippGetString (attr, i, NULL), "-warning"))
++ {
++ if (info->reason_level <= GTK_PRINTER_STATE_LEVEL_WARNING)
++ {
++ info->reason_msg = ippGetString (attr, i, NULL);
++ info->reason_level = GTK_PRINTER_STATE_LEVEL_WARNING;
++ }
++ }
++ else /* It is error in the case of no suffix. */
++ {
++ info->reason_msg = ippGetString (attr, i, NULL);
++ info->reason_level = GTK_PRINTER_STATE_LEVEL_ERROR;
++ }
++ }
++ }
++ else if (strcmp (ippGetName (attr), "printer-state") == 0)
++ info->state = ippGetInteger (attr, 0);
++ else if (strcmp (ippGetName (attr), "queued-job-count") == 0)
++ info->job_count = ippGetInteger (attr, 0);
++ else if (strcmp (ippGetName (attr), "printer-is-accepting-jobs") == 0)
++ {
++ if (ippGetBoolean (attr, 0) == 1)
++ info->is_accepting_jobs = TRUE;
++ else
++ info->is_accepting_jobs = FALSE;
++ }
++ else if (strcmp (ippGetName (attr), "job-sheets-supported") == 0)
++ {
++ if (cups_backend->covers == NULL)
++ {
++ cups_backend->number_of_covers = ippGetCount (attr);
++ cups_backend->covers = g_new (char *, cups_backend->number_of_covers + 1);
++ for (i = 0; i < cups_backend->number_of_covers; i++)
++ cups_backend->covers[i] = g_strdup (ippGetString (attr, i, NULL));
++ cups_backend->covers[cups_backend->number_of_covers] = NULL;
++ }
++ }
++ else if (strcmp (ippGetName (attr), "job-sheets-default") == 0)
++ {
++ if (ippGetCount (attr) == 2)
++ {
++ info->default_cover_before = ippGetString (attr, 0, NULL);
++ info->default_cover_after = ippGetString (attr, 1, NULL);
++ }
++ }
++ else if (strcmp (ippGetName (attr), "printer-type") == 0)
++ {
++ info->got_printer_type = TRUE;
++ if (ippGetInteger (attr, 0) & 0x00020000)
++ info->default_printer = TRUE;
++ else
++ info->default_printer = FALSE;
++
++ if (ippGetInteger (attr, 0) & 0x00000002)
++ info->remote_printer = TRUE;
++ else
++ info->remote_printer = FALSE;
++ }
++ else if (strcmp (ippGetName (attr), "auth-info-required") == 0)
++ {
++ if (strcmp (ippGetString (attr, 0, NULL), "none") != 0)
++ {
++ info->auth_info_required = g_new0 (gchar *, ippGetCount (attr) + 1);
++ for (i = 0; i < ippGetCount (attr); i++)
++ info->auth_info_required[i] = g_strdup (ippGetString (attr, i, NULL));
++ }
++ }
++ else
++ {
++ GTK_NOTE (PRINTING,
++ g_print ("CUPS Backend: Attribute %s ignored", ippGetName (attr)));
++ }
++
++}
+ static void
+ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ GtkCupsResult *result,
+@@ -1816,128 +1945,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
+ {
+- if (strcmp (ippGetName (attr), "printer-name") == 0 &&
+- ippGetValueTag (attr) == IPP_TAG_NAME)
+- printer_name = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "printer-uri-supported") == 0 &&
+- ippGetValueTag (attr) == IPP_TAG_URI)
+- printer_uri = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "member-uris") == 0 &&
+- ippGetValueTag (attr) == IPP_TAG_URI)
+- member_uris = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "printer-location") == 0)
+- location = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "printer-info") == 0)
+- description = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "printer-state-message") == 0)
+- state_msg = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "printer-state-reasons") == 0)
+- /* Store most important reason to reason_msg and set
+- its importance at printer_state_reason_level */
+- {
+- for (i = 0; i < ippGetCount (attr); i++)
+- {
+- if (strcmp (ippGetString (attr, i, NULL), "none") != 0)
+- {
+- /* Sets is_paused flag for paused printer. */
+- if (strcmp (ippGetString (attr, i, NULL), "paused") == 0)
+- {
+- is_paused = TRUE;
+- }
+-
+- interested_in = FALSE;
+- for (j = 0; j < G_N_ELEMENTS (reasons); j++)
+- if (strncmp (ippGetString (attr, i, NULL), reasons[j], strlen (reasons[j])) == 0)
+- {
+- interested_in = TRUE;
+- break;
+- }
+-
+- if (interested_in)
+- {
+- if (g_str_has_suffix (ippGetString (attr, i, NULL), "-report"))
+- {
+- if (printer_state_reason_level <= 1)
+- {
+- reason_msg = ippGetString (attr, i, NULL);
+- printer_state_reason_level = 1;
+- }
+- }
+- else if (g_str_has_suffix (ippGetString (attr, i, NULL), "-warning"))
+- {
+- if (printer_state_reason_level <= 2)
+- {
+- reason_msg = ippGetString (attr, i, NULL);
+- printer_state_reason_level = 2;
+- }
+- }
+- else /* It is error in the case of no suffix. */
+- {
+- reason_msg = ippGetString (attr, i, NULL);
+- printer_state_reason_level = 3;
+- }
+- }
+- }
+- }
+- }
+- else if (strcmp (ippGetName (attr), "printer-state") == 0)
+- state = ippGetInteger (attr, 0);
+- else if (strcmp (ippGetName (attr), "queued-job-count") == 0)
+- job_count = ippGetInteger (attr, 0);
+- else if (strcmp (ippGetName (attr), "printer-is-accepting-jobs") == 0)
+- {
+- if (ippGetBoolean (attr, 0) == 1)
+- is_accepting_jobs = TRUE;
+- else
+- is_accepting_jobs = FALSE;
+- }
+- else if (strcmp (ippGetName (attr), "job-sheets-supported") == 0)
+- {
+- if (cups_backend->covers == NULL)
+- {
+- cups_backend->number_of_covers = ippGetCount (attr);
+- cups_backend->covers = g_new (char *, cups_backend->number_of_covers + 1);
+- for (i = 0; i < cups_backend->number_of_covers; i++)
+- cups_backend->covers[i] = g_strdup (ippGetString (attr, i, NULL));
+- cups_backend->covers[cups_backend->number_of_covers] = NULL;
+- }
+- }
+- else if (strcmp (ippGetName (attr), "job-sheets-default") == 0)
+- {
+- if (ippGetCount (attr) == 2)
+- {
+- default_cover_before = ippGetString (attr, 0, NULL);
+- default_cover_after = ippGetString (attr, 1, NULL);
+- }
+- }
+- else if (strcmp (ippGetName (attr), "printer-type") == 0)
+- {
+- got_printer_type = TRUE;
+- if (ippGetInteger (attr, 0) & 0x00020000)
+- default_printer = TRUE;
+- else
+- default_printer = FALSE;
+-
+- if (ippGetInteger (attr, 0) & 0x00000002)
+- remote_printer = TRUE;
+- else
+- remote_printer = FALSE;
+- }
+- else if (strcmp (ippGetName (attr), "auth-info-required") == 0)
+- {
+- if (strcmp (ippGetString (attr, 0, NULL), "none") != 0)
+- {
+- auth_info_required = g_new0 (gchar *, ippGetCount (attr) + 1);
+- for (i = 0; i < ippGetCount (attr); i++)
+- auth_info_required[i] = g_strdup (ippGetString (attr, i, NULL));
+- }
+- }
+- else
+- {
+- GTK_NOTE (PRINTING,
+- g_print ("CUPS Backend: Attribute %s ignored", ippGetName (attr)));
+- }
+-
++ cups_printer_handle_attribute (cups_backend, attr, info);
+ attr = attr->next;
+ }
+
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0005-gtk3-Extract-function-cups_printer_handle_attribute.patch b/patches/0005-gtk3-Extract-function-cups_printer_handle_attribute.patch
new file mode 100644
index 0000000..51af75b
--- /dev/null
+++ b/patches/0005-gtk3-Extract-function-cups_printer_handle_attribute.patch
@@ -0,0 +1,282 @@
+From f51d01d94b62e0e2567c9a8c56a327bd020389d5 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 19 Feb 2012 13:28:42 -0800
+Subject: [PATCH 5/9] Extract function cups_printer_handle_attribute
+
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 252 +++++++++++-----------
+ 1 files changed, 130 insertions(+), 122 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 17f3ddc..d57974e 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -1758,6 +1758,135 @@ typedef struct
+ gboolean remote_printer;
+ gchar **auth_info_required;
+ } PrinterSetupInfo;
++
++static void
++cups_printer_handle_attribute (GtkPrintBackendCups *cups_backend,
++ ipp_attribute_t *attr,
++ PrinterSetupInfo *info)
++{
++ gint i,j;
++
++ if (strcmp (ippGetName (attr), "printer-name") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_NAME)
++ info->printer_name = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-uri-supported") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_URI)
++ info->printer_uri = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "member-uris") == 0 &&
++ ippGetValueTag (attr) == IPP_TAG_URI)
++ info->member_uris = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-location") == 0)
++ info->location = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-info") == 0)
++ info->description = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-state-message") == 0)
++ info->state_msg = ippGetString (attr, 0, NULL);
++ else if (strcmp (ippGetName (attr), "printer-state-reasons") == 0)
++ /* Store most important reason to reason_msg and set
++ its importance at printer_state_reason_level */
++ {
++ for (i = 0; i < ippGetCount (attr); i++)
++ {
++ gboolean interested_in = FALSE;
++ if (strcmp (ippGetString (attr, i, NULL), "none") == 0)
++ continue;
++ /* Sets is_paused flag for paused printer. */
++ if (strcmp (ippGetString (attr, i, NULL), "paused") == 0)
++ {
++ info->is_paused = TRUE;
++ }
++
++ for (j = 0; j < G_N_ELEMENTS (printer_messages); j++)
++ if (strncmp (ippGetString (attr, i, NULL), printer_messages[j], strlen (printer_messages[j])) == 0)
++ {
++ interested_in = TRUE;
++ break;
++ }
++
++ if (!interested_in)
++ continue;
++ if (g_str_has_suffix (ippGetString (attr, i, NULL), "-report"))
++ {
++ if (info->reason_level <= GTK_PRINTER_STATE_LEVEL_INFO)
++ {
++ info->reason_msg = ippGetString (attr, i, NULL);
++ info->reason_level = GTK_PRINTER_STATE_LEVEL_INFO;
++ }
++ }
++ else if (g_str_has_suffix (ippGetString (attr, i, NULL), "-warning"))
++ {
++ if (info->reason_level <= GTK_PRINTER_STATE_LEVEL_WARNING)
++ {
++ info->reason_msg = ippGetString (attr, i, NULL);
++ info->reason_level = GTK_PRINTER_STATE_LEVEL_WARNING;
++ }
++ }
++ else /* It is error in the case of no suffix. */
++ {
++ info->reason_msg = ippGetString (attr, i, NULL);
++ info->reason_level = GTK_PRINTER_STATE_LEVEL_ERROR;
++ }
++ }
++ }
++ else if (strcmp (ippGetName (attr), "printer-state") == 0)
++ info->state = ippGetInteger (attr, 0);
++ else if (strcmp (ippGetName (attr), "queued-job-count") == 0)
++ info->job_count = ippGetInteger (attr, 0);
++ else if (strcmp (ippGetName (attr), "printer-is-accepting-jobs") == 0)
++ {
++ if (ippGetBoolean (attr, 0) == 1)
++ info->is_accepting_jobs = TRUE;
++ else
++ info->is_accepting_jobs = FALSE;
++ }
++ else if (strcmp (ippGetName (attr), "job-sheets-supported") == 0)
++ {
++ if (cups_backend->covers == NULL)
++ {
++ cups_backend->number_of_covers = ippGetCount (attr);
++ cups_backend->covers = g_new (char *, cups_backend->number_of_covers + 1);
++ for (i = 0; i < cups_backend->number_of_covers; i++)
++ cups_backend->covers[i] = g_strdup (ippGetString (attr, i, NULL));
++ cups_backend->covers[cups_backend->number_of_covers] = NULL;
++ }
++ }
++ else if (strcmp (ippGetName (attr), "job-sheets-default") == 0)
++ {
++ if (ippGetCount (attr) == 2)
++ {
++ info->default_cover_before = ippGetString (attr, 0, NULL);
++ info->default_cover_after = ippGetString (attr, 1, NULL);
++ }
++ }
++ else if (strcmp (ippGetName (attr), "printer-type") == 0)
++ {
++ info->got_printer_type = TRUE;
++ if (ippGetInteger (attr, 0) & 0x00020000)
++ info->default_printer = TRUE;
++ else
++ info->default_printer = FALSE;
++
++ if (ippGetInteger (attr, 0) & 0x00000002)
++ info->remote_printer = TRUE;
++ else
++ info->remote_printer = FALSE;
++ }
++ else if (strcmp (ippGetName (attr), "auth-info-required") == 0)
++ {
++ if (strcmp (ippGetString (attr, 0, NULL), "none") != 0)
++ {
++ info->auth_info_required = g_new0 (gchar *, ippGetCount (attr) + 1);
++ for (i = 0; i < ippGetCount (attr); i++)
++ info->auth_info_required[i] = g_strdup (ippGetString (attr, i, NULL));
++ }
++ }
++ else
++ {
++ GTK_NOTE (PRINTING,
++ g_print ("CUPS Backend: Attribute %s ignored", ippGetName (attr)));
++ }
++
++}
+ static void
+ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ GtkCupsResult *result,
+@@ -1829,128 +1958,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
+ {
+- if (strcmp (ippGetName (attr), "printer-name") == 0 &&
+- ippGetValueTag (attr) == IPP_TAG_NAME)
+- printer_name = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "printer-uri-supported") == 0 &&
+- ippGetValueTag (attr) == IPP_TAG_URI)
+- printer_uri = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "member-uris") == 0 &&
+- ippGetValueTag (attr) == IPP_TAG_URI)
+- member_uris = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "printer-location") == 0)
+- location = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "printer-info") == 0)
+- description = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "printer-state-message") == 0)
+- state_msg = ippGetString (attr, 0, NULL);
+- else if (strcmp (ippGetName (attr), "printer-state-reasons") == 0)
+- /* Store most important reason to reason_msg and set
+- its importance at printer_state_reason_level */
+- {
+- for (i = 0; i < ippGetCount (attr); i++)
+- {
+- if (strcmp (ippGetString (attr, i, NULL), "none") != 0)
+- {
+- /* Sets is_paused flag for paused printer. */
+- if (strcmp (ippGetString (attr, i, NULL), "paused") == 0)
+- {
+- is_paused = TRUE;
+- }
+-
+- interested_in = FALSE;
+- for (j = 0; j < G_N_ELEMENTS (reasons); j++)
+- if (strncmp (ippGetString (attr, i, NULL), reasons[j], strlen (reasons[j])) == 0)
+- {
+- interested_in = TRUE;
+- break;
+- }
+-
+- if (interested_in)
+- {
+- if (g_str_has_suffix (ippGetString (attr, i, NULL), "-report"))
+- {
+- if (printer_state_reason_level <= 1)
+- {
+- reason_msg = ippGetString (attr, i, NULL);
+- printer_state_reason_level = 1;
+- }
+- }
+- else if (g_str_has_suffix (ippGetString (attr, i, NULL), "-warning"))
+- {
+- if (printer_state_reason_level <= 2)
+- {
+- reason_msg = ippGetString (attr, i, NULL);
+- printer_state_reason_level = 2;
+- }
+- }
+- else /* It is error in the case of no suffix. */
+- {
+- reason_msg = ippGetString (attr, i, NULL);
+- printer_state_reason_level = 3;
+- }
+- }
+- }
+- }
+- }
+- else if (strcmp (ippGetName (attr), "printer-state") == 0)
+- state = ippGetInteger (attr, 0);
+- else if (strcmp (ippGetName (attr), "queued-job-count") == 0)
+- job_count = ippGetInteger (attr, 0);
+- else if (strcmp (ippGetName (attr), "printer-is-accepting-jobs") == 0)
+- {
+- if (ippGetBoolean (attr, 0) == 1)
+- is_accepting_jobs = TRUE;
+- else
+- is_accepting_jobs = FALSE;
+- }
+- else if (strcmp (ippGetName (attr), "job-sheets-supported") == 0)
+- {
+- if (cups_backend->covers == NULL)
+- {
+- cups_backend->number_of_covers = ippGetCount (attr);
+- cups_backend->covers = g_new (char *, cups_backend->number_of_covers + 1);
+- for (i = 0; i < cups_backend->number_of_covers; i++)
+- cups_backend->covers[i] = g_strdup (ippGetString (attr, i, NULL));
+- cups_backend->covers[cups_backend->number_of_covers] = NULL;
+- }
+- }
+- else if (strcmp (ippGetName (attr), "job-sheets-default") == 0)
+- {
+- if (ippGetCount (attr) == 2)
+- {
+- default_cover_before = ippGetString (attr, 0, NULL);
+- default_cover_after = ippGetString (attr, 1, NULL);
+- }
+- }
+- else if (strcmp (ippGetName (attr), "printer-type") == 0)
+- {
+- got_printer_type = TRUE;
+- if (ippGetInteger (attr, 0) & 0x00020000)
+- default_printer = TRUE;
+- else
+- default_printer = FALSE;
+-
+- if (ippGetInteger (attr, 0) & 0x00000002)
+- remote_printer = TRUE;
+- else
+- remote_printer = FALSE;
+- }
+- else if (strcmp (ippGetName (attr), "auth-info-required") == 0)
+- {
+- if (strcmp (ippGetString (attr, 0, NULL), "none") != 0)
+- {
+- auth_info_required = g_new0 (gchar *, ippGetCount (attr) + 1);
+- for (i = 0; i < ippGetCount (attr); i++)
+- auth_info_required[i] = g_strdup (ippGetString (attr, i, NULL));
+- }
+- }
+- else
+- {
+- GTK_NOTE (PRINTING,
+- g_print ("CUPS Backend: Attribute %s ignored", ippGetName (attr)));
+- }
+-
++ cups_printer_handle_attribute (cups_backend, attr, info);
+ attr = attr->next;
+ }
+
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0006-gtk2-Extract-Function-cups_create_printer.patch b/patches/0006-gtk2-Extract-Function-cups_create_printer.patch
new file mode 100644
index 0000000..0f6f931
--- /dev/null
+++ b/patches/0006-gtk2-Extract-Function-cups_create_printer.patch
@@ -0,0 +1,222 @@
+From 814c0944a953371708ec9ffa32c8d261245409d2 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 25 Feb 2012 17:52:02 -0800
+Subject: [PATCH 6/9] Extract Function cups_create_printer
+
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 185 ++++++++++++----------
+ 1 files changed, 99 insertions(+), 86 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 8bd68bc..e2d9192 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -1874,6 +1874,102 @@ cups_printer_handle_attribute (GtkPrintBackendCups *cups_backend,
+ }
+
+ }
++
++static GtkPrinter*
++cups_create_printer (GtkPrintBackendCups *cups_backend,
++ PrinterSetupInfo *info)
++{
++ GtkPrinterCups *cups_printer;
++ GtkPrinter *printer;
++ char uri[HTTP_MAX_URI]; /* Printer URI */
++ char method[HTTP_MAX_URI]; /* Method/scheme name */
++ char username[HTTP_MAX_URI]; /* Username:password */
++ char hostname[HTTP_MAX_URI]; /* Hostname */
++ char resource[HTTP_MAX_URI]; /* Resource name */
++ int port; /* Port number */
++ char *cups_server; /* CUPS server */
++ GtkPrintBackend *backend = GTK_PRINT_BACKEND (cups_backend);
++
++ cups_printer = gtk_printer_cups_new (info->printer_name, backend);
++
++ cups_printer->device_uri = g_strdup_printf ("/printers/%s",
++ info->printer_name);
++
++ /* Check to see if we are looking at a class */
++ if (info->member_uris)
++ {
++ cups_printer->printer_uri = g_strdup (info->member_uris);
++ /* TODO if member_uris is a class we need to recursivly find a printer */
++ GTK_NOTE (PRINTING,
++ g_print ("CUPS Backend: Found class with printer %s\n",
++ info->member_uris));
++ }
++ else
++ {
++ cups_printer->printer_uri = g_strdup (info->printer_uri);
++ GTK_NOTE (PRINTING,
++ g_print ("CUPS Backend: Found printer %s\n", info->printer_uri));
++ }
++
++#ifdef HAVE_CUPS_API_1_2
++ httpSeparateURI (HTTP_URI_CODING_ALL, cups_printer->printer_uri,
++ method, sizeof (method),
++ username, sizeof (username),
++ hostname, sizeof (hostname),
++ &port,
++ resource, sizeof (resource));
++
++#else
++ httpSeparate (cups_printer->printer_uri,
++ method,
++ username,
++ hostname,
++ &port,
++ resource);
++#endif
++
++ if (strncmp (resource, "/printers/", 10) == 0)
++ {
++ cups_printer->ppd_name = g_strdup (resource + 10);
++ GTK_NOTE (PRINTING,
++ g_print ("CUPS Backend: Setting ppd name '%s' for printer/class '%s'\n", cups_printer->ppd_name, info->printer_name));
++ }
++
++ gethostname (uri, sizeof (uri));
++ cups_server = g_strdup (cupsServer());
++
++ if (strcasecmp (uri, hostname) == 0)
++ strcpy (hostname, "localhost");
++
++ /* if the cups server is local and listening at a unix domain socket
++ * then use the socket connection
++ */
++ if ((strstr (hostname, "localhost") != NULL) &&
++ (cups_server[0] == '/'))
++ strcpy (hostname, cups_server);
++
++ g_free (cups_server);
++
++ cups_printer->default_cover_before = g_strdup (info->default_cover_before);
++ cups_printer->default_cover_after = g_strdup (info->default_cover_after);
++
++ cups_printer->hostname = g_strdup (hostname);
++ cups_printer->port = port;
++
++ cups_printer->auth_info_required = g_strdupv (info->auth_info_required);
++ g_strfreev (info->auth_info_required);
++
++ printer = GTK_PRINTER (cups_printer);
++
++ if (cups_backend->default_printer != NULL &&
++ strcmp (cups_backend->default_printer, gtk_printer_get_name (printer)) == 0)
++ gtk_printer_set_is_default (printer, TRUE);
++
++
++ gtk_print_backend_add_printer (backend, printer);
++ return printer;
++}
++
+ static void
+ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ GtkCupsResult *result,
+@@ -1928,7 +2024,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ GtkPrinter *printer;
+ gboolean status_changed = FALSE;
+ GList *node;
+- gint i,j;
++ gint i;
+ gchar *reason_msg_desc = NULL;
+ gchar *tmp_msg = NULL;
+ gchar *tmp_msg2 = NULL;
+@@ -1990,91 +2086,8 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ printer = gtk_print_backend_find_printer (backend, info->printer_name);
+ if (!printer)
+ {
+- GtkPrinterCups *cups_printer;
+- char uri[HTTP_MAX_URI]; /* Printer URI */
+- char method[HTTP_MAX_URI]; /* Method/scheme name */
+- char username[HTTP_MAX_URI]; /* Username:password */
+- char hostname[HTTP_MAX_URI]; /* Hostname */
+- char resource[HTTP_MAX_URI]; /* Resource name */
+- int port; /* Port number */
+- char *cups_server; /* CUPS server */
+-
+- list_has_changed = TRUE;
+- cups_printer = gtk_printer_cups_new (printer_name, backend);
+-
+- cups_printer->device_uri = g_strdup_printf ("/printers/%s", printer_name);
+-
+- /* Check to see if we are looking at a class */
+- if (member_uris)
+- {
+- cups_printer->printer_uri = g_strdup (member_uris);
+- /* TODO if member_uris is a class we need to recursivly find a printer */
+- GTK_NOTE (PRINTING,
+- g_print ("CUPS Backend: Found class with printer %s\n", member_uris));
+- }
+- else
+- {
+- cups_printer->printer_uri = g_strdup (printer_uri);
+- GTK_NOTE (PRINTING,
+- g_print ("CUPS Backend: Found printer %s\n", printer_uri));
+- }
+-
+-#if (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2) || CUPS_VERSION_MAJOR > 1
+- httpSeparateURI (HTTP_URI_CODING_ALL, cups_printer->printer_uri,
+- method, sizeof (method),
+- username, sizeof (username),
+- hostname, sizeof (hostname),
+- &port,
+- resource, sizeof (resource));
+-
+-#else
+- httpSeparate (cups_printer->printer_uri,
+- method,
+- username,
+- hostname,
+- &port,
+- resource);
+-#endif
+-
+- if (strncmp (resource, "/printers/", 10) == 0)
+- {
+- cups_printer->ppd_name = g_strdup (resource + 10);
+- GTK_NOTE (PRINTING,
+- g_print ("CUPS Backend: Setting ppd name '%s' for printer/class '%s'\n", cups_printer->ppd_name, printer_name));
+- }
+-
+- gethostname (uri, sizeof (uri));
+- cups_server = g_strdup (cupsServer());
+-
+- if (strcasecmp (uri, hostname) == 0)
+- strcpy (hostname, "localhost");
+-
+- /* if the cups server is local and listening at a unix domain socket
+- * then use the socket connection
+- */
+- if ((strstr (hostname, "localhost") != NULL) &&
+- (cups_server[0] == '/'))
+- strcpy (hostname, cups_server);
+-
+- g_free (cups_server);
+-
+- cups_printer->default_cover_before = g_strdup (default_cover_before);
+- cups_printer->default_cover_after = g_strdup (default_cover_after);
+-
+- cups_printer->hostname = g_strdup (hostname);
+- cups_printer->port = port;
+-
+- cups_printer->auth_info_required = g_strdupv (auth_info_required);
+- g_strfreev (auth_info_required);
+-
+- printer = GTK_PRINTER (cups_printer);
+-
+- if (cups_backend->default_printer != NULL &&
+- strcmp (cups_backend->default_printer, gtk_printer_get_name (printer)) == 0)
+- gtk_printer_set_is_default (printer, TRUE);
+-
+-
+- gtk_print_backend_add_printer (backend, printer);
++ printer = cups_create_printer (cups_backend, info);
++ list_has_changed = TRUE;
+ }
+ else
+ g_object_ref (printer);
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0006-gtk3-Extract-Function-cups_create_printer.patch b/patches/0006-gtk3-Extract-Function-cups_create_printer.patch
new file mode 100644
index 0000000..5bd34d2
--- /dev/null
+++ b/patches/0006-gtk3-Extract-Function-cups_create_printer.patch
@@ -0,0 +1,238 @@
+From 722dbc499b97f4df9fabcee1b5e652b89e1af676 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 19 Feb 2012 13:29:11 -0800
+Subject: [PATCH 6/9] Extract Function cups_create_printer
+
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 201 ++++++++++++----------
+ 1 files changed, 107 insertions(+), 94 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index d57974e..6055b36 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -1887,6 +1887,108 @@ cups_printer_handle_attribute (GtkPrintBackendCups *cups_backend,
+ }
+
+ }
++
++static GtkPrinter*
++cups_create_printer (GtkPrintBackendCups *cups_backend,
++ PrinterSetupInfo *info)
++{
++ GtkPrinterCups *cups_printer;
++ GtkPrinter *printer;
++ char uri[HTTP_MAX_URI]; /* Printer URI */
++ char method[HTTP_MAX_URI]; /* Method/scheme name */
++ char username[HTTP_MAX_URI]; /* Username:password */
++ char hostname[HTTP_MAX_URI]; /* Hostname */
++ char resource[HTTP_MAX_URI]; /* Resource name */
++ int port; /* Port number */
++ char *cups_server; /* CUPS server */
++ GtkPrintBackend *backend = GTK_PRINT_BACKEND (cups_backend);
++
++#ifdef HAVE_COLORD
++ cups_printer = gtk_printer_cups_new (info->printer_name,
++ backend,
++ cups_backend->colord_client);
++#else
++ cups_printer = gtk_printer_cups_new (info->printer_name, backend, NULL);
++#endif
++
++ cups_printer->device_uri = g_strdup_printf ("/printers/%s",
++ info->printer_name);
++
++ /* Check to see if we are looking at a class */
++ if (info->member_uris)
++ {
++ cups_printer->printer_uri = g_strdup (info->member_uris);
++ /* TODO if member_uris is a class we need to recursivly find a printer */
++ GTK_NOTE (PRINTING,
++ g_print ("CUPS Backend: Found class with printer %s\n",
++ info->member_uris));
++ }
++ else
++ {
++ cups_printer->printer_uri = g_strdup (info->printer_uri);
++ GTK_NOTE (PRINTING,
++ g_print ("CUPS Backend: Found printer %s\n", info->printer_uri));
++ }
++
++#ifdef HAVE_CUPS_API_1_2
++ httpSeparateURI (HTTP_URI_CODING_ALL, cups_printer->printer_uri,
++ method, sizeof (method),
++ username, sizeof (username),
++ hostname, sizeof (hostname),
++ &port,
++ resource, sizeof (resource));
++
++#else
++ httpSeparate (cups_printer->printer_uri,
++ method,
++ username,
++ hostname,
++ &port,
++ resource);
++#endif
++
++ if (strncmp (resource, "/printers/", 10) == 0)
++ {
++ cups_printer->ppd_name = g_strdup (resource + 10);
++ GTK_NOTE (PRINTING,
++ g_print ("CUPS Backend: Setting ppd name '%s' for printer/class '%s'\n", cups_printer->ppd_name, info->printer_name));
++ }
++
++ gethostname (uri, sizeof (uri));
++ cups_server = g_strdup (cupsServer());
++
++ if (strcasecmp (uri, hostname) == 0)
++ strcpy (hostname, "localhost");
++
++ /* if the cups server is local and listening at a unix domain socket
++ * then use the socket connection
++ */
++ if ((strstr (hostname, "localhost") != NULL) &&
++ (cups_server[0] == '/'))
++ strcpy (hostname, cups_server);
++
++ g_free (cups_server);
++
++ cups_printer->default_cover_before = g_strdup (info->default_cover_before);
++ cups_printer->default_cover_after = g_strdup (info->default_cover_after);
++
++ cups_printer->hostname = g_strdup (hostname);
++ cups_printer->port = port;
++
++ cups_printer->auth_info_required = g_strdupv (info->auth_info_required);
++ g_strfreev (info->auth_info_required);
++
++ printer = GTK_PRINTER (cups_printer);
++
++ if (cups_backend->default_printer != NULL &&
++ strcmp (cups_backend->default_printer, gtk_printer_get_name (printer)) == 0)
++ gtk_printer_set_is_default (printer, TRUE);
++
++
++ gtk_print_backend_add_printer (backend, printer);
++ return printer;
++}
++
+ static void
+ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ GtkCupsResult *result,
+@@ -1941,7 +2043,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ GtkPrinter *printer;
+ gboolean status_changed = FALSE;
+ GList *node;
+- gint i,j;
++ gint i;
+ gchar *reason_msg_desc = NULL;
+ gchar *tmp_msg = NULL;
+ gchar *tmp_msg2 = NULL;
+@@ -2002,99 +2104,10 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ printer = gtk_print_backend_find_printer (backend, info->printer_name);
+ if (!printer)
+- {
+- GtkPrinterCups *cups_printer;
+- char uri[HTTP_MAX_URI]; /* Printer URI */
+- char method[HTTP_MAX_URI]; /* Method/scheme name */
+- char username[HTTP_MAX_URI]; /* Username:password */
+- char hostname[HTTP_MAX_URI]; /* Hostname */
+- char resource[HTTP_MAX_URI]; /* Resource name */
+- int port; /* Port number */
+- char *cups_server; /* CUPS server */
+-
+- list_has_changed = TRUE;
+-#ifdef HAVE_COLORD
+- cups_printer = gtk_printer_cups_new (printer_name,
+- backend,
+- cups_backend->colord_client);
+-#else
+- cups_printer = gtk_printer_cups_new (printer_name, backend, NULL);
+-#endif
+-
+- cups_printer->device_uri = g_strdup_printf ("/printers/%s", printer_name);
+-
+- /* Check to see if we are looking at a class */
+- if (member_uris)
+- {
+- cups_printer->printer_uri = g_strdup (member_uris);
+- /* TODO if member_uris is a class we need to recursivly find a printer */
+- GTK_NOTE (PRINTING,
+- g_print ("CUPS Backend: Found class with printer %s\n", member_uris));
+- }
+- else
+- {
+- cups_printer->printer_uri = g_strdup (printer_uri);
+- GTK_NOTE (PRINTING,
+- g_print ("CUPS Backend: Found printer %s\n", printer_uri));
+- }
+-
+-#if (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2) || CUPS_VERSION_MAJOR > 1
+- httpSeparateURI (HTTP_URI_CODING_ALL, cups_printer->printer_uri,
+- method, sizeof (method),
+- username, sizeof (username),
+- hostname, sizeof (hostname),
+- &port,
+- resource, sizeof (resource));
+-
+-#else
+- httpSeparate (cups_printer->printer_uri,
+- method,
+- username,
+- hostname,
+- &port,
+- resource);
+-#endif
+-
+- if (strncmp (resource, "/printers/", 10) == 0)
+- {
+- cups_printer->ppd_name = g_strdup (resource + 10);
+- GTK_NOTE (PRINTING,
+- g_print ("CUPS Backend: Setting ppd name '%s' for printer/class '%s'\n", cups_printer->ppd_name, printer_name));
+- }
+-
+- gethostname (uri, sizeof (uri));
+- cups_server = g_strdup (cupsServer());
+-
+- if (strcasecmp (uri, hostname) == 0)
+- strcpy (hostname, "localhost");
+-
+- /* if the cups server is local and listening at a unix domain socket
+- * then use the socket connection
+- */
+- if ((strstr (hostname, "localhost") != NULL) &&
+- (cups_server[0] == '/'))
+- strcpy (hostname, cups_server);
+-
+- g_free (cups_server);
+-
+- cups_printer->default_cover_before = g_strdup (default_cover_before);
+- cups_printer->default_cover_after = g_strdup (default_cover_after);
+-
+- cups_printer->hostname = g_strdup (hostname);
+- cups_printer->port = port;
+-
+- cups_printer->auth_info_required = g_strdupv (auth_info_required);
+- g_strfreev (auth_info_required);
+-
+- printer = GTK_PRINTER (cups_printer);
+-
+- if (cups_backend->default_printer != NULL &&
+- strcmp (cups_backend->default_printer, gtk_printer_get_name (printer)) == 0)
+- gtk_printer_set_is_default (printer, TRUE);
+-
+-
+- gtk_print_backend_add_printer (backend, printer);
+- }
++ {
++ printer = cups_create_printer (cups_backend, info);
++ list_has_changed = TRUE;
++ }
+ else
+ g_object_ref (printer);
+
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0007-gtk2-Move-some-variable-declarations-into-the-scopes-in-w.patch b/patches/0007-gtk2-Move-some-variable-declarations-into-the-scopes-in-w.patch
new file mode 100644
index 0000000..73423a3
--- /dev/null
+++ b/patches/0007-gtk2-Move-some-variable-declarations-into-the-scopes-in-w.patch
@@ -0,0 +1,98 @@
+From a9b8fbefb1a2285d30752ffa5bd481f9a175f16c Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 25 Feb 2012 17:52:46 -0800
+Subject: [PATCH 7/9] Move some variable declarations into the scopes in which
+ they're used.
+
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 39 +++++++++++----------
+ 1 files changed, 20 insertions(+), 19 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index e2d9192..a51f681 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -2025,12 +2025,8 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ gboolean status_changed = FALSE;
+ GList *node;
+ gint i;
+- gchar *reason_msg_desc = NULL;
+- gchar *tmp_msg = NULL;
+- gchar *tmp_msg2 = NULL;
+- gboolean found = FALSE;
+ PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo);
+-
++
+ /* Skip leading attributes until we hit a printer...
+ */
+ while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
+@@ -2126,23 +2122,30 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ if (info->state_msg != NULL && strlen (info->state_msg) == 0)
+ {
+- if (info->is_paused && !info->is_accepting_jobs)
+- /* Translators: this is a printer status. */
++ gchar *tmp_msg2 = NULL;
++ if (info->is_paused && !info->is_accepting_jobs)
++ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Paused ; Rejecting Jobs"));
+ if (info->is_paused && info->is_accepting_jobs)
+- /* Translators: this is a printer status. */
++ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Paused"));
+ if (!info->is_paused && !info->is_accepting_jobs)
+- /* Translators: this is a printer status. */
++ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Rejecting Jobs"));
+
+ if (tmp_msg2 != NULL)
+- info->state_msg = tmp_msg2;
+- }
++ {
++ info->state_msg = tmp_msg2;
++ g_free (tmp_msg2);
++ }
++ }
+
+ /* Set description of the reason and combine it with printer-state-message. */
+ if ( (info->reason_msg != NULL))
+ {
++ gchar *reason_msg_desc = NULL;
++ gboolean found = FALSE;
++
+ for (i = 0; i < G_N_ELEMENTS (printer_messages); i++)
+ {
+ if (strncmp (info->reason_msg, printer_messages[i],
+@@ -2164,23 +2167,21 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ info->state_msg = reason_msg_desc;
+ else
+ {
+- tmp_msg = g_strjoin (" ; ", info->state_msg, reason_msg_desc, NULL);
++ gchar *tmp_msg = NULL;
++ tmp_msg = g_strjoin (" ; ", info->state_msg,
++ reason_msg_desc, NULL);
+ info->state_msg = tmp_msg;
++ g_free (tmp_msg);
+ }
+ }
++ if (reason_msg_desc != NULL)
++ g_free (reason_msg_desc);
+ }
+
+ status_changed |= gtk_printer_set_state_message (printer, info->state_msg);
+ status_changed |= gtk_printer_set_is_accepting_jobs (printer, info->is_accepting_jobs);
+
+- if (tmp_msg != NULL)
+- g_free (tmp_msg);
+-
+- if (tmp_msg2 != NULL)
+- g_free (tmp_msg2);
+
+- if (reason_msg_desc != NULL)
+- g_free (reason_msg_desc);
+
+ /* Set printer icon according to importance
+ (none, report, warning, error - report is omitted). */
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0007-gtk3-Move-some-variable-declarations-into-the-scopes-in-w.patch b/patches/0007-gtk3-Move-some-variable-declarations-into-the-scopes-in-w.patch
new file mode 100644
index 0000000..07f9424
--- /dev/null
+++ b/patches/0007-gtk3-Move-some-variable-declarations-into-the-scopes-in-w.patch
@@ -0,0 +1,98 @@
+From 3c9483f6ef5ac72e25f1520231116f500fba035d Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 19 Feb 2012 13:45:17 -0800
+Subject: [PATCH 7/9] Move some variable declarations into the scopes in which
+ they're used.
+
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 39 +++++++++++----------
+ 1 files changed, 20 insertions(+), 19 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 6055b36..5d99dc0 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -2044,12 +2044,8 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ gboolean status_changed = FALSE;
+ GList *node;
+ gint i;
+- gchar *reason_msg_desc = NULL;
+- gchar *tmp_msg = NULL;
+- gchar *tmp_msg2 = NULL;
+- gboolean found = FALSE;
+ PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo);
+-
++
+ /* Skip leading attributes until we hit a printer...
+ */
+ while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
+@@ -2145,23 +2141,30 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ if (info->state_msg != NULL && strlen (info->state_msg) == 0)
+ {
+- if (info->is_paused && !info->is_accepting_jobs)
+- /* Translators: this is a printer status. */
++ gchar *tmp_msg2 = NULL;
++ if (info->is_paused && !info->is_accepting_jobs)
++ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Paused ; Rejecting Jobs"));
+ if (info->is_paused && info->is_accepting_jobs)
+- /* Translators: this is a printer status. */
++ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Paused"));
+ if (!info->is_paused && !info->is_accepting_jobs)
+- /* Translators: this is a printer status. */
++ /* Translators: this is a printer status. */
+ tmp_msg2 = g_strdup ( N_("Rejecting Jobs"));
+
+ if (tmp_msg2 != NULL)
+- info->state_msg = tmp_msg2;
+- }
++ {
++ info->state_msg = tmp_msg2;
++ g_free (tmp_msg2);
++ }
++ }
+
+ /* Set description of the reason and combine it with printer-state-message. */
+ if ( (info->reason_msg != NULL))
+ {
++ gchar *reason_msg_desc = NULL;
++ gboolean found = FALSE;
++
+ for (i = 0; i < G_N_ELEMENTS (printer_messages); i++)
+ {
+ if (strncmp (info->reason_msg, printer_messages[i],
+@@ -2183,23 +2186,21 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ info->state_msg = reason_msg_desc;
+ else
+ {
+- tmp_msg = g_strjoin (" ; ", info->state_msg, reason_msg_desc, NULL);
++ gchar *tmp_msg = NULL;
++ tmp_msg = g_strjoin (" ; ", info->state_msg,
++ reason_msg_desc, NULL);
+ info->state_msg = tmp_msg;
++ g_free (tmp_msg);
+ }
+ }
++ if (reason_msg_desc != NULL)
++ g_free (reason_msg_desc);
+ }
+
+ status_changed |= gtk_printer_set_state_message (printer, info->state_msg);
+ status_changed |= gtk_printer_set_is_accepting_jobs (printer, info->is_accepting_jobs);
+
+- if (tmp_msg != NULL)
+- g_free (tmp_msg);
+-
+- if (tmp_msg2 != NULL)
+- g_free (tmp_msg2);
+
+- if (reason_msg_desc != NULL)
+- g_free (reason_msg_desc);
+
+ /* Set printer icon according to importance
+ (none, report, warning, error - report is omitted). */
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0008-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch b/patches/0008-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch
new file mode 100644
index 0000000..b7990c4
--- /dev/null
+++ b/patches/0008-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch
@@ -0,0 +1,64 @@
+From 97cacfeb64cb4f36e3465cd8dcfc91afafd0b97c Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 25 Feb 2012 17:53:32 -0800
+Subject: [PATCH 8/9] [Bug 670373] modules/printing/cups/gtkprintbackendcups.c
+ won't build with CUPS 1.6
+
+ Having refactored cups_request_printer_list_cb so that the cups
+ version-dependent block size is small enough to be handled in a single
+ ifdef, make the ifdef HAVE_CUPS_API_1_6 block
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 24 +++++++++++++++++++++-
+ 1 files changed, 23 insertions(+), 1 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index a51f681..c7ee014 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -2018,7 +2018,29 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ removed_printer_checklist = gtk_print_backend_get_printer_list (backend);
+
+ response = gtk_cups_result_get_response (result);
++#ifdef HAVE_CUPS_API_1_6
++ for (attr = ippFirstAttribute (response); attr != NULL;
++ attr = ippNextAttribute (response))
++ {
++ GtkPrinter *printer;
++ gboolean status_changed = FALSE;
++ GList *node;
++ gint i;
++ PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo);
++
++ /* Skip leading attributes until we hit a printer...
++ */
++ while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
++ attr = ippNextAttribute (response);
+
++ if (attr == NULL)
++ break;
++ while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
++ {
++ cups_printer_handle_attribute (cups_backend, attr, info);
++ attr = ippNextAttribute (response);
++ }
++#else
+ for (attr = response->attrs; attr != NULL; attr = attr->next)
+ {
+ GtkPrinter *printer;
+@@ -2034,12 +2056,12 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ if (attr == NULL)
+ break;
+-
+ while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
+ {
+ cups_printer_handle_attribute (cups_backend, attr, info);
+ attr = attr->next;
+ }
++#endif
+
+ if (info->printer_name == NULL ||
+ (info->printer_uri == NULL && info->member_uris == NULL))
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0008-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch b/patches/0008-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch
new file mode 100644
index 0000000..58cddf5
--- /dev/null
+++ b/patches/0008-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch
@@ -0,0 +1,62 @@
+From aef6a55641986bdb574db57b536b2c71975c3c16 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 19 Feb 2012 13:48:19 -0800
+Subject: [PATCH 8/9] [Bug 670373] modules/printing/cups/gtkprintbackendcups.c
+ won't build with CUPS 1.6
+
+Having refactored cups_request_printer_list_cb so that the cups version-dependent block size is small enough to be handled in a single ifdef, make the ifdef HAVE_CUPS_API_1_6 block.
+---
+ modules/printbackends/cups/gtkprintbackendcups.c | 24 +++++++++++++++++++++-
+ 1 files changed, 23 insertions(+), 1 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
+index 5d99dc0..b56f85c 100644
+--- a/modules/printbackends/cups/gtkprintbackendcups.c
++++ b/modules/printbackends/cups/gtkprintbackendcups.c
+@@ -2037,7 +2037,29 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+ removed_printer_checklist = gtk_print_backend_get_printer_list (backend);
+
+ response = gtk_cups_result_get_response (result);
++#ifdef HAVE_CUPS_API_1_6
++ for (attr = ippFirstAttribute (response); attr != NULL;
++ attr = ippNextAttribute (response))
++ {
++ GtkPrinter *printer;
++ gboolean status_changed = FALSE;
++ GList *node;
++ gint i;
++ PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo);
++
++ /* Skip leading attributes until we hit a printer...
++ */
++ while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
++ attr = ippNextAttribute (response);
+
++ if (attr == NULL)
++ break;
++ while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
++ {
++ cups_printer_handle_attribute (cups_backend, attr, info);
++ attr = ippNextAttribute (response);
++ }
++#else
+ for (attr = response->attrs; attr != NULL; attr = attr->next)
+ {
+ GtkPrinter *printer;
+@@ -2053,12 +2075,12 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
+
+ if (attr == NULL)
+ break;
+-
+ while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
+ {
+ cups_printer_handle_attribute (cups_backend, attr, info);
+ attr = attr->next;
+ }
++#endif
+
+ if (info->printer_name == NULL ||
+ (info->printer_uri == NULL && info->member_uris == NULL))
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0009-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch b/patches/0009-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch
new file mode 100644
index 0000000..c0d9d03
--- /dev/null
+++ b/patches/0009-Bug-670373-gtk2-modules-printing-cups-gtkprintbackendcups.patch
@@ -0,0 +1,73 @@
+From 2d59385649cf916594fd802a4445525a3c6656b1 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 25 Feb 2012 17:54:10 -0800
+Subject: [PATCH 9/9] [Bug 670373] modules/printing/cups/gtkprintbackendcups.c
+ won't build with CUPS 1.6
+
+ Fix up accesses of ipp structures in gtkcupsutils.c
+---
+ modules/printbackends/cups/gtkcupsutils.c | 20 ++++++++++++++------
+ 1 files changed, 14 insertions(+), 6 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkcupsutils.c b/modules/printbackends/cups/gtkcupsutils.c
+index a1eb1a1..9fe79d1 100644
+--- a/modules/printbackends/cups/gtkcupsutils.c
++++ b/modules/printbackends/cups/gtkcupsutils.c
+@@ -83,6 +83,14 @@ static GtkCupsRequestStateFunc get_states[] = {
+ _get_read_data
+ };
+
++#ifndef HAVE_CUPS_API_1_6
++#define ippSetOperation(ipp_request, ipp_op_id) ipp_request->request.op.operation_id = ipp_op_id
++#define ippSetRequestId(ipp_request, ipp_rq_id) ipp_request->request.op.request_id = ipp_rq_id
++#define ippSetState(ipp_request, ipp_state) ipp_request->state = ipp_state
++#define ippGetString(attr, index, foo) attr->values[index].string.text
++#define ippGetCount(attr) attr->num_values
++#endif
++
+ static void
+ gtk_cups_result_set_error (GtkCupsResult *result,
+ GtkCupsErrorType error_type,
+@@ -165,8 +173,8 @@ gtk_cups_request_new_with_username (http_t *connection,
+ request->data_io = data_io;
+
+ request->ipp_request = ippNew ();
+- request->ipp_request->request.op.operation_id = operation_id;
+- request->ipp_request->request.op.request_id = 1;
++ ippSetOperation (request->ipp_request, operation_id);
++ ippSetRequestId (request->ipp_request, 1);
+
+ language = cupsLangDefault ();
+
+@@ -352,8 +360,8 @@ gtk_cups_request_ipp_get_string (GtkCupsRequest *request,
+ name,
+ tag);
+
+- if (attribute != NULL && attribute->values != NULL)
+- return attribute->values[0].string.text;
++ if (attribute != NULL && ippGetCount (attribute) > 0)
++ return ippGetString (attribute, 0, NULL);
+ else
+ return NULL;
+ }
+@@ -731,7 +739,7 @@ _post_send (GtkCupsRequest *request)
+ request->attempts = 0;
+
+ request->state = GTK_CUPS_POST_WRITE_REQUEST;
+- request->ipp_request->state = IPP_IDLE;
++ ippSetState (request->ipp_request, IPP_IDLE);
+ }
+
+ static void
+@@ -1223,7 +1231,7 @@ _get_send (GtkCupsRequest *request)
+ request->state = GTK_CUPS_GET_CHECK;
+ request->poll_state = GTK_CUPS_HTTP_READ;
+
+- request->ipp_request->state = IPP_IDLE;
++ ippSetState (request->ipp_request, IPP_IDLE);
+ }
+
+ static void
+--
+1.7.7.5 (Apple Git-28)
+
diff --git a/patches/0009-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch b/patches/0009-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch
new file mode 100644
index 0000000..e54899f
--- /dev/null
+++ b/patches/0009-Bug-670373-gtk3-modules-printing-cups-gtkprintbackendcups.patch
@@ -0,0 +1,73 @@
+From 2478a24b02db310c2db3e5abd3f48dc5ed21b1f1 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 19 Feb 2012 15:11:24 -0800
+Subject: [PATCH 9/9] [Bug 670373] modules/printing/cups/gtkprintbackendcups.c
+ won't build with CUPS 1.6
+
+Fix up accesses of ipp structures in gtkcupsutils.c
+---
+ modules/printbackends/cups/gtkcupsutils.c | 20 ++++++++++++++------
+ 1 files changed, 14 insertions(+), 6 deletions(-)
+
+diff --git a/modules/printbackends/cups/gtkcupsutils.c b/modules/printbackends/cups/gtkcupsutils.c
+index 39a743f..48b2a27 100644
+--- a/modules/printbackends/cups/gtkcupsutils.c
++++ b/modules/printbackends/cups/gtkcupsutils.c
+@@ -83,6 +83,14 @@ static GtkCupsRequestStateFunc get_states[] = {
+ _get_read_data
+ };
+
++#ifndef HAVE_CUPS_API_1_6
++#define ippSetOperation(ipp_request, ipp_op_id) ipp_request->request.op.operation_id = ipp_op_id
++#define ippSetRequestId(ipp_request, ipp_rq_id) ipp_request->request.op.request_id = ipp_rq_id
++#define ippSetState(ipp_request, ipp_state) ipp_request->state = ipp_state
++#define ippGetString(attr, index, foo) attr->values[index].string.text
++#define ippGetCount(attr) attr->num_values
++#endif
++
+ static void
+ gtk_cups_result_set_error (GtkCupsResult *result,
+ GtkCupsErrorType error_type,
+@@ -165,8 +173,8 @@ gtk_cups_request_new_with_username (http_t *connection,
+ request->data_io = data_io;
+
+ request->ipp_request = ippNew ();
+- request->ipp_request->request.op.operation_id = operation_id;
+- request->ipp_request->request.op.request_id = 1;
++ ippSetOperation (request->ipp_request, operation_id);
++ ippSetRequestId (request->ipp_request, 1);
+
+ language = cupsLangDefault ();
+
+@@ -355,8 +363,8 @@ gtk_cups_request_ipp_get_string (GtkCupsRequest *request,
+ name,
+ tag);
+
+- if (attribute != NULL && attribute->values != NULL)
+- return attribute->values[0].string.text;
++ if (attribute != NULL && ippGetCount (attribute) > 0)
++ return ippGetString (attribute, 0, NULL);
+ else
+ return NULL;
+ }
+@@ -734,7 +742,7 @@ _post_send (GtkCupsRequest *request)
+ request->attempts = 0;
+
+ request->state = GTK_CUPS_POST_WRITE_REQUEST;
+- request->ipp_request->state = IPP_IDLE;
++ ippSetState (request->ipp_request, IPP_IDLE);
+ }
+
+ static void
+@@ -1227,7 +1235,7 @@ _get_send (GtkCupsRequest *request)
+ request->state = GTK_CUPS_GET_CHECK;
+ request->poll_state = GTK_CUPS_HTTP_READ;
+
+- request->ipp_request->state = IPP_IDLE;
++ ippSetState (request->ipp_request, IPP_IDLE);
+ }
+
+ static void
+--
+1.7.7.5 (Apple Git-28)
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]