1 /* 2 Open Tracker License 3 4 Terms and Conditions 5 6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 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: 14 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. 17 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. 24 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. 28 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. 32 All rights reserved. 33 */ 34 35 #ifndef _TRACKER_H 36 #define _TRACKER_H 37 38 #include <Application.h> 39 #include <Resources.h> 40 #include <Entry.h> 41 42 #include "LockingList.h" 43 #include "SettingsHandler.h" 44 #include "Utilities.h" 45 46 #include "tracker_private.h" 47 48 namespace BPrivate { 49 50 class BClipboardRefsWatcher; 51 class BContainerWindow; 52 class BDeskWindow; 53 class BInfoWindow; 54 class BTrashWatcher; 55 class ExtraAttributeLazyInstaller; 56 class MimeTypeList; 57 class Model; 58 class BooleanValueSetting; 59 class ScalarValueSetting; 60 class HexScalarValueSetting; 61 class TaskLoop; 62 class TrackerSettingsWindow; 63 64 typedef LockingList<BWindow> WindowList; 65 // this is because MW can't handle nested templates 66 67 68 const uint32 kNextSpecifier = 'snxt'; 69 const uint32 kPreviousSpecifier = 'sprv'; 70 const uint32 B_ENTRY_SPECIFIER = 'sref'; 71 72 #define kPropertyEntry "Entry" 73 #define kPropertySelection "Selection" 74 75 76 77 class TTracker : public BApplication { 78 public: 79 TTracker(); 80 virtual ~TTracker(); 81 82 // BApplication overrides 83 virtual void Quit(); 84 virtual bool QuitRequested(); 85 virtual void ReadyToRun(); 86 virtual void MessageReceived(BMessage *); 87 virtual void Pulse(); 88 virtual void RefsReceived(BMessage *); 89 virtual void ArgvReceived(int32 argc, char **argv); 90 91 MimeTypeList *MimeTypes() const; 92 // list of mime types that have a description and do not have 93 // themselves as a preferred handler (case of applications) 94 95 bool TrashFull() const; 96 bool IsTrashNode(const node_ref *) const; 97 bool InTrashNode(const entry_ref *) const; 98 99 void CloseParentWaitingForChildSoon(const entry_ref *child, 100 const node_ref *parent); 101 // closes parent, waits for child to open first 102 103 void SelectChildInParentSoon(const entry_ref *child, 104 const node_ref *parent); 105 // waits till child shows up in parent and selects it 106 107 void SelectPoseAtLocationSoon(node_ref parent, BPoint location); 108 // Used to select next item when deleting in list view mode 109 110 enum OpenSelector { 111 kOpen, 112 kOpenWith, 113 kRunOpenWithWindow 114 }; 115 116 bool EntryHasWindowOpen(const entry_ref *); 117 // return true if there is an open window for an entry 118 119 status_t NeedMoreNodeMonitors(); 120 // call if ran out of node monitors to allocate more 121 // return false if already using all we can get 122 static status_t WatchNode(const node_ref *, uint32 flags, 123 BMessenger target); 124 // cover call for watch_node; if first watch_node fails, 125 // tries bumping the node monitor limit and calls watch_node 126 // again 127 128 TaskLoop *MainTaskLoop() const; 129 BMessenger MountServer() const; 130 131 bool QueryActiveForDevice(dev_t); 132 void CloseActiveQueryWindows(dev_t); 133 134 void SaveAllPoseLocations(); 135 136 void CloseParent(node_ref closeThis); 137 138 void ShowSettingsWindow(); 139 140 BContainerWindow *FindContainerWindow(const node_ref *, int32 number = 0) const; 141 BContainerWindow *FindContainerWindow(const entry_ref *, int32 number = 0) const; 142 BContainerWindow *FindParentContainerWindow(const entry_ref *) const; 143 // right now works just on plain windows, not on query windows 144 145 BClipboardRefsWatcher *ClipboardRefsWatcher() const; 146 147 protected: 148 // scripting 149 virtual BHandler *ResolveSpecifier(BMessage *, int32, BMessage *, 150 int32, const char *); 151 virtual status_t GetSupportedSuites(BMessage *); 152 153 bool HandleScriptingMessage(BMessage *); 154 155 bool ExecuteProperty(BMessage *, int32, const char *, BMessage *); 156 bool CreateProperty(BMessage *, BMessage *, int32, const char *, 157 BMessage *); 158 bool DeleteProperty(BMessage *, int32, 159 const char *, BMessage *); 160 bool CountProperty(BMessage *, int32, const char *, BMessage *); 161 bool GetProperty(BMessage *, int32, const char *, BMessage *); 162 bool SetProperty(BMessage *, BMessage *, int32, const char *, BMessage *); 163 164 private: 165 // callbacks for ChildParentSoon calls 166 bool CloseParentWaitingForChild(const entry_ref *child, 167 const node_ref *parent); 168 bool LaunchAndCloseParentIfOK(const entry_ref *launchThis, 169 const node_ref *closeThis, const BMessage *messageToBundle); 170 bool SelectChildInParent(const entry_ref *child, 171 const node_ref *parent); 172 void SelectPoseAtLocationInParent(node_ref parent, BPoint location); 173 bool CloseParentWindowCommon(BContainerWindow *); 174 175 void InitMimeTypes(); 176 bool InstallMimeIfNeeded(const char *type, int32 bitsID, 177 const char *shortDescription, const char *longDescription, 178 const char *preferredAppSignature, uint32 forceMask = 0); 179 // used by InitMimeTypes - checks if a metamime of a given <type> is 180 // installed and if it has all the specified attributes; if not, the 181 // whole mime type is installed and all attributes are set; nulls can 182 // be passed for attributes that don't matter; returns true if anything 183 // had to be changed 184 // <forceMask> can be used to forcibly set a metamime attribute, even if it exists 185 186 void InstallDefaultTemplates(); 187 void InstallTemporaryBackgroundImages(); 188 189 void InstallIndices(); 190 void InstallIndices(dev_t); 191 192 void CloseAllWindows(); 193 void CloseWindowAndChildren(const node_ref *); 194 void CloseAllInWorkspace(); 195 void OpenInfoWindows(BMessage*); 196 void MoveRefsToTrash(const BMessage *); 197 void OpenContainerWindow(Model *, BMessage *refsList = NULL, 198 OpenSelector openSelector = kOpen, uint32 openFlags = 0, 199 bool checkAlreadyOpen = true, const BMessage *stateMessage = NULL); 200 // pass either a Model or a list of entries to open 201 void _OpenPreviouslyOpenedWindows(const char* pathFilter = NULL); 202 203 void SetDefaultPrinter(const BMessage *); 204 void EditQueries(const BMessage *); 205 206 BInfoWindow *FindInfoWindow(const node_ref *) const; 207 208 BDeskWindow *GetDeskWindow() const; 209 210 status_t OpenRef(const entry_ref *, const node_ref *nodeToClose = NULL, 211 const node_ref *nodeToSelect = NULL, OpenSelector selector = kOpen, 212 const BMessage *messageToBundle = NULL); 213 214 MimeTypeList *fMimeTypeList; 215 WindowList fWindowList; 216 BClipboardRefsWatcher *fClipboardRefsWatcher; 217 BTrashWatcher *fTrashWatcher; 218 TaskLoop *fTaskLoop; 219 int32 fNodeMonitorCount; 220 221 TrackerSettingsWindow *fSettingsWindow; 222 223 typedef BApplication _inherited; 224 }; 225 226 227 inline TaskLoop * 228 TTracker::MainTaskLoop() const 229 { 230 return fTaskLoop; 231 } 232 233 inline BClipboardRefsWatcher * 234 TTracker::ClipboardRefsWatcher() const 235 { 236 return fClipboardRefsWatcher; 237 } 238 239 } // namespace BPrivate 240 241 using namespace BPrivate; 242 243 #endif /* _TRACKER_H */ 244