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 vg_TRACE_EXECUTION("main: exited _XHPNlioctl ...");
487 #endif /* VG_TRACE */
491 * get information about the display...
494 dpyinfo.dpy = XtDisplay(toplevel);
495 /* dpyinfo.name = "";*/
496 dpyinfo.screen = DefaultScreen(dpyinfo.dpy);
497 dpyinfo.root = RootWindow (dpyinfo.dpy, dpyinfo.screen);
498 dpyinfo.depth = DefaultDepth (dpyinfo.dpy, dpyinfo.screen);
499 dpyinfo.width = DisplayWidth (dpyinfo.dpy, dpyinfo.screen);
500 dpyinfo.height = DisplayHeight(dpyinfo.dpy, dpyinfo.screen);
501 dpyinfo.black_pixel = BlackPixel (dpyinfo.dpy, dpyinfo.screen);
502 dpyinfo.visual = DefaultVisual(dpyinfo.dpy, dpyinfo.screen);
504 /* JET - for Xinerama, see if the extension */
505 /* is available and init accordingly. */
509 dpyinfo.DtXineramaInfo = _DtXineramaInit(dpyinfo.dpy);
512 if (dpyinfo.DtXineramaInfo == NULL)
513 { /* No xinerama, no joy. */
514 fprintf(stderr, "### JET VGMAIN: Xinerama NOT available.\n");
518 fprintf(stderr, "### JET VGMAIN: Xinerama available, scrns = %d\n",
519 dpyinfo.DtXineramaInfo->numscreens);
526 * check if any overrides were passed in the argv string...
529 for ( i = 1; i < argc; i++) {
538 * add the unit convertor for resources...
541 XtAddConverter(XmRString, XmRUnitType, XmCvtStringToUnitType, NULL, 0);
544 * get user-specified resources...
547 SetResourceDatabase();
549 XtGetApplicationResources(toplevel, &appInfo, AppResources,
550 XtNumber(AppResources), NULL, 0);
553 vg_TRACE_EXECUTION("main: got application resources ...");
554 #endif /* VG_TRACE */
561 vg_TRACE_EXECUTION("main: making UI ...");
562 #endif /* VG_TRACE */
563 MakeBackground(); /* login_shell, table, matte */
564 MakeLogo(); /* logo, logo_pixmap, logo_shadow */
565 MakeGreeting(); /* greeting */
566 MakeLogin(); /* login_matte ... */
567 MakeDtlabel(); /* Show Desktop selection in options menu*/
570 * grab the display and keyboard...
571 * moved it from before to after creating text widgets in MakeLogin
577 MakeButtons(); /* ok, clear, options, help buttons */
578 MakeDialog(copyright); /* copyright dialog */
580 if (appInfo.optionsDelay == 0 )
581 MakeOptionsMenu(); /* make option_button pop-up menu */
583 XtAddTimeOut((unsigned long) appInfo.optionsDelay * 1000,
584 MakeOptionsProc, NULL);
586 MakeAltDtButtons(); /* make alt desktop buttons, if any */
588 vg_TRACE_EXECUTION("main: made UI ...");
589 #endif /* VG_TRACE */
592 * Add request callback.
593 XtAddInput(0, (XtPointer)XtInputReadMask, RequestCB, NULL);
597 * force the focus to the login_text widget...
600 XtAddEventHandler(login_text, ExposureMask, False,
605 * create windows for the widgets...
609 vg_TRACE_EXECUTION("main: going to realize login_shell ...");
610 #endif /* VG_TRACE */
611 XtRealizeWidget(login_shell);
613 vg_TRACE_EXECUTION("main: realized login_shell ...");
614 #endif /* VG_TRACE */
618 * miscellaneous stuff...
620 * - turn off keyboard bell
621 * - return root cursor to normal from hourglass
622 * - start pinging the server
626 if (appInfo.workspaceCursor)
632 XUndefineCursor(dpyinfo.dpy, dpyinfo.root);
634 PingServerCB(NULL, NULL);
638 * bring up the windows and enter event loop...
641 XRaiseWindow(XtDisplay(greeting), XtWindow(greeting));
643 XRaiseWindow(XtDisplay(logo_shadow), XtWindow(logo_shadow));
644 XRaiseWindow(XtDisplay(logo), XtWindow(logo));
646 /* XtPopup(login_shell, XtGrabNone); */
647 _DtEnvControl( DT_ENV_RESTORE_PRE_DT );
650 * Add request callback.
653 XtAddInput(0, (XtPointer)XtInputReadMask, RequestCB, NULL);
656 vg_TRACE_EXECUTION("main: entering XtMainLoop ...");
657 #endif /* VG_TRACE */
665 /***************************************************************************
669 * initialize the toolkit
670 ***************************************************************************/
672 #define MINTIMEOUT 20
674 static jmp_buf syncJump;
677 syncTimeout( int arg )
680 longjmp (syncJump, 1);
685 InitToolKit( int argc, char **argv )
688 int timeout; /* timeout to initialize toolkit */
693 vg_TRACE_EXECUTION("InitToolKit: enter ...");
694 #endif /* VG_TRACE */
697 * use server grabTimeout as initial value for timeout...
700 timeout = ((t = (char *)getenv(GRABTIMEOUT)) == NULL ? 0 : atoi(t));
701 timeout += MINTIMEOUT; /* minimum MINTIMEOUT seconds */
705 * initialize the toolkit. Wrap a timer around it in case the server
709 signal (SIGALRM, syncTimeout);
710 if (setjmp (syncJump)) {
712 ReadCatalog(MC_LOG_SET,MC_LOG_NO_DPYINIT,MC_DEF_LOG_NO_DPYINIT),
714 exit(NOTIFY_RESTART);
717 alarm ((unsigned) timeout);
719 root = XtInitialize("dtlogin", "Dtlogin", NULL, 0,
721 /* Disable Drag and Drop RK 11.02.93 */
722 XtVaSetValues(XmGetXmDisplay(XtDisplay(root)),
723 XmNdragInitiatorProtocolStyle, XmDRAG_NONE,
728 signal (SIGALRM, SIG_DFL);
736 /***************************************************************************
741 ***************************************************************************/
744 MakeRootCursor( void )
748 vg_cursor = XCreateFontCursor (dpyinfo.dpy, XC_left_ptr);
750 XDefineCursor (dpyinfo.dpy, dpyinfo.root, vg_cursor);
755 /***************************************************************************
759 * Widgets: login_shell, table, matte
760 ***************************************************************************/
763 MakeBackground( void )
768 vg_TRACE_EXECUTION("MakeBackground: entered ...");
769 #endif /* VG_TRACE */
771 * create the login shell widget...
776 /* CORE resource set */
777 XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
778 XtSetArg(argt[i], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP ); i++;
779 XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
780 XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
781 XtSetArg(argt[i], XmNsensitive, True ); i++;
782 XtSetArg(argt[i], XmNtranslations, NULL ); i++;
784 /* COMPOSITE resource set */
785 XtSetArg(argt[i], XmNinsertPosition, NULL ); i++;
787 /* SHELL resource set (set to avoid interference by user) */
788 XtSetArg(argt[i], XmNallowShellResize, False ); i++;
789 XtSetArg(argt[i], XmNcreatePopupChildProc, NULL ); i++;
790 XtSetArg(argt[i], XmNgeometry, NULL ); i++;
791 XtSetArg(argt[i], XmNpopupCallback, NULL ); i++;
792 XtSetArg(argt[i], XmNpopdownCallback, NULL ); i++;
793 XtSetArg(argt[i], XmNoverrideRedirect, False ); i++;
794 XtSetArg(argt[i], XmNsaveUnder, False ); i++;
796 login_shell = XtCreatePopupShell("login_shell", transientShellWidgetClass,
798 XtAddCallback(login_shell, XmNpopupCallback, LayoutCB, NULL);
800 /* Fix to display Input Method's status area. */
801 XtSetArg(argt[0], XmNheight, dpyinfo.height);
802 XtSetValues(login_shell, argt, 1);
806 * create the full-screen drawing area...
809 i = InitArg(DrawingA);
810 XtSetArg(argt[i], XmNwidth, dpyinfo.width ); i++;
811 XtSetArg(argt[i], XmNheight, dpyinfo.height ); i++;
812 XtSetArg(argt[i], XmNunitType, XmPIXELS ); i++;
814 table = XtCreateManagedWidget("table", xmDrawingAreaWidgetClass,
815 login_shell, argt, i);
817 XtAddEventHandler(table, ButtonPressMask, False, RefreshEH, NULL);
818 XtAddCallback(table, XmNhelpCallback, ShowDialogCB, (XtPointer) help);
822 * create the main matte...
826 /* XmNwidth, (set by user) */
827 /* XmNheight, (set by user) */
828 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
830 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
831 XtSetArg(argt[i], XmNshadowThickness, 5 ); i++;
834 matte = XmCreateForm(table, "matte", argt, i);
835 XtManageChild(matte);
838 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
839 XtSetArg(argt[i], XmNshadowThickness, 2); i++;
840 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
841 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
842 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
844 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
846 XtSetArg(argt[i], XmNtopOffset, 15); i++;
847 XtSetArg(argt[i], XmNbottomOffset, 15); i++;
848 XtSetArg(argt[i], XmNleftOffset, 15); i++;
850 XtSetArg(argt[i], XmNrightOffset, 15); i++;
852 matteFrame = XmCreateFrame(matte, "matteFrame", argt, i);
853 XtManageChild(matteFrame);
856 matte1 = XmCreateForm(matteFrame, "matte1", argt, i);
857 XtManageChild(matte1);
863 MakeAltDtButtons( void )
868 XrmValue startup_value;
869 char temp[MAXPATHLEN] = "\0";
872 char lastsess[MAXPATHLEN];
873 Widget default_dt = NULL;
874 int default_is_custom_dt = True;
875 int found_alt_dt = False;
880 vg_TRACE_EXECUTION("MakeAltDtButtons: entered ...");
881 #endif /* VG_TRACE */
883 if (getenv("SESSION_SET") == NULL) {
884 default_is_custom_dt = False;
887 if ((session = getenv ("SESSION")) == NULL) {
891 if(appInfo.altDts > 0) {
893 (Widget *) calloc(appInfo.altDts, sizeof (Widget))) == NULL)
895 ReadCatalog(MC_ERROR_SET,MC_NO_MEMORY, MC_DEF_NO_MEMORY),
898 for(i = 0; i < appInfo.altDts; ++i) {
903 /* alt desktops begin numbering with 1 */
904 sprintf(altdtname,"%s%d", "Dtlogin*altDtName",i+1);
905 sprintf(altdtclass,"%s%d", "Dtlogin*AltDtName",i+1);
907 sprintf(altdtkey,"%s%d","Dtlogin*altDtKey",i+1);
908 sprintf(altdtkeyclass,"%s%d","Dtlogin*AltDtKey",i+1);
910 sprintf(altdtstart,"%s%d","Dtlogin*altDtStart",i+1);
911 sprintf(altdtstartclass,"%s%d","Dtlogin*AltDtStart",i+1);
914 XtDatabase(dpyinfo.dpy),
915 altdtkey, altdtkeyclass,
916 &keyrmtype, &keyrmvalue) == True) {
918 * remove trailing spaces
920 if(strchr(keyrmvalue.addr,' '))
921 temp_p = strtok(keyrmvalue.addr," ");
923 temp_p = keyrmvalue.addr;
926 * Make sure the key file exists.
928 if (stat( temp_p, &statb) == 0) {
930 j = InitArg(ToggleBG);
932 XtDatabase(dpyinfo.dpy),
933 altdtstart, altdtstartclass,
934 &startup_name, &startup_value) == True) {
937 * remove trailing spaces
939 if (strchr(startup_value.addr, ' '))
940 snprintf(temp, sizeof(temp), "%s", strtok(startup_value.addr, " "));
942 snprintf(temp, sizeof(temp), "%s", startup_value.addr);
944 if (default_is_custom_dt)
945 if (strcmp(session, temp) == 0) {
950 LogError((unsigned char *)"No startup script for altdt %d \n", i);
953 XtDatabase(dpyinfo.dpy),
954 altdtname, altdtclass,
955 &rmtype, &rmvalue) == True) {
956 if (! strncmp(rmvalue.addr, DISPLAYNAME, strlen(DISPLAYNAME))) {
959 host = GetDisplayName();
960 snprintf(temp, sizeof(temp), "%s - %s", host, rmvalue.addr + strlen(DISPLAYNAME));
961 xmstr = XmStringCreateLocalized(temp);
964 xmstr = XmStringCreateLocalized(rmvalue.addr);
968 LogError((unsigned char *)
969 "Couldn't find the altdtname resource in the db\n");
970 sprintf(altdtname,"%s%d", "Alternate Desktop-",i+1);
971 xmstr = XmStringCreateLocalized(altdtname);
974 sprintf(altdtlogo,"%s%d","Dtlogin*altDtLogo",i+1);
975 sprintf(altlogoclass,"%s%d","Dtlogin*AltDtLogo",i+1);
977 XtDatabase(dpyinfo.dpy),
978 altdtlogo, altlogoclass,
979 &logotype, &logovalue) == True) {
980 XtSetArg(argt[j], XmNuserData, logovalue.addr); j++;
983 XtSetArg(argt[j], XmNuserData, logoInfo.bitmapFile); j++;
986 XtSetArg(argt[j], XmNlabelString, xmstr); j++;
987 XtSetArg(argt[j], XmNrecomputeSize, True); j++;
989 alt_dts[i] = XmCreateToggleButtonGadget(
991 rmvalue.addr, argt, j);
995 XmNvalueChangedCallback, MenuItemCB,
996 (XtPointer) OB_ALT_DTS);
997 XtManageChild(alt_dts[i]);
1001 default_dt = alt_dts[i];
1004 LogError((unsigned char *) "Couldn't find the keyfile \n");
1007 LogError((unsigned char *)
1008 "Couldn't find the altkeyfile resource in the database\n");
1012 if ((appInfo.altDts == 0) || !found_alt_dt)
1013 XtManageChild(options_dt);
1016 * Use the regular desktop if none of the known sessions matched the
1017 * specified custom session.
1019 if (default_is_custom_dt && NULL == default_dt) {
1020 default_dt = options_dt;
1022 XtManageChild(options_dt);
1026 * [ Failsafe Session ] menu pane...
1028 i = InitArg(ToggleBG);
1029 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_FS_LABEL, MC_DEF_FS_LABEL);
1030 XtSetArg(argt[i], XmNuserData, logoInfo.bitmapFile ); i++;
1031 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1032 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1033 options_failsafe = XmCreateToggleButtonGadget(session_menu,
1034 "options_failsafe", argt, i);
1035 XmStringFree(xmstr);
1036 XtAddCallback(options_failsafe, XmNvalueChangedCallback,
1037 MenuItemCB, (XtPointer) OB_FAILSAFE);
1039 XtManageChild(options_failsafe);
1042 * which option to set..
1044 SetDefaultDt(default_dt);
1045 SetDtLabelAndIcon();
1048 /***************************************************************************
1052 * Widgets: ok_button, clear_button, options_button, help_button
1053 ***************************************************************************/
1061 Dimension max_width; /* maximum width of a set of widgets */
1062 Dimension max_height; /* maximum height of a set of widgets */
1063 Dimension thick1; /* defaultButtonShadowThickness */
1064 Dimension thick2; /* shadowThickness */
1066 int origin; /* horizontal origin for button placement */
1067 int spacing; /* spacing between buttons (width/32) */
1070 vg_TRACE_EXECUTION("MakeButtons: entered ...");
1071 #endif /* VG_TRACE */
1074 * create the buttons...
1079 i = InitArg(PushBG);
1080 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1081 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
1082 XtSetArg(argt[i], XmNtraversalOn, True); i++;
1084 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL );
1085 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1087 ok_button = XmCreatePushButtonGadget(matte1, "ok_button", argt, i);
1089 XmStringFree(xmstr);
1090 XtManageChild(ok_button);
1092 XtAddCallback(ok_button, XmNactivateCallback, RespondChallengeCB, NULL);
1098 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_CLEAR_LABEL, MC_DEF_CLEAR_LABEL);
1099 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1101 clear_button = XmCreatePushButtonGadget(matte1, "clear_button", argt, i);
1103 XmStringFree(xmstr);
1104 XtManageChild(clear_button);
1105 XtAddCallback(clear_button, XmNactivateCallback, RespondClearCB,
1112 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
1113 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1115 help_button = XmCreatePushButtonGadget(matte1, "help_button", argt, i);
1116 XtAddCallback(help_button, XmNactivateCallback, ShowDialogCB,
1118 XmStringFree(xmstr);
1119 XtManageChild(help_button);
1121 /* options button */
1124 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1125 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
1126 xmstr = ReadCatalogXms(
1129 MC_DEF_OPTIONS_LABEL );
1131 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
1132 XtSetArg(argt[i], XmNtraversalOn, True); i++;
1133 options_button = DtCreateMenuButton(matte1, "options_button", argt, i);
1134 XtOverrideTranslations(
1136 XtParseTranslationTable(" <Key> Return: Select()"));
1138 XtManageChild(options_button);
1139 XmStringFree(xmstr);
1142 * tell form that ok_button is the default button...
1146 XtSetArg(argt[i], XmNdefaultButton, ok_button ); i++;
1147 XtSetValues(matte1, argt, i);
1150 * make all buttons *look* the same size...
1154 max_width = max_height = 0;
1155 GetBiggest(ok_button, &max_width, &max_height);
1156 GetBiggest(clear_button, &max_width, &max_height);
1157 GetBiggest(options_button, &max_width, &max_height);
1158 GetBiggest(help_button, &max_width, &max_height);
1160 if ( (int) max_width < MIN_BUTTON_SIZE) max_width = MIN_BUTTON_SIZE;
1163 XtSetArg(argt[i], XmNdefaultButtonShadowThickness, &thick1); i++;
1164 XtSetArg(argt[i], XmNshadowThickness, &thick2); i++;
1165 XtGetValues(ok_button, argt, i);
1170 XtSetArg(argt[i], XmNwidth, max_width ); i++;
1171 XtSetArg(argt[i], XmNheight, max_height ); i++;
1172 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1173 XtSetArg(argt[i], XmNbottomOffset, thick1 ); i++;
1174 XtSetValues(options_button, argt, i);
1177 XtSetArg(argt[i], XmNwidth, max_width + 2*thick1 ); i++;
1178 XtSetArg(argt[i], XmNheight, max_height + 2*thick1 ); i++;
1179 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1181 XtSetValues(ok_button, argt, i);
1182 XtSetValues(clear_button, argt, i);
1183 XtSetValues(help_button, argt, i);
1189 /***************************************************************************
1193 * Widgets: error_message, help_message, copyright_msg, hostname_message,
1195 ***************************************************************************/
1198 MakeDialog( DialogType dtype )
1207 Widget w = NULL, text;
1208 Dimension txt_width, txt_height;
1209 XmString ok, cancel, nw, sv;
1211 Widget tlev; /* JET - warning, there be dragons here */
1212 unsigned int dpwidth, dpheight, xorg, yorg;
1217 vg_TRACE_EXECUTION("MakeDialog: entered ...");
1218 #endif /* VG_TRACE */
1220 * do things common to all dialogs...
1224 /* get info on prefered screen */
1225 if (!_DtXineramaGetScreen(dpyinfo.DtXineramaInfo,
1226 appInfo.xineramaPreferredScreen,
1227 &dpwidth, &dpheight, &xorg, &yorg))
1228 { /* no joy here either - setup for normal */
1229 dpwidth = dpyinfo.width;
1230 dpheight = dpyinfo.height;
1233 /* else, should be setup properly */
1234 XWarpPointer(dpyinfo.dpy,None,dpyinfo.root,0,0,0,0,dpwidth/2,dpheight/2);
1235 #else /* no Xinerama */
1236 dpwidth = dpyinfo.width;
1237 dpheight = dpyinfo.height;
1241 ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
1242 cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
1244 i = InitArg(MessageBox);
1245 XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++;
1246 XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++;
1247 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
1248 XtSetArg(argt[i], XmNokLabelString, ok ); i++;
1249 XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++;
1250 XtSetArg(argt[i], XmNnoResize, False ); i++;
1251 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
1254 * create the various dialogs...
1257 /* JET - check the matte widget, and if non-null, well use that as
1258 * the parent for dialogs. Otherwise use table (the original
1259 * toplevel widget for this func). This is useful for Xinerama so
1260 * that child dialogs are centered on the matte, and not the whole
1264 if (matte != (Widget)NULL)
1272 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
1273 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1275 w = XmCreateErrorDialog(tlev, "error_message", argt, i);
1276 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1277 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1285 txt_width = (dpwidth > 850) ? 800 : dpwidth - 50;
1286 txt_height = (dpheight > 900) ? 600 : dpheight - 300;
1288 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
1289 XtSetArg(argt[i], XmNmessageString, xmstr); i++;
1291 w = XmCreateInformationDialog(tlev, "help_message", argt, i);
1292 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1293 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1296 XtSetArg(argt[i], XmNheight, txt_height); i++;
1297 XtSetArg(argt[i], XmNwidth, txt_width); i++;
1298 XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
1299 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
1300 XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
1301 XtSetArg(argt[i], XmNeditable, False); i++;
1304 XmNvalue, ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP)); i++;
1305 text = XmCreateScrolledText(w, "help_message_text", argt, i);
1307 XtManageChild(text);
1314 if ((fp = fopen(COPYRIGHT,"r")) == NULL)
1315 xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
1316 XmFONTLIST_DEFAULT_TAG);
1318 xmstr = (XmString) NULL;
1320 while (fgets(buffer, 128, fp) != NULL) {
1322 if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
1324 if ( xmstr != NULL )
1325 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
1327 xmstr = XmStringConcat(xmstr,
1328 XmStringCreate(buffer,
1329 XmFONTLIST_DEFAULT_TAG));
1334 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1336 w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
1337 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
1338 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1340 XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);
1348 nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
1349 sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);
1351 xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
1352 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1353 XtSetArg(argt[i], XmNokLabelString, nw ); i++;
1354 XtSetArg(argt[i], XmNcancelLabelString, sv ); i++;
1356 w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);
1358 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1363 hostname_message = w;
1369 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED,
1370 MC_DEF_PASSWD_EXPIRED);
1371 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
1373 w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);
1375 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
1389 XtAddCallback(w, XmNokCallback, RespondDialogCB, NULL);
1390 XtAddCallback(w, XmNcancelCallback, RespondDialogCB, NULL);
1395 XtSetArg(argt[0], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); i++;
1397 XtSetValues(w, argt, 1);
1400 XmStringFree(xmstr);
1402 XmStringFree(cancel);
1406 * adjust the width of the "ok" button on the dialogs...
1409 width = (dtype == hostname ? FromMM(4000) : MIN_BUTTON_SIZE);
1412 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
1413 XtSetArg(argt[i], XmNwidth, width ); i++;
1415 XtSetValues(XmMessageBoxGetChild(w, XmDIALOG_OK_BUTTON), argt, i);
1419 /***************************************************************************
1424 ***************************************************************************/
1432 vg_TRACE_EXECUTION("MakeDtlabel: entered ...");
1433 #endif /* VG_TRACE */
1435 i = InitArg(LabelG);
1436 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1437 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET ); i++;
1438 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM ); i++;
1439 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM ); i++;
1440 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;
1441 XtSetArg(argt[i], XmNtopWidget, greeting ); i++;
1443 dt_label = XmCreateLabel(matte1, "dt_label", argt, i);
1444 XtManageChild(dt_label);
1449 /***************************************************************************
1454 ***************************************************************************/
1457 char *labelString; /* string for label */
1458 char *persLabelString; /* alternate string for label */
1459 XmFontList fontList;
1460 } GreetInfo, *GreetInfoPtr;
1462 static GreetInfo greetInfo;
1464 static XtResource greetResources[] = {
1465 {XmNlabelString, XmCLabelString,
1466 XmRString, sizeof(char *),
1467 XtOffset(GreetInfoPtr, labelString), XtRString, "default" },
1469 {"persLabelString", "PersLabelString",
1470 XmRString, sizeof(char *),
1471 XtOffset(GreetInfoPtr, persLabelString), XtRString, "default" },
1473 {XmNfontList, XmCFontList,
1474 XmRFontList, sizeof(XmFontList),
1475 XtOffset(GreetInfoPtr, fontList), XtRString, NULL }
1479 MakeGreeting( void )
1486 char *p, *q, *s, *t;
1487 int newLine = False;
1491 vg_TRACE_EXECUTION("MakeGreeting: entered ...");
1492 #endif /* VG_TRACE */
1495 * get the user's greeting preferences...
1498 XtGetSubresources(table, &greetInfo, "greeting", "Greeting",
1499 greetResources, XtNumber(greetResources), NULL, 0);
1503 * get the local hostname...
1506 gethostname(host, sizeof (host));
1507 if ( (p = strchr(host,'.')) != NULL )
1511 ** Get display name (for %DisplayName% substitutions),
1512 ** reducing "a.b.c.d:0" constructs to shorter "a:0" form.
1516 dpyinfo.name ? dpyinfo.name : (DisplayString(dpyinfo.dpy)), 127);
1518 p = strchr(disp, '.');
1519 t = strchr(disp, ':');
1520 if (p && t) strcpy(p,t);
1524 * use the default string if the user has not specified one...
1527 if ( greetInfo.persLabelString &&
1528 strcmp(greetInfo.persLabelString, "default") == 0 ) {
1532 ReadCatalog(MC_LABEL_SET,MC_PERS_GREET_LABEL,MC_DEF_PERS_GREET_LABEL);
1533 greetInfo.persLabelString = strdup(msg);
1536 if ( greetInfo.labelString &&
1537 strcmp(greetInfo.labelString, "default") == 0 ) {
1539 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_GREET_LABEL,MC_DEF_GREET_LABEL);
1540 xmstr = XmStringConcat(xmstr,
1541 XmStringCreate(" ", XmFONTLIST_DEFAULT_TAG));
1542 xmstr = XmStringConcat(xmstr,
1543 XmStringCreate(host, XmFONTLIST_DEFAULT_TAG));
1547 * scan user's message for %LocalHost% token. Replace with hostname
1552 if ( !greetInfo.labelString ||
1553 strlen(greetInfo.labelString) == 0 ||
1554 strcmp(greetInfo.labelString, "None") == 0 ||
1555 strcmp(greetInfo.labelString, "none") == 0 )
1557 greetmsg = strdup(" ");
1559 greetmsg = strdup(greetInfo.labelString);
1563 xmstr = (XmString) NULL;
1569 * scan for a new line character in remaining label string.
1570 * If found, work with that substring first...
1573 if ( (p = strchr(q, '\n')) != NULL ) {
1578 if ( *q == '\0' ) /* handle consecutive newlines */
1587 * replace all occurrences of %LocalHost% and %DisplayName%
1588 * in the current substring...
1592 p = strstr(q, LOCALHOST);
1593 t = strstr(q, DISPLAYNAME);
1595 if (p && t) { /* both present? do whichever comes first */
1596 if (p > t) p = NULL;
1599 if (p) { /* replace a %LocalHost% string */
1601 skip = sizeof(LOCALHOST);
1602 } else if (t) { /* replace a %DisplayName% string */
1605 skip = sizeof(DISPLAYNAME);
1606 } else /* nothing left to replace */
1609 xmstr = XmStringConcat(xmstr,
1611 XmFONTLIST_DEFAULT_TAG));
1612 xmstr = XmStringConcat(xmstr,
1614 XmFONTLIST_DEFAULT_TAG));
1618 if ( strlen(q) != 0 )
1619 xmstr = XmStringConcat(xmstr,
1621 XmFONTLIST_DEFAULT_TAG));
1624 * add a line separator if this is a multi-line greeting...
1627 if ( newLine == True ) {
1628 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
1631 } while ( newLine == True ) ;
1638 * create the Welcome message...
1641 i = InitArg(LabelG);
1642 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1643 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1644 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
1645 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_POSITION); i++;
1646 /* XtSetArg(argt[i], XmNtopPosition, 15); i++; */
1647 /* Changed this to accommodate desktop label */
1648 XtSetArg(argt[i], XmNtopPosition, 9); i++;
1649 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
1653 * use the user's font if one has been specified, otherwise use
1654 * the application's default...
1657 if ( greetInfo.fontList != NULL ) {
1658 XtSetArg(argt[i], XmNfontList, greetInfo.fontList ); i++;
1661 greeting = XmCreateLabel(matte1, "greeting", argt, i);
1662 XtManageChild(greeting);
1664 XmStringFree(xmstr);
1667 /***************************************************************************
1671 * Widgets: login_matte,
1672 * login_form, login_label, login_text
1673 ***************************************************************************/
1680 LoginTextPtr textdata;
1681 XtTranslations textTable;
1686 vg_TRACE_EXECUTION("MakeLogin: entered ...");
1687 #endif /* VG_TRACE */
1690 * create the login form
1694 XtSetArg(argt[i], XmNshadowThickness, 0); i++;
1695 XtSetArg(argt[i], XmNresizable, False ); i++;
1696 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
1697 XtSetArg(argt[i], XmNleftOffset, 80); i++;
1698 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
1699 XtSetArg(argt[i], XmNrightOffset, 80); i++;
1700 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
1701 XtSetArg(argt[i], XmNbottomPosition, 65); i++;
1703 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY); i++;
1705 XtSetArg(argt[i], XmNallowShellResize, True); i++;
1707 login_form = XmCreateForm(matte1, "login_form", argt, i);
1708 XtManageChild(login_form);
1711 * create the login text field...
1715 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION ); i++;
1716 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_POSITION ); i++;
1717 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_POSITION ); i++;
1718 XtSetArg(argt[i], XmNbottomPosition, 95 ); i++;
1719 XtSetArg(argt[i], XmNrightPosition, 80 ); i++;
1720 XtSetArg(argt[i], XmNleftPosition, 20 ); i++;
1721 XtSetArg(argt[i], XmNselectionArrayCount, 1 ); i++;
1722 XtSetArg(argt[i], XmNmaxLength, 80 ); i++;
1723 XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
1725 textdata = malloc(sizeof(LoginText));
1726 XtSetArg(argt[i], XmNuserData, textdata ); i++;
1728 login_text = XmCreateTextField(login_form, "login_text", argt, i);
1731 * From Human Interface model, Tab key operation should work same on
1732 * user field as it does on password field. Password field is setup
1733 * to take Tab key as password data. HIE model is for user field to
1736 XtOverrideTranslations(
1738 XtParseTranslationTable(
1739 " Shift <Key>Tab: prev-tab-group() \n\
1740 Ctrl <Key>Tab: next-tab-group() "));
1742 XtManageChild(login_text);
1744 XtAddCallback(login_text, XmNfocusCallback, TextFocusCB, NULL);
1748 XtAddActions(textActions, 2);
1749 textTable = XtParseTranslationTable(textEventBindings);
1752 XtSetArg(argt[i], XmNtranslations, textTable ); i++;
1754 XtSetArg(argt[i], XmNverifyBell, False ); i++;
1756 passwd_text = XmCreateTextField(login_form, "passwd_text", argt, i);
1758 textdata->bEcho = True;
1759 textdata->noechobuf[0] = '\0';
1760 textdata->text[0] = passwd_text;
1761 textdata->text[1] = login_text;
1763 XtManageChild(passwd_text);
1765 XtAddCallback(passwd_text, XmNfocusCallback, TextFocusCB, NULL);
1767 XtAddCallback(passwd_text, XmNmodifyVerifyCallback, EditPasswdCB, NULL);
1770 * Get default greeting string
1773 XtSetArg(argt[i], XmNlabelString, &textdata->onGreeting); i++;
1774 XtGetValues(greeting, argt, i);
1775 textdata->offGreetingFormat = greetInfo.persLabelString;
1776 textdata->offGreetingUname = NULL;
1779 * create the login labels...
1782 i = InitArg(LabelG);
1784 /* modified recomputeSize initial value from False to True, fails
1785 * when setting longer strings. Manifested as bug ID:1200690.
1787 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1789 XtSetArg(argt[i], XmNtraversalOn, False ); i++;
1790 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET ); i++;
1791 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
1793 /* XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM ); i++;
1794 Commented this statement to align login_label and login_text
1795 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM ); i++;
1796 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;
1797 XtSetArg(argt[i], XmNbottomOffset, 10 ); i++;
1800 XtSetArg(argt[i], XmNleftWidget, login_text ); i++;
1801 XtSetArg(argt[i], XmNbottomWidget, login_text ); i++;
1805 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LOGIN_LABEL, MC_DEF_LOGIN_LABEL);
1806 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1808 login_label = XmCreateLabel(login_form, "login_label", argt, i);
1809 XtManageChild(login_label);
1811 XmStringFree(xmstr);
1818 /***************************************************************************
1822 * Widgets: options_menu, options_item[]
1823 ***************************************************************************/
1826 MakeOptionsMenu( void )
1833 vg_TRACE_EXECUTION("MakeOptionsMenu: entered ...");
1834 #endif /* VG_TRACE */
1837 * get the built-in pop_up menu from the DtMenuButton...
1840 XtVaGetValues(options_button, DtNsubMenuId, &options_menu, NULL);
1843 * create language cascade menus...
1846 if ( lang_menu == NULL )
1851 * create first level menu items...
1856 * build [ Language ] menu pane if there are languages to choose from...
1858 if ( lang_menu != NULL ) {
1860 * [ Language ] menu pane...
1861 * attach language cascade menu to this pane
1863 i = InitArg(CascadeBG);
1864 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LANG_LABEL, MC_DEF_LANG_LABEL);
1865 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1866 XtSetArg(argt[i], XmNsubMenuId, lang_menu ); i++;
1867 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1868 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
1869 "options_languages", argt, i);
1870 XmStringFree(xmstr);
1876 i = InitArg(SeparatorG);
1877 options_item[j] = XmCreateSeparatorGadget(options_menu,
1883 if( session_menu == NULL) {
1884 session_menu = XmCreatePulldownMenu(options_menu, "session_menu", NULL, 0);
1888 * [ Dt "Reg" ] menu pane...
1890 i = k = InitArg(ToggleBG);
1891 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_DT_LABEL, MC_DEF_DT_LABEL);
1892 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1893 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1894 XtSetArg(argt[i], XmNuserData, logoInfo.bitmapFile ); i++;
1896 options_dt = XmCreateToggleButtonGadget(session_menu,
1899 XmStringFree(xmstr);
1900 XtAddCallback(options_dt,
1901 XmNvalueChangedCallback,
1904 /*XtManageChild(options_dt); */
1906 * [ Dt Lite ] menu pane...
1909 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_DTLITE_LABEL, MC_DEF_DTLITE_LABEL);
1910 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1911 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1913 options_dtlite = XmCreateToggleButtonGadget(session_menu,
1916 XmStringFree(xmstr);
1917 XtAddCallback(options_dtlite,
1918 XmNvalueChangedCallback,
1920 (XtPointer) OB_DTLITE);
1925 if ( session_menu != NULL ) {
1927 * [ Language ] menu pane...
1928 * attach language cascade menu to this pane
1930 i = InitArg(CascadeBG);
1931 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_SES_LABEL, MC_DEF_SES_LABEL);
1932 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1933 XtSetArg(argt[i], XmNsubMenuId, session_menu ); i++;
1934 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
1935 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
1936 "session_menus", argt, i);
1937 XmStringFree(xmstr);
1943 i = InitArg(SeparatorG);
1944 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
1951 * [ No Windows ] menu pane...
1953 i = k = InitArg(PushBG);
1954 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
1955 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1956 options_item[j] = options_nowindows
1957 = XmCreatePushButtonGadget(options_menu,
1958 "options_noWindows",
1960 XmStringFree(xmstr);
1961 XtAddCallback(options_item[j], XmNactivateCallback,
1962 MenuItemCB, (XtPointer) OB_NO_WINDOWS);
1964 if (getenv(LOCATION) == NULL || strcmp(getenv(LOCATION), "local") != 0 )
1965 XtSetSensitive(options_item[j], False);
1970 * [ Restart Server ] menu pane...
1972 i = k = InitArg(PushBG);
1973 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_RS_LABEL, MC_DEF_RS_LABEL);
1974 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1975 options_item[j] = XmCreatePushButtonGadget(options_menu,
1976 "options_restartServer",
1978 XmStringFree(xmstr);
1979 XtAddCallback(options_item[j], XmNactivateCallback,
1980 MenuItemCB, (XtPointer) OB_RESTART_SERVER);
1983 #ifdef copyright_option
1987 i = InitArg(SeparatorG);
1988 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
1994 * [ Copyright ] menu pane...
1996 i = k = InitArg(PushBG);
1997 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_COPY_LABEL, MC_DEF_COPY_LABEL);
1998 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
1999 options_item[j] = XmCreatePushButtonGadget(options_menu,
2000 "options_copyright",
2002 XmStringFree(xmstr);
2003 XtAddCallback(options_item[j], XmNactivateCallback,
2004 MenuItemCB, (XtPointer) OB_COPYRIGHT);
2009 * manage the [Options] menu...
2011 XtManageChildren(options_item, j);
2016 * If the DT Lite Session Manager is not available, remove the DT Lite
2017 * and DT menu panes. The actual widgets must still be created since
2018 * other code (ex. MenuItemCB()) tries to obtain some of their resources.
2021 if ( stat(DTLITESESSION, &statb) != 0 ||
2022 ((statb.st_mode & S_IXOTH) != S_IXOTH) ) {
2024 XtUnmanageChild(options_dtlite);
2026 XtUnmanageChild(options_dt);
2030 if ( getenv(PINGINTERVAL) != NULL )
2031 XtUnmanageChild(options_nowindows);
2039 /***************************************************************************
2043 * Local self-insert action for the text widget. The default action
2044 * discards control characters, which are allowed in password.
2045 ***************************************************************************/
2048 MyInsert( Widget w, XEvent *event, char **params, Cardinal *num_params )
2051 XComposeStatus compstatus;
2054 n = XLookupString((XKeyEvent *)event, str, sizeof(str),
2055 (KeySym *)NULL, &compstatus);
2059 XmTextFieldInsert(w, XmTextFieldGetInsertionPosition(w), str);
2063 /***************************************************************************
2067 * Local backspace action for the text widget.
2068 * Deletes the last character of the password string in the
2069 * widget for each backspace key press, and also does not move the cursor
2070 * position in the widget.
2071 ***************************************************************************/
2074 MyBackspace( Widget w, XEvent *event, char **params, Cardinal *num_params )
2076 LoginTextPtr textdata;
2078 textdata = GetLoginTextPtr(w);
2080 if (textdata && !textdata->bEcho && (int) strlen(textdata->noechobuf) > 0)
2082 textdata->noechobuf[strlen(textdata->noechobuf) - 1] = '\0';
2087 /***************************************************************************
2091 * X protocol error handler to override the default
2092 ***************************************************************************/
2095 ErrorHandler( Display *dpy, XErrorEvent *event )
2103 /***************************************************************************
2107 * Xt protocol error handler to override the default
2108 ***************************************************************************/
2111 xtErrorHandler( String msg )
2113 LogError((unsigned char *) "%s\n", msg ) ;
2114 exit(NOTIFY_RESTART);
2120 /***************************************************************************
2124 * Xt protocol error handler to override the default
2125 ***************************************************************************/
2128 xtWarningHandler( String msg )
2130 LogError( (unsigned char *) "%s\n", msg ) ;
2137 /***************************************************************************
2141 * Timeout routine to build options menu
2142 ***************************************************************************/
2145 MakeOptionsProc( XtPointer data, XtIntervalId *id )
2148 if (options_menu == NULL)
2157 /***************************************************************************
2161 * Catch a SIGTERM and unmanage display
2162 ***************************************************************************/
2165 Terminate( int arg )
2168 if(-1 == write(1, "terminate", 9)) {
2169 perror(strerror(errno));
2171 CleanupAndExit(NULL, NOTIFY_ABORT);
2177 /***************************************************************************
2179 * DebugWidgetResources
2181 * Get widget resources
2182 ***************************************************************************/
2184 typedef struct resource_values {
2189 int rightAttachment;
2192 int bottomAttachment;
2196 DebugWidgetResources(Widget w)
2199 struct resource_values values;
2203 bzero((char *) &values, sizeof(values));
2204 XtSetArg(argt[i], XmNheight, &values.height); i++;
2205 XtSetArg(argt[i], XmNwidth, &values.width); i++;
2206 XtSetArg(argt[i], XmNx, &values.x); i++;
2207 XtSetArg(argt[i], XmNy, &values.y); i++;
2208 XtSetArg(argt[i], XmNrightAttachment, &values.rightAttachment); i++;
2209 XtSetArg(argt[i], XmNleftAttachment, &values.leftAttachment); i++;
2210 XtSetArg(argt[i], XmNtopAttachment, &values.topAttachment); i++;
2211 XtSetArg(argt[i], XmNbottomAttachment, &values.bottomAttachment); i++;
2213 XtGetValues(w, argt, i);
2216 /***************************************************************************
2218 * GetDisplayName (void) - transform the display name into a "short"
2219 * host name that is used to create a display-specific session.
2221 * The display name should match one of the following patterns:
2223 * 1. host (non-qualified)
2228 * 6. host.domain:n.s
2230 * Note that 1 and 2 will be used if the display name is actually
2231 * something like unix:0, local:0 or 0:0
2233 ***************************************************************************/
2235 GetDisplayName (void)
2237 char host[MAXHOSTNAMELEN];
2238 static char tmp[MAXHOSTNAMELEN + 3];
2243 pch = XDisplayString(dpyinfo.dpy);
2246 !strncmp (pch, "local:0", 7) ||
2247 !strncmp (pch, "unix:0", 6) ||
2248 !strncmp (pch, ":0.0", 4) ||
2249 !strncmp (pch, ":0", 2)) {
2250 gethostname (host, MAXHOSTNAMELEN);
2254 col = strchr (pch, ':');
2255 dot = strchr (pch, '.');
2259 strncpy (tmp, pch, dot - pch); /* case #2 above */
2260 tmp[dot - pch] = '\000';
2262 strcpy (tmp, pch); /* case #1 above */
2265 if (!dot || (dot > col)) { /* case #3 and 4 above */
2266 strncpy (tmp, pch, col - pch);
2267 tmp[col - pch] = '\000';
2268 } else { /* case # 5 and 6 above */
2269 strncpy (tmp, pch, dot - pch);
2270 tmp[dot - pch] = '\000';