xpfe/components/directory/nsDirectoryViewer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpfe/components/directory/nsDirectoryViewer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,120 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsdirectoryviewer__h____
    1.10 +#define nsdirectoryviewer__h____
    1.11 +
    1.12 +#include "nsNetUtil.h"
    1.13 +#include "nsIStreamListener.h"
    1.14 +#include "nsIContentViewer.h"
    1.15 +#include "nsIHTTPIndex.h"
    1.16 +#include "nsIRDFService.h"
    1.17 +#include "nsIRDFDataSource.h"
    1.18 +#include "nsIRDFLiteral.h"
    1.19 +#include "nsIDocumentLoaderFactory.h"
    1.20 +#include "nsITimer.h"
    1.21 +#include "nsISupportsArray.h"
    1.22 +#include "nsXPIDLString.h"
    1.23 +#include "nsIDirIndexListener.h"
    1.24 +#include "nsIFTPChannel.h"
    1.25 +#include "nsCycleCollectionParticipant.h"
    1.26 +
    1.27 +class nsDirectoryViewerFactory : public nsIDocumentLoaderFactory
    1.28 +{
    1.29 +public:
    1.30 +    nsDirectoryViewerFactory();
    1.31 +    virtual ~nsDirectoryViewerFactory();
    1.32 +
    1.33 +    // nsISupports interface
    1.34 +    NS_DECL_ISUPPORTS
    1.35 +    NS_DECL_NSIDOCUMENTLOADERFACTORY
    1.36 +};
    1.37 +
    1.38 +class nsHTTPIndex : public nsIHTTPIndex,
    1.39 +                    public nsIRDFDataSource,
    1.40 +                    public nsIStreamListener,
    1.41 +                    public nsIDirIndexListener,
    1.42 +                    public nsIInterfaceRequestor,
    1.43 +                    public nsIFTPEventSink
    1.44 +{
    1.45 +private:
    1.46 +
    1.47 +    // note: these are NOT statics due to the native of nsHTTPIndex
    1.48 +    // where it may or may not be treated as a singleton
    1.49 +
    1.50 +    nsCOMPtr<nsIRDFResource>     kNC_Child;
    1.51 +    nsCOMPtr<nsIRDFResource>     kNC_Comment;
    1.52 +    nsCOMPtr<nsIRDFResource>     kNC_Loading;
    1.53 +    nsCOMPtr<nsIRDFResource>     kNC_URL;
    1.54 +    nsCOMPtr<nsIRDFResource>     kNC_Description;
    1.55 +    nsCOMPtr<nsIRDFResource>     kNC_ContentLength;
    1.56 +    nsCOMPtr<nsIRDFResource>     kNC_LastModified;
    1.57 +    nsCOMPtr<nsIRDFResource>     kNC_ContentType;
    1.58 +    nsCOMPtr<nsIRDFResource>     kNC_FileType;
    1.59 +    nsCOMPtr<nsIRDFResource>     kNC_IsContainer;
    1.60 +    nsCOMPtr<nsIRDFLiteral>      kTrueLiteral;
    1.61 +    nsCOMPtr<nsIRDFLiteral>      kFalseLiteral;
    1.62 +
    1.63 +    nsCOMPtr<nsIRDFService>      mDirRDF;
    1.64 +
    1.65 +protected:
    1.66 +    // We grab a reference to the content viewer container (which
    1.67 +    // indirectly owns us) so that we can insert ourselves as a global
    1.68 +    // in the script context _after_ the XUL doc has been embedded into
    1.69 +    // content viewer. We'll know that this has happened once we receive
    1.70 +    // an OnStartRequest() notification
    1.71 +
    1.72 +    nsCOMPtr<nsIRDFDataSource>   mInner;
    1.73 +    nsCOMPtr<nsISupportsArray>   mConnectionList;
    1.74 +    nsCOMPtr<nsISupportsArray>   mNodeList;
    1.75 +    nsCOMPtr<nsITimer>           mTimer;
    1.76 +    nsCOMPtr<nsIDirIndexParser>  mParser;
    1.77 +    nsCString mBaseURL;
    1.78 +    nsCString                    mEncoding;
    1.79 +    bool                         mBindToGlobalObject;
    1.80 +    nsIInterfaceRequestor*       mRequestor; // WEAK
    1.81 +    nsCOMPtr<nsIRDFResource>     mDirectory;
    1.82 +
    1.83 +    nsHTTPIndex(nsIInterfaceRequestor* aRequestor);
    1.84 +    nsresult CommonInit(void);
    1.85 +    nsresult Init(nsIURI* aBaseURL);
    1.86 +    void        GetDestination(nsIRDFResource* r, nsXPIDLCString& dest);
    1.87 +    bool        isWellknownContainerURI(nsIRDFResource *r);
    1.88 +    nsresult    AddElement(nsIRDFResource *parent, nsIRDFResource *prop,
    1.89 +                           nsIRDFNode *child);
    1.90 +
    1.91 +    static void FireTimer(nsITimer* aTimer, void* aClosure);
    1.92 +
    1.93 +public:
    1.94 +    nsHTTPIndex();
    1.95 +    virtual ~nsHTTPIndex();
    1.96 +    nsresult Init(void);
    1.97 +
    1.98 +    static nsresult Create(nsIURI* aBaseURI, nsIInterfaceRequestor* aContainer,
    1.99 +                           nsIHTTPIndex** aResult);
   1.100 +
   1.101 +    // nsIHTTPIndex interface
   1.102 +    NS_DECL_NSIHTTPINDEX
   1.103 +
   1.104 +    // NSIRDFDataSource interface
   1.105 +    NS_DECL_NSIRDFDATASOURCE
   1.106 +
   1.107 +    NS_DECL_NSIREQUESTOBSERVER
   1.108 +    NS_DECL_NSISTREAMLISTENER
   1.109 +    
   1.110 +    NS_DECL_NSIDIRINDEXLISTENER
   1.111 +    NS_DECL_NSIINTERFACEREQUESTOR
   1.112 +    NS_DECL_NSIFTPEVENTSINK
   1.113 +
   1.114 +    // nsISupports interface
   1.115 +    NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   1.116 +    NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHTTPIndex, nsIHTTPIndex)
   1.117 +};
   1.118 +
   1.119 +// {82776710-5690-11d3-BE36-00104BDE6048}
   1.120 +#define NS_DIRECTORYVIEWERFACTORY_CID \
   1.121 +{ 0x82776710, 0x5690, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
   1.122 +
   1.123 +#endif // nsdirectoryviewer__h____

mercurial