]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
modified when to call cupsGetNamedDest()
authormohitmo <mohitmohan12@gmail.com>
Wed, 17 Jun 2020 05:57:16 +0000 (11:27 +0530)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 20 Aug 2020 19:21:18 +0000 (21:21 +0200)
(cherry picked from commit d17f2f94069ca684f8fae325603f51314cdcec44)

utils/cups-browsed.c

index 7ca6724ce2d93f97d48295f207607ec4437554fb..64a786ec68b8ada9a5bc31a97351f61d96ac9943 100644 (file)
@@ -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