[gtk+] build: require cups >= 1.2



commit 80d54b45338fbf08f719efdaae08edc31bb89a73
Author: Javier JardÃn <jjardon gnome org>
Date:   Fri Mar 16 12:54:40 2012 +0000

    build: require cups >= 1.2
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=672182

 configure.ac                                     |    5 +--
 modules/printbackends/cups/gtkcupsutils.c        |   22 -----------
 modules/printbackends/cups/gtkcupsutils.h        |    2 -
 modules/printbackends/cups/gtkprintbackendcups.c |   42 ----------------------
 4 files changed, 2 insertions(+), 69 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2be9ae2..742f6b1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1388,9 +1388,8 @@ else
     CUPS_API_MINOR=`echo $ECHO_N $CUPS_API_VERSION | awk -F. '{print $2}'`
 
     if test $CUPS_API_MAJOR -gt 1 -o \
-            $CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -ge 2; then
-      AC_DEFINE(HAVE_CUPS_API_1_2, 1,
-                [Define to 1 if CUPS 1.2 API is available])
+            $CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -lt 2; then
+      AC_MSG_ERROR([CUPS >= 1.2 not found])
     fi
 
     AC_SUBST(CUPS_API_MAJOR)
diff --git a/modules/printbackends/cups/gtkcupsutils.c b/modules/printbackends/cups/gtkcupsutils.c
index 42254c0..e9cc9b6 100644
--- a/modules/printbackends/cups/gtkcupsutils.c
+++ b/modules/printbackends/cups/gtkcupsutils.c
@@ -834,11 +834,7 @@ _post_write_data (GtkCupsRequest *request)
         }
 
 
-#if HAVE_CUPS_API_1_2
       if (httpWrite2 (request->http, buffer, bytes) < bytes)
