1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Benjamin Smedberg <benjamin@smedbergs.us>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either of the GNU General Public License Version 2 or later (the "GPL"),
27 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #ifndef nsFileSystemDataSource_h__
40 : #define nsFileSystemDataSource_h__
41 :
42 : #include "nsIRDFDataSource.h"
43 : #include "nsIRDFLiteral.h"
44 : #include "nsIRDFResource.h"
45 : #include "nsIRDFService.h"
46 : #include "nsISupportsArray.h"
47 : #include "nsCOMPtr.h"
48 : #include "nsString.h"
49 : #include "nsCycleCollectionParticipant.h"
50 :
51 : #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_WIN)
52 : #define USE_NC_EXTENSION
53 : #endif
54 :
55 : class FileSystemDataSource : public nsIRDFDataSource
56 : {
57 : public:
58 0 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
59 1464 : NS_DECL_CYCLE_COLLECTION_CLASS(FileSystemDataSource)
60 : NS_DECL_NSIRDFDATASOURCE
61 :
62 : static nsresult Create(nsISupports* aOuter,
63 : const nsIID& aIID, void **aResult);
64 :
65 0 : ~FileSystemDataSource() { }
66 : nsresult Init();
67 :
68 : private:
69 0 : FileSystemDataSource() { }
70 :
71 : // helper methods
72 : bool isFileURI(nsIRDFResource* aResource);
73 : bool isDirURI(nsIRDFResource* aSource);
74 : nsresult GetVolumeList(nsISimpleEnumerator **aResult);
75 : nsresult GetFolderList(nsIRDFResource *source, bool allowHidden, bool onlyFirst, nsISimpleEnumerator **aResult);
76 : nsresult GetName(nsIRDFResource *source, nsIRDFLiteral** aResult);
77 : nsresult GetURL(nsIRDFResource *source, bool *isFavorite, nsIRDFLiteral** aResult);
78 : nsresult GetFileSize(nsIRDFResource *source, nsIRDFInt** aResult);
79 : nsresult GetLastMod(nsIRDFResource *source, nsIRDFDate** aResult);
80 :
81 : nsCOMPtr<nsIRDFService> mRDFService;
82 :
83 : // pseudo-constants
84 : nsCOMPtr<nsIRDFResource> mNC_FileSystemRoot;
85 : nsCOMPtr<nsIRDFResource> mNC_Child;
86 : nsCOMPtr<nsIRDFResource> mNC_Name;
87 : nsCOMPtr<nsIRDFResource> mNC_URL;
88 : nsCOMPtr<nsIRDFResource> mNC_Icon;
89 : nsCOMPtr<nsIRDFResource> mNC_Length;
90 : nsCOMPtr<nsIRDFResource> mNC_IsDirectory;
91 : nsCOMPtr<nsIRDFResource> mWEB_LastMod;
92 : nsCOMPtr<nsIRDFResource> mNC_FileSystemObject;
93 : nsCOMPtr<nsIRDFResource> mNC_pulse;
94 : nsCOMPtr<nsIRDFResource> mRDF_InstanceOf;
95 : nsCOMPtr<nsIRDFResource> mRDF_type;
96 :
97 : nsCOMPtr<nsIRDFLiteral> mLiteralTrue;
98 : nsCOMPtr<nsIRDFLiteral> mLiteralFalse;
99 :
100 : #ifdef USE_NC_EXTENSION
101 : nsresult GetExtension(nsIRDFResource *source, nsIRDFLiteral** aResult);
102 : nsCOMPtr<nsIRDFResource> mNC_extension;
103 : #endif
104 :
105 : #ifdef XP_WIN
106 : bool isValidFolder(nsIRDFResource *source);
107 : nsresult getIEFavoriteURL(nsIRDFResource *source, nsString aFileURL, nsIRDFLiteral **urlLiteral);
108 : nsCOMPtr<nsIRDFResource> mNC_IEFavoriteObject;
109 : nsCOMPtr<nsIRDFResource> mNC_IEFavoriteFolder;
110 : nsCString ieFavoritesDir;
111 : #endif
112 : };
113 :
114 : #endif // nsFileSystemDataSource_h__
|