[gtk+/gtk-3-4] Bug 670373: modules/printing/cups/gtkprintbackendcups.c won't build with CUPS 1.6



commit 63b9487421674f8237ee6eb977d37378ea1ec513
Author: John Ralls <jralls ceridwen us>
Date:   Sun Feb 19 15:11:24 2012 -0800

    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 e9cc9b6..15132a8 100644
--- a/modules/printbackends/cups/gtkcupsutils.c
+++ b/modules/printbackends/cups/gtkcupsutils.c
@@ -81,6 +81,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,
@@ -163,8 +171,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 ();
 
@@ -353,8 +361,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;
 }
@@ -732,7 +740,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 
@@ -1221,7 +1229,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 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]