Tracker: style fixes to Tracker class

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