diff --git a/CHANGES.md b/CHANGES.md index 50827dfc6..250d0a227 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/cups/dest.c b/cups/dest.c index e971e6df6..b48d8f219 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -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... */