[Haiku-commits] r31039 - haiku/trunk/src/kits/tracker

bonefish at mail.berlios.de bonefish at mail.berlios.de
Sun Jun 14 12:57:13 CEST 2009


Author: bonefish
Date: 2009-06-14 12:57:09 +0200 (Sun, 14 Jun 2009)
New Revision: 31039
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31039&view=rev

Modified:
   haiku/trunk/src/kits/tracker/FilePanel.cpp
   haiku/trunk/src/kits/tracker/Tracker.cpp
Log:
* Use public functionality instead of private BeOS syscalls.
* Automatic whitespace cleanup.


Modified: haiku/trunk/src/kits/tracker/FilePanel.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/FilePanel.cpp	2009-06-14 00:37:07 UTC (rev 31038)
+++ haiku/trunk/src/kits/tracker/FilePanel.cpp	2009-06-14 10:57:09 UTC (rev 31039)
@@ -34,6 +34,8 @@
 
 // Implementation for the public FilePanel object.
 
+#include <sys/resource.h>
+
 #include <BeBuild.h>
 #include <Debug.h>
 #include <FilePanel.h>
@@ -50,7 +52,6 @@
 #ifndef _IMPEXP_TRACKER
 #	define _IMPEXP_TRACKER
 #endif
-extern "C" _IMPEXP_ROOT int _kset_fd_limit_(int num);
 
 // these two calls are deprecated
 extern _IMPEXP_TRACKER void run_open_panel();
@@ -80,9 +81,13 @@
 {
 	// boost file descriptor limit so file panels in other apps don't have
 	// problems
-	_kset_fd_limit_ (512);
+	struct rlimit rl;
+	rl.rlim_cur = 512;
+	rl.rlim_max = RLIM_SAVED_MAX;
+	setrlimit(RLIMIT_NOFILE, &rl);
+
 	BEntry startDir(ref);
-	fWindow = new TFilePanel(mode, target, &startDir, nodeFlavors, 
+	fWindow = new TFilePanel(mode, target, &startDir, nodeFlavors,
 		multipleSelection, message, filter, 0, B_DOCUMENT_WINDOW_LOOK,
 		modal ? B_MODAL_APP_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL,
 		hideWhenDone);
@@ -109,14 +114,14 @@
 	// just pull it to us
 	uint32 workspace = 1UL << (uint32)current_workspace();
 	uint32 windowWorkspaces = fWindow->Workspaces();
-	if (!(windowWorkspaces & workspace)) 
+	if (!(windowWorkspaces & workspace))
 		// window in a different workspace, reopen in current
 		fWindow->SetWorkspaces(workspace);
 
-	if (!IsShowing()) 
+	if (!IsShowing())
 		fWindow->Show();
 
-	fWindow->Activate();	
+	fWindow->Activate();
 }
 
 void
@@ -198,7 +203,7 @@
 	AutoLock<BWindow> lock(fWindow);
 	if (!lock)
 		return;
-	
+
 	static_cast<TFilePanel *>(fWindow)->Refresh();
 }
 
@@ -228,7 +233,7 @@
 	AutoLock<BWindow> lock(fWindow);
 	if (!lock)
 		return;
-	
+
 	static_cast<TFilePanel *>(fWindow)->SetButtonLabel(button, text);
 }
 
@@ -267,7 +272,7 @@
 {
 	entry_ref ref;
 	status_t err = get_ref_for_path(path, &ref);
-	if (err < B_OK) 
+	if (err < B_OK)
 	  return;
 
 	AutoLock<BWindow> lock(fWindow);
@@ -317,7 +322,7 @@
 	AutoLock<BWindow> lock(fWindow);
 	if (!lock)
 		return B_ERROR;
-	
+
 	return static_cast<TFilePanel *>(fWindow)->GetNextEntryRef(ref);
 
 }
@@ -329,8 +334,8 @@
 	AutoLock<BWindow> lock(fWindow);
 	if (!lock)
 		return;
-	
-	static_cast<TFilePanel *>(fWindow)->SetHideWhenDone(on);  
+
+	static_cast<TFilePanel *>(fWindow)->SetHideWhenDone(on);
 }
 
 bool

