common: Add proper definitions for special CUPS marker levels.

And report STATE(media-empty) globally based on this.
master
Solomon Peachy 3 years ago
parent b7560192b9
commit 13d62550f3
  1. 8
      backend_canonselphy.c
  2. 6
      backend_canonselphyneo.c
  3. 13
      backend_common.c
  4. 4
      backend_common.h
  5. 8
      backend_dnpds40.c
  6. 4
      backend_kodak1400.c
  7. 2
      backend_kodak605.c
  8. 2
      backend_kodak6800.c
  9. 4
      backend_magicard.c
  10. 13
      backend_mitsup95d.c
  11. 2
      backend_shinkos1245.c
  12. 2
      backend_shinkos2145.c
  13. 2
      backend_shinkos6145.c
  14. 2
      backend_shinkos6245.c
  15. 8
      backend_sonyupd.c
  16. 4
      backend_sonyupdneo.c

@ -641,7 +641,7 @@ static int canonselphy_attach(void *vctx, struct libusb_device_handle *dev, int
/* Fill out marker structure */
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.levelmax = -1; /* Unknown */
ctx->marker.levelmax = CUPS_MARKER_UNAVAILABLE;
if (test_mode < TEST_MODE_NOATTACH) {
/* Read printer status. Twice. */
@ -656,9 +656,9 @@ static int canonselphy_attach(void *vctx, struct libusb_device_handle *dev, int
return CUPS_BACKEND_FAILED;
if (ctx->printer->error_detect(rdbuf))
ctx->marker.levelnow = 0; /* Out of media */
ctx->marker.levelnow = 0;
else
ctx->marker.levelnow = -3; /* Unknown but OK */
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN_OK;
ctx->marker.name = ctx->printer->pgcode_names? ctx->printer->pgcode_names(rdbuf, ctx->printer, &ctx->marker.numtype) : "Unknown";
} else {
@ -1115,7 +1115,7 @@ static int canonselphy_query_markers(void *vctx, struct marker **markers, int *c
if (ctx->printer->error_detect(rdbuf))
ctx->marker.levelnow = 0;
else
ctx->marker.levelnow = -3;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN_OK;
*markers = &ctx->marker;
*count = 1;

@ -225,11 +225,11 @@ static int selphyneo_attach(void *vctx, struct libusb_device_handle *dev, int ty
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = selphynew_pgcodes(rdback.data[6]);
ctx->marker.numtype = rdback.data[6];
ctx->marker.levelmax = -1;
ctx->marker.levelmax = CUPS_MARKER_UNAVAILABLE;
if (rdback.data[2]) {
ctx->marker.levelnow = 0;
} else {
ctx->marker.levelnow = -3;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN_OK;
}
return CUPS_BACKEND_OK;
@ -506,7 +506,7 @@ static int selphyneo_query_markers(void *vctx, struct marker **markers, int *cou
if (rdback.data[2])
ctx->marker.levelnow = 0;
else
ctx->marker.levelnow = -3;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN_OK;
*markers = &ctx->marker;
*count = 1;

@ -31,7 +31,7 @@
#include <errno.h>
#include <signal.h>
#define BACKEND_VERSION "0.98"
#define BACKEND_VERSION "0.99"
#ifndef URI_PREFIX
#error "Must Define URI_PREFIX"
#endif
@ -1462,13 +1462,13 @@ minimal:
ATTR("marker-message=");
for (i = 0 ; i < marker_count; i++) {
switch (markers[i].levelnow) {
case -1:
case CUPS_MARKER_UNAVAILABLE:
DEBUG2("'\"Unable to query remaining prints on %s media\"'", markers[i].name);
break;
case -2:
case CUPS_MARKER_UNKNOWN:
DEBUG2("'\"Unknown remaining prints on %s media\"'", markers[i].name);
break;
case -3:
case CUPS_MARKER_UNKNOWN_OK:
DEBUG2("'\"One or more remaining prints on %s media\"'", markers[i].name);
break;
default:
@ -1481,6 +1481,11 @@ minimal:
DEBUG2("\n");
}
if (markers[0].levelnow == 0)
STATE("+media-empty\n");
else if (markers[0].levelnow > 0 || markers[0].levelnow == CUPS_MARKER_UNKNOWN_OK)
STATE("-media-empty\n");
/* If we're running as a CUPS backend, report the media type */
if (full && getenv("DEVICE_URI")) {
for (i = 0 ; i < marker_count ; i++) {

@ -295,6 +295,10 @@ extern struct dyesub_backend BACKEND;
#define CUPS_BACKEND_RETRY 6 /* Retry later */
#define CUPS_BACKEND_RETRY_CURRENT 7 /* Retry immediately */
#define CUPS_MARKER_UNAVAILABLE -1
#define CUPS_MARKER_UNKNOWN -2
#define CUPS_MARKER_UNKNOWN_OK -3
/* Argument processing */
#define GETOPT_LIST_GLOBAL "d:DfGhv"
#define GETOPT_PROCESS_GLOBAL \

@ -1225,7 +1225,7 @@ static int dnpds40_attach(void *vctx, struct libusb_device_handle *dev, int type
ctx->marker[0].name = ctx->media_text;
ctx->marker[0].numtype = ctx->media;
ctx->marker[0].levelmax = ctx->media_count_new;
ctx->marker[0].levelnow = -2;
ctx->marker[0].levelnow = CUPS_MARKER_UNKNOWN;
ctx->marker_count = 1;
if (ctx->type == P_DNP_DS80D) {
@ -1233,7 +1233,7 @@ static int dnpds40_attach(void *vctx, struct libusb_device_handle *dev, int type
ctx->marker[1].name = dnpds80_duplex_media_types(ctx->duplex_media);
ctx->marker[1].numtype = ctx->duplex_media;
ctx->marker[1].levelmax = ctx->marker[0].levelmax/2;
ctx->marker[1].levelnow = -2;
ctx->marker[1].levelnow = CUPS_MARKER_UNKNOWN;
ctx->marker_count++;
}
@ -3084,10 +3084,10 @@ static int dnpds40_query_markers(void *vctx, struct marker **markers, int *count
ctx->marker[1].levelnow = 0;
break;
case DUPLEX_UNIT_PAPER_PROTECTIVE:
ctx->marker[1].levelnow = -1;
ctx->marker[1].levelnow = CUPS_MARKER_UNAVAILABLE;
break;
case DUPLEX_UNIT_PAPER_PRESENT:
ctx->marker[1].levelnow = -3;
ctx->marker[1].levelnow = CUPS_MARKER_UNKNOWN_OK;
break;
}
}

@ -301,8 +301,8 @@ static int kodak1400_attach(void *vctx, struct libusb_device_handle *dev, int ty
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = "Unknown";
ctx->marker.numtype = -1;
ctx->marker.levelmax = -1;
ctx->marker.levelnow = -2;
ctx->marker.levelmax = CUPS_MARKER_UNAVAILABLE;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
return CUPS_BACKEND_OK;
}

@ -397,7 +397,7 @@ static int kodak605_attach(void *vctx, struct libusb_device_handle *dev, int typ
ctx->marker.name = kodak6_mediatypes(ctx->media->type);
ctx->marker.numtype = ctx->media->type;
ctx->marker.levelmax = 100; /* Ie percentage */
ctx->marker.levelnow = -2;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
return CUPS_BACKEND_OK;
}

@ -738,7 +738,7 @@ static int kodak6800_attach(void *vctx, struct libusb_device_handle *dev, int ty
ctx->marker.name = kodak6_mediatypes(ctx->media_type);
ctx->marker.numtype = ctx->media_type;
ctx->marker.levelmax = 100; /* Ie percentage */
ctx->marker.levelnow = -2;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
return CUPS_BACKEND_OK;
}

@ -452,8 +452,8 @@ static int magicard_attach(void *vctx, struct libusb_device_handle *dev, int typ
ctx->marker.color = "#00FFFF#FF00FF#FFFF00"; // XXX YMCK too!
ctx->marker.name = "Unknown"; // LC1/LC3/LC6/LC8
ctx->marker.numtype = -1;
ctx->marker.levelmax = -1;
ctx->marker.levelnow = -2;
ctx->marker.levelmax = CUPS_MARKER_UNAVAILABLE;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
return CUPS_BACKEND_OK;
}

@ -146,8 +146,8 @@ static int mitsup95d_attach(void *vctx, struct libusb_device_handle *dev, int ty
ctx->marker.color = "#000000"; /* Ie black! */
ctx->marker.name = "Unknown";
ctx->marker.numtype = -1;
ctx->marker.levelmax = -1;
ctx->marker.levelnow = -2;
ctx->marker.levelmax = CUPS_MARKER_UNAVAILABLE;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
return CUPS_BACKEND_OK;
}
@ -557,7 +557,7 @@ static int mitsup95d_query_markers(void *vctx, struct marker **markers, int *cou
if (mitsup95d_get_status(ctx, queryresp))
return CUPS_BACKEND_FAILED;
ctx->marker.levelnow = -3;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN_OK;
if (ctx->type == P_MITSU_P95D) {
if (queryresp[6] & 0x40) {
@ -569,13 +569,6 @@ static int mitsup95d_query_markers(void *vctx, struct marker **markers, int *cou
}
}
/* Lot state */
if (ctx->marker.levelnow)
STATE("-media-empty\n");
else
STATE("+media-empty\n");
*markers = &ctx->marker;
*count = 1;

@ -977,7 +977,7 @@ static int shinkos1245_attach(void *vctx, struct libusb_device_handle *dev, int
ctx->marker.name = ctx->media_8x12 ? "8x12" : "8x10";
ctx->marker.numtype = ctx->media_8x12;
ctx->marker.levelmax = ctx->media_8x12 ? 230 : 280;
ctx->marker.levelnow = -2;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
return CUPS_BACKEND_OK;
}

@ -890,7 +890,7 @@ static int shinkos2145_attach(void *vctx, struct libusb_device_handle *dev, int
ctx->marker.name = sinfonia_print_codes(ctx->media_code, 0);
ctx->marker.numtype = ctx->media_code;
ctx->marker.levelmax = media_prints;
ctx->marker.levelnow = -2;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
return CUPS_BACKEND_OK;
}

@ -1049,7 +1049,7 @@ static int shinkos6145_attach(void *vctx, struct libusb_device_handle *dev, int
ctx->marker.name = print_ribbons(ctx->media.ribbon_code);
ctx->marker.numtype = ctx->media.ribbon_code;
ctx->marker.levelmax = ribbon_sizes(ctx->media.ribbon_code);
ctx->marker.levelnow = -2;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
return CUPS_BACKEND_OK;
}

@ -1015,7 +1015,7 @@ static int shinkos6245_attach(void *vctx, struct libusb_device_handle *dev, int
ctx->marker.name = ribbon_sizes(ctx->media.ribbon_code);
ctx->marker.numtype = ctx->media.ribbon_code;
ctx->marker.levelmax = 100;
ctx->marker.levelnow = -2;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
return CUPS_BACKEND_OK;
}

@ -121,8 +121,8 @@ static int upd_attach(void *vctx, struct libusb_device_handle *dev, int type,
ctx->marker.name = "Unknown";
ctx->marker.numtype = -1;
ctx->marker.levelmax = -1;
ctx->marker.levelnow = -2;
ctx->marker.levelmax = CUPS_MARKER_UNAVAILABLE;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
return CUPS_BACKEND_OK;
}
@ -583,10 +583,8 @@ static int upd_query_markers(void *vctx, struct marker **markers, int *count)
if (ctx->stsbuf.sts1 == 0x40 ||
ctx->stsbuf.sts1 == 0x08) {
ctx->marker.levelnow = 0;
STATE("+media-empty\n");
} else {
ctx->marker.levelnow = -3;
STATE("-media-empty\n");
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN_OK;
}
return CUPS_BACKEND_OK;

@ -142,8 +142,8 @@ static int updneo_attach(void *vctx, struct libusb_device_handle *dev, int type,
ctx->marker.name = "Unknown";
ctx->marker.numtype = -1;
ctx->marker.levelmax = -1;
ctx->marker.levelnow = -2;
ctx->marker.levelmax = CUPS_MARKER_UNAVAILABLE;
ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
} else {
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->native_bpp = 3;

Loading…
Cancel
Save