Link with C++ linker
[oweals/cde.git] / cde / programs / dtsession / Sm.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: Sm.h /main/15 1996/09/14 14:48:18 drk $ */
24 /*************************************<+>*************************************
25  *****************************************************************************
26  **
27  **  File:        Sm.h
28  **
29  **  Project:     HP DT Session Manager (dtsession)
30  **
31  **  Description:
32  **  -----------
33  **  Contains all general, global variables used by the session manager
34  **
35  **
36  **
37  *****************************************************************************
38  *************************************<+>*************************************/
39 /*                                                                 
40  * (c) Copyright 1996 Digital Equipment Corporation.
41  * (c) Copyright 1990, 1993, 1994, 1996 Hewlett-Packard Company          
42  * (c) Copyright 1993, 1994, 1996 International Business Machines Corp. 
43  * (c) Copyright 1993, 1994, 1996 Sun Microsystems, Inc.                
44  * (c) Copyright 1993, 1994, 1996 Novell, Inc.                      
45  * (c) Copyright 1996 FUJITSU LIMITED.
46  * (c) Copyright 1996 Hitachi.
47  */
48
49 #ifndef _sm_h
50 #define _sm_h
51
52 /*
53  * #include statements
54  */
55
56 #include <signal.h>
57 #include <sys/param.h>
58 #include <X11/Xlib.h>
59 #include <Dt/DtP.h>
60 #include <Dt/UserMsg.h>
61 #include <Tt/tt_c.h>
62 #include "SmError.h"
63
64 /* 
65  *  #define statements 
66  */
67
68 #define HELPVIEW_COMMAND_LINE  CDE_INSTALLATION_TOP "/bin/dthelpview -helpVolume Dtintro"
69
70
71 /*
72  * Wrappers for system calls
73  */
74 #define         SM_MALLOC(SIZE)                 XtMalloc(SIZE)
75 #define         SM_REALLOC(PTR, SIZE)   XtRealloc(PTR, SIZE)
76 #define         SM_FREE(PTR)                    XtFree(PTR)
77 #define         SM_EXIT(STATUS)                 SmExit(STATUS)
78
79 #ifdef __hpux
80 #define         SM_SETEUID(EUID)        setresuid(-1, EUID, -1)
81 #define         SM_SETESUID(UID)        setresuid(-1, UID, UID)
82 #else
83 #ifndef SVR4
84 #define         SM_SETEUID(EUID)        seteuid(EUID)
85 #define         SM_SETESUID(UID)        setreuid(UID, UID)
86 #else
87 #define         SM_SETEUID(EUID)        seteuid(EUID)
88 #define         SM_SETESUID(UID)        (setuid(UID), seteuid(UID))
89 #endif
90 #endif
91
92 /*
93  * Types of states the session manager can be in
94  */
95 #define         READY                   0
96 #define         IN_PROCESS              1
97
98 /*
99  *  session types .. home or current or default
100  */
101 #define         DEFAULT_SESSION         0
102 #define         HOME_SESSION            1
103 #define         CURRENT_SESSION         2
104
105 /*
106  * The lower bounds for each resolution of display - caculated
107  * as Y Resolution - which is pixels/meter
108  */
109 #define                 HIGH_RES_Y_RES                  3583
110 #define                 MED_RES_Y_RES                   3150
111 #define                 LOW_RES_Y_RES                   1
112
113 /*
114  * Maximum number of screens saved during a session
115  */
116 #define         MAX_SCREENS_SAVED       10
117
118 /* contention management definitions */
119 #define SM_CM_SYSTEM       (1L << 0)
120 #define SM_CM_HANDSHAKE    (1L << 1)
121
122 #define SM_CM_ALL          (SM_CM_SYSTEM  | SM_CM_HANDSHAKE)
123 #define SM_CM_NONE         0
124
125 #define SM_CM_DEFAULT      SM_CM_NONE
126
127 #ifndef NO_MESSAGE_CATALOG
128 # ifdef __ultrix
129 #  define _CLIENT_CAT_NAME "dtsession.cat"
130 # else  /* __ultrix */
131 #  define _CLIENT_CAT_NAME "dtsession"
132 # endif /* __ultrix */
133 extern char *_DtGetMessage(char *filename, int set, int n, char *s);
134 # define GETMESSAGE(set, number, string)\
135     (_DtGetMessage(_CLIENT_CAT_NAME, set, number, string))
136 #else
137 # define GETMESSAGE(set, number, string)\
138     string
139 #endif
140
141 typedef int (*IOErrorHandlerProc)(
142         Display *
143 );
144
145 /* 
146  * typedef statements 
147  */
148
149 /*
150  * Pointer to hold information returned by session settings
151  */
152 typedef struct
153 {
154     int                 accelNum;           /* Pointer Control Information */
155     int                 accelDenom;
156     int                 threshold;
157
158     int                 timeout;            /*Screen Saver Information */
159     int                 interval;
160     int                 preferBlank;
161     int                 allowExp;
162
163     char                *fontDirs;          /*Font path Information */
164     
165     XKeyboardState      kbdState;           /* Keyboard Control Information */
166     char                *autoRepeats;
167     
168     char                *buttonMap;         /*Button Mapping Information */
169     
170     int                 numKeyCode;         /*Key Mapping information */
171     int                 keySymPerCode;
172     char                *keySyms;
173
174     int                 maxKeyPerMod;       /*Modifier Mapping Information */
175     char                *modSyms;
176
177     Boolean             didQuery;       /*Was this information queried for*/
178
179     int                 confirmMode;
180     int                 startState;
181 } SessionSettings, *SessionSettingsPtr;
182
183 /*
184  * Structure to save all of the session manager resources
185  */
186 typedef struct
187 {
188     char        *wmStartup;
189     Boolean     querySettings;
190     char        *keyholders;
191     int         alarmTime;
192     int         memThreshold;
193     char        *sessionVersion;
194     int         displayResolution;
195     char        *sessionLang;
196     long        contManagement;
197     int         waitClientTimeout;
198     int         waitWmTimeout;
199     Boolean     useBMS;
200     Boolean     saveFontPath;
201     int         saveYourselfTimeout;
202     Boolean     mergeXdefaults;
203     int         numSessionsBackedup;
204     char        *ignoreEnvironment;
205 } SessionResources, *SessionResourcesPtr;
206
207 /*
208  * Screen saver resources.
209  */
210 typedef struct
211 {
212     int         cycleTimeout;
213     int         saverTimeout;
214     int         lockTimeout;
215     Boolean     random;
216     char        *saverList;
217 } SaverResources, *SaverResourcesPtr;
218
219 /*
220  * Structure to hold global state settings
221  */
222 typedef struct
223 {
224     Boolean                     audioChange;
225     Boolean                     pointerChange;
226     Boolean                     pointerMapChange;
227     char                        pointerMap[5];
228     int                         numButton;
229     Boolean                     keyboardChange;
230     Boolean                     screenSavChange;
231     char                        dClickBuf[50];
232 } SettingsSet;
233
234 typedef struct
235 {
236         Boolean         audioChange;
237         Boolean         pointerChange;
238         Boolean         keyboardChange;
239         Boolean         screenSavChange;
240         Boolean         dClickChange;
241         Boolean         fontChange;
242         Boolean         preeditChange;
243 } SettingsCust;
244
245
246 /*
247  * Structure to hold general information needed to be shared by
248  * different modules in the session manager
249  */
250 typedef struct
251 {
252     Display             *display;
253     Widget              topLevelWid;
254     Window              topLevelWindow;
255     XtAppContext        appCon;
256     char                *programName;           /* main()'s argv[0] */
257     int                 numSavedScreens;
258     int                 screen;
259     int                 lockedState;
260     int                 smState;
261     short               sessionType;
262     unsigned long       blackPixel;
263     unsigned long       whitePixel;
264     unsigned long       foregroundPix;
265     unsigned long       backgroundPix;
266     Cursor              lockCursor, padlockCursor, blankCursor;
267     Cursor              waitCursor;
268     char                resourcePath[MAXPATHLEN + 1];
269     char                settingPath[MAXPATHLEN + 1];
270     char                clientPath[MAXPATHLEN + 1];
271     char                fontPath[MAXPATHLEN + 1];
272     char                exitPath[MAXPATHLEN + 1];
273     char                etcPath[MAXPATHLEN + 1]; /*
274                                                   * Used for sessionEtc on
275                                                   * the way up and for
276                                                   * moving current to
277                                                   * current.old on the way
278                                                   * down
279                                                   */
280     char                *savePath;
281     char                *restoreSession;
282     Boolean             dtwmRunning;
283     Boolean             bmsDead;
284     Tt_pattern          requests2Handle;
285     Tt_pattern          events2Watch;
286     Boolean             compatMode;
287     Boolean             lockOnTimeoutStatus;
288     gid_t               runningGID, conMgmtGID;
289     uid_t               runningUID, unLockUID;
290     Boolean             secureSystem;
291     Boolean             screenSaver;  /* obsolete */
292     Boolean             screenSaverRunning; /* obsolete */
293     Boolean             userSetWaitWmTimeout;
294     int                 savedWaitWmTimeout;
295     /*
296      * These strings are for our copy once we
297      * fetch resources with XtGetApplicationResources.
298      * These string returned can be overwritten anytime
299      * another Xrm call is made as in MergeCoeResources (libXv3.0)
300      * or in our own calls to XrmGetFileDatabase.
301      */
302
303     /*
304      * This set is the for smRes
305      */
306     char        *wmStartup;
307     char        *keyholders;
308     char        *sessionVersion;
309     char        *sessionLang;
310
311     /*
312      * This set is the for smSettings
313      */
314     char        *fontDirs;          /*Font path Information */
315     char        *autoRepeats;
316     char        *buttonMap;         /*Button Mapping Information */
317     char        *keySyms;
318     char        *modSyms;
319    
320     char        *saverList; /* Current screen saver list */
321     void        *saverListParse; /* Current parsed screen saver list */
322
323     Boolean     coverScreen; /* full screen cover */
324     char        *SmNextension; /* screen saver extension name */
325     char        *SmCextension; /* screen saver extension class */
326     char        *extensionSpec; /* sprintf specification */
327 #if defined (USE_X11SSEXT)
328     int         ssEventType; /* screen saver event type */
329 #endif /* USE_X11SSEXT */
330     struct sigaction childvec;
331     struct sigaction defvec;
332
333     Boolean     homeSave;        /* True if the save is via the Style
334                                     Manager's Save Home Session button. */
335     Boolean     displaySpecific; /* Is Ture if the session is for a
336                                     specific display, otherwise False */
337     Boolean     loggingOut;     /* Is True if the current save is for
338                                    a logout; False otherwise. */
339 } GeneralData;
340
341
342 /*
343  * External variables
344  */
345 extern  char    *_dtsessionMG();
346
347 /*
348  * Files that the session manager saves sessions to and restores sessions
349  * from.  allocated in SmStrDef.c
350  */
351 extern char SM_CLIENT_FILE[];
352 extern char SM_CLIENT_FILE2[];
353 extern char SM_RESOURCE_FILE[];
354 extern char SM_FONT_FILE[];
355 extern char SM_LOW_RES_EXT[];
356 extern char SM_MED_RES_EXT[];
357 extern char SM_HIGH_RES_EXT[];
358 extern char SM_SETTING_FILE[];
359 extern char SM_CONVERSION_FILE[];
360 extern char SM_SYSTEM_CLIENT_FILE[];
361 extern char SM_SYSTEM_RESOURCE_FILE[];
362 extern char SM_SYSTEM_FONT_FILE[];
363
364 extern char SM_SYSTEM_PATH[];
365 extern char SM_SECURE_PATH[];
366
367 extern char SM_CURRENT_DIRECTORY[];
368 extern char SM_CURRENT_FONT_DIRECTORY[];
369 extern char SM_HOME_DIRECTORY[];
370 extern char SM_HOME_FONT_DIRECTORY[];
371 extern char SM_OLD_EXTENSION[];
372 extern char SM_SYSTEM_DIRECTORY[];
373 extern char smEtcFile[];
374 extern char smExitFile[];
375
376 /*
377  * Session manager name and class used to get resources allocated in SmStrDef.c
378  */
379 extern char SM_RESOURCE_CLASS[];
380 extern char SM_RESOURCE_NAME[];
381 extern char SM_HELP_VOLUME[];
382
383
384 /*
385  * Name of the lock the session manager has to make sure it's the only
386  * session manager running
387  */
388 extern char     SM_RUNNING_LOCK[];
389
390 /*
391  * Location and name of the screen saver program
392  */
393 extern char     SM_SCREEN_SAVER_LOC[];
394 extern char     SM_SCREEN_SAVER_NAME[];
395
396 /*
397  * Global resource settings. These settings determine program behavior
398  * wrt settings restoration, lock behavior, window manager startup etc
399  */
400 extern SessionResources         smRes;
401 extern SaverResources           smSaverRes;
402 extern SettingsSet              smToSet;
403 extern SettingsCust             smCust;
404 extern SessionSettings          smSettings;
405 extern GeneralData              smGD;
406
407
408 /*  
409  *  External Interface  
410  */
411
412 #endif /* __sm_h*/