Modified: haiku/trunk/src/kits/tracker/Tracker.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/Tracker.cpp	2009-06-14 00:37:07 UTC (rev 31038)
+++ haiku/trunk/src/kits/tracker/Tracker.cpp	2009-06-14 10:57:09 UTC (rev 31039)
@@ -32,8 +32,10 @@
 All rights reserved.
 */
 
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/resource.h>
 #include <unistd.h>
 
 #include <Alert.h>
@@ -90,9 +92,6 @@
 #ifndef _IMPEXP_ROOT
 #	define _IMPEXP_ROOT
 #endif
-extern "C" _IMPEXP_ROOT int _kset_fd_limit_(int num);
-extern "C" _IMPEXP_ROOT int _kset_mon_limit_(int num);
-	// from priv_syscalls.h
 
 const int32 DEFAULT_MON_NUM = 4096;
 	// copied from fsil.c
@@ -109,14 +108,14 @@
 
 NodePreloader *gPreloader = NULL;
 
-void 
+void
 InitIconPreloader()
 {
 	static int32 lock = 0;
 
 	if (atomic_add(&lock, 1) != 0) {
 		// Just wait for the icon cache to be instantiated
-		int32 tries = 20;	
+		int32 tries = 20;
 		while (IconCache::sIconCache == NULL && tries-- > 0)
 			snooze(10000);
 		return;
@@ -166,7 +165,7 @@
 	}
 	if (!fs_stat_dev(model->NodeRef()->device,&info))
 		return info.flags;
-	
+
 	return B_FS_HAS_ATTR;
 }
 
@@ -176,7 +175,7 @@
 {
 	BPath path;
 	status_t err = find_directory(B_COMMON_VAR_DIRECTORY, &path);
-	
+
 	if (err != B_OK){
 		PRINT(("var err = %s\n", strerror(err)));
 		return;
@@ -188,7 +187,7 @@
 		// make var dir invisible
 		info.fInvisible = true;
 		info.fInitedDirectory = -1;
-		
+
 		if (varDirectory.WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &info, sizeof(info))
 			== sizeof(info))
 			varDirectory.RemoveAttr(kAttrPoseInfoForeign);
@@ -203,17 +202,19 @@
 	:	BApplication(kTrackerSignature),
 	fSettingsWindow(NULL)
 {
-	// set the cwd to /boot/home, anything that's launched 
-	// from Tracker will automatically inherit this 
+	// set the cwd to /boot/home, anything that's launched
+	// from Tracker will automatically inherit this
 	BPath homePath;
-	
+
 	if (find_directory(B_USER_DIRECTORY, &homePath) == B_OK)
 		chdir(homePath.Path());
-	
-	_kset_fd_limit_(512);
-		// ask for a bunch more file descriptors so that nested copying
-		// works well
-	
+
+	// ask for a bunch more file descriptors so that nested copying works well
+	struct rlimit rl;
+	rl.rlim_cur = 512;
+	rl.rlim_max = RLIM_SAVED_MAX;
+	setrlimit(RLIMIT_NOFILE, &rl);
+
 	fNodeMonitorCount = DEFAULT_MON_NUM;
 
 #ifdef CHECK_OPEN_MODEL_LEAKS
@@ -261,7 +262,7 @@
 
 	gStatusWindow->AttemptToQuit();
 		// try quitting the copy/move/empty trash threads
-		
+
 	BVolume bootVolume;
 	DEBUG_ONLY(status_t err =) BVolumeRoster().GetBootVolume(&bootVolume);
 	ASSERT(err == B_OK);
@@ -311,8 +312,8 @@
 						message.AddInt8(path.Path(), flags);
 					}
 				}
-			}	
-			window->Unlock();		
+			}
+			window->Unlock();
 		}
 	}
 	lock.Unlock();
@@ -351,15 +352,15 @@
 	fAutoMounter->Lock();
 	fAutoMounter->QuitRequested();	// automounter does some stuff in QuitRequested
 	fAutoMounter->Quit();			// but we really don't care if it is cooperating or not
-	
+
 	fClipboardRefsWatcher->Lock();
 	fClipboardRefsWatcher->Quit();
