From 9347367fba72090eb5a59714477976ebb98918c7 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Tue, 13 Apr 2010 11:40:32 +0000 Subject: [PATCH] - Handle SNMP supply level quirks (bug #581825). --- cups-snmp-quirks.patch | 86 ++++++++++++++++++++++++++++++++++++++++++ cups.spec | 7 +++- 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 cups-snmp-quirks.patch diff --git a/cups-snmp-quirks.patch b/cups-snmp-quirks.patch new file mode 100644 index 0000000..81639bb --- /dev/null +++ b/cups-snmp-quirks.patch @@ -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... + */ diff --git a/cups.spec b/cups.spec index d822f37..53e9ae1 100644 --- a/cups.spec +++ b/cups.spec @@ -8,7 +8,7 @@ Summary: Common Unix Printing System Name: cups Version: 1.4.3 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Group: System Environment/Daemons Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2 @@ -56,6 +56,7 @@ Patch29: cups-0755.patch Patch30: cups-EAI_AGAIN.patch Patch31: cups-str3505.patch Patch32: cups-str3541.patch +Patch33: cups-snmp-quirks.patch Patch100: cups-lspp.patch @@ -218,6 +219,7 @@ module. %patch30 -p1 -b .EAI_AGAIN %patch31 -p1 -b .str3505 %patch32 -p1 -b .str3541 +%patch33 -p1 -b .snmp-quirks %if %lspp %patch100 -p1 -b .lspp @@ -521,6 +523,9 @@ rm -rf $RPM_BUILD_ROOT %{php_extdir}/phpcups.so %changelog +* Tue Apr 13 2010 Tim Waugh 1:1.4.3-3 +- Handle SNMP supply level quirks (bug #581825). + * Wed Mar 31 2010 Tim Waugh 1:1.4.3-2 - Another BrowsePoll fix: handle EAI_NODATA as well (bug #567353).