29 #include <nsIClassInfoImpl.h>
30 #include <nsIProgrammingLanguage.h>
31 #include <nsIObjectInputStream.h>
32 #include <nsIObjectOutputStream.h>
45 nsRefPtr<sbFileSystemNode>
node;
60 sbFileSystemNode::sbFileSystemNode()
61 : mID(0), mParentID(0)
74 NS_ASSERTION(!aLeafName.IsEmpty(),
"Error: Leaf name is empty!");
76 mLeafName.Assign(aLeafName);
78 mLastModify = aLastModify;
98 mLeafName = aLeafName;
105 aLeafName.Assign(mLeafName);
119 NS_ENSURE_ARG_POINTER(aIsDir);
127 mLastModify = aLastModify;
134 NS_ENSURE_ARG_POINTER(aLastModify);
135 *aLastModify = mLastModify;
142 NS_ENSURE_ARG_POINTER(aNode);
146 NS_ENSURE_SUCCESS(rv, rv);
156 NS_ENSURE_ARG_POINTER(aNode);
158 nsString nodeFileName;
160 NS_ENSURE_SUCCESS(rv, rv);
162 mChildMap.erase(nodeFileName);
170 NS_ENSURE_ARG_POINTER(aChildCount);
171 *aChildCount = mChildMap.size();
179 NS_ENSURE_ARG_POINTER(aReplacementNode);
180 nsString leafName(aLeafName);
181 mChildMap[leafName] = aReplacementNode;
195 NS_ENSURE_ARG_POINTER(aID);
210 NS_ENSURE_ARG_POINTER(aOutID);
219 sbFileSystemNode::Read(nsIObjectInputStream *aInputStream)
221 NS_ENSURE_ARG_POINTER(aInputStream);
224 rv = aInputStream->Read32(&mID);
225 NS_ENSURE_SUCCESS(rv, rv);
227 rv = aInputStream->Read32(&mParentID);
228 NS_ENSURE_SUCCESS(rv, rv);
231 nsCString storedLeafName;
232 rv = aInputStream->ReadCString(storedLeafName);
233 NS_ENSURE_SUCCESS(rv, rv);
235 mLeafName.Assign(NS_ConvertUTF8toUTF16(storedLeafName));
237 rv = aInputStream->ReadBoolean(&mIsDir);
238 NS_ENSURE_SUCCESS(rv, rv);
241 rv = aInputStream->Read64(&lastmodify);
242 if (NS_SUCCEEDED(rv)) {
243 mLastModify = lastmodify;
253 sbFileSystemNode::Write(nsIObjectOutputStream *aOutputStream)
255 NS_ENSURE_ARG_POINTER(aOutputStream);
258 rv = aOutputStream->Write32(mID);
259 NS_ENSURE_SUCCESS(rv, rv);
261 rv = aOutputStream->Write32(mParentID);
262 NS_ENSURE_SUCCESS(rv, rv);
265 rv = aOutputStream->WriteUtf8Z(mLeafName.BeginReading());
266 NS_ENSURE_SUCCESS(rv, rv);
268 rv = aOutputStream->WriteBoolean(mIsDir);
269 NS_ENSURE_SUCCESS(rv, rv);
271 PRUint64 lastmodify = mLastModify;
272 rv = aOutputStream->Write64(lastmodify);
273 NS_ENSURE_SUCCESS(rv, rv);
282 sbFileSystemNode::GetInterfaces(PRUint32*
count, nsIID***
array)
284 NS_ENSURE_ARG_POINTER(count);
285 NS_ENSURE_ARG_POINTER(array);
291 sbFileSystemNode::GetHelperForLanguage(PRUint32
language,
294 NS_ENSURE_ARG_POINTER(_retval);
300 sbFileSystemNode::GetContractID(
char** aContractID)
302 NS_ENSURE_ARG_POINTER(aContractID);
303 *aContractID = nsnull;
308 sbFileSystemNode::GetClassDescription(
char** aClassDescription)
310 NS_ENSURE_ARG_POINTER(aClassDescription);
311 *aClassDescription = nsnull;
316 sbFileSystemNode::GetClassID(nsCID** aClassID)
318 NS_ENSURE_ARG_POINTER(aClassID);
324 sbFileSystemNode::GetImplementationLanguage(PRUint32* aImplementationLanguage)
326 NS_ENSURE_ARG_POINTER(aImplementationLanguage);
327 *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
332 sbFileSystemNode::GetFlags(PRUint32* aFlags)
334 NS_ENSURE_ARG_POINTER(aFlags);
340 sbFileSystemNode::GetClassIDNoAlloc(nsCID* aClassIDNoAlloc)
342 NS_ENSURE_ARG_POINTER(aClassIDNoAlloc);
343 *aClassIDNoAlloc = kFileSystemTreeCID;
nsresult SetNodeID(PRUint32 aID)
virtual ~sbFileSystemNode()
sbNodeMap * GetChildren()
nsresult AddChild(sbFileSystemNode *aNode)
sbNodeMap::value_type sbNodeMapPair
nsresult GetLeafName(nsAString &aLeafName)
nsresult RemoveChild(sbFileSystemNode *aNode)
NodeContext(const nsAString &aFullPath, sbFileSystemNode *aNode)
nsresult SetLeafName(const nsAString &aLeafName)
std::map< nsString, nsRefPtr< sbFileSystemNode > > sbNodeMap
nsRefPtr< sbFileSystemNode > node
nsresult GetParentID(PRUint32 *aOutID)
nsresult GetIsDir(PRBool *aIsDir)
nsresult SetIsDir(const PRBool aIsDir)
NS_IMPL_THREADSAFE_ISUPPORTS2(sbFileSystemNode, nsISerializable, nsIClassInfo) NS_IMPL_CI_INTERFACE_GETTER2(sbFileSystemNode
nsresult GetChildCount(PRUint32 *aChildCount)
nsresult GetNodeID(PRUint32 *aID)
nsresult ReplaceNode(const nsAString &aLeafName, sbFileSystemNode *aReplacementNode)
nsresult SetLastModify(const PRInt64 aLastModify)
#define SONGBIRD_FILESYSTEMNODE_CID
NS_IMPL_CI_INTERFACE_GETTER2(sbDataRemoteWrapper, sbIDataRemote, nsIClassInfo) sbDataRemoteWrapper
static NS_DEFINE_CID(kFileSystemTreeCID, SONGBIRD_FILESYSTEMNODE_CID)
nsresult SetParentID(const PRUint32 aID)
nsresult GetLastModify(PRInt64 *aLastModify)
nsresult SetChildren(const sbNodeMap &aNodeMap)
NS_DECL_ISUPPORTS NS_DECL_NSISERIALIZABLE NS_DECL_NSICLASSINFO nsresult Init(const nsAString &aLeafName, PRBool aIsDir, PRUint64 aLastModify)