]> git.ipfire.org Git - thirdparty/cups.git/blame - scheduler/subscriptions.h
Load cups into easysw/current.
[thirdparty/cups.git] / scheduler / subscriptions.h
CommitLineData
ef416fc2 1/*
bc44d920 2 * "$Id: subscriptions.h 6649 2007-07-11 21:46:42Z mike $"
ef416fc2 3 *
4 * Subscription definitions for the Common UNIX Printing System (CUPS) scheduler.
5 *
bc44d920 6 * Copyright 2007 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... */
23 CUPSD_EVENT_PRINTER_RESTARTED = 0x0001,
24 /* Sent after printer restarted */
25 CUPSD_EVENT_PRINTER_SHUTDOWN = 0x0002,/* Sent after printer shutdown */
26 CUPSD_EVENT_PRINTER_STOPPED = 0x0004, /* Sent after printer stopped */
27 CUPSD_EVENT_PRINTER_FINISHINGS_CHANGED = 0x0008,
28 /* Sent after finishings-supported changed */
29 CUPSD_EVENT_PRINTER_MEDIA_CHANGED = 0x0010,
30 /* Sent after media-supported changed */
31 CUPSD_EVENT_PRINTER_ADDED = 0x0020, /* Sent after printer added */
32 CUPSD_EVENT_PRINTER_DELETED = 0x0040, /* Sent after printer deleted */
33 CUPSD_EVENT_PRINTER_MODIFIED = 0x0080,/* Sent after printer modified */
34
35 /* Convenience printer event groupings... */
36 CUPSD_EVENT_PRINTER_STATE_CHANGED = 0x0007,
37 /* RESTARTED + SHUTDOWN + STOPPED */
38 CUPSD_EVENT_PRINTER_CONFIG_CHANGED = 0x0018,
39 /* FINISHINGS_CHANGED + MEDIA_CHANGED */
40 CUPSD_EVENT_PRINTER_CHANGED = 0x00ff, /* All of the above */
41
42 /* Individual job events... */
e00b005a 43 CUPSD_EVENT_JOB_STATE = 0x0100, /* Any state change */
44 CUPSD_EVENT_JOB_CREATED = 0x0200, /* Send after job is created */
45 CUPSD_EVENT_JOB_COMPLETED = 0x0400, /* Sent after job is completed */
46 CUPSD_EVENT_JOB_STOPPED = 0x0800, /* Sent after job is stopped */
47 CUPSD_EVENT_JOB_CONFIG_CHANGED = 0x1000,
ef416fc2 48 /* Sent after set-job-attributes */
e00b005a 49 CUPSD_EVENT_JOB_PROGRESS = 0x2000, /* Sent for each page */
ef416fc2 50
51 /* Convenience job event grouping... */
e00b005a 52 CUPSD_EVENT_JOB_STATE_CHANGED = 0x0f00,
53 /* Any state change + CREATED + COMPLETED + STOPPED */
ef416fc2 54
55 /* Server events... */
e00b005a 56 CUPSD_EVENT_SERVER_RESTARTED = 0x4000,/* Sent after server restarts */
57 CUPSD_EVENT_SERVER_STARTED = 0x8000, /* Sent when server first starts */
58 CUPSD_EVENT_SERVER_STOPPED = 0x10000, /* Sent when server is stopped */
59 CUPSD_EVENT_SERVER_AUDIT = 0x20000, /* Security-related stuff */
ef416fc2 60
61 /* Everything and nothing... */
62 CUPSD_EVENT_NONE = 0, /* Nothing */
63 CUPSD_EVENT_ALL = 0x1ffff /* Everything */
64} cupsd_eventmask_t;
65
66
67/*
68 * Notiification support structures...
69 */
70
71typedef struct cupsd_event_s /**** Event structure ****/
72{
73 cupsd_eventmask_t event; /* Event */
74 time_t time; /* Time of event */
75 ipp_t *attrs; /* Notification message */
76 cupsd_printer_t *dest; /* Associated printer, if any */
77 cupsd_job_t *job; /* Associated job, if any */
78} cupsd_event_t;
79
80typedef struct cupsd_subscription_s /**** Subscription structure ****/
81{
82 int id; /* subscription-id */
83 unsigned mask; /* Event mask */
84 char *owner; /* notify-subscriber-user-name */
85 char *recipient; /* notify-recipient-uri, if applicable */
86 unsigned char user_data[64]; /* notify-user-data */
87 int user_data_len; /* Length of notify-user-data */
88 int lease; /* notify-lease-duration */
89 int interval; /* notify-time-interval */
90 cupsd_printer_t *dest; /* notify-printer-uri, if any */
91 cupsd_job_t *job; /* notify-job-id, if any */
92 int pid; /* Process ID of notifier */
93 int pipe; /* Pipe to notifier */
94 int status; /* Exit status of notifier */
95 time_t last; /* Time of last notification */
96 time_t expire; /* Lease expiration time */
97 int first_event_id, /* First event-id in cache */
98 next_event_id, /* Next event-id to use */
99 num_events; /* Number of cached events */
100 cupsd_event_t **events; /* Cached events */
101} cupsd_subscription_t;
102
103
104/*
105 * Globals...
106 */
107
108VAR int MaxSubscriptions VALUE(100),
109 /* Overall subscription limit */
110 MaxSubscriptionsPerJob VALUE(0),
111 /* Per-job subscription limit */
112 MaxSubscriptionsPerPrinter VALUE(0),
113 /* Per-printer subscription limit */
114 MaxSubscriptionsPerUser VALUE(0),
115 /* Per-user subscription limit */
116 NextSubscriptionId VALUE(1),
117 /* Next subscription ID */
118 DefaultLeaseDuration VALUE(86400),
119 /* Default notify-lease-duration */
120 MaxLeaseDuration VALUE(0);
121 /* Maximum notify-lease-duration */
122VAR cups_array_t *Subscriptions VALUE(NULL);
123 /* Active subscriptions */
124
ed486911 125VAR int MaxEvents VALUE(100); /* Maximum number of events */
ef416fc2 126
ed486911 127VAR unsigned LastEvent VALUE(0); /* Last event(s) processed */
ef416fc2 128VAR int NotifierPipes[2] VALUE2(-1, -1);
129 /* Pipes for notifier error/debug output */
130VAR cupsd_statbuf_t *NotifierStatusBuffer VALUE(NULL);
131 /* Status buffer for pipes */
132
133
134/*
135 * Prototypes...
136 */
137
138extern void cupsdAddEvent(cupsd_eventmask_t event, cupsd_printer_t *dest,
139 cupsd_job_t *job, const char *text, ...);
140extern cupsd_subscription_t *
141 cupsdAddSubscription(unsigned mask, cupsd_printer_t *dest,
142 cupsd_job_t *job, const char *uri,
143 int sub_id);
ef416fc2 144extern void cupsdDeleteAllSubscriptions(void);
145extern void cupsdDeleteSubscription(cupsd_subscription_t *sub, int update);
146extern const char *
147 cupsdEventName(cupsd_eventmask_t event);
148extern cupsd_eventmask_t
149 cupsdEventValue(const char *name);
150
151extern cupsd_subscription_t *
152 cupsdFindSubscription(int id);
153extern void cupsdExpireSubscriptions(cupsd_printer_t *dest,
154 cupsd_job_t *job);
155extern void cupsdLoadAllSubscriptions(void);
156extern void cupsdSaveAllSubscriptions(void);
ef416fc2 157extern void cupsdStopAllNotifiers(void);
ef416fc2 158
159
160/*
bc44d920 161 * End of "$Id: subscriptions.h 6649 2007-07-11 21:46:42Z mike $".
ef416fc2 162 */