-#else
-      if (httpWrite (request->http, buffer, (int) bytes) < bytes)
-#endif /* HAVE_CUPS_API_1_2 */
         {
           int http_errno;
 
@@ -1412,11 +1408,7 @@ _get_read_data (GtkCupsRequest *request)
 
   request->poll_state = GTK_CUPS_HTTP_READ;
 
-#if HAVE_CUPS_API_1_2
   bytes = httpRead2 (request->http, buffer, sizeof (buffer));
-#else
-  bytes = httpRead (request->http, buffer, sizeof (buffer));
-#endif /* HAVE_CUPS_API_1_2 */
   request->bytes_received += bytes;
 
   GTK_NOTE (PRINTING,
@@ -1443,11 +1435,7 @@ _get_read_data (GtkCupsRequest *request)
     }
 
   /* Stop if we do not expect any more data or EOF was received. */
-#if HAVE_CUPS_API_1_2
   if (httpGetLength2 (request->http) <= request->bytes_received || bytes == 0)
-#else
-  if (httpGetLength (request->http) <= request->bytes_received || bytes == 0)
-#endif /* HAVE_CUPS_API_1_2 */
     {
       request->state = GTK_CUPS_GET_DONE;
       request->poll_state = GTK_CUPS_HTTP_IDLE;
@@ -1505,7 +1493,6 @@ GtkCupsConnectionTest *
 gtk_cups_connection_test_new (const char *server)
 {
   GtkCupsConnectionTest *result = NULL;
-#ifdef HAVE_CUPS_API_1_2
   gchar                 *port_str = NULL;
 
   result = g_new (GtkCupsConnectionTest, 1);
@@ -1525,9 +1512,6 @@ gtk_cups_connection_test_new (const char *server)
   result->at_init = GTK_CUPS_CONNECTION_NOT_AVAILABLE;
 
   result->at_init = gtk_cups_connection_test_get_state (result);
-#else
-  result = g_new (GtkCupsConnectionTest, 1);
-#endif
 
   return result;
 }
@@ -1541,7 +1525,6 @@ gtk_cups_connection_test_new (const char *server)
 GtkCupsConnectionState 
 gtk_cups_connection_test_get_state (GtkCupsConnectionTest *test)
 {
-#ifdef HAVE_CUPS_API_1_2
   GtkCupsConnectionState result = GTK_CUPS_CONNECTION_NOT_AVAILABLE;
   http_addrlist_t       *iter;
   gint                   error_code;
@@ -1622,9 +1605,6 @@ gtk_cups_connection_test_get_state (GtkCupsConnectionTest *test)
 
       return result;
     }
-#else
-  return GTK_CUPS_CONNECTION_AVAILABLE;
-#endif
 }
 
 /* This function frees memory used by the GtkCupsConnectionTest structure.
@@ -1635,7 +1615,6 @@ gtk_cups_connection_test_free (GtkCupsConnectionTest *test)
   if (test == NULL)
     return;
 
-#ifdef HAVE_CUPS_API_1_2
   test->current_addr = NULL;
   test->last_wrong_addr = NULL;
   httpAddrFreeList (test->addrlist);
@@ -1644,6 +1623,5 @@ gtk_cups_connection_test_free (GtkCupsConnectionTest *test)
       close (test->socket);
       test->socket = -1;
     }
-#endif
   g_free (test);
 }
diff --git a/modules/printbackends/cups/gtkcupsutils.h b/modules/printbackends/cups/gtkcupsutils.h
index 5070181..e49a5d3 100644
--- a/modules/printbackends/cups/gtkcupsutils.h
+++ b/modules/printbackends/cups/gtkcupsutils.h
@@ -106,13 +106,11 @@ struct _GtkCupsRequest
 
 struct _GtkCupsConnectionTest
 {
-#ifdef HAVE_CUPS_API_1_2
   GtkCupsConnectionState at_init;
   http_addrlist_t       *addrlist;
   http_addrlist_t       *current_addr;
   http_addrlist_t       *last_wrong_addr;
   gint                   socket;
-#endif
 };
 
 #define GTK_CUPS_REQUEST_START 0
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index bc1f305..f7081da 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -733,40 +733,6 @@ is_address_local (const gchar *address)
     return FALSE;
 }
 
-#ifndef HAVE_CUPS_API_1_2
-/* Included from CUPS library because of backward compatibility */
-const char *
-httpGetHostname(http_t *http,
-                char   *s,
-                int    slen)
-{
-  struct hostent *host;
-
-  if (!s || slen <= 1)
-    return (NULL);
-
-  if (http)
-    {
-      if (http->hostname[0] == '/')
-        g_strlcpy (s, "localhost", slen);
-      else
-        g_strlcpy (s, http->hostname, slen);
-    }
-  else
-    {
-      if (gethostname (s, slen) < 0)
-        g_strlcpy (s, "localhost", slen);
-
-      if (!strchr (s, '.'))
-        {
-          if ((host = gethostbyname (s)) != NULL && host->h_name)
-            g_strlcpy (s, host->h_name, slen);
-        }
-    }
-  return (s);
-}
-#endif
-
 static void
 gtk_print_backend_cups_set_password (GtkPrintBackend  *backend,
                                      gchar           **auth_info_required,
@@ -1002,11 +968,7 @@ cups_dispatch_add_poll (GSource *source)
 	  else
 	    dispatch->data_poll->events = 0;
 
-#ifdef HAVE_CUPS_API_1_2
           dispatch->data_poll->fd = httpGetFd (dispatch->request->http);
-#else
-          dispatch->data_poll->fd = dispatch->request->http->fd;
-#endif
           g_source_add_poll (source, dispatch->data_poll);
         }
     }
@@ -3300,9 +3262,7 @@ create_pickone_option (ppd_file_t   *ppd_file,
   char *label;
   int n_choices;
   int i;
-#ifdef HAVE_CUPS_API_1_2
   ppd_coption_t *coption;
-#endif
 
   g_assert (ppd_option->ui == PPD_UI_PICKONE);
   
@@ -3318,7 +3278,6 @@ create_pickone_option (ppd_file_t   *ppd_file,
 
       label = get_option_text (ppd_file, ppd_option);
 
-#ifdef HAVE_CUPS_API_1_2
       coption = ppdFindCustomOption (ppd_file, ppd_option->keyword);
 
       if (coption)
@@ -3371,7 +3330,6 @@ create_pickone_option (ppd_file_t   *ppd_file,
 	    g_warning ("CUPS Backend: Multi-parameter PPD Custom Option not supported");
 #endif
 	}
-#endif /* HAVE_CUPS_API_1_2 */
 
       if (!option)
         option = gtk_printer_option_new (gtk_name, label,



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