From d17f2f94069ca684f8fae325603f51314cdcec44 Mon Sep 17 00:00:00 2001 From: mohitmo Date: Wed, 17 Jun 2020 11:27:16 +0530 Subject: [PATCH] modified when to call cupsGetNamedDest() --- utils/cups-browsed.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c index 7ca6724ce..64a786ec6 100644 --- a/utils/cups-browsed.c +++ b/utils/cups-browsed.c @@ -7807,7 +7807,35 @@ gboolean update_cups_queues(gpointer unused) { #ifdef HAVE_CUPS_1_6 /* Check whether there is a temporary CUPS queue which we would overwrite */ - dest = cupsGetNamedDest(http, p->queue_name, NULL); + ipp_t *response = NULL; + const char const *pattrs[] = + { + "printer-name" + }; + + const char const *req_attrs[] = + { + "printer-name" + }; + + if ((response = + get_printer_attributes2(http, uri, + pattrs, 1, req_attrs, 1, 0)) == NULL) { + debug_printf ("No CUPS queue with URI %s found\n", uri); + } + else { + attr = ippFindAttribute(response, "printer-name", IPP_TAG_NAME); + if(!strcmp(ippGetString(attr, 0, NULL), p->queue_name)){ + dest = cupsGetNamedDest(http, p->queue_name, NULL); + debug_printf ("CUPS queue %s with URI %s found", p->queue_name, uri); + } + else { + debug_printf ("CUPS queue with URI %s found, but with \"printer-name\" %s", uri, ippGetString(attr, 0, NULL)); + } + } + + ippDelete(response); + if (dest) { /* CUPS has found a queue with this name. Either CUPS generates a temporary queue here or we have already -- 2.47.3