-	
+
 	fTrashWatcher->Lock();
 	fTrashWatcher->Quit();
 
 	WellKnowEntryList::Quit();
-	
+
 	delete gPreloader;
 	delete fTaskLoop;
 	delete IconCache::sIconCache;
@@ -397,7 +398,7 @@
 				CloseWindowAndChildren(itemNode);
 				break;
 			}
-			
+
 		case kCloseAllWindows:
 			CloseAllWindows();
 			break;
@@ -451,7 +452,7 @@
 			// show the addprinter window
 			run_add_printer_panel();
 			break;
-			
+
 		case kMakeActivePrinter:
 			// get the current selection
 			SetDefaultPrinter(message);
@@ -642,7 +643,7 @@
 };
 
 
-bool 
+bool
 TTracker::LaunchAndCloseParentIfOK(const entry_ref *launchThis,
 	const node_ref *closeThis, const BMessage *messageToBundle)
 {
@@ -651,7 +652,7 @@
 		refsReceived = *messageToBundle;
 		refsReceived.what = B_REFS_RECEIVED;
 	}
-	refsReceived.AddRef("refs", launchThis);	
+	refsReceived.AddRef("refs", launchThis);
 	// synchronous launch, we are already in our own thread
 	if (TrackerLaunch(&refsReceived, false) == B_OK) {
 		// if launched fine, close parent window in a bit
@@ -691,7 +692,7 @@
 			alert->Go();
 			return result;
 		}
-	} else 
+	} else
 		model = new Model(&entry);
 
 	result = model->InitCheck();
@@ -850,7 +851,7 @@
 		for (int32 index = 1; index < argc; index++) {
 			BEntry entry;
 			if (entry.SetTo(&workingDirectory, argv[index]) == B_OK
-				&& entry.GetRef(&ref) == B_OK) 
+				&& entry.GetRef(&ref) == B_OK)
 				OpenRef(&ref);
 			else if (get_ref_for_path(argv[index], &ref) == B_OK)
 				OpenRef(&ref);
@@ -870,13 +871,13 @@
 		window = FindContainerWindow(model->NodeRef());
 
 	bool someWindowActivated = false;
-	
-	uint32 workspace = (uint32)(1 << current_workspace());		
+
+	uint32 workspace = (uint32)(1 << current_workspace());
 	int32 windowCount = 0;
-	
+
 	while (window) {
 		// At least one window open, just pull to front
-		// make sure we don't jerk workspaces around		
+		// make sure we don't jerk workspaces around
 		uint32 windowWorkspaces = window->Workspaces();
 		if (windowWorkspaces & workspace) {
 			window->Activate();
@@ -884,13 +885,13 @@
 		}
 		window = FindContainerWindow(model->NodeRef(), ++windowCount);
 	}
-	
+
 	if (someWindowActivated) {
 		delete model;
-		return;	
+		return;
 	} // If no window was actiated, (none in the current workspace
 	  // we open a new one.
-	
+
 	if (openSelector == kRunOpenWithWindow) {
 		BMessage *refList = NULL;
 		if (!originalRefsList) {
@@ -914,12 +915,12 @@
 	} else
 		// window will adopt the model
 		window = new BContainerWindow(&fWindowList, openFlags);
-	
+
 	if (model)
 		window->CreatePoseView(model);
 
 	BMessage restoreStateMessage(kRestoreState);
-	
+
 	if (stateMessage)
 		restoreStateMessage.AddMessage("state", stateMessage);
 
@@ -941,7 +942,7 @@
 		entry_ref ref;
 		message->FindRef("refs", index, &ref);
 		BEntry entry(&ref, true);
-		if (entry.InitCheck() == B_OK && entry.Exists()) 
+		if (entry.InitCheck() == B_OK && entry.Exists())
 			(new FindWindow(&ref, editOnlyIfTemplate))->Show();
 	}
 }
