]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/ipp.c
Merge changes from CUPS 1.4svn-r8177 (tentative CUPS 1.4b2)
[thirdparty/cups.git] / backend / ipp.c
index 2d1b802310872e4596a5758d61b00baf6a1aef22..78b3ddb3bba0b0d50a9c510ab0f4e9df90a450c9 100644 (file)
@@ -102,7 +102,8 @@ main(int  argc,                             /* I - Number of command-line args */
                sep;                    /* Separator character */
   int          snmp_fd,                /* SNMP socket */
                start_count,            /* Page count via SNMP at start */
-               page_count;             /* Page count via SNMP */
+               page_count,             /* Page count via SNMP */
+               have_supplies;          /* Printer supports supply levels? */
   int          num_files;              /* Number of files to print */
   char         **files,                /* Files to print */
                *filename;              /* Pointer to single filename */
@@ -198,8 +199,9 @@ main(int  argc,                             /* I - Number of command-line args */
     else
       s = argv[0];
 
-    printf("network %s \"Unknown\" \"Internet Printing Protocol (%s)\"\n",
-           s, s);
+    printf("network %s \"Unknown\" \"%s (%s)\"\n",
+           s, _cupsLangString(cupsLangDefault(),
+                             _("Internet Printing Protocol")), s);
     return (CUPS_BACKEND_OK);
   }
   else if (argc < 6)
@@ -523,8 +525,9 @@ main(int  argc,                             /* I - Number of command-line args */
 
   do
   {
-    _cupsLangPrintf(stderr, _("INFO: Connecting to %s on port %d...\n"),
-                   hostname, port);
+    fprintf(stderr, "DEBUG: Connecting to %s:%d\n",
+           hostname, port);
+    _cupsLangPuts(stderr, _("INFO: Connecting to printer...\n"));
 
     if ((http = httpConnectEncrypt(hostname, port, cupsEncryption())) == NULL)
     {
@@ -609,7 +612,7 @@ main(int  argc,                             /* I - Number of command-line args */
   }
 
   fputs("STATE: -connecting-to-device\n", stderr);
-  _cupsLangPrintf(stderr, _("INFO: Connected to %s...\n"), hostname);
+  _cupsLangPuts(stderr, _("INFO: Connected to printer...\n"));
 
 #ifdef AF_INET6
   if (http->hostaddr->addr.sa_family == AF_INET6)
@@ -628,19 +631,10 @@ main(int  argc,                           /* I - Number of command-line args */
   */
 
   if ((snmp_fd = _cupsSNMPOpen(http->hostaddr->addr.sa_family)) >= 0)
-  {
-    if (backendSNMPSupplies(snmp_fd, http->hostaddr, &start_count, NULL))
-    {
-     /*
-      * No, close it...
-      */
-
-      _cupsSNMPClose(snmp_fd);
-      snmp_fd = -1;
-    }
-  }
+    have_supplies = !backendSNMPSupplies(snmp_fd, http->hostaddr, &start_count,
+                                         NULL);
   else
-    start_count = 0;
+    have_supplies = start_count = 0;
 
  /*
   * Build a URI for the printer and fill the standard IPP attributes for
@@ -1118,7 +1112,7 @@ main(int  argc,                           /* I - Number of command-line args */
     }
     else if (ipp_status == IPP_SERVICE_UNAVAILABLE ||
             ipp_status == IPP_PRINTER_BUSY)
-      break;
+      continue;
     else
       copies_remaining --;
 
@@ -1256,7 +1250,7 @@ main(int  argc,                           /* I - Number of command-line args */
   * Collect the final page count as needed...
   */
 
-  if (snmp_fd >= 0 && 
+  if (have_supplies && 
       !backendSNMPSupplies(snmp_fd, http->hostaddr, &page_count, NULL) &&
       page_count > start_count)
     fprintf(stderr, "PAGE: total %d\n", page_count - start_count);
@@ -1648,6 +1642,7 @@ report_printer_state(ipp_t *ipp,  /* I - IPP response */
     else if (!strncmp(reason, "media-jam", 9))
       message = _("Media jam!");
     else if (!strncmp(reason, "moving-to-paused", 16) ||
+             !strncmp(reason, "offline", 7) ||
              !strncmp(reason, "paused", 6) ||
             !strncmp(reason, "shutdown", 8))
       message = _("Printer offline.");