michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsFileSystemDataSource_h__ michael@0: #define nsFileSystemDataSource_h__ michael@0: michael@0: #include "nsIRDFDataSource.h" michael@0: #include "nsIRDFLiteral.h" michael@0: #include "nsIRDFResource.h" michael@0: #include "nsIRDFService.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsString.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: #if defined(XP_UNIX) || defined(XP_WIN) michael@0: #define USE_NC_EXTENSION michael@0: #endif michael@0: michael@0: class FileSystemDataSource MOZ_FINAL : public nsIRDFDataSource michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIRDFDATASOURCE michael@0: michael@0: static nsresult Create(nsISupports* aOuter, michael@0: const nsIID& aIID, void **aResult); michael@0: michael@0: ~FileSystemDataSource() { } michael@0: nsresult Init(); michael@0: michael@0: private: michael@0: FileSystemDataSource() { } michael@0: michael@0: // helper methods michael@0: bool isFileURI(nsIRDFResource* aResource); michael@0: bool isDirURI(nsIRDFResource* aSource); michael@0: nsresult GetVolumeList(nsISimpleEnumerator **aResult); michael@0: nsresult GetFolderList(nsIRDFResource *source, bool allowHidden, bool onlyFirst, nsISimpleEnumerator **aResult); michael@0: nsresult GetName(nsIRDFResource *source, nsIRDFLiteral** aResult); michael@0: nsresult GetURL(nsIRDFResource *source, bool *isFavorite, nsIRDFLiteral** aResult); michael@0: nsresult GetFileSize(nsIRDFResource *source, nsIRDFInt** aResult); michael@0: nsresult GetLastMod(nsIRDFResource *source, nsIRDFDate** aResult); michael@0: michael@0: nsCOMPtr mRDFService; michael@0: michael@0: // pseudo-constants michael@0: nsCOMPtr mNC_FileSystemRoot; michael@0: nsCOMPtr mNC_Child; michael@0: nsCOMPtr mNC_Name; michael@0: nsCOMPtr mNC_URL; michael@0: nsCOMPtr mNC_Icon; michael@0: nsCOMPtr mNC_Length; michael@0: nsCOMPtr mNC_IsDirectory; michael@0: nsCOMPtr mWEB_LastMod; michael@0: nsCOMPtr mNC_FileSystemObject; michael@0: nsCOMPtr mNC_pulse; michael@0: nsCOMPtr mRDF_InstanceOf; michael@0: nsCOMPtr mRDF_type; michael@0: michael@0: nsCOMPtr mLiteralTrue; michael@0: nsCOMPtr mLiteralFalse; michael@0: michael@0: #ifdef USE_NC_EXTENSION michael@0: nsresult GetExtension(nsIRDFResource *source, nsIRDFLiteral** aResult); michael@0: nsCOMPtr mNC_extension; michael@0: #endif michael@0: michael@0: #ifdef XP_WIN michael@0: bool isValidFolder(nsIRDFResource *source); michael@0: nsresult getIEFavoriteURL(nsIRDFResource *source, nsString aFileURL, nsIRDFLiteral **urlLiteral); michael@0: nsCOMPtr mNC_IEFavoriteObject; michael@0: nsCOMPtr mNC_IEFavoriteFolder; michael@0: nsCString ieFavoritesDir; michael@0: #endif michael@0: }; michael@0: michael@0: #endif // nsFileSystemDataSource_h__