Track local default in cupsEnumDests() (STR #4332).

This commit is contained in:
Tim Waugh 2014-03-06 11:03:37 +00:00
parent fb3a0f4a71
commit fbc1998b1d
2 changed files with 50 additions and 0 deletions

46
cups-str4332.patch Normal file
View File

@ -0,0 +1,46 @@
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 ++)

View File

@ -71,6 +71,7 @@ Patch43: cups-avahi-browse.patch
Patch44: cups-str4380.patch
Patch45: cups-str4366.patch
Patch46: cups-str4386.patch
Patch47: cups-str4332.patch
Patch100: cups-lspp.patch
@ -272,6 +273,8 @@ Sends IPP requests to the specified URI and tests and/or displays the results.
%patch45 -p1 -b .str4366
# libcups: avoid race condition when sending IPP requests (STR #4386).
%patch46 -p1 -b .str4386
# Track local default in cupsEnumDests() (STR #4332).
%patch47 -p1 -b .str4332
%if %lspp
# LSPP support.
@ -653,6 +656,7 @@ rm -f %{cups_serverbin}/backend/smb
%changelog
* Thu Mar 6 2014 Tim Waugh <twaugh@redhat.com> - 1:1.7.1-6
- Track local default in cupsEnumDests() (STR #4332).
- libcups: avoid race condition when sending IPP requests (STR #4386).
- Prevent feedback loop when fetching error_log over HTTP (STR #4366).