]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
cupsEnumDests did not set the "is_default" field (STR #4332)
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 5 Mar 2014 20:11:06 +0000 (20:11 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 5 Mar 2014 20:11:06 +0000 (20:11 +0000)
Copy the default code from cupsGetDests2...

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11686 a1ca3aef-8c08-0410-bb20-df032aa958be

CHANGES-1.7.txt
cups/dest.c

index 61d434d97c1df22d5e8c0899b2f7a945e571853e..df9d3c88620c4dbb963a9f8fad7ac92874d3f2a0 100644 (file)
@@ -9,6 +9,7 @@ CHANGES IN CUPS V1.7.2
        - Fixed the Japanese localization (STR #4385)
        - Added a German localization (STR #4363)
        - Updated Linux "relro" support (STR #4349)
+       - cupsEnumDests did not set the "is_default" field (STR #4332)
        - cupsDoIORequest could miss the server status, causing failed lpadmin
          and other administrative commands (STR #4386)
        - cupsEnumDests didn't always call the callback function (STR #4380)
index c19caa741f4601a334a6a13b5e2d3fb916493d15..675bf5fb53ee0d2dcbead692e9daf16b80e2a843 100644 (file)
@@ -823,6 +823,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 */
@@ -868,6 +872,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 ++)