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