Home | History | Annotate | Line # | Download | only in SM
      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 
     71 /*
     73  * SmcCloseConnection status return
     74  */
     75 
     76 typedef enum {
     77     SmcClosedNow,
     78     SmcClosedASAP,
     79     SmcConnectionInUse
     80 } SmcCloseStatus;
     81 
     82 
     83 
     84 /*
     86  * Client callbacks
     87  */
     88 
     89 typedef void (*SmcSaveYourselfProc) (
     90     SmcConn		/* smcConn */,
     91     SmPointer		/* clientData */,
     92     int  		/* saveType */,
     93     Bool		/* shutdown */,
     94     int			/* interactStyle */,
     95     Bool		/* fast */
     96 );
     97 
     98 typedef void (*SmcSaveYourselfPhase2Proc) (
     99     SmcConn		/* smcConn */,
    100     SmPointer		/* clientData */
    101 );
    102 
    103 typedef void (*SmcInteractProc) (
    104     SmcConn		/* smcConn */,
    105     SmPointer		/* clientData */
    106 );
    107 
    108 typedef void (*SmcDieProc) (
    109     SmcConn		/* smcConn */,
    110     SmPointer		/* clientData */
    111 );
    112 
    113 typedef void (*SmcShutdownCancelledProc) (
    114     SmcConn		/* smcConn */,
    115     SmPointer		/* clientData */
    116 );
    117 
    118 typedef void (*SmcSaveCompleteProc) (
    119     SmcConn		/* smcConn */,
    120     SmPointer		/* clientData */
    121 );
    122 
    123 typedef 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 
    135 typedef 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 /*
    168  * Session manager callbacks
    169  */
    170 
    171 typedef Status (*SmsRegisterClientProc) (
    172     SmsConn 		/* smsConn */,
    173     SmPointer		/* managerData */,
    174     char *		/* previousId */
    175 );
    176 
    177 typedef void (*SmsInteractRequestProc) (
    178     SmsConn		/* smsConn */,
    179     SmPointer		/* managerData */,
    180     int			/* dialogType */
    181 );
    182 
    183 typedef void (*SmsInteractDoneProc) (
    184     SmsConn		/* smsConn */,
    185     SmPointer		/* managerData */,
    186     Bool		/* cancelShutdown */
    187 );
    188 
    189 typedef void (*SmsSaveYourselfRequestProc) (
    190     SmsConn		/* smsConn */,
    191     SmPointer		/* managerData */,
    192     int  		/* saveType */,
    193     Bool		/* shutdown */,
    194     int			/* interactStyle */,
    195     Bool		/* fast */,
    196     Bool		/* global */
    197 );
    198 
    199 typedef void (*SmsSaveYourselfPhase2RequestProc) (
    200     SmsConn		/* smsConn */,
    201     SmPointer		/* managerData */
    202 );
    203 
    204 typedef void (*SmsSaveYourselfDoneProc) (
    205     SmsConn		/* smsConn */,
    206     SmPointer		/* managerData */,
    207     Bool		/* success */
    208 );
    209 
    210 typedef void (*SmsCloseConnectionProc) (
    211     SmsConn		/* smsConn */,
    212     SmPointer		/* managerData */,
    213     int			/* count */,
    214     char **		/* reasonMsgs */
    215 );
    216 
    217 typedef void (*SmsSetPropertiesProc) (
    218     SmsConn		/* smsConn */,
    219     SmPointer		/* managerData */,
    220     int			/* numProps */,
    221     SmProp **		/* props */
    222 );
    223 
    224 typedef void (*SmsDeletePropertiesProc) (
    225     SmsConn		/* smsConn */,
    226     SmPointer		/* managerData */,
    227     int			/* numProps */,
    228     char **		/* propNames */
    229 );
    230 
    231 typedef void (*SmsGetPropertiesProc) (
    232     SmsConn		/* smsConn */,
    233     SmPointer		/* managerData */
    234 );
    235 
    236 
    237 /*
    238  * Callbacks set up by a session manager when a new client connects.
    239  */
    240 
    241 typedef struct {
    242 
    243     struct {
    244 	SmsRegisterClientProc	callback;
    245 	SmPointer		manager_data;
    246     } register_client;
    247 
    248     struct {
    249 	SmsInteractRequestProc	callback;
    250 	SmPointer		manager_data;
    251     } interact_request;
    252 
    253     struct {
    254 	SmsInteractDoneProc	callback;
    255 	SmPointer		manager_data;
    256     } interact_done;
    257 
    258     struct {
    259 	SmsSaveYourselfRequestProc	callback;
    260 	SmPointer			manager_data;
    261     } save_yourself_request;
    262 
    263     struct {
    264 	SmsSaveYourselfPhase2RequestProc	callback;
    265 	SmPointer				manager_data;
    266     } save_yourself_phase2_request;
    267 
    268     struct {
    269 	SmsSaveYourselfDoneProc	callback;
    270 	SmPointer		manager_data;
    271     } save_yourself_done;
    272 
    273     struct {
    274 	SmsCloseConnectionProc	callback;
    275 	SmPointer		manager_data;
    276     } close_connection;
    277 
    278     struct {
    279 	SmsSetPropertiesProc	callback;
    280 	SmPointer		manager_data;
    281     } set_properties;
    282 
    283     struct {
    284 	SmsDeletePropertiesProc	callback;
    285 	SmPointer		manager_data;
    286     } delete_properties;
    287 
    288     struct {
    289 	SmsGetPropertiesProc	callback;
    290 	SmPointer		manager_data;
    291     } get_properties;
    292 
    293 } SmsCallbacks;
    294 
    295 
    296 #define SmsRegisterClientProcMask		(1L << 0)
    297 #define SmsInteractRequestProcMask		(1L << 1)
    298 #define SmsInteractDoneProcMask			(1L << 2)
    299 #define SmsSaveYourselfRequestProcMask  	(1L << 3)
    300 #define SmsSaveYourselfP2RequestProcMask	(1L << 4)
    301 #define SmsSaveYourselfDoneProcMask		(1L << 5)
    302 #define SmsCloseConnectionProcMask		(1L << 6)
    303 #define SmsSetPropertiesProcMask		(1L << 7)
    304 #define SmsDeletePropertiesProcMask		(1L << 8)
    305 #define SmsGetPropertiesProcMask		(1L << 9)
    306 
    307 
    308 
    309 typedef Status (*SmsNewClientProc) (
    310     SmsConn 		/* smsConn */,
    311     SmPointer		/* managerData */,
    312     unsigned long *	/* maskRet */,
    313     SmsCallbacks *	/* callbacksRet */,
    314     char **		/* failureReasonRet */
    315 );
    316 
    317 
    318 
    319 /*
    321  * Error handlers
    322  */
    323 
    324 typedef void (*SmcErrorHandler) (
    325     SmcConn		/* smcConn */,
    326     Bool		/* swap */,
    327     int			/* offendingMinorOpcode */,
    328     unsigned long 	/* offendingSequence */,
    329     int 		/* errorClass */,
    330     int			/* severity */,
    331     SmPointer		/* values */
    332 );
    333 
    334 typedef void (*SmsErrorHandler) (
    335     SmsConn		/* smsConn */,
    336     Bool		/* swap */,
    337     int			/* offendingMinorOpcode */,
    338     unsigned long 	/* offendingSequence */,
    339     int 		/* errorClass */,
    340     int			/* severity */,
    341     SmPointer		/* values */
    342 );
    343 
    344 
    345 
    346 /*
    348  * Function Prototypes
    349  */
    350 
    351 _XFUNCPROTOBEGIN
    352 
    353 extern SmcConn SmcOpenConnection (
    354     char *		/* networkIdsList */,
    355     SmPointer		/* context */,
    356     int			/* xsmpMajorRev */,
    357     int			/* xsmpMinorRev */,
    358     unsigned long	/* mask */,
    359     SmcCallbacks *	/* callbacks */,
    360     const char *	/* previousId */,
    361     char **		/* clientIdRet */,
    362     int			/* errorLength */,
    363     char *		/* errorStringRet */
    364 );
    365 
    366 extern SmcCloseStatus SmcCloseConnection (
    367     SmcConn		/* smcConn */,
    368     int			/* count */,
    369     char **		/* reasonMsgs */
    370 );
    371 
    372 extern void SmcModifyCallbacks (
    373     SmcConn		/* smcConn */,
    374     unsigned long	/* mask */,
    375     SmcCallbacks *	/* callbacks */
    376 );
    377 
    378 extern void SmcSetProperties (
    379     SmcConn		/* smcConn */,
    380     int      	        /* numProps */,
    381     SmProp **		/* props */
    382 );
    383 
    384 extern void SmcDeleteProperties (
    385     SmcConn		/* smcConn */,
    386     int      	        /* numProps */,
    387     char **		/* propNames */
    388 );
    389 
    390 extern Status SmcGetProperties (
    391     SmcConn		/* smcConn */,
    392     SmcPropReplyProc	/* propReplyProc */,
    393     SmPointer		/* clientData */
    394 );
    395 
    396 extern Status SmcInteractRequest (
    397     SmcConn		/* smcConn */,
    398     int			/* dialogType */,
    399     SmcInteractProc	/* interactProc */,
    400     SmPointer		/* clientData */
    401 );
    402 
    403 extern void SmcInteractDone (
    404     SmcConn		/* smcConn */,
    405     Bool 		/* cancelShutdown */
    406 );
    407 
    408 extern void SmcRequestSaveYourself (
    409     SmcConn		/* smcConn */,
    410     int			/* saveType */,
    411     Bool 		/* shutdown */,
    412     int			/* interactStyle */,
    413     Bool		/* fast */,
    414     Bool		/* global */
    415 );
    416 
    417 extern Status SmcRequestSaveYourselfPhase2 (
    418     SmcConn			/* smcConn */,
    419     SmcSaveYourselfPhase2Proc	/* saveYourselfPhase2Proc */,
    420     SmPointer			/* clientData */
    421 );
    422 
    423 extern void SmcSaveYourselfDone (
    424     SmcConn		/* smcConn */,
    425     Bool		/* success */
    426 );
    427 
    428 extern int SmcProtocolVersion (
    429     SmcConn		/* smcConn */
    430 );
    431 
    432 extern int SmcProtocolRevision (
    433     SmcConn		/* smcConn */
    434 );
    435 
    436 extern char *SmcVendor (
    437     SmcConn		/* smcConn */
    438 );
    439 
    440 extern char *SmcRelease (
    441     SmcConn		/* smcConn */
    442 );
    443 
    444 extern char *SmcClientID (
    445     SmcConn		/* smcConn */
    446 );
    447 
    448 extern IceConn SmcGetIceConnection (
    449     SmcConn		/* smcConn */
    450 );
    451 
    452 extern Status SmsInitialize (
    453     const char *		/* vendor */,
    454     const char *		/* release */,
    455     SmsNewClientProc		/* newClientProc */,
    456     SmPointer			/* managerData */,
    457     IceHostBasedAuthProc	/* hostBasedAuthProc */,
    458     int				/* errorLength */,
    459     char *			/* errorStringRet */
    460 );
    461 
    462 extern char *SmsClientHostName (
    463     SmsConn		/* smsConn */
    464 );
    465 
    466 extern char *SmsGenerateClientID (
    467     SmsConn		/* smsConn */
    468 );
    469 
    470 extern Status SmsRegisterClientReply (
    471     SmsConn		/* smsConn */,
    472     char *		/* clientId */
    473 );
    474 
    475 extern void SmsSaveYourself (
    476     SmsConn		/* smsConn */,
    477     int			/* saveType */,
    478     Bool 		/* shutdown */,
    479     int			/* interactStyle */,
    480     Bool		/* fast */
    481 );
    482 
    483 extern void SmsSaveYourselfPhase2 (
    484     SmsConn		/* smsConn */
    485 );
    486 
    487 extern void SmsInteract (
    488     SmsConn		/* smsConn */
    489 );
    490 
    491 extern void SmsDie (
    492     SmsConn		/* smsConn */
    493 );
    494 
    495 extern void SmsSaveComplete (
    496     SmsConn		/* smsConn */
    497 );
    498 
    499 extern void SmsShutdownCancelled (
    500     SmsConn		/* smsConn */
    501 );
    502 
    503 extern void SmsReturnProperties (
    504     SmsConn		/* smsConn */,
    505     int			/* numProps */,
    506     SmProp **		/* props */
    507 );
    508 
    509 extern void SmsCleanUp (
    510     SmsConn		/* smsConn */
    511 );
    512 
    513 extern int SmsProtocolVersion (
    514     SmsConn		/* smsConn */
    515 );
    516 
    517 extern int SmsProtocolRevision (
    518     SmsConn		/* smsConn */
    519 );
    520 
    521 extern char *SmsClientID (
    522     SmsConn		/* smsConn */
    523 );
    524 
    525 extern IceConn SmsGetIceConnection (
    526     SmsConn		/* smsConn */
    527 );
    528 
    529 extern SmcErrorHandler SmcSetErrorHandler (
    530     SmcErrorHandler 	/* handler */
    531 );
    532 
    533 extern SmsErrorHandler SmsSetErrorHandler (
    534     SmsErrorHandler 	/* handler */
    535 );
    536 
    537 extern void SmFreeProperty (
    538     SmProp *		/* prop */
    539 );
    540 
    541 extern void SmFreeReasons (
    542     int			/* count */,
    543     char **		/* reasonMsgs */
    544 );
    545 
    546 _XFUNCPROTOEND
    547 
    548 #endif /* _SMLIB_H_ */
    549