- Handle SNMP supply level quirks (bug #581825).

This commit is contained in:
Tim Waugh 2010-04-13 11:34:34 +00:00
parent 047219f6ca
commit 0b3b2f7afb
2 changed files with 92 additions and 1 deletions

86
cups-snmp-quirks.patch Normal file
View File

@ -0,0 +1,86 @@
diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-supplies.c
--- cups-1.4.3/backend/snmp-supplies.c.snmp-quirks 2009-11-20 01:27:57.000000000 +0000
+++ cups-1.4.3/backend/snmp-supplies.c 2010-04-13 11:54:13.508023630 +0100
@@ -38,6 +38,15 @@
/*
+ * Printer quirks...
+ */
+
+/* The prtMarkerSuppliesLevel values are percentages, not levels
+ * relative to the stated capacity. */
+#define QUIRK_LEVEL_IS_PERCENTAGE (1<<0)
+
+
+/*
* Local structures...
*/
@@ -57,6 +66,12 @@ typedef struct /**** Printer state ta
const char *keyword; /* IPP printer-state-reasons keyword */
} backend_state_t;
+typedef struct /**** Printer quirk table ****/
+{
+ const char *description; /* hrDeviceDescr */
+ int quirks; /* quirks (bitmask) */
+} printer_quirk_t;
+
/*
* Local globals...
@@ -68,6 +83,7 @@ static int current_state = -1;
static int charset = -1; /* Character set for supply names */
static int num_supplies = 0;
/* Number of supplies found */
+static int quirks = 0; /* Printer quirks */
static backend_supplies_t supplies[CUPS_MAX_SUPPLIES];
/* Supply information */
@@ -153,6 +169,11 @@ static const backend_state_t const print
{ CUPS_TC_outputFull, "output-area-full-warning" }
};
+static const printer_quirk_t const printer_quirks[] =
+ {
+ { "Officejet Pro 8500 A909g", QUIRK_LEVEL_IS_PERCENTAGE }
+ };
+
/*
* Local functions...
@@ -208,6 +229,9 @@ backendSNMPSupplies(
if (i)
*ptr++ = ',';
+ if (quirks & QUIRK_LEVEL_IS_PERCENTAGE)
+ supplies[i].max_capacity = 100;
+
if (supplies[i].max_capacity > 0)
sprintf(ptr, "%d", 100 * supplies[i].level / supplies[i].max_capacity);
else
@@ -366,6 +390,7 @@ backend_init_supplies(
current_state = -1;
num_supplies = -1;
charset = -1;
+ quirks = 0;
memset(supplies, 0, sizeof(supplies));
@@ -404,6 +429,15 @@ backend_init_supplies(
fprintf(stderr, "DEBUG2: hrDeviceDesc=\"%s\"\n", description);
+ for (i = 0; i < sizeof (printer_quirks) / sizeof (printer_quirks[0]); i++)
+ {
+ if (!strcmp (description, printer_quirks[i].description))
+ {
+ quirks = printer_quirks[i].quirks;
+ break;
+ }
+ }
+
/*
* See if we have already queried this device...
*/

View File

@ -8,7 +8,7 @@
Summary: Common Unix Printing System Summary: Common Unix Printing System
Name: cups Name: cups
Version: 1.4.3 Version: 1.4.3
Release: 2%{?dist} Release: 3%{?dist}
License: GPLv2 License: GPLv2
Group: System Environment/Daemons Group: System Environment/Daemons
Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2 Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@ -63,6 +63,7 @@ Patch29: cups-0755.patch
Patch30: cups-EAI_AGAIN.patch Patch30: cups-EAI_AGAIN.patch
Patch31: cups-str3505.patch Patch31: cups-str3505.patch
Patch32: cups-str3541.patch Patch32: cups-str3541.patch
Patch33: cups-snmp-quirks.patch
Patch100: cups-lspp.patch Patch100: cups-lspp.patch
@ -262,6 +263,7 @@ module.
%patch31 -p1 -b .str3505 %patch31 -p1 -b .str3505
# Fix lpstat to adhere to -o option. # Fix lpstat to adhere to -o option.
%patch32 -p1 -b .str3541 %patch32 -p1 -b .str3541
%patch33 -p1 -b .snmp-quirks
%if %lspp %if %lspp
# LSPP support. # LSPP support.
@ -562,6 +564,9 @@ rm -rf $RPM_BUILD_ROOT
%{php_extdir}/phpcups.so %{php_extdir}/phpcups.so
%changelog %changelog
* Tue Apr 13 2010 Tim Waugh <twaugh@redhat.com> 1:1.4.3-3
- Handle SNMP supply level quirks (bug #581825).
* Wed Mar 31 2010 Tim Waugh <twaugh@redhat.com> 1:1.4.3-2 * Wed Mar 31 2010 Tim Waugh <twaugh@redhat.com> 1:1.4.3-2
- Another BrowsePoll fix: handle EAI_NODATA as well (bug #567353). - Another BrowsePoll fix: handle EAI_NODATA as well (bug #567353).