[Xfce4-commits] r22668 - xfprint/trunk/printing-systems/cups

Jean-François Wauthy pollux at xfce.org
Sat Aug 5 19:26:43 UTC 2006


Author: pollux
Date: 2006-08-05 19:26:42 +0000 (Sat, 05 Aug 2006)
New Revision: 22668

Modified:
   xfprint/trunk/printing-systems/cups/cups.c
Log:
if cupsServer() returns a domain socket pathname substitutes it with localhost (fix bug #2107)

Modified: xfprint/trunk/printing-systems/cups/cups.c
===================================================================
--- xfprint/trunk/printing-systems/cups/cups.c	2006-08-05 18:49:00 UTC (rev 22667)
+++ xfprint/trunk/printing-systems/cups/cups.c	2006-08-05 19:26:42 UTC (rev 22668)
@@ -148,15 +148,24 @@
 cups_request_new_for_printer (int operation_id, const gchar * printer)
 {
   ipp_t *request;
-  gchar *printer_uri;
+  gchar *server = NULL;
+  gchar *printer_uri = NULL;
 
   g_return_val_if_fail (printer, NULL);
 
-  printer_uri = g_strdup_printf ("ipp://%s/printers/%s", cupsServer (), printer);
+  server = g_strdup (cupsServer ());
+  if ((strlen (server) > 0) && server[0] == '/') {
+    g_free (server);
+    server = g_strdup ("localhost");
+  }
+
+  printer_uri = g_strdup_printf ("ipp://%s/printers/%s", server, printer);
   request = cups_request_new (operation_id);
 
   ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer_uri);
+
   g_free (printer_uri);
+  g_free (server);
 
   return request;
 }
@@ -166,17 +175,26 @@
 {
   http_t *HTTP = NULL;
   ipp_status_t status;
+  gchar *server = NULL;
 
   cupsSetPasswordCB (cups_password_cb);
 
-  HTTP = httpConnectEncrypt (cupsServer (), ippPort (), cupsEncryption ());
+  server = g_strdup (cupsServer ());
+  if ((strlen (server) > 0) && server[0] == '/') {
+    g_free (server);
+    server = g_strdup ("localhost");
+  }
 
+  HTTP = httpConnectEncrypt (server, ippPort (), cupsEncryption ());
+
   if (!HTTP) {
     ippDelete (request);
     g_warning ("Unable to connect CUPS server");
     return NULL;
   }
 
+  g_free (server);
+
   request = cupsDoRequest (HTTP, request, path);
   httpClose (HTTP);
   status = cupsLastError ();



More information about the Xfce4-commits mailing list