25 #include <nsComponentManagerUtils.h>
26 #include <nsServiceManagerUtils.h>
28 #include <nsThreadUtils.h>
29 #include <nsAutoLock.h>
31 #include <nsISimpleEnumerator.h>
32 #include <nsIProxyObjectManager.h>
33 #include <nsIRunnable.h>
34 #include <nsIThreadManager.h>
35 #include <nsIThreadPool.h>
43 #define PATH_SEPERATOR_CHAR \
44 NS_LITERAL_STRING(FILE_PATH_SEPARATOR).CharAt(0)
48 static PRLogModuleInfo* gFSTreeLog = nsnull;
49 #define TRACE(args) PR_LOG(gFSTreeLog, PR_LOG_DEBUG, args)
50 #define LOG(args) PR_LOG(gFSTreeLog, PR_LOG_WARN, args)
57 #define __FUNCTION__ __PRETTY_FUNCTION__
72 nsRefPtr<sbFileSystemNode>
node;
81 , mShouldLoadSession(PR_FALSE)
82 , mIsIntialized(PR_FALSE)
88 gFSTreeLog = PR_NewLogModule(
"sbFSTree");
91 NS_ASSERTION(mRootNodeLock,
"Failed to create mRootNodeLock!");
92 NS_ASSERTION(mListenerLock,
"Failed to create mListenerLock!");
98 nsAutoLock::DestroyLock(mRootNodeLock);
101 nsAutoLock::DestroyLock(mListenerLock);
109 return NS_ERROR_ALREADY_INITIALIZED;
112 mIsIntialized = PR_TRUE;
113 mShouldLoadSession = PR_FALSE;
114 mRootPath.Assign(aPath);
115 mIsRecursiveBuild = aIsRecursive;
124 return NS_ERROR_ALREADY_INITIALIZED;
127 mSavedSessionID = aSessionID;
128 mShouldLoadSession = PR_TRUE;
129 mIsIntialized = PR_FALSE;
140 nsCOMPtr<nsIThreadManager> threadMgr =
141 do_GetService(
"@mozilla.org/thread-manager;1", &rv);
142 NS_ENSURE_SUCCESS(rv, rv);
146 rv = threadMgr->GetCurrentThread(getter_AddRefs(mOwnerContextThread));
147 NS_ENSURE_SUCCESS(rv, rv);
149 nsCOMPtr<nsIThreadPool> threadPoolService =
150 do_GetService(
"@songbirdnest.com/Songbird/ThreadPoolService;1", &rv);
151 NS_ENSURE_SUCCESS(rv, rv);
153 nsCOMPtr<nsIRunnable> runnable =
155 NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE);
157 rv = threadPoolService->Dispatch(runnable, NS_DISPATCH_NORMAL);
158 NS_ENSURE_SUCCESS(rv, rv);
169 nsRefPtr<sbFileSystemNode> savedRootNode;
170 if (mShouldLoadSession) {
171 nsRefPtr<sbFileSystemTreeState> savedTreeState =
173 NS_ASSERTION(savedTreeState,
"Could not create a sbFileSystemTreeState!");
175 rv = savedTreeState->LoadTreeState(mSavedSessionID,
178 getter_AddRefs(savedRootNode));
180 NS_ASSERTION(NS_SUCCEEDED(rv),
"Failed to load saved tree session!");
185 nsCOMPtr<nsIRunnable> runnable =
187 NS_ASSERTION(runnable,
188 "Could not create a runnable for NotifySessionLoadError()!");
189 rv = mOwnerContextThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
190 NS_ASSERTION(NS_SUCCEEDED(rv),
191 "Could not dispatch NotifySessionLoadError()!");
196 mIsIntialized = PR_TRUE;
200 mRootFile = do_CreateInstance(
"@mozilla.org/file/local;1", &rv);
201 NS_ASSERTION(NS_SUCCEEDED(rv),
"Could not create a nsILocalFile!");
203 rv = mRootFile->InitWithPath(mRootPath);
204 NS_ASSERTION(NS_SUCCEEDED(rv),
"Could not InitWithPath a nsILocalFile!");
207 PRBool exists = PR_FALSE;
208 if ((NS_FAILED(mRootFile->Exists(&exists))) || !exists) {
209 nsCOMPtr<nsIRunnable> runnable =
211 NS_ASSERTION(runnable,
212 "Could not create a runnable for NotifyRootPathIsMissing()!");
214 rv = mOwnerContextThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
215 NS_ASSERTION(NS_SUCCEEDED(rv),
216 "Could not Dispatch NotifyRootPathIsMissing()!");
224 nsAutoLock rootNodeLock(mRootNodeLock);
226 rv =
CreateNode(mRootFile, nsnull, getter_AddRefs(mRootNode));
227 NS_ASSERTION(NS_SUCCEEDED(rv),
"Could not create a sbFileSystemNode!");
231 rv =
AddChildren(mRootPath, mRootNode, PR_TRUE, PR_FALSE);
232 NS_ASSERTION(NS_SUCCEEDED(rv),
"Failed to add children to root node!");
235 if (mShouldLoadSession && savedRootNode) {
240 NS_WARNING(
"Could not get the old session tree changes!");
245 nsCOMPtr<nsIRunnable> runnable =
247 NS_ASSERTION(runnable,
248 "Could not create a runnable for NotifyBuildComplete()!!");
250 rv = mOwnerContextThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
251 NS_ASSERTION(NS_SUCCEEDED(rv),
"Could not dispatch NotifyBuildComplete()!");
257 TRACE((
"%s: build for [%s] complete",
259 NS_ConvertUTF16toUTF8(mRootPath).
get()));
264 if (mShouldLoadSession && mSessionChanges.Length() > 0) {
266 for (PRUint32
i = 0;
i < mSessionChanges.Length();
i++) {
267 nsRefPtr<sbFileSystemPathChange> curPathChange(mSessionChanges[
i]);
268 if (!curPathChange) {
269 NS_WARNING(
"Could not get current path change!");
273 nsString curEventPath;
274 rv = curPathChange->GetChangePath(curEventPath);
276 NS_WARNING(
"Could not get the current change event path!");
281 rv = curPathChange->GetChangeType(&curChangeType);
283 NS_WARNING(
"Could not get current change type!");
287 rv = NotifyChanges(curEventPath, curChangeType);
289 NS_WARNING(
"Could not notify listeners of changes!");
293 mSessionChanges.Clear();
297 nsAutoLock listenerLock(mListenerLock);
299 mListener->
OnTreeReady(mRootPath, mDiscoveredDirs);
304 mDiscoveredDirs.Clear();
310 nsAutoLock listenerLock(mListenerLock);
320 nsAutoLock listenerLock(mListenerLock);
330 nsRefPtr<sbFileSystemNode> pathNode;
333 nsAutoLock rootLock(mRootNodeLock);
334 rv =
GetNode(aPath, mRootNode, getter_AddRefs(pathNode));
337 TRACE((
"%s: Could not update the tree at path '%s'!!!",
338 __FUNCTION__, NS_ConvertUTF16toUTF8(aPath).
get()));
341 NS_ENSURE_SUCCESS(rv, rv);
345 NS_ENSURE_SUCCESS(rv, rv);
347 nsString
path(aPath);
348 PRUint32 numChanges = pathChangesArray.Length();
349 for (PRUint32
i = 0;
i < numChanges;
i++) {
350 nsRefPtr<sbFileSystemNodeChange> curChange =
355 NS_ENSURE_SUCCESS(rv, rv);
357 nsRefPtr<sbFileSystemNode> curChangeNode;
358 rv = curChange->GetNode(getter_AddRefs(curChangeNode));
359 NS_ENSURE_SUCCESS(rv, rv);
361 nsString curLeafName;
362 rv = curChangeNode->GetLeafName(curLeafName);
363 NS_ENSURE_SUCCESS(rv, rv);
366 curNodeFullPath.Append(curLeafName);
369 rv = curChangeNode->GetIsDir(&isDir);
370 NS_ENSURE_SUCCESS(rv, rv);
372 switch (curChangeType) {
380 nsString curChangeLeafName;
381 rv = curChangeNode->GetLeafName(curChangeLeafName);
382 NS_ENSURE_SUCCESS(rv, rv);
386 nsAutoLock rootLock(mRootNodeLock);
387 rv = pathNode->ReplaceNode(curChangeLeafName, curChangeNode);
389 NS_ENSURE_SUCCESS(rv, rv);
396 NS_ENSURE_SUCCESS(rv, rv);
401 nsAutoLock rootLock(mRootNodeLock);
402 rv = pathNode->AddChild(curChangeNode);
404 NS_ENSURE_SUCCESS(rv, rv);
410 NS_ENSURE_SUCCESS(rv, rv);
414 nsAutoLock rootLock(mRootNodeLock);
415 rv = pathNode->RemoveChild(curChangeNode);
417 NS_ENSURE_SUCCESS(rv, rv);
422 rv = NotifyChanges(curNodeFullPath, curChangeType);
423 NS_ENSURE_SUCCESS(rv, rv);
432 NS_ENSURE_ARG_POINTER(aListener);
434 nsAutoLock listenerLock(mListenerLock);
436 mListener = aListener;
443 nsAutoLock listeners(mListenerLock);
453 return NS_ERROR_UNEXPECTED;
457 nsAutoLock rootNodeLock(mRootNodeLock);
460 NS_ENSURE_TRUE(treeState, NS_ERROR_OUT_OF_MEMORY);
463 rv = treeState->SaveTreeState(
this, aSessionID);
464 NS_ENSURE_SUCCESS(rv, rv);
472 PRBool aBuildDiscoveredDirArray,
473 PRBool aNotifyListeners)
475 std::stack<NodeContext> nodeContextStack;
476 nodeContextStack.push(
NodeContext(aPath, aParentNode));
478 while (!nodeContextStack.empty()) {
479 NodeContext curNodeContext = nodeContextStack.top();
480 nodeContextStack.pop();
490 for (next = begin; next != end; ++
next) {
491 nsRefPtr<sbFileSystemNode> curNode(next->second);
496 rv = curNodeContext.
node->AddChild(curNode);
501 PRBool isDir = PR_FALSE;
502 rv = curNode->GetIsDir(&isDir);
507 if (aNotifyListeners || isDir) {
508 nsString curNodeLeafName(next->first);
512 curNodePath.Append(curNodeLeafName);
514 if (mIsRecursiveBuild && isDir) {
515 nodeContextStack.push(
NodeContext(curNodePath, curNode));
517 if (aBuildDiscoveredDirArray) {
518 mDiscoveredDirs.AppendElement(curNodePath);
522 if (aNotifyListeners) {
523 rv = NotifyChanges(curNodePath,
eAdded);
525 NS_WARNING(
"Could not notify listener of change!");
541 nsCOMPtr<nsISimpleEnumerator> pathEnum;
543 NS_ENSURE_SUCCESS(rv, rv);
546 while ((NS_SUCCEEDED(pathEnum->HasMoreElements(&hasMore))) &&
hasMore) {
547 nsCOMPtr<nsISupports> curItem;
548 rv = pathEnum->GetNext(getter_AddRefs(curItem));
549 if (NS_FAILED(rv) || !curItem)
552 nsCOMPtr<nsIFile> curFile = do_QueryInterface(curItem, &rv);
553 if (NS_FAILED(rv) || !curFile)
558 rv = curFile->IsSymlink(&isSymlink);
559 if (NS_FAILED(rv) || isSymlink)
565 rv = curFile->IsSpecial(&isSpecial);
566 if (NS_FAILED(rv) || isSpecial)
570 nsRefPtr<sbFileSystemNode> curNode;
571 rv =
CreateNode(curFile, aParentNode, getter_AddRefs(curNode));
572 if (NS_FAILED(rv) || !curNode)
575 nsString curNodeLeafName;
576 rv = curNode->GetLeafName(curNodeLeafName);
591 NS_ENSURE_ARG_POINTER(aRootSearchNode);
592 NS_ENSURE_ARG_POINTER(aNodeRetVal);
593 NS_ENSURE_ARG(StringBeginsWith(aPath, mRootPath));
595 *aNodeRetVal = nsnull;
599 nsString
path(aPath);
600 if (StringEndsWith(path, NS_LITERAL_STRING(FILE_PATH_SEPARATOR))) {
601 path.Cut(path.Length() - 1, 1);
605 if (path.Equals(mRootPath)) {
606 NS_IF_ADDREF(*aNodeRetVal = aRootSearchNode);
611 PRInt32 strRange = path.Find(mRootPath);
612 NS_ENSURE_TRUE(strRange >= 0, NS_ERROR_FAILURE);
613 strRange += mRootPath.Length();
616 nsString searchPath(Substring(path, strRange, path.Length() - strRange));
618 searchPath.Cut(0, 1);
622 nsTArray<nsString> pathComponents;
624 NS_LITERAL_STRING(FILE_PATH_SEPARATOR),
628 nsRefPtr<sbFileSystemNode> curSearchNode = aRootSearchNode;
630 PRBool foundTargetNode = PR_TRUE;
631 PRUint32 numComponents = pathComponents.Length();
632 for (PRUint32
i = 0;
i < numComponents;
i++) {
633 nsString curPathComponent(pathComponents[
i]);
635 sbNodeMap *curChildren = curSearchNode->GetChildren();
641 sbNodeMapIter foundNodeIter = curChildren->find(curPathComponent);
642 if (foundNodeIter == curChildren->end()) {
643 foundTargetNode = PR_FALSE;
648 curSearchNode = foundNodeIter->second;
651 if (foundTargetNode) {
652 NS_ADDREF(*aNodeRetVal = curSearchNode);
656 rv = NS_ERROR_FAILURE;
667 NS_ENSURE_ARG_POINTER(aFile);
674 nsString parentNodeLeafName;
676 NS_ENSURE_SUCCESS(rv, rv);
678 nsCOMPtr<nsIFile> parentFile;
679 rv = aFile->GetParent(getter_AddRefs(parentFile));
680 if (NS_SUCCEEDED(rv) && parentFile) {
681 nsString parentFileLeafName;
682 rv = parentFile->GetLeafName(parentFileLeafName);
683 NS_ENSURE_SUCCESS(rv, rv);
684 NS_ASSERTION(parentFileLeafName.Equals(parentNodeLeafName),
685 "ERROR: CreateNode() Potential invalid parent used!");
691 rv = aFile->GetLeafName(leafName);
692 NS_ENSURE_SUCCESS(rv, rv);
695 rv = aFile->IsDirectory(&isDir);
696 NS_ENSURE_SUCCESS(rv, rv);
699 rv = aFile->GetLastModifiedTime(&lastModify);
700 NS_ENSURE_SUCCESS(rv, rv);
703 NS_ENSURE_TRUE(node, NS_ERROR_OUT_OF_MEMORY);
705 rv = node->Init(leafName, isDir, lastModify);
706 NS_ENSURE_SUCCESS(rv, rv);
708 NS_ADDREF(*aNodeRetVal = node);
714 const nsAString & aNodePath,
721 nsCOMPtr<nsISimpleEnumerator> pathEnum;
723 NS_ENSURE_SUCCESS(rv, rv);
726 while ((NS_SUCCEEDED(pathEnum->HasMoreElements(&hasMore))) &&
hasMore) {
727 nsCOMPtr<nsISupports> curItem;
728 rv = pathEnum->GetNext(getter_AddRefs(curItem));
729 if (NS_FAILED(rv) || !curItem) {
730 NS_WARNING(
"ERROR: Could not GetNext() item in enumerator!");
734 nsCOMPtr<nsIFile> curFile = do_QueryInterface(curItem, &rv);
735 if (NS_FAILED(rv) || !curFile) {
736 NS_WARNING(
"ERROR: Could not QI to a nsIFile!");
740 nsString curFileLeafName;
741 rv = curFile->GetLeafName(curFileLeafName);
743 NS_WARNING(
"ERROR: Could not get the leaf name from the file-spec!");
748 sbNodeMapIter foundNodeIter = childSnapshot.find(curFileLeafName);
749 if (foundNodeIter == childSnapshot.end()) {
753 nsRefPtr<sbFileSystemNode> newFileNode;
754 rv =
CreateNode(curFile, aNode, getter_AddRefs(newFileNode));
755 if (NS_FAILED(rv) || !newFileNode) {
756 NS_WARNING(
"ERROR: Could not create a sbFileSystemNode!");
762 NS_WARNING(
"ERROR: Could not add create change item!");
770 nsRefPtr<sbFileSystemNode> curChildNode(foundNodeIter->second);
772 NS_WARNING(
"ERROR: Could not get node from sbNodeMapIter!");
777 PRInt64 curFileLastModify;
778 rv = curFile->GetLastModifiedTime(&curFileLastModify);
780 NS_WARNING(
"ERROR: Could not get file last modify time!");
783 PRInt64 curChildNodeLastModify;
784 rv = curChildNode->GetLastModify(&curChildNodeLastModify);
786 NS_WARNING(
"ERROR: Could not get node last modify time!");
790 if (curFileLastModify != curChildNodeLastModify) {
793 nsRefPtr<sbFileSystemNode> changedNode;
794 rv =
CreateNode(curFile, aNode, getter_AddRefs(changedNode));
795 if (NS_FAILED(rv) || !changedNode) {
796 NS_WARNING(
"ERROR: Could not create a sbFileSystemNode!");
802 NS_WARNING(
"ERROR: Could not add create change item!");
809 childSnapshot.erase(curFileLeafName);
818 for (next = begin; next != end; ++
next) {
819 nsRefPtr<sbFileSystemNode> curNode(next->second);
820 NS_ASSERTION(curNode,
"Could not get the current child snapshot node!");
822 NS_WARNING(
"ERROR: Could not get node from sbNodeMapIter!");
827 NS_ASSERTION(NS_SUCCEEDED(rv),
"Error: Could not add a change event!");
837 NS_ENSURE_ARG_POINTER(mRootNode);
838 NS_ENSURE_ARG_POINTER(aOldRootNode);
842 nsAutoLock rootNodeLock(mRootNodeLock);
846 PRBool isSame = PR_FALSE;
849 NS_ENSURE_SUCCESS(rv, rv);
853 NS_ENSURE_SUCCESS(rv, rv);
857 std::stack<NodeContext> nodeContextStack;
858 nodeContextStack.push(
NodeContext(mRootPath, mRootNode));
860 while (!nodeContextStack.empty()) {
861 NodeContext curNodeContext = nodeContextStack.top();
862 nodeContextStack.pop();
866 nsRefPtr<sbFileSystemNode> oldNodeContext;
869 getter_AddRefs(oldNodeContext));
870 if (NS_FAILED(rv) || !oldNodeContext) {
871 NS_WARNING(
"Could not find old context node!!! Something is really bad!");
875 sbNodeMap *curNodeChildren = curNodeContext.
node->GetChildren();
876 sbNodeMap oldNodeChildSnapshot(*oldNodeContext->GetChildren());
884 for (next = begin; next != end; ++
next) {
885 nsString curChildPath(curContextRootPath);
886 curChildPath.Append(next->first);
889 sbNodeMapIter found = oldNodeChildSnapshot.find(next->first);
890 if (found == oldNodeChildSnapshot.end()) {
893 std::stack<NodeContext> addedNodeContext;
894 addedNodeContext.push(
NodeContext(curChildPath, next->second));
898 NS_WARNING(
"Could not report tree added events!");
906 rv =
CompareNodes(next->second, found->second, &isSame);
908 NS_WARNING(
"Could not compare child nodes!");
917 NS_WARNING(
"could not create change item!");
925 oldNodeChildSnapshot.erase(found->first);
928 nsRefPtr<sbFileSystemNode> curChildNode(next->second);
929 nodeContextStack.push(
NodeContext(curChildPath, curChildNode));
935 if (oldNodeChildSnapshot.size() > 0) {
942 for (removeNext = removeBegin; removeNext != removeEnd; ++removeNext) {
943 nsString curRemoveChildPath(curContextRootPath);
944 curRemoveChildPath.Append(removeNext->first);
946 removedNodeContext.push(
NodeContext(curRemoveChildPath,
947 removeNext->second));
951 NS_ENSURE_SUCCESS(rv, rv);
961 nsAString & aFullPath)
963 NS_ENSURE_ARG_POINTER(aAddedDirNode);
974 nsresult rv =
AddChildren(fullPath, aAddedDirNode, PR_FALSE, PR_TRUE);
975 NS_ENSURE_SUCCESS(rv, rv);
982 nsAString & aFullPath)
984 NS_ENSURE_ARG_POINTER(aRemovedDirNode);
991 NS_ENSURE_TRUE(dirChildren, NS_ERROR_UNEXPECTED);
996 for (next = begin; next != end; ++
next) {
997 nsRefPtr<sbFileSystemNode> curNode(next->second);
1002 nsString curNodeLeafName(next->first);
1004 nsString curNodePath(fullPath);
1005 curNodePath.Append(curNodeLeafName);
1008 nsresult rv = curNode->GetIsDir(&isDir);
1009 NS_ENSURE_SUCCESS(rv, rv);
1014 NS_ENSURE_SUCCESS(rv, rv);
1018 rv = NotifyChanges(curNodePath,
eRemoved);
1019 NS_ENSURE_SUCCESS(rv, rv);
1026 sbFileSystemTree::NotifyChanges(
const nsAString & aChangePath,
1027 PRUint32 aChangeType)
1029 NS_ENSURE_TRUE(aChangeType ==
eChanged ||
1032 NS_ERROR_INVALID_ARG);
1035 nsresult rv = NS_GetCurrentThread(getter_AddRefs(currentThread));
1036 NS_ENSURE_SUCCESS(rv, rv);
1037 if (currentThread != mOwnerContextThread) {
1038 nsCOMPtr<sbPIFileSystemTree> proxiedThis;
1042 NS_PROXY_SYNC | NS_PROXY_ALWAYS,
1043 getter_AddRefs(proxiedThis));
1044 NS_ENSURE_SUCCESS(rv, rv);
1045 rv = proxiedThis->NotifyChanges(aChangePath, aChangeType);
1049 nsAutoLock listenerLock(mListenerLock);
1061 NS_ENSURE_ARG_POINTER(aResultEnum);
1064 nsCOMPtr<nsILocalFile> pathFile =
1065 do_CreateInstance(
"@mozilla.org/file/local;1", &rv);
1066 NS_ENSURE_SUCCESS(rv, rv);
1068 rv = pathFile->InitWithPath(aPath);
1069 NS_ENSURE_SUCCESS(rv, rv);
1071 return pathFile->GetDirectoryEntries(aResultEnum);
1079 NS_ENSURE_ARG_POINTER(aNode1);
1080 NS_ENSURE_ARG_POINTER(aNode2);
1087 NS_ENSURE_SUCCESS(rv, rv);
1091 NS_ENSURE_SUCCESS(rv, rv);
1093 if (!node1Name.Equals(node2Name)) {
1094 NS_WARNING(
"CompareNodes() was given two nodes w/o the same leaf name!");
1095 return NS_ERROR_FAILURE;
1099 PRInt64 node1Modify;
1101 NS_ENSURE_SUCCESS(rv, rv);
1103 PRInt64 node2Modify;
1105 NS_ENSURE_SUCCESS(rv, rv);
1107 *aIsSame = (node1Modify == node2Modify);
1117 while (!aContextStack.empty()) {
1119 aContextStack.pop();
1125 if (NS_FAILED(rv)) {
1126 NS_WARNING(
"Could not create a change item!");
1132 if (!childNodes || childNodes->size() == 0) {
1141 for (next = begin; next != end; ++
next) {
1142 nsString curChildPath(curContextPath);
1143 curChildPath.Append(next->first);
1145 aContextStack.push(
NodeContext(curChildPath, next->second));
1157 NS_ENSURE_ARG_POINTER(aChangedNode);
1159 nsRefPtr<sbFileSystemNodeChange> changedItem =
1161 NS_ENSURE_TRUE(changedItem, NS_ERROR_OUT_OF_MEMORY);
1163 nsRefPtr<sbFileSystemNodeChange> *appendResult =
1164 aChangeArray.AppendElement(changedItem);
1166 return (appendResult ?
NS_OK : NS_ERROR_FAILURE);
1174 nsRefPtr<sbFileSystemPathChange> changedItem =
1176 NS_ENSURE_TRUE(changedItem, NS_ERROR_OUT_OF_MEMORY);
1178 nsRefPtr<sbFileSystemPathChange> *appendResult =
1179 aChangeArray.AppendElement(changedItem);
1181 return (appendResult ?
NS_OK : NS_ERROR_FAILURE);
1187 nsString resultPath(aFilePath);
1188 PRUint32 length = resultPath.Length();
1190 resultPath.AppendLiteral(FILE_PATH_SEPARATOR);
GeneratorThread currentThread
nsresult SetListener(sbFileSystemTreeListener *aListener)
nsresult NotifyDirAdded(sbFileSystemNode *aAddedDirNode, nsAString &aFullPath)
nsresult GetNode(const nsAString &aPath, sbFileSystemNode *aRootSearchNode, sbFileSystemNode **aNodeRetVal)
NS_IMETHOD OnTreeSessionLoadError()=0
nsresult SaveTreeSession(const nsID &aSessionID)
static nsresult GetPathEntries(const nsAString &aPath, nsISimpleEnumerator **aResultEnum)
nsresult GetChildren(const nsAString &aPath, sbFileSystemNode *aParentNode, sbNodeMap &aNodeMap)
void NotifyBuildComplete()
nsresult InitWithTreeSession(nsID &aSessionID)
sbNodeMap * GetChildren()
nsresult do_GetProxyForObject(nsIEventTarget *aTarget, REFNSIID aIID, nsISupports *aObj, PRInt32 aProxyType, void **aProxyObject)
nsresult GetNodeChanges(sbFileSystemNode *aNode, const nsAString &aNodePath, sbNodeChangeArray &aOutChangeArray)
sbNodeMap::value_type sbNodeMapPair
void NotifySessionLoadError()
nsresult GetTreeChanges(sbFileSystemNode *aOldRootNode, sbPathChangeArray &aOutChangeArray)
friend class sbFileSystemTreeState
nsresult GetLeafName(nsAString &aLeafName)
NS_DECL_ISUPPORTS NS_DECL_SBPIFILESYSTEMTREE nsresult Init(const nsAString &aPath, PRBool aIsRecursive)
NodeContext(const nsAString &aFullPath, sbFileSystemNode *aNode)
nsresult AddChildren(const nsAString &aPath, sbFileSystemNode *aParentNode, PRBool aBuildDiscoveredDirArray, PRBool aNotifyListener)
NS_IMPL_THREADSAFE_ISUPPORTS1(sbDeviceCapsCompatibility, sbIDeviceCapsCompatibility) sbDeviceCapsCompatibility
nsresult CreateNode(nsIFile *aFile, sbFileSystemNode *aParentNode, sbFileSystemNode **aNodeRetVal)
static nsresult AppendCreatePathChangeItem(const nsAString &aEventPath, EChangeType aChangeType, sbPathChangeArray &aChangeArray)
#define PATH_SEPERATOR_CHAR
std::map< nsString, nsRefPtr< sbFileSystemNode > > sbNodeMap
void NotifyRootPathIsMissing()
nsresult NotifyDirRemoved(sbFileSystemNode *aRemovedDirNode, nsAString &aFullPath)
void nsString_Split(const nsAString &aString, const nsAString &aDelimiter, nsTArray< nsString > &aSubStringArray)
nsRefPtr< sbFileSystemNode > node
sbNodeMap::const_iterator sbNodeMapIter
nsTArray< nsRefPtr< sbFileSystemPathChange > > sbPathChangeArray
virtual ~sbFileSystemTree()
nsTArray< nsRefPtr< sbFileSystemNodeChange > > sbNodeChangeArray
NS_IMETHOD OnRootPathMissing()=0
std::stack< NodeContext > sbNodeContextStack
NS_IMETHOD OnTreeReady(const nsAString &aTreeRootPath, sbStringArray &aDirPathArray)=0
StringArrayEnumerator prototype hasMore
static nsresult CompareNodes(sbFileSystemNode *aNode1, sbFileSystemNode *aNode2, PRBool *aIsSame)
NS_IMETHOD GetChangeType(EChangeType *aChangeType)
nsresult Update(const nsAString &aPath)
nsresult GetLastModify(PRInt64 *aLastModify)
NS_IMETHOD OnChangeFound(const nsAString &aChangePath, EChangeType aChangeType)=0
_getSelectedPageStyle s i
nsString EnsureTrailingPath(const nsAString &aFilePath)
nsresult CreateTreeEvents(sbNodeContextStack &aContextStack, EChangeType aChangeType, sbPathChangeArray &aChangeArray)
static nsresult AppendCreateNodeChangeItem(sbFileSystemNode *aChangedNode, EChangeType aChangeType, sbNodeChangeArray &aChangeArray)