From ec4ebc2066f3f4b68bfb17b2cb3c1b95a15f0913 Mon Sep 17 00:00:00 2001 From: "neeti%netscape.com" Date: Fri, 7 May 1999 05:26:41 +0000 Subject: [PATCH] Landing PICS --- extensions/pics/public/makefile.win | 3 + extensions/pics/public/nsIPICS.h | 9 +- .../pics/public/nsPICSElementObserver.h | 88 +++++++++++++++++++ extensions/pics/public/nspics.h | 38 ++++++++ extensions/pics/tests/TestPICS.cpp | 58 ++++++++++-- extensions/pics/tests/makefile.win | 4 + 6 files changed, 188 insertions(+), 12 deletions(-) create mode 100644 extensions/pics/public/nsPICSElementObserver.h create mode 100644 extensions/pics/public/nspics.h diff --git a/extensions/pics/public/makefile.win b/extensions/pics/public/makefile.win index 70446eeb5d1..9547dc59409 100644 --- a/extensions/pics/public/makefile.win +++ b/extensions/pics/public/makefile.win @@ -19,10 +19,13 @@ DEPTH=..\..\.. IGNORE_MANIFEST=1 +DEFINES=-D_IMPL_NS_PICS -DWIN32_LEAN_AND_MEAN MODULE=pics EXPORTS = \ + nspics.h \ nsIPICS.h \ + nsPICSElementObserver.h \ $(NULL) include <$(DEPTH)\config\rules.mak> diff --git a/extensions/pics/public/nsIPICS.h b/extensions/pics/public/nsIPICS.h index 64736556c70..b39f16a084e 100644 --- a/extensions/pics/public/nsIPICS.h +++ b/extensions/pics/public/nsIPICS.h @@ -20,7 +20,7 @@ #define nsIPICS_h__ #include "nsISupports.h" -#include "nsIPref.h" +#include "nsIWebShellServices.h" // {DFB4E4D2-AFC3-11d2-8286-00805F2AB103} @@ -36,10 +36,13 @@ class nsIPICS : public nsISupports { public: - NS_IMETHOD ProcessPICSLabel(char *label) = 0; - NS_IMETHOD Init() = 0; + NS_IMETHOD ProcessPICSLabel(char *label) = 0; + NS_IMETHOD GetWebShell(PRUint32 key, nsIWebShellServices*& aResult) = 0; + NS_IMETHOD SetNotified(nsIWebShellServices* aResult, nsIURL* aURL, PRBool notified) = 0; }; +extern NS_EXPORT nsresult NS_NewPICS(nsIPICS** aPICS); + /* ProgID prefixes for PICS DLL registration. */ #define NS_PICS_PROGID "component:||netscape|extensions|pics" diff --git a/extensions/pics/public/nsPICSElementObserver.h b/extensions/pics/public/nsPICSElementObserver.h new file mode 100644 index 00000000000..d314d4683d9 --- /dev/null +++ b/extensions/pics/public/nsPICSElementObserver.h @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsPICSElementObserver_h___ +#define nsPICSElementObserver_h___ + +#include "nsIFactory.h" +#include "nsIElementObserver.h" +#include "nsIObserver.h" + + +// {E12F6997-F28F-11d2-8ACE-00105A1B8860} +#define NS_IPICSELEMENTOBSERVER_IID \ +{ 0xbb170ff3, 0xf814, 0x11d2, { 0x8a, 0xd0, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }; + + + +class nsPICSElementObserver : public nsIElementObserver, public nsIObserver { +public: + + nsPICSElementObserver(); + virtual ~nsPICSElementObserver(void); + + /* + * This method return the tag which the observer care about + */ +// NS_IMETHOD GetTagName(const char * oTag); + NS_IMETHOD_(const char*) GetTagName(); + + /* + * Subject call observer when the parser hit the tag + * @param aDocumentID- ID of the document + * @param aTag- the tag + * @param numOfAttributes - number of attributes + * @param nameArray - array of name. + * @param valueArray - array of value + */ + NS_IMETHOD Notify(PRUint32 aDocumentID, eHTMLTags aTag, + PRUint32 numOfAttributes, const PRUnichar* nameArray[], + const PRUnichar* valueArray[]); + + NS_IMETHOD Notify(nsISupports** result); + + NS_DECL_ISUPPORTS + + +private: + +}; + +class nsPICSElementObserverFactory : public nsIFactory { +public: + + NS_DECL_ISUPPORTS + + // nsIFactory methods: + + NS_IMETHOD CreateInstance(nsISupports *aOuter, + REFNSIID aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + + // nsPICSElementObserver methods: + + nsPICSElementObserverFactory(void); + virtual ~nsPICSElementObserverFactory(void); + +}; + +extern NS_EXPORT nsresult NS_NewPICSElementObserver(nsIObserver** anObserver); + +#endif /* nsPICSElementObserver_h___ */ diff --git a/extensions/pics/public/nspics.h b/extensions/pics/public/nspics.h new file mode 100644 index 00000000000..5e3510b9d0c --- /dev/null +++ b/extensions/pics/public/nspics.h @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/** + * MODULE NOTES: + * @update gess 4/1/98 + */ + +#ifndef nspics_h___ +#define nspics_h___ + +#include "nscore.h" +#include "nsError.h" + +#ifdef _IMPL_NS_PICS +#define NS_PICS NS_EXPORT +#else +#define NS_PICS NS_IMPORT +#endif + +#endif /* nspics_h___ */ + + diff --git a/extensions/pics/tests/TestPICS.cpp b/extensions/pics/tests/TestPICS.cpp index 6bc7fc9ea6c..d226f6e4afe 100644 --- a/extensions/pics/tests/TestPICS.cpp +++ b/extensions/pics/tests/TestPICS.cpp @@ -1,12 +1,24 @@ #define NS_IMPL_IDS #include "nsISupports.h" #include "nsRepository.h" +#include "nsIServiceManager.h" #include "nsIPICS.h" +#include "nsIPref.h" +#include "nsIParser.h" +#include "nsParserCIID.h" +#include "nsINetService.h" +#include "nsIObserverService.h" +#include "nsString.h" #include "prmem.h" #include "plstr.h" +#include "nspics.h" - +#define PICS_DLL "pics.dll" #define PREF_DLL "xppref32.dll" +#define BASE_DLL "raptorbase.dll" +#define RAPTORHTMLPARS_DLL "raptorhtmlpars.dll" +#define NETLIB_DLL "netlib.dll" + @@ -16,15 +28,28 @@ static NS_DEFINE_IID(kPICSCID, NS_PICS_CID); static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID); static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); +static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID); -int main(int argc, char *argv[]) + +static NS_DEFINE_CID(kObserverServiceCID, NS_OBSERVERSERVICE_CID); +static NS_DEFINE_CID(kObserverCID, NS_OBSERVER_CID); + +static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); +static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); + + +PRInt32 main(PRInt32 argc, char *argv[]) { nsIPICS *pics = NULL; + nsresult res; + + nsIObserverService* anObserverService; + nsString aTopic("tagobserver"); + - - nsresult res = nsRepository::CreateInstance(kPICSCID, + res = nsRepository::CreateInstance(kPICSCID, NULL, kIPICSIID, (void **) &pics); @@ -52,13 +77,28 @@ int main(int argc, char *argv[]) char fileBuf6[1000] = "(PICS-1.1 \"http://www.gcf.org/v2.5\" l r (suds 0.5 density 0 color/hue 1) r (subject 2 density 1 color/hue 1))"; char fileBuf7[1000] = "(PICS-1.1 \"http://www.gcf.org/v2.5\" by \"John Doe\" labels on \"1994.11.05T08:15-0500\" until \"1995.12.31T23:59-0000\" for \"http://w3.org/PICS/Overview.html\" ratings (suds 0.5 density 0 color/hue 1) for \"http://w3.org/PICS/Underview.html\" by \"Jane Doe\" ratings (subject 2 density 1 color/hue 1))"; + + char fileBuf8[1000] = "(PICS-1.1 \"\"http://www.rsac.org/ratingsv01.html\"\" l gen true r (n 0 s 0 v 0 l 0)"; + char fileBuf9[1000] = "(PICS-1.1 \"http://www.rsac.org/ratingsv01.html\" l gen true r (n 0 s 0 v 0 l 0)"; + char fileBuf10[1000] = "\"(PICS-1.1)"; + char fileBuf11[1000] = "(PICS-1.1 \"http://www.rsac.org/ratingsv01.html\" l gen true comment \"RSACi North America Server\" by \"philipd@w3.org\" for \"http://www.w3.org\" on \"1996.04.16T08:15-0500\" r (n 0 s 0 v 0 l 0))"; if (res == NS_OK) { - // Load preferences - nsComponentManager::RegisterComponent(kPrefCID, NULL, NULL, PREF_DLL, PR_FALSE, PR_FALSE); - pics->Init(); - - pics->ProcessPICSLabel(fileBuf4); + // Load preferences + nsComponentManager::RegisterComponent(kPrefCID, NULL, NULL, PREF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kObserverServiceCID, "ObserverService", NS_OBSERVERSERVICE_PROGID, BASE_DLL,PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kObserverCID, "Observer", NS_OBSERVER_PROGID, BASE_DLL,PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCParserCID, NULL, NULL, RAPTORHTMLPARS_DLL, PR_FALSE, PR_FALSE); + + res = nsServiceManager::GetService(kObserverServiceCID, + nsIObserverService::GetIID(), + (nsISupports **)&anObserverService); + + + + + pics->ProcessPICSLabel(fileBuf11); } PR_Free(fileBuf2); diff --git a/extensions/pics/tests/makefile.win b/extensions/pics/tests/makefile.win index 8c76a167099..c88dc5d1f47 100644 --- a/extensions/pics/tests/makefile.win +++ b/extensions/pics/tests/makefile.win @@ -17,6 +17,7 @@ DEPTH = ..\..\.. +DEFINES=-D_IMPL_NS_PICS -DWIN32_LEAN_AND_MEAN MODULE=pics MAKE_OBJ_TYPE = EXE @@ -37,12 +38,15 @@ LINCS = -I$(PUBLIC)/js \ -I$(PUBLIC)\pics \ -I$(PUBLIC)\pref \ -I$(PUBLIC)\xpcom \ + -I$(PUBLIC)\raptor \ + -I$(PUBLIC)\netlib \ -I$(DEPTH)\include \ LLIBS= \ $(DIST)\lib\pics.lib \ $(DIST)\lib\xpcom32.lib \ + $(DIST)\lib\raptorbase.lib \ $(DIST)\lib\plc3.lib \ $(LIBNSPR) \