]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add a temporary queue before setting the defaults for lpoptions (Issue #833)
authorMichael R Sweet <msweet@msweet.org>
Fri, 20 Sep 2024 17:08:09 +0000 (13:08 -0400)
committerMichael R Sweet <msweet@msweet.org>
Fri, 20 Sep 2024 17:08:09 +0000 (13:08 -0400)
CHANGES.md
cups/dest.c

index 50827dfc6488403a3ea4026e732cc03a4b4813d8..250d0a22754e22a2d052b1d8a68644b7da2609be 100644 (file)
@@ -6,6 +6,7 @@ Changes in CUPS v2.4.11 (YYYY-MM-DD)
 ------------------------------------
 
 - Updated the maximum file descriptor limit for `cupsd` to 64k-1 (Issue #989)
+- Fixed `lpoptions -d` with a discovered but not added printer (Issue #833)
 - Fixed incorrect error message for HTTP/IPP errors (Issue #893)
 - Fixed JobPrivateAccess and SubscriptionPrivateAccess support for "all"
   (Issue #990)
index e971e6df626fcb319cd4a85f07a1d146f9e16a76..b48d8f219cccea5d584c2e64ae9891794cfa697f 100644 (file)
@@ -2058,6 +2058,35 @@ cupsSetDests2(http_t      *http, /* I - Connection to server or @code CUPS_HTTP_
   if (!num_dests || !dests)
     return (-1);
 
+ /*
+  * See if the default destination has a printer URI associated with it...
+  */
+
+  if ((dest = cupsGetDest(/*name*/NULL, /*instance*/NULL, num_dests, dests)) != NULL && !cupsGetOption("printer-uri-supported", dest->num_options, dest->options))
+  {
+   /*
+    * No, try adding it...
+    */
+
+    const char *uri;                   /* Device/printer URI */
+
+    if ((uri = cupsGetOption("device-uri", dest->num_options, dest->options)) != NULL)
+    {
+      char     tempresource[1024];     /* Temporary resource path */
+
+#ifdef HAVE_DNSSD
+      if (strstr(uri, "._tcp"))
+        uri = cups_dnssd_resolve(dest, uri, /*msec*/30000, /*cancel*/NULL, /*cb*/NULL, /*user_data*/NULL);
+#endif /* HAVE_DNSSD */
+
+      if (uri)
+       uri = _cupsCreateDest(dest->name, cupsGetOption("printer-info", dest->num_options, dest->options), NULL, uri, tempresource, sizeof(tempresource));
+
+      if (uri)
+       dest->num_options = cupsAddOption("printer-uri-supported", uri, dest->num_options, &dest->options);
+    }
+  }
+
  /*
   * Get the server destinations...
   */