2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: 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] = {0};
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(displayWidth, displayHeight);
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 coming 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[11];
2589 char workspaceNumber[11];
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[11];
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[] )
3423 FILE * pwd_file = NULL;
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");
3437 if (fread (¤t_directory[i], sizeof(char), 1, pwd_file) != 1)
3445 if (current_directory[i] == '\n')
3455 current_directory[i] = '\0';
3458 /************************************************************************
3461 * Given a string that contains a single or set of host:path
3462 * specifications, parse out each host:path, validate it as
3463 * a accessible directory, and call a function to create a
3464 * file manager view of the directory.
3466 ************************************************************************/
3470 char *directory_set,
3477 /* Loop the the directory set string until all of */
3478 /* the path specifications have be parsed. */
3482 separator = DtStrchr (directory_set, ',');
3483 if (separator != NULL)
3486 _DtPathFromInput(directory_set, NULL, &host, &path);
3490 GetNewView (host, path, type, NULL, 0);
3494 char *tmpStr, *errTitle, *errMsg, *dmsg;
3496 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
3497 errTitle = XtNewString(tmpStr);
3498 tmpStr = GETMESSAGE(18, 38, "Invalid folder specification, %s");
3499 errMsg = XtNewString(tmpStr);
3500 dmsg = XtMalloc(strlen(errMsg)+strlen(directory_set)+1);
3501 sprintf(dmsg, errMsg, directory_set);
3502 _DtMessage(toplevel, errTitle, dmsg, NULL, HelpRequestCB);
3509 /* Free up the unique host and directory names */
3510 /* that were allocated. */
3512 XtFree ((char *) host);
3513 XtFree ((char *) path);
3515 /* Set the starting position of the next host:path */
3517 if (separator != NULL)
3518 directory_set = separator + 1;
3527 /************************************************************************
3530 * Given a directory name, generate a new view for the directory.
3532 ************************************************************************/
3536 char *directory_name,
3538 WindowPosition *position,
3541 DialogData * dialog_data;
3542 DialogInstanceData * instance_data;
3543 FileMgrData * file_mgr_data;
3545 FileMgrRec * file_mgr_rec;
3546 char * real_directory_name;
3548 XClassHint classHints;
3549 char *title, *tmpTitle;
3550 struct stat stat_buf;
3552 char *errMsg = NULL;
3554 DtEliminateDots( directory_name );
3556 if (stat(directory_name, &stat_buf) == 0)
3558 if ((stat_buf.st_mode & S_IFMT) != S_IFDIR)
3560 tmpStr = GETMESSAGE(18, 19,
3561 "The folder specification,\n%s\nis not a folder.");
3562 errMsg = XtNewString(tmpStr);
3567 tmpStr = GETMESSAGE(18, 20,
3568 "The folder specification,\n%s\ndoes not exist.");
3569 errMsg = XtNewString(tmpStr);
3576 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
3577 title = XtNewString(tmpStr);
3578 dmsg = XtMalloc(strlen(errMsg) +
3579 strlen(directory_name) + 1);
3580 sprintf(dmsg, errMsg, directory_name);
3581 _DtMessage(toplevel, title, dmsg, NULL, HelpRequestCB);
3590 * Special case: When opening any of the special desktop directory
3591 * icons (Home, Remote Systems, etc), we want to display the correct
3592 * path (i.e. $HOME instead of $HOME/.dt/Desktop/Home). So ... we'll
3593 * do the remap here.
3595 real_directory_name = directory_name;
3597 if(openDirType == NEW || (strcmp(real_directory_name, desktop_dir) == 0))
3599 for(i = 0; i < view_count; i++)
3601 if((strcmp(real_directory_name, view_set[i]->directory_name) == 0 &&
3602 (strcmp(host_name, view_set[i]->host_name) == 0))
3607 Screen *currentScreen;
3610 dialog_data = (DialogData *) view_set[i]->dialog_data;
3611 file_mgr_data = (FileMgrData *) dialog_data->data;
3612 file_mgr_rec = (FileMgrRec *) file_mgr_data->file_mgr_rec;
3614 screen = XDefaultScreen(display);
3615 currentScreen = XScreenOfDisplay(display, screen);
3616 rootWindow = RootWindowOfScreen(currentScreen);
3618 /* Get the current Workspace */
3619 if (DtWsmGetCurrentWorkspace(display, rootWindow, &pCurrent)
3622 Atom * ws_presence = NULL;
3623 unsigned long num_workspaces = 0;
3626 if (DtWsmGetWorkspacesOccupied(display,
3627 XtWindow(file_mgr_rec->shell), &ws_presence,
3628 &num_workspaces) == Success)
3630 /* Already in this workspace? */
3631 for (k = 0; k < num_workspaces; k++)
3633 if (ws_presence[k] == pCurrent)
3637 if (k >= num_workspaces)
3639 /* Add to the workspace */
3640 ws_presence = (Atom *) XtRealloc((char *)ws_presence,
3641 sizeof (Atom) * (num_workspaces + 1));
3643 ws_presence[num_workspaces] = pCurrent;
3644 DtWsmSetWorkspacesOccupied(display,
3645 XtWindow(file_mgr_rec->shell),
3646 ws_presence, num_workspaces + 1);
3648 XFree((char *)ws_presence);
3652 /* Change the hints to reflect the current workspace */
3653 DtWsmSetWorkspacesOccupied(display,
3654 XtWindow(file_mgr_rec->shell),
3659 /* must map the window to catch iconified windows */
3660 /* a XtPopup will not catch it */
3661 XtMapWidget(file_mgr_rec->shell);
3662 XRaiseWindow(display, XtWindow(file_mgr_rec->shell));
3664 /* announce activity */
3667 msg = tt_pnotice_create(TT_SESSION, "DtActivity_Began");
3668 tt_message_send(msg);
3669 tttk_message_destroy(msg);
3677 /* If in novice mode, force the icon for this dir to the 'Open' state */
3678 if (openDirType == NEW)
3679 ForceMyIconOpen(host_name, directory_name);
3681 /* Increment the list size if necessary. */
3683 if (view_count == view_set_size)
3685 view_set_size += 10;
3687 (View **) XtRealloc ((char *)view_set,
3688 sizeof (View **) * view_set_size);
3691 view_set[view_count] = (View *) XtMalloc (sizeof (View));
3692 view_set[view_count]->msg = 0;
3693 view_set[view_count]->pats = 0;
3695 if (initiating_view != NULL)
3696 dialog_data = _DtGetDefaultDialogData (file_mgr_dialog);
3700 char full_path[MAX_PATH + 1];
3703 tmp_path = _DtCreateDtDirs(display);
3705 sprintf(full_path, "%s/%s", tmp_path, TOOL_SETTINGS_FILENAME);
3707 sprintf(full_path, "%s/%s", tmp_path, HOME_SETTINGS_FILENAME);
3709 db = XrmGetFileDatabase (full_path);
3714 restoreType = TOOL_RESTORE;
3715 LoadViews(1, db, NULL, directory_name, type, msg);
3719 restoreType = HOME_RESTORE;
3720 LoadViews(1, db, host_name, directory_name, NULL, msg);
3724 * Free the Xrm Database
3726 XrmDestroyDatabase(db);
3727 dialog_data = (DialogData *)view_set[view_count - 1]->dialog_data;
3728 file_mgr_data = (FileMgrData *) dialog_data->data;
3731 application_args.tool_width = file_mgr_data->width;
3732 application_args.tool_height = file_mgr_data->height;
3736 application_args.dir_width = file_mgr_data->width;
3737 application_args.dir_height = file_mgr_data->height;
3739 if(file_mgr_data->find != NULL &&
3740 file_mgr_data->current_directory != NULL)
3742 DialogData * dialog_data;
3743 FindData * find_data;
3745 dialog_data = (DialogData *)file_mgr_data->find;
3746 find_data = (FindData *)dialog_data->data;
3748 XtFree(find_data->directories);
3749 if(file_mgr_data->restricted_directory == NULL)
3752 find_data->directories = XtNewString(users_home_dir);
3754 find_data->directories =
3755 XtNewString(file_mgr_data->current_directory);
3759 if(strcmp(file_mgr_data->current_directory,
3760 file_mgr_data->restricted_directory) == 0)
3761 find_data->directories = XtNewString("/");
3763 find_data->directories =
3764 XtNewString(file_mgr_data->current_directory +
3765 strlen(file_mgr_data->restricted_directory));
3769 /* If in novice mode, force the icon for all the dir's to the
3771 if (openDirType == NEW)
3772 ForceMyIconOpen(host_name, NULL);
3774 return((DialogData *)view_set[view_count - 1]->dialog_data);
3777 dialog_data = _DtGetDefaultDialogData (file_mgr_dialog);
3779 view_set[view_count]->dialog_data = (XtPointer) dialog_data;
3780 file_mgr_data = (FileMgrData *) dialog_data->data;
3782 /* Adjust the view settings if this new view was created */
3783 /* because of an action on a previous view. */
3785 if (initiating_view != NULL)
3787 FileMgrPropagateSettings ((FileMgrData *)initiating_view, file_mgr_data);
3788 /* force new window to come up in flat mode */
3789 file_mgr_data->show_type =
3790 ((PreferencesData *)file_mgr_data->preferences->data)->show_type =
3792 file_mgr_data->view = file_mgr_data->view_single;
3795 /* Call the FileMgr dialog to build up its directory set for */
3796 /* the directory name. */
3797 FileMgrBuildDirectories (file_mgr_data, host_name, real_directory_name);
3801 PreferencesData *preferences_data;
3803 file_mgr_data->toolbox = True;
3804 file_mgr_data->width = application_args.tool_width;
3805 file_mgr_data->height = application_args.tool_height;
3807 /* we want to default for the toolboxes (i.e. Application Manager) to
3808 * look different from a normal File Manager view. Let's turn off
3809 * the iconic_path, current_directory, and status_line.
3811 file_mgr_data->show_iconic_path = False;
3812 file_mgr_data->show_current_dir = False;
3814 file_mgr_data->show_status_line = True;
3817 preferences_data = (PreferencesData *)file_mgr_data->preferences->data;
3818 preferences_data->show_iconic_path = file_mgr_data->show_iconic_path;
3819 preferences_data->show_current_dir = file_mgr_data->show_current_dir;
3820 preferences_data->show_status_line = file_mgr_data->show_status_line;
3824 file_mgr_data->toolbox = False;
3825 file_mgr_data->width = application_args.dir_width;
3826 file_mgr_data->height = application_args.dir_height;
3830 if(file_mgr_data->find != NULL && file_mgr_data->current_directory != NULL)
3832 DialogData * dialog_data;
3833 FindData * find_data;
3835 dialog_data = (DialogData *)file_mgr_data->find;
3836 find_data = (FindData *)dialog_data->data;
3838 XtFree(find_data->directories);
3839 if(file_mgr_data->restricted_directory == NULL)
3842 find_data->directories = XtNewString(users_home_dir);
3844 find_data->directories =
3845 XtNewString(file_mgr_data->current_directory);
3849 if(strcmp(file_mgr_data->current_directory,
3850 file_mgr_data->restricted_directory) == 0)
3851 find_data->directories = XtNewString("/");
3853 find_data->directories =
3854 XtNewString(file_mgr_data->current_directory +
3855 strlen(file_mgr_data->restricted_directory));
3859 view_set[view_count]->host_name = XtNewString (file_mgr_data->host);
3860 view_set[view_count]->directory_name =
3861 XtNewString (file_mgr_data->current_directory);
3863 /* Load default position info, or inherit, if appropriate */
3864 if ((fmd = (FileMgrData *)initiating_view) &&
3865 (strcmp(fmd->host, host_name) == 0) &&
3866 (strcmp(fmd->current_directory, real_directory_name) == 0))
3868 InheritPositionInfo(fmd, file_mgr_data);
3871 LoadPositionInfo(file_mgr_data);
3874 /* Get the dialog displayed. */
3877 instance_data = (DialogInstanceData *) dialog_data->data;
3878 instance_data->x = position->x;
3879 instance_data->y = position->y;
3880 instance_data->displayed = True; /* @@@ Hack! without this,
3881 _DtShowDialog will ignore
3882 our position info */
3885 tmpTitle = file_mgr_data->title;
3886 title = file_mgr_data->title = _DtBuildFMTitle(file_mgr_data);
3888 XtFree(special_title);
3889 special_title = XtNewString(title);
3891 classHints.res_name = title;
3892 classHints.res_class = DTFILE_CLASS_NAME;
3893 initiating_view = NULL;
3895 _DtShowDialog (NULL, NULL, NULL, dialog_data, NULL, NULL, RemoveTextFields,
3896 NULL, NULL, False, special_view, title, &classHints);
3899 file_mgr_data->title = tmpTitle;
3902 ViewAccept( view_set[view_count], msg );
3908 /* If in novice mode, force the icon for all the dir's to the 'Open' state */
3909 if (openDirType == NEW)
3910 ForceMyIconOpen(host_name, NULL);
3912 return(dialog_data);
3918 /************************************************************************
3921 * Update the view set array when a view is closed.
3923 ************************************************************************/
3927 DialogData *dialog_data )
3931 FileMgrData * file_mgr_data;
3932 DialogData * tmpDialog_data;
3933 FileMgrRec * file_mgr_rec;
3934 XmManagerWidget file_window;
3935 char *directory_name = NULL;
3936 char *host_name = NULL;
3938 if(dialog_data == trashDialogData)
3940 CloseTrash(NULL, NULL, NULL);
3944 for (i = 0; i < view_count; i++)
3946 if (dialog_data == (DialogData *) (view_set[i]->dialog_data))
3948 tmpDialog_data = (DialogData *) (view_set[i]->dialog_data);
3949 file_mgr_data = (FileMgrData *)tmpDialog_data->data;
3951 directory_name = (char *)XtMalloc( strlen(view_set[i]->directory_name) + 1);
3952 strcpy(directory_name, view_set[i]->directory_name);
3953 host_name = (char *)XtMalloc( strlen(view_set[i]->host_name) + 1);
3954 strcpy(host_name, view_set[i]->host_name);
3956 if (view_set[i]->msg != 0) {
3957 if (view_set[i]->pats != 0) {
3958 ttdt_file_quit( view_set[i]->pats, 0 );
3959 view_set[i]->pats = 0;
3961 tt_message_reply( view_set[i]->msg );
3962 tttk_message_destroy( view_set[i]->msg );
3963 view_set[i]->msg = 0;
3966 XtFree ((char *) view_set[i]->directory_name);
3967 XtFree ((char *) view_set[i]->host_name);
3968 XtFree ((char *) view_set[i]);
3971 for (j = i; j < view_count - 1; j++)
3972 view_set[j] = view_set[j + 1];
3976 _DtHideDialog (dialog_data, True);
3978 file_mgr_rec = (FileMgrRec *)file_mgr_data->file_mgr_rec;
3979 file_window = (XmManagerWidget)file_mgr_rec->file_window;
3980 /* For next time, unmanage all the icons */
3981 XtUnmanageChildren(file_window->composite.children,
3982 file_window->composite.num_children);
3984 if(PositionFlagSet(file_mgr_data))
3985 SavePositionInfo(file_mgr_data);
3987 /* If it is an Application Manager view, then no point in
3988 caching this dialog, so free it */
3990 if(file_mgr_data->toolbox)
3991 _DtFreeDialog(dialog_data);
3993 _DtFreeDialogData (dialog_data);
4000 /* Update the directory cache list to remove unneeded directories. */
4002 UpdateCachedDirectories (view_set, view_count);
4004 if (openDirType == NEW)
4005 ForceMyIconClosed(host_name, directory_name);
4007 XtFree(directory_name);
4014 /************************************************************************
4017 * This function is called when a view may be changing its
4018 * current directory. It updates the view_set list to the
4019 * new host and directory.
4021 ************************************************************************/
4025 XtPointer file_mgr_data,
4026 char *old_host_name,
4027 char *new_host_name,
4028 char *old_directory_name,
4029 char *new_directory_name )
4034 /* See if the directory is one being viewed */
4036 for (i = 0; i < view_count; i++)
4038 if (((DialogData *) (view_set[i]->dialog_data))->data == file_mgr_data)
4040 if (strcmp (old_host_name, view_set[i]->host_name) == 0 &&
4041 strcmp (old_directory_name, view_set[i]->directory_name) == 0)
4043 XtFree ((char *) view_set[i]->host_name);
4044 view_set[i]->host_name = XtNewString (new_host_name);
4046 XtFree ((char *) view_set[i]->directory_name);
4047 view_set[i]->directory_name = XtNewString (new_directory_name);
4053 /* Update the directory cache list to remove unneeded directories. */
4055 UpdateCachedDirectories (view_set, view_count);
4060 /************************************************************************
4063 * Dispatch ToolTalk events to internal handlers.
4065 ************************************************************************/
4067 static Tt_callback_action
4076 op = tt_message_op( msg );
4077 status = tt_ptr_error( op );
4078 if ((status != TT_OK) || (op == 0)) {
4079 /* Let tttk_Xt_input_handler() Do The Right Thing */
4080 return TT_CALLBACK_CONTINUE;
4082 if (strcmp( op, "DtTypes_Reloaded" ) == 0) {
4084 } else if (strcmp( op, "XSession_Ending" ) == 0) {
4085 if( emptyTrashOnExit )
4089 return TT_CALLBACK_CONTINUE;
4092 tttk_message_destroy( msg );
4093 return TT_CALLBACK_PROCESSED;
4096 /************************************************************************
4099 * Dispatch ToolTalk requests to internal handlers.
4101 ************************************************************************/
4112 op = tt_message_op( msg );
4113 status = tt_ptr_error( op );
4114 if ((status != TT_OK) || (op == 0)) {
4115 /* Let tttk_Xt_input_handler() Do The Right Thing */
4116 return TT_CALLBACK_CONTINUE;
4118 if (strcmp( op, "DtFileSession_Run" ) == 0) {
4119 ViewSessionHandler( msg );
4120 } else if (strcmp( op, "DtFolder_Show" ) == 0) {
4121 ViewDirectoryHandler( msg );
4122 } else if (strcmp( op, "DtHome_Show" ) == 0) {
4123 ViewHomeDirectoryHandler( msg );
4124 } else if (strcmp( op, "DtTools_Show" ) == 0) {
4125 ViewToolsDirectoryHandler( msg );
4126 } else if (strcmp( op, "DtTrash_Show" ) == 0) {
4127 TrashDisplayHandler( msg );
4128 } else if (strcmp( op, "DtTrash_Remove" ) == 0) {
4129 TrashRemoveHandler( msg );
4130 } else if (strcmp( op, "DtTrash_Empty" ) == 0) {
4131 TrashEmptyHandler( msg );
4132 } else if (strcmp( op, "DtTrash_File" ) == 0) {
4133 TrashRemoveNoConfirmHandler( msg );
4134 } else if (strcmp( op, "DtTrash_Restore" ) == 0) {
4135 TrashRestoreHandler( msg );
4136 } else if (strcmp( op, "DtFile_PutOnWorkspace" ) == 0) {
4137 PutOnWorkspaceHandler( msg );
4138 } else if (strcmp( op, "DtFile_Move" ) == 0) {
4139 MoveCopyLinkHandler( msg, MOVE_FILE );
4140 } else if (strcmp( op, "DtFile_Copy" ) == 0) {
4141 MoveCopyLinkHandler( msg, COPY_FILE );
4142 } else if (strcmp( op, "DtFile_Link" ) == 0) {
4143 MoveCopyLinkHandler( msg, LINK_FILE );
4146 return TT_CALLBACK_CONTINUE;
4149 return TT_CALLBACK_PROCESSED;
4155 /************************************************************************
4157 * ViewSessionHandler
4158 * This function is called upon the dt session message
4159 * being received. The name of the session file is extracted
4160 * out of the message and a function is called to create
4161 * a view or set of views described by the file.
4163 ************************************************************************/
4169 char *file = tt_message_file( msg );
4170 tt_message_reply( msg );
4171 tttk_message_destroy( msg );
4173 if (! tt_is_err( tt_ptr_error( file )))
4175 if (view_count == 0 && desktop_data->numIconsUsed == 0)
4177 int session_flag = 0;
4180 session_name = strrchr(file, '/');
4182 LoadDesktopInfo(session_name);
4183 session_flag = RestoreSession (session_name, NORMAL_RESTORE, NULL);
4184 if ((session_flag != 0) && (view_count == 0))
4186 char current_directory[MAX_PATH];
4188 GetPWD(current_directory);
4189 if (current_directory[0] != '\0')
4192 (home_host_name, current_directory, NULL, NULL, 0))
4193 ViewHomeDirectoryHandler (0);
4197 ViewHomeDirectoryHandler (0);
4203 char *tmpStr, *msg, *title;
4205 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.");
4206 msg = XtNewString(tmpStr);
4207 title = XtNewString((GETMESSAGE(18,40,"Session Error")));
4208 _DtMessage (toplevel, title, msg, NULL, HelpRequestCB);
4219 /************************************************************************
4221 * ViewDirectoryHandler
4222 * This function is called upon the dt directory message
4223 * being received. The name of the directory is extracted
4224 * out of the message and a function is called to create
4225 * a view of the directory.
4227 ************************************************************************/
4230 ViewDirectoryHandler(
4237 initiating_view = NULL;
4238 msgFile = tt_message_file( msg );
4239 if (tt_is_err( tt_ptr_error( msgFile ))) msgFile = 0;
4243 if(msgFile && strncmp(msgFile, "~", 1) != 0 )
4245 if((strcmp(users_home_dir, "/") != 0) &&
4246 (strncmp(msgFile, users_home_dir, strlen(users_home_dir)-1) != 0))
4248 char *tmpStr, *errTitle, *errMsg, *dmsg;
4250 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
4251 errTitle = XtNewString(tmpStr);
4252 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.");
4253 errMsg = XtNewString(tmpStr);
4254 dmsg = XtMalloc(strlen(errMsg)+strlen(msgFile)+1);
4255 sprintf(dmsg, errMsg, msgFile);
4256 _DtMessage(toplevel, errTitle, dmsg, NULL, HelpRequestCB);
4263 tt_message_reply( msg );
4264 tttk_message_destroy( msg );
4270 numArgs = tt_message_args_count( msg );
4271 if (tt_is_err( tt_int_error( numArgs ))) numArgs = 0;
4274 special_view = True;
4275 special_treeType = UNSET_VALUE;
4276 special_treeFiles = UNSET_VALUE;
4277 special_viewType = UNSET_VALUE;
4278 special_orderType = UNSET_VALUE;
4279 special_directionType = UNSET_VALUE;
4280 special_randomType = UNSET_VALUE;
4281 special_restricted = NULL;
4282 special_title = NULL;
4283 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4284 for(i = 0; i < numArgs; i++)
4288 vtype = tt_message_arg_type( msg, i );
4289 if ((vtype == 0) || (tt_is_err( tt_ptr_error( vtype )))) {
4292 val = tt_message_arg_val( msg, i );
4293 if(strcmp(vtype, "-title") == 0)
4295 special_title = XtNewString(val);
4297 else if(strcmp(vtype, "-help_volume") == 0)
4299 special_helpVol = XtNewString(val);
4301 if(strcmp(vtype, "-tree") == 0)
4303 DtfileStringToTree(val, &special_treeType);
4305 else if(strcmp(vtype, "-tree_files") == 0)
4307 DtfileStringToTreeFiles(val, &special_treeFiles);
4309 else if(strcmp(vtype, VIEW_HEADER) == 0)
4311 DtfileStringToView(val, &special_viewType);
4313 else if(strcmp(vtype, "-order") == 0)
4315 DtfileStringToOrder(val, &special_orderType);
4317 else if(strcmp(vtype, "-direction") == 0)
4319 DtfileStringToDirection(val, &special_directionType);
4321 else if(strcmp(vtype, "-grid") == 0)
4323 DtfileStringToGrid(val, &special_randomType);
4325 else if(strcmp(vtype, RESTRICTED_HEADER) == 0)
4327 special_restricted = XtNewString(msgFile);
4332 if ((restrictMode) && (!special_restricted))
4336 ptr = strrchr(users_home_dir, '/');
4338 special_restricted = XtNewString(users_home_dir);
4343 else if (restrictMode)
4347 special_view = True;
4348 special_treeType = treeType;
4349 special_treeFiles = treeFiles;
4350 special_viewType = viewType;
4351 special_orderType = orderType;
4352 special_directionType = directionType;
4353 special_randomType = randomType;
4355 ptr = strrchr(users_home_dir, '/');
4357 special_restricted = XtNewString(users_home_dir);
4360 special_title = NULL;
4361 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4365 special_view = False;
4367 OpenDirectories (msgFile, NULL);
4370 tt_message_reply( msg );
4371 tttk_message_destroy( msg );
4377 /************************************************************************
4380 * This function is called upon the dt directory message
4381 * being received. The name of the directory is extracted
4382 * out of the message and a function is called to create
4383 * a view of the directory. This function is passed directly
4384 * to DtActionInvoke to be used as a callback.
4386 ************************************************************************/
4395 DialogData *return_data;
4399 if(root_dir && strncmp(root_dir, "~", 1) != 0 )
4401 if((strcmp(users_home_dir, "/") != 0) &&
4402 (strncmp(root_dir, users_home_dir, strlen(users_home_dir)-1) != 0))
4404 char *tmpStr, *errTitle, *errMsg, *dmsg;
4406 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
4407 errTitle = XtNewString(tmpStr);
4408 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.");
4409 errMsg = XtNewString(tmpStr);
4410 dmsg = XtMalloc(strlen(errMsg)+strlen(root_dir)+1);
4411 sprintf(dmsg, errMsg, root_dir);
4412 _DtMessage(toplevel, errTitle, dmsg, NULL, HelpRequestCB);
4422 initiating_view = NULL;
4423 special_view = True;
4424 special_treeType = treeType;
4425 special_treeFiles = treeFiles;
4426 special_viewType = viewType;
4427 special_orderType = orderType;
4428 special_directionType = directionType;
4429 special_randomType = randomType;
4432 special_restricted = XtNewString(root_dir);
4435 special_restricted = NULL;
4438 if ((restrictMode) && (!special_restricted))
4442 ptr = strrchr(users_home_dir, '/');
4444 special_restricted = XtNewString(users_home_dir);
4448 special_title = NULL;
4449 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4451 return_data = GetNewView (home_host_name, root_dir, NULL, NULL, msg);
4453 if ((!return_data) && msg)
4455 tt_message_reply(msg);
4456 tttk_message_destroy( msg );
4459 return(return_data);
4464 /************************************************************************
4466 * ViewHomeDirectoryHandler
4467 * This function is called upon the dt home directory message
4468 * being received. The home directory is extracted from the
4469 * users uid and used to open the directory.
4471 ************************************************************************/
4475 ViewHomeDirectoryHandler(
4478 register int i, j, k;
4479 struct passwd * pwInfo;
4482 char full_path[MAX_PATH + 1];
4483 struct stat stat_buf;
4486 /* We have a new view so set initiating_view to null */
4487 initiating_view = NULL;
4489 if ((homeDir = getenv("HOME")) == NULL || strlen (homeDir) == 0)
4491 pwInfo = getpwuid (getuid());
4492 homeDir = pwInfo->pw_dir;
4495 /* Look and see if we have a default environment file present */
4496 tmp_path = _DtCreateDtDirs(display);
4499 if (msg) numArgs = tt_message_args_count(msg);
4500 if (tt_is_err(tt_int_error(numArgs))) numArgs = 0;
4503 special_view = True;
4504 special_treeType = UNSET_VALUE;
4505 special_treeFiles = UNSET_VALUE;
4506 special_viewType = UNSET_VALUE;
4507 special_orderType = UNSET_VALUE;
4508 special_directionType = UNSET_VALUE;
4509 special_randomType = UNSET_VALUE;
4510 special_restricted = NULL;
4511 special_title = NULL;
4512 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4513 for(i = 0; i < numArgs; i++)
4517 vtype = tt_message_arg_type( msg, i );
4518 if ((vtype == 0) || (tt_is_err( tt_ptr_error( vtype )))) {
4521 val = tt_message_arg_val(msg, i);
4522 if(strcmp(vtype, "-title") == 0)
4524 special_title = XtNewString(val);
4526 else if(strcmp(vtype, "-help_volume") == 0)
4528 special_helpVol = XtNewString(val);
4530 if(strcmp(vtype, "-tree") == 0)
4532 DtfileStringToTree(val, &special_treeType);
4534 else if(strcmp(vtype, "-tree_files") == 0)
4536 DtfileStringToTreeFiles(val, &special_treeFiles);
4538 else if(strcmp(vtype, VIEW_HEADER) == 0)
4540 DtfileStringToView(val, &special_viewType);
4542 else if(strcmp(vtype, "-order") == 0)
4544 DtfileStringToOrder(val, &special_orderType);
4546 else if(strcmp(vtype, "-direction") == 0)
4548 DtfileStringToDirection(val, &special_directionType);
4550 else if(strcmp(vtype, "-grid") == 0)
4552 DtfileStringToGrid(val, &special_randomType);
4554 else if(strcmp(vtype, RESTRICTED_HEADER) == 0)
4556 special_restricted = XtNewString(val);
4562 else if (restrictMode)
4566 special_view = True;
4567 special_treeType = treeType;
4568 special_treeFiles = treeFiles;
4569 special_viewType = viewType;
4570 special_orderType = orderType;
4571 special_directionType = directionType;
4572 special_randomType = randomType;
4574 ptr = strrchr(users_home_dir, '/');
4576 special_restricted = XtNewString(users_home_dir);
4579 special_title = NULL;
4580 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4583 special_view = False;
4585 if (tmp_path == NULL)
4586 OpenDirectories (homeDir, NULL);
4589 sprintf(full_path, "%s/%s", tmp_path, HOME_SETTINGS_FILENAME);
4592 /* Stat the file and make sure its there */
4595 if (stat (full_path, &stat_buf) == 0 && numArgs < 1)
4597 restoreType = HOME_RESTORE;
4598 RestoreSession(full_path, HOME_RESTORE, NULL);
4599 restoreType = NORMAL_RESTORE;
4605 ptr = strrchr(users_home_dir, '/');
4607 strcpy(full_path, users_home_dir);
4609 OpenDirectories (full_path, NULL);
4612 else if (numArgs < 1 && stat (full_path, &stat_buf) == 0)
4614 restoreType = HOME_RESTORE;
4615 RestoreSession(full_path, HOME_RESTORE, NULL);
4616 restoreType = NORMAL_RESTORE;
4622 ptr = strrchr(users_home_dir, '/');
4624 if( ptr != users_home_dir )
4627 strcpy(full_path, users_home_dir);
4630 OpenDirectories (full_path, NULL);
4636 tt_message_reply(msg);
4637 tttk_message_destroy(msg);
4641 /************************************************************************
4643 * ViewToolsDirectroyHandler
4644 * This function is called upon the dt tools message
4645 * being received. The names of the tools directories are
4646 * retrieved from libXue, a view is created and the change
4647 * directory dialog for the view is displayed with the
4648 * set of directories contained in the list.
4650 ************************************************************************/
4653 ViewToolsDirectoryHandler(
4657 char * tmp_path = NULL;
4658 char * tool_dir = NULL;
4659 char * msgFile = NULL;
4662 /* We have a new view so set initiating_view to null */
4663 initiating_view = NULL;
4665 /* Look and see if we have a default environment file present */
4666 tmp_path = _DtCreateDtDirs(display);
4668 if (msg) msgFile = tt_message_file(msg);
4669 if (tt_is_err(tt_ptr_error(msgFile))) msgFile = 0;
4671 if (msg) numArgs = tt_message_args_count(msg);
4672 if (tt_is_err(tt_int_error( numArgs ))) numArgs = 0;
4678 char *link_point = NULL;
4679 char *root_toolbox = NULL;
4680 char *user_install_point = NULL;
4682 special_view = True;
4683 special_treeType = treeType;
4684 special_treeFiles = treeFiles;
4685 special_viewType = viewType;
4686 special_orderType = orderType;
4687 special_directionType = directionType;
4688 special_randomType = randomType;
4689 special_restricted = XtNewString(msgFile);
4690 special_title = NULL;
4691 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4692 for(i = 0; i < numArgs; i++)
4696 vtype = tt_message_arg_type( msg, i );
4697 if ((vtype == 0) || (tt_is_err( tt_ptr_error( vtype )))) {
4700 val = tt_message_arg_val( msg, i );
4701 if(strcmp(vtype, "-title") == 0)
4703 special_title = XtNewString(val);
4705 else if(strcmp(vtype, "-help_volume") == 0)
4707 special_helpVol = XtNewString(val);
4709 else if(strcmp(vtype, "-root") == 0)
4711 root_toolbox = XtNewString(val);
4713 else if(strcmp(vtype, "-common_link_point") == 0)
4715 link_point = XtNewString(val);
4717 else if(strcmp(vtype, "-user_install_point") == 0)
4719 user_install_point = XtNewString(val);
4721 if(strcmp(vtype, "-tree") == 0)
4723 DtfileStringToTree(val, &special_treeType);
4725 else if(strcmp(vtype, "-tree_files") == 0)
4727 DtfileStringToTreeFiles(val, &special_treeFiles);
4729 else if(strcmp(vtype, VIEW_HEADER) == 0)
4731 DtfileStringToView(val, &special_viewType);
4733 else if(strcmp(vtype, "-order") == 0)
4735 DtfileStringToOrder(val, &special_orderType);
4737 else if(strcmp(vtype, "-direction") == 0)
4739 DtfileStringToDirection(val, &special_directionType);
4741 else if(strcmp(vtype, "-grid") == 0)
4743 DtfileStringToGrid(val, &special_randomType);
4745 else if(strcmp(vtype, RESTRICTED_HEADER) == 0)
4752 /* Due to the use of tooltalk messaging, app manager objects
4753 that are dragged either to the desktop or to the front
4754 panel are identified by their fully resolved names (ie.
4755 /usr/dt/appconfig/appmanager/$LANG/.... as opposed to
4756 /var/dt/appconfig/appmanager/$DTUSERSESSION/....). In order
4757 for the File Manager to treat these objects as links existing
4758 in the /var/.... directory, we use the following ugly code:
4760 1. Search the incoming path for $LANG (if you can't find
4761 $LANG, try C since this is the default).
4762 2. Concatenate the path following $LANG to the path for the
4763 root toolbox (this comes in with the tooltalk message
4764 so that we don't have to hardcode it).
4765 3. Call OpenDirectories with the new path that you have
4766 created and with the root toolbox path as the restricted
4769 This problem is further complicated by:
4770 1. Users traversing into APPGROUPs.
4771 2. Users opening the parent folders for workspace APPGROUPs.
4773 For situation 1, File Manager kicks the user into the App Manager
4774 if he/she traverses into an APPGROUP. BUT we don't want to
4775 make modifications to the path as we do above.
4776 So, if there is nothing following $LANG or if we can't find
4778 (ie. /var/dt/appconfig/appmanager/$DTUSERSESSION), call
4779 OpenDirectories with no parameter changes.
4781 For situation 2, File Manager is unable to distinguish between
4782 workspace objects dragged from /usr/.... or /var/...., so
4783 the parent folder for all workspace APPGROUPS is considered to
4784 be in the /var path. In addition to the OpenAppGroup action,
4785 there is an OpenParentAppGroup action which also triggers
4786 ViewToolsDirectoryHandler but sends in an additional
4787 parameter (user_install_point).
4788 If we know that this msg was generated by the OpenParentAppGroup
4790 AND nothing follows $LANG.
4791 Modify the parameters as above.
4792 OR we can't find $LANG but we can find the user_install_point
4793 (user's personal appgroup path).
4794 Concatenate the path following .dt/appmanager to the path for the
4795 root toolbox. Call OpenDirectories with the new path and the
4796 root toolbox as the restricted directory.
4804 if ((user_install_point) &&
4805 (ptr = strstr(msgFile, user_install_point)))
4807 ptr += strlen(user_install_point);
4808 tool_dir = XtMalloc(strlen(root_toolbox) + strlen(ptr) + 1);
4809 sprintf(tool_dir, "%s%s", root_toolbox, ptr);
4810 XtFree(special_restricted);
4811 special_restricted = XtNewString(root_toolbox);
4815 ptr = strstr(msgFile, link_point);
4820 link_point = XtNewString("C");
4821 ptr = strstr(msgFile, link_point);
4826 ptr += strlen(link_point);
4827 if (strcmp(ptr, "") != 0)
4829 tool_dir = XtMalloc(strlen(root_toolbox) +
4831 sprintf(tool_dir, "%s%s", root_toolbox, ptr);
4832 XtFree(special_restricted);
4833 special_restricted = XtNewString(root_toolbox);
4835 else if (user_install_point)
4837 tool_dir = XtNewString(root_toolbox);
4838 XtFree(special_restricted);
4839 special_restricted = XtNewString(root_toolbox);
4846 XtFree(root_toolbox);
4847 XtFree(user_install_point);
4849 else if (restrictMode)
4853 special_view = True;
4854 ptr = strrchr(users_home_dir, '/');
4856 special_restricted = XtNewString(users_home_dir);
4860 special_view = False;
4863 if (tmp_path == NULL)
4866 OpenDirectories (tool_dir, special_restricted);
4867 else if (msgFile != NULL)
4868 OpenDirectories (msgFile, special_restricted);
4872 char full_path[MAX_PATH + 1];
4873 struct stat stat_buf;
4875 sprintf(full_path, "%s/%s", tmp_path, TOOL_SETTINGS_FILENAME);
4878 /* Stat the file and make sure its there */
4879 if (stat (full_path, &stat_buf) == 0 && numArgs > 0)
4881 DialogData * dialog_data;
4882 FileMgrData * file_mgr_data;
4884 restoreType = TOOL_RESTORE;
4886 RestoreSession(full_path, TOOL_RESTORE, tool_dir);
4888 RestoreSession(full_path, TOOL_RESTORE, msgFile);
4889 dialog_data = (DialogData *)view_set[view_count - 1]->dialog_data;
4890 file_mgr_data = (FileMgrData *) dialog_data->data;
4891 application_args.tool_width = file_mgr_data->width;
4892 application_args.tool_height = file_mgr_data->height;
4893 restoreType = NORMAL_RESTORE;
4898 OpenDirectories (tool_dir, special_restricted);
4899 else if (msgFile != NULL)
4900 OpenDirectories (msgFile, special_restricted);
4909 tt_message_reply( msg );
4910 tttk_message_destroy( msg );
4918 /************************************************************************
4921 * This function is called upon the DtSTOP message.
4923 ************************************************************************/
4928 XtPointer clientData,
4929 String * messageFields,
4932 tt_message_reply( msg );
4933 tttk_message_destroy( msg );
4934 FinalizeToolTalkSession( );
4940 * This is the message handling function responsible for reloading
4941 * the filetype and action databases, and then updating our collection
4942 * of action menu items, and updating all open views.
4946 ReloadDatabases(void)
4949 DialogData * dialog_data;
4950 FileMgrData * file_mgr_data;
4951 FileMgrRec * file_mgr_rec;
4952 FileViewData *file_view_data;
4953 DesktopRec *desktopWindow;
4957 XmeFlushIconFileCache ( NULL );
4959 /* Update each directory_set view, both mapped and not */
4960 UpdateDirectorySet();
4962 /* Force action menus to update the next time they're posted */
4963 XtFree(fileMgrPopup.action_pane_file_type);
4964 fileMgrPopup.action_pane_file_type = NULL;
4965 XtFree(desktop_data->popupMenu->action_pane_file_type);
4966 desktop_data->popupMenu->action_pane_file_type = NULL;
4968 /* Update each view */
4969 for (i = 0; i < view_count; i++)
4971 dialog_data = (DialogData *)view_set[i]->dialog_data;
4972 file_mgr_data = (FileMgrData *) dialog_data->data;
4973 file_mgr_rec = (FileMgrRec *) file_mgr_data->file_mgr_rec;
4974 XtFree(file_mgr_rec->action_pane_file_type);
4975 file_mgr_rec->action_pane_file_type = NULL;
4976 UpdateFilterAfterDBReread(file_mgr_data->filter_active);
4977 UpdateFilterAfterDBReread(file_mgr_data->filter_edit);
4978 FileMgrRedisplayFiles(file_mgr_rec, file_mgr_data, False);
4981 /* go through the desktop objects to make sure the icons change
4982 * Do this by setting the logical_type to -l, CheckDesktop will
4983 * then update the logical type and the icon
4985 for(i = 0; i < desktop_data->numIconsUsed; i++)
4987 desktopWindow = desktop_data->desktopWindows[i];
4988 file_view_data = desktopWindow->file_view_data;
4990 file_view_data->file_data->logical_type = NULL;
4997 * Whenever a directory view or drawer view is closed, we need to remove
4998 * any of its text field children, so that they will not magically reappear
4999 * should this view be reused from the cache to view the same directory later.
5004 XtPointer client_data,
5005 DialogData * old_dialog_data,
5006 DialogData * new_dialog_data)
5008 FileMgrRec * file_mgr_rec;
5009 XmManagerWidget file_window;
5013 file_mgr_rec = (FileMgrRec *) _DtGetDialogInstance(old_dialog_data);
5014 file_window = (XmManagerWidget) file_mgr_rec->file_window;
5015 num_children = file_window->composite.num_children;
5017 for (i = 0; i < num_children; i++)
5019 if (XmIsTextField(file_window->composite.children[i]))
5020 XtDestroyWidget(file_window->composite.children[i]);
5023 _DtFreeDialogData (new_dialog_data);
5028 * This function searches the view list, and returns the file_mgr_data
5029 * associated with the passed-in widget.
5037 DialogData * dialog_data;
5038 FileMgrData * file_mgr_data;
5040 for (i = 0; i < view_count; i++)
5042 dialog_data = (DialogData *) view_set[i]->dialog_data;
5043 file_mgr_data = (FileMgrData *) dialog_data->data;
5045 if (w == ((FileMgrRec *)file_mgr_data->file_mgr_rec)->file_window ||
5046 w == ((FileMgrRec *)file_mgr_data->file_mgr_rec)->shell)
5047 return(file_mgr_data);
5055 CheckForOpenDirectory(
5056 FileViewData *order_list,
5057 DirectorySet *directory_set,
5058 FileMgrData *file_mgr_data,
5059 char * logical_type)
5063 char *file_type_name, *new_file_type_name;
5064 char directory_name[MAX_PATH];
5065 char * real_dir_name;
5066 FileMgrRec *file_mgr_rec;
5068 PixmapData *pixmapData = NULL;
5070 if (file_mgr_data->view == BY_NAME_AND_ICON)
5075 file_mgr_rec = (FileMgrRec *)file_mgr_data->file_mgr_rec;
5077 if (strcmp (directory_set->name, "/") != 0)
5078 sprintf( directory_name, "%s/%s", directory_set->name, order_list->file_data->file_name);
5080 sprintf( directory_name, "%s%s", directory_set->name, order_list->file_data->file_name );
5082 (void) DtEliminateDots (directory_name);
5084 real_dir_name = XtNewString(directory_name);
5086 for(i = 0; i < view_count; i++)
5088 if(strcmp(real_dir_name, view_set[i]->directory_name) == 0)
5090 file_type_name = order_list->file_data->logical_type;
5091 new_file_type_name = (char *)XtMalloc(strlen(file_type_name)
5092 + strlen(ICON_OPEN_PREFIX) + 1);
5093 sprintf(new_file_type_name, "%s%s", ICON_OPEN_PREFIX, file_type_name);
5094 pixmapData = _DtRetrievePixmapData(new_file_type_name,
5097 file_mgr_rec->file_window,
5099 XtFree(new_file_type_name);
5103 XtFree(real_dir_name);
5105 if(pixmapData == NULL || pixmapData->iconFileName == NULL)
5107 if( pixmapData != NULL )
5109 DtDtsFreeAttributeValue(pixmapData->hostPrefix);
5110 DtDtsFreeAttributeValue(pixmapData->instanceIconName);
5111 DtDtsFreeAttributeValue(pixmapData->iconName);
5112 XtFree((char *)pixmapData);
5115 pixmapData = _DtRetrievePixmapData(logical_type,
5118 file_mgr_rec->file_window,
5127 * The is the menu callback function for cleaning up a view.
5133 XtPointer client_data,
5134 XtPointer call_data)
5138 FileMgrRec * file_mgr_rec;
5139 DialogData * dialog_data;
5140 FileMgrData * file_mgr_data;
5142 XmManagerWidget file_window;
5144 FileViewData * file_view_data;
5145 XRectangle textExtent;
5148 if ((int)(XtArgVal) client_data == FM_POPUP)
5151 mbar = XmGetPostedFromWidget(XtParent(w));
5154 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
5155 XtGetValues(mbar, args, 1);
5157 /* Ignore accelerators when we're insensitive */
5158 if ((file_mgr_rec->menuStates & CLEAN_UP) == 0)
5161 /* Ignore accelerators received after we're unposted */
5162 if ((dialog_data = _DtGetInstanceData((XtPointer)file_mgr_rec)) == NULL)
5165 file_mgr_data = (FileMgrData *)dialog_data->data;
5167 /* Reset the grid size, so it will be recalculated later. */
5168 file_mgr_data->grid_height = 0;
5169 file_mgr_data->grid_width = 0;
5171 if(file_mgr_data->object_positions)
5172 FreePositionInfo(file_mgr_data);
5174 /* CLEAN_UP_OP is not really a menu state.
5175 It's a flag to let GetFileData in FileMgr.c (call when the directory
5176 is being reread) not to reload icon positions from the .!dt<userid> file.
5178 file_mgr_rec->menuStates |= CLEAN_UP_OP;
5180 /* Re-layout the view */
5181 FileMgrRedisplayFiles(file_mgr_rec, file_mgr_data, False);
5183 if ((file_mgr_data->show_type == SINGLE_DIRECTORY) &&
5184 (file_mgr_data->view != BY_ATTRIBUTES) &&
5185 (file_mgr_data->positionEnabled == RANDOM_ON))
5187 ((PreferencesData *)(file_mgr_data->preferences->data))->positionEnabled =
5192 /* Update the preferences dialog */
5193 ((PreferencesData *)(file_mgr_data->preferences->data))->positionEnabled =
5197 /* Move any text widget, to keep them in sync with their icons */
5198 file_window = (XmManagerWidget)file_mgr_rec->file_window;
5200 for (j = 0; j < file_window->composite.num_children; j++)
5202 if (XmIsTextField(file_window->composite.children[j]) &&
5203 !file_window->composite.children[j]->core.being_destroyed)
5205 XtSetArg(args[0], XmNuserData, &name);
5206 XtGetValues(file_window->composite.children[j], args, 1);
5208 /* Find the associated icon data */
5209 /* @@@ this won't work for tree mode! */
5210 for (i = 0; i < file_mgr_data->directory_set[0]->file_count; i++)
5212 file_view_data = file_mgr_data->directory_set[0]->file_view_data[i];
5213 if (strcmp(name, file_view_data->file_data->file_name) == 0)
5215 _DtIconGetTextExtent_r(file_view_data->widget, &textExtent);
5218 (Dimension)(file_window->composite.children[j]->core.height -
5219 textExtent.height)/(Dimension)2;
5220 XtSetArg (args[0], XmNx, x);
5221 XtSetArg (args[1], XmNy, y);
5222 XtSetValues (file_window->composite.children[j], args, 2);
5229 if ((file_mgr_rec->menuStates & CLEAN_UP_OP))
5230 file_mgr_rec->menuStates &= ~CLEAN_UP_OP;
5233 /*************************************<->*************************************
5235 * DtfileCvtStringToObjPlace (args, numArgs, fromVal, toVal)
5240 * This function converts a string to an desktop placement scheme description.
5245 * args = NULL (don't care)
5247 * numArgs = 0 (don't care)
5249 * fromVal = resource value to convert
5254 * toVal = descriptor to use to return converted value
5256 *************************************<->***********************************/
5259 DtfileCvtStringToObjPlace (
5265 unsigned char *pch = (unsigned char *) (fromVal->addr);
5266 unsigned char *pchNext;
5270 Boolean fPrimarySet = False;
5271 Boolean fSecondarySet = False;
5274 * Icon placement layout values:
5277 #define OBJ_PLACE_BOTTOM_STR (unsigned char *)"bottom"
5278 #define OBJ_PLACE_LEFT_STR (unsigned char *)"left"
5279 #define OBJ_PLACE_RIGHT_STR (unsigned char *)"right"
5280 #define OBJ_PLACE_TOP_STR (unsigned char *)"top"
5284 * Convert the icon placement resource value:
5289 while (*pch && _DtNextToken (pch, &len, &pchNext))
5297 if (_DtStringsAreEquivalent((char *)pch, (char *)OBJ_PLACE_BOTTOM_STR))
5301 cval |= OBJ_PLACE_BOTTOM_PRIMARY;
5304 else if (!fSecondarySet)
5307 (OBJ_PLACE_BOTTOM_PRIMARY | OBJ_PLACE_TOP_PRIMARY)))
5309 cval |= OBJ_PLACE_BOTTOM_SECONDARY;
5310 fSecondarySet = True;
5319 if (_DtStringsAreEquivalent ((char *)pch, (char *)OBJ_PLACE_LEFT_STR))
5323 cval |= OBJ_PLACE_LEFT_PRIMARY;
5326 else if (!fSecondarySet)
5329 (OBJ_PLACE_LEFT_PRIMARY | OBJ_PLACE_RIGHT_PRIMARY)))
5331 cval |= OBJ_PLACE_LEFT_SECONDARY;
5332 fSecondarySet = True;
5340 if (_DtStringsAreEquivalent ((char *)pch, (char *)OBJ_PLACE_RIGHT_STR))
5344 cval |= OBJ_PLACE_RIGHT_PRIMARY;
5347 else if (!fSecondarySet)
5350 (OBJ_PLACE_RIGHT_PRIMARY | OBJ_PLACE_LEFT_PRIMARY)))
5352 cval |= OBJ_PLACE_RIGHT_SECONDARY;
5353 fSecondarySet = True;
5361 if (_DtStringsAreEquivalent ((char *)pch, (char *)OBJ_PLACE_TOP_STR))
5365 cval |= OBJ_PLACE_TOP_PRIMARY;
5368 else if (!fSecondarySet)
5371 (OBJ_PLACE_TOP_PRIMARY | OBJ_PLACE_BOTTOM_PRIMARY)))
5373 cval |= OBJ_PLACE_TOP_SECONDARY;
5374 fSecondarySet = True;
5387 cval = OBJ_PLACE_TOP_PRIMARY;
5391 if (cval & (OBJ_PLACE_LEFT_PRIMARY | OBJ_PLACE_RIGHT_PRIMARY))
5393 cval |= OBJ_PLACE_TOP_SECONDARY;
5396 cval |= OBJ_PLACE_RIGHT_SECONDARY;
5401 (*toVal).size = sizeof (long);
5402 (*toVal).addr = (XtPointer) &cval;
5404 } /* END OF FUNCTION DtfileCvtStringToObjPlace */
5406 /*************************************<->*************************************
5408 * _DtNextToken (pchIn, pLen, ppchNext)
5418 * pchIn = pointer to start of next token
5423 * pLen = pointer to integer containing number of characters in next token
5424 * ppchNext = address of pointer to following token
5426 * Return = next token or NULL
5433 *************************************<->***********************************/
5435 static unsigned char
5437 unsigned char *pchIn,
5439 unsigned char **ppchNext)
5441 unsigned char *pchR = pchIn;
5446 for (i = 0; ((chlen = mblen ((char *)pchIn, MB_CUR_MAX)) > 0); i++)
5447 /* find end of word: requires singlebyte whitespace terminator */
5449 if ((chlen == 1) && isspace (*pchIn))
5457 for (i = 0; *pchIn && !isspace (*pchIn); i++, pchIn++)
5458 /* find end of word */
5463 /* skip to next word */
5465 while (pchIn && (mblen ((char *)pchIn, MB_CUR_MAX) == 1) && isspace (*pchIn))
5467 while (pchIn && isspace (*pchIn))
5484 } /* END OF FUNCTION _DtNextToken */
5486 /*************************************<->*************************************
5488 * DtfileCvtStringToOpenDir (args, numArgs, fromVal, toVal)
5493 * This function converts a string to an desktop placement scheme description.
5498 * args = NULL (don't care)
5500 * numArgs = 0 (don't care)
5502 * fromVal = resource value to convert
5507 * toVal = descriptor to use to return converted value
5509 *************************************<->***********************************/
5512 DtfileCvtStringToOpenDir (
5518 char * in_str = (char *) (fromVal->addr);
5521 toVal->size = sizeof (int);
5522 toVal->addr = (XtPointer) &i;
5524 if (_DtStringsAreEquivalent (in_str, "current"))
5526 else if (_DtStringsAreEquivalent (in_str, "new"))
5535 XtStringConversionWarning ((char *)fromVal->addr, "OpenDir");
5540 /*************************************<->*************************************
5542 * DtfileCvtStringToDTIcon (args, numArgs, fromVal, toVal)
5547 * This function converts a string to an desktop placement scheme description.
5552 * args = NULL (don't care)
5554 * numArgs = 0 (don't care)
5556 * fromVal = resource value to convert
5561 * toVal = descriptor to use to return converted value
5563 *************************************<->***********************************/
5566 DtfileCvtStringToDTIcon (
5572 char * in_str = (char *) (fromVal->addr);
5575 toVal->size = sizeof (int);
5576 toVal->addr = (XtPointer) &i;
5578 if (_DtStringsAreEquivalent (in_str, "large"))
5580 else if (_DtStringsAreEquivalent (in_str, "small"))
5582 else if (_DtStringsAreEquivalent (in_str, "default"))
5583 i = LARGE; /* for now, eventually want to look at screen width/height*/
5591 XtStringConversionWarning ((char *)fromVal->addr, "DesktopIcon");
5597 DtfileCvtStringToTree (
5603 char * in_str = (char *) (fromVal->addr);
5606 toVal->size = sizeof (int);
5607 toVal->addr = (XtPointer) &i;
5609 DtfileStringToTree(in_str, &i);
5613 DtfileCvtStringToTreeFiles (
5619 char * in_str = (char *) (fromVal->addr);
5622 toVal->size = sizeof (int);
5623 toVal->addr = (XtPointer) &i;
5625 DtfileStringToTreeFiles(in_str, &i);
5629 DtfileCvtStringToView (
5635 char * in_str = (char *) (fromVal->addr);
5638 toVal->size = sizeof (int);
5639 toVal->addr = (XtPointer) &i;
5641 DtfileStringToView(in_str, &i);
5645 DtfileCvtStringToOrder (
5651 char * in_str = (char *) (fromVal->addr);
5654 toVal->size = sizeof (int);
5655 toVal->addr = (XtPointer) &i;
5657 DtfileStringToOrder(in_str, &i);
5661 DtfileCvtStringToDirection (
5667 char * in_str = (char *) (fromVal->addr);
5670 toVal->size = sizeof (int);
5671 toVal->addr = (XtPointer) &i;
5673 DtfileStringToDirection(in_str, &i);
5677 DtfileCvtStringToGrid (
5683 char * in_str = (char *) (fromVal->addr);
5686 toVal->size = sizeof (int);
5687 toVal->addr = (XtPointer) &i;
5689 DtfileStringToGrid(in_str, &i);
5698 FileMgrData *file_mgr_data;
5699 DialogData *dialog_data;
5701 for(i = 0; i < view_count; i++)
5703 if(strcmp(directory, view_set[i]->directory_name) == 0 &&
5704 strcmp(host, view_set[i]->host_name) == 0)
5706 dialog_data = (DialogData *) view_set[i]->dialog_data;
5707 file_mgr_data = (FileMgrData *) dialog_data->data;
5708 return(file_mgr_data);
5715 GetRestrictedDirectory (
5719 FileMgrData *file_mgr_data;
5720 FileMgrRec *file_mgr_rec;
5721 DialogData *dialog_data;
5723 for(i = 0; i < view_count; i++)
5725 dialog_data = (DialogData *) view_set[i]->dialog_data;
5726 file_mgr_data = (FileMgrData *) dialog_data->data;
5727 file_mgr_rec = (FileMgrRec *)file_mgr_data->file_mgr_rec;
5728 if(file_mgr_rec->current_directory_text == widget &&
5729 file_mgr_data->fast_cd_enabled)
5731 return(file_mgr_data->restricted_directory);
5734 return((char *)NULL);
5742 if (_DtStringsAreEquivalent (str, "on"))
5743 *type = MULTIPLE_DIRECTORY;
5744 else if (_DtStringsAreEquivalent (str, "off"))
5745 *type = SINGLE_DIRECTORY;
5747 *type = UNSET_VALUE;
5751 DtfileStringToTreeFiles(
5755 if (_DtStringsAreEquivalent (str, "never"))
5756 *type = TREE_FILES_NEVER;
5757 else if (_DtStringsAreEquivalent (str, "choose"))
5758 *type = TREE_FILES_CHOOSE;
5759 else if (_DtStringsAreEquivalent (str, "always"))
5760 *type = TREE_FILES_ALWAYS;
5762 *type = UNSET_VALUE;
5770 if (_DtStringsAreEquivalent (str, "no_icon") ||
5771 _DtStringsAreEquivalent (str, "no_icons"))
5773 else if (_DtStringsAreEquivalent (str, "large_icon") ||
5774 _DtStringsAreEquivalent (str, "large_icons"))
5775 *type = BY_NAME_AND_ICON;
5776 else if (_DtStringsAreEquivalent (str, "small_icon") ||
5777 _DtStringsAreEquivalent (str, "small_icons"))
5778 *type = BY_NAME_AND_SMALL_ICON;
5779 else if (_DtStringsAreEquivalent (str, "attributes"))
5780 *type = BY_ATTRIBUTES;
5782 *type = UNSET_VALUE;
5786 DtfileStringToOrder(
5790 if (_DtStringsAreEquivalent (str, "file_type"))
5791 *type = ORDER_BY_FILE_TYPE;
5792 else if (_DtStringsAreEquivalent (str, "alphabetical"))
5793 *type = ORDER_BY_ALPHABETICAL;
5794 else if (_DtStringsAreEquivalent (str, "date"))
5795 *type = ORDER_BY_DATE;
5796 else if (_DtStringsAreEquivalent (str, "size"))
5797 *type = ORDER_BY_SIZE;
5799 *type = UNSET_VALUE;
5804 DtfileStringToDirection(
5808 if (_DtStringsAreEquivalent (str, "ascending"))
5809 *type = DIRECTION_ASCENDING;
5810 else if (_DtStringsAreEquivalent (str, "descending"))
5811 *type = DIRECTION_DESCENDING;
5813 *type = UNSET_VALUE;
5821 if (_DtStringsAreEquivalent (str, "on"))
5823 else if (_DtStringsAreEquivalent (str, "off"))
5826 *type = UNSET_VALUE;
5830 SetupSendRequestArgs(
5831 ApplicationArgs application_args,
5835 if(application_args.title != NULL)
5837 tt_message_arg_add( msg, TT_IN, "-title", application_args.title );
5839 if(application_args.restricted != NULL)
5841 tt_message_arg_add( msg, TT_IN, RESTRICTED_HEADER, 0 );
5843 vtype = VIEW_HEADER;
5844 switch( application_args.view )
5847 tt_message_arg_add( msg, TT_IN, vtype, "no_icon" );
5849 case BY_NAME_AND_ICON:
5850 tt_message_arg_add( msg, TT_IN, vtype, "large_icon" );
5852 case BY_NAME_AND_SMALL_ICON:
5853 tt_message_arg_add( msg, TT_IN, vtype, "small_icon" );
5856 tt_message_arg_add( msg, TT_IN, vtype, "attributes" );
5859 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5864 switch( application_args.order )
5866 case ORDER_BY_FILE_TYPE:
5867 tt_message_arg_add( msg, TT_IN, vtype, "file_type" );
5869 case ORDER_BY_ALPHABETICAL:
5870 tt_message_arg_add( msg, TT_IN, vtype, "alphabetical" );
5873 tt_message_arg_add( msg, TT_IN, vtype, "date" );
5876 tt_message_arg_add( msg, TT_IN, vtype, "size" );
5879 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5883 vtype = "-direction";
5884 switch( application_args.direction )
5886 case DIRECTION_ASCENDING:
5887 tt_message_arg_add( msg, TT_IN, vtype, "ascending" );
5889 case DIRECTION_DESCENDING:
5890 tt_message_arg_add( msg, TT_IN, vtype, "descending" );
5893 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5898 switch( application_args.grid )
5901 tt_message_arg_add( msg, TT_IN, vtype, "on" );
5904 tt_message_arg_add( msg, TT_IN, vtype, "off" );
5907 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5911 switch( application_args.tree_view )
5913 case MULTIPLE_DIRECTORY:
5914 tt_message_arg_add( msg, TT_IN, vtype, "on" );
5916 case SINGLE_DIRECTORY:
5917 tt_message_arg_add( msg, TT_IN, vtype, "off" );
5920 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5924 vtype = "-tree_files";
5925 switch( application_args.tree_files )
5927 case TREE_FILES_NEVER:
5928 tt_message_arg_add( msg, TT_IN, vtype, "never" );
5930 case TREE_FILES_CHOOSE:
5931 tt_message_arg_add( msg, TT_IN, vtype, "choose" );
5933 case TREE_FILES_ALWAYS:
5934 tt_message_arg_add( msg, TT_IN, vtype, "always" );
5937 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5941 if(application_args.help_volume != NULL)
5943 tt_message_arg_add( msg, TT_IN, "-help_volume",
5944 application_args.help_volume );
5949 * This routine is used by ForceMyIconOpen to get the "Open" filetype and
5950 * find out what the new icon is. It then places that icon in the
5951 * correct icon gadget.
5954 BuildAndShowIconName(
5955 char *file_type_name,
5957 unsigned char show_type,
5960 char *new_file_type_name;
5963 PixmapData *pixmapData;
5965 new_file_type_name = (char *)XtMalloc(strlen(file_type_name) +
5966 strlen(ICON_OPEN_PREFIX) + 1);
5967 sprintf(new_file_type_name, "%s%s", ICON_OPEN_PREFIX, file_type_name);
5969 if (view == BY_NAME_AND_ICON && show_type != MULTIPLE_DIRECTORY)
5970 pixmapData = _DtRetrievePixmapData(new_file_type_name,
5976 pixmapData = _DtRetrievePixmapData(new_file_type_name,
5982 if(pixmapData && pixmapData->iconFileName)
5984 XtSetArg (args[0], XmNimageName, pixmapData->iconFileName);
5985 XtSetValues(widget, args, 1);
5990 XtSetArg (args[0], XmNimageName, NULL);
5991 XtSetValues(widget, args, 1);
5995 _DtCheckAndFreePixmapData(new_file_type_name,
5997 (DtIconGadget) widget,
6000 XtFree(new_file_type_name);
6005 * Given a directory name, this function will see if a view of the parent
6006 * directory is open; if so, then it will update the icon representing
6007 * this icon, in the parent view, so that it is drawn as 'closed'. This
6008 * function must only be called if openDirType == NEW.
6014 char * directory_name)
6020 FileViewData * file_view_data = NULL;
6021 DialogData *dialog_data;
6022 FileMgrData *file_mgr_data;
6023 DesktopRec *desktopWindow;
6026 PixmapData *pixmapData;
6028 /* find the parent directory of the one just removed */
6029 parent = _DtPName(directory_name);
6030 fname = DName(directory_name);
6032 /* first check to see if any File Manager views have this directory */
6033 for (i = 0; i < view_count; i++)
6035 dialog_data = (DialogData *) view_set[i]->dialog_data;
6036 file_mgr_data = (FileMgrData *) dialog_data->data;
6038 /* loop through until we find the file_view_data structure for
6039 * the directory to force open */
6041 for(j = 0; j < file_mgr_data->directory_count; j++)
6043 if (strcmp(parent, file_mgr_data->directory_set[j]->name) == 0)
6045 for (k = 0; k < file_mgr_data->directory_set[j]->file_count; k++)
6048 file_mgr_data->directory_set[j]->file_view_data[k];
6049 if (strcmp(file_view_data->file_data->file_name, fname) == 0)
6059 if( (file_view_data) && (file_mgr_data->view != BY_NAME) )
6061 if (file_mgr_data->view == BY_NAME_AND_ICON &&
6062 file_mgr_data->show_type != MULTIPLE_DIRECTORY)
6063 pixmapData = _DtRetrievePixmapData(
6064 file_view_data->file_data->logical_type,
6067 file_view_data->widget,
6070 pixmapData = _DtRetrievePixmapData(
6071 file_view_data->file_data->logical_type,
6074 file_view_data->widget,
6078 XtSetArg (args[0], XmNimageName, pixmapData->iconFileName);
6080 XtSetArg (args[0], XmNimageName, NULL);
6081 XtSetValues (file_view_data->widget, args, 1);
6083 _DtCheckAndFreePixmapData(file_view_data->file_data->logical_type,
6084 file_view_data->widget,
6085 (DtIconGadget) file_view_data->widget,
6089 /* now check to see if any desktop objects are this directory */
6090 for(j = 0; j < desktop_data->numIconsUsed; j++)
6094 desktopWindow = desktop_data->desktopWindows[j];
6095 file_view_data = desktopWindow->file_view_data;
6097 sprintf(buf, "%s/%s", desktopWindow->dir_linked_to,
6098 desktopWindow->file_name);
6099 DtEliminateDots (buf);
6101 if( (strcmp(buf, directory_name) == 0) &&
6102 (strcmp(desktopWindow->host, host_name) == 0) )
6104 pixmapData = _DtRetrievePixmapData(
6105 file_view_data->file_data->logical_type,
6108 desktopWindow->shell,
6112 XtSetArg (args[0], XmNimageName, pixmapData->iconFileName);
6114 XtSetArg (args[0], XmNimageName, NULL);
6115 XtSetValues (desktopWindow->iconGadget, args, 1);
6117 _DtCheckAndFreePixmapData(
6118 desktopWindow->file_view_data->file_data->logical_type,
6119 desktopWindow->shell,
6120 (DtIconGadget) desktopWindow->iconGadget,
6127 /*************************************************************************
6129 * MarqueeSelect - this is the callback which gets called when there is
6130 * a marquee event happening on the root window.
6132 ************************************************************************/
6141 XtPointer client_data)
6146 Screen *currentScreen;
6148 char *workspace_name=NULL;
6154 case DT_WSM_MARQUEE_SELECTION_TYPE_BEGIN:
6155 display = XtDisplay(desktop_data->desktopWindows[0]->shell);
6156 screen = XDefaultScreen(display);
6157 currentScreen = XScreenOfDisplay(display, screen);
6158 rootWindow = RootWindowOfScreen(currentScreen);
6160 if(DtWsmGetCurrentWorkspace(display, rootWindow, &pCurrent)
6163 workspace_name = XGetAtomName (display, pCurrent);
6164 CleanUpWSName(workspace_name);
6168 XtNewString(desktop_data->workspaceData[0]->name);
6170 for(i = 0; i < desktop_data->numWorkspaces; i++)
6172 if(strcmp(workspace_name,
6173 desktop_data->workspaceData[i]->name) == 0)
6175 DeselectAllDTFiles(desktop_data->workspaceData[i]);
6179 XtFree(workspace_name);
6182 case DT_WSM_MARQUEE_SELECTION_TYPE_END:
6183 CheckDesktopMarquee(x, y, width, height);
6186 case DT_WSM_MARQUEE_SELECTION_TYPE_CANCEL:
6189 case DT_WSM_MARQUEE_SELECTION_TYPE_CONTINUE:
6190 CheckDesktopMarquee(x, y, width, height);
6200 * We must wait for the message response, before exiting
6204 WaitForResponseAndExit( void )
6212 XtPointer clientData,
6217 FinalizeToolTalkSession( );
6223 * Puts up an Error dialog with Cancel and Help unmapped in the
6224 * center of the screen. The last argument is the OK callback
6228 post_dialog(Widget parent, char *title, char *msg, void (*DtErrExitCB)())
6230 Widget dialog, dialogShell;
6231 XmString message_text, ok;
6233 Dimension dialogWd, dialogHt;
6236 ok = XmStringCreateLocalized ((char*)_DtOkString);
6237 message_text = XmStringCreateLocalized (msg);
6239 XtSetArg(args[n], XmNautoUnmanage, False); n++;
6240 XtSetArg(args[n], XmNokLabelString, ok); n++;
6241 XtSetArg(args[n], XmNtitle, title); n++;
6242 XtSetArg(args[n], XmNmessageString, message_text); n++;
6243 XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
6244 XtSetArg (args[n], XmNdefaultPosition, False); n++;
6245 XtSetArg(args[n], XmNuseAsyncGeometry, True); n++;
6247 dialog = XmCreateErrorDialog (parent, title, args, n);
6248 XtAddCallback (dialog, XmNokCallback, DtErrExitCB, NULL);
6249 XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_CANCEL_BUTTON));
6250 XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
6252 /* Disable the frame menu from dialog since we don't want the user
6253 to be able to close dialogs with the frame menu */
6255 dialogShell = XtParent(dialog);
6256 XtSetArg(args[0], XmNmappedWhenManaged, False);
6257 XtSetArg(args[1], XmNmwmDecorations, MWM_DECOR_ALL | MWM_DECOR_MENU);
6258 XtSetValues(dialogShell, args, 2);
6259 XtManageChild (dialog);
6260 XtRealizeWidget (dialogShell);
6262 /* Center the dialog */
6264 XtSetArg(args[0], XmNwidth, &dialogWd);
6265 XtSetArg(args[1], XmNheight, &dialogHt);
6266 XtGetValues(dialog, args, 2);
6267 XtSetArg (args[0], XmNx,
6268 (WidthOfScreen(XtScreen(dialog)) - dialogWd) / 2);
6269 XtSetArg (args[1], XmNy,
6270 (HeightOfScreen(XtScreen(dialog)) - dialogHt) / 2);
6271 XtSetArg (args[2], XmNmappedWhenManaged, True);
6272 XtSetValues (dialog, args, 3);
6274 XtSetArg(args[0], XmNmappedWhenManaged, True);
6275 XtSetValues(dialogShell, args, 1);
6277 XtManageChild (dialog);
6278 XmStringFree(message_text);
6284 * This is the Callback when an error occurs while trying to create
6285 * the .dt folder or sub-folders. Application exits.
6289 DtErrExitCB (Widget dialog, XtPointer client_data, XtPointer call_data)
6291 XtPopdown (XtParent (dialog));
6292 FinalizeToolTalkSession();
6296 #if defined(__osf__) || defined(CSRG_BASED)
6298 sigchld_handler(int signo) /* Do not use the arg signo at the moment */
6304 On DUX, the process remains in the ZOMBIE
6305 state untill parent invokes wait or waitpid.
6308 pid = waitpid(-1, &stat_loc, WNOHANG);
6309 /* Child exit handling code follows, if any */
6311 #endif /* __osf__ */