]> Pileus Git - ~andy/gtk/commitdiff
build: require cups >= 1.2
authorJavier Jardón <jjardon@gnome.org>
Fri, 16 Mar 2012 12:54:40 +0000 (12:54 +0000)
committerJavier Jardón <jjardon@gnome.org>
Mon, 19 Mar 2012 00:10:14 +0000 (00:10 +0000)
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=672182

configure.ac
modules/printbackends/cups/gtkcupsutils.c
modules/printbackends/cups/gtkcupsutils.h
modules/printbackends/cups/gtkprintbackendcups.c

index 2be9ae20f2a19e5be2640310b45785a8a4a5e601..742f6b156ea700c7ab93f434bb9992efe409356b 100644 (file)
@@ -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)
index 42254c0a4515bb7d9728bd42dc31534b54df9ede..e9cc9b648776a0f97a10ae5e6b1dd293e493adc1 100644 (file)
@@ -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);
 }
index 50701818bfef163be9414171250061aae9c95287..e49a5d3bc5f33989031992f7e7cc694236dd8f4f 100644 (file)
@@ -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
index bc1f30508c1fdd7f06ca2e7daba9293ae7ef80fa..f7081daef395572e14abbccbe5ab638dee743b46 100644 (file)
@@ -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,