@@ -1000,7 +1001,7 @@
 TTracker::FindContainerWindow(const node_ref *node, int32 number) const
 {
 	ASSERT(fWindowList.IsLocked());
-	
+
 	int32 count = fWindowList.CountItems();
 
 	int32 windowsFound = 0;
@@ -1008,7 +1009,7 @@
 	for (int32 index = 0; index < count; index++) {
 		BContainerWindow *window = dynamic_cast<BContainerWindow *>
 			(fWindowList.ItemAt(index));
-			
+
 		if (window && window->IsShowing(node) && number == windowsFound++)
 			return window;
 	}
@@ -1020,7 +1021,7 @@
 TTracker::FindContainerWindow(const entry_ref *entry, int32 number) const
 {
 	ASSERT(fWindowList.IsLocked());
-	
+
 	int32 count = fWindowList.CountItems();
 
 	int32 windowsFound = 0;
@@ -1036,7 +1037,7 @@
 }
 
 
-bool 
+bool
 TTracker::EntryHasWindowOpen(const entry_ref *entry)
 {
 	AutoLock<WindowList> lock(&fWindowList);
@@ -1049,15 +1050,15 @@
 {
 	BEntry entry(ref);
 	BEntry parent;
-	
+
 	if (entry.GetParent(&parent) != B_OK)
 		return NULL;
-	
+
 	entry_ref parentRef;
 	parent.GetRef(&parentRef);
 
 	ASSERT(fWindowList.IsLocked());
-	
+
 	int32 count = fWindowList.CountItems();
 	for (int32 index = 0; index < count; index++) {
 		BContainerWindow *window = dynamic_cast<BContainerWindow *>
@@ -1073,7 +1074,7 @@
 TTracker::FindInfoWindow(const node_ref* node) const
 {
 	ASSERT(fWindowList.IsLocked());
-	
+
 	int32 count = fWindowList.CountItems();
 	for (int32 index = 0; index < count; index++) {
 		BInfoWindow *window = dynamic_cast<BInfoWindow *>
@@ -1085,7 +1086,7 @@
 }
 
 
-bool 
+bool
 TTracker::QueryActiveForDevice(dev_t device)
 {
 	AutoLock<WindowList> lock(&fWindowList);
@@ -1103,7 +1104,7 @@
 }
 
 
-void 
+void
 TTracker::CloseActiveQueryWindows(dev_t device)
 {
 	// used when trying to unmount a volume - an active query would prevent that from
@@ -1143,8 +1144,8 @@
 		if (window) {
 			AutoLock<BWindow> lock(window);
 			BDeskWindow *deskWindow = dynamic_cast<BDeskWindow *>(window);
-		
-			if (deskWindow) 
+
+			if (deskWindow)
 				deskWindow->SaveDesktopPoseLocations();
 			else
 				window->PoseView()->SavePoseLocations();
@@ -1174,7 +1175,7 @@
 
 			if ((*window->TargetModel()->NodeRef() == *node)
 				|| dir.Contains(&wind_entry)) {
-				
+
 				// ToDo:
 				// get rid of the Remove here, BContainerWindow::Quit does it
 				fWindowList.RemoveItemAt(index);
@@ -1203,11 +1204,11 @@
 		BWindow *window = fWindowList.ItemAt(index);
 		if (window->Workspaces() & currentWorkspace)
 			// avoid the desktop
-			if (!dynamic_cast<BDeskWindow *>(window) 
+			if (!dynamic_cast<BDeskWindow *>(window)
 				&& !dynamic_cast<BStatusWindow *>(window))
 				window->PostMessage(B_QUIT_REQUESTED);
-	}	
-}	
+	}
+}
 
 
 void
@@ -1235,7 +1236,7 @@
 				// ToDo:
 				// get rid of the Remove here, BContainerWindow::Quit does it
 			fWindowList.RemoveItemAt(index);
-	}	
+	}
 }
 
 
@@ -1325,7 +1326,7 @@
 	InstallDefaultTemplates();
 	InstallIndices();
 	InstallTemporaryBackgroundImages();
-	
+
 	HideVarDir();
 
 	fTrashWatcher = new BTrashWatcher();
@@ -1333,13 +1334,13 @@
 
 	fClipboardRefsWatcher = new BClipboardRefsWatcher();
 	fClipboardRefsWatcher->Run();
-	
+
 	fAutoMounter = new AutoMounter();
 	fAutoMounter->Run();
-	
+
 	fTaskLoop = new StandAloneTaskLoop(true);
 
-	// open desktop window 
+	// open desktop window
 	BContainerWindow *deskWindow = NULL;
 	BVolume	bootVolume;
 	BVolumeRoster().GetBootVolume(&bootVolume);
@@ -1389,9 +1390,9 @@
 TTracker::MimeTypes() const
 {
 	return fMimeTypeList;
-}	
+}
 
-void 
+void
 TTracker::SelectChildInParentSoon(const entry_ref *parent,
 	const node_ref *child)
 {
@@ -1400,7 +1401,7 @@
 		100000, 200000, 5000000);
 }
 
