]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/printers.c
Merge changes from CUPS 1.4svn-r7874.
[thirdparty/cups.git] / scheduler / printers.c
index 3a63fc2e668b80f792abfb5989521fec35af40d6..eeed48f6603244fdfa59edac1dc0b4d4f8e72a6f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: printers.c 7608 2008-05-21 01:37:21Z mike $"
+ * "$Id: printers.c 7677 2008-06-19 23:22:19Z mike $"
  *
  *   Printer routines for the Common UNIX Printing System (CUPS).
  *
@@ -133,6 +133,8 @@ cupsdAddPrinter(const char *name)   /* I - Name of printer */
   if (!Printers)
     Printers = cupsArrayNew(compare_printers, NULL);
 
+  cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                  "cupsdAddPrinter: Adding %s to Printers", p->name);
   cupsArrayAdd(Printers, p);
 
   if (!ImplicitPrinters)
@@ -347,6 +349,7 @@ cupsdCreateCommonData(void)
   static const char * const errors[] = /* printer-error-policy-supported values */
                {
                  "abort-job",
+                 "retry-current-job",
                  "retry-job",
                  "stop-printer"
                };
@@ -640,10 +643,17 @@ cupsdDeletePrinter(
   * Remove the printer from the list...
   */
 
+  cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                  "cupsdDeletePrinter: Removing %s from Printers", p->name);
   cupsArrayRemove(Printers, p);
 
   if (p->type & CUPS_PRINTER_IMPLICIT)
+  {
+    cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                   "cupsdDeletePrinter: Removing %s from ImplicitPrinters",
+                   p->name);
     cupsArrayRemove(ImplicitPrinters, p);
+  }
 
  /*
   * Remove the dummy interface/icon/option files under IRIX...
@@ -1128,7 +1138,7 @@ cupsdLoadAllPrinters(void)
           for (value = valueptr; *valueptr && !isspace(*valueptr & 255); valueptr ++);
 
          if (*valueptr)
-            *valueptr++ = '\0';
+            *valueptr = '\0';
 
          cupsdSetString(&p->job_sheets[1], value);
        }
@@ -1285,10 +1295,17 @@ cupsdRenamePrinter(
   * Remove the printer from the array(s) first...
   */
 
+  cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                  "cupsdRenamePrinter: Removing %s from Printers", p->name);
   cupsArrayRemove(Printers, p);
 
   if (p->type & CUPS_PRINTER_IMPLICIT)
+  {
+    cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                   "cupsdRenamePrinter: Removing %s from ImplicitPrinters",
+                   p->name);
     cupsArrayRemove(ImplicitPrinters, p);
+  }
 
  /*
   * Rename the printer type...
@@ -1316,10 +1333,17 @@ cupsdRenamePrinter(
   * Add the printer back to the printer array(s)...
   */
 
+  cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                  "cupsdRenamePrinter: Adding %s to Printers", p->name);
   cupsArrayAdd(Printers, p);
 
   if (p->type & CUPS_PRINTER_IMPLICIT)
+  {
+    cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                   "cupsdRenamePrinter: Adding %s to ImplicitPrinters",
+                   p->name);
     cupsArrayAdd(ImplicitPrinters, p);
+  }
 }
 
 
@@ -1569,6 +1593,24 @@ cupsdSaveAllPrinters(void)
       cupsFilePuts(fp, "\n");
     }
 
