86be664afc339496380b34c3b93736d595d70a3f
[framework/uifw/xorg/lib/libsm.git] / include / X11 / SM / SMlib.h
1 /*
2
3 Copyright 1993, 1998  The Open Group
4
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in 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
42 typedef IcePointer SmPointer;
43
44
45 /*
46  * Connection objects.  Defined in SMlibint.h
47  */
48
49 typedef struct _SmcConn *SmcConn;
50 typedef struct _SmsConn *SmsConn;
51
52
53 /*
54  * Session Management property
55  */
56
57 typedef struct {
58     int         length;         /* length (in bytes) of the value */
59     SmPointer   value;          /* the value */
60 } SmPropValue;
61
62 typedef 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 \f
71 /*
72  * SmcCloseConnection status return
73  */
74
75 typedef enum {
76     SmcClosedNow,
77     SmcClosedASAP,
78     SmcConnectionInUse
79 } SmcCloseStatus;
80
81
82 \f
83 /*
84  * Client callbacks
85  */
86
87 typedef void (*SmcSaveYourselfProc) (
88     SmcConn             /* smcConn */,
89     SmPointer           /* clientData */,
90     int                 /* saveType */,
91     Bool                /* shutdown */,
92     int                 /* interactStyle */,
93     Bool                /* fast */
94 );
95
96 typedef void (*SmcSaveYourselfPhase2Proc) (
97     SmcConn             /* smcConn */,
98     SmPointer           /* clientData */
99 );
100
101 typedef void (*SmcInteractProc) (
102     SmcConn             /* smcConn */,
103     SmPointer           /* clientData */
104 );
105
106 typedef void (*SmcDieProc) (
107     SmcConn             /* smcConn */,
108     SmPointer           /* clientData */
109 );
110
111 typedef void (*SmcShutdownCancelledProc) (
112     SmcConn             /* smcConn */,
113     SmPointer           /* clientData */
114 );
115
116 typedef void (*SmcSaveCompleteProc) (
117     SmcConn             /* smcConn */,
118     SmPointer           /* clientData */
119 );
120
121 typedef 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
133 typedef 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 \f
164 /*
165  * Session manager callbacks
166  */
167
168 typedef Status (*SmsRegisterClientProc) (
169     SmsConn             /* smsConn */,
170     SmPointer           /* managerData */,
171     char *              /* previousId */                                     
172 );
173
174 typedef void (*SmsInteractRequestProc) (
175     SmsConn             /* smsConn */,
176     SmPointer           /* managerData */,
177     int                 /* dialogType */
178 );
179
180 typedef void (*SmsInteractDoneProc) (
181     SmsConn             /* smsConn */,
182     SmPointer           /* managerData */,
183     Bool                /* cancelShutdown */
184 );
185
186 typedef 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
196 typedef void (*SmsSaveYourselfPhase2RequestProc) (
197     SmsConn             /* smsConn */,
198     SmPointer           /* managerData */
199 );
200
201 typedef void (*SmsSaveYourselfDoneProc) (
202     SmsConn             /* smsConn */,
203     SmPointer           /* managerData */,
204     Bool                /* success */
205 );
206
207 typedef void (*SmsCloseConnectionProc) (
208     SmsConn             /* smsConn */,
209     SmPointer           /* managerData */,
210     int                 /* count */,
211     char **             /* reasonMsgs */
212 );
213
214 typedef void (*SmsSetPropertiesProc) (
215     SmsConn             /* smsConn */,
216     SmPointer           /* managerData */,
217     int                 /* numProps */,
218     SmProp **           /* props */
219 );
220
221 typedef void (*SmsDeletePropertiesProc) (
222     SmsConn             /* smsConn */,
223     SmPointer           /* managerData */,
224     int                 /* numProps */,
225     char **             /* propNames */
226 );
227
228 typedef 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
238 typedef 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
306 typedef Status (*SmsNewClientProc) (
307     SmsConn             /* smsConn */,
308     SmPointer           /* managerData */,
309     unsigned long *     /* maskRet */,
310     SmsCallbacks *      /* callbacksRet */,
311     char **             /* failureReasonRet */
312 );
313
314
315 \f
316 /*
317  * Error handlers
318  */
319
320 typedef 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
330 typedef 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 \f
342 /*
343  * Function Prototypes
344  */
345
346 _XFUNCPROTOBEGIN
347
348 extern SmcConn SmcOpenConnection (
349     char *              /* networkIdsList */,
350     SmPointer           /* context */,
351     int                 /* xsmpMajorRev */,
352     int                 /* xsmpMinorRev */,
353     unsigned long       /* mask */,
354     SmcCallbacks *      /* callbacks */,
355     char *              /* previousId */,
356     char **             /* clientIdRet */,
357     int                 /* errorLength */,
358     char *              /* errorStringRet */
359 );
360
361 extern SmcCloseStatus SmcCloseConnection (
362     SmcConn             /* smcConn */,
363     int                 /* count */,
364     char **             /* reasonMsgs */
365 );
366
367 extern void SmcModifyCallbacks (
368     SmcConn             /* smcConn */,
369     unsigned long       /* mask */,
370     SmcCallbacks *      /* callbacks */
371 );
372
373 extern void SmcSetProperties (
374     SmcConn             /* smcConn */,
375     int                 /* numProps */,
376     SmProp **           /* props */
377 );
378
379 extern void SmcDeleteProperties (
380     SmcConn             /* smcConn */,
381     int                 /* numProps */,
382     char **             /* propNames */
383 );
384
385 extern Status SmcGetProperties (
386     SmcConn             /* smcConn */,
387     SmcPropReplyProc    /* propReplyProc */,
388     SmPointer           /* clientData */
389 );
390
391 extern Status SmcInteractRequest (
392     SmcConn             /* smcConn */,
393     int                 /* dialogType */,
394     SmcInteractProc     /* interactProc */,
395     SmPointer           /* clientData */
396 );
397
398 extern void SmcInteractDone (
399     SmcConn             /* smcConn */,
400     Bool                /* cancelShutdown */
401 );
402
403 extern void SmcRequestSaveYourself (
404     SmcConn             /* smcConn */,
405     int                 /* saveType */,
406     Bool                /* shutdown */,
407     int                 /* interactStyle */,
408     Bool                /* fast */,
409     Bool                /* global */
410 );
411
412 extern Status SmcRequestSaveYourselfPhase2 (
413     SmcConn                     /* smcConn */,
414     SmcSaveYourselfPhase2Proc   /* saveYourselfPhase2Proc */,
415     SmPointer                   /* clientData */
416 );
417
418 extern void SmcSaveYourselfDone (
419     SmcConn             /* smcConn */,
420     Bool                /* success */
421 );
422
423 extern int SmcProtocolVersion (
424     SmcConn             /* smcConn */
425 );
426
427 extern int SmcProtocolRevision (
428     SmcConn             /* smcConn */
429 );
430
431 extern char *SmcVendor (
432     SmcConn             /* smcConn */
433 );
434
435 extern char *SmcRelease (
436     SmcConn             /* smcConn */
437 );
438
439 extern char *SmcClientID (
440     SmcConn             /* smcConn */
441 );
442
443 extern IceConn SmcGetIceConnection (
444     SmcConn             /* smcConn */
445 );
446
447 extern Status SmsInitialize (
448     char *                      /* vendor */,
449     char *                      /* release */,
450     SmsNewClientProc            /* newClientProc */,
451     SmPointer                   /* managerData */,
452     IceHostBasedAuthProc        /* hostBasedAuthProc */,
453     int                         /* errorLength */,
454     char *                      /* errorStringRet */
455 );
456
457 extern char *SmsClientHostName (
458     SmsConn             /* smsConn */
459 );
460
461 extern char *SmsGenerateClientID (
462     SmsConn             /* smsConn */
463 );
464
465 extern Status SmsRegisterClientReply (
466     SmsConn             /* smsConn */,
467     char *              /* clientId */
468 );
469
470 extern void SmsSaveYourself (
471     SmsConn             /* smsConn */,
472     int                 /* saveType */,
473     Bool                /* shutdown */,
474     int                 /* interactStyle */,
475     Bool                /* fast */
476 );
477
478 extern void SmsSaveYourselfPhase2 (
479     SmsConn             /* smsConn */
480 );
481
482 extern void SmsInteract (
483     SmsConn             /* smsConn */
484 );
485
486 extern void SmsDie (
487     SmsConn             /* smsConn */
488 );
489
490 extern void SmsSaveComplete (
491     SmsConn             /* smsConn */
492 );
493
494 extern void SmsShutdownCancelled (
495     SmsConn             /* smsConn */
496 );
497
498 extern void SmsReturnProperties (
499     SmsConn             /* smsConn */,
500     int                 /* numProps */,
501     SmProp **           /* props */
502 );
503
504 extern void SmsCleanUp (
505     SmsConn             /* smsConn */
506 );
507
508 extern int SmsProtocolVersion (
509     SmsConn             /* smsConn */
510 );
511
512 extern int SmsProtocolRevision (
513     SmsConn             /* smsConn */
514 );
515
516 extern char *SmsClientID (
517     SmsConn             /* smsConn */
518 );
519
520 extern IceConn SmsGetIceConnection (
521     SmsConn             /* smsConn */
522 );
523
524 extern SmcErrorHandler SmcSetErrorHandler (
525     SmcErrorHandler     /* handler */
526 );
527
528 extern SmsErrorHandler SmsSetErrorHandler (
529     SmsErrorHandler     /* handler */
530 );
531
532 extern void SmFreeProperty (
533     SmProp *            /* prop */
534 );
535
536 extern void SmFreeReasons (
537     int                 /* count */,
538     char **             /* reasonMsgs */
539 );
540
541 _XFUNCPROTOEND
542
543 #endif /* _SMLIB_H_ */