From 6b33281c3ee2a3fee39324c27df3059a304f3dea Mon Sep 17 00:00:00 2001 From: Michael Sweet Date: Thu, 12 Oct 2017 08:31:03 -0400 Subject: [PATCH] One further fix for cupsGetDests2 - don't show network printers when the server is remote. --- cups/dest.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/cups/dest.c b/cups/dest.c index 45626884b3..57a8dc95cf 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -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... -- 2.47.3