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