+    if ((marker = ippFindAttribute(printer->attrs, "marker-message",
+                                   IPP_TAG_TEXT)) != NULL)
+    {
+      cupsFilePrintf(fp, "Attribute %s ", marker->name);
+
+      if ((ptr = strchr(marker->values[0].string.text, '#')) != NULL)
+      {
+       cupsFileWrite(fp, marker->values[0].string.text,
+                     ptr - marker->values[0].string.text);
+       cupsFilePutChar(fp, '\\');
+       cupsFilePuts(fp, ptr);
+      }
+      else
+       cupsFilePuts(fp, marker->values[0].string.text);
+
+      cupsFilePuts(fp, "\n");
+    }
+
     if ((marker = ippFindAttribute(printer->attrs, "marker-names",
                                    IPP_TAG_NAME)) != NULL)
     {
@@ -1860,6 +1902,8 @@ cupsdSetPrinterAttr(
 
     if (!strcmp(name, "marker-types"))
       value_tag = IPP_TAG_KEYWORD;
+    else if (!strcmp(name, "marker-message"))
+      value_tag = IPP_TAG_TEXT;
     else
       value_tag = IPP_TAG_NAME;
 
@@ -1871,7 +1915,12 @@ cupsdSetPrinterAttr(
     }
 
     if (attr)
+    {
+      for (i = 0; i < attr->num_values; i ++)
+       _cupsStrFree(attr->values[i].string.text);
+
       attr->num_values = count;
+    }
     else
       attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, value_tag, name,
                            count, NULL, NULL);
@@ -1889,7 +1938,6 @@ cupsdSetPrinterAttr(
       if ((ptr = strchr(value, ',')) != NULL)
         *ptr++ = '\0';
 
-      _cupsStrFree(attr->values[i].string.text);
       attr->values[i].string.text = _cupsStrAlloc(value);
 
       if (ptr)
@@ -2156,29 +2204,20 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
       if (p->num_printers > 0)
       {
        /*
-       * Add a list of member URIs and names...
+       * Add a list of member names; URIs are added in copy_printer_attrs...
        */
 
-       attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI,
-                             "member-uris", p->num_printers, NULL, NULL);
+       attr    = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME,
+                                "member-names", p->num_printers, NULL, NULL);
         p->type |= CUPS_PRINTER_OPTIONS;
 
        for (i = 0; i < p->num_printers; i ++)
        {
           if (attr != NULL)
-            attr->values[i].string.text = _cupsStrAlloc(p->printers[i]->uri);
+            attr->values[i].string.text = _cupsStrAlloc(p->printers[i]->name);
 
          p->type &= ~CUPS_PRINTER_OPTIONS | p->printers[i]->type;
         }
-
-       attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME,
-                             "member-names", p->num_printers, NULL, NULL);
-
-       if (attr != NULL)
-       {
-         for (i = 0; i < p->num_printers; i ++)
-            attr->values[i].string.text = _cupsStrAlloc(p->printers[i]->name);
-        }
       }
     }
     else
@@ -2364,7 +2403,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
              if ((duplex = ppdFindOption(ppd, "KD03Duplex")) == NULL)
                duplex = ppdFindOption(ppd, "JCLDuplex");
 
-       if (duplex && duplex->num_choices > 1)
+       if (duplex && duplex->num_choices > 1 &&
+           !ppdInstallableConflict(ppd, duplex->keyword, "DuplexTumble"))
        {
          p->type |= CUPS_PRINTER_DUPLEX;
 
@@ -3725,7 +3765,7 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */
   * Add all of the default options from the .conf files...
   */
 
-  for (num_options = 0, i = p->num_options, option = p->options;
+  for (num_options = 0, options = NULL, i = p->num_options, option = p->options;
        i > 0;
        i --, option ++)
   {
@@ -3757,7 +3797,7 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */
                   1);
 
   if (!cupsGetOption("document-format", p->num_options, p->options))
-    ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE,
+    ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE,
                 "document-format-default", NULL, "application/octet-stream");
 
   if (!cupsGetOption("job-hold-until", p->num_options, p->options))
@@ -3810,7 +3850,8 @@ add_printer_filter(
   *     super/type cost program
   */
 
-  if (sscanf(filter, "%15[^/]/%31s%d%1023s", super, type, &cost, program) != 4)
+  if (sscanf(filter, "%15[^/]/%31s%d%*[ \t]%1023[^\n]", super, type, &cost,
+             program) != 4)
   {
     cupsdLogMessage(CUPSD_LOG_ERROR, "%s: invalid filter string \"%s\"!",
                     p->name, filter);
@@ -4320,5 +4361,5 @@ write_irix_state(cupsd_printer_t *p)      /* I - Printer to update */
 
 
 /*
- * End of "$Id: printers.c 7608 2008-05-21 01:37:21Z mike $".
+ * End of "$Id: printers.c 7677 2008-06-19 23:22:19Z mike $".
  */