[MOD] STR #4181: ipp backend does not set compression for Send-Document operation

Bernd Krumb??ck <[email protected]>
Newsgroups gmane.comp.printing.cups.bugs
Message-ID <[email protected]>
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Whenever the ipp backend uses "Create-Job" instead of "Print-Job", the
parameter "compression" leads to printing problems (because the remote
side does not decompress the data). The backend does not set the operation
attribute "compression" for "Send-Document" operation.

Please check the attached patch and correct it, if necessary.

regards,
Bernd

Link: http://www.cups.org/str.php?L4181
Version: 1.5.4

_______________________________________________
cups-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/cups-bugs
cups-1.5.4-ipp-comp.patch (text/plain, 4.2 KB)
--- backend/ipp.c.orig	2012-09-07 07:40:49.000000000 +0200
+++ backend/ipp.c	2012-09-07 11:34:59.000000000 +0200
@@ -99,6 +99,7 @@
 					/* Password tries */
 static const char * const pattrs[] =	/* Printer attributes we want */
 {
+  "compression-supported",
   "copies-supported",
   "cups-version",
   "document-format-supported",
@@ -229,6 +230,7 @@
   int		job_id;			/* job-id value */
   ipp_attribute_t *job_sheets;		/* job-media-sheets-completed */
   ipp_attribute_t *job_state;		/* job-state */
+  ipp_attribute_t *compression_sup;	/* compression-supported */
   ipp_attribute_t *copies_sup;		/* copies-supported */
   ipp_attribute_t *cups_version;	/* cups-version */
   ipp_attribute_t *format_sup;		/* document-format-supported */
@@ -245,7 +247,8 @@
 		copies_remaining;	/* Number of copies remaining */
   const char	*content_type,		/* CONTENT_TYPE environment variable */
 		*final_content_type,	/* FINAL_CONTENT_TYPE environment var */
-		*document_format;	/* document-format value */
+		*document_format,	/* document-format value */
+		*compression_format;	/* compression-format value */
   int		fd;			/* File descriptor */
   off_t		bytes = 0;		/* Bytes copied */
   char		buffer[16384];		/* Copy buffer */
@@ -794,6 +797,7 @@
   * copies...
   */
 
+  compression_sup  = NULL;
   copies_sup       = NULL;
   cups_version     = NULL;
   format_sup       = NULL;
@@ -986,6 +990,16 @@
     * Check for supported attributes...
     */
 
+    if ((compression_sup = ippFindAttribute(supported, "compression-supported",
+	                                  IPP_TAG_KEYWORD)) != NULL)
+    {
+      fprintf(stderr, "DEBUG: compression-supported (%d values)\n",
+	      compression_sup->num_values);
+      for (i = 0; i < compression_sup->num_values; i ++)
+	fprintf(stderr, "DEBUG: [%d] = \"%s\"\n", i,
+	        compression_sup->values[i].string.text);
+    }
+
     if ((copies_sup = ippFindAttribute(supported, "copies-supported",
 	                               IPP_TAG_RANGE)) != NULL)
     {
@@ -1202,8 +1216,26 @@
     }
   }
 
-  fprintf(stderr, "DEBUG: final_content_type=\"%s\", document_format=\"%s\"\n",
-          final_content_type, document_format ? document_format : "(null)");
+  compression_format = NULL;
+  if (compression_sup != NULL)
+  {
+    for (i = 0; i < compression_sup->num_values; i ++)
+      if (!_cups_strcasecmp(compression,
+                            compression_sup->values[i].string.text))
+      {
+        compression_format = compression;
+	break;
+      }
+  }
+
+  if (!compression_format)
+  {
+    perror("DEBUG: Requested compression not supported");
+    return (CUPS_BACKEND_FAILED);
+  }
+
+  fprintf(stderr, "DEBUG: final_content_type=\"%s\", document_format=\"%s\", compression=\"%s\"\n",
+          final_content_type, document_format ? document_format : "(null)", compression_format ? compression_format : "none");
 
  /*
   * If the printer does not support HTTP/1.1 (which IPP requires), copy stdin
@@ -1284,7 +1316,7 @@
   while (!job_canceled && validate_job)
   {
     request = new_request(IPP_VALIDATE_JOB, version, uri, argv[2],
-                          monitor.job_name, num_options, options, compression,
+                          monitor.job_name, num_options, options, compression_format,
 			  copies_sup ? copies : 1, document_format, pc,
 			  media_col_sup, doc_handling_sup);
 
@@ -1357,7 +1389,7 @@
     request = new_request((num_files > 1 || create_job) ? IPP_CREATE_JOB :
                                                           IPP_PRINT_JOB,
 			  version, uri, argv[2], monitor.job_name, num_options,
-			  options, compression, copies_sup ? copies : 1,
+			  options, compression_format, copies_sup ? copies : 1,
 			  document_format, pc, media_col_sup, doc_handling_sup);
 
    /*
@@ -1568,6 +1600,10 @@
 	  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE,
 		       "document-format", NULL, document_format);
 
+	if (compression_format)
+	  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+		       "compression", NULL, compression_format);
+
 	fprintf(stderr, "DEBUG: Sending file %d using chunking...\n", i + 1);
 	http_status = cupsSendRequest(http, request, resource, 0);
 	if (http_status == HTTP_CONTINUE && request->state == IPP_DATA)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.