|
Packit |
2fc92b |
/*
|
|
Packit |
2fc92b |
* Subscription definitions for the CUPS scheduler.
|
|
Packit |
2fc92b |
*
|
|
Packit |
2fc92b |
* Copyright 2007-2010 by Apple Inc.
|
|
Packit |
2fc92b |
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
|
Packit |
2fc92b |
*
|
|
Packit |
2fc92b |
* These coded instructions, statements, and computer programs are the
|
|
Packit |
2fc92b |
* property of Apple Inc. and are protected by Federal copyright
|
|
Packit |
2fc92b |
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
|
Packit |
2fc92b |
* which should have been included with this file. If this file is
|
|
Packit |
2fc92b |
* missing or damaged, see the license at "http://www.cups.org/".
|
|
Packit |
2fc92b |
*/
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
/*
|
|
Packit |
2fc92b |
* Event mask enumeration...
|
|
Packit |
2fc92b |
*/
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
typedef enum
|
|
Packit |
2fc92b |
{
|
|
Packit |
2fc92b |
/* Individual printer events... */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_STATE = 0x0001, /* Sent after generic printer state change */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_RESTARTED = 0x0002,
|
|
Packit |
2fc92b |
/* Sent after printer restarted */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_SHUTDOWN = 0x0004,/* Sent after printer shutdown */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_STOPPED = 0x0008, /* Sent after printer stopped */
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_CONFIG = 0x0010, /* Send after add/modify changes attrs */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_FINISHINGS_CHANGED = 0x0020,
|
|
Packit |
2fc92b |
/* Sent after finishings-supported changed */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_MEDIA_CHANGED = 0x0040,
|
|
Packit |
2fc92b |
/* Sent after media-supported changed */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_ADDED = 0x0080, /* Sent after printer added */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_DELETED = 0x0100, /* Sent after printer deleted */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_MODIFIED = 0x0200,/* Sent after printer modified */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_QUEUE_ORDER_CHANGED = 0x0400,
|
|
Packit |
2fc92b |
/* Sent when the order of jobs is changed */
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
/* Convenience printer event groupings... */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_STATE_CHANGED = 0x000f,
|
|
Packit |
2fc92b |
/* STATE + RESTARTED + SHUTDOWN + STOPPED */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_CONFIG_CHANGED = 0x0070,
|
|
Packit |
2fc92b |
/* CONFIG + FINISHINGS_CHANGED + MEDIA_CHANGED */
|
|
Packit |
2fc92b |
CUPSD_EVENT_PRINTER_CHANGED = 0x07ff, /* All of the above */
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
/* Individual job events... */
|
|
Packit |
2fc92b |
CUPSD_EVENT_JOB_STATE = 0x0800, /* Any state change */
|
|
Packit |
2fc92b |
CUPSD_EVENT_JOB_CREATED = 0x1000, /* Send after job is created */
|
|
Packit |
2fc92b |
CUPSD_EVENT_JOB_COMPLETED = 0x2000, /* Sent after job is completed */
|
|
Packit |
2fc92b |
CUPSD_EVENT_JOB_STOPPED = 0x4000, /* Sent after job is stopped */
|
|
Packit |
2fc92b |
CUPSD_EVENT_JOB_CONFIG_CHANGED = 0x8000,
|
|
Packit |
2fc92b |
/* Sent after set-job-attributes */
|
|
Packit |
2fc92b |
CUPSD_EVENT_JOB_PROGRESS = 0x10000, /* Sent for each page */
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
/* Convenience job event grouping... */
|
|
Packit |
2fc92b |
CUPSD_EVENT_JOB_STATE_CHANGED = 0x7800,
|
|
Packit |
2fc92b |
/* STATE + CREATED + COMPLETED + STOPPED */
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
/* Server events... */
|
|
Packit |
2fc92b |
CUPSD_EVENT_SERVER_RESTARTED = 0x20000,/* Sent after server restarts */
|
|
Packit |
2fc92b |
CUPSD_EVENT_SERVER_STARTED = 0x40000, /* Sent when server first starts */
|
|
Packit |
2fc92b |
CUPSD_EVENT_SERVER_STOPPED = 0x80000, /* Sent when server is stopped */
|
|
Packit |
2fc92b |
CUPSD_EVENT_SERVER_AUDIT = 0x100000, /* Security-related stuff */
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
/* Everything and nothing... */
|
|
Packit |
2fc92b |
CUPSD_EVENT_NONE = 0, /* Nothing */
|
|
Packit |
2fc92b |
CUPSD_EVENT_ALL = 0x1fffff /* Everything */
|
|
Packit |
2fc92b |
} cupsd_eventmask_t;
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
/*
|
|
Packit |
2fc92b |
* Notiification support structures...
|
|
Packit |
2fc92b |
*/
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
typedef struct cupsd_event_s /**** Event structure ****/
|
|
Packit |
2fc92b |
{
|
|
Packit |
2fc92b |
cupsd_eventmask_t event; /* Event */
|
|
Packit |
2fc92b |
time_t time; /* Time of event */
|
|
Packit |
2fc92b |
ipp_t *attrs; /* Notification message */
|
|
Packit |
2fc92b |
cupsd_printer_t *dest; /* Associated printer, if any */
|
|
Packit |
2fc92b |
cupsd_job_t *job; /* Associated job, if any */
|
|
Packit |
2fc92b |
} cupsd_event_t;
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
typedef struct cupsd_subscription_s /**** Subscription structure ****/
|
|
Packit |
2fc92b |
{
|
|
Packit |
2fc92b |
int id; /* subscription-id */
|
|
Packit |
2fc92b |
unsigned mask; /* Event mask */
|
|
Packit |
2fc92b |
char *owner; /* notify-subscriber-user-name */
|
|
Packit |
2fc92b |
char *recipient; /* notify-recipient-uri, if applicable */
|
|
Packit |
2fc92b |
unsigned char user_data[64]; /* notify-user-data */
|
|
Packit |
2fc92b |
int user_data_len; /* Length of notify-user-data */
|
|
Packit |
2fc92b |
int lease; /* notify-lease-duration */
|
|
Packit |
2fc92b |
int interval; /* notify-time-interval */
|
|
Packit |
2fc92b |
cupsd_printer_t *dest; /* notify-printer-uri, if any */
|
|
Packit |
2fc92b |
cupsd_job_t *job; /* notify-job-id, if any */
|
|
Packit |
2fc92b |
int pid; /* Process ID of notifier */
|
|
Packit |
2fc92b |
int pipe; /* Pipe to notifier */
|
|
Packit |
2fc92b |
int status; /* Exit status of notifier */
|
|
Packit |
2fc92b |
time_t last; /* Time of last notification */
|
|
Packit |
2fc92b |
time_t expire; /* Lease expiration time */
|
|
Packit |
2fc92b |
int first_event_id, /* First event-id in cache */
|
|
Packit |
2fc92b |
next_event_id; /* Next event-id to use */
|
|
Packit |
2fc92b |
cups_array_t *events; /* Cached events */
|
|
Packit |
2fc92b |
} cupsd_subscription_t;
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
/*
|
|
Packit |
2fc92b |
* Globals...
|
|
Packit |
2fc92b |
*/
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
VAR int MaxSubscriptions VALUE(100),
|
|
Packit |
2fc92b |
/* Overall subscription limit */
|
|
Packit |
2fc92b |
MaxSubscriptionsPerJob VALUE(0),
|
|
Packit |
2fc92b |
/* Per-job subscription limit */
|
|
Packit |
2fc92b |
MaxSubscriptionsPerPrinter VALUE(0),
|
|
Packit |
2fc92b |
/* Per-printer subscription limit */
|
|
Packit |
2fc92b |
MaxSubscriptionsPerUser VALUE(0),
|
|
Packit |
2fc92b |
/* Per-user subscription limit */
|
|
Packit |
2fc92b |
NextSubscriptionId VALUE(1),
|
|
Packit |
2fc92b |
/* Next subscription ID */
|
|
Packit |
2fc92b |
DefaultLeaseDuration VALUE(86400),
|
|
Packit |
2fc92b |
/* Default notify-lease-duration */
|
|
Packit |
2fc92b |
MaxLeaseDuration VALUE(0);
|
|
Packit |
2fc92b |
/* Maximum notify-lease-duration */
|
|
Packit |
2fc92b |
VAR cups_array_t *Subscriptions VALUE(NULL);
|
|
Packit |
2fc92b |
/* Active subscriptions */
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
VAR int MaxEvents VALUE(100); /* Maximum number of events */
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
VAR unsigned LastEvent VALUE(0); /* Last event(s) processed */
|
|
Packit |
2fc92b |
VAR int NotifierPipes[2] VALUE2(-1, -1);
|
|
Packit |
2fc92b |
/* Pipes for notifier error/debug output */
|
|
Packit |
2fc92b |
VAR cupsd_statbuf_t *NotifierStatusBuffer VALUE(NULL);
|
|
Packit |
2fc92b |
/* Status buffer for pipes */
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
/*
|
|
Packit |
2fc92b |
* Prototypes...
|
|
Packit |
2fc92b |
*/
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
extern void cupsdAddEvent(cupsd_eventmask_t event, cupsd_printer_t *dest,
|
|
Packit |
2fc92b |
cupsd_job_t *job, const char *text, ...);
|
|
Packit |
2fc92b |
extern cupsd_subscription_t *
|
|
Packit |
2fc92b |
cupsdAddSubscription(unsigned mask, cupsd_printer_t *dest,
|
|
Packit |
2fc92b |
cupsd_job_t *job, const char *uri,
|
|
Packit |
2fc92b |
int sub_id);
|
|
Packit |
2fc92b |
extern void cupsdDeleteAllSubscriptions(void);
|
|
Packit |
2fc92b |
extern void cupsdDeleteSubscription(cupsd_subscription_t *sub, int update);
|
|
Packit |
2fc92b |
extern const char *
|
|
Packit |
2fc92b |
cupsdEventName(cupsd_eventmask_t event);
|
|
Packit |
2fc92b |
extern cupsd_eventmask_t
|
|
Packit |
2fc92b |
cupsdEventValue(const char *name);
|
|
Packit |
2fc92b |
|
|
Packit |
2fc92b |
extern cupsd_subscription_t *
|
|
Packit |
2fc92b |
cupsdFindSubscription(int id);
|
|
Packit |
2fc92b |
extern void cupsdExpireSubscriptions(cupsd_printer_t *dest,
|
|
Packit |
2fc92b |
cupsd_job_t *job);
|
|
Packit |
2fc92b |
extern void cupsdLoadAllSubscriptions(void);
|
|
Packit |
2fc92b |
extern void cupsdSaveAllSubscriptions(void);
|
|
Packit |
2fc92b |
extern void cupsdStopAllNotifiers(void);
|