mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-08 17:50:10 +00:00
cups: Use non-deprecated API
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.
This commit is contained in:
parent
feddf5a694
commit
ed31ea3773
@ -169,9 +169,16 @@ gtk_cups_request_new_with_username (http_t *connection,
|
||||
else
|
||||
{
|
||||
request->http = NULL;
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
request->http = httpConnect2 (request->server, ippPort (),
|
||||
NULL, AF_UNSPEC,
|
||||
cupsEncryption (),
|
||||
1, 30000, NULL);
|
||||
#else
|
||||
request->http = httpConnectEncrypt (request->server,
|
||||
ippPort (),
|
||||
cupsEncryption ());
|
||||
#endif
|
||||
|
||||
if (request->http)
|
||||
httpBlocking (request->http, 0);
|
||||
@ -686,9 +693,16 @@ _connect (GtkCupsRequest *request)
|
||||
|
||||
if (request->http == NULL)
|
||||
{
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
request->http = httpConnect2 (request->server, ippPort (),
|
||||
NULL, AF_UNSPEC,
|
||||
cupsEncryption (),
|
||||
1, 30000, NULL);
|
||||
#else
|
||||
request->http = httpConnectEncrypt (request->server,
|
||||
ippPort (),
|
||||
cupsEncryption ());
|
||||
#endif
|
||||
|
||||
if (request->http == NULL)
|
||||
request->attempts++;
|
||||
@ -741,7 +755,15 @@ _post_send (GtkCupsRequest *request)
|
||||
|
||||
if (httpPost (request->http, request->resource))
|
||||
{
|
||||
if (httpReconnect (request->http))
|
||||
int res;
|
||||
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
res = httpReconnect2 (request->http, 30000, NULL);
|
||||
#else
|
||||
res = httpReconnect (request->http);
|
||||
#endif
|
||||
|
||||
if (res)
|
||||
{
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
@ -1039,7 +1061,11 @@ _post_check (GtkCupsRequest *request)
|
||||
}
|
||||
|
||||
if (auth_result ||
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
httpReconnect2 (request->http, 30000, NULL))
|
||||
#else
|
||||
httpReconnect (request->http))
|
||||
#endif
|
||||
{
|
||||
/* if the password has been used, reset password_state
|
||||
* so that we ask for a new one next time around
|
||||
@ -1098,7 +1124,11 @@ _post_check (GtkCupsRequest *request)
|
||||
request->state = GTK_CUPS_POST_CONNECT;
|
||||
|
||||
/* Reconnect... */
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
httpReconnect2 (request->http, 30000, NULL);
|
||||
#else
|
||||
httpReconnect (request->http);
|
||||
#endif
|
||||
|
||||
/* Upgrade with encryption... */
|
||||
httpEncryption (request->http, HTTP_ENCRYPT_REQUIRED);
|
||||
@ -1226,7 +1256,14 @@ _get_send (GtkCupsRequest *request)
|
||||
|
||||
if (httpGet (request->http, request->resource))
|
||||
{
|
||||
if (httpReconnect (request->http))
|
||||
int reconnect;
|
||||
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
reconnect = httpReconnect2 (request->http, 30000, NULL);
|
||||
#else
|
||||
reconnect = httpReconnect (request->http);
|
||||
#endif
|
||||
if (reconnect)
|
||||
{
|
||||
request->state = GTK_CUPS_GET_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
@ -1335,7 +1372,11 @@ _get_check (GtkCupsRequest *request)
|
||||
}
|
||||
|
||||
if (auth_result ||
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
httpReconnect2 (request->http, 30000, NULL))
|
||||
#else
|
||||
httpReconnect (request->http))
|
||||
#endif
|
||||
{
|
||||
/* if the password has been used, reset password_state
|
||||
* so that we ask for a new one next time around
|
||||
@ -1367,7 +1408,11 @@ _get_check (GtkCupsRequest *request)
|
||||
request->state = GTK_CUPS_GET_CONNECT;
|
||||
|
||||
/* Reconnect... */
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
httpReconnect2 (request->http, 30000, NULL);
|
||||
#else
|
||||
httpReconnect (request->http);
|
||||
#endif
|
||||
|
||||
/* Upgrade with encryption... */
|
||||
httpEncryption (request->http, HTTP_ENCRYPT_REQUIRED);
|
||||
|
@ -740,7 +740,15 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
|
||||
#ifdef HAVE_CUPS_API_1_6
|
||||
if (cups_printer->avahi_browsed)
|
||||
{
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
http = httpConnect2 (cups_printer->hostname, cups_printer->port,
|
||||
NULL, AF_UNSPEC,
|
||||
HTTP_ENCRYPTION_IF_REQUESTED,
|
||||
1, 30000,
|
||||
NULL);
|
||||
#else
|
||||
http = httpConnect (cups_printer->hostname, cups_printer->port);
|
||||
#endif
|
||||
if (http)
|
||||
{
|
||||
request = gtk_cups_request_new_with_username (http,
|
||||
@ -2850,7 +2858,11 @@ cups_request_printer_info (const gchar *printer_uri,
|
||||
GtkCupsRequest *request;
|
||||
http_t *http;
|
||||
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
http = httpConnect2 (host, port, NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL);
|
||||
#else
|
||||
http = httpConnect (host, port);
|
||||
#endif
|
||||
if (http)
|
||||
{
|
||||
request = gtk_cups_request_new_with_username (http,
|
||||
@ -3960,9 +3972,16 @@ cups_request_ppd (GtkPrinter *printer)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_CUPS_API_2_0
|
||||
http = httpConnect2 (cups_printer->hostname, cups_printer->port,
|
||||
NULL, AF_UNSPEC,
|
||||
cupsEncryption (),
|
||||
1, 30000, NULL);
|
||||
#else
|
||||
http = httpConnectEncrypt (cups_printer->hostname,
|
||||
cups_printer->port,
|
||||
cupsEncryption ());
|
||||
#endif
|
||||
|
||||
data = g_new0 (GetPPDData, 1);
|
||||
|
||||
|
@ -184,9 +184,13 @@ gtk_printer_cups_finalize (GObject *object)
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user