-void 
+void
 TTracker::CloseParentWaitingForChildSoon(const entry_ref *child,
 	const node_ref *parent)
 {
@@ -1409,7 +1410,7 @@
 		200000, 100000, 5000000);
 }
 
-void 
+void
 TTracker::SelectPoseAtLocationSoon(node_ref parent, BPoint pointInPose)
 {
 	fTaskLoop->RunLater(NewMemberFunctionObject
@@ -1417,7 +1418,7 @@
 		100000);
 }
 
-void 
+void
 TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose)
 {
 	AutoLock<WindowList> lock(&fWindowList);
@@ -1428,12 +1429,12 @@
 	}
 }
 
-bool 
+bool
 TTracker::CloseParentWaitingForChild(const entry_ref *child,
 	const node_ref *parent)
 {
 	AutoLock<WindowList> lock(&fWindowList);
-	
+
 	BContainerWindow *parentWindow = FindContainerWindow(parent);
 	if (!parentWindow)
 		// parent window already closed, give up
@@ -1452,10 +1453,10 @@
 		if (!window->IsHidden())
 			return CloseParentWindowCommon(parentWindow);
 	}
-	return false;	
+	return false;
 }
 
-void 
+void
 TTracker::CloseParent(node_ref parent)
 {
 	AutoLock<WindowList> lock(&fWindowList);
@@ -1482,11 +1483,11 @@
 	}
 }
 
-bool 
+bool
 TTracker::CloseParentWindowCommon(BContainerWindow *window)
 {
 	ASSERT(fWindowList.IsLocked());
-	
+
 	if (dynamic_cast<BDeskWindow *>(window))
 		// don't close the destop
 		return false;
@@ -1495,18 +1496,18 @@
 	return true;
 }
 
-bool 
+bool
 TTracker::SelectChildInParent(const entry_ref *parent, const node_ref *child)
 {
 	AutoLock<WindowList> lock(&fWindowList);
-	
+
 	BContainerWindow *window = FindContainerWindow(parent);
-	if (!window) 
+	if (!window)
 		// parent window already closed, give up
 		return false;
 
 	AutoLock<BWindow> windowLock(window);
-	
+
 	if (windowLock.IsLocked()) {
 		BPoseView *view = window->PoseView();
 		int32 index;
@@ -1516,18 +1517,24 @@
 			return true;
 		}
 	}
-	return false;	
+	return false;
 }
 
 const int32 kNodeMonitorBumpValue = 512;
 
-status_t 
+status_t
 TTracker::NeedMoreNodeMonitors()
 {
 	fNodeMonitorCount += kNodeMonitorBumpValue;
 	PRINT(("bumping nodeMonitorCount to %d\n", fNodeMonitorCount));
 
-	return _kset_mon_limit_(fNodeMonitorCount);
+	struct rlimit rl;
+	rl.rlim_cur = fNodeMonitorCount;
+	rl.rlim_max = RLIM_SAVED_MAX;
+	if (setrlimit(RLIMIT_NOVMON, &rl) < 0)
+		return errno;
+	return B_OK;
+
 }
 
 status_t
@@ -1570,7 +1577,7 @@
 }
 
 
-bool 
+bool
 TTracker::InTrashNode(const entry_ref *node) const
 {
 	return FSInTrashDir(node);
@@ -1588,5 +1595,5 @@
 TTracker::IsTrashNode(const node_ref *node) const
 {
 	return fTrashWatcher->IsTrashNode(node);
-}	
+}
 




More information about the Haiku-commits mailing list