1/*
2
3Copyright 1993, 1998 The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25*/
26
27/*
28 * Author: Ralph Mor, X Consortium
29 */
30
31#ifndef _SMLIB_H_
32#define _SMLIB_H_
33
34#include <X11/SM/SM.h>
35#include <X11/ICE/ICElib.h>
36
37
38/*
39 * Generic SM pointer
40 */
41
42typedef IcePointer SmPointer;
43
44
45/*
46 * Connection objects. Defined in SMlibint.h
47 */
48
49typedef struct _SmcConn *SmcConn;
50typedef struct _SmsConn *SmsConn;
51
52
53/*
54 * Session Management property
55 */
56
57typedef struct {
58 int length; /* length (in bytes) of the value */
59 SmPointer value; /* the value */
60} SmPropValue;
61
62typedef struct {
63 char *name; /* name of property */
64 char *type; /* type of property */
65 int num_vals; /* number of values in property */
66 SmPropValue *vals; /* the values */
67} SmProp;
68
69
70
71/*
72 * SmcCloseConnection status return
73 */
74
75typedef enum {
76 SmcClosedNow,
77 SmcClosedASAP,
78 SmcConnectionInUse
79} SmcCloseStatus;
80
81
82
83/*
84 * Client callbacks
85 */
86
87typedef void (*SmcSaveYourselfProc) (
88 SmcConn /* smcConn */,
89 SmPointer /* clientData */,
90 int /* saveType */,
91 Bool /* shutdown */,
92 int /* interactStyle */,
93 Bool /* fast */
94);
95
96typedef void (*SmcSaveYourselfPhase2Proc) (
97 SmcConn /* smcConn */,
98 SmPointer /* clientData */
99);
100
101typedef void (*SmcInteractProc) (
102 SmcConn /* smcConn */,
103 SmPointer /* clientData */
104);
105
106typedef void (*SmcDieProc) (
107 SmcConn /* smcConn */,
108 SmPointer /* clientData */
109);
110
111typedef void (*SmcShutdownCancelledProc) (
112 SmcConn /* smcConn */,
113 SmPointer /* clientData */
114);
115
116typedef void (*SmcSaveCompleteProc) (
117 SmcConn /* smcConn */,
118 SmPointer /* clientData */
119);
120
121typedef void (*SmcPropReplyProc) (
122 SmcConn /* smcConn */,
123 SmPointer /* clientData */,
124 int /* numProps */,
125 SmProp ** /* props */
126);
127
128
129/*
130 * Callbacks set up at SmcOpenConnection time
131 */
132
133typedef struct {
134
135 struct {
136 SmcSaveYourselfProc callback;
137 SmPointer client_data;
138 } save_yourself;
139
140 struct {
141 SmcDieProc callback;
142 SmPointer client_data;
143 } die;
144
145 struct {
146 SmcSaveCompleteProc callback;
147 SmPointer client_data;
148 } save_complete;
149
150 struct {
151 SmcShutdownCancelledProc callback;
152 SmPointer client_data;
153 } shutdown_cancelled;
154
155} SmcCallbacks;
156
157#define SmcSaveYourselfProcMask (1L << 0)
158#define SmcDieProcMask (1L << 1)
159#define SmcSaveCompleteProcMask (1L << 2)
160#define SmcShutdownCancelledProcMask (1L << 3)
161
162
163
164/*
165 * Session manager callbacks
166 */
167
168typedef Status (*SmsRegisterClientProc) (
169 SmsConn /* smsConn */,
170 SmPointer /* managerData */,
171 char * /* previousId */
172);
173
174typedef void (*SmsInteractRequestProc) (
175 SmsConn /* smsConn */,
176 SmPointer /* managerData */,
177 int /* dialogType */
178);
179
180typedef void (*SmsInteractDoneProc) (
181 SmsConn /* smsConn */,
182 SmPointer /* managerData */,
183 Bool /* cancelShutdown */
184);
185
186typedef void (*SmsSaveYourselfRequestProc) (
187 SmsConn /* smsConn */,
188 SmPointer /* managerData */,
189 int /* saveType */,
190 Bool /* shutdown */,
191 int /* interactStyle */,
192 Bool /* fast */,
193 Bool /* global */
194);
195
196typedef void (*SmsSaveYourselfPhase2RequestProc) (
197 SmsConn /* smsConn */,
198 SmPointer /* managerData */
199);
200
201typedef void (*SmsSaveYourselfDoneProc) (
202 SmsConn /* smsConn */,
203 SmPointer /* managerData */,
204 Bool /* success */
205);
206
207typedef void (*SmsCloseConnectionProc) (
208 SmsConn /* smsConn */,
209 SmPointer /* managerData */,
210 int /* count */,
211 char ** /* reasonMsgs */
212);
213
214typedef void (*SmsSetPropertiesProc) (
215 SmsConn /* smsConn */,
216 SmPointer /* managerData */,
217 int /* numProps */,
218 SmProp ** /* props */
219);
220
221typedef void (*SmsDeletePropertiesProc) (
222 SmsConn /* smsConn */,
223 SmPointer /* managerData */,
224 int /* numProps */,
225 char ** /* propNames */
226);
227
228typedef void (*SmsGetPropertiesProc) (
229 SmsConn /* smsConn */,
230 SmPointer /* managerData */
231);
232
233
234/*
235 * Callbacks set up by a session manager when a new client connects.
236 */
237
238typedef struct {
239
240 struct {
241 SmsRegisterClientProc callback;
242 SmPointer manager_data;
243 } register_client;
244
245 struct {
246 SmsInteractRequestProc callback;
247 SmPointer manager_data;
248 } interact_request;
249
250 struct {
251 SmsInteractDoneProc callback;
252 SmPointer manager_data;
253 } interact_done;
254
255 struct {
256 SmsSaveYourselfRequestProc callback;
257 SmPointer manager_data;
258 } save_yourself_request;
259
260 struct {
261 SmsSaveYourselfPhase2RequestProc callback;
262 SmPointer manager_data;
263 } save_yourself_phase2_request;
264
265 struct {
266 SmsSaveYourselfDoneProc callback;
267 SmPointer manager_data;
268 } save_yourself_done;
269
270 struct {
271 SmsCloseConnectionProc callback;
272 SmPointer manager_data;
273 } close_connection;
274
275 struct {
276 SmsSetPropertiesProc callback;
277 SmPointer manager_data;
278 } set_properties;
279
280 struct {
281 SmsDeletePropertiesProc callback;
282 SmPointer manager_data;
283 } delete_properties;
284
285 struct {
286 SmsGetPropertiesProc callback;
287 SmPointer manager_data;
288 } get_properties;
289
290} SmsCallbacks;
291
292
293#define SmsRegisterClientProcMask (1L << 0)
294#define SmsInteractRequestProcMask (1L << 1)
295#define SmsInteractDoneProcMask (1L << 2)
296#define SmsSaveYourselfRequestProcMask (1L << 3)
297#define SmsSaveYourselfP2RequestProcMask (1L << 4)
298#define SmsSaveYourselfDoneProcMask (1L << 5)
299#define SmsCloseConnectionProcMask (1L << 6)
300#define SmsSetPropertiesProcMask (1L << 7)
301#define SmsDeletePropertiesProcMask (1L << 8)
302#define SmsGetPropertiesProcMask (1L << 9)
303
304
305
306typedef Status (*SmsNewClientProc) (
307 SmsConn /* smsConn */,
308 SmPointer /* managerData */,
309 unsigned long * /* maskRet */,
310 SmsCallbacks * /* callbacksRet */,
311 char ** /* failureReasonRet */
312);
313
314
315
316/*
317 * Error handlers
318 */
319
320typedef void (*SmcErrorHandler) (
321 SmcConn /* smcConn */,
322 Bool /* swap */,
323 int /* offendingMinorOpcode */,
324 unsigned long /* offendingSequence */,
325 int /* errorClass */,
326 int /* severity */,
327 SmPointer /* values */
328);
329
330typedef void (*SmsErrorHandler) (
331 SmsConn /* smsConn */,
332 Bool /* swap */,
333 int /* offendingMinorOpcode */,
334 unsigned long /* offendingSequence */,
335 int /* errorClass */,
336 int /* severity */,
337 SmPointer /* values */
338);
339
340
341
342/*
343 * Function Prototypes
344 */
345
346_XFUNCPROTOBEGIN
347
348extern SmcConn SmcOpenConnection (
349 char * /* networkIdsList */,
350 SmPointer /* context */,
351 int /* xsmpMajorRev */,
352 int /* xsmpMinorRev */,
353 unsigned long /* mask */,
354 SmcCallbacks * /* callbacks */,
355 const char * /* previousId */,
356 char ** /* clientIdRet */,
357 int /* errorLength */,
358 char * /* errorStringRet */
359);
360
361extern SmcCloseStatus SmcCloseConnection (
362 SmcConn /* smcConn */,
363 int /* count */,
364 char ** /* reasonMsgs */
365);
366
367extern void SmcModifyCallbacks (
368 SmcConn /* smcConn */,
369 unsigned long /* mask */,
370 SmcCallbacks * /* callbacks */
371);
372
373extern void SmcSetProperties (
374 SmcConn /* smcConn */,
375 int /* numProps */,
376 SmProp ** /* props */
377);
378
379extern void SmcDeleteProperties (
380 SmcConn /* smcConn */,
381 int /* numProps */,
382 char ** /* propNames */
383);
384
385extern Status SmcGetProperties (
386 SmcConn /* smcConn */,
387 SmcPropReplyProc /* propReplyProc */,
388 SmPointer /* clientData */
389);
390
391extern Status SmcInteractRequest (
392 SmcConn /* smcConn */,
393 int /* dialogType */,
394 SmcInteractProc /* interactProc */,
395 SmPointer /* clientData */
396);
397
398extern void SmcInteractDone (
399 SmcConn /* smcConn */,
400 Bool /* cancelShutdown */
401);
402
403extern void SmcRequestSaveYourself (
404 SmcConn /* smcConn */,
405 int /* saveType */,
406 Bool /* shutdown */,
407 int /* interactStyle */,
408 Bool /* fast */,
409 Bool /* global */
410);
411
412extern Status SmcRequestSaveYourselfPhase2 (
413 SmcConn /* smcConn */,
414 SmcSaveYourselfPhase2Proc /* saveYourselfPhase2Proc */,
415 SmPointer /* clientData */
416);
417
418extern void SmcSaveYourselfDone (
419 SmcConn /* smcConn */,
420 Bool /* success */
421);
422
423extern int SmcProtocolVersion (
424 SmcConn /* smcConn */
425);
426
427extern int SmcProtocolRevision (
428 SmcConn /* smcConn */
429);
430
431extern char *SmcVendor (
432 SmcConn /* smcConn */
433);
434
435extern char *SmcRelease (
436 SmcConn /* smcConn */
437);
438
439extern char *SmcClientID (
440 SmcConn /* smcConn */
441);
442
443extern IceConn SmcGetIceConnection (
444 SmcConn /* smcConn */
445);
446
447extern Status SmsInitialize (
448 const char * /* vendor */,
449 const char * /* release */,
450 SmsNewClientProc /* newClientProc */,
451 SmPointer /* managerData */,
452 IceHostBasedAuthProc /* hostBasedAuthProc */,
453 int /* errorLength */,
454 char * /* errorStringRet */
455);
456
457extern char *SmsClientHostName (
458 SmsConn /* smsConn */
459);
460
461extern char *SmsGenerateClientID (
462 SmsConn /* smsConn */
463);
464
465extern Status SmsRegisterClientReply (
466 SmsConn /* smsConn */,
467 char * /* clientId */
468);
469
470extern void SmsSaveYourself (
471 SmsConn /* smsConn */,
472 int /* saveType */,
473 Bool /* shutdown */,
474 int /* interactStyle */,
475 Bool /* fast */
476);
477
478extern void SmsSaveYourselfPhase2 (
479 SmsConn /* smsConn */
480);
481
482extern void SmsInteract (
483 SmsConn /* smsConn */
484);
485
486extern void SmsDie (
487 SmsConn /* smsConn */
488);
489
490extern void SmsSaveComplete (
491 SmsConn /* smsConn */
492);
493
494extern void SmsShutdownCancelled (
495 SmsConn /* smsConn */
496);
497
498extern void SmsReturnProperties (
499 SmsConn /* smsConn */,
500 int /* numProps */,
501 SmProp ** /* props */
502);
503
504extern void SmsCleanUp (
505 SmsConn /* smsConn */
506);
507
508extern int SmsProtocolVersion (
509 SmsConn /* smsConn */
510);
511
512extern int SmsProtocolRevision (
513 SmsConn /* smsConn */
514);
515
516extern char *SmsClientID (
517 SmsConn /* smsConn */
518);
519
520extern IceConn SmsGetIceConnection (
521 SmsConn /* smsConn */
522);
523
524extern SmcErrorHandler SmcSetErrorHandler (
525 SmcErrorHandler /* handler */
526);
527
528extern SmsErrorHandler SmsSetErrorHandler (
529 SmsErrorHandler /* handler */
530);
531
532extern void SmFreeProperty (
533 SmProp * /* prop */
534);
535
536extern void SmFreeReasons (
537 int /* count */,
538 char ** /* reasonMsgs */
539);
540
541_XFUNCPROTOEND
542
543#endif /* _SMLIB_H_ */
544

source code of include/X11/SM/SMlib.h