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