...
 
Commits (4)
  • Emmanuele Bassi's avatar
    Detect CUPS ≥ 1.7 · 91cc9b58
    Emmanuele Bassi authored
    We support CUPS ≥ 1.2, but we use API that was introduced and deprecated
    at a later point.
    91cc9b58
  • Emmanuele Bassi's avatar
    cups: Use non-deprecated API · 9236ee05
    Emmanuele Bassi authored
    The http* family of functions was deprecated after CUPS 1.7. We can
    conditionally use it when built against a newer version of CUPS. The
    additional parameters are taken directly from the fallback values
    inside CUPS itself.
    9236ee05
  • Emmanuele Bassi's avatar
    Require CUPS >= 2.0 · a7e207ab
    Emmanuele Bassi authored
    Drop support for versions of CUPS < 2.0, to simplify the backend code
    and drop a lot of conditional blocks.
    a7e207ab
  • Marek Kašík's avatar
    Require CUPS >= 2.0 in configure.ac · 4e804ff4
    Marek Kašík authored
    Require CUPS 2.0 and newer to simplify code.
    This removes all ifdefs dependent on CUPS version.
    4e804ff4
......@@ -23,9 +23,6 @@
/* Define to 1 if you have the <crt_externs.h> header file. */
#mesondefine HAVE_CRT_EXTERNS_H
/* Define to 1 if CUPS 1.6 API is available */
#mesondefine HAVE_CUPS_API_1_6
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
#mesondefine HAVE_DCGETTEXT
......
......@@ -29,9 +29,6 @@
/* Define to 1 if you have the <crt_externs.h> header file. */
/* #undef HAVE_CRT_EXTERNS_H */
/* Define to 1 if CUPS 1.2 API is available */
/* #undef HAVE_CUPS_API_1_2 */
/* Define to 1 if you have the `dcgettext' function. */
#define HAVE_DCGETTEXT 1
......
......@@ -1534,15 +1534,8 @@ else
CUPS_API_MAJOR=`echo $ECHO_N $CUPS_API_VERSION | awk -F. '{print $1}'`
CUPS_API_MINOR=`echo $ECHO_N $CUPS_API_VERSION | awk -F. '{print $2}'`
if test $CUPS_API_MAJOR -lt 1 -o \
$CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -lt 2; then
AC_MSG_ERROR([CUPS >= 1.2 not found])
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])
have_cups_api_1_6=yes
if test $CUPS_API_MAJOR -lt 2; then
AC_MSG_ERROR([CUPS >= 2.0 not found])
fi
AC_SUBST(CUPS_API_MAJOR)
......
......@@ -81,28 +81,6 @@ 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
int
ippSetVersion (ipp_t *ipp,
int major,
int minor)
{
if (!ipp || major < 0 || minor < 0)
return 0;
ipp->request.any.version[0] = major;
ipp->request.any.version[1] = minor;
return 1;
}
#endif
static void
gtk_cups_result_set_error (GtkCupsResult *result,
GtkCupsErrorType error_type,
......@@ -168,10 +146,10 @@ gtk_cups_request_new_with_username (http_t *connection,
}
else
{
request->http = NULL;
request->http = httpConnectEncrypt (request->server,
ippPort (),
cupsEncryption ());
request->http = httpConnect2 (request->server, ippPort (),
NULL, AF_UNSPEC,
cupsEncryption (),
1, 30000, NULL);
if (request->http)
httpBlocking (request->http, 0);
......@@ -686,10 +664,10 @@ _connect (GtkCupsRequest *request)
if (request->http == NULL)
{
request->http = httpConnectEncrypt (request->server,
ippPort (),
cupsEncryption ());
request->http = httpConnect2 (request->server, ippPort (),
NULL, AF_UNSPEC,
cupsEncryption (),
1, 30000, NULL);
if (request->http == NULL)
request->attempts++;
......@@ -741,7 +719,11 @@ _post_send (GtkCupsRequest *request)
if (httpPost (request->http, request->resource))
{
if (httpReconnect (request->http))
int res;
res = httpReconnect2 (request->http, 30000, NULL);
if (res)
{
request->state = GTK_CUPS_POST_DONE;
request->poll_state = GTK_CUPS_HTTP_IDLE;
......@@ -1039,7 +1021,7 @@ _post_check (GtkCupsRequest *request)
}
if (auth_result ||
httpReconnect (request->http))
httpReconnect2 (request->http, 30000, NULL))
{
/* if the password has been used, reset password_state
* so that we ask for a new one next time around
......@@ -1098,7 +1080,7 @@ _post_check (GtkCupsRequest *request)
request->state = GTK_CUPS_POST_CONNECT;
/* Reconnect... */
httpReconnect (request->http);
httpReconnect2 (request->http, 30000, NULL);
/* Upgrade with encryption... */
httpEncryption (request->http, HTTP_ENCRYPT_REQUIRED);
......@@ -1226,7 +1208,10 @@ _get_send (GtkCupsRequest *request)
if (httpGet (request->http, request->resource))
{
if (httpReconnect (request->http))
int reconnect;
reconnect = httpReconnect2 (request->http, 30000, NULL);
if (reconnect)
{
request->state = GTK_CUPS_GET_DONE;
request->poll_state = GTK_CUPS_HTTP_IDLE;
......@@ -1335,7 +1320,7 @@ _get_check (GtkCupsRequest *request)
}
if (auth_result ||
httpReconnect (request->http))
httpReconnect2 (request->http, 30000, NULL))
{
/* if the password has been used, reset password_state
* so that we ask for a new one next time around
......@@ -1367,7 +1352,7 @@ _get_check (GtkCupsRequest *request)
request->state = GTK_CUPS_GET_CONNECT;
/* Reconnect... */
httpReconnect (request->http);
httpReconnect2 (request->http, 30000, NULL);
/* Upgrade with encryption... */
httpEncryption (request->http, HTTP_ENCRYPT_REQUIRED);
......
......@@ -24,13 +24,12 @@
#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
#define _PPD_DEPRECATED
#include <cups/cups.h>
#include <cups/language.h>
......@@ -71,7 +70,6 @@ typedef struct _GtkPrintBackendCupsClass GtkPrintBackendCupsClass;
#define _CUPS_MAX_ATTEMPTS 10
#define _CUPS_MAX_CHUNK_SIZE 8192
#ifdef HAVE_CUPS_API_1_6
#define AVAHI_IF_UNSPEC -1
#define AVAHI_PROTO_INET 0
#define AVAHI_PROTO_INET6 1
......@@ -81,7 +79,6 @@ typedef struct _GtkPrintBackendCupsClass GtkPrintBackendCupsClass;
#define AVAHI_SERVER_IFACE "org.freedesktop.Avahi.Server"
#define AVAHI_SERVICE_BROWSER_IFACE "org.freedesktop.Avahi.ServiceBrowser"
#define AVAHI_SERVICE_RESOLVER_IFACE "org.freedesktop.Avahi.ServiceResolver"
#endif
/* define this to see warnings about ignored ppd options */
#undef PRINT_IGNORED_OPTIONS
......@@ -145,14 +142,14 @@ struct _GtkPrintBackendCups
#ifdef HAVE_COLORD
CdClient *colord_client;
#endif
#ifdef HAVE_CUPS_API_1_6
GDBusConnection *dbus_connection;
gchar *avahi_default_printer;
guint avahi_service_browser_subscription_id;
guint avahi_service_browser_subscription_ids[2];
gchar *avahi_service_browser_paths[2];
GCancellable *avahi_cancellable;
#endif
char *avahi_default_printer;
guint avahi_service_browser_subscription_id;
guint avahi_service_browser_subscription_ids[2];
char *avahi_service_browser_paths[2];
GCancellable *avahi_cancellable;
gboolean secrets_service_available;
guint secrets_service_watch_id;
GCancellable *secrets_service_cancellable;
......@@ -230,9 +227,7 @@ static gboolean is_address_local (const gchar
static gboolean request_auth_info (gpointer data);
static void lookup_auth_info (gpointer data);
#ifdef HAVE_CUPS_API_1_6
static void avahi_request_printer_list (GtkPrintBackendCups *cups_backend);
#endif
static void secrets_service_appeared_cb (GDBusConnection *connection,
const gchar *name,
......@@ -285,50 +280,6 @@ 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
#define ippGetCollection(attr, index) attr->values[index].collection
static int
ippGetRange (ipp_attribute_t *attr,
int element,
int *upper)
{
*upper = attr->values[element].range.upper;
return (attr->values[element].range.lower);
}
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
/*
* GtkPrintBackendCups
*/
......@@ -753,10 +704,13 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
cups_printer = GTK_PRINTER_CUPS (gtk_print_job_get_printer (job));
settings = gtk_print_job_get_settings (job);
#ifdef HAVE_CUPS_API_1_6
if (cups_printer->avahi_browsed)
{
http = httpConnect (cups_printer->hostname, cups_printer->port);
http = httpConnect2 (cups_printer->hostname, cups_printer->port,
NULL, AF_UNSPEC,
HTTP_ENCRYPTION_IF_REQUESTED,
1, 30000,
NULL);
if (http)
{
request = gtk_cups_request_new_with_username (http,
......@@ -795,7 +749,6 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
}
}
else
#endif
{
request = gtk_cups_request_new_with_username (NULL,
GTK_CUPS_POST,
......@@ -905,9 +858,7 @@ void overwrite_and_free (gpointer data)
static void
gtk_print_backend_cups_init (GtkPrintBackendCups *backend_cups)
{
#ifdef HAVE_CUPS_API_1_6
gint i;
#endif
int i;
backend_cups->list_printers_poll = FALSE;
backend_cups->got_default_printer = FALSE;
......@@ -928,7 +879,6 @@ gtk_print_backend_cups_init (GtkPrintBackendCups *backend_cups)
backend_cups->colord_client = cd_client_new ();
#endif
#ifdef HAVE_CUPS_API_1_6
backend_cups->dbus_connection = NULL;
backend_cups->avahi_default_printer = NULL;
backend_cups->avahi_service_browser_subscription_id = 0;
......@@ -937,7 +887,6 @@ gtk_print_backend_cups_init (GtkPrintBackendCups *backend_cups)
backend_cups->avahi_service_browser_paths[i] = NULL;
backend_cups->avahi_service_browser_subscription_ids[i] = 0;
}
#endif
cups_get_local_default_printer (backend_cups);
......@@ -973,11 +922,9 @@ gtk_print_backend_cups_finalize (GObject *object)
g_object_unref (backend_cups->colord_client);
#endif
#ifdef HAVE_CUPS_API_1_6
g_clear_object (&backend_cups->avahi_cancellable);
g_clear_pointer (&backend_cups->avahi_default_printer, g_free);
g_clear_object (&backend_cups->dbus_connection);
#endif
g_clear_object (&backend_cups->secrets_service_cancellable);
if (backend_cups->secrets_service_watch_id != 0)
......@@ -992,9 +939,7 @@ static void
gtk_print_backend_cups_dispose (GObject *object)
{
GtkPrintBackendCups *backend_cups;
#ifdef HAVE_CUPS_API_1_6
gint i;
#endif
int i;
GTK_NOTE (PRINTING,
g_print ("CUPS Backend: %s\n", G_STRFUNC));
......@@ -1010,7 +955,6 @@ gtk_print_backend_cups_dispose (GObject *object)
g_source_remove (backend_cups->default_printer_poll);
backend_cups->default_printer_poll = 0;
#ifdef HAVE_CUPS_API_1_6
g_cancellable_cancel (backend_cups->avahi_cancellable);
for (i = 0; i < 2; i++)
......@@ -1046,7 +990,6 @@ gtk_print_backend_cups_dispose (GObject *object)
backend_cups->avahi_service_browser_subscription_id);
backend_cups->avahi_service_browser_subscription_id = 0;
}
#endif
backend_parent_class->dispose (object);
}
......@@ -1802,18 +1745,8 @@ cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
state = 0;
#ifdef HAVE_CUPS_API_1_6
attr = ippFindAttribute (response, "job-state", IPP_TAG_ENUM);
state = ippGetInteger (attr, 0);
#else
for (attr = response->attrs; attr != NULL; attr = attr->next)
{
if (!attr->name)
continue;
_CUPS_MAP_ATTR_INT (attr, state, "job-state");
}
#endif
done = FALSE;
switch (state)
......@@ -2052,9 +1985,7 @@ typedef struct
gboolean default_printer;
gboolean got_printer_type;
gboolean remote_printer;
#ifdef HAVE_CUPS_API_1_6
gboolean avahi_printer;
#endif
gchar **auth_info_required;
gint default_number_up;
guchar ipp_version_major;
......@@ -2485,13 +2416,11 @@ cups_create_printer (GtkPrintBackendCups *cups_backend,
char *cups_server; /* CUPS server */
#ifdef HAVE_COLORD
#ifdef HAVE_CUPS_API_1_6
if (info->avahi_printer)
cups_printer = gtk_printer_cups_new (info->printer_name,
backend,
NULL);
else
#endif
cups_printer = gtk_printer_cups_new (info->printer_name,
backend,
cups_backend->colord_client);
......@@ -2567,9 +2496,7 @@ cups_create_printer (GtkPrintBackendCups *cups_backend,
strcmp (cups_backend->default_printer, gtk_printer_get_name (printer)) == 0)
gtk_printer_set_is_default (printer, TRUE);
#ifdef HAVE_CUPS_API_1_6
cups_printer->avahi_browsed = info->avahi_printer;
#endif
gtk_print_backend_add_printer (backend, printer);
return printer;
......@@ -2748,7 +2675,6 @@ set_default_printer (GtkPrintBackendCups *cups_backend,
}
}
#ifdef HAVE_CUPS_API_1_6
static void
cups_request_printer_info_cb (GtkPrintBackendCups *cups_backend,
GtkCupsResult *result,
......@@ -2875,7 +2801,7 @@ cups_request_printer_info (const gchar *printer_uri,
GtkCupsRequest *request;
http_t *http;
http = httpConnect (host, port);
http = httpConnect2 (host, port, NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL);
if (http)
{
request = gtk_cups_request_new_with_username (http,
......@@ -2943,9 +2869,7 @@ find_printer_by_uuid (GtkPrintBackendCups *backend,
printer_uuid += 5;
printer_uuid = g_strndup (printer_uuid, 36);
#if GLIB_CHECK_VERSION(2, 52, 0)
if (g_uuid_string_is_valid (printer_uuid))
#endif
{
if (g_strcmp0 (printer_uuid, UUID) == 0)
{
......@@ -3518,7 +3442,6 @@ avahi_request_printer_list (GtkPrintBackendCups *cups_backend)
cups_backend->avahi_cancellable = g_cancellable_new ();
g_bus_get (G_BUS_TYPE_SYSTEM, cups_backend->avahi_cancellable, avahi_create_browsers, cups_backend);
}
#endif
static void
cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
......@@ -3569,7 +3492,6 @@ 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))
{
......@@ -3585,42 +3507,21 @@ 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 = ippNextAttribute (response);
}
#else
for (attr = response->attrs; attr != NULL; attr = attr->next)
{
GtkPrinter *printer;
gboolean status_changed = FALSE;
GList *node;
PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo);
info->default_number_up = 1;
/* Skip leading attributes until we hit a printer...
*/
while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
attr = attr->next;
if (attr == NULL)
break;
while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
{
cups_printer_handle_attribute (cups_backend, attr, info);
attr = attr->next;
}
#endif
{
cups_printer_handle_attribute (cups_backend, attr, info);
attr = ippNextAttribute (response);
}
if (info->printer_name == NULL ||
(info->printer_uri == NULL && info->member_uris == NULL))
{
if (attr == NULL)
break;
else
continue;
}
{
if (attr == NULL)
break;
else
continue;
}
if (info->got_printer_type)
{
......@@ -3718,9 +3619,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
{
for (iter = removed_printer_checklist; iter; iter = iter->next)
{
#ifdef HAVE_CUPS_API_1_6
if (!GTK_PRINTER_CUPS (iter->data)->avahi_browsed)
#endif
{
mark_printer_inactive (GTK_PRINTER (iter->data), backend);
list_has_changed = TRUE;
......@@ -3742,12 +3641,8 @@ done:
g_free (remote_default_printer);
}
#ifdef HAVE_CUPS_API_1_6
if (!cups_backend->got_default_printer && cups_backend->avahi_default_printer != NULL)
{
set_default_printer (cups_backend, cups_backend->avahi_default_printer);
}
#endif
set_default_printer (cups_backend, cups_backend->avahi_default_printer);
gdk_threads_leave ();
}
......@@ -3842,9 +3737,7 @@ cups_get_printer_list (GtkPrintBackend *backend)
g_source_set_name_by_id (cups_backend->list_printers_poll, "[gtk+] cups_request_printer_list");
}
#ifdef HAVE_CUPS_API_1_6
avahi_request_printer_list (cups_backend);
#endif
}
}
......@@ -3882,26 +3775,6 @@ cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
GTK_PRINTER_CUPS (printer)->reading_ppd = FALSE;
print_backend->reading_ppds--;
#ifndef HAVE_CUPS_API_1_6
if (gtk_cups_result_is_error (result))
{
gboolean success = FALSE;
/* If we get a 404 then it is just a raw printer without a ppd
and not an error. */
if ((gtk_cups_result_get_error_type (result) == GTK_CUPS_ERROR_HTTP) &&
(gtk_cups_result_get_error_status (result) == HTTP_NOT_FOUND))
{
gtk_printer_set_has_details (printer, TRUE);
success = TRUE;
}
g_signal_emit_by_name (printer, "details-acquired", success);
goto done;
}
#endif
if (!gtk_cups_result_is_error (result))
{
/* let ppdOpenFd take over the ownership of the open file */
......@@ -3911,7 +3784,6 @@ cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
ppdMarkDefaults (data->printer->ppd_file);
}
#ifdef HAVE_CUPS_API_1_6
fstat (g_io_channel_unix_get_fd (data->ppd_io), &data_info);
/*
* Standalone Avahi printers and raw printers don't have PPD files or have
......@@ -3931,7 +3803,6 @@ cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
goto done;
}
#endif
gtk_printer_set_has_details (printer, TRUE);
g_signal_emit_by_name (printer, "details-acquired", TRUE);
......@@ -3960,11 +3831,7 @@ cups_request_ppd (GtkPrinter *printer)
GTK_NOTE (PRINTING,
g_print ("CUPS Backend: %s\n", G_STRFUNC));
if (cups_printer->remote
#ifdef HAVE_CUPS_API_1_6
&& !cups_printer->avahi_browsed
#endif
)
if (cups_printer->remote && !cups_printer->avahi_browsed)
{
GtkCupsConnectionState state;
......@@ -4000,9 +3867,10 @@ cups_request_ppd (GtkPrinter *printer)
}
}
http = httpConnectEncrypt (cups_printer->hostname,
cups_printer->port,
cupsEncryption ());
http = httpConnect2 (cups_printer->hostname, cups_printer->port,
NULL, AF_UNSPEC,
cupsEncryption (),
1, 30000, NULL);
data = g_new0 (GetPPDData, 1);
......@@ -4310,13 +4178,14 @@ 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 (ippGetString (attr, 0, NULL));
print_backend->default_printer = g_strdup (ippGetString (attr, 0, NULL));
print_backend->got_default_printer = TRUE;
if (print_backend->default_printer != NULL)
{
printer = gtk_print_backend_find_printer (GTK_PRINT_BACKEND (print_backend), print_backend->default_printer);
printer = gtk_print_backend_find_printer (GTK_PRINT_BACKEND (print_backend),
print_backend->default_printer);
if (printer != NULL)
{
gtk_printer_set_is_default (printer, TRUE);
......@@ -4371,11 +4240,7 @@ cups_printer_request_details (GtkPrinter *printer)
if (!cups_printer->reading_ppd &&
gtk_printer_cups_get_ppd (cups_printer) == NULL)
{
if (cups_printer->remote
#ifdef HAVE_CUPS_API_1_6
&& !cups_printer->avahi_browsed
#endif
)
if (cups_printer->remote && !cups_printer->avahi_browsed)
{
if (cups_printer->get_remote_ppd_poll == 0)
{
......
......@@ -115,12 +115,10 @@ gtk_printer_cups_init (GtkPrinterCups *printer)
printer->remote_cups_connection_test = NULL;
printer->auth_info_required = NULL;
printer->default_number_up = 1;
#ifdef HAVE_CUPS_API_1_6
printer->avahi_browsed = FALSE;
printer->avahi_name = NULL;
printer->avahi_type = NULL;
printer->avahi_domain = NULL;
#endif
printer->ipp_version_major = 1;
printer->ipp_version_minor = 1;
printer->supports_copies = FALSE;
......@@ -176,17 +174,19 @@ gtk_printer_cups_finalize (GObject *object)
g_object_unref (printer->colord_profile);
#endif
#ifdef HAVE_CUPS_API_1_6
g_free (printer->avahi_name);
g_free (printer->avahi_type);
g_free (printer->avahi_domain);
#endif
g_strfreev (printer->covers);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (printer->ppd_file)
ppdClose (printer->ppd_file);
G_GNUC_END_IGNORE_DEPRECATIONS
g_free (printer->media_default);
g_list_free_full (printer->media_supported, g_free);
g_list_free_full (printer->media_size_supported, g_free);
......
......@@ -81,6 +81,7 @@ struct _GtkPrinterCups
guint get_remote_ppd_poll;
gint get_remote_ppd_attempts;
GtkCupsConnectionTest *remote_cups_connection_test;
#ifdef HAVE_COLORD
CdClient *colord_client;
CdDevice *colord_device;
......@@ -89,12 +90,12 @@ struct _GtkPrinterCups
gchar *colord_title;
gchar *colord_qualifier;
#endif
#ifdef HAVE_CUPS_API_1_6
gboolean avahi_browsed;
gchar *avahi_name;
gchar *avahi_type;
gchar *avahi_domain;
#endif
char *avahi_name;
char *avahi_type;
char *avahi_domain;
guchar ipp_version_major;
guchar ipp_version_minor;
gboolean supports_copies;
......
......@@ -74,11 +74,7 @@ if enabled_print_backends.contains('cups')
cups_major_version = cc.compute_int('CUPS_VERSION_MAJOR', prefix : '#include <cups/cups.h>')
cups_minor_version = cc.compute_int('CUPS_VERSION_MINOR', prefix : '#include <cups/cups.h>')
message('Found CUPS version: @0@.@1@'.format(cups_major_version, cups_minor_version))
if cups_major_version > 1 or cups_minor_version >= 2
if cups_major_version > 1 or cups_minor_version >= 6
cdata.set('HAVE_CUPS_API_1_6', 1)
endif
if cups_major_version >= 2
if cc.compiles('#include <cups/http.h> \n http_t http; char *s = http.authstring;')
cdata.set('HAVE_HTTP_AUTHSTRING', 1,
description :'Define if cups http_t authstring field is accessible')
......@@ -88,7 +84,7 @@ if enabled_print_backends.contains('cups')
cdata.set('HAVE_HTTPGETAUTHSTRING', 1)
endif
else
cups_error = 'Need CUPS version >= 1.2'
cups_error = 'Need CUPS version >= 2.0'
endif
else
cups_error = 'Cannot find CUPS headers in default prefix.'
......