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 libraries 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 snprintf(temp, sizeof(temp), "%s", strtok(startup_value.addr, " "));
945 snprintf(temp, sizeof(temp), "%s", 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();
963 snprintf(temp, sizeof(temp), "%s - %s", host, rmvalue.addr + strlen(DISPLAYNAME));
964 xmstr = XmStringCreateLocalized(temp);
967 xmstr = XmStringCreateLocalized(rmvalue.addr);
971 LogError((unsigned char *)
972 "Couldn't find the altdtname resource in the db\n");
973 sprintf(altdtname,"%s%d", "Alternate Desktop-",i+1);
974 xmstr = XmStringCreateLocalized(altdtname);
977 sprintf(altdtlogo,"%s%d","Dtlogin*altDtLogo",i+1);
978 sprintf(altlogoclass,"%s%d","Dtlogin*AltDtLogo",i+1);
980 XtDatabase(dpyinfo.dpy),
981 altdtlogo, altlogoclass,
982 &logotype, &logovalue) == True) {
983 XtSetArg(argt[j], XmNuserData, logovalue.addr); j++;
986 XtSetArg(argt[j], XmNuserData, logoInfo.bitmapFile); j++;
989 XtSetArg(argt[j], XmNlabelString, xmstr); j++;
990 XtSetArg(argt[j], XmNrecomputeSize, True); j++;
992 alt_dts[i] = XmCreateToggleButtonGadget(
994 rmvalue.addr, argt, j);
998 XmNvalueChangedCallback, MenuItemCB,
999 (XtPointer) OB_ALT_DTS);
1000 XtManageChild(alt_dts[i]);
1001 found_alt_dt = True;
1004 default_dt = alt_dts[i];
1007 LogError((unsigned char *) "Couldn't find the keyfile \n");
1010 LogError((unsigned char *)
1011 "Couldn't find the altkeyfile resource in the database\n");
1015 if ((appInfo.altDts == 0) || !found_alt_dt)
1016 XtManageChild(options_dt);
1019 * Use the regular desktop if none of the known sessions matched the
1020 * specified custom session.
1022 if (default_is_custom_dt && NULL == default_dt) {
1023 default_dt = options_dt;
1025 XtManageChild(options_dt);
1029 * [ Failsafe Session ] menu pane...
1031 i = InitArg(ToggleBG);
1032 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_FS_LABEL, MC_DEF_FS_LABEL);
1033 XtSetArg(argt[i], XmNuserData, logoInfo.bitmapFile ); i++;
1034 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1035 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1036 options_failsafe = XmCreateToggleButtonGadget(session_menu,
1037 "options_failsafe", argt, i);
1038 XmStringFree(xmstr);
1039 XtAddCallback(options_failsafe, XmNvalueChangedCallback,
1040 MenuItemCB, (XtPointer) OB_FAILSAFE);
1042 XtManageChild(options_failsafe);
1045 * which option to set..
1047 SetDefaultDt(default_dt);
1048 SetDtLabelAndIcon();
1051 /***************************************************************************
1055 * Widgets: ok_button, clear_button, options_button, help_button
1056 ***************************************************************************/
1064 Dimension max_width; /* maximum width of a set of widgets */
1065 Dimension max_height; /* maximum height of a set of widgets */
1066 Dimension thick1; /* defaultButtonShadowThickness */
1067 Dimension thick2; /* shadowThickness */
1069 int origin; /* horizontal origin for button placement */
1070 int spacing; /* spacing between buttons (width/32) */
1073 vg_TRACE_EXECUTION("MakeButtons: entered ...");
1074 #endif /* VG_TRACE */
1077 * create the buttons...
1082 i = InitArg(PushBG);
1083 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1084 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
1085 XtSetArg(argt[i], XmNtraversalOn, True); i++;
1087 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL );
1088 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1090 ok_button = XmCreatePushButtonGadget(matte1, "ok_button", argt, i);
1092 XmStringFree(xmstr);
1093 XtManageChild(ok_button);
1095 XtAddCallback(ok_button, XmNactivateCallback, RespondChallengeCB, NULL);
1101 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_CLEAR_LABEL, MC_DEF_CLEAR_LABEL);
1102 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1104 clear_button = XmCreatePushButtonGadget(matte1, "clear_button", argt, i);
1106 XmStringFree(xmstr);
1107 XtManageChild(clear_button);
1108 XtAddCallback(clear_button, XmNactivateCallback, RespondClearCB,
1115 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
1116 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1118 help_button = XmCreatePushButtonGadget(matte1, "help_button", argt, i);
1119 XtAddCallback(help_button, XmNactivateCallback, ShowDialogCB,
1121 XmStringFree(xmstr);
1122 XtManageChild(help_button);
1124 /* options button */
1127 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1128 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
1129 xmstr = ReadCatalogXms(
1132 MC_DEF_OPTIONS_LABEL );
1134 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
1135 XtSetArg(argt[i], XmNtraversalOn, True); i++;
1136 options_button = DtCreateMenuButton(matte1, "options_button", argt, i);
1137 XtOverrideTranslations(
1139 XtParseTranslationTable(" <Key> Return: Select()"));
1141 XtManageChild(options_button);
1142 XmStringFree(xmstr);
1145 * tell form that ok_button is the default button...
1149 XtSetArg(argt[i], XmNdefaultButton, ok_button ); i++;
1150 XtSetValues(matte1, argt, i);
1153 * make all buttons *look* the same size...
1157 max_width = max_height = 0;
1158 GetBiggest(ok_button, &max_width, &max_height);
1159 GetBiggest(clear_button, &max_width, &max_height);
1160 GetBiggest(options_button, &max_width, &max_height);
1161 GetBiggest(help_button, &max_width, &max_height);
1163 if ( (int) max_width < MIN_BUTTON_SIZE) max_width = MIN_BUTTON_SIZE;
1166 XtSetArg(argt[i], XmNdefaultButtonShadowThickness, &thick1); i++;
1167 XtSetArg(argt[i], XmNshadowThickness, &thick2); i++;
1168 XtGetValues(ok_button, argt, i);
1173 XtSetArg(argt[i], XmNwidth, max_width ); i++;
1174 XtSetArg(argt[i], XmNheight, max_height ); i++;
1175 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1176 XtSetArg(argt[i], XmNbottomOffset, thick1 ); i++;
1177 XtSetValues(options_button, argt, i);
1180 XtSetArg(argt[i], XmNwidth, max_width + 2*thick1 ); i++;
1181 XtSetArg(argt[i], XmNheight, max_height + 2*thick1 ); i++;
1182 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1184 XtSetValues(ok_button, argt, i);
1185 XtSetValues(clear_button, argt, i);
1186 XtSetValues(help_button, argt, i);
1192 /***************************************************************************
1196 * Widgets: error_message, help_message, copyright_msg, hostname_message,
1198 ***************************************************************************/
1201 MakeDialog( DialogType dtype )
1210 Widget w = NULL, text;
1211 Dimension txt_width, txt_height;
1212 XmString ok, cancel, nw, sv;
1214 Widget tlev; /* JET - warning, there be dragons here */
1215 unsigned int dpwidth, dpheight, xorg, yorg;
1220 vg_TRACE_EXECUTION("MakeDialog: entered ...");
1221 #endif /* VG_TRACE */
1223 * do things common to all dialogs...
1227 /* get info on prefered screen */
1228 if (!_DtXineramaGetScreen(dpyinfo.DtXineramaInfo,
1229 appInfo.xineramaPreferredScreen,
1230 &dpwidth, &dpheight, &xorg, &yorg))
1231 { /* no joy here either - setup for normal */
1232 dpwidth = dpyinfo.width;
1233 dpheight = dpyinfo.height;
1236 /* else, should be setup properly */
1237 XWarpPointer(dpyinfo.dpy,None,dpyinfo.root,0,0,0,0,dpwidth/2,dpheight/2);
1238 #else /* no Xinerama */
1239 dpwidth = dpyinfo.width;
1240 dpheight = dpyinfo.height;
1244 ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
1245 cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
1247 i = InitArg(MessageBox);
1248 XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++;
1249 XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++;
1250 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
1251 XtSetArg(argt[i], XmNokLabelString, ok ); i++;
1252 XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++;
1253 XtSetArg(argt[i], XmNnoResize, False ); i++;
1254 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
1257 * create the various dialogs...
1260 /* JET - check the matte widget, and if non-null, well use that as
1261 * the parent for dialogs. Otherwise use table (the original
1262 * toplevel widget for this func). This is useful for Xinerama so
1263 * that child dialogs are centered on the matte, and not the whole
1267 if (matte != (Widget)NULL)
1275 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
1276 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1278 w = XmCreateErrorDialog(tlev, "error_message", argt, i);
1279 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1280 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1288 txt_width = (dpwidth > 850) ? 800 : dpwidth - 50;
1289 txt_height = (dpheight > 900) ? 600 : dpheight - 300;
1291 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
1292 XtSetArg(argt[i], XmNmessageString, xmstr); i++;
1294 w = XmCreateInformationDialog(tlev, "help_message", argt, i);
1295 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1296 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1299 XtSetArg(argt[i], XmNheight, txt_height); i++;
1300 XtSetArg(argt[i], XmNwidth, txt_width); i++;
1301 XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
1302 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
1303 XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
1304 XtSetArg(argt[i], XmNeditable, False); i++;
1307 XmNvalue, ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP)); i++;
1308 text = XmCreateScrolledText(w, "help_message_text", argt, i);
1310 XtManageChild(text);
1317 if ((fp = fopen(COPYRIGHT,"r")) == NULL)
1318 xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
1319 XmFONTLIST_DEFAULT_TAG);
1321 xmstr = (XmString) NULL;
1323 while (fgets(buffer, 128, fp) != NULL) {
1325 if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
1327 if ( xmstr != NULL )
1328 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
1330 xmstr = XmStringConcat(xmstr,
1331 XmStringCreate(buffer,
1332 XmFONTLIST_DEFAULT_TAG));
1337 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1339 w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
1340 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1341 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1343 XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);
1351 nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
1352 sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);
1354 xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
1355 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1356 XtSetArg(argt[i], XmNokLabelString, nw ); i++;
1357 XtSetArg(argt[i], XmNcancelLabelString, sv ); i++;
1359 w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);
1361 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1366 hostname_message = w;
1372 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED,
1373 MC_DEF_PASSWD_EXPIRED);
1374 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1376 w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);
1378 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1392 XtAddCallback(w, XmNokCallback, RespondDialogCB, NULL);
1393 XtAddCallback(w, XmNcancelCallback, RespondDialogCB, NULL);
1398 XtSetArg(argt[0], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); i++;
1400 XtSetValues(w, argt, 1);
1403 XmStringFree(xmstr);
1405 XmStringFree(cancel);
1409 * adjust the width of the "ok" button on the dialogs...
1412 width = (dtype == hostname ? FromMM(4000) : MIN_BUTTON_SIZE);
1415 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1416 XtSetArg(argt[i], XmNwidth, width ); i++;
1418 XtSetValues(XmMessageBoxGetChild(w, XmDIALOG_OK_BUTTON), argt, i);
1422 /***************************************************************************
1427 ***************************************************************************/
1435 vg_TRACE_EXECUTION("MakeDtlabel: entered ...");
1436 #endif /* VG_TRACE */
1438 i = InitArg(LabelG);
1439 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1440 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET ); i++;
1441 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM ); i++;
1442 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM ); i++;
1443 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;
1444 XtSetArg(argt[i], XmNtopWidget, greeting ); i++;
1446 dt_label = XmCreateLabel(matte1, "dt_label", argt, i);
1447 XtManageChild(dt_label);
1452 /***************************************************************************
1457 ***************************************************************************/
1460 char *labelString; /* string for label */
1461 char *persLabelString; /* alternate string for label */
1462 XmFontList fontList;
1463 } GreetInfo, *GreetInfoPtr;
1465 static GreetInfo greetInfo;
1467 static XtResource greetResources[] = {
1468 {XmNlabelString, XmCLabelString,
1469 XmRString, sizeof(char *),
1470 XtOffset(GreetInfoPtr, labelString), XtRString, "default" },
1472 {"persLabelString", "PersLabelString",
1473 XmRString, sizeof(char *),
1474 XtOffset(GreetInfoPtr, persLabelString), XtRString, "default" },
1476 {XmNfontList, XmCFontList,
1477 XmRFontList, sizeof(XmFontList),
1478 XtOffset(GreetInfoPtr, fontList), XtRString, NULL }
1482 MakeGreeting( void )
1489 char *p, *q, *s, *t;
1490 int newLine = False;
1494 vg_TRACE_EXECUTION("MakeGreeting: entered ...");
1495 #endif /* VG_TRACE */
1498 * get the user's greeting preferences...
1501 XtGetSubresources(table, &greetInfo, "greeting", "Greeting",
1502 greetResources, XtNumber(greetResources), NULL, 0);
1506 * get the local hostname...
1509 gethostname(host, sizeof (host));
1510 if ( (p = strchr(host,'.')) != NULL )
1514 ** Get display name (for %DisplayName% substitutions),
1515 ** reducing "a.b.c.d:0" constructs to shorter "a:0" form.
1519 dpyinfo.name ? dpyinfo.name : (DisplayString(dpyinfo.dpy)), 127);
1521 p = strchr(disp, '.');
1522 t = strchr(disp, ':');
1523 if (p && t) strcpy(p,t);
1527 * use the default string if the user has not specified one...
1530 if ( greetInfo.persLabelString &&
1531 strcmp(greetInfo.persLabelString, "default") == 0 ) {
1535 ReadCatalog(MC_LABEL_SET,MC_PERS_GREET_LABEL,MC_DEF_PERS_GREET_LABEL);
1536 greetInfo.persLabelString = strdup(msg);
1539 if ( greetInfo.labelString &&
1540 strcmp(greetInfo.labelString, "default") == 0 ) {
1542 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_GREET_LABEL,MC_DEF_GREET_LABEL);
1543 xmstr = XmStringConcat(xmstr,
1544 XmStringCreate(" ", XmFONTLIST_DEFAULT_TAG));
1545 xmstr = XmStringConcat(xmstr,
1546 XmStringCreate(host, XmFONTLIST_DEFAULT_TAG));
1550 * scan user's message for %LocalHost% token. Replace with hostname
1555 if ( !greetInfo.labelString ||
1556 strlen(greetInfo.labelString) == 0 ||
1557 strcmp(greetInfo.labelString, "None") == 0 ||
1558 strcmp(greetInfo.labelString, "none") == 0 )
1560 greetmsg = strdup(" ");
1562 greetmsg = strdup(greetInfo.labelString);
1566 xmstr = (XmString) NULL;
1572 * scan for a new line character in remaining label string.
1573 * If found, work with that substring first...
1576 if ( (p = strchr(q, '\n')) != NULL ) {
1581 if ( *q == '\0' ) /* handle consecutive newlines */
1590 * replace all occurrences of %LocalHost% and %DisplayName%
1591 * in the current substring...
1595 p = strstr(q, LOCALHOST);
1596 t = strstr(q, DISPLAYNAME);
1598 if (p && t) { /* both present? do whichever comes first */
1599 if (p > t) p = NULL;
1602 if (p) { /* replace a %LocalHost% string */
1604 skip = sizeof(LOCALHOST);
1605 } else if (t) { /* replace a %DisplayName% string */
1608 skip = sizeof(DISPLAYNAME);
1609 } else /* nothing left to replace */
1612 xmstr = XmStringConcat(xmstr,
1614 XmFONTLIST_DEFAULT_TAG));
1615 xmstr = XmStringConcat(xmstr,
1617 XmFONTLIST_DEFAULT_TAG));
1621 if ( strlen(q) != 0 )
1622 xmstr = XmStringConcat(xmstr,
1624 XmFONTLIST_DEFAULT_TAG));
1627 * add a line separator if this is a multi-line greeting...
1630 if ( newLine == True ) {
1631 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
1634 } while ( newLine == True ) ;
1641 * create the Welcome message...
1644 i = InitArg(LabelG);
1645 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1646 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1647 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
1648 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_POSITION); i++;
1649 /* XtSetArg(argt[i], XmNtopPosition, 15); i++; */
1650 /* Changed this to accommodate desktop label */
1651 XtSetArg(argt[i], XmNtopPosition, 9); i++;
1652 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
1656 * use the user's font if one has been specified, otherwise use
1657 * the application's default...
1660 if ( greetInfo.fontList != NULL ) {
1661 XtSetArg(argt[i], XmNfontList, greetInfo.fontList ); i++;
1664 greeting = XmCreateLabel(matte1, "greeting", argt, i);
1665 XtManageChild(greeting);
1667 XmStringFree(xmstr);
1670 /***************************************************************************
1674 * Widgets: login_matte,
1675 * login_form, login_label, login_text
1676 ***************************************************************************/
1683 LoginTextPtr textdata;
1684 XtTranslations textTable;
1689 vg_TRACE_EXECUTION("MakeLogin: entered ...");
1690 #endif /* VG_TRACE */
1693 * create the login form
1697 XtSetArg(argt[i], XmNshadowThickness, 0); i++;
1698 XtSetArg(argt[i], XmNresizable, False ); i++;
1699 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
1700 XtSetArg(argt[i], XmNleftOffset, 80); i++;
1701 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
1702 XtSetArg(argt[i], XmNrightOffset, 80); i++;
1703 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1704 XtSetArg(argt[i], XmNbottomPosition, 65); i++;
1706 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY); i++;
1708 XtSetArg(argt[i], XmNallowShellResize, True); i++;
1710 login_form = XmCreateForm(matte1, "login_form", argt, i);
1711 XtManageChild(login_form);
1714 * create the login text field...
1718 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION ); i++;
1719 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_POSITION ); i++;
1720 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_POSITION ); i++;
1721 XtSetArg(argt[i], XmNbottomPosition, 95 ); i++;
1722 XtSetArg(argt[i], XmNrightPosition, 80 ); i++;
1723 XtSetArg(argt[i], XmNleftPosition, 20 ); i++;
1724 XtSetArg(argt[i], XmNselectionArrayCount, 1 ); i++;
1725 XtSetArg(argt[i], XmNmaxLength, 80 ); i++;
1726 XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
1728 textdata = malloc(sizeof(LoginText));
1729 XtSetArg(argt[i], XmNuserData, textdata ); i++;
1731 login_text = XmCreateTextField(login_form, "login_text", argt, i);
1734 * From Human Interface model, Tab key operation should work same on
1735 * user field as it does on password field. Password field is setup
1736 * to take Tab key as password data. HIE model is for user field to
1739 XtOverrideTranslations(
1741 XtParseTranslationTable(
1742 " Shift <Key>Tab: prev-tab-group() \n\
1743 Ctrl <Key>Tab: next-tab-group() "));
1745 XtManageChild(login_text);
1747 XtAddCallback(login_text, XmNfocusCallback, TextFocusCB, NULL);
1751 XtAddActions(textActions, 2);
1752 textTable = XtParseTranslationTable(textEventBindings);
1755 XtSetArg(argt[i], XmNtranslations, textTable ); i++;
1757 XtSetArg(argt[i], XmNverifyBell, False ); i++;
1759 passwd_text = XmCreateTextField(login_form, "passwd_text", argt, i);
1761 textdata->bEcho = True;
1762 textdata->noechobuf[0] = '\0';
1763 textdata->text[0] = passwd_text;
1764 textdata->text[1] = login_text;
1766 XtManageChild(passwd_text);
1768 XtAddCallback(passwd_text, XmNfocusCallback, TextFocusCB, NULL);
1770 XtAddCallback(passwd_text, XmNmodifyVerifyCallback, EditPasswdCB, NULL);
1773 * Get default greeting string
1776 XtSetArg(argt[i], XmNlabelString, &textdata->onGreeting); i++;
1777 XtGetValues(greeting, argt, i);
1778 textdata->offGreetingFormat = greetInfo.persLabelString;
1779 textdata->offGreetingUname = NULL;
1782 * create the login labels...
1785 i = InitArg(LabelG);
1787 /* modified recomputeSize initial value from False to True, fails
1788 * when setting longer strings. Manifested as bug ID:1200690.
1790 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1792 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1793 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET ); i++;
1794 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
1796 /* XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM ); i++;
1797 Commented this statement to align login_label and login_text
1798 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM ); i++;
1799 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;
1800 XtSetArg(argt[i], XmNbottomOffset, 10 ); i++;
1803 XtSetArg(argt[i], XmNleftWidget, login_text ); i++;
1804 XtSetArg(argt[i], XmNbottomWidget, login_text ); i++;
1808 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LOGIN_LABEL, MC_DEF_LOGIN_LABEL);
1809 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1811 login_label = XmCreateLabel(login_form, "login_label", argt, i);
1812 XtManageChild(login_label);
1814 XmStringFree(xmstr);
1821 /***************************************************************************
1825 * Widgets: options_menu, options_item[]
1826 ***************************************************************************/
1829 MakeOptionsMenu( void )
1836 vg_TRACE_EXECUTION("MakeOptionsMenu: entered ...");
1837 #endif /* VG_TRACE */
1840 * get the built-in pop_up menu from the DtMenuButton...
1843 XtVaGetValues(options_button, DtNsubMenuId, &options_menu, NULL);
1846 * create language cascade menus...
1849 if ( lang_menu == NULL )
1854 * create first level menu items...
1859 * build [ Language ] menu pane if there are languages to choose from...
1861 if ( lang_menu != NULL ) {
1863 * [ Language ] menu pane...
1864 * attach language cascade menu to this pane
1866 i = InitArg(CascadeBG);
1867 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LANG_LABEL, MC_DEF_LANG_LABEL);
1868 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1869 XtSetArg(argt[i], XmNsubMenuId, lang_menu ); i++;
1870 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1871 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
1872 "options_languages", argt, i);
1873 XmStringFree(xmstr);
1879 i = InitArg(SeparatorG);
1880 options_item[j] = XmCreateSeparatorGadget(options_menu,
1886 if( session_menu == NULL) {
1887 session_menu = XmCreatePulldownMenu(options_menu, "session_menu", NULL, 0);
1891 * [ Dt "Reg" ] menu pane...
1893 i = k = InitArg(ToggleBG);
1894 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_DT_LABEL, MC_DEF_DT_LABEL);
1895 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1896 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1897 XtSetArg(argt[i], XmNuserData, logoInfo.bitmapFile ); i++;
1899 options_dt = XmCreateToggleButtonGadget(session_menu,
1902 XmStringFree(xmstr);
1903 XtAddCallback(options_dt,
1904 XmNvalueChangedCallback,
1907 /*XtManageChild(options_dt); */
1909 * [ Dt Lite ] menu pane...
1912 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_DTLITE_LABEL, MC_DEF_DTLITE_LABEL);
1913 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1914 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1916 options_dtlite = XmCreateToggleButtonGadget(session_menu,
1919 XmStringFree(xmstr);
1920 XtAddCallback(options_dtlite,
1921 XmNvalueChangedCallback,
1923 (XtPointer) OB_DTLITE);
1928 if ( session_menu != NULL ) {
1930 * [ Language ] menu pane...
1931 * attach language cascade menu to this pane
1933 i = InitArg(CascadeBG);
1934 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_SES_LABEL, MC_DEF_SES_LABEL);
1935 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1936 XtSetArg(argt[i], XmNsubMenuId, session_menu ); i++;
1937 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1938 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
1939 "session_menus", argt, i);
1940 XmStringFree(xmstr);
1946 i = InitArg(SeparatorG);
1947 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
1954 * [ No Windows ] menu pane...
1956 i = k = InitArg(PushBG);
1957 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
1958 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1959 options_item[j] = options_nowindows
1960 = XmCreatePushButtonGadget(options_menu,
1961 "options_noWindows",
1963 XmStringFree(xmstr);
1964 XtAddCallback(options_item[j], XmNactivateCallback,
1965 MenuItemCB, (XtPointer) OB_NO_WINDOWS);
1967 if (getenv(LOCATION) == NULL || strcmp(getenv(LOCATION), "local") != 0 )
1968 XtSetSensitive(options_item[j], False);
1973 * [ Restart Server ] menu pane...
1975 i = k = InitArg(PushBG);
1976 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_RS_LABEL, MC_DEF_RS_LABEL);
1977 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1978 options_item[j] = XmCreatePushButtonGadget(options_menu,
1979 "options_restartServer",
1981 XmStringFree(xmstr);
1982 XtAddCallback(options_item[j], XmNactivateCallback,
1983 MenuItemCB, (XtPointer) OB_RESTART_SERVER);
1986 #ifdef copyright_option
1990 i = InitArg(SeparatorG);
1991 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
1997 * [ Copyright ] menu pane...
1999 i = k = InitArg(PushBG);
2000 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_COPY_LABEL, MC_DEF_COPY_LABEL);
2001 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
2002 options_item[j] = XmCreatePushButtonGadget(options_menu,
2003 "options_copyright",
2005 XmStringFree(xmstr);
2006 XtAddCallback(options_item[j], XmNactivateCallback,
2007 MenuItemCB, (XtPointer) OB_COPYRIGHT);
2012 * manage the [Options] menu...
2014 XtManageChildren(options_item, j);
2019 * If the DT Lite Session Manager is not available, remove the DT Lite
2020 * and DT menu panes. The actual widgets must still be created since
2021 * other code (ex. MenuItemCB()) tries to obtain some of their resources.
2024 if ( stat(DTLITESESSION, &statb) != 0 ||
2025 ((statb.st_mode & S_IXOTH) != S_IXOTH) ) {
2027 XtUnmanageChild(options_dtlite);
2029 XtUnmanageChild(options_dt);
2033 if ( getenv(PINGINTERVAL) != NULL )
2034 XtUnmanageChild(options_nowindows);
2042 /***************************************************************************
2046 * Local self-insert action for the text widget. The default action
2047 * discards control characters, which are allowed in password.
2048 ***************************************************************************/
2051 MyInsert( Widget w, XEvent *event, char **params, Cardinal *num_params )
2054 XComposeStatus compstatus;
2057 n = XLookupString((XKeyEvent *)event, str, sizeof(str),
2058 (KeySym *)NULL, &compstatus);
2062 XmTextFieldInsert(w, XmTextFieldGetInsertionPosition(w), str);
2066 /***************************************************************************
2070 * Local backspace action for the text widget.
2071 * Deletes the last character of the password string in the
2072 * widget for each backspace key press, and also does not move the cursor
2073 * position in the widget.
2074 ***************************************************************************/
2077 MyBackspace( Widget w, XEvent *event, char **params, Cardinal *num_params )
2079 LoginTextPtr textdata;
2081 textdata = GetLoginTextPtr(w);
2083 if (textdata && !textdata->bEcho && (int) strlen(textdata->noechobuf) > 0)
2085 textdata->noechobuf[strlen(textdata->noechobuf) - 1] = '\0';
2090 /***************************************************************************
2094 * X protocol error handler to override the default
2095 ***************************************************************************/
2098 ErrorHandler( Display *dpy, XErrorEvent *event )
2106 /***************************************************************************
2110 * Xt protocol error handler to override the default
2111 ***************************************************************************/
2114 xtErrorHandler( String msg )
2116 LogError((unsigned char *) "%s\n", msg ) ;
2117 exit(NOTIFY_RESTART);
2123 /***************************************************************************
2127 * Xt protocol error handler to override the default
2128 ***************************************************************************/
2131 xtWarningHandler( String msg )
2133 LogError( (unsigned char *) "%s\n", msg ) ;
2140 /***************************************************************************
2144 * Timeout routine to build options menu
2145 ***************************************************************************/
2148 MakeOptionsProc( XtPointer data, XtIntervalId *id )
2151 if (options_menu == NULL)
2160 /***************************************************************************
2164 * Catch a SIGTERM and unmanage display
2165 ***************************************************************************/
2168 Terminate( int arg )
2171 if(-1 == write(1, "terminate", 9)) {
2172 perror(strerror(errno));
2174 CleanupAndExit(NULL, NOTIFY_ABORT);
2180 /***************************************************************************
2182 * DebugWidgetResources
2184 * Get widget resources
2185 ***************************************************************************/
2187 typedef struct resource_values {
2192 int rightAttachment;
2195 int bottomAttachment;
2199 DebugWidgetResources(Widget w)
2202 struct resource_values values;
2206 bzero((char *) &values, sizeof(values));
2207 XtSetArg(argt[i], XmNheight, &values.height); i++;
2208 XtSetArg(argt[i], XmNwidth, &values.width); i++;
2209 XtSetArg(argt[i], XmNx, &values.x); i++;
2210 XtSetArg(argt[i], XmNy, &values.y); i++;
2211 XtSetArg(argt[i], XmNrightAttachment, &values.rightAttachment); i++;
2212 XtSetArg(argt[i], XmNleftAttachment, &values.leftAttachment); i++;
2213 XtSetArg(argt[i], XmNtopAttachment, &values.topAttachment); i++;
2214 XtSetArg(argt[i], XmNbottomAttachment, &values.bottomAttachment); i++;
2216 XtGetValues(w, argt, i);
2219 /***************************************************************************
2221 * GetDisplayName (void) - transform the display name into a "short"
2222 * host name that is used to create a display-specific session.
2224 * The display name should match one of the following patterns:
2226 * 1. host (non-qualified)
2231 * 6. host.domain:n.s
2233 * Note that 1 and 2 will be used if the display name is actually
2234 * something like unix:0, local:0 or 0:0
2236 ***************************************************************************/
2238 GetDisplayName (void)
2240 char host[MAXHOSTNAMELEN];
2241 static char tmp[MAXHOSTNAMELEN + 3];
2246 pch = XDisplayString(dpyinfo.dpy);
2249 !strncmp (pch, "local:0", 7) ||
2250 !strncmp (pch, "unix:0", 6) ||
2251 !strncmp (pch, ":0.0", 4) ||
2252 !strncmp (pch, ":0", 2)) {
2253 gethostname (host, MAXHOSTNAMELEN);
2257 col = strchr (pch, ':');
2258 dot = strchr (pch, '.');
2262 strncpy (tmp, pch, dot - pch); /* case #2 above */
2263 tmp[dot - pch] = '\000';
2265 strcpy (tmp, pch); /* case #1 above */
2268 if (!dot || (dot > col)) { /* case #3 and 4 above */
2269 strncpy (tmp, pch, col - pch);
2270 tmp[col - pch] = '\000';
2271 } else { /* case # 5 and 6 above */
2272 strncpy (tmp, pch, dot - pch);
2273 tmp[dot - pch] = '\000';