]> 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:03:52 +0000 (13:03 -0400)
committerMichael R Sweet <msweet@msweet.org>
Fri, 20 Sep 2024 17:03:52 +0000 (13:03 -0400)
cups/dest.c

index 2693de611ab66ce10d654653bbf41d26642bf48c..6abae8e7186ebed7eb9c68d1ff30fa822189750b 100644 (file)
@@ -1960,6 +1960,30 @@ 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
+
+      if (strstr(uri, "._tcp"))
+        uri = cups_dest_resolve(dest, uri, /*msec*/30000, /*cancel*/NULL, /*cb*/NULL, /*user_data*/NULL);
+
+      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...
   //