]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Mirror fix from trunk.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 27 Sep 2013 16:18:26 +0000 (16:18 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 27 Sep 2013 16:18:26 +0000 (16:18 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.7@11319 a1ca3aef-8c08-0410-bb20-df032aa958be

CHANGES.txt
backend/snmp-supplies.c

index 01c3d1c4032606b2c7ffde9e3463262a824b7a5f..ea10cc7721455807816c52957c903ced19d58e26 100644 (file)
@@ -4,6 +4,9 @@ CHANGES.txt - 1.7.0 - 2013-09-27
 CHANGES IN CUPS V1.7.0
 
        - Updated Japanese localization.
+       - Network backends now use the prtMarkerSuppliesClass property to
+         determine the direction of supply level values
+         (<rdar://problem/14302628>)
        - The scheduler did not remove backup PPD files when a printer was
          deleted (<rdar://problem/15065555>)
        - The scheduler incorrectly responded to HEAD requests when the web
index c669b5db9b95eaec9838a01aae09d61c2af2954d..0864c2290cbd720c6bf0965bfe88503e8dfd8db4 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   SNMP supplies functions for CUPS.
  *
- *   Copyright 2008-2012 by Apple Inc.
+ *   Copyright 2008-2013 by Apple Inc.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Apple Inc. and are protected by Federal copyright
@@ -62,6 +62,7 @@ typedef struct                                /**** Printer supply data ****/
   char name[CUPS_SNMP_MAX_STRING],     /* Name of supply */
        color[8];                       /* Color: "#RRGGBB" or "none" */
   int  colorant,                       /* Colorant index */
+       sclass,                         /* Supply class */
        type,                           /* Supply type */
        max_capacity,                   /* Maximum capacity */
        level;                          /* Current level value */
@@ -148,6 +149,13 @@ static const int   prtMarkerSuppliesMaxCapacity[] =
                        (sizeof(prtMarkerSuppliesMaxCapacity) /
                         sizeof(prtMarkerSuppliesMaxCapacity[0]));
                                        /* Offset to supply index */
+static const int       prtMarkerSuppliesClass[] =
+                       { CUPS_OID_prtMarkerSuppliesClass, -1 },
+                                       /* Class OID */
+                       prtMarkerSuppliesClassOffset =
+                       (sizeof(prtMarkerSuppliesClass) /
+                        sizeof(prtMarkerSuppliesClass[0]));
+                                       /* Offset to supply index */
 static const int       prtMarkerSuppliesType[] =
                        { CUPS_OID_prtMarkerSuppliesType, -1 },
                                        /* Type OID */
@@ -257,6 +265,9 @@ backendSNMPSupplies(
       else
         percent = 50;
 
+      if (supplies[i].sclass == CUPS_TC_receptacleThatIsFilled)
+        percent = 100 - percent;
+
       if (percent <= 5)
       {
         switch (supplies[i].type)
@@ -561,14 +572,14 @@ backend_init_supplies(
    /*
     * Yes, read the cache file:
     *
-    *     2 num_supplies charset
+    *     3 num_supplies charset
     *     device description
     *     supply structures...
     */
 
     if (cupsFileGets(cachefile, value, sizeof(value)))
     {
-      if (sscanf(value, "2 %d%d", &num_supplies, &charset) == 2 &&
+      if (sscanf(value, "3 %d%d", &num_supplies, &charset) == 2 &&
           num_supplies <= CUPS_MAX_SUPPLIES &&
           cupsFileGets(cachefile, value, sizeof(value)))
       {
@@ -664,7 +675,7 @@ backend_init_supplies(
 
   if ((cachefile = cupsFileOpen(cachefilename, "w")) != NULL)
   {
-    cupsFilePrintf(cachefile, "2 %d %d\n", num_supplies, charset);
+    cupsFilePrintf(cachefile, "3 %d %d\n", num_supplies, charset);
     cupsFilePrintf(cachefile, "%s\n", description);
 
     if (num_supplies > 0)
@@ -969,6 +980,25 @@ backend_walk_cb(cups_snmp_t *packet,       /* I - SNMP packet */
         packet->object_value.integer > 0)
       supplies[i - 1].max_capacity = packet->object_value.integer;
   }
+  else if (_cupsSNMPIsOIDPrefixed(packet, prtMarkerSuppliesClass))
+  {
+   /*
+    * Get marker class...
+    */
+
+    i = packet->object_name[prtMarkerSuppliesClassOffset];
+    if (i < 1 || i > CUPS_MAX_SUPPLIES ||
+        packet->object_type != CUPS_ASN1_INTEGER)
+      return;
+
+    fprintf(stderr, "DEBUG2: prtMarkerSuppliesClass.1.%d = %d\n", i,
+            packet->object_value.integer);
+
+    if (i > num_supplies)
+      num_supplies = i;
+
+    supplies[i - 1].sclass = packet->object_value.integer;
+  }
   else if (_cupsSNMPIsOIDPrefixed(packet, prtMarkerSuppliesType))
   {
    /*