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