nsFileSystemDataSource.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsFileSystemDataSource_h__
  6. #define nsFileSystemDataSource_h__
  7. #include "nsIRDFDataSource.h"
  8. #include "nsIRDFLiteral.h"
  9. #include "nsIRDFResource.h"
  10. #include "nsIRDFService.h"
  11. #include "nsCOMPtr.h"
  12. #include "nsString.h"
  13. #include "mozilla/Attributes.h"
  14. #if defined(XP_UNIX) || defined(XP_WIN)
  15. #define USE_NC_EXTENSION
  16. #endif
  17. class FileSystemDataSource final : public nsIRDFDataSource
  18. {
  19. public:
  20. NS_DECL_ISUPPORTS
  21. NS_DECL_NSIRDFDATASOURCE
  22. static nsresult Create(nsISupports* aOuter,
  23. const nsIID& aIID, void **aResult);
  24. nsresult Init();
  25. private:
  26. FileSystemDataSource() { }
  27. ~FileSystemDataSource() { }
  28. // helper methods
  29. bool isFileURI(nsIRDFResource* aResource);
  30. bool isDirURI(nsIRDFResource* aSource);
  31. nsresult GetVolumeList(nsISimpleEnumerator **aResult);
  32. nsresult GetFolderList(nsIRDFResource *source, bool allowHidden, bool onlyFirst, nsISimpleEnumerator **aResult);
  33. nsresult GetName(nsIRDFResource *source, nsIRDFLiteral** aResult);
  34. nsresult GetURL(nsIRDFResource *source, bool *isFavorite, nsIRDFLiteral** aResult);
  35. nsresult GetFileSize(nsIRDFResource *source, nsIRDFInt** aResult);
  36. nsresult GetLastMod(nsIRDFResource *source, nsIRDFDate** aResult);
  37. nsCOMPtr<nsIRDFService> mRDFService;
  38. // pseudo-constants
  39. nsCOMPtr<nsIRDFResource> mNC_FileSystemRoot;
  40. nsCOMPtr<nsIRDFResource> mNC_Child;
  41. nsCOMPtr<nsIRDFResource> mNC_Name;
  42. nsCOMPtr<nsIRDFResource> mNC_URL;
  43. nsCOMPtr<nsIRDFResource> mNC_Icon;
  44. nsCOMPtr<nsIRDFResource> mNC_Length;
  45. nsCOMPtr<nsIRDFResource> mNC_IsDirectory;
  46. nsCOMPtr<nsIRDFResource> mWEB_LastMod;
  47. nsCOMPtr<nsIRDFResource> mNC_FileSystemObject;
  48. nsCOMPtr<nsIRDFResource> mNC_pulse;
  49. nsCOMPtr<nsIRDFResource> mRDF_InstanceOf;
  50. nsCOMPtr<nsIRDFResource> mRDF_type;
  51. nsCOMPtr<nsIRDFLiteral> mLiteralTrue;
  52. nsCOMPtr<nsIRDFLiteral> mLiteralFalse;
  53. #ifdef USE_NC_EXTENSION
  54. nsresult GetExtension(nsIRDFResource *source, nsIRDFLiteral** aResult);
  55. nsCOMPtr<nsIRDFResource> mNC_extension;
  56. #endif
  57. #ifdef XP_WIN
  58. bool isValidFolder(nsIRDFResource *source);
  59. nsresult getIEFavoriteURL(nsIRDFResource *source, nsString aFileURL, nsIRDFLiteral **urlLiteral);
  60. nsCOMPtr<nsIRDFResource> mNC_IEFavoriteObject;
  61. nsCOMPtr<nsIRDFResource> mNC_IEFavoriteFolder;
  62. nsCString ieFavoritesDir;
  63. #endif
  64. };
  65. #endif // nsFileSystemDataSource_h__