cups/cups-str4332.patch

47 lines
1.5 KiB
Diff
Raw Normal View History

diff -up cups-1.7.1/cups/dest.c.str4332 cups-1.7.1/cups/dest.c
--- cups-1.7.1/cups/dest.c.str4332 2014-03-06 11:01:32.539652971 +0000
+++ cups-1.7.1/cups/dest.c 2014-03-06 11:01:41.567696560 +0000
@@ -891,6 +891,10 @@ cupsEnumDests(
num_dests; /* Number of destinations */
cups_dest_t *dests = NULL, /* Destinations */
*dest; /* Current destination */
+ const char *defprinter; /* Default printer */
+ char name[1024], /* Copy of printer name */
+ *instance, /* Pointer to instance name */
+ *user_default; /* User default printer */
#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
int count, /* Number of queries started */
remaining; /* Remainder of timeout */
@@ -936,6 +940,31 @@ cupsEnumDests(
num_dests = _cupsGetDests(CUPS_HTTP_DEFAULT, IPP_OP_CUPS_GET_PRINTERS, NULL,
&dests, type, mask);
+ if ((user_default = _cupsUserDefault(name, sizeof(name))) != NULL)
+ defprinter = name;
+ else if ((defprinter = cupsGetDefault2(CUPS_HTTP_DEFAULT)) != NULL)
+ {
+ strlcpy(name, defprinter, sizeof(name));
+ defprinter = name;
+ }
+
+ if (defprinter)
+ {
+ /*
+ * Separate printer and instance name...
+ */
+
+ if ((instance = strchr(name, '/')) != NULL)
+ *instance++ = '\0';
+
+ /*
+ * Lookup the printer and instance and make it the default...
+ */
+
+ if ((dest = cupsGetDest(name, instance, num_dests, dests)) != NULL)
+ dest->is_default = 1;
+ }
+
for (i = num_dests, dest = dests;
i > 0 && (!cancel || !*cancel);
i --, dest ++)