]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
One further fix for cupsGetDests2 - don't show network printers when the server
authorMichael Sweet <michael.r.sweet@gmail.com>
Thu, 12 Oct 2017 12:31:03 +0000 (08:31 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Thu, 12 Oct 2017 12:31:03 +0000 (08:31 -0400)
is remote.

cups/dest.c

index 45626884b3d5a18af998c5ae1f0d647b869a5035..57a8dc95cfac07367ee9318962bd249abeb16bc6 100644 (file)
@@ -1656,6 +1656,20 @@ cupsGetDests2(http_t      *http, /* I - Connection to server or @code CUPS_HTTP_
     return (0);
   }
 
+ /*
+  * Connect to the server as needed...
+  */
+
+  if (!http)
+  {
+    if ((http = _cupsConnect()) == NULL)
+    {
+      *dests = NULL;
+
+      return (0);
+    }
+  }
+
  /*
   * Grab the printers and classes...
   */
@@ -1663,7 +1677,24 @@ cupsGetDests2(http_t      *http, /* I - Connection to server or @code CUPS_HTTP_
   data.num_dests = 0;
   data.dests     = NULL;
 
-  cups_enum_dests(http, 0, _CUPS_DNSSD_GET_DESTS, NULL, 0, 0, (cups_dest_cb_t)cups_get_cb, &data);
+  if (!httpAddrLocalhost(httpGetAddress(http)))
+  {
+   /*
+    * When talking to a remote cupsd, just enumerate printers on the remote
+    * cupsd.
+    */
+
+    cups_enum_dests(http, 0, _CUPS_DNSSD_GET_DESTS, NULL, 0, CUPS_PRINTER_DISCOVERED, (cups_dest_cb_t)cups_get_cb, &data);
+  }
+  else
+  {
+   /*
+    * When talking to a local cupsd, enumerate both local printers and ones we
+    * can find on the network...
+    */
+
+    cups_enum_dests(http, 0, _CUPS_DNSSD_GET_DESTS, NULL, 0, 0, (cups_dest_cb_t)cups_get_cb, &data);
+  }
 
  /*
   * Make a copy of the "real" queues for a later sanity check...