123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /* $TOG: vgmain.c /main/19 1998/09/14 18:31:11 mgreess $ */
- /* *
- * (c) Copyright 1993, 1994 Hewlett-Packard Company *
- * (c) Copyright 1993, 1994 International Business Machines Corp. *
- * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
- * (c) Copyright 1993, 1994 Novell, Inc. *
- */
- /****************************************************************************
- **
- ** File: vgmain.c
- **
- ** Project: HP Visual User Environment (DT)
- **
- ** Description: Main line code for Dtgreet application
- **
- ** These routines initialize the toolkit, create the widgets,
- ** set up callbacks, and wait for events.
- **
- **
- ** (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
- **
- **
- **
- ****************************************************************************
- ************************************<+>*************************************/
- /***************************************************************************
- *
- * Includes
- *
- ***************************************************************************/
- #include <stdio.h>
- #include <setjmp.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/signal.h>
- #include <sys/stat.h>
- #include <sys/param.h>
- #include <locale.h>
- #include <netdb.h>
- #include <Xm/Xm.h>
- #include <X11/Xfuncs.h>
- #include <X11/Shell.h>
- #include <X11/cursorfont.h>
- #include <Xm/DragC.h>
- #include <Xm/DrawingA.h>
- #include <Xm/Frame.h>
- #include <Xm/Form.h>
- #include <Xm/Label.h>
- #include <Xm/LabelG.h>
- #include <Xm/Text.h>
- #include <Xm/TextF.h>
- #include <Xm/PushB.h>
- #include <Xm/PushBG.h>
- #include <Xm/MessageB.h>
- #include <Xm/RowColumn.h>
- #include <Xm/SeparatoG.h>
- #include <Xm/ToggleBG.h>
- #include <Xm/CascadeBG.h>
- #include <Dt/EnvControlP.h>
- #include "vg.h"
- #include "vgmsg.h"
- #include <Dt/MenuButton.h>
- #ifdef USE_XINERAMA
- #include <Dt/DtXinerama.h>
- #endif
- #if !defined(NL_CAT_LOCALE)
- #define NL_CAT_LOCALE 0
- #endif
- #define LOCALHOST "%LocalHost%"
- #define DISPLAYNAME "%DisplayName%"
- /***************************************************************************
- *
- * External declarations
- *
- ***************************************************************************/
- extern char password[]; /* pswd string value */
- extern int password_length; /* pswd string length */
- /***************************************************************************
- *
- * Procedure declarations
- *
- ***************************************************************************/
- static SIGVAL syncTimeout( int arg ) ;
- static Widget InitToolKit( int argc, char **argv) ;
- static void MakeRootCursor( void ) ;
- static void MakeBackground( void ) ;
- static void MakeButtons( void ) ;
- static void MakeDtlabel( void );
- static void MakeGreeting( void ) ;
- static void MakeLogin( void ) ;
- static void MyInsert( Widget w, XEvent *event, char **params,
- Cardinal *num_params) ;
- static void MyBackspace( Widget w, XEvent *event, char **params,
- Cardinal *num_params) ;
- static int ErrorHandler( Display *dpy, XErrorEvent *event) ;
- static void xtErrorHandler( String msg ) ;
- static void xtWarningHandler( String msg ) ;
- static void MakeOptionsProc( XtPointer data, XtIntervalId *id) ;
- static SIGVAL Terminate( int arg ) ;
- static char * GetLangName( char * label );
- static void MakeAltDtButtons( void );
- static void DebugWidgetResources(Widget w);
- static char * GetDisplayName();
- /***************************************************************************
- *
- * Global variables
- *
- ***************************************************************************/
- AppInfo appInfo; /* application resources */
- Arg argt[100]; /* used for resources */
- DisplayInfo dpyinfo; /* information about the display */
- XmString xmstr; /* used for compound strings */
- char *errorLogFile; /* current value of environment var. */
- int showVerifyError;/* display a Verify() error dialog */
- char altdtname[MAXPATHLEN];
- char altdtclass[MAXPATHLEN];
- char altdtkey[MAXPATHLEN];
- char altdtkeyclass[MAXPATHLEN];
- char altdtstart[MAXPATHLEN];
- char altdtstartclass[MAXPATHLEN];
- char altdtlogo[MAXPATHLEN];
- char altlogoclass[MAXPATHLEN];
- char *langenv;
- char *logotype; /* for XrmGetResource() */
- XrmValue logovalue; /* for XrmGetResource() */
- char *rmtype;
- XrmValue rmvalue;
- char *keyrmtype;
- XrmValue keyrmvalue;
- /******************************************************************************
- **
- ** WIDGET LAYOUT
- **
- ** toplevel "main" (toplevel)
- ** login_shell "login_shell" (overrideShell)
- ** table "table" (DrawingAreaWidget)
- ** copyright_msg "copyright_msg" (MessageBox)
- ** error_message "error_message" (MessageBox)
- ** help_message "help_message" (MessageBox)
- ** passwd_message "passwd_message" (MessageBox)
- ** hostname_message "hostname_msg" (MessageBox)
- ** matte "matte" (FormWidget)
- ** logo "logo" (FrameWidget)
- ** logo_pixmap "logo_pixmap" (LabelGadget)
- ** matteFrame "matteFrame" (FrameWidget)
- ** matte1 "matte1" (FormWidget)
- ** help_button "help_button" (PushButtonGadget)
- ** greeting "greeting" (LabelGadget)
- ** dt_label "dt_label" (LabelGadget)
- ** login_form "login_form" (FormWidget)
- ** login_label "login_label" (LabelGadget)
- ** login_text "login_text" (TextField)
- ** passwd_text "passwd_text" (TextField)
- ** ok_button "ok_button" (PushButtonGadget)
- ** clear_button "clear_button" (PushButtonGadget)
- ** options_button "options_button" (DtMenuButtonWidget)
- ** options_menu "options_menu" (PopupMenu)
- ** options_item[0] "options_languages" (CascadeButtonGadget)
- ** options_item[1] "options_sep2" (SeparatorGadget)
- ** options_item[2] "session_menus" (CascadeButtonGadget)
- ** options_item[3] "options_sep1" (SeparatorGadget)
- ** options_item[4] "options_noWindows" (PushButtonGadget)
- ** options_item[5] "options_restartServer"(PushButtonGadget)
- ** options_item[6] "options_sep1" (SeparatorGadget)
- ** options_item[7] "options_Copyright" (PushButtonGadget)
- ** session_menu "session_menu" (PulldownMenu)
- ** options_dt "options_dt" (ToggleButtonGadget)
- ** options_failsafe "options_failsafe" (ToggleButtonGadget)
- ** lang_menu "lang_menu" (PulldownMenu)
- ** (lang items) (lang items) (ToggleButtonGadget)
- ** ...
- **
- */
- Widget toplevel; /* top level shell widget */
- Widget login_shell; /* shell for the main login widgets. */
- Widget table; /* black background for everything */
- Widget matte; /* main level form widget */
- Widget matteFrame; /* main level form widget */
- Widget matte1; /* second level form widget */
- Widget greeting; /* Welcome message */
- Widget dt_label; /* Desktop i.e. set in options menu */
- Widget logo1; /* frame around the Corporate logo */
- Widget logo_pixmap; /* Corporate logo */
- Widget logo_shadow; /* drop shadow under the Corporate logo */
- Widget login_matte; /* bulletin board for login/password */
- Widget login_form; /* form containing the login widgets */
- Widget login_label; /* label to left of login text widget */
- Widget login_text; /* login text widget */
- Widget ok_button; /* accept name/password text button */
- Widget clear_button; /* clear name/password text button */
- Widget options_button; /* login options button */
- Widget help_button; /* help button */
- Widget copyright_msg = NULL; /* copyright notice widget */
- Widget help_message = NULL; /* the help message box */
- Widget error_message = NULL; /* the error message box */
- Widget hostname_message = NULL; /* the invalid hostname message box */
- Widget passwd_message = NULL; /* the expired password message box */
- Widget options_menu = NULL; /* pop-up menu on options button */
- Widget options_item[10]; /* items on options pop_up menu */
- Widget options_nowindows; /* nowindows pane on options pop_up menu */
- Widget options_failsafe; /* failsafe pane on options pop_up menu */
- Widget options_dtlite; /* dtlite pane on options pop_up menu */
- Widget *alt_dts; /* alt_dts widgets on options pop_up menu */
- Widget options_dt; /* dt regular pane on options pop_up menu */
- Widget options_last_dt; /* user's last dt */
- Widget lang_menu = NULL; /* cascading menu on "Language" option */
- Widget session_menu = NULL; /* cascading menu on "Session" option */
- /***************************************************************************
- *
- * Text widget actions and translations
- *
- ***************************************************************************/
- static XtActionsRec textActions[] = {
- {"my-insert", (XtActionProc)MyInsert},
- {"my-bksp", (XtActionProc)MyBackspace},
- };
- static char textEventBindings[] = {
- "Shift <Key>Tab: prev-tab-group() \n\
- Ctrl <Key>Tab: next-tab-group() \n\
- <Key>osfEndLine: end-of-line() \n\
- <Key>osfBeginLine: beginning-of-line() \n\
- ~Shift <Key>osfRight: forward-character()\n\
- ~Shift <Key>osfLeft: backward-character()\n\
- Ctrl <Key>osfDelete: delete-to-end-of-line()\n\
- <Key>osfDelete: delete-next-character()\n\
- <Key>osfBackSpace: my-bksp()\n\
- <Key>osfActivate: activate()\n\
- Ctrl <Key>Return: activate()\n\
- <Key>Return: activate()\n\
- <Key>: my-insert()\n\
- ~Ctrl ~Shift ~Meta ~Alt<Btn1Down>: grab-focus() \n\
- <EnterWindow>: enter()\n\
- <LeaveWindow>: leave()\n\
- <FocusIn>: focusIn()\n\
- <FocusOut>: focusOut()\n\
- <Unmap>: unmap()"
- };
- static
- XtResource AppResources[] = {
- { "workspaceCursor", "WorkspaceCursor",
- XtRBoolean, sizeof(Boolean), XtOffset(AppInfoPtr, workspaceCursor),
- XtRImmediate, (caddr_t)False },
- { "labelFont", "LabelFont",
- XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, labelFont),
- XmRString, "Fixed" },
- { "textFont", "TextFont",
- XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, textFont),
- XmRString, "Fixed" },
- { "optionsDelay", "OptionsDelay",
- XtRInt, sizeof(int), XtOffset(AppInfoPtr, optionsDelay),
- XtRImmediate, (XtPointer) 0 },
- { "altDts", "AltDts",
- XtRInt, sizeof(int), XtOffset(AppInfoPtr, altDts),
- XtRImmediate, (XtPointer) 0
- },
- {"languageList", "LanguageList",
- XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
- XtRString, NULL },
- #if defined(USE_XINERAMA)
- { "xineramaPreferredScreen", "XineramaPreferredScreen",
- XtRInt, sizeof(int), XtOffset(AppInfoPtr, xineramaPreferredScreen),
- XtRImmediate, (XtPointer) 0
- },
- #endif
- #if defined (ENABLE_DYNAMIC_LANGLIST)
- {"languageListCmd", "LanguageListCmd",
- XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
- XtRString, NULL },
- #endif /* ENABLE_DYNAMIC_LANGLIST */
- };
- /***************************************************************************
- *
- * Main
- *
- ***************************************************************************/
- int
- main( int argc, char **argv )
- {
- char *session;
- int i; /* index for argt */
- char **p; /* temp pointer to traverse argv */
- Boolean nograb=FALSE; /* debugging option to not grab server/key */
- int debug=0; /* print debugging output */
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("--------------------- main ------------------------");
- #endif /* VG_TRACE */
- setlocale(LC_ALL, "");
- XtSetLanguageProc( NULL, NULL, NULL );
- langenv = getenv("LANG");
-
- /*
- * set TERM signal handler...
- */
-
- (void) signal(SIGTERM, Terminate);
- /*
- * check some environment variables...
- */
- errorLogFile = getenv(ERRORLOG);
-
- #ifdef sun
- if (getenv("OPENWINHOME") == NULL) putenv(OWPATH_ENV);
- #endif
- _DtEnvControl( DT_ENV_SET );
- /*
- * set custom error handler for X protocol errors...
- */
- XSetErrorHandler(ErrorHandler);
- /*
- * scan argv looking for display name...
- */
-
- showVerifyError = 0;
-
- for ( i = argc, p = argv; i > 0; i--, p++ ) {
- if ( strcmp(*p, "-display") == 0) {
- p++;
- i--;
- dpyinfo.name = malloc(strlen(*p) + 1);
- strcpy(dpyinfo.name, *p);
- continue;
- }
- if ( strcmp(*p, "-debug") == 0) {
- p++;
- i--;
- debug = atoi(*p);
- continue;
- }
- if ( strcmp(*p, "-nograb") == 0) {
- nograb = TRUE;
- continue;
- }
- if ( strcmp(*p, "-showerror") == 0) {
- p++;
- i--;
- showVerifyError = atoi(*p);
- continue;
- }
- }
-
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("main: after options.");
- #endif /* VG_TRACE */
- #ifdef VG_DEBUG
- LogError((unsigned char *) "main: sleeping %d seconds.\n", debug);
- if (debug) {
- sleep(debug);
- }
- #endif /* VG_DEBUG */
- /*
- * initialize the Intrinsics...
- */
-
- toplevel = InitToolKit(argc, argv);
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("main: exited InitToolKit ...");
- #endif /* VG_TRACE */
- if (debug) {
- XtSetErrorHandler(xtErrorHandler);
- XtSetWarningHandler(xtWarningHandler);
- }
- /*
- * get information about the display...
- */
- dpyinfo.dpy = XtDisplay(toplevel);
- /* dpyinfo.name = "";*/
- dpyinfo.screen = DefaultScreen(dpyinfo.dpy);
- dpyinfo.root = RootWindow (dpyinfo.dpy, dpyinfo.screen);
- dpyinfo.depth = DefaultDepth (dpyinfo.dpy, dpyinfo.screen);
- dpyinfo.width = DisplayWidth (dpyinfo.dpy, dpyinfo.screen);
- dpyinfo.height = DisplayHeight(dpyinfo.dpy, dpyinfo.screen);
- dpyinfo.black_pixel = BlackPixel (dpyinfo.dpy, dpyinfo.screen);
- dpyinfo.visual = DefaultVisual(dpyinfo.dpy, dpyinfo.screen);
- /* JET - for Xinerama, see if the extension */
- /* is available and init accordingly. */
- #ifdef USE_XINERAMA
- dpyinfo.DtXineramaInfo = _DtXineramaInit(dpyinfo.dpy);
- # ifdef DEBUG
- if (dpyinfo.DtXineramaInfo == NULL)
- { /* No xinerama, no joy. */
- fprintf(stderr, "### JET VGMAIN: Xinerama NOT available.\n");
- }
- else
- {
- fprintf(stderr, "### JET VGMAIN: Xinerama available, scrns = %d\n",
- dpyinfo.DtXineramaInfo->numscreens);
- }
- # endif
- #endif
- /*
- * check if any overrides were passed in the argv string...
- */
- for ( i = 1; i < argc; i++) {
- switch(i) {
- default:
- break;
- }
- }
- /*
- * add the unit convertor for resources...
- */
-
- XtAddConverter(XmRString, XmRUnitType, XmCvtStringToUnitType, NULL, 0);
- /*
- * get user-specified resources...
- */
- SetResourceDatabase();
-
- XtGetApplicationResources(toplevel, &appInfo, AppResources,
- XtNumber(AppResources), NULL, 0);
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("main: got application resources ...");
- #endif /* VG_TRACE */
-
- /*
- * build widgets...
- */
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("main: making UI ...");
- #endif /* VG_TRACE */
- MakeBackground(); /* login_shell, table, matte */
- MakeLogo(); /* logo, logo_pixmap, logo_shadow */
- MakeGreeting(); /* greeting */
- MakeLogin(); /* login_matte ... */
- MakeDtlabel(); /* Show Desktop selection in options menu*/
- /*
- * grab the display and keyboard...
- * moved it from before to after creating text widgets in MakeLogin
- * RK 01.11.94
- */
- if ( ! nograb )
- SecureDisplay();
- MakeButtons(); /* ok, clear, options, help buttons */
- MakeDialog(copyright); /* copyright dialog */
- if (appInfo.optionsDelay == 0 )
- MakeOptionsMenu(); /* make option_button pop-up menu */
- else
- XtAddTimeOut((unsigned long) appInfo.optionsDelay * 1000,
- MakeOptionsProc, NULL);
- MakeAltDtButtons(); /* make alt desktop buttons, if any */
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("main: made UI ...");
- #endif /* VG_TRACE */
- /*
- * Add request callback.
- XtAddInput(0, (XtPointer)XtInputReadMask, RequestCB, NULL);
- */
-
- /*
- * force the focus to the login_text widget...
- */
- /*
- XtAddEventHandler(login_text, ExposureMask, False,
- FakeFocusIn, NULL);
- */
- /*
- * create windows for the widgets...
- */
-
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("main: going to realize login_shell ...");
- #endif /* VG_TRACE */
- XtRealizeWidget(login_shell);
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("main: realized login_shell ...");
- #endif /* VG_TRACE */
-
-
- /*
- * miscellaneous stuff...
- *
- * - turn off keyboard bell
- * - return root cursor to normal from hourglass
- * - start pinging the server
- */
-
- ChangeBell("off");
- if (appInfo.workspaceCursor)
- {
- MakeRootCursor();
- }
- else
- {
- XUndefineCursor(dpyinfo.dpy, dpyinfo.root);
- }
- PingServerCB(NULL, NULL);
-
- /*
- * bring up the windows and enter event loop...
- */
- XRaiseWindow(XtDisplay(greeting), XtWindow(greeting));
- /*
- XRaiseWindow(XtDisplay(logo_shadow), XtWindow(logo_shadow));
- XRaiseWindow(XtDisplay(logo), XtWindow(logo));
- */
- /* XtPopup(login_shell, XtGrabNone); */
- _DtEnvControl( DT_ENV_RESTORE_PRE_DT );
- /*
- * Add request callback.
- */
- sleep(5);
- XtAddInput(0, (XtPointer)XtInputReadMask, RequestCB, NULL);
-
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("main: entering XtMainLoop ...");
- #endif /* VG_TRACE */
- XtMainLoop();
- exit (0);
- }
- /***************************************************************************
- *
- * InitToolKit
- *
- * initialize the toolkit
- ***************************************************************************/
- #define MINTIMEOUT 20
- static sigjmp_buf syncJump;
- static SIGVAL
- syncTimeout( int arg )
- {
- siglongjmp (syncJump, 1);
- }
- static Widget
- InitToolKit( int argc, char **argv )
- {
-
- int timeout; /* timeout to initialize toolkit */
- char *t;
- Widget root;
-
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("InitToolKit: enter ...");
- #endif /* VG_TRACE */
- /*
- * use server grabTimeout as initial value for timeout...
- */
- timeout = ((t = (char *)getenv(GRABTIMEOUT)) == NULL ? 0 : atoi(t));
- timeout += MINTIMEOUT; /* minimum MINTIMEOUT seconds */
- /*
- * initialize the toolkit. Wrap a timer around it in case the server
- * is grabbed.
- */
- signal (SIGALRM, syncTimeout);
- if (sigsetjmp (syncJump, 1)) {
- LogError(
- ReadCatalog(MC_LOG_SET,MC_LOG_NO_DPYINIT,MC_DEF_LOG_NO_DPYINIT),
- dpyinfo.name);
- exit(NOTIFY_RESTART);
- }
- alarm ((unsigned) timeout);
- root = XtInitialize("dtlogin", "Dtlogin", NULL, 0,
- &argc, argv);
- /* Disable Drag and Drop RK 11.02.93 */
- XtVaSetValues(XmGetXmDisplay(XtDisplay(root)),
- XmNdragInitiatorProtocolStyle, XmDRAG_NONE,
- NULL);
-
- alarm (0);
- signal (SIGALRM, SIG_DFL);
- return(root);
- }
- /***************************************************************************
- *
- * MakeRootCursor
- *
- * Widgets: none
- ***************************************************************************/
- static void
- MakeRootCursor( void )
- {
- Cursor vg_cursor;
- vg_cursor = XCreateFontCursor (dpyinfo.dpy, XC_left_ptr);
- XDefineCursor (dpyinfo.dpy, dpyinfo.root, vg_cursor);
- return;
- }
- /***************************************************************************
- *
- * MakeBackground
- *
- * Widgets: login_shell, table, matte
- ***************************************************************************/
- static void
- MakeBackground( void )
- {
- int i;
-
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("MakeBackground: entered ...");
- #endif /* VG_TRACE */
- /*
- * create the login shell widget...
- */
- i = 0;
- /* CORE resource set */
- XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
- XtSetArg(argt[i], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP ); i++;
- XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
- XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
- XtSetArg(argt[i], XmNsensitive, True ); i++;
- XtSetArg(argt[i], XmNtranslations, NULL ); i++;
- /* COMPOSITE resource set */
- XtSetArg(argt[i], XmNinsertPosition, NULL ); i++;
- /* SHELL resource set (set to avoid interference by user) */
- XtSetArg(argt[i], XmNallowShellResize, False ); i++;
- XtSetArg(argt[i], XmNcreatePopupChildProc, NULL ); i++;
- XtSetArg(argt[i], XmNgeometry, NULL ); i++;
- XtSetArg(argt[i], XmNpopupCallback, NULL ); i++;
- XtSetArg(argt[i], XmNpopdownCallback, NULL ); i++;
- XtSetArg(argt[i], XmNoverrideRedirect, False ); i++;
- XtSetArg(argt[i], XmNsaveUnder, False ); i++;
- login_shell = XtCreatePopupShell("login_shell", transientShellWidgetClass,
- toplevel, argt, i);
- XtAddCallback(login_shell, XmNpopupCallback, LayoutCB, NULL);
- /* Fix to display Input Method's status area. */
- XtSetArg(argt[0], XmNheight, dpyinfo.height);
- XtSetValues(login_shell, argt, 1);
- /*
- * create the full-screen drawing area...
- */
- i = InitArg(DrawingA);
- XtSetArg(argt[i], XmNwidth, dpyinfo.width ); i++;
- XtSetArg(argt[i], XmNheight, dpyinfo.height ); i++;
- XtSetArg(argt[i], XmNunitType, XmPIXELS ); i++;
- table = XtCreateManagedWidget("table", xmDrawingAreaWidgetClass,
- login_shell, argt, i);
- XtAddEventHandler(table, ButtonPressMask, False, RefreshEH, NULL);
- XtAddCallback(table, XmNhelpCallback, ShowDialogCB, (XtPointer) help);
- /*
- * create the main matte...
- */
- i = InitArg(Form);
- /* XmNwidth, (set by user) */
- /* XmNheight, (set by user) */
- XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
- /*
- XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
- XtSetArg(argt[i], XmNshadowThickness, 5 ); i++;
- */
- matte = XmCreateForm(table, "matte", argt, i);
- XtManageChild(matte);
- i = 0;
- XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
- XtSetArg(argt[i], XmNshadowThickness, 2); i++;
- XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
- /*
- XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
- */
- XtSetArg(argt[i], XmNtopOffset, 15); i++;
- XtSetArg(argt[i], XmNbottomOffset, 15); i++;
- XtSetArg(argt[i], XmNleftOffset, 15); i++;
- /*
- XtSetArg(argt[i], XmNrightOffset, 15); i++;
- */
- matteFrame = XmCreateFrame(matte, "matteFrame", argt, i);
- XtManageChild(matteFrame);
- i = 0;
- matte1 = XmCreateForm(matteFrame, "matte1", argt, i);
- XtManageChild(matte1);
-
- }
- static void
- MakeAltDtButtons( void )
- {
- int i,j;
- struct stat statb;
- char *startup_name;
- XrmValue startup_value;
- char temp[MAXPATHLEN] = "\0";
- char *session;
- FILE *ls;
- char lastsess[MAXPATHLEN];
- Widget default_dt = NULL;
- int default_is_custom_dt = True;
- int found_alt_dt = False;
- char *temp_p;
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("MakeAltDtButtons: entered ...");
- #endif /* VG_TRACE */
- if (getenv("SESSION_SET") == NULL) {
- default_is_custom_dt = False;
- }
- if ((session = getenv ("SESSION")) == NULL) {
- session = " ";
- }
- if(appInfo.altDts > 0) {
- if ((alt_dts =
- (Widget *) calloc(appInfo.altDts, sizeof (Widget))) == NULL)
- LogError(
- ReadCatalog(MC_ERROR_SET,MC_NO_MEMORY, MC_DEF_NO_MEMORY),
- dpyinfo.name);
- for(i = 0; i < appInfo.altDts; ++i) {
- int is_default;
- is_default = FALSE;
- /* alt desktops begin numbering with 1 */
- sprintf(altdtname,"%s%d", "Dtlogin*altDtName",i+1);
- sprintf(altdtclass,"%s%d", "Dtlogin*AltDtName",i+1);
- sprintf(altdtkey,"%s%d","Dtlogin*altDtKey",i+1);
- sprintf(altdtkeyclass,"%s%d","Dtlogin*AltDtKey",i+1);
- sprintf(altdtstart,"%s%d","Dtlogin*altDtStart",i+1);
- sprintf(altdtstartclass,"%s%d","Dtlogin*AltDtStart",i+1);
- if (XrmGetResource(
- XtDatabase(dpyinfo.dpy),
- altdtkey, altdtkeyclass,
- &keyrmtype, &keyrmvalue) == True) {
- /*
- * remove trailing spaces
- */
- if(strchr(keyrmvalue.addr,' '))
- temp_p = strtok(keyrmvalue.addr," ");
- else
- temp_p = keyrmvalue.addr;
- /*
- * Make sure the key file exists.
- */
- if (stat( temp_p, &statb) == 0) {
- j = InitArg(ToggleBG);
- if (XrmGetResource(
- XtDatabase(dpyinfo.dpy),
- altdtstart, altdtstartclass,
- &startup_name, &startup_value) == True) {
- /*
- * remove trailing spaces
- */
- if (strchr(startup_value.addr, ' '))
- snprintf(temp, sizeof(temp), "%s", strtok(startup_value.addr, " "));
- else
- snprintf(temp, sizeof(temp), "%s", startup_value.addr);
- if (default_is_custom_dt)
- if (strcmp(session, temp) == 0) {
- is_default = TRUE;
- }
- }
- else
- LogError((unsigned char *)"No startup script for altdt %d \n", i);
- if (XrmGetResource(
- XtDatabase(dpyinfo.dpy),
- altdtname, altdtclass,
- &rmtype, &rmvalue) == True) {
- if (! strncmp(rmvalue.addr, DISPLAYNAME, strlen(DISPLAYNAME))) {
- char *host;
- host = GetDisplayName();
- snprintf(temp, sizeof(temp), "%s - %s", host, rmvalue.addr + strlen(DISPLAYNAME));
- xmstr = XmStringCreateLocalized(temp);
- }
- else {
- xmstr = XmStringCreateLocalized(rmvalue.addr);
- }
- }
- else {
- LogError((unsigned char *)
- "Couldn't find the altdtname resource in the db\n");
- sprintf(altdtname,"%s%d", "Alternate Desktop-",i+1);
- xmstr = XmStringCreateLocalized(altdtname);
- }
- sprintf(altdtlogo,"%s%d","Dtlogin*altDtLogo",i+1);
- sprintf(altlogoclass,"%s%d","Dtlogin*AltDtLogo",i+1);
- if (XrmGetResource(
- XtDatabase(dpyinfo.dpy),
- altdtlogo, altlogoclass,
- &logotype, &logovalue) == True) {
- XtSetArg(argt[j], XmNuserData, logovalue.addr); j++;
- }
- else{
- XtSetArg(argt[j], XmNuserData, logoInfo.bitmapFile); j++;
- }
- XtSetArg(argt[j], XmNlabelString, xmstr); j++;
- XtSetArg(argt[j], XmNrecomputeSize, True); j++;
-
- alt_dts[i] = XmCreateToggleButtonGadget(
- session_menu,
- rmvalue.addr, argt, j);
- XmStringFree(xmstr);
- XtAddCallback(
- alt_dts[i],
- XmNvalueChangedCallback, MenuItemCB,
- (XtPointer) OB_ALT_DTS);
- XtManageChild(alt_dts[i]);
- found_alt_dt = True;
- if (is_default)
- default_dt = alt_dts[i];
- }
- else
- LogError((unsigned char *) "Couldn't find the keyfile \n");
- }
- else
- LogError((unsigned char *)
- "Couldn't find the altkeyfile resource in the database\n");
- }
- }
- if ((appInfo.altDts == 0) || !found_alt_dt)
- XtManageChild(options_dt);
-
- /*
- * Use the regular desktop if none of the known sessions matched the
- * specified custom session.
- */
- if (default_is_custom_dt && NULL == default_dt) {
- default_dt = options_dt;
- if (found_alt_dt)
- XtManageChild(options_dt);
- }
- /*
- * [ Failsafe Session ] menu pane...
- */
- i = InitArg(ToggleBG);
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_FS_LABEL, MC_DEF_FS_LABEL);
- XtSetArg(argt[i], XmNuserData, logoInfo.bitmapFile ); i++;
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
- options_failsafe = XmCreateToggleButtonGadget(session_menu,
- "options_failsafe", argt, i);
- XmStringFree(xmstr);
- XtAddCallback(options_failsafe, XmNvalueChangedCallback,
- MenuItemCB, (XtPointer) OB_FAILSAFE);
- XtManageChild(options_failsafe);
- /*
- * which option to set..
- */
- SetDefaultDt(default_dt);
- SetDtLabelAndIcon();
- }
- /***************************************************************************
- *
- * MakeButtons
- *
- * Widgets: ok_button, clear_button, options_button, help_button
- ***************************************************************************/
- static void
- MakeButtons( void )
- {
- int i;
- Dimension max_width; /* maximum width of a set of widgets */
- Dimension max_height; /* maximum height of a set of widgets */
- Dimension thick1; /* defaultButtonShadowThickness */
- Dimension thick2; /* shadowThickness */
- int origin; /* horizontal origin for button placement */
- int spacing; /* spacing between buttons (width/32) */
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("MakeButtons: entered ...");
- #endif /* VG_TRACE */
-
- /*
- * create the buttons...
- */
- /* ok button */
-
- i = InitArg(PushBG);
- XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(argt[i], XmNbottomPosition, 95); i++;
- XtSetArg(argt[i], XmNtraversalOn, True); i++;
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL );
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- ok_button = XmCreatePushButtonGadget(matte1, "ok_button", argt, i);
- XmStringFree(xmstr);
- XtManageChild(ok_button);
- XtAddCallback(ok_button, XmNactivateCallback, RespondChallengeCB, NULL);
- /* clear button */
- i -= 1;
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_CLEAR_LABEL, MC_DEF_CLEAR_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- clear_button = XmCreatePushButtonGadget(matte1, "clear_button", argt, i);
- XmStringFree(xmstr);
- XtManageChild(clear_button);
- XtAddCallback(clear_button, XmNactivateCallback, RespondClearCB,
- (XtPointer) 0);
- /* help button */
-
- i -= 1;
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- help_button = XmCreatePushButtonGadget(matte1, "help_button", argt, i);
- XtAddCallback(help_button, XmNactivateCallback, ShowDialogCB,
- (XtPointer) help);
- XmStringFree(xmstr);
- XtManageChild(help_button);
- /* options button */
- i = InitArg(Label);
- XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(argt[i], XmNbottomPosition, 95); i++;
- xmstr = ReadCatalogXms(
- MC_LABEL_SET,
- MC_OPTIONS_LABEL,
- MC_DEF_OPTIONS_LABEL );
- XtSetArg(argt[i], XmNlabelString, xmstr); i++;
- XtSetArg(argt[i], XmNtraversalOn, True); i++;
- options_button = DtCreateMenuButton(matte1, "options_button", argt, i);
- XtOverrideTranslations(
- options_button,
- XtParseTranslationTable(" <Key> Return: Select()"));
- XtManageChild(options_button);
- XmStringFree(xmstr);
- /*
- * tell form that ok_button is the default button...
- */
- i = 0;
- XtSetArg(argt[i], XmNdefaultButton, ok_button ); i++;
- XtSetValues(matte1, argt, i);
-
- /*
- * make all buttons *look* the same size...
- */
-
- max_width = max_height = 0;
- GetBiggest(ok_button, &max_width, &max_height);
- GetBiggest(clear_button, &max_width, &max_height);
- GetBiggest(options_button, &max_width, &max_height);
- GetBiggest(help_button, &max_width, &max_height);
- if ( (int) max_width < MIN_BUTTON_SIZE) max_width = MIN_BUTTON_SIZE;
-
- i = 0;
- XtSetArg(argt[i], XmNdefaultButtonShadowThickness, &thick1); i++;
- XtSetArg(argt[i], XmNshadowThickness, &thick2); i++;
- XtGetValues(ok_button, argt, i);
- thick1 *= 4;
- thick1 += thick2;
- i = 0;
- XtSetArg(argt[i], XmNwidth, max_width ); i++;
- XtSetArg(argt[i], XmNheight, max_height ); i++;
- XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
- XtSetArg(argt[i], XmNbottomOffset, thick1 ); i++;
- XtSetValues(options_button, argt, i);
- i = 0;
- XtSetArg(argt[i], XmNwidth, max_width + 2*thick1 ); i++;
- XtSetArg(argt[i], XmNheight, max_height + 2*thick1 ); i++;
- XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
- XtSetValues(ok_button, argt, i);
- XtSetValues(clear_button, argt, i);
- XtSetValues(help_button, argt, i);
- }
- /***************************************************************************
- *
- * MakeDialog
- *
- * Widgets: error_message, help_message, copyright_msg, hostname_message,
- * passwd_message
- ***************************************************************************/
- void
- MakeDialog( DialogType dtype )
- {
- int i, j;
- int width;
-
- FILE *fp, *fopen();
- char buffer[128];
- Widget w = NULL, text;
- Dimension txt_width, txt_height;
- XmString ok, cancel, nw, sv;
- Widget tlev; /* JET - warning, there be dragons here */
- unsigned int dpwidth, dpheight, xorg, yorg;
-
-
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("MakeDialog: entered ...");
- #endif /* VG_TRACE */
- /*
- * do things common to all dialogs...
- */
- #ifdef USE_XINERAMA
- /* get info on prefered screen */
- if (!_DtXineramaGetScreen(dpyinfo.DtXineramaInfo,
- appInfo.xineramaPreferredScreen,
- &dpwidth, &dpheight, &xorg, &yorg))
- { /* no joy here either - setup for normal */
- dpwidth = dpyinfo.width;
- dpheight = dpyinfo.height;
- xorg = yorg = 0;
- }
- /* else, should be setup properly */
- XWarpPointer(dpyinfo.dpy,None,dpyinfo.root,0,0,0,0,dpwidth/2,dpheight/2);
- #else /* no Xinerama */
- dpwidth = dpyinfo.width;
- dpheight = dpyinfo.height;
- xorg = yorg = 0;
- #endif
- ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
- cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
- i = InitArg(MessageBox);
- XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++;
- XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++;
- XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
- XtSetArg(argt[i], XmNokLabelString, ok ); i++;
- XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++;
- XtSetArg(argt[i], XmNnoResize, False ); i++;
- XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
- /*
- * create the various dialogs...
- */
- /* JET - check the matte widget, and if non-null, well use that as
- * the parent for dialogs. Otherwise use table (the original
- * toplevel widget for this func). This is useful for Xinerama so
- * that child dialogs are centered on the matte, and not the whole
- * SLS screen.
- */
- if (matte != (Widget)NULL)
- tlev = matte;
- else
- tlev = table;
- switch (dtype) {
- case error:
- xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
- XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
- w = XmCreateErrorDialog(tlev, "error_message", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
- error_message = w;
- break;
- case help:
- txt_width = (dpwidth > 850) ? 800 : dpwidth - 50;
- txt_height = (dpheight > 900) ? 600 : dpheight - 300;
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
- XtSetArg(argt[i], XmNmessageString, xmstr); i++;
- w = XmCreateInformationDialog(tlev, "help_message", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
- i = InitArg(Text);
- XtSetArg(argt[i], XmNheight, txt_height); i++;
- XtSetArg(argt[i], XmNwidth, txt_width); i++;
- XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
- XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
- XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
- XtSetArg(argt[i], XmNeditable, False); i++;
- XtSetArg(
- argt[i],
- XmNvalue, ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP)); i++;
- text = XmCreateScrolledText(w, "help_message_text", argt, i);
- XtManageChild(text);
- XtManageChild(w);
- help_message = w;
- break;
- case copyright:
- if ((fp = fopen(COPYRIGHT,"r")) == NULL)
- xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
- XmFONTLIST_DEFAULT_TAG);
- else {
- xmstr = (XmString) NULL;
-
- while (fgets(buffer, 128, fp) != NULL) {
- j = strlen(buffer);
- if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
-
- if ( xmstr != NULL )
- xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
- xmstr = XmStringConcat(xmstr,
- XmStringCreate(buffer,
- XmFONTLIST_DEFAULT_TAG));
- }
- fclose(fp);
- }
- XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
- w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
-
- XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);
- copyright_msg = w;
- break;
-
- case hostname:
-
- nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
- sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);
- xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
- XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
- XtSetArg(argt[i], XmNokLabelString, nw ); i++;
- XtSetArg(argt[i], XmNcancelLabelString, sv ); i++;
- w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
- XmStringFree(nw);
- XmStringFree(sv);
- hostname_message = w;
- break;
- case expassword:
- xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED,
- MC_DEF_PASSWD_EXPIRED);
- XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
- w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
- passwd_message = w;
- break;
- }
- /*
- * finish up...
- */
- switch (dtype) {
- case error:
- case hostname:
- case expassword:
- XtAddCallback(w, XmNokCallback, RespondDialogCB, NULL);
- XtAddCallback(w, XmNcancelCallback, RespondDialogCB, NULL);
- break;
- }
- XtSetArg(argt[0], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); i++;
- if(w) {
- XtSetValues(w, argt, 1);
- }
- XmStringFree(xmstr);
- XmStringFree(ok);
- XmStringFree(cancel);
- /*
- * adjust the width of the "ok" button on the dialogs...
- */
- width = (dtype == hostname ? FromMM(4000) : MIN_BUTTON_SIZE);
-
- i = 0;
- XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
- XtSetArg(argt[i], XmNwidth, width ); i++;
- XtSetValues(XmMessageBoxGetChild(w, XmDIALOG_OK_BUTTON), argt, i);
- }
- /***************************************************************************
- *
- * MakeDtlabel
- *
- * Widgets: dt_label
- ***************************************************************************/
- static void
- MakeDtlabel( void )
- {
- int i;
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("MakeDtlabel: entered ...");
- #endif /* VG_TRACE */
- i = InitArg(LabelG);
- XtSetArg(argt[i], XmNtraversalOn, False ); i++;
- XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET ); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM ); i++;
- XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM ); i++;
- XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;
- XtSetArg(argt[i], XmNtopWidget, greeting ); i++;
-
- dt_label = XmCreateLabel(matte1, "dt_label", argt, i);
- XtManageChild(dt_label);
- }
- /***************************************************************************
- *
- * MakeGreeting
- *
- * Widgets: greeting
- ***************************************************************************/
- typedef struct {
- char *labelString; /* string for label */
- char *persLabelString; /* alternate string for label */
- XmFontList fontList;
- } GreetInfo, *GreetInfoPtr;
- static GreetInfo greetInfo;
- static XtResource greetResources[] = {
- {XmNlabelString, XmCLabelString,
- XmRString, sizeof(char *),
- XtOffset(GreetInfoPtr, labelString), XtRString, "default" },
- {"persLabelString", "PersLabelString",
- XmRString, sizeof(char *),
- XtOffset(GreetInfoPtr, persLabelString), XtRString, "default" },
- {XmNfontList, XmCFontList,
- XmRFontList, sizeof(XmFontList),
- XtOffset(GreetInfoPtr, fontList), XtRString, NULL }
- };
- static void
- MakeGreeting( void )
- {
- int i;
- char *greetmsg;
- char host[128];
- char disp[128];
- char *p, *q, *s, *t;
- int newLine = False;
- int skip;
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("MakeGreeting: entered ...");
- #endif /* VG_TRACE */
- /*
- * get the user's greeting preferences...
- */
-
- XtGetSubresources(table, &greetInfo, "greeting", "Greeting",
- greetResources, XtNumber(greetResources), NULL, 0);
- /*
- * get the local hostname...
- */
-
- gethostname(host, sizeof (host));
- if ( (p = strchr(host,'.')) != NULL )
- *p = '\0';
- /*
- ** Get display name (for %DisplayName% substitutions),
- ** reducing "a.b.c.d:0" constructs to shorter "a:0" form.
- */
- strncpy(disp,
- dpyinfo.name ? dpyinfo.name : (DisplayString(dpyinfo.dpy)), 127);
- disp[127] = '\0';
- p = strchr(disp, '.');
- t = strchr(disp, ':');
- if (p && t) strcpy(p,t);
-
- /*
- * use the default string if the user has not specified one...
- */
- if ( greetInfo.persLabelString &&
- strcmp(greetInfo.persLabelString, "default") == 0 ) {
- const char *msg;
- msg =
- (const char *)
- ReadCatalog(MC_LABEL_SET,MC_PERS_GREET_LABEL,MC_DEF_PERS_GREET_LABEL);
- greetInfo.persLabelString = strdup(msg);
- }
-
- if ( greetInfo.labelString &&
- strcmp(greetInfo.labelString, "default") == 0 ) {
-
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_GREET_LABEL,MC_DEF_GREET_LABEL);
- xmstr = XmStringConcat(xmstr,
- XmStringCreate(" ", XmFONTLIST_DEFAULT_TAG));
- xmstr = XmStringConcat(xmstr,
- XmStringCreate(host, XmFONTLIST_DEFAULT_TAG));
- }
- else {
- /*
- * scan user's message for %LocalHost% token. Replace with hostname
- * if found...
- */
-
- if ( !greetInfo.labelString ||
- strlen(greetInfo.labelString) == 0 ||
- strcmp(greetInfo.labelString, "None") == 0 ||
- strcmp(greetInfo.labelString, "none") == 0 )
-
- greetmsg = strdup(" ");
- else {
- greetmsg = strdup(greetInfo.labelString);
- }
- s = greetmsg;
- xmstr = (XmString) NULL;
- do {
- q = s;
-
- /*
- * scan for a new line character in remaining label string.
- * If found, work with that substring first...
- */
-
- if ( (p = strchr(q, '\n')) != NULL ) {
- *p = '\0';
- newLine = True;
- s = ++p;
- if ( *q == '\0' ) /* handle consecutive newlines */
- q = " ";
-
- }
- else {
- newLine = False;
- }
-
- /*
- * replace all occurrences of %LocalHost% and %DisplayName%
- * in the current substring...
- */
-
- while (1) {
- p = strstr(q, LOCALHOST);
- t = strstr(q, DISPLAYNAME);
-
- if (p && t) { /* both present? do whichever comes first */
- if (p > t) p = NULL;
- else t = NULL;
- }
- if (p) { /* replace a %LocalHost% string */
- t = host;
- skip = sizeof(LOCALHOST);
- } else if (t) { /* replace a %DisplayName% string */
- p = t;
- t = disp;
- skip = sizeof(DISPLAYNAME);
- } else /* nothing left to replace */
- break;
- *p = '\0';
- xmstr = XmStringConcat(xmstr,
- XmStringCreate(q,
- XmFONTLIST_DEFAULT_TAG));
- xmstr = XmStringConcat(xmstr,
- XmStringCreate(t,
- XmFONTLIST_DEFAULT_TAG));
- q = p + skip - 1;
- }
- if ( strlen(q) != 0 )
- xmstr = XmStringConcat(xmstr,
- XmStringCreate(q,
- XmFONTLIST_DEFAULT_TAG));
- /*
- * add a line separator if this is a multi-line greeting...
- */
-
- if ( newLine == True ) {
- xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
- }
-
- } while ( newLine == True ) ;
-
- free(greetmsg);
- }
- /*
- * create the Welcome message...
- */
-
- i = InitArg(LabelG);
- XtSetArg(argt[i], XmNtraversalOn, False ); i++;
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNtopAttachment, XmATTACH_POSITION); i++;
- /* XtSetArg(argt[i], XmNtopPosition, 15); i++; */
- /* Changed this to accommodate desktop label */
- XtSetArg(argt[i], XmNtopPosition, 9); i++;
- XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
- /*
- * use the user's font if one has been specified, otherwise use
- * the application's default...
- */
- if ( greetInfo.fontList != NULL ) {
- XtSetArg(argt[i], XmNfontList, greetInfo.fontList ); i++;
- }
- greeting = XmCreateLabel(matte1, "greeting", argt, i);
- XtManageChild(greeting);
- XmStringFree(xmstr);
- }
- /***************************************************************************
- *
- * MakeLogin
- *
- * Widgets: login_matte,
- * login_form, login_label, login_text
- ***************************************************************************/
- static void
- MakeLogin( void )
- {
- int i;
- int j;
- LoginTextPtr textdata;
- XtTranslations textTable;
- Widget passwd_text;
- String greetstr;
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("MakeLogin: entered ...");
- #endif /* VG_TRACE */
- /*
- * create the login form
- */
- i = 0;
- XtSetArg(argt[i], XmNshadowThickness, 0); i++;
- XtSetArg(argt[i], XmNresizable, False ); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNleftOffset, 80); i++;
- XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNrightOffset, 80); i++;
- XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(argt[i], XmNbottomPosition, 65); i++;
- /*
- XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY); i++;
- */
- XtSetArg(argt[i], XmNallowShellResize, True); i++;
- login_form = XmCreateForm(matte1, "login_form", argt, i);
- XtManageChild(login_form);
- /*
- * create the login text field...
- */
- i = InitArg(Text);
- XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION ); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_POSITION ); i++;
- XtSetArg(argt[i], XmNrightAttachment, XmATTACH_POSITION ); i++;
- XtSetArg(argt[i], XmNbottomPosition, 95 ); i++;
- XtSetArg(argt[i], XmNrightPosition, 80 ); i++;
- XtSetArg(argt[i], XmNleftPosition, 20 ); i++;
- XtSetArg(argt[i], XmNselectionArrayCount, 1 ); i++;
- XtSetArg(argt[i], XmNmaxLength, 80 ); i++;
- XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
- textdata = malloc(sizeof(LoginText));
- XtSetArg(argt[i], XmNuserData, textdata ); i++;
- login_text = XmCreateTextField(login_form, "login_text", argt, i);
- /*
- * From Human Interface model, Tab key operation should work same on
- * user field as it does on password field. Password field is setup
- * to take Tab key as password data. HIE model is for user field to
- * do same.
- */
- XtOverrideTranslations(
- login_text,
- XtParseTranslationTable(
- " Shift <Key>Tab: prev-tab-group() \n\
- Ctrl <Key>Tab: next-tab-group() "));
- XtManageChild(login_text);
- XtAddActions(textActions, 2);
- textTable = XtParseTranslationTable(textEventBindings);
- #if 0
- XtSetArg(argt[i], XmNtranslations, textTable ); i++;
- #endif
- XtSetArg(argt[i], XmNverifyBell, False ); i++;
- passwd_text = XmCreateTextField(login_form, "passwd_text", argt, i);
- textdata->bEcho = True;
- textdata->noechobuf[0] = '\0';
- textdata->text[0] = passwd_text;
- textdata->text[1] = login_text;
- XtManageChild(passwd_text);
- XtAddCallback(passwd_text, XmNmodifyVerifyCallback, EditPasswdCB, NULL);
- /*
- * Get default greeting string
- */
- i = 0;
- XtSetArg(argt[i], XmNlabelString, &textdata->onGreeting); i++;
- XtGetValues(greeting, argt, i);
- textdata->offGreetingFormat = greetInfo.persLabelString;
- textdata->offGreetingUname = NULL;
- /*
- * create the login labels...
- */
- i = InitArg(LabelG);
- /* modified recomputeSize initial value from False to True, fails
- * when setting longer strings. Manifested as bug ID:1200690.
- */
- XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
- XtSetArg(argt[i], XmNtraversalOn, False ); i++;
- XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET ); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
- /* XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM ); i++;
- Commented this statement to align login_label and login_text
- XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM ); i++;
- XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;
- XtSetArg(argt[i], XmNbottomOffset, 10 ); i++;
- */
- XtSetArg(argt[i], XmNleftWidget, login_text ); i++;
- XtSetArg(argt[i], XmNbottomWidget, login_text ); i++;
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LOGIN_LABEL, MC_DEF_LOGIN_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
-
- login_label = XmCreateLabel(login_form, "login_label", argt, i);
- XtManageChild(login_label);
- XmStringFree(xmstr);
- }
- /***************************************************************************
- *
- * MakeOptionsMenu
- *
- * Widgets: options_menu, options_item[]
- ***************************************************************************/
- void
- MakeOptionsMenu( void )
- {
- int i, j, k;
- struct stat statb;
- #ifdef VG_TRACE
- vg_TRACE_EXECUTION("MakeOptionsMenu: entered ...");
- #endif /* VG_TRACE */
- /*
- * get the built-in pop_up menu from the DtMenuButton...
- */
-
- XtVaGetValues(options_button, DtNsubMenuId, &options_menu, NULL);
- /*
- * create language cascade menus...
- */
- if ( lang_menu == NULL )
- MakeLangMenu();
- /*
- * create first level menu items...
- */
- j = 0;
- /*
- * build [ Language ] menu pane if there are languages to choose from...
- */
- if ( lang_menu != NULL ) {
- /*
- * [ Language ] menu pane...
- * attach language cascade menu to this pane
- */
- i = InitArg(CascadeBG);
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LANG_LABEL, MC_DEF_LANG_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- XtSetArg(argt[i], XmNsubMenuId, lang_menu ); i++;
- XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
- options_item[j] = XmCreateCascadeButtonGadget(options_menu,
- "options_languages", argt, i);
- XmStringFree(xmstr);
- j++;
- /*
- * separator...
- */
- i = InitArg(SeparatorG);
- options_item[j] = XmCreateSeparatorGadget(options_menu,
- "options_sep2",
- argt, i);
- j++;
- }
- if( session_menu == NULL) {
- session_menu = XmCreatePulldownMenu(options_menu, "session_menu", NULL, 0);
- /*
- * [ Dt "Reg" ] menu pane...
- */
- i = k = InitArg(ToggleBG);
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_DT_LABEL, MC_DEF_DT_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
- XtSetArg(argt[i], XmNuserData, logoInfo.bitmapFile ); i++;
- options_dt = XmCreateToggleButtonGadget(session_menu,
- "options_dt",
- argt, i);
- XmStringFree(xmstr);
- XtAddCallback(options_dt,
- XmNvalueChangedCallback,
- MenuItemCB,
- (XtPointer) OB_DT);
- /*XtManageChild(options_dt); */
- /*
- * [ Dt Lite ] menu pane...
- */
- i = k;
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_DTLITE_LABEL, MC_DEF_DTLITE_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
- options_dtlite = XmCreateToggleButtonGadget(session_menu,
- "options_dtlite",
- argt, i);
- XmStringFree(xmstr);
- XtAddCallback(options_dtlite,
- XmNvalueChangedCallback,
- MenuItemCB,
- (XtPointer) OB_DTLITE);
- }
- if ( session_menu != NULL ) {
- /*
- * [ Language ] menu pane...
- * attach language cascade menu to this pane
- */
- i = InitArg(CascadeBG);
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_SES_LABEL, MC_DEF_SES_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- XtSetArg(argt[i], XmNsubMenuId, session_menu ); i++;
- XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
- options_item[j] = XmCreateCascadeButtonGadget(options_menu,
- "session_menus", argt, i);
- XmStringFree(xmstr);
- j++;
- /*
- * separator...
- */
- i = InitArg(SeparatorG);
- options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
- argt, i);
- j++;
- }
- /*
- * [ No Windows ] menu pane...
- */
- i = k = InitArg(PushBG);
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- options_item[j] = options_nowindows
- = XmCreatePushButtonGadget(options_menu,
- "options_noWindows",
- argt, i);
- XmStringFree(xmstr);
- XtAddCallback(options_item[j], XmNactivateCallback,
- MenuItemCB, (XtPointer) OB_NO_WINDOWS);
- if (getenv(LOCATION) == NULL || strcmp(getenv(LOCATION), "local") != 0 )
- XtSetSensitive(options_item[j], False);
- j++;
- /*
- * [ Restart Server ] menu pane...
- */
- i = k = InitArg(PushBG);
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_RS_LABEL, MC_DEF_RS_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- options_item[j] = XmCreatePushButtonGadget(options_menu,
- "options_restartServer",
- argt, i);
- XmStringFree(xmstr);
- XtAddCallback(options_item[j], XmNactivateCallback,
- MenuItemCB, (XtPointer) OB_RESTART_SERVER);
- j++;
- #ifdef copyright_option
- /*
- * separator...
- */
- i = InitArg(SeparatorG);
- options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
- argt, i);
- j++;
- /*
- * [ Copyright ] menu pane...
- */
- i = k = InitArg(PushBG);
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_COPY_LABEL, MC_DEF_COPY_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- options_item[j] = XmCreatePushButtonGadget(options_menu,
- "options_copyright",
- argt, i);
- XmStringFree(xmstr);
- XtAddCallback(options_item[j], XmNactivateCallback,
- MenuItemCB, (XtPointer) OB_COPYRIGHT);
- j++;
- #endif
- /*
- * manage the [Options] menu...
- */
- XtManageChildren(options_item, j);
- /*
- * If the DT Lite Session Manager is not available, remove the DT Lite
- * and DT menu panes. The actual widgets must still be created since
- * other code (ex. MenuItemCB()) tries to obtain some of their resources.
- */
-
- if ( stat(DTLITESESSION, &statb) != 0 ||
- ((statb.st_mode & S_IXOTH) != S_IXOTH) ) {
- XtUnmanageChild(options_dtlite);
- /*
- XtUnmanageChild(options_dt);
- */
- }
- if ( getenv(PINGINTERVAL) != NULL )
- XtUnmanageChild(options_nowindows);
-
- }
- /***************************************************************************
- *
- * MyInsert
- *
- * Local self-insert action for the text widget. The default action
- * discards control characters, which are allowed in password.
- ***************************************************************************/
- static void
- MyInsert( Widget w, XEvent *event, char **params, Cardinal *num_params )
- {
- char str[32];
- XComposeStatus compstatus;
- int n;
- n = XLookupString((XKeyEvent *)event, str, sizeof(str),
- (KeySym *)NULL, &compstatus);
- if (n > 0) {
- str[n] = '\0';
- XmTextFieldInsert(w, XmTextFieldGetInsertionPosition(w), str);
- }
- }
- /***************************************************************************
- *
- * MyBackspace
- *
- * Local backspace action for the text widget.
- * Deletes the last character of the password string in the
- * widget for each backspace key press, and also does not move the cursor
- * position in the widget.
- ***************************************************************************/
- static void
- MyBackspace( Widget w, XEvent *event, char **params, Cardinal *num_params )
- {
- LoginTextPtr textdata;
- textdata = GetLoginTextPtr(w);
- if (textdata && !textdata->bEcho && (int) strlen(textdata->noechobuf) > 0)
- {
- textdata->noechobuf[strlen(textdata->noechobuf) - 1] = '\0';
- }
- }
- /***************************************************************************
- *
- * ErrorHandler
- *
- * X protocol error handler to override the default
- ***************************************************************************/
- static int
- ErrorHandler( Display *dpy, XErrorEvent *event )
- {
- return 0;
- }
- /***************************************************************************
- *
- * xtErrorHandler
- *
- * Xt protocol error handler to override the default
- ***************************************************************************/
- static void
- xtErrorHandler( String msg )
- {
- LogError((unsigned char *) "%s\n", msg ) ;
- exit(NOTIFY_RESTART);
- }
- /***************************************************************************
- *
- * xtWarningHandler
- *
- * Xt protocol error handler to override the default
- ***************************************************************************/
- static void
- xtWarningHandler( String msg )
- {
- LogError( (unsigned char *) "%s\n", msg ) ;
- return ;
- }
- /***************************************************************************
- *
- * MakeOptionsProc
- *
- * Timeout routine to build options menu
- ***************************************************************************/
- static void
- MakeOptionsProc( XtPointer data, XtIntervalId *id )
- {
- if (options_menu == NULL)
- MakeOptionsMenu();
-
- return;
- }
- /***************************************************************************
- *
- * Terminate
- *
- * Catch a SIGTERM and unmanage display
- ***************************************************************************/
- static SIGVAL
- Terminate( int arg )
- {
- if(-1 == write(1, "terminate", 9)) {
- perror(strerror(errno));
- }
- CleanupAndExit(NULL, NOTIFY_ABORT);
- }
- /***************************************************************************
- *
- * DebugWidgetResources
- *
- * Get widget resources
- ***************************************************************************/
- typedef struct resource_values {
- int height;
- int width;
- int x;
- int y;
- int rightAttachment;
- int leftAttachment;
- int topAttachment;
- int bottomAttachment;
- } ResourceValues;
- static void
- DebugWidgetResources(Widget w)
- {
- struct resource_values values;
- int i;
- i = 0;
- bzero((char *) &values, sizeof(values));
- XtSetArg(argt[i], XmNheight, &values.height); i++;
- XtSetArg(argt[i], XmNwidth, &values.width); i++;
- XtSetArg(argt[i], XmNx, &values.x); i++;
- XtSetArg(argt[i], XmNy, &values.y); i++;
- XtSetArg(argt[i], XmNrightAttachment, &values.rightAttachment); i++;
- XtSetArg(argt[i], XmNleftAttachment, &values.leftAttachment); i++;
- XtSetArg(argt[i], XmNtopAttachment, &values.topAttachment); i++;
- XtSetArg(argt[i], XmNbottomAttachment, &values.bottomAttachment); i++;
- XtGetValues(w, argt, i);
- }
- /***************************************************************************
- *
- * GetDisplayName (void) - transform the display name into a "short"
- * host name that is used to create a display-specific session.
- *
- * The display name should match one of the following patterns:
- *
- * 1. host (non-qualified)
- * 2. host.domain
- * 3. host:n
- * 4. host:n.s
- * 5. host.domain:n
- * 6. host.domain:n.s
- *
- * Note that 1 and 2 will be used if the display name is actually
- * something like unix:0, local:0 or 0:0
- *
- ***************************************************************************/
- static char *
- GetDisplayName (void)
- {
- char host[MAXHOSTNAMELEN];
- static char tmp[MAXHOSTNAMELEN + 3];
- char * pch;
- char * col;
- char * dot;
- pch = XDisplayString(dpyinfo.dpy);
- if (!pch ||
- !strncmp (pch, "local:0", 7) ||
- !strncmp (pch, "unix:0", 6) ||
- !strncmp (pch, ":0.0", 4) ||
- !strncmp (pch, ":0", 2)) {
- gethostname (host, MAXHOSTNAMELEN);
- pch = host;
- }
- col = strchr (pch, ':');
- dot = strchr (pch, '.');
- if (!col) {
- if (dot) {
- strncpy (tmp, pch, dot - pch); /* case #2 above */
- tmp[dot - pch] = '\000';
- } else {
- strcpy (tmp, pch); /* case #1 above */
- }
- } else {
- if (!dot || (dot > col)) { /* case #3 and 4 above */
- strncpy (tmp, pch, col - pch);
- tmp[col - pch] = '\000';
- } else { /* case # 5 and 6 above */
- strncpy (tmp, pch, dot - pch);
- tmp[dot - pch] = '\000';
- }
- }
-
- strcat (tmp, ":0");
- return (tmp);
- }
|