123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529 |
- /*
- * 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: SmUI.c /main/32 1998/07/23 18:08:17 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: SmUI.c
- **
- ** Project: DT Session Manager (dtsession)
- **
- ** Description:
- ** -----------
- ** This file handles all UI components of the session manager. This
- ** includes all dialog boxes. The session manager does not handle its
- ** representations in the front panel and customizer. That is handled
- ** by those tools.
- **
- **
- **
- *******************************************************************
- ** (c) Copyright Hewlett-Packard Company, 1990. All rights are
- ** reserved. Copying or other reproduction of this program
- ** except for archival purposes is prohibited without prior
- ** written consent of Hewlett-Packard Company.
- ********************************************************************
- **
- **
- **
- *****************************************************************************
- *************************************<+>*************************************/
- #include <signal.h>
- #include <stdio.h>
- #include <sys/param.h>
- #include <X11/Intrinsic.h>
- #include <Xm/MwmUtil.h>
- #include <Xm/Xm.h>
- #include <Xm/PushB.h>
- #include <Xm/Form.h>
- #include <Xm/Label.h>
- #include <Xm/LabelG.h>
- #include <Xm/DrawingA.h>
- #include <Xm/Frame.h>
- #include <Xm/Separator.h>
- #include <Xm/MessageB.h>
- #include <Xm/DialogS.h>
- #include <Xm/Text.h>
- #include <Dt/DtP.h>
- #include <Dt/SessionM.h>
- #include <Dt/Icon.h>
- #include <Dt/MsgLog.h>
- #include <Dt/Lock.h>
- #include <Tt/tttk.h>
- #include "Sm.h"
- #include "SmUI.h"
- #include "SmSave.h"
- #include "SmRestore.h"
- #include "SmHelp.h"
- #include "SmGlobals.h"
- #ifdef USE_XINERAMA
- #include <DtXinerama.h>
- #endif
- typedef enum {
- ConfirmationNone,
- ConfirmationOK,
- ConfirmationCancel,
- ConfirmationHelp
- } ConfirmState;
- ConfirmState confirmState;
- /*
- * #define statements
- */
- #define PASSWORD_INDICATOR " "
- typedef struct _ExitRecord {
- Tt_message *pmsg;
- union {
- Widget exitCancelledDialog;
- int queryExitConfirmedMode;
- } u;
- Boolean doSave;
- } ExitRecord;
- /*
- * Global variables
- */
- DialogData smDD;
- Arg uiArgs[20];
- /*
- * Local Function Declarations
- */
- static int CompatModeExit( void ) ;
- static void ExitConfirmed( Widget, XtPointer, XtPointer ) ;
- static void ExitCancelled( Widget, XtPointer, XtPointer ) ;
- static void LockDialogUp( Widget, XtPointer, XtPointer ) ;
- static void SimpleOK( Widget, XtPointer, XtPointer ) ;
- static void ConfirmOKCB ( Widget, XtPointer, XtPointer ) ;
- static void ConfirmCancelCB ( Widget, XtPointer, XtPointer ) ;
- static void ConfirmHelpCB ( Widget, XtPointer, XtPointer ) ;
- static void XSMPFailureOKCB( Widget w, XtPointer client_data, XtPointer call_data );
- static void SaveTimeout( XtPointer , XtIntervalId *) ;
- /*
- * Local vars
- */
- static Boolean session_confirmed = False;
- static Boolean reasonsDialogOK;
- static Boolean saveTimeout;
- /*************************************<->*************************************
- *
- * CreateLockDialog ()
- *
- *
- * Description:
- * -----------
- * Create the lock dialog when it exists NOT as a part of a cover
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- Widget
- CreateLockDialog( void )
- {
- int i, slen;
- Widget loginLabel, instructLabel, tmpLock, indFrame;
- Widget passwdLabel, passwdForm, picFrame, loginPic, loginFrame;
- Dimension width; /* width, height of login label */
- XmString lockString, passwordString;
- char *lockMessage;
- char *envLog;
- Pixel fg, bg, focus_color; /* foreground, background colors */
-
- i = 0;
- XtSetArg(uiArgs[i], XmNallowShellResize, True); i++;
- XtSetArg(uiArgs[i], XmNmarginWidth, 0); i++;
- XtSetArg(uiArgs[i], XmNmarginHeight, 0); i++;
- XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness,5); i++;
- XtSetArg(uiArgs[i], XmNunitType, XmPIXELS); i++;
- XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
- XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
- XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
- XtSetArg(uiArgs[i], XmNmappedWhenManaged, True); i++;
- tmpLock = XmCreateFormDialog(smGD.topLevelWid, "lockDialog", uiArgs, i);
- XtAddCallback (XtParent(tmpLock), XmNpopupCallback,
- LockDialogUp, NULL);
- smDD.matte[0] = tmpLock;
- i = 0;
- XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
- XtSetArg(uiArgs[i], XmNmwmDecorations, 0);i++;
- XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
- XtSetValues(XtParent(tmpLock), uiArgs, i);
-
- i = 0;
- XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 2); i++;
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNtopOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNbottomOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNrightOffset, 15); i++;
- picFrame = XmCreateFrame(tmpLock, "picFrame", uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNforeground, &fg); i++;
- XtSetArg(uiArgs[i], XmNbackground, &bg); i++;
- XtGetValues(tmpLock, uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNfillMode, XmFILL_SELF); i++;
- XtSetArg(uiArgs[i], XmNbehavior, XmICON_LABEL); i++;
- XtSetArg(uiArgs[i], XmNpixmapForeground, fg); i++;
- XtSetArg(uiArgs[i], XmNpixmapBackground, bg); i++;
- XtSetArg(uiArgs[i], XmNstring, NULL); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
- XtSetArg(uiArgs[i], XmNtraversalOn, False); i++;
- loginPic = _DtCreateIcon(picFrame, "lockLabelPixmap", uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 2); i++;
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNtopOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNbottomOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNleftOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(uiArgs[i], XmNrightOffset, 0); i++;
- XtSetArg(uiArgs[i], XmNrightWidget, loginPic); i++;
- loginFrame = XmCreateFrame(tmpLock, "loginFrame", uiArgs, i);
- /*
- * create the login matte...
- */
- i = 0;
- XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
- smDD.loginMatte[0] = XmCreateForm(loginFrame, "loginMatte", uiArgs, i);
- /*
- * create the login/password forms
- */
- i = 0;
- XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
- XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNrightOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNbottomPosition, 50); i++;
- XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNleftOffset, 15); i++;
- smDD.loginForm[0] = XmCreateForm(smDD.loginMatte[0], "loginForm", uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNtopPosition, 50); i++;
- XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
- XtSetArg(uiArgs[i], XmNleftWidget, smDD.loginForm[0]); i++;
- XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
- XtSetArg(uiArgs[i], XmNrightWidget, smDD.loginForm[0]); i++;
- passwdForm = XmCreateForm(smDD.loginMatte[0], "passwdForm", uiArgs, i);
- /*
- * create the login/password labels...
- */
- i = 0;
- envLog = getenv("LOGNAME");
- slen = 100 + strlen(envLog) + 1;
- lockMessage = XtCalloc(1, slen);
- snprintf(lockMessage, slen - 1,
- (char*) GETMESSAGE(18, 1, "Display locked by user %s."), envLog);
- lockString = XmStringCreateLocalized(lockMessage);
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
- XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_CENTER); i++;
- XtSetArg(uiArgs[i], XmNlabelString, lockString); i++;
- loginLabel = XmCreateLabelGadget(smDD.loginForm[0],
- "loginLabel", uiArgs, i);
- XtManageChild(loginLabel);
- XmStringFree(lockString);
- XtFree(lockMessage);
- i = 0;
- lockString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 2, "Enter password to unlock.")));
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(uiArgs[i], XmNtopWidget, loginLabel); i++;
- XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_CENTER); i++;
- XtSetArg(uiArgs[i], XmNlabelString, lockString); i++;
- instructLabel = XmCreateLabelGadget(smDD.loginForm[0], "instructLabel",
- uiArgs, i);
- XtManageChild(instructLabel);
- XmStringFree(lockString);
- i = 0;
- passwordString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 3, "Password: ")));
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
- XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNbottomPosition, 80); i++;
- XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_END); i++;
- XtSetArg(uiArgs[i], XmNlabelString, passwordString); i++;
- passwdLabel = XmCreateLabelGadget(passwdForm,
- "passwdLabel", uiArgs, i);
- XtManageChild(passwdLabel);
- XmStringFree(passwordString);
- /*
- * Give the password label an offset
- */
- i = 0;
- XtSetArg(uiArgs[i], XmNwidth, &width);i++;
- XtGetValues(passwdLabel, uiArgs, i);
- i = 0;
- width += (width/6);
- XtSetArg(uiArgs[i], XmNwidth, width);i++;
- XtSetArg(uiArgs[i], XmNrecomputeSize, False);i++;
- XtSetValues(passwdLabel, uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_IN); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 1); i++;
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
- XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNbottomPosition, 80); i++;
- XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(uiArgs[i], XmNleftWidget, passwdLabel); i++;
- XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNrightOffset, 10); i++;
- XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_END); i++;
- indFrame = XmCreateFrame(passwdForm, "indFrame", uiArgs, i);
- i = 0;
- passwordString = XmStringCreateLocalized("|");
- XtSetArg(uiArgs[i], XmNlabelString, passwordString); i++;
- XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_BEGINNING); i++;
- smDD.indLabel[0] = XmCreateLabel(indFrame, "indLabel",
- uiArgs, i);
- XtManageChild(smDD.indLabel[0]);
- XmStringFree(passwordString);
- i = 0;
- XtSetArg(uiArgs[i], XmNhighlightColor, &focus_color); i++;
- XtGetValues(indFrame, uiArgs, i);
- XtVaSetValues ( smDD.indLabel[0],
- XmNborderWidth, 2,
- XmNborderColor, focus_color,
- NULL );
-
- /*
- * Manage forms AFTER all children have been managed
- */
- XtManageChild(indFrame);
- XtManageChild(passwdForm);
- XtManageChild(smDD.loginForm[0]);
- XtManageChild(smDD.loginMatte[0]);
- XtManageChild(loginPic);
- XtManageChild(picFrame);
- XtManageChild(loginFrame);
- return(tmpLock);
- }
- /*************************************<->*************************************
- *
- * ExitSession ()
- *
- *
- * Description:
- * -----------
- * Determines which exit routines get called when an exit request is made
- * of the session manager.
- * If smGD.bmsDead == false, we just exit.
- * If ASK_STATE is turned on, the query dialog is
- * put up, if VERBOSE is on, confirm exit in current mode (restart or reset)
- * if confirmation is turned off - exit immediately.
- *
- *
- * Inputs:
- * ------
- * msg -- if non-zero, Session_Exit request to reply/fail && destroy
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void
- ExitSession(
- Tt_message msg)
- {
- if (smGD.bmsDead == True)
- {
- ImmediateExit(-1, msg, True);
- }
- if(smGD.compatMode == True)
- {
- if (msg != 0) {
- tt_message_reply( msg );
- tt_message_destroy( msg );
- }
- CompatModeExit();
- }
- else
- {
- if(smSettings.confirmMode == DtSM_VERBOSE_MODE ||
- smSettings.startState == DtSM_ASK_STATE)
- {
- ConfirmExit( msg, True );
- }
- else
- {
- ImmediateExit(smSettings.startState, msg, True);
- }
- }
- }
- /*************************************<->*************************************
- *
- * ConfirmExit ()
- *
- *
- * Description:
- * -----------
- * Create the exit confirmation dialog box (if it hasn't been) and confirm
- * that the user wants to exit the session. This routine only gets called
- * when the user hasn't turned of exit confirmation and is not in ASK mode
- *
- *
- * Inputs:
- * ------
- * msg -- if non-zero, Session_Exit request to reply/fail && destroy
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- int
- ConfirmExit(
- Tt_message msg,
- Boolean doSave)
- {
- int i;
- String tmpString;
- ExitRecord *exitRec;
- Tt_message *pmsg;
- static XmString homeToHome; /* started Home, restore to Home */
- static XmString returnToCurrent; /* started Home or Current but
- retrun to Current */
- static XmString currentToHome; /* started Current, return to Home */
- if(smDD.confExit == NULL)
- {
- /*
- * Create all compound strings for confirmation dialogs
- */
- returnToCurrent = XmStringCreateLocalized(((char *)GETMESSAGE(18, 4,
- "Exiting the desktop session...\n\n\
- Your Current session will be restored upon login.\n\n\
- Application updates you have not saved will be lost.\n\n\
- Continue Logout?")));
- homeToHome = XmStringCreateLocalized(((char *)GETMESSAGE(18, 5,
- "Exiting the desktop session...\n\n\
- Your Home session will be restored upon login.\n\
- Your Current session will not be saved.\n\n\
- Application updates you have not saved will be lost.\n\n\
- Continue Logout?")));
- currentToHome = XmStringCreateLocalized(((char *)GETMESSAGE(18, 75,
- "Exiting the desktop session...\n\n\
- Your Current session will be saved but your Home\n\
- session will be restored upon login.\n\n\
- Application updates you have not saved will be lost.\n\n\
- Continue Logout?")));
- /*
- * Build up the correct string for this dialog
- */
- i = 0;
- if (smGD.sessionType == HOME_SESSION &&
- smSettings.startState == DtSM_HOME_STATE)
- {
- XtSetArg(uiArgs[i], XmNmessageString, homeToHome); i++;
- }
- else if (smGD.sessionType == CURRENT_SESSION &&
- smSettings.startState == DtSM_HOME_STATE)
- {
- XtSetArg(uiArgs[i], XmNmessageString, currentToHome); i++;
- }
- else
- {
- XtSetArg(uiArgs[i], XmNmessageString, returnToCurrent); i++;
- }
- /*
- * Now create the dialog box
- */
- tmpString = GETMESSAGE(18, 6, "Logout Confirmation");
- XtSetArg (uiArgs[i], XmNallowShellResize, False); i++;
- XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
- XtSetArg(uiArgs[i], XmNmessageAlignment, XmALIGNMENT_CENTER); i++;
- XtSetArg(uiArgs[i], XmNtitle, tmpString); i++;
- XtSetArg(uiArgs[i], XmNokLabelString, smDD.okLogoutString); i++;
- XtSetArg(uiArgs[i], XmNcancelLabelString, smDD.cancelLogoutString); i++;
- XtSetArg(uiArgs[i], XmNhelpLabelString, smDD.helpString); i++;
- XtSetArg(uiArgs[i], XmNautoUnmanage, False); i++;
- pmsg = (Tt_message *)XtMalloc(sizeof(Tt_message));
- XtSetArg(uiArgs[i], XmNuserData, pmsg); i++;
- smDD.confExit = XmCreateWarningDialog(smGD.topLevelWid, "exitDialog",
- uiArgs, i);
-
- i = 0;
- XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
- XtSetArg(uiArgs[i], XmNmwmFunctions, 0);i++;
- XtSetArg(uiArgs[i], XmNmwmDecorations,
- (MWM_DECOR_TITLE | MWM_DECOR_BORDER));i++;
- XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
- XtSetValues(XtParent(smDD.confExit), uiArgs, i);
- exitRec = (ExitRecord *)XtMalloc( sizeof(ExitRecord) );
- exitRec->pmsg = pmsg;
- exitRec->doSave = doSave;
- XtAddCallback (smDD.confExit, XmNokCallback, ExitConfirmed, exitRec);
- #ifndef NO_XVH
- XtAddCallback (smDD.confExit, XmNhelpCallback,
- TopicHelpRequested, HELP_LOGOUT_STR);
- #endif
- exitRec = (ExitRecord *)XtMalloc( sizeof(ExitRecord) );
- exitRec->pmsg = pmsg;
- exitRec->doSave = doSave;
- exitRec->u.exitCancelledDialog = smDD.confExit;
- XtAddCallback (smDD.confExit, XmNcancelCallback,
- ExitCancelled, exitRec);
- }
- else
- {
- /*
- * The user may have changed the type of session to be
- * restored so must update the dialog's message.
- */
- i = 0;
- if (smGD.sessionType == HOME_SESSION &&
- smSettings.startState == DtSM_HOME_STATE)
- {
- XtSetArg(uiArgs[i], XmNmessageString, homeToHome); i++;
- }
- else if (smGD.sessionType == CURRENT_SESSION &&
- smSettings.startState == DtSM_HOME_STATE)
- {
- XtSetArg(uiArgs[i], XmNmessageString, currentToHome); i++;
- }
- else
- {
- XtSetArg(uiArgs[i], XmNmessageString, returnToCurrent); i++;
- }
- XtSetValues(smDD.confExit, uiArgs, i);
- }
- /*
- * Refresh buffer containing pointer to Tt_message.
- */
- i=0;
- XtSetArg(uiArgs[i], XmNuserData, &pmsg); i++;
- XtGetValues(smDD.confExit, uiArgs, i);
- *pmsg = msg;
- XtAddCallback (XtParent(smDD.confExit), XmNpopupCallback, DialogUp, NULL);
-
- XtManageChild(smDD.confExit);
- return(0);
- }
- /*************************************<->*************************************
- *
- * WarnMsgFailue ()
- *
- *
- * Description:
- * -----------
- * Let the user know that the bms has died and that the current session
- * will not be saved.
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- int
- WarnMsgFailure( void )
- {
- int i;
- XmString bmsDeadString;
- String tmpString;
- if(smDD.deadWid == NULL)
- {
- bmsDeadString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 38,
- "Messaging System Inoperative\n\n\
- To restart:\n\n1) Save all open data files.\n\
- 2) Logout.\n\
- 3) Log in again.\n\nNote: The current session will not be saved.\n\n\
- When you are ready to begin the restart process, click [OK] and\n\
- proceed to save your files.")));
- /*
- * Now create the dialog box
- */
- i = 0;
- tmpString = GETMESSAGE(18, 12, "Message Failure");
- XtSetArg(uiArgs[i], XmNmessageString, bmsDeadString);i++;
- XtSetArg(uiArgs[i], XmNallowShellResize, True); i++;
- XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
- XtSetArg(uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
- XtSetArg(uiArgs[i], XmNtitle, tmpString); i++;
- XtSetArg(uiArgs[i], XmNokLabelString, smDD.okString); i++;
- XtSetArg(uiArgs[i], XmNhelpLabelString, smDD.helpString); i++;
- XtSetArg(uiArgs[i], XmNautoUnmanage, False); i++;
- smDD.deadWid = XmCreateWarningDialog(smGD.topLevelWid, "deadDialog",
- uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
- XtSetArg(uiArgs[i], XmNmwmFunctions, 0);i++;
- XtSetArg(uiArgs[i], XmNmwmDecorations,
- (MWM_DECOR_TITLE | MWM_DECOR_BORDER));i++;
- XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
- XtSetValues(XtParent(smDD.deadWid), uiArgs, i);
-
- XtAddCallback (XtParent(smDD.deadWid),
- XmNpopupCallback, DialogUp, NULL);
- XtUnmanageChild(XmMessageBoxGetChild(smDD.deadWid,
- XmDIALOG_CANCEL_BUTTON));
- /*
- * Now add in the callback and get out of here
- */
- XtAddCallback (smDD.deadWid, XmNokCallback,
- SimpleOK, (XtPointer) smDD.deadWid);
- #ifndef NO_XVH
- XtAddCallback (smDD.deadWid, XmNhelpCallback,
- TopicHelpRequested, HELP_BMS_DEAD_STR);
- #endif
- XtAddCallback (smDD.deadWid, XmNcancelCallback,
- NULL, NULL);
- XmStringFree(bmsDeadString);
- }
- XtManageChild(smDD.deadWid);
- return(0);
- }
- /*************************************<->*************************************
- *
- * CompatModeExit ()
- *
- *
- * Description:
- * -----------
- * Let the user know that the logout button can not be used to exit in
- * compatibility mode.
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static int
- CompatModeExit( void )
- {
- int i;
- XmString compatModeString;
- String tmpString;
- if(smDD.compatExit == NULL)
- {
- compatModeString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 34,
- "This session was started from an X Window System startup script.\n\n\
- No session information will be saved.\n\nUse the reset key sequence to log out.")));
- /*
- * Now create the dialog box
- */
- i = 0;
- tmpString = GETMESSAGE(18, 35, "Logout Message");
- XtSetArg(uiArgs[i], XmNmessageString, compatModeString);i++;
- XtSetArg(uiArgs[i], XmNallowShellResize, True); i++;
- XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
- XtSetArg(uiArgs[i], XmNmessageAlignment, XmALIGNMENT_CENTER); i++;
- XtSetArg(uiArgs[i], XmNtitle, tmpString); i++;
- XtSetArg(uiArgs[i], XmNokLabelString, smDD.okString); i++;
- XtSetArg(uiArgs[i], XmNhelpLabelString, smDD.helpString); i++;
- XtSetArg(uiArgs[i], XmNautoUnmanage, False); i++;
- smDD.compatExit = XmCreateInformationDialog(smGD.topLevelWid,
- "compatDialog",
- uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
- XtSetArg(uiArgs[i], XmNmwmFunctions, 0);i++;
- XtSetArg(uiArgs[i], XmNmwmDecorations,
- (MWM_DECOR_TITLE | MWM_DECOR_BORDER));i++;
- XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
- XtSetValues(XtParent(smDD.compatExit), uiArgs, i);
-
- XtAddCallback (XtParent(smDD.compatExit),
- XmNpopupCallback, DialogUp, NULL);
- XtUnmanageChild(XmMessageBoxGetChild(smDD.compatExit,
- XmDIALOG_CANCEL_BUTTON));
- /*
- * Now add in the callback and get out of here
- */
- XtAddCallback (smDD.compatExit, XmNokCallback,
- SimpleOK, smDD.compatExit);
- #ifndef NO_XVH
- XtAddCallback (smDD.compatExit, XmNhelpCallback,
- TopicHelpRequested, HELP_LOGOUT_COMPAT_MODE_STR);
- #endif
- XmStringFree(compatModeString);
- }
- XtManageChild(smDD.compatExit);
- return(0);
- }
- /*************************************<->*************************************
- *
- * CreateLockDialogWithCover()
- *
- *
- * Description:
- * -----------
- * Create the lock dialog when it exists as a part of a cover
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- Widget
- CreateLockDialogWithCover(
- Widget parent )
- {
- int i;
- Widget loginLabel, instructLabel, tmpLock;
- Widget indFrame, loginPic, picFrame, loginFrame;
- Widget passwdLabel, passwdForm;
- Dimension width; /* width, height of drop shadow */
- XmString lockString, passwordString;
- char *lockMessage;
- char *envLog;
- Pixel fg, bg, focus_color; /* foreground, background colors */
- i = 0;
- XtSetArg(uiArgs[i], XmNmarginWidth, 0); i++;
- XtSetArg(uiArgs[i], XmNmarginHeight, 0); i++;
- XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness,5); i++;
- XtSetArg(uiArgs[i], XmNunitType, XmPIXELS); i++;
- XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
- XtSetArg(uiArgs[i], XmNmappedWhenManaged, False); i++;
- tmpLock = XmCreateForm(parent, "lockDialog", uiArgs, i);
- smDD.matte[1] = tmpLock;
- i = 0;
- XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 2); i++;
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNtopOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNbottomOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNrightOffset, 15); i++;
- picFrame = XmCreateFrame(tmpLock, "picFrame", uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNforeground, &fg); i++;
- XtSetArg(uiArgs[i], XmNbackground, &bg); i++;
- XtGetValues(tmpLock, uiArgs, i);
-
- i = 0;
- XtSetArg(uiArgs[i], XmNfillMode, XmFILL_SELF); i++;
- XtSetArg(uiArgs[i], XmNbehavior, XmICON_LABEL); i++;
- XtSetArg(uiArgs[i], XmNpixmapForeground, fg); i++;
- XtSetArg(uiArgs[i], XmNpixmapBackground, bg); i++;
- XtSetArg(uiArgs[i], XmNstring, NULL); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
- XtSetArg(uiArgs[i], XmNtraversalOn, False); i++;
- loginPic = _DtCreateIcon(picFrame, "lockLabelPixmap", uiArgs, i);
-
- i = 0;
- XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 2); i++;
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNtopOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNbottomOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNleftOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(uiArgs[i], XmNrightWidget, picFrame); i++;
- XtSetArg(uiArgs[i], XmNrightOffset, 0); i++;
- loginFrame = XmCreateFrame(tmpLock, "loginFrame", uiArgs, i);
- /*
- * create the login matte...
- */
- i = 0;
- XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
- smDD.loginMatte[1] = XmCreateForm(loginFrame, "loginMatte", uiArgs, i);
- /*
- * create the login/password forms
- */
- i = 0;
- XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
- XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNrightOffset, 15); i++;
- XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNbottomPosition, 50); i++;
- XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNleftOffset, 15); i++;
- smDD.loginForm[1] = XmCreateForm(smDD.loginMatte[1], "loginForm", uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNtopPosition, 50); i++;
- XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
- XtSetArg(uiArgs[i], XmNleftWidget, smDD.loginForm[1]); i++;
- XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
- XtSetArg(uiArgs[i], XmNrightWidget, smDD.loginForm[1]); i++;
- passwdForm = XmCreateForm(smDD.loginMatte[1], "passwdForm", uiArgs, i);
- /*
- * create the login/password labels...
- */
- i = 0;
- envLog = getenv("LOGNAME");
- lockMessage = XtCalloc(1, 100 + strlen(envLog));
- snprintf(lockMessage, 100 + strlen(envLog) - 1,
- ((char *)GETMESSAGE(18, 1, "Display locked by user %s.")), envLog);
- lockString = XmStringCreateLocalized(lockMessage);
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
- XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_CENTER); i++;
- XtSetArg(uiArgs[i], XmNlabelString, lockString); i++;
- loginLabel = XmCreateLabelGadget(smDD.loginForm[1],
- "loginLabel", uiArgs, i);
- XtManageChild(loginLabel);
- XmStringFree(lockString);
- XtFree(lockMessage);
- i = 0;
- lockString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 2, "Enter password to unlock.")));
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(uiArgs[i], XmNtopWidget, loginLabel); i++;
- XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_CENTER); i++;
- XtSetArg(uiArgs[i], XmNlabelString, lockString); i++;
- instructLabel = XmCreateLabelGadget(smDD.loginForm[1], "instructLabel",
- uiArgs, i);
- XtManageChild(instructLabel);
- XmStringFree(lockString);
- i = 0;
- passwordString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 3, "Password: ")));
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
- XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNbottomPosition, 80); i++;
- XtSetArg(uiArgs[i], XmNleftOffset, 0); i++;
- XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_END); i++;
- XtSetArg(uiArgs[i], XmNlabelString, passwordString); i++;
- passwdLabel = XmCreateLabelGadget(passwdForm,
- "passwdLabel", uiArgs, i);
- XtManageChild(passwdLabel);
- XmStringFree(passwordString);
- /*
- * Give the password label an offset
- */
- i = 0;
- XtSetArg(uiArgs[i], XmNwidth, &width);i++;
- XtGetValues(passwdLabel, uiArgs, i);
- i = 0;
- width += (width/6);
- XtSetArg(uiArgs[i], XmNwidth, width);i++;
- XtSetArg(uiArgs[i], XmNrecomputeSize, False);i++;
- XtSetValues(passwdLabel, uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_IN); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 1); i++;
- XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
- XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(uiArgs[i], XmNbottomPosition, 80); i++;
- XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(uiArgs[i], XmNleftWidget, passwdLabel); i++;
- XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNrightOffset, 10); i++;
- XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_END); i++;
- indFrame = XmCreateFrame(passwdForm, "indFrame", uiArgs, i);
- i = 0;
- passwordString = XmStringCreateLocalized("|");
- XtSetArg(uiArgs[i], XmNlabelString, passwordString); i++;
- XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_BEGINNING); i++;
- smDD.indLabel[1] = XmCreateLabel(indFrame, "indLabel",
- uiArgs, i);
- XtManageChild(smDD.indLabel[1]);
- XmStringFree(passwordString);
-
- i = 0;
- XtSetArg(uiArgs[i], XmNhighlightColor, &focus_color); i++;
- XtGetValues(indFrame, uiArgs, i);
- XtVaSetValues ( smDD.indLabel[1],
- XmNborderWidth, 2,
- XmNborderColor, focus_color,
- NULL );
- /*
- * Manage forms AFTER all children have been managed
- */
- XtManageChild(indFrame);
- XtManageChild(passwdForm);
- XtManageChild(smDD.loginForm[1]);
- XtManageChild(smDD.loginMatte[1]);
- XtManageChild(loginPic);
- XtManageChild(picFrame);
- XtManageChild(loginFrame);
-
- return(tmpLock);
- }
- /*************************************<->*************************************
- *
- * CreateCoverDialog ()
- *
- *
- * Description:
- * -----------
- * Create the cover dialogs for all the screens
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- Widget
- CreateCoverDialog(
- int screenNum,
- Boolean withLock )
- {
- int i;
- Widget tmpCover, table;
- char geomString[50];
- sprintf(geomString, "%dx%d+0+0",
- DisplayWidth(smGD.display, screenNum),
- DisplayHeight(smGD.display, screenNum));
- i = 0;
- XtSetArg(uiArgs[i], XmNmwmDecorations, 0);i++;
- XtSetArg(uiArgs[i], XmNgeometry, (String) geomString);i++;
- XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
- XtSetArg(uiArgs[i], XmNallowShellResize, True); i++;
- XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
- XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
- XtSetArg(uiArgs[i], XmNdepth, DefaultDepth(smGD.display, screenNum));i++;
- XtSetArg(uiArgs[i], XmNscreen,
- ScreenOfDisplay(smGD.display, screenNum));i++;
- XtSetArg(uiArgs[i], XmNcolormap,
- DefaultColormap(smGD.display, screenNum));i++;
- tmpCover = XtCreatePopupShell("coverDialog", topLevelShellWidgetClass,
- smGD.topLevelWid, uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNmarginWidth, 0); i++;
- XtSetArg(uiArgs[i], XmNmarginHeight, 0); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
- XtSetArg(uiArgs[i], XmNheight,
- (Dimension) DisplayHeight(smGD.display, smGD.screen)); i++;
- XtSetArg(uiArgs[i], XmNwidth,
- (Dimension) DisplayWidth(smGD.display, smGD.screen)); i++;
- XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
- table = XmCreateDrawingArea(tmpCover, "drawArea", uiArgs, i);
- XtManageChild(table);
- smDD.coverDrawing[screenNum] = table;
- if(withLock == True)
- {
- XtAddCallback (tmpCover, XmNpopupCallback,
- LockDialogUp, NULL);
- }
- XtRealizeWidget(tmpCover);
-
- return(tmpCover);
- }
- /*************************************<->*************************************
- *
- * ExitConfirmed ()
- *
- *
- * Description:
- * -----------
- * Callback that is called when user confirms the exit of a session by
- * pressing the OK button on the confirmation dialog. This routine just
- * facilitates the exit process.
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static void
- ExitConfirmed(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- ExitRecord *exitRec = (ExitRecord *)client_data;
- XtUnmanageChild(smDD.confExit);
- ImmediateExit(smSettings.startState, *exitRec->pmsg, exitRec->doSave);
- }
- /*************************************<->*************************************
- *
- * ImmediateExit -
- *
- *
- * Description:
- * -----------
- * This process puts in motion the exit procedure, and then exits.
- *
- *
- * Inputs:
- * ------
- * mode = Whether this session should be reset or restarted
- * msg -- if non-zero, Session_Exit request to reply/fail && destroy
- * doSave - if True, the session will be saved.
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void
- ImmediateExit(
- int mode,
- Tt_message msg,
- Boolean doSave)
- {
- long old;
- Tt_message notice;
- /*
- * Turn off SIGTERM so we don't catch one in the middle of shutting
- * down
- */
- #if !defined(SVR4)
- old = sigblock(sigmask(SIGTERM));
- sigblock(sigmask(SIGHUP));
- sigblock(sigmask(SIGPIPE));
- #else
- old = sighold(SIGTERM);
- #endif
- /*
- *
- */
- if(smGD.bmsDead == False)
- {
- notice = (Tt_message) tttk_message_create( NULL, TT_NOTICE, TT_SESSION, NULL,
- "XSession_Ending", NULL);
- tt_message_send( notice );
- tt_message_destroy( notice );
- }
- if (msg != 0) {
- tt_message_reply( msg );
- tt_message_destroy( msg );
- }
- if (doSave)
- {
- XEvent next;
- Tt_message msg;
- int sessionType = smGD.sessionType;
- XtIntervalId timerId;
- msg = (Tt_message) tttk_message_create( NULL, TT_NOTICE, TT_SESSION, NULL,
- "DtActivity_Beginning", NULL );
- tt_message_send( msg );
- tt_message_destroy( msg );
- if (smGD.sessionType == CURRENT_SESSION ||
- smGD.sessionType == DEFAULT_SESSION)
- SaveState (False, DtSM_CURRENT_STATE, SmSaveLocal, True,
- DEFAULT_INTERACT_STYLE, DEFAULT_FAST, DEFAULT_GLOBAL);
- else if (smGD.sessionType == HOME_SESSION &&
- smSettings.startState == DtSM_CURRENT_STATE)
- SaveState (False, DtSM_HOME_STATE, SmSaveLocal, True,
- DEFAULT_INTERACT_STYLE, DEFAULT_FAST, DEFAULT_GLOBAL);
- else
- SaveState (False, DtSM_HOME_STATE, SmSaveGlobal, True,
- DEFAULT_INTERACT_STYLE, DEFAULT_FAST, DEFAULT_GLOBAL);
- /*
- * Restore sessionType - it may have been changed in SaveState
- */
- smGD.sessionType = sessionType;
- XSync(smGD.display, 0);
- smGD.loggingOut = True;
- /* JET - set this here so we don't exit prematurely (while
- * handling our own SM exit callback - duh).
- */
- smGD.ExitComplete = False;
- saveTimeout = False;
- timerId = XtAppAddTimeOut (smGD.appCon, smRes.saveYourselfTimeout,
- SaveTimeout, NULL);
- while (smXSMP.saveState.saveComplete == False &&
- smXSMP.saveState.shutdownCanceled == False) {
- if (saveTimeout)
- break;
- XtAppNextEvent(smGD.appCon, &next);
- if (next.type != 0)
- XtDispatchEvent(&next);
- }
- }
-
- /* JET - need this, since dtsession was exiting in the
- * XtAppNextEvent above (receiving it's own EXIT SM message) This
- * is checked in SmExit() so exit's will only occur after this
- * housekeeping has been completed.
- */
- smGD.ExitComplete = True;
- if (smXSMP.saveState.shutdownCanceled == False) {
- /*
- * Run the user's exit script if there is one
- */
- if (smGD.compatMode == False)
- {
- StartEtc(True); /* run sessionexit */
- }
- _DtReleaseLock(smGD.display, SM_RUNNING_LOCK);
- SM_EXIT(0);
- }
- }
- /*************************************<->*************************************
- *
- * ExitCancelled ()
- *
- *
- * Description:
- * -----------
- * Called when the user bails out from a logout at the confirmation dialog
- *
- *
- * Inputs:
- * ------
- * client_data - tells which dialog to unmange (the query or confirm exit)
- * msg -- if non-zero, Session_Exit request to reply/fail && destroy
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static void
- ExitCancelled(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- ExitRecord *exitRec = (ExitRecord *)client_data;
- if(XtIsManaged(exitRec->u.exitCancelledDialog))
- {
- XtUnmanageChild(exitRec->u.exitCancelledDialog);
- }
- if(smDD.smHelpDialog && XtIsManaged(smDD.smHelpDialog))
- {
- XtUnmanageChild(smDD.smHelpDialog);
- }
- if (*exitRec->pmsg != 0) {
- tttk_message_fail(*exitRec->pmsg, TT_DESKTOP_ECANCELED, 0, 1 );
- }
- SetSystemReady();
- }
- /*************************************<->*************************************
- *
- * DialogUp ()
- *
- *
- * Description:
- * -----------
- * Once the dialog is managed, but not popped up - reposition it so that
- * it appears in the middle of the screen then remove the popup callback
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- * None
- *
- *
- * Comments:
- * --------
- * This routine can be used for any generic SYSTEM_MODAL dialog
- *
- *************************************<->***********************************/
- void
- DialogUp(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- int i;
- Dimension width, height;
- Position x, y;
- unsigned int dpwidth, dpheight, xorg, yorg; /* JET - Xinerama */
- /*
- * Get the size of the dialog box - then compute its position
- */
- i = 0;
- XtSetArg(uiArgs[i], XmNwidth, &width);i++;
- XtSetArg(uiArgs[i], XmNheight, &height);i++;
- XtGetValues(w, uiArgs, i);
-
- /* JET - get xinerama info */
- #ifdef USE_XINERAMA
- /* use the 'prefered' screen */
- if (!_DtXineramaGetScreen(smGD.DtXineramaInfo,
- smRes.xineramaPreferredScreen,
- &dpwidth, &dpheight, &xorg, &yorg))
- { /* no joy here either - setup for normal */
- dpwidth = DisplayWidth(smGD.display, smGD.screen);
- dpheight = DisplayHeight(smGD.display, smGD.screen);
- xorg = yorg = 0;
- }
- #else /* no Xinerama */
- dpwidth = DisplayWidth(smGD.display, smGD.screen);
- dpheight = DisplayHeight(smGD.display, smGD.screen);
- xorg = yorg = 0;
- #endif
- x = (dpwidth / 2) - (width / 2);
- y = (dpheight / 2) - (height / 2);
- /* add the x/y origins for Xinerama */
- x += xorg;
- y += yorg;
- i = 0;
- XtSetArg(uiArgs[i], XmNx, x);i++;
- XtSetArg(uiArgs[i], XmNy, y);i++;
- XtSetValues(w, uiArgs, i);
- XtRemoveCallback(w, XmNpopupCallback, DialogUp, NULL);
- }
- /*************************************<->*************************************
- *
- * ShowWaitState (flag)
- *
- *
- * Description:
- * -----------
- * Enter/Leave the wait state.
- *
- *
- * Inputs:
- * ------
- * flag = TRUE for Enter, FALSE for Leave.
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- * Stolen from the window manager code.
- *
- *************************************<->***********************************/
- void
- ShowWaitState(
- Boolean flag )
- {
- if (flag)
- {
- XGrabPointer (smGD.display, DefaultRootWindow(smGD.display), FALSE,
- 0, GrabModeAsync, GrabModeAsync, None,
- smGD.waitCursor, CurrentTime);
- XGrabKeyboard (smGD.display, DefaultRootWindow(smGD.display), FALSE,
- GrabModeAsync, GrabModeAsync, CurrentTime);
- }
- else
- {
- XUngrabPointer (smGD.display, CurrentTime);
- XUngrabKeyboard (smGD.display, CurrentTime);
- }
- XSync(smGD.display, 0);
- }
- /*************************************<->*************************************
- *
- * InitCursorInfo ()
- *
- *
- * Description:
- * -----------
- * This function determines whether a server supports large cursors. It it
- * does large feedback cursors are used in some cases (wait state and
- * system modal state); otherwise smaller (16x16) standard cursors are used.
- *
- * Outputs:
- * -------
- * Returns true if large cursors are supported, false otherwise
- *
- * Comments:
- * ---------
- * This code was stolen from the window manager
- *
- *************************************<->***********************************/
- Boolean
- InitCursorInfo( void )
- {
- unsigned int cWidth;
- unsigned int cHeight;
- if (XQueryBestCursor (smGD.display, DefaultRootWindow(smGD.display),
- 32, 32, &cWidth, &cHeight))
- {
- if ((cWidth >= 32) && (cHeight >= 32))
- {
- return(True);
- }
- }
- return(False);
- }
- /*************************************<->*************************************
- *
- * LockDialogUp ()
- *
- *
- * Description:
- * -----------
- * Once the lock dialog is managed, but not popped up - reposition it so that
- * it appears in the middle of the screen then remove the popup callback
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static void
- LockDialogUp(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
-
- register int i;
- Dimension width, height; /* size values returned by XtGetValues */
- Dimension shadowThickness;/* size values returned by XtGetValues */
- unsigned int dpwidth, dpheight, xorg, yorg; /* JET - xinerama */
-
- struct
- { /* position, size of widgets (pixels) */
- int x, y;
- int width;
- int height;
- int shadow;
- } mw; /* matte, logo, drop shadow & login matte */
- int width1, width2; /* general width variable */
- int x1, y1; /* general position variables */
- int index;
-
- /* JET - get xinerama info */
- #ifdef USE_XINERAMA
- /* use the prefered screen */
- if (!_DtXineramaGetScreen(smGD.DtXineramaInfo,
- smRes.xineramaPreferredScreen,
- &dpwidth, &dpheight, &xorg, &yorg))
- { /* no joy here either - setup for normal */
- dpwidth = DisplayWidth(smGD.display, smGD.screen);
- dpheight = DisplayHeight(smGD.display, smGD.screen);
- xorg = yorg = 0;
- }
- #else /* no Xinerama */
- dpwidth = DisplayWidth(smGD.display, smGD.screen);
- dpheight = DisplayHeight(smGD.display, smGD.screen);
- xorg = yorg = 0;
- #endif
- /*
- * The partial cover has widgets of index 0 - the cover has
- * index 1
- */
- if(smGD.coverScreen == True)
- {
- index = 1;
- }
- else
- {
- index = 0;
- }
-
- /*
- * - center the main matte horizontally and vertically...
- */
- i = 0;
- XtSetArg(uiArgs[i], XmNwidth, &width); i++;
- XtSetArg(uiArgs[i], XmNheight, &height); i++;
- XtSetArg(uiArgs[i], XmNshadowThickness, &shadowThickness); i++;
- XtGetValues(smDD.matte[index], uiArgs, i);
- mw.shadow = shadowThickness;
- mw.width = width;
- mw.height = height;
- mw.x = (dpwidth - mw.width)/2;
- mw.y = (dpheight - mw.height)/2;
- if ( mw.x < 0 ) mw.x = 0;
- if ( mw.y < 0 ) mw.y = 0;
-
- /* adjust origins if using Xinerama */
- x1 = mw.x + xorg;
- y1 = mw.y + yorg;
- i = 0;
- XtSetArg(uiArgs[i], XmNx, x1); i++;
- XtSetArg(uiArgs[i], XmNy, y1); i++;
- XtSetValues(smDD.matte[index], uiArgs, i);
- /*
- * - center the login/password frames horizontally in the login_matte...
- */
- XtSetArg(uiArgs[0], XmNwidth, &width);
- XtGetValues(smDD.loginMatte[index], uiArgs, 1);
- width1 = (int)width;
- XtSetArg(uiArgs[0], XmNwidth, &width);
- XtGetValues(smDD.loginForm[index], uiArgs, 1);
- width2 = (int)width;
-
- i = 0;
- XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(uiArgs[i], XmNleftOffset, (width1 - width2) / 2); i++;
- XtSetValues(smDD.loginForm[index], uiArgs, i);
- }
- /*************************************<->*************************************
- *
- * SimpleOK()
- *
- *
- * Description:
- * -----------
- * Simply dismiss a dialog. Does special process for a compatibility mode
- * logout dialog and when the bms won't start.
- *
- *
- * Inputs:
- * ------
- * client_data - sends in the dialog to be dismissed.
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static void
- SimpleOK(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- Widget dismissDialog = (Widget) client_data;
- if(XtIsManaged(dismissDialog))
- {
- XtUnmanageChild(dismissDialog);
- }
- if(dismissDialog == smDD.compatExit)
- {
- SetSystemReady();
- }
- if(dismissDialog == smDD.noStart)
- {
- SM_EXIT(-1);
- }
- if(dismissDialog == smDD.clientReasons)
- {
- reasonsDialogOK = True;
- }
- }
- /*************************************<->*************************************
- *
- * UpdatePasswdField ()
- *
- *
- * Description:
- * -----------
- * Give the visual feedback necessary when the user is entering a password
- *
- *
- * Inputs:
- * ------
- * numChars = number of characters entered into the field
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void
- UpdatePasswdField(
- int numChars )
- {
- int i, index;
- char *passwdMessage = XtMalloc(numChars + 1);
- XmString tmpString;
- if (!passwdMessage) {
- PrintErrnoError(DtError, smNLS.cantMallocErrorString);
- return;
- }
- if(numChars > 0)
- {
- strcpy(passwdMessage, "|");
- for(i = 1;i < numChars;i++)
- {
- if(i==1)
- strcpy(passwdMessage, "|");
- else
- strcat(passwdMessage, " ");
- }
- strcat(passwdMessage, PASSWORD_INDICATOR);
- }
- else
- {
- strcpy(passwdMessage, "|");
- }
- tmpString = XmStringCreateLocalized (passwdMessage);
- XtFree(passwdMessage);
- /*
- * Set the index for the indLabel widget
- */
- if(smGD.coverScreen == True)
- {
- index = 1;
- }
- else
- {
- index = 0;
- }
-
- i = 0;
- XtSetArg(uiArgs[i], XmNlabelString, tmpString); i++;
- XtSetValues(smDD.indLabel[index], uiArgs, i);
- XmStringFree(tmpString);
- }
- /*************************************<->*************************************
- *
- * WarnNoStartup ()
- *
- *
- * Description:
- * -----------
- * When the BMS refuses to be started, warn the user about why dt is
- * crashing and then exit.
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- int
- WarnNoStartup( void )
- {
- int i;
- XmString bmsNoStartString;
- String tmpString;
- bmsNoStartString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 36,
- "The desktop messaging system could not be started.\n\n\
- To correct the problem:\n\n\
- 1. Choose [OK] to return to the login screen.\n\n\
- 2. Select Failsafe Session from the login screen's option\n\
- menu and log in.\n\n\
- 3. Check to see that the desktop is properly installed,\n\
- the hostname is correct (/etc/hosts) and that the\n\
- network is properly configured.\n\n\
- For additional information, see the CDE User's Guide.")));
- /*
- * Now create the dialog box
- */
- i = 0;
- tmpString = GETMESSAGE(18, 37, "Action Required");
- XtSetArg(uiArgs[i], XmNmessageString, bmsNoStartString);i++;
- XtSetArg(uiArgs[i], XmNallowShellResize, True); i++;
- XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
- XtSetArg(uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
- XtSetArg(uiArgs[i], XmNtitle, tmpString); i++;
- XtSetArg(uiArgs[i], XmNokLabelString, smDD.okString); i++;
- XtSetArg(uiArgs[i], XmNautoUnmanage, False); i++;
- smDD.noStart = XmCreateWarningDialog(smGD.topLevelWid, "noStartDialog",
- uiArgs, i);
- XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
- XtSetValues(XtParent(smDD.noStart), uiArgs, i);
- XtAddCallback (XtParent(smDD.noStart),
- XmNpopupCallback, DialogUp, NULL);
- XtUnmanageChild(XmMessageBoxGetChild(smDD.noStart,
- XmDIALOG_HELP_BUTTON));
- XtUnmanageChild(XmMessageBoxGetChild(smDD.noStart,
- XmDIALOG_CANCEL_BUTTON));
- /*
- * Now add in the callback and get out of here
- */
- XtAddCallback (smDD.noStart, XmNokCallback,
- SimpleOK, smDD.noStart);
- XmStringFree(bmsNoStartString);
- XtManageChild(smDD.noStart);
- return(0);
- } /* END OF FUNCTION WarnNoStartup */
- /*************************************<->*************************************
- *
- * ConfirmSessionCreation () -
- *
- * Description:
- * -----------
- *
- * Inputs:
- * ------
- *
- * Outputs:
- * -------
- *
- * Returns True if the user says to continue the session; False otherwise
- * or if malloc fails;
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- Boolean
- ConfirmSessionCreation (
- short session_type,
- unsigned int _argc,
- char **_argv)
- {
- int i, j;
- XmString title_string;
- XmString ok_string;
- XmString cancel_string;
- XmString help_string;
- XmString msg_string;
- Widget tmp_widget;
- Arg args[20];
- char *pch1;
- char *pch2;
- char *pch3;
- Dimension width, height;
- Position x, y;
- XEvent next;
- int argc = _argc;
- char **argv = NULL;
- /*
- * Create temporary argv because the X toolkit may remove
- * pieces of the command line options.
- */
- if (_argc > 0) {
- argv = (char **) XtMalloc (_argc * sizeof (char *));
- for (i = 0; i < _argc; i++)
- argv[i] = _argv[i];
- }
- if (session_type == HOME_SESSION)
- pch1 = strdup ((char *) GETMESSAGE(18, 50, "Home"));
- else
- pch1 = strdup ((char *) GETMESSAGE(18, 51, "Current"));
- if (!pch1) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- pch2 = strdup ((char *) GETMESSAGE(18, 52,
- "A display-specific '%s' session was selected\nfor display '%s' but one does not exist.\n\nIf you continue, a new display-specific session will\nbe created."));
- if (!pch2) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- pch3 = XtMalloc (strlen (pch1) +
- strlen (XDisplayName (getenv("DISPLAY"))) +
- strlen (pch2) +
- 4);
- if (!pch3) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- (void) sprintf (pch3, pch2, pch1, XDisplayName (getenv("DISPLAY")));
- /*
- * The X toolkit has not yet been initialized, so do it now.
- */
- j = 0;
- XtToolkitInitialize ();
- smGD.appCon = XtCreateApplicationContext();
- smGD.display = XtOpenDisplay(smGD.appCon, NULL, argv[0],
- SM_RESOURCE_CLASS, NULL, 0, &argc, argv);
- XtSetArg(args[j], XmNbackground,
- XBlackPixel(smGD.display, XDefaultScreen(smGD.display))); j++;
- XtSetArg(args[j], XmNmappedWhenManaged, False); j++;
- XtSetArg (args[j], XmNwidth, 1); j++;
- XtSetArg (args[j], XmNheight, 1); j++;
- tmp_widget = XtAppCreateShell (
- "foo", "foo",
- applicationShellWidgetClass,
- smGD.display, args, j);
- XtRealizeWidget(tmp_widget);
- /*
- * Create the compound strings for the confirmation dialog
- */
- msg_string = XmStringCreateLocalized (pch3);
- title_string = XmStringCreateLocalized(pch3);
- ok_string = XmStringCreateLocalized(((char *) GETMESSAGE(18, 39, "OK")));
- cancel_string = XmStringCreateLocalized(((char *) GETMESSAGE(18, 40, "Cancel")));
- help_string = XmStringCreateLocalized(((char *) GETMESSAGE(18, 41, "Help")));
- free (pch1); free (pch2); XtFree (pch3);
- /*
- * Create the dialog box
- */
- i = 0;
- XtSetArg (uiArgs[i], XmNmessageString, msg_string); i++;
- XtSetArg (uiArgs[i], XmNallowShellResize, False); i++;
- XtSetArg (uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
- XtSetArg (uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
- XtSetArg (uiArgs[i], XmNmappedWhenManaged, True); i++;
- XtSetArg (uiArgs[i], XmNtitle, title_string); i++;
- XtSetArg (uiArgs[i], XmNokLabelString, ok_string); i++;
- XtSetArg (uiArgs[i], XmNcancelLabelString, cancel_string); i++;
- XtSetArg (uiArgs[i], XmNhelpLabelString, help_string); i++;
- XtSetArg (uiArgs[i], XmNautoUnmanage, False); i++;
- smDD.confirmSession = XmCreateWarningDialog(
- tmp_widget, "confirmDialog", uiArgs, i);
- XtAddCallback (smDD.confirmSession, XmNokCallback,
- ConfirmOKCB, NULL);
- /*
- * Some help state is not yet initialized and the help
- * callback assumes it is so some initializations must
- * be done now.
- */
- smDD.smHelpDialog = NULL;
- smDD.okString = ok_string;
- smGD.topLevelWid = tmp_widget;
- XtAddCallback (smDD.confirmSession, XmNhelpCallback,
- TopicHelpRequested, HELP_CONFIRMATION_SESSION_STR);
- XtAddCallback (smDD.confirmSession, XmNcancelCallback,
- ConfirmCancelCB, NULL);
-
- XtManageChild(smDD.confirmSession);
- /*
- * Center the dialog on the display
- */
- i = 0;
- XtSetArg(uiArgs[i], XmNwidth, &width); i++;
- XtSetArg(uiArgs[i], XmNheight, &height); i++;
- XtGetValues(smDD.confirmSession, uiArgs, i);
- x = (DisplayWidth(smGD.display, XDefaultScreen(smGD.display)) / 2)
- - (width / 2);
- y = (DisplayHeight(smGD.display, XDefaultScreen(smGD.display)) / 2)
- - (height / 2);
- i = 0;
- XtSetArg(uiArgs[i], XmNx, x); i++;
- XtSetArg(uiArgs[i], XmNy, y); i++;
- XtSetValues(smDD.confirmSession, uiArgs, i);
- XmStringFree (msg_string);
- XmStringFree (title_string);
- XmStringFree (cancel_string);
- XmStringFree (help_string);
- /*
- * Spin until the OK or Cancel CB is invoked
- */
- confirmState = ConfirmationNone;
- while(1) {
- XtAppNextEvent(smGD.appCon, &next);
- if (next.type != 0)
- XtDispatchEvent(&next);
- if (confirmState == ConfirmationOK) {
- XtDestroyWidget (tmp_widget);
- XmStringFree (ok_string);
- return (True);
- }
- else if (confirmState == ConfirmationCancel) {
- XtDestroyWidget (tmp_widget);
- XmStringFree (ok_string);
- return (False);
- }
- }
- }
- /*************************************<->*************************************
- *
- * ConfirmOKCB ()
- *
- *************************************<->***********************************/
- static void
- ConfirmOKCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- XtUnmanageChild(smDD.confirmSession);
- confirmState = ConfirmationOK;
- }
- /*************************************<->*************************************
- *
- * ConfirmCancelCB ()
- *
- *************************************<->***********************************/
- static void
- ConfirmCancelCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- XtUnmanageChild(smDD.confirmSession);
- confirmState = ConfirmationCancel;
- }
- /*************************************<->*************************************
- *
- * PostXSMPFailureDialog () -
- *
- * Description:
- * -----------
- *
- * Inputs:
- * ------
- *
- * Outputs:
- * -------
- *
- * Returns True if the user says to continue the session; False otherwise
- * or if malloc fails;
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void
- PostXSMPFailureDialog (
- XSMPFailure failure_code,
- Boolean check_errorlog)
- {
- int i, j;
- XmString ok_string;
- XmString help_string;
- XmString msg_string;
- Arg args[20];
- char *pch1;
- char *pch2 = "";
- char *pch3;
- char *pch4;
- char *pch5;
- char *error_file;
- Dimension width, height;
- Position x, y;
- XEvent next;
- int len;
- pch1 = strdup ((char *) GETMESSAGE(40, 1,
- "A session cannot be started because of the\nfollowing error:"));
- if (!pch1) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- switch (failure_code) {
- case XSMP_FAILURE_SMS_INITIALIZE:
- pch2 = strdup ((char *) GETMESSAGE (40, 2,
- "SmsInitialize failed."));
- break;
- case XSMP_FAILURE_ICE_LISTEN:
- pch2 = strdup ((char *) GETMESSAGE (40, 3,
- "IceListenForConnections failed."));
- break;
- case XSMP_FAILURE_AUTHENTICATION:
- pch2 = strdup ((char *) GETMESSAGE (40, 4,
- "The authentication file ~/.ICEauthority could not be created.\n If the files ~/.ICEauthority-c and ~/.ICEauthority-l exist,\n they must be removed before your session can be started."));
- break;
- case XSMP_FAILURE_ICE_ADD_WATCH:
- pch2 = strdup ((char *) GETMESSAGE (40, 5,
- "IceAddConnectionWatch failed."));
- break;
- case XSMP_FAILURE_ICE_COMPOSE_IDS:
- pch2 = strdup ((char *) GETMESSAGE (40, 6,
- "IceComposeNetworkIds failed."));
- break;
- case XSMP_FAILURE_MALLOC:
- pch2 = strdup ((char *) GETMESSAGE (40, 7,
- "Could not create the SESSION_MANAGER environment variable."));
- break;
- }
- if (!pch2) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- pch3 = strdup ((char *) GETMESSAGE(18, 70,
- "See the following for more information:"));
- if (!pch3) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- pch4 = strdup ((char *) GETMESSAGE(18, 71,
- "CDE Advanced Users and System's Administration Guide"));
- if (!pch4) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- error_file = XtMalloc(MAXPATHLEN+1);
- strcpy (error_file, "");
- /* JET - VU#497553 */
- if (check_errorlog)
- {
- char *home;
- if (home = getenv ("HOME"))
- {
- len = strlen(home) +
- strlen(DtPERSONAL_CONFIG_DIRECTORY) +
- strlen(DtERRORLOG_FILE);
- if (len > MAXPATHLEN)
- error_file = XtRealloc(error_file, len + 1);
- sprintf (error_file, "%s/%s/%s", home,
- DtPERSONAL_CONFIG_DIRECTORY,
- DtERRORLOG_FILE);
- }
- }
- pch5 = XtMalloc (strlen (pch1) + strlen (pch2) + strlen (pch3) + strlen (pch4) +
- strlen (error_file) + 15);
- if (!pch5) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- (void) sprintf (pch5, "%s\n\n %s\n\n%s\n\n %s\n %s\n",
- pch1, pch2, pch3, pch4, error_file);
- XtFree(error_file);
- /*
- * No top level widget has been created so must create one now.
- */
- j = 0;
- XtSetArg (args[j], XmNbackground, XBlackPixel(smGD.display,
- XDefaultScreen(smGD.display))); j++;
- XtSetArg (args[j], XmNmappedWhenManaged, False); j++;
- XtSetArg (args[j], XmNwidth, 1); j++;
- XtSetArg (args[j], XmNheight, 1); j++;
- smGD.topLevelWid = XtAppCreateShell (SM_RESOURCE_NAME,
- SM_RESOURCE_CLASS, applicationShellWidgetClass,
- smGD.display, args, j);
- XtRealizeWidget(smGD.topLevelWid);
- /*
- * Create the compound strings for the confirmation dialog
- */
- msg_string = XmStringCreateLocalized (pch5);
- ok_string = XmStringCreateLocalized(((char *) GETMESSAGE(18, 39, "OK")));
- help_string = XmStringCreateLocalized(((char *) GETMESSAGE(18, 41, "Help")));
- free (pch1); free (pch2); free (pch3); free (pch4); XtFree (pch5);
- /*
- * Create the dialog box
- */
- i = 0;
- XtSetArg (uiArgs[i], XmNmessageString, msg_string); i++;
- XtSetArg (uiArgs[i], XmNallowShellResize, False); i++;
- XtSetArg (uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
- XtSetArg (uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
- XtSetArg (uiArgs[i], XmNmappedWhenManaged, True); i++;
- XtSetArg (uiArgs[i], XmNokLabelString, ok_string); i++;
- XtSetArg (uiArgs[i], XmNhelpLabelString, help_string); i++;
- XtSetArg (uiArgs[i], XmNautoUnmanage, False); i++;
- smDD.confirmSession = XmCreateWarningDialog(
- smGD.topLevelWid, "confirmDialog", uiArgs, i);
- XtAddCallback (smDD.confirmSession, XmNokCallback,
- XSMPFailureOKCB, NULL);
- /*
- * Some help state is not yet initialized and the help
- * callback assumes it is so some initializations must
- * be done now.
- */
- smDD.smHelpDialog = NULL;
- smDD.okString = ok_string;
- XtAddCallback (smDD.confirmSession, XmNhelpCallback,
- TopicHelpRequested, HELP_XSMP_INIT_FAILURE_STR);
- XtUnmanageChild(XmMessageBoxGetChild(smDD.confirmSession,
- XmDIALOG_CANCEL_BUTTON));
- XtManageChild(smDD.confirmSession);
- /*
- * Center the dialog on the display
- */
- i = 0;
- XtSetArg(uiArgs[i], XmNwidth, &width); i++;
- XtSetArg(uiArgs[i], XmNheight, &height); i++;
- XtGetValues(smDD.confirmSession, uiArgs, i);
- x = (DisplayWidth(smGD.display, XDefaultScreen(smGD.display)) / 2)
- - (width / 2);
- y = (DisplayHeight(smGD.display, XDefaultScreen(smGD.display)) / 2)
- - (height / 2);
- i = 0;
- XtSetArg(uiArgs[i], XmNx, x); i++;
- XtSetArg(uiArgs[i], XmNy, y); i++;
- XtSetValues(smDD.confirmSession, uiArgs, i);
- XmStringFree (msg_string);
- XmStringFree (help_string);
- /*
- * Spin until the OK CB is invoked
- */
- while(1) {
- XtAppNextEvent(smGD.appCon, &next);
- if (next.type != 0)
- XtDispatchEvent(&next);
- }
- }
- /*************************************<->*************************************
- *
- * XSMPFailureOKCB ()
- *
- *************************************<->***********************************/
- static void
- XSMPFailureOKCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- XtUnmanageChild(smDD.confirmSession);
- SM_EXIT(1);
- }
- /*************************************<->*************************************
- *
- * PostSaveSessionErrorDialog
- *
- * Description:
- * -----------
- * Let the user know that the Save_Session message does not have the
- * required data and the session will not be saved.
- *
- * Inputs:
- * ------
- *
- * Outputs:
- * -------
- *
- *************************************<->***********************************/
- void
- PostSaveSessionErrorDialog ( void )
- {
- int i;
- XmString messageString;
- String titleString;
- if(smDD.saveSession == NULL)
- {
- messageString = XmStringCreateLocalized (((char *) GETMESSAGE(18, 56,
- "The session cannot be saved because the required\n\
- 'save_type' parameter was not in the message.\n\n\
- The session will not be saved.")));
- titleString = GETMESSAGE(18, 55, "Save Session Failure");
- i = 0;
- XtSetArg (uiArgs[i], XmNmessageString, messageString); i++;
- XtSetArg (uiArgs[i], XmNallowShellResize, True); i++;
- XtSetArg (uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
- XtSetArg (uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
- XtSetArg (uiArgs[i], XmNtitle, titleString); i++;
- XtSetArg (uiArgs[i], XmNokLabelString, smDD.okString); i++;
- XtSetArg (uiArgs[i], XmNhelpLabelString, smDD.helpString); i++;
- XtSetArg (uiArgs[i], XmNautoUnmanage, False); i++;
- smDD.saveSession = XmCreateErrorDialog(smGD.topLevelWid,
- "sessionSaveDialog", uiArgs, i);
- i = 0;
- XtSetArg (uiArgs[i], XmNuseAsyncGeometry, True);i++;
- XtSetArg (uiArgs[i], XmNmwmFunctions, 0);i++;
- XtSetArg (uiArgs[i], XmNmwmDecorations,
- (MWM_DECOR_TITLE | MWM_DECOR_BORDER)); i++;
- XtSetArg (uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
- XtSetValues(XtParent(smDD.saveSession), uiArgs, i);
-
- XtAddCallback (XtParent(smDD.saveSession),
- XmNpopupCallback, DialogUp, NULL);
- XtUnmanageChild (XmMessageBoxGetChild(smDD.saveSession,
- XmDIALOG_CANCEL_BUTTON));
- XtAddCallback (smDD.saveSession, XmNokCallback,
- SimpleOK, (XtPointer) smDD.saveSession);
- #ifndef NO_XVH
- XtAddCallback (smDD.saveSession, XmNhelpCallback,
- TopicHelpRequested, HELP_SESSION_SAVE_ERROR_STR);
- #endif
- XmStringFree(messageString);
- }
- XtManageChild(smDD.saveSession);
- return;
- }
- /*************************************<->*************************************
- *
- * PostReasonsDialog - posts a Warning dialog on behalf of a client
- * that supplied a "reason" when it closed its connection
- *
- * Inputs:
- * ------
- *
- * Outputs: void
- * -------
- *
- *************************************<->***********************************/
- void
- PostReasonsDialog (
- char * progName,
- int numMsgs,
- char ** message,
- Boolean waitForResponse)
- {
- XmString msgString;
- XmString okString;
- XmString helpString;
- Arg args[20];
- char * titleString;
- char * str1;
- char * str2;
- char * str3;
- int i;
- int len;
- XEvent next;
- str1 = strdup ((char *) GETMESSAGE(40, 28,
- "Application '%s'\nexited for the following reason:\n\n%s"));
- if (!str1) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- for (i = 0, len = 0; i < numMsgs; i++)
- len += strlen (message[i]);
- str2 = XtMalloc (len + (numMsgs * 3) + 1);
- if (!str2) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- str2[0] = '\000';
- for (i = 0; i < numMsgs; i++) {
- strcat (str2, message[i]);
- strcat (str2, "\n");
- }
- str3 = XtMalloc (strlen (str1) + strlen (str2) + strlen (progName) + 4);
- if (!str3) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- (void) sprintf (str3, str1, progName, str2);
- DtMsgLogMessage (smGD.programName, DtMsgLogWarning, str3);
- free (str1);
- str1 = strdup ((char *) GETMESSAGE(40, 29,
- "Application Close Reasons"));
- if (!str1) {
- PrintError(DtError, smNLS.cantMallocErrorString);
- SM_EXIT(1);
- }
- msgString = XmStringCreateLocalized (str3);
- okString = XmStringCreateLocalized(((char *) GETMESSAGE(18, 39, "OK")));
- helpString = XmStringCreateLocalized(((char *) GETMESSAGE(18, 41, "Help")));
- /*
- * Create the dialog box
- */
- i = 0;
- XtSetArg (uiArgs[i], XmNmessageString, msgString); i++;
- XtSetArg (uiArgs[i], XmNallowShellResize, False); i++;
- XtSetArg (uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
- XtSetArg (uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
- XtSetArg (uiArgs[i], XmNmappedWhenManaged, True); i++;
- XtSetArg (uiArgs[i], XmNtitle, str1); i++;
- XtSetArg (uiArgs[i], XmNokLabelString, okString); i++;
- XtSetArg (uiArgs[i], XmNhelpLabelString, helpString); i++;
- XtSetArg (uiArgs[i], XmNautoUnmanage, False); i++;
- smDD.clientReasons = XmCreateWarningDialog(smGD.topLevelWid,
- "clientReasons", uiArgs, i);
- i = 0;
- XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
- XtSetArg(uiArgs[i], XmNmwmFunctions, 0);i++;
- XtSetArg(uiArgs[i], XmNmwmDecorations,
- (MWM_DECOR_TITLE | MWM_DECOR_BORDER));i++;
- XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
- XtSetValues(XtParent(smDD.clientReasons), uiArgs, i);
-
- XtAddCallback (XtParent(smDD.clientReasons),
- XmNpopupCallback, DialogUp, NULL);
- XtUnmanageChild (XmMessageBoxGetChild (smDD.clientReasons,
- XmDIALOG_CANCEL_BUTTON));
- /*
- * Now add in the callback and get out of here
- */
- XtAddCallback (smDD.clientReasons, XmNokCallback,
- SimpleOK, (XtPointer) smDD.clientReasons);
- #ifndef NO_XVH
- XtAddCallback (smDD.clientReasons, XmNhelpCallback,
- TopicHelpRequested, HELP_APP_CLOSE_REASONS_STR);
- #endif
- free (str1);
- XtFree (str2);
- XtFree (str3);
- XmStringFree (msgString);
- XmStringFree (okString);
- XmStringFree (helpString);
- XtManageChild (smDD.clientReasons);
- /*
- * Spin until the OK callback is invoked. If a shutdown
- * is in progress, we don't want to return until the
- * user has acknowledged this message.
- */
- reasonsDialogOK = False;
- if (waitForResponse) {
- while (1) {
- XtAppNextEvent (smGD.appCon, &next);
- if (next.type != 0)
- XtDispatchEvent(&next);
- if (reasonsDialogOK == True)
- break;
- }
- }
- }
- /*************************************<->*************************************
- *
- * SaveTimeout
- *
- * Description:
- * -----------
- * Timeout procedure that is invoked when a save timer expires.
- *
- * Inputs:
- * ------
- *
- * Outputs: None
- * -------
- *
- *************************************<->***********************************/
- static void
- SaveTimeout (
- XtPointer client_data,
- XtIntervalId *id)
- {
- saveTimeout = True;
- if (smXSMP.saveState.shutdownCanceled == False) {
- /*
- * Run the user's exit script if there is one
- */
- if (smGD.compatMode == False)
- StartEtc(True); /* run sessionexit */
- _DtReleaseLock(smGD.display, SM_RUNNING_LOCK);
- SM_EXIT(0);
- }
- }
|