Back to index

lightning-sunbird  0.9+nobinonly
nsDirectoryDataSource.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Seth Spitzer <sspitzer@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 #ifndef __nsDirectoryDataSource_h
00039 #define __nsDirectoryDataSource_h
00040  
00041 
00042 #include "nsAbRDFDataSource.h"
00043 #include "nsIRDFService.h"
00044 #include "nsIAbListener.h"
00045 #include "nsIAbDirectory.h"
00046 #include "nsDirPrefs.h"
00047 #include "nsIAbListener.h"
00048 #include "nsISupportsArray.h"
00049 #include "nsIObserver.h"
00050 #include "nsWeakReference.h"
00051 #include "nsICollation.h"
00052 
00056 class nsAbDirectoryDataSource : public nsAbRDFDataSource,
00057                                                      public nsIAbListener, public nsIObserver, public nsSupportsWeakReference
00058 {
00059 private:
00060        PRBool mInitialized;
00061 
00062 public:
00063   
00064        NS_DECL_ISUPPORTS_INHERITED
00065   NS_DECL_NSIABLISTENER
00066   NS_DECL_NSIOBSERVER
00067 
00068        nsAbDirectoryDataSource(void);
00069        virtual ~nsAbDirectoryDataSource (void);
00070        virtual nsresult Init();
00071 
00072        // nsIRDFDataSource methods
00073        NS_IMETHOD GetURI(char* *uri);
00074 
00075        NS_IMETHOD GetTarget(nsIRDFResource* source,
00076                                       nsIRDFResource* property,
00077                                       PRBool tv,
00078                                       nsIRDFNode** target);
00079 
00080        NS_IMETHOD GetTargets(nsIRDFResource* source,
00081                                           nsIRDFResource* property,    
00082                                           PRBool tv,
00083                                           nsISimpleEnumerator** targets);
00084 
00085        NS_IMETHOD Assert(nsIRDFResource* source,
00086                                    nsIRDFResource* property, 
00087                                    nsIRDFNode* target,
00088                                    PRBool tv);
00089 
00090        NS_IMETHOD HasAssertion(nsIRDFResource* source,
00091                                             nsIRDFResource* property,
00092                                             nsIRDFNode* target,
00093                                             PRBool tv,
00094                                             PRBool* hasAssertion);
00095 
00096        NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result);
00097 
00098        NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
00099                                             nsISimpleEnumerator** labels); 
00100 
00101        NS_IMETHOD IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
00102                                                    nsIRDFResource*   aCommand,
00103                                                    nsISupportsArray/*<nsIRDFResource>*/* aArguments,
00104                                                    PRBool* aResult);
00105 
00106        NS_IMETHOD DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
00107                                       nsIRDFResource*   aCommand,
00108                                       nsISupportsArray/*<nsIRDFResource>*/* aArguments);
00109 
00110 protected:
00111 
00112        nsresult createDirectoryNode(nsIAbDirectory* directory, nsIRDFResource* property,
00113                                  nsIRDFNode** target);
00114        nsresult createDirectoryNameNode(nsIAbDirectory *directory,
00115                                      nsIRDFNode **target);
00116        nsresult createDirectoryUriNode(nsIAbDirectory *directory,
00117                                      nsIRDFNode **target);
00118        nsresult createDirectoryChildNode(nsIAbDirectory *directory,
00119                                       nsIRDFNode **target);
00120        nsresult createDirectoryIsMailListNode(nsIAbDirectory *directory,
00121                                       nsIRDFNode **target);
00122   nsresult createDirectoryIsRemoteNode(nsIAbDirectory *directory,
00123     nsIRDFNode **target);
00124   nsresult createDirectoryIsSecureNode(nsIAbDirectory *directory,
00125     nsIRDFNode **target);
00126        nsresult createDirectoryIsWriteableNode(nsIAbDirectory *directory,
00127                                             nsIRDFNode **target);
00128   nsresult createDirectoryTreeNameSortNode(nsIAbDirectory *directory,
00129                                             nsIRDFNode **target);
00130        nsresult getDirectoryArcLabelsOut(nsIAbDirectory *directory,
00131                                                                          nsISupportsArray **arcs);
00132 
00133   nsresult DoModifyDirectory(nsISupportsArray *parentDir,
00134                               nsISupportsArray *arguments);
00135        nsresult DoDeleteFromDirectory(nsISupportsArray *parentDirs,
00136                                                    nsISupportsArray *delDirs);
00137        nsresult DoDeleteCardsFromDirectory(nsIAbDirectory *directory,
00138                                                    nsISupportsArray *delDirs);
00139 
00140        nsresult DoDirectoryAssert(nsIAbDirectory *directory, 
00141                                    nsIRDFResource *property, nsIRDFNode *target);
00142        nsresult DoDirectoryHasAssertion(nsIAbDirectory *directory, 
00143                                                   nsIRDFResource *property, nsIRDFNode *target,
00144                                                   PRBool tv, PRBool *hasAssertion);
00145 
00146        nsresult GetTargetHasAssertion(nsIRDFDataSource *dataSource, nsIRDFResource* dirResource,
00147                                                     nsIRDFResource *property,PRBool tv, nsIRDFNode *target,PRBool* hasAssertion);
00148   nsresult CreateCollationKey(const nsString &aSource,  PRUint8 **aKey, PRUint32 *aLength);
00149 
00150   nsCOMPtr<nsIRDFResource> kNC_Child;
00151   nsCOMPtr<nsIRDFResource> kNC_DirName;
00152   nsCOMPtr<nsIRDFResource> kNC_CardChild;
00153   nsCOMPtr<nsIRDFResource> kNC_DirUri;
00154   nsCOMPtr<nsIRDFResource> kNC_IsMailList;
00155   nsCOMPtr<nsIRDFResource> kNC_IsRemote;
00156   nsCOMPtr<nsIRDFResource> kNC_IsSecure;
00157   nsCOMPtr<nsIRDFResource> kNC_IsWriteable;
00158   nsCOMPtr<nsIRDFResource> kNC_DirTreeNameSort;
00159   nsCOMPtr<nsICollation> mCollationKeyGenerator;
00160   
00161   // commands
00162   nsCOMPtr<nsIRDFResource> kNC_Modify;
00163   nsCOMPtr<nsIRDFResource> kNC_Delete;
00164   nsCOMPtr<nsIRDFResource> kNC_DeleteCards;
00165   
00166   //Cached literals
00167   nsCOMPtr<nsIRDFNode> kTrueLiteral;
00168   nsCOMPtr<nsIRDFNode> kFalseLiteral;
00169 
00170 private:
00171   nsresult Cleanup();
00172 };
00173 
00174 nsresult NS_NewAbDirectoryDataSource(const nsIID& iid, void **result);
00175 
00176 
00177 #endif