2 * Subscription definitions for the CUPS scheduler.
4 * Copyright 2007-2010 by Apple Inc.
5 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
7 * These coded instructions, statements, and computer programs are the
8 * property of Apple Inc. and are protected by Federal copyright
9 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 * which should have been included with this file. If this file is
11 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * Event mask enumeration...
20 /* Individual printer events... */
21 CUPSD_EVENT_PRINTER_STATE
= 0x0001, /* Sent after generic printer state change */
22 CUPSD_EVENT_PRINTER_RESTARTED
= 0x0002,
23 /* Sent after printer restarted */
24 CUPSD_EVENT_PRINTER_SHUTDOWN
= 0x0004,/* Sent after printer shutdown */
25 CUPSD_EVENT_PRINTER_STOPPED
= 0x0008, /* Sent after printer stopped */
27 CUPSD_EVENT_PRINTER_CONFIG
= 0x0010, /* Send after add/modify changes attrs */
28 CUPSD_EVENT_PRINTER_FINISHINGS_CHANGED
= 0x0020,
29 /* Sent after finishings-supported changed */
30 CUPSD_EVENT_PRINTER_MEDIA_CHANGED
= 0x0040,
31 /* Sent after media-supported changed */
32 CUPSD_EVENT_PRINTER_ADDED
= 0x0080, /* Sent after printer added */
33 CUPSD_EVENT_PRINTER_DELETED
= 0x0100, /* Sent after printer deleted */
34 CUPSD_EVENT_PRINTER_MODIFIED
= 0x0200,/* Sent after printer modified */
35 CUPSD_EVENT_PRINTER_QUEUE_ORDER_CHANGED
= 0x0400,
36 /* Sent when the order of jobs is changed */
38 /* Convenience printer event groupings... */
39 CUPSD_EVENT_PRINTER_STATE_CHANGED
= 0x000f,
40 /* STATE + RESTARTED + SHUTDOWN + STOPPED */
41 CUPSD_EVENT_PRINTER_CONFIG_CHANGED
= 0x0070,
42 /* CONFIG + FINISHINGS_CHANGED + MEDIA_CHANGED */
43 CUPSD_EVENT_PRINTER_CHANGED
= 0x07ff, /* All of the above */
45 /* Individual job events... */
46 CUPSD_EVENT_JOB_STATE
= 0x0800, /* Any state change */
47 CUPSD_EVENT_JOB_CREATED
= 0x1000, /* Send after job is created */
48 CUPSD_EVENT_JOB_COMPLETED
= 0x2000, /* Sent after job is completed */
49 CUPSD_EVENT_JOB_STOPPED
= 0x4000, /* Sent after job is stopped */
50 CUPSD_EVENT_JOB_CONFIG_CHANGED
= 0x8000,
51 /* Sent after set-job-attributes */
52 CUPSD_EVENT_JOB_PROGRESS
= 0x10000, /* Sent for each page */
54 /* Convenience job event grouping... */
55 CUPSD_EVENT_JOB_STATE_CHANGED
= 0x7800,
56 /* STATE + CREATED + COMPLETED + STOPPED */
58 /* Server events... */
59 CUPSD_EVENT_SERVER_RESTARTED
= 0x20000,/* Sent after server restarts */
60 CUPSD_EVENT_SERVER_STARTED
= 0x40000, /* Sent when server first starts */
61 CUPSD_EVENT_SERVER_STOPPED
= 0x80000, /* Sent when server is stopped */
62 CUPSD_EVENT_SERVER_AUDIT
= 0x100000, /* Security-related stuff */
64 /* Everything and nothing... */
65 CUPSD_EVENT_NONE
= 0, /* Nothing */
66 CUPSD_EVENT_ALL
= 0x1fffff /* Everything */
71 * Notiification support structures...
74 typedef struct cupsd_event_s
/**** Event structure ****/
76 cupsd_eventmask_t event
; /* Event */
77 time_t time
; /* Time of event */
78 ipp_t
*attrs
; /* Notification message */
79 cupsd_printer_t
*dest
; /* Associated printer, if any */
80 cupsd_job_t
*job
; /* Associated job, if any */
83 typedef struct cupsd_subscription_s
/**** Subscription structure ****/
85 int id
; /* subscription-id */
86 unsigned mask
; /* Event mask */
87 char *owner
; /* notify-subscriber-user-name */
88 char *recipient
; /* notify-recipient-uri, if applicable */
89 unsigned char user_data
[64]; /* notify-user-data */
90 int user_data_len
; /* Length of notify-user-data */
91 int lease
; /* notify-lease-duration */
92 int interval
; /* notify-time-interval */
93 cupsd_printer_t
*dest
; /* notify-printer-uri, if any */
94 cupsd_job_t
*job
; /* notify-job-id, if any */
95 int pid
; /* Process ID of notifier */
96 int pipe
; /* Pipe to notifier */
97 int status
; /* Exit status of notifier */
98 time_t last
; /* Time of last notification */
99 time_t expire
; /* Lease expiration time */
100 int first_event_id
, /* First event-id in cache */
101 next_event_id
; /* Next event-id to use */
102 cups_array_t
*events
; /* Cached events */
103 } cupsd_subscription_t
;
110 VAR
int MaxSubscriptions
VALUE(100),
111 /* Overall subscription limit */
112 MaxSubscriptionsPerJob
VALUE(0),
113 /* Per-job subscription limit */
114 MaxSubscriptionsPerPrinter
VALUE(0),
115 /* Per-printer subscription limit */
116 MaxSubscriptionsPerUser
VALUE(0),
117 /* Per-user subscription limit */
118 NextSubscriptionId
VALUE(1),
119 /* Next subscription ID */
120 DefaultLeaseDuration
VALUE(86400),
121 /* Default notify-lease-duration */
122 MaxLeaseDuration
VALUE(0);
123 /* Maximum notify-lease-duration */
124 VAR cups_array_t
*Subscriptions
VALUE(NULL
);
125 /* Active subscriptions */
127 VAR
int MaxEvents
VALUE(100); /* Maximum number of events */
129 VAR
unsigned LastEvent
VALUE(0); /* Last event(s) processed */
130 VAR
int NotifierPipes
[2] VALUE2(-1, -1);
131 /* Pipes for notifier error/debug output */
132 VAR cupsd_statbuf_t
*NotifierStatusBuffer
VALUE(NULL
);
133 /* Status buffer for pipes */
140 extern void cupsdAddEvent(cupsd_eventmask_t event
, cupsd_printer_t
*dest
,
141 cupsd_job_t
*job
, const char *text
, ...);
142 extern cupsd_subscription_t
*
143 cupsdAddSubscription(unsigned mask
, cupsd_printer_t
*dest
,
144 cupsd_job_t
*job
, const char *uri
,
146 extern void cupsdDeleteAllSubscriptions(void);
147 extern void cupsdDeleteSubscription(cupsd_subscription_t
*sub
, int update
);
149 cupsdEventName(cupsd_eventmask_t event
);
150 extern cupsd_eventmask_t
151 cupsdEventValue(const char *name
);
153 extern cupsd_subscription_t
*
154 cupsdFindSubscription(int id
);
155 extern void cupsdExpireSubscriptions(cupsd_printer_t
*dest
,
157 extern void cupsdLoadAllSubscriptions(void);
158 extern void cupsdSaveAllSubscriptions(void);
159 extern void cupsdStopAllNotifiers(void);