- Use upstream method of handling SNMP quirks in PPDs (STR #3551, bug
#581825).
This commit is contained in:
parent
c1fd48d63a
commit
fdf33eb9cd
@ -1,36 +1,34 @@
|
||||
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 @@
|
||||
+++ cups-1.4.3/backend/snmp-supplies.c 2010-06-09 16:27:05.515019804 +0100
|
||||
@@ -38,6 +38,13 @@
|
||||
|
||||
|
||||
/*
|
||||
+ * Printer quirks...
|
||||
+ */
|
||||
+
|
||||
+/* The prtMarkerSuppliesLevel values are percentages, not levels
|
||||
+ * relative to the stated capacity. */
|
||||
+#define QUIRK_LEVEL_IS_PERCENTAGE (1<<0)
|
||||
+#define QUIRK_CAPACITY (1<<0)
|
||||
+
|
||||
+
|
||||
+/*
|
||||
* Local structures...
|
||||
*/
|
||||
|
||||
@@ -57,6 +66,12 @@ typedef struct /**** Printer state ta
|
||||
@@ -57,6 +64,12 @@ typedef struct /**** Printer state ta
|
||||
const char *keyword; /* IPP printer-state-reasons keyword */
|
||||
} backend_state_t;
|
||||
|
||||
+typedef struct /**** Printer quirk table ****/
|
||||
+typedef struct /**** Quirk names table ****/
|
||||
+{
|
||||
+ const char *description; /* hrDeviceDescr */
|
||||
+ int quirks; /* quirks (bitmask) */
|
||||
+} printer_quirk_t;
|
||||
+ int bit; /* Quirk bit */
|
||||
+ const char *keyword; /* cupsSNMPQuirks keyword */
|
||||
+} quirk_name_t;
|
||||
+
|
||||
|
||||
/*
|
||||
* Local globals...
|
||||
@@ -68,6 +83,7 @@ static int current_state = -1;
|
||||
@@ -68,6 +81,7 @@ static int current_state = -1;
|
||||
static int charset = -1; /* Character set for supply names */
|
||||
static int num_supplies = 0;
|
||||
/* Number of supplies found */
|
||||
@ -38,29 +36,41 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
|
||||
static backend_supplies_t supplies[CUPS_MAX_SUPPLIES];
|
||||
/* Supply information */
|
||||
|
||||
@@ -153,6 +169,11 @@ static const backend_state_t const print
|
||||
@@ -153,6 +167,15 @@ static const backend_state_t const print
|
||||
{ CUPS_TC_outputFull, "output-area-full-warning" }
|
||||
};
|
||||
|
||||
+static const printer_quirk_t const printer_quirks[] =
|
||||
+static const quirk_name_t const quirk_names[] =
|
||||
+ {
|
||||
+ { "Officejet Pro 8500 A909g", QUIRK_LEVEL_IS_PERCENTAGE }
|
||||
+ /*
|
||||
+ * The prtMarkerSuppliesLevel values are
|
||||
+ * percentages, not levels relative to the
|
||||
+ * stated capacity.
|
||||
+ */
|
||||
+ { QUIRK_CAPACITY, "capacity" }
|
||||
+ };
|
||||
+
|
||||
|
||||
/*
|
||||
* Local functions...
|
||||
@@ -208,6 +229,9 @@ backendSNMPSupplies(
|
||||
@@ -208,6 +231,9 @@ backendSNMPSupplies(
|
||||
if (i)
|
||||
*ptr++ = ',';
|
||||
|
||||
+ if (quirks & QUIRK_LEVEL_IS_PERCENTAGE)
|
||||
+ if (quirks & QUIRK_CAPACITY)
|
||||
+ 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(
|
||||
@@ -305,6 +331,7 @@ backend_init_supplies(
|
||||
http_addr_t *addr) /* I - Printer address */
|
||||
{
|
||||
int i, /* Looping var */
|
||||
+ len, /* Quirk name length */
|
||||
type; /* Current marker type */
|
||||
cups_file_t *cachefile; /* Cache file */
|
||||
const char *cachedir; /* CUPS_CACHEDIR value */
|
||||
@@ -366,6 +393,7 @@ backend_init_supplies(
|
||||
current_state = -1;
|
||||
num_supplies = -1;
|
||||
charset = -1;
|
||||
@ -68,19 +78,38 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
|
||||
|
||||
memset(supplies, 0, sizeof(supplies));
|
||||
|
||||
@@ -404,6 +429,15 @@ backend_init_supplies(
|
||||
@@ -381,6 +409,34 @@ backend_init_supplies(
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "DEBUG2: hrDeviceDesc=\"%s\"\n", description);
|
||||
|
||||
+ for (i = 0; i < sizeof (printer_quirks) / sizeof (printer_quirks[0]); i++)
|
||||
+ if (ppd &&
|
||||
+ (ppdattr = ppdFindAttr(ppd, "cupsSNMPQuirks", NULL)) != NULL &&
|
||||
+ ppdattr->value)
|
||||
+ {
|
||||
+ if (!strcmp (description, printer_quirks[i].description))
|
||||
+ ptr = ppdattr->value;
|
||||
+ while (*ptr != '\0')
|
||||
+ {
|
||||
+ quirks = printer_quirks[i].quirks;
|
||||
+ break;
|
||||
+ /*
|
||||
+ * Match keyword against quirk_names table.
|
||||
+ */
|
||||
+
|
||||
+ for (i = 0; i < sizeof (quirk_names) / sizeof (quirk_names[0]); i++)
|
||||
+ {
|
||||
+ len = strlen (quirk_names[i].keyword);
|
||||
+ if (!strncmp (value, quirk_names[i].keyword, len) &&
|
||||
+ (value[len] == '\0' || value[len] == ' '))
|
||||
+ quirks |= quirk_names[i].bit;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Advance to next keyword.
|
||||
+ */
|
||||
+
|
||||
+ ptr += strcspn (ptr, " ");
|
||||
+ ptr += strspn (ptr, " ");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
ppdClose(ppd);
|
||||
|
||||
/*
|
||||
* See if we have already queried this device...
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@
|
||||
Summary: Common Unix Printing System
|
||||
Name: cups
|
||||
Version: 1.4.3
|
||||
Release: 7%{?dist}
|
||||
Release: 8%{?dist}
|
||||
License: GPLv2
|
||||
Group: System Environment/Daemons
|
||||
Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
|
||||
@ -532,6 +532,10 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{php_extdir}/phpcups.so
|
||||
|
||||
%changelog
|
||||
* Wed Jun 9 2010 Tim Waugh <twaugh@redhat.com> 1:1.4.3-8
|
||||
- Use upstream method of handling SNMP quirks in PPDs (STR #3551,
|
||||
bug #581825).
|
||||
|
||||
* Tue Jun 01 2010 Jiri Popelka <jpopelka@redhat.com> 1:1.4.3-7
|
||||
- Added back still useful str3425.patch.
|
||||
Second part of STR #3425 is still not fixed in 1.4.3
|
||||
|
Loading…
Reference in New Issue
Block a user