home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 August - Disc 2 / chip_20018102_hu.iso / linux / X-4.1.0 / doc / smlib.txt < prev    next >
Text File  |  2001-06-27  |  76KB  |  3,103 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.         X Session Management Library
  11.  
  12.             Version 1.0
  13.  
  14.            X Consortium Standard
  15.  
  16.          X Version 11, Release 6.4
  17.  
  18.              Ralph Mor
  19.             X Consortium
  20.  
  21.  
  22.  
  23.        Copyright (C) 1993, 1994 X Consortium
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. Permission  is hereby granted, free of charge, to any person
  32. obtaining a copy of this software and associated  documenta-
  33. tion files (the ``Software''), to deal in the Software with-
  34. out restriction, including without limitation the rights  to
  35. use,  copy,  modify, merge, publish, distribute, sublicense,
  36. and/or sell copies of the Software, and to permit persons to
  37. whom the Software is furnished to do so, subject to the fol-
  38. lowing conditions:
  39.  
  40. The above copyright notice and this permission notice  shall
  41. be  included  in  all  copies or substantial portions of the
  42. Software.
  43.  
  44. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF  ANY
  45. KIND,  EXPRESS    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  46. WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PUR-
  47. POSE  AND  NONINFRINGEMENT.  IN NO EVENT SHALL THE X CONSOR-
  48. TIUM BE LIABLE FOR ANY CLAIM, DAMAGES  OR  OTHER  LIABILITY,
  49. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  50. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR  THE  USE
  51. OR OTHER DEALINGS IN THE SOFTWARE.
  52.  
  53. Except    as  contained in this notice, the name of the X Con-
  54. sortium shall not be used in  advertising  or  otherwise  to
  55. promote  the  sale,  use  or other dealings in this Software
  56. without prior written authorization from the X Consortium.
  57.  
  58.  
  59.  
  60. X Window System is a trademark of X Consortium, Inc.
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. 1.  Overview of Session Management
  140.  
  141. The purpose of the X Session Management Protocol  (XSMP)  is
  142. to provide a uniform mechanism for users to save and restore
  143. their sessions.  A session is a group of  clients,  each  of
  144. which  has a particular state.    The session is controlled by
  145. a network service called the session manager.    The  session
  146. manager  issues  commands  to  its  clients on behalf of the
  147. user.  These commands may cause clients to save their  state
  148. or  to    terminate.  It is expected that the client will save
  149. its state in such a way that the client can be restarted  at
  150. a  later  time    and  resume its operation as if it had never
  151. been terminated.  A client's state might include information
  152. about  the file currently being edited, the current position
  153. of the insertion point within the file, or the start  of  an
  154. uncommitted  transaction.   The  means    by which clients are
  155. restarted is unspecified by this protocol.
  156.  
  157. For purposes of this protocol, a client of the session    man-
  158. ager  is  defined as a connection to the session manager.  A
  159. client is typically, though not necessarily, a process    run-
  160. ning an application program connected to an X display.    How-
  161. ever, a client may be connected to more than one  X  display
  162. or not be connected to any X displays at all.
  163.  
  164. 2.  The Session Management Library
  165.  
  166. The  Session  Management  Library (SMlib) is a low-level "C"
  167. language interface to XSMP.   It  is  expected    that  higher
  168. level toolkits, such as Xt, will hide many of the details of
  169. session management  from  clients.   Higher  level  toolkits
  170. might  also be developed for session managers to use, but no
  171. such effort is currently under way.
  172.  
  173. SMlib has two parts to it:
  174.  
  175. o    One set of functions for clients that want to  be    part
  176.      of a session
  177.  
  178. o    One set of functions for session managers to call
  179.  
  180. Some applications will use both sets of functions and act as
  181. nested session managers.  That is, they will be both a    ses-
  182. sion manager and a client of another session.  An example is
  183. a mail program that could start a text    editor    for  editing
  184. the  text  of a mail message.  The mail program is part of a
  185. regular session and, at the same time, is also acting  as  a
  186. session manager to the editor.
  187.  
  188. Clients  initialize by connecting to the session manager and
  189. obtaining a client-ID that uniquely identifies them  in  the
  190. session.  The session manager maintains a list of properties
  191. for each client in the session.  These    properties  describe
  192. the client's environment and, most importantly, describe how
  193.  
  194.  
  195.  
  196.                 - 1 -
  197.  
  198.  
  199.  
  200.  
  201.  
  202. X Session Management Library            X11, Release 6.4
  203.  
  204.  
  205. the client  can  be  restarted    (via  an  SmRestartCommand).
  206. Clients are expected to save their state in such a way as to
  207. allow multiple instantiations of themselves  to  be  managed
  208. independently.    For example, clients may use their client-ID
  209. as part of a filename in which to store the state for a par-
  210. ticular  instantiation.   The  client-ID  should be saved as
  211. part of the SmRestartCommand so that the client will  retain
  212. the same ID after it is restarted.
  213.  
  214. Once the client initializes itself with the session manager,
  215. it must be ready to respond to    messages  from    the  session
  216. manager.   For    example, it might be asked to save its state
  217. or to terminate.  In the case of  a  shutdown,    the  session
  218. manager might give each client a chance to interact with the
  219. user and cancel the shutdown.
  220.  
  221. 3.  Understanding SMlib's Dependence on ICE
  222.  
  223. The X Session Management Protocol is layered on top  of  the
  224. Inter-Client  Exchange    (ICE) Protocol.  The ICE protocol is
  225. designed to multiplex several protocols over a    single    con-
  226. nection.   As a result, working with SMlib requires a little
  227. knowledge of how the ICE library works.
  228.  
  229. The ICE library  utilizes  callbacks  to  process  messages.
  230. When  a  client detects that there is data to read on an ICE
  231. connection, it should call the IceProcessMessages  function.
  232. IceProcessMessages  will read the message header and look at
  233. the major opcode in order to determine    which  protocol  the
  234. message  was intended for.  The appropriate protocol library
  235. will then be triggered to unpack the message and hand it off
  236. to the client via a callback.
  237.  
  238. The  main  point to be aware of is that an application using
  239. SMlib must have some code that detects when there is data to
  240. read  on  an  ICE connection.  This can be done via a select
  241. call on the file descriptor for the ICE connection, but more
  242. typically, XtAppAddInput will be used to register a callback
  243. that will invoke IceProcessMessages each time there is    data
  244. to read on the ICE connection.
  245.  
  246. To further complicate things, knowing which file descriptors
  247. to call select on requires an understanding of how ICE    con-
  248. nections  are  created.   On the client side, a call must be
  249. made to SmcOpenConnection in order to open a connection with
  250. a session manager.  SmcOpenConnection will internally make a
  251. call into IceOpenConnection, which will, in turn,  determine
  252. if  an    ICE connection already exists between the client and
  253. session manager.  Most likely, a connection will not already
  254. exist  and  a  new ICE connection will be created.  The main
  255. point to be aware of is that, on the client side, it is  not
  256. obvious  when  ICE  connections  get  created  or destroyed,
  257. because connections are shared when possible.  To deal    with
  258. this,  the  ICE  library lets the application register watch
  259.  
  260.  
  261.  
  262.                 - 2 -
  263.  
  264.  
  265.  
  266.  
  267.  
  268. X Session Management Library            X11, Release 6.4
  269.  
  270.  
  271. procedures that will be invoked each time an ICE  connection
  272. is  opened  or closed.    These watch procedures could be used
  273. to add or remove ICE  file  descriptors  from  the  list  of
  274. descriptors to call select on.
  275.  
  276. On  the session manager side, things work a bit differently.
  277. The session manager has complete control over  the  creation
  278. of  ICE  connections.  The session manager has to first call
  279. IceListenForConnections in order to start listening for con-
  280. nections   from  clients.   Once  a  connection  attempt  is
  281. detected, IceAcceptConnection must be called, and  the    ses-
  282. sion  manager  can simply add the new ICE file descriptor to
  283. the list of descriptors to call select on.
  284.  
  285. For further information on the library functions related  to
  286. ICE connections, see the Inter-Client Exchange Library stan-
  287. dard.
  288.  
  289. 4.  Header Files and Library Name
  290.  
  291. Applications (both  session  managers  and  clients)  should
  292. include  the header file <X11/SM/SMlib.h>.  This header file
  293. defines all of the SMlib data structures and function proto-
  294. types.     SMlib.h  includes  the  header  file <X11/SM/SM.h>,
  295. which defines all of the SMlib constants.
  296.  
  297. Because SMlib is dependent on ICE, applications should    link
  298. against SMlib and ICElib by using -lSM -lICE.
  299.  
  300. 5.  Session Management Client (Smc) Functions
  301.  
  302. This section discusses how Session Management clients:
  303.  
  304. o    Connect to the Session Manager
  305.  
  306. o    Close the connection
  307.  
  308. o    Modify callbacks
  309.  
  310. o    Set, delete, and retrieve Session Manager properties
  311.  
  312. o    Interact with the user
  313.  
  314. o    Request a ``Save Yourself''
  315.  
  316. o    Request a ``Save Yourself Phase 2''
  317.  
  318. o    Complete a ``Save Yourself''
  319.  
  320. o    Use Smc informational functions
  321.  
  322. o    Handle Errors
  323.  
  324.  
  325.  
  326.  
  327.  
  328.                 - 3 -
  329.  
  330.  
  331.  
  332.  
  333.  
  334. X Session Management Library            X11, Release 6.4
  335.  
  336.  
  337. 5.1.  Connecting to the Session Manager
  338.  
  339. To   open   a    connection   with  a  session  manager,  use
  340. SmcOpenConnection.
  341. __
  342. |
  343. SmcConn SmcOpenConnection(network_ids_list, context, xsmp_major_rev, xsmp_minor_rev,
  344.             mask, callbacks, previous_id, client_id_ret, error_length, error_string_ret)
  345.     char *network_ids_list;
  346.     SmPointer context;
  347.     int xsmp_major_rev;
  348.     int xsmp_minor_rev;
  349.     unsigned long mask;
  350.     SmcCallbacks *callbacks;
  351.     char *previous_id;
  352.     char **client_id_ret;
  353.     int error_length;
  354.     char *error_string_ret;
  355.  
  356.  
  357. network_ids_list
  358.       Specifies the network ID(s) of  the  session    man-
  359.       ager.
  360.  
  361. context   A  pointer  to  an opaque object or NULL.  Used to
  362.       determine if an ICE connection can be shared    (see
  363.       below).
  364.  
  365. xsmp_major_rev
  366.       The highest major version of the XSMP the applica-
  367.       tion supports.
  368.  
  369. xsmp_minor_rev
  370.       The highest minor version of the XSMP the applica-
  371.       tion    supports (for the specified xsmp_major_rev).
  372.  
  373. mask      A mask indicating which callbacks to register.
  374.  
  375. callbacks The callbacks to register.   These  callbacks  are
  376.       used    to respond to messages from the session man-
  377.       ager.
  378.  
  379. previous_id
  380.       The client ID from the previous session.
  381.  
  382. client_id_ret
  383.       The client ID for the current session is returned.
  384.  
  385. error_length
  386.       Length of the error_string_ret argument passed in.
  387.  
  388. error_string_ret
  389.       Returns a null-terminated error message,  if    any.
  390.       The    error_string_ret  argument  points  to    user
  391.  
  392.  
  393.  
  394.                 - 4 -
  395.  
  396.  
  397.  
  398.  
  399.  
  400. X Session Management Library            X11, Release 6.4
  401.  
  402.  
  403.       supplied memory.  No more than error_length  bytes
  404.       are used.
  405. |__
  406.  
  407. The  network_ids_list  argument  is a null-terminated string
  408. containing a list of network IDs for  the  session  manager,
  409. separated by commas.  If network_ids_list is NULL, the value
  410. of the SESSION_MANAGER environment variable  will  be  used.
  411. Each network ID has the following format:
  412.  
  413.      tcp/<hostname>:<portnumber>    or
  414.      decnet/<hostname>::<objname>   or
  415.      local/<hostname>:<path>
  416.  
  417.  
  418. An  attempt  will  be  made to use the first network ID.  If
  419. that fails, an attempt will be made using the second network
  420. ID, and so on.
  421.  
  422. After  the connection is established, SmcOpenConnection reg-
  423. isters the client with the session manager.  If  the  client
  424. is  being  restarted  from  a  previous session, previous_id
  425. should contain a null  terminated  string  representing  the
  426. client ID from the previous session.  If the client is first
  427. joining the session, previous_id should be set to NULL.   If
  428. previous_id  is specified but is determined to be invalid by
  429. the session manager, SMlib will re-register the client    with
  430. previous_id set to NULL.
  431.  
  432. If  SmcOpenConnection succeeds, it returns an opaque connec-
  433. tion pointer of type SmcConn and the client_id_ret  argument
  434. contains  the  client  ID  to be used for this session.  The
  435. client_id_ret should be freed with a call to  free  when  no
  436. longer    needed.  On failure, SmcOpenConnection returns NULL,
  437. and the reason for failure is returned in  error_string_ret.
  438.  
  439. Note that SMlib uses the ICE protocol to establish a connec-
  440. tion with the session manager.    If an ICE connection already
  441. exists    between  the client and session manager, it might be
  442. possible for the same ICE connection to be used for  session
  443. management.
  444.  
  445. The  context argument indicates how willing the client is to
  446. share the ICE connection with other protocols.     If  context
  447. is NULL, then the caller is always willing to share the con-
  448. nection.  If context is not NULL, then    the  caller  is  not
  449. willing to use a previously opened ICE connection that has a
  450. different non-NULL context associated with it.
  451.  
  452. As previously discussed (section 3, ``Understanding  SMlib's
  453. Dependence  on ICE''), the client will have to keep track of
  454. when ICE connections are created or destroyed (using IceAdd-
  455. ConnectionWatch and IceRemoveConnectionWatch), and will have
  456. to call IceProcessMessages each time  a  select  shows    that
  457.  
  458.  
  459.  
  460.                 - 5 -
  461.  
  462.  
  463.  
  464.  
  465.  
  466. X Session Management Library            X11, Release 6.4
  467.  
  468.  
  469. there  is  data  to  read on an ICE connection.  For further
  470. information, see the Inter-Client Exchange Library standard.
  471.  
  472. The  callbacks    argument contains a set of callbacks used to
  473. respond to session manager events.  The mask argument speci-
  474. fies  which  callbacks are set.  All of the callbacks speci-
  475. fied in this version of SMlib are mandatory.  The mask argu-
  476. ment is necessary in order to maintain backwards compatibil-
  477. ity in future versions of the library.
  478.  
  479. The following values may be ORed together to obtain  a    mask
  480. value:
  481.  
  482.  
  483. SmcSaveYourselfProcMask
  484. SmcDieProcMask
  485. SmcSaveCompleteProcMask
  486. SmcShutdownCancelledProcMask
  487.  
  488.  
  489. For  each  callback,  the  client  can register a pointer to
  490. client data.  When SMlib invokes the callback, it will    pass
  491. the client data pointer.
  492.  
  493. __
  494. |
  495. typedef struct {
  496.  
  497.      struct {
  498.       SmcSaveYourselfProc callback;
  499.       SmPointer client_data;
  500.      } save_yourself;
  501.  
  502.      struct {
  503.       SmcDieProc callback;
  504.       SmPointer client_data;
  505.      } die;
  506.  
  507.      struct {
  508.       SmcSaveCompleteProc callback;
  509.       SmPointer client_data;
  510.      } save_complete;
  511.  
  512.      struct {
  513.       SmcShutdownCancelledProc callback;
  514.       SmPointer client_data;
  515.      } shutdown_cancelled;
  516.  
  517. } SmcCallbacks;
  518.  
  519. |__
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.                 - 6 -
  527.  
  528.  
  529.  
  530.  
  531.  
  532. X Session Management Library            X11, Release 6.4
  533.  
  534.  
  535. 5.1.1.    The Save Yourself Callback
  536.  
  537. The Save Yourself callback is of type SmcSaveYourselfProc.
  538. __
  539. |
  540. typedef void (*SmcSaveYourselfProc)();
  541.  
  542. void SaveYourselfProc(smc_conn, client_data, save_type, shutdown, interact_style, fast)
  543.     SmcConn smc_conn;
  544.     SmPointer client_data;
  545.     int save_type;
  546.     Bool shutdown;
  547.     int interact_style;
  548.     Bool fast;
  549.  
  550.  
  551. smc_conn  The session management connection object.
  552.  
  553. client_data
  554.       Client data specified when the callback was regis-
  555.       tered.
  556.  
  557. save_type Specifies the type of information that  should  be
  558.       saved.
  559.  
  560. shutdown  Specifies if a shutdown is taking place.
  561.  
  562. interact_style
  563.       The type of interaction allowed with the user.
  564.  
  565. fast      If  True,  the  client  should  save    its state as
  566.       quickly as possible.
  567. |__
  568.  
  569. The session manager sends a ``Save Yourself'' message  to  a
  570. client either to checkpoint it or just before termination so
  571. that it can save its state.  The client responds  with    zero
  572. or  more  calls to SmcSetProperties to update the properties
  573. indicating how to restart the client.  When all the  proper-
  574. ties have been set, the client calls SmcSaveYourselfDone.
  575.  
  576. If  interact_style  is    SmInteractStyleNone, the client must
  577. not interact with the user while saving  state.   If  inter-
  578. act_style  is SmInteractStyleErrors, the client may interact
  579. with the user only if an error condition arises.  If  inter-
  580. act_style  is SmInteractStyleAny, then the client may inter-
  581. act with the user for any purpose.  Because only one  client
  582. can  interact  with the user at a time, the client must call
  583. SmcInteractRequest and wait for an ``Interact'' message from
  584. the  session  manager.     When the client is done interacting
  585. with the user, it calls  SmcInteractDone.   The  client  may
  586. only  call  SmcInteractRequest    after  it  receives a ``Save
  587. Yourself'' message and before it calls    SmcSaveYourselfDone.
  588.  
  589.  
  590.  
  591.  
  592.                 - 7 -
  593.  
  594.  
  595.  
  596.  
  597.  
  598. X Session Management Library            X11, Release 6.4
  599.  
  600.  
  601. If  save_type  is  SmSaveLocal,  the  client must update the
  602. properties to reflect its current state.   Specifically,  it
  603. should    save enough information to restore the state as seen
  604. by the user of this client.  It should not affect the  state
  605. as  seen  by other users.  If save_type is SmSaveGlobal, the
  606. user wants the client to commit all of its  data  to  perma-
  607. nent,    globally   accessible    storage.   If  save_type  is
  608. SmSaveBoth, the client should do both of  these  (it  should
  609. first  commit  the data to permanent storage before updating
  610. its properties).
  611.  
  612. Some examples are as follows:
  613.  
  614.  
  615. o    If a word processor were sent a ``Save Yourself''    with
  616.      a type of SmSaveLocal, it could create a temporary file
  617.      that included the current contents  of  the  file,  the
  618.      location  of  the cursor, and other aspects of the cur-
  619.      rent  editing  session.   It  would  then    update     its
  620.      SmRestartCommand  property  with  enough information to
  621.      find this temporary file.
  622.  
  623. o    If a word processor were sent a ``Save Yourself''    with
  624.      a    type  of SmSaveGlobal, it would simply save the cur-
  625.      rently edited file.
  626.  
  627. o    If a word processor were sent a ``Save Yourself''    with
  628.      a type of SmSaveBoth, it would first save the currently
  629.      edited file.  It would then  create  a  temporary    file
  630.      with  information    such  as the current position of the
  631.      cursor and what file  is  being  edited.    Finally,  it
  632.      would  update its SmRestartCommand property with enough
  633.      information to find the temporary file.
  634.  
  635. The shutdown argument specifies whether the system is  being
  636. shut  down.   The  interaction    is  different  depending  on
  637. whether or not shutdown is set.  If not shutting  down,  the
  638. client    should    save  its  state  and wait for a ``Save Com-
  639. plete'' message.  If shutting down,  the  client  must    save
  640. state  and then prevent interaction until it receives either
  641. a ``Die'' or a ``Shutdown Cancelled.''
  642.  
  643. The fast argument specifies that the client should save  its
  644. state  as  quickly as possible.  For example, if the session
  645. manager knows that power is about to fail, it would set fast
  646. to True.
  647.  
  648. 5.1.2.    The Die Callback
  649.  
  650. The Die callback is of type SmcDieProc.
  651. __
  652. |
  653.  
  654.  
  655.  
  656.  
  657.  
  658.                 - 8 -
  659.  
  660.  
  661.  
  662.  
  663.  
  664. X Session Management Library            X11, Release 6.4
  665.  
  666.  
  667. typedef void (*SmcDieProc)();
  668.  
  669. void DieProc(smc_conn, client_data)
  670.     SmcConn smc_conn;
  671.     SmPointer client_data;
  672.  
  673.  
  674. smc_conn  The session management connection object.
  675.  
  676. client_data
  677.       Client data specified when the callback was regis-
  678.       tered.
  679. |__
  680.  
  681. The session manager sends a ``Die'' message to a client when
  682. it  wants  it  to die.    The client should respond by calling
  683. SmcCloseConnection.  A session manager that behaves properly
  684. will  send  a  ``Save  Yourself'' message before the ``Die''
  685. message.
  686.  
  687. 5.1.3.    The Save Complete Callback
  688.  
  689. The Save Complete callback is of type SmcSaveCompleteProc.
  690. __
  691. |
  692. typedef void (*SmcSaveCompleteProc)();
  693.  
  694. void SaveCompleteProc(smc_conn, client_data)
  695.     SmcConn smc_conn;
  696.     SmPointer client_data;
  697.  
  698.  
  699. smc_conn  The session management connection object.
  700.  
  701. client_data
  702.       Client data specified when the callback was regis-
  703.       tered.
  704. |__
  705.  
  706. When  the session manager is done with a checkpoint, it will
  707. send each of the clients a ``Save Complete''  message.     The
  708. client is then free to change its state.
  709.  
  710. 5.1.4.    The Shutdown Cancelled Callback
  711.  
  712. The    Shutdown    Cancelled    callback    is      of    type
  713. SmcShutdownCancelledProc.
  714. __
  715. |
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.                 - 9 -
  725.  
  726.  
  727.  
  728.  
  729.  
  730. X Session Management Library            X11, Release 6.4
  731.  
  732.  
  733. typedef void (*SmcShutdownCancelledProc)();
  734.  
  735. void ShutdownCancelledProc(smc_conn, client_data)
  736.     SmcConn smc_conn;
  737.     SmPointer client_data;
  738.  
  739.  
  740. smc_conn  The session management connection object.
  741.  
  742. client_data
  743.       Client data specified when the callback was regis-
  744.       tered.
  745. |__
  746.  
  747. The  session  manager sends a ``Shutdown Cancelled'' message
  748. when the user cancelled the shutdown during  an  interaction
  749. (see  section  5.5,  ``Interacting  With  the  User'').  The
  750. client can now continue as if the shutdown  had  never    hap-
  751. pened.     If  the  client  has not called SmcSaveYourselfDone
  752. yet, it can either abort the save and then call SmcSaveYour-
  753. selfDone  with    the success argument set to False, or it can
  754. continue with the save    and  then  call  SmcSaveYourselfDone
  755. with  the success argument set to reflect the outcome of the
  756. save.
  757.  
  758. 5.2.  Closing the Connection
  759.  
  760. To  close  a  connection  with    a   session   manager,     use
  761. SmcCloseConnection.
  762.  
  763. __
  764. |
  765. SmcCloseStatus SmcCloseConnection(smc_conn, count, reason_msgs)
  766.     SmcConn smc_conn;
  767.     int count;
  768.     char **reason_msgs;
  769.  
  770.  
  771. smc_conn  The session management connection object.
  772.  
  773. count      The number of reason messages.
  774.  
  775. reason_msgs
  776.       The reasons for closing the connection.
  777. |__
  778.  
  779. The  reason_msgs argument will most likely be NULL if resig-
  780. nation is expected by the client.  Otherwise, it contains  a
  781. list  of  null-terminated Compound Text strings representing
  782. the reason for termination.  The session manager should dis-
  783. play these reason messages to the user.
  784.  
  785. Note that SMlib used the ICE protocol to establish a connec-
  786. tion with the session manager, and various  protocols  other
  787.  
  788.  
  789.  
  790.                - 10 -
  791.  
  792.  
  793.  
  794.  
  795.  
  796. X Session Management Library            X11, Release 6.4
  797.  
  798.  
  799. than session management may be active on the ICE connection.
  800. When SmcCloseConnection is called, the ICE  connection    will
  801. be  closed  only  if all protocols have been shutdown on the
  802. connection.  Check the ICElib standard for IceAddConnection-
  803. Watch  and IceRemoveConnectionWatch to learn how to set up a
  804. callback to be invoked each time an ICE connection is opened
  805. or  closed.   Typically  this  callback adds/removes the ICE
  806. file descriptor from the list of active descriptors to    call
  807. select on (or calls XtAppAddInput or XtRemoveInput).
  808.  
  809. SmcCloseConnection returns one of the following values:
  810.  
  811. o    SmcClosedNow  -  the  ICE connection was closed at this
  812.      time, the watch procedures were invoked, and  the    con-
  813.      nection was freed.
  814.  
  815. o    SmcClosedASAP - an IO error had occurred on the connec-
  816.      tion, but SmcCloseConnection is being called  within  a
  817.      nested  IceProcessMessages.   The watch procedures have
  818.      been invoked at this time, but the connection  will  be
  819.      freed  as    soon  as  possible  (when  the nesting level
  820.      reaches zero and IceProcessMessages returns a status of
  821.      IceProcessMessagesConnectionClosed).
  822.  
  823. o    SmcConnectionInUse  -  the connection was not closed at
  824.      this time, because it is being  used  by  other  active
  825.      protocols.
  826.  
  827. 5.3.  Modifying Callbacks
  828.  
  829. To   modify  callbacks    set  up  in  SmcOpenConnection,  use
  830. SmcModifyCallbacks.
  831. __
  832. |
  833. void SmcModifyCallbacks(smc_conn, mask, callbacks)
  834.     SmcConn smc_conn;
  835.     unsigned long mask;
  836.     SmcCallbacks *callbacks;
  837.  
  838.  
  839. smc_conn  The session management connection object.
  840.  
  841. mask      A mask indicating which callbacks to modify.
  842.  
  843. callbacks The new callbacks.
  844. |__
  845.  
  846. When specifying a value for the mask argument, the following
  847. values may be ORed together:
  848.  
  849.  
  850. SmcSaveYourselfProcMask
  851. SmcDieProcMask
  852. SmcSaveCompleteProcMask
  853.  
  854.  
  855.  
  856.                - 11 -
  857.  
  858.  
  859.  
  860.  
  861.  
  862. X Session Management Library            X11, Release 6.4
  863.  
  864.  
  865. SmcShutdownCancelledProcMask
  866.  
  867.  
  868. 5.4.   Setting,  Deleting, and Retrieving Session Management
  869. Properties
  870.  
  871. To  set  session  management properties for this client, use
  872. SmcSetProperties.
  873. __
  874. |
  875. void SmcSetProperties(smc_conn, num_props, props)
  876.     SmcConn smc_conn;
  877.     int num_props;
  878.     SmProp **props;
  879.  
  880.  
  881. smc_conn  The session management connection object.
  882.  
  883. num_props The number of properties.
  884.  
  885. props      The list of properties to set.
  886. |__
  887.  
  888. The properties are specified as an array of property  point-
  889. ers.   Previously  set    property  values may be over-written
  890. using the SmcSetProperties function.  Note that the  session
  891. manager  is not expected to restore property values when the
  892. session is restarted.  Because of this, clients  should  not
  893. try  to  use  the  session manager as a database for storing
  894. application specific state.
  895.  
  896. For a description of session management properties  and  the
  897. SmProp    structure, see section 7, ``Session Management Prop-
  898. erties.''
  899.  
  900.  
  901. To delete properties  previously  set  by  the    client,  use
  902. SmcDeleteProperties.
  903. __
  904. |
  905. void SmcDeleteProperties(smc_conn, num_props, prop_names)
  906.     SmcConn smc_conn;
  907.     int num_props;
  908.     char **prop_names;
  909.  
  910.  
  911. smc_conn  The session management connection object.
  912.  
  913. num_props The number of properties.
  914.  
  915. prop_names
  916.       The list of properties to delete.
  917.  
  918.  
  919.  
  920.  
  921.  
  922.                - 12 -
  923.  
  924.  
  925.  
  926.  
  927.  
  928. X Session Management Library            X11, Release 6.4
  929.  
  930.  
  931. |__
  932.  
  933.  
  934. To  get  properties  previously  stored  by  the client, use
  935. SmcGetProperties.
  936. __
  937. |
  938. Status SmcGetProperties(smc_conn, prop_reply_proc, client_data)
  939.     SmcConn smc_conn;
  940.     SmcPropReplyProc prop_reply_proc;
  941.     SmPointer client_data;
  942.  
  943.  
  944. smc_conn  The session management connection object.
  945.  
  946. prop_reply_proc
  947.       The callback to be  invoked  when  the  properties
  948.       reply comes back.
  949.  
  950. client_data
  951.       This    pointer to client data will be passed to the
  952.       SmcPropReplyProc callback.
  953. |__
  954.  
  955. The return value of SmcGetProperties is zero for failure and
  956. a positive value for success.
  957.  
  958. Note  that  the  library does not block until the properties
  959. reply comes back.  Rather, a  callback    of  type  SmcPropRe-
  960. plyProc is invoked when the data is ready.
  961. __
  962. |
  963. typedef void (*SmcPropReplyProc)();
  964.  
  965. void PropReplyProc(smc_conn, client_data, num_props, props)
  966.     SmcConn smc_conn;
  967.     SmPointer client_data;
  968.     int num_props;
  969.     SmProp **props;
  970.  
  971.  
  972. smc_conn  The session management connection object.
  973.  
  974. client_data
  975.       Client data specified when the callback was regis-
  976.       tered.
  977.  
  978. num_props The number of properties returned.
  979.  
  980. props      The list of properties returned.
  981. |__
  982.  
  983. To free each property, use SmFreeProperty  (see  section  8,
  984. ``Freeing  Data'').   To  free the actual array of pointers,
  985.  
  986.  
  987.  
  988.                - 13 -
  989.  
  990.  
  991.  
  992.  
  993.  
  994. X Session Management Library            X11, Release 6.4
  995.  
  996.  
  997. use free.
  998.  
  999. 5.5.  Interacting With the User
  1000.  
  1001. After receiving a ``Save Yourself'' message with  an  inter-
  1002. act_style  of  SmInteractStyleErrors  or SmInteractStyleAny,
  1003. the client may choose to interact with    the  user.   Because
  1004. only  one  client  can interact with the user at a time, the
  1005. client must call SmcInteractRequest and wait for an ``Inter-
  1006. act'' message from the session manager.
  1007. __
  1008. |
  1009. Status SmcInteractRequest(smc_conn, dialog_type, interact_proc, client_data)
  1010.     SmcConn smc_conn;
  1011.     int dialog_type;
  1012.     SmcInteractProc interact_proc;
  1013.     SmPointer client_data;
  1014.  
  1015.  
  1016. smc_conn  The session management connection object.
  1017.  
  1018. dialog_type
  1019.       The type of dialog the client wishes to present to
  1020.       the user.
  1021.  
  1022. interact_proc
  1023.       The callback to be invoked when  the    ``Interact''
  1024.       message arrives from the session manager.
  1025.  
  1026. client_data
  1027.       This    pointer to client data will be passed to the
  1028.       SmcInteractProc  callback  when  the    ``Interact''
  1029.       message arrives.
  1030. |__
  1031.  
  1032. The  return  value of SmcInteractRequest is zero for failure
  1033. and a positive value for success.
  1034.  
  1035. The dialog_type  argument  specifies  either  SmDialogError,
  1036. indicating  that  the client wants to start an error dialog,
  1037. or SmDialogNormal, meaning that the client wishes to start a
  1038. nonerror dialog.
  1039.  
  1040. Note  that  if    a shutdown is in progress, the user may have
  1041. the option of cancelling the shutdown.    If the    shutdown  is
  1042. cancelled, the clients that have not interacted yet with the
  1043. user will receive a ``Shutdown Cancelled''  message  instead
  1044. of the ``Interact'' message.
  1045.  
  1046. The  SmcInteractProc  callback    will  be  invoked  when  the
  1047. ``Interact'' message arrives from the session manager.
  1048. __
  1049. |
  1050.  
  1051.  
  1052.  
  1053.  
  1054.                - 14 -
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. X Session Management Library            X11, Release 6.4
  1061.  
  1062.  
  1063. typedef void (*SmcInteractProc)();
  1064.  
  1065. void InteractProc(smc_conn, client_data)
  1066.     SmcConn smc_conn;
  1067.     SmPointer client_data;
  1068.  
  1069.  
  1070. smc_conn  The session management connection object.
  1071.  
  1072. client_data
  1073.       Client data specified when the callback was regis-
  1074.       tered.
  1075. |__
  1076.  
  1077.  
  1078. After  interacting with the user (in response to an ``Inter-
  1079. act'' message), you should call SmcInteractDone.
  1080. __
  1081. |
  1082. void SmcInteractDone(smc_conn, cancel_shutdown)
  1083.     SmcConn smc_conn;
  1084.     Bool cancel_shutdown;
  1085.  
  1086.  
  1087. smc_conn  The session management connection object.
  1088.  
  1089. cancel_shutdown
  1090.       If True, indicates that the user requests that the
  1091.       entire shutdown be cancelled.
  1092. |__
  1093.  
  1094. The  cancel_shutdown argument may only be True if the corre-
  1095. sponding ``Save Yourself'' specified True for  shutdown  and
  1096. SmInteractStyleErrors  or  SmInteractStyleAny for the inter-
  1097. act_style.
  1098.  
  1099. 5.6.  Requesting a Save Yourself
  1100.  
  1101. To request  a  checkpoint  from  the  session  manager,  use
  1102. SmcRequestSaveYourself.
  1103. __
  1104. |
  1105. void SmcRequestSaveYourself(smc_conn, save_type, shutdown, interact_style, fast, global)
  1106.     SmcConn smc_conn;
  1107.     int save_type;
  1108.     Bool shutdown;
  1109.     int interact_style;
  1110.     Bool fast;
  1111.     Bool global;
  1112.  
  1113.  
  1114. smc_conn  The session management connection object.
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.                - 15 -
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. X Session Management Library            X11, Release 6.4
  1127.  
  1128.  
  1129. save_type Specifies  the  type of information that should be
  1130.       saved.
  1131.  
  1132. shutdown  Specifies if a shutdown is taking place.
  1133.  
  1134. interact_style
  1135.       The type of interaction allowed with the user.
  1136.  
  1137. fast      If True, the    client    should    save  its  state  as
  1138.       quickly as possible.
  1139.  
  1140. global      Controls who gets the ``Save Yourself.''
  1141. |__
  1142.  
  1143. The  save_type, shutdown, interact_style, and fast arguments
  1144. are discussed in more detail in section  5.1.1,  ``The    Save
  1145. Yourself Callback.''
  1146.  
  1147. If  global  is    set to True, then the resulting ``Save Your-
  1148. self'' should be sent to all clients in  the  session.     For
  1149. example,  a  vendor  of a Uninterruptible Power Supply (UPS)
  1150. might include a Session Management client that would monitor
  1151. the  status  of  the UPS and generate a fast shutdown if the
  1152. power is about to be lost.
  1153.  
  1154. If global is set to False, then the ``Save Yourself'' should
  1155. only be sent to the client that requested it.
  1156.  
  1157. 5.7.  Requesting a Save Yourself Phase 2
  1158.  
  1159. In  response to a ``Save Yourself, the client may request to
  1160. be informed when all the other clients are quiescent so that
  1161. it    can    save    their    state.     To   do   so,     use
  1162. SmcRequestSaveYourselfPhase2.
  1163. __
  1164. |
  1165. Status SmcRequestSaveYourselfPhase2(smc_conn, save_yourself_phase2_proc, client_data)
  1166.     SmcConn smc_conn;
  1167.     SmcSaveYourselfPhase2Proc save_yourself_phase2_proc;
  1168.     SmPointer client_data;
  1169.  
  1170.  
  1171. smc_conn  The session management connection object.
  1172.  
  1173. save_yourself_phase2_proc
  1174.       The callback to be invoked when the  ``Save  Your-
  1175.       self    Phase  2''  message arrives from the session
  1176.       manager.
  1177.  
  1178. client_data
  1179.       This pointer to client data will be passed to  the
  1180.       SmcSaveYourselfPhase2Proc callback when the ``Save
  1181.       Yourself Phase 2'' message arrives.
  1182.  
  1183.  
  1184.  
  1185.  
  1186.                - 16 -
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. X Session Management Library            X11, Release 6.4
  1193.  
  1194.  
  1195. |__
  1196.  
  1197. The return value of SmcRequestSaveYourselfPhase2 is zero for
  1198. failure and a positive value for success.
  1199.  
  1200. This  request is needed by clients that manage other clients
  1201. (for example, window managers, workspace  managers,  and  so
  1202. on).   The  manager  must  make sure that all of the clients
  1203. that are being managed are in an idle state  so  that  their
  1204. state can be saved.
  1205.  
  1206. 5.8.  Completing a Save Yourself
  1207.  
  1208. After  saving  state in response to a ``Save Yourself'' mes-
  1209. sage, you should call SmcSaveYourselfDone.
  1210. __
  1211. |
  1212. void SmcSaveYourselfDone(smc_conn, success)
  1213.     SmcConn smc_conn;
  1214.     Bool success;
  1215.  
  1216.  
  1217. smc_conn  The session management connection object.
  1218.  
  1219. success   If True, the ``Save Yourself'' operation was    com-
  1220.       pleted successfully.
  1221. |__
  1222.  
  1223. Before calling SmcSaveYourselfDone, the client must have set
  1224. each required property at least once since the client regis-
  1225. tered with the session manager.
  1226.  
  1227. 5.9.  Using Smc Informational Functions
  1228.  
  1229. __
  1230. |
  1231. int SmcProtocolVersion(smc_conn)
  1232.     SmcConn smc_conn;
  1233. |__
  1234.  
  1235. SmcProtocolVersion  returns the major version of the session
  1236. management protocol associated with this session.
  1237.  
  1238.  
  1239. __
  1240. |
  1241. int SmcProtocolRevision(smc_conn)
  1242.     SmcConn smc_conn;
  1243. |__
  1244.  
  1245. SmcProtocolRevision returns the minor version of the session
  1246. management protocol associated with this session.
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.                - 17 -
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. X Session Management Library            X11, Release 6.4
  1259.  
  1260. __
  1261. |
  1262. char *SmcVendor(smc_conn)
  1263.     SmcConn smc_conn;
  1264. |__
  1265.  
  1266. SmcVendor returns a string that provides some identification
  1267. of the owner of the session manager.  The string  should  be
  1268. freed with a call to free.
  1269.  
  1270.  
  1271. __
  1272. |
  1273. char *SmcRelease(smc_conn)
  1274.     SmcConn smc_conn;
  1275. |__
  1276.  
  1277. SmcRelease returns a string that provides the release number
  1278. of the session manager.  The string should be freed  with  a
  1279. call to free.
  1280.  
  1281.  
  1282. __
  1283. |
  1284. char *SmcClientID(smc_conn)
  1285.     SmcConn smc_conn;
  1286. |__
  1287.  
  1288. SmcClientID  returns a null-terminated string for the client
  1289. ID associated with this connection.   This  information  was
  1290. also  returned in SmcOpenConnection (it is provided here for
  1291. convenience).  Call free on this pointer when the client  ID
  1292. is no longer needed.
  1293.  
  1294.  
  1295. __
  1296. |
  1297. IceConn SmcGetIceConnection(smc_conn)
  1298.     SmcConn smc_conn;
  1299. |__
  1300.  
  1301. SmcGetIceConnection  returns the ICE connection object asso-
  1302. ciated with this session management connection object.     The
  1303. ICE  connection  object  can  be used to get some additional
  1304. information about the connection.  Some of the    more  useful
  1305. functions   which   can   be   used   on   the    IceConn  are
  1306. IceConnectionNumber,            IceConnectionString,
  1307. IceLastSentSequenceNumber,    IceLastReceivedSequenceNumber,
  1308. and IcePing.  For further information, see the    Inter-Client
  1309. Exchange Library standard.
  1310.  
  1311. 5.10.  Error Handling
  1312.  
  1313. If the client receives an unexpected protocol error from the
  1314. session manager, an error handler is invoked  by  SMlib.   A
  1315.  
  1316.  
  1317.  
  1318.                - 18 -
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. X Session Management Library            X11, Release 6.4
  1325.  
  1326.  
  1327. default  error    handler  exists that simply prints the error
  1328. message to stderr and exits if the severity of the error  is
  1329. fatal.     The client can change this error handler by calling
  1330. the SmcSetErrorHandler function.
  1331. __
  1332. |
  1333. SmcErrorHandler SmcSetErrorHandler(handler)
  1334.     SmcErrorHandler handler;
  1335.  
  1336.  
  1337. handler   The  error  handler.     You  should  pass  NULL  to
  1338.       restore the default handler.
  1339. |__
  1340.  
  1341. SmcSetErrorHandler returns the previous error handler.
  1342.  
  1343. The SmcErrorHandler has the following type:
  1344. __
  1345. |
  1346. typedef void (*SmcErrorHandler)();
  1347.  
  1348. void ErrorHandler(smc_conn, swap, offending_minor_opcode, offending_sequence_num, error_class, severity, values)
  1349.     SmcConn smc_conn;
  1350.     Bool swap;
  1351.     int offending_minor_opcode;
  1352.     unsigned long offending_sequence_num;
  1353.     int error_class;
  1354.     int severity;
  1355.     IcePointer values;
  1356.  
  1357.  
  1358. smc_conn  The session management connection object.
  1359.  
  1360. swap      A flag that indicates if the specified values need
  1361.       byte swapping.
  1362.  
  1363. offending_minor_opcode
  1364.       The minor opcode of the offending message.
  1365.  
  1366. offending_sequence_num
  1367.       The sequence number of the offending message.
  1368.  
  1369. error_class
  1370.       The error class of the offending message.
  1371.  
  1372. severity  IceCanContinue,    IceFatalToProtocol,      or
  1373.       IceFatalToConnection.
  1374.  
  1375. values      Any  additional error values specific to the minor
  1376.       opcode and class.
  1377. |__
  1378.  
  1379. Note that this error handler is invoked for protocol related
  1380. errors.   To  install an error handler to be invoked when an
  1381.  
  1382.  
  1383.  
  1384.                - 19 -
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. X Session Management Library            X11, Release 6.4
  1391.  
  1392.  
  1393. IO error  occurs,  use    IceSetIOErrorHandler.    For  further
  1394. information, see the Inter-Client Exchange Library standard.
  1395.  
  1396. 6.  Session Management Server (Sms) Functions
  1397.  
  1398. This section discusses how Session Management servers:
  1399.  
  1400. o    Initialize the library
  1401.  
  1402. o    Register the client
  1403.  
  1404. o    Send a ``Save Yourself'' message
  1405.  
  1406. o    Send a ``Save Yourself Phase 2'' message
  1407.  
  1408. o    Send an ``Interact'' message
  1409.  
  1410. o    Send a ``Save Complete'' message
  1411.  
  1412. o    Send a ``Die'' message
  1413.  
  1414. o    Cancel a shutdown
  1415.  
  1416. o    Return properties
  1417.  
  1418. o    Ping a client
  1419.  
  1420. o    Clean up after a client disconnects
  1421.  
  1422. o    Use Sms informational functions
  1423.  
  1424. o    Handle errors
  1425.  
  1426. 6.1.  Initializing the Library
  1427.  
  1428. SmsInitialize is the first SMlib  function  that  should  be
  1429. called    by a session manager.  It provides information about
  1430. the session manager and registers a callback  that  will  be
  1431. invoked  each time a new client connects to the session man-
  1432. ager.
  1433. __
  1434. |
  1435. Status SmsInitialize(vendor, release, new_client_proc, manager_data, host_based_auth_proc,
  1436.             error_length, error_string_ret)
  1437.     char *vendor;
  1438.     char *release;
  1439.     SmsNewClientProc new_client_proc;
  1440.     SmPointer manager_data;
  1441.     IceHostBasedAuthProc host_based_auth_proc;
  1442.     int error_length;
  1443.     char *error_string_ret;
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.                - 20 -
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. X Session Management Library            X11, Release 6.4
  1457.  
  1458.  
  1459. vendor      A string specifying the session manager vendor.
  1460.  
  1461. release   A string specifying the  session  manager  release
  1462.       number.
  1463.  
  1464. new_client_proc
  1465.       Callback to be invoked each time a new client con-
  1466.       nects to the session manager.
  1467.  
  1468. manager_data
  1469.       When the  SmsNewClientProc  callback    is  invoked,
  1470.       this pointer to manager data will be passed.
  1471.  
  1472. host_based_auth_proc
  1473.       Host based authentication callback.
  1474.  
  1475. error_length
  1476.       Length of the error_string_ret argument passed in.
  1477.  
  1478. error_string_ret
  1479.       Returns a null-terminated error message,  if    any.
  1480.       The  error_string_ret points to user supplied mem-
  1481.       ory.    No more than error_length bytes are used.
  1482. |__
  1483.  
  1484. After the SmsInitialize function is called, the session man-
  1485. ager  should  call  the  IceListenForConnections function to
  1486. listen for new connections.  Afterwards, each time a  client
  1487. connects,     the     session      manager     should    call
  1488. IceAcceptConnection.
  1489.  
  1490. See section  9,  ``Authentication  of  Clients,''  for    more
  1491. details  on authentication (including host based authentica-
  1492. tion).    Also see the Inter-Client Exchange Library  standard
  1493. for  further details on listening for and accepting ICE con-
  1494. nections.
  1495.  
  1496. Each time a new client connects to the session manager,  the
  1497. SmsNewClientProc  callback  is invoked.  The session manager
  1498. obtains a new opaque connection object that  it  should  use
  1499. for  all  future interaction with the client.  At this time,
  1500. the session manager must also register a set of callbacks to
  1501. respond  to  the  different  messages  that the client might
  1502. send.
  1503. __
  1504. |
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.                - 21 -
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. X Session Management Library            X11, Release 6.4
  1523.  
  1524.  
  1525. typedef Status (*SmsNewClientProc)();
  1526.  
  1527. Status NewClientProc(sms_conn, manager_data, mask_ret, callbacks_ret, failure_reason_ret)
  1528.     SmsConn sms_conn;
  1529.     SmPointer manager_data;
  1530.     unsigned long *mask_ret;
  1531.     SmsCallbacks *callbacks_ret;
  1532.     char **failure_reason_ret;
  1533.  
  1534.  
  1535. sms_conn  A new opaque connection object.
  1536.  
  1537. manager_data
  1538.       Manager data specified when the callback was    reg-
  1539.       istered.
  1540.  
  1541. mask_ret  On  return,  indicates which callbacks were set by
  1542.       the session manager.
  1543.  
  1544. callbacks_ret
  1545.       On return, contains the  callbacks  registered  by
  1546.       the session manager.
  1547.  
  1548. failure_reason_ret
  1549.       Failure reason returned.
  1550. |__
  1551.  
  1552. If  a  failure    occurs, the SmsNewClientProc should return a
  1553. zero status as well as allocate and return a failure  reason
  1554. string in failure_reason_ret.  SMlib will be responsible for
  1555. freeing this memory.
  1556.  
  1557. The session manager must register  a  set  of  callbacks  to
  1558. respond  to  client events.  The mask_ret argument specifies
  1559. which callbacks are set.  All of the callbacks specified  in
  1560. this  version of SMlib are mandatory.  The mask_ret argument
  1561. is necessary in order to maintain backwards compatibility in
  1562. future versions of the library.
  1563.  
  1564. The  following    values may be ORed together to obtain a mask
  1565. value:
  1566.  
  1567.  
  1568. SmsRegisterClientProcMask
  1569. SmsInteractRequestProcMask
  1570. SmsInteractDoneProcMask
  1571. SmsSaveYourselfRequestProcMask
  1572. SmsSaveYourselfP2RequestProcMask
  1573. SmsSaveYourselfDoneProcMask
  1574. SmsCloseConnectionProcMask
  1575. SmsSetPropertiesProcMask
  1576. SmsDeletePropertiesProcMask
  1577. SmsGetPropertiesProcMask
  1578.  
  1579.  
  1580.  
  1581.  
  1582.                - 22 -
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. X Session Management Library            X11, Release 6.4
  1589.  
  1590.  
  1591. For each  callback,  the  session  manager  can  register  a
  1592. pointer  to  manager  data  specific to that callback.    This
  1593. pointer will be passed to the callback when it is invoked by
  1594. SMlib.
  1595. __
  1596. |
  1597.  
  1598. typedef struct {
  1599.      struct {
  1600.       SmsRegisterClientProc callback;
  1601.       SmPointer manager_data;
  1602.      } register_client;
  1603.  
  1604.      struct {
  1605.       SmsInteractRequestProc callback;
  1606.       SmPointer manager_data;
  1607.      } interact_request;
  1608.  
  1609.      struct {
  1610.       SmsInteractDoneProc callback;
  1611.       SmPointer manager_data;
  1612.      } interact_done;
  1613.  
  1614.      struct {
  1615.       SmsSaveYourselfRequestProc callback;
  1616.       SmPointer manager_data;
  1617.      } save_yourself_request;
  1618.  
  1619.      struct {
  1620.       SmsSaveYourselfPhase2RequestProc callback;
  1621.       SmPointer manager_data;
  1622.      } save_yourself_phase2_request;
  1623.  
  1624.      struct {
  1625.       SmsSaveYourselfDoneProc callback;
  1626.       SmPointer manager_data;
  1627.      } save_yourself_done;
  1628.  
  1629.      struct {
  1630.       SmsCloseConnectionProc callback;
  1631.       SmPointer manager_data;
  1632.      } close_connection;
  1633.  
  1634.      struct {
  1635.       SmsSetPropertiesProc callback;
  1636.       SmPointer manager_data;
  1637.      } set_properties;
  1638.  
  1639.      struct {
  1640.       SmsDeletePropertiesProc callback;
  1641.       SmPointer manager_data;
  1642.      } delete_properties;
  1643.  
  1644.      struct {
  1645.  
  1646.  
  1647.  
  1648.                - 23 -
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. X Session Management Library            X11, Release 6.4
  1655.  
  1656.  
  1657.       SmsGetPropertiesProc callback;
  1658.       SmPointer manager_data;
  1659.      } get_properties;
  1660.  
  1661. } SmsCallbacks;
  1662.  
  1663. |__
  1664.  
  1665.  
  1666. 6.1.1.    The Register Client Callback
  1667.  
  1668. The Register Client callback is the first callback that will
  1669. be invoked after the client connects to the session manager.
  1670. Its type is SmsRegisterClientProc.
  1671. __
  1672. |
  1673. typedef Status (*SmsRegisterClientProc();
  1674.  
  1675. Status RegisterClientProc(sms_conn, manager_data, previous_id)
  1676.     SmsConn sms_conn;
  1677.     SmPointer manager_data;
  1678.     char *previous_id;
  1679.  
  1680.  
  1681. sms_conn  The session management connection object.
  1682.  
  1683. manager_data
  1684.       Manager  data specified when the callback was reg-
  1685.       istered.
  1686.  
  1687. previous_id
  1688.       The client ID from the previous session.
  1689. |__
  1690.  
  1691. Before any further interaction takes place with the  client,
  1692. the client must be registered with the session manager.
  1693.  
  1694. If  the  client  is being restarted from a previous session,
  1695. previous_id will contain a null-terminated string represent-
  1696. ing  the  client ID from the previous session.    Call free on
  1697. the previous_id pointer when it is no longer needed.  If the
  1698. client    is  first  joining  the session, previous_id will be
  1699. NULL.
  1700.  
  1701. If previous_id is invalid, the session    manager  should  not
  1702. register  the  client  at  this  time.    This callback should
  1703. return a status of zero, which will cause an  error  message
  1704. to  be    sent  to  the client.  The client should re-register
  1705. with previous_id set to NULL.
  1706.  
  1707. Otherwise, the session manager should  register  the  client
  1708. with  a unique client ID by calling the SmsRegisterClientRe-
  1709. ply function (to be discussed shortly), and the SmsRegister-
  1710. ClientProc callback should return a status of one.
  1711.  
  1712.  
  1713.  
  1714.                - 24 -
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. X Session Management Library            X11, Release 6.4
  1721.  
  1722.  
  1723. 6.1.2.    The Interact Request Callback
  1724.  
  1725. The    Interact     Request    callback    is      of    type
  1726. SmsInteractRequestProc.
  1727. __
  1728. |
  1729. typedef void (*SmsInteractRequestProc)();
  1730.  
  1731. void InteractRequestProc(sms_conn, manager_data, dialog_type)
  1732.     SmsConn sms_conn;
  1733.     SmPointer manager_data;
  1734.     int dialog_type;
  1735.  
  1736.  
  1737. sms_conn  The session management connection object.
  1738.  
  1739. manager_data
  1740.       Manager data specified when the callback was    reg-
  1741.       istered.
  1742.  
  1743. dialog_type
  1744.       The type of dialog the client wishes to present to
  1745.       the user.
  1746. |__
  1747.  
  1748. When a client receives a ``Save Yourself'' message  with  an
  1749. interact_style         of       SmInteractStyleErrors      or
  1750. SmInteractStyleAny, the client may choose to  interact    with
  1751. the  user.   Because  only  one client can interact with the
  1752. user at a time, the client must request to interact with the
  1753. user.    The  session  manager  should  keep  a    queue of all
  1754. clients wishing to interact.  It should send an ``Interact''
  1755. message  to  one client at a time and wait for an ``Interact
  1756. Done'' message before continuing with the next client.
  1757.  
  1758. The dialog_type  argument  specifies  either  SmDialogError,
  1759. indicating  that  the client wants to start an error dialog,
  1760. or SmDialogNormal, meaning that the client wishes to start a
  1761. nonerror dialog.
  1762.  
  1763. If  a  shutdown is in progress, the user may have the option
  1764. of cancelling the shutdown.  If the  shutdown  is  cancelled
  1765. (specified  in    the  ``Interact Done'' message), the session
  1766. manager should send a ``Shutdown Cancelled'' message to each
  1767. client that requested to interact.
  1768.  
  1769. 6.1.3.    The Interact Done Callback
  1770.  
  1771. When  the  client  is  done  interacting  with the user, the
  1772. SmsInteractDoneProc callback will be invoked.
  1773. __
  1774. |
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.                - 25 -
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. X Session Management Library            X11, Release 6.4
  1787.  
  1788.  
  1789. typedef void (*SmsInteractDoneProc)();
  1790.  
  1791. void InteractDoneProc(sms_conn, manager_data, cancel_shutdown)
  1792.     SmsConn sms_conn;
  1793.     SmPointer manager_data;
  1794.     Bool cancel_shutdown;
  1795.  
  1796.  
  1797. sms_conn  The session management connection object.
  1798.  
  1799. manager_data
  1800.       Manager data specified when the callback was    reg-
  1801.       istered.
  1802.  
  1803. cancel_shutdown
  1804.       Specifies  if  the  user  requests that the entire
  1805.       shutdown be cancelled.
  1806. |__
  1807.  
  1808. Note that the shutdown can be cancelled only if  the  corre-
  1809. sponding  ``Save  Yourself'' specified True for shutdown and
  1810. SmInteractStyleErrors or SmInteractStyleAny for  the  inter-
  1811. act_style.
  1812.  
  1813. 6.1.4.    The Save Yourself Request Callback
  1814.  
  1815. The    Save   Yourself     Request   callback   is   of    type
  1816. SmsSaveYourselfRequestProc.
  1817. __
  1818. |
  1819. typedef void (*SmsSaveYourselfRequestProc)();
  1820.  
  1821. void SaveYourselfRequestProc(sms_conn, manager_data, save_type, shutdown, interact_style, fast, global)
  1822.     SmsConn sms_conn;
  1823.     SmPointer manager_data;
  1824.     int save_type;
  1825.     Bool shutdown;
  1826.     int interact_style;
  1827.     Bool fast;
  1828.     Bool global;
  1829.  
  1830.  
  1831. sms_conn  The session management connection object.
  1832.  
  1833. manager_data
  1834.       Manager data specified when the callback was    reg-
  1835.       istered.
  1836.  
  1837. save_type Specifies  the  type of information that should be
  1838.       saved.
  1839.  
  1840. shutdown  Specifies if a shutdown is taking place.
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.                - 26 -
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. X Session Management Library            X11, Release 6.4
  1853.  
  1854.  
  1855. interact_style
  1856.       The type of interaction allowed with the user.
  1857.  
  1858. fast      If True, the    client    should    save  its  state  as
  1859.       quickly as possible.
  1860.  
  1861. global      Controls who gets the ``Save Yourself.''
  1862. |__
  1863.  
  1864. The  Save  Yourself  Request  prompts the session manager to
  1865. initiate a checkpoint or shutdown.  For information  on  the
  1866. save_type, shutdown, interact_style, and fast arguments, see
  1867. section 6.3, ``Sending a Save Yourself Message.''
  1868.  
  1869. If global is set to True, then the  resulting  ``Save  Your-
  1870. self'' should be sent to all applications.  If global is set
  1871. to False, then the ``Save Yourself'' should only be sent  to
  1872. the client that requested it.
  1873.  
  1874. 6.1.5.    The Save Yourself Phase 2 Request Callback
  1875.  
  1876. The Save Yourself  Phase  2  Request  callback    is  of    type
  1877. SmsSaveYourselfPhase2RequestProc.
  1878. __
  1879. |
  1880. typedef void (*SmsSaveYourselfPhase2RequestProc)();
  1881.  
  1882. void SmsSaveYourselfPhase2RequestProc(sms_conn, manager_data)
  1883.     SmsConn sms_conn;
  1884.     SmPointer manager_data;
  1885.  
  1886.  
  1887. sms_conn  The session management connection object.
  1888.  
  1889. manager_data
  1890.       Manager  data specified when the callback was reg-
  1891.       istered.
  1892. |__
  1893.  
  1894. This request is sent by clients that  manage  other  clients
  1895. (for  example,    window    managers, workspace managers, and so
  1896. on).  Such managers must make sure that all of    the  clients
  1897. that  are  being  managed are in an idle state so that their
  1898. state can be saved.
  1899.  
  1900. 6.1.6.    The Save Yourself Done Callback
  1901.  
  1902. When the client is done saving its state in  response  to  a
  1903. ``Save    Yourself'' message, the SmsSaveYourselfDoneProc will
  1904. be invoked.
  1905. __
  1906. |
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.                - 27 -
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. X Session Management Library            X11, Release 6.4
  1919.  
  1920.  
  1921. typedef void (*SmsSaveYourselfDoneProc)();
  1922.  
  1923. void SaveYourselfDoneProc(sms_conn, manager_data, success)
  1924.     SmsConn sms_conn;
  1925.     SmPointer manager_data;
  1926.     Bool success;
  1927.  
  1928.  
  1929. sms_conn  The session management connection object.
  1930.  
  1931. manager_data
  1932.       Manager data specified when the callback was    reg-
  1933.       istered.
  1934.  
  1935. success   If True, the Save Yourself operation was completed
  1936.       successfully.
  1937. |__
  1938.  
  1939. Before the ``Save Yourself Done'' was sent, the client    must
  1940. have  set each required property at least once since it reg-
  1941. istered with the session manager.
  1942.  
  1943. 6.1.7.    The Connection Closed Callback
  1944.  
  1945. If  the  client  properly  terminates  (that  is,  it  calls
  1946. SmcCloseConnection),  the SmsCloseConnectionProc callback is
  1947. invoked.
  1948. __
  1949. |
  1950. typedef void (*SmsCloseConnectionProc)();
  1951.  
  1952. void CloseConnectionProc(sms_conn, manager_data, count, reason_msgs)
  1953.     SmsConn sms_conn;
  1954.     SmPointer manager_data;
  1955.     int count;
  1956.     char **reason_msgs;
  1957.  
  1958.  
  1959. sms_conn  The session management connection object.
  1960.  
  1961. manager_data
  1962.       Manager data specified when the callback was    reg-
  1963.       istered.
  1964.  
  1965. count      The number of reason messages.
  1966.  
  1967. reason_msgs
  1968.       The reasons for closing the connection.
  1969. |__
  1970.  
  1971. The  reason_msgs  argument  will most likely be NULL and the
  1972. count argument zero (0) if resignation is  expected  by  the
  1973. user.  Otherwise, it contains a list of null-terminated Com-
  1974. pound Text strings representing the reason for    termination.
  1975.  
  1976.  
  1977.  
  1978.                - 28 -
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. X Session Management Library            X11, Release 6.4
  1985.  
  1986.  
  1987. The  session manager should display these reason messages to
  1988. the user.
  1989.  
  1990. Call SmFreeReasons to free the reason messages.  For further
  1991. information, see section 8, ``Freeing Data.''
  1992.  
  1993. 6.1.8.    The Set Properties Callback
  1994.  
  1995. When the client sets session management properties, the Sms-
  1996. SetPropertiesProc callback will be invoked.
  1997. __
  1998. |
  1999. typedef void (*SmsSetPropertiesProc)();
  2000.  
  2001. void SetPropertiesProc(sms_conn, manager_data, num_props, props)
  2002.     SmsConn sms_conn;
  2003.     SmPointer manager_data;
  2004.     int num_props;
  2005.     SmProp **props;
  2006.  
  2007.  
  2008. smc_conn  The session management connection object.
  2009.  
  2010. manager_data
  2011.       Manager data specified when the callback was    reg-
  2012.       istered.
  2013.  
  2014. num_props The number of properties.
  2015.  
  2016. props      The list of properties to set.
  2017. |__
  2018.  
  2019. The  properties are specified as an array of property point-
  2020. ers.  For a description of session management properties and
  2021. the  SmProp  structure,  see section 7, ``Session Management
  2022. Properties.''
  2023.  
  2024. Previously set property values may  be    over-written.    Some
  2025. properties  have  predefined semantics.  The session manager
  2026. is required to store nonpredefined properties.
  2027.  
  2028. To free each  property,  use  SmFreeProperty.    For  further
  2029. information,  see  section  8, ``Freeing Data.''  You should
  2030. free the actual array of pointers with a call to free.
  2031.  
  2032. 6.1.9.    The Delete Properties Callback
  2033.  
  2034. When the client deletes session management  properties,  the
  2035. SmsDeletePropertiesProc callback will be invoked.
  2036. __
  2037. |
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.                - 29 -
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. X Session Management Library            X11, Release 6.4
  2051.  
  2052.  
  2053. typedef void (*SmsDeletePropertiesProc)();
  2054.  
  2055. void DeletePropertiesProc(sms_conn, manager_data, num_props, prop_names)
  2056.     SmsConn sms_conn;
  2057.     SmPointer manager_data;
  2058.     int num_props;
  2059.     char **prop_names;
  2060.  
  2061.  
  2062. smc_conn  The session management connection object.
  2063.  
  2064. manager_data
  2065.       Manager  data specified when the callback was reg-
  2066.       istered.
  2067.  
  2068. num_props The number of properties.
  2069.  
  2070. prop_names
  2071.       The list of properties to delete.
  2072. |__
  2073.  
  2074. The properties are specified as an array of strings.  For  a
  2075. description  of session management properties and the SmProp
  2076. structure, see section 7, ``Session Management Properties.''
  2077.  
  2078. 6.1.10.  The Get Properties Callback
  2079.  
  2080. The SmsGetPropertiesProc callback is invoked when the client
  2081. wants to retrieve properties it set.
  2082. __
  2083. |
  2084. typedef void (*SmsGetPropertiesProc)();
  2085.  
  2086. void GetPropertiesProc(sms_conn, manager_data)
  2087.     SmsConn sms_conn;
  2088.     SmPointer manager_data;
  2089.  
  2090.  
  2091. smc_conn  The session management connection object.
  2092.  
  2093. manager_data
  2094.       Manager data specified when the callback was    reg-
  2095.       istered.
  2096. |__
  2097.  
  2098. The    session      manager    should   respond    by   calling
  2099. SmsReturnProperties.  All of the  properties  set  for    this
  2100. client should be returned.
  2101.  
  2102. 6.2.  Registering the Client
  2103.  
  2104. To register a client (in response to a SmsRegisterClientProc
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.                - 30 -
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. X Session Management Library            X11, Release 6.4
  2117.  
  2118.  
  2119. callback), use SmsRegisterClientReply.
  2120. __
  2121. |
  2122. Status SmsRegisterClientReply(sms_conn, client_id)
  2123.     SmsConn sms_conn;
  2124.     char *client_id;
  2125.  
  2126.  
  2127. sms_conn  The session management connection object.
  2128.  
  2129. client_id A null-terminated  string  representing  a  unique
  2130.       client ID.
  2131. |__
  2132.  
  2133. The return value of SmsRegisterClientReply is zero for fail-
  2134. ure and a positive value for success.  Failure will occur if
  2135. SMlib  can  not allocate memory to hold a copy of the client
  2136. ID for it's own internal needs.
  2137.  
  2138. If a non-NULL previous_id was specified when the client reg-
  2139. istered  itself,  client_id  should  be  identical to previ-
  2140. ous_id.
  2141.  
  2142. Otherwise, client_id should be a unique ID freshly generated
  2143. by  the  session  manager.  In addition, the session manager
  2144. should send a ``Save Yourself'' message with type  =  Local,
  2145. shutdown  =  False,  interact-style = None, and fast = False
  2146. immediately after registering the client.
  2147.  
  2148. Note that once a client ID has been assigned to the  client,
  2149. the  client  keeps  this  ID indefinitely.  If the client is
  2150. terminated and restarted, it will be reassigned the same ID.
  2151. It  is    desirable  to be able to pass client IDs around from
  2152. machine to machine, from user to user, and from session man-
  2153. ager to session manager, while retaining the identity of the
  2154. client.  This, combined with the indefinite  persistence  of
  2155. client    IDs,  means  that  client  IDs    need  to be globally
  2156. unique.
  2157.  
  2158. You should call the SmsGenerateClientID function to generate
  2159. a globally unique client ID.
  2160. __
  2161. |
  2162. char *SmsGenerateClientID(sms_conn)
  2163.     SmsConn sms_conn;
  2164.  
  2165.  
  2166. sms_conn  The session management connection object.
  2167. |__
  2168.  
  2169. NULL  will  be    returned  if  the ID could not be generated.
  2170. Otherwise, the return value of the function  is  the  client
  2171. ID.   It  should be freed with a call to free when no longer
  2172. needed.
  2173.  
  2174.  
  2175.  
  2176.                - 31 -
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182. X Session Management Library            X11, Release 6.4
  2183.  
  2184.  
  2185. 6.3.  Sending a Save Yourself Message
  2186.  
  2187. To   send   a    ``Save     Yourself''   to   a   client,     use
  2188. SmsSaveYourself.
  2189. __
  2190. |
  2191. void SmsSaveYourself(sms_conn, save_type, shutdown, interact_style, fast)
  2192.     SmsConn sms_conn;
  2193.     int save_type;
  2194.     Bool shutdown;
  2195.     int interact_style;
  2196.     Bool fast;
  2197.  
  2198.  
  2199. sms_conn  The session management connection object.
  2200.  
  2201. save_type Specifies  the  type of information that should be
  2202.       saved.
  2203.  
  2204. shutdown  Specifies if a shutdown is taking place.
  2205.  
  2206. interact_style
  2207.       The type of interaction allowed with the user.
  2208.  
  2209. fast      If True, the    client    should    save  its  state  as
  2210.       quickly as possible.
  2211. |__
  2212.  
  2213. The  session  manager sends a ``Save Yourself'' message to a
  2214. client either to checkpoint it or just before termination so
  2215. that  it  can save its state.  The client responds with zero
  2216. or more ``Set Properties'' messages to update the properties
  2217. indicating  how to restart the client.    When all the proper-
  2218. ties have been set,  the  client  sends  a  ``Save  Yourself
  2219. Done'' message.
  2220.  
  2221. If  interact_style  is    SmInteractStyleNone, the client must
  2222. not interact with the user while saving  state.   If  inter-
  2223. act_style  is SmInteractStyleErrors, the client may interact
  2224. with the user only if an error condition arises.  If  inter-
  2225. act_style  is SmInteractStyleAny, then the client may inter-
  2226. act with the user for any purpose.  The client must send  an
  2227. ``Interact  Request''  message    and wait for an ``Interact''
  2228. message from the session manager before it can interact with
  2229. the  user.   When  the    client    is done interacting with the
  2230. user, it should send  an  ``Interact  Done''  message.     The
  2231. ``Interact  Request''  message    can be sent any time after a
  2232. ``Save Yourself'' and before a ``Save Yourself Done.''
  2233.  
  2234. If save_type is SmSaveLocal,  the  client  must  update  the
  2235. properties  to    reflect its current state.  Specifically, it
  2236. should save enough information to restore the state as    seen
  2237. by  the user of this client.  It should not affect the state
  2238. as seen by other users.  If save_type  is  SmSaveGlobal  the
  2239.  
  2240.  
  2241.  
  2242.                - 32 -
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248. X Session Management Library            X11, Release 6.4
  2249.  
  2250.  
  2251. user  wants  the  client to commit all of its data to perma-
  2252. nent,  globally  accessible  storage.     If   save_type   is
  2253. SmSaveBoth,  the  client  should do both of these (it should
  2254. first commit the data to permanent storage  before  updating
  2255. its properties).
  2256.  
  2257. The shutdown argument specifies whether the session is being
  2258. shut  down.   The  interaction    is  different  depending  on
  2259. whether  or not shutdown is set.  If not shutting down, then
  2260. the client can save and resume normal operation.   If  shut-
  2261. ting down, the client must save and then must prevent inter-
  2262. action until it receives either a ``Die''  or  a  ``Shutdown
  2263. Cancelled,''  because  anything the user does after the save
  2264. will be lost.
  2265.  
  2266. The fast argument specifies that the client should save  its
  2267. state  as  quickly as possible.  For example, if the session
  2268. manager knows that power is about to  fail,  it  should  set
  2269. fast to True.
  2270.  
  2271. 6.4.  Sending a Save Yourself Phase 2 Message
  2272.  
  2273. In  order  to  send a ``Save Yourself Phase 2'' message to a
  2274. client, use SmsSaveYourselfPhase2.
  2275. __
  2276. |
  2277. void SmsSaveYourselfPhase2(sms_conn)
  2278.     SmsConn sms_conn;
  2279.  
  2280.  
  2281. sms_conn  The session management connection object.
  2282. |__
  2283.  
  2284. The session manager sends this message to a client that  has
  2285. previously sent a ``Save Yourself Phase 2 Request'' message.
  2286. This message informs the client that all other    clients  are
  2287. in  a  fixed  state  and  this client can save state that is
  2288. associated with other clients.
  2289.  
  2290. 6.5.  Sending an Interact Message
  2291.  
  2292. To  send  an  ``Interact''  message   to   a   client,     use
  2293. SmsInteract.
  2294. __
  2295. |
  2296. void SmsInteract(sms_conn)
  2297.     SmsConn sms_conn;
  2298.  
  2299.  
  2300. sms_conn  The session management connection object.
  2301. |__
  2302.  
  2303. The  ``Interact'' message grants the client the privilege of
  2304. interacting  with  the    user.    When  the  client  is    done
  2305.  
  2306.  
  2307.  
  2308.                - 33 -
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314. X Session Management Library            X11, Release 6.4
  2315.  
  2316.  
  2317. interacting with the user, it must send an ``Interact Done''
  2318. message to the session manager.
  2319.  
  2320. 6.6.  Sending a Save Complete Message
  2321.  
  2322. To send  a  ``Save  Complete''    message  to  a    client,  use
  2323. SmsSaveComplete.
  2324. __
  2325. |
  2326. void SmsSaveComplete(sms_conn)
  2327.     SmsConn sms_conn;
  2328.  
  2329.  
  2330. sms_conn  The session management connection object.
  2331. |__
  2332.  
  2333. The  session manager sends this message when it is done with
  2334. a checkpoint.  The client is then free to change its  state.
  2335.  
  2336. 6.7.  Sending a Die Message
  2337.  
  2338. To send a ``Die'' message to a client, use SmsDie.
  2339. __
  2340. |
  2341. void SmsDie(sms_conn)
  2342.     SmsConn sms_conn;
  2343.  
  2344.  
  2345. sms_conn  The session management connection object.
  2346. |__
  2347.  
  2348. Before    the session manager terminates, it should wait for a
  2349. ``Connection Closed'' message from each client that it    sent
  2350. a ``Die'' message to, timing out appropriately.
  2351.  
  2352. 6.8.  Cancelling a Shutdown
  2353.  
  2354. To cancel a shutdown, use SmsShutdownCancelled.
  2355. __
  2356. |
  2357. void SmsShutdownCancelled(sms_conn)
  2358.     SmsConn sms_conn;
  2359.  
  2360.  
  2361. sms_conn  The session management connection object.
  2362. |__
  2363.  
  2364. The  client  can  now  continue as if the shutdown had never
  2365. happened.  If the client has  not  sent  a  ``Save  Yourself
  2366. Done''    message yet, it can either abort the save and send a
  2367. ``Save Yourself Done'' with  the  success  argument  set  to
  2368. False,    or  it    can continue with the save and send a ``Save
  2369. Yourself Done'' with the success argument set to reflect the
  2370. outcome of the save.
  2371.  
  2372.  
  2373.  
  2374.                - 34 -
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. X Session Management Library            X11, Release 6.4
  2381.  
  2382.  
  2383. 6.9.  Returning Properties
  2384.  
  2385. In  response  to  a  ``Get Properties'' message, the session
  2386. manager should call SmsReturnProperties.
  2387. __
  2388. |
  2389. void SmsReturnProperties(sms_conn, num_props, props)
  2390.     SmsConn sms_conn;
  2391.     int num_props;
  2392.     SmProp **props;
  2393.  
  2394.  
  2395. sms_conn  The session management connection object.
  2396.  
  2397. num_props The number of properties.
  2398.  
  2399. props      The list of properties to return to the client.
  2400. |__
  2401.  
  2402. The properties are returned as an array of  property  point-
  2403. ers.  For a description of session management properties and
  2404. the SmProp structure, see section  7,  ``Session  Management
  2405. Properties.''
  2406.  
  2407. 6.10.  Pinging a Client
  2408.  
  2409. To  check  that  a client is still alive, you should use the
  2410. IcePing function provided by the ICE library.  To do so, the
  2411. ICE  connection  must be obtained using the SmsGetIceConnec-
  2412. tion (see section  6.12,  ``Using  Sms    Informational  Func-
  2413. tions'').
  2414.  
  2415. __
  2416. |
  2417. void IcePing(ice_conn, ping_reply_proc, client_data)
  2418.     IceConn ice_conn;
  2419.     IcePingReplyProc ping_reply_proc;
  2420.     IcePointer client_data;
  2421.  
  2422.  
  2423. ice_conn  A valid ICE connection object.
  2424.  
  2425. ping_reply_proc
  2426.       The    callback  to  invoke  when  the  Ping  reply
  2427.       arrives.
  2428.  
  2429. client_data
  2430.       This pointer will  be  passed  to  the  IcePingRe-
  2431.       plyProc callback.
  2432. |__
  2433.  
  2434. When the Ping reply is ready (if ever), the IcePingReplyProc
  2435. callback will be invoked.  A  session  manager    should    have
  2436. some  sort  of    timeout  period,  after which it assumes the
  2437.  
  2438.  
  2439.  
  2440.                - 35 -
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446. X Session Management Library            X11, Release 6.4
  2447.  
  2448.  
  2449. client has unexpectedly died.
  2450.  
  2451. __
  2452. |
  2453. typedef void (*IcePingReplyProc)();
  2454.  
  2455. void PingReplyProc(ice_conn, client_data)
  2456.     IceConn ice_conn;
  2457.     IcePointer client_data;
  2458.  
  2459.  
  2460. ice_conn  The ICE connection object.
  2461.  
  2462. client_data
  2463.       The client data specified in the call to  IcePing.
  2464. |__
  2465.  
  2466.  
  2467. 6.11.  Cleaning Up After a Client Disconnects
  2468.  
  2469. When  the  session  manager receives a ``Connection Closed''
  2470. message or otherwise detects that  the    client    aborted  the
  2471. connection,  it should call the SmsCleanUp function in order
  2472. to free up the connection object.
  2473. __
  2474. |
  2475. void SmsCleanUp(sms_conn)
  2476.     SmsConn sms_conn;
  2477.  
  2478.  
  2479. sms_conn  The session management connection object.
  2480. |__
  2481.  
  2482.  
  2483. 6.12.  Using Sms Informational Functions
  2484.  
  2485. __
  2486. |
  2487. int SmsProtocolVersion(sms_conn)
  2488.     SmsConn sms_conn;
  2489.  
  2490. |__
  2491.  
  2492. SmsProtocolVersion returns the major version of the  session
  2493. management protocol associated with this session.
  2494.  
  2495.  
  2496. __
  2497. |
  2498. int SmsProtocolRevision(sms_conn)
  2499.     SmsConn sms_conn;
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.                - 36 -
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. X Session Management Library            X11, Release 6.4
  2513.  
  2514.  
  2515. |__
  2516.  
  2517. SmsProtocolRevision returns the minor version of the session
  2518. management protocol associated with this session.
  2519.  
  2520.  
  2521. __
  2522. |
  2523. char *SmsClientID(sms_conn)
  2524.     SmsConn sms_conn;
  2525.  
  2526. |__
  2527.  
  2528. SmsClientID returns a null-terminated string for the  client
  2529. ID associated with this connection.  You should call free on
  2530. this pointer when the client ID is no longer needed.
  2531.  
  2532.  
  2533. To obtain the host name of a client, use  SmsClientHostName.
  2534. This host name will be needed to restart the client.
  2535. __
  2536. |
  2537. char *SmsClientHostName(sms_conn)
  2538.     SmsConn sms_conn;
  2539. |__
  2540.  
  2541. The  string returned is of the form protocol/hostname, where
  2542. protocol is one of {tcp, decnet, local}.   You    should    call
  2543. free on the string returned when it is no longer needed.
  2544.  
  2545.  
  2546. __
  2547. |
  2548. IceConn SmsGetIceConnection(sms_conn)
  2549.     SmsConn sms_conn;
  2550. |__
  2551.  
  2552. SmsGetIceConnection  returns the ICE connection object asso-
  2553. ciated with this session management connection object.     The
  2554. ICE  connection  object  can  be used to get some additional
  2555. information about the connection.  Some of the    more  useful
  2556. functions   which   can   be   used   on   the    IceConn  are
  2557. IceConnectionNumber, and IceLastSequenceNumber.  For further
  2558. information, see the Inter-Client Exchange Library standard.
  2559.  
  2560. 6.13.  Error Handling
  2561.  
  2562. If the session manager receives an unexpected protocol error
  2563. from  a  client,  an  error  handler is invoked by SMlib.  A
  2564. default error handler exists which simply prints  the  error
  2565. message  (it does not exit).  The session manager can change
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.                - 37 -
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578. X Session Management Library            X11, Release 6.4
  2579.  
  2580.  
  2581. this error handler by calling SmsSetErrorHandler.
  2582. __
  2583. |
  2584. SmsErrorHandler SmsSetErrorHandler(handler)
  2585.     SmsErrorHandler handler;
  2586.  
  2587.  
  2588. handler   The  error  handler.     You  should  pass  NULL  to
  2589.       restore the default handler.
  2590. |__
  2591.  
  2592. SmsSetErrorHandler  returns the previous error handler.  The
  2593. SmsErrorHandler has the following type:
  2594. __
  2595. |
  2596. typedef void (*SmsErrorHandler)();
  2597.  
  2598. void ErrorHandler(sms_conn, swap, offending_minor_opcode, offending_sequence_num, error_class, severity, values)
  2599.     SmsConn sms_conn;
  2600.     Bool swap;
  2601.     int offending_minor_opcode;
  2602.     unsigned long offending_sequence_num;
  2603.     int error_class;
  2604.     int severity;
  2605.     IcePointer values;
  2606.  
  2607.  
  2608. sms_conn  The session management connection object.
  2609.  
  2610. swap      A flag which indicates  if  the  specified  values
  2611.       need byte swapping.
  2612.  
  2613. offending_minor_opcode
  2614.       The minor opcode of the offending message.
  2615.  
  2616. offending_sequence_num
  2617.       The sequence number of the offending message.
  2618.  
  2619. error_class
  2620.       The error class of the offending message.
  2621.  
  2622. severity  IceCanContinue,    IceFatalToProtocol,      or
  2623.       IceFatalToConnection.
  2624.  
  2625. values      Any additional error values specific to the  minor
  2626.       opcode and class.
  2627. |__
  2628.  
  2629. Note that this error handler is invoked for protocol related
  2630. errors.  To install an error handler to be invoked  when  an
  2631. IO  error  occurs,  use  IceSetIOErrorHandler.     For further
  2632. information, see the Inter-Client Exchange Library standard.
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.                - 38 -
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. X Session Management Library            X11, Release 6.4
  2645.  
  2646.  
  2647. 7.  Session Management Properties
  2648.  
  2649. Each property is defined by the SmProc structure:
  2650.  
  2651.  
  2652. typedef struct {
  2653.      char *name;     /* name of property */
  2654.      char *type;     /* type of property */
  2655.      int num_vals;     /* number of values */
  2656.      SmPropValue *vals;  /* the list of values */
  2657. } SmProp;
  2658.  
  2659. typedef struct {
  2660.      int length;     /* the length of the value */
  2661.      SmPointer value;     /* the value */
  2662. } SmPropValue;
  2663.  
  2664.  
  2665. The  X    Session Management Protocol defines a list of prede-
  2666. fined properties, several of which are required to be set by
  2667. the  client.   The  following table specifies the predefined
  2668. properties and indicates  which  ones  are  required.    Each
  2669. property has a type associated with it.
  2670.  
  2671. A  type  of  SmCARD8 indicates that there is a single 1-byte
  2672. value.    A type of SmARRAY8 indicates that there is a  single
  2673. array  of  bytes.   A  type of SmLISTofARRAY8 indicates that
  2674. there is a list of array of bytes.
  2675.  
  2676.  
  2677. -------------------------------------------------------------
  2678. Name             Type       POSIX Type        Required
  2679. -------------------------------------------------------------
  2680. SmCloneCommand         OS-specific   SmLISTofARRAY8     Yes
  2681. SmCurrentDirectory   OS-specific   SmARRAY8           No
  2682. SmDiscardCommand     OS-specific   SmLISTofARRAY8     No*
  2683. SmEnvironment         OS-specific   SmLISTofARRAY8      No
  2684. SmProcessID         OS-specific   SmARRAY8           No
  2685. SmProgram         OS-specific   SmARRAY8          Yes
  2686. SmRestartCommand     OS-specific   SmLISTofARRAY8     Yes
  2687. SmResignCommand      OS-specific   SmLISTofARRAY8      No
  2688. SmRestartStyleHint   SmCARD8       SmCARD8           No
  2689. SmShutdownCommand    OS-specific   SmLISTofARRAY8      No
  2690. SmUserID         SmARRAY8       SmARRAY8          Yes
  2691. -------------------------------------------------------------
  2692.  
  2693.  
  2694. * Required if any state is stored in an external  repository
  2695. (for example, state file).
  2696.  
  2697. o    SmCloneCommand
  2698.  
  2699.      This is like the SmRestartCommand, except it restarts a
  2700.      copy of the application.  The only difference  is    that
  2701.  
  2702.  
  2703.  
  2704.                - 39 -
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710. X Session Management Library            X11, Release 6.4
  2711.  
  2712.  
  2713.      the application does not supply its client ID at regis-
  2714.      ter time.    On POSIX systems, this    should    be  of    type
  2715.      SmLISTofARRAY8.
  2716.  
  2717. o    SmCurrentDirectory
  2718.  
  2719.      On POSIX-based systems, this specifies the value of the
  2720.      current directory that needs to  be  set  up  prior  to
  2721.      starting the SmProgram and should of type SmARRAY8.
  2722.  
  2723. o    SmDiscardCommand
  2724.  
  2725.      The discard command contains a command that when deliv-
  2726.      ered to the host that the client is running on  (deter-
  2727.      mined  from  the  connection), will cause it to discard
  2728.      any information about the current state.  If this    com-
  2729.      mand  is not specified, the Session Manager will assume
  2730.      that all of  the  client's  state    is  encoded  in  the
  2731.      SmRestartCommand.    On POSIX systems, the type should be
  2732.      SmLISTofARRAY8.
  2733.  
  2734. o    SmEnvironment
  2735.  
  2736.      On POSIX based systems, this will be of  type  SmLISTo-
  2737.      fARRAY8,  where  the ARRAY8s alternate between environ-
  2738.      ment variable name and environment variable value.
  2739.  
  2740. o    SmProcessID
  2741.  
  2742.      This specifies an OS-specific identifier for  the    pro-
  2743.      cess.  On POSIX systems, this should contain the return
  2744.      value of getpid turned into a Latin-1 (decimal) string.
  2745.  
  2746. o    SmProgram
  2747.  
  2748.      This  is  the  name of the program that is running.  On
  2749.      POSIX systems, this should be first parameter passed to
  2750.      execve and should be of type SmARRAY8.
  2751.  
  2752. o    SmRestartCommand
  2753.  
  2754.      The  restart  command  contains  a  command  that, when
  2755.      delivered to the host that the  client  is  running  on
  2756.      (determined from the connection), will cause the client
  2757.      to restart in its current state.  On  POSIX-based    sys-
  2758.      tems,  this  is of type SmLISTofARRAY8, and each of the
  2759.      elements in the array represents an element in the argv
  2760.      array.   This  restart  command  should ensure that the
  2761.      client restarts with the specified client-ID.
  2762.  
  2763. o    SmResignCommand
  2764.  
  2765.      A client that sets the SmRestartStyleHint to  SmRestar-
  2766.      tAnway  uses  this  property  to specify a command that
  2767.  
  2768.  
  2769.  
  2770.                - 40 -
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. X Session Management Library            X11, Release 6.4
  2777.  
  2778.  
  2779.      undoes the effect of the client and removes  any  saved
  2780.      state.   As  an  example,    consider  a  user  that runs
  2781.      xmodmap, which registers with the Session Manager, sets
  2782.      SmRestartStyleHint  to SmRestartAnyway, and then termi-
  2783.      nates.  To allow the Session  Manager  (at  the  user's
  2784.      request)  to  undo this, xmodmap would register a SmRe-
  2785.      signCommand that undoes the effects of the xmodmap.
  2786.  
  2787. o    SmRestartStyleHint
  2788.  
  2789.      If the RestartStyleHint property is  present,  it    will
  2790.      contain the style of restarting the client prefers.  If
  2791.      this style  is  not  specified,  SmRestartIfRunning  is
  2792.      assumed.  The possible values are as follows:
  2793.  
  2794.      -----------------------------
  2795.      Name            Value
  2796.      -----------------------------
  2797.      SmRestartIfRunning       0
  2798.      SmRestartAnyway          1
  2799.      SmRestartImmediately     2
  2800.      SmRestartNever          3
  2801.      -----------------------------
  2802.  
  2803.  
  2804.      The SmRestartIfRunning style is used in the usual case.
  2805.      The client should be restarted in the next  session  if
  2806.      it was running at the end of the current session.
  2807.  
  2808.      The  SmRestartAnyway  style is used to tell the Session
  2809.      Manager that the application should be restarted in the
  2810.      next  session  even if it exits before the current ses-
  2811.      sion is terminated.  It should be noted  that  this  is
  2812.      only  a  hint  and  the Session Manager will follow the
  2813.      policies specified by its    users  in  determining    what
  2814.      applications to restart.
  2815.  
  2816.      A    client that uses SmRestartAnyway should also set the
  2817.      SmResignCommand  and  SmShutdownCommand  properties  to
  2818.      commands  that  undo  the    state of the client after it
  2819.      exits.
  2820.  
  2821.      The SmRestartImmediately style is like SmRestartAnyway,
  2822.      but,  in  addition, the client is meant to run continu-
  2823.      ously.  If the client exits, the Session Manager should
  2824.      try to restart it in the current session.
  2825.  
  2826.      SmRestartNever style specifies that the client does not
  2827.      wish to be restarted in the next session.
  2828.  
  2829. o    SmShutdownCommand
  2830.  
  2831.      This command is executed at shutdown time to  clean  up
  2832.      after  a  client that is no longer running but retained
  2833.  
  2834.  
  2835.  
  2836.                - 41 -
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842. X Session Management Library            X11, Release 6.4
  2843.  
  2844.  
  2845.      its state by setting  SmRestartStyleHint  to  SmRestar-
  2846.      tAnyway.  The client must not remove any saved state as
  2847.      the client is still part of the session.  As  an  exam-
  2848.      ple,  consider a client that turns on a camera at start
  2849.      up time.  This client then exits.    At session shutdown,
  2850.      the  user    wants  the  camera  turned off.  This client
  2851.      would set the SmRestartStyleHint to SmRestartAnyway and
  2852.      would  register a SmShutdownCommand that would turn off
  2853.      the camera.
  2854.  
  2855. o    SmUserID
  2856.  
  2857.      Specifies the user ID.  On  POSIX-based  systems,    this
  2858.      will  contain  the  user's  name (the pw_name member of
  2859.      struct passwd).
  2860.  
  2861. 8.  Freeing Data
  2862.  
  2863. To free an individual property, use SmFreeProperty.
  2864. __
  2865. |
  2866. void SmFreeProperty(prop)
  2867.     SmProp *prop;
  2868.  
  2869.  
  2870. prop      The property to free.
  2871. |__
  2872.  
  2873.  
  2874. To free the reason strings from  the  SmsCloseConnectionProc
  2875. callback, use SmFreeReasons.
  2876. __
  2877. |
  2878. void SmFreeReasons(count, reasons)
  2879.     int count;
  2880.     char **reasons;
  2881.  
  2882.  
  2883. count      The number of reason strings.
  2884.  
  2885. reasons   The list of reason strings to free.
  2886. |__
  2887.  
  2888.  
  2889. 9.  Authentication of Clients
  2890.  
  2891. As  stated  earlier, the session management protocol is lay-
  2892. ered on top of ICE.  Authentication occurs at two levels  in
  2893. the ICE protocol:
  2894.  
  2895. o    The first is when an ICE connection is opened.
  2896.  
  2897. o    The  second  is  when a Protocol Setup occurs on an ICE
  2898.      connection.
  2899.  
  2900.  
  2901.  
  2902.                - 42 -
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908. X Session Management Library            X11, Release 6.4
  2909.  
  2910.  
  2911. The authentication methods that are available are  implemen-
  2912. tation-dependent  (that  is.,  dependent  on  the ICElib and
  2913. SMlib implementations in use).    For further information, see
  2914. the Inter-Client Exchange Library standard.
  2915.  
  2916. 10.  Working in a Multi-Threaded Environment
  2917.  
  2918. To  declare  that multiple threads in an application will be
  2919. using SMlib (or any other library layered on top of ICElib),
  2920. you  should  call  IceInitThreads.  For further information,
  2921. see the Inter-Client Exchange Library standard.
  2922.  
  2923. 11.  Acknowledgements
  2924.  
  2925. Thanks to the following people for  their  participation  in
  2926. the  X Session Management design: Jordan Brown, Ellis Cohen,
  2927. Donna  Converse,  Stephen  Gildea,  Vania  Joloboff,  Stuart
  2928. Marks, Bob Scheifler, Ralph Swick, and Mike Wexler.
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.  
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.                - 43 -
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.  
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.  
  2991.  
  2992.  
  2993.  
  2994.  
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.  
  3001.  
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034.                - 44 -
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.  
  3041.  
  3042.  
  3043.              Table of Contents
  3044.  
  3045.  
  3046. 1. Overview of Session Management  . . . . . . . . . . .   1
  3047. 2. The Session Management Library  . . . . . . . . . . .   1
  3048. 3. Understanding SMlib's Dependence on ICE . . . . . . .   2
  3049. 4. Header Files and Library Name . . . . . . . . . . . .   3
  3050. 5. Session Management Client (Smc) Functions . . . . . .   3
  3051. 5.1. Connecting to the Session Manager . . . . . . . . .   4
  3052. 5.1.1. The Save Yourself Callback  . . . . . . . . . . .   7
  3053. 5.1.2. The Die Callback  . . . . . . . . . . . . . . . .   8
  3054. 5.1.3. The Save Complete Callback  . . . . . . . . . . .   9
  3055. 5.1.4. The Shutdown Cancelled Callback . . . . . . . . .   9
  3056. 5.2. Closing the Connection  . . . . . . . . . . . . . .  10
  3057. 5.3. Modifying Callbacks . . . . . . . . . . . . . . . .  11
  3058. 5.4. Setting, Deleting, and Retrieving Session Man-
  3059. agement Properties . . . . . . . . . . . . . . . . . . .  12
  3060. 5.5. Interacting With the User . . . . . . . . . . . . .  14
  3061. 5.6. Requesting a Save Yourself  . . . . . . . . . . . .  15
  3062. 5.7. Requesting a Save Yourself Phase 2  . . . . . . . .  16
  3063. 5.8. Completing a Save Yourself  . . . . . . . . . . . .  17
  3064. 5.9. Using Smc Informational Functions . . . . . . . . .  17
  3065. 5.10. Error Handling . . . . . . . . . . . . . . . . . .  18
  3066. 6. Session Management Server (Sms) Functions . . . . . .  20
  3067. 6.1. Initializing the Library  . . . . . . . . . . . . .  20
  3068. 6.1.1. The Register Client Callback  . . . . . . . . . .  24
  3069. 6.1.2. The Interact Request Callback . . . . . . . . . .  25
  3070. 6.1.3. The Interact Done Callback  . . . . . . . . . . .  25
  3071. 6.1.4. The Save Yourself Request Callback  . . . . . . .  26
  3072. 6.1.5. The Save Yourself Phase 2 Request Callback  . . .  27
  3073. 6.1.6. The Save Yourself Done Callback . . . . . . . . .  27
  3074. 6.1.7. The Connection Closed Callback  . . . . . . . . .  28
  3075. 6.1.8. The Set Properties Callback . . . . . . . . . . .  29
  3076. 6.1.9. The Delete Properties Callback  . . . . . . . . .  29
  3077. 6.1.10. The Get Properties Callback  . . . . . . . . . .  30
  3078. 6.2. Registering the Client  . . . . . . . . . . . . . .  30
  3079. 6.3. Sending a Save Yourself Message . . . . . . . . . .  32
  3080. 6.4. Sending a Save Yourself Phase 2 Message . . . . . .  33
  3081. 6.5. Sending an Interact Message . . . . . . . . . . . .  33
  3082. 6.6. Sending a Save Complete  Message  . . . . . . . . .  34
  3083. 6.7. Sending a Die Message . . . . . . . . . . . . . . .  34
  3084. 6.8. Cancelling a Shutdown . . . . . . . . . . . . . . .  34
  3085. 6.9. Returning Properties  . . . . . . . . . . . . . . .  35
  3086. 6.10. Pinging a Client . . . . . . . . . . . . . . . . .  35
  3087. 6.11. Cleaning Up After a Client Disconnects . . . . . .  36
  3088. 6.12. Using Sms Informational Functions  . . . . . . . .  36
  3089. 6.13. Error Handling . . . . . . . . . . . . . . . . . .  37
  3090. 7. Session Management Properties . . . . . . . . . . . .  39
  3091. 8. Freeing Data  . . . . . . . . . . . . . . . . . . . .  42
  3092. 9. Authentication of Clients . . . . . . . . . . . . . .  42
  3093. 10. Working in a Multi-Threaded Environment  . . . . . .  43
  3094. 11. Acknowledgements . . . . . . . . . . . . . . . . . .  43
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.                  iii
  3101.  
  3102.  
  3103.