Submitted By:            Armin K. <krejzi at email dot com>
Date:                    2012-08-15
Initial Package Version: 3.4.2
Upstream Status:         Fixed upstream
Origin:                  Upstream bugzilla
Description:             Fixes compiling with CUPS 1.6.0 and later

--- gnome-control-center.orig/panels/printers/cc-printers-panel.c	2012-04-10 17:01:29.000000000 +0200
+++ gnome-control-center/panels/printers/cc-printers-panel.c	2012-08-15 16:40:20.554617709 +0200
@@ -58,6 +58,16 @@
 
 #define CUPS_STATUS_CHECK_INTERVAL 5
 
+#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
+#define HAVE_CUPS_1_6 1
+#endif
+
+#ifndef HAVE_CUPS_1_6
+#define ippGetState(ipp) ipp->state
+#define ippGetStatusCode(ipp) ipp->request.status.status_code
+#define ippGetString(attr, element, language) attr->values[element].string.text
+#endif
+
 struct _CcPrintersPanelPrivate
 {
   GtkBuilder *builder;
@@ -311,7 +321,7 @@
 
           if (response)
             {
-              if (response->request.status.status_code <= IPP_OK_CONFLICT)
+              if (ippGetStatusCode (response) <= IPP_OK_CONFLICT)
                 {
                   ipp_attribute_t *attr_username = NULL;
                   ipp_attribute_t *attr_printer_uri = NULL;
@@ -319,12 +329,12 @@
                   attr_username = ippFindAttribute(response, "job-originating-user-name", IPP_TAG_NAME);
                   attr_printer_uri = ippFindAttribute(response, "job-printer-uri", IPP_TAG_URI);
                   if (attr_username && attr_printer_uri &&
-                      g_strcmp0 (attr_username->values[0].string.text, cupsUser ()) == 0 &&
-                      g_strrstr (attr_printer_uri->values[0].string.text, "/") != 0 &&
+                      g_strcmp0 (ippGetString (attr_username, 0, NULL), cupsUser ()) == 0 &&
+                      g_strrstr (ippGetString (attr_printer_uri, 0, NULL), "/") != 0 &&
                       priv->current_dest >= 0 &&
                       priv->current_dest < priv->num_dests &&
                       priv->dests != NULL &&
-                      g_strcmp0 (g_strrstr (attr_printer_uri->values[0].string.text, "/") + 1,
+                      g_strcmp0 (g_strrstr (ippGetString (attr_printer_uri, 0, NULL), "/") + 1,
                                  priv->dests[priv->current_dest].name) == 0)
                     actualize_jobs_list (self);
                 }
@@ -2288,7 +2298,7 @@
 
       if (response)
         {
-          if (response->state == IPP_ERROR)
+          if (ippGetState(response) == IPP_ERROR)
             g_warning ("An error has occured during printing of test page.");
           ippDelete (response);
         }
--- gnome-control-center.orig/panels/printers/pp-new-printer-dialog.c	2012-04-16 14:54:29.000000000 +0200
+++ gnome-control-center/panels/printers/pp-new-printer-dialog.c	2012-08-15 16:40:20.557617778 +0200
@@ -59,6 +59,14 @@
 
 #define ALLOWED_CHARACTERS "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
 
+#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
+#define HAVE_CUPS_1_6 1
+#endif
+
+#ifndef HAVE_CUPS_1_6
+#define ippGetState(ipp) ipp->state
+#endif
+
 static void pp_new_printer_dialog_hide (PpNewPrinterDialog *pp);
 static void actualize_devices_list (PpNewPrinterDialog *pp);
 
@@ -1760,7 +1768,7 @@
                                                           _("Automatic configuration"));
                   if (response)
                     {
-                      if (response->state == IPP_ERROR)
+                      if (ippGetState(response) == IPP_ERROR)
                         g_warning ("An error has occured during automatic configuration of new printer.");
                       ippDelete (response);
                     }
--- gnome-control-center.orig/panels/printers/pp-utils.c	2012-04-16 14:54:29.000000000 +0200
+++ gnome-control-center/panels/printers/pp-utils.c	2012-08-15 16:40:20.561617877 +0200
@@ -35,6 +35,37 @@
 #define SCP_PATH  "/org/fedoraproject/Config/Printing"
 #define SCP_IFACE "org.fedoraproject.Config.Printing"
 
+#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
+#define HAVE_CUPS_1_6 1
+#endif
+
+#ifndef HAVE_CUPS_1_6
+#define ippGetCount(attr)     attr->num_values
+#define ippGetGroupTag(attr)  attr->group_tag
+#define ippGetValueTag(attr)  attr->value_tag
+#define ippGetName(attr)      attr->name
+#define ippGetStatusCode(ipp) ipp->request.status.status_code
+#define ippGetInteger(attr, element) attr->values[element].integer
+#define ippGetString(attr, element, language) attr->values[element].string.text
+
+static ipp_attribute_t *
+ippFirstAttribute(ipp_t *ipp)
+{
+  if (!ipp)
+    return (NULL);
+  return (ipp->current = ipp->attrs);
+}
+
+static ipp_attribute_t *
+ippNextAttribute(ipp_t *ipp)
+{
+  if (!ipp || !ipp->current)
+    return (NULL);
+  return (ipp->current = ipp->current->next);
+}
+#endif
+
+
 gchar *
 get_tag_value (const gchar *tag_string, const gchar *tag_name)
 {
@@ -935,12 +966,12 @@
               response = cupsDoRequest (http, request, "/");
 
               if (response &&
-                  response->request.status.status_code <= IPP_OK_CONFLICT)
+                  ippGetStatusCode (response) <= IPP_OK_CONFLICT)
                 {
-                  for (attr = response->attrs; attr != NULL; attr = attr->next)
+                  for (attr = ippFirstAttribute (response); attr != NULL; attr = ippNextAttribute (response))
                     {
-                      while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
-                        attr = attr->next;
+                      while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
+                        attr = ippNextAttribute (response);
 
                       if (attr == NULL)
                         break;
@@ -950,22 +981,22 @@
                       ppd_name = NULL;
                       ppd_product = NULL;
 
-                      while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
+                      while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
                         {
-                          if (g_strcmp0 (attr->name, "ppd-device-id") == 0 &&
-                              attr->value_tag == IPP_TAG_TEXT)
-                            ppd_device_id = attr->values[0].string.text;
-                          else if (g_strcmp0 (attr->name, "ppd-make-and-model") == 0 &&
-                                   attr->value_tag == IPP_TAG_TEXT)
-                            ppd_make_and_model = attr->values[0].string.text;
-                          else if (g_strcmp0 (attr->name, "ppd-name") == 0 &&
-                                   attr->value_tag == IPP_TAG_NAME)
-                            ppd_name = attr->values[0].string.text;
-                          else if (g_strcmp0 (attr->name, "ppd-product") == 0 &&
-                                   attr->value_tag == IPP_TAG_TEXT)
-                            ppd_product = attr->values[0].string.text;
+                          if (g_strcmp0 (ippGetName (attr), "ppd-device-id") == 0 &&
+                              ippGetValueTag (attr) == IPP_TAG_TEXT)
+                            ppd_device_id = (gchar *) ippGetString (attr, 0, NULL);
+                          else if (g_strcmp0 (ippGetName (attr), "ppd-make-and-model") == 0 &&
+                                   ippGetValueTag (attr) == IPP_TAG_TEXT)
+                            ppd_make_and_model = ippGetString (attr, 0, NULL);
+                          else if (g_strcmp0 (ippGetName (attr), "ppd-name") == 0 &&
+                                   ippGetValueTag (attr) == IPP_TAG_NAME)
+                            ppd_name = ippGetString (attr, 0, NULL);
+                          else if (g_strcmp0 (ippGetName (attr), "ppd-product") == 0 &&
+                                   ippGetValueTag (attr) == IPP_TAG_TEXT)
+                            ppd_product = ippGetString (attr, 0, NULL);
 
-                          attr = attr->next;
+                          attr = ippNextAttribute (response);
                         }
 
                       if (ppd_device_id && ppd_name)
@@ -1009,15 +1040,15 @@
               response = cupsDoRequest (http, request, "/");
 
               if (response &&
-                  response->request.status.status_code <= IPP_OK_CONFLICT)
+                  ippGetStatusCode (response) <= IPP_OK_CONFLICT)
                 {
                   for (i = 0; equivalents && equivalents[i]; i++)
                     {
                       eq_normalized = normalize (equivalents[i]);
-                      for (attr = response->attrs; attr != NULL; attr = attr->next)
+                      for (attr = ippFirstAttribute (response); attr != NULL; attr = ippNextAttribute (response))
                         {
-                          while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
-                            attr = attr->next;
+                          while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
+                            attr = ippNextAttribute (response);
 
                           if (attr == NULL)
                             break;
@@ -1027,22 +1058,22 @@
                           ppd_name = NULL;
                           ppd_product = NULL;
 
-                          while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
+                          while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
                             {
-                              if (g_strcmp0 (attr->name, "ppd-device-id") == 0 &&
-                                  attr->value_tag == IPP_TAG_TEXT)
-                                ppd_device_id = attr->values[0].string.text;
-                              else if (g_strcmp0 (attr->name, "ppd-make-and-model") == 0 &&
-                                       attr->value_tag == IPP_TAG_TEXT)
-                                ppd_make_and_model = attr->values[0].string.text;
-                              else if (g_strcmp0 (attr->name, "ppd-name") == 0 &&
-                                       attr->value_tag == IPP_TAG_NAME)
-                                ppd_name = attr->values[0].string.text;
-                              else if (g_strcmp0 (attr->name, "ppd-product") == 0 &&
-                                       attr->value_tag == IPP_TAG_TEXT)
-                                ppd_product = attr->values[0].string.text;
+                              if (g_strcmp0 (ippGetName (attr), "ppd-device-id") == 0 &&
+                                  ippGetValueTag (attr) == IPP_TAG_TEXT)
+                                ppd_device_id = ippGetString (attr, 0, NULL);
+                              else if (g_strcmp0 (ippGetName (attr), "ppd-make-and-model") == 0 &&
+                                       ippGetValueTag (attr) == IPP_TAG_TEXT)
+                                ppd_make_and_model = ippGetString (attr, 0, NULL);
+                              else if (g_strcmp0 (ippGetName (attr), "ppd-name") == 0 &&
+                                       ippGetValueTag (attr) == IPP_TAG_NAME)
+                                ppd_name = ippGetString (attr, 0, NULL);
+                              else if (g_strcmp0 (ippGetName (attr), "ppd-product") == 0 &&
+                                       ippGetValueTag (attr) == IPP_TAG_TEXT)
+                                ppd_product = ippGetString (attr, 0, NULL);
 
-                              attr = attr->next;
+                              attr = ippNextAttribute (response);
                             }
 
                           if (ppd_device_id && ppd_name)
@@ -1352,23 +1383,23 @@
       ipp_attribute_t *attr = NULL;
       ipp_attribute_t *allowed = NULL;
 
-      for (attr = response->attrs; attr != NULL; attr = attr->next)
+      for (attr = ippFirstAttribute (response); attr != NULL; attr = ippNextAttribute (response))
         {
-          if (attr->group_tag == IPP_TAG_PRINTER &&
-              attr->value_tag == IPP_TAG_NAME &&
-              !g_strcmp0 (attr->name, "requesting-user-name-allowed"))
+          if (ippGetGroupTag (attr) == IPP_TAG_PRINTER &&
+              ippGetValueTag (attr) == IPP_TAG_NAME &&
+              !g_strcmp0 (ippGetName (attr), "requesting-user-name-allowed"))
             allowed = attr;
         }
 
-      if (allowed && allowed->num_values > 0)
+      if (allowed && ippGetCount (allowed) > 0)
         {
           int i;
 
-          num_allowed_users = allowed->num_values;
+          num_allowed_users = ippGetCount (allowed);
           users = g_new (gchar*, num_allowed_users);
 
           for (i = 0; i < num_allowed_users; i ++)
-            users[i] = g_strdup (allowed->values[i].string.text);
+            users[i] = g_strdup (ippGetString (allowed, i, NULL));
         }
       ippDelete(response);
     }
@@ -1454,12 +1485,12 @@
                     "notify-lease-duration", lease_duration);
       response = cupsDoRequest (http, request, "/");
       if (response != NULL &&
-          response->request.status.status_code <= IPP_OK_CONFLICT) {
+          ippGetStatusCode (response) <= IPP_OK_CONFLICT) {
         if ((attr = ippFindAttribute (response, "notify-lease-duration",
                                       IPP_TAG_INTEGER)) == NULL)
           g_debug ("No notify-lease-duration in response!\n");
         else
-          if (attr->values[0].integer == lease_duration)
+          if (ippGetInteger (attr, 0) == lease_duration)
             result = id;
       }
     }
@@ -1481,12 +1512,12 @@
       response = cupsDoRequest (http, request, "/");
 
       if (response != NULL &&
-          response->request.status.status_code <= IPP_OK_CONFLICT) {
+          ippGetStatusCode (response) <= IPP_OK_CONFLICT) {
         if ((attr = ippFindAttribute (response, "notify-subscription-id",
                                       IPP_TAG_INTEGER)) == NULL)
           g_debug ("No notify-subscription-id in response!\n");
         else
-          result = attr->values[0].integer;
+          result = ippGetInteger (attr, 0);
       }
     }
 
@@ -1655,38 +1686,38 @@
 
       if (response)
         {
-          if (response->request.status.status_code <= IPP_OK_CONFLICT)
+          if (ippGetStatusCode (response) <= IPP_OK_CONFLICT)
             {
               attr = ippFindAttribute (response, "printer-error-policy", IPP_TAG_NAME);
               if (attr)
-                error_policy = g_strdup (attr->values[0].string.text);
+                error_policy = g_strdup (ippGetString (attr, 0, NULL));
 
               attr = ippFindAttribute (response, "printer-op-policy", IPP_TAG_NAME);
               if (attr)
-                op_policy = g_strdup (attr->values[0].string.text);
+                op_policy = g_strdup (ippGetString (attr, 0, NULL));
 
               attr = ippFindAttribute (response, "requesting-user-name-allowed", IPP_TAG_NAME);
-              if (attr && attr->num_values > 0)
+              if (attr && ippGetCount (attr) > 0)
                 {
-                  users_allowed = g_new0 (gchar *, attr->num_values + 1);
-                  for (i = 0; i < attr->num_values; i++)
-                    users_allowed[i] = g_strdup (attr->values[i].string.text);
+                  users_allowed = g_new0 (gchar *, ippGetCount (attr) + 1);
+                  for (i = 0; i < ippGetCount (attr); i++)
+                    users_allowed[i] = g_strdup (ippGetString (attr, i, NULL));
                 }
 
               attr = ippFindAttribute (response, "requesting-user-name-denied", IPP_TAG_NAME);
-              if (attr && attr->num_values > 0)
+              if (attr && ippGetCount (attr) > 0)
                 {
-                  users_denied = g_new0 (gchar *, attr->num_values + 1);
-                  for (i = 0; i < attr->num_values; i++)
-                    users_denied[i] = g_strdup (attr->values[i].string.text);
+                  users_denied = g_new0 (gchar *, ippGetCount (attr) + 1);
+                  for (i = 0; i < ippGetCount (attr); i++)
+                    users_denied[i] = g_strdup (ippGetString (attr, i, NULL));
                 }
 
               attr = ippFindAttribute (response, "member-names", IPP_TAG_NAME);
-              if (attr && attr->num_values > 0)
+              if (attr && ippGetCount (attr) > 0)
                 {
-                  member_names = g_new0 (gchar *, attr->num_values + 1);
-                  for (i = 0; i < attr->num_values; i++)
-                    member_names[i] = g_strdup (attr->values[i].string.text);
+                  member_names = g_new0 (gchar *, ippGetCount (attr) + 1);
+                  for (i = 0; i < ippGetCount (attr); i++)
+                    member_names[i] = g_strdup (ippGetString (attr, i, NULL));
                 }
             }
           ippDelete (response);
