6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
38 #include <Application.h>
39 #include <Resources.h>
42 #include "LockingList.h"
43 #include "SettingsHandler.h"
44 #include "Utilities.h"
46 #include "tracker_private.h"
51 class BClipboardRefsWatcher
;
52 class BContainerWindow
;
56 class ExtraAttributeLazyInstaller
;
59 class BooleanValueSetting
;
60 class ScalarValueSetting
;
61 class HexScalarValueSetting
;
63 class TrackerSettingsWindow
;
66 typedef LockingList
<BWindow
> WindowList
;
67 // this is because MW can't handle nested templates
70 const uint32 kNextSpecifier
= 'snxt';
71 const uint32 kPreviousSpecifier
= 'sprv';
72 const uint32 B_ENTRY_SPECIFIER
= 'sref';
75 #define kPropertyEntry "Entry"
76 #define kPropertySelection "Selection"
79 class TTracker
: public BApplication
{
84 // BApplication overrides
86 virtual bool QuitRequested();
87 virtual void ReadyToRun();
88 virtual void MessageReceived(BMessage
* message
);
90 virtual void RefsReceived(BMessage
* message
);
91 virtual void ArgvReceived(int32 argc
, char** argv
);
93 MimeTypeList
* MimeTypes() const;
94 // list of mime types that have a description and do not have
95 // themselves as a preferred handler (case of applications)
97 bool TrashFull() const;
98 bool IsTrashNode(const node_ref
* node
) const;
99 bool InTrashNode(const entry_ref
* ref
) const;
101 void CloseParentWaitingForChildSoon(const entry_ref
* child
,
102 const node_ref
* parent
);
103 // closes parent, waits for child to open first
105 void SelectChildInParentSoon(const entry_ref
* child
,
106 const node_ref
* parent
);
107 // waits till child shows up in parent and selects it
109 void SelectPoseAtLocationSoon(node_ref parent
, BPoint location
);
110 // Used to select next item when deleting in list view mode
118 bool EntryHasWindowOpen(const entry_ref
*);
119 // return true if there is an open window for an entry
121 status_t
NeedMoreNodeMonitors();
122 // call if ran out of node monitors to allocate more
123 // return false if already using all we can get
124 static status_t
WatchNode(const node_ref
*, uint32 flags
,
126 // cover call for watch_node; if first watch_node fails,
127 // tries bumping the node monitor limit and calls watch_node
130 TaskLoop
* MainTaskLoop() const;
131 BMessenger
MountServer() const;
133 bool QueryActiveForDevice(dev_t
);
134 void CloseActiveQueryWindows(dev_t
);
136 void SaveAllPoseLocations();
138 void CloseParent(node_ref closeThis
);
140 void ShowSettingsWindow();
142 BContainerWindow
* FindContainerWindow(const node_ref
*,
143 int32 number
= 0) const;
144 BContainerWindow
* FindContainerWindow(const entry_ref
*,
145 int32 number
= 0) const;
146 BContainerWindow
* FindParentContainerWindow(const entry_ref
*) const;
147 // right now works just on plain windows, not on query windows
149 BClipboardRefsWatcher
* ClipboardRefsWatcher() const;
153 virtual BHandler
* ResolveSpecifier(BMessage
*, int32
, BMessage
*,
155 virtual status_t
GetSupportedSuites(BMessage
*);
157 bool HandleScriptingMessage(BMessage
*);
159 bool ExecuteProperty(BMessage
*, int32
, const char*, BMessage
*);
160 bool CreateProperty(BMessage
*, BMessage
*, int32
, const char*,
162 bool DeleteProperty(BMessage
*, int32
,
163 const char*, BMessage
*);
164 bool CountProperty(BMessage
*, int32
, const char*, BMessage
*);
165 bool GetProperty(BMessage
*, int32
, const char*, BMessage
*);
166 bool SetProperty(BMessage
*, BMessage
*, int32
, const char*, BMessage
*);
169 class WatchingInterface
;
172 // callbacks for ChildParentSoon calls
173 bool CloseParentWaitingForChild(const entry_ref
* child
,
174 const node_ref
* parent
);
175 bool LaunchAndCloseParentIfOK(const entry_ref
* launchThis
,
176 const node_ref
* closeThis
, const BMessage
* messageToBundle
);
177 bool SelectChildInParent(const entry_ref
* child
,
178 const node_ref
* parent
);
179 void SelectPoseAtLocationInParent(node_ref parent
, BPoint location
);
180 bool CloseParentWindowCommon(BContainerWindow
*);
182 void InitMimeTypes();
183 bool InstallMimeIfNeeded(const char* type
, int32 bitsID
,
184 const char* shortDescription
, const char* longDescription
,
185 const char* preferredAppSignature
, uint32 forceMask
= 0);
186 // used by InitMimeTypes - checks if a metamime of a given <type>
187 // is installed and if it has all the specified attributes;
188 // if not, the whole mime type is installed and all attributes
189 // are set; nulls can be passed for attributes that don't matter;
190 // returns true if anything had to be changed <forceMask> can be
191 // used to forcibly set a metamime attribute, even if it exists
193 void InstallDefaultTemplates();
194 void InstallTemporaryBackgroundImages();
196 void InstallIndices();
197 void InstallIndices(dev_t
);
199 void CloseAllWindows();
200 void CloseWindowAndChildren(const node_ref
*);
201 void CloseAllInWorkspace();
202 void OpenInfoWindows(BMessage
*);
203 void MoveRefsToTrash(const BMessage
*);
204 void SelectRefs(const BMessage
*);
205 void OpenContainerWindow(Model
*, BMessage
* refsList
= NULL
,
206 OpenSelector openSelector
= kOpen
, uint32 openFlags
= 0,
207 bool checkAlreadyOpen
= true,
208 const BMessage
* stateMessage
= NULL
);
209 // pass either a Model or a list of entries to open
210 void _OpenPreviouslyOpenedWindows(const char* pathFilter
= NULL
);
212 void SetDefaultPrinter(const BMessage
*);
213 void EditQueries(const BMessage
*);
215 BInfoWindow
* FindInfoWindow(const node_ref
*) const;
217 BDeskWindow
* GetDeskWindow() const;
219 status_t
OpenRef(const entry_ref
*, const node_ref
* nodeToClose
= NULL
,
220 const node_ref
* nodeToSelect
= NULL
,
221 OpenSelector selector
= kOpen
,
222 const BMessage
* messageToBundle
= NULL
);
224 MimeTypeList
* fMimeTypeList
;
225 WindowList fWindowList
;
226 BClipboardRefsWatcher
* fClipboardRefsWatcher
;
227 BTrashWatcher
* fTrashWatcher
;
229 int32 fNodeMonitorCount
;
230 WatchingInterface
* fWatchingInterface
;
232 TrackerSettingsWindow
* fSettingsWindow
;
234 typedef BApplication _inherited
;
239 TTracker::MainTaskLoop() const
245 inline BClipboardRefsWatcher
*
246 TTracker::ClipboardRefsWatcher() const
248 return fClipboardRefsWatcher
;
251 } // namespace BPrivate
253 using namespace BPrivate
;