fepitre / rpms / gtk3

Forked from rpms/gtk3 4 years ago
Clone

Blame SOURCES/0001-printing-Check-connection-to-remote-CUPS-server-on-c.patch

25dd04
From 24a399252e811ae8db5738156026590b30f2d228 Mon Sep 17 00:00:00 2001
25dd04
From: Marek Kasik <mkasik@redhat.com>
25dd04
Date: Fri, 11 Jul 2014 11:33:30 +0200
25dd04
Subject: [PATCH] printing: Check connection to remote CUPS server on correct
25dd04
 port
25dd04
25dd04
Add parameter for specification of port to gtk_cups_connection_cups_new().
25dd04
Use default port returned by ippPort() if the given port is lower than 0.
25dd04
25dd04
https://bugzilla.gnome.org/show_bug.cgi?id=693738
25dd04
---
25dd04
 modules/printbackends/cups/gtkcupsutils.c        | 8 ++++++--
25dd04
 modules/printbackends/cups/gtkcupsutils.h        | 3 ++-
25dd04
 modules/printbackends/cups/gtkprintbackendcups.c | 8 +++++---
25dd04
 3 files changed, 13 insertions(+), 6 deletions(-)
25dd04
25dd04
diff --git a/modules/printbackends/cups/gtkcupsutils.c b/modules/printbackends/cups/gtkcupsutils.c
25dd04
index da3436e..54239ca 100644
25dd04
--- a/modules/printbackends/cups/gtkcupsutils.c
25dd04
+++ b/modules/printbackends/cups/gtkcupsutils.c
25dd04
@@ -1522,14 +1522,18 @@ gtk_cups_result_get_error_string (GtkCupsResult *result)
25dd04
  * a socket for communication with a CUPS server 'server'.
25dd04
  */
25dd04
 GtkCupsConnectionTest *
25dd04
-gtk_cups_connection_test_new (const char *server)
25dd04
+gtk_cups_connection_test_new (const char *server,
25dd04
+                              const int   port)
25dd04
 {
25dd04
   GtkCupsConnectionTest *result = NULL;
25dd04
   gchar                 *port_str = NULL;
25dd04
 
25dd04
   result = g_new (GtkCupsConnectionTest, 1);
25dd04
 
25dd04
-  port_str = g_strdup_printf ("%d", ippPort ());
25dd04
+  if (port >= 0)
25dd04
+    port_str = g_strdup_printf ("%d", port);
25dd04
+  else
25dd04
+    port_str = g_strdup_printf ("%d", ippPort ());
25dd04
 
25dd04
   if (server != NULL)
25dd04
     result->addrlist = httpAddrGetList (server, AF_UNSPEC, port_str);
25dd04
diff --git a/modules/printbackends/cups/gtkcupsutils.h b/modules/printbackends/cups/gtkcupsutils.h
25dd04
index 55186f5..500bb4f 100644
25dd04
--- a/modules/printbackends/cups/gtkcupsutils.h
25dd04
+++ b/modules/printbackends/cups/gtkcupsutils.h
25dd04
@@ -187,7 +187,8 @@ GtkCupsErrorType        gtk_cups_result_get_error_type     (GtkCupsResult      *
25dd04
 int                     gtk_cups_result_get_error_status   (GtkCupsResult      *result);
25dd04
 int                     gtk_cups_result_get_error_code     (GtkCupsResult      *result);
25dd04
 const char            * gtk_cups_result_get_error_string   (GtkCupsResult      *result);
25dd04
-GtkCupsConnectionTest * gtk_cups_connection_test_new       (const char            *server);
25dd04
+GtkCupsConnectionTest * gtk_cups_connection_test_new       (const char         *server,
25dd04
+                                                            const int           port);
25dd04
 GtkCupsConnectionState  gtk_cups_connection_test_get_state (GtkCupsConnectionTest *test);
25dd04
 void                    gtk_cups_connection_test_free      (GtkCupsConnectionTest *test);
25dd04
 
25dd04
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
25dd04
index b9782c5..80e9fea 100644
25dd04
--- a/modules/printbackends/cups/gtkprintbackendcups.c
25dd04
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
25dd04
@@ -3528,7 +3528,7 @@ cups_get_printer_list (GtkPrintBackend *backend)
25dd04
   cups_backend = GTK_PRINT_BACKEND_CUPS (backend);
25dd04
 
25dd04
   if (cups_backend->cups_connection_test == NULL)
25dd04
-    cups_backend->cups_connection_test = gtk_cups_connection_test_new (NULL);
25dd04
+    cups_backend->cups_connection_test = gtk_cups_connection_test_new (NULL, -1);
25dd04
 
25dd04
   if (cups_backend->list_printers_poll == 0)
25dd04
     {
25dd04
@@ -3931,7 +3931,7 @@ cups_get_default_printer (GtkPrintBackendCups *backend)
25dd04
   cups_backend = backend;
25dd04
 
25dd04
   if (cups_backend->cups_connection_test == NULL)
25dd04
-    cups_backend->cups_connection_test = gtk_cups_connection_test_new (NULL);
25dd04
+    cups_backend->cups_connection_test = gtk_cups_connection_test_new (NULL, -1);
25dd04
 
25dd04
   if (cups_backend->default_printer_poll == 0)
25dd04
     {
25dd04
@@ -4073,7 +4073,9 @@ cups_printer_request_details (GtkPrinter *printer)
25dd04
         {
25dd04
           if (cups_printer->get_remote_ppd_poll == 0)
25dd04
             {
25dd04
-              cups_printer->remote_cups_connection_test = gtk_cups_connection_test_new (cups_printer->hostname);
25dd04
+              cups_printer->remote_cups_connection_test =
25dd04
+                gtk_cups_connection_test_new (cups_printer->hostname,
25dd04
+                                              cups_printer->port);
25dd04
 
25dd04
               if (cups_request_ppd (printer))
25dd04
                 {
25dd04
-- 
25dd04
2.4.0
25dd04