From: Michael R Sweet Date: Fri, 20 Sep 2024 17:03:52 +0000 (-0400) Subject: Add a temporary queue before setting the defaults for lpoptions (Issue #833) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85e977d09366761d06082158a98668c15da9485d;p=thirdparty%2Fcups.git Add a temporary queue before setting the defaults for lpoptions (Issue #833) --- diff --git a/cups/dest.c b/cups/dest.c index 2693de611a..6abae8e718 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -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... //