summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2019-12-11 23:18:39 -0500
committerSolomon Peachy <pizza@shaftnet.org>2019-12-11 23:20:04 -0500
commit0a70fd1612858db7844992218f2b0559bdb334be (patch)
tree9cce9c849306a39a8851f42a19120ebfc3d9e59c
parentbb225929abaacb3f3825f985e68900dea2022a0a (diff)
downloadselphy_print-0a70fd1612858db7844992218f2b0559bdb334be.tar.gz
selphy_print-0a70fd1612858db7844992218f2b0559bdb334be.tar.bz2
selphy_print-0a70fd1612858db7844992218f2b0559bdb334be.zip
common: Add proper definitions for special CUPS marker levels.
And report STATE(media-empty) globally based on this.
-rw-r--r--backend_canonselphy.c8
-rw-r--r--backend_canonselphyneo.c6
-rw-r--r--backend_common.c13
-rw-r--r--backend_common.h4
-rw-r--r--backend_dnpds40.c8
-rw-r--r--backend_kodak1400.c4
-rw-r--r--backend_kodak605.c2
-rw-r--r--backend_kodak6800.c2
-rw-r--r--backend_magicard.c4
-rw-r--r--backend_mitsup95d.c13
-rw-r--r--backend_shinkos1245.c2
-rw-r--r--backend_shinkos2145.c2
-rw-r--r--backend_shinkos6145.c2
-rw-r--r--backend_shinkos6245.c2
-rw-r--r--backend_sonyupd.c8
-rw-r--r--backend_sonyupdneo.c4
16 files changed, 42 insertions, 42 deletions
diff --git a/backend_canonselphy.c b/backend_canonselphy.c
index c5a3913..82c0566 100644
--- a/backend_canonselphy.c
+++ b/backend_canonselphy.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;
diff --git a/backend_canonselphyneo.c b/backend_canonselphyneo.c
index 85047fd..44d2cf7 100644
--- a/backend_canonselphyneo.c
+++ b/backend_canonselphyneo.c
@@ -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;
diff --git a/backend_common.c b/backend_common.c
index a2b170c..1129490 100644
--- a/backend_common.c
+++ b/backend_common.c
@@ -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++) {
diff --git a/backend_common.h b/backend_common.h
index e980bd9..64dfa57 100644
--- a/backend_common.h
+++ b/backend_common.h
@@ -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 \
diff --git a/backend_dnpds40.c b/backend_dnpds40.c
index 76c52bf..e413579 100644
--- a/backend_dnpds40.c
+++ b/backend_dnpds40.c
@@ -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;
}
}
diff --git a/backend_kodak1400.c b/backend_kodak1400.c
index 9e995f2..80e4ae8 100644
--- a/backend_kodak1400.c
+++ b/backend_kodak1400.c
@@ -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;
}
diff --git a/backend_kodak605.c b/backend_kodak605.c
index dc5313d..2ffb05a 100644
--- a/backend_kodak605.c
+++ b/backend_kodak605.c
@@ -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;
}
diff --git a/backend_kodak6800.c b/backend_kodak6800.c
index 740e4bc..8a34a0e 100644
--- a/backend_kodak6800.c
+++ b/backend_kodak6800.c
@@ -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;
}
diff --git a/backend_magicard.c b/backend_magicard.c
index 4a4ba7a..7c504c4 100644
--- a/backend_magicard.c
+++ b/backend_magicard.c
@@ -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;
}
diff --git a/backend_mitsup95d.c b/backend_mitsup95d.c
index 84155ae..1109ef0 100644
--- a/backend_mitsup95d.c
+++ b/backend_mitsup95d.c
@@ -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;
diff --git a/backend_shinkos1245.c b/backend_shinkos1245.c
index 52cc2e2..722ebf5 100644
--- a/backend_shinkos1245.c
+++ b/backend_shinkos1245.c
@@ -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;
}
diff --git a/backend_shinkos2145.c b/backend_shinkos2145.c
index e1762c6..99dd062 100644
--- a/backend_shinkos2145.c
+++ b/backend_shinkos2145.c
@@ -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;
}
diff --git a/backend_shinkos6145.c b/backend_shinkos6145.c
index 5347ca4..801a6b6 100644
--- a/backend_shinkos6145.c
+++ b/backend_shinkos6145.c
@@ -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;
}
diff --git a/backend_shinkos6245.c b/backend_shinkos6245.c
index a156c03..ef3476e 100644
--- a/backend_shinkos6245.c
+++ b/backend_shinkos6245.c
@@ -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;
}
diff --git a/backend_sonyupd.c b/backend_sonyupd.c
index ecc13bb..f6d5d77 100644
--- a/backend_sonyupd.c
+++ b/backend_sonyupd.c
@@ -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;
diff --git a/backend_sonyupdneo.c b/backend_sonyupdneo.c
index 6d75e47..d9e202f 100644
--- a/backend_sonyupdneo.c
+++ b/backend_sonyupdneo.c
@@ -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;