2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $TOG: vgmain.c /main/19 1998/09/14 18:31:11 mgreess $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
31 /****************************************************************************
35 ** Project: HP Visual User Environment (DT)
37 ** Description: Main line code for Dtgreet application
39 ** These routines initialize the toolkit, create the widgets,
40 ** set up callbacks, and wait for events.
43 ** (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
47 ****************************************************************************
48 ************************************<+>*************************************/
52 /***************************************************************************
56 ***************************************************************************/
62 #include <sys/signal.h>
64 #include <sys/param.h>
69 #include <X11/Xfuncs.h>
70 #include <X11/Shell.h>
71 #include <X11/cursorfont.h>
73 #include <Xm/DrawingA.h>
77 #include <Xm/LabelG.h>
81 #include <Xm/PushBG.h>
82 #include <Xm/MessageB.h>
83 #include <Xm/RowColumn.h>
84 #include <Xm/SeparatoG.h>
85 #include <Xm/ToggleBG.h>
86 #include <Xm/CascadeBG.h>
87 #include <Dt/EnvControlP.h>
90 #include <Dt/MenuButton.h>
94 #include <DtXinerama.h>
97 #if !defined(NL_CAT_LOCALE)
98 #define NL_CAT_LOCALE 0
101 #define LOCALHOST "%LocalHost%"
102 #define DISPLAYNAME "%DisplayName%"
104 /***************************************************************************
106 * External declarations
108 ***************************************************************************/
109 extern char password[]; /* pswd string value */
110 extern int password_length; /* pswd string length */
113 /***************************************************************************
115 * Procedure declarations
117 ***************************************************************************/
119 static SIGVAL syncTimeout( int arg ) ;
120 static Widget InitToolKit( int argc, char **argv) ;
121 static void MakeRootCursor( void ) ;
122 static void MakeBackground( void ) ;
123 static void MakeButtons( void ) ;
124 static void MakeDtlabel( void );
125 static void MakeGreeting( void ) ;
126 static void MakeLogin( void ) ;
127 static void MyInsert( Widget w, XEvent *event, char **params,
128 Cardinal *num_params) ;
129 static void MyBackspace( Widget w, XEvent *event, char **params,
130 Cardinal *num_params) ;
131 static int ErrorHandler( Display *dpy, XErrorEvent *event) ;
132 static void xtErrorHandler( String msg ) ;
133 static void xtWarningHandler( String msg ) ;
134 static void MakeOptionsProc( XtPointer data, XtIntervalId *id) ;
135 static SIGVAL Terminate( int arg ) ;
136 static char * GetLangName( char * label );
137 static void MakeAltDtButtons( void );
138 static void DebugWidgetResources(Widget w);
139 static char * GetDisplayName();
145 /***************************************************************************
149 ***************************************************************************/
152 AppInfo appInfo; /* application resources */
153 Arg argt[100]; /* used for resources */
154 DisplayInfo dpyinfo; /* information about the display */
155 XmString xmstr; /* used for compound strings */
156 char *errorLogFile; /* current value of environment var. */
157 int showVerifyError;/* display a Verify() error dialog */
159 char altdtname[MAXPATHLEN];
160 char altdtclass[MAXPATHLEN];
161 char altdtkey[MAXPATHLEN];
162 char altdtkeyclass[MAXPATHLEN];
163 char altdtstart[MAXPATHLEN];
164 char altdtstartclass[MAXPATHLEN];
165 char altdtlogo[MAXPATHLEN];
166 char altlogoclass[MAXPATHLEN];
168 char *logotype; /* for XrmGetResource() */
169 XrmValue logovalue; /* for XrmGetResource() */
175 /******************************************************************************
179 ** toplevel "main" (toplevel)
180 ** login_shell "login_shell" (overrideShell)
181 ** table "table" (DrawingAreaWidget)
182 ** copyright_msg "copyright_msg" (MessageBox)
183 ** error_message "error_message" (MessageBox)
184 ** help_message "help_message" (MessageBox)
185 ** passwd_message "passwd_message" (MessageBox)
186 ** hostname_message "hostname_msg" (MessageBox)
187 ** matte "matte" (FormWidget)
188 ** logo "logo" (FrameWidget)
189 ** logo_pixmap "logo_pixmap" (LabelGadget)
190 ** matteFrame "matteFrame" (FrameWidget)
191 ** matte1 "matte1" (FormWidget)
192 ** help_button "help_button" (PushButtonGadget)
193 ** greeting "greeting" (LabelGadget)
194 ** dt_label "dt_label" (LabelGadget)
195 ** login_form "login_form" (FormWidget)
196 ** login_label "login_label" (LabelGadget)
197 ** login_text "login_text" (TextField)
198 ** passwd_text "passwd_text" (TextField)
199 ** ok_button "ok_button" (PushButtonGadget)
200 ** clear_button "clear_button" (PushButtonGadget)
201 ** options_button "options_button" (DtMenuButtonWidget)
202 ** options_menu "options_menu" (PopupMenu)
203 ** options_item[0] "options_languages" (CascadeButtonGadget)
204 ** options_item[1] "options_sep2" (SeparatorGadget)
205 ** options_item[2] "session_menus" (CascadeButtonGadget)
206 ** options_item[3] "options_sep1" (SeparatorGadget)
207 ** options_item[4] "options_noWindows" (PushButtonGadget)
208 ** options_item[5] "options_restartServer"(PushButtonGadget)
209 ** options_item[6] "options_sep1" (SeparatorGadget)
210 ** options_item[7] "options_Copyright" (PushButtonGadget)
211 ** session_menu "session_menu" (PulldownMenu)
212 ** options_dt "options_dt" (ToggleButtonGadget)
213 ** options_failsafe "options_failsafe" (ToggleButtonGadget)
214 ** lang_menu "lang_menu" (PulldownMenu)
215 ** (lang items) (lang items) (ToggleButtonGadget)
221 Widget toplevel; /* top level shell widget */
222 Widget login_shell; /* shell for the main login widgets. */
223 Widget table; /* black background for everything */
224 Widget matte; /* main level form widget */
225 Widget matteFrame; /* main level form widget */
226 Widget matte1; /* second level form widget */
228 Widget greeting; /* Welcome message */
229 Widget dt_label; /* Desktop i.e. set in options menu */
231 Widget logo1; /* frame around the Corporate logo */
232 Widget logo_pixmap; /* Corporate logo */
233 Widget logo_shadow; /* drop shadow under the Corporate logo */
235 Widget login_matte; /* bulletin board for login/password */
236 Widget login_form; /* form containing the login widgets */
237 Widget login_label; /* label to left of login text widget */
238 Widget login_text; /* login text widget */
240 Widget ok_button; /* accept name/password text button */
241 Widget clear_button; /* clear name/password text button */
242 Widget options_button; /* login options button */
243 Widget help_button; /* help button */
245 Widget copyright_msg = NULL; /* copyright notice widget */
246 Widget help_message = NULL; /* the help message box */
247 Widget error_message = NULL; /* the error message box */
248 Widget hostname_message = NULL; /* the invalid hostname message box */
249 Widget passwd_message = NULL; /* the expired password message box */
251 Widget options_menu = NULL; /* pop-up menu on options button */
252 Widget options_item[10]; /* items on options pop_up menu */
253 Widget options_nowindows; /* nowindows pane on options pop_up menu */
254 Widget options_failsafe; /* failsafe pane on options pop_up menu */
255 Widget options_dtlite; /* dtlite pane on options pop_up menu */
256 Widget *alt_dts; /* alt_dts widgets on options pop_up menu */
257 Widget options_dt; /* dt regular pane on options pop_up menu */
258 Widget options_last_dt; /* user's last dt */
260 Widget lang_menu = NULL; /* cascading menu on "Language" option */
261 Widget session_menu = NULL; /* cascading menu on "Session" option */
264 /***************************************************************************
266 * Text widget actions and translations
268 ***************************************************************************/
270 static XtActionsRec textActions[] = {
271 {"my-insert", (XtActionProc)MyInsert},
272 {"my-bksp", (XtActionProc)MyBackspace},
275 static char textEventBindings[] = {
276 "Shift <Key>Tab: prev-tab-group() \n\
277 Ctrl <Key>Tab: next-tab-group() \n\
278 <Key>osfEndLine: end-of-line() \n\
279 <Key>osfBeginLine: beginning-of-line() \n\
280 ~Shift <Key>osfRight: forward-character()\n\
281 ~Shift <Key>osfLeft: backward-character()\n\
282 Ctrl <Key>osfDelete: delete-to-end-of-line()\n\
283 <Key>osfDelete: delete-next-character()\n\
284 <Key>osfBackSpace: my-bksp()\n\
285 <Key>osfActivate: activate()\n\
286 Ctrl <Key>Return: activate()\n\
287 <Key>Return: activate()\n\
288 <Key>: my-insert()\n\
289 ~Ctrl ~Shift ~Meta ~Alt<Btn1Down>: grab-focus() \n\
290 <EnterWindow>: enter()\n\
291 <LeaveWindow>: leave()\n\
292 <FocusIn>: focusIn()\n\
293 <FocusOut>: focusOut()\n\
299 XtResource AppResources[] = {
300 { "workspaceCursor", "WorkspaceCursor",
301 XtRBoolean, sizeof(Boolean), XtOffset(AppInfoPtr, workspaceCursor),
302 XtRImmediate, (caddr_t)False },
304 { "labelFont", "LabelFont",
305 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, labelFont),
306 XmRString, "Fixed" },
308 { "textFont", "TextFont",
309 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, textFont),
310 XmRString, "Fixed" },
312 { "optionsDelay", "OptionsDelay",
313 XtRInt, sizeof(int), XtOffset(AppInfoPtr, optionsDelay),
314 XtRImmediate, (XtPointer) 0 },
316 { "altDts", "AltDts",
317 XtRInt, sizeof(int), XtOffset(AppInfoPtr, altDts),
318 XtRImmediate, (XtPointer) 0
321 {"languageList", "LanguageList",
322 XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
325 #if defined(USE_XINERAMA)
326 { "xineramaPreferredScreen", "XineramaPreferredScreen",
327 XtRInt, sizeof(int), XtOffset(AppInfoPtr, xineramaPreferredScreen),
328 XtRImmediate, (XtPointer) 0
332 #if defined (ENABLE_DYNAMIC_LANGLIST)
333 {"languageListCmd", "LanguageListCmd",
334 XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
336 #endif /* ENABLE_DYNAMIC_LANGLIST */
343 /***************************************************************************
347 ***************************************************************************/
351 main( int argc, char **argv )
355 int i; /* index for argt */
356 char **p; /* temp pointer to traverse argv */
357 Boolean nograb=FALSE; /* debugging option to not grab server/key */
358 int debug=0; /* print debugging output */
361 vg_TRACE_EXECUTION("--------------------- main ------------------------");
362 #endif /* VG_TRACE */
364 setlocale(LC_ALL, "");
365 XtSetLanguageProc( NULL, NULL, NULL );
366 langenv = getenv("LANG");
369 * set TERM signal handler...
372 (void) signal(SIGTERM, Terminate);
378 extern SIGVAL BLS_ToggleDebug( int arg );
381 * Allow debug output to be turned on for dtgreet.
384 (void) signal(SIGHUP, BLS_ToggleDebug);
389 * set up authorization parameters, see the identity(3) man page...
393 set_auth_parameters(1, argv);
400 * check some environment variables...
403 errorLogFile = getenv(ERRORLOG);
406 if (getenv("OPENWINHOME") == NULL) putenv(OWPATH_ENV);
409 _DtEnvControl( DT_ENV_SET );
412 * set custom error handler for X protocol errors...
415 XSetErrorHandler(ErrorHandler);
419 * scan argv looking for display name...
424 for ( i = argc, p = argv; i > 0; i--, p++ ) {
425 if ( strcmp(*p, "-display") == 0) {
428 dpyinfo.name = malloc(strlen(*p) + 1);
429 strcpy(dpyinfo.name, *p);
433 if ( strcmp(*p, "-debug") == 0) {
440 if ( strcmp(*p, "-nograb") == 0) {
445 if ( strcmp(*p, "-showerror") == 0) {
448 showVerifyError = atoi(*p);
454 vg_TRACE_EXECUTION("main: after options.");
455 #endif /* VG_TRACE */
460 LogError((unsigned char *) "main: sleeping %d seconds.\n", debug);
465 #endif /* VG_DEBUG */
468 * initialize the Intrinsics...
471 toplevel = InitToolKit(argc, argv);
473 vg_TRACE_EXECUTION("main: exited InitToolKit ...");
474 #endif /* VG_TRACE */
477 XtSetErrorHandler(xtErrorHandler);
478 XtSetWarningHandler(xtWarningHandler);
483 * prevent the toolkit from starting the NLIO server...
486 _XHPNlioctl(0,0,-1,0);
489 vg_TRACE_EXECUTION("main: exited _XHPNlioctl ...");
490 #endif /* VG_TRACE */
494 * get information about the display...
497 dpyinfo.dpy = XtDisplay(toplevel);
498 /* dpyinfo.name = "";*/
499 dpyinfo.screen = DefaultScreen(dpyinfo.dpy);
500 dpyinfo.root = RootWindow (dpyinfo.dpy, dpyinfo.screen);
501 dpyinfo.depth = DefaultDepth (dpyinfo.dpy, dpyinfo.screen);
502 dpyinfo.width = DisplayWidth (dpyinfo.dpy, dpyinfo.screen);
503 dpyinfo.height = DisplayHeight(dpyinfo.dpy, dpyinfo.screen);
504 dpyinfo.black_pixel = BlackPixel (dpyinfo.dpy, dpyinfo.screen);
505 dpyinfo.visual = DefaultVisual(dpyinfo.dpy, dpyinfo.screen);
507 /* JET - for Xinerama, see if the extension */
508 /* is available and init accordingly. */
512 dpyinfo.DtXineramaInfo = _DtXineramaInit(dpyinfo.dpy);
515 if (dpyinfo.DtXineramaInfo == NULL)
516 { /* No xinerama, no joy. */
517 fprintf(stderr, "### JET VGMAIN: Xinerama NOT available.\n");
521 fprintf(stderr, "### JET VGMAIN: Xinerama available, scrns = %d\n",
522 dpyinfo.DtXineramaInfo->numscreens);
529 * check if any overrides were passed in the argv string...
532 for ( i = 1; i < argc; i++) {
541 * add the unit convertor for resources...
544 XtAddConverter(XmRString, XmRUnitType, XmCvtStringToUnitType, NULL, 0);
547 * get user-specified resources...
550 SetResourceDatabase();
552 XtGetApplicationResources(toplevel, &appInfo, AppResources,
553 XtNumber(AppResources), NULL, 0);
556 vg_TRACE_EXECUTION("main: got application resources ...");
557 #endif /* VG_TRACE */
564 vg_TRACE_EXECUTION("main: making UI ...");
565 #endif /* VG_TRACE */
566 MakeBackground(); /* login_shell, table, matte */
567 MakeLogo(); /* logo, logo_pixmap, logo_shadow */
568 MakeGreeting(); /* greeting */
569 MakeLogin(); /* login_matte ... */
570 MakeDtlabel(); /* Show Desktop selection in options menu*/
573 * grab the display and keyboard...
574 * moved it from before to after creating text widgets in MakeLogin
580 MakeButtons(); /* ok, clear, options, help buttons */
581 MakeDialog(copyright); /* copyright dialog */
583 if (appInfo.optionsDelay == 0 )
584 MakeOptionsMenu(); /* make option_button pop-up menu */
586 XtAddTimeOut((unsigned long) appInfo.optionsDelay * 1000,
587 MakeOptionsProc, NULL);
589 MakeAltDtButtons(); /* make alt desktop buttons, if any */
591 vg_TRACE_EXECUTION("main: made UI ...");
592 #endif /* VG_TRACE */
595 * Add request callback.
596 XtAddInput(0, (XtPointer)XtInputReadMask, RequestCB, NULL);
600 * force the focus to the login_text widget...
603 XtAddEventHandler(login_text, ExposureMask, False,
608 * create windows for the widgets...
612 vg_TRACE_EXECUTION("main: going to realize login_shell ...");
613 #endif /* VG_TRACE */
614 XtRealizeWidget(login_shell);
616 vg_TRACE_EXECUTION("main: realized login_shell ...");
617 #endif /* VG_TRACE */
621 * miscellaneous stuff...
623 * - turn off keyboard bell
624 * - return root cursor to normal from hourglass
625 * - start pinging the server
629 if (appInfo.workspaceCursor)
635 XUndefineCursor(dpyinfo.dpy, dpyinfo.root);
637 PingServerCB(NULL, NULL);
641 * bring up the windows and enter event loop...
644 XRaiseWindow(XtDisplay(greeting), XtWindow(greeting));
646 XRaiseWindow(XtDisplay(logo_shadow), XtWindow(logo_shadow));
647 XRaiseWindow(XtDisplay(logo), XtWindow(logo));
649 /* XtPopup(login_shell, XtGrabNone); */
650 _DtEnvControl( DT_ENV_RESTORE_PRE_DT );
653 * Add request callback.
656 XtAddInput(0, (XtPointer)XtInputReadMask, RequestCB, NULL);
659 vg_TRACE_EXECUTION("main: entering XtMainLoop ...");
660 #endif /* VG_TRACE */
668 /***************************************************************************
672 * initialize the toolkit
673 ***************************************************************************/
675 #define MINTIMEOUT 20
677 static jmp_buf syncJump;
680 syncTimeout( int arg )
683 longjmp (syncJump, 1);
688 InitToolKit( int argc, char **argv )
691 int timeout; /* timeout to initialize toolkit */
696 vg_TRACE_EXECUTION("InitToolKit: enter ...");
697 #endif /* VG_TRACE */
700 * use server grabTimeout as initial value for timeout...
703 timeout = ((t = (char *)getenv(GRABTIMEOUT)) == NULL ? 0 : atoi(t));
704 timeout += MINTIMEOUT; /* minimum MINTIMEOUT seconds */
708 * initialize the toolkit. Wrap a timer around it in case the server
712 signal (SIGALRM, syncTimeout);
713 if (setjmp (syncJump)) {
715 ReadCatalog(MC_LOG_SET,MC_LOG_NO_DPYINIT,MC_DEF_LOG_NO_DPYINIT),
717 exit(NOTIFY_RESTART);
720 alarm ((unsigned) timeout);
722 root = XtInitialize("dtlogin", "Dtlogin", NULL, 0,
724 /* Disable Drag and Drop RK 11.02.93 */
725 XtVaSetValues(XmGetXmDisplay(XtDisplay(root)),
726 XmNdragInitiatorProtocolStyle, XmDRAG_NONE,
731 signal (SIGALRM, SIG_DFL);
739 /***************************************************************************
744 ***************************************************************************/
747 MakeRootCursor( void )
751 vg_cursor = XCreateFontCursor (dpyinfo.dpy, XC_left_ptr);
753 XDefineCursor (dpyinfo.dpy, dpyinfo.root, vg_cursor);
758 /***************************************************************************
762 * Widgets: login_shell, table, matte
763 ***************************************************************************/
766 MakeBackground( void )
771 vg_TRACE_EXECUTION("MakeBackground: entered ...");
772 #endif /* VG_TRACE */
774 * create the login shell widget...
779 /* CORE resource set */
780 XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
781 XtSetArg(argt[i], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP ); i++;
782 XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
783 XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
784 XtSetArg(argt[i], XmNsensitive, True ); i++;
785 XtSetArg(argt[i], XmNtranslations, NULL ); i++;
787 /* COMPOSITE resource set */
788 XtSetArg(argt[i], XmNinsertPosition, NULL ); i++;
790 /* SHELL resource set (set to avoid interference by user) */
791 XtSetArg(argt[i], XmNallowShellResize, False ); i++;
792 XtSetArg(argt[i], XmNcreatePopupChildProc, NULL ); i++;
793 XtSetArg(argt[i], XmNgeometry, NULL ); i++;
794 XtSetArg(argt[i], XmNpopupCallback, NULL ); i++;
795 XtSetArg(argt[i], XmNpopdownCallback, NULL ); i++;
796 XtSetArg(argt[i], XmNoverrideRedirect, False ); i++;
797 XtSetArg(argt[i], XmNsaveUnder, False ); i++;
799 login_shell = XtCreatePopupShell("login_shell", transientShellWidgetClass,
801 XtAddCallback(login_shell, XmNpopupCallback, LayoutCB, NULL);
803 /* Fix to display Input Method's status area. */
804 XtSetArg(argt[0], XmNheight, dpyinfo.height);
805 XtSetValues(login_shell, argt, 1);
809 * create the full-screen drawing area...
812 i = InitArg(DrawingA);
813 XtSetArg(argt[i], XmNwidth, dpyinfo.width ); i++;
814 XtSetArg(argt[i], XmNheight, dpyinfo.height ); i++;
815 XtSetArg(argt[i], XmNunitType, XmPIXELS ); i++;
817 table = XtCreateManagedWidget("table", xmDrawingAreaWidgetClass,
818 login_shell, argt, i);
820 XtAddEventHandler(table, ButtonPressMask, False, RefreshEH, NULL);
821 XtAddCallback(table, XmNhelpCallback, ShowDialogCB, (XtPointer) help);
825 * create the main matte...
829 /* XmNwidth, (set by user) */
830 /* XmNheight, (set by user) */
831 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
833 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
834 XtSetArg(argt[i], XmNshadowThickness, 5 ); i++;
837 matte = XmCreateForm(table, "matte", argt, i);
838 XtManageChild(matte);
841 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
842 XtSetArg(argt[i], XmNshadowThickness, 2); i++;
843 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
844 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
845 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
847 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
849 XtSetArg(argt[i], XmNtopOffset, 15); i++;
850 XtSetArg(argt[i], XmNbottomOffset, 15); i++;
851 XtSetArg(argt[i], XmNleftOffset, 15); i++;
853 XtSetArg(argt[i], XmNrightOffset, 15); i++;
855 matteFrame = XmCreateFrame(matte, "matteFrame", argt, i);
856 XtManageChild(matteFrame);
859 matte1 = XmCreateForm(matteFrame, "matte1", argt, i);
860 XtManageChild(matte1);
866 MakeAltDtButtons( void )
871 XrmValue startup_value;
872 char temp[MAXPATHLEN] = "\0";
875 char lastsess[MAXPATHLEN];
876 Widget default_dt = NULL;
877 int default_is_custom_dt = True;
878 int found_alt_dt = False;
883 vg_TRACE_EXECUTION("MakeAltDtButtons: entered ...");
884 #endif /* VG_TRACE */
886 if (getenv("SESSION_SET") == NULL) {
887 default_is_custom_dt = False;
890 if ((session = getenv ("SESSION")) == NULL) {
894 if(appInfo.altDts > 0) {
896 (Widget *) calloc(appInfo.altDts, sizeof (Widget))) == NULL)
898 ReadCatalog(MC_ERROR_SET,MC_NO_MEMORY, MC_DEF_NO_MEMORY),
901 for(i = 0; i < appInfo.altDts; ++i) {
906 /* alt desktops begin numbering with 1 */
907 sprintf(altdtname,"%s%d", "Dtlogin*altDtName",i+1);
908 sprintf(altdtclass,"%s%d", "Dtlogin*AltDtName",i+1);
910 sprintf(altdtkey,"%s%d","Dtlogin*altDtKey",i+1);
911 sprintf(altdtkeyclass,"%s%d","Dtlogin*AltDtKey",i+1);
913 sprintf(altdtstart,"%s%d","Dtlogin*altDtStart",i+1);
914 sprintf(altdtstartclass,"%s%d","Dtlogin*AltDtStart",i+1);
917 XtDatabase(dpyinfo.dpy),
918 altdtkey, altdtkeyclass,
919 &keyrmtype, &keyrmvalue) == True) {
921 * remove trailing spaces
923 if(strchr(keyrmvalue.addr,' '))
924 temp_p = strtok(keyrmvalue.addr," ");
926 temp_p = keyrmvalue.addr;
929 * Make sure the key file exists.
931 if (stat( temp_p, &statb) == 0) {
933 j = InitArg(ToggleBG);
935 XtDatabase(dpyinfo.dpy),
936 altdtstart, altdtstartclass,
937 &startup_name, &startup_value) == True) {
940 * remove trailing spaces
942 if (strchr(startup_value.addr, ' '))
943 strcpy(temp, strtok(startup_value.addr," "));
945 strcpy(temp, startup_value.addr);
947 if (default_is_custom_dt)
948 if (strcmp(session, temp) == 0) {
953 LogError((unsigned char *)"No startup script for altdt %d \n", i);
956 XtDatabase(dpyinfo.dpy),
957 altdtname, altdtclass,
958 &rmtype, &rmvalue) == True) {
959 if (! strncmp(rmvalue.addr, DISPLAYNAME, strlen(DISPLAYNAME))) {
962 host = GetDisplayName();
965 strcat(temp, rmvalue.addr + strlen(DISPLAYNAME));
966 xmstr = XmStringCreateLocalized(temp);
969 xmstr = XmStringCreateLocalized(rmvalue.addr);
973 LogError((unsigned char *)
974 "Couldn't find the altdtname resource in the db\n");
975 sprintf(altdtname,"%s%d", "Alternate Desktop-",i+1);
976 xmstr = XmStringCreateLocalized(altdtname);
979 sprintf(altdtlogo,"%s%d","Dtlogin*altDtLogo",i+1);
980 sprintf(altlogoclass,"%s%d","Dtlogin*AltDtLogo",i+1);
982 XtDatabase(dpyinfo.dpy),
983 altdtlogo, altlogoclass,
984 &logotype, &logovalue) == True) {
985 XtSetArg(argt[j], XmNuserData, logovalue.addr); j++;
988 XtSetArg(argt[j], XmNuserData, logoInfo.bitmapFile); j++;
991 XtSetArg(argt[j], XmNlabelString, xmstr); j++;
992 XtSetArg(argt[j], XmNrecomputeSize, True); j++;
994 alt_dts[i] = XmCreateToggleButtonGadget(
996 rmvalue.addr, argt, j);
1000 XmNvalueChangedCallback, MenuItemCB,
1001 (XtPointer) OB_ALT_DTS);
1002 XtManageChild(alt_dts[i]);
1003 found_alt_dt = True;
1006 default_dt = alt_dts[i];
1009 LogError((unsigned char *) "Couldn't find the keyfile \n");
1012 LogError((unsigned char *)
1013 "Couldn't find the altkeyfile resource in the database\n");
1017 if ((appInfo.altDts == 0) || !found_alt_dt)
1018 XtManageChild(options_dt);
1021 * Use the regular desktop if none of the known sessions matched the
1022 * specified custom session.
1024 if (default_is_custom_dt && NULL == default_dt) {
1025 default_dt = options_dt;
1027 XtManageChild(options_dt);
1031 * [ Failsafe Session ] menu pane...
1033 i = InitArg(ToggleBG);
1034 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_FS_LABEL, MC_DEF_FS_LABEL);
1035 XtSetArg(argt[i], XmNuserData, logoInfo.bitmapFile ); i++;
1036 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1037 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1038 options_failsafe = XmCreateToggleButtonGadget(session_menu,
1039 "options_failsafe", argt, i);
1040 XmStringFree(xmstr);
1041 XtAddCallback(options_failsafe, XmNvalueChangedCallback,
1042 MenuItemCB, (XtPointer) OB_FAILSAFE);
1044 XtManageChild(options_failsafe);
1047 * which option to set..
1049 SetDefaultDt(default_dt);
1050 SetDtLabelAndIcon();
1053 /***************************************************************************
1057 * Widgets: ok_button, clear_button, options_button, help_button
1058 ***************************************************************************/
1066 Dimension max_width; /* maximum width of a set of widgets */
1067 Dimension max_height; /* maximum height of a set of widgets */
1068 Dimension thick1; /* defaultButtonShadowThickness */
1069 Dimension thick2; /* shadowThickness */
1071 int origin; /* horizontal origin for button placement */
1072 int spacing; /* spacing between buttons (width/32) */
1075 vg_TRACE_EXECUTION("MakeButtons: entered ...");
1076 #endif /* VG_TRACE */
1079 * create the buttons...
1084 i = InitArg(PushBG);
1085 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1086 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
1087 XtSetArg(argt[i], XmNtraversalOn, True); i++;
1089 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL );
1090 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1092 ok_button = XmCreatePushButtonGadget(matte1, "ok_button", argt, i);
1094 XmStringFree(xmstr);
1095 XtManageChild(ok_button);
1097 XtAddCallback(ok_button, XmNactivateCallback, RespondChallengeCB, NULL);
1103 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_CLEAR_LABEL, MC_DEF_CLEAR_LABEL);
1104 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1106 clear_button = XmCreatePushButtonGadget(matte1, "clear_button", argt, i);
1108 XmStringFree(xmstr);
1109 XtManageChild(clear_button);
1110 XtAddCallback(clear_button, XmNactivateCallback, RespondClearCB,
1117 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
1118 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1120 help_button = XmCreatePushButtonGadget(matte1, "help_button", argt, i);
1121 XtAddCallback(help_button, XmNactivateCallback, ShowDialogCB,
1123 XmStringFree(xmstr);
1124 XtManageChild(help_button);
1126 /* options button */
1129 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1130 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
1131 xmstr = ReadCatalogXms(
1134 MC_DEF_OPTIONS_LABEL );
1136 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
1137 XtSetArg(argt[i], XmNtraversalOn, True); i++;
1138 options_button = DtCreateMenuButton(matte1, "options_button", argt, i);
1139 XtOverrideTranslations(
1141 XtParseTranslationTable(" <Key> Return: Select()"));
1143 XtManageChild(options_button);
1144 XmStringFree(xmstr);
1147 * tell form that ok_button is the default button...
1151 XtSetArg(argt[i], XmNdefaultButton, ok_button ); i++;
1152 XtSetValues(matte1, argt, i);
1155 * make all buttons *look* the same size...
1159 max_width = max_height = 0;
1160 GetBiggest(ok_button, &max_width, &max_height);
1161 GetBiggest(clear_button, &max_width, &max_height);
1162 GetBiggest(options_button, &max_width, &max_height);
1163 GetBiggest(help_button, &max_width, &max_height);
1165 if ( (int) max_width < MIN_BUTTON_SIZE) max_width = MIN_BUTTON_SIZE;
1168 XtSetArg(argt[i], XmNdefaultButtonShadowThickness, &thick1); i++;
1169 XtSetArg(argt[i], XmNshadowThickness, &thick2); i++;
1170 XtGetValues(ok_button, argt, i);
1175 XtSetArg(argt[i], XmNwidth, max_width ); i++;
1176 XtSetArg(argt[i], XmNheight, max_height ); i++;
1177 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1178 XtSetArg(argt[i], XmNbottomOffset, thick1 ); i++;
1179 XtSetValues(options_button, argt, i);
1182 XtSetArg(argt[i], XmNwidth, max_width + 2*thick1 ); i++;
1183 XtSetArg(argt[i], XmNheight, max_height + 2*thick1 ); i++;
1184 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1186 XtSetValues(ok_button, argt, i);
1187 XtSetValues(clear_button, argt, i);
1188 XtSetValues(help_button, argt, i);
1194 /***************************************************************************
1198 * Widgets: error_message, help_message, copyright_msg, hostname_message,
1200 ***************************************************************************/
1203 MakeDialog( DialogType dtype )
1213 Dimension txt_width, txt_height;
1214 XmString ok, cancel, nw, sv;
1216 Widget tlev; /* JET - warning, there be dragons here */
1217 unsigned int dpwidth, dpheight, xorg, yorg;
1222 vg_TRACE_EXECUTION("MakeDialog: entered ...");
1223 #endif /* VG_TRACE */
1225 * do things common to all dialogs...
1229 /* get info on prefered screen */
1230 if (!_DtXineramaGetScreen(dpyinfo.DtXineramaInfo,
1231 appInfo.xineramaPreferredScreen,
1232 &dpwidth, &dpheight, &xorg, &yorg))
1233 { /* no joy here either - setup for normal */
1234 dpwidth = dpyinfo.width;
1235 dpheight = dpyinfo.height;
1238 /* else, should be setup properly */
1239 #else /* no Xinerama */
1240 dpwidth = dpyinfo.width;
1241 dpheight = dpyinfo.height;
1245 ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
1246 cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
1248 i = InitArg(MessageBox);
1249 XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++;
1250 XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++;
1251 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
1252 XtSetArg(argt[i], XmNokLabelString, ok ); i++;
1253 XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++;
1254 XtSetArg(argt[i], XmNnoResize, False ); i++;
1255 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
1258 * create the various dialogs...
1261 /* JET - check the matte widget, and if non-null, well use that as
1262 * the parent for dialogs. Otherwise use table (the original
1263 * toplevel widget for this func). This is useful for Xinerama so
1264 * that child dialogs are centered on the matte, and not the whole
1268 if (matte != (Widget)NULL)
1276 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
1277 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1279 w = XmCreateErrorDialog(tlev, "error_message", argt, i);
1280 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1281 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1289 txt_width = (dpwidth > 850) ? 800 : dpwidth - 50;
1290 txt_height = (dpheight > 900) ? 600 : dpheight - 300;
1292 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
1293 XtSetArg(argt[i], XmNmessageString, xmstr); i++;
1295 w = XmCreateInformationDialog(tlev, "help_message", argt, i);
1296 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1297 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1300 XtSetArg(argt[i], XmNheight, txt_height); i++;
1301 XtSetArg(argt[i], XmNwidth, txt_width); i++;
1302 XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
1303 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
1304 XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
1305 XtSetArg(argt[i], XmNeditable, False); i++;
1308 XmNvalue, ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP)); i++;
1309 text = XmCreateScrolledText(w, "help_message_text", argt, i);
1311 XtManageChild(text);
1318 if ((fp = fopen(COPYRIGHT,"r")) == NULL)
1319 #if defined( __hp_osf )
1320 xmstr = XmStringCreate("Cannot open copyright file '/usr/X11/copyright'.",
1321 XmFONTLIST_DEFAULT_TAG);
1323 xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
1324 XmFONTLIST_DEFAULT_TAG);
1327 xmstr = (XmString) NULL;
1329 while (fgets(buffer, 128, fp) != NULL) {
1331 if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
1333 if ( xmstr != NULL )
1334 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
1336 xmstr = XmStringConcat(xmstr,
1337 XmStringCreate(buffer,
1338 XmFONTLIST_DEFAULT_TAG));
1343 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1345 w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
1346 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1347 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1349 XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);
1357 nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
1358 sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);
1360 xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
1361 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1362 XtSetArg(argt[i], XmNokLabelString, nw ); i++;
1363 XtSetArg(argt[i], XmNcancelLabelString, sv ); i++;
1365 w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);
1367 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1372 hostname_message = w;
1378 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED,
1379 MC_DEF_PASSWD_EXPIRED);
1380 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1382 w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);
1384 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1398 XtAddCallback(w, XmNokCallback, RespondDialogCB, NULL);
1399 XtAddCallback(w, XmNcancelCallback, RespondDialogCB, NULL);
1404 XtSetArg(argt[0], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); i++;
1405 XtSetValues(w, argt, 1);
1407 XmStringFree(xmstr);
1409 XmStringFree(cancel);
1413 * adjust the width of the "ok" button on the dialogs...
1416 width = (dtype == hostname ? FromMM(4000) : MIN_BUTTON_SIZE);
1419 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1420 XtSetArg(argt[i], XmNwidth, width ); i++;
1422 XtSetValues(XmMessageBoxGetChild(w, XmDIALOG_OK_BUTTON), argt, i);
1426 /***************************************************************************
1431 ***************************************************************************/
1439 vg_TRACE_EXECUTION("MakeDtlabel: entered ...");
1440 #endif /* VG_TRACE */
1442 i = InitArg(LabelG);
1443 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1444 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET ); i++;
1445 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM ); i++;
1446 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM ); i++;
1447 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;
1448 XtSetArg(argt[i], XmNtopWidget, greeting ); i++;
1450 dt_label = XmCreateLabel(matte1, "dt_label", argt, i);
1451 XtManageChild(dt_label);
1456 /***************************************************************************
1461 ***************************************************************************/
1464 char *labelString; /* string for label */
1465 char *persLabelString; /* alternate string for label */
1466 XmFontList fontList;
1467 } GreetInfo, *GreetInfoPtr;
1469 static GreetInfo greetInfo;
1471 static XtResource greetResources[] = {
1472 {XmNlabelString, XmCLabelString,
1473 XmRString, sizeof(char *),
1474 XtOffset(GreetInfoPtr, labelString), XtRString, "default" },
1476 {"persLabelString", "PersLabelString",
1477 XmRString, sizeof(char *),
1478 XtOffset(GreetInfoPtr, persLabelString), XtRString, "default" },
1480 {XmNfontList, XmCFontList,
1481 XmRFontList, sizeof(XmFontList),
1482 XtOffset(GreetInfoPtr, fontList), XtRString, NULL }
1486 MakeGreeting( void )
1493 char *p, *q, *s, *t;
1494 int newLine = False;
1498 vg_TRACE_EXECUTION("MakeGreeting: entered ...");
1499 #endif /* VG_TRACE */
1502 * get the user's greeting preferences...
1505 XtGetSubresources(table, &greetInfo, "greeting", "Greeting",
1506 greetResources, XtNumber(greetResources), NULL, 0);
1510 * get the local hostname...
1513 gethostname(host, sizeof (host));
1514 if ( (p = strchr(host,'.')) != NULL )
1518 ** Get display name (for %DisplayName% substitutions),
1519 ** reducing "a.b.c.d:0" constructs to shorter "a:0" form.
1523 dpyinfo.name ? dpyinfo.name : (DisplayString(dpyinfo.dpy)), 127);
1525 p = strchr(disp, '.');
1526 t = strchr(disp, ':');
1527 if (p && t) strcpy(p,t);
1531 * use the default string if the user has not specified one...
1534 if ( greetInfo.persLabelString &&
1535 strcmp(greetInfo.persLabelString, "default") == 0 ) {
1539 ReadCatalog(MC_LABEL_SET,MC_PERS_GREET_LABEL,MC_DEF_PERS_GREET_LABEL);
1540 greetInfo.persLabelString = strdup(msg);
1543 if ( greetInfo.labelString &&
1544 strcmp(greetInfo.labelString, "default") == 0 ) {
1546 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_GREET_LABEL,MC_DEF_GREET_LABEL);
1547 xmstr = XmStringConcat(xmstr,
1548 XmStringCreate(" ", XmFONTLIST_DEFAULT_TAG));
1549 xmstr = XmStringConcat(xmstr,
1550 XmStringCreate(host, XmFONTLIST_DEFAULT_TAG));
1554 * scan user's message for %LocalHost% token. Replace with hostname
1559 if ( strlen(greetInfo.labelString) == 0 ||
1560 strcmp(greetInfo.labelString, "None") == 0 ||
1561 strcmp(greetInfo.labelString, "none") == 0 )
1563 greetmsg = strdup(" ");
1565 greetmsg = strdup(greetInfo.labelString);
1569 xmstr = (XmString) NULL;
1575 * scan for a new line character in remaining label string.
1576 * If found, work with that substring first...
1579 if ( (p = strchr(q, '\n')) != NULL ) {
1584 if ( *q == '\0' ) /* handle consecutive newlines */
1593 * replace all occurrances of %LocalHost% and %DisplayName%
1594 * in the current substring...
1598 p = strstr(q, LOCALHOST);
1599 t = strstr(q, DISPLAYNAME);
1601 if (p && t) { /* both present? do whichever comes first */
1602 if (p > t) p = NULL;
1605 if (p) { /* replace a %LocalHost% string */
1607 skip = sizeof(LOCALHOST);
1608 } else if (t) { /* replace a %DisplayName% string */
1611 skip = sizeof(DISPLAYNAME);
1612 } else /* nothing left to replace */
1615 xmstr = XmStringConcat(xmstr,
1617 XmFONTLIST_DEFAULT_TAG));
1618 xmstr = XmStringConcat(xmstr,
1620 XmFONTLIST_DEFAULT_TAG));
1624 if ( strlen(q) != 0 )
1625 xmstr = XmStringConcat(xmstr,
1627 XmFONTLIST_DEFAULT_TAG));
1630 * add a line seperator if this is a multi-line greeting...
1633 if ( newLine == True ) {
1634 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
1637 } while ( newLine == True ) ;
1644 * create the Welcome message...
1647 i = InitArg(LabelG);
1648 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1649 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1650 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
1651 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_POSITION); i++;
1652 /* XtSetArg(argt[i], XmNtopPosition, 15); i++; */
1653 /* Changed this to accomodate desktop label */
1654 XtSetArg(argt[i], XmNtopPosition, 9); i++;
1655 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
1659 * use the user's font if one has been specified, otherwise use
1660 * the application's default...
1663 if ( greetInfo.fontList != NULL ) {
1664 XtSetArg(argt[i], XmNfontList, greetInfo.fontList ); i++;
1667 greeting = XmCreateLabel(matte1, "greeting", argt, i);
1668 XtManageChild(greeting);
1670 XmStringFree(xmstr);
1673 /***************************************************************************
1677 * Widgets: login_matte,
1678 * login_form, login_label, login_text
1679 ***************************************************************************/
1686 LoginTextPtr textdata;
1687 XtTranslations textTable;
1692 vg_TRACE_EXECUTION("MakeLogin: entered ...");
1693 #endif /* VG_TRACE */
1696 * create the login form
1700 XtSetArg(argt[i], XmNshadowThickness, 0); i++;
1701 XtSetArg(argt[i], XmNresizable, False ); i++;
1702 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
1703 XtSetArg(argt[i], XmNleftOffset, 80); i++;
1704 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
1705 XtSetArg(argt[i], XmNrightOffset, 80); i++;
1706 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1707 XtSetArg(argt[i], XmNbottomPosition, 65); i++;
1709 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY); i++;
1711 XtSetArg(argt[i], XmNallowShellResize, True); i++;
1713 login_form = XmCreateForm(matte1, "login_form", argt, i);
1714 XtManageChild(login_form);
1717 * create the login text field...
1721 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION ); i++;
1722 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_POSITION ); i++;
1723 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_POSITION ); i++;
1724 XtSetArg(argt[i], XmNbottomPosition, 95 ); i++;
1725 XtSetArg(argt[i], XmNrightPosition, 80 ); i++;
1726 XtSetArg(argt[i], XmNleftPosition, 20 ); i++;
1727 XtSetArg(argt[i], XmNselectionArrayCount, 1 ); i++;
1728 XtSetArg(argt[i], XmNmaxLength, 80 ); i++;
1729 XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
1731 textdata = malloc(sizeof(LoginText));
1732 XtSetArg(argt[i], XmNuserData, textdata ); i++;
1734 login_text = XmCreateTextField(login_form, "login_text", argt, i);
1737 * From Human Interface model, Tab key operation should work same on
1738 * user field as it does on password field. Password field is setup
1739 * to take Tab key as password data. HIE model is for user field to
1742 XtOverrideTranslations(
1744 XtParseTranslationTable(
1745 " Shift <Key>Tab: prev-tab-group() \n\
1746 Ctrl <Key>Tab: next-tab-group() "));
1748 XtManageChild(login_text);
1750 XtAddCallback(login_text, XmNfocusCallback, TextFocusCB, NULL);
1754 XtAddActions(textActions, 2);
1755 textTable = XtParseTranslationTable(textEventBindings);
1758 XtSetArg(argt[i], XmNtranslations, textTable ); i++;
1760 XtSetArg(argt[i], XmNverifyBell, False ); i++;
1762 passwd_text = XmCreateTextField(login_form, "passwd_text", argt, i);
1764 textdata->bEcho = True;
1765 textdata->noechobuf[0] = '\0';
1766 textdata->text[0] = passwd_text;
1767 textdata->text[1] = login_text;
1769 XtManageChild(passwd_text);
1771 XtAddCallback(passwd_text, XmNfocusCallback, TextFocusCB, NULL);
1773 XtAddCallback(passwd_text, XmNmodifyVerifyCallback, EditPasswdCB, NULL);
1776 * Get default greeting string
1779 XtSetArg(argt[i], XmNlabelString, &textdata->onGreeting); i++;
1780 XtGetValues(greeting, argt, i);
1781 textdata->offGreetingFormat = greetInfo.persLabelString;
1782 textdata->offGreetingUname = NULL;
1785 * create the login labels...
1788 i = InitArg(LabelG);
1790 /* modified recomputeSize initial value from False to True, fails
1791 * when setting longer strings. Manifested as bug ID:1200690.
1793 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1795 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1796 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET ); i++;
1797 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
1799 /* XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM ); i++;
1800 Commented this statement to align login_label and login_text
1801 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM ); i++;
1802 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;
1803 XtSetArg(argt[i], XmNbottomOffset, 10 ); i++;
1806 XtSetArg(argt[i], XmNleftWidget, login_text ); i++;
1807 XtSetArg(argt[i], XmNbottomWidget, login_text ); i++;
1811 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LOGIN_LABEL, MC_DEF_LOGIN_LABEL);
1812 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1814 login_label = XmCreateLabel(login_form, "login_label", argt, i);
1815 XtManageChild(login_label);
1817 XmStringFree(xmstr);
1824 /***************************************************************************
1828 * Widgets: options_menu, options_item[]
1829 ***************************************************************************/
1832 MakeOptionsMenu( void )
1839 vg_TRACE_EXECUTION("MakeOptionsMenu: entered ...");
1840 #endif /* VG_TRACE */
1843 * get the built-in pop_up menu from the DtMenuButton...
1846 XtVaGetValues(options_button, DtNsubMenuId, &options_menu, NULL);
1849 * create language cascade menus...
1852 if ( lang_menu == NULL )
1857 * create first level menu items...
1862 * build [ Language ] menu pane if there are languages to choose from...
1864 if ( lang_menu != NULL ) {
1866 * [ Language ] menu pane...
1867 * attach language cascade menu to this pane
1869 i = InitArg(CascadeBG);
1870 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LANG_LABEL, MC_DEF_LANG_LABEL);
1871 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1872 XtSetArg(argt[i], XmNsubMenuId, lang_menu ); i++;
1873 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1874 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
1875 "options_languages", argt, i);
1876 XmStringFree(xmstr);
1882 i = InitArg(SeparatorG);
1883 options_item[j] = XmCreateSeparatorGadget(options_menu,
1889 if( session_menu == NULL) {
1890 session_menu = XmCreatePulldownMenu(options_menu, "session_menu", NULL, 0);
1894 * [ Dt "Reg" ] menu pane...
1896 i = k = InitArg(ToggleBG);
1897 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_DT_LABEL, MC_DEF_DT_LABEL);
1898 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1899 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1900 XtSetArg(argt[i], XmNuserData, logoInfo.bitmapFile ); i++;
1902 options_dt = XmCreateToggleButtonGadget(session_menu,
1905 XmStringFree(xmstr);
1906 XtAddCallback(options_dt,
1907 XmNvalueChangedCallback,
1910 /*XtManageChild(options_dt); */
1912 * [ Dt Lite ] menu pane...
1915 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_DTLITE_LABEL, MC_DEF_DTLITE_LABEL);
1916 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1917 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1919 options_dtlite = XmCreateToggleButtonGadget(session_menu,
1922 XmStringFree(xmstr);
1923 XtAddCallback(options_dtlite,
1924 XmNvalueChangedCallback,
1926 (XtPointer) OB_DTLITE);
1931 if ( session_menu != NULL ) {
1933 * [ Language ] menu pane...
1934 * attach language cascade menu to this pane
1936 i = InitArg(CascadeBG);
1937 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_SES_LABEL, MC_DEF_SES_LABEL);
1938 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1939 XtSetArg(argt[i], XmNsubMenuId, session_menu ); i++;
1940 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1941 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
1942 "session_menus", argt, i);
1943 XmStringFree(xmstr);
1949 i = InitArg(SeparatorG);
1950 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
1962 * [ No Windows ] menu pane...
1964 i = k = InitArg(PushBG);
1965 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
1966 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1967 options_item[j] = options_nowindows
1968 = XmCreatePushButtonGadget(options_menu,
1969 "options_noWindows",
1971 XmStringFree(xmstr);
1972 XtAddCallback(options_item[j], XmNactivateCallback,
1973 MenuItemCB, (XtPointer) OB_NO_WINDOWS);
1975 if (getenv(LOCATION) == NULL || strcmp(getenv(LOCATION), "local") != 0 )
1976 XtSetSensitive(options_item[j], False);
1982 * [ Restart Server ] menu pane...
1984 i = k = InitArg(PushBG);
1985 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_RS_LABEL, MC_DEF_RS_LABEL);
1986 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1987 options_item[j] = XmCreatePushButtonGadget(options_menu,
1988 "options_restartServer",
1990 XmStringFree(xmstr);
1991 XtAddCallback(options_item[j], XmNactivateCallback,
1992 MenuItemCB, (XtPointer) OB_RESTART_SERVER);
1995 #ifdef copyright_option
1999 i = InitArg(SeparatorG);
2000 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
2006 * [ Copyright ] menu pane...
2008 i = k = InitArg(PushBG);
2009 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_COPY_LABEL, MC_DEF_COPY_LABEL);
2010 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
2011 options_item[j] = XmCreatePushButtonGadget(options_menu,
2012 "options_copyright",
2014 XmStringFree(xmstr);
2015 XtAddCallback(options_item[j], XmNactivateCallback,
2016 MenuItemCB, (XtPointer) OB_COPYRIGHT);
2021 * manage the [Options] menu...
2023 XtManageChildren(options_item, j);
2028 * If the DT Lite Session Manager is not available, remove the DT Lite
2029 * and DT menu panes. The actual widgets must still be created since
2030 * other code (ex. MenuItemCB()) tries to obtain some of their resources.
2033 if ( stat(DTLITESESSION, &statb) != 0 ||
2034 ((statb.st_mode & S_IXOTH) != S_IXOTH) ) {
2036 XtUnmanageChild(options_dtlite);
2038 XtUnmanageChild(options_dt);
2042 if ( getenv(PINGINTERVAL) != NULL )
2043 XtUnmanageChild(options_nowindows);
2051 /***************************************************************************
2055 * Local self-insert action for the text widget. The default action
2056 * discards control characters, which are allowed in password.
2057 ***************************************************************************/
2060 MyInsert( Widget w, XEvent *event, char **params, Cardinal *num_params )
2063 XComposeStatus compstatus;
2066 n = XLookupString((XKeyEvent *)event, str, sizeof(str),
2067 (KeySym *)NULL, &compstatus);
2071 XmTextFieldInsert(w, XmTextFieldGetInsertionPosition(w), str);
2075 /***************************************************************************
2079 * Local backspace action for the text widget.
2080 * Deletes the last character of the password string in the
2081 * widget for each backspace key press, and also does not move the cursor
2082 * position in the widget.
2083 ***************************************************************************/
2086 MyBackspace( Widget w, XEvent *event, char **params, Cardinal *num_params )
2088 LoginTextPtr textdata;
2090 textdata = GetLoginTextPtr(w);
2092 if (textdata && !textdata->bEcho && (int) strlen(textdata->noechobuf) > 0)
2094 textdata->noechobuf[strlen(textdata->noechobuf) - 1] = '\0';
2099 /***************************************************************************
2103 * X protocol error handler to override the default
2104 ***************************************************************************/
2107 ErrorHandler( Display *dpy, XErrorEvent *event )
2115 /***************************************************************************
2119 * Xt protocol error handler to override the default
2120 ***************************************************************************/
2123 xtErrorHandler( String msg )
2125 LogError((unsigned char *) "%s\n", msg ) ;
2126 exit(NOTIFY_RESTART);
2132 /***************************************************************************
2136 * Xt protocol error handler to override the default
2137 ***************************************************************************/
2140 xtWarningHandler( String msg )
2142 LogError( (unsigned char *) "%s\n", msg ) ;
2149 /***************************************************************************
2153 * Timeout routine to build options menu
2154 ***************************************************************************/
2157 MakeOptionsProc( XtPointer data, XtIntervalId *id )
2160 if (options_menu == NULL)
2169 /***************************************************************************
2173 * Catch a SIGTERM and unmanage display
2174 ***************************************************************************/
2177 Terminate( int arg )
2180 write(1, "terminate", 9);
2181 CleanupAndExit(NULL, NOTIFY_ABORT);
2187 /***************************************************************************
2189 * DebugWidgetResources
2191 * Get widget resources
2192 ***************************************************************************/
2194 typedef struct resource_values {
2199 int rightAttachment;
2202 int bottomAttachment;
2206 DebugWidgetResources(Widget w)
2209 struct resource_values values;
2213 bzero((char *) &values, sizeof(values));
2214 XtSetArg(argt[i], XmNheight, &values.height); i++;
2215 XtSetArg(argt[i], XmNwidth, &values.width); i++;
2216 XtSetArg(argt[i], XmNx, &values.x); i++;
2217 XtSetArg(argt[i], XmNy, &values.y); i++;
2218 XtSetArg(argt[i], XmNrightAttachment, &values.rightAttachment); i++;
2219 XtSetArg(argt[i], XmNleftAttachment, &values.leftAttachment); i++;
2220 XtSetArg(argt[i], XmNtopAttachment, &values.topAttachment); i++;
2221 XtSetArg(argt[i], XmNbottomAttachment, &values.bottomAttachment); i++;
2223 XtGetValues(w, argt, i);
2227 /***************************************************************************
2229 * GetDisplayName (void) - transform the display name into a "short"
2230 * host name that is used to create a display-specific session.
2232 * The display name should match one of the following patterns:
2234 * 1. host (non-qualified)
2239 * 6. host.domain:n.s
2241 * Note that 1 and 2 will be used if the display name is actually
2242 * something like unix:0, local:0 or 0:0
2244 ***************************************************************************/
2246 GetDisplayName (void)
2248 char host[MAXHOSTNAMELEN];
2249 static char tmp[MAXHOSTNAMELEN + 3];
2254 pch = XDisplayString(dpyinfo.dpy);
2257 !strncmp (pch, "local:0", 7) ||
2258 !strncmp (pch, "unix:0", 6) ||
2259 !strncmp (pch, ":0.0", 4) ||
2260 !strncmp (pch, ":0", 2)) {
2261 gethostname (host, MAXHOSTNAMELEN);
2265 col = strchr (pch, ':');
2266 dot = strchr (pch, '.');
2270 strncpy (tmp, pch, dot - pch); /* case #2 above */
2271 tmp[dot - pch] = '\000';
2273 strcpy (tmp, pch); /* case #1 above */
2276 if (!dot || (dot > col)) { /* case #3 and 4 above */
2277 strncpy (tmp, pch, col - pch);
2278 tmp[col - pch] = '\000';
2279 } else { /* case # 5 and 6 above */
2280 strncpy (tmp, pch, dot - pch);
2281 tmp[dot - pch] = '\000';