notifier - get job attributes
Rodger Devine
rdevine at umich.edu
Thu Mar 25 13:58:03 PDT 2010
Hi Folks,
I'm working on a notifier in C to store printer and job status info.
Using the testnotify.c example we've had luck retrieving default values:
[Notifier] notify-charset (charset): "utf-8"
[Notifier] notify-natural-langugage (naturalLanguage): "en-us"
[Notifier] notify-subscription-id (integer): 1
[Notifier] notify-sequence-number (integer): 2633
[Notifier] notify-subscribed-event (keyword): "job-completed"
[Notifier] printer-up-time (integer): 1269549374
[Notifier] notify-text (textWithoutLanguage): "Job completed."
[Notifier] notify-printer-uri (uri): "ipp://server:631/printers/zilch"
[Notifier] printer-name (nameWithoutLanguage): "zilch"
[Notifier] printer-state (enum): 3
[Notifier] printer-state-reasons (keyword): "none"
[Notifier] printer-is-accepting-jobs (boolean): true
[Notifier] notify-job-id (integer): 2061
[Notifier] job-state (enum): 9
[Notifier] job-name (nameWithoutLanguage): "testnotify.c"
[Notifier] job-state-reasons (keyword): "job-completed-successfully"
[Notifier] job-impressions-completed (integer): 5
But we run into issues getting other job attributes such as job size,
user name, etc. (i.e. "job-k-octets", "job-originating-user-name")
1) Is there a way to get job attributes looping through the IPP request
attributes like so? (see snipets below):
for (group = IPP_TAG_ZERO, attr = ipp->attrs; attr; attr = attr->next)
{ ....
switch (attr->value_tag)
{
case IPP_TAG_ENUM :
...
case IPP_TAG_JOB :
{
int jobid = 0;
int size = 0;
const char *username = NULL;
const char *dest = NULL;
const char *actualdest = NULL;
time_t jobtime = 0;
const char *title = "no title";
ipp_attribute_t *reasons = NULL;
for (i = 0, val = attr->values; i < attr->num_values; i ++, val ++)
{
...
if (!strcmp(attr->name, "job-originating-user-name") &&
attr->value_tag == IPP_TAG_NAME) {
username = attr->values[0].string.text;
fprintf(stderr, "USERNAME::: %s", username);
2) Reviewing the lpstat.c (-o option) also sheds some light on the
issue, suggesting that building an IPP_GET_JOBS request and using the
cupsDoRequest function is the way to go.
Rodger
More information about the cups
mailing list