diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp index 3627670638..4d511bc90d 100644 --- a/src/kits/tracker/Tracker.cpp +++ b/src/kits/tracker/Tracker.cpp @@ -91,6 +91,10 @@ All rights reserved. #include "VolumeWindow.h" +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "Tracker" + + // prototypes for some private kernel calls that will some day be public #ifndef _IMPEXP_ROOT # define _IMPEXP_ROOT @@ -114,6 +118,7 @@ namespace BPrivate { NodePreloader* gPreloader = NULL; + class LaunchLooper : public BLooper { public: LaunchLooper() @@ -147,7 +152,7 @@ public: BLooper* gLaunchLooper = NULL; -// #pragma mark - +// #pragma mark - functions void @@ -237,10 +242,6 @@ public: // #pragma mark - TTracker -#undef B_TRANSLATION_CONTEXT -#define B_TRANSLATION_CONTEXT "Tracker" - - TTracker::TTracker() : BApplication(kTrackerSignature), @@ -329,11 +330,11 @@ TTracker::QuitRequested() // save open windows in a message inside an attribute of the desktop int32 count = fWindowList.CountItems(); for (int32 i = 0; i < count; i++) { - BContainerWindow* window = dynamic_cast - (fWindowList.ItemAt(i)); + BContainerWindow* window + = dynamic_cast(fWindowList.ItemAt(i)); - if (window && window->Lock()) { - if (window->TargetModel() + if (window != NULL && window->Lock()) { + if (window->TargetModel() != NULL && !window->PoseView()->IsDesktopWindow()) { if (window->TargetModel()->IsRoot()) message.AddBool("open_disks_window", true); @@ -375,6 +376,7 @@ TTracker::QuitRequested() } if (!pathAlreadyExists) message.AddString("paths", path.Path()); + message.AddInt8(path.Path(), flags); } } @@ -488,7 +490,6 @@ TTracker::MessageReceived(BMessage* message) break; #ifdef MOUNT_MENU_IN_DESKBAR - case 'gmtv': { // Someone (probably the deskbar) has requested a list of @@ -499,7 +500,6 @@ TTracker::MessageReceived(BMessage* message) message->SendReply(&reply); break; } - #endif case kUnmountVolume: @@ -665,18 +665,20 @@ public: EntryAndNodeDoSoonWithMessageFunctor(FT func, T* target, const entry_ref* child, const node_ref* parent, const BMessage* message) - : fFunc(func), - fTarget(target), - fNode(*parent), - fEntry(*child) - { - fSendMessage = (message != NULL); - if (message) - fMessage = *message; - } + : + fFunc(func), + fTarget(target), + fNode(*parent), + fEntry(*child) + { + fSendMessage = message != NULL; + if (message != NULL) + fMessage = *message; + } virtual ~EntryAndNodeDoSoonWithMessageFunctor() {} - virtual void operator()() { + virtual void operator()() + { result = (fTarget->*fFunc)(&fEntry, &fNode, fSendMessage ? &fMessage : NULL); } @@ -804,7 +806,8 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose, // This cruft is to support a hacky workaround for // double-clicking broken refs for cifs; should get fixed // in R5 - LaunchBrokenLink(brokenLinkPreferredApp.String(), &refsReceived); + LaunchBrokenLink(brokenLinkPreferredApp.String(), + &refsReceived); } else TrackerLaunch(&refsReceived, true); } @@ -861,8 +864,9 @@ TTracker::RefsReceived(BMessage* message) TrackerLaunch(&handlingApp, message, true); break; } - } // fall thru, opening refs by the Tracker as if they were - // double-clicked + } + // fall thru, opening refs by the Tracker as if they were + // double-clicked case kOpen: { // copy over "Poses" messenger so that refs received @@ -1417,7 +1421,7 @@ TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter) } } - // Open disks window if needed + // open disks window if needed if (pathFilter == NULL && TrackerSettings().ShowDisksIcon() && message.HasBool("open_disks_window")) { @@ -1537,7 +1541,7 @@ TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose) { AutoLock lock(&fWindowList); BContainerWindow* parentWindow = FindContainerWindow(&parent); - if (parentWindow) { + if (parentWindow != NULL) { AutoLock lock(parentWindow); parentWindow->PoseView()->SelectPoseAtLocation(pointInPose); } @@ -1551,7 +1555,7 @@ TTracker::CloseParentWaitingForChild(const entry_ref* child, AutoLock lock(&fWindowList); BContainerWindow* parentWindow = FindContainerWindow(parent); - if (!parentWindow) { + if (parentWindow == NULL) { // parent window already closed, give up return true; } @@ -1564,11 +1568,12 @@ TTracker::CloseParentWaitingForChild(const entry_ref* child, resolvedChild = *child; BContainerWindow* window = FindContainerWindow(&resolvedChild); - if (window) { + if (window != NULL) { AutoLock lock(window); if (!window->IsHidden()) return CloseParentWindowCommon(parentWindow); } + return false; } @@ -1634,7 +1639,7 @@ TTracker::SelectChildInParent(const entry_ref* parent, const node_ref* child) BPoseView* view = window->PoseView(); int32 index; BPose* pose = view->FindPose(child, &index); - if (pose) { + if (pose != NULL) { view->SelectPose(pose, index); return true; } diff --git a/src/kits/tracker/Tracker.h b/src/kits/tracker/Tracker.h index c35325f934..b36d68666b 100644 --- a/src/kits/tracker/Tracker.h +++ b/src/kits/tracker/Tracker.h @@ -45,6 +45,7 @@ All rights reserved. #include "tracker_private.h" + namespace BPrivate { class BClipboardRefsWatcher; @@ -61,6 +62,7 @@ class HexScalarValueSetting; class TaskLoop; class TrackerSettingsWindow; + typedef LockingList WindowList; // this is because MW can't handle nested templates @@ -69,166 +71,166 @@ const uint32 kNextSpecifier = 'snxt'; const uint32 kPreviousSpecifier = 'sprv'; const uint32 B_ENTRY_SPECIFIER = 'sref'; + #define kPropertyEntry "Entry" #define kPropertySelection "Selection" - class TTracker : public BApplication { - public: - TTracker(); - virtual ~TTracker(); +public: + TTracker(); + virtual ~TTracker(); - // BApplication overrides - virtual void Quit(); - virtual bool QuitRequested(); - virtual void ReadyToRun(); - virtual void MessageReceived(BMessage*); - virtual void Pulse(); - virtual void RefsReceived(BMessage*); - virtual void ArgvReceived(int32 argc, char** argv); + // BApplication overrides + virtual void Quit(); + virtual bool QuitRequested(); + virtual void ReadyToRun(); + virtual void MessageReceived(BMessage*); + virtual void Pulse(); + virtual void RefsReceived(BMessage*); + virtual void ArgvReceived(int32 argc, char** argv); - MimeTypeList* MimeTypes() const; - // list of mime types that have a description and do not have - // themselves as a preferred handler (case of applications) + MimeTypeList* MimeTypes() const; + // list of mime types that have a description and do not have + // themselves as a preferred handler (case of applications) - bool TrashFull() const; - bool IsTrashNode(const node_ref*) const; - bool InTrashNode(const entry_ref*) const; + bool TrashFull() const; + bool IsTrashNode(const node_ref*) const; + bool InTrashNode(const entry_ref*) const; - void CloseParentWaitingForChildSoon(const entry_ref* child, - const node_ref* parent); - // closes parent, waits for child to open first + void CloseParentWaitingForChildSoon(const entry_ref* child, + const node_ref* parent); + // closes parent, waits for child to open first - void SelectChildInParentSoon(const entry_ref* child, - const node_ref* parent); - // waits till child shows up in parent and selects it + void SelectChildInParentSoon(const entry_ref* child, + const node_ref* parent); + // waits till child shows up in parent and selects it - void SelectPoseAtLocationSoon(node_ref parent, BPoint location); - // Used to select next item when deleting in list view mode + void SelectPoseAtLocationSoon(node_ref parent, BPoint location); + // Used to select next item when deleting in list view mode - enum OpenSelector { - kOpen, - kOpenWith, - kRunOpenWithWindow - }; + enum OpenSelector { + kOpen, + kOpenWith, + kRunOpenWithWindow + }; - bool EntryHasWindowOpen(const entry_ref*); - // return true if there is an open window for an entry + bool EntryHasWindowOpen(const entry_ref*); + // return true if there is an open window for an entry - status_t NeedMoreNodeMonitors(); - // call if ran out of node monitors to allocate more - // return false if already using all we can get - static status_t WatchNode(const node_ref*, uint32 flags, - BMessenger target); - // cover call for watch_node; if first watch_node fails, - // tries bumping the node monitor limit and calls watch_node - // again + status_t NeedMoreNodeMonitors(); + // call if ran out of node monitors to allocate more + // return false if already using all we can get + static status_t WatchNode(const node_ref*, uint32 flags, + BMessenger target); + // cover call for watch_node; if first watch_node fails, + // tries bumping the node monitor limit and calls watch_node + // again - TaskLoop* MainTaskLoop() const; - BMessenger MountServer() const; + TaskLoop* MainTaskLoop() const; + BMessenger MountServer() const; - bool QueryActiveForDevice(dev_t); - void CloseActiveQueryWindows(dev_t); + bool QueryActiveForDevice(dev_t); + void CloseActiveQueryWindows(dev_t); - void SaveAllPoseLocations(); + void SaveAllPoseLocations(); - void CloseParent(node_ref closeThis); + void CloseParent(node_ref closeThis); - void ShowSettingsWindow(); + void ShowSettingsWindow(); - BContainerWindow* FindContainerWindow(const node_ref*, - int32 number = 0) const; - BContainerWindow* FindContainerWindow(const entry_ref*, - int32 number = 0) const; - BContainerWindow* FindParentContainerWindow(const entry_ref*) const; - // right now works just on plain windows, not on query windows + BContainerWindow* FindContainerWindow(const node_ref*, + int32 number = 0) const; + BContainerWindow* FindContainerWindow(const entry_ref*, + int32 number = 0) const; + BContainerWindow* FindParentContainerWindow(const entry_ref*) const; + // right now works just on plain windows, not on query windows - BClipboardRefsWatcher* ClipboardRefsWatcher() const; + BClipboardRefsWatcher* ClipboardRefsWatcher() const; - protected: - // scripting - virtual BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, - int32, const char*); - virtual status_t GetSupportedSuites(BMessage*); +protected: + // scripting + virtual BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, + int32, const char*); + virtual status_t GetSupportedSuites(BMessage*); - bool HandleScriptingMessage(BMessage*); + bool HandleScriptingMessage(BMessage*); - bool ExecuteProperty(BMessage*, int32, const char*, BMessage*); - bool CreateProperty(BMessage*, BMessage*, int32, const char*, - BMessage*); - bool DeleteProperty(BMessage*, int32, - const char*, BMessage*); - bool CountProperty(BMessage*, int32, const char*, BMessage*); - bool GetProperty(BMessage*, int32, const char*, BMessage*); - bool SetProperty(BMessage*, BMessage*, int32, const char*, BMessage*); + bool ExecuteProperty(BMessage*, int32, const char*, BMessage*); + bool CreateProperty(BMessage*, BMessage*, int32, const char*, + BMessage*); + bool DeleteProperty(BMessage*, int32, + const char*, BMessage*); + bool CountProperty(BMessage*, int32, const char*, BMessage*); + bool GetProperty(BMessage*, int32, const char*, BMessage*); + bool SetProperty(BMessage*, BMessage*, int32, const char*, BMessage*); - private: - class WatchingInterface; +private: + class WatchingInterface; - private: - // callbacks for ChildParentSoon calls - bool CloseParentWaitingForChild(const entry_ref* child, - const node_ref* parent); - bool LaunchAndCloseParentIfOK(const entry_ref* launchThis, - const node_ref* closeThis, const BMessage* messageToBundle); - bool SelectChildInParent(const entry_ref* child, - const node_ref* parent); - void SelectPoseAtLocationInParent(node_ref parent, BPoint location); - bool CloseParentWindowCommon(BContainerWindow*); +private: + // callbacks for ChildParentSoon calls + bool CloseParentWaitingForChild(const entry_ref* child, + const node_ref* parent); + bool LaunchAndCloseParentIfOK(const entry_ref* launchThis, + const node_ref* closeThis, const BMessage* messageToBundle); + bool SelectChildInParent(const entry_ref* child, + const node_ref* parent); + void SelectPoseAtLocationInParent(node_ref parent, BPoint location); + bool CloseParentWindowCommon(BContainerWindow*); - void InitMimeTypes(); - bool InstallMimeIfNeeded(const char* type, int32 bitsID, - const char* shortDescription, const char* longDescription, - const char* preferredAppSignature, uint32 forceMask = 0); - // used by InitMimeTypes - checks if a metamime of a given - // is installed and if it has all the specified attributes; - // if not, the whole mime type is installed and all attributes - // are set; nulls can be passed for attributes that don't matter; - // returns true if anything had to be changed can be - // used to forcibly set a metamime attribute, even if it exists + void InitMimeTypes(); + bool InstallMimeIfNeeded(const char* type, int32 bitsID, + const char* shortDescription, const char* longDescription, + const char* preferredAppSignature, uint32 forceMask = 0); + // used by InitMimeTypes - checks if a metamime of a given + // is installed and if it has all the specified attributes; + // if not, the whole mime type is installed and all attributes + // are set; nulls can be passed for attributes that don't matter; + // returns true if anything had to be changed can be + // used to forcibly set a metamime attribute, even if it exists - void InstallDefaultTemplates(); - void InstallTemporaryBackgroundImages(); + void InstallDefaultTemplates(); + void InstallTemporaryBackgroundImages(); - void InstallIndices(); - void InstallIndices(dev_t); + void InstallIndices(); + void InstallIndices(dev_t); - void CloseAllWindows(); - void CloseWindowAndChildren(const node_ref*); - void CloseAllInWorkspace(); - void OpenInfoWindows(BMessage*); - void MoveRefsToTrash(const BMessage*); - void OpenContainerWindow(Model*, BMessage* refsList = NULL, - OpenSelector openSelector = kOpen, uint32 openFlags = 0, - bool checkAlreadyOpen = true, - const BMessage* stateMessage = NULL); - // pass either a Model or a list of entries to open - void _OpenPreviouslyOpenedWindows(const char* pathFilter = NULL); + void CloseAllWindows(); + void CloseWindowAndChildren(const node_ref*); + void CloseAllInWorkspace(); + void OpenInfoWindows(BMessage*); + void MoveRefsToTrash(const BMessage*); + void OpenContainerWindow(Model*, BMessage* refsList = NULL, + OpenSelector openSelector = kOpen, uint32 openFlags = 0, + bool checkAlreadyOpen = true, + const BMessage* stateMessage = NULL); + // pass either a Model or a list of entries to open + void _OpenPreviouslyOpenedWindows(const char* pathFilter = NULL); - void SetDefaultPrinter(const BMessage*); - void EditQueries(const BMessage*); + void SetDefaultPrinter(const BMessage*); + void EditQueries(const BMessage*); - BInfoWindow* FindInfoWindow(const node_ref*) const; + BInfoWindow* FindInfoWindow(const node_ref*) const; - BDeskWindow* GetDeskWindow() const; + BDeskWindow* GetDeskWindow() const; - status_t OpenRef(const entry_ref*, const node_ref* nodeToClose = NULL, - const node_ref* nodeToSelect = NULL, - OpenSelector selector = kOpen, - const BMessage* messageToBundle = NULL); + status_t OpenRef(const entry_ref*, const node_ref* nodeToClose = NULL, + const node_ref* nodeToSelect = NULL, + OpenSelector selector = kOpen, + const BMessage* messageToBundle = NULL); - MimeTypeList* fMimeTypeList; - WindowList fWindowList; - BClipboardRefsWatcher* fClipboardRefsWatcher; - BTrashWatcher* fTrashWatcher; - TaskLoop* fTaskLoop; - int32 fNodeMonitorCount; - WatchingInterface* fWatchingInterface; + MimeTypeList* fMimeTypeList; + WindowList fWindowList; + BClipboardRefsWatcher* fClipboardRefsWatcher; + BTrashWatcher* fTrashWatcher; + TaskLoop* fTaskLoop; + int32 fNodeMonitorCount; + WatchingInterface* fWatchingInterface; - TrackerSettingsWindow* fSettingsWindow; + TrackerSettingsWindow* fSettingsWindow; - typedef BApplication _inherited; + typedef BApplication _inherited; }; @@ -249,4 +251,5 @@ TTracker::ClipboardRefsWatcher() const using namespace BPrivate; + #endif // _TRACKER_H