xpfe/components/directory/nsDirectoryViewer.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     6 #ifndef nsdirectoryviewer__h____
     7 #define nsdirectoryviewer__h____
     9 #include "nsNetUtil.h"
    10 #include "nsIStreamListener.h"
    11 #include "nsIContentViewer.h"
    12 #include "nsIHTTPIndex.h"
    13 #include "nsIRDFService.h"
    14 #include "nsIRDFDataSource.h"
    15 #include "nsIRDFLiteral.h"
    16 #include "nsIDocumentLoaderFactory.h"
    17 #include "nsITimer.h"
    18 #include "nsISupportsArray.h"
    19 #include "nsXPIDLString.h"
    20 #include "nsIDirIndexListener.h"
    21 #include "nsIFTPChannel.h"
    22 #include "nsCycleCollectionParticipant.h"
    24 class nsDirectoryViewerFactory : public nsIDocumentLoaderFactory
    25 {
    26 public:
    27     nsDirectoryViewerFactory();
    28     virtual ~nsDirectoryViewerFactory();
    30     // nsISupports interface
    31     NS_DECL_ISUPPORTS
    32     NS_DECL_NSIDOCUMENTLOADERFACTORY
    33 };
    35 class nsHTTPIndex : public nsIHTTPIndex,
    36                     public nsIRDFDataSource,
    37                     public nsIStreamListener,
    38                     public nsIDirIndexListener,
    39                     public nsIInterfaceRequestor,
    40                     public nsIFTPEventSink
    41 {
    42 private:
    44     // note: these are NOT statics due to the native of nsHTTPIndex
    45     // where it may or may not be treated as a singleton
    47     nsCOMPtr<nsIRDFResource>     kNC_Child;
    48     nsCOMPtr<nsIRDFResource>     kNC_Comment;
    49     nsCOMPtr<nsIRDFResource>     kNC_Loading;
    50     nsCOMPtr<nsIRDFResource>     kNC_URL;
    51     nsCOMPtr<nsIRDFResource>     kNC_Description;
    52     nsCOMPtr<nsIRDFResource>     kNC_ContentLength;
    53     nsCOMPtr<nsIRDFResource>     kNC_LastModified;
    54     nsCOMPtr<nsIRDFResource>     kNC_ContentType;
    55     nsCOMPtr<nsIRDFResource>     kNC_FileType;
    56     nsCOMPtr<nsIRDFResource>     kNC_IsContainer;
    57     nsCOMPtr<nsIRDFLiteral>      kTrueLiteral;
    58     nsCOMPtr<nsIRDFLiteral>      kFalseLiteral;
    60     nsCOMPtr<nsIRDFService>      mDirRDF;
    62 protected:
    63     // We grab a reference to the content viewer container (which
    64     // indirectly owns us) so that we can insert ourselves as a global
    65     // in the script context _after_ the XUL doc has been embedded into
    66     // content viewer. We'll know that this has happened once we receive
    67     // an OnStartRequest() notification
    69     nsCOMPtr<nsIRDFDataSource>   mInner;
    70     nsCOMPtr<nsISupportsArray>   mConnectionList;
    71     nsCOMPtr<nsISupportsArray>   mNodeList;
    72     nsCOMPtr<nsITimer>           mTimer;
    73     nsCOMPtr<nsIDirIndexParser>  mParser;
    74     nsCString mBaseURL;
    75     nsCString                    mEncoding;
    76     bool                         mBindToGlobalObject;
    77     nsIInterfaceRequestor*       mRequestor; // WEAK
    78     nsCOMPtr<nsIRDFResource>     mDirectory;
    80     nsHTTPIndex(nsIInterfaceRequestor* aRequestor);
    81     nsresult CommonInit(void);
    82     nsresult Init(nsIURI* aBaseURL);
    83     void        GetDestination(nsIRDFResource* r, nsXPIDLCString& dest);
    84     bool        isWellknownContainerURI(nsIRDFResource *r);
    85     nsresult    AddElement(nsIRDFResource *parent, nsIRDFResource *prop,
    86                            nsIRDFNode *child);
    88     static void FireTimer(nsITimer* aTimer, void* aClosure);
    90 public:
    91     nsHTTPIndex();
    92     virtual ~nsHTTPIndex();
    93     nsresult Init(void);
    95     static nsresult Create(nsIURI* aBaseURI, nsIInterfaceRequestor* aContainer,
    96                            nsIHTTPIndex** aResult);
    98     // nsIHTTPIndex interface
    99     NS_DECL_NSIHTTPINDEX
   101     // NSIRDFDataSource interface
   102     NS_DECL_NSIRDFDATASOURCE
   104     NS_DECL_NSIREQUESTOBSERVER
   105     NS_DECL_NSISTREAMLISTENER
   107     NS_DECL_NSIDIRINDEXLISTENER
   108     NS_DECL_NSIINTERFACEREQUESTOR
   109     NS_DECL_NSIFTPEVENTSINK
   111     // nsISupports interface
   112     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   113     NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHTTPIndex, nsIHTTPIndex)
   114 };
   116 // {82776710-5690-11d3-BE36-00104BDE6048}
   117 #define NS_DIRECTORYVIEWERFACTORY_CID \
   118 { 0x82776710, 0x5690, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
   120 #endif // nsdirectoryviewer__h____

mercurial