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>
93 #if !defined(NL_CAT_LOCALE)
94 #define NL_CAT_LOCALE 0
97 #define LOCALHOST "%LocalHost%"
98 #define DISPLAYNAME "%DisplayName%"
100 /***************************************************************************
102 * External declarations
104 ***************************************************************************/
105 extern char password[]; /* pswd string value */
106 extern int password_length; /* pswd string length */
109 /***************************************************************************
111 * Procedure declarations
113 ***************************************************************************/
115 static SIGVAL syncTimeout( int arg ) ;
116 static Widget InitToolKit( int argc, char **argv) ;
117 static void MakeRootCursor( void ) ;
118 static void MakeBackground( void ) ;
119 static void MakeButtons( void ) ;
120 static void MakeDtlabel( void );
121 static void MakeGreeting( void ) ;
122 static void MakeLogin( void ) ;
123 static void MyInsert( Widget w, XEvent *event, char **params,
124 Cardinal *num_params) ;
125 static void MyBackspace( Widget w, XEvent *event, char **params,
126 Cardinal *num_params) ;
127 static int ErrorHandler( Display *dpy, XErrorEvent *event) ;
128 static void xtErrorHandler( String msg ) ;
129 static void xtWarningHandler( String msg ) ;
130 static void MakeOptionsProc( XtPointer data, XtIntervalId *id) ;
131 static SIGVAL Terminate( int arg ) ;
132 static char * GetLangName( char * label );
133 static void MakeAltDtButtons( void );
134 static void DebugWidgetResources(Widget w);
135 static char * GetDisplayName();
141 /***************************************************************************
145 ***************************************************************************/
148 AppInfo appInfo; /* application resources */
149 Arg argt[100]; /* used for resources */
150 DisplayInfo dpyinfo; /* information about the display */
151 XmString xmstr; /* used for compound strings */
152 char *errorLogFile; /* current value of environment var. */
153 int showVerifyError;/* display a Verify() error dialog */
155 char altdtname[MAXPATHLEN];
156 char altdtclass[MAXPATHLEN];
157 char altdtkey[MAXPATHLEN];
158 char altdtkeyclass[MAXPATHLEN];
159 char altdtstart[MAXPATHLEN];
160 char altdtstartclass[MAXPATHLEN];
161 char altdtlogo[MAXPATHLEN];
162 char altlogoclass[MAXPATHLEN];
164 char *logotype; /* for XrmGetResource() */
165 XrmValue logovalue; /* for XrmGetResource() */
171 /******************************************************************************
175 ** toplevel "main" (toplevel)
176 ** login_shell "login_shell" (overrideShell)
177 ** table "table" (DrawingAreaWidget)
178 ** copyright_msg "copyright_msg" (MessageBox)
179 ** error_message "error_message" (MessageBox)
180 ** help_message "help_message" (MessageBox)
181 ** passwd_message "passwd_message" (MessageBox)
182 ** hostname_message "hostname_msg" (MessageBox)
183 ** matte "matte" (FormWidget)
184 ** logo "logo" (FrameWidget)
185 ** logo_pixmap "logo_pixmap" (LabelGadget)
186 ** matteFrame "matteFrame" (FrameWidget)
187 ** matte1 "matte1" (FormWidget)
188 ** help_button "help_button" (PushButtonGadget)
189 ** greeting "greeting" (LabelGadget)
190 ** dt_label "dt_label" (LabelGadget)
191 ** login_form "login_form" (FormWidget)
192 ** login_label "login_label" (LabelGadget)
193 ** login_text "login_text" (TextField)
194 ** passwd_text "passwd_text" (TextField)
195 ** ok_button "ok_button" (PushButtonGadget)
196 ** clear_button "clear_button" (PushButtonGadget)
197 ** options_button "options_button" (DtMenuButtonWidget)
198 ** options_menu "options_menu" (PopupMenu)
199 ** options_item[0] "options_languages" (CascadeButtonGadget)
200 ** options_item[1] "options_sep2" (SeparatorGadget)
201 ** options_item[2] "session_menus" (CascadeButtonGadget)
202 ** options_item[3] "options_sep1" (SeparatorGadget)
203 ** options_item[4] "options_noWindows" (PushButtonGadget)
204 ** options_item[5] "options_restartServer"(PushButtonGadget)
205 ** options_item[6] "options_sep1" (SeparatorGadget)
206 ** options_item[7] "options_Copyright" (PushButtonGadget)
207 ** session_menu "session_menu" (PulldownMenu)
208 ** options_dt "options_dt" (ToggleButtonGadget)
209 ** options_failsafe "options_failsafe" (ToggleButtonGadget)
210 ** lang_menu "lang_menu" (PulldownMenu)
211 ** (lang items) (lang items) (ToggleButtonGadget)
217 Widget toplevel; /* top level shell widget */
218 Widget login_shell; /* shell for the main login widgets. */
219 Widget table; /* black background for everything */
220 Widget matte; /* main level form widget */
221 Widget matteFrame; /* main level form widget */
222 Widget matte1; /* second level form widget */
224 Widget greeting; /* Welcome message */
225 Widget dt_label; /* Desktop i.e. set in options menu */
227 Widget logo1; /* frame around the Corporate logo */
228 Widget logo_pixmap; /* Corporate logo */
229 Widget logo_shadow; /* drop shadow under the Corporate logo */
231 Widget login_matte; /* bulletin board for login/password */
232 Widget login_form; /* form containing the login widgets */
233 Widget login_label; /* label to left of login text widget */
234 Widget login_text; /* login text widget */
236 Widget ok_button; /* accept name/password text button */
237 Widget clear_button; /* clear name/password text button */
238 Widget options_button; /* login options button */
239 Widget help_button; /* help button */
241 Widget copyright_msg = NULL; /* copyright notice widget */
242 Widget help_message = NULL; /* the help message box */
243 Widget error_message = NULL; /* the error message box */
244 Widget hostname_message = NULL; /* the invalid hostname message box */
245 Widget passwd_message = NULL; /* the expired password message box */
247 Widget options_menu = NULL; /* pop-up menu on options button */
248 Widget options_item[10]; /* items on options pop_up menu */
249 Widget options_nowindows; /* nowindows pane on options pop_up menu */
250 Widget options_failsafe; /* failsafe pane on options pop_up menu */
251 Widget options_dtlite; /* dtlite pane on options pop_up menu */
252 Widget *alt_dts; /* alt_dts widgets on options pop_up menu */
253 Widget options_dt; /* dt regular pane on options pop_up menu */
254 Widget options_last_dt; /* user's last dt */
256 Widget lang_menu = NULL; /* cascading menu on "Language" option */
257 Widget session_menu = NULL; /* cascading menu on "Session" option */
260 /***************************************************************************
262 * Text widget actions and translations
264 ***************************************************************************/
266 static XtActionsRec textActions[] = {
267 {"my-insert", (XtActionProc)MyInsert},
268 {"my-bksp", (XtActionProc)MyBackspace},
271 static char textEventBindings[] = {
272 "Shift <Key>Tab: prev-tab-group() \n\
273 Ctrl <Key>Tab: next-tab-group() \n\
274 <Key>osfEndLine: end-of-line() \n\
275 <Key>osfBeginLine: beginning-of-line() \n\
276 ~Shift <Key>osfRight: forward-character()\n\
277 ~Shift <Key>osfLeft: backward-character()\n\
278 Ctrl <Key>osfDelete: delete-to-end-of-line()\n\
279 <Key>osfDelete: delete-next-character()\n\
280 <Key>osfBackSpace: my-bksp()\n\
281 <Key>osfActivate: activate()\n\
282 Ctrl <Key>Return: activate()\n\
283 <Key>Return: activate()\n\
284 <Key>: my-insert()\n\
285 ~Ctrl ~Shift ~Meta ~Alt<Btn1Down>: grab-focus() \n\
286 <EnterWindow>: enter()\n\
287 <LeaveWindow>: leave()\n\
288 <FocusIn>: focusIn()\n\
289 <FocusOut>: focusOut()\n\
295 XtResource AppResources[] = {
296 { "workspaceCursor", "WorkspaceCursor",
297 XtRBoolean, sizeof(Boolean), XtOffset(AppInfoPtr, workspaceCursor),
298 XtRImmediate, (caddr_t)False },
300 { "labelFont", "LabelFont",
301 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, labelFont),
302 XmRString, "Fixed" },
304 { "textFont", "TextFont",
305 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, textFont),
306 XmRString, "Fixed" },
308 { "optionsDelay", "OptionsDelay",
309 XtRInt, sizeof(int), XtOffset(AppInfoPtr, optionsDelay),
310 XtRImmediate, (XtPointer) 0 },
312 { "altDts", "AltDts",
313 XtRInt, sizeof(int), XtOffset(AppInfoPtr, altDts),
314 XtRImmediate, (XtPointer) 0
317 {"languageList", "LanguageList",
318 XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
321 #if defined (ENABLE_DYNAMIC_LANGLIST)
322 {"languageListCmd", "LanguageListCmd",
323 XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
325 #endif /* ENABLE_DYNAMIC_LANGLIST */
332 /***************************************************************************
336 ***************************************************************************/
340 main( int argc, char **argv )
344 int i; /* index for argt */
345 char **p; /* temp pointer to traverse argv */
346 Boolean nograb=FALSE; /* debugging option to not grab server/key */
347 int debug=0; /* print debugging output */
350 vg_TRACE_EXECUTION("--------------------- main ------------------------");
351 #endif /* VG_TRACE */
353 setlocale(LC_ALL, "");
354 XtSetLanguageProc( NULL, NULL, NULL );
355 langenv = getenv("LANG");
358 * set TERM signal handler...
361 (void) signal(SIGTERM, Terminate);
367 extern SIGVAL BLS_ToggleDebug( int arg );
370 * Allow debug output to be turned on for dtgreet.
373 (void) signal(SIGHUP, BLS_ToggleDebug);
378 * set up authorization parameters, see the identity(3) man page...
382 set_auth_parameters(1, argv);
389 * check some environment variables...
392 errorLogFile = getenv(ERRORLOG);
395 if (getenv("OPENWINHOME") == NULL) putenv(OWPATH_ENV);
398 _DtEnvControl( DT_ENV_SET );
401 * set custom error handler for X protocol errors...
404 XSetErrorHandler(ErrorHandler);
408 * scan argv looking for display name...
413 for ( i = argc, p = argv; i > 0; i--, p++ ) {
414 if ( strcmp(*p, "-display") == 0) {
417 dpyinfo.name = malloc(strlen(*p) + 1);
418 strcpy(dpyinfo.name, *p);
422 if ( strcmp(*p, "-debug") == 0) {
429 if ( strcmp(*p, "-nograb") == 0) {
434 if ( strcmp(*p, "-showerror") == 0) {
437 showVerifyError = atoi(*p);
443 vg_TRACE_EXECUTION("main: after options.");
444 #endif /* VG_TRACE */
449 LogError((unsigned char *) "main: sleeping %d seconds.\n", debug);
454 #endif /* VG_DEBUG */
457 * initialize the Intrinsics...
460 toplevel = InitToolKit(argc, argv);
462 vg_TRACE_EXECUTION("main: exited InitToolKit ...");
463 #endif /* VG_TRACE */
466 XtSetErrorHandler(xtErrorHandler);
467 XtSetWarningHandler(xtWarningHandler);
472 * prevent the toolkit from starting the NLIO server...
475 _XHPNlioctl(0,0,-1,0);
478 vg_TRACE_EXECUTION("main: exited _XHPNlioctl ...");
479 #endif /* VG_TRACE */
483 * get information about the display...
486 dpyinfo.dpy = XtDisplay(toplevel);
487 /* dpyinfo.name = "";*/
488 dpyinfo.screen = DefaultScreen(dpyinfo.dpy);
489 dpyinfo.root = RootWindow (dpyinfo.dpy, dpyinfo.screen);
490 dpyinfo.depth = DefaultDepth (dpyinfo.dpy, dpyinfo.screen);
491 dpyinfo.width = DisplayWidth (dpyinfo.dpy, dpyinfo.screen);
492 dpyinfo.height = DisplayHeight(dpyinfo.dpy, dpyinfo.screen);
493 dpyinfo.black_pixel = BlackPixel (dpyinfo.dpy, dpyinfo.screen);
494 dpyinfo.visual = DefaultVisual(dpyinfo.dpy, dpyinfo.screen);
497 * check if any overrides were passed in the argv string...
500 for ( i = 1; i < argc; i++) {
509 * add the unit convertor for resources...
512 XtAddConverter(XmRString, XmRUnitType, XmCvtStringToUnitType, NULL, 0);
515 * get user-specified resources...
518 SetResourceDatabase();
520 XtGetApplicationResources(toplevel, &appInfo, AppResources,
521 XtNumber(AppResources), NULL, 0);
524 vg_TRACE_EXECUTION("main: got application resources ...");
525 #endif /* VG_TRACE */
532 vg_TRACE_EXECUTION("main: making UI ...");
533 #endif /* VG_TRACE */
534 MakeBackground(); /* login_shell, table, matte */
535 MakeLogo(); /* logo, logo_pixmap, logo_shadow */
536 MakeGreeting(); /* greeting */
537 MakeLogin(); /* login_matte ... */
538 MakeDtlabel(); /* Show Desktop selection in options menu*/
541 * grab the display and keyboard...
542 * moved it from before to after creating text widgets in MakeLogin
548 MakeButtons(); /* ok, clear, options, help buttons */
549 MakeDialog(copyright); /* copyright dialog */
551 if (appInfo.optionsDelay == 0 )
552 MakeOptionsMenu(); /* make option_button pop-up menu */
554 XtAddTimeOut((unsigned long) appInfo.optionsDelay * 1000,
555 MakeOptionsProc, NULL);
557 MakeAltDtButtons(); /* make alt desktop buttons, if any */
559 vg_TRACE_EXECUTION("main: made UI ...");
560 #endif /* VG_TRACE */
563 * Add request callback.
564 XtAddInput(0, (XtPointer)XtInputReadMask, RequestCB, NULL);
568 * force the focus to the login_text widget...
571 XtAddEventHandler(login_text, ExposureMask, False,
576 * create windows for the widgets...
580 vg_TRACE_EXECUTION("main: going to realize login_shell ...");
581 #endif /* VG_TRACE */
582 XtRealizeWidget(login_shell);
584 vg_TRACE_EXECUTION("main: realized login_shell ...");
585 #endif /* VG_TRACE */
589 * miscellaneous stuff...
591 * - turn off keyboard bell
592 * - return root cursor to normal from hourglass
593 * - start pinging the server
597 if (appInfo.workspaceCursor)
603 XUndefineCursor(dpyinfo.dpy, dpyinfo.root);
605 PingServerCB(NULL, NULL);
609 * bring up the windows and enter event loop...
612 XRaiseWindow(XtDisplay(greeting), XtWindow(greeting));
614 XRaiseWindow(XtDisplay(logo_shadow), XtWindow(logo_shadow));
615 XRaiseWindow(XtDisplay(logo), XtWindow(logo));
617 /* XtPopup(login_shell, XtGrabNone); */
618 _DtEnvControl( DT_ENV_RESTORE_PRE_DT );
621 * Add request callback.
624 XtAddInput(0, (XtPointer)XtInputReadMask, RequestCB, NULL);
627 vg_TRACE_EXECUTION("main: entering XtMainLoop ...");
628 #endif /* VG_TRACE */
636 /***************************************************************************
640 * initialize the toolkit
641 ***************************************************************************/
643 #define MINTIMEOUT 20
645 static jmp_buf syncJump;
648 syncTimeout( int arg )
651 longjmp (syncJump, 1);
656 InitToolKit( int argc, char **argv )
659 int timeout; /* timeout to initialize toolkit */
664 vg_TRACE_EXECUTION("InitToolKit: enter ...");
665 #endif /* VG_TRACE */
668 * use server grabTimeout as initial value for timeout...
671 timeout = ((t = (char *)getenv(GRABTIMEOUT)) == NULL ? 0 : atoi(t));
672 timeout += MINTIMEOUT; /* minimum MINTIMEOUT seconds */
676 * initialize the toolkit. Wrap a timer around it in case the server
680 signal (SIGALRM, syncTimeout);
681 if (setjmp (syncJump)) {
683 ReadCatalog(MC_LOG_SET,MC_LOG_NO_DPYINIT,MC_DEF_LOG_NO_DPYINIT),
685 exit(NOTIFY_RESTART);
688 alarm ((unsigned) timeout);
690 root = XtInitialize("dtlogin", "Dtlogin", NULL, 0,
692 /* Disable Drag and Drop RK 11.02.93 */
693 XtVaSetValues(XmGetXmDisplay(XtDisplay(root)),
694 XmNdragInitiatorProtocolStyle, XmDRAG_NONE,
699 signal (SIGALRM, SIG_DFL);
707 /***************************************************************************
712 ***************************************************************************/
715 MakeRootCursor( void )
719 vg_cursor = XCreateFontCursor (dpyinfo.dpy, XC_left_ptr);
721 XDefineCursor (dpyinfo.dpy, dpyinfo.root, vg_cursor);
726 /***************************************************************************
730 * Widgets: login_shell, table, matte
731 ***************************************************************************/
734 MakeBackground( void )
739 vg_TRACE_EXECUTION("MakeBackground: entered ...");
740 #endif /* VG_TRACE */
742 * create the login shell widget...
747 /* CORE resource set */
748 XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
749 XtSetArg(argt[i], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP ); i++;
750 XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
751 XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
752 XtSetArg(argt[i], XmNsensitive, True ); i++;
753 XtSetArg(argt[i], XmNtranslations, NULL ); i++;
755 /* COMPOSITE resource set */
756 XtSetArg(argt[i], XmNinsertPosition, NULL ); i++;
758 /* SHELL resource set (set to avoid interference by user) */
759 XtSetArg(argt[i], XmNallowShellResize, False ); i++;
760 XtSetArg(argt[i], XmNcreatePopupChildProc, NULL ); i++;
761 XtSetArg(argt[i], XmNgeometry, NULL ); i++;
762 XtSetArg(argt[i], XmNpopupCallback, NULL ); i++;
763 XtSetArg(argt[i], XmNpopdownCallback, NULL ); i++;
764 XtSetArg(argt[i], XmNoverrideRedirect, False ); i++;
765 XtSetArg(argt[i], XmNsaveUnder, False ); i++;
767 login_shell = XtCreatePopupShell("login_shell", transientShellWidgetClass,
769 XtAddCallback(login_shell, XmNpopupCallback, LayoutCB, NULL);
771 /* Fix to display Input Method's status area. */
772 XtSetArg(argt[0], XmNheight, dpyinfo.height);
773 XtSetValues(login_shell, argt, 1);
777 * create the full-screen drawing area...
780 i = InitArg(DrawingA);
781 XtSetArg(argt[i], XmNwidth, dpyinfo.width ); i++;
782 XtSetArg(argt[i], XmNheight, dpyinfo.height ); i++;
783 XtSetArg(argt[i], XmNunitType, XmPIXELS ); i++;
785 table = XtCreateManagedWidget("table", xmDrawingAreaWidgetClass,
786 login_shell, argt, i);
788 XtAddEventHandler(table, ButtonPressMask, False, RefreshEH, NULL);
789 XtAddCallback(table, XmNhelpCallback, ShowDialogCB, (XtPointer) help);
793 * create the main matte...
797 /* XmNwidth, (set by user) */
798 /* XmNheight, (set by user) */
799 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
801 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
802 XtSetArg(argt[i], XmNshadowThickness, 5 ); i++;
805 matte = XmCreateForm(table, "matte", argt, i);
806 XtManageChild(matte);
809 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
810 XtSetArg(argt[i], XmNshadowThickness, 2); i++;
811 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
812 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
813 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
815 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
817 XtSetArg(argt[i], XmNtopOffset, 15); i++;
818 XtSetArg(argt[i], XmNbottomOffset, 15); i++;
819 XtSetArg(argt[i], XmNleftOffset, 15); i++;
821 XtSetArg(argt[i], XmNrightOffset, 15); i++;
823 matteFrame = XmCreateFrame(matte, "matteFrame", argt, i);
824 XtManageChild(matteFrame);
827 matte1 = XmCreateForm(matteFrame, "matte1", argt, i);
828 XtManageChild(matte1);
834 MakeAltDtButtons( void )
839 XrmValue startup_value;
840 char temp[MAXPATHLEN] = "\0";
843 char lastsess[MAXPATHLEN];
844 Widget default_dt = NULL;
845 int default_is_custom_dt = True;
846 int found_alt_dt = False;
851 vg_TRACE_EXECUTION("MakeAltDtButtons: entered ...");
852 #endif /* VG_TRACE */
854 if (getenv("SESSION_SET") == NULL) {
855 default_is_custom_dt = False;
858 if ((session = getenv ("SESSION")) == NULL) {
862 if(appInfo.altDts > 0) {
864 (Widget *) calloc(appInfo.altDts, sizeof (Widget))) == NULL)
866 ReadCatalog(MC_ERROR_SET,MC_NO_MEMORY, MC_DEF_NO_MEMORY),
869 for(i = 0; i < appInfo.altDts; ++i) {
874 /* alt desktops begin numbering with 1 */
875 sprintf(altdtname,"%s%d", "Dtlogin*altDtName",i+1);
876 sprintf(altdtclass,"%s%d", "Dtlogin*AltDtName",i+1);
878 sprintf(altdtkey,"%s%d","Dtlogin*altDtKey",i+1);
879 sprintf(altdtkeyclass,"%s%d","Dtlogin*AltDtKey",i+1);
881 sprintf(altdtstart,"%s%d","Dtlogin*altDtStart",i+1);
882 sprintf(altdtstartclass,"%s%d","Dtlogin*AltDtStart",i+1);
885 XtDatabase(dpyinfo.dpy),
886 altdtkey, altdtkeyclass,
887 &keyrmtype, &keyrmvalue) == True) {
889 * remove trailing spaces
891 if(strchr(keyrmvalue.addr,' '))
892 temp_p = strtok(keyrmvalue.addr," ");
894 temp_p = keyrmvalue.addr;
897 * Make sure the key file exists.
899 if (stat( temp_p, &statb) == NULL) {
901 j = InitArg(ToggleBG);
903 XtDatabase(dpyinfo.dpy),
904 altdtstart, altdtstartclass,
905 &startup_name, &startup_value) == True) {
908 * remove trailing spaces
910 if (strchr(startup_value.addr, ' '))
911 strcpy(temp, strtok(startup_value.addr," "));
913 strcpy(temp, startup_value.addr);
915 if (default_is_custom_dt)
916 if (strcmp(session, temp) == 0) {
921 LogError((unsigned char *)"No startup script for altdt %d \n", i);
924 XtDatabase(dpyinfo.dpy),
925 altdtname, altdtclass,
926 &rmtype, &rmvalue) == True) {
927 if (! strncmp(rmvalue.addr, DISPLAYNAME, strlen(DISPLAYNAME))) {
930 host = GetDisplayName();
933 strcat(temp, rmvalue.addr + strlen(DISPLAYNAME));
934 xmstr = XmStringCreateLocalized(temp);
937 xmstr = XmStringCreateLocalized(rmvalue.addr);
941 LogError((unsigned char *)
942 "Couldn't find the altdtname resource in the db\n");
943 sprintf(altdtname,"%s%d", "Alternate Desktop-",i+1);
944 xmstr = XmStringCreateLocalized(altdtname);
947 sprintf(altdtlogo,"%s%d","Dtlogin*altDtLogo",i+1);
948 sprintf(altlogoclass,"%s%d","Dtlogin*AltDtLogo",i+1);
950 XtDatabase(dpyinfo.dpy),
951 altdtlogo, altlogoclass,
952 &logotype, &logovalue) == True) {
953 XtSetArg(argt[j], XmNuserData, logovalue.addr); j++;
956 XtSetArg(argt[j], XmNuserData, logoInfo.bitmapFile); j++;
959 XtSetArg(argt[j], XmNlabelString, xmstr); j++;
960 XtSetArg(argt[j], XmNrecomputeSize, True); j++;
962 alt_dts[i] = XmCreateToggleButtonGadget(
964 rmvalue.addr, argt, j);
968 XmNvalueChangedCallback, MenuItemCB,
969 (XtPointer) OB_ALT_DTS);
970 XtManageChild(alt_dts[i]);
974 default_dt = alt_dts[i];
977 LogError((unsigned char *) "Couldn't find the keyfile \n");
980 LogError((unsigned char *)
981 "Couldn't find the altkeyfile resource in the database\n");
985 if ((appInfo.altDts == 0) || !found_alt_dt)
986 XtManageChild(options_dt);
989 * Use the regular desktop if none of the known sessions matched the
990 * specified custom session.
992 if (default_is_custom_dt && NULL == default_dt) {
993 default_dt = options_dt;
995 XtManageChild(options_dt);
999 * [ Failsafe Session ] menu pane...
1001 i = InitArg(ToggleBG);
1002 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_FS_LABEL, MC_DEF_FS_LABEL);
1003 XtSetArg(argt[i], XmNuserData, logoInfo.bitmapFile ); i++;
1004 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1005 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1006 options_failsafe = XmCreateToggleButtonGadget(session_menu,
1007 "options_failsafe", argt, i);
1008 XmStringFree(xmstr);
1009 XtAddCallback(options_failsafe, XmNvalueChangedCallback,
1010 MenuItemCB, (XtPointer) OB_FAILSAFE);
1012 XtManageChild(options_failsafe);
1015 * which option to set..
1017 SetDefaultDt(default_dt);
1018 SetDtLabelAndIcon();
1021 /***************************************************************************
1025 * Widgets: ok_button, clear_button, options_button, help_button
1026 ***************************************************************************/
1034 Dimension max_width; /* maximum width of a set of widgets */
1035 Dimension max_height; /* maximum height of a set of widgets */
1036 Dimension thick1; /* defaultButtonShadowThickness */
1037 Dimension thick2; /* shadowThickness */
1039 int origin; /* horizontal origin for button placement */
1040 int spacing; /* spacing between buttons (width/32) */
1043 vg_TRACE_EXECUTION("MakeButtons: entered ...");
1044 #endif /* VG_TRACE */
1047 * create the buttons...
1052 i = InitArg(PushBG);
1053 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1054 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
1055 XtSetArg(argt[i], XmNtraversalOn, True); i++;
1057 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL );
1058 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1060 ok_button = XmCreatePushButtonGadget(matte1, "ok_button", argt, i);
1062 XmStringFree(xmstr);
1063 XtManageChild(ok_button);
1065 XtAddCallback(ok_button, XmNactivateCallback, RespondChallengeCB, NULL);
1071 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_CLEAR_LABEL, MC_DEF_CLEAR_LABEL);
1072 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1074 clear_button = XmCreatePushButtonGadget(matte1, "clear_button", argt, i);
1076 XmStringFree(xmstr);
1077 XtManageChild(clear_button);
1078 XtAddCallback(clear_button, XmNactivateCallback, RespondClearCB,
1085 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
1086 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1088 help_button = XmCreatePushButtonGadget(matte1, "help_button", argt, i);
1089 XtAddCallback(help_button, XmNactivateCallback, ShowDialogCB,
1091 XmStringFree(xmstr);
1092 XtManageChild(help_button);
1094 /* options button */
1097 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1098 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
1099 xmstr = ReadCatalogXms(
1102 MC_DEF_OPTIONS_LABEL );
1104 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
1105 XtSetArg(argt[i], XmNtraversalOn, True); i++;
1106 options_button = DtCreateMenuButton(matte1, "options_button", argt, i);
1107 XtOverrideTranslations(
1109 XtParseTranslationTable(" <Key> Return: Select()"));
1111 XtManageChild(options_button);
1112 XmStringFree(xmstr);
1115 * tell form that ok_button is the default button...
1119 XtSetArg(argt[i], XmNdefaultButton, ok_button ); i++;
1120 XtSetValues(matte1, argt, i);
1123 * make all buttons *look* the same size...
1127 max_width = max_height = 0;
1128 GetBiggest(ok_button, &max_width, &max_height);
1129 GetBiggest(clear_button, &max_width, &max_height);
1130 GetBiggest(options_button, &max_width, &max_height);
1131 GetBiggest(help_button, &max_width, &max_height);
1133 if ( (int) max_width < MIN_BUTTON_SIZE) max_width = MIN_BUTTON_SIZE;
1136 XtSetArg(argt[i], XmNdefaultButtonShadowThickness, &thick1); i++;
1137 XtSetArg(argt[i], XmNshadowThickness, &thick2); i++;
1138 XtGetValues(ok_button, argt, i);
1143 XtSetArg(argt[i], XmNwidth, max_width ); i++;
1144 XtSetArg(argt[i], XmNheight, max_height ); i++;
1145 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1146 XtSetArg(argt[i], XmNbottomOffset, thick1 ); i++;
1147 XtSetValues(options_button, argt, i);
1150 XtSetArg(argt[i], XmNwidth, max_width + 2*thick1 ); i++;
1151 XtSetArg(argt[i], XmNheight, max_height + 2*thick1 ); i++;
1152 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1154 XtSetValues(ok_button, argt, i);
1155 XtSetValues(clear_button, argt, i);
1156 XtSetValues(help_button, argt, i);
1162 /***************************************************************************
1166 * Widgets: error_message, help_message, copyright_msg, hostname_message,
1168 ***************************************************************************/
1171 MakeDialog( DialogType dtype )
1181 Dimension txt_width, txt_height;
1182 XmString ok, cancel, nw, sv;
1186 vg_TRACE_EXECUTION("MakeDialog: entered ...");
1187 #endif /* VG_TRACE */
1189 * do things common to all dialogs...
1192 ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
1193 cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
1195 i = InitArg(MessageBox);
1196 XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++;
1197 XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++;
1198 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
1199 XtSetArg(argt[i], XmNokLabelString, ok ); i++;
1200 XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++;
1201 XtSetArg(argt[i], XmNnoResize, False ); i++;
1202 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
1205 * create the various dialogs...
1211 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
1212 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1214 w = XmCreateErrorDialog(table, "error_message", argt, i);
1215 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1216 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1224 txt_width = (dpyinfo.width > 850) ? 800 : dpyinfo.width - 50;
1225 txt_height = (dpyinfo.height > 900) ? 600 : dpyinfo.height - 300;
1227 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
1228 XtSetArg(argt[i], XmNmessageString, xmstr); i++;
1230 w = XmCreateInformationDialog(table, "help_message", argt, i);
1231 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1232 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1235 XtSetArg(argt[i], XmNheight, txt_height); i++;
1236 XtSetArg(argt[i], XmNwidth, txt_width); i++;
1237 XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
1238 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
1239 XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
1240 XtSetArg(argt[i], XmNeditable, False); i++;
1243 XmNvalue, ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP)); i++;
1244 text = XmCreateScrolledText(w, "help_message_text", argt, i);
1246 XtManageChild(text);
1253 if ((fp = fopen(COPYRIGHT,"r")) == NULL)
1254 #if defined( __hp_osf )
1255 xmstr = XmStringCreate("Cannot open copyright file '/usr/X11/copyright'.",
1256 XmFONTLIST_DEFAULT_TAG);
1258 xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
1259 XmFONTLIST_DEFAULT_TAG);
1262 xmstr = (XmString) NULL;
1264 while (fgets(buffer, 128, fp) != NULL) {
1266 if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
1268 if ( xmstr != NULL )
1269 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
1271 xmstr = XmStringConcat(xmstr,
1272 XmStringCreate(buffer,
1273 XmFONTLIST_DEFAULT_TAG));
1278 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1280 w = XmCreateInformationDialog(table, "copyright_msg", argt, i);
1281 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1282 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1284 XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);
1292 nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
1293 sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);
1295 xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
1296 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1297 XtSetArg(argt[i], XmNokLabelString, nw ); i++;
1298 XtSetArg(argt[i], XmNcancelLabelString, sv ); i++;
1300 w = XmCreateWarningDialog(table, "hostname_msg", argt, i);
1302 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1307 hostname_message = w;
1313 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED,
1314 MC_DEF_PASSWD_EXPIRED);
1315 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1317 w = XmCreateQuestionDialog(table, "password_msg", argt, i);
1319 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1333 XtAddCallback(w, XmNokCallback, RespondDialogCB, NULL);
1334 XtAddCallback(w, XmNcancelCallback, RespondDialogCB, NULL);
1339 XtSetArg(argt[0], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); i++;
1340 XtSetValues(w, argt, 1);
1342 XmStringFree(xmstr);
1344 XmStringFree(cancel);
1348 * adjust the width of the "ok" button on the dialogs...
1351 width = (dtype == hostname ? FromMM(4000) : MIN_BUTTON_SIZE);
1354 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1355 XtSetArg(argt[i], XmNwidth, width ); i++;
1357 XtSetValues(XmMessageBoxGetChild(w, XmDIALOG_OK_BUTTON), argt, i);
1361 /***************************************************************************
1366 ***************************************************************************/
1374 vg_TRACE_EXECUTION("MakeDtlabel: entered ...");
1375 #endif /* VG_TRACE */
1377 i = InitArg(LabelG);
1378 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1379 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET ); i++;
1380 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM ); i++;
1381 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM ); i++;
1382 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;
1383 XtSetArg(argt[i], XmNtopWidget, greeting ); i++;
1385 dt_label = XmCreateLabel(matte1, "dt_label", argt, i);
1386 XtManageChild(dt_label);
1391 /***************************************************************************
1396 ***************************************************************************/
1399 char *labelString; /* string for label */
1400 char *persLabelString; /* alternate string for label */
1401 XmFontList fontList;
1402 } GreetInfo, *GreetInfoPtr;
1404 static GreetInfo greetInfo;
1406 static XtResource greetResources[] = {
1407 {XmNlabelString, XmCLabelString,
1408 XmRString, sizeof(char *),
1409 XtOffset(GreetInfoPtr, labelString), XtRString, "default" },
1411 {"persLabelString", "PersLabelString",
1412 XmRString, sizeof(char *),
1413 XtOffset(GreetInfoPtr, persLabelString), XtRString, "default" },
1415 {XmNfontList, XmCFontList,
1416 XmRFontList, sizeof(XmFontList),
1417 XtOffset(GreetInfoPtr, fontList), XtRString, NULL }
1421 MakeGreeting( void )
1428 char *p, *q, *s, *t;
1429 int newLine = False;
1433 vg_TRACE_EXECUTION("MakeGreeting: entered ...");
1434 #endif /* VG_TRACE */
1437 * get the user's greeting preferences...
1440 XtGetSubresources(table, &greetInfo, "greeting", "Greeting",
1441 greetResources, XtNumber(greetResources), NULL, 0);
1445 * get the local hostname...
1448 gethostname(host, sizeof (host));
1449 if ( (p = strchr(host,'.')) != NULL )
1453 ** Get display name (for %DisplayName% substitutions),
1454 ** reducing "a.b.c.d:0" constructs to shorter "a:0" form.
1458 dpyinfo.name ? dpyinfo.name : (DisplayString(dpyinfo.dpy)), 127);
1460 p = strchr(disp, '.');
1461 t = strchr(disp, ':');
1462 if (p && t) strcpy(p,t);
1466 * use the default string if the user has not specified one...
1469 if ( greetInfo.persLabelString &&
1470 strcmp(greetInfo.persLabelString, "default") == 0 ) {
1474 ReadCatalog(MC_LABEL_SET,MC_PERS_GREET_LABEL,MC_DEF_PERS_GREET_LABEL);
1475 greetInfo.persLabelString = strdup(msg);
1478 if ( greetInfo.labelString &&
1479 strcmp(greetInfo.labelString, "default") == 0 ) {
1481 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_GREET_LABEL,MC_DEF_GREET_LABEL);
1482 xmstr = XmStringConcat(xmstr,
1483 XmStringCreate(" ", XmFONTLIST_DEFAULT_TAG));
1484 xmstr = XmStringConcat(xmstr,
1485 XmStringCreate(host, XmFONTLIST_DEFAULT_TAG));
1489 * scan user's message for %LocalHost% token. Replace with hostname
1494 if ( strlen(greetInfo.labelString) == 0 ||
1495 strcmp(greetInfo.labelString, "None") == 0 ||
1496 strcmp(greetInfo.labelString, "none") == 0 )
1498 greetmsg = strdup(" ");
1500 greetmsg = strdup(greetInfo.labelString);
1504 xmstr = (XmString) NULL;
1510 * scan for a new line character in remaining label string.
1511 * If found, work with that substring first...
1514 if ( (p = strchr(q, '\n')) != NULL ) {
1519 if ( *q == '\0' ) /* handle consecutive newlines */
1528 * replace all occurrances of %LocalHost% and %DisplayName%
1529 * in the current substring...
1533 p = strstr(q, LOCALHOST);
1534 t = strstr(q, DISPLAYNAME);
1536 if (p && t) { /* both present? do whichever comes first */
1537 if (p > t) p = NULL;
1540 if (p) { /* replace a %LocalHost% string */
1542 skip = sizeof(LOCALHOST);
1543 } else if (t) { /* replace a %DisplayName% string */
1546 skip = sizeof(DISPLAYNAME);
1547 } else /* nothing left to replace */
1550 xmstr = XmStringConcat(xmstr,
1552 XmFONTLIST_DEFAULT_TAG));
1553 xmstr = XmStringConcat(xmstr,
1555 XmFONTLIST_DEFAULT_TAG));
1559 if ( strlen(q) != 0 )
1560 xmstr = XmStringConcat(xmstr,
1562 XmFONTLIST_DEFAULT_TAG));
1565 * add a line seperator if this is a multi-line greeting...
1568 if ( newLine == True ) {
1569 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
1572 } while ( newLine == True ) ;
1579 * create the Welcome message...
1582 i = InitArg(LabelG);
1583 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1584 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1585 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
1586 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_POSITION); i++;
1587 /* XtSetArg(argt[i], XmNtopPosition, 15); i++; */
1588 /* Changed this to accomodate desktop label */
1589 XtSetArg(argt[i], XmNtopPosition, 9); i++;
1590 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
1594 * use the user's font if one has been specified, otherwise use
1595 * the application's default...
1598 if ( greetInfo.fontList != NULL ) {
1599 XtSetArg(argt[i], XmNfontList, greetInfo.fontList ); i++;
1602 greeting = XmCreateLabel(matte1, "greeting", argt, i);
1603 XtManageChild(greeting);
1605 XmStringFree(xmstr);
1608 /***************************************************************************
1612 * Widgets: login_matte,
1613 * login_form, login_label, login_text
1614 ***************************************************************************/
1621 LoginTextPtr textdata;
1622 XtTranslations textTable;
1627 vg_TRACE_EXECUTION("MakeLogin: entered ...");
1628 #endif /* VG_TRACE */
1631 * create the login form
1635 XtSetArg(argt[i], XmNshadowThickness, 0); i++;
1636 XtSetArg(argt[i], XmNresizable, False ); i++;
1637 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
1638 XtSetArg(argt[i], XmNleftOffset, 80); i++;
1639 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
1640 XtSetArg(argt[i], XmNrightOffset, 80); i++;
1641 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1642 XtSetArg(argt[i], XmNbottomPosition, 65); i++;
1644 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY); i++;
1646 XtSetArg(argt[i], XmNallowShellResize, True); i++;
1648 login_form = XmCreateForm(matte1, "login_form", argt, i);
1649 XtManageChild(login_form);
1652 * create the login text field...
1656 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION ); i++;
1657 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_POSITION ); i++;
1658 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_POSITION ); i++;
1659 XtSetArg(argt[i], XmNbottomPosition, 95 ); i++;
1660 XtSetArg(argt[i], XmNrightPosition, 80 ); i++;
1661 XtSetArg(argt[i], XmNleftPosition, 20 ); i++;
1662 XtSetArg(argt[i], XmNselectionArrayCount, 1 ); i++;
1663 XtSetArg(argt[i], XmNmaxLength, 80 ); i++;
1664 XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
1666 textdata = malloc(sizeof(LoginText));
1667 XtSetArg(argt[i], XmNuserData, textdata ); i++;
1669 login_text = XmCreateTextField(login_form, "login_text", argt, i);
1672 * From Human Interface model, Tab key operation should work same on
1673 * user field as it does on password field. Password field is setup
1674 * to take Tab key as password data. HIE model is for user field to
1677 XtOverrideTranslations(
1679 XtParseTranslationTable(
1680 " Shift <Key>Tab: prev-tab-group() \n\
1681 Ctrl <Key>Tab: next-tab-group() "));
1683 XtManageChild(login_text);
1685 XtAddCallback(login_text, XmNfocusCallback, TextFocusCB, NULL);
1689 XtAddActions(textActions, 2);
1690 textTable = XtParseTranslationTable(textEventBindings);
1693 XtSetArg(argt[i], XmNtranslations, textTable ); i++;
1695 XtSetArg(argt[i], XmNverifyBell, False ); i++;
1697 passwd_text = XmCreateTextField(login_form, "passwd_text", argt, i);
1699 textdata->bEcho = True;
1700 textdata->noechobuf[0] = '\0';
1701 textdata->text[0] = passwd_text;
1702 textdata->text[1] = login_text;
1704 XtManageChild(passwd_text);
1706 XtAddCallback(passwd_text, XmNfocusCallback, TextFocusCB, NULL);
1708 XtAddCallback(passwd_text, XmNmodifyVerifyCallback, EditPasswdCB, NULL);
1711 * Get default greeting string
1714 XtSetArg(argt[i], XmNlabelString, &textdata->onGreeting); i++;
1715 XtGetValues(greeting, argt, i);
1716 textdata->offGreetingFormat = greetInfo.persLabelString;
1717 textdata->offGreetingUname = NULL;
1720 * create the login labels...
1723 i = InitArg(LabelG);
1725 /* modified recomputeSize initial value from False to True, fails
1726 * when setting longer strings. Manifested as bug ID:1200690.
1728 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1730 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1731 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET ); i++;
1732 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
1734 /* XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM ); i++;
1735 Commented this statement to align login_label and login_text
1736 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM ); i++;
1737 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;
1738 XtSetArg(argt[i], XmNbottomOffset, 10 ); i++;
1741 XtSetArg(argt[i], XmNleftWidget, login_text ); i++;
1742 XtSetArg(argt[i], XmNbottomWidget, login_text ); i++;
1746 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LOGIN_LABEL, MC_DEF_LOGIN_LABEL);
1747 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1749 login_label = XmCreateLabel(login_form, "login_label", argt, i);
1750 XtManageChild(login_label);
1752 XmStringFree(xmstr);
1759 /***************************************************************************
1763 * Widgets: options_menu, options_item[]
1764 ***************************************************************************/
1767 MakeOptionsMenu( void )
1774 vg_TRACE_EXECUTION("MakeOptionsMenu: entered ...");
1775 #endif /* VG_TRACE */
1778 * get the built-in pop_up menu from the DtMenuButton...
1781 XtVaGetValues(options_button, DtNsubMenuId, &options_menu, NULL);
1784 * create language cascade menus...
1787 if ( lang_menu == NULL )
1792 * create first level menu items...
1797 * build [ Language ] menu pane if there are languages to choose from...
1799 if ( lang_menu != NULL ) {
1801 * [ Language ] menu pane...
1802 * attach language cascade menu to this pane
1804 i = InitArg(CascadeBG);
1805 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LANG_LABEL, MC_DEF_LANG_LABEL);
1806 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1807 XtSetArg(argt[i], XmNsubMenuId, lang_menu ); i++;
1808 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1809 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
1810 "options_languages", argt, i);
1811 XmStringFree(xmstr);
1817 i = InitArg(SeparatorG);
1818 options_item[j] = XmCreateSeparatorGadget(options_menu,
1824 if( session_menu == NULL) {
1825 session_menu = XmCreatePulldownMenu(options_menu, "session_menu", NULL, 0);
1829 * [ Dt "Reg" ] menu pane...
1831 i = k = InitArg(ToggleBG);
1832 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_DT_LABEL, MC_DEF_DT_LABEL);
1833 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1834 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1835 XtSetArg(argt[i], XmNuserData, logoInfo.bitmapFile ); i++;
1837 options_dt = XmCreateToggleButtonGadget(session_menu,
1840 XmStringFree(xmstr);
1841 XtAddCallback(options_dt,
1842 XmNvalueChangedCallback,
1845 /*XtManageChild(options_dt); */
1847 * [ Dt Lite ] menu pane...
1850 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_DTLITE_LABEL, MC_DEF_DTLITE_LABEL);
1851 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1852 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1854 options_dtlite = XmCreateToggleButtonGadget(session_menu,
1857 XmStringFree(xmstr);
1858 XtAddCallback(options_dtlite,
1859 XmNvalueChangedCallback,
1861 (XtPointer) OB_DTLITE);
1866 if ( session_menu != NULL ) {
1868 * [ Language ] menu pane...
1869 * attach language cascade menu to this pane
1871 i = InitArg(CascadeBG);
1872 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_SES_LABEL, MC_DEF_SES_LABEL);
1873 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1874 XtSetArg(argt[i], XmNsubMenuId, session_menu ); i++;
1875 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1876 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
1877 "session_menus", argt, i);
1878 XmStringFree(xmstr);
1884 i = InitArg(SeparatorG);
1885 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
1897 * [ No Windows ] menu pane...
1899 i = k = InitArg(PushBG);
1900 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
1901 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1902 options_item[j] = options_nowindows
1903 = XmCreatePushButtonGadget(options_menu,
1904 "options_noWindows",
1906 XmStringFree(xmstr);
1907 XtAddCallback(options_item[j], XmNactivateCallback,
1908 MenuItemCB, (XtPointer) OB_NO_WINDOWS);
1910 if (getenv(LOCATION) == NULL || strcmp(getenv(LOCATION), "local") != 0 )
1911 XtSetSensitive(options_item[j], False);
1917 * [ Restart Server ] menu pane...
1919 i = k = InitArg(PushBG);
1920 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_RS_LABEL, MC_DEF_RS_LABEL);
1921 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1922 options_item[j] = XmCreatePushButtonGadget(options_menu,
1923 "options_restartServer",
1925 XmStringFree(xmstr);
1926 XtAddCallback(options_item[j], XmNactivateCallback,
1927 MenuItemCB, (XtPointer) OB_RESTART_SERVER);
1930 #ifdef copyright_option
1934 i = InitArg(SeparatorG);
1935 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
1941 * [ Copyright ] menu pane...
1943 i = k = InitArg(PushBG);
1944 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_COPY_LABEL, MC_DEF_COPY_LABEL);
1945 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1946 options_item[j] = XmCreatePushButtonGadget(options_menu,
1947 "options_copyright",
1949 XmStringFree(xmstr);
1950 XtAddCallback(options_item[j], XmNactivateCallback,
1951 MenuItemCB, (XtPointer) OB_COPYRIGHT);
1956 * manage the [Options] menu...
1958 XtManageChildren(options_item, j);
1963 * If the DT Lite Session Manager is not available, remove the DT Lite
1964 * and DT menu panes. The actual widgets must still be created since
1965 * other code (ex. MenuItemCB()) tries to obtain some of their resources.
1968 if ( stat(DTLITESESSION, &statb) != 0 ||
1969 ((statb.st_mode & S_IXOTH) != S_IXOTH) ) {
1971 XtUnmanageChild(options_dtlite);
1973 XtUnmanageChild(options_dt);
1977 if ( getenv(PINGINTERVAL) != NULL )
1978 XtUnmanageChild(options_nowindows);
1986 /***************************************************************************
1990 * Local self-insert action for the text widget. The default action
1991 * discards control characters, which are allowed in password.
1992 ***************************************************************************/
1995 MyInsert( Widget w, XEvent *event, char **params, Cardinal *num_params )
1998 XComposeStatus compstatus;
2001 n = XLookupString((XKeyEvent *)event, str, sizeof(str),
2002 (KeySym *)NULL, &compstatus);
2006 XmTextFieldInsert(w, XmTextFieldGetInsertionPosition(w), str);
2010 /***************************************************************************
2014 * Local backspace action for the text widget.
2015 * Deletes the last character of the password string in the
2016 * widget for each backspace key press, and also does not move the cursor
2017 * position in the widget.
2018 ***************************************************************************/
2021 MyBackspace( Widget w, XEvent *event, char **params, Cardinal *num_params )
2023 LoginTextPtr textdata;
2025 textdata = GetLoginTextPtr(w);
2027 if (textdata && !textdata->bEcho && (int) strlen(textdata->noechobuf) > 0)
2029 textdata->noechobuf[strlen(textdata->noechobuf) - 1] = '\0';
2034 /***************************************************************************
2038 * X protocol error handler to override the default
2039 ***************************************************************************/
2042 ErrorHandler( Display *dpy, XErrorEvent *event )
2050 /***************************************************************************
2054 * Xt protocol error handler to override the default
2055 ***************************************************************************/
2058 xtErrorHandler( String msg )
2060 LogError((unsigned char *) "%s\n", msg ) ;
2061 exit(NOTIFY_RESTART);
2067 /***************************************************************************
2071 * Xt protocol error handler to override the default
2072 ***************************************************************************/
2075 xtWarningHandler( String msg )
2077 LogError( (unsigned char *) "%s\n", msg ) ;
2084 /***************************************************************************
2088 * Timeout routine to build options menu
2089 ***************************************************************************/
2092 MakeOptionsProc( XtPointer data, XtIntervalId *id )
2095 if (options_menu == NULL)
2104 /***************************************************************************
2108 * Catch a SIGTERM and unmanage display
2109 ***************************************************************************/
2112 Terminate( int arg )
2115 write(1, "terminate", 9);
2116 CleanupAndExit(NULL, NOTIFY_ABORT);
2122 /***************************************************************************
2124 * DebugWidgetResources
2126 * Get widget resources
2127 ***************************************************************************/
2129 typedef struct resource_values {
2134 int rightAttachment;
2137 int bottomAttachment;
2141 DebugWidgetResources(Widget w)
2144 struct resource_values values;
2148 bzero((char *) &values, sizeof(values));
2149 XtSetArg(argt[i], XmNheight, &values.height); i++;
2150 XtSetArg(argt[i], XmNwidth, &values.width); i++;
2151 XtSetArg(argt[i], XmNx, &values.x); i++;
2152 XtSetArg(argt[i], XmNy, &values.y); i++;
2153 XtSetArg(argt[i], XmNrightAttachment, &values.rightAttachment); i++;
2154 XtSetArg(argt[i], XmNleftAttachment, &values.leftAttachment); i++;
2155 XtSetArg(argt[i], XmNtopAttachment, &values.topAttachment); i++;
2156 XtSetArg(argt[i], XmNbottomAttachment, &values.bottomAttachment); i++;
2158 XtGetValues(w, argt, i);
2162 /***************************************************************************
2164 * GetDisplayName (void) - transform the display name into a "short"
2165 * host name that is used to create a display-specific session.
2167 * The display name should match one of the following patterns:
2169 * 1. host (non-qualified)
2174 * 6. host.domain:n.s
2176 * Note that 1 and 2 will be used if the display name is actually
2177 * something like unix:0, local:0 or 0:0
2179 ***************************************************************************/
2181 GetDisplayName (void)
2183 char host[MAXHOSTNAMELEN];
2184 static char tmp[MAXHOSTNAMELEN + 3];
2189 pch = XDisplayString(dpyinfo.dpy);
2192 !strncmp (pch, "local:0", 7) ||
2193 !strncmp (pch, "unix:0", 6) ||
2194 !strncmp (pch, ":0.0", 4) ||
2195 !strncmp (pch, ":0", 2)) {
2196 gethostname (host, MAXHOSTNAMELEN);
2200 col = strchr (pch, ':');
2201 dot = strchr (pch, '.');
2205 strncpy (tmp, pch, dot - pch); /* case #2 above */
2206 tmp[dot - pch] = '\000';
2208 strcpy (tmp, pch); /* case #1 above */
2211 if (!dot || (dot > col)) { /* case #3 and 4 above */
2212 strncpy (tmp, pch, col - pch);
2213 tmp[col - pch] = '\000';
2214 } else { /* case # 5 and 6 above */
2215 strncpy (tmp, pch, dot - pch);
2216 tmp[dot - pch] = '\000';