2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: Main.c /main/29 1999/09/17 13:35:04 mgreess $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 * COMPONENT_NAME: Desktop File Manager (dtfile)
31 * Description: This file contains the main program for dtfile.
32 * It also contains functions for session management and
33 * directory view control.
35 * FUNCTIONS: BlackPixelOfScreen
36 * BuildAndShowIconName
37 * CheckForOpenDirectory
44 * DtfileCvtStringToDTIcon
45 * DtfileCvtStringToDirection
46 * DtfileCvtStringToGrid
47 * DtfileCvtStringToObjPlace
48 * DtfileCvtStringToOpenDir
49 * DtfileCvtStringToOrder
50 * DtfileCvtStringToTree
51 * DtfileCvtStringToTreeFiles
52 * DtfileCvtStringToView
53 * DtfileStringToDirection
57 * DtfileStringToTreeFiles
66 * GetRestrictedDirectory
85 * SetupSendRequestArgs
90 * ViewDirectoryHandler
92 * ViewHomeDirectoryHandler
94 * ViewToolsDirectoryHandler
95 * WaitForResponseAndExit
99 * _DtWsmAddMarqueeSelectionCallback
105 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
106 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
107 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
108 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
110 ****************************************************************************
111 ************************************<+>*************************************/
113 #include <sys/types.h>
116 #include <sys/stat.h>
119 #if defined(__osf__) || defined(CSRG_BASED)
120 #include <sys/wait.h>
128 #ifndef sun /* don't need the nl_types.h file */
129 #include <nl_types.h>
135 #include <Xm/DrawingA.h>
136 #include <Xm/DrawingAP.h>
137 #include <Xm/MessageB.h>
138 #include <Xm/RowColumn.h>
139 #include <Xm/MwmUtil.h>
141 #include <Xm/IconFileP.h>
143 #include <Dt/IconP.h>
144 #include <Dt/IconFile.h>
146 #include <Dt/HelpDialog.h>
149 #include <X11/extensions/shape.h>
152 #include <X11/Shell.h>
153 #include <X11/Xatom.h>
154 #include <Xm/Protocols.h>
156 #include <X11/Xmu/Editres.h>
158 #include <Dt/Session.h>
161 #include <Dt/Connect.h>
162 #include <Dt/FileM.h>
163 #include <Dt/Indicator.h>
165 #include <Dt/UserMsg.h>
168 #include <Dt/DtNlUtils.h>
169 #include <Dt/CommandM.h>
170 #include <Dt/EnvControlP.h>
172 #include <Dt/SharedProcs.h>
175 #include "SharedProcs.h"
183 #include "ChangeDir.h"
191 extern void MoveCopyLinkHandler(Tt_message ttMsg, int opType);
194 extern void PutOnWorkspaceHandler(Tt_message ttMsg);
197 extern void UpdateFilterAfterDBReread (DialogData * dialog_data);
199 /* From ToolTalk.c */
200 extern int InitializeToolTalkSession( Widget topLevel, int ttFd );
201 extern Tt_status InitializeToolTalkProcid( int *ttFd, Widget topLevel, Boolean sendStarted );
202 extern void FinalizeToolTalkSession();
204 void CloseTrash(Widget w, XtPointer client_data, XtPointer call_data) ;
208 /* When openDir resource is set to NEW
209 File Manager will use this prefix to find for a different icon
212 #define ICON_OPEN_PREFIX "OPEN_"
214 /* THESE ARE ONLY STRINGS WHICH DO NOT NEED TO BE LOCALIZED */
215 /* Don't use '#define' since you end up with multiple copies */
216 char DTFILE_CLASS_NAME[] = "Dtfile";
217 char DTFILE_HELP_NAME[] = "Filemgr";
218 char DESKTOP_DIR[] = ".dt/Desktop";
220 static char WS_RES_HEADER[] = ".Workspace.";
221 static char SEC_HELP_RES_HEADER[] = ".secondaryHelpDialogCount: ";
222 static char WS_LOAD_RES_HEADER[] = "Workspace";
223 static char SEC_LOAD_HELP_RES_HEADER[] = "secondaryHelpDialogCount";
224 static char RESTRICTED_HEADER[] = "-restricted";
225 static char VIEW_HEADER[] = "-view";
228 /* Structure, resource definitions, for View's optional parameters. */
241 int instanceIconWidth;
242 int instanceIconHeight;
243 XmFontList user_font;
244 Dimension tool_width;
245 Dimension tool_height;
247 Dimension dir_height;
256 int maxDirectoryProcesses;
257 int maxRereadProcesses;
258 int maxRereadProcsPerTick;
261 Boolean showFilesystem;
262 Boolean showDropZone;
263 Boolean showEmptySet;
264 Boolean showEmptyMsg;
266 Boolean restrictMode;
267 int desktopPlacement;
268 Boolean freezeOnConfig;
269 #if defined(__hpux) || defined(sun)
270 Boolean follow_links;
275 int retryLoadDesktop;
280 Boolean emptyTrashOnExit;
281 } ApplicationArgs, *ApplicationArgsPtr;
283 static ApplicationArgs application_args;
285 /******** Static Function Declarations ********/
287 static void ErrorHandler(
289 XErrorEvent *event) ;
290 static void ToolkitErrorHandler(
294 static void RestrictModeUsage(
296 static void Stop( void ) ;
297 static void RestoreSettingsFile( void ) ;
298 static void MoveDefaultSettings(
300 static void SaveDefaultCancelCB(
302 XtPointer client_data,
303 XtPointer call_data) ;
304 static void SaveDefaultOkCB(
306 XtPointer client_data,
307 XtPointer call_data) ;
308 static void SaveSession(
310 static int RestoreSession(
315 char current_directory[]) ;
316 static void OpenDirectories(
319 static Tt_callback_action ObserveTtNotice(
322 static void ViewSessionHandler(
324 static void ViewDirectoryHandler(
326 static void ViewHomeDirectoryHandler(
328 static void ViewToolsDirectoryHandler(
330 static void ExitHandler(
332 XtPointer clientData,
333 String * messageFields,
335 static void ReloadDatabases( void );
336 static void ViewAccept(
339 static void LoadViews (
343 char *directory_name,
346 static void RemoveTextFields (
347 XtPointer client_data,
348 DialogData * old_dialog_data,
349 DialogData * new_dialog_data) ;
350 static void DtfileCvtStringToObjPlace (
355 static unsigned char *_DtNextToken (
356 unsigned char *pchIn,
358 unsigned char **ppchNext) ;
359 static void DtfileCvtStringToOpenDir (
364 static void DtfileCvtStringToDTIcon (
369 static void DtfileCvtStringToTree (
374 static void DtfileCvtStringToTreeFiles (
379 static void DtfileCvtStringToView (
384 static void DtfileCvtStringToOrder (
389 static void DtfileCvtStringToDirection (
394 static void DtfileCvtStringToGrid (
399 static void DtfileStringToTree(
402 static void DtfileStringToTreeFiles(
405 static void DtfileStringToView(
408 static void DtfileStringToOrder(
411 static void DtfileStringToDirection(
414 static void DtfileStringToGrid(
417 static void SetupSendRequestArgs(
418 ApplicationArgs application_args,
420 static void BuildAndShowIconName(
421 char *file_type_name,
423 unsigned char show_type,
425 static void MarqueeSelect (
432 XtPointer client_data);
433 static void WaitForResponseAndExit( void ) ;
435 XtPointer clientData,
438 static Widget post_dialog(
443 static void DtErrExitCB(
445 XtPointer client_data,
446 XtPointer call_data);
448 /******** End Static Function Declarations ********/
455 /* performance flag */
456 #ifdef DT_PERFORMANCE
460 /* The id's of the dialogs registered by main */
463 int change_dir_dialog;
464 int preferences_dialog;
470 /* The shared menu button and pane Id's */
472 Widget * create_dataBtn;
475 Widget * duplicateBtn;
478 Widget * create_directoryBtn;
479 Widget * change_directoryBtn;
480 Widget * showHiddenMenu;
481 Widget * preferencesBtn;
483 Widget * defaultEnvBtn;
490 Widget * terminalBtn;
491 Widget * usingHelp = NULL;
492 Widget * fileManagerHelp = NULL;
493 Widget * applicationManagerHelp = NULL;
494 Widget * usingHelpTrash = NULL;
497 /* Bitmask used to indicate the current sensitivity state of shared menu btns */
499 unsigned int currentMenuStates = ( RENAME | MOVE | DUPLICATE | LINK | TRASH |
500 MODIFY | CHANGEDIR | PREFERENCES | FILTER |
501 FIND | CREATE_DIR | CREATE_FILE |
502 PUT_ON_DESKTOP | PUTBACK |
504 HOME | CHANGE_DIR | TERMINAL);
506 /* Drag manager globals */
508 Boolean dragActive = False;
510 /* Desktop Globals */
514 /* Globally referenced application name. Set to argv[0] in main */
516 char * application_name = NULL;
519 /* uid for root user; used when we are checking access permissions */
526 char home_host_name[MAX_PATH];
527 char users_home_dir[MAX_PATH];
530 /* Toolbox directory */
532 char * desktop_dir = NULL;
533 char * trash_dir = NULL;
534 char * remote_sys_dir = NULL;
538 int restoreType = NORMAL_RESTORE;
541 /* Black and White pixels */
547 /* File manager view set before a new view is created and */
548 /* used to propagate visual attributes from the initiating */
549 /* view to the new view. */
551 XtPointer initiating_view = NULL;
552 Boolean special_view = False;
553 Boolean TrashView = False;
556 /* system wide user font */
558 XmFontList user_font;
561 /* Global localizable strings */
567 /* Global dialog button labels, as XmStrings */
570 XmString cancelXmString;
571 XmString helpXmString;
572 XmString applyXmString;
573 XmString closeXmString;
576 /* Global top level widget */
580 /* Global Application resources */
581 Boolean showFilesystem;
582 Boolean showDropZone;
583 Boolean showEmptySet;
584 Boolean showEmptyMsg;
585 Boolean restrictMode;
589 char *fileMgrHelpVol;
594 int desktopPlacement;
595 Boolean freezeOnConfig;
596 #if defined(__hpux) || defined(sun)
597 Boolean follow_links;
607 unsigned char keybdFocusPolicy;
608 int special_treeType;
609 int special_treeFiles;
610 int special_viewType;
611 int special_orderType;
612 int special_directionType;
613 int special_randomType;
614 char *special_restricted;
616 char *special_helpVol;
620 int retryLoadDesktopInfo;
627 Boolean emptyTrashOnExit;
630 Boolean shapeExtension;
633 /* Drag state variables */
634 Boolean B1DragPossible = False;
635 Boolean B2DragPossible = False;
636 Boolean ProcessBtnUp = False;
637 Boolean ProcessBtnUpCD = True;
641 int xErrorDetected = False;
643 /* BMenu button binding */
646 View ** view_set = NULL;
648 int view_set_size = 0;
650 /* Globals used within this file. */
652 static Display * display;
653 char * dt_path = NULL;
654 static Boolean message_display_enabled = True;
657 static Atom save_yourself_atom;
658 static Atom command_atom;
659 static Atom wm_state_atom;
660 static Atom save_mode;
662 /* Structure used on a save session to see if a dt is iconic */
671 /* Application resource list definition */
673 static XrmOptionDescRec option_list[] =
675 { "-noview", "noView", XrmoptionIsArg, NULL },
676 { "-session", "session", XrmoptionSepArg, NULL },
677 { "-dir", "folder", XrmoptionSepArg, NULL },
678 { "-folder", "folder", XrmoptionSepArg, NULL },
679 { "-tree", "treeView", XrmoptionSepArg, NULL },
680 { "-tree_files", "treeFiles", XrmoptionSepArg, NULL },
681 { VIEW_HEADER, "view", XrmoptionSepArg, NULL },
682 { "-order", "order", XrmoptionSepArg, NULL },
683 { "-direction", "direction", XrmoptionSepArg, NULL },
684 { "-grid", "grid", XrmoptionSepArg, NULL },
685 { RESTRICTED_HEADER, "restricted", XrmoptionIsArg, NULL },
686 { "-title", "title", XrmoptionSepArg, NULL },
687 { "-help_volume", "help_volume", XrmoptionSepArg, NULL },
688 { "-noprompt", "promptUser", XrmoptionNoArg, "False" },
689 { "-small_icon_width", "smallIconWidth", XrmoptionSepArg, NULL },
690 { "-small_icon_height", "smallIconHeight", XrmoptionSepArg, NULL },
691 { "-large_icon_width", "largeIconWidth", XrmoptionSepArg, NULL },
692 { "-large_icon_height", "largeIconHeight", XrmoptionSepArg, NULL },
696 static XtResource resources[] =
699 "noView", "NoView", XmRString, sizeof (char *),
700 XtOffset (ApplicationArgsPtr, no_view), XmRImmediate, (XtPointer) NULL,
704 "session", "Session", XmRString, sizeof (char *),
705 XtOffset (ApplicationArgsPtr, session), XmRImmediate, (XtPointer) NULL,
709 "folder", "Folder", XmRString, sizeof (char *),
710 XtOffset (ApplicationArgsPtr, directories), XmRImmediate, (XtPointer) NULL,
714 "treeView", "TreeView", "Tree", sizeof (int),
715 XtOffset (ApplicationArgsPtr, tree_view), XmRImmediate,
716 (XtPointer) UNSET_VALUE,
720 "treeFiles", "TreeFiles", "TreeFiles", sizeof (int),
721 XtOffset (ApplicationArgsPtr, tree_files), XmRImmediate,
722 (XtPointer) UNSET_VALUE,
726 "view", "View", "View", sizeof (int),
727 XtOffset (ApplicationArgsPtr, view), XmRImmediate, (XtPointer) UNSET_VALUE,
731 "order", "Order", "Order", sizeof (int),
732 XtOffset (ApplicationArgsPtr, order), XmRImmediate, (XtPointer) UNSET_VALUE,
736 "direction", "Direction", "Direction", sizeof (int),
737 XtOffset (ApplicationArgsPtr, direction), XmRImmediate,
738 (XtPointer) UNSET_VALUE,
742 "grid", "Grid", "Grid", sizeof (int),
743 XtOffset (ApplicationArgsPtr, grid), XmRImmediate, (XtPointer) UNSET_VALUE,
747 "instanceIconWidth", "InstanceIconWidth", XmRInt, sizeof (int),
748 XtOffset (ApplicationArgsPtr, instanceIconWidth), XmRImmediate,
753 "instanceIconHeight", "InstanceIconHeight", XmRInt, sizeof (int),
754 XtOffset (ApplicationArgsPtr, instanceIconHeight), XmRImmediate,
759 "restricted", "Restricted", XmRString, sizeof (char *),
760 XtOffset (ApplicationArgsPtr, restricted), XmRImmediate, (XtPointer) NULL,
764 "title", "Title", XmRString, sizeof (char *),
765 XtOffset (ApplicationArgsPtr, title), XmRImmediate, (XtPointer)NULL,
769 "help_volume", "Help_volume", XmRString, sizeof (char *),
770 XtOffset (ApplicationArgsPtr, help_volume), XmRImmediate, (XtPointer)NULL,
774 "userFont", "XmCFontList", XmRFontList, sizeof (XmFontList),
775 XtOffset (ApplicationArgsPtr, user_font), XmRString, (XtPointer) "Fixed",
779 "toolWidth", "ToolWidth", XmRHorizontalDimension, sizeof (Dimension),
780 XtOffset (ApplicationArgsPtr, tool_width), XmRImmediate, (XtPointer) 700,
784 "toolHeight", "ToolHeight", XmRVerticalDimension, sizeof (Dimension),
785 XtOffset (ApplicationArgsPtr, tool_height), XmRImmediate, (XtPointer) 250,
789 "dirWidth", "DirWidth", XmRHorizontalDimension, sizeof (Dimension),
790 XtOffset (ApplicationArgsPtr, dir_width), XmRImmediate, (XtPointer) 555,
794 "dirHeight", "DirHeight", XmRVerticalDimension, sizeof (Dimension),
795 XtOffset (ApplicationArgsPtr, dir_height), XmRImmediate, (XtPointer) 400,
799 "promptUser", "PromptUser", XmRBoolean, sizeof (Boolean),
800 XtOffset (ApplicationArgsPtr, prompt_user), XmRImmediate, (XtPointer) True,
804 "rootTitle", "RootTitle", XmRString, sizeof (char *),
805 XtOffset (ApplicationArgsPtr, root_title), XmRImmediate, (XtPointer)"ROOT",
809 "moveThreshold", "MoveThreshold", XmRInt, sizeof (int),
810 XtOffset (ApplicationArgsPtr, dragThreshold), XmRImmediate, (XtPointer) 4,
814 "rereadTime", "RereadTime", XmRInt, sizeof (int),
815 XtOffset (ApplicationArgsPtr, rereadTime), XmRImmediate, (XtPointer) 3,
819 "checkBrokenLink", "CheckBrokenLink", XmRInt, sizeof (int),
820 XtOffset (ApplicationArgsPtr, checkBrokenLink), XmRImmediate,
825 "maxDirectoryProcesses", "MaxDirectoryProcesses", XmRInt, sizeof (int),
826 XtOffset (ApplicationArgsPtr, maxDirectoryProcesses), XmRImmediate,
831 "maxRereadProcesses", "MaxRereadProcesses", XmRInt, sizeof (int),
832 XtOffset (ApplicationArgsPtr, maxRereadProcesses), XmRImmediate,
837 "maxRereadProcsPerTick", "MaxRereadProcsPerTick", XmRInt, sizeof (int),
838 XtOffset (ApplicationArgsPtr, maxRereadProcsPerTick), XmRImmediate,
843 "trashWait", "TrashWait", XmRInt, sizeof (int),
844 XtOffset (ApplicationArgsPtr, trashWait), XmRImmediate, (XtPointer) 1,
848 "desktopIcon", "DesktopIcon", "DesktopIcon", sizeof (int),
849 XtOffset (ApplicationArgsPtr, desktopIconType), XmRImmediate,
854 "showFilesystem", "ShowFilesystem", XmRBoolean, sizeof (Boolean),
855 XtOffset (ApplicationArgsPtr, showFilesystem), XmRImmediate,
860 "showDropZone", "ShowDropZone", XmRBoolean, sizeof (Boolean),
861 XtOffset (ApplicationArgsPtr, showDropZone), XmRImmediate,
866 "showEmptySet", "ShowEmptySet", XmRBoolean, sizeof (Boolean),
867 XtOffset (ApplicationArgsPtr, showEmptySet), XmRImmediate,
872 "showEmptyMsg", "ShowEmptyMsg", XmRBoolean, sizeof (Boolean),
873 XtOffset (ApplicationArgsPtr, showEmptyMsg), XmRImmediate,
878 "openFolder", "OpenFolder", "OpenFolder", sizeof (int),
879 XtOffset (ApplicationArgsPtr, openDirType), XmRImmediate,
884 "restrictMode", "RestrictMode", XmRBoolean, sizeof (Boolean),
885 XtOffset (ApplicationArgsPtr, restrictMode), XmRImmediate,
890 "objectPlacement", "ObjectPlacement", "ObjectPlacement", sizeof (int),
891 XtOffset (ApplicationArgsPtr, desktopPlacement), XmRImmediate,
892 (XtPointer)(OBJ_PLACE_TOP_PRIMARY | OBJ_PLACE_RIGHT_SECONDARY),
896 "freezeOnConfig", "FreezeOnConfig", XmRBoolean, sizeof (Boolean),
897 XtOffset (ApplicationArgsPtr, freezeOnConfig), XmRImmediate,
902 "fileManagerIcon", "FileManagerIcon", XmRString, sizeof (char *),
903 XtOffset (ApplicationArgsPtr, fileMgrIcon), XmRImmediate,
904 (XtPointer) HOME_ICON_NAME,
908 "appManagerIcon", "AppManagerIcon", XmRString, sizeof (char *),
909 XtOffset (ApplicationArgsPtr, appMgrIcon), XmRImmediate,
910 (XtPointer) TOOL_ICON_NAME,
914 "trashIcon", "TrashIcon", XmRString, sizeof (char *),
915 XtOffset (ApplicationArgsPtr, trashIcon), XmRImmediate,
916 (XtPointer) TRASH_ICON_NAME,
920 "retryLoadDesktop", "RetryLoadDesktop", XmRInt, sizeof (int),
921 XtOffset (ApplicationArgsPtr, retryLoadDesktop), XmRImmediate,
926 "smallIconWidth", "SmallIconWidth", XmRInt, sizeof (int),
927 XtOffset (ApplicationArgsPtr, smallIconWidth), XmRImmediate,
932 "smallIconHeight", "SmallIconHeight", XmRInt, sizeof (int),
933 XtOffset (ApplicationArgsPtr, smallIconHeight), XmRImmediate,
938 "largeIconWidth", "LargeIconWidth", XmRInt, sizeof (int),
939 XtOffset (ApplicationArgsPtr, largeIconWidth), XmRImmediate,
944 "largeIconHeight", "LargeIconHeight", XmRInt, sizeof (int),
945 XtOffset (ApplicationArgsPtr, largeIconHeight), XmRImmediate,
950 "emptyTrashOnExit", "EmptyTrashOnExit", XmRBoolean, sizeof (Boolean),
951 XtOffset (ApplicationArgsPtr, emptyTrashOnExit), XmRImmediate,
955 #if defined(__hpux) || defined(sun)
956 { "followLinks", "FollowLinks", XmRBoolean, sizeof(Boolean),
957 XtOffset(ApplicationArgsPtr, follow_links), XmRImmediate,
964 XtActionsRec actionTable[] = {
965 {"Space", (XtActionProc)VFTextChangeSpace},
966 {"EscapeFM", (XtActionProc)CancelOut},
969 /************************************************************************
972 * The main program for the file manager.
974 ************************************************************************/
976 extern XtInputId ProcessToolTalkInputId;
978 #if defined(__osf__) || defined(CSRG_BASED)
979 extern void sigchld_handler(int);
987 #ifdef DT_PERFORMANCE
988 struct timeval update_time_s;
989 struct timeval update_time_f;
990 struct timeval update_time_ss;
991 struct timeval update_time_fs;
994 char current_directory[MAX_PATH];
995 struct passwd * pwInfo;
999 Boolean eventDebugging;
1006 XSetWindowAttributes sAttributes;
1011 XrmValue resource_value;
1016 int ttFd; /* ToolTalk file descriptor */
1018 Tt_pattern events2Watch;
1019 Tt_pattern requests2Handle;
1022 #if defined(__osf__) || defined(CSRG_BASED)
1023 struct sigaction sa, osa;
1024 #endif /* __osf__ */
1025 int session_flag = 0;
1027 #ifdef DT_PERFORMANCE
1029 gettimeofday(&update_time_ss, NULL);
1031 (void) signal (SIGINT, (void (*)())Stop);
1033 /* We don't want any zombie children, do we? */
1034 #if defined(__osf__) || defined(CSRG_BASED)
1035 sa.sa_handler = sigchld_handler;
1036 sigemptyset(&sa.sa_mask);
1039 if (sigaction(SIGCHLD, &sa, &osa) < 0)
1040 /* error handling follows, none for now */
1043 (void) signal (SIGCHLD, SIG_IGN);
1044 #endif /* __osf__ */
1045 XtSetLanguageProc( NULL, NULL, NULL );
1047 #ifdef DT_PERFORMANCE
1048 { /* Initialize the checkpoint protocol - Aloke Gupta */
1050 display = XOpenDisplay("");
1051 _DtPerfChkpntInit(display, RootWindow(display, DefaultScreen(display)),
1057 _DtEnvControl(DT_ENV_SET);
1059 #ifdef DT_PERFORMANCE
1060 printf(" XtInitalize\n");
1061 gettimeofday(&update_time_s, NULL);
1063 /* Added by Aloke Gupta */
1064 _DtPerfChkpntMsgSend("Begin XtInitialize");
1067 /* Initialize the toolkit and open the display */
1068 toplevel = XtInitialize (argv[0], DTFILE_CLASS_NAME,
1069 option_list, XtNumber(option_list),
1070 (int *)&argc, argv);
1072 /* MERGE START: May not need
1074 _XmColorObjCreate ( toplevel, NULL, NULL );
1078 #ifdef DT_PERFORMANCE
1079 gettimeofday(&update_time_f, NULL);
1080 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1081 update_time_f.tv_usec += 1000000;
1082 update_time_f.tv_sec--;
1084 printf(" done XtInitialize, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1086 /* Added by Aloke Gupta */
1087 _DtPerfChkpntMsgSend("Done XtInitialize");
1090 /* Initialize the function ptr for alphabetic sorting */
1091 FMStrcoll = GetStrcollProc();
1093 /* Open the message catalog - DO NOT PERFORM until after XtInitialize! */
1095 char * foo = ((char *)GETMESSAGE(18, 1, ""));
1098 /* set application name for later */
1099 str = strrchr(argv[0], '/');
1101 application_name = XtNewString (str + 1);
1103 application_name = XtNewString (argv[0]);
1106 XtSetArg(args[n], XmNallowShellResize, True); n++;
1107 XtSetArg(args[n], XmNmappedWhenManaged, False); n++;
1108 XtSetArg(args[n], XmNheight, 1); n++;
1109 XtSetArg(args[n], XmNwidth, 1); n++;
1110 XtSetValues(toplevel, args, n);
1111 XtRealizeWidget(toplevel);
1112 display = XtDisplay (toplevel);
1114 XtAddEventHandler(toplevel, 0, True,
1115 (XtEventHandler) _XEditResCheckMessages,
1119 /* Initialize BMenu button binding */
1121 int numMouseButtons = XGetPointerMapping(display,
1122 (unsigned char *)NULL, 0);
1123 bMenuButton = (numMouseButtons < 3) ? Button2 : Button3;
1126 /* initialize debugging flag */
1128 if ((tmpStr = getenv("DTFILE_DEBUG")) != NULL)
1130 debug = atoi(tmpStr);
1134 if (getenv("DTFILE_XSYNC") != NULL)
1136 XSynchronize(display, True);
1140 /* initialize performance flag */
1141 #ifdef DT_PERFORMANCE
1142 if ((tmpStr = getenv("DTFILE_PERFORM")) != NULL)
1144 perform = atoi(tmpStr);
1148 if (getenv("DTFILE_XSYNC") != NULL)
1150 XSynchronize(display, True);
1154 /* Create the atom set used by save and restore session */
1155 save_yourself_atom = XmInternAtom (display, "WM_SAVE_YOURSELF", False);
1156 wm_state_atom = XmInternAtom (display, "WM_STATE", False);
1157 command_atom = XA_WM_COMMAND;
1158 save_mode = XmInternAtom (display, _XA_DT_RESTORE_MODE, False);
1160 root = RootWindowOfScreen(XtScreen(toplevel));
1162 /* Set session property on the top level window */
1163 XmAddWMProtocols(toplevel, &save_yourself_atom, 1);
1164 XmAddWMProtocolCallback(toplevel, save_yourself_atom, SaveSessionCallback,
1167 XSetErrorHandler ((int (*)())ErrorHandler);
1168 XtAppSetErrorHandler (XtWidgetToApplicationContext(toplevel),
1169 ToolkitErrorHandler);
1171 /* get the keyboard focus policy so we know how we want to set up the */
1173 XtSetArg(args[0], XmNkeyboardFocusPolicy, &keybdFocusPolicy);
1174 XtGetValues(toplevel, args, 1);
1176 /* If all of the command line parameters were not processed */
1177 /* out, print out a usage message set and exit. */
1179 if (argc != 1) Usage (argv);
1181 displayWidth = DisplayWidth(display, DefaultScreen(display));
1182 displayHeight = DisplayHeight(display, DefaultScreen(display));
1184 /* Get Dt initialized */
1186 if (DtInitialize (display, toplevel, argv[0], FILE_MANAGER_TOOL_CLASS) == False)
1188 /* Fatal Error: could not connect to the messaging system. */
1189 /* DtInitialize() has already logged an appropriate error msg */
1193 #ifdef DT_PERFORMANCE
1194 printf(" Setup Converters and get resources\n");
1195 gettimeofday(&update_time_s, NULL);
1197 /* Added by Aloke Gupta */
1198 _DtPerfChkpntMsgSend("Begin Setup Converters");
1202 /* First lets add the resource converters needed */
1203 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1204 XtRString, "ObjectPlacement",
1205 (XtConverter)DtfileCvtStringToObjPlace, NULL, 0);
1206 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1207 XtRString, "OpenFolder",
1208 (XtConverter)DtfileCvtStringToOpenDir, NULL, 0);
1209 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1210 XtRString, "DesktopIcon",
1211 (XtConverter)DtfileCvtStringToDTIcon, NULL, 0);
1212 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1214 (XtConverter)DtfileCvtStringToTree, NULL, 0);
1215 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1216 XtRString, "TreeFiles",
1217 (XtConverter)DtfileCvtStringToTreeFiles, NULL, 0);
1218 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1220 (XtConverter)DtfileCvtStringToView, NULL, 0);
1221 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1223 (XtConverter)DtfileCvtStringToOrder, NULL, 0);
1224 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1225 XtRString, "Direction",
1226 (XtConverter)DtfileCvtStringToDirection, NULL, 0);
1227 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1229 (XtConverter)DtfileCvtStringToGrid, NULL, 0);
1231 /* Get the application defined resources of session and */
1232 /* directory, and get the processes host. */
1234 XtGetApplicationResources(toplevel, &application_args,
1235 resources, XtNumber(resources), NULL,0);
1237 #ifdef DT_PERFORMANCE
1238 gettimeofday(&update_time_f, NULL);
1239 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1240 update_time_f.tv_usec += 1000000;
1241 update_time_f.tv_sec--;
1243 printf(" done Setting up Converters and got resources, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1245 /* Added by Aloke Gupta */
1246 _DtPerfChkpntMsgSend("Done Setup Converters");
1249 #ifdef DT_PERFORMANCE
1250 printf(" DtDbLoad\n");
1251 gettimeofday(&update_time_s, NULL);
1252 /* Added by Aloke Gupta */
1253 _DtPerfChkpntMsgSend("Begin DtDbLoad");
1257 /* Set up the messaging and file types */
1260 #ifdef DT_PERFORMANCE
1261 gettimeofday(&update_time_f, NULL);
1262 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1263 update_time_f.tv_usec += 1000000;
1264 update_time_f.tv_sec--;
1266 printf(" done DtDbLoad, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1268 /* Added by Aloke Gupta */
1269 _DtPerfChkpntMsgSend("Done DtDbLoad");
1274 /* Create some global strings */
1275 db = XtDatabase(display);
1276 if (XrmGetResource (db, "dttypes.defaultActions",
1277 "Dttypes.DefaultActions", &rep_type,
1280 string = XtNewString(resource_value.addr);
1281 for(str = DtStrtok(string, ",") ,i = 0; str != NULL && i < 2 ;
1282 str = DtStrtok(NULL, ","), i++) {
1284 openInPlace = XtNewString(str);
1286 openNewView = XtNewString(str);
1290 if(openInPlace == NULL || strlen(openInPlace) == 0)
1291 openInPlace = XtNewString("OpenInPlace");
1292 if(openNewView == NULL || strlen(openNewView) == 0)
1293 openNewView = XtNewString("OpenNewView");
1295 DtGetShortHostname (home_host_name, MAX_PATH);
1297 /* Get the lock established to ensure only one dtfile process */
1299 if (_DtGetLock (display, DTFILE_CLASS_NAME) == 0)
1301 status = InitializeToolTalkProcid( &ttFd, toplevel, False );
1302 if (TT_OK != status)
1304 char *errfmt, *errmsg, *title, *statmsg;
1305 title = GETMESSAGE(21,38,"File Manager Error");
1306 errfmt = GETMESSAGE(18, 40,
1307 "Could not connect to ToolTalk:\n%s\nExiting ...");
1308 statmsg = tt_status_message(status);
1310 errmsg = XtMalloc(strlen(errfmt) + strlen(statmsg) + 2);
1311 fprintf(stderr, errfmt, statmsg);
1312 sprintf(errmsg, errfmt, statmsg);
1314 /* put up error dialog and loop,
1315 * application will exit in dialog callback
1317 post_dialog(toplevel, title, errmsg, DtErrExitCB);
1320 if (application_args.session != NULL)
1322 msg = tttk_message_create( 0, TT_REQUEST, TT_SESSION, 0,
1323 "DtFileSession_Run",
1324 (Tt_message_callback)ExitApp );
1325 tt_message_file_set( msg, application_args.session );
1326 tt_message_send( msg );
1328 else if (application_args.directories != NULL)
1330 msg = tttk_message_create( 0, TT_REQUEST, TT_SESSION, 0,
1332 (Tt_message_callback)ExitApp );
1333 tt_message_file_set( msg, application_args.directories );
1334 SetupSendRequestArgs( application_args, msg );
1335 tt_message_send( msg );
1339 /* Default action: Open up pwd or home dir */
1340 GetPWD(current_directory);
1342 if (current_directory[0] != '\0')
1344 msg = tttk_message_create( 0, TT_REQUEST, TT_SESSION, 0,
1346 (Tt_message_callback)ExitApp );
1347 tt_message_file_set( msg, current_directory );
1351 msg = tttk_message_create( 0, TT_REQUEST, TT_SESSION, 0,
1353 (Tt_message_callback)ExitApp );
1355 SetupSendRequestArgs( application_args, msg );
1356 tt_message_send( msg );
1358 WaitForResponseAndExit();
1361 /* Initialize the encapsulation mechanism and install the dialogs */
1362 /* used by the file manager. */
1364 _DtInitializeEncapsulation (display, argv[0], DTFILE_CLASS_NAME);
1365 topPositionOffset = -8;
1367 status = InitializeToolTalkProcid( &ttFd, toplevel, True );
1368 if (TT_OK != status)
1370 char *errfmt, *errmsg, *title, *statmsg;
1371 title = GETMESSAGE(21,38,"File Manager Error");
1372 errfmt = GETMESSAGE(18, 40,
1373 "Could not connect to ToolTalk:\n%s\nExiting ...");
1374 statmsg = tt_status_message(status);
1376 errmsg = XtMalloc(strlen(errfmt) + strlen(statmsg) + 2);
1377 fprintf(stderr, errfmt, statmsg);
1378 sprintf(errmsg, errfmt, statmsg);
1380 /* put up error dialog and loop,
1381 * application will exit in dialog callback
1383 post_dialog(toplevel, title, errmsg, DtErrExitCB);
1387 #ifdef DT_PERFORMANCE
1388 printf(" Setup Callbacks (messaging)\n");
1389 gettimeofday(&update_time_s, NULL);
1391 /* Added by Aloke Gupta */
1392 _DtPerfChkpntMsgSend("Begin Setup Callbacks");
1395 events2Watch = tt_pattern_create();
1396 tt_pattern_category_set( events2Watch, TT_OBSERVE );
1397 tt_pattern_class_add( events2Watch, TT_NOTICE );
1398 tt_pattern_scope_add( events2Watch, TT_SESSION );
1399 sessId = tt_default_session();
1400 tt_pattern_session_add( events2Watch, sessId );
1402 tt_pattern_op_add( events2Watch, "DtTypes_Reloaded" );
1403 tt_pattern_op_add( events2Watch, "XSession_Ending" );
1404 tt_pattern_callback_add( events2Watch, ObserveTtNotice );
1405 tt_pattern_register( events2Watch );
1407 requests2Handle = tt_pattern_create();
1408 tt_pattern_category_set( requests2Handle, TT_HANDLE );
1409 tt_pattern_class_add( requests2Handle, TT_REQUEST );
1410 tt_pattern_scope_add( requests2Handle, TT_SESSION );
1411 sessId = tt_default_session();
1412 tt_pattern_session_add( requests2Handle, sessId );
1414 tt_pattern_op_add( requests2Handle, "DtFileSession_Run" );
1415 tt_pattern_op_add( requests2Handle, "DtFolder_Show" );
1416 tt_pattern_op_add( requests2Handle, "DtHome_Show" );
1417 tt_pattern_op_add( requests2Handle, "DtTools_Show" );
1418 tt_pattern_op_add( requests2Handle, "DtTrash_Show" );
1419 tt_pattern_op_add( requests2Handle, "DtTrash_Remove" );
1420 tt_pattern_op_add( requests2Handle, "DtTrash_Empty" );
1421 tt_pattern_op_add( requests2Handle, "DtTrash_File" );
1422 tt_pattern_op_add( requests2Handle, "DtTrash_Restore" );
1423 tt_pattern_op_add( requests2Handle, "DtFile_PutOnWorkspace" );
1424 tt_pattern_op_add( requests2Handle, "DtFile_Move" );
1425 tt_pattern_op_add( requests2Handle, "DtFile_Copy" );
1426 tt_pattern_op_add( requests2Handle, "DtFile_Link" );
1427 tt_pattern_callback_add( requests2Handle, HandleTtRequest );
1428 tt_pattern_register( requests2Handle );
1430 /* Setup the settings file if any to setup */
1432 _DtWsmAddMarqueeSelectionCallback(toplevel,
1433 (DtWsmMarqueeSelectionProc) MarqueeSelect,
1436 #ifdef DT_PERFORMANCE
1437 gettimeofday(&update_time_f, NULL);
1438 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1439 update_time_f.tv_usec += 1000000;
1440 update_time_f.tv_sec--;
1442 printf(" done Setting Callbacks (messaging), time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1444 /* Added by Aloke Gupta */
1445 _DtPerfChkpntMsgSend("Done Setup Callbacks");
1449 smallIconWidth = application_args.smallIconWidth;
1450 smallIconHeight = application_args.smallIconHeight;
1451 largeIconWidth = application_args.largeIconWidth;
1452 largeIconHeight = application_args.largeIconHeight;
1453 user_font = application_args.user_font;
1454 dragThreshold = application_args.dragThreshold;
1455 rereadTime = application_args.rereadTime;
1456 checkBrokenLink = application_args.checkBrokenLink;
1457 maxDirectoryProcesses = application_args.maxDirectoryProcesses;
1458 maxRereadProcesses = application_args.maxRereadProcesses;
1459 maxRereadProcsPerTick = application_args.maxRereadProcsPerTick;
1460 trashWait = application_args.trashWait;
1461 showFilesystem = application_args.showFilesystem;
1462 showDropZone = application_args.showDropZone;
1463 showEmptySet = application_args.showEmptySet;
1464 showEmptyMsg = application_args.showEmptyMsg;
1465 restrictMode = application_args.restrictMode;
1466 openDirType = application_args.openDirType;
1467 desktopIconType = application_args.desktopIconType;
1468 desktopPlacement = application_args.desktopPlacement;
1469 freezeOnConfig = application_args.freezeOnConfig;
1470 emptyTrashOnExit = application_args.emptyTrashOnExit;
1471 #if defined(__hpux) || defined(sun)
1472 follow_links = application_args.follow_links;
1474 instanceWidth = application_args.instanceIconWidth;
1475 instanceHeight = application_args.instanceIconHeight;
1476 fileMgrIcon = application_args.fileMgrIcon;
1477 appMgrIcon = application_args.appMgrIcon;
1478 trashIcon = application_args.trashIcon;
1479 retryLoadDesktopInfo = application_args.retryLoadDesktop;
1480 if( application_args.directories != NULL
1481 || (strcmp (application_args.restricted, RESTRICTED_HEADER) == 0)
1484 special_view = True;
1485 if(strcmp (application_args.restricted, RESTRICTED_HEADER) == 0)
1487 if(application_args.directories != NULL)
1488 special_restricted = XtNewString(application_args.directories);
1491 /* Get users pwd so we can set the restricted dir to it */
1492 GetPWD(current_directory);
1494 if (current_directory[0] != '\0')
1495 special_restricted = XtNewString(current_directory);
1497 special_restricted = XtNewString("~");
1500 else if( restrictMode )
1501 special_restricted = XtNewString("~");
1503 special_restricted = NULL;
1504 special_treeType = treeType = application_args.tree_view;
1505 special_treeFiles = treeFiles = application_args.tree_files;
1506 special_viewType = viewType = application_args.view;
1507 special_orderType = orderType = application_args.order;
1508 special_directionType = directionType = application_args.direction;
1509 special_randomType = randomType = application_args.grid;
1510 special_title = XtNewString(application_args.title);
1511 if(application_args.help_volume == NULL)
1513 special_helpVol = XtNewString(DTFILE_HELP_NAME);
1514 fileMgrHelpVol = XtNewString(DTFILE_HELP_NAME);
1518 special_helpVol = XtNewString(application_args.help_volume);
1519 fileMgrHelpVol = XtNewString(application_args.help_volume);
1521 fileMgrTitle = application_args.title;
1525 special_view = False;
1526 treeType = application_args.tree_view;
1527 treeFiles = application_args.tree_files;
1528 viewType = application_args.view;
1529 orderType = application_args.order;
1530 directionType = application_args.direction;
1531 randomType = application_args.grid;
1532 fileMgrTitle = application_args.title;
1533 if(application_args.help_volume == NULL)
1534 fileMgrHelpVol = XtNewString(DTFILE_HELP_NAME);
1536 fileMgrHelpVol = XtNewString(application_args.help_volume);
1540 if(desktopIconType == LARGE)
1542 numRows = displayHeight / PIXELS_PER_ROW_LARGE;
1543 numColumns = displayWidth / PIXELS_PER_COLUMN_LARGE;
1547 numRows = displayHeight / PIXELS_PER_ROW_SMALL;
1548 numColumns = displayWidth / PIXELS_PER_COLUMN_SMALL;
1552 /* determine whether the Server has the shape extension */
1553 if(XShapeQueryExtension(display, &base1, &base2) == True)
1554 shapeExtension = True;
1556 shapeExtension = False;
1559 /* get the name for the root directory */
1560 root_title = (char *)XtMalloc(strlen(application_args.root_title) + 1);
1561 strcpy(root_title, application_args.root_title);
1563 if ((homeDir = getenv("HOME")) == NULL || strlen (homeDir) == 0)
1565 pwInfo = getpwuid (getuid());
1566 homeDir = pwInfo->pw_dir;
1568 strncpy(users_home_dir, homeDir, MAX_PATH - 1);
1571 if(application_args.directories != NULL &&
1572 strncmp(application_args.directories, "~", 1) != 0 )
1574 if(strncmp(application_args.directories, users_home_dir,
1575 strlen(users_home_dir)) != 0)
1576 RestrictModeUsage (argv);
1578 else if (application_args.directories == NULL)
1579 application_args.directories = XtNewString("~");
1581 if (strcmp(users_home_dir, "/") != 0)
1582 strcat(users_home_dir, "/");
1584 XtAppAddActions(XtWidgetToApplicationContext (toplevel), actionTable, 2);
1586 /* Create some global Xm strings for our dialog buttons */
1588 okXmString = XmStringCreateLocalized((char*)_DtOkString);
1589 cancelXmString = XmStringCreateLocalized((char*)_DtCancelString);
1590 helpXmString = XmStringCreateLocalized((char*)_DtHelpString);
1591 applyXmString = XmStringCreateLocalized((char*)_DtApplyString);
1592 closeXmString = XmStringCreateLocalized((char*)_DtCloseString);
1594 /* Get the dt path created and initialized */
1596 dt_path = _DtCreateDtDirs (display);
1598 if (dt_path == NULL)
1602 title = XtNewString((GETMESSAGE(21,38,"File Manager Error")));
1603 tmpStr = GETMESSAGE(18, 2, "Could not create the ~/.dt folder or sub folders.");
1604 msg = XtNewString(tmpStr);
1606 /* put up error dialog and loop, application will exit in
1609 dialog = post_dialog(toplevel, title, msg, DtErrExitCB);
1615 XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
1619 /* Set the black and white pixel globals. */
1621 black_pixel = BlackPixelOfScreen (XtScreen (toplevel));
1622 white_pixel = WhitePixelOfScreen (XtScreen (toplevel));
1625 * Take over the drawing area's redisplay functions, so that we can get
1626 * the dtfile views to redraw according to stacking order, using our own
1629 xmDrawingAreaWidgetClass->core_class.expose = DrawingAreaRedisplay;
1632 /* Get the root user id */
1634 if ((pw = getpwnam("root")) == NULL)
1635 root_user = 0; /* Assume root is uid 0 */
1637 root_user = pw->pw_uid;
1640 file_mgr_dialog = _DtInstallDialog (fileMgrClass, True, True);
1641 change_dir_dialog = _DtInstallDialog (changeDirClass, True, True);
1642 preferences_dialog = _DtInstallDialog (preferencesClass, True, True);
1643 filter_dialog = _DtInstallDialog (filterClass, True, True);
1644 find_dialog = _DtInstallDialog (findClass, True, True);
1645 mod_attr_dialog = _DtInstallDialog (modAttrClass, True, True);
1646 help_dialog = _DtInstallDialog (helpClass, False, False);
1648 if(special_view == True && special_restricted != NULL) {
1649 if(strncmp(special_restricted, "~", 1) == 0)
1653 special_restricted = _DtChangeTildeToHome(special_restricted);
1654 ptr = strrchr(special_restricted, '/');
1661 /* Setup the settings file if any to setup */
1662 RestoreSettingsFile();
1664 #ifdef DT_PERFORMANCE
1665 printf(" TrashCreateDialog\n");
1666 gettimeofday(&update_time_s, NULL);
1668 /* Added by Aloke Gupta */
1669 _DtPerfChkpntMsgSend("Begin TrashCreateDialog");
1672 if( InitializeTrash( application_args.prompt_user ) )
1674 #ifdef DEFER_TRASH_CREATION
1677 TrashCreateDialog (display);
1680 #ifdef DT_PERFORMANCE
1681 gettimeofday(&update_time_f, NULL);
1682 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1683 update_time_f.tv_usec += 1000000;
1684 update_time_f.tv_sec--;
1686 printf(" done TrashCreateDialog, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1688 /* Added by Aloke Gupta */
1689 _DtPerfChkpntMsgSend("Done TrashCreateDialog");
1692 /* lets go empty the trash if there is any */
1697 #ifdef DT_PERFORMANCE
1698 printf(" Setup Desktop\n");
1699 gettimeofday(&update_time_s, NULL);
1700 /* Added by Aloke Gupta */
1701 _DtPerfChkpntMsgSend("Begin Setup Desktop");
1704 /* go build 10 desktop windows */
1705 desktop_data = NULL;
1706 InitializeDesktopWindows(10, display);
1707 InitializeDesktopGrid();
1709 LoadDesktopInfo(application_args.session);
1711 /* Install WorkSpaceRemoved handler.
1712 This handler will be called when a workspace is being removed
1713 so File Manager can go through its desktop icons and clean up.
1715 DtWsmAddWorkspaceModifiedCallback( toplevel, WorkSpaceRemoved, NULL );
1717 #ifdef DT_PERFORMANCE
1718 gettimeofday(&update_time_f, NULL);
1719 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1720 update_time_f.tv_usec += 1000000;
1721 update_time_f.tv_sec--;
1723 printf(" done Setting up Desktop, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1725 /* Added by Aloke Gupta */
1726 _DtPerfChkpntMsgSend("Done Setup Desktop");
1730 /* Process the application resources to restore a session, dt */
1731 /* a directory set or display the users home directory. */
1733 #ifdef DT_PERFORMANCE
1734 printf(" Bring up View\n");
1735 gettimeofday(&update_time_s, NULL);
1737 /* Added by Aloke Gupta */
1738 _DtPerfChkpntMsgSend("Begin Bring up View");
1742 if (strcmp (application_args.no_view, "-noview") != 0)
1744 if (application_args.session != NULL)
1746 RestoreSession (application_args.session, NORMAL_RESTORE, NULL);
1747 else if (application_args.directories != NULL)
1749 restoreType = CURRENT_DIR_RESTORE;
1750 OpenDirectories (application_args.directories, NULL);
1754 #ifdef DT_PERFORMANCE
1755 gettimeofday(&update_time_f, NULL);
1756 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1757 update_time_f.tv_usec += 1000000;
1758 update_time_f.tv_sec--;
1760 printf(" done Bringing up view, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec); fflush(stdout);
1762 /* Added by Aloke Gupta */
1763 _DtPerfChkpntMsgSend("Done Bring up View");
1767 /* If no views were opened upon invocation, display the */
1768 /* current directory. */
1770 if ( (strcmp (application_args.no_view, "-noview") != 0) &&
1771 ((application_args.session == NULL) ||
1772 (session_flag != 0)) )
1774 if (view_count == 0)
1776 /* Get users pwd so we can create a fileviewer window of it */
1777 GetPWD(current_directory);
1779 if (current_directory[0] != '\0')
1781 if (!GetNewView (home_host_name, current_directory, NULL, NULL, 0))
1782 ViewHomeDirectoryHandler (0);
1786 ViewHomeDirectoryHandler (0);
1792 /* Set up the timer based directory reading. */
1793 InitializeDirectoryRead (toplevel);
1795 /* Process and dispatch incoming events */
1796 eventDebugging = getenv("EVENT_DEBUGGING") != NULL;
1798 #ifdef DT_PERFORMANCE
1799 printf(" InitializeToolTalkSession\n");
1800 gettimeofday(&update_time_s, NULL);
1802 (void) InitializeToolTalkSession( toplevel, ttFd );
1803 #ifdef DT_PERFORMANCE
1804 gettimeofday(&update_time_f, NULL);
1805 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1806 update_time_f.tv_usec += 1000000;
1807 update_time_f.tv_sec--;
1809 printf(" done InitializeToolTalkSession, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1812 #ifdef DT_PERFORMANCE
1813 gettimeofday(&update_time_fs, NULL);
1814 if (update_time_ss.tv_usec > update_time_fs.tv_usec) {
1815 update_time_fs.tv_usec += 1000000;
1816 update_time_fs.tv_sec--;
1818 printf(" Finish, time: %ld.%ld\n\n", update_time_fs.tv_sec - update_time_ss.tv_sec, update_time_fs.tv_usec - update_time_ss .tv_usec);
1823 XtNextEvent(&event);
1825 if (event.type != 0)
1826 XtDispatchEvent(&event);
1829 return EXIT_SUCCESS;
1834 /************************************************************************
1838 ************************************************************************/
1843 XErrorEvent *event )
1845 #define _DTFILE_BUFSIZE 1024
1846 char errmsg[_DTFILE_BUFSIZE];
1848 _DtPrintDefaultErrorSafe (disp, event, errmsg, _DTFILE_BUFSIZE);
1849 _DtSimpleError(application_name, DtWarning, NULL, errmsg, NULL);
1850 xErrorDetected = True;
1852 /* We do not want to exit here lets try to continue... */
1857 ToolkitErrorHandler(
1863 tmpStr = GETMESSAGE(18, 6, "An X Toolkit error occurred... Exiting.\n");
1864 msg = (char *)malloc(strlen(tmpStr) + strlen(message) + 3);
1865 strcpy(msg, message);
1867 strcat(msg, tmpStr);
1868 _DtSimpleError (application_name, DtError, NULL, msg);
1871 FinalizeToolTalkSession( );
1878 /************************************************************************
1881 * When incorrect parameters have been specified on the command
1882 * line, print out a set of messages detailing the correct use
1885 ************************************************************************/
1892 char * message_string1 = "\nUsage: %s...\n\n"
1894 "Dtfile runs in server mode.\n\n"
1895 " -session SessionFile\n\n\t"
1896 "Dtfile runs with the session file specified in the SessionFile\n\t"
1898 " -folder Folder[,Folder,Folder]\n"
1899 " -dir Folder[,Folder,Folder]\n\n\t"
1900 "Dtfile displays a window for each folder specified in the\n\t"
1901 "Folder parameter. The Folder parameter may contain many\n\t"
1902 "folders separated by commas. Folders may be in the form\n\t"
1904 " -title Title\n\n\t"
1905 "Dtfile uses the string specified in the Title parameter as the\n\t"
1906 "title for its windows.\n\n"
1907 " -help_volume HelpVolume\n\n\t"
1908 "Dtfile uses the help volume specified in the HelpVolume parameter.\n\n"
1909 " -restricted\n\n\t"
1910 "Dtfile will not display folders above the restricted folder.\n\t"
1911 "If the -dir option is used, the folder specified in that option\n\t"
1912 "is the restricted folder. If the -dir option is not used, the\n\t"
1913 "user's current folder is the restricted folder.\n\n"
1914 " -grid on/off\n\n\t"
1915 "on = Files are displayed in a grid pattern.\n\t"
1916 "off = Files are displayed as placed.\n\n"
1917 " -tree on/off\n\n\t"
1918 "on = Files are displayed in single folder mode.\n";
1920 char * message_string2 = "\toff = Files are displayed in folder tree mode.\n\n"
1921 " -tree_files never/always/choose\n\n\t"
1922 "never = Tree mode has two states: partially expanded or collapsed.\n\t"
1923 "always = Tree mode has two states: fully expanded or collapsed.\n\t"
1924 "choose = Tree mode has three states: partially expanded, fully\n\t"
1925 " expanded, or collapsed.\n\n"
1926 " -order alphabetical/file_type/date/size\n\n\t"
1927 "Files are displayed in the specified order: alphabetical, by file\n\t"
1928 "type, by date, or by size.\n\n"
1929 " -view no_icon/large_icon/small_icon/attributes\n\n\t"
1930 "Files are displayed in the specified format: text only, text and\n\t"
1931 "large icons, text and small icons, with attributes.\n\n"
1932 " -direction ascending/descending\n\n\t"
1933 "Files are displayed in the specified direction: ascending or\n\t"
1935 " -large_icon_width <size>\n\n"
1936 " -large_icon_height <size>\n\n"
1937 " -small_icon_width <size>\n\n"
1938 " -small_icon_height <size>\n\n"
1939 " The display area size for the icon images in File Manager\n"
1940 " Icon images larger than this size will be clipped to this size\n"
1941 " The default display area size for large is 38 and small is 24\n\n"
1945 template = (GETMESSAGE(18,23, message_string1));
1946 fprintf (stderr, template, argv[0]);
1947 template = (GETMESSAGE(18,24, message_string2));
1948 fprintf (stderr, "%s", template);
1958 char * message_string = "\nRestricted Mode Usage: %s...\n\n"
1959 " -folder Folder[,Folder,Folder]\n"
1960 " -dir Folder[,Folder,Folder]\n\n\t"
1961 "Where Folder is a Folder below and/or including\n\t"
1962 "the user's Home Folder.\n\n";
1964 template = (GETMESSAGE(18,26, message_string));
1966 fprintf (stderr, template, argv[0]);
1968 FinalizeToolTalkSession( );
1975 /************************************************************************
1978 * Catches Ctrl C's and exits.
1980 ************************************************************************/
1985 FinalizeToolTalkSession( );
1995 /***********************************************************************
1997 * RestoreSettingsFile
1998 * Used to restore the save settings files from
1999 * either $HOME/.dt/$DISPLAY/current or $HOME/.dt/$DISPLAY/home.
2001 ***********************************************************************/
2003 RestoreSettingsFile( void )
2007 char *homeSavePath=NULL;
2008 char *homeHomePath=NULL;
2009 char *toolSavePath=NULL;
2010 char *toolHomePath=NULL;
2014 unsigned long nitems;
2015 unsigned long leftover;
2016 unsigned char *data = NULL;
2019 /* go get the dt path */
2020 /* _DtCreateDtDirs returs a path of MaxPath Length */
2021 dtPath = (char *)_DtCreateDtDirs(display);
2023 /* Determin which type of session we are running HOME or CURRENT */
2025 /* get the root window property of SaveMode */
2026 XGetWindowProperty(display, RootWindow(display,0),
2027 save_mode, 0L, (long)BUFSIZ,False,
2028 XA_STRING, &actualType,
2029 &actualFormat,&nitems,&leftover,
2032 if(strcmp((char *)data, "home") == 0)
2033 dirName = XtNewString("home");
2034 else if(strcmp((char *)data, "current") == 0)
2035 dirName = XtNewString("current");
2039 return; /* we are comming up in a system mode (e.g. default) */
2043 /* Build the paths to read the files from */
2045 toolSavePath = (char *)XtMalloc(strlen(dtPath) +
2046 strlen(TOOL_SETTINGS_FILENAME) +
2047 strlen(dirName) + 4);
2049 homeSavePath = (char *)XtMalloc(strlen(dtPath) +
2050 strlen(HOME_SETTINGS_FILENAME) +
2051 strlen(dirName) + 4);
2053 sprintf( homeSavePath, "%s/%s/%s", dtPath, dirName, HOME_SETTINGS_FILENAME );
2054 sprintf( toolSavePath, "%s/%s/%s", dtPath, dirName, TOOL_SETTINGS_FILENAME );
2056 /* open the home settings file to see if its there */
2057 if((fd = open(homeSavePath, O_RDONLY)) != -1)
2060 /* create where the saved file is going to go */
2062 homeHomePath = (char *)XtMalloc(strlen(dtPath) +
2063 strlen(HOME_SETTINGS_FILENAME) + 2);
2065 sprintf( homeHomePath, "%s/%s", dtPath, HOME_SETTINGS_FILENAME );
2067 /* remove any existing dtfile.home (e.g. HOME_SETTINGS_FILENAME) */
2068 unlink(homeHomePath);
2070 /* copy the saved one into $HOME/.dt/$DISPLAY ... this is the one that
2071 * will be used by the dtfile
2073 status = link(homeSavePath, homeHomePath);
2078 tmpStr = GETMESSAGE(18,27, "Unable to recover the saved default home settings file, will use default.\n");
2079 msg = XtNewString(tmpStr);
2080 _DtSimpleErrnoError(application_name, DtWarning, NULL, msg, NULL);
2086 /* open the tool settings file to see if its there */
2087 if((fd = open(toolSavePath, O_RDONLY)) != -1)
2090 /* create where the saved file is going to go */
2091 toolHomePath = (char *)XtMalloc(strlen(dtPath) +
2092 strlen(TOOL_SETTINGS_FILENAME) + 2);
2094 sprintf( toolHomePath, "%s/%s", dtPath, TOOL_SETTINGS_FILENAME );
2096 /* remove any existing dtfile.tool (e.g. TOOL_SETTINGS_FILENAME) */
2097 unlink(toolHomePath);
2099 /* copy the saved one into $HOME/.dt/$DISPLAY ... this is the one that
2100 * will be used by the dtfile
2102 status = link(toolSavePath, toolHomePath);
2107 tmpStr = GETMESSAGE(18,28, "Unable to recover the saved default tool settings file, will use default.\n");
2108 msg = XtNewString(tmpStr);
2109 _DtSimpleErrnoError(application_name, DtWarning, NULL, msg, NULL);
2119 XtFree(homeSavePath);
2120 XtFree(toolSavePath);
2121 XtFree(toolHomePath);
2122 XtFree(homeHomePath);
2131 /***********************************************************************
2133 * MoveDefaultSettings
2134 * Used to save the dtfile.tool and dtfile.home settings files to
2135 * either $HOME/.dt/$DISPLAY/current or $HOME/.dt/$DISPLAY/home.
2136 * The parameter mode determines whether it is home or
2139 ***********************************************************************/
2141 MoveDefaultSettings(
2145 char *toolSavePath=NULL;
2146 char *homeSavePath=NULL;
2148 char *toolMovePath=NULL;
2149 char *homeMovePath=NULL;
2152 /* determine whether home or current */
2153 if(mode == HOME_DIR_RESTORE)
2154 dirName = XtNewString("home");
2156 dirName = XtNewString("current");
2158 /* go get the dt path */
2159 /* _DtCreateDtDirs returs a path of MaxPath Length */
2160 dtPath = (char *)_DtCreateDtDirs(display);
2163 /* Build the paths to save the files to */
2165 toolSavePath = (char *)XtMalloc(strlen(dtPath) +
2166 strlen(TOOL_SETTINGS_FILENAME) +
2167 strlen(dirName) + 4);
2169 homeSavePath = (char *)XtMalloc(strlen(dtPath) +
2170 strlen(HOME_SETTINGS_FILENAME) +
2171 strlen(dirName) + 4);
2174 /* create the directory and filename of where its going to be saved */
2175 sprintf( homeSavePath, "%s/%s/%s", dtPath, dirName, HOME_SETTINGS_FILENAME );
2176 sprintf( toolSavePath, "%s/%s/%s", dtPath, dirName, TOOL_SETTINGS_FILENAME );
2178 /* Setup the paths used to GET the old files */
2180 toolMovePath= (char *)XtMalloc(strlen(dtPath) +
2181 strlen(TOOL_SETTINGS_FILENAME) + 3);
2183 homeMovePath= (char *)XtMalloc(strlen(dtPath) +
2184 strlen(HOME_SETTINGS_FILENAME) + 3);
2186 /* create the filename of where its going to be saved from */
2188 /* Tool File location */
2189 sprintf( toolMovePath, "%s/%s", dtPath, TOOL_SETTINGS_FILENAME );
2191 /* Home File location */
2192 sprintf( homeMovePath, "%s/%s", dtPath, HOME_SETTINGS_FILENAME );
2195 /* get rid of the tool settings file that is already in home or current */
2196 status = unlink(toolSavePath);
2198 /* get rid of the home settings file that is already in home or current */
2199 status = unlink(homeSavePath);
2202 /* now save tool settings file in home or current determined by savePath */
2203 status = link(toolMovePath, toolSavePath);
2205 /* now save home settings file in home or current determined by savePath */
2206 status = link(homeMovePath, homeSavePath);
2209 XtFree(homeMovePath);
2210 XtFree(toolMovePath);
2211 XtFree(homeSavePath);
2212 XtFree(toolSavePath);
2218 /************************************************************************
2221 * Callback for the Save Settings menupick.
2223 ************************************************************************/
2227 XtPointer client_data,
2228 XtPointer call_data )
2235 FileMgrRec * file_mgr_rec;
2236 DialogData * dialog_data;
2237 FileMgrData * file_mgr_data;
2240 /* Strip the file_mgr_rec from the current widget
2241 * and attach it to the ok callback button
2245 /* Get the file_mgr_rec hanging off the menubar */
2246 mbar = XmGetPostedFromWidget(XtParent(w));
2247 XmUpdateDisplay (w);
2248 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
2249 XtGetValues(mbar, args, 1);
2252 /* Ignore accelerators when we're insensitive */
2253 if ((file_mgr_rec->menuStates & SETTINGS) == 0)
2255 XSetInputFocus(XtDisplay(w),
2256 XtWindow(file_mgr_rec->defaultEnvBtn_child),
2257 RevertToParent, CurrentTime);
2261 /* Desensatize the save settings menu pick here */
2262 file_mgr_rec->menuStates &= ~SETTINGS;
2265 /* Get the file_mgr_rec dialog data info */
2266 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
2268 file_mgr_data = (FileMgrData *) dialog_data->data;
2271 /* Based on the path we must determine if we are saving a Tools or
2272 * HomeDir dtfile view.
2274 if (file_mgr_data->restricted_directory != NULL && file_mgr_data->toolbox)
2275 file_mgr_data->restoreKind = TOOL_RESTORE;
2277 file_mgr_data->restoreKind = HOME_RESTORE;
2280 /* Setup and call the _DtMessageDialog procedure to post the dialog */
2282 if (file_mgr_data->restoreKind == HOME_RESTORE)
2284 tmpStr = (GETMESSAGE(18,29, "Save the current File Manager View window size,\npreferences, and filter settings?\n\nThey will be used for any new File Manager View windows\nstarted from the Front Panel."));
2288 tmpStr = (GETMESSAGE(18,35, "Save the current Application Manager\nView window size, preferences, and filter settings?\n\nThey will be used for any new Application Manager\nwindows started from the Front Panel."));
2290 message = XtNewString(tmpStr);
2292 if(file_mgr_data->title != NULL &&
2293 strcmp(file_mgr_data->helpVol, DTFILE_HELP_NAME) != 0)
2295 tmpStr = GETMESSAGE(18, 16, "Save As Default Options");
2296 title = (char *)XtMalloc(strlen(tmpStr) +
2297 strlen(file_mgr_data->title) + 5);
2298 sprintf(title, "%s - %s", file_mgr_data->title, tmpStr);
2302 tmpStr = GETMESSAGE(18, 32, "File Manager - Save As Default Options");
2303 title = XtNewString(tmpStr);
2305 dlog = (Widget)_DtMessageDialog(mbar, title, message, NULL, TRUE,
2306 SaveDefaultCancelCB, SaveDefaultOkCB, NULL,
2307 HelpRequestCB, False, QUESTION_DIALOG);
2308 file_mgr_rec->defaultEnvBtn_child=dlog;
2313 /* Add array as userdata on the dialog. */
2315 XtSetArg(args[0], XmNuserData, file_mgr_rec);
2316 XtSetValues(dlog, args, 1);
2320 /************************************************************************
2322 * SaveDefaultCancelCB
2323 * Cleanup and unmanage the save settings dialog.
2325 ************************************************************************/
2327 SaveDefaultCancelCB(
2329 XtPointer client_data,
2330 XtPointer call_data )
2332 FileMgrRec * file_mgr_rec;
2335 /* Update the display, and un-post the dialog */
2336 XtUnmanageChild((Widget)client_data);
2337 XmUpdateDisplay((Widget)client_data);
2338 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
2339 XtGetValues((Widget)client_data, args, 1);
2342 /* Re-sensatize the save settings menu pick */
2343 file_mgr_rec->menuStates |= SETTINGS;
2346 XtDestroyWidget((Widget)client_data);
2351 /************************************************************************
2354 * Save the current dtfile view as the default environment for
2355 * new dtfiles created.
2357 ************************************************************************/
2361 XtPointer client_data,
2362 XtPointer call_data )
2365 FileMgrRec * file_mgr_rec;
2366 static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL };
2367 char view_number[5];
2371 DialogData * dialog_data;
2372 FileMgrData * file_mgr_data;
2375 char full_path[MAX_PATH + 1];
2378 char * save_directory;
2379 char ** save_branch_list;
2380 FileViewData ** save_selection_list;
2381 int save_selected_file_count;
2384 /* Get the file_mgr_rec hanging off the dialog */
2385 XtUnmanageChild((Widget)client_data);
2386 XmUpdateDisplay ((Widget)client_data);
2387 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
2388 XtGetValues((Widget)client_data, args, 1);
2391 /* Re-sensatize the save settings menu pick */
2392 file_mgr_rec->menuStates |= SETTINGS;
2395 /* Get the file_mgr_rec dialog data info */
2397 dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec);
2398 file_mgr_data = (FileMgrData *) dialog_data->data;
2401 /* Build the path for our env file */
2403 tmp_path = _DtCreateDtDirs(display);
2404 if (tmp_path == NULL)
2406 XtDestroyWidget(client_data);
2411 /* Look and see what type of restore we are doing */
2412 if (file_mgr_data->restoreKind == TOOL_RESTORE)
2414 sprintf(full_path, "%s/%s", tmp_path, TOOL_SETTINGS_FILENAME);
2415 application_args.tool_width = file_mgr_data->width;
2416 application_args.tool_height = file_mgr_data->height;
2420 sprintf(full_path, "%s/%s", tmp_path, HOME_SETTINGS_FILENAME);
2421 application_args.dir_width = file_mgr_data->width;
2422 application_args.dir_height = file_mgr_data->height;
2428 /* Create the Environment session file */
2430 if ((fd = creat(full_path, S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP)) == -1)
2433 tmpStr = GETMESSAGE(18, 17, "Unable to create a file to store the default options.");
2434 title = XtNewString((GETMESSAGE(21,38,"Object Create Error")));
2435 msg = XtNewString(tmpStr);
2436 _DtMessage (toplevel, title, msg, NULL, HelpRequestCB);
2443 /* Write out the general information */
2445 (void) write (fd, "*", strlen ("*"));
2446 (void) write (fd, DTFILE_CLASS_NAME,strlen (DTFILE_CLASS_NAME));
2447 (void) write (fd, "*view_count: ", strlen ("*view_count: "));
2449 (void) sprintf (view_number, "%d", 1);
2450 (void) write (fd, view_number, strlen (view_number));
2451 (void) write (fd, "\n#\n", strlen ("\n#\n"));
2453 name_list[1] = view_number;
2455 /* Temporarily remove data that we don't need or want saved */
2457 save_host = file_mgr_data->host;
2458 save_directory = file_mgr_data->current_directory;
2459 save_branch_list = file_mgr_data->branch_list;
2460 save_selection_list = file_mgr_data->selection_list;
2461 save_selected_file_count = file_mgr_data->selected_file_count;
2462 file_mgr_data->host = NULL;
2463 file_mgr_data->current_directory = NULL;
2464 file_mgr_data->branch_list = NULL;
2465 file_mgr_data->selection_list = NULL;
2466 file_mgr_data->selected_file_count = 0;
2468 /* Call the encapsulation mechanism to write each dialog */
2470 (void) sprintf (view_number, "%d", 0);
2471 _DtWriteDialogData (dialog_data, fd, name_list);
2472 (void) write (fd, "#\n", strlen ("#\n"));
2474 /* Restore the data that was temporarily removed */
2476 file_mgr_data->host = save_host;
2477 file_mgr_data->current_directory = save_directory;
2478 file_mgr_data->branch_list = save_branch_list;
2479 file_mgr_data->selection_list = save_selection_list;
2480 file_mgr_data->selected_file_count = save_selected_file_count;
2484 XtDestroyWidget(client_data);
2490 /************************************************************************
2492 * SaveSessionCallback
2493 * Get the session name and call the function to save the session.
2495 ************************************************************************/
2498 SaveSessionCallback(
2500 XtPointer client_data,
2501 XtPointer call_data )
2503 char * full_path=NULL;
2504 char * file_name=NULL;
2506 int restore=NORMAL_RESTORE;
2507 Boolean status=FALSE;
2508 char * sessionFileName;
2511 if(view_count == 0 && desktop_data->numIconsUsed == 0)
2513 XChangeProperty (display, XtWindow (toplevel), command_atom,
2514 XA_STRING, 8, PropModeReplace, (unsigned char *)NULL, 0);
2515 XSync(display, False);
2516 FinalizeToolTalkSession( );
2520 status = DtSessionSavePath(w, &full_path, &file_name);
2523 sessionFileName = file_name;
2526 XtFree( (char *)full_path);
2527 full_path = (char *) XtMalloc (sizeof (char) * MAX_PATH);
2528 sprintf( full_path, "%s/%s", dt_path, DTFILE_CLASS_NAME );
2529 sessionFileName = full_path;
2531 SaveSession( full_path );
2533 /* skip to the /.dt/ portion of the sessionFileName */
2534 strPtr = strstr(full_path, "/.dt/");
2535 (void)strcpy(full_path, strPtr);
2537 /* Save off the settings files for both tool and home views */
2539 strPtr = DtStrrchr(full_path, '/');
2542 if ((strncmp(strPtr, "/home", 5) == 0))
2543 restore = HOME_DIR_RESTORE;
2544 else if ((strncmp(strPtr, "/current", 8) == 0))
2545 restore = CURRENT_DIR_RESTORE;
2549 } while ((strPtr != NULL) && (restore == NORMAL_RESTORE));
2551 SaveDesktopInfo(restore);
2553 /* Cop the settings files to the proper dir */
2554 MoveDefaultSettings(restore);
2556 /* Generate the reinvoking command and add it as the property value */
2557 argv = (char **) XtMalloc(3 * sizeof(char *));
2558 argv[0] = XtNewString(application_name);
2559 argv[1] = XtNewString("-session");
2560 argv[2] = XtNewString(sessionFileName);
2561 XSetCommand(XtDisplay(toplevel), XtWindow(toplevel), argv, 3);
2563 XtFree ((char *) argv[0]);
2564 XtFree ((char *) argv[1]);
2565 XtFree ((char *) argv[2]);
2566 XtFree ((char *) argv);
2568 XtFree ((char *) full_path);
2569 XtFree ((char *) file_name);
2572 /************************************************************************
2575 * Save the current File Manager session as a set of resources
2576 * within the file denoted by path.
2578 ************************************************************************/
2585 static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL, NULL,
2587 char view_number[5];
2589 char workspaceNumber[5];
2591 Atom * ws_presence = NULL;
2592 char * workspace_name=NULL;
2593 unsigned long num_workspaces = 0;
2597 unsigned long nitems;
2598 unsigned long leftover;
2599 WM_STATE * wm_state;
2601 DialogData * dialog_data;
2602 FileMgrData * file_mgr_data;
2603 FileMgrRec * file_mgr_rec;
2608 WorkspaceRec * workspaceInfo;
2611 char *actualSavedTitle;
2613 /* This needs to be done because name_list is static and the values
2614 can be changed during the routine. This means that they need to be
2615 NULL'd out each pass */
2616 name_list[1] = NULL;
2617 name_list[2] = NULL;
2618 name_list[3] = NULL;
2619 name_list[4] = NULL;
2620 name_list[5] = NULL;
2622 /* Disable any message box display during save session */
2624 message_display_enabled = False;
2627 /* Create the session file */
2629 if ((fd = creat (path, S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP)) == -1)
2631 tmpStr = GETMESSAGE(18, 18, "Could not open the session file.");
2632 msg = XtNewString(tmpStr);
2633 _DtSimpleError (application_name, DtError, NULL, msg);
2635 message_display_enabled = True;
2641 /* Write out the general information */
2643 /* Number of dtfile views */
2644 (void) write (fd, "*", strlen ("*"));
2645 (void) write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2646 (void) write (fd, "*view_count: ", strlen ("*view_count: "));
2648 if (trashFileMgrData)
2650 if (trashFileMgrData->file_mgr_rec)
2651 (void) sprintf (view_number, "%d", view_count + 1);
2653 (void) sprintf (view_number, "%d", view_count);
2657 (void) sprintf (view_number, "%d", view_count);
2659 (void) write (fd, view_number, strlen (view_number));
2660 (void) write (fd, "\n#\n", strlen ("\n#\n"));
2662 (void) write (fd, "*", strlen ("*"));
2663 (void) write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2664 (void) write (fd, "*showFilesystem: ", strlen ("*showFilesystem: "));
2667 (void) write (fd, "True", strlen ("True"));
2669 (void) write (fd, "False", strlen ("False"));
2670 (void) write (fd, "\n#\n", strlen ("\n#\n"));
2672 (void) write (fd, "*", strlen ("*"));
2673 (void) write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2674 (void) write (fd, "*restrictMode: ", strlen ("*restrictMode: "));
2677 (void) write (fd, "True", strlen ("True"));
2679 (void) write (fd, "False", strlen ("False"));
2680 (void) write (fd, "\n#\n", strlen ("\n#\n"));
2682 (void) write (fd, "*", strlen ("*"));
2683 (void) write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2684 (void) write (fd, "*openFolder: ", strlen ("*openFolder: "));
2686 if(openDirType == NEW)
2687 (void) write (fd, "NEW", strlen ("NEW"));
2689 (void) write (fd, "CURRENT", strlen ("CURRENT"));
2690 (void) write (fd, "\n#\n", strlen ("\n#\n"));
2693 name_list[1] = view_number;
2697 /* Write out each of the view's resources */
2698 /* start with -1 so we can include the trash dialog */
2699 for (i = -1; i < view_count; i++)
2704 dialog_data = (DialogData *) trashDialogData;
2710 dialog_data = (DialogData *) view_set[i]->dialog_data;
2713 file_mgr_data = (FileMgrData *) dialog_data->data;
2714 if(i == -1 && trashDialogData)
2715 file_mgr_data->IsTrashCan = True;
2716 file_mgr_rec = (FileMgrRec *) file_mgr_data->file_mgr_rec;
2717 if(file_mgr_rec == NULL)
2720 /* This is a bug fix ... We don't want to save the title if the
2721 View is the Trash Can of if it is an Application Manager. This
2722 is because if the user saves a session in one Locale, then logs
2723 in in another, the Title will be in the locale that the session was
2724 saved in rather then the new local. So let's save the Title,
2725 Null it out, Save the session info, and finally restore the Title.
2727 if(i == -1 || file_mgr_data->toolbox)
2729 /* the Trash Can or toolbox (i.e. Application Manager) */
2730 actualSavedTitle = file_mgr_data->title;
2731 file_mgr_data->title = NULL;
2735 /* Getting the WM_STATE property to see if iconified or not */
2736 XGetWindowProperty (display, XtWindow (file_mgr_rec->shell),
2737 wm_state_atom, 0L, (long) BUFSIZ, False,
2738 wm_state_atom, &actual_type, &actual_format,
2739 &nitems, &leftover, (unsigned char **) &wm_state);
2741 /* Write out if iconified our not */
2743 write (fd, "*", strlen ("*"));
2744 write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2745 sprintf (view_number, "%d", view_index);
2746 write (fd, ".", strlen ("."));
2747 write (fd, view_number, strlen (view_number));
2749 (void) write (fd, ".iconify: ", strlen (".iconify: "));
2751 if (wm_state->state == IconicState)
2752 write (fd, "True\n", strlen ("True\n"));
2754 write (fd, "False\n", strlen ("False\n"));
2757 /* Get the workspaces for this dt by accessing the property. */
2759 if (DtWsmGetWorkspacesOccupied (display, XtWindow (file_mgr_rec->shell),
2760 &ws_presence, &num_workspaces) == Success)
2762 write (fd, "*", strlen ("*"));
2763 write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2764 (void) write (fd, ".", strlen ("."));
2765 (void) write (fd, view_number, strlen (view_number));
2766 (void) write (fd, ".workspace: ", strlen (".workspace: "));
2769 for (j = 0; j < num_workspaces; j++)
2771 if (j != 0) (void) write (fd, "*", strlen ("*"));
2772 workspace_name = XGetAtomName (display, ws_presence[j]);
2773 (void) write (fd, workspace_name, strlen (workspace_name));
2774 XtFree ((char *) workspace_name);
2778 (void) write (fd, "\n", strlen ("\n"));
2779 XFree((char *)ws_presence);
2783 /* Call the encapsulation mechanism to write each dialog */
2786 _DtWriteDialogData (trashDialogData, fd, name_list);
2788 _DtWriteDialogData ((DialogData *)view_set[i]->dialog_data,
2790 (void) write (fd, "#\n", strlen ("#\n"));
2795 file_mgr_data->title = actualSavedTitle;
2801 * Save off help dialog information for each workspace.
2802 * These are the help dialogs used for the desktop objects.
2804 name_list[1] = WS_LOAD_RES_HEADER;
2805 name_list[2] = workspaceNumber;
2806 name_list[3] = number;
2808 for (i = 0; i < desktop_data->numWorkspaces; i++)
2810 workspaceInfo = desktop_data->workspaceData[i];
2813 * Save number of secondary help dialogs in format:
2814 * *Dtfile.Workspace.<WS#>.secondaryHelpDialogCount: <#>
2816 write(fd, "*", strlen("*"));
2817 write(fd, DTFILE_CLASS_NAME, strlen(DTFILE_CLASS_NAME));
2818 write(fd, WS_RES_HEADER, strlen(WS_RES_HEADER));
2819 sprintf(workspaceNumber, "%d", i);
2820 write(fd, workspaceNumber, strlen(workspaceNumber));
2821 write(fd, SEC_HELP_RES_HEADER, strlen(SEC_HELP_RES_HEADER));
2822 sprintf(view_number, "%d", workspaceInfo->secondaryHelpDialogCount);
2823 write(fd, view_number, strlen(view_number));
2824 write (fd, "\n#\n", strlen ("\n#\n"));
2826 /* Save each of the secondary help dialogs */
2827 for (j = 0; j < workspaceInfo->secondaryHelpDialogCount; j++)
2829 sprintf(number, "%d", j + 1);
2830 _DtWriteDialogData(workspaceInfo->secondaryHelpDialogList[j],
2834 /* Save the primary help dialog window */
2835 if (workspaceInfo->primaryHelpDialog)
2837 sprintf(number, "%d", 0);
2838 _DtWriteDialogData(workspaceInfo->primaryHelpDialog,
2841 write (fd, "#\n", strlen ("#\n"));
2845 /* Re-able message box display flag after save session */
2846 message_display_enabled = True;
2854 * Given a directory name, this function will see if a view of the parent
2855 * directory is open; if so, then it will update the icon representing
2856 * this icon, in the parent view, so that it is drawn as 'open'. This
2857 * function must only be called if openDirType == NEW.
2863 char * directory_name)
2865 FileViewData * file_view_data = NULL;
2866 DesktopRec *desktopWindow;
2874 char *icon_name, *new_file_type_name, *file_type_name;
2877 /* if directory_name is passed in a NULL, we want to go through all
2878 existing open directories and check to see if there are any open
2879 directories in each of them. This is used at the end of OpenNewView
2880 and the end of ShowNewDirectory */
2881 if (directory_name == NULL)
2883 for (i = 0; i < view_count; i++)
2885 dd = (DialogData *) view_set[i]->dialog_data;
2886 fmd = (FileMgrData *) dd->data;
2888 for(j = 0; j < fmd->directory_count; j++)
2890 ForceMyIconOpen(view_set[i]->host_name,
2891 fmd->directory_set[j]->name);
2897 parent = _DtPName(directory_name);
2898 fname = DName(directory_name);
2900 /* first lets check to see if the directory is open in one of the
2901 open file manager views */
2902 for (i = 0; i < view_count; i++)
2904 dd = (DialogData *) view_set[i]->dialog_data;
2905 fmd = (FileMgrData *) dd->data;
2907 /* loop through until we find the file_view_data structure for the
2908 directory to force open */
2909 if (strcmp(host_name, view_set[i]->host_name) == 0)
2911 for(j = 0; j < fmd->directory_count; j++)
2913 if (strcmp(parent, fmd->directory_set[j]->name) == 0)
2915 for (k = 0; k < fmd->directory_set[j]->file_count; k++)
2917 file_view_data = fmd->directory_set[j]->file_view_data[k];
2918 if (strcmp(file_view_data->file_data->file_name, fname) == 0)
2920 file_view_data = NULL;
2929 fmd = (FileMgrData *)(((DirectorySet *)file_view_data->directory_set)->
2932 file_type_name = file_view_data->file_data->logical_type;
2934 if(fmd->view != BY_NAME)
2935 BuildAndShowIconName(file_type_name, fmd->view,
2936 fmd->show_type, file_view_data->widget);
2940 /* now we need to check to see if the directory being opened has a
2941 representation on the Desktop */
2942 for(i = 0; i < desktop_data->numIconsUsed; i++)
2946 desktopWindow = desktop_data->desktopWindows[i];
2947 file_view_data = desktopWindow->file_view_data;
2949 sprintf(buf, "%s/%s", desktopWindow->dir_linked_to,
2950 desktopWindow->file_name);
2951 DtEliminateDots (buf);
2953 if (strcmp(buf, directory_name) == 0 &&
2954 strcmp(desktopWindow->host, host_name) == 0)
2956 file_type_name = file_view_data->file_data->logical_type;
2957 if(desktopIconType == LARGE)
2958 BuildAndShowIconName(file_type_name, BY_NAME_AND_ICON,
2959 SINGLE_DIRECTORY, desktopWindow->iconGadget);
2961 BuildAndShowIconName(file_type_name, BY_NAME_AND_SMALL_ICON,
2962 SINGLE_DIRECTORY, desktopWindow->iconGadget);
2970 /************************************************************************
2973 * Open the file as a resource data base, and use the data to
2974 * create a set of File Manager views.
2976 ************************************************************************/
2981 int type_of_restore,
2984 static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL, NULL,
2987 XrmName xrm_name[10];
2988 XrmRepresentation rep_type;
2991 char * full_path = NULL;
2992 Boolean status=False;
2996 int num_sec_help_dialogs;
2999 DialogData * dialogData;
3000 struct stat stat_buf;
3003 /* Build the session path if we need to.
3004 * (e.g. When using the -session option)
3006 if (type_of_restore == NORMAL_RESTORE)
3008 status = DtSessionRestorePath(toplevel, &full_path, path);
3013 if (stat(full_path, &stat_buf) != 0)
3015 char *tmpStr, *msg, *title;
3017 tmpStr = GETMESSAGE(18, 18, "Could not open the session file.");
3018 msg = XtNewString(tmpStr);
3019 title = XtNewString((GETMESSAGE(21,39,"File Open Error")));
3020 _DtMessage (toplevel, title, msg, NULL, HelpRequestCB);
3028 path = XtNewString(full_path);
3031 /* This prevents the encapsulator from placing the dialogs */
3032 disableDialogAutoPlacement = True;
3034 /* Open the file as a resource database and query it to */
3035 /* get the previously saved view count. */
3037 db = XrmGetFileDatabase (path);
3039 if (type_of_restore == NORMAL_RESTORE)
3041 /* first find out if it should show the file system */
3042 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3043 xrm_name [1] = XrmStringToQuark ("showFilesystem");
3045 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3047 if ((temp = (char *) value.addr) != NULL &&
3048 strcmp (temp, "True") == 0)
3050 showFilesystem = True;
3053 showFilesystem = False;
3056 showFilesystem = True;
3058 /* find out if it should be in restricted mode */
3059 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3060 xrm_name [1] = XrmStringToQuark ("restrictMode");
3062 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3064 if ((temp = (char *) value.addr) != NULL &&
3065 strcmp (temp, "True") == 0)
3067 restrictMode = True;
3070 restrictMode = False;
3073 restrictMode = False;
3075 /* find out openFolder mode */
3076 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3077 xrm_name [1] = XrmStringToQuark ("openFolder");
3079 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3081 if ((temp = (char *) value.addr) != NULL &&
3082 strcmp (temp, "NEW") == 0)
3087 openDirType = CURRENT;
3090 openDirType = CURRENT;
3093 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3094 xrm_name [1] = XrmStringToQuark ("view_count");
3097 /* Load standard dtfile views */
3098 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3100 num_views = atoi (value.addr);
3102 LoadViews(num_views, db, NULL, directory, special_restricted, 0);
3105 /* Restore any desktop help dialogs */
3106 if (type_of_restore == NORMAL_RESTORE)
3108 for (i = 0; i < desktop_data->numWorkspaces; i++)
3110 sprintf(wsNum, "%d", i);
3111 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3112 xrm_name [1] = XrmStringToQuark (WS_LOAD_RES_HEADER);
3113 xrm_name [2] = XrmStringToQuark (wsNum);
3114 xrm_name [3] = XrmStringToQuark (SEC_LOAD_HELP_RES_HEADER);
3117 /* Load standard dtfile views */
3118 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3120 num_sec_help_dialogs = atoi (value.addr);
3121 if (num_sec_help_dialogs > 0)
3123 desktop_data->workspaceData[i]->secondaryHelpDialogCount =
3124 num_sec_help_dialogs;
3125 desktop_data->workspaceData[i]->secondaryHelpDialogList =
3126 (DialogData **) XtMalloc(sizeof(DialogData *) *
3127 num_sec_help_dialogs);
3129 for (j = 0; j < num_sec_help_dialogs; j++)
3131 name_list[0] = DTFILE_CLASS_NAME;
3132 name_list[1] = WS_LOAD_RES_HEADER;
3133 name_list[2] = wsNum;
3134 name_list[3] = dialogNum;
3135 name_list[4] = NULL;
3136 sprintf(dialogNum, "%d", j + 1);
3138 _DtGetResourceDialogData(help_dialog, db, name_list);
3139 desktop_data->workspaceData[i]->secondaryHelpDialogList[j]=
3141 ShowDTHelpDialog(NULL, i, HYPER_HELP_DIALOG,
3142 dialogData, NULL, NULL, NULL, NULL,
3148 /* Load the primary help dialog */
3149 name_list[0] = DTFILE_CLASS_NAME;
3150 name_list[1] = WS_LOAD_RES_HEADER;
3151 name_list[2] = wsNum;
3152 name_list[3] = dialogNum;
3153 name_list[4] = NULL;
3154 sprintf(dialogNum, "%d", 0);
3155 dialogData = _DtGetResourceDialogData(help_dialog, db, name_list);
3157 /* Keep only if currently posted */
3158 if (!(((HelpData *)dialogData->data)->displayed))
3160 /* Not currently displayed */
3161 _DtFreeDialogData(dialogData);
3164 desktop_data->workspaceData[i]->primaryHelpDialog = dialogData;
3167 ShowDTHelpDialog(NULL, i, MAIN_HELP_DIALOG,
3168 dialogData, NULL, DTFILE_HELP_NAME,
3177 /* Free the Xrm Database */
3178 XrmDestroyDatabase(db);
3179 disableDialogAutoPlacement = False;
3190 extern Tt_message FileCallback();
3191 extern Tt_message SessionCallback();
3193 if ((msg == 0) || tt_is_err( tt_ptr_error( msg ))) {
3198 * Register for notifications on the directory viewed.
3199 * This is done so that requesting apps can notify the
3200 * view if the directory name is changed.
3202 view->pats = ttdt_file_join( view->directory_name, TT_SESSION, 0,
3203 FileCallback, view );
3204 if (tt_is_err( tt_ptr_error( view->pats ))) {
3208 /* Returned patterns automatically get destroyed when msg is destroyed */
3209 ttdt_message_accept( msg, SessionCallback,
3210 _DtGetDialogShell( (DialogData *)view->dialog_data ),
3220 char *directory_name,
3225 XrmName xrm_name[5];
3226 XrmRepresentation rep_type;
3228 static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL };
3229 char view_number[5];
3230 DialogData * dialog_data;
3231 FileMgrData * file_mgr_data;
3233 XClassHint classHints;
3234 char * iconify = NULL;
3235 Boolean iconify_window;
3237 char *title, *tmpTitle;
3239 name_list[1] = view_number;
3240 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3243 /* Get and display view_count views. */
3245 for (i = 0; i < num_views; i++)
3247 struct stat stat_buf;
3249 (void) sprintf (view_number, "%d", i);
3250 xrm_name [1] = XrmStringToQuark (view_number);
3252 /* Get the main dialog data and set up the view */
3254 dialog_data = _DtGetResourceDialogData (file_mgr_dialog, db, name_list);
3255 file_mgr_data = (FileMgrData *) dialog_data->data;
3257 if(file_mgr_data->toolbox && file_mgr_data->title == NULL)
3258 file_mgr_data->title = DtActionLabel("Dtappmgr");
3260 if (stat(file_mgr_data->current_directory, &stat_buf) != 0)
3262 _DtFreeDialogData(dialog_data);
3266 if (trashFileMgrData
3267 && (file_mgr_data->IsTrashCan == True)
3268 && strcmp(file_mgr_data->current_directory, trash_dir) == 0)
3270 trashFileMgrData->view = file_mgr_data->view;
3271 trashFileMgrData->order = file_mgr_data->order;
3272 trashFileMgrData->direction = file_mgr_data->direction;
3273 trashFileMgrData->positionEnabled = file_mgr_data->positionEnabled;
3274 trashFileMgrData->preferences = file_mgr_data->preferences;
3275 file_mgr_data->preferences = NULL;
3276 _DtFreeDialogData(dialog_data);
3280 /* Increment the view list size if necessary and add directory to list */
3282 if (view_count == view_set_size)
3284 view_set_size += 10;
3286 (View **) XtRealloc ((char *)view_set,
3287 sizeof (View **) * view_set_size);
3289 view_set[view_count] = (View *) XtMalloc (sizeof (View));
3290 view_set[view_count]->dialog_data = (XtPointer) dialog_data;
3291 view_set[view_count]->msg = 0;
3292 view_set[view_count]->pats = 0;
3294 if(restoreType == TOOL_RESTORE)
3295 file_mgr_data->toolbox = True;
3297 if(directory_name == NULL)
3299 view_set[view_count]->host_name = XtNewString (file_mgr_data->host);
3300 view_set[view_count]->directory_name =
3301 XtNewString (file_mgr_data->current_directory);
3305 XtFree(file_mgr_data->current_directory);
3306 file_mgr_data->current_directory = NULL;
3307 XtFree(file_mgr_data->restricted_directory);
3308 file_mgr_data->restricted_directory = NULL;
3310 view_set[view_count]->directory_name = XtNewString(directory_name);
3311 XtFree((char *)file_mgr_data->selection_list);
3312 file_mgr_data->selection_list = NULL;
3313 if(host_name == NULL)
3315 view_set[view_count]->host_name = XtNewString (file_mgr_data->host);
3316 file_mgr_data->current_directory = XtNewString(directory_name);
3318 file_mgr_data->restricted_directory =
3319 XtNewString(directory_name);
3321 file_mgr_data->restricted_directory =
3326 view_set[view_count]->host_name = XtNewString (host_name);
3327 XtFree(file_mgr_data->host);
3328 file_mgr_data->host = XtNewString(host_name);
3329 file_mgr_data->current_directory = XtNewString(directory_name);
3330 if(special_view && special_restricted != NULL)
3331 file_mgr_data->restricted_directory =
3332 XtNewString(special_restricted);
3334 file_mgr_data->restricted_directory = NULL;
3336 FileMgrBuildDirectories (file_mgr_data,
3337 view_set[view_count]->host_name, directory_name);
3340 /* Get the workspace set the view is contained in */
3341 /* and set the property for the view just created */
3343 xrm_name [2] = XrmStringToQuark ("workspace");
3346 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3348 /* Make sure we have some valid workspaces names to work with */
3350 /* value.addr should = NULL if no workspace names */
3351 workspaces = (char *) value.addr;
3354 /* we have no workspace resource so use default */
3357 /* Get and set whether the view is iconic */
3359 xrm_name [2] = XrmStringToQuark ("iconify");
3362 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3364 /* If there is an iconify resource and its value is True, */
3365 /* then mark the window as iconified. */
3367 if ((iconify = (char *) value.addr) != NULL &&
3368 strcmp (iconify, "True") == 0)
3370 iconify_window = True;
3374 iconify_window = False;
3377 iconify_window = False;
3379 if(file_mgr_data->positionEnabled == RANDOM_ON &&
3380 (file_mgr_data->object_positions == NULL))
3381 LoadPositionInfo(file_mgr_data);
3383 /* Call _DtShowDialog to create and manage the new window */
3385 tmpTitle = file_mgr_data->title;
3386 title = file_mgr_data->title = _DtBuildFMTitle(file_mgr_data);
3388 XtFree(special_title);
3389 special_title = XtNewString(title);
3391 classHints.res_name = title;
3392 classHints.res_class = DTFILE_CLASS_NAME;
3394 _DtShowDialog (NULL, NULL, NULL, dialog_data, NULL, NULL,
3395 RemoveTextFields, NULL, workspaces, iconify_window,
3396 special_view, title, &classHints);
3399 file_mgr_data->title = tmpTitle;
3402 ViewAccept( view_set[view_count], msg );
3409 if (openDirType == NEW)
3410 ForceMyIconOpen(file_mgr_data->host, NULL);
3414 /************************************************************************
3418 ************************************************************************/
3421 char current_directory[] )
3426 /* Open a pwd process and read the current working directory */
3427 /* from it. If the open fails or a read fails, then display */
3428 /* the users home directory. */
3430 pwd_file = popen ("pwd", "r");
3433 if (pwd_file != NULL)
3438 if (fread (¤t_directory[i], sizeof(char), 1, pwd_file) != 1)
3446 if (current_directory[i] == '\n')
3452 (void) pclose (pwd_file);
3453 current_directory[i] = '\0';
3457 /************************************************************************
3460 * Given a string that contains a single or set of host:path
3461 * specifications, parse out each host:path, validate it as
3462 * a accessible directory, and call a function to create a
3463 * file manager view of the directory.
3465 ************************************************************************/
3469 char *directory_set,
3476 /* Loop the the directory set string until all of */
3477 /* the path specifications have be parsed. */
3481 separator = DtStrchr (directory_set, ',');
3482 if (separator != NULL)
3485 _DtPathFromInput(directory_set, NULL, &host, &path);
3489 GetNewView (host, path, type, NULL, 0);
3493 char *tmpStr, *errTitle, *errMsg, *dmsg;
3495 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
3496 errTitle = XtNewString(tmpStr);
3497 tmpStr = GETMESSAGE(18, 38, "Invalid folder specification, %s");
3498 errMsg = XtNewString(tmpStr);
3499 dmsg = XtMalloc(strlen(errMsg)+strlen(directory_set)+1);
3500 sprintf(dmsg, errMsg, directory_set);
3501 _DtMessage(toplevel, errTitle, dmsg, NULL, HelpRequestCB);
3508 /* Free up the unique host and directory names */
3509 /* that were allocated. */
3511 XtFree ((char *) host);
3512 XtFree ((char *) path);
3514 /* Set the starting position of the next host:path */
3516 if (separator != NULL)
3517 directory_set = separator + 1;
3526 /************************************************************************
3529 * Given a directory name, generate a new view for the directory.
3531 ************************************************************************/
3535 char *directory_name,
3537 WindowPosition *position,
3540 DialogData * dialog_data;
3541 DialogInstanceData * instance_data;
3542 FileMgrData * file_mgr_data;
3544 FileMgrRec * file_mgr_rec;
3545 char * real_directory_name;
3547 XClassHint classHints;
3548 char *title, *tmpTitle;
3549 struct stat stat_buf;
3551 char *errMsg = NULL;
3553 DtEliminateDots( directory_name );
3555 if (stat(directory_name, &stat_buf) == 0)
3557 if ((stat_buf.st_mode & S_IFMT) != S_IFDIR)
3559 tmpStr = GETMESSAGE(18, 19,
3560 "The folder specification,\n%s\nis not a folder.");
3561 errMsg = XtNewString(tmpStr);
3566 tmpStr = GETMESSAGE(18, 20,
3567 "The folder specification,\n%s\ndoes not exist.");
3568 errMsg = XtNewString(tmpStr);
3575 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
3576 title = XtNewString(tmpStr);
3577 dmsg = XtMalloc(strlen(errMsg) +
3578 strlen(directory_name) + 1);
3579 sprintf(dmsg, errMsg, directory_name);
3580 _DtMessage(toplevel, title, dmsg, NULL, HelpRequestCB);
3589 * Special case: When opening any of the special desktop directory
3590 * icons (Home, Remote Systems, etc), we want to display the correct
3591 * path (i.e. $HOME instead of $HOME/.dt/Desktop/Home). So ... we'll
3592 * do the remap here.
3594 real_directory_name = directory_name;
3596 if(openDirType == NEW || (strcmp(real_directory_name, desktop_dir) == 0))
3598 for(i = 0; i < view_count; i++)
3600 if((strcmp(real_directory_name, view_set[i]->directory_name) == 0 &&
3601 (strcmp(host_name, view_set[i]->host_name) == 0))
3606 Screen *currentScreen;
3609 dialog_data = (DialogData *) view_set[i]->dialog_data;
3610 file_mgr_data = (FileMgrData *) dialog_data->data;
3611 file_mgr_rec = (FileMgrRec *) file_mgr_data->file_mgr_rec;
3613 screen = XDefaultScreen(display);
3614 currentScreen = XScreenOfDisplay(display, screen);
3615 rootWindow = RootWindowOfScreen(currentScreen);
3617 /* Get the current Workspace */
3618 if (DtWsmGetCurrentWorkspace(display, rootWindow, &pCurrent)
3621 Atom * ws_presence = NULL;
3622 unsigned long num_workspaces = 0;
3625 if (DtWsmGetWorkspacesOccupied(display,
3626 XtWindow(file_mgr_rec->shell), &ws_presence,
3627 &num_workspaces) == Success)
3629 /* Already in this workspace? */
3630 for (k = 0; k < num_workspaces; k++)
3632 if (ws_presence[k] == pCurrent)
3636 if (k >= num_workspaces)
3638 /* Add to the workspace */
3639 ws_presence = (Atom *) XtRealloc((char *)ws_presence,
3640 sizeof (Atom) * (num_workspaces + 1));
3642 ws_presence[num_workspaces] = pCurrent;
3643 DtWsmSetWorkspacesOccupied(display,
3644 XtWindow(file_mgr_rec->shell),
3645 ws_presence, num_workspaces + 1);
3647 XFree((char *)ws_presence);
3651 /* Change the hints to reflect the current workspace */
3652 DtWsmSetWorkspacesOccupied(display,
3653 XtWindow(file_mgr_rec->shell),
3658 /* must map the window to catch iconified windows */
3659 /* a XtPopup will not catch it */
3660 XtMapWidget(file_mgr_rec->shell);
3661 XRaiseWindow(display, XtWindow(file_mgr_rec->shell));
3663 /* announce activity */
3666 msg = tt_pnotice_create(TT_SESSION, "DtActivity_Began");
3667 tt_message_send(msg);
3668 tttk_message_destroy(msg);
3676 /* If in novice mode, force the icon for this dir to the 'Open' state */
3677 if (openDirType == NEW)
3678 ForceMyIconOpen(host_name, directory_name);
3680 /* Increment the list size if necessary. */
3682 if (view_count == view_set_size)
3684 view_set_size += 10;
3686 (View **) XtRealloc ((char *)view_set,
3687 sizeof (View **) * view_set_size);
3690 view_set[view_count] = (View *) XtMalloc (sizeof (View));
3691 view_set[view_count]->msg = 0;
3692 view_set[view_count]->pats = 0;
3694 if (initiating_view != NULL)
3695 dialog_data = _DtGetDefaultDialogData (file_mgr_dialog);
3699 char full_path[MAX_PATH + 1];
3702 tmp_path = _DtCreateDtDirs(display);
3704 sprintf(full_path, "%s/%s", tmp_path, TOOL_SETTINGS_FILENAME);
3706 sprintf(full_path, "%s/%s", tmp_path, HOME_SETTINGS_FILENAME);
3708 db = XrmGetFileDatabase (full_path);
3713 restoreType = TOOL_RESTORE;
3714 LoadViews(1, db, NULL, directory_name, type, msg);
3718 restoreType = HOME_RESTORE;
3719 LoadViews(1, db, host_name, directory_name, NULL, msg);
3723 * Free the Xrm Database
3725 XrmDestroyDatabase(db);
3726 dialog_data = (DialogData *)view_set[view_count - 1]->dialog_data;
3727 file_mgr_data = (FileMgrData *) dialog_data->data;
3730 application_args.tool_width = file_mgr_data->width;
3731 application_args.tool_height = file_mgr_data->height;
3735 application_args.dir_width = file_mgr_data->width;
3736 application_args.dir_height = file_mgr_data->height;
3738 if(file_mgr_data->find != NULL &&
3739 file_mgr_data->current_directory != NULL)
3741 DialogData * dialog_data;
3742 FindData * find_data;
3744 dialog_data = (DialogData *)file_mgr_data->find;
3745 find_data = (FindData *)dialog_data->data;
3747 XtFree(find_data->directories);
3748 if(file_mgr_data->restricted_directory == NULL)
3751 find_data->directories = XtNewString(users_home_dir);
3753 find_data->directories =
3754 XtNewString(file_mgr_data->current_directory);
3758 if(strcmp(file_mgr_data->current_directory,
3759 file_mgr_data->restricted_directory) == 0)
3760 find_data->directories = XtNewString("/");
3762 find_data->directories =
3763 XtNewString(file_mgr_data->current_directory +
3764 strlen(file_mgr_data->restricted_directory));
3768 /* If in novice mode, force the icon for all the dir's to the
3770 if (openDirType == NEW)
3771 ForceMyIconOpen(host_name, NULL);
3773 return((DialogData *)view_set[view_count - 1]->dialog_data);
3776 dialog_data = _DtGetDefaultDialogData (file_mgr_dialog);
3778 view_set[view_count]->dialog_data = (XtPointer) dialog_data;
3779 file_mgr_data = (FileMgrData *) dialog_data->data;
3781 /* Adjust the view settings if this new view was created */
3782 /* because of an action on a previous view. */
3784 if (initiating_view != NULL)
3786 FileMgrPropagateSettings ((FileMgrData *)initiating_view, file_mgr_data);
3787 /* force new window to come up in flat mode */
3788 file_mgr_data->show_type =
3789 ((PreferencesData *)file_mgr_data->preferences->data)->show_type =
3791 file_mgr_data->view = file_mgr_data->view_single;
3794 /* Call the FileMgr dialog to build up its directory set for */
3795 /* the directory name. */
3796 FileMgrBuildDirectories (file_mgr_data, host_name, real_directory_name);
3800 PreferencesData *preferences_data;
3802 file_mgr_data->toolbox = True;
3803 file_mgr_data->width = application_args.tool_width;
3804 file_mgr_data->height = application_args.tool_height;
3806 /* we want to default for the toolboxes (i.e. Application Manager) to
3807 * look different from a normal File Manager view. Let's turn off
3808 * the iconic_path, current_directory, and status_line.
3810 file_mgr_data->show_iconic_path = False;
3811 file_mgr_data->show_current_dir = False;
3813 file_mgr_data->show_status_line = True;
3816 preferences_data = (PreferencesData *)file_mgr_data->preferences->data;
3817 preferences_data->show_iconic_path = file_mgr_data->show_iconic_path;
3818 preferences_data->show_current_dir = file_mgr_data->show_current_dir;
3819 preferences_data->show_status_line = file_mgr_data->show_status_line;
3823 file_mgr_data->toolbox = False;
3824 file_mgr_data->width = application_args.dir_width;
3825 file_mgr_data->height = application_args.dir_height;
3829 if(file_mgr_data->find != NULL && file_mgr_data->current_directory != NULL)
3831 DialogData * dialog_data;
3832 FindData * find_data;
3834 dialog_data = (DialogData *)file_mgr_data->find;
3835 find_data = (FindData *)dialog_data->data;
3837 XtFree(find_data->directories);
3838 if(file_mgr_data->restricted_directory == NULL)
3841 find_data->directories = XtNewString(users_home_dir);
3843 find_data->directories =
3844 XtNewString(file_mgr_data->current_directory);
3848 if(strcmp(file_mgr_data->current_directory,
3849 file_mgr_data->restricted_directory) == 0)
3850 find_data->directories = XtNewString("/");
3852 find_data->directories =
3853 XtNewString(file_mgr_data->current_directory +
3854 strlen(file_mgr_data->restricted_directory));
3858 view_set[view_count]->host_name = XtNewString (file_mgr_data->host);
3859 view_set[view_count]->directory_name =
3860 XtNewString (file_mgr_data->current_directory);
3862 /* Load default position info, or inherit, if appropriate */
3863 if ((fmd = (FileMgrData *)initiating_view) &&
3864 (strcmp(fmd->host, host_name) == 0) &&
3865 (strcmp(fmd->current_directory, real_directory_name) == 0))
3867 InheritPositionInfo(fmd, file_mgr_data);
3870 LoadPositionInfo(file_mgr_data);
3873 /* Get the dialog displayed. */
3876 instance_data = (DialogInstanceData *) dialog_data->data;
3877 instance_data->x = position->x;
3878 instance_data->y = position->y;
3879 instance_data->displayed = True; /* @@@ Hack! without this,
3880 _DtShowDialog will ignore
3881 our position info */
3884 tmpTitle = file_mgr_data->title;
3885 title = file_mgr_data->title = _DtBuildFMTitle(file_mgr_data);
3887 XtFree(special_title);
3888 special_title = XtNewString(title);
3890 classHints.res_name = title;
3891 classHints.res_class = DTFILE_CLASS_NAME;
3892 initiating_view = NULL;
3894 _DtShowDialog (NULL, NULL, NULL, dialog_data, NULL, NULL, RemoveTextFields,
3895 NULL, NULL, False, special_view, title, &classHints);
3898 file_mgr_data->title = tmpTitle;
3901 ViewAccept( view_set[view_count], msg );
3907 /* If in novice mode, force the icon for all the dir's to the 'Open' state */
3908 if (openDirType == NEW)
3909 ForceMyIconOpen(host_name, NULL);
3911 return(dialog_data);
3917 /************************************************************************
3920 * Update the view set array when a view is closed.
3922 ************************************************************************/
3926 DialogData *dialog_data )
3930 FileMgrData * file_mgr_data;
3931 DialogData * tmpDialog_data;
3932 FileMgrRec * file_mgr_rec;
3933 XmManagerWidget file_window;
3934 char *directory_name = NULL;
3935 char *host_name = NULL;
3937 if(dialog_data == trashDialogData)
3939 CloseTrash(NULL, NULL, NULL);
3943 for (i = 0; i < view_count; i++)
3945 if (dialog_data == (DialogData *) (view_set[i]->dialog_data))
3947 tmpDialog_data = (DialogData *) (view_set[i]->dialog_data);
3948 file_mgr_data = (FileMgrData *)tmpDialog_data->data;
3950 directory_name = (char *)XtMalloc( strlen(view_set[i]->directory_name) + 1);
3951 strcpy(directory_name, view_set[i]->directory_name);
3952 host_name = (char *)XtMalloc( strlen(view_set[i]->host_name) + 1);
3953 strcpy(host_name, view_set[i]->host_name);
3955 if (view_set[i]->msg != 0) {
3956 if (view_set[i]->pats != 0) {
3957 ttdt_file_quit( view_set[i]->pats, 0 );
3958 view_set[i]->pats = 0;
3960 tt_message_reply( view_set[i]->msg );
3961 tttk_message_destroy( view_set[i]->msg );
3962 view_set[i]->msg = 0;
3965 XtFree ((char *) view_set[i]->directory_name);
3966 XtFree ((char *) view_set[i]->host_name);
3967 XtFree ((char *) view_set[i]);
3970 for (j = i; j < view_count - 1; j++)
3971 view_set[j] = view_set[j + 1];
3975 _DtHideDialog (dialog_data, True);
3977 file_mgr_rec = (FileMgrRec *)file_mgr_data->file_mgr_rec;
3978 file_window = (XmManagerWidget)file_mgr_rec->file_window;
3979 /* For next time, unmanage all the icons */
3980 XtUnmanageChildren(file_window->composite.children,
3981 file_window->composite.num_children);
3983 if(PositionFlagSet(file_mgr_data))
3984 SavePositionInfo(file_mgr_data);
3986 /* If it is an Application Manager view, then no point in
3987 caching this dialog, so free it */
3989 if(file_mgr_data->toolbox)
3990 _DtFreeDialog(dialog_data);
3992 _DtFreeDialogData (dialog_data);
3999 /* Update the directory cache list to remove unneeded directories. */
4001 UpdateCachedDirectories (view_set, view_count);
4003 if (openDirType == NEW)
4004 ForceMyIconClosed(host_name, directory_name);
4006 XtFree(directory_name);
4013 /************************************************************************
4016 * This function is called when a view may be changing its
4017 * current directory. It updates the view_set list to the
4018 * new host and directory.
4020 ************************************************************************/
4024 XtPointer file_mgr_data,
4025 char *old_host_name,
4026 char *new_host_name,
4027 char *old_directory_name,
4028 char *new_directory_name )
4033 /* See if the directory is one being viewed */
4035 for (i = 0; i < view_count; i++)
4037 if (((DialogData *) (view_set[i]->dialog_data))->data == file_mgr_data)
4039 if (strcmp (old_host_name, view_set[i]->host_name) == 0 &&
4040 strcmp (old_directory_name, view_set[i]->directory_name) == 0)
4042 XtFree ((char *) view_set[i]->host_name);
4043 view_set[i]->host_name = XtNewString (new_host_name);
4045 XtFree ((char *) view_set[i]->directory_name);
4046 view_set[i]->directory_name = XtNewString (new_directory_name);
4052 /* Update the directory cache list to remove unneeded directories. */
4054 UpdateCachedDirectories (view_set, view_count);
4059 /************************************************************************
4062 * Dispatch ToolTalk events to internal handlers.
4064 ************************************************************************/
4066 static Tt_callback_action
4075 op = tt_message_op( msg );
4076 status = tt_ptr_error( op );
4077 if ((status != TT_OK) || (op == 0)) {
4078 /* Let tttk_Xt_input_handler() Do The Right Thing */
4079 return TT_CALLBACK_CONTINUE;
4081 if (strcmp( op, "DtTypes_Reloaded" ) == 0) {
4083 } else if (strcmp( op, "XSession_Ending" ) == 0) {
4084 if( emptyTrashOnExit )
4088 return TT_CALLBACK_CONTINUE;
4091 tttk_message_destroy( msg );
4092 return TT_CALLBACK_PROCESSED;
4095 /************************************************************************
4098 * Dispatch ToolTalk requests to internal handlers.
4100 ************************************************************************/
4111 op = tt_message_op( msg );
4112 status = tt_ptr_error( op );
4113 if ((status != TT_OK) || (op == 0)) {
4114 /* Let tttk_Xt_input_handler() Do The Right Thing */
4115 return TT_CALLBACK_CONTINUE;
4117 if (strcmp( op, "DtFileSession_Run" ) == 0) {
4118 ViewSessionHandler( msg );
4119 } else if (strcmp( op, "DtFolder_Show" ) == 0) {
4120 ViewDirectoryHandler( msg );
4121 } else if (strcmp( op, "DtHome_Show" ) == 0) {
4122 ViewHomeDirectoryHandler( msg );
4123 } else if (strcmp( op, "DtTools_Show" ) == 0) {
4124 ViewToolsDirectoryHandler( msg );
4125 } else if (strcmp( op, "DtTrash_Show" ) == 0) {
4126 TrashDisplayHandler( msg );
4127 } else if (strcmp( op, "DtTrash_Remove" ) == 0) {
4128 TrashRemoveHandler( msg );
4129 } else if (strcmp( op, "DtTrash_Empty" ) == 0) {
4130 TrashEmptyHandler( msg );
4131 } else if (strcmp( op, "DtTrash_File" ) == 0) {
4132 TrashRemoveNoConfirmHandler( msg );
4133 } else if (strcmp( op, "DtTrash_Restore" ) == 0) {
4134 TrashRestoreHandler( msg );
4135 } else if (strcmp( op, "DtFile_PutOnWorkspace" ) == 0) {
4136 PutOnWorkspaceHandler( msg );
4137 } else if (strcmp( op, "DtFile_Move" ) == 0) {
4138 MoveCopyLinkHandler( msg, MOVE_FILE );
4139 } else if (strcmp( op, "DtFile_Copy" ) == 0) {
4140 MoveCopyLinkHandler( msg, COPY_FILE );
4141 } else if (strcmp( op, "DtFile_Link" ) == 0) {
4142 MoveCopyLinkHandler( msg, LINK_FILE );
4145 return TT_CALLBACK_CONTINUE;
4148 return TT_CALLBACK_PROCESSED;
4154 /************************************************************************
4156 * ViewSessionHandler
4157 * This function is called upon the dt session message
4158 * being received. The name of the session file is extracted
4159 * out of the message and a function is called to create
4160 * a view or set of views described by the file.
4162 ************************************************************************/
4168 char *file = tt_message_file( msg );
4169 tt_message_reply( msg );
4170 tttk_message_destroy( msg );
4172 if (! tt_is_err( tt_ptr_error( file )))
4174 if (view_count == 0 && desktop_data->numIconsUsed == 0)
4176 int session_flag = 0;
4179 session_name = strrchr(file, '/');
4181 LoadDesktopInfo(session_name);
4182 session_flag = RestoreSession (session_name, NORMAL_RESTORE, NULL);
4183 if ((session_flag != 0) && (view_count == 0))
4185 char current_directory[MAX_PATH];
4187 GetPWD(current_directory);
4188 if (current_directory[0] != '\0')
4191 (home_host_name, current_directory, NULL, NULL, 0))
4192 ViewHomeDirectoryHandler (0);
4196 ViewHomeDirectoryHandler (0);
4202 char *tmpStr, *msg, *title;
4204 tmpStr = GETMESSAGE(18, 39, "Cannot start a second File Manager session because a File Manager\nsession is already open on the desktop. If you want to start a new File\nManager session, you must first close all current File Manager windows\nand remove all File Manager objects from the workspaces.");
4205 msg = XtNewString(tmpStr);
4206 title = XtNewString((GETMESSAGE(18,40,"Session Error")));
4207 _DtMessage (toplevel, title, msg, NULL, HelpRequestCB);
4218 /************************************************************************
4220 * ViewDirectoryHandler
4221 * This function is called upon the dt directory message
4222 * being received. The name of the directory is extracted
4223 * out of the message and a function is called to create
4224 * a view of the directory.
4226 ************************************************************************/
4229 ViewDirectoryHandler(
4236 initiating_view = NULL;
4237 msgFile = tt_message_file( msg );
4238 if (tt_is_err( tt_ptr_error( msgFile ))) msgFile = 0;
4242 if(msgFile && strncmp(msgFile, "~", 1) != 0 )
4244 if((strcmp(users_home_dir, "/") != 0) &&
4245 (strncmp(msgFile, users_home_dir, strlen(users_home_dir)-1) != 0))
4247 char *tmpStr, *errTitle, *errMsg, *dmsg;
4249 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
4250 errTitle = XtNewString(tmpStr);
4251 tmpStr = GETMESSAGE(2,20,"You cannot switch to folder:\n\n%s\n\nYou are not allowed to view this folder\nbecause it is a restricted folder.");
4252 errMsg = XtNewString(tmpStr);
4253 dmsg = XtMalloc(strlen(errMsg)+strlen(msgFile)+1);
4254 sprintf(dmsg, errMsg, msgFile);
4255 _DtMessage(toplevel, errTitle, dmsg, NULL, HelpRequestCB);
4262 tt_message_reply( msg );
4263 tttk_message_destroy( msg );
4269 numArgs = tt_message_args_count( msg );
4270 if (tt_is_err( tt_int_error( numArgs ))) numArgs = 0;
4273 special_view = True;
4274 special_treeType = UNSET_VALUE;
4275 special_treeFiles = UNSET_VALUE;
4276 special_viewType = UNSET_VALUE;
4277 special_orderType = UNSET_VALUE;
4278 special_directionType = UNSET_VALUE;
4279 special_randomType = UNSET_VALUE;
4280 special_restricted = NULL;
4281 special_title = NULL;
4282 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4283 for(i = 0; i < numArgs; i++)
4287 vtype = tt_message_arg_type( msg, i );
4288 if ((vtype == 0) || (tt_is_err( tt_ptr_error( vtype )))) {
4291 val = tt_message_arg_val( msg, i );
4292 if(strcmp(vtype, "-title") == 0)
4294 special_title = XtNewString(val);
4296 else if(strcmp(vtype, "-help_volume") == 0)
4298 special_helpVol = XtNewString(val);
4300 if(strcmp(vtype, "-tree") == 0)
4302 DtfileStringToTree(val, &special_treeType);
4304 else if(strcmp(vtype, "-tree_files") == 0)
4306 DtfileStringToTreeFiles(val, &special_treeFiles);
4308 else if(strcmp(vtype, VIEW_HEADER) == 0)
4310 DtfileStringToView(val, &special_viewType);
4312 else if(strcmp(vtype, "-order") == 0)
4314 DtfileStringToOrder(val, &special_orderType);
4316 else if(strcmp(vtype, "-direction") == 0)
4318 DtfileStringToDirection(val, &special_directionType);
4320 else if(strcmp(vtype, "-grid") == 0)
4322 DtfileStringToGrid(val, &special_randomType);
4324 else if(strcmp(vtype, RESTRICTED_HEADER) == 0)
4326 special_restricted = XtNewString(msgFile);
4331 if ((restrictMode) && (!special_restricted))
4335 ptr = strrchr(users_home_dir, '/');
4337 special_restricted = XtNewString(users_home_dir);
4342 else if (restrictMode)
4346 special_view = True;
4347 special_treeType = treeType;
4348 special_treeFiles = treeFiles;
4349 special_viewType = viewType;
4350 special_orderType = orderType;
4351 special_directionType = directionType;
4352 special_randomType = randomType;
4354 ptr = strrchr(users_home_dir, '/');
4356 special_restricted = XtNewString(users_home_dir);
4359 special_title = NULL;
4360 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4364 special_view = False;
4366 OpenDirectories (msgFile, NULL);
4369 tt_message_reply( msg );
4370 tttk_message_destroy( msg );
4376 /************************************************************************
4379 * This function is called upon the dt directory message
4380 * being received. The name of the directory is extracted
4381 * out of the message and a function is called to create
4382 * a view of the directory. This function is passed directly
4383 * to DtActionInvoke to be used as a callback.
4385 ************************************************************************/
4394 DialogData *return_data;
4398 if(root_dir && strncmp(root_dir, "~", 1) != 0 )
4400 if((strcmp(users_home_dir, "/") != 0) &&
4401 (strncmp(root_dir, users_home_dir, strlen(users_home_dir)-1) != 0))
4403 char *tmpStr, *errTitle, *errMsg, *dmsg;
4405 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
4406 errTitle = XtNewString(tmpStr);
4407 tmpStr = GETMESSAGE(2,20,"You cannot switch to folder:\n\n%s\n\nYou are not allowed to view this folder\nbecause it is a restricted folder.");
4408 errMsg = XtNewString(tmpStr);
4409 dmsg = XtMalloc(strlen(errMsg)+strlen(root_dir)+1);
4410 sprintf(dmsg, errMsg, root_dir);
4411 _DtMessage(toplevel, errTitle, dmsg, NULL, HelpRequestCB);
4421 initiating_view = NULL;
4422 special_view = True;
4423 special_treeType = treeType;
4424 special_treeFiles = treeFiles;
4425 special_viewType = viewType;
4426 special_orderType = orderType;
4427 special_directionType = directionType;
4428 special_randomType = randomType;
4431 special_restricted = XtNewString(root_dir);
4434 special_restricted = NULL;
4437 if ((restrictMode) && (!special_restricted))
4441 ptr = strrchr(users_home_dir, '/');
4443 special_restricted = XtNewString(users_home_dir);
4447 special_title = NULL;
4448 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4450 return_data = GetNewView (home_host_name, root_dir, NULL, NULL, msg);
4452 if ((!return_data) && msg)
4454 tt_message_reply(msg);
4455 tttk_message_destroy( msg );
4458 return(return_data);
4463 /************************************************************************
4465 * ViewHomeDirectoryHandler
4466 * This function is called upon the dt home directory message
4467 * being received. The home directory is extracted from the
4468 * users uid and used to open the directory.
4470 ************************************************************************/
4474 ViewHomeDirectoryHandler(
4477 register int i, j, k;
4478 struct passwd * pwInfo;
4481 char full_path[MAX_PATH + 1];
4482 struct stat stat_buf;
4485 /* We have a new view so set initiating_view to null */
4486 initiating_view = NULL;
4488 if ((homeDir = getenv("HOME")) == NULL || strlen (homeDir) == 0)
4490 pwInfo = getpwuid (getuid());
4491 homeDir = pwInfo->pw_dir;
4494 /* Look and see if we have a default environment file present */
4495 tmp_path = _DtCreateDtDirs(display);
4498 if (msg) numArgs = tt_message_args_count(msg);
4499 if (tt_is_err(tt_int_error(numArgs))) numArgs = 0;
4502 special_view = True;
4503 special_treeType = UNSET_VALUE;
4504 special_treeFiles = UNSET_VALUE;
4505 special_viewType = UNSET_VALUE;
4506 special_orderType = UNSET_VALUE;
4507 special_directionType = UNSET_VALUE;
4508 special_randomType = UNSET_VALUE;
4509 special_restricted = NULL;
4510 special_title = NULL;
4511 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4512 for(i = 0; i < numArgs; i++)
4516 vtype = tt_message_arg_type( msg, i );
4517 if ((vtype == 0) || (tt_is_err( tt_ptr_error( vtype )))) {
4520 val = tt_message_arg_val(msg, i);
4521 if(strcmp(vtype, "-title") == 0)
4523 special_title = XtNewString(val);
4525 else if(strcmp(vtype, "-help_volume") == 0)
4527 special_helpVol = XtNewString(val);
4529 if(strcmp(vtype, "-tree") == 0)
4531 DtfileStringToTree(val, &special_treeType);
4533 else if(strcmp(vtype, "-tree_files") == 0)
4535 DtfileStringToTreeFiles(val, &special_treeFiles);
4537 else if(strcmp(vtype, VIEW_HEADER) == 0)
4539 DtfileStringToView(val, &special_viewType);
4541 else if(strcmp(vtype, "-order") == 0)
4543 DtfileStringToOrder(val, &special_orderType);
4545 else if(strcmp(vtype, "-direction") == 0)
4547 DtfileStringToDirection(val, &special_directionType);
4549 else if(strcmp(vtype, "-grid") == 0)
4551 DtfileStringToGrid(val, &special_randomType);
4553 else if(strcmp(vtype, RESTRICTED_HEADER) == 0)
4555 special_restricted = XtNewString(val);
4561 else if (restrictMode)
4565 special_view = True;
4566 special_treeType = treeType;
4567 special_treeFiles = treeFiles;
4568 special_viewType = viewType;
4569 special_orderType = orderType;
4570 special_directionType = directionType;
4571 special_randomType = randomType;
4573 ptr = strrchr(users_home_dir, '/');
4575 special_restricted = XtNewString(users_home_dir);
4578 special_title = NULL;
4579 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4582 special_view = False;
4584 if (tmp_path == NULL)
4585 OpenDirectories (homeDir, NULL);
4588 sprintf(full_path, "%s/%s", tmp_path, HOME_SETTINGS_FILENAME);
4591 /* Stat the file and make sure its there */
4594 if (stat (full_path, &stat_buf) == 0 && numArgs < 1)
4596 restoreType = HOME_RESTORE;
4597 RestoreSession(full_path, HOME_RESTORE, NULL);
4598 restoreType = NORMAL_RESTORE;
4604 ptr = strrchr(users_home_dir, '/');
4606 strcpy(full_path, users_home_dir);
4608 OpenDirectories (full_path, NULL);
4611 else if (numArgs < 1 && stat (full_path, &stat_buf) == 0)
4613 restoreType = HOME_RESTORE;
4614 RestoreSession(full_path, HOME_RESTORE, NULL);
4615 restoreType = NORMAL_RESTORE;
4621 ptr = strrchr(users_home_dir, '/');
4623 if( ptr != users_home_dir )
4626 strcpy(full_path, users_home_dir);
4629 OpenDirectories (full_path, NULL);
4635 tt_message_reply(msg);
4636 tttk_message_destroy(msg);
4640 /************************************************************************
4642 * ViewToolsDirectroyHandler
4643 * This function is called upon the dt tools message
4644 * being received. The names of the tools directories are
4645 * retrieved from libXue, a view is created and the change
4646 * directory dialog for the view is displayed with the
4647 * set of directories contained in the list.
4649 ************************************************************************/
4652 ViewToolsDirectoryHandler(
4656 char * tmp_path = NULL;
4657 char * tool_dir = NULL;
4658 char * msgFile = NULL;
4661 /* We have a new view so set initiating_view to null */
4662 initiating_view = NULL;
4664 /* Look and see if we have a default environment file present */
4665 tmp_path = _DtCreateDtDirs(display);
4667 if (msg) msgFile = tt_message_file(msg);
4668 if (tt_is_err(tt_ptr_error(msgFile))) msgFile = 0;
4670 if (msg) numArgs = tt_message_args_count(msg);
4671 if (tt_is_err(tt_int_error( numArgs ))) numArgs = 0;
4677 char *link_point = NULL;
4678 char *root_toolbox = NULL;
4679 char *user_install_point = NULL;
4681 special_view = True;
4682 special_treeType = treeType;
4683 special_treeFiles = treeFiles;
4684 special_viewType = viewType;
4685 special_orderType = orderType;
4686 special_directionType = directionType;
4687 special_randomType = randomType;
4688 special_restricted = XtNewString(msgFile);
4689 special_title = NULL;
4690 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4691 for(i = 0; i < numArgs; i++)
4695 vtype = tt_message_arg_type( msg, i );
4696 if ((vtype == 0) || (tt_is_err( tt_ptr_error( vtype )))) {
4699 val = tt_message_arg_val( msg, i );
4700 if(strcmp(vtype, "-title") == 0)
4702 special_title = XtNewString(val);
4704 else if(strcmp(vtype, "-help_volume") == 0)
4706 special_helpVol = XtNewString(val);
4708 else if(strcmp(vtype, "-root") == 0)
4710 root_toolbox = XtNewString(val);
4712 else if(strcmp(vtype, "-common_link_point") == 0)
4714 link_point = XtNewString(val);
4716 else if(strcmp(vtype, "-user_install_point") == 0)
4718 user_install_point = XtNewString(val);
4720 if(strcmp(vtype, "-tree") == 0)
4722 DtfileStringToTree(val, &special_treeType);
4724 else if(strcmp(vtype, "-tree_files") == 0)
4726 DtfileStringToTreeFiles(val, &special_treeFiles);
4728 else if(strcmp(vtype, VIEW_HEADER) == 0)
4730 DtfileStringToView(val, &special_viewType);
4732 else if(strcmp(vtype, "-order") == 0)
4734 DtfileStringToOrder(val, &special_orderType);
4736 else if(strcmp(vtype, "-direction") == 0)
4738 DtfileStringToDirection(val, &special_directionType);
4740 else if(strcmp(vtype, "-grid") == 0)
4742 DtfileStringToGrid(val, &special_randomType);
4744 else if(strcmp(vtype, RESTRICTED_HEADER) == 0)
4751 /* Due to the use of tooltalk messaging, app manager objects
4752 that are dragged either to the desktop or to the front
4753 panel are identified by their fully resolved names (ie.
4754 /usr/dt/appconfig/appmanager/$LANG/.... as opposed to
4755 /var/dt/appconfig/appmanager/$DTUSERSESSION/....). In order
4756 for the File Manager to treat these objects as links existing
4757 in the /var/.... directory, we use the following ugly code:
4759 1. Search the incoming path for $LANG (if you can't find
4760 $LANG, try C since this is the default).
4761 2. Concatenate the path following $LANG to the path for the
4762 root toolbox (this comes in with the tooltalk message
4763 so that we don't have to hardcode it).
4764 3. Call OpenDirectories with the new path that you have
4765 created and with the root toolbox path as the restricted
4768 This problem is further complicated by:
4769 1. Users traversing into APPGROUPs.
4770 2. Users opening the parent folders for workspace APPGROUPs.
4772 For situation 1, File Manager kicks the user into the App Manager
4773 if he/she traverses into an APPGROUP. BUT we don't want to
4774 make modifications to the path as we do above.
4775 So, if there is nothing following $LANG or if we can't find
4777 (ie. /var/dt/appconfig/appmanager/$DTUSERSESSION), call
4778 OpenDirectories with no parameter changes.
4780 For situation 2, File Manager is unable to distinguish between
4781 workspace objects dragged from /usr/.... or /var/...., so
4782 the parent folder for all workspace APPGROUPS is considered to
4783 be in the /var path. In addition to the OpenAppGroup action,
4784 there is an OpenParentAppGroup action which also triggers
4785 ViewToolsDirectoryHandler but sends in an additional
4786 parameter (user_install_point).
4787 If we know that this msg was generated by the OpenParentAppGroup
4789 AND nothing follows $LANG.
4790 Modify the parameters as above.
4791 OR we can't find $LANG but we can find the user_install_point
4792 (user's personal appgroup path).
4793 Concatenate the path following .dt/appmanager to the path for the
4794 root toolbox. Call OpenDirectories with the new path and the
4795 root toolbox as the restricted directory.
4803 if ((user_install_point) &&
4804 (ptr = strstr(msgFile, user_install_point)))
4806 ptr += strlen(user_install_point);
4807 tool_dir = XtMalloc(strlen(root_toolbox) + strlen(ptr) + 1);
4808 sprintf(tool_dir, "%s%s", root_toolbox, ptr);
4809 XtFree(special_restricted);
4810 special_restricted = XtNewString(root_toolbox);
4814 ptr = strstr(msgFile, link_point);
4819 link_point = XtNewString("C");
4820 ptr = strstr(msgFile, link_point);
4825 ptr += strlen(link_point);
4826 if (strcmp(ptr, "") != 0)
4828 tool_dir = XtMalloc(strlen(root_toolbox) +
4830 sprintf(tool_dir, "%s%s", root_toolbox, ptr);
4831 XtFree(special_restricted);
4832 special_restricted = XtNewString(root_toolbox);
4834 else if (user_install_point)
4836 tool_dir = XtNewString(root_toolbox);
4837 XtFree(special_restricted);
4838 special_restricted = XtNewString(root_toolbox);
4845 XtFree(root_toolbox);
4846 XtFree(user_install_point);
4848 else if (restrictMode)
4852 special_view = True;
4853 ptr = strrchr(users_home_dir, '/');
4855 special_restricted = XtNewString(users_home_dir);
4859 special_view = False;
4862 if (tmp_path == NULL)
4865 OpenDirectories (tool_dir, special_restricted);
4866 else if (msgFile != NULL)
4867 OpenDirectories (msgFile, special_restricted);
4871 char full_path[MAX_PATH + 1];
4872 struct stat stat_buf;
4874 sprintf(full_path, "%s/%s", tmp_path, TOOL_SETTINGS_FILENAME);
4877 /* Stat the file and make sure its there */
4878 if (stat (full_path, &stat_buf) == 0 && numArgs > 0)
4880 DialogData * dialog_data;
4881 FileMgrData * file_mgr_data;
4883 restoreType = TOOL_RESTORE;
4885 RestoreSession(full_path, TOOL_RESTORE, tool_dir);
4887 RestoreSession(full_path, TOOL_RESTORE, msgFile);
4888 dialog_data = (DialogData *)view_set[view_count - 1]->dialog_data;
4889 file_mgr_data = (FileMgrData *) dialog_data->data;
4890 application_args.tool_width = file_mgr_data->width;
4891 application_args.tool_height = file_mgr_data->height;
4892 restoreType = NORMAL_RESTORE;
4897 OpenDirectories (tool_dir, special_restricted);
4898 else if (msgFile != NULL)
4899 OpenDirectories (msgFile, special_restricted);
4908 tt_message_reply( msg );
4909 tttk_message_destroy( msg );
4917 /************************************************************************
4920 * This function is called upon the DtSTOP message.
4922 ************************************************************************/
4927 XtPointer clientData,
4928 String * messageFields,
4931 tt_message_reply( msg );
4932 tttk_message_destroy( msg );
4933 FinalizeToolTalkSession( );
4939 * This is the message handling function responsible for reloading
4940 * the filetype and action databases, and then updating our collection
4941 * of action menu items, and updating all open views.
4945 ReloadDatabases(void)
4948 DialogData * dialog_data;
4949 FileMgrData * file_mgr_data;
4950 FileMgrRec * file_mgr_rec;
4951 FileViewData *file_view_data;
4952 DesktopRec *desktopWindow;
4956 XmeFlushIconFileCache ( NULL );
4958 /* Update each directory_set view, both mapped and not */
4959 UpdateDirectorySet();
4961 /* Force action menus to update the next time they're posted */
4962 XtFree(fileMgrPopup.action_pane_file_type);
4963 fileMgrPopup.action_pane_file_type = NULL;
4964 XtFree(desktop_data->popupMenu->action_pane_file_type);
4965 desktop_data->popupMenu->action_pane_file_type = NULL;
4967 /* Update each view */
4968 for (i = 0; i < view_count; i++)
4970 dialog_data = (DialogData *)view_set[i]->dialog_data;
4971 file_mgr_data = (FileMgrData *) dialog_data->data;
4972 file_mgr_rec = (FileMgrRec *) file_mgr_data->file_mgr_rec;
4973 XtFree(file_mgr_rec->action_pane_file_type);
4974 file_mgr_rec->action_pane_file_type = NULL;
4975 UpdateFilterAfterDBReread(file_mgr_data->filter_active);
4976 UpdateFilterAfterDBReread(file_mgr_data->filter_edit);
4977 FileMgrRedisplayFiles(file_mgr_rec, file_mgr_data, False);
4980 /* go through the desktop objects to make sure the icons change
4981 * Do this by setting the logical_type to -l, CheckDesktop will
4982 * then update the logical type and the icon
4984 for(i = 0; i < desktop_data->numIconsUsed; i++)
4986 desktopWindow = desktop_data->desktopWindows[i];
4987 file_view_data = desktopWindow->file_view_data;
4989 file_view_data->file_data->logical_type = NULL;
4996 * Whenever a directory view or drawer view is closed, we need to remove
4997 * any of its text field children, so that they will not magically reappear
4998 * should this view be reused from the cache to view the same directory later.
5003 XtPointer client_data,
5004 DialogData * old_dialog_data,
5005 DialogData * new_dialog_data)
5007 FileMgrRec * file_mgr_rec;
5008 XmManagerWidget file_window;
5012 file_mgr_rec = (FileMgrRec *) _DtGetDialogInstance(old_dialog_data);
5013 file_window = (XmManagerWidget) file_mgr_rec->file_window;
5014 num_children = file_window->composite.num_children;
5016 for (i = 0; i < num_children; i++)
5018 if (XmIsTextField(file_window->composite.children[i]))
5019 XtDestroyWidget(file_window->composite.children[i]);
5022 _DtFreeDialogData (new_dialog_data);
5027 * This function searches the view list, and returns the file_mgr_data
5028 * associated with the passed-in widget.
5036 DialogData * dialog_data;
5037 FileMgrData * file_mgr_data;
5039 for (i = 0; i < view_count; i++)
5041 dialog_data = (DialogData *) view_set[i]->dialog_data;
5042 file_mgr_data = (FileMgrData *) dialog_data->data;
5044 if (w == ((FileMgrRec *)file_mgr_data->file_mgr_rec)->file_window ||
5045 w == ((FileMgrRec *)file_mgr_data->file_mgr_rec)->shell)
5046 return(file_mgr_data);
5054 CheckForOpenDirectory(
5055 FileViewData *order_list,
5056 DirectorySet *directory_set,
5057 FileMgrData *file_mgr_data,
5058 char * logical_type)
5062 char *file_type_name, *new_file_type_name;
5063 char directory_name[MAX_PATH];
5064 char * real_dir_name;
5065 FileMgrRec *file_mgr_rec;
5067 PixmapData *pixmapData = NULL;
5069 if (file_mgr_data->view == BY_NAME_AND_ICON)
5074 file_mgr_rec = (FileMgrRec *)file_mgr_data->file_mgr_rec;
5076 if (strcmp (directory_set->name, "/") != 0)
5077 sprintf( directory_name, "%s/%s", directory_set->name, order_list->file_data->file_name);
5079 sprintf( directory_name, "%s%s", directory_set->name, order_list->file_data->file_name );
5081 (void) DtEliminateDots (directory_name);
5083 real_dir_name = XtNewString(directory_name);
5085 for(i = 0; i < view_count; i++)
5087 if(strcmp(real_dir_name, view_set[i]->directory_name) == 0)
5089 file_type_name = order_list->file_data->logical_type;
5090 new_file_type_name = (char *)XtMalloc(strlen(file_type_name)
5091 + strlen(ICON_OPEN_PREFIX) + 1);
5092 sprintf(new_file_type_name, "%s%s", ICON_OPEN_PREFIX, file_type_name);
5093 pixmapData = _DtRetrievePixmapData(new_file_type_name,
5096 file_mgr_rec->file_window,
5098 XtFree(new_file_type_name);
5102 XtFree(real_dir_name);
5104 if(pixmapData == NULL || pixmapData->iconFileName == NULL)
5106 if( pixmapData != NULL )
5108 DtDtsFreeAttributeValue(pixmapData->hostPrefix);
5109 DtDtsFreeAttributeValue(pixmapData->instanceIconName);
5110 DtDtsFreeAttributeValue(pixmapData->iconName);
5111 XtFree((char *)pixmapData);
5114 pixmapData = _DtRetrievePixmapData(logical_type,
5117 file_mgr_rec->file_window,
5126 * The is the menu callback function for cleaning up a view.
5132 XtPointer client_data,
5133 XtPointer call_data)
5137 FileMgrRec * file_mgr_rec;
5138 DialogData * dialog_data;
5139 FileMgrData * file_mgr_data;
5141 XmManagerWidget file_window;
5143 FileViewData * file_view_data;
5144 XRectangle textExtent;
5147 if ((int)(XtArgVal) client_data == FM_POPUP)
5150 mbar = XmGetPostedFromWidget(XtParent(w));
5153 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
5154 XtGetValues(mbar, args, 1);
5156 /* Ignore accelerators when we're insensitive */
5157 if ((file_mgr_rec->menuStates & CLEAN_UP) == 0)
5160 /* Ignore accelerators received after we're unposted */
5161 if ((dialog_data = _DtGetInstanceData((XtPointer)file_mgr_rec)) == NULL)
5164 file_mgr_data = (FileMgrData *)dialog_data->data;
5166 /* Reset the grid size, so it will be recalculated later. */
5167 file_mgr_data->grid_height = 0;
5168 file_mgr_data->grid_width = 0;
5170 if(file_mgr_data->object_positions)
5171 FreePositionInfo(file_mgr_data);
5173 /* CLEAN_UP_OP is not really a menu state.
5174 It's a flag to let GetFileData in FileMgr.c (call when the directory
5175 is being reread) not to reload icon positions from the .!dt<userid> file.
5177 file_mgr_rec->menuStates |= CLEAN_UP_OP;
5179 /* Re-layout the view */
5180 FileMgrRedisplayFiles(file_mgr_rec, file_mgr_data, False);
5182 if ((file_mgr_data->show_type == SINGLE_DIRECTORY) &&
5183 (file_mgr_data->view != BY_ATTRIBUTES) &&
5184 (file_mgr_data->positionEnabled == RANDOM_ON))
5186 ((PreferencesData *)(file_mgr_data->preferences->data))->positionEnabled =
5191 /* Update the preferences dialog */
5192 ((PreferencesData *)(file_mgr_data->preferences->data))->positionEnabled =
5196 /* Move any text widget, to keep them in sync with their icons */
5197 file_window = (XmManagerWidget)file_mgr_rec->file_window;
5199 for (j = 0; j < file_window->composite.num_children; j++)
5201 if (XmIsTextField(file_window->composite.children[j]) &&
5202 !file_window->composite.children[j]->core.being_destroyed)
5204 XtSetArg(args[0], XmNuserData, &name);
5205 XtGetValues(file_window->composite.children[j], args, 1);
5207 /* Find the associated icon data */
5208 /* @@@ this won't work for tree mode! */
5209 for (i = 0; i < file_mgr_data->directory_set[0]->file_count; i++)
5211 file_view_data = file_mgr_data->directory_set[0]->file_view_data[i];
5212 if (strcmp(name, file_view_data->file_data->file_name) == 0)
5214 _DtIconGetTextExtent_r(file_view_data->widget, &textExtent);
5217 (Dimension)(file_window->composite.children[j]->core.height -
5218 textExtent.height)/(Dimension)2;
5219 XtSetArg (args[0], XmNx, x);
5220 XtSetArg (args[1], XmNy, y);
5221 XtSetValues (file_window->composite.children[j], args, 2);
5228 if ((file_mgr_rec->menuStates & CLEAN_UP_OP))
5229 file_mgr_rec->menuStates &= ~CLEAN_UP_OP;
5232 /*************************************<->*************************************
5234 * DtfileCvtStringToObjPlace (args, numArgs, fromVal, toVal)
5239 * This function converts a string to an desktop placement scheme description.
5244 * args = NULL (don't care)
5246 * numArgs = 0 (don't care)
5248 * fromVal = resource value to convert
5253 * toVal = descriptor to use to return converted value
5255 *************************************<->***********************************/
5258 DtfileCvtStringToObjPlace (
5264 unsigned char *pch = (unsigned char *) (fromVal->addr);
5265 unsigned char *pchNext;
5269 Boolean fPrimarySet = False;
5270 Boolean fSecondarySet = False;
5273 * Icon placement layout values:
5276 #define OBJ_PLACE_BOTTOM_STR (unsigned char *)"bottom"
5277 #define OBJ_PLACE_LEFT_STR (unsigned char *)"left"
5278 #define OBJ_PLACE_RIGHT_STR (unsigned char *)"right"
5279 #define OBJ_PLACE_TOP_STR (unsigned char *)"top"
5283 * Convert the icon placement resource value:
5288 while (*pch && _DtNextToken (pch, &len, &pchNext))
5296 if (_DtStringsAreEquivalent((char *)pch, (char *)OBJ_PLACE_BOTTOM_STR))
5300 cval |= OBJ_PLACE_BOTTOM_PRIMARY;
5303 else if (!fSecondarySet)
5306 (OBJ_PLACE_BOTTOM_PRIMARY | OBJ_PLACE_TOP_PRIMARY)))
5308 cval |= OBJ_PLACE_BOTTOM_SECONDARY;
5309 fSecondarySet = True;
5318 if (_DtStringsAreEquivalent ((char *)pch, (char *)OBJ_PLACE_LEFT_STR))
5322 cval |= OBJ_PLACE_LEFT_PRIMARY;
5325 else if (!fSecondarySet)
5328 (OBJ_PLACE_LEFT_PRIMARY | OBJ_PLACE_RIGHT_PRIMARY)))
5330 cval |= OBJ_PLACE_LEFT_SECONDARY;
5331 fSecondarySet = True;
5339 if (_DtStringsAreEquivalent ((char *)pch, (char *)OBJ_PLACE_RIGHT_STR))
5343 cval |= OBJ_PLACE_RIGHT_PRIMARY;
5346 else if (!fSecondarySet)
5349 (OBJ_PLACE_RIGHT_PRIMARY | OBJ_PLACE_LEFT_PRIMARY)))
5351 cval |= OBJ_PLACE_RIGHT_SECONDARY;
5352 fSecondarySet = True;
5360 if (_DtStringsAreEquivalent ((char *)pch, (char *)OBJ_PLACE_TOP_STR))
5364 cval |= OBJ_PLACE_TOP_PRIMARY;
5367 else if (!fSecondarySet)
5370 (OBJ_PLACE_TOP_PRIMARY | OBJ_PLACE_BOTTOM_PRIMARY)))
5372 cval |= OBJ_PLACE_TOP_SECONDARY;
5373 fSecondarySet = True;
5386 cval = OBJ_PLACE_TOP_PRIMARY;
5390 if (cval & (OBJ_PLACE_LEFT_PRIMARY | OBJ_PLACE_RIGHT_PRIMARY))
5392 cval |= OBJ_PLACE_TOP_SECONDARY;
5395 cval |= OBJ_PLACE_RIGHT_SECONDARY;
5400 (*toVal).size = sizeof (long);
5401 (*toVal).addr = (XtPointer) &cval;
5403 } /* END OF FUNCTION DtfileCvtStringToObjPlace */
5405 /*************************************<->*************************************
5407 * _DtNextToken (pchIn, pLen, ppchNext)
5417 * pchIn = pointer to start of next token
5422 * pLen = pointer to integer containing number of characters in next token
5423 * ppchNext = address of pointer to following token
5425 * Return = next token or NULL
5432 *************************************<->***********************************/
5434 static unsigned char
5436 unsigned char *pchIn,
5438 unsigned char **ppchNext)
5440 unsigned char *pchR = pchIn;
5445 for (i = 0; ((chlen = mblen ((char *)pchIn, MB_CUR_MAX)) > 0); i++)
5446 /* find end of word: requires singlebyte whitespace terminator */
5448 if ((chlen == 1) && isspace (*pchIn))
5456 for (i = 0; *pchIn && !isspace (*pchIn); i++, pchIn++)
5457 /* find end of word */
5462 /* skip to next word */
5464 while (pchIn && (mblen ((char *)pchIn, MB_CUR_MAX) == 1) && isspace (*pchIn))
5466 while (pchIn && isspace (*pchIn))
5483 } /* END OF FUNCTION _DtNextToken */
5485 /*************************************<->*************************************
5487 * DtfileCvtStringToOpenDir (args, numArgs, fromVal, toVal)
5492 * This function converts a string to an desktop placement scheme description.
5497 * args = NULL (don't care)
5499 * numArgs = 0 (don't care)
5501 * fromVal = resource value to convert
5506 * toVal = descriptor to use to return converted value
5508 *************************************<->***********************************/
5511 DtfileCvtStringToOpenDir (
5517 char * in_str = (char *) (fromVal->addr);
5520 toVal->size = sizeof (int);
5521 toVal->addr = (XtPointer) &i;
5523 if (_DtStringsAreEquivalent (in_str, "current"))
5525 else if (_DtStringsAreEquivalent (in_str, "new"))
5534 XtStringConversionWarning ((char *)fromVal->addr, "OpenDir");
5539 /*************************************<->*************************************
5541 * DtfileCvtStringToDTIcon (args, numArgs, fromVal, toVal)
5546 * This function converts a string to an desktop placement scheme description.
5551 * args = NULL (don't care)
5553 * numArgs = 0 (don't care)
5555 * fromVal = resource value to convert
5560 * toVal = descriptor to use to return converted value
5562 *************************************<->***********************************/
5565 DtfileCvtStringToDTIcon (
5571 char * in_str = (char *) (fromVal->addr);
5574 toVal->size = sizeof (int);
5575 toVal->addr = (XtPointer) &i;
5577 if (_DtStringsAreEquivalent (in_str, "large"))
5579 else if (_DtStringsAreEquivalent (in_str, "small"))
5581 else if (_DtStringsAreEquivalent (in_str, "default"))
5582 i = LARGE; /* for now, eventually want to look at screen width/height*/
5590 XtStringConversionWarning ((char *)fromVal->addr, "DesktopIcon");
5596 DtfileCvtStringToTree (
5602 char * in_str = (char *) (fromVal->addr);
5605 toVal->size = sizeof (int);
5606 toVal->addr = (XtPointer) &i;
5608 DtfileStringToTree(in_str, &i);
5612 DtfileCvtStringToTreeFiles (
5618 char * in_str = (char *) (fromVal->addr);
5621 toVal->size = sizeof (int);
5622 toVal->addr = (XtPointer) &i;
5624 DtfileStringToTreeFiles(in_str, &i);
5628 DtfileCvtStringToView (
5634 char * in_str = (char *) (fromVal->addr);
5637 toVal->size = sizeof (int);
5638 toVal->addr = (XtPointer) &i;
5640 DtfileStringToView(in_str, &i);
5644 DtfileCvtStringToOrder (
5650 char * in_str = (char *) (fromVal->addr);
5653 toVal->size = sizeof (int);
5654 toVal->addr = (XtPointer) &i;
5656 DtfileStringToOrder(in_str, &i);
5660 DtfileCvtStringToDirection (
5666 char * in_str = (char *) (fromVal->addr);
5669 toVal->size = sizeof (int);
5670 toVal->addr = (XtPointer) &i;
5672 DtfileStringToDirection(in_str, &i);
5676 DtfileCvtStringToGrid (
5682 char * in_str = (char *) (fromVal->addr);
5685 toVal->size = sizeof (int);
5686 toVal->addr = (XtPointer) &i;
5688 DtfileStringToGrid(in_str, &i);
5697 FileMgrData *file_mgr_data;
5698 DialogData *dialog_data;
5700 for(i = 0; i < view_count; i++)
5702 if(strcmp(directory, view_set[i]->directory_name) == 0 &&
5703 strcmp(host, view_set[i]->host_name) == 0)
5705 dialog_data = (DialogData *) view_set[i]->dialog_data;
5706 file_mgr_data = (FileMgrData *) dialog_data->data;
5707 return(file_mgr_data);
5714 GetRestrictedDirectory (
5718 FileMgrData *file_mgr_data;
5719 FileMgrRec *file_mgr_rec;
5720 DialogData *dialog_data;
5722 for(i = 0; i < view_count; i++)
5724 dialog_data = (DialogData *) view_set[i]->dialog_data;
5725 file_mgr_data = (FileMgrData *) dialog_data->data;
5726 file_mgr_rec = (FileMgrRec *)file_mgr_data->file_mgr_rec;
5727 if(file_mgr_rec->current_directory_text == widget &&
5728 file_mgr_data->fast_cd_enabled)
5730 return(file_mgr_data->restricted_directory);
5733 return((char *)NULL);
5741 if (_DtStringsAreEquivalent (str, "on"))
5742 *type = MULTIPLE_DIRECTORY;
5743 else if (_DtStringsAreEquivalent (str, "off"))
5744 *type = SINGLE_DIRECTORY;
5746 *type = UNSET_VALUE;
5750 DtfileStringToTreeFiles(
5754 if (_DtStringsAreEquivalent (str, "never"))
5755 *type = TREE_FILES_NEVER;
5756 else if (_DtStringsAreEquivalent (str, "choose"))
5757 *type = TREE_FILES_CHOOSE;
5758 else if (_DtStringsAreEquivalent (str, "always"))
5759 *type = TREE_FILES_ALWAYS;
5761 *type = UNSET_VALUE;
5769 if (_DtStringsAreEquivalent (str, "no_icon") ||
5770 _DtStringsAreEquivalent (str, "no_icons"))
5772 else if (_DtStringsAreEquivalent (str, "large_icon") ||
5773 _DtStringsAreEquivalent (str, "large_icons"))
5774 *type = BY_NAME_AND_ICON;
5775 else if (_DtStringsAreEquivalent (str, "small_icon") ||
5776 _DtStringsAreEquivalent (str, "small_icons"))
5777 *type = BY_NAME_AND_SMALL_ICON;
5778 else if (_DtStringsAreEquivalent (str, "attributes"))
5779 *type = BY_ATTRIBUTES;
5781 *type = UNSET_VALUE;
5785 DtfileStringToOrder(
5789 if (_DtStringsAreEquivalent (str, "file_type"))
5790 *type = ORDER_BY_FILE_TYPE;
5791 else if (_DtStringsAreEquivalent (str, "alphabetical"))
5792 *type = ORDER_BY_ALPHABETICAL;
5793 else if (_DtStringsAreEquivalent (str, "date"))
5794 *type = ORDER_BY_DATE;
5795 else if (_DtStringsAreEquivalent (str, "size"))
5796 *type = ORDER_BY_SIZE;
5798 *type = UNSET_VALUE;
5803 DtfileStringToDirection(
5807 if (_DtStringsAreEquivalent (str, "ascending"))
5808 *type = DIRECTION_ASCENDING;
5809 else if (_DtStringsAreEquivalent (str, "descending"))
5810 *type = DIRECTION_DESCENDING;
5812 *type = UNSET_VALUE;
5820 if (_DtStringsAreEquivalent (str, "on"))
5822 else if (_DtStringsAreEquivalent (str, "off"))
5825 *type = UNSET_VALUE;
5829 SetupSendRequestArgs(
5830 ApplicationArgs application_args,
5834 if(application_args.title != NULL)
5836 tt_message_arg_add( msg, TT_IN, "-title", application_args.title );
5838 if(application_args.restricted != NULL)
5840 tt_message_arg_add( msg, TT_IN, RESTRICTED_HEADER, 0 );
5842 vtype = VIEW_HEADER;
5843 switch( application_args.view )
5846 tt_message_arg_add( msg, TT_IN, vtype, "no_icon" );
5848 case BY_NAME_AND_ICON:
5849 tt_message_arg_add( msg, TT_IN, vtype, "large_icon" );
5851 case BY_NAME_AND_SMALL_ICON:
5852 tt_message_arg_add( msg, TT_IN, vtype, "small_icon" );
5855 tt_message_arg_add( msg, TT_IN, vtype, "attributes" );
5858 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5863 switch( application_args.order )
5865 case ORDER_BY_FILE_TYPE:
5866 tt_message_arg_add( msg, TT_IN, vtype, "file_type" );
5868 case ORDER_BY_ALPHABETICAL:
5869 tt_message_arg_add( msg, TT_IN, vtype, "alphabetical" );
5872 tt_message_arg_add( msg, TT_IN, vtype, "date" );
5875 tt_message_arg_add( msg, TT_IN, vtype, "size" );
5878 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5882 vtype = "-direction";
5883 switch( application_args.direction )
5885 case DIRECTION_ASCENDING:
5886 tt_message_arg_add( msg, TT_IN, vtype, "ascending" );
5888 case DIRECTION_DESCENDING:
5889 tt_message_arg_add( msg, TT_IN, vtype, "descending" );
5892 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5897 switch( application_args.grid )
5900 tt_message_arg_add( msg, TT_IN, vtype, "on" );
5903 tt_message_arg_add( msg, TT_IN, vtype, "off" );
5906 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5910 switch( application_args.tree_view )
5912 case MULTIPLE_DIRECTORY:
5913 tt_message_arg_add( msg, TT_IN, vtype, "on" );
5915 case SINGLE_DIRECTORY:
5916 tt_message_arg_add( msg, TT_IN, vtype, "off" );
5919 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5923 vtype = "-tree_files";
5924 switch( application_args.tree_files )
5926 case TREE_FILES_NEVER:
5927 tt_message_arg_add( msg, TT_IN, vtype, "never" );
5929 case TREE_FILES_CHOOSE:
5930 tt_message_arg_add( msg, TT_IN, vtype, "choose" );
5932 case TREE_FILES_ALWAYS:
5933 tt_message_arg_add( msg, TT_IN, vtype, "always" );
5936 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5940 if(application_args.help_volume != NULL)
5942 tt_message_arg_add( msg, TT_IN, "-help_volume",
5943 application_args.help_volume );
5948 * This routine is used by ForceMyIconOpen to get the "Open" filetype and
5949 * find out what the new icon is. It then places that icon in the
5950 * correct icon gadget.
5953 BuildAndShowIconName(
5954 char *file_type_name,
5956 unsigned char show_type,
5959 char *new_file_type_name;
5962 PixmapData *pixmapData;
5964 new_file_type_name = (char *)XtMalloc(strlen(file_type_name) +
5965 strlen(ICON_OPEN_PREFIX) + 1);
5966 sprintf(new_file_type_name, "%s%s", ICON_OPEN_PREFIX, file_type_name);
5968 if (view == BY_NAME_AND_ICON && show_type != MULTIPLE_DIRECTORY)
5969 pixmapData = _DtRetrievePixmapData(new_file_type_name,
5975 pixmapData = _DtRetrievePixmapData(new_file_type_name,
5981 if(pixmapData && pixmapData->iconFileName)
5983 XtSetArg (args[0], XmNimageName, pixmapData->iconFileName);
5984 XtSetValues(widget, args, 1);
5989 XtSetArg (args[0], XmNimageName, NULL);
5990 XtSetValues(widget, args, 1);
5994 _DtCheckAndFreePixmapData(new_file_type_name,
5996 (DtIconGadget) widget,
5999 XtFree(new_file_type_name);
6004 * Given a directory name, this function will see if a view of the parent
6005 * directory is open; if so, then it will update the icon representing
6006 * this icon, in the parent view, so that it is drawn as 'closed'. This
6007 * function must only be called if openDirType == NEW.
6013 char * directory_name)
6019 FileViewData * file_view_data = NULL;
6020 DialogData *dialog_data;
6021 FileMgrData *file_mgr_data;
6022 DesktopRec *desktopWindow;
6025 PixmapData *pixmapData;
6027 /* find the parent directory of the one just removed */
6028 parent = _DtPName(directory_name);
6029 fname = DName(directory_name);
6031 /* first check to see if any File Manager views have this directory */
6032 for (i = 0; i < view_count; i++)
6034 dialog_data = (DialogData *) view_set[i]->dialog_data;
6035 file_mgr_data = (FileMgrData *) dialog_data->data;
6037 /* loop through until we find the file_view_data structure for
6038 * the directory to force open */
6040 for(j = 0; j < file_mgr_data->directory_count; j++)
6042 if (strcmp(parent, file_mgr_data->directory_set[j]->name) == 0)
6044 for (k = 0; k < file_mgr_data->directory_set[j]->file_count; k++)
6047 file_mgr_data->directory_set[j]->file_view_data[k];
6048 if (strcmp(file_view_data->file_data->file_name, fname) == 0)
6058 if( (file_view_data) && (file_mgr_data->view != BY_NAME) )
6060 if (file_mgr_data->view == BY_NAME_AND_ICON &&
6061 file_mgr_data->show_type != MULTIPLE_DIRECTORY)
6062 pixmapData = _DtRetrievePixmapData(
6063 file_view_data->file_data->logical_type,
6066 file_view_data->widget,
6069 pixmapData = _DtRetrievePixmapData(
6070 file_view_data->file_data->logical_type,
6073 file_view_data->widget,
6077 XtSetArg (args[0], XmNimageName, pixmapData->iconFileName);
6079 XtSetArg (args[0], XmNimageName, NULL);
6080 XtSetValues (file_view_data->widget, args, 1);
6082 _DtCheckAndFreePixmapData(file_view_data->file_data->logical_type,
6083 file_view_data->widget,
6084 (DtIconGadget) file_view_data->widget,
6088 /* now check to see if any desktop objects are this directory */
6089 for(j = 0; j < desktop_data->numIconsUsed; j++)
6093 desktopWindow = desktop_data->desktopWindows[j];
6094 file_view_data = desktopWindow->file_view_data;
6096 sprintf(buf, "%s/%s", desktopWindow->dir_linked_to,
6097 desktopWindow->file_name);
6098 DtEliminateDots (buf);
6100 if( (strcmp(buf, directory_name) == 0) &&
6101 (strcmp(desktopWindow->host, host_name) == 0) )
6103 pixmapData = _DtRetrievePixmapData(
6104 file_view_data->file_data->logical_type,
6107 desktopWindow->shell,
6111 XtSetArg (args[0], XmNimageName, pixmapData->iconFileName);
6113 XtSetArg (args[0], XmNimageName, NULL);
6114 XtSetValues (desktopWindow->iconGadget, args, 1);
6116 _DtCheckAndFreePixmapData(
6117 desktopWindow->file_view_data->file_data->logical_type,
6118 desktopWindow->shell,
6119 (DtIconGadget) desktopWindow->iconGadget,
6126 /*************************************************************************
6128 * MarqueeSelect - this is the callback which gets called when there is
6129 * a marquee event happening on the root window.
6131 ************************************************************************/
6140 XtPointer client_data)
6145 Screen *currentScreen;
6147 char *workspace_name=NULL;
6153 case DT_WSM_MARQUEE_SELECTION_TYPE_BEGIN:
6154 display = XtDisplay(desktop_data->desktopWindows[0]->shell);
6155 screen = XDefaultScreen(display);
6156 currentScreen = XScreenOfDisplay(display, screen);
6157 rootWindow = RootWindowOfScreen(currentScreen);
6159 if(DtWsmGetCurrentWorkspace(display, rootWindow, &pCurrent)
6162 workspace_name = XGetAtomName (display, pCurrent);
6163 CleanUpWSName(workspace_name);
6167 XtNewString(desktop_data->workspaceData[0]->name);
6169 for(i = 0; i < desktop_data->numWorkspaces; i++)
6171 if(strcmp(workspace_name,
6172 desktop_data->workspaceData[i]->name) == 0)
6174 DeselectAllDTFiles(desktop_data->workspaceData[i]);
6178 XtFree(workspace_name);
6181 case DT_WSM_MARQUEE_SELECTION_TYPE_END:
6182 CheckDesktopMarquee(x, y, width, height);
6185 case DT_WSM_MARQUEE_SELECTION_TYPE_CANCEL:
6188 case DT_WSM_MARQUEE_SELECTION_TYPE_CONTINUE:
6189 CheckDesktopMarquee(x, y, width, height);
6199 * We must wait for the message response, before exiting
6203 WaitForResponseAndExit( void )
6211 XtPointer clientData,
6216 FinalizeToolTalkSession( );
6222 * Puts up an Error dialog with Cancel and Help unmapped in the
6223 * center of the screen. The last argument is the OK callback
6227 post_dialog(Widget parent, char *title, char *msg, void (*DtErrExitCB)())
6229 Widget dialog, dialogShell;
6230 XmString message_text, ok;
6232 Dimension dialogWd, dialogHt;
6235 ok = XmStringCreateLocalized ((char*)_DtOkString);
6236 message_text = XmStringCreateLocalized (msg);
6238 XtSetArg(args[n], XmNautoUnmanage, False); n++;
6239 XtSetArg(args[n], XmNokLabelString, ok); n++;
6240 XtSetArg(args[n], XmNtitle, title); n++;
6241 XtSetArg(args[n], XmNmessageString, message_text); n++;
6242 XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
6243 XtSetArg (args[n], XmNdefaultPosition, False); n++;
6244 XtSetArg(args[n], XmNuseAsyncGeometry, True); n++;
6246 dialog = XmCreateErrorDialog (parent, title, args, n);
6247 XtAddCallback (dialog, XmNokCallback, DtErrExitCB, NULL);
6248 XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_CANCEL_BUTTON));
6249 XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
6251 /* Disable the frame menu from dialog since we don't want the user
6252 to be able to close dialogs with the frame menu */
6254 dialogShell = XtParent(dialog);
6255 XtSetArg(args[0], XmNmappedWhenManaged, False);
6256 XtSetArg(args[1], XmNmwmDecorations, MWM_DECOR_ALL | MWM_DECOR_MENU);
6257 XtSetValues(dialogShell, args, 2);
6258 XtManageChild (dialog);
6259 XtRealizeWidget (dialogShell);
6261 /* Center the dialog */
6263 XtSetArg(args[0], XmNwidth, &dialogWd);
6264 XtSetArg(args[1], XmNheight, &dialogHt);
6265 XtGetValues(dialog, args, 2);
6266 XtSetArg (args[0], XmNx,
6267 (WidthOfScreen(XtScreen(dialog)) - dialogWd) / 2);
6268 XtSetArg (args[1], XmNy,
6269 (HeightOfScreen(XtScreen(dialog)) - dialogHt) / 2);
6270 XtSetArg (args[2], XmNmappedWhenManaged, True);
6271 XtSetValues (dialog, args, 3);
6273 XtSetArg(args[0], XmNmappedWhenManaged, True);
6274 XtSetValues(dialogShell, args, 1);
6276 XtManageChild (dialog);
6277 XmStringFree(message_text);
6283 * This is the Callback when an error occurs while trying to create
6284 * the .dt folder or sub-folders. Application exits.
6288 DtErrExitCB (Widget dialog, XtPointer client_data, XtPointer call_data)
6290 XtPopdown (XtParent (dialog));
6291 FinalizeToolTalkSession();
6295 #if defined(__osf__) || defined(CSRG_BASED)
6297 sigchld_handler(int signo) /* Do not use the arg signo at the moment */
6303 On DUX, the process remains in the ZOMBIE
6304 state untill parent invokes wait or waitpid.
6307 pid = waitpid(-1, &stat_loc, WNOHANG);
6308 /* Child exit handling code follows, if any */
6310 #endif /* __osf__ */