home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-bin / x11r6.1 / include / x11 / sm / smlib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-17  |  13.1 KB  |  661 lines

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