From d16438323fdd25c2f6efa9d450ab5192f73fa7fd Mon Sep 17 00:00:00 2001 From: "spider%netscape.com" Date: Sat, 1 Aug 1998 01:43:57 +0000 Subject: [PATCH] Prefs support --- shell/public/nsIShellInstance.h | 8 ++++++++ shell/src/makefile.win | 5 +++-- shell/src/nsShellInstance.cpp | 22 ++++++++++++++++++++++ shell/src/nsShellInstance.h | 8 ++++++++ shell/src/windows/makefile.win | 3 ++- 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/shell/public/nsIShellInstance.h b/shell/public/nsIShellInstance.h index 1ce893a9124e..599d8356b27d 100644 --- a/shell/public/nsIShellInstance.h +++ b/shell/public/nsIShellInstance.h @@ -26,6 +26,7 @@ #include "nsIWidget.h" class nsIApplicationShell; +class nsIPref; #define NS_ISHELLINSTANCE_IID \ { 0xbf88e640, 0xdf99, 0x11d1, \ @@ -113,6 +114,13 @@ public: */ NS_IMETHOD ExitApplication() = 0 ; + /** + * Get Preferences Object + * @result An nsIPref pointer + */ + NS_IMETHOD_(nsIPref *) GetPreferences() = 0; + + }; #endif /* nsIShellInstance_h___ */ diff --git a/shell/src/makefile.win b/shell/src/makefile.win index dd307f03415b..5095206c7967 100644 --- a/shell/src/makefile.win +++ b/shell/src/makefile.win @@ -18,7 +18,7 @@ DEPTH=..\.. IGNORE_MANIFEST=1 -DEFINES=-D_IMPL_NS_SHELL -DWIN32_LEAN_AND_MEAN +DEFINES=-D_IMPL_NS_SHELL -DWIN32_LEAN_AND_MEAN MODULE=shell DIRS = windows @@ -38,7 +38,7 @@ CPP_OBJS= \ $(NULL) LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \ - -I$(PUBLIC)\dom -I$(PUBLIC)\js -I$(PUBLIC)\netlib -I$(PUBLIC)\shell + -I$(PUBLIC)\dom -I$(PUBLIC)\js -I$(PUBLIC)\netlib -I$(PUBLIC)\shell -I$(PUBLIC)\pref MAKE_OBJ_TYPE = DLL DLLNAME = shell @@ -60,6 +60,7 @@ LLIBS= \ $(DIST)\lib\libplc21.lib \ $(DIST)\lib\jsdom.lib \ $(DIST)\lib\netlib.lib \ + $(DIST)\lib\xppref32.lib \ $(LIBNSPR) include <$(DEPTH)\config\rules.mak> diff --git a/shell/src/nsShellInstance.cpp b/shell/src/nsShellInstance.cpp index 0aee10c88ae9..ba1621b580a8 100644 --- a/shell/src/nsShellInstance.cpp +++ b/shell/src/nsShellInstance.cpp @@ -15,6 +15,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ +#define NS_IMPL_IDS 1 + #include "nspr.h" #include "net.h" @@ -36,6 +38,8 @@ #include "nsGfxCIID.h" #include "nsParserCIID.h" +#include "nsIPref.h" + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); static NS_DEFINE_IID(kCShellInstance, NS_SHELLINSTANCE_CID); @@ -67,10 +71,12 @@ private: nsShellInstance::nsShellInstance() { mApplicationWindow = NULL; + mPref = nsnull; } nsShellInstance::~nsShellInstance() { + NS_IF_RELEASE(mPref); } NS_DEFINE_IID(kIShellInstanceIID, NS_ISHELLINSTANCE_IID); @@ -82,6 +88,13 @@ nsresult nsShellInstance::Init() RegisterFactories() ; + // Load preferences + res = NSRepository::CreateInstance(kPrefCID, NULL, kIPrefIID, + (void **) &mPref); + if (NS_OK != res) { + return res; + } + return res; } @@ -124,6 +137,11 @@ void * nsShellInstance::GetNativeInstance() return mNativeInstance ; } +nsIPref * nsShellInstance::GetPreferences() +{ + return (mPref) ; +} + void nsShellInstance::SetNativeInstance(void * aNativeInstance) { mNativeInstance = aNativeInstance; @@ -152,10 +170,12 @@ nsresult nsShellInstance::RegisterFactories() #define GFXWIN_DLL "raptorgfxwin.dll" #define WIDGET_DLL "raptorwidget.dll" #define PARSER_DLL "raptorhtmlpars.dll" + #define PREF_DLL "xppref32.dll" #else #define GFXWIN_DLL "libgfxunix.so" #define WIDGET_DLL "libwidgetunix.so" #define PARSER_DLL "libraptorhtmlpars.so" + #define PREF_DLL "libpref.so" #endif @@ -205,6 +225,8 @@ nsresult nsShellInstance::RegisterFactories() NSRepository::RegisterFactory(kCTextFieldCID, WIDGET_DLL, PR_FALSE, PR_FALSE); NSRepository::RegisterFactory(kCParserCID, PARSER_DLL, PR_FALSE, PR_FALSE); NSRepository::RegisterFactory(kCParserNodeCID, PARSER_DLL, PR_FALSE, PR_FALSE); + + NSRepository::RegisterFactory(kPrefCID, PREF_DLL, PR_FALSE, PR_FALSE); return NS_OK; diff --git a/shell/src/nsShellInstance.h b/shell/src/nsShellInstance.h index 847f2588b0d8..7c4d5c1bc156 100644 --- a/shell/src/nsShellInstance.h +++ b/shell/src/nsShellInstance.h @@ -15,6 +15,7 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ + #include #include "nsIApplicationShell.h" #include "nsIFactory.h" @@ -23,6 +24,10 @@ #include "nsCRT.h" #include "nsIShellInstance.h" + +class nsIPref; + + // platform independent native handle to application instance typedef void * nsNativeApplicationInstance ; @@ -126,10 +131,13 @@ public: */ NS_IMETHOD ExitApplication() ; + NS_IMETHOD_(nsIPref *) GetPreferences() ; + private: nsNativeApplicationInstance mNativeInstance ; nsIApplicationShell * mApplicationShell ; nsIWidget * mApplicationWindow ; + nsIPref * mPref; }; diff --git a/shell/src/windows/makefile.win b/shell/src/windows/makefile.win index ce8af8a97d17..dd3cbfec5996 100644 --- a/shell/src/windows/makefile.win +++ b/shell/src/windows/makefile.win @@ -30,7 +30,7 @@ CPP_OBJS= \ .\$(OBJDIR)\winmain.obj \ $(NULL) -LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor -I$(XPDIST)\public\shell -I$(XPDIST)\public\dom -I$(XPDIST)\public\js -I.. +LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor -I$(XPDIST)\public\shell -I$(XPDIST)\public\pref -I$(XPDIST)\public\dom -I$(XPDIST)\public\js -I.. MAKE_OBJ_TYPE = LIB @@ -52,6 +52,7 @@ LLIBS= \ $(DIST)\lib\util.lib \ $(DIST)\lib\libplc21.lib \ $(DIST)\lib\jsdom.lib \ + $(DIST)\lib\xppref32.lib \ $(LIBNSPR) include <$(DEPTH)\config\rules.mak>