From ffd802f9ed57230a1c5da98b0ef3562e307307c6 Mon Sep 17 00:00:00 2001 From: "benjamin%smedbergs.us" <benjamin%smedbergs.us> Date: Wed, 9 Aug 2006 13:39:19 +0000 Subject: [PATCH] Bug 345517 - Build Firefox --enable-libxul by default, r=darin/mento --- Makefile.in | 17 +- browser/app/Makefile.in | 65 ------- browser/components/build/Makefile.in | 10 +- browser/components/dirprovider/Makefile.in | 6 +- .../nsBrowserDirectoryProvider.cpp | 7 +- browser/components/feeds/src/Makefile.in | 2 - .../components/feeds/src/nsFeedSniffer.cpp | 40 ++-- browser/components/feeds/src/nsFeedSniffer.h | 2 +- browser/components/migration/src/Makefile.in | 3 +- .../src/nsBrowserProfileMigratorUtils.cpp | 9 +- .../src/nsBrowserProfileMigratorUtils.h | 4 +- .../migration/src/nsCaminoProfileMigrator.cpp | 1 + .../migration/src/nsCaminoProfileMigrator.h | 4 +- .../src/nsDogbertProfileMigrator.cpp | 27 +-- .../migration/src/nsDogbertProfileMigrator.h | 2 +- .../migration/src/nsICabProfileMigrator.cpp | 1 + .../migration/src/nsICabProfileMigrator.h | 4 +- .../migration/src/nsIEProfileMigrator.cpp | 58 +++--- .../migration/src/nsIEProfileMigrator.h | 2 +- .../migration/src/nsMacIEProfileMigrator.cpp | 5 +- .../migration/src/nsMacIEProfileMigrator.h | 2 +- .../src/nsNetscapeProfileMigratorBase.cpp | 21 +- .../src/nsNetscapeProfileMigratorBase.h | 2 +- .../src/nsOmniWebProfileMigrator.cpp | 2 + .../migration/src/nsOmniWebProfileMigrator.h | 4 +- .../migration/src/nsOperaProfileMigrator.cpp | 51 +++-- .../migration/src/nsOperaProfileMigrator.h | 2 +- .../src/nsPhoenixProfileMigrator.cpp | 26 +-- .../migration/src/nsPhoenixProfileMigrator.h | 2 +- .../migration/src/nsProfileMigrator.cpp | 34 ++-- .../migration/src/nsSafariProfileMigrator.cpp | 18 +- .../migration/src/nsSafariProfileMigrator.h | 2 +- .../src/nsSeamonkeyProfileMigrator.cpp | 34 ++-- .../src/nsSeamonkeyProfileMigrator.h | 2 +- .../components/safebrowsing/src/Makefile.in | 1 - .../src/nsDocNavStartProgressListener.cpp | 5 +- browser/components/shell/src/Makefile.in | 1 - .../shell/src/nsGNOMEShellService.cpp | 110 ++++++++--- .../shell/src/nsGNOMEShellService.h | 2 +- .../shell/src/nsMacShellService.cpp | 5 +- .../components/shell/src/nsMacShellService.h | 1 + .../shell/src/nsWindowsShellService.cpp | 39 ++-- browser/installer/unix/packages-static | 7 +- browser/installer/windows/packages-static | 5 +- client.mk | 1 + config/autoconf.mk.in | 1 + config/config.mk | 8 + configure.in | 13 +- intl/unicharutil/util/Makefile.in | 4 + intl/unicharutil/util/internal/Makefile.in | 5 +- modules/staticmod/Makefile.in | 181 ++++-------------- modules/staticmod/meta.mak | 164 ---------------- modules/staticmod/nsMetaModule.cpp | 167 ++++++++++++++++ modules/staticmod/nsMetaModule.cpp.in | 135 ------------- toolkit/xre/Makefile.in | 4 +- 55 files changed, 554 insertions(+), 776 deletions(-) delete mode 100755 modules/staticmod/meta.mak create mode 100644 modules/staticmod/nsMetaModule.cpp delete mode 100644 modules/staticmod/nsMetaModule.cpp.in diff --git a/Makefile.in b/Makefile.in index ae7b695be8535..8bd16a6b3815a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -289,19 +289,16 @@ ifdef MOZ_JAVAXPCOM tier_50_dirs += extensions/java endif -ifndef BUILD_STATIC_LIBS +ifneq (1_,$(BUILD_STATIC_LIBS)_$(MOZ_META_COMPONENT)) ifdef MOZ_XUL_APP ifneq (,$(MOZ_ENABLE_GTK)$(MOZ_ENABLE_GTK2)) tier_50_dirs += embedding/browser/gtk -endif -endif -endif +endif # GTK -ifdef MOZ_XUL_APP -ifndef BUILD_STATIC_LIBS tier_50_dirs += toolkit/library -endif -endif + +endif # MOZ_XUL_APP +endif # STATIC ifdef MOZ_ENABLE_LIBXUL tier_50_dirs += xpcom/stub @@ -454,6 +451,10 @@ ifdef ENABLE_TESTS tier_99_dirs += tools/test-harness endif +ifdef MOZ_META_COMPONENT +tier_99_dirs += modules/staticmod +endif + # This should be built last, after all IDL files in the tree have been processed ifdef MOZ_JAVAXPCOM tier_99_dirs += extensions/java/xpcom/interfaces diff --git a/browser/app/Makefile.in b/browser/app/Makefile.in index 5732df1c6f0e4..59a7f2d084921 100644 --- a/browser/app/Makefile.in +++ b/browser/app/Makefile.in @@ -97,17 +97,6 @@ CPPSRCS = nsBrowserApp.cpp LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre -ifdef BUILD_STATIC_LIBS -STATIC_COMPONENTS_LINKER_PATH = -L$(DEPTH)/staticlib -LIBS += $(DEPTH)/toolkit/xre/$(LIB_PREFIX)xulapp_s.$(LIB_SUFFIX) -else -ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) -LIBS += $(DIST)/bin/XUL -else -EXTRA_DSO_LIBS += xul -endif -endif - ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) TK_LIBS := -framework Cocoa $(TK_LIBS) endif @@ -117,7 +106,6 @@ EXTRA_DSO_LIBS += thebes endif LIBS += \ - $(STATIC_COMPONENTS_LINKER_PATH) \ $(EXTRA_DSO_LIBS) \ $(MOZ_JS_LIBS) \ $(XPCOM_LIBS) \ @@ -148,25 +136,11 @@ endif NSDISTMODE = copy include $(topsrcdir)/config/config.mk -ifndef BUILD_STATIC_LIBS ifdef NS_TRACE_MALLOC EXTRA_DSO_LIBS += tracemalloc endif -else -include $(topsrcdir)/config/static-config.mk - -EXTRA_DEPS += \ - $(STATIC_EXTRA_DEPS) \ - $(NULL) -DEFINES += $(STATIC_DEFINES) -CPPSRCS += $(STATIC_CPPSRCS) -EXTRA_DSO_LIBS += $(STATIC_EXTRA_DSO_LIBS) -REQUIRES += $(STATIC_REQUIRES) -EXTRA_LIBS += $(STATIC_EXTRA_LIBS) -endif - ifeq ($(OS_ARCH),WINNT) OS_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool) ifdef MOZ_ENABLE_CAIRO_GFX @@ -179,9 +153,6 @@ RCFLAGS += -DMOZ_PHOENIX -I$(srcdir) else RCFLAGS += -DMOZ_PHOENIX --include-dir $(srcdir) endif -ifdef BUILD_STATIC_LIBS -RCFLAGS += -DMOZ_STATIC_BUILD -endif ifdef DEBUG RCFLAGS += -DDEBUG endif @@ -189,18 +160,11 @@ endif ifeq ($(OS_ARCH),BeOS) BEOS_PROGRAM_RESOURCE = $(srcdir)/apprunner-beos.rsrc -ifdef BUILD_STATIC_LIBS -OS_LIBS += -ltracker -lgame -endif endif ifeq ($(OS_ARCH),OS2) RESFILE=splashos2.res RCFLAGS += -DMOZ_PHOENIX -ifdef BUILD_STATIC_LIBS -EXE_DEF_FILE = browser.def -RCFLAGS += -DMOZ_STATIC_BUILD -i $(DIST)/include/widget -endif ifdef DEBUG RCFLAGS += -DDEBUG endif @@ -211,21 +175,6 @@ include $(topsrcdir)/config/rules.mk DEFINES += -DFIREFOX_ICO=\"$(DIST)/branding/firefox.ico\" -DDOCUMENT_ICO=\"$(DIST)/branding/document.ico\" -ifdef BUILD_STATIC_LIBS -include $(topsrcdir)/config/static-rules.mk - -DEFINES += -DIMPL_XREAPI -endif - -ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) -ifdef BUILD_STATIC_LIBS -LIBS += -framework QuickTime -framework IOKit -ifdef USE_PREBINDING -BIN_FLAGS += -Wl,-headerpad -Wl,5a0c -endif -endif -endif - ifeq ($(MOZ_WIDGET_TOOLKIT),photon) LIBS += -lphexlib endif @@ -248,20 +197,6 @@ endif $(PROGRAM): $(DEPTH)/toolkit/xre/$(LIB_PREFIX)xulapp_s.$(LIB_SUFFIX) -ifeq ($(OS_ARCH),OS2) -ifdef BUILD_STATIC_LIBS -$(EXE_DEF_FILE): - rm -f $@ - @echo NAME mozilla >$(EXE_DEF_FILE) - @echo IMPORTS >>$(EXE_DEF_FILE) - @echo WinQueryProperty = PMMERGE.5450 >>$(EXE_DEF_FILE) - @echo WinRemoveProperty = PMMERGE.5451 >>$(EXE_DEF_FILE) - @echo WinSetProperty = PMMERGE.5452 >>$(EXE_DEF_FILE) - -LDFLAGS += -Zlinker /NOE -endif -endif - ifneq (,$(filter-out OS2 WINNT,$(OS_ARCH))) firefox:: mozilla.in Makefile.in Makefile $(DEPTH)/config/autoconf.mk diff --git a/browser/components/build/Makefile.in b/browser/components/build/Makefile.in index 4493808866991..a9849ecd59a86 100644 --- a/browser/components/build/Makefile.in +++ b/browser/components/build/Makefile.in @@ -11,7 +11,6 @@ SHORT_LIBNAME = brwsrcmp EXPORT_LIBRARY = 1 IS_COMPONENT = 1 MODULE_NAME = nsBrowserCompsModule -MOZILLA_INTERNAL_API = 1 REQUIRES = \ xpcom \ @@ -76,17 +75,12 @@ LOCAL_INCLUDES += -I$(srcdir)/../safebrowsing/src SHARED_LIBRARY_LIBS += ../safebrowsing/src/$(LIB_PREFIX)safebrowsing_s.$(LIB_SUFFIX) endif -# Link to gkgfx for GNOME shell service -ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2) -EXTRA_DSO_LIBS += gkgfx -endif - EXTRA_DSO_LDOPTS += \ - $(LIBS_DIR) \ - $(EXTRA_DSO_LIBS) \ + $(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \ $(MOZ_UNICHARUTIL_LIBS) \ $(LIBXUL_DIST)/../modules/libreg/src/$(LIB_PREFIX)mozreg_s.$(LIB_SUFFIX) \ $(MOZ_JS_LIBS) \ + $(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \ $(MOZ_COMPONENT_LIBS) \ $(NULL) diff --git a/browser/components/dirprovider/Makefile.in b/browser/components/dirprovider/Makefile.in index 6e8d68fdfe993..6a88882b1cae6 100755 --- a/browser/components/dirprovider/Makefile.in +++ b/browser/components/dirprovider/Makefile.in @@ -50,7 +50,6 @@ endif IS_COMPONENT = 1 MODULE_NAME = BrowserDirProvider EXPORT_LIBRARY = 1 -MOZILLA_INTERNAL_API = 1 REQUIRES = \ xpcom \ @@ -61,6 +60,9 @@ REQUIRES = \ CPPSRCS = nsBrowserDirectoryProvider.cpp -EXTRA_DSO_LDOPTS = $(MOZ_COMPONENT_LIBS) +EXTRA_DSO_LDOPTS = \ + $(XPCOM_GLUE_LDOPTS) \ + $(NSPR_LIBS) \ + $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/browser/components/dirprovider/nsBrowserDirectoryProvider.cpp b/browser/components/dirprovider/nsBrowserDirectoryProvider.cpp index 1bad4955b1346..58ba906396402 100755 --- a/browser/components/dirprovider/nsBrowserDirectoryProvider.cpp +++ b/browser/components/dirprovider/nsBrowserDirectoryProvider.cpp @@ -48,9 +48,12 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h" #include "nsCategoryManagerUtils.h" +#include "nsComponentManagerUtils.h" #include "nsCOMArray.h" +#include "nsDirectoryServiceUtils.h" #include "nsIGenericFactory.h" -#include "nsString.h" +#include "nsServiceManagerUtils.h" +#include "nsStringAPI.h" #include "nsXULAppAPI.h" class nsBrowserDirectoryProvider : @@ -118,7 +121,7 @@ nsBrowserDirectoryProvider::GetFile(const char *aKey, PRBool *aPersist, nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (prefs) { - nsXPIDLCString path; + nsCString path; rv = prefs->GetCharPref("browser.bookmarks.file", getter_Copies(path)); if (NS_SUCCEEDED(rv)) { NS_NewNativeLocalFile(path, PR_TRUE, (nsILocalFile**)(nsIFile**) getter_AddRefs(file)); diff --git a/browser/components/feeds/src/Makefile.in b/browser/components/feeds/src/Makefile.in index 2972371ebe4ae..332fc5378e82f 100644 --- a/browser/components/feeds/src/Makefile.in +++ b/browser/components/feeds/src/Makefile.in @@ -58,6 +58,4 @@ LOCAL_INCLUDES = -I$(srcdir)/../../build FORCE_STATIC_LIB = 1 -MOZILLA_INTERNAL_API = 1 - include $(topsrcdir)/config/rules.mk diff --git a/browser/components/feeds/src/nsFeedSniffer.cpp b/browser/components/feeds/src/nsFeedSniffer.cpp index 54b31b55b16b3..d23506ad22793 100644 --- a/browser/components/feeds/src/nsFeedSniffer.cpp +++ b/browser/components/feeds/src/nsFeedSniffer.cpp @@ -42,13 +42,14 @@ #include "nsNetCID.h" #include "nsXPCOM.h" #include "nsCOMPtr.h" -#include "nsString.h" #include "nsStringStream.h" #include "nsBrowserCompsCID.h" #include "nsICategoryManager.h" #include "nsIServiceManager.h" +#include "nsComponentManagerUtils.h" +#include "nsServiceManagerUtils.h" #include "nsIStreamConverterService.h" #include "nsIStreamConverter.h" @@ -96,9 +97,12 @@ nsFeedSniffer::ConvertEncodedData(nsIRequest* request, converter->OnStartRequest(request, nsnull); - nsCOMPtr<nsIInputStream> rawStream; - rv = NS_NewByteInputStream(getter_AddRefs(rawStream), - (const char*)data, length); + nsCOMPtr<nsIStringInputStream> rawStream = + do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID); + if (!rawStream) + return NS_ERROR_FAILURE; + + rv = rawStream->SetData((const char*)data, length); NS_ENSURE_SUCCESS(rv, rv); rv = converter->OnDataAvailable(request, nsnull, rawStream, 0, length); @@ -167,40 +171,24 @@ nsFeedSniffer::GetMIMETypeFromContent(nsIRequest* request, length = MAX_BYTES; // Thus begins the actual sniffing. - nsDependentCSubstring dataString((const char*)testData, - (const char*)testData + length); - nsACString::const_iterator start_iter, end_iter; + nsDependentCSubstring dataString((const char*)testData, length); PRBool isFeed = PR_FALSE; // RSS 0.91/0.92/2.0 - dataString.BeginReading(start_iter); - dataString.EndReading(end_iter); - isFeed = FindInReadable(NS_LITERAL_CSTRING("<rss"), start_iter, end_iter); + isFeed = dataString.Find("<rss") != -1; // Atom 1.0 if (!isFeed) { - dataString.BeginReading(start_iter); - dataString.EndReading(end_iter); - isFeed = FindInReadable(NS_LITERAL_CSTRING("<feed"), start_iter, end_iter); + isFeed = dataString.Find("<feed") != -1; } // RSS 1.0 if (!isFeed) { - dataString.BeginReading(start_iter); - dataString.EndReading(end_iter); - isFeed = FindInReadable(NS_LITERAL_CSTRING("<rdf:RDF"), start_iter, end_iter); - if (isFeed) { - dataString.BeginReading(start_iter); - dataString.EndReading(end_iter); - isFeed = FindInReadable(NS_LITERAL_CSTRING(NS_RDF), start_iter, end_iter); - if (isFeed) { - dataString.BeginReading(start_iter); - dataString.EndReading(end_iter); - isFeed = FindInReadable(NS_LITERAL_CSTRING(NS_RSS), start_iter, end_iter); - } - } + isFeed = dataString.Find("<rdf:RDF") != -1 && + dataString.Find(NS_RDF) != -1 && + dataString.Find(NS_RSS) != -1; } // If we sniffed a feed, coerce our internal type diff --git a/browser/components/feeds/src/nsFeedSniffer.h b/browser/components/feeds/src/nsFeedSniffer.h index 959b6a642cc0b..2718abb012eca 100644 --- a/browser/components/feeds/src/nsFeedSniffer.h +++ b/browser/components/feeds/src/nsFeedSniffer.h @@ -39,7 +39,7 @@ #include "nsIGenericFactory.h" #include "nsIContentSniffer.h" #include "nsIStreamListener.h" -#include "nsString.h" +#include "nsStringAPI.h" class nsFeedSniffer : public nsIContentSniffer, nsIStreamListener { diff --git a/browser/components/migration/src/Makefile.in b/browser/components/migration/src/Makefile.in index e9d8fc674baa4..c1062a46143a0 100644 --- a/browser/components/migration/src/Makefile.in +++ b/browser/components/migration/src/Makefile.in @@ -43,7 +43,6 @@ include $(DEPTH)/config/autoconf.mk MODULE = migration LIBRARY_NAME = migration_s -MOZILLA_INTERNAL_API = 1 REQUIRES = \ xpcom \ @@ -63,7 +62,7 @@ REQUIRES = \ docshell \ xulapp \ $(NULL) - + ifdef MOZ_PLACES REQUIRES += places else diff --git a/browser/components/migration/src/nsBrowserProfileMigratorUtils.cpp b/browser/components/migration/src/nsBrowserProfileMigratorUtils.cpp index e65fe680164e8..17a473e83221f 100644 --- a/browser/components/migration/src/nsBrowserProfileMigratorUtils.cpp +++ b/browser/components/migration/src/nsBrowserProfileMigratorUtils.cpp @@ -96,9 +96,10 @@ void SetProxyPref(const nsAString& aHostPort, const char* aPref, if (portDelimOffset > 0) { SetUnicharPref(aPref, Substring(hostPort, 0, portDelimOffset), aPrefs); nsAutoString port(Substring(hostPort, portDelimOffset + 1)); - PRInt32 stringErr; + nsresult stringErr; portValue = port.ToInteger(&stringErr); - aPrefs->SetIntPref(aPortPref, portValue); + if (NS_SUCCEEDED(stringErr)) + aPrefs->SetIntPref(aPortPref, portValue); } else SetUnicharPref(aPref, hostPort, aPrefs); @@ -268,11 +269,11 @@ ImportBookmarksHTML(nsIFile* aBookmarksFile, rv = bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle)); NS_ENSURE_SUCCESS(rv, rv); - nsXPIDLString sourceName; + nsString sourceName; bundle->GetStringFromName(aImportSourceNameKey, getter_Copies(sourceName)); const PRUnichar* sourceNameStrings[] = { sourceName.get() }; - nsXPIDLString importedBookmarksTitle; + nsString importedBookmarksTitle; bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), sourceNameStrings, 1, getter_Copies(importedBookmarksTitle)); diff --git a/browser/components/migration/src/nsBrowserProfileMigratorUtils.h b/browser/components/migration/src/nsBrowserProfileMigratorUtils.h index 83c18d3952dca..992d92b70a573 100644 --- a/browser/components/migration/src/nsBrowserProfileMigratorUtils.h +++ b/browser/components/migration/src/nsBrowserProfileMigratorUtils.h @@ -60,7 +60,9 @@ #include "nsIPrefBranch.h" #include "nsIFile.h" -#include "nsString.h" +#include "nsStringAPI.h" +#include "nsCOMPtr.h" + class nsIProfileStartup; diff --git a/browser/components/migration/src/nsCaminoProfileMigrator.cpp b/browser/components/migration/src/nsCaminoProfileMigrator.cpp index 436319da8a157..c2f9eb7d46127 100644 --- a/browser/components/migration/src/nsCaminoProfileMigrator.cpp +++ b/browser/components/migration/src/nsCaminoProfileMigrator.cpp @@ -42,6 +42,7 @@ #include "nsIServiceManager.h" #include "nsISupportsArray.h" #include "nsISupportsPrimitives.h" +#include "nsServiceManagerUtils.h" /////////////////////////////////////////////////////////////////////////////// // nsCaminoProfileMigrator diff --git a/browser/components/migration/src/nsCaminoProfileMigrator.h b/browser/components/migration/src/nsCaminoProfileMigrator.h index 91623ccac48ac..42f6c39bccab2 100644 --- a/browser/components/migration/src/nsCaminoProfileMigrator.h +++ b/browser/components/migration/src/nsCaminoProfileMigrator.h @@ -41,7 +41,7 @@ #include "nsIBrowserProfileMigrator.h" #include "nsIObserverService.h" #include "nsISupportsArray.h" -#include "nsString.h" +#include "nsStringAPI.h" class nsCaminoProfileMigrator : public nsIBrowserProfileMigrator { @@ -58,4 +58,4 @@ private: nsCOMPtr<nsIObserverService> mObserverService; }; -#endif \ No newline at end of file +#endif diff --git a/browser/components/migration/src/nsDogbertProfileMigrator.cpp b/browser/components/migration/src/nsDogbertProfileMigrator.cpp index 9aff14bf32425..7451699cd6e91 100644 --- a/browser/components/migration/src/nsDogbertProfileMigrator.cpp +++ b/browser/components/migration/src/nsDogbertProfileMigrator.cpp @@ -37,7 +37,6 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsBrowserProfileMigratorUtils.h" -#include "nsCRT.h" #include "nsDogbertProfileMigrator.h" #include "nsICookieManager2.h" #include "nsIFile.h" @@ -53,12 +52,12 @@ #include "nsISupportsPrimitives.h" #include "nsNetCID.h" #include "nsNetUtil.h" -#include "nsReadableUtils.h" #include "prprf.h" #include "prenv.h" -#include "nsEscape.h" #include "NSReg.h" #include "nsDirectoryServiceDefs.h" +#include "nsDirectoryServiceUtils.h" +#include <stdlib.h> #ifndef MAXPATHLEN #ifdef _MAX_PATH @@ -289,7 +288,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) if (!mProfiles) { nsresult rv; - rv = NS_NewISupportsArray(getter_AddRefs(mProfiles)); + mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIFile> regFile; @@ -361,7 +360,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) mSourceProfile = profileFile; - rv = NS_NewISupportsArray(getter_AddRefs(mProfiles)); + mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsISupportsString> nameString @@ -566,7 +565,7 @@ nsDogbertProfileMigrator::FixDogbertCookies() // skip line if it is a comment or null line if (buffer.IsEmpty() || buffer.CharAt(0) == '#' || - buffer.CharAt(0) == nsCRT::CR || buffer.CharAt(0) == nsCRT::LF) { + buffer.CharAt(0) == '\r' || buffer.CharAt(0) == '\n') { fileOutputStream->Write(buffer.get(), buffer.Length(), &written); continue; } @@ -583,15 +582,17 @@ nsDogbertProfileMigrator::FixDogbertCookies() continue; // separate the expires field from the rest of the cookie line - nsCAutoString prefix, expiresString, suffix; - buffer.Mid(prefix, hostIndex, expiresIndex-hostIndex-1); - buffer.Mid(expiresString, expiresIndex, nameIndex-expiresIndex-1); - buffer.Mid(suffix, nameIndex, buffer.Length()-nameIndex); + const nsDependentCSubstring prefix = + Substring(buffer, hostIndex, expiresIndex-hostIndex-1); + const nsDependentCSubstring expiresString = + Substring(buffer, expiresIndex, nameIndex-expiresIndex-1); + const nsDependentCSubstring suffix = + Substring(buffer, nameIndex, buffer.Length()-nameIndex); // correct the expires field char* expiresCString = ToNewCString(expiresString); unsigned long expires = strtoul(expiresCString, nsnull, 10); - nsCRT::free(expiresCString); + NS_Free(expiresCString); // if the cookie is supposed to expire at the end of the session // expires == 0. don't adjust those cookies. @@ -643,7 +644,7 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks() dogbertPrefsFile->Append(PREF_FILE_NAME_IN_4x); psvc->ReadUserPrefs(dogbertPrefsFile); - nsXPIDLCString toolbarName; + nsCString toolbarName; nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc)); rv = branch->GetCharPref("custtoolbar.personal_toolbar_folder", getter_Copies(toolbarName)); // If the pref wasn't set in the user's 4.x preferences, there's no way we can "Fix" the @@ -663,5 +664,5 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks() targetBookmarksFile->Append(BOOKMARKS_FILE_NAME_IN_5x); return AnnotatePersonalToolbarFolder(sourceBookmarksFile, - targetBookmarksFile, toolbarName); + targetBookmarksFile, toolbarName.get()); } diff --git a/browser/components/migration/src/nsDogbertProfileMigrator.h b/browser/components/migration/src/nsDogbertProfileMigrator.h index 9d3b9c5d0603f..bf3d75deb87f7 100644 --- a/browser/components/migration/src/nsDogbertProfileMigrator.h +++ b/browser/components/migration/src/nsDogbertProfileMigrator.h @@ -43,7 +43,7 @@ #include "nsIObserverService.h" #include "nsISupportsArray.h" #include "nsNetscapeProfileMigratorBase.h" -#include "nsString.h" +#include "nsStringAPI.h" #ifdef XP_MACOSX #define NEED_TO_FIX_4X_COOKIES 1 diff --git a/browser/components/migration/src/nsICabProfileMigrator.cpp b/browser/components/migration/src/nsICabProfileMigrator.cpp index 0d49c854f6909..cdd595d2f6159 100644 --- a/browser/components/migration/src/nsICabProfileMigrator.cpp +++ b/browser/components/migration/src/nsICabProfileMigrator.cpp @@ -42,6 +42,7 @@ #include "nsIServiceManager.h" #include "nsISupportsArray.h" #include "nsISupportsPrimitives.h" +#include "nsServiceManagerUtils.h" /////////////////////////////////////////////////////////////////////////////// // nsICabProfileMigrator diff --git a/browser/components/migration/src/nsICabProfileMigrator.h b/browser/components/migration/src/nsICabProfileMigrator.h index a641b877bc577..34ef943e4b59d 100644 --- a/browser/components/migration/src/nsICabProfileMigrator.h +++ b/browser/components/migration/src/nsICabProfileMigrator.h @@ -41,7 +41,7 @@ #include "nsIBrowserProfileMigrator.h" #include "nsIObserverService.h" #include "nsISupportsArray.h" -#include "nsString.h" +#include "nsStringAPI.h" class nsICabProfileMigrator : public nsIBrowserProfileMigrator { @@ -58,4 +58,4 @@ private: nsCOMPtr<nsIObserverService> mObserverService; }; -#endif \ No newline at end of file +#endif diff --git a/browser/components/migration/src/nsIEProfileMigrator.cpp b/browser/components/migration/src/nsIEProfileMigrator.cpp index 27bef75207dcd..845e1626a8b72 100644 --- a/browser/components/migration/src/nsIEProfileMigrator.cpp +++ b/browser/components/migration/src/nsIEProfileMigrator.cpp @@ -45,12 +45,13 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsBrowserProfileMigratorUtils.h" #include "nsCOMPtr.h" +#include "nsCRTGlue.h" #include "nsNetCID.h" #include "nsDocShellCID.h" #include "nsDebug.h" -#include "nsDependentString.h" #include "nsDirectoryServiceDefs.h" -#include "nsString.h" +#include "nsDirectoryServiceUtils.h" +#include "nsStringAPI.h" #include "plstr.h" #include "prio.h" #include "prmem.h" @@ -91,7 +92,6 @@ #include "nsIBookmarksService.h" #endif #include "nsIStringBundle.h" -#include "nsCRT.h" #include "nsNetUtil.h" #include "nsToolkitCompsCID.h" #include "nsUnicharUtils.h" @@ -877,7 +877,7 @@ nsIEProfileMigrator::MigrateSiteAuthSignons(IPStore* aPStore) } nsAutoString tmp(itemName); - tmp.Truncate(6); + tmp.SetLength(6); if (tmp.Equals(NS_LITERAL_STRING("DPAPI:"))) // often FTP logins password = NULL; // We can't handle these yet @@ -920,9 +920,8 @@ nsIEProfileMigrator::GetSignonsListFromPStore(IPStore* aPStore, nsVoidArray* aSi hr = aPStore->ReadItem(0, &IEPStoreAutocompGUID, &IEPStoreAutocompGUID, itemName, &count, &data, NULL, 0); if (SUCCEEDED(hr) && data) { nsAutoString itemNameString(itemName); - nsAutoString suffix; - itemNameString.Right(suffix, 11); - if (suffix.EqualsIgnoreCase(":StringData")) { + if (StringTail(itemNameString, 11). + LowerCaseEqualsLiteral(":stringdata")) { // :StringData contains the saved data const nsAString& key = Substring(itemNameString, 0, itemNameString.Length() - 11); char* realm = nsnull; @@ -977,7 +976,7 @@ nsIEProfileMigrator::KeyIsURI(const nsAString& aKey, char** aRealm) uri->GetHost(host); realm.Append(host); - *aRealm = nsCRT::strdup(realm.get()); + *aRealm = ToNewCString(realm); return validScheme; } } @@ -1000,15 +999,14 @@ nsIEProfileMigrator::ResolveAndMigrateSignons(IPStore* aPStore, nsVoidArray* aSi hr = aPStore->ReadItem(0, &IEPStoreAutocompGUID, &IEPStoreAutocompGUID, itemName, &count, &data, NULL, 0); if (SUCCEEDED(hr) && data) { nsAutoString itemNameString(itemName); - nsAutoString suffix; - itemNameString.Right(suffix, 11); - if (suffix.EqualsIgnoreCase(":StringData")) { + if (StringTail(itemNameString, 11). + LowerCaseEqualsLiteral(":stringdata")) { // :StringData contains the saved data const nsAString& key = Substring(itemNameString, 0, itemNameString.Length() - 11); // Assume all keys that are valid URIs are signons, not saved form data, and that // all keys that aren't valid URIs are form field names (containing form data). - nsXPIDLCString realm; + nsCString realm; if (!KeyIsURI(key, getter_Copies(realm))) { // Search the data for a username that matches one of the found signons. EnumerateUsernames(key, (PRUnichar*)data, (count/sizeof(PRUnichar)), aSignonsFound); @@ -1025,7 +1023,7 @@ nsIEProfileMigrator::ResolveAndMigrateSignons(IPStore* aPStore, nsVoidArray* aSi for (PRInt32 i = 0; i < signonCount; ++i) { SignonData* sd = (SignonData*)aSignonsFound->ElementAt(i); ::CoTaskMemFree(sd->user); // |sd->user| is a pointer to the start of a buffer that also contains sd->pass - nsCRT::free(sd->realm); + NS_Free(sd->realm); delete sd; } } @@ -1128,12 +1126,11 @@ nsIEProfileMigrator::CopyFormData(PRBool aReplace) hr = PStore->ReadItem(0, &IEPStoreAutocompGUID, &IEPStoreAutocompGUID, itemName, &count, &data, NULL, 0); if (SUCCEEDED(hr) && data) { nsAutoString itemNameString(itemName); - nsAutoString suffix; - itemNameString.Right(suffix, 11); - if (suffix.EqualsIgnoreCase(":StringData")) { + if (StringTail(itemNameString, 11). + LowerCaseEqualsLiteral(":stringdata")) { // :StringData contains the saved data const nsAString& key = Substring(itemNameString, 0, itemNameString.Length() - 11); - nsXPIDLCString realm; + nsCString realm; if (!KeyIsURI(key, getter_Copies(realm))) { nsresult rv = AddDataToFormHistory(key, (PRUnichar*)data, (count/sizeof(PRUnichar))); if (NS_FAILED(rv)) return rv; @@ -1212,12 +1209,12 @@ nsIEProfileMigrator::CopyFavorites(PRBool aReplace) { nsCOMPtr<nsIStringBundle> bundle; bundleService->CreateBundle(TRIDENTPROFILE_BUNDLE, getter_AddRefs(bundle)); - nsXPIDLString sourceNameIE; + nsString sourceNameIE; bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameIE").get(), getter_Copies(sourceNameIE)); const PRUnichar* sourceNameStrings[] = { sourceNameIE.get() }; - nsXPIDLString importedIEFavsTitle; + nsString importedIEFavsTitle; bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), sourceNameStrings, 1, getter_Copies(importedIEFavsTitle)); @@ -1284,7 +1281,7 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder) nsresult rv; nsCOMPtr<nsINavBookmarksService> bms(do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); - PRInt64 keywordsFolder; + PRInt64 keywordsFolder = 0; #else nsCOMPtr<nsIBookmarksService> bms(do_GetService("@mozilla.org/browser/bookmarks-service;1")); nsCOMPtr<nsIRDFResource> keywordsFolder, bookmark; @@ -1303,12 +1300,12 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder) break; if (!keywordsFolder) { - nsXPIDLString sourceNameIE; + nsString sourceNameIE; bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameIE").get(), getter_Copies(sourceNameIE)); const PRUnichar* sourceNameStrings[] = { sourceNameIE.get() }; - nsXPIDLString importedIESearchUrlsTitle; + nsString importedIESearchUrlsTitle; bundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchURLsFolder").get(), sourceNameStrings, 1, getter_Copies(importedIESearchUrlsTitle)); #ifdef MOZ_PLACES @@ -1337,13 +1334,13 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder) NS_ConvertUTF8toUTF16 host(hostCStr); const PRUnichar* nameStrings[] = { host.get() }; - nsXPIDLString keywordName; + nsString keywordName; nsresult rv = bundle->FormatStringFromName( NS_LITERAL_STRING("importedSearchURLsTitle").get(), nameStrings, 1, getter_Copies(keywordName)); const PRUnichar* descStrings[] = { keyName.get(), host.get() }; - nsXPIDLString keywordDesc; + nsString keywordDesc; rv = bundle->FormatStringFromName( NS_LITERAL_STRING("importedSearchUrlDesc").get(), descStrings, 2, getter_Copies(keywordDesc)); @@ -1373,7 +1370,7 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder) } void -nsIEProfileMigrator::ResolveShortcut(const nsAFlatString &aFileName, char** aOutURL) +nsIEProfileMigrator::ResolveShortcut(const nsString &aFileName, char** aOutURL) { HRESULT result; @@ -1467,8 +1464,8 @@ nsIEProfileMigrator::ParseFavoritesFolder(nsIFile* aDirectory, NS_NAMED_LITERAL_STRING(lnkExt, ".lnk"); PRInt32 lnkExtStart = bookmarkName.Length() - lnkExt.Length(); if (StringEndsWith(bookmarkName, lnkExt, - nsCaseInsensitiveStringComparator())) - bookmarkName.Truncate(lnkExtStart); + CaseInsensitiveCompare)) + bookmarkName.SetLength(lnkExtStart); #ifdef MOZ_PLACES nsCOMPtr<nsIURI> bookmarkURI; @@ -1561,8 +1558,7 @@ nsIEProfileMigrator::ParseFavoritesFolder(nsIFile* aDirectory, nsCAutoString extension; url->GetFileExtension(extension); - if (!extension.Equals(NS_LITERAL_CSTRING("url"), - nsCaseInsensitiveCStringComparator())) + if (!extension.Equals("url", CaseInsensitiveCompare)) continue; nsAutoString name(Substring(bookmarkName, 0, @@ -1571,7 +1567,7 @@ nsIEProfileMigrator::ParseFavoritesFolder(nsIFile* aDirectory, nsAutoString path; currFile->GetPath(path); - nsXPIDLCString resolvedURL; + nsCString resolvedURL; ResolveShortcut(path, getter_Copies(resolvedURL)); #ifdef MOZ_PLACES @@ -1719,7 +1715,7 @@ nsIEProfileMigrator::CopyCookies(PRBool aReplace) nsCAutoString fileName; cookieFile->GetNativeLeafName(fileName); const nsACString &fileOwner = Substring(fileName, 0, usernameLength); - if (!fileOwner.Equals(username, nsCaseInsensitiveCStringComparator())) + if (!fileOwner.Equals(username, CaseInsensitiveCompare)) continue; // ensure the contents buffer is large enough to hold the entire file diff --git a/browser/components/migration/src/nsIEProfileMigrator.h b/browser/components/migration/src/nsIEProfileMigrator.h index 9d4f90cb07f98..fef2876e7de94 100644 --- a/browser/components/migration/src/nsIEProfileMigrator.h +++ b/browser/components/migration/src/nsIEProfileMigrator.h @@ -89,7 +89,7 @@ protected: nsresult AddDataToFormHistory(const nsAString& aKey, PRUnichar* data, unsigned long len); nsresult CopyFavorites(PRBool aReplace); - void ResolveShortcut(const nsAFlatString &aFileName, char** aOutURL); + void ResolveShortcut(const nsString &aFileName, char** aOutURL); #ifdef MOZ_PLACES nsresult ParseFavoritesFolder(nsIFile* aDirectory, PRInt64 aParentFolder, diff --git a/browser/components/migration/src/nsMacIEProfileMigrator.cpp b/browser/components/migration/src/nsMacIEProfileMigrator.cpp index bac5865e7e369..5ed3dc03e2f26 100644 --- a/browser/components/migration/src/nsMacIEProfileMigrator.cpp +++ b/browser/components/migration/src/nsMacIEProfileMigrator.cpp @@ -20,6 +20,7 @@ * * Contributor(s): * Ben Goodger <ben@bengoodger.com> + * Benjamin Smedberg <benjamin@smedbergs.us> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -45,6 +46,8 @@ #include "nsIStringBundle.h" #include "nsISupportsArray.h" #include "nsISupportsPrimitives.h" +#include "nsServiceManagerUtils.h" +#include "nsIProperties.h" #define MACIE_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("Favorites.html") #define MACIE_PREFERENCES_FOLDER_NAME NS_LITERAL_STRING("Explorer") @@ -196,7 +199,7 @@ nsMacIEProfileMigrator::CopyBookmarks(PRBool aReplace) rv = bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle)); NS_ENSURE_SUCCESS(rv, rv); - nsXPIDLString toolbarFolderNameMacIE; + nsString toolbarFolderNameMacIE; bundle->GetStringFromName(NS_LITERAL_STRING("toolbarFolderNameMacIE").get(), getter_Copies(toolbarFolderNameMacIE)); nsCAutoString ctoolbarFolderNameMacIE; diff --git a/browser/components/migration/src/nsMacIEProfileMigrator.h b/browser/components/migration/src/nsMacIEProfileMigrator.h index 51087eb05df23..7733b0ed9362e 100644 --- a/browser/components/migration/src/nsMacIEProfileMigrator.h +++ b/browser/components/migration/src/nsMacIEProfileMigrator.h @@ -41,7 +41,7 @@ #include "nsIBrowserProfileMigrator.h" #include "nsIObserverService.h" #include "nsISupportsArray.h" -#include "nsString.h" +#include "nsStringAPI.h" class nsMacIEProfileMigrator : public nsIBrowserProfileMigrator { diff --git a/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp b/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp index 94f3270307fed..7957b7d57af35 100644 --- a/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp +++ b/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp @@ -37,7 +37,6 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsBrowserProfileMigratorUtils.h" -#include "nsCRT.h" #include "nsICookieManager2.h" #include "nsIFile.h" #include "nsILineInputStream.h" @@ -52,8 +51,6 @@ #include "nsIURL.h" #include "nsNetscapeProfileMigratorBase.h" #include "nsNetUtil.h" -#include "nsReadableUtils.h" -#include "nsXPIDLString.h" #include "prtime.h" #include "prprf.h" @@ -175,8 +172,8 @@ nsNetscapeProfileMigratorBase::GetProfileDataFromRegistry(nsILocalFile* aRegistr aProfileLocations->AppendElement(dir); // Get the profile name and add it to the names array - nsXPIDLString profileName; - CopyUTF8toUTF16(profileStr, profileName); + nsString profileName; + CopyUTF8toUTF16(nsDependentCString(profileStr), profileName); nsCOMPtr<nsISupportsString> profileNameString( do_CreateInstance("@mozilla.org/supports-string;1")); @@ -227,7 +224,7 @@ nsNetscapeProfileMigratorBase::GetWString(void* aTransform, nsIPrefBranch* aBran getter_AddRefs(prefValue)); if (NS_SUCCEEDED(rv) && prefValue) { - nsXPIDLString data; + nsString data; prefValue->ToString(getter_Copies(data)); xform->stringValue = ToNewCString(NS_ConvertUTF16toUTF8(data)); @@ -242,7 +239,7 @@ nsNetscapeProfileMigratorBase::SetWStringFromASCII(void* aTransform, nsIPrefBran PrefTransform* xform = (PrefTransform*)aTransform; if (xform->prefHasValue) { nsCOMPtr<nsIPrefLocalizedString> pls(do_CreateInstance("@mozilla.org/pref-localizedstring;1")); - nsAutoString data; data.AssignWithConversion(xform->stringValue); + NS_ConvertUTF8toUTF16 data(xform->stringValue); pls->SetData(data.get()); return aBranch->SetComplexValue(xform->targetPrefName ? xform->targetPrefName : xform->sourcePrefName, NS_GET_IID(nsIPrefLocalizedString), pls); } @@ -341,7 +338,6 @@ nsNetscapeProfileMigratorBase::ImportNetscapeCookies(nsIFile* aCookiesFile) nsCAutoString buffer; PRBool isMore = PR_TRUE; PRInt32 hostIndex = 0, isDomainIndex, pathIndex, secureIndex, expiresIndex, nameIndex, cookieIndex; - nsASingleFragmentCString::char_iterator iter; PRInt32 numInts; PRInt64 expires; PRBool isDomain; @@ -381,18 +377,19 @@ nsNetscapeProfileMigratorBase::ImportNetscapeCookies(nsIFile* aCookiesFile) // check the expirytime first - if it's expired, ignore // nullstomp the trailing tab, to avoid copying the string - buffer.BeginWriting(iter); + char *iter = buffer.BeginWriting(); *(iter += nameIndex - 1) = char(0); numInts = PR_sscanf(buffer.get() + expiresIndex, "%lld", &expires); if (numInts != 1 || nsInt64(expires) < currentTime) continue; isDomain = Substring(buffer, isDomainIndex, pathIndex - isDomainIndex - 1).Equals(kTrue); - const nsASingleFragmentCString &host = Substring(buffer, hostIndex, isDomainIndex - hostIndex - 1); + const nsDependentCSubstring host = + Substring(buffer, hostIndex, isDomainIndex - hostIndex - 1); // check for bad legacy cookies (domain not starting with a dot, or containing a port), // and discard if (isDomain && !host.IsEmpty() && host.First() != '.' || - host.FindChar(':') != kNotFound) + host.FindChar(':') != -1) continue; // create a new nsCookie and assign the data. @@ -458,7 +455,7 @@ nsNetscapeProfileMigratorBase::LocateSignonsFile(char** aResult) nsCAutoString extn; url->GetFileExtension(extn); - if (extn.EqualsIgnoreCase("s")) { + if (extn.Equals("s", CaseInsensitiveCompare)) { url->GetFileName(fileName); break; } diff --git a/browser/components/migration/src/nsNetscapeProfileMigratorBase.h b/browser/components/migration/src/nsNetscapeProfileMigratorBase.h index 6d9a1fd1b181f..d9c4989bb1d69 100644 --- a/browser/components/migration/src/nsNetscapeProfileMigratorBase.h +++ b/browser/components/migration/src/nsNetscapeProfileMigratorBase.h @@ -41,7 +41,7 @@ #include "nsILocalFile.h" #include "nsIStringBundle.h" #include "nsISupportsArray.h" -#include "nsString.h" +#include "nsStringAPI.h" class nsIFile; class nsIPrefBranch; diff --git a/browser/components/migration/src/nsOmniWebProfileMigrator.cpp b/browser/components/migration/src/nsOmniWebProfileMigrator.cpp index 28cbb53a9d2b2..7036abca7e471 100644 --- a/browser/components/migration/src/nsOmniWebProfileMigrator.cpp +++ b/browser/components/migration/src/nsOmniWebProfileMigrator.cpp @@ -20,6 +20,7 @@ * * Contributor(s): * Ben Goodger <ben@bengoodger.com> + * Benjamin Smedberg <benjamin@smedbergs.us> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -42,6 +43,7 @@ #include "nsIServiceManager.h" #include "nsISupportsArray.h" #include "nsISupportsPrimitives.h" +#include "nsServiceManagerUtils.h" /////////////////////////////////////////////////////////////////////////////// // nsOmniWebProfileMigrator diff --git a/browser/components/migration/src/nsOmniWebProfileMigrator.h b/browser/components/migration/src/nsOmniWebProfileMigrator.h index ba43b14c68430..1fb6894744dcb 100644 --- a/browser/components/migration/src/nsOmniWebProfileMigrator.h +++ b/browser/components/migration/src/nsOmniWebProfileMigrator.h @@ -41,7 +41,7 @@ #include "nsIBrowserProfileMigrator.h" #include "nsIObserverService.h" #include "nsISupportsArray.h" -#include "nsString.h" +#include "nsStringAPI.h" class nsOmniWebProfileMigrator : public nsIBrowserProfileMigrator { @@ -58,4 +58,4 @@ private: nsCOMPtr<nsIObserverService> mObserverService; }; -#endif \ No newline at end of file +#endif diff --git a/browser/components/migration/src/nsOperaProfileMigrator.cpp b/browser/components/migration/src/nsOperaProfileMigrator.cpp index c31841c94acf4..8e0acf237dcb0 100644 --- a/browser/components/migration/src/nsOperaProfileMigrator.cpp +++ b/browser/components/migration/src/nsOperaProfileMigrator.cpp @@ -37,8 +37,8 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsBrowserProfileMigratorUtils.h" -#include "nsCRT.h" #include "nsDirectoryServiceDefs.h" +#include "nsDirectoryServiceUtils.h" #include "nsDocShellCID.h" #ifdef MOZ_PLACES #include "nsINavBookmarksService.h" @@ -67,8 +67,6 @@ #include "nsISupportsPrimitives.h" #include "nsNetUtil.h" #include "nsOperaProfileMigrator.h" -#include "nsReadableUtils.h" -#include "nsString.h" #include "nsToolkitCompsCID.h" #ifdef XP_WIN #include <windows.h> @@ -217,7 +215,9 @@ NS_IMETHODIMP nsOperaProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) { if (!mProfiles) { - nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfiles)); + nsresult rv; + + mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIProperties> fileLocator(do_GetService("@mozilla.org/file/directory_service;1")); @@ -379,7 +379,7 @@ nsOperaProfileMigrator::SetWString(void* aTransform, nsIPrefBranch* aBranch) { PrefTransform* xform = (PrefTransform*)aTransform; nsCOMPtr<nsIPrefLocalizedString> pls(do_CreateInstance("@mozilla.org/pref-localizedstring;1")); - nsAutoString data; data.AssignWithConversion(xform->stringValue); + NS_ConvertASCIItoUTF16 data(xform->stringValue); pls->SetData(data.get()); return aBranch->SetComplexValue(xform->targetPrefName, NS_GET_IID(nsIPrefLocalizedString), pls); } @@ -435,7 +435,7 @@ nsOperaProfileMigrator::CopyPreferences(PRBool aReplace) transform->prefSetterFunc(transform, branch); } if (colorString) - nsCRT::free(colorString); + NS_Free(colorString); } else { nsCAutoString val; @@ -443,7 +443,7 @@ nsOperaProfileMigrator::CopyPreferences(PRBool aReplace) transform->keyName, val); if (NS_SUCCEEDED(rv)) { - PRInt32 strerr; + nsresult strerr; switch (transform->type) { case _OPM(STRING): transform->stringValue = ToNewCString(val); @@ -462,7 +462,7 @@ nsOperaProfileMigrator::CopyPreferences(PRBool aReplace) transform->prefHasValue = PR_TRUE; transform->prefSetterFunc(transform, branch); if (transform->type == _OPM(STRING) && transform->stringValue) { - nsCRT::free(transform->stringValue); + NS_Free(transform->stringValue); transform->stringValue = nsnull; } } @@ -550,7 +550,7 @@ nsOperaProfileMigrator::GetInteger(nsINIParser &aParser, if (NS_FAILED(rv)) return rv; - *aResult = val.ToInteger((PRInt32*) &rv); + *aResult = val.ToInteger(&rv); return rv; } @@ -874,7 +874,7 @@ nsOperaCookieMigrator::AddCookieOverride(nsIPermissionManager* aManager) { nsresult rv; - nsXPIDLCString domain; + nsCString domain; SynthesizeDomain(getter_Copies(domain)); nsCOMPtr<nsIURI> uri(do_CreateInstance("@mozilla.org/network/standard-url;1")); if (!uri) @@ -896,10 +896,10 @@ nsOperaCookieMigrator::AddCookie(nsICookieManager2* aManager) { // This is where we use the information gathered in all the other // states to add a cookie to the Firebird/Firefox Cookie Manager. - nsXPIDLCString domain; + nsCString domain; SynthesizeDomain(getter_Copies(domain)); - nsXPIDLCString path; + nsCString path; SynthesizePath(getter_Copies(path)); mCookieOpen = PR_FALSE; @@ -1006,7 +1006,7 @@ nsOperaProfileMigrator::CopyHistory(PRBool aReplace) break; case LASTVISIT: // Opera time format is a second offset, PRTime is a microsecond offset - PRInt32 err; + nsresult err; lastVisitDate = buffer.ToInteger(&err); PRInt64 temp, million; @@ -1067,12 +1067,12 @@ nsOperaProfileMigrator::CopyBookmarks(PRBool aReplace) nsCOMPtr<nsIStringBundle> bundle; bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle)); if (!aReplace) { - nsXPIDLString sourceNameOpera; + nsString sourceNameOpera; bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameOpera").get(), getter_Copies(sourceNameOpera)); const PRUnichar* sourceNameStrings[] = { sourceNameOpera.get() }; - nsXPIDLString importedOperaHotlistTitle; + nsString importedOperaHotlistTitle; bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), sourceNameStrings, 1, getter_Copies(importedOperaHotlistTitle)); @@ -1135,12 +1135,12 @@ nsOperaProfileMigrator::CopySmartKeywords(nsIBookmarksService* aBMS, if (NS_FAILED(rv)) return NS_OK; - nsXPIDLString sourceNameOpera; + nsString sourceNameOpera; aBundle->GetStringFromName(NS_LITERAL_STRING("sourceNameOpera").get(), getter_Copies(sourceNameOpera)); const PRUnichar* sourceNameStrings[] = { sourceNameOpera.get() }; - nsXPIDLString importedSearchUrlsTitle; + nsString importedSearchUrlsTitle; aBundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchURLsFolder").get(), sourceNameStrings, 1, getter_Copies(importedSearchUrlsTitle)); @@ -1207,10 +1207,10 @@ nsOperaProfileMigrator::CopySmartKeywords(nsIBookmarksService* aBMS, nsCAutoString hostCStr; uri->GetHost(hostCStr); - nsAutoString host; host.AssignWithConversion(hostCStr.get()); + NS_ConvertASCIItoUTF16 host(hostCStr); const PRUnichar* descStrings[] = { NS_ConvertUTF8toUTF16(keyword).get(), host.get() }; - nsXPIDLString keywordDesc; + nsString keywordDesc; aBundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchUrlDesc").get(), descStrings, 2, getter_Copies(keywordDesc)); @@ -1340,7 +1340,6 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream, nsAutoString name, keyword, description; nsCAutoString url; PRBool onToolbar = PR_FALSE; - NS_NAMED_LITERAL_STRING(empty, ""); do { nsCAutoString cBuffer; rv = aStream->ReadLine(cBuffer, &moreData); @@ -1349,7 +1348,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream, if (!moreData) break; CopyUTF8toUTF16(cBuffer, buffer); - nsXPIDLString data; + nsString data; LineType type = GetLineType(buffer, getter_Copies(data)); switch(type) { case LineType_FOLDER: @@ -1415,10 +1414,10 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream, if (NS_FAILED(rv)) continue; #endif - name = empty; - url.AssignWithConversion(empty); - keyword = empty; - description = empty; + name.Truncate(); + url.Truncate(); + keyword.Truncate(); + description.Truncate(); onToolbar = PR_FALSE; } } @@ -1440,7 +1439,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream, continue; rv = ParseBookmarksFolder(aStream, itemRes, aToolbar, aBMS); #endif - name = empty; + name.Truncate(); } } break; diff --git a/browser/components/migration/src/nsOperaProfileMigrator.h b/browser/components/migration/src/nsOperaProfileMigrator.h index 5ab44b7000be4..d2dc1d2e62190 100644 --- a/browser/components/migration/src/nsOperaProfileMigrator.h +++ b/browser/components/migration/src/nsOperaProfileMigrator.h @@ -43,7 +43,7 @@ #include "nsIBrowserProfileMigrator.h" #include "nsIObserverService.h" #include "nsISupportsArray.h" -#include "nsString.h" +#include "nsStringAPI.h" #include "nsVoidArray.h" class nsICookieManager2; diff --git a/browser/components/migration/src/nsPhoenixProfileMigrator.cpp b/browser/components/migration/src/nsPhoenixProfileMigrator.cpp index 164f7c7abdce8..2bfde1abdff0b 100644 --- a/browser/components/migration/src/nsPhoenixProfileMigrator.cpp +++ b/browser/components/migration/src/nsPhoenixProfileMigrator.cpp @@ -36,7 +36,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsBrowserProfileMigratorUtils.h" -#include "nsCRT.h" #include "nsDirectoryServiceDefs.h" #include "nsIObserverService.h" #include "nsIPrefService.h" @@ -173,11 +172,11 @@ nsPhoenixProfileMigrator::GetMigrateData(const PRUnichar* aProfile, aReplace, mSourceProfile, aResult); // Now locate passwords - nsXPIDLCString signonsFileName; + nsCString signonsFileName; GetSignonFileName(aReplace, getter_Copies(signonsFileName)); if (!signonsFileName.IsEmpty()) { - nsAutoString fileName; fileName.AssignWithConversion(signonsFileName); + NS_ConvertASCIItoUTF16 fileName(signonsFileName); nsCOMPtr<nsIFile> sourcePasswordsFile; mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile)); sourcePasswordsFile->Append(fileName); @@ -229,11 +228,9 @@ NS_IMETHODIMP nsPhoenixProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) { if (!mProfileNames && !mProfileLocations) { - nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfileNames)); - if (NS_FAILED(rv)) return rv; - - rv = NS_NewISupportsArray(getter_AddRefs(mProfileLocations)); - if (NS_FAILED(rv)) return rv; + mProfileNames = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); + mProfileLocations = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); + NS_ENSURE_TRUE(mProfileNames && mProfileLocations, NS_ERROR_UNEXPECTED); // Fills mProfileNames and mProfileLocations FillProfileDataFromPhoenixRegistry(); @@ -257,11 +254,14 @@ nsPhoenixProfileMigrator::GetSourceProfile(const PRUnichar* aProfile) PRUint32 count; mProfileNames->Count(&count); for (PRUint32 i = 0; i < count; ++i) { - nsCOMPtr<nsISupportsString> str(do_QueryElementAt(mProfileNames, i)); - nsXPIDLString profileName; + nsCOMPtr<nsISupportsString> str; + mProfileNames->QueryElementAt(i, NS_GET_IID(nsISupportsString), + getter_AddRefs(str)); + nsString profileName; str->GetData(profileName); if (profileName.Equals(aProfile)) { - mSourceProfile = do_QueryElementAt(mProfileLocations, i); + mProfileLocations->QueryElementAt(i, NS_GET_IID(nsILocalFile), + getter_AddRefs(mSourceProfile)); break; } } @@ -397,7 +397,7 @@ nsPhoenixProfileMigrator::CopyPasswords(PRBool aReplace) { nsresult rv; - nsXPIDLCString signonsFileName; + nsCString signonsFileName; if (!aReplace) return NS_OK; @@ -417,7 +417,7 @@ nsPhoenixProfileMigrator::CopyPasswords(PRBool aReplace) if (signonsFileName.IsEmpty()) return NS_ERROR_FILE_NOT_FOUND; - nsAutoString fileName; fileName.AssignWithConversion(signonsFileName); + NS_ConvertASCIItoUTF16 fileName(signonsFileName); return aReplace ? CopyFile(fileName, fileName) : NS_OK; } diff --git a/browser/components/migration/src/nsPhoenixProfileMigrator.h b/browser/components/migration/src/nsPhoenixProfileMigrator.h index df2fb99e1a2d1..3eb5d63f1b637 100644 --- a/browser/components/migration/src/nsPhoenixProfileMigrator.h +++ b/browser/components/migration/src/nsPhoenixProfileMigrator.h @@ -43,7 +43,7 @@ #include "nsIObserverService.h" #include "nsISupportsArray.h" #include "nsNetscapeProfileMigratorBase.h" -#include "nsString.h" +#include "nsStringAPI.h" class nsIFile; class nsIPrefBranch; diff --git a/browser/components/migration/src/nsProfileMigrator.cpp b/browser/components/migration/src/nsProfileMigrator.cpp index 7091d958a63fa..f717acfee5757 100644 --- a/browser/components/migration/src/nsProfileMigrator.cpp +++ b/browser/components/migration/src/nsProfileMigrator.cpp @@ -42,6 +42,7 @@ #include "nsIDOMWindowInternal.h" #include "nsILocalFile.h" #include "nsIObserverService.h" +#include "nsIProperties.h" #include "nsIServiceManager.h" #include "nsISupportsPrimitives.h" #include "nsISupportsArray.h" @@ -51,13 +52,13 @@ #include "nsCOMPtr.h" #include "nsBrowserCompsCID.h" +#include "nsComponentManagerUtils.h" #include "nsDirectoryServiceDefs.h" +#include "nsServiceManagerUtils.h" -#include "nsCRT.h" #include "NSReg.h" -#include "nsReadableUtils.h" +#include "nsStringAPI.h" #include "nsUnicharUtils.h" -#include "nsString.h" #ifdef XP_WIN #include <windows.h> #include "nsIWindowsRegKey.h" @@ -65,7 +66,6 @@ #endif #include "nsAutoPtr.h" -#include "nsNativeCharsetUtils.h" #ifndef MAXPATHLEN #ifdef _MAX_PATH @@ -95,8 +95,8 @@ nsProfileMigrator::Migrate(nsIProfileStartup* aStartup) if (NS_FAILED(rv)) return rv; if (!bpm) { - nsCAutoString contractID = - NS_LITERAL_CSTRING(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX) + key; + nsCAutoString contractID(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX); + contractID.Append(key); bpm = do_CreateInstance(contractID.get()); if (!bpm) return NS_ERROR_FAILURE; @@ -123,8 +123,8 @@ nsProfileMigrator::Migrate(nsIProfileStartup* aStartup) // By opening the Migration FE with a supplied bpm, it will automatically // migrate from it. nsCOMPtr<nsIWindowWatcher> ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); - nsCOMPtr<nsISupportsArray> params; - NS_NewISupportsArray(getter_AddRefs(params)); + nsCOMPtr<nsISupportsArray> params = + do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); if (!ww || !params) return NS_ERROR_FAILURE; params->AppendElement(cstr); @@ -187,20 +187,18 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsACString& aKey, if (NS_FAILED(regKey->ReadStringValue(EmptyString(), value))) return NS_ERROR_FAILURE; - nsAString::const_iterator start, end; - value.BeginReading(start); - value.EndReading(end); - nsAString::const_iterator tmp = start; - - if (!FindInReadable(NS_LITERAL_STRING(".exe"), tmp, end, - nsCaseInsensitiveStringComparator())) + PRInt32 len = value.Find(NS_LITERAL_STRING(".exe"), CaseInsensitiveCompare); + if (len == -1) return NS_ERROR_FAILURE; + PRUint32 start = 0; // skip an opening quotation mark if present - if (value.CharAt(1) != ':') - ++start; + if (value.get()[1] != ':') { + start = 1; + --len; + } - nsDependentSubstring filePath(start, end); + const nsDependentSubstring filePath(Substring(value, start, len)); // We want to find out what the default browser is but the path in and of itself // isn't enough. Why? Because sometimes on Windows paths get truncated like so: diff --git a/browser/components/migration/src/nsSafariProfileMigrator.cpp b/browser/components/migration/src/nsSafariProfileMigrator.cpp index 0aa5187ae4f41..90077a7d68cf5 100644 --- a/browser/components/migration/src/nsSafariProfileMigrator.cpp +++ b/browser/components/migration/src/nsSafariProfileMigrator.cpp @@ -38,8 +38,8 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsBrowserProfileMigratorUtils.h" -#include "nsCRT.h" #include "nsDirectoryServiceDefs.h" +#include "nsDirectoryServiceUtils.h" #include "nsDocShellCID.h" #ifdef MOZ_PLACES #include "nsINavBookmarksService.h" @@ -301,7 +301,7 @@ GetNullTerminatedString(CFStringRef aStringRef) void FreeNullTerminatedString(char* aString) { - nsCRT::free(aString); + free(aString); aString = nsnull; } @@ -476,7 +476,7 @@ nsSafariProfileMigrator::SetDefaultEncoding(void* aTransform, nsIPrefBranch* aBr for (PRUint16 i = 0; (charsetIndex == -1) && i < (sizeof(gCharsets) / sizeof(gCharsets[0])); ++i) { if (gCharsets[i].webkitLabelLength == encodingLength && - !nsCRT::strcmp(gCharsets[i].webkitLabel, encodingStr)) + !strcmp(gCharsets[i].webkitLabel, encodingStr)) charsetIndex = (PRInt16)i; } if (charsetIndex == -1) // Default to "Western" @@ -654,7 +654,7 @@ nsSafariProfileMigrator::SetDisplayImages(void* aTransform, nsIPrefBranch* aBran nsresult nsSafariProfileMigrator::SetFontName(void* aTransform, nsIPrefBranch* aBranch) { - nsXPIDLCString associatedLangGroup; + nsCString associatedLangGroup; nsresult rv = aBranch->GetCharPref("migration.associatedLangGroup", getter_Copies(associatedLangGroup)); if (NS_FAILED(rv)) @@ -670,7 +670,7 @@ nsSafariProfileMigrator::SetFontName(void* aTransform, nsIPrefBranch* aBranch) nsresult nsSafariProfileMigrator::SetFontSize(void* aTransform, nsIPrefBranch* aBranch) { - nsXPIDLCString associatedLangGroup; + nsCString associatedLangGroup; nsresult rv = aBranch->GetCharPref("migration.associatedLangGroup", getter_Copies(associatedLangGroup)); if (NS_FAILED(rv)) @@ -916,12 +916,12 @@ nsSafariProfileMigrator::CopyBookmarks(PRBool aReplace) nsCOMPtr<nsIStringBundle> bundle; bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle)); - nsXPIDLString sourceNameSafari; + nsString sourceNameSafari; bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameSafari").get(), getter_Copies(sourceNameSafari)); const PRUnichar* sourceNameStrings[] = { sourceNameSafari.get() }; - nsXPIDLString importedSafariBookmarksTitle; + nsString importedSafariBookmarksTitle; bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), sourceNameStrings, 1, getter_Copies(importedSafariBookmarksTitle)); @@ -1144,7 +1144,9 @@ nsSafariProfileMigrator::ProfileHasContentStyleSheet(PRBool *outExists) rv = userChromeDir->GetNativePath(userChromeDirPath); NS_ENSURE_SUCCESS(rv, rv); - nsCAutoString path = userChromeDirPath + NS_LITERAL_CSTRING("/userContent.css"); + nsCAutoString path(userChromeDirPath); + path.Append("/userContent.css"); + nsCOMPtr<nsILocalFile> file; rv = NS_NewNativeLocalFile(path, PR_FALSE, getter_AddRefs(file)); diff --git a/browser/components/migration/src/nsSafariProfileMigrator.h b/browser/components/migration/src/nsSafariProfileMigrator.h index 581d98c54e805..34775f7d6aa1c 100644 --- a/browser/components/migration/src/nsSafariProfileMigrator.h +++ b/browser/components/migration/src/nsSafariProfileMigrator.h @@ -42,7 +42,7 @@ #include "nsIBrowserProfileMigrator.h" #include "nsIObserverService.h" #include "nsISupportsArray.h" -#include "nsString.h" +#include "nsStringAPI.h" #include <CoreFoundation/CoreFoundation.h> diff --git a/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp b/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp index b34c14b3cd532..3b193fa46c7da 100644 --- a/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp +++ b/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp @@ -36,7 +36,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsBrowserProfileMigratorUtils.h" -#include "nsCRT.h" #include "nsDirectoryServiceDefs.h" #include "nsICookieManager2.h" #include "nsIObserverService.h" @@ -161,11 +160,11 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile, aReplace, mSourceProfile, aResult); // Now locate passwords - nsXPIDLCString signonsFileName; + nsCString signonsFileName; GetSignonFileName(aReplace, getter_Copies(signonsFileName)); if (!signonsFileName.IsEmpty()) { - nsAutoString fileName; fileName.AssignWithConversion(signonsFileName); + NS_ConvertASCIItoUTF16 fileName(signonsFileName); nsCOMPtr<nsIFile> sourcePasswordsFile; mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile)); sourcePasswordsFile->Append(fileName); @@ -217,11 +216,9 @@ NS_IMETHODIMP nsSeamonkeyProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) { if (!mProfileNames && !mProfileLocations) { - nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfileNames)); - if (NS_FAILED(rv)) return rv; - - rv = NS_NewISupportsArray(getter_AddRefs(mProfileLocations)); - if (NS_FAILED(rv)) return rv; + mProfileNames = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); + mProfileLocations = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); + NS_ENSURE_TRUE(mProfileNames && mProfileLocations, NS_ERROR_UNEXPECTED); // Fills mProfileNames and mProfileLocations FillProfileDataFromSeamonkeyRegistry(); @@ -255,7 +252,7 @@ nsSeamonkeyProfileMigrator::GetSourceHomePageURL(nsACString& aResult) NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(prefValue)); if (NS_SUCCEEDED(rv) && prefValue) { - nsXPIDLString data; + nsString data; prefValue->ToString(getter_Copies(data)); nsCAutoString val; @@ -280,11 +277,14 @@ nsSeamonkeyProfileMigrator::GetSourceProfile(const PRUnichar* aProfile) PRUint32 count; mProfileNames->Count(&count); for (PRUint32 i = 0; i < count; ++i) { - nsCOMPtr<nsISupportsString> str(do_QueryElementAt(mProfileNames, i)); - nsXPIDLString profileName; + nsCOMPtr<nsISupportsString> str; + mProfileNames->QueryElementAt(i, NS_GET_IID(nsISupportsString), + getter_AddRefs(str)); + nsString profileName; str->GetData(profileName); if (profileName.Equals(aProfile)) { - mSourceProfile = do_QueryElementAt(mProfileLocations, i); + mProfileLocations->QueryElementAt(i, NS_GET_IID(nsILocalFile), + getter_AddRefs(mSourceProfile)); break; } } @@ -570,7 +570,7 @@ nsSeamonkeyProfileMigrator::WriteFontsBranch(nsIPrefService* aPrefService, switch (pref->type) { case nsIPrefBranch::PREF_STRING: rv = branch->SetCharPref(pref->prefName, pref->stringValue); - nsCRT::free(pref->stringValue); + NS_Free(pref->stringValue); pref->stringValue = nsnull; break; case nsIPrefBranch::PREF_BOOL: @@ -585,11 +585,11 @@ nsSeamonkeyProfileMigrator::WriteFontsBranch(nsIPrefService* aPrefService, rv = branch->SetComplexValue(pref->prefName, NS_GET_IID(nsIPrefLocalizedString), pls); - nsCRT::free(pref->wstringValue); + NS_Free(pref->wstringValue); pref->wstringValue = nsnull; break; } - nsCRT::free(pref->prefName); + NS_Free(pref->prefName); pref->prefName = nsnull; delete pref; pref = nsnull; @@ -673,13 +673,13 @@ nsSeamonkeyProfileMigrator::CopyPasswords(PRBool aReplace) { nsresult rv; - nsXPIDLCString signonsFileName; + nsCString signonsFileName; GetSignonFileName(aReplace, getter_Copies(signonsFileName)); if (signonsFileName.IsEmpty()) return NS_ERROR_FILE_NOT_FOUND; - nsAutoString fileName; fileName.AssignWithConversion(signonsFileName); + NS_ConvertASCIItoUTF16 fileName(signonsFileName); if (aReplace) rv = CopyFile(fileName, fileName); else { diff --git a/browser/components/migration/src/nsSeamonkeyProfileMigrator.h b/browser/components/migration/src/nsSeamonkeyProfileMigrator.h index b48462da535b6..d3ba01dd986b5 100644 --- a/browser/components/migration/src/nsSeamonkeyProfileMigrator.h +++ b/browser/components/migration/src/nsSeamonkeyProfileMigrator.h @@ -43,7 +43,7 @@ #include "nsIObserverService.h" #include "nsISupportsArray.h" #include "nsNetscapeProfileMigratorBase.h" -#include "nsString.h" +#include "nsStringAPI.h" class nsIFile; class nsIPrefBranch; diff --git a/browser/components/safebrowsing/src/Makefile.in b/browser/components/safebrowsing/src/Makefile.in index d16e3f8db9572..17b724b9da159 100644 --- a/browser/components/safebrowsing/src/Makefile.in +++ b/browser/components/safebrowsing/src/Makefile.in @@ -43,7 +43,6 @@ include $(DEPTH)/config/autoconf.mk MODULE = safebrowsing LIBRARY_NAME = safebrowsing_s -MOZILLA_INTERNAL_API = 1 FORCE_STATIC_LIB = 1 REQUIRES = \ diff --git a/browser/components/safebrowsing/src/nsDocNavStartProgressListener.cpp b/browser/components/safebrowsing/src/nsDocNavStartProgressListener.cpp index 03142b0cbb265..afe91d461e1f4 100644 --- a/browser/components/safebrowsing/src/nsDocNavStartProgressListener.cpp +++ b/browser/components/safebrowsing/src/nsDocNavStartProgressListener.cpp @@ -42,8 +42,9 @@ #include "nsITimer.h" #include "nsIURI.h" #include "nsIWebProgress.h" +#include "nsComponentManagerUtils.h" #include "nsServiceManagerUtils.h" -#include "nsString.h" +#include "nsStringAPI.h" NS_IMPL_ISUPPORTS4(nsDocNavStartProgressListener, nsIDocNavStartProgressListener, @@ -328,7 +329,7 @@ nsDocNavStartProgressListener::Observe(nsISupports *subject, const char *topic, // We don't care about URL fragments so we take that off. PRInt32 pos = uriString.FindChar('#'); if (pos > -1) { - uriString.Truncate(pos); + uriString.SetLength(pos); } mCallback->OnDocNavStart(request, uriString); diff --git a/browser/components/shell/src/Makefile.in b/browser/components/shell/src/Makefile.in index 284d85be25686..acc7ddf57751a 100644 --- a/browser/components/shell/src/Makefile.in +++ b/browser/components/shell/src/Makefile.in @@ -43,7 +43,6 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk MODULE = shellservice -MOZILLA_INTERNAL_API = 1 REQUIRES = \ xpcom \ diff --git a/browser/components/shell/src/nsGNOMEShellService.cpp b/browser/components/shell/src/nsGNOMEShellService.cpp index cdce43fad6ec8..22b1c880e841d 100644 --- a/browser/components/shell/src/nsGNOMEShellService.cpp +++ b/browser/components/shell/src/nsGNOMEShellService.cpp @@ -43,7 +43,7 @@ #include "nsDirectoryServiceDefs.h" #include "nsIPrefService.h" #include "prenv.h" -#include "nsString.h" +#include "nsStringAPI.h" #include "nsIGConfService.h" #include "nsIGnomeVFSService.h" #include "nsIStringBundle.h" @@ -56,10 +56,10 @@ #include "imgIRequest.h" #include "imgIContainer.h" #include "nsIImage.h" +#include "prprf.h" #ifdef MOZ_WIDGET_GTK2 #include "nsIImageToPixbuf.h" #endif -#include "nsColor.h" #include <glib.h> #include <glib-object.h> @@ -217,12 +217,13 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes, nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); nsCAutoString schemeList; - nsCAutoString appKeyValue(mAppPath + NS_LITERAL_CSTRING(" \"%s\"")); + nsCAutoString appKeyValue(mAppPath); + appKeyValue.Append(" \"%s\""); unsigned int i; for (i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) { - schemeList.Append(nsDependentCString(appProtocols[i].name) - + NS_LITERAL_CSTRING(",")); + schemeList.Append(nsDependentCString(appProtocols[i].name)); + schemeList.Append(','); if (appProtocols[i].essential || aClaimAllTypes) { gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name), @@ -242,7 +243,7 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes, bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle)); NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE); - nsXPIDLString brandShortName, brandFullName; + nsString brandShortName, brandFullName; brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), getter_Copies(brandShortName)); brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(), @@ -279,7 +280,7 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes, if (lastSlash == -1) { NS_ERROR("no slash in executable path?"); } else { - iconFilePath.Truncate(lastSlash); + iconFilePath.SetLength(lastSlash); nsCOMPtr<nsILocalFile> iconFile; NS_NewNativeLocalFile(iconFilePath, PR_FALSE, getter_AddRefs(iconFile)); if (iconFile) { @@ -400,7 +401,7 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement, nsCAutoString filePath(PR_GetEnv("HOME")); // get the product brand name from localized strings - nsXPIDLString brandName; + nsString brandName; nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID; nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(bundleCID)); if (bundleService) { @@ -415,10 +416,10 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement, } // build the file name - filePath.Append(NS_LITERAL_CSTRING("/") + - NS_ConvertUTF16toUTF8(brandName) + - NS_LITERAL_CSTRING("_wallpaper.png")); - + filePath.Append('/'); + filePath.Append(NS_ConvertUTF16toUTF8(brandName)); + filePath.Append("_wallpaper.png"); + // write the image to a file in the home dir rv = WriteImage(filePath, gfxFrame); @@ -447,6 +448,59 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement, return rv; } +// In: pointer to two characters CC +// Out: parsed color number +static PRUint8 +HexToNum(char ch) +{ + if ('0' <= ch && '9' >= ch) + return ch - '0'; + + if ('A' <= ch && 'F' >= ch) + return ch - 'A'; + + if ('a' <= ch && 'f' >= ch) + return ch - 'a'; + + return 0; +} + + +// In: 3 or 6-character RRGGBB hex string +// Out: component colors +static PRBool +HexToRGB(const nsCString& aColorSpec, + PRUint8 &aRed, + PRUint8 &aGreen, + PRUint8 &aBlue) +{ + const char *buf = aColorSpec.get(); + + if (aColorSpec.Length() == 6) { + aRed = HexToNum(buf[0]) >> 4 | + HexToNum(buf[1]); + aGreen = HexToNum(buf[2]) >> 4 | + HexToNum(buf[3]); + aBlue = HexToNum(buf[4]) >> 4 | + HexToNum(buf[5]); + return PR_TRUE; + } + + if (aColorSpec.Length() == 3) { + aRed = HexToNum(buf[0]); + aGreen = HexToNum(buf[1]); + aBlue = HexToNum(buf[2]); + + aRed |= aRed >> 4; + aGreen |= aGreen >> 4; + aBlue |= aBlue >> 4; + + return PR_TRUE; + } + + return PR_FALSE; +} + NS_IMETHODIMP nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor) { @@ -463,26 +517,36 @@ nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor) // Chop off the leading '#' character background.Cut(0, 1); - nscolor rgb; - if (!NS_ASCIIHexToRGB(background, &rgb)) - return NS_ERROR_FAILURE; + PRUint8 red, green, blue; + if (!HexToRGB(background, red, green, blue)) + return NS_ERROR_FAILURE; // The result must be in RGB order with the high 8 bits zero. - *aColor = (NS_GET_R(rgb) << 16 | NS_GET_G(rgb) << 8 | NS_GET_B(rgb)); + *aColor = (red << 16 | green << 8 | blue); return NS_OK; } +static void +ColorToHex(PRUint32 aColor, nsCString& aResult) +{ + char *buf = aResult.BeginWriting(7); + if (!buf) + return; + + PRUint8 red = (aColor >> 16); + PRUint8 green = (aColor >> 8) & 0xff; + PRUint8 blue = aColor & 0xff; + + PR_snprintf(buf, 8, "#%02x%02x%02x", red, green, blue); +} + NS_IMETHODIMP nsGNOMEShellService::SetDesktopBackgroundColor(PRUint32 aColor) { nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); - unsigned char red = (aColor >> 16); - unsigned char green = (aColor >> 8) & 0xff; - unsigned char blue = aColor & 0xff; - - nsCAutoString colorString; - NS_RGBToASCIIHex(NS_RGB(red, green, blue), colorString); + nsCString colorString; + ColorToHex(aColor, colorString); gconf->SetString(NS_LITERAL_CSTRING(kDesktopColorKey), colorString); @@ -556,7 +620,7 @@ nsGNOMEShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const ns if (NS_FAILED(rv)) return rv; - const nsPromiseFlatCString& spec = PromiseFlatCString(aURI); + const nsCString spec(aURI); const char* specStr = spec.get(); PRUint32 pid; return process->Run(PR_FALSE, &specStr, 1, &pid); diff --git a/browser/components/shell/src/nsGNOMEShellService.h b/browser/components/shell/src/nsGNOMEShellService.h index 7b98433c80f89..1fdbd0152b596 100644 --- a/browser/components/shell/src/nsGNOMEShellService.h +++ b/browser/components/shell/src/nsGNOMEShellService.h @@ -38,7 +38,7 @@ #define nsgnomeshellservice_h____ #include "nsIShellService.h" -#include "nsString.h" +#include "nsStringAPI.h" class nsGNOMEShellService : public nsIShellService { diff --git a/browser/components/shell/src/nsMacShellService.cpp b/browser/components/shell/src/nsMacShellService.cpp index 817c0d736bb53..7d95c2a56c2dc 100644 --- a/browser/components/shell/src/nsMacShellService.cpp +++ b/browser/components/shell/src/nsMacShellService.cpp @@ -21,6 +21,7 @@ * Contributor(s): * Ben Goodger <ben@mozilla.org> (Original Author) * Asaf Romano <mozilla.mano@sent.com> + * Benjamin Smedberg <benjamin@smedbergs.us> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -52,7 +53,7 @@ #include "nsMacShellService.h" #include "nsNetUtil.h" #include "nsShellService.h" -#include "nsString.h" +#include "nsStringAPI.h" #include <CoreFoundation/CoreFoundation.h> #include <Carbon/Carbon.h> @@ -468,7 +469,7 @@ nsMacShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const nsAC if (NS_FAILED(rv)) return rv; - const nsPromiseFlatCString& spec = PromiseFlatCString(aURI); + const nsCString spec(aURI); const UInt8* uriString = (const UInt8*)spec.get(); CFURLRef uri = ::CFURLCreateWithBytes(NULL, uriString, aURI.Length(), kCFStringEncodingUTF8, NULL); diff --git a/browser/components/shell/src/nsMacShellService.h b/browser/components/shell/src/nsMacShellService.h index 3d0a9d3d029cd..52ca55c1c3087 100644 --- a/browser/components/shell/src/nsMacShellService.h +++ b/browser/components/shell/src/nsMacShellService.h @@ -41,6 +41,7 @@ #include "nsIMacShellService.h" #include "nsIWebProgressListener.h" #include "nsILocalFile.h" +#include "nsCOMPtr.h" class nsMacShellService : public nsIMacShellService, public nsIWebProgressListener diff --git a/browser/components/shell/src/nsWindowsShellService.cpp b/browser/components/shell/src/nsWindowsShellService.cpp index 0841362fd2f95..bed3c0c48e99c 100644 --- a/browser/components/shell/src/nsWindowsShellService.cpp +++ b/browser/components/shell/src/nsWindowsShellService.cpp @@ -41,7 +41,6 @@ #include "gfxIImageFrame.h" #include "imgIContainer.h" #include "imgIRequest.h" -#include "nsCRT.h" #include "nsIDOMDocument.h" #include "nsIDOMElement.h" #include "nsIDOMHTMLImageElement.h" @@ -57,7 +56,6 @@ #include "nsIProcess.h" #include "nsICategoryManager.h" #include "nsBrowserCompsCID.h" -#include "nsNativeCharsetUtils.h" #include "nsDirectoryServiceUtils.h" #include "nsAppDirectoryServiceDefs.h" @@ -452,12 +450,13 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs NS_ENSURE_SUCCESS(rv, rv); // Create the Start Menu item if it doesn't exist - nsXPIDLString brandFullName; + nsString brandFullName; brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(), getter_Copies(brandFullName)); nsCAutoString nativeFullName; // For the now, we use 'A' APIs (see bug 240272, 239279) - NS_CopyUnicodeToNative(brandFullName, nativeFullName); + NS_UTF16ToCString(brandFullName, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, + nativeFullName); nsCAutoString key1(NS_LITERAL_CSTRING(SMI)); key1.Append(exeName); @@ -466,35 +465,39 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs backupKey, aClaimAllTypes, aForAllUsers); // Set the Options and Safe Mode start menu context menu item labels - nsCAutoString optionsKey(NS_LITERAL_CSTRING(SMI "%APPEXE%\\shell\\properties")); - optionsKey.ReplaceSubstring("%APPEXE%", exeName.get()); + nsCAutoString optionsKey(SMI); + optionsKey.Append(exeName); + optionsKey.Append("\\shell\\properties"); - nsCAutoString safeModeKey(NS_LITERAL_CSTRING(SMI "%APPEXE%\\shell\\safemode")); - safeModeKey.ReplaceSubstring("%APPEXE%", exeName.get()); + nsCAutoString safeModeKey(SMI); + safeModeKey.Append(exeName); + safeModeKey.Append("\\shell\\safemode"); - nsXPIDLString brandShortName; + nsString brandShortName; brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), getter_Copies(brandShortName)); const PRUnichar* brandNameStrings[] = { brandShortName.get() }; // Set the Options menu item - nsXPIDLString optionsTitle; + nsString optionsTitle; bundle->FormatStringFromName(NS_LITERAL_STRING("optionsLabel").get(), brandNameStrings, 1, getter_Copies(optionsTitle)); // Set the Safe Mode menu item - nsXPIDLString safeModeTitle; + nsString safeModeTitle; bundle->FormatStringFromName(NS_LITERAL_STRING("safeModeLabel").get(), brandNameStrings, 1, getter_Copies(safeModeTitle)); // Set the registry keys nsCAutoString nativeTitle; // For the now, we use 'A' APIs (see bug 240272, 239279) - NS_CopyUnicodeToNative(optionsTitle, nativeTitle); + NS_UTF16ToCString(optionsTitle, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, + nativeTitle); SetRegKey(optionsKey.get(), "", nativeTitle.get(), PR_TRUE, backupKey, aClaimAllTypes, aForAllUsers); // For the now, we use 'A' APIs (see bug 240272, 239279) - NS_CopyUnicodeToNative(safeModeTitle, nativeTitle); + NS_UTF16ToCString(safeModeTitle, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, + nativeTitle); SetRegKey(safeModeKey.get(), "", nativeTitle.get(), PR_TRUE, backupKey, aClaimAllTypes, aForAllUsers); @@ -571,7 +574,7 @@ nsWindowsShellService::DeleteRegKey(HKEY baseKey, const char *keyName) // Continue till we get an error or are done. while (rc == ERROR_SUCCESS) { - char subkeyName[_MAX_PATH]; + char subkeyName[MAX_PATH]; DWORD len = sizeof subkeyName; // Get first subkey name. Note that we always get the // first one, then delete it. So we need to get @@ -791,7 +794,7 @@ nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement, NS_ENSURE_SUCCESS(rv, rv); // e.g. "Desktop Background.bmp" - nsXPIDLString fileLeafName; + nsString fileLeafName; rv = shellBundle->GetStringFromName (NS_LITERAL_STRING("desktopBackgroundLeafNameWin").get(), getter_Copies(fileLeafName)); @@ -1057,7 +1060,7 @@ nsWindowsShellService::GetMailAccountKey(HKEY* aResult) NS_IMETHODIMP nsWindowsShellService::Observe(nsISupports* aObject, const char* aTopic, const PRUnichar* aMessage) { - if (!nsCRT::strcmp("app-startup", aTopic)) { + if (!strcmp("app-startup", aTopic)) { PRBool isDefault; IsDefaultBrowser(PR_FALSE, &isDefault); if (!isDefault) @@ -1065,7 +1068,7 @@ nsWindowsShellService::Observe(nsISupports* aObject, const char* aTopic, const P return RegisterDDESupport(); } - else if (!nsCRT::strcmp("quit-application", aTopic)) { + else if (!strcmp("quit-application", aTopic)) { PRBool isDefault; IsDefaultBrowser(PR_FALSE, &isDefault); if (!isDefault) @@ -1093,7 +1096,7 @@ nsWindowsShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const if (NS_FAILED(rv)) return rv; - const nsPromiseFlatCString& spec = PromiseFlatCString(aURI); + const nsCString spec(aURI); const char* specStr = spec.get(); PRUint32 pid; return process->Run(PR_FALSE, &specStr, 1, &pid); diff --git a/browser/installer/unix/packages-static b/browser/installer/unix/packages-static index 0ee104b3427f0..2d182d226a09b 100644 --- a/browser/installer/unix/packages-static +++ b/browser/installer/unix/packages-static @@ -33,11 +33,9 @@ bin/libmozjs.so bin/libplc4.so bin/libplds4.so bin/libxpcom.so -bin/libxpcom_core.so +bin/libxul.so bin/libxpistub.so bin/libnspr4.so -bin/components/libxpinstall.so -bin/components/libjar50.so [browser] ; [Base Browser Files] @@ -50,6 +48,8 @@ bin/res/cmessage.txt bin/xpicleanup ; [Components] +bin/components/libappmeta.so +bin/components/libimgicon.so bin/components/accessibility.xpt bin/components/appshell.xpt bin/components/appstartup.xpt @@ -107,7 +107,6 @@ bin/components/imglib2.xpt bin/components/intl.xpt bin/components/jar.xpt bin/components/jsconsole.xpt -bin/components/libjsd.so bin/components/jsdservice.xpt bin/components/layout_base.xpt bin/components/layout_printing.xpt diff --git a/browser/installer/windows/packages-static b/browser/installer/windows/packages-static index 180c1a0cdc04a..c4ceccb57ff02 100644 --- a/browser/installer/windows/packages-static +++ b/browser/installer/windows/packages-static @@ -32,11 +32,9 @@ bin\js3250.dll bin\plc4.dll bin\plds4.dll bin\xpcom.dll -bin\xpcom_core.dll +bin\xul.dll bin\xpistub.dll bin\nspr4.dll -bin\components\xpinstal.dll -bin\components\jar50.dll bin\Microsoft.VC80.CRT.manifest bin\msvcm80.dll bin\msvcp80.dll @@ -52,6 +50,7 @@ bin\LICENSE bin\README.txt ; [Components] +bin\appmeta.dll bin\components\alerts.xpt bin\AccessibleMarshal.dll bin\components\accessibility.xpt diff --git a/client.mk b/client.mk index 2cd12ebfa1503..a6ba60c6993c8 100644 --- a/client.mk +++ b/client.mk @@ -157,6 +157,7 @@ MODULES_core := \ mozilla/modules/oji \ mozilla/modules/plugin \ mozilla/modules/zlib \ + mozilla/modules/staticmod \ mozilla/netwerk \ mozilla/plugin/oji \ mozilla/profile \ diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index aff0eed3bd704..81877dc6e105a 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -116,6 +116,7 @@ MOZ_PLAINTEXT_EDITOR_ONLY = @MOZ_PLAINTEXT_EDITOR_ONLY@ MOZ_COMPOSER = @MOZ_COMPOSER@ BUILD_STATIC_LIBS = @BUILD_STATIC_LIBS@ MOZ_ENABLE_LIBXUL = @MOZ_ENABLE_LIBXUL@ +MOZ_META_COMPONENT = @MOZ_META_COMPONENT@ ENABLE_TESTS = @ENABLE_TESTS@ IBMBIDI = @IBMBIDI@ MOZ_UNIVERSALCHARDET = @MOZ_UNIVERSALCHARDET@ diff --git a/config/config.mk b/config/config.mk index 9cea5728c24b6..6f460f557f130 100644 --- a/config/config.mk +++ b/config/config.mk @@ -290,11 +290,18 @@ ifneq (,$(FORCE_SHARED_LIB)$(FORCE_USE_PIC)) _ENABLE_PIC=1 endif +# In Firefox, all components are linked into either libxul or the static +# meta-component, and should be compiled with PIC. +ifdef MOZ_META_COMPONENT +_ENABLE_PIC=1 +endif + # If module is going to be merged into the nsStaticModule, # make sure that the entry points are translated and # the module is built static. ifdef IS_COMPONENT +ifdef EXPORT_LIBRARY ifneq (,$(BUILD_STATIC_LIBS)) ifdef MODULE_NAME DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1 @@ -302,6 +309,7 @@ FORCE_STATIC_LIB=1 endif endif endif +endif # Determine if module being compiled is destined # to be merged into libxul diff --git a/configure.in b/configure.in index 9903be613ad70..66a34904130f8 100644 --- a/configure.in +++ b/configure.in @@ -3996,6 +3996,7 @@ MOZ_ARG_HEADER(Application) BUILD_MODULES=all BUILD_STATIC_LIBS= +MOZ_META_COMPONENT= ENABLE_TESTS=1 MOZ_ACTIVEX_SCRIPTING_SUPPORT= MOZ_BRANDING_DIRECTORY= @@ -4270,6 +4271,7 @@ browser) MOZ_APP_VERSION=$FIREFOX_VERSION MOZ_NO_XPCOM_OBSOLETE=1 MOZ_EXTENSIONS_DEFAULT=" xml-rpc inspector gnomevfs reporter" + MOZ_ENABLE_LIBXUL=1 AC_DEFINE(MOZ_PHOENIX) ;; @@ -6750,10 +6752,6 @@ MOZ_ARG_ENABLE_BOOL(libxul, MOZ_ENABLE_LIBXUL=1, MOZ_ENABLE_LIBXUL=) -if test -n "$MOZ_ENABLE_LIBXUL" -a -n "$BUILD_STATIC_LIBS"; then - AC_MSG_ERROR([--enable-libxul is not compatible with --enable-static]) -fi - if test -n "$MOZ_ENABLE_LIBXUL" -a -z "$MOZ_XUL_APP"; then AC_MSG_ERROR([--enable-libxul is only compatible with toolkit XUL applications.]) fi @@ -6765,6 +6763,13 @@ else XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS" fi +# A Firefox static build is really a meta-component build, not truly static +if test "$MOZ_BUILD_APP" = "browser" -a -n "$BUILD_STATIC_LIBS"; then + MOZ_META_COMPONENT=1 +fi + +AC_SUBST(MOZ_META_COMPONENT) + dnl ======================================================== dnl = Force JS to be a static lib dnl ======================================================== diff --git a/intl/unicharutil/util/Makefile.in b/intl/unicharutil/util/Makefile.in index becce2219d7e5..254169cc916dd 100644 --- a/intl/unicharutil/util/Makefile.in +++ b/intl/unicharutil/util/Makefile.in @@ -54,6 +54,10 @@ MODULE=unicharutil LIBRARY_NAME=unicharutil_external_s DIST_INSTALL = 1 +ifdef MOZ_META_COMPONENT +EXPORT_LIBRARY = 1 +endif + REQUIRES=xpcom \ string \ uconv \ diff --git a/intl/unicharutil/util/internal/Makefile.in b/intl/unicharutil/util/internal/Makefile.in index 485f4f6ad6988..78702e36325bd 100755 --- a/intl/unicharutil/util/internal/Makefile.in +++ b/intl/unicharutil/util/internal/Makefile.in @@ -51,9 +51,12 @@ include $(DEPTH)/config/autoconf.mk MODULE=unicharutil LIBRARY_NAME=unicharutil_s DIST_INSTALL = 1 -EXPORT_LIBRARY = 1 MOZILLA_INTERNAL_API = 1 +ifndef MOZ_META_COMPONENT +EXPORT_LIBRARY = 1 +endif + include $(srcdir)/../objs.mk EXTRA_DEPS += $(srcdir)/../objs.mk diff --git a/modules/staticmod/Makefile.in b/modules/staticmod/Makefile.in index 2e7f0e875366c..61064f8d539b0 100644 --- a/modules/staticmod/Makefile.in +++ b/modules/staticmod/Makefile.in @@ -35,6 +35,9 @@ # # ***** END LICENSE BLOCK ***** +# This makefile links all the static components which have EXPORT_LIBRARY +# set into a single component DLL. + DEPTH = ../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ @@ -42,131 +45,32 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -ifdef MOZ_STATIC_COMPONENTS -MODULE = staticmod -LIBRARY_NAME = staticmod -SHORT_LIBNAME = statcmod -endif - +LIBRARY_NAME = appmeta IS_COMPONENT = 1 +FORCE_SHARED_LIB = 1 -include $(topsrcdir)/config/config.mk +CPPSRCS = nsMetaModule.cpp -REQUIRES = xpcom \ - $(NULL) +REQUIRES = xpcom -ifdef MOZ_STATIC_COMPONENTS -CPPSRCS = nsStaticModule.cpp -endif +include $(topsrcdir)/config/config.mk -LOCAL_INCLUDES = -I$(srcdir) +FINAL_COMPONENT_LIBS := $(shell cat $(FINAL_LINK_COMPS)) +FINAL_LINK_LIBS := $(shell cat $(FINAL_LINK_LIBS)) -# -# _COMPONENT_BASE is the base name of the meta component library -# that we are building in the current pass of this makefile -# -# mozcomps is a special name used to specify that we want to link all -# of the non-meta components into this special meta component -# -ifdef _COMPONENT_BASE -ifeq ($(_COMPONENT_BASE),mozcomps) -_FINAL_COMPONENT_NAMES := $(shell cat $(FINAL_LINK_COMP_NAMES)) -_FINAL_COMPONENT_LIBS := $(shell cat $(FINAL_LINK_COMPS)) -_FINAL_LINK_LIBS := $(shell cat $(FINAL_LINK_LIBS)) -_META_COMPONENT_NAMES := _FINAL_COMPONENT_NAMES -_META_COMPONENT_LIBS := _FINAL_COMPONENT_LIBS -_META_DEP_LIBS := _FINAL_LINK_LIBS -else -_META_COMPONENT_NAMES := MOZ_META_COMPONENTS_$(_COMPONENT_BASE) -_META_COMPONENT_LIBS := MOZ_META_COMPONENTS_$(_COMPONENT_BASE)_comps -_META_DEP_LIBS := MOZ_META_COMPONENTS_$(_COMPONENT_BASE)_libs -endif # mozcomps -endif # _COMPONENT_BASE - -ifdef MOZ_STATIC_COMPONENTS SHARED_LIBRARY_LIBS = \ - $(foreach m, $(MOZ_STATIC_COMPONENTS), $(DIST)/lib/components/$(LIB_PREFIX)$(m).$(LIB_SUFFIX)) -endif - -ifdef _COMPONENT_BASE -ifneq ($(_COMPONENT_BASE),mozcomps) -SHARED_LIBRARY_LIBS = $(foreach m,$($(_META_COMPONENT_LIBS)), $(DIST)/lib/components/$(LIB_PREFIX)$(m).$(LIB_SUFFIX)) -EXTRA_DSO_LDOPTS += $(foreach m,$($(_META_DEP_LIBS)), $(DIST)/lib/$(LIB_PREFIX)$(m).$(LIB_SUFFIX)) -endif -endif - -# -# Create each meta component by calling this makefile recursively -# and forcing it to built a shared library meta component library -# -ifndef NO_RECURSE -libs clean distclean clobber realclean clobber_all:: - set -e; \ - for f in $(MOZ_META_COMPONENTS); do \ - $(MAKE) NO_RECURSE=1 BUILD_STATIC_LIBS= LIBRARY_NAME=meta_$$f CPPSRCS=nsMetaModule_$$f.cpp _COMPONENT_BASE=$$f $@ ; \ - done -endif + $(foreach c,$(FINAL_COMPONENT_LIBS),$(DIST)/lib/components/$(LIB_PREFIX)$(c).$(LIB_SUFFIX)) \ + $(foreach l,$(FINAL_LINK_LIBS),$(DIST)/lib/$(LIB_PREFIX)$(l).$(LIB_SUFFIX)) \ + $(NULL) -ifeq ($(LIBRARY_NAME),meta_mozcomps) -include $(topsrcdir)/config/static-config.mk -EXTRA_DSO_LIBS = $(STATIC_EXTRA_DSO_LIBS) -endif - -include $(topsrcdir)/config/rules.mk - -ifeq ($(LIBRARY_NAME),meta_mozcomps) -include $(topsrcdir)/config/static-rules.mk -endif - -ifdef MOZ_STATIC_COMPONENTS -EXTRA_DSO_LDOPTS += \ - $(ZLIB_LIBS) \ - $(XPCOM_LIBS) \ - $(MOZ_JS_LIBS) \ +EXTRA_DSO_LDOPTS = \ + $(XPCOM_GLUE_LDOPTS) \ $(NSPR_LIBS) \ - $(PNG_LIBS) -endif + $(NULL) -ifdef MOZ_META_COMPONENTS -# Force XPCOM_TRANSLATE_NSGM_ENTRY_POINT to be defined so the macros -# in nsIGenericFactory.h will come out in the wash. -DEFINES += -DMETA_MODULE=\"$(LIBRARY_NAME)\" -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT - -ifeq ($(LIBRARY_NAME),meta_mail) -EXTRA_DSO_LDOPTS += \ - $(LIBS_DIR) \ - $(call EXPAND_MOZLIBNAME,xpcom_compat gkgfx rdfutil_s) \ - $(MOZ_UNICHARUTIL_LIBS) \ - $(MOZ_COMPONENT_LIBS) \ - $(TK_LIBS) \ - $(NULL) -endif # meta_mail - -ifeq ($(LIBRARY_NAME),meta_crypto) -EXTRA_DSO_LDOPTS += \ - $(MOZ_JS_LIBS) \ - $(NSS_LIBS) \ - $(MOZ_UNICHARUTIL_LIBS) \ - $(MOZ_COMPONENT_LIBS) \ - $(NULL) -endif # meta_crypto - -ifeq ($(LIBRARY_NAME),meta_mozcomps) - -# We don't want to link mozcomps against NSS if not necessary -ifneq (,$(findstring crypto,$(MOZ_META_COMPONENTS))) -STATIC_EXTRA_LIBS := $(filter-out $(NSS_LIBS),$(STATIC_EXTRA_LIBS)) -endif +include $(topsrcdir)/config/rules.mk -EXTRA_DSO_LDOPTS += \ - $(LIBS_DIR) \ - $(EXTRA_DSO_LIBS) \ - $(STATIC_EXTRA_LIBS) \ - $(MOZ_JS_LIBS) \ - $(MOZ_UNICHARUTIL_LIBS) \ - $(MOZ_COMPONENT_LIBS) \ - $(TK_LIBS) \ - $(NULL) +DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) OS_LIBS += -framework QuickTime @@ -176,39 +80,32 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) OS_LIBS += -framework Cocoa endif -endif # meta_mozcomps - -endif # MOZ_META_COMPONENTS - ifeq ($(OS_ARCH),WINNT) -OS_LIBS += ole32.lib shell32.lib +OS_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool imm32) +# XXX temporary workaround until link ordering issue is solved +ifdef GNU_CC +OS_LIBS += $(call EXPAND_LIBNAME,winmm wsock32 gdi32) +endif +ifdef MOZ_ENABLE_CAIRO_GFX +OS_LIBS += $(call EXPAND_LIBNAME, usp10) +endif endif -GARBAGE += $(CPPSRCS) +ifneq (,$(MOZ_ENABLE_GTK)$(MOZ_ENABLE_GTK2)$(MOZ_ENABLE_XLIB)) +OS_LIBS += $(XLDFLAGS) $(XT_LIBS) +endif -list: - echo $(MOZ_STATIC_COMPONENTS) +OS_LIBS += $(TK_LIBS) -ifdef _NO_AUTO_VARS -_TARGET = $(srcdir)/$(@F) -GARBAGE += $(addprefix $(srcdir)/,$(CPPSRCS)) -else -_TARGET = $@ -endif +GARBAGE += module_list.h -ifdef MOZ_STATIC_COMPONENTS -nsStaticModule.cpp: nsMetaModule.cpp.in Makefile Makefile.in $(DEPTH)/config/autoconf.mk - rm -f $@ - cat $< | \ - sed -e "s|%DECLARE_SUBMODULE_INFOS%|$(foreach m, $(MOZ_STATIC_COMPONENTS), extern nsModuleInfo NSMODULEINFO($(m));)|" | \ - sed -e "s|%SUBMODULE_INFOS%|$(foreach m, $(MOZ_STATIC_COMPONENTS), \\& NSMODULEINFO($(m)),)|" \ - > $(_TARGET) -endif +LOCAL_INCLUDES += -I. + +FINAL_COMPONENT_NAMES := $(shell cat $(FINAL_LINK_COMP_NAMES)) -nsMetaModule_%.cpp: nsMetaModule.cpp.in Makefile Makefile.in $(topsrcdir)/config/config.mk - rm -f $@ - cat $< | \ - sed -e "s|%DECLARE_SUBMODULE_INFOS%|$(foreach m, $($(_META_COMPONENT_NAMES)), extern nsModuleInfo NSMODULEINFO($(m));)|" | \ - sed -e "s|%SUBMODULE_INFOS%|$(foreach m, $($(_META_COMPONENT_NAMES)), \\& NSMODULEINFO($(m)),)|" \ - > $(_TARGET) +nsMetaModule.$(OBJ_SUFFIX): module_list.h +module_list.h: Makefile Makefile.in $(DEPTH)/config/autoconf.mk + echo '#define MODULES \' > $@ + awk '{ print "MODULE(" $$1 ") \\" }' < $(FINAL_LINK_COMP_NAMES) >> $@ + echo >> $@ diff --git a/modules/staticmod/meta.mak b/modules/staticmod/meta.mak deleted file mode 100755 index 9a6da1faa5bc1..0000000000000 --- a/modules/staticmod/meta.mak +++ /dev/null @@ -1,164 +0,0 @@ -#!nmake -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH=..\.. - -REQUIRES = xpcom - -include <$(DEPTH)/config/config.mak> - -MAKE_OBJ_TYPE = DLL -DLLNAME = $(META_MODULE).dll -DLL = .\$(OBJDIR)\$(DLLNAME) - -LINK_COMP_NAMES = $(DIST)\$(META_MODULE)-link-comp-names -LINK_COMPS = $(DIST)\$(META_MODULE)-link-comps -LINK_LIBS = $(DIST)\$(META_MODULE)-link-libs -SEDCMDS = nsMetaModule_$(META_MODULE).cpp.sed - -EXTRA_LIBS_LIST_FILE = $(OBJDIR)\$(META_MODULE)-libs.txt - -GARBAGE = $(GARBAGE) $(SEDCMDS) $(LIBFILE) nsMetaModule_$(META_MODULE).cpp - -LCFLAGS = $(LCFLAGS) -DMETA_MODULE=\"$(META_MODULE)\" -CPP_OBJS = .\$(OBJDIR)\nsMetaModule_$(META_MODULE).obj - -# XXX Lame! This is currently the superset of all static libraries not -# explicitly made part of the META_MODULE. -LLIBS = $(DIST)\lib\gkgfx.lib \ - $(DIST)\lib\rdfutil_s.lib \ - $(DIST)\lib\js3250.lib \ - $(DIST)\lib\xpcom.lib \ - $(DIST)\lib\unicharutil_s.lib \ - $(LIBNSPR) - -WIN_LIBS = rpcrt4.lib \ - ole32.lib \ - shell32.lib - - -!ifdef MOZ_GECKO_DLL -LLIBS = $(LLIBS) \ - $(DIST)\lib\png.lib \ - $(DIST)\lib\mng.lib \ - $(DIST)\lib\util.lib \ - $(DIST)\lib\mozexpat.lib \ - $(DIST)\lib\nsldap32v40.lib - -WIN_LIBS = $(WIN_LIBS) \ - comctl32.lib \ - comdlg32.lib \ - uuid.lib \ - ole32.lib \ - shell32.lib \ - oleaut32.lib \ - version.lib \ - winspool.lib - -!endif - -include <$(DEPTH)/config/rules.mak> - -# -# Create the sed commands that are used translate nsMetaModule_(foo).cpp.in -# into nsMetaModule_(foo).cpp, using the component names, -# -$(SEDCMDS): $(LINK_COMP_NAMES) - echo +++make: Creating $@ - rm -f $@ - echo s/%DECLARE_SUBMODULE_INFOS%/\>> $@ - sed -e "s/\(.*\)/extern nsModuleInfo NSMODULEINFO(\1);\\\/" $(LINK_COMP_NAMES) >> $@ - echo />> $@ - echo s/%SUBMODULE_INFOS%/\>> $@ - sed -e "s/\(.*\)/\\\\\& NSMODULEINFO(\1),\\\/" $(LINK_COMP_NAMES) >> $@ - echo />> $@ - -# -# Create nsMetaModule_(foo).cpp from nsMetaModule.cpp.in -# -nsMetaModule_$(META_MODULE).cpp: nsMetaModule.cpp.in $(SEDCMDS) - echo +++make: Creating $@ - rm -f $@ - sed -f $(SEDCMDS) nsMetaModule.cpp.in > $@ - -# -# If no link components file has been created, make an empty one now. -# -$(LINK_COMPS): - echo +++ make: Creating empty link components file: $@ - touch $@ - -# -# If no link libs file has been created, make an empty one now. -# -$(LINK_LIBS): - echo +++ make: Creating empty link libraries file: $@ - touch $@ - -# -# Create a list of libraries that we'll need to link against from the -# component list and the ``export library'' list -# -$(EXTRA_LIBS_LIST_FILE): $(LINK_COMPS) $(LINK_LIBS) - echo +++ make: Creating list of link libraries: $@ - rm -f $@ - sed -e "s/\(.*\)/$(DIST:\=\\\)\\\lib\\\\\1.lib/" $(LINK_COMPS) > $@ - sed -e "s/\(.*\)/$(DIST:\=\\\)\\\lib\\\\\1.lib/" $(LINK_LIBS) >> $@ - - -# XXX this is a hack. The ``gecko'' meta-module consists -# of all the static components linked into a DLL instead -# of an executable. To make this work, we'll copy the -# statically linked libs, components, and component names -# to the right file. This relies on the fact that the -# modules/staticmod directory gets built after all the other -# directories in the tree are processed. -!if defined(MOZ_GECKO_DLL) && "$(META_MODULE)" == "gecko" -export:: - copy $(FINAL_LINK_LIBS) $(DIST)\$(META_MODULE)-link-libs - copy $(FINAL_LINK_COMPS) $(DIST)\$(META_MODULE)-link-comps - copy $(FINAL_LINK_COMP_NAMES) $(DIST)\$(META_MODULE)-link-comp-names -!endif - - -libs:: $(DLL) - $(MAKE_INSTALL) $(DLL) $(DIST)/bin/components - -clobber:: - rm -f $(DIST)/bin/components/$(DLLNAME) - diff --git a/modules/staticmod/nsMetaModule.cpp b/modules/staticmod/nsMetaModule.cpp new file mode 100644 index 0000000000000..6f2fd85c7dd18 --- /dev/null +++ b/modules/staticmod/nsMetaModule.cpp @@ -0,0 +1,167 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Christopher Seawood <cls@seawood.org> + * Doug Turner <dougt@netscape.com> + * Chris Waterson <waterson@netscape.com> + * Benjamin Smedberg <benjamin@smedbergs.us> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsIGenericFactory.h" +#include "nsXPCOM.h" +#include "nsIModule.h" +#include "nsCOMPtr.h" +#include "nsCOMArray.h" +#include "nsMemory.h" +#include "nsAutoPtr.h" + +#include "module_list.h" + +#define NSGETMODULE(_name) _name##_NSGetModule + +#define MODULE(_name) \ +NSGETMODULE_ENTRY_POINT(_name) (nsIComponentManager*, nsIFile*, nsIModule**); + +MODULES + +#undef MODULE + +#define MODULE(_name) NSGETMODULE(_name), + +static const nsGetModuleProc kGetModules[] = { + MODULES +}; + +#undef MODULE + +class MetaModule : public nsIModule +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIMODULE + + MetaModule() { } + nsresult Init(nsIComponentManager*, nsIFile*); + +private: + ~MetaModule() { } + + nsCOMArray<nsIModule> mModules; +}; + +NS_IMPL_THREADSAFE_ISUPPORTS1(MetaModule, nsIModule) + +nsresult +MetaModule::Init(nsIComponentManager* aCompMgr, nsIFile* aLocation) +{ + if (!mModules.SetCapacity(NS_ARRAY_LENGTH(kGetModules))) + return NS_ERROR_OUT_OF_MEMORY; + + // eat all errors + nsGetModuleProc const *end = kGetModules + NS_ARRAY_LENGTH(kGetModules); + + nsCOMPtr<nsIModule> module; + for (nsGetModuleProc const *cur = kGetModules; cur < end; ++cur) { + nsresult rv = (*cur)(aCompMgr, aLocation, getter_AddRefs(module)); + if (NS_SUCCEEDED(rv)) + mModules.AppendObject(module); + } + + return NS_OK; +} + +NS_IMETHODIMP +MetaModule::GetClassObject(nsIComponentManager* aCompMgr, REFNSCID aCID, + REFNSIID aIID, void **aResult) +{ + for (PRInt32 i = mModules.Count() - 1; i >= 0; --i) { + nsresult rv = mModules[i]->GetClassObject(aCompMgr, aCID, + aIID, aResult); + if (NS_SUCCEEDED(rv)) + return rv; + } + + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +MetaModule::RegisterSelf(nsIComponentManager* aCompMgr, nsIFile* aLocation, + const char *aStr, const char *aType) +{ + for (PRInt32 i = mModules.Count() - 1; i >= 0; --i) { + mModules[i]->RegisterSelf(aCompMgr, aLocation, aStr, aType); + } + return NS_OK; +} + +NS_IMETHODIMP +MetaModule::UnregisterSelf(nsIComponentManager* aCompMgr, nsIFile* aLocation, + const char *aStr) +{ + for (PRInt32 i = mModules.Count() - 1; i >= 0; --i) { + mModules[i]->UnregisterSelf(aCompMgr, aLocation, aStr); + } + return NS_OK; +} + +NS_IMETHODIMP +MetaModule::CanUnload(nsIComponentManager* aCompMgr, PRBool *aResult) +{ + for (PRInt32 i = mModules.Count() - 1; i >= 0; --i) { + nsresult rv = mModules[i]->CanUnload(aCompMgr, aResult); + if (NS_FAILED(rv)) + return rv; + + // Any submodule may veto unloading + if (!*aResult) + return NS_OK; + } + + return NS_OK; +} + +extern "C" NS_EXPORT nsresult +NSGetModule(nsIComponentManager *servMgr, + nsIFile *location, + nsIModule **result) +{ + nsRefPtr<MetaModule> mmodule = new MetaModule(); + nsresult rv = mmodule->Init(servMgr, location); + if (NS_FAILED(rv)) + return rv; + + NS_ADDREF(*result = mmodule); + return NS_OK; +} diff --git a/modules/staticmod/nsMetaModule.cpp.in b/modules/staticmod/nsMetaModule.cpp.in deleted file mode 100644 index 8e22c2b5132d4..0000000000000 --- a/modules/staticmod/nsMetaModule.cpp.in +++ /dev/null @@ -1,135 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Christopher Seawood <cls@seawood.org> - * Doug Turner <dougt@netscape.com> - * Chris Waterson <waterson@netscape.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#line 27 "nsMetaModule.cpp.in" -#include "nsError.h" -#include "nsIModule.h" -#include "nsIFile.h" -#include "nsIGenericFactory.h" -#include "prmem.h" - -%DECLARE_SUBMODULE_INFOS% -#line 35 "nsMetaModule.cpp.in" - -static nsModuleInfo* gSubModules[] = { - %SUBMODULE_INFOS% -#line 39 "nsMetaModule.cpp.in" -}; - -#define NUM_SUB_MODULES (sizeof(gSubModules) / sizeof(gSubModules[0])) - -static nsModuleComponentInfo* gComponentInfo; -static PRBool gInitialized = PR_FALSE; - -PR_STATIC_CALLBACK(nsresult) -Initialize(nsIModule *self) -{ - if (! gInitialized) { - // Run the ctor for each sub-module - gInitialized = PR_TRUE; - - nsModuleInfo** module = gSubModules; - nsModuleInfo** limit = module + NUM_SUB_MODULES; - for ( ; module < limit; ++module) { - if ((*module)->mCtor) - ((*module)->mCtor)(self); - } - } - - return NS_OK; -} - -PR_STATIC_CALLBACK(void) -Shutdown(nsIModule *self) -{ - if (gInitialized) { - // Run the dtor for each sub-module - gInitialized = PR_FALSE; - - nsModuleInfo** module = gSubModules; - nsModuleInfo** limit = module + NUM_SUB_MODULES; - for ( ; module < limit; ++module) { - if ((*module)->mDtor) - ((*module)->mDtor)(self); - } - } -} - -extern "C" NS_EXPORT nsresult -NSGetModule(nsIComponentManager *servMgr, - nsIFile *location, - nsIModule **result) -{ - // Count the number of components contained in all of the - // sub-modules - nsModuleInfo** info = gSubModules; - nsModuleInfo** limit = info + NUM_SUB_MODULES; - PRUint32 count = 0; - for ( ; info < limit; ++info) - count += (*info)->mCount; - - // Allocate an nsModuleComponentInfo array large enough to contain - // all of them. This will be permanently leaked. - gComponentInfo = new nsModuleComponentInfo[count]; - if (! gComponentInfo) - return NS_ERROR_OUT_OF_MEMORY; - - // Copy the module component info into the contiguous array - nsModuleComponentInfo *comps = gComponentInfo; - for (info = gSubModules; info < limit; ++info) { - PRUint32 n = (*info)->mCount; - ::memcpy(comps, (*info)->mComponents, sizeof(nsModuleComponentInfo) * n); - comps += n; - } - - // Dummy up an nsModuleInfo struct to register us as a generic - // module that contains all our sub-module's components. - nsModuleInfo metainfo; - memset(&metainfo, 0, sizeof(metainfo)); - metainfo.mVersion = NS_MODULEINFO_VERSION; - metainfo.mModuleName = META_MODULE " meta module"; - metainfo.mComponents = gComponentInfo; - metainfo.mCount = count; - metainfo.mCtor = Initialize; - metainfo.mDtor = Shutdown; - - return NS_NewGenericModule2(&metainfo, result); -} - diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in index fe959c385ae89..9f351f5f0ca64 100644 --- a/toolkit/xre/Makefile.in +++ b/toolkit/xre/Makefile.in @@ -111,7 +111,7 @@ CPPSRCS = \ DEFINES += -DIMPL_XREAPI -ifndef BUILD_STATIC_LIBS +ifneq (1_,$(BUILD_STATIC_LIBS)_$(MOZ_META_COMPONENT)) CPPSRCS += nsEmbedFunctions.cpp endif @@ -179,12 +179,14 @@ endif include $(topsrcdir)/config/rules.mk ifdef BUILD_STATIC_LIBS +ifndef MOZ_META_COMPONENT export:: @$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_COMP_NAMES) Apprunner # embedding/browser/gtk/src/Makefile.in sucks! we need to add an empty line to # FINAL_LINK_COMPS to keep the two lists in sync :-( @$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_COMPS) "" endif +endif LOCAL_INCLUDES += \ -I$(srcdir) \ -- GitLab