SmUI.c 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $TOG: SmUI.c /main/32 1998/07/23 18:08:17 mgreess $ */
  24. /* *
  25. * (c) Copyright 1993, 1994 Hewlett-Packard Company *
  26. * (c) Copyright 1993, 1994 International Business Machines Corp. *
  27. * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
  28. * (c) Copyright 1993, 1994 Novell, Inc. *
  29. */
  30. /*************************************<+>*************************************
  31. *****************************************************************************
  32. **
  33. ** File: SmUI.c
  34. **
  35. ** Project: DT Session Manager (dtsession)
  36. **
  37. ** Description:
  38. ** -----------
  39. ** This file handles all UI components of the session manager. This
  40. ** includes all dialog boxes. The session manager does not handle its
  41. ** representations in the front panel and customizer. That is handled
  42. ** by those tools.
  43. **
  44. **
  45. **
  46. *******************************************************************
  47. ** (c) Copyright Hewlett-Packard Company, 1990. All rights are
  48. ** reserved. Copying or other reproduction of this program
  49. ** except for archival purposes is prohibited without prior
  50. ** written consent of Hewlett-Packard Company.
  51. ********************************************************************
  52. **
  53. **
  54. **
  55. *****************************************************************************
  56. *************************************<+>*************************************/
  57. #include <signal.h>
  58. #include <stdio.h>
  59. #include <sys/param.h>
  60. #include <X11/Intrinsic.h>
  61. #include <Xm/MwmUtil.h>
  62. #include <Xm/Xm.h>
  63. #include <Xm/PushB.h>
  64. #include <Xm/Form.h>
  65. #include <Xm/Label.h>
  66. #include <Xm/LabelG.h>
  67. #include <Xm/DrawingA.h>
  68. #include <Xm/Frame.h>
  69. #include <Xm/Separator.h>
  70. #include <Xm/MessageB.h>
  71. #include <Xm/DialogS.h>
  72. #include <Xm/Text.h>
  73. #include <Dt/DtP.h>
  74. #include <Dt/SessionM.h>
  75. #include <Dt/Icon.h>
  76. #include <Dt/MsgLog.h>
  77. #include <Dt/Lock.h>
  78. #include <Tt/tttk.h>
  79. #include "Sm.h"
  80. #include "SmUI.h"
  81. #include "SmSave.h"
  82. #include "SmRestore.h"
  83. #include "SmHelp.h"
  84. #include "SmGlobals.h"
  85. #ifdef USE_XINERAMA
  86. #include <DtXinerama.h>
  87. #endif
  88. typedef enum {
  89. ConfirmationNone,
  90. ConfirmationOK,
  91. ConfirmationCancel,
  92. ConfirmationHelp
  93. } ConfirmState;
  94. ConfirmState confirmState;
  95. /*
  96. * #define statements
  97. */
  98. #define PASSWORD_INDICATOR " "
  99. typedef struct _ExitRecord {
  100. Tt_message *pmsg;
  101. union {
  102. Widget exitCancelledDialog;
  103. int queryExitConfirmedMode;
  104. } u;
  105. Boolean doSave;
  106. } ExitRecord;
  107. /*
  108. * Global variables
  109. */
  110. DialogData smDD;
  111. Arg uiArgs[20];
  112. /*
  113. * Local Function Declarations
  114. */
  115. static int CompatModeExit( void ) ;
  116. static void ExitConfirmed( Widget, XtPointer, XtPointer ) ;
  117. static void ExitCancelled( Widget, XtPointer, XtPointer ) ;
  118. static void LockDialogUp( Widget, XtPointer, XtPointer ) ;
  119. static void SimpleOK( Widget, XtPointer, XtPointer ) ;
  120. static void ConfirmOKCB ( Widget, XtPointer, XtPointer ) ;
  121. static void ConfirmCancelCB ( Widget, XtPointer, XtPointer ) ;
  122. static void ConfirmHelpCB ( Widget, XtPointer, XtPointer ) ;
  123. static void XSMPFailureOKCB( Widget w, XtPointer client_data, XtPointer call_data );
  124. static void SaveTimeout( XtPointer , XtIntervalId *) ;
  125. /*
  126. * Local vars
  127. */
  128. static Boolean session_confirmed = False;
  129. static Boolean reasonsDialogOK;
  130. static Boolean saveTimeout;
  131. /*************************************<->*************************************
  132. *
  133. * CreateLockDialog ()
  134. *
  135. *
  136. * Description:
  137. * -----------
  138. * Create the lock dialog when it exists NOT as a part of a cover
  139. *
  140. *
  141. * Inputs:
  142. * ------
  143. *
  144. *
  145. * Outputs:
  146. * -------
  147. * None.
  148. *
  149. *
  150. * Comments:
  151. * --------
  152. *
  153. *************************************<->***********************************/
  154. Widget
  155. CreateLockDialog( void )
  156. {
  157. int i, slen;
  158. Widget loginLabel, instructLabel, tmpLock, indFrame;
  159. Widget passwdLabel, passwdForm, picFrame, loginPic, loginFrame;
  160. Dimension width; /* width, height of login label */
  161. XmString lockString, passwordString;
  162. char *lockMessage;
  163. char *envLog;
  164. Pixel fg, bg, focus_color; /* foreground, background colors */
  165. i = 0;
  166. XtSetArg(uiArgs[i], XmNallowShellResize, True); i++;
  167. XtSetArg(uiArgs[i], XmNmarginWidth, 0); i++;
  168. XtSetArg(uiArgs[i], XmNmarginHeight, 0); i++;
  169. XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
  170. XtSetArg(uiArgs[i], XmNshadowThickness,5); i++;
  171. XtSetArg(uiArgs[i], XmNunitType, XmPIXELS); i++;
  172. XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
  173. XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
  174. XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
  175. XtSetArg(uiArgs[i], XmNmappedWhenManaged, True); i++;
  176. tmpLock = XmCreateFormDialog(smGD.topLevelWid, "lockDialog", uiArgs, i);
  177. XtAddCallback (XtParent(tmpLock), XmNpopupCallback,
  178. LockDialogUp, NULL);
  179. smDD.matte[0] = tmpLock;
  180. i = 0;
  181. XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
  182. XtSetArg(uiArgs[i], XmNmwmDecorations, 0);i++;
  183. XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
  184. XtSetValues(XtParent(tmpLock), uiArgs, i);
  185. i = 0;
  186. XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
  187. XtSetArg(uiArgs[i], XmNshadowThickness, 2); i++;
  188. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_FORM); i++;
  189. XtSetArg(uiArgs[i], XmNtopOffset, 15); i++;
  190. XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_FORM); i++;
  191. XtSetArg(uiArgs[i], XmNbottomOffset, 15); i++;
  192. XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
  193. XtSetArg(uiArgs[i], XmNrightOffset, 15); i++;
  194. picFrame = XmCreateFrame(tmpLock, "picFrame", uiArgs, i);
  195. i = 0;
  196. XtSetArg(uiArgs[i], XmNforeground, &fg); i++;
  197. XtSetArg(uiArgs[i], XmNbackground, &bg); i++;
  198. XtGetValues(tmpLock, uiArgs, i);
  199. i = 0;
  200. XtSetArg(uiArgs[i], XmNfillMode, XmFILL_SELF); i++;
  201. XtSetArg(uiArgs[i], XmNbehavior, XmICON_LABEL); i++;
  202. XtSetArg(uiArgs[i], XmNpixmapForeground, fg); i++;
  203. XtSetArg(uiArgs[i], XmNpixmapBackground, bg); i++;
  204. XtSetArg(uiArgs[i], XmNstring, NULL); i++;
  205. XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
  206. XtSetArg(uiArgs[i], XmNtraversalOn, False); i++;
  207. loginPic = _DtCreateIcon(picFrame, "lockLabelPixmap", uiArgs, i);
  208. i = 0;
  209. XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
  210. XtSetArg(uiArgs[i], XmNshadowThickness, 2); i++;
  211. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_FORM); i++;
  212. XtSetArg(uiArgs[i], XmNtopOffset, 15); i++;
  213. XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_FORM); i++;
  214. XtSetArg(uiArgs[i], XmNbottomOffset, 15); i++;
  215. XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
  216. XtSetArg(uiArgs[i], XmNleftOffset, 15); i++;
  217. XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
  218. XtSetArg(uiArgs[i], XmNrightOffset, 0); i++;
  219. XtSetArg(uiArgs[i], XmNrightWidget, loginPic); i++;
  220. loginFrame = XmCreateFrame(tmpLock, "loginFrame", uiArgs, i);
  221. /*
  222. * create the login matte...
  223. */
  224. i = 0;
  225. XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
  226. smDD.loginMatte[0] = XmCreateForm(loginFrame, "loginMatte", uiArgs, i);
  227. /*
  228. * create the login/password forms
  229. */
  230. i = 0;
  231. XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
  232. XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
  233. XtSetArg(uiArgs[i], XmNrightOffset, 15); i++;
  234. XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
  235. XtSetArg(uiArgs[i], XmNbottomPosition, 50); i++;
  236. XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
  237. XtSetArg(uiArgs[i], XmNleftOffset, 15); i++;
  238. smDD.loginForm[0] = XmCreateForm(smDD.loginMatte[0], "loginForm", uiArgs, i);
  239. i = 0;
  240. XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
  241. XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
  242. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
  243. XtSetArg(uiArgs[i], XmNtopPosition, 50); i++;
  244. XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
  245. XtSetArg(uiArgs[i], XmNleftWidget, smDD.loginForm[0]); i++;
  246. XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
  247. XtSetArg(uiArgs[i], XmNrightWidget, smDD.loginForm[0]); i++;
  248. passwdForm = XmCreateForm(smDD.loginMatte[0], "passwdForm", uiArgs, i);
  249. /*
  250. * create the login/password labels...
  251. */
  252. i = 0;
  253. envLog = getenv("LOGNAME");
  254. slen = 100 + strlen(envLog) + 1;
  255. lockMessage = XtCalloc(1, slen);
  256. snprintf(lockMessage, slen - 1,
  257. (char*) GETMESSAGE(18, 1, "Display locked by user %s."), envLog);
  258. lockString = XmStringCreateLocalized(lockMessage);
  259. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
  260. XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
  261. XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_CENTER); i++;
  262. XtSetArg(uiArgs[i], XmNlabelString, lockString); i++;
  263. loginLabel = XmCreateLabelGadget(smDD.loginForm[0],
  264. "loginLabel", uiArgs, i);
  265. XtManageChild(loginLabel);
  266. XmStringFree(lockString);
  267. XtFree(lockMessage);
  268. i = 0;
  269. lockString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 2, "Enter password to unlock.")));
  270. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
  271. XtSetArg(uiArgs[i], XmNtopWidget, loginLabel); i++;
  272. XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_CENTER); i++;
  273. XtSetArg(uiArgs[i], XmNlabelString, lockString); i++;
  274. instructLabel = XmCreateLabelGadget(smDD.loginForm[0], "instructLabel",
  275. uiArgs, i);
  276. XtManageChild(instructLabel);
  277. XmStringFree(lockString);
  278. i = 0;
  279. passwordString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 3, "Password: ")));
  280. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
  281. XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
  282. XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
  283. XtSetArg(uiArgs[i], XmNbottomPosition, 80); i++;
  284. XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
  285. XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_END); i++;
  286. XtSetArg(uiArgs[i], XmNlabelString, passwordString); i++;
  287. passwdLabel = XmCreateLabelGadget(passwdForm,
  288. "passwdLabel", uiArgs, i);
  289. XtManageChild(passwdLabel);
  290. XmStringFree(passwordString);
  291. /*
  292. * Give the password label an offset
  293. */
  294. i = 0;
  295. XtSetArg(uiArgs[i], XmNwidth, &width);i++;
  296. XtGetValues(passwdLabel, uiArgs, i);
  297. i = 0;
  298. width += (width/6);
  299. XtSetArg(uiArgs[i], XmNwidth, width);i++;
  300. XtSetArg(uiArgs[i], XmNrecomputeSize, False);i++;
  301. XtSetValues(passwdLabel, uiArgs, i);
  302. i = 0;
  303. XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_IN); i++;
  304. XtSetArg(uiArgs[i], XmNshadowThickness, 1); i++;
  305. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
  306. XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
  307. XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
  308. XtSetArg(uiArgs[i], XmNbottomPosition, 80); i++;
  309. XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
  310. XtSetArg(uiArgs[i], XmNleftWidget, passwdLabel); i++;
  311. XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
  312. XtSetArg(uiArgs[i], XmNrightOffset, 10); i++;
  313. XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_END); i++;
  314. indFrame = XmCreateFrame(passwdForm, "indFrame", uiArgs, i);
  315. i = 0;
  316. passwordString = XmStringCreateLocalized("|");
  317. XtSetArg(uiArgs[i], XmNlabelString, passwordString); i++;
  318. XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_BEGINNING); i++;
  319. smDD.indLabel[0] = XmCreateLabel(indFrame, "indLabel",
  320. uiArgs, i);
  321. XtManageChild(smDD.indLabel[0]);
  322. XmStringFree(passwordString);
  323. i = 0;
  324. XtSetArg(uiArgs[i], XmNhighlightColor, &focus_color); i++;
  325. XtGetValues(indFrame, uiArgs, i);
  326. XtVaSetValues ( smDD.indLabel[0],
  327. XmNborderWidth, 2,
  328. XmNborderColor, focus_color,
  329. NULL );
  330. /*
  331. * Manage forms AFTER all children have been managed
  332. */
  333. XtManageChild(indFrame);
  334. XtManageChild(passwdForm);
  335. XtManageChild(smDD.loginForm[0]);
  336. XtManageChild(smDD.loginMatte[0]);
  337. XtManageChild(loginPic);
  338. XtManageChild(picFrame);
  339. XtManageChild(loginFrame);
  340. return(tmpLock);
  341. }
  342. /*************************************<->*************************************
  343. *
  344. * ExitSession ()
  345. *
  346. *
  347. * Description:
  348. * -----------
  349. * Determines which exit routines get called when an exit request is made
  350. * of the session manager.
  351. * If smGD.bmsDead == false, we just exit.
  352. * If ASK_STATE is turned on, the query dialog is
  353. * put up, if VERBOSE is on, confirm exit in current mode (restart or reset)
  354. * if confirmation is turned off - exit immediately.
  355. *
  356. *
  357. * Inputs:
  358. * ------
  359. * msg -- if non-zero, Session_Exit request to reply/fail && destroy
  360. *
  361. *
  362. * Outputs:
  363. * -------
  364. * None.
  365. *
  366. *
  367. * Comments:
  368. * --------
  369. *
  370. *************************************<->***********************************/
  371. void
  372. ExitSession(
  373. Tt_message msg)
  374. {
  375. if (smGD.bmsDead == True)
  376. {
  377. ImmediateExit(-1, msg, True);
  378. }
  379. if(smGD.compatMode == True)
  380. {
  381. if (msg != 0) {
  382. tt_message_reply( msg );
  383. tt_message_destroy( msg );
  384. }
  385. CompatModeExit();
  386. }
  387. else
  388. {
  389. if(smSettings.confirmMode == DtSM_VERBOSE_MODE ||
  390. smSettings.startState == DtSM_ASK_STATE)
  391. {
  392. ConfirmExit( msg, True );
  393. }
  394. else
  395. {
  396. ImmediateExit(smSettings.startState, msg, True);
  397. }
  398. }
  399. }
  400. /*************************************<->*************************************
  401. *
  402. * ConfirmExit ()
  403. *
  404. *
  405. * Description:
  406. * -----------
  407. * Create the exit confirmation dialog box (if it hasn't been) and confirm
  408. * that the user wants to exit the session. This routine only gets called
  409. * when the user hasn't turned of exit confirmation and is not in ASK mode
  410. *
  411. *
  412. * Inputs:
  413. * ------
  414. * msg -- if non-zero, Session_Exit request to reply/fail && destroy
  415. *
  416. *
  417. * Outputs:
  418. * -------
  419. * None.
  420. *
  421. *
  422. * Comments:
  423. * --------
  424. *
  425. *************************************<->***********************************/
  426. int
  427. ConfirmExit(
  428. Tt_message msg,
  429. Boolean doSave)
  430. {
  431. int i;
  432. String tmpString;
  433. ExitRecord *exitRec;
  434. Tt_message *pmsg;
  435. static XmString homeToHome; /* started Home, restore to Home */
  436. static XmString returnToCurrent; /* started Home or Current but
  437. retrun to Current */
  438. static XmString currentToHome; /* started Current, return to Home */
  439. if(smDD.confExit == NULL)
  440. {
  441. /*
  442. * Create all compound strings for confirmation dialogs
  443. */
  444. returnToCurrent = XmStringCreateLocalized(((char *)GETMESSAGE(18, 4,
  445. "Exiting the desktop session...\n\n\
  446. Your Current session will be restored upon login.\n\n\
  447. Application updates you have not saved will be lost.\n\n\
  448. Continue Logout?")));
  449. homeToHome = XmStringCreateLocalized(((char *)GETMESSAGE(18, 5,
  450. "Exiting the desktop session...\n\n\
  451. Your Home session will be restored upon login.\n\
  452. Your Current session will not be saved.\n\n\
  453. Application updates you have not saved will be lost.\n\n\
  454. Continue Logout?")));
  455. currentToHome = XmStringCreateLocalized(((char *)GETMESSAGE(18, 75,
  456. "Exiting the desktop session...\n\n\
  457. Your Current session will be saved but your Home\n\
  458. session will be restored upon login.\n\n\
  459. Application updates you have not saved will be lost.\n\n\
  460. Continue Logout?")));
  461. /*
  462. * Build up the correct string for this dialog
  463. */
  464. i = 0;
  465. if (smGD.sessionType == HOME_SESSION &&
  466. smSettings.startState == DtSM_HOME_STATE)
  467. {
  468. XtSetArg(uiArgs[i], XmNmessageString, homeToHome); i++;
  469. }
  470. else if (smGD.sessionType == CURRENT_SESSION &&
  471. smSettings.startState == DtSM_HOME_STATE)
  472. {
  473. XtSetArg(uiArgs[i], XmNmessageString, currentToHome); i++;
  474. }
  475. else
  476. {
  477. XtSetArg(uiArgs[i], XmNmessageString, returnToCurrent); i++;
  478. }
  479. /*
  480. * Now create the dialog box
  481. */
  482. tmpString = GETMESSAGE(18, 6, "Logout Confirmation");
  483. XtSetArg (uiArgs[i], XmNallowShellResize, False); i++;
  484. XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
  485. XtSetArg(uiArgs[i], XmNmessageAlignment, XmALIGNMENT_CENTER); i++;
  486. XtSetArg(uiArgs[i], XmNtitle, tmpString); i++;
  487. XtSetArg(uiArgs[i], XmNokLabelString, smDD.okLogoutString); i++;
  488. XtSetArg(uiArgs[i], XmNcancelLabelString, smDD.cancelLogoutString); i++;
  489. XtSetArg(uiArgs[i], XmNhelpLabelString, smDD.helpString); i++;
  490. XtSetArg(uiArgs[i], XmNautoUnmanage, False); i++;
  491. pmsg = (Tt_message *)XtMalloc(sizeof(Tt_message));
  492. XtSetArg(uiArgs[i], XmNuserData, pmsg); i++;
  493. smDD.confExit = XmCreateWarningDialog(smGD.topLevelWid, "exitDialog",
  494. uiArgs, i);
  495. i = 0;
  496. XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
  497. XtSetArg(uiArgs[i], XmNmwmFunctions, 0);i++;
  498. XtSetArg(uiArgs[i], XmNmwmDecorations,
  499. (MWM_DECOR_TITLE | MWM_DECOR_BORDER));i++;
  500. XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
  501. XtSetValues(XtParent(smDD.confExit), uiArgs, i);
  502. exitRec = (ExitRecord *)XtMalloc( sizeof(ExitRecord) );
  503. exitRec->pmsg = pmsg;
  504. exitRec->doSave = doSave;
  505. XtAddCallback (smDD.confExit, XmNokCallback, ExitConfirmed, exitRec);
  506. #ifndef NO_XVH
  507. XtAddCallback (smDD.confExit, XmNhelpCallback,
  508. TopicHelpRequested, HELP_LOGOUT_STR);
  509. #endif
  510. exitRec = (ExitRecord *)XtMalloc( sizeof(ExitRecord) );
  511. exitRec->pmsg = pmsg;
  512. exitRec->doSave = doSave;
  513. exitRec->u.exitCancelledDialog = smDD.confExit;
  514. XtAddCallback (smDD.confExit, XmNcancelCallback,
  515. ExitCancelled, exitRec);
  516. }
  517. else
  518. {
  519. /*
  520. * The user may have changed the type of session to be
  521. * restored so must update the dialog's message.
  522. */
  523. i = 0;
  524. if (smGD.sessionType == HOME_SESSION &&
  525. smSettings.startState == DtSM_HOME_STATE)
  526. {
  527. XtSetArg(uiArgs[i], XmNmessageString, homeToHome); i++;
  528. }
  529. else if (smGD.sessionType == CURRENT_SESSION &&
  530. smSettings.startState == DtSM_HOME_STATE)
  531. {
  532. XtSetArg(uiArgs[i], XmNmessageString, currentToHome); i++;
  533. }
  534. else
  535. {
  536. XtSetArg(uiArgs[i], XmNmessageString, returnToCurrent); i++;
  537. }
  538. XtSetValues(smDD.confExit, uiArgs, i);
  539. }
  540. /*
  541. * Refresh buffer containing pointer to Tt_message.
  542. */
  543. i=0;
  544. XtSetArg(uiArgs[i], XmNuserData, &pmsg); i++;
  545. XtGetValues(smDD.confExit, uiArgs, i);
  546. *pmsg = msg;
  547. XtAddCallback (XtParent(smDD.confExit), XmNpopupCallback, DialogUp, NULL);
  548. XtManageChild(smDD.confExit);
  549. return(0);
  550. }
  551. /*************************************<->*************************************
  552. *
  553. * WarnMsgFailue ()
  554. *
  555. *
  556. * Description:
  557. * -----------
  558. * Let the user know that the bms has died and that the current session
  559. * will not be saved.
  560. *
  561. *
  562. * Inputs:
  563. * ------
  564. *
  565. *
  566. * Outputs:
  567. * -------
  568. * None.
  569. *
  570. *
  571. * Comments:
  572. * --------
  573. *
  574. *************************************<->***********************************/
  575. int
  576. WarnMsgFailure( void )
  577. {
  578. int i;
  579. XmString bmsDeadString;
  580. String tmpString;
  581. if(smDD.deadWid == NULL)
  582. {
  583. bmsDeadString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 38,
  584. "Messaging System Inoperative\n\n\
  585. To restart:\n\n1) Save all open data files.\n\
  586. 2) Logout.\n\
  587. 3) Log in again.\n\nNote: The current session will not be saved.\n\n\
  588. When you are ready to begin the restart process, click [OK] and\n\
  589. proceed to save your files.")));
  590. /*
  591. * Now create the dialog box
  592. */
  593. i = 0;
  594. tmpString = GETMESSAGE(18, 12, "Message Failure");
  595. XtSetArg(uiArgs[i], XmNmessageString, bmsDeadString);i++;
  596. XtSetArg(uiArgs[i], XmNallowShellResize, True); i++;
  597. XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
  598. XtSetArg(uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
  599. XtSetArg(uiArgs[i], XmNtitle, tmpString); i++;
  600. XtSetArg(uiArgs[i], XmNokLabelString, smDD.okString); i++;
  601. XtSetArg(uiArgs[i], XmNhelpLabelString, smDD.helpString); i++;
  602. XtSetArg(uiArgs[i], XmNautoUnmanage, False); i++;
  603. smDD.deadWid = XmCreateWarningDialog(smGD.topLevelWid, "deadDialog",
  604. uiArgs, i);
  605. i = 0;
  606. XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
  607. XtSetArg(uiArgs[i], XmNmwmFunctions, 0);i++;
  608. XtSetArg(uiArgs[i], XmNmwmDecorations,
  609. (MWM_DECOR_TITLE | MWM_DECOR_BORDER));i++;
  610. XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
  611. XtSetValues(XtParent(smDD.deadWid), uiArgs, i);
  612. XtAddCallback (XtParent(smDD.deadWid),
  613. XmNpopupCallback, DialogUp, NULL);
  614. XtUnmanageChild(XmMessageBoxGetChild(smDD.deadWid,
  615. XmDIALOG_CANCEL_BUTTON));
  616. /*
  617. * Now add in the callback and get out of here
  618. */
  619. XtAddCallback (smDD.deadWid, XmNokCallback,
  620. SimpleOK, (XtPointer) smDD.deadWid);
  621. #ifndef NO_XVH
  622. XtAddCallback (smDD.deadWid, XmNhelpCallback,
  623. TopicHelpRequested, HELP_BMS_DEAD_STR);
  624. #endif
  625. XtAddCallback (smDD.deadWid, XmNcancelCallback,
  626. NULL, NULL);
  627. XmStringFree(bmsDeadString);
  628. }
  629. XtManageChild(smDD.deadWid);
  630. return(0);
  631. }
  632. /*************************************<->*************************************
  633. *
  634. * CompatModeExit ()
  635. *
  636. *
  637. * Description:
  638. * -----------
  639. * Let the user know that the logout button can not be used to exit in
  640. * compatibility mode.
  641. *
  642. *
  643. * Inputs:
  644. * ------
  645. *
  646. *
  647. * Outputs:
  648. * -------
  649. * None.
  650. *
  651. *
  652. * Comments:
  653. * --------
  654. *
  655. *************************************<->***********************************/
  656. static int
  657. CompatModeExit( void )
  658. {
  659. int i;
  660. XmString compatModeString;
  661. String tmpString;
  662. if(smDD.compatExit == NULL)
  663. {
  664. compatModeString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 34,
  665. "This session was started from an X Window System startup script.\n\n\
  666. No session information will be saved.\n\nUse the reset key sequence to log out.")));
  667. /*
  668. * Now create the dialog box
  669. */
  670. i = 0;
  671. tmpString = GETMESSAGE(18, 35, "Logout Message");
  672. XtSetArg(uiArgs[i], XmNmessageString, compatModeString);i++;
  673. XtSetArg(uiArgs[i], XmNallowShellResize, True); i++;
  674. XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
  675. XtSetArg(uiArgs[i], XmNmessageAlignment, XmALIGNMENT_CENTER); i++;
  676. XtSetArg(uiArgs[i], XmNtitle, tmpString); i++;
  677. XtSetArg(uiArgs[i], XmNokLabelString, smDD.okString); i++;
  678. XtSetArg(uiArgs[i], XmNhelpLabelString, smDD.helpString); i++;
  679. XtSetArg(uiArgs[i], XmNautoUnmanage, False); i++;
  680. smDD.compatExit = XmCreateInformationDialog(smGD.topLevelWid,
  681. "compatDialog",
  682. uiArgs, i);
  683. i = 0;
  684. XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
  685. XtSetArg(uiArgs[i], XmNmwmFunctions, 0);i++;
  686. XtSetArg(uiArgs[i], XmNmwmDecorations,
  687. (MWM_DECOR_TITLE | MWM_DECOR_BORDER));i++;
  688. XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
  689. XtSetValues(XtParent(smDD.compatExit), uiArgs, i);
  690. XtAddCallback (XtParent(smDD.compatExit),
  691. XmNpopupCallback, DialogUp, NULL);
  692. XtUnmanageChild(XmMessageBoxGetChild(smDD.compatExit,
  693. XmDIALOG_CANCEL_BUTTON));
  694. /*
  695. * Now add in the callback and get out of here
  696. */
  697. XtAddCallback (smDD.compatExit, XmNokCallback,
  698. SimpleOK, smDD.compatExit);
  699. #ifndef NO_XVH
  700. XtAddCallback (smDD.compatExit, XmNhelpCallback,
  701. TopicHelpRequested, HELP_LOGOUT_COMPAT_MODE_STR);
  702. #endif
  703. XmStringFree(compatModeString);
  704. }
  705. XtManageChild(smDD.compatExit);
  706. return(0);
  707. }
  708. /*************************************<->*************************************
  709. *
  710. * CreateLockDialogWithCover()
  711. *
  712. *
  713. * Description:
  714. * -----------
  715. * Create the lock dialog when it exists as a part of a cover
  716. *
  717. *
  718. * Inputs:
  719. * ------
  720. *
  721. *
  722. * Outputs:
  723. * -------
  724. * None.
  725. *
  726. *
  727. * Comments:
  728. * --------
  729. *
  730. *************************************<->***********************************/
  731. Widget
  732. CreateLockDialogWithCover(
  733. Widget parent )
  734. {
  735. int i;
  736. Widget loginLabel, instructLabel, tmpLock;
  737. Widget indFrame, loginPic, picFrame, loginFrame;
  738. Widget passwdLabel, passwdForm;
  739. Dimension width; /* width, height of drop shadow */
  740. XmString lockString, passwordString;
  741. char *lockMessage;
  742. char *envLog;
  743. Pixel fg, bg, focus_color; /* foreground, background colors */
  744. i = 0;
  745. XtSetArg(uiArgs[i], XmNmarginWidth, 0); i++;
  746. XtSetArg(uiArgs[i], XmNmarginHeight, 0); i++;
  747. XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
  748. XtSetArg(uiArgs[i], XmNshadowThickness,5); i++;
  749. XtSetArg(uiArgs[i], XmNunitType, XmPIXELS); i++;
  750. XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
  751. XtSetArg(uiArgs[i], XmNmappedWhenManaged, False); i++;
  752. tmpLock = XmCreateForm(parent, "lockDialog", uiArgs, i);
  753. smDD.matte[1] = tmpLock;
  754. i = 0;
  755. XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
  756. XtSetArg(uiArgs[i], XmNshadowThickness, 2); i++;
  757. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_FORM); i++;
  758. XtSetArg(uiArgs[i], XmNtopOffset, 15); i++;
  759. XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_FORM); i++;
  760. XtSetArg(uiArgs[i], XmNbottomOffset, 15); i++;
  761. XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
  762. XtSetArg(uiArgs[i], XmNrightOffset, 15); i++;
  763. picFrame = XmCreateFrame(tmpLock, "picFrame", uiArgs, i);
  764. i = 0;
  765. XtSetArg(uiArgs[i], XmNforeground, &fg); i++;
  766. XtSetArg(uiArgs[i], XmNbackground, &bg); i++;
  767. XtGetValues(tmpLock, uiArgs, i);
  768. i = 0;
  769. XtSetArg(uiArgs[i], XmNfillMode, XmFILL_SELF); i++;
  770. XtSetArg(uiArgs[i], XmNbehavior, XmICON_LABEL); i++;
  771. XtSetArg(uiArgs[i], XmNpixmapForeground, fg); i++;
  772. XtSetArg(uiArgs[i], XmNpixmapBackground, bg); i++;
  773. XtSetArg(uiArgs[i], XmNstring, NULL); i++;
  774. XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
  775. XtSetArg(uiArgs[i], XmNtraversalOn, False); i++;
  776. loginPic = _DtCreateIcon(picFrame, "lockLabelPixmap", uiArgs, i);
  777. i = 0;
  778. XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_OUT); i++;
  779. XtSetArg(uiArgs[i], XmNshadowThickness, 2); i++;
  780. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_FORM); i++;
  781. XtSetArg(uiArgs[i], XmNtopOffset, 15); i++;
  782. XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_FORM); i++;
  783. XtSetArg(uiArgs[i], XmNbottomOffset, 15); i++;
  784. XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
  785. XtSetArg(uiArgs[i], XmNleftOffset, 15); i++;
  786. XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
  787. XtSetArg(uiArgs[i], XmNrightWidget, picFrame); i++;
  788. XtSetArg(uiArgs[i], XmNrightOffset, 0); i++;
  789. loginFrame = XmCreateFrame(tmpLock, "loginFrame", uiArgs, i);
  790. /*
  791. * create the login matte...
  792. */
  793. i = 0;
  794. XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
  795. smDD.loginMatte[1] = XmCreateForm(loginFrame, "loginMatte", uiArgs, i);
  796. /*
  797. * create the login/password forms
  798. */
  799. i = 0;
  800. XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
  801. XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
  802. XtSetArg(uiArgs[i], XmNrightOffset, 15); i++;
  803. XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
  804. XtSetArg(uiArgs[i], XmNbottomPosition, 50); i++;
  805. XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
  806. XtSetArg(uiArgs[i], XmNleftOffset, 15); i++;
  807. smDD.loginForm[1] = XmCreateForm(smDD.loginMatte[1], "loginForm", uiArgs, i);
  808. i = 0;
  809. XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
  810. XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
  811. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
  812. XtSetArg(uiArgs[i], XmNtopPosition, 50); i++;
  813. XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
  814. XtSetArg(uiArgs[i], XmNleftWidget, smDD.loginForm[1]); i++;
  815. XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
  816. XtSetArg(uiArgs[i], XmNrightWidget, smDD.loginForm[1]); i++;
  817. passwdForm = XmCreateForm(smDD.loginMatte[1], "passwdForm", uiArgs, i);
  818. /*
  819. * create the login/password labels...
  820. */
  821. i = 0;
  822. envLog = getenv("LOGNAME");
  823. lockMessage = XtCalloc(1, 100 + strlen(envLog));
  824. snprintf(lockMessage, 100 + strlen(envLog) - 1,
  825. ((char *)GETMESSAGE(18, 1, "Display locked by user %s.")), envLog);
  826. lockString = XmStringCreateLocalized(lockMessage);
  827. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
  828. XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
  829. XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_CENTER); i++;
  830. XtSetArg(uiArgs[i], XmNlabelString, lockString); i++;
  831. loginLabel = XmCreateLabelGadget(smDD.loginForm[1],
  832. "loginLabel", uiArgs, i);
  833. XtManageChild(loginLabel);
  834. XmStringFree(lockString);
  835. XtFree(lockMessage);
  836. i = 0;
  837. lockString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 2, "Enter password to unlock.")));
  838. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
  839. XtSetArg(uiArgs[i], XmNtopWidget, loginLabel); i++;
  840. XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_CENTER); i++;
  841. XtSetArg(uiArgs[i], XmNlabelString, lockString); i++;
  842. instructLabel = XmCreateLabelGadget(smDD.loginForm[1], "instructLabel",
  843. uiArgs, i);
  844. XtManageChild(instructLabel);
  845. XmStringFree(lockString);
  846. i = 0;
  847. passwordString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 3, "Password: ")));
  848. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
  849. XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
  850. XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
  851. XtSetArg(uiArgs[i], XmNbottomPosition, 80); i++;
  852. XtSetArg(uiArgs[i], XmNleftOffset, 0); i++;
  853. XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_END); i++;
  854. XtSetArg(uiArgs[i], XmNlabelString, passwordString); i++;
  855. passwdLabel = XmCreateLabelGadget(passwdForm,
  856. "passwdLabel", uiArgs, i);
  857. XtManageChild(passwdLabel);
  858. XmStringFree(passwordString);
  859. /*
  860. * Give the password label an offset
  861. */
  862. i = 0;
  863. XtSetArg(uiArgs[i], XmNwidth, &width);i++;
  864. XtGetValues(passwdLabel, uiArgs, i);
  865. i = 0;
  866. width += (width/6);
  867. XtSetArg(uiArgs[i], XmNwidth, width);i++;
  868. XtSetArg(uiArgs[i], XmNrecomputeSize, False);i++;
  869. XtSetValues(passwdLabel, uiArgs, i);
  870. i = 0;
  871. XtSetArg(uiArgs[i], XmNshadowType, XmSHADOW_IN); i++;
  872. XtSetArg(uiArgs[i], XmNshadowThickness, 1); i++;
  873. XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
  874. XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
  875. XtSetArg(uiArgs[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
  876. XtSetArg(uiArgs[i], XmNbottomPosition, 80); i++;
  877. XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
  878. XtSetArg(uiArgs[i], XmNleftWidget, passwdLabel); i++;
  879. XtSetArg(uiArgs[i], XmNrightAttachment, XmATTACH_FORM); i++;
  880. XtSetArg(uiArgs[i], XmNrightOffset, 10); i++;
  881. XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_END); i++;
  882. indFrame = XmCreateFrame(passwdForm, "indFrame", uiArgs, i);
  883. i = 0;
  884. passwordString = XmStringCreateLocalized("|");
  885. XtSetArg(uiArgs[i], XmNlabelString, passwordString); i++;
  886. XtSetArg(uiArgs[i], XmNalignment, XmALIGNMENT_BEGINNING); i++;
  887. smDD.indLabel[1] = XmCreateLabel(indFrame, "indLabel",
  888. uiArgs, i);
  889. XtManageChild(smDD.indLabel[1]);
  890. XmStringFree(passwordString);
  891. i = 0;
  892. XtSetArg(uiArgs[i], XmNhighlightColor, &focus_color); i++;
  893. XtGetValues(indFrame, uiArgs, i);
  894. XtVaSetValues ( smDD.indLabel[1],
  895. XmNborderWidth, 2,
  896. XmNborderColor, focus_color,
  897. NULL );
  898. /*
  899. * Manage forms AFTER all children have been managed
  900. */
  901. XtManageChild(indFrame);
  902. XtManageChild(passwdForm);
  903. XtManageChild(smDD.loginForm[1]);
  904. XtManageChild(smDD.loginMatte[1]);
  905. XtManageChild(loginPic);
  906. XtManageChild(picFrame);
  907. XtManageChild(loginFrame);
  908. return(tmpLock);
  909. }
  910. /*************************************<->*************************************
  911. *
  912. * CreateCoverDialog ()
  913. *
  914. *
  915. * Description:
  916. * -----------
  917. * Create the cover dialogs for all the screens
  918. *
  919. *
  920. * Inputs:
  921. * ------
  922. *
  923. *
  924. * Outputs:
  925. * -------
  926. * None.
  927. *
  928. *
  929. * Comments:
  930. * --------
  931. *
  932. *************************************<->***********************************/
  933. Widget
  934. CreateCoverDialog(
  935. int screenNum,
  936. Boolean withLock )
  937. {
  938. int i;
  939. Widget tmpCover, table;
  940. char geomString[50];
  941. sprintf(geomString, "%dx%d+0+0",
  942. DisplayWidth(smGD.display, screenNum),
  943. DisplayHeight(smGD.display, screenNum));
  944. i = 0;
  945. XtSetArg(uiArgs[i], XmNmwmDecorations, 0);i++;
  946. XtSetArg(uiArgs[i], XmNgeometry, (String) geomString);i++;
  947. XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
  948. XtSetArg(uiArgs[i], XmNallowShellResize, True); i++;
  949. XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
  950. XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
  951. XtSetArg(uiArgs[i], XmNdepth, DefaultDepth(smGD.display, screenNum));i++;
  952. XtSetArg(uiArgs[i], XmNscreen,
  953. ScreenOfDisplay(smGD.display, screenNum));i++;
  954. XtSetArg(uiArgs[i], XmNcolormap,
  955. DefaultColormap(smGD.display, screenNum));i++;
  956. tmpCover = XtCreatePopupShell("coverDialog", topLevelShellWidgetClass,
  957. smGD.topLevelWid, uiArgs, i);
  958. i = 0;
  959. XtSetArg(uiArgs[i], XmNmarginWidth, 0); i++;
  960. XtSetArg(uiArgs[i], XmNmarginHeight, 0); i++;
  961. XtSetArg(uiArgs[i], XmNshadowThickness, 0); i++;
  962. XtSetArg(uiArgs[i], XmNheight,
  963. (Dimension) DisplayHeight(smGD.display, smGD.screen)); i++;
  964. XtSetArg(uiArgs[i], XmNwidth,
  965. (Dimension) DisplayWidth(smGD.display, smGD.screen)); i++;
  966. XtSetArg(uiArgs[i], XmNresizePolicy, XmRESIZE_NONE);i++;
  967. table = XmCreateDrawingArea(tmpCover, "drawArea", uiArgs, i);
  968. XtManageChild(table);
  969. smDD.coverDrawing[screenNum] = table;
  970. if(withLock == True)
  971. {
  972. XtAddCallback (tmpCover, XmNpopupCallback,
  973. LockDialogUp, NULL);
  974. }
  975. XtRealizeWidget(tmpCover);
  976. return(tmpCover);
  977. }
  978. /*************************************<->*************************************
  979. *
  980. * ExitConfirmed ()
  981. *
  982. *
  983. * Description:
  984. * -----------
  985. * Callback that is called when user confirms the exit of a session by
  986. * pressing the OK button on the confirmation dialog. This routine just
  987. * facilitates the exit process.
  988. *
  989. *
  990. * Inputs:
  991. * ------
  992. *
  993. *
  994. * Outputs:
  995. * -------
  996. * None.
  997. *
  998. *
  999. * Comments:
  1000. * --------
  1001. *
  1002. *************************************<->***********************************/
  1003. static void
  1004. ExitConfirmed(
  1005. Widget w,
  1006. XtPointer client_data,
  1007. XtPointer call_data )
  1008. {
  1009. ExitRecord *exitRec = (ExitRecord *)client_data;
  1010. XtUnmanageChild(smDD.confExit);
  1011. ImmediateExit(smSettings.startState, *exitRec->pmsg, exitRec->doSave);
  1012. }
  1013. /*************************************<->*************************************
  1014. *
  1015. * ImmediateExit -
  1016. *
  1017. *
  1018. * Description:
  1019. * -----------
  1020. * This process puts in motion the exit procedure, and then exits.
  1021. *
  1022. *
  1023. * Inputs:
  1024. * ------
  1025. * mode = Whether this session should be reset or restarted
  1026. * msg -- if non-zero, Session_Exit request to reply/fail && destroy
  1027. * doSave - if True, the session will be saved.
  1028. *
  1029. *
  1030. * Outputs:
  1031. * -------
  1032. * None.
  1033. *
  1034. *
  1035. * Comments:
  1036. * --------
  1037. *
  1038. *************************************<->***********************************/
  1039. void
  1040. ImmediateExit(
  1041. int mode,
  1042. Tt_message msg,
  1043. Boolean doSave)
  1044. {
  1045. long old;
  1046. Tt_message notice;
  1047. /*
  1048. * Turn off SIGTERM so we don't catch one in the middle of shutting
  1049. * down
  1050. */
  1051. #if !defined(SVR4)
  1052. old = sigblock(sigmask(SIGTERM));
  1053. sigblock(sigmask(SIGHUP));
  1054. sigblock(sigmask(SIGPIPE));
  1055. #else
  1056. old = sighold(SIGTERM);
  1057. #endif
  1058. /*
  1059. *
  1060. */
  1061. if(smGD.bmsDead == False)
  1062. {
  1063. notice = (Tt_message) tttk_message_create( NULL, TT_NOTICE, TT_SESSION, NULL,
  1064. "XSession_Ending", NULL);
  1065. tt_message_send( notice );
  1066. tt_message_destroy( notice );
  1067. }
  1068. if (msg != 0) {
  1069. tt_message_reply( msg );
  1070. tt_message_destroy( msg );
  1071. }
  1072. if (doSave)
  1073. {
  1074. XEvent next;
  1075. Tt_message msg;
  1076. int sessionType = smGD.sessionType;
  1077. XtIntervalId timerId;
  1078. msg = (Tt_message) tttk_message_create( NULL, TT_NOTICE, TT_SESSION, NULL,
  1079. "DtActivity_Beginning", NULL );
  1080. tt_message_send( msg );
  1081. tt_message_destroy( msg );
  1082. if (smGD.sessionType == CURRENT_SESSION ||
  1083. smGD.sessionType == DEFAULT_SESSION)
  1084. SaveState (False, DtSM_CURRENT_STATE, SmSaveLocal, True,
  1085. DEFAULT_INTERACT_STYLE, DEFAULT_FAST, DEFAULT_GLOBAL);
  1086. else if (smGD.sessionType == HOME_SESSION &&
  1087. smSettings.startState == DtSM_CURRENT_STATE)
  1088. SaveState (False, DtSM_HOME_STATE, SmSaveLocal, True,
  1089. DEFAULT_INTERACT_STYLE, DEFAULT_FAST, DEFAULT_GLOBAL);
  1090. else
  1091. SaveState (False, DtSM_HOME_STATE, SmSaveGlobal, True,
  1092. DEFAULT_INTERACT_STYLE, DEFAULT_FAST, DEFAULT_GLOBAL);
  1093. /*
  1094. * Restore sessionType - it may have been changed in SaveState
  1095. */
  1096. smGD.sessionType = sessionType;
  1097. XSync(smGD.display, 0);
  1098. smGD.loggingOut = True;
  1099. /* JET - set this here so we don't exit prematurely (while
  1100. * handling our own SM exit callback - duh).
  1101. */
  1102. smGD.ExitComplete = False;
  1103. saveTimeout = False;
  1104. timerId = XtAppAddTimeOut (smGD.appCon, smRes.saveYourselfTimeout,
  1105. SaveTimeout, NULL);
  1106. while (smXSMP.saveState.saveComplete == False &&
  1107. smXSMP.saveState.shutdownCanceled == False) {
  1108. if (saveTimeout)
  1109. break;
  1110. XtAppNextEvent(smGD.appCon, &next);
  1111. if (next.type != 0)
  1112. XtDispatchEvent(&next);
  1113. }
  1114. }
  1115. /* JET - need this, since dtsession was exiting in the
  1116. * XtAppNextEvent above (receiving it's own EXIT SM message) This
  1117. * is checked in SmExit() so exit's will only occur after this
  1118. * housekeeping has been completed.
  1119. */
  1120. smGD.ExitComplete = True;
  1121. if (smXSMP.saveState.shutdownCanceled == False) {
  1122. /*
  1123. * Run the user's exit script if there is one
  1124. */
  1125. if (smGD.compatMode == False)
  1126. {
  1127. StartEtc(True); /* run sessionexit */
  1128. }
  1129. _DtReleaseLock(smGD.display, SM_RUNNING_LOCK);
  1130. SM_EXIT(0);
  1131. }
  1132. }
  1133. /*************************************<->*************************************
  1134. *
  1135. * ExitCancelled ()
  1136. *
  1137. *
  1138. * Description:
  1139. * -----------
  1140. * Called when the user bails out from a logout at the confirmation dialog
  1141. *
  1142. *
  1143. * Inputs:
  1144. * ------
  1145. * client_data - tells which dialog to unmange (the query or confirm exit)
  1146. * msg -- if non-zero, Session_Exit request to reply/fail && destroy
  1147. *
  1148. *
  1149. * Outputs:
  1150. * -------
  1151. * None.
  1152. *
  1153. *
  1154. * Comments:
  1155. * --------
  1156. *
  1157. *************************************<->***********************************/
  1158. static void
  1159. ExitCancelled(
  1160. Widget w,
  1161. XtPointer client_data,
  1162. XtPointer call_data )
  1163. {
  1164. ExitRecord *exitRec = (ExitRecord *)client_data;
  1165. if(XtIsManaged(exitRec->u.exitCancelledDialog))
  1166. {
  1167. XtUnmanageChild(exitRec->u.exitCancelledDialog);
  1168. }
  1169. if(smDD.smHelpDialog && XtIsManaged(smDD.smHelpDialog))
  1170. {
  1171. XtUnmanageChild(smDD.smHelpDialog);
  1172. }
  1173. if (*exitRec->pmsg != 0) {
  1174. tttk_message_fail(*exitRec->pmsg, TT_DESKTOP_ECANCELED, 0, 1 );
  1175. }
  1176. SetSystemReady();
  1177. }
  1178. /*************************************<->*************************************
  1179. *
  1180. * DialogUp ()
  1181. *
  1182. *
  1183. * Description:
  1184. * -----------
  1185. * Once the dialog is managed, but not popped up - reposition it so that
  1186. * it appears in the middle of the screen then remove the popup callback
  1187. *
  1188. *
  1189. * Inputs:
  1190. * ------
  1191. *
  1192. *
  1193. * Outputs:
  1194. * -------
  1195. * None
  1196. *
  1197. *
  1198. * Comments:
  1199. * --------
  1200. * This routine can be used for any generic SYSTEM_MODAL dialog
  1201. *
  1202. *************************************<->***********************************/
  1203. void
  1204. DialogUp(
  1205. Widget w,
  1206. XtPointer client_data,
  1207. XtPointer call_data )
  1208. {
  1209. int i;
  1210. Dimension width, height;
  1211. Position x, y;
  1212. unsigned int dpwidth, dpheight, xorg, yorg; /* JET - Xinerama */
  1213. /*
  1214. * Get the size of the dialog box - then compute its position
  1215. */
  1216. i = 0;
  1217. XtSetArg(uiArgs[i], XmNwidth, &width);i++;
  1218. XtSetArg(uiArgs[i], XmNheight, &height);i++;
  1219. XtGetValues(w, uiArgs, i);
  1220. /* JET - get xinerama info */
  1221. #ifdef USE_XINERAMA
  1222. /* use the 'prefered' screen */
  1223. if (!_DtXineramaGetScreen(smGD.DtXineramaInfo,
  1224. smRes.xineramaPreferredScreen,
  1225. &dpwidth, &dpheight, &xorg, &yorg))
  1226. { /* no joy here either - setup for normal */
  1227. dpwidth = DisplayWidth(smGD.display, smGD.screen);
  1228. dpheight = DisplayHeight(smGD.display, smGD.screen);
  1229. xorg = yorg = 0;
  1230. }
  1231. #else /* no Xinerama */
  1232. dpwidth = DisplayWidth(smGD.display, smGD.screen);
  1233. dpheight = DisplayHeight(smGD.display, smGD.screen);
  1234. xorg = yorg = 0;
  1235. #endif
  1236. x = (dpwidth / 2) - (width / 2);
  1237. y = (dpheight / 2) - (height / 2);
  1238. /* add the x/y origins for Xinerama */
  1239. x += xorg;
  1240. y += yorg;
  1241. i = 0;
  1242. XtSetArg(uiArgs[i], XmNx, x);i++;
  1243. XtSetArg(uiArgs[i], XmNy, y);i++;
  1244. XtSetValues(w, uiArgs, i);
  1245. XtRemoveCallback(w, XmNpopupCallback, DialogUp, NULL);
  1246. }
  1247. /*************************************<->*************************************
  1248. *
  1249. * ShowWaitState (flag)
  1250. *
  1251. *
  1252. * Description:
  1253. * -----------
  1254. * Enter/Leave the wait state.
  1255. *
  1256. *
  1257. * Inputs:
  1258. * ------
  1259. * flag = TRUE for Enter, FALSE for Leave.
  1260. *
  1261. *
  1262. * Outputs:
  1263. * -------
  1264. * None.
  1265. *
  1266. *
  1267. * Comments:
  1268. * --------
  1269. * Stolen from the window manager code.
  1270. *
  1271. *************************************<->***********************************/
  1272. void
  1273. ShowWaitState(
  1274. Boolean flag )
  1275. {
  1276. if (flag)
  1277. {
  1278. XGrabPointer (smGD.display, DefaultRootWindow(smGD.display), FALSE,
  1279. 0, GrabModeAsync, GrabModeAsync, None,
  1280. smGD.waitCursor, CurrentTime);
  1281. XGrabKeyboard (smGD.display, DefaultRootWindow(smGD.display), FALSE,
  1282. GrabModeAsync, GrabModeAsync, CurrentTime);
  1283. }
  1284. else
  1285. {
  1286. XUngrabPointer (smGD.display, CurrentTime);
  1287. XUngrabKeyboard (smGD.display, CurrentTime);
  1288. }
  1289. XSync(smGD.display, 0);
  1290. }
  1291. /*************************************<->*************************************
  1292. *
  1293. * InitCursorInfo ()
  1294. *
  1295. *
  1296. * Description:
  1297. * -----------
  1298. * This function determines whether a server supports large cursors. It it
  1299. * does large feedback cursors are used in some cases (wait state and
  1300. * system modal state); otherwise smaller (16x16) standard cursors are used.
  1301. *
  1302. * Outputs:
  1303. * -------
  1304. * Returns true if large cursors are supported, false otherwise
  1305. *
  1306. * Comments:
  1307. * ---------
  1308. * This code was stolen from the window manager
  1309. *
  1310. *************************************<->***********************************/
  1311. Boolean
  1312. InitCursorInfo( void )
  1313. {
  1314. unsigned int cWidth;
  1315. unsigned int cHeight;
  1316. if (XQueryBestCursor (smGD.display, DefaultRootWindow(smGD.display),
  1317. 32, 32, &cWidth, &cHeight))
  1318. {
  1319. if ((cWidth >= 32) && (cHeight >= 32))
  1320. {
  1321. return(True);
  1322. }
  1323. }
  1324. return(False);
  1325. }
  1326. /*************************************<->*************************************
  1327. *
  1328. * LockDialogUp ()
  1329. *
  1330. *
  1331. * Description:
  1332. * -----------
  1333. * Once the lock dialog is managed, but not popped up - reposition it so that
  1334. * it appears in the middle of the screen then remove the popup callback
  1335. *
  1336. *
  1337. * Inputs:
  1338. * ------
  1339. *
  1340. *
  1341. * Outputs:
  1342. * -------
  1343. * None.
  1344. *
  1345. *
  1346. * Comments:
  1347. * --------
  1348. *
  1349. *************************************<->***********************************/
  1350. static void
  1351. LockDialogUp(
  1352. Widget w,
  1353. XtPointer client_data,
  1354. XtPointer call_data )
  1355. {
  1356. register int i;
  1357. Dimension width, height; /* size values returned by XtGetValues */
  1358. Dimension shadowThickness;/* size values returned by XtGetValues */
  1359. unsigned int dpwidth, dpheight, xorg, yorg; /* JET - xinerama */
  1360. struct
  1361. { /* position, size of widgets (pixels) */
  1362. int x, y;
  1363. int width;
  1364. int height;
  1365. int shadow;
  1366. } mw; /* matte, logo, drop shadow & login matte */
  1367. int width1, width2; /* general width variable */
  1368. int x1, y1; /* general position variables */
  1369. int index;
  1370. /* JET - get xinerama info */
  1371. #ifdef USE_XINERAMA
  1372. /* use the prefered screen */
  1373. if (!_DtXineramaGetScreen(smGD.DtXineramaInfo,
  1374. smRes.xineramaPreferredScreen,
  1375. &dpwidth, &dpheight, &xorg, &yorg))
  1376. { /* no joy here either - setup for normal */
  1377. dpwidth = DisplayWidth(smGD.display, smGD.screen);
  1378. dpheight = DisplayHeight(smGD.display, smGD.screen);
  1379. xorg = yorg = 0;
  1380. }
  1381. #else /* no Xinerama */
  1382. dpwidth = DisplayWidth(smGD.display, smGD.screen);
  1383. dpheight = DisplayHeight(smGD.display, smGD.screen);
  1384. xorg = yorg = 0;
  1385. #endif
  1386. /*
  1387. * The partial cover has widgets of index 0 - the cover has
  1388. * index 1
  1389. */
  1390. if(smGD.coverScreen == True)
  1391. {
  1392. index = 1;
  1393. }
  1394. else
  1395. {
  1396. index = 0;
  1397. }
  1398. /*
  1399. * - center the main matte horizontally and vertically...
  1400. */
  1401. i = 0;
  1402. XtSetArg(uiArgs[i], XmNwidth, &width); i++;
  1403. XtSetArg(uiArgs[i], XmNheight, &height); i++;
  1404. XtSetArg(uiArgs[i], XmNshadowThickness, &shadowThickness); i++;
  1405. XtGetValues(smDD.matte[index], uiArgs, i);
  1406. mw.shadow = shadowThickness;
  1407. mw.width = width;
  1408. mw.height = height;
  1409. mw.x = (dpwidth - mw.width)/2;
  1410. mw.y = (dpheight - mw.height)/2;
  1411. if ( mw.x < 0 ) mw.x = 0;
  1412. if ( mw.y < 0 ) mw.y = 0;
  1413. /* adjust origins if using Xinerama */
  1414. x1 = mw.x + xorg;
  1415. y1 = mw.y + yorg;
  1416. i = 0;
  1417. XtSetArg(uiArgs[i], XmNx, x1); i++;
  1418. XtSetArg(uiArgs[i], XmNy, y1); i++;
  1419. XtSetValues(smDD.matte[index], uiArgs, i);
  1420. /*
  1421. * - center the login/password frames horizontally in the login_matte...
  1422. */
  1423. XtSetArg(uiArgs[0], XmNwidth, &width);
  1424. XtGetValues(smDD.loginMatte[index], uiArgs, 1);
  1425. width1 = (int)width;
  1426. XtSetArg(uiArgs[0], XmNwidth, &width);
  1427. XtGetValues(smDD.loginForm[index], uiArgs, 1);
  1428. width2 = (int)width;
  1429. i = 0;
  1430. XtSetArg(uiArgs[i], XmNleftAttachment, XmATTACH_FORM); i++;
  1431. XtSetArg(uiArgs[i], XmNleftOffset, (width1 - width2) / 2); i++;
  1432. XtSetValues(smDD.loginForm[index], uiArgs, i);
  1433. }
  1434. /*************************************<->*************************************
  1435. *
  1436. * SimpleOK()
  1437. *
  1438. *
  1439. * Description:
  1440. * -----------
  1441. * Simply dismiss a dialog. Does special process for a compatibility mode
  1442. * logout dialog and when the bms won't start.
  1443. *
  1444. *
  1445. * Inputs:
  1446. * ------
  1447. * client_data - sends in the dialog to be dismissed.
  1448. *
  1449. *
  1450. * Outputs:
  1451. * -------
  1452. * None.
  1453. *
  1454. *
  1455. * Comments:
  1456. * --------
  1457. *
  1458. *************************************<->***********************************/
  1459. static void
  1460. SimpleOK(
  1461. Widget w,
  1462. XtPointer client_data,
  1463. XtPointer call_data )
  1464. {
  1465. Widget dismissDialog = (Widget) client_data;
  1466. if(XtIsManaged(dismissDialog))
  1467. {
  1468. XtUnmanageChild(dismissDialog);
  1469. }
  1470. if(dismissDialog == smDD.compatExit)
  1471. {
  1472. SetSystemReady();
  1473. }
  1474. if(dismissDialog == smDD.noStart)
  1475. {
  1476. SM_EXIT(-1);
  1477. }
  1478. if(dismissDialog == smDD.clientReasons)
  1479. {
  1480. reasonsDialogOK = True;
  1481. }
  1482. }
  1483. /*************************************<->*************************************
  1484. *
  1485. * UpdatePasswdField ()
  1486. *
  1487. *
  1488. * Description:
  1489. * -----------
  1490. * Give the visual feedback necessary when the user is entering a password
  1491. *
  1492. *
  1493. * Inputs:
  1494. * ------
  1495. * numChars = number of characters entered into the field
  1496. *
  1497. *
  1498. * Outputs:
  1499. * -------
  1500. * None.
  1501. *
  1502. *
  1503. * Comments:
  1504. * --------
  1505. *
  1506. *************************************<->***********************************/
  1507. void
  1508. UpdatePasswdField(
  1509. int numChars )
  1510. {
  1511. int i, index;
  1512. char *passwdMessage = XtMalloc(numChars + 1);
  1513. XmString tmpString;
  1514. if (!passwdMessage) {
  1515. PrintErrnoError(DtError, smNLS.cantMallocErrorString);
  1516. return;
  1517. }
  1518. if(numChars > 0)
  1519. {
  1520. strcpy(passwdMessage, "|");
  1521. for(i = 1;i < numChars;i++)
  1522. {
  1523. if(i==1)
  1524. strcpy(passwdMessage, "|");
  1525. else
  1526. strcat(passwdMessage, " ");
  1527. }
  1528. strcat(passwdMessage, PASSWORD_INDICATOR);
  1529. }
  1530. else
  1531. {
  1532. strcpy(passwdMessage, "|");
  1533. }
  1534. tmpString = XmStringCreateLocalized (passwdMessage);
  1535. XtFree(passwdMessage);
  1536. /*
  1537. * Set the index for the indLabel widget
  1538. */
  1539. if(smGD.coverScreen == True)
  1540. {
  1541. index = 1;
  1542. }
  1543. else
  1544. {
  1545. index = 0;
  1546. }
  1547. i = 0;
  1548. XtSetArg(uiArgs[i], XmNlabelString, tmpString); i++;
  1549. XtSetValues(smDD.indLabel[index], uiArgs, i);
  1550. XmStringFree(tmpString);
  1551. }
  1552. /*************************************<->*************************************
  1553. *
  1554. * WarnNoStartup ()
  1555. *
  1556. *
  1557. * Description:
  1558. * -----------
  1559. * When the BMS refuses to be started, warn the user about why dt is
  1560. * crashing and then exit.
  1561. *
  1562. *
  1563. * Inputs:
  1564. * ------
  1565. *
  1566. *
  1567. * Outputs:
  1568. * -------
  1569. * None.
  1570. *
  1571. *
  1572. * Comments:
  1573. * --------
  1574. *
  1575. *************************************<->***********************************/
  1576. int
  1577. WarnNoStartup( void )
  1578. {
  1579. int i;
  1580. XmString bmsNoStartString;
  1581. String tmpString;
  1582. bmsNoStartString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 36,
  1583. "The desktop messaging system could not be started.\n\n\
  1584. To correct the problem:\n\n\
  1585. 1. Choose [OK] to return to the login screen.\n\n\
  1586. 2. Select Failsafe Session from the login screen's option\n\
  1587. menu and log in.\n\n\
  1588. 3. Check to see that the desktop is properly installed,\n\
  1589. the hostname is correct (/etc/hosts) and that the\n\
  1590. network is properly configured.\n\n\
  1591. For additional information, see the CDE User's Guide.")));
  1592. /*
  1593. * Now create the dialog box
  1594. */
  1595. i = 0;
  1596. tmpString = GETMESSAGE(18, 37, "Action Required");
  1597. XtSetArg(uiArgs[i], XmNmessageString, bmsNoStartString);i++;
  1598. XtSetArg(uiArgs[i], XmNallowShellResize, True); i++;
  1599. XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
  1600. XtSetArg(uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
  1601. XtSetArg(uiArgs[i], XmNtitle, tmpString); i++;
  1602. XtSetArg(uiArgs[i], XmNokLabelString, smDD.okString); i++;
  1603. XtSetArg(uiArgs[i], XmNautoUnmanage, False); i++;
  1604. smDD.noStart = XmCreateWarningDialog(smGD.topLevelWid, "noStartDialog",
  1605. uiArgs, i);
  1606. XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
  1607. XtSetValues(XtParent(smDD.noStart), uiArgs, i);
  1608. XtAddCallback (XtParent(smDD.noStart),
  1609. XmNpopupCallback, DialogUp, NULL);
  1610. XtUnmanageChild(XmMessageBoxGetChild(smDD.noStart,
  1611. XmDIALOG_HELP_BUTTON));
  1612. XtUnmanageChild(XmMessageBoxGetChild(smDD.noStart,
  1613. XmDIALOG_CANCEL_BUTTON));
  1614. /*
  1615. * Now add in the callback and get out of here
  1616. */
  1617. XtAddCallback (smDD.noStart, XmNokCallback,
  1618. SimpleOK, smDD.noStart);
  1619. XmStringFree(bmsNoStartString);
  1620. XtManageChild(smDD.noStart);
  1621. return(0);
  1622. } /* END OF FUNCTION WarnNoStartup */
  1623. /*************************************<->*************************************
  1624. *
  1625. * ConfirmSessionCreation () -
  1626. *
  1627. * Description:
  1628. * -----------
  1629. *
  1630. * Inputs:
  1631. * ------
  1632. *
  1633. * Outputs:
  1634. * -------
  1635. *
  1636. * Returns True if the user says to continue the session; False otherwise
  1637. * or if malloc fails;
  1638. *
  1639. * Comments:
  1640. * --------
  1641. *
  1642. *************************************<->***********************************/
  1643. Boolean
  1644. ConfirmSessionCreation (
  1645. short session_type,
  1646. unsigned int _argc,
  1647. char **_argv)
  1648. {
  1649. int i, j;
  1650. XmString title_string;
  1651. XmString ok_string;
  1652. XmString cancel_string;
  1653. XmString help_string;
  1654. XmString msg_string;
  1655. Widget tmp_widget;
  1656. Arg args[20];
  1657. char *pch1;
  1658. char *pch2;
  1659. char *pch3;
  1660. Dimension width, height;
  1661. Position x, y;
  1662. XEvent next;
  1663. int argc = _argc;
  1664. char **argv = NULL;
  1665. /*
  1666. * Create temporary argv because the X toolkit may remove
  1667. * pieces of the command line options.
  1668. */
  1669. if (_argc > 0) {
  1670. argv = (char **) XtMalloc (_argc * sizeof (char *));
  1671. for (i = 0; i < _argc; i++)
  1672. argv[i] = _argv[i];
  1673. }
  1674. if (session_type == HOME_SESSION)
  1675. pch1 = strdup ((char *) GETMESSAGE(18, 50, "Home"));
  1676. else
  1677. pch1 = strdup ((char *) GETMESSAGE(18, 51, "Current"));
  1678. if (!pch1) {
  1679. PrintError(DtError, smNLS.cantMallocErrorString);
  1680. SM_EXIT(1);
  1681. }
  1682. pch2 = strdup ((char *) GETMESSAGE(18, 52,
  1683. "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."));
  1684. if (!pch2) {
  1685. PrintError(DtError, smNLS.cantMallocErrorString);
  1686. SM_EXIT(1);
  1687. }
  1688. pch3 = XtMalloc (strlen (pch1) +
  1689. strlen (XDisplayName (getenv("DISPLAY"))) +
  1690. strlen (pch2) +
  1691. 4);
  1692. if (!pch3) {
  1693. PrintError(DtError, smNLS.cantMallocErrorString);
  1694. SM_EXIT(1);
  1695. }
  1696. (void) sprintf (pch3, pch2, pch1, XDisplayName (getenv("DISPLAY")));
  1697. /*
  1698. * The X toolkit has not yet been initialized, so do it now.
  1699. */
  1700. j = 0;
  1701. XtToolkitInitialize ();
  1702. smGD.appCon = XtCreateApplicationContext();
  1703. smGD.display = XtOpenDisplay(smGD.appCon, NULL, argv[0],
  1704. SM_RESOURCE_CLASS, NULL, 0, &argc, argv);
  1705. XtSetArg(args[j], XmNbackground,
  1706. XBlackPixel(smGD.display, XDefaultScreen(smGD.display))); j++;
  1707. XtSetArg(args[j], XmNmappedWhenManaged, False); j++;
  1708. XtSetArg (args[j], XmNwidth, 1); j++;
  1709. XtSetArg (args[j], XmNheight, 1); j++;
  1710. tmp_widget = XtAppCreateShell (
  1711. "foo", "foo",
  1712. applicationShellWidgetClass,
  1713. smGD.display, args, j);
  1714. XtRealizeWidget(tmp_widget);
  1715. /*
  1716. * Create the compound strings for the confirmation dialog
  1717. */
  1718. msg_string = XmStringCreateLocalized (pch3);
  1719. title_string = XmStringCreateLocalized(pch3);
  1720. ok_string = XmStringCreateLocalized(((char *) GETMESSAGE(18, 39, "OK")));
  1721. cancel_string = XmStringCreateLocalized(((char *) GETMESSAGE(18, 40, "Cancel")));
  1722. help_string = XmStringCreateLocalized(((char *) GETMESSAGE(18, 41, "Help")));
  1723. free (pch1); free (pch2); XtFree (pch3);
  1724. /*
  1725. * Create the dialog box
  1726. */
  1727. i = 0;
  1728. XtSetArg (uiArgs[i], XmNmessageString, msg_string); i++;
  1729. XtSetArg (uiArgs[i], XmNallowShellResize, False); i++;
  1730. XtSetArg (uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
  1731. XtSetArg (uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
  1732. XtSetArg (uiArgs[i], XmNmappedWhenManaged, True); i++;
  1733. XtSetArg (uiArgs[i], XmNtitle, title_string); i++;
  1734. XtSetArg (uiArgs[i], XmNokLabelString, ok_string); i++;
  1735. XtSetArg (uiArgs[i], XmNcancelLabelString, cancel_string); i++;
  1736. XtSetArg (uiArgs[i], XmNhelpLabelString, help_string); i++;
  1737. XtSetArg (uiArgs[i], XmNautoUnmanage, False); i++;
  1738. smDD.confirmSession = XmCreateWarningDialog(
  1739. tmp_widget, "confirmDialog", uiArgs, i);
  1740. XtAddCallback (smDD.confirmSession, XmNokCallback,
  1741. ConfirmOKCB, NULL);
  1742. /*
  1743. * Some help state is not yet initialized and the help
  1744. * callback assumes it is so some initializations must
  1745. * be done now.
  1746. */
  1747. smDD.smHelpDialog = NULL;
  1748. smDD.okString = ok_string;
  1749. smGD.topLevelWid = tmp_widget;
  1750. XtAddCallback (smDD.confirmSession, XmNhelpCallback,
  1751. TopicHelpRequested, HELP_CONFIRMATION_SESSION_STR);
  1752. XtAddCallback (smDD.confirmSession, XmNcancelCallback,
  1753. ConfirmCancelCB, NULL);
  1754. XtManageChild(smDD.confirmSession);
  1755. /*
  1756. * Center the dialog on the display
  1757. */
  1758. i = 0;
  1759. XtSetArg(uiArgs[i], XmNwidth, &width); i++;
  1760. XtSetArg(uiArgs[i], XmNheight, &height); i++;
  1761. XtGetValues(smDD.confirmSession, uiArgs, i);
  1762. x = (DisplayWidth(smGD.display, XDefaultScreen(smGD.display)) / 2)
  1763. - (width / 2);
  1764. y = (DisplayHeight(smGD.display, XDefaultScreen(smGD.display)) / 2)
  1765. - (height / 2);
  1766. i = 0;
  1767. XtSetArg(uiArgs[i], XmNx, x); i++;
  1768. XtSetArg(uiArgs[i], XmNy, y); i++;
  1769. XtSetValues(smDD.confirmSession, uiArgs, i);
  1770. XmStringFree (msg_string);
  1771. XmStringFree (title_string);
  1772. XmStringFree (cancel_string);
  1773. XmStringFree (help_string);
  1774. /*
  1775. * Spin until the OK or Cancel CB is invoked
  1776. */
  1777. confirmState = ConfirmationNone;
  1778. while(1) {
  1779. XtAppNextEvent(smGD.appCon, &next);
  1780. if (next.type != 0)
  1781. XtDispatchEvent(&next);
  1782. if (confirmState == ConfirmationOK) {
  1783. XtDestroyWidget (tmp_widget);
  1784. XmStringFree (ok_string);
  1785. return (True);
  1786. }
  1787. else if (confirmState == ConfirmationCancel) {
  1788. XtDestroyWidget (tmp_widget);
  1789. XmStringFree (ok_string);
  1790. return (False);
  1791. }
  1792. }
  1793. }
  1794. /*************************************<->*************************************
  1795. *
  1796. * ConfirmOKCB ()
  1797. *
  1798. *************************************<->***********************************/
  1799. static void
  1800. ConfirmOKCB(
  1801. Widget w,
  1802. XtPointer client_data,
  1803. XtPointer call_data )
  1804. {
  1805. XtUnmanageChild(smDD.confirmSession);
  1806. confirmState = ConfirmationOK;
  1807. }
  1808. /*************************************<->*************************************
  1809. *
  1810. * ConfirmCancelCB ()
  1811. *
  1812. *************************************<->***********************************/
  1813. static void
  1814. ConfirmCancelCB(
  1815. Widget w,
  1816. XtPointer client_data,
  1817. XtPointer call_data )
  1818. {
  1819. XtUnmanageChild(smDD.confirmSession);
  1820. confirmState = ConfirmationCancel;
  1821. }
  1822. /*************************************<->*************************************
  1823. *
  1824. * PostXSMPFailureDialog () -
  1825. *
  1826. * Description:
  1827. * -----------
  1828. *
  1829. * Inputs:
  1830. * ------
  1831. *
  1832. * Outputs:
  1833. * -------
  1834. *
  1835. * Returns True if the user says to continue the session; False otherwise
  1836. * or if malloc fails;
  1837. *
  1838. * Comments:
  1839. * --------
  1840. *
  1841. *************************************<->***********************************/
  1842. void
  1843. PostXSMPFailureDialog (
  1844. XSMPFailure failure_code,
  1845. Boolean check_errorlog)
  1846. {
  1847. int i, j;
  1848. XmString ok_string;
  1849. XmString help_string;
  1850. XmString msg_string;
  1851. Arg args[20];
  1852. char *pch1;
  1853. char *pch2 = "";
  1854. char *pch3;
  1855. char *pch4;
  1856. char *pch5;
  1857. char *error_file;
  1858. Dimension width, height;
  1859. Position x, y;
  1860. XEvent next;
  1861. int len;
  1862. pch1 = strdup ((char *) GETMESSAGE(40, 1,
  1863. "A session cannot be started because of the\nfollowing error:"));
  1864. if (!pch1) {
  1865. PrintError(DtError, smNLS.cantMallocErrorString);
  1866. SM_EXIT(1);
  1867. }
  1868. switch (failure_code) {
  1869. case XSMP_FAILURE_SMS_INITIALIZE:
  1870. pch2 = strdup ((char *) GETMESSAGE (40, 2,
  1871. "SmsInitialize failed."));
  1872. break;
  1873. case XSMP_FAILURE_ICE_LISTEN:
  1874. pch2 = strdup ((char *) GETMESSAGE (40, 3,
  1875. "IceListenForConnections failed."));
  1876. break;
  1877. case XSMP_FAILURE_AUTHENTICATION:
  1878. pch2 = strdup ((char *) GETMESSAGE (40, 4,
  1879. "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."));
  1880. break;
  1881. case XSMP_FAILURE_ICE_ADD_WATCH:
  1882. pch2 = strdup ((char *) GETMESSAGE (40, 5,
  1883. "IceAddConnectionWatch failed."));
  1884. break;
  1885. case XSMP_FAILURE_ICE_COMPOSE_IDS:
  1886. pch2 = strdup ((char *) GETMESSAGE (40, 6,
  1887. "IceComposeNetworkIds failed."));
  1888. break;
  1889. case XSMP_FAILURE_MALLOC:
  1890. pch2 = strdup ((char *) GETMESSAGE (40, 7,
  1891. "Could not create the SESSION_MANAGER environment variable."));
  1892. break;
  1893. }
  1894. if (!pch2) {
  1895. PrintError(DtError, smNLS.cantMallocErrorString);
  1896. SM_EXIT(1);
  1897. }
  1898. pch3 = strdup ((char *) GETMESSAGE(18, 70,
  1899. "See the following for more information:"));
  1900. if (!pch3) {
  1901. PrintError(DtError, smNLS.cantMallocErrorString);
  1902. SM_EXIT(1);
  1903. }
  1904. pch4 = strdup ((char *) GETMESSAGE(18, 71,
  1905. "CDE Advanced Users and System's Administration Guide"));
  1906. if (!pch4) {
  1907. PrintError(DtError, smNLS.cantMallocErrorString);
  1908. SM_EXIT(1);
  1909. }
  1910. error_file = XtMalloc(MAXPATHLEN+1);
  1911. strcpy (error_file, "");
  1912. /* JET - VU#497553 */
  1913. if (check_errorlog)
  1914. {
  1915. char *home;
  1916. if (home = getenv ("HOME"))
  1917. {
  1918. len = strlen(home) +
  1919. strlen(DtPERSONAL_CONFIG_DIRECTORY) +
  1920. strlen(DtERRORLOG_FILE);
  1921. if (len > MAXPATHLEN)
  1922. error_file = XtRealloc(error_file, len + 1);
  1923. sprintf (error_file, "%s/%s/%s", home,
  1924. DtPERSONAL_CONFIG_DIRECTORY,
  1925. DtERRORLOG_FILE);
  1926. }
  1927. }
  1928. pch5 = XtMalloc (strlen (pch1) + strlen (pch2) + strlen (pch3) + strlen (pch4) +
  1929. strlen (error_file) + 15);
  1930. if (!pch5) {
  1931. PrintError(DtError, smNLS.cantMallocErrorString);
  1932. SM_EXIT(1);
  1933. }
  1934. (void) sprintf (pch5, "%s\n\n %s\n\n%s\n\n %s\n %s\n",
  1935. pch1, pch2, pch3, pch4, error_file);
  1936. XtFree(error_file);
  1937. /*
  1938. * No top level widget has been created so must create one now.
  1939. */
  1940. j = 0;
  1941. XtSetArg (args[j], XmNbackground, XBlackPixel(smGD.display,
  1942. XDefaultScreen(smGD.display))); j++;
  1943. XtSetArg (args[j], XmNmappedWhenManaged, False); j++;
  1944. XtSetArg (args[j], XmNwidth, 1); j++;
  1945. XtSetArg (args[j], XmNheight, 1); j++;
  1946. smGD.topLevelWid = XtAppCreateShell (SM_RESOURCE_NAME,
  1947. SM_RESOURCE_CLASS, applicationShellWidgetClass,
  1948. smGD.display, args, j);
  1949. XtRealizeWidget(smGD.topLevelWid);
  1950. /*
  1951. * Create the compound strings for the confirmation dialog
  1952. */
  1953. msg_string = XmStringCreateLocalized (pch5);
  1954. ok_string = XmStringCreateLocalized(((char *) GETMESSAGE(18, 39, "OK")));
  1955. help_string = XmStringCreateLocalized(((char *) GETMESSAGE(18, 41, "Help")));
  1956. free (pch1); free (pch2); free (pch3); free (pch4); XtFree (pch5);
  1957. /*
  1958. * Create the dialog box
  1959. */
  1960. i = 0;
  1961. XtSetArg (uiArgs[i], XmNmessageString, msg_string); i++;
  1962. XtSetArg (uiArgs[i], XmNallowShellResize, False); i++;
  1963. XtSetArg (uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
  1964. XtSetArg (uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
  1965. XtSetArg (uiArgs[i], XmNmappedWhenManaged, True); i++;
  1966. XtSetArg (uiArgs[i], XmNokLabelString, ok_string); i++;
  1967. XtSetArg (uiArgs[i], XmNhelpLabelString, help_string); i++;
  1968. XtSetArg (uiArgs[i], XmNautoUnmanage, False); i++;
  1969. smDD.confirmSession = XmCreateWarningDialog(
  1970. smGD.topLevelWid, "confirmDialog", uiArgs, i);
  1971. XtAddCallback (smDD.confirmSession, XmNokCallback,
  1972. XSMPFailureOKCB, NULL);
  1973. /*
  1974. * Some help state is not yet initialized and the help
  1975. * callback assumes it is so some initializations must
  1976. * be done now.
  1977. */
  1978. smDD.smHelpDialog = NULL;
  1979. smDD.okString = ok_string;
  1980. XtAddCallback (smDD.confirmSession, XmNhelpCallback,
  1981. TopicHelpRequested, HELP_XSMP_INIT_FAILURE_STR);
  1982. XtUnmanageChild(XmMessageBoxGetChild(smDD.confirmSession,
  1983. XmDIALOG_CANCEL_BUTTON));
  1984. XtManageChild(smDD.confirmSession);
  1985. /*
  1986. * Center the dialog on the display
  1987. */
  1988. i = 0;
  1989. XtSetArg(uiArgs[i], XmNwidth, &width); i++;
  1990. XtSetArg(uiArgs[i], XmNheight, &height); i++;
  1991. XtGetValues(smDD.confirmSession, uiArgs, i);
  1992. x = (DisplayWidth(smGD.display, XDefaultScreen(smGD.display)) / 2)
  1993. - (width / 2);
  1994. y = (DisplayHeight(smGD.display, XDefaultScreen(smGD.display)) / 2)
  1995. - (height / 2);
  1996. i = 0;
  1997. XtSetArg(uiArgs[i], XmNx, x); i++;
  1998. XtSetArg(uiArgs[i], XmNy, y); i++;
  1999. XtSetValues(smDD.confirmSession, uiArgs, i);
  2000. XmStringFree (msg_string);
  2001. XmStringFree (help_string);
  2002. /*
  2003. * Spin until the OK CB is invoked
  2004. */
  2005. while(1) {
  2006. XtAppNextEvent(smGD.appCon, &next);
  2007. if (next.type != 0)
  2008. XtDispatchEvent(&next);
  2009. }
  2010. }
  2011. /*************************************<->*************************************
  2012. *
  2013. * XSMPFailureOKCB ()
  2014. *
  2015. *************************************<->***********************************/
  2016. static void
  2017. XSMPFailureOKCB(
  2018. Widget w,
  2019. XtPointer client_data,
  2020. XtPointer call_data )
  2021. {
  2022. XtUnmanageChild(smDD.confirmSession);
  2023. SM_EXIT(1);
  2024. }
  2025. /*************************************<->*************************************
  2026. *
  2027. * PostSaveSessionErrorDialog
  2028. *
  2029. * Description:
  2030. * -----------
  2031. * Let the user know that the Save_Session message does not have the
  2032. * required data and the session will not be saved.
  2033. *
  2034. * Inputs:
  2035. * ------
  2036. *
  2037. * Outputs:
  2038. * -------
  2039. *
  2040. *************************************<->***********************************/
  2041. void
  2042. PostSaveSessionErrorDialog ( void )
  2043. {
  2044. int i;
  2045. XmString messageString;
  2046. String titleString;
  2047. if(smDD.saveSession == NULL)
  2048. {
  2049. messageString = XmStringCreateLocalized (((char *) GETMESSAGE(18, 56,
  2050. "The session cannot be saved because the required\n\
  2051. 'save_type' parameter was not in the message.\n\n\
  2052. The session will not be saved.")));
  2053. titleString = GETMESSAGE(18, 55, "Save Session Failure");
  2054. i = 0;
  2055. XtSetArg (uiArgs[i], XmNmessageString, messageString); i++;
  2056. XtSetArg (uiArgs[i], XmNallowShellResize, True); i++;
  2057. XtSetArg (uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
  2058. XtSetArg (uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
  2059. XtSetArg (uiArgs[i], XmNtitle, titleString); i++;
  2060. XtSetArg (uiArgs[i], XmNokLabelString, smDD.okString); i++;
  2061. XtSetArg (uiArgs[i], XmNhelpLabelString, smDD.helpString); i++;
  2062. XtSetArg (uiArgs[i], XmNautoUnmanage, False); i++;
  2063. smDD.saveSession = XmCreateErrorDialog(smGD.topLevelWid,
  2064. "sessionSaveDialog", uiArgs, i);
  2065. i = 0;
  2066. XtSetArg (uiArgs[i], XmNuseAsyncGeometry, True);i++;
  2067. XtSetArg (uiArgs[i], XmNmwmFunctions, 0);i++;
  2068. XtSetArg (uiArgs[i], XmNmwmDecorations,
  2069. (MWM_DECOR_TITLE | MWM_DECOR_BORDER)); i++;
  2070. XtSetArg (uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
  2071. XtSetValues(XtParent(smDD.saveSession), uiArgs, i);
  2072. XtAddCallback (XtParent(smDD.saveSession),
  2073. XmNpopupCallback, DialogUp, NULL);
  2074. XtUnmanageChild (XmMessageBoxGetChild(smDD.saveSession,
  2075. XmDIALOG_CANCEL_BUTTON));
  2076. XtAddCallback (smDD.saveSession, XmNokCallback,
  2077. SimpleOK, (XtPointer) smDD.saveSession);
  2078. #ifndef NO_XVH
  2079. XtAddCallback (smDD.saveSession, XmNhelpCallback,
  2080. TopicHelpRequested, HELP_SESSION_SAVE_ERROR_STR);
  2081. #endif
  2082. XmStringFree(messageString);
  2083. }
  2084. XtManageChild(smDD.saveSession);
  2085. return;
  2086. }
  2087. /*************************************<->*************************************
  2088. *
  2089. * PostReasonsDialog - posts a Warning dialog on behalf of a client
  2090. * that supplied a "reason" when it closed its connection
  2091. *
  2092. * Inputs:
  2093. * ------
  2094. *
  2095. * Outputs: void
  2096. * -------
  2097. *
  2098. *************************************<->***********************************/
  2099. void
  2100. PostReasonsDialog (
  2101. char * progName,
  2102. int numMsgs,
  2103. char ** message,
  2104. Boolean waitForResponse)
  2105. {
  2106. XmString msgString;
  2107. XmString okString;
  2108. XmString helpString;
  2109. Arg args[20];
  2110. char * titleString;
  2111. char * str1;
  2112. char * str2;
  2113. char * str3;
  2114. int i;
  2115. int len;
  2116. XEvent next;
  2117. str1 = strdup ((char *) GETMESSAGE(40, 28,
  2118. "Application '%s'\nexited for the following reason:\n\n%s"));
  2119. if (!str1) {
  2120. PrintError(DtError, smNLS.cantMallocErrorString);
  2121. SM_EXIT(1);
  2122. }
  2123. for (i = 0, len = 0; i < numMsgs; i++)
  2124. len += strlen (message[i]);
  2125. str2 = XtMalloc (len + (numMsgs * 3) + 1);
  2126. if (!str2) {
  2127. PrintError(DtError, smNLS.cantMallocErrorString);
  2128. SM_EXIT(1);
  2129. }
  2130. str2[0] = '\000';
  2131. for (i = 0; i < numMsgs; i++) {
  2132. strcat (str2, message[i]);
  2133. strcat (str2, "\n");
  2134. }
  2135. str3 = XtMalloc (strlen (str1) + strlen (str2) + strlen (progName) + 4);
  2136. if (!str3) {
  2137. PrintError(DtError, smNLS.cantMallocErrorString);
  2138. SM_EXIT(1);
  2139. }
  2140. (void) sprintf (str3, str1, progName, str2);
  2141. DtMsgLogMessage (smGD.programName, DtMsgLogWarning, str3);
  2142. free (str1);
  2143. str1 = strdup ((char *) GETMESSAGE(40, 29,
  2144. "Application Close Reasons"));
  2145. if (!str1) {
  2146. PrintError(DtError, smNLS.cantMallocErrorString);
  2147. SM_EXIT(1);
  2148. }
  2149. msgString = XmStringCreateLocalized (str3);
  2150. okString = XmStringCreateLocalized(((char *) GETMESSAGE(18, 39, "OK")));
  2151. helpString = XmStringCreateLocalized(((char *) GETMESSAGE(18, 41, "Help")));
  2152. /*
  2153. * Create the dialog box
  2154. */
  2155. i = 0;
  2156. XtSetArg (uiArgs[i], XmNmessageString, msgString); i++;
  2157. XtSetArg (uiArgs[i], XmNallowShellResize, False); i++;
  2158. XtSetArg (uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
  2159. XtSetArg (uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
  2160. XtSetArg (uiArgs[i], XmNmappedWhenManaged, True); i++;
  2161. XtSetArg (uiArgs[i], XmNtitle, str1); i++;
  2162. XtSetArg (uiArgs[i], XmNokLabelString, okString); i++;
  2163. XtSetArg (uiArgs[i], XmNhelpLabelString, helpString); i++;
  2164. XtSetArg (uiArgs[i], XmNautoUnmanage, False); i++;
  2165. smDD.clientReasons = XmCreateWarningDialog(smGD.topLevelWid,
  2166. "clientReasons", uiArgs, i);
  2167. i = 0;
  2168. XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
  2169. XtSetArg(uiArgs[i], XmNmwmFunctions, 0);i++;
  2170. XtSetArg(uiArgs[i], XmNmwmDecorations,
  2171. (MWM_DECOR_TITLE | MWM_DECOR_BORDER));i++;
  2172. XtSetArg(uiArgs[i], XmNmwmInputMode, MWM_INPUT_SYSTEM_MODAL);i++;
  2173. XtSetValues(XtParent(smDD.clientReasons), uiArgs, i);
  2174. XtAddCallback (XtParent(smDD.clientReasons),
  2175. XmNpopupCallback, DialogUp, NULL);
  2176. XtUnmanageChild (XmMessageBoxGetChild (smDD.clientReasons,
  2177. XmDIALOG_CANCEL_BUTTON));
  2178. /*
  2179. * Now add in the callback and get out of here
  2180. */
  2181. XtAddCallback (smDD.clientReasons, XmNokCallback,
  2182. SimpleOK, (XtPointer) smDD.clientReasons);
  2183. #ifndef NO_XVH
  2184. XtAddCallback (smDD.clientReasons, XmNhelpCallback,
  2185. TopicHelpRequested, HELP_APP_CLOSE_REASONS_STR);
  2186. #endif
  2187. free (str1);
  2188. XtFree (str2);
  2189. XtFree (str3);
  2190. XmStringFree (msgString);
  2191. XmStringFree (okString);
  2192. XmStringFree (helpString);
  2193. XtManageChild (smDD.clientReasons);
  2194. /*
  2195. * Spin until the OK callback is invoked. If a shutdown
  2196. * is in progress, we don't want to return until the
  2197. * user has acknowledged this message.
  2198. */
  2199. reasonsDialogOK = False;
  2200. if (waitForResponse) {
  2201. while (1) {
  2202. XtAppNextEvent (smGD.appCon, &next);
  2203. if (next.type != 0)
  2204. XtDispatchEvent(&next);
  2205. if (reasonsDialogOK == True)
  2206. break;
  2207. }
  2208. }
  2209. }
  2210. /*************************************<->*************************************
  2211. *
  2212. * SaveTimeout
  2213. *
  2214. * Description:
  2215. * -----------
  2216. * Timeout procedure that is invoked when a save timer expires.
  2217. *
  2218. * Inputs:
  2219. * ------
  2220. *
  2221. * Outputs: None
  2222. * -------
  2223. *
  2224. *************************************<->***********************************/
  2225. static void
  2226. SaveTimeout (
  2227. XtPointer client_data,
  2228. XtIntervalId *id)
  2229. {
  2230. saveTimeout = True;
  2231. if (smXSMP.saveState.shutdownCanceled == False) {
  2232. /*
  2233. * Run the user's exit script if there is one
  2234. */
  2235. if (smGD.compatMode == False)
  2236. StartEtc(True); /* run sessionexit */
  2237. _DtReleaseLock(smGD.display, SM_RUNNING_LOCK);
  2238. SM_EXIT(0);
  2239. }
  2240. }