fixes bug 219400 "remove callers of nsServiceManager:: methods" r=bsmedberg

This commit is contained in:
darin%meer.net 2004-11-07 23:59:35 +00:00
Родитель 1382a3a19b
Коммит f94aa8151e
80 изменённых файлов: 383 добавлений и 3234 удалений

Просмотреть файл

@ -206,26 +206,23 @@ bm_AddRefGlobals()
if (gRefCnt++ == 0)
{
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDF);
rv = CallGetService(kRDFServiceCID, &gRDF);
if (NS_FAILED(rv)) {
NS_ERROR("unable to get RDF service");
return rv;
}
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_FAILED(rv)) return rv;
rv = CallGetService(kRDFContainerUtilsCID, &gRDFC);
if (NS_FAILED(rv)) {
NS_ERROR("unable to get RDF container utils");
return rv;
}
rv = nsServiceManager::GetService(kRDFContainerUtilsCID,
NS_GET_IID(nsIRDFContainerUtils),
(nsISupports**) &gRDFC);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF container utils");
if (NS_FAILED(rv)) return rv;
rv = nsServiceManager::GetService(kCharsetAliasCID,
NS_GET_IID(nsICharsetAlias),
(nsISupports**) &gCharsetAlias);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get charset alias service");
if (NS_FAILED(rv)) return rv;
rv = CallGetService(kCharsetAliasCID, &gCharsetAlias);
if (NS_FAILED(rv)) {
NS_ERROR("unable to get charset alias service");
return rv;
}
gRDF->GetResource(NS_LITERAL_CSTRING(kURINC_BookmarksTopRoot),
&kNC_BookmarksTopRoot);
@ -356,23 +353,9 @@ bm_ReleaseGlobals()
{
if (--gRefCnt == 0)
{
if (gRDF)
{
nsServiceManager::ReleaseService(kRDFServiceCID, gRDF);
gRDF = nsnull;
}
if (gRDFC)
{
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFC);
gRDFC = nsnull;
}
if (gCharsetAlias)
{
nsServiceManager::ReleaseService(kCharsetAliasCID, gCharsetAlias);
gCharsetAlias = nsnull;
}
NS_IF_RELEASE(gRDF);
NS_IF_RELEASE(gRDFC);
NS_IF_RELEASE(gCharsetAlias);
NS_IF_RELEASE(kNC_Bookmark);
NS_IF_RELEASE(kNC_BookmarkSeparator);
@ -1105,11 +1088,9 @@ BookmarkParser::ParseMetaTag(const nsString &aLine, nsIUnicodeDecoder **decoder)
if (charset.Length() < 1) return NS_ERROR_UNEXPECTED;
// found a charset, now try and get a decoder from it to Unicode
nsICharsetConverterManager *charsetConv = nsnull;
rv = nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager),
(nsISupports**)&charsetConv);
if (NS_SUCCEEDED(rv) && (charsetConv))
nsICharsetConverterManager *charsetConv;
rv = CallGetService(kCharsetConverterManagerCID, &charsetConv);
if (NS_SUCCEEDED(rv))
{
rv = charsetConv->GetUnicodeDecoderRaw(charset.get(), decoder);
NS_RELEASE(charsetConv);
@ -1673,17 +1654,19 @@ nsBookmarksService::Init()
if (NS_FAILED(rv)) return rv;
/* create a URL for the string resource file */
nsCOMPtr<nsIURI> uri;
if (NS_SUCCEEDED(rv = mNetService->NewURI(bookmark_properties, nsnull, nsnull,
getter_AddRefs(uri))))
nsCOMPtr<nsIURI> uri;
mNetService->NewURI(bookmark_properties, nsnull, nsnull,
getter_AddRefs(uri));
if (uri)
{
/* create a bundle for the localization */
nsCOMPtr<nsIStringBundleService> stringService;
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kStringBundleServiceCID,
NS_GET_IID(nsIStringBundleService), getter_AddRefs(stringService))))
nsCOMPtr<nsIStringBundleService> stringService =
do_GetService(kStringBundleServiceCID);
if (stringService)
{
nsCAutoString spec;
if (NS_SUCCEEDED(rv = uri->GetSpec(spec)))
uri->GetSpec(spec);
if (!uri.IsEmpty())
{
stringService->CreateBundle(spec.get(), getter_AddRefs(mBundle));
}

Просмотреть файл

@ -182,16 +182,8 @@ nsChromeRegistry::~nsChromeRegistry()
delete mDataSourceTable;
}
if (mRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
mRDFService = nsnull;
}
if (mRDFContainerUtils) {
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, mRDFContainerUtils);
mRDFContainerUtils = nsnull;
}
NS_IF_RELEASE(mRDFService);
NS_IF_RELEASE(mRDFContainerUtils);
}
NS_IMPL_THREADSAFE_ISUPPORTS5(nsChromeRegistry,
@ -251,14 +243,10 @@ nsChromeRegistry::Init()
gChromeRegistry = this;
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**)&mRDFService);
rv = CallGetService(kRDFServiceCID, &mRDFService);
NS_ENSURE_SUCCESS(rv, rv);
rv = nsServiceManager::GetService(kRDFContainerUtilsCID,
NS_GET_IID(nsIRDFContainerUtils),
(nsISupports**)&mRDFContainerUtils);
rv = CallGetService(kRDFContainerUtilsCID, &mRDFContainerUtils);
NS_ENSURE_SUCCESS(rv, rv);
rv = mRDFService->GetResource(nsDependentCString(kURICHROME_baseURL),

Просмотреть файл

@ -67,9 +67,7 @@ nsChromeUIDataSource::nsChromeUIDataSource(nsIRDFDataSource* aComposite)
mComposite->AddObserver(this);
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**)&mRDFService);
rv = CallGetService(kRDFServiceCID, &mRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
mRDFService->RegisterDataSource(this, PR_TRUE);
@ -79,10 +77,7 @@ nsChromeUIDataSource::~nsChromeUIDataSource()
{
mRDFService->UnregisterDataSource(this);
if (mRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
mRDFService = nsnull;
}
NS_IF_RELEASE(mRDFService);
}
// we require a special implementation of Release, which knows about

Просмотреть файл

@ -206,22 +206,21 @@ nsInternetCiter::Rewrap(const nsAString& aInString,
nsCOMPtr<nsILineBreaker> lineBreaker;
nsILineBreakerFactory *lf;
nsresult rv;
rv = nsServiceManager::GetService(NS_LWBRK_CONTRACTID,
NS_GET_IID(nsILineBreakerFactory),
(nsISupports **)&lf);
rv = CallGetService(NS_LWBRK_CONTRACTID, &lf);
if (NS_SUCCEEDED(rv))
{
nsAutoString lbarg;
rv = lf->GetBreaker(lbarg, getter_AddRefs(lineBreaker));
nsServiceManager::ReleaseService(NS_LWBRK_CONTRACTID, lf);
lf->GetBreaker(lbarg, getter_AddRefs(lineBreaker));
NS_RELEASE(lf);
}
// Loop over lines in the input string, rewrapping each one.
PRUint32 length = aInString.Length();
PRUint32 length;
PRUint32 posInString = 0;
PRUint32 outStringCol = 0;
PRUint32 citeLevel = 0;
const nsPromiseFlatString &tString = PromiseFlatString(aInString);//MJUDGE SCC NEED HELP
const nsPromiseFlatString &tString = PromiseFlatString(aInString);
length = tString.Length();
#ifdef DEBUG_wrapping
int loopcount = 0;
#endif

Просмотреть файл

@ -59,22 +59,19 @@ nsWrapUtils::Rewrap(const nsAString& aInString,
nsCOMPtr<nsILineBreaker> lineBreaker;
nsILineBreakerFactory *lf;
nsresult rv;
rv = nsServiceManager::GetService(NS_LWBRK_CONTRACTID,
NS_GET_IID(nsILineBreakerFactory),
(nsISupports **)&lf);
nsresult rv = CallGetService(NS_LWBRK_CONTRACTID, &lf);
if (NS_SUCCEEDED(rv))
{
nsAutoString lbarg;
rv = lf->GetBreaker(lbarg, getter_AddRefs(lineBreaker));
nsServiceManager::ReleaseService(NS_LWBRK_CONTRACTID, lf);
lf->GetBreaker(lbarg, getter_AddRefs(lineBreaker));
NS_RELEASE(lf);
}
aOutString.Truncate();
// Now we either have a line breaker, or we don't.
PRInt32 length = aInString.Length();
nsString tString(aInString);
const nsPromiseFlatString &tString = PromiseFlatString(aInString);
PRInt32 length = tString.Length();
const PRUnichar* unicodeStr = tString.get();
for (i = 0; i < length; ) // loop over lines
{

Просмотреть файл

@ -77,8 +77,7 @@ mozSqlResult::Init()
nsresult rv;
if (gRefCnt++ == 0) {
rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
rv = CallGetService(kRDFServiceCID, &gRDFService);
if (NS_FAILED(rv)) return rv;
rv = CallCreateInstance(kDateTimeFormatCID, &gFormat);
@ -145,7 +144,7 @@ mozSqlResult::~mozSqlResult()
NS_IF_RELEASE(kSQL_ResultRoot);
NS_IF_RELEASE(gFormat);
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
NS_IF_RELEASE(gRDFService);
gRDFService = nsnull;
}
}

Просмотреть файл

@ -85,11 +85,8 @@ mozSqlService::~mozSqlService()
NS_IF_RELEASE(kSQL_Database);
NS_IF_RELEASE(kSQL_Priority);
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFContainerUtils);
gRDFContainerUtils = nsnull;
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
NS_IF_RELEASE(gRDFContainerUtils);
NS_IF_RELEASE(gRDFService);
}
NS_IMPL_ISUPPORTS3(mozSqlService,
@ -109,13 +106,10 @@ mozSqlService::Init()
{
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
rv = CallGetService(kRDFServiceCID, &gRDFService);
if (NS_FAILED(rv)) return rv;
rv = nsServiceManager::GetService(kRDFContainerUtilsCID, NS_GET_IID(nsIRDFContainerUtils),
(nsISupports**) &gRDFContainerUtils);
rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils);
if (NS_FAILED(rv)) return rv;
gRDFService->GetResource(NS_LITERAL_CSTRING("SQL:AliasesRoot"),

Просмотреть файл

@ -1778,10 +1778,8 @@ wallet_StepForwardOrBack
//#include "nsIUGenCategory.h"
//#include "nsUnicharUtilCIID.h"
//static NS_DEFINE_IID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
//static NS_DEFINE_IID(kIUGenCategoryIID, NS_IUGENCATEGORY_IID);
//#include "nsICaseConversion.h"
//static NS_DEFINE_IID(kICaseConversionIID, NS_ICASECONVERSION_IID);
//static nsICaseConversion* gCaseConv = nsnull;
static void
@ -1870,12 +1868,10 @@ wallet_ResolvePositionalSchema(nsIDOMNode* elementNode, nsACString& schema) {
/* break out if an alphanumeric character is found */
// nsresult res = nsServiceManager::GetService(kUnicharUtilCID, kICaseConversionIID,
// (nsISupports**)&gCaseConv);
// nsresult res = CallGetService(kUnicharUtilCID, &gCaseConv);
//
// nsIUGenCategory* intl = nsnull;
// nsresult rv = nsServiceManager::GetService(kUnicharUtilCID, kIUGenCategoryIID,
// (nsISupports**)&intl);
// nsresult rv = CallGetService(kUnicharUtilCID, &intl);
// Whaaaaaa, intl is never released here!
// if (NS_SUCCEEDED(rv) && intl) {
// PRBool accept;

Просмотреть файл

@ -381,17 +381,11 @@ NS_IMETHODIMP mozXMLTermShell::SendText(const PRUnichar* aString,
NS_IMETHODIMP
mozXMLTermShell::Exit()
{
nsIAppShellService* appShell = nsnull;
XMLT_LOG(mozXMLTermShell::Exit,10,("\n"));
// Create the Application Shell instance...
// XXXbsmedberg what the hell is this?
nsresult result = nsServiceManager::GetService(NS_APPSHELLSERVICE_CONTRACTID,
NS_GET_IID(nsIAppShellService),
(nsISupports**)&appShell);
if (NS_SUCCEEDED(result)) {
nsServiceManager::ReleaseService(NS_APPSHELLSERVICE_CONTRACTID, appShell);
}
nsCOMPtr<nsIAppShellService> appShell =
do_GetService(NS_APPSHELLSERVICE_CONTRACTID);
return NS_OK;
}

Просмотреть файл

@ -455,8 +455,7 @@ nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
mPixelSize = 1;
}
if (!gInitialized) {
nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager), (nsISupports**) &gCharsetManager);
CallGetService(kCharsetConverterManagerCID, &gCharsetManager);
if (!gCharsetManager) {
FreeGlobals();
return NS_ERROR_FAILURE;
@ -2711,8 +2710,7 @@ GetConverter(const char* aEncoding, nsIUnicodeEncoder **aConverter)
nsresult rv;
if (!gCharsetManager) {
nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager), (nsISupports**)&gCharsetManager);
CallGetService(kCharsetConverterManagerCID, &gCharsetManager);
if (!gCharsetManager) {
FreeGlobals();
return NS_ERROR_FAILURE;

Просмотреть файл

@ -783,9 +783,7 @@ nsFreeType2::GetCharSetManager()
//
// get the sCharSetManager
//
nsServiceManager::GetService(kCharSetManagerCID,
NS_GET_IID(nsICharsetConverterManager),
(nsISupports**) &sCharSetManager);
CallGetService(kCharSetManagerCID, &sCharSetManager);
NS_ASSERTION(sCharSetManager,"failed to create the charset manager");
}
return sCharSetManager;

Просмотреть файл

@ -242,8 +242,7 @@ mozilla_decoder_get_charset (PangoFcDecoder *decoder,
priv->charset = FcCharSetCreate();
if (!gCharsetManager) {
nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager), (nsISupports**)&gCharsetManager);
CallGetService(kCharsetConverterManagerCID, &gCharsetManager);
}
nsCOMPtr<nsIUnicodeEncoder> encoder;

Просмотреть файл

@ -1093,14 +1093,12 @@ InitGlobals(nsIDeviceContext *aDevice)
aDevice->GetCanonicalPixelScale(gDevScale);
nsServiceManager::GetService(kCharSetManagerCID,
NS_GET_IID(nsICharsetConverterManager), (nsISupports**) &gCharSetManager);
CallGetService(kCharSetManagerCID, &gCharSetManager);
if (!gCharSetManager) {
FreeGlobals();
return NS_ERROR_FAILURE;
}
nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref),
(nsISupports**) &gPref);
CallGetService(kPrefCID, &gPref);
if (!gPref) {
FreeGlobals();
return NS_ERROR_FAILURE;

Просмотреть файл

@ -426,8 +426,7 @@ nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
mPixelSize = 1;
}
if (!gInitialized) {
nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager), (nsISupports**) &gCharsetManager);
CallGetService(kCharsetConverterManagerCID, &gCharsetManager);
if (!gCharsetManager) {
FreeGlobals();
return NS_ERROR_FAILURE;
@ -2537,8 +2536,7 @@ GetConverter(const char* aEncoding, nsIUnicodeEncoder **aConverter)
nsresult rv;
if (!gCharsetManager) {
nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager), (nsISupports**)&gCharsetManager);
CallGetService(kCharsetConverterManagerCID, &gCharsetManager);
if (!gCharsetManager) {
FreeGlobals();
return NS_ERROR_FAILURE;

Просмотреть файл

@ -529,8 +529,7 @@ GetConverter(const nsCString& aFontName, nsIUnicodeEncoder** aConverter)
if (!gCharsetManager)
{
rv = nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager), (nsISupports**) &gCharsetManager);
rv = CallGetService(kCharsetConverterManagerCID, &gCharsetManager);
if(NS_FAILED(rv)) return rv;
}

Просмотреть файл

@ -214,8 +214,7 @@ static nsFontCleanupObserver *gFontCleanupObserver;
static nsresult
InitGlobals(void)
{
nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref),
(nsISupports**) &gPref);
CallGetService(kPrefCID, &gPref);
if (!gPref) {
FreeGlobals();
return NS_ERROR_FAILURE;

Просмотреть файл

@ -81,8 +81,7 @@ nsISupports*
OS2Uni::GetUconvObject(int aCodePage, ConverterRequest aReq)
{
if (gCharsetManager == nsnull) {
nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager), (nsISupports**) &gCharsetManager);
CallGetService(kCharsetConverterManagerCID, &gCharsetManager);
}
nsresult rv;

Просмотреть файл

@ -87,7 +87,7 @@ nsFontMetricsPh::nsFontMetricsPh()
static nsresult InitGlobals()
{
nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), (nsISupports**) &gPref);
CallGetService(kPrefCID, &gPref);
if (!gPref) return NS_ERROR_FAILURE;
gFontMetricsCache = new nsHashtable();

Просмотреть файл

@ -200,7 +200,7 @@ nsPostScriptObj::nsPostScriptObj() :
{
PR_LOG(nsPostScriptObjLM, PR_LOG_DEBUG, ("nsPostScriptObj::nsPostScriptObj()\n"));
nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), (nsISupports**) &gPrefs);
CallGetService(kPrefCID, &gPrefs);
gLangGroups = new nsHashtable();
}

Просмотреть файл

@ -279,14 +279,12 @@ static nsFontCleanupObserver *gFontCleanupObserver;
static nsresult
InitGlobals(void)
{
nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager), (nsISupports**) &gCharsetManager);
CallGetService(kCharsetConverterManagerCID, &gCharsetManager);
if (!gCharsetManager) {
FreeGlobals();
return NS_ERROR_FAILURE;
}
nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref),
(nsISupports**) &gPref);
CallGetService(kPrefCID, &gPref);
if (!gPref) {
FreeGlobals();
return NS_ERROR_FAILURE;
@ -386,8 +384,8 @@ static void CheckFontLangGroup(nsIAtom* lang1, nsIAtom* lang2, const char* lang3
if (lang1 == lang2) {
nsresult res = NS_OK;
if (!gFontPackageProxy) {
res = nsServiceManager::GetService("@mozilla.org/intl/fontpackageservice;1",
NS_GET_IID(nsIFontPackageProxy), (nsISupports**) &gFontPackageProxy);
res = CallGetService("@mozilla.org/intl/fontpackageservice;1",
&gFontPackageProxy);
if (NS_FAILED(res)) {
NS_ERROR("Cannot get the font package proxy");
return;

Просмотреть файл

@ -1214,9 +1214,7 @@ nsFT2FontCatalog::InitGlobals(FT_Library lib)
nsulCodePageRangeLanguage *crl = nsnull;
nsServiceManager::GetService(NS_PREF_CONTRACTID,
NS_GET_IID(nsIPref),
(nsISupports**) &sPref);
CallGetService(NS_PREF_CONTRACTID, &sPref);
if (!sPref)
goto cleanup_and_return;

Просмотреть файл

@ -90,39 +90,32 @@ NS_IMETHODIMP nsUnicodeToTIS620::Convert(const PRUnichar* input,
char* output,
PRInt32* aDestLength)
{
PRSize outLen = 0;
PRSize outLen = 0;
#ifdef DEBUG_prabhath_no_shaper
printf("Debug/Test Case of No thai pango shaper Object\n");
// Comment out mCtlObj == nsnull for test purposes
#endif
if (mCtlObj == nsnull) {
nsICharsetConverterManager* gCharSetManager = nsnull;
nsIUnicodeEncoder* gDefaultTISConverter = nsnull;
nsresult res;
nsServiceManager::GetService(kCharSetManagerCID,
NS_GET_IID(nsICharsetConverterManager), (nsISupports**) &gCharSetManager);
#ifdef DEBUG_prabhath
printf("ERROR: No CTL IMPLEMENTATION - Default Thai Conversion");
// CP874 is the default converter for thai ;
// In case mCtlObj is absent (no CTL support), use it to convert.
#endif
if (!gCharSetManager)
nsCOMPtr<nsICharsetConverterManager> charsetMgr =
do_GetService(kCharSetManagerCID);
if (!charsetMgr)
return NS_ERROR_FAILURE;
res = gCharSetManager->GetUnicodeEncoderRaw("TIS-620", &gDefaultTISConverter);
if (!gDefaultTISConverter) {
nsCOMPtr<nsIUnicodeEncoder> encoder;
charsetMgr->GetUnicodeEncoderRaw("TIS-620", getter_AddRefs(encoder));
if (!encoder) {
NS_WARNING("cannot get default converter for tis-620");
NS_IF_RELEASE(gCharSetManager);
return NS_ERROR_FAILURE;
}
gDefaultTISConverter->Convert(input, aSrcLength, output, aDestLength);
NS_IF_RELEASE(gCharSetManager);
NS_IF_RELEASE(gDefaultTISConverter);
encoder->Convert(input, aSrcLength, output, aDestLength);
return NS_OK;
}

Просмотреть файл

@ -38,7 +38,7 @@
#include "nsXPCOM.h"
#include "nsIComponentManager.h"
#include "nsISupports.h"
#include "nsIServiceManager.h"
#include "nsIServiceManagerUtils.h"
#include "nsILineBreakerFactory.h"
#include "nsILineBreaker.h"
#include "nsIWordBreakerFactory.h"
@ -52,8 +52,6 @@
IMPL_NS_IBREAKSTATE( nsBreakState )
NS_DEFINE_CID(kLWBrkCID, NS_LWBRK_CID);
NS_DEFINE_IID(kILineBreakerFactory, NS_ILINEBREAKERFACTORY_IID);
NS_DEFINE_IID(kIWordBreakerFactory, NS_IWORDBREAKERFACTORY_IID);
static char teng1[] =
@ -220,9 +218,7 @@ PRBool TestLineBreaker()
nsILineBreakerFactory *t = NULL;
nsresult res;
PRBool ok = PR_TRUE;
res = nsServiceManager::GetService(kLWBrkCID,
kILineBreakerFactory,
(nsISupports**) &t);
res = CallGetService(kLWBrkCID, &t);
printf("Test 1 - GetService():\n");
if(NS_FAILED(res) || ( t == NULL ) ) {
@ -230,13 +226,11 @@ PRBool TestLineBreaker()
ok = PR_FALSE;
} else {
#ifdef WORD_AROUND_SERVICE_MANAGER_ASSERT
res = nsServiceManager::ReleaseService(kLWBrkCID, t);
NS_RELEASE(t);
#endif
}
res = nsServiceManager::GetService(kLWBrkCID,
kILineBreakerFactory,
(nsISupports**) &t);
res = CallGetService(kLWBrkCID, &t);
if(NS_FAILED(res) || ( t == NULL ) ) {
printf("\t2nd GetService failed\n");
@ -288,7 +282,7 @@ PRBool TestLineBreaker()
}
#ifdef WORD_AROUND_SERVICE_MANAGER_ASSERT
res = nsServiceManager::ReleaseService(kLWBrkCID, t);
NS_RELEASE(t);
#endif
}
printf("==================================\n");
@ -306,21 +300,17 @@ PRBool TestWordBreaker()
nsIWordBreakerFactory *t = NULL;
nsresult res;
PRBool ok = PR_TRUE;
res = nsServiceManager::GetService(kLWBrkCID,
kIWordBreakerFactory,
(nsISupports**) &t);
res = CallGetService(kLWBrkCID, &t);
printf("Test 1 - GetService():\n");
if(NS_FAILED(res) || ( t == NULL ) ) {
printf("\t1st GetService failed\n");
ok = PR_FALSE;
} else {
res = nsServiceManager::ReleaseService(kLWBrkCID, t);
NS_RELEASE(t);
}
res = nsServiceManager::GetService(kLWBrkCID,
kIWordBreakerFactory,
(nsISupports**) &t);
res = CallGetService(kLWBrkCID, &t);
if(NS_FAILED(res) || ( t == NULL ) ) {
printf("\t2nd GetService failed\n");
@ -371,7 +361,7 @@ PRBool TestWordBreaker()
NS_IF_RELEASE(lb);
}
res = nsServiceManager::ReleaseService(kLWBrkCID, t);
NS_RELEASE(t);
}
printf("==================================\n");
printf("Finish nsIWordBreakerFactory Test \n");
@ -413,9 +403,7 @@ void SamplePrintWordWithBreak()
PRUint32 numOfFragment = sizeof(wb) / sizeof(char*);
nsIWordBreakerFactory *t = NULL;
nsresult res = nsServiceManager::GetService(kLWBrkCID,
kIWordBreakerFactory,
(nsISupports**) &t);
nsresult res = CallGetService(kLWBrkCID, &t);
nsIWordBreaker *wbk;
nsAutoString wb_arg;
@ -474,9 +462,7 @@ void SampleFindWordBreakFromPosition(PRUint32 fragN, PRUint32 offset)
PRUint32 numOfFragment = sizeof(wb) / sizeof(char*);
nsIWordBreakerFactory *t = NULL;
nsresult res = nsServiceManager::GetService(kLWBrkCID,
kIWordBreakerFactory,
(nsISupports**) &t);
nsresult res = CallGetService(kLWBrkCID, &t);
nsIWordBreaker *wbk;
nsAutoString wb_arg;

Просмотреть файл

@ -64,17 +64,15 @@ NS_IMETHODIMP nsTextToSubURI::ConvertAndEscape(
if(nsnull == _retval)
return NS_ERROR_NULL_POINTER;
*_retval = nsnull;
nsIUnicodeEncoder *encoder = nsnull;
nsresult rv = NS_OK;
// Get Charset, get the encoder.
nsICharsetConverterManager * ccm = nsnull;
rv = nsServiceManager::GetService(kCharsetConverterManagerCID ,
NS_GET_IID(nsICharsetConverterManager),
(nsISupports**)&ccm);
if(NS_SUCCEEDED(rv) && (nsnull != ccm)) {
nsICharsetConverterManager *ccm;
rv = CallGetService(kCharsetConverterManagerCID, &ccm);
if(NS_SUCCEEDED(rv)) {
nsIUnicodeEncoder *encoder;
rv = ccm->GetUnicodeEncoder(charset, &encoder);
nsServiceManager::ReleaseService( kCharsetConverterManagerCID, ccm);
NS_RELEASE(ccm);
if (NS_SUCCEEDED(rv)) {
rv = encoder->SetOutputErrorBehavior(nsIUnicodeEncoder::kOnError_Replace, nsnull, (PRUnichar)'?');
if(NS_SUCCEEDED(rv))
@ -109,7 +107,7 @@ NS_IMETHODIMP nsTextToSubURI::ConvertAndEscape(
if(pBuf != buf)
PR_Free(pBuf);
}
NS_IF_RELEASE(encoder);
NS_RELEASE(encoder);
}
}
@ -152,10 +150,10 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeAndConvert(
}
}
}
NS_IF_RELEASE(decoder);
NS_RELEASE(decoder);
}
}
PR_FREEIF(unescaped);
PR_Free(unescaped);
return rv;
}

Просмотреть файл

@ -112,11 +112,9 @@ void msEncode(UINT cp, const PRUnichar *src,
int main(int argc, const char** argv)
{
nsresult res= NS_OK;
nsICharsetConverterManager* ccMain=nsnull;
// get ccMain;
nsServiceManager::GetService(kCharsetConverterManagerCID,
kICharsetConverterManagerIID, (nsISupports**) &ccMain);
nsresult res;
nsCOMPtr<nsICharsetConverterManager> ccMain =
do_GetService(kCharsetConverterManagerCID, &res);
if(NS_FAILED(res))
{
fprintf(stderr, "Cannot get Character Converter Manager %x\n", res);

Просмотреть файл

@ -1069,9 +1069,8 @@ nsresult testUTF7Encoder()
nsresult testPlatformCharset()
{
nsIPlatformCharset * cinfo;
nsresult res = nsServiceManager::GetService(kPlatformCharsetCID,
NS_GET_IID(nsIPlatformCharset), (nsISupports **)&cinfo);
nsIPlatformCharset *cinfo;
nsresult res = CallGetService(kPlatformCharsetCID, &cinfo);
if (NS_FAILED(res)) {
printf("ERROR at GetService() code=0x%x.\n",res);
return res;

Просмотреть файл

@ -49,7 +49,6 @@
#include "nsICharsetAlias.h"
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
static NS_DEFINE_IID(kICharsetConverterManagerIID, NS_ICHARSETCONVERTERMANAGER_IID);
#include <stdio.h>
#include <string.h>
@ -79,14 +78,12 @@ int main(int argc, const char** argv)
FILE* infile = 0;
FILE* outfile = 0;
nsresult res= NS_OK;
nsICharsetConverterManager* ccMain=nsnull;
nsICharsetAlias* aliasmgr = nsnull;
NS_InitXPCOM2(nsnull, nsnull, nsnull);
// get ccMain;
res = nsServiceManager::GetService(kCharsetConverterManagerCID,
kICharsetConverterManagerIID, (nsISupports**) &ccMain);
nsCOMPtr<nsICharsetConverterManager> ccMain =
do_GetService(kCharsetConverterManagerCID, &res);
if(NS_FAILED(res))
{
fprintf(stderr, "Cannot get Character Converter Manager %x\n", res);
@ -94,12 +91,11 @@ int main(int argc, const char** argv)
}
// Get the charset alias manager
res = nsServiceManager::GetService(NS_CHARSETALIAS_CONTRACTID, NS_GET_IID(nsICharsetAlias),
(nsISupports**) &aliasmgr);
nsCOMPtr<nsICharsetAlias> aliasmgr =
do_GetService(NS_CHARSETALIAS_CONTRACTID, &res);
if (NS_FAILED(res))
{
fprintf(stderr, "Cannot get Charset Alias Manager %x\n", res);
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccMain);
return -1;
}
@ -221,8 +217,6 @@ int main(int argc, const char** argv)
fprintf(stderr, "Done!\n");
NS_IF_RELEASE(encoder);
NS_IF_RELEASE(decoder);
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccMain);
nsServiceManager::ReleaseService(NS_CHARSETALIAS_CONTRACTID, aliasmgr);
return 0;
}
usage();
@ -234,7 +228,5 @@ int main(int argc, const char** argv)
fclose(outfile);
NS_IF_RELEASE(encoder);
NS_IF_RELEASE(decoder);
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccMain);
nsServiceManager::ReleaseService(NS_CHARSETALIAS_CONTRACTID, aliasmgr);
return -1;
}

Просмотреть файл

@ -55,7 +55,6 @@
#include "nsString.h"
NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
NS_DEFINE_IID(kCaseConversionIID, NS_ICASECONVERSION_IID);
NS_DEFINE_CID(kEntityConverterCID, NS_ENTITYCONVERTER_CID);
NS_DEFINE_CID(kSaveAsCharsetCID, NS_SAVEASCHARSET_CID);
NS_DEFINE_CID(kUnicodeNormalizerCID, NS_UNICODE_NORMALIZER_CID);
@ -271,20 +270,16 @@ void TestCaseConversion()
printf("==============================\n");
nsICaseConversion *t = NULL;
nsresult res;
res = nsServiceManager::GetService(kUnicharUtilCID,
kCaseConversionIID,
(nsISupports**) &t);
res = CallGetService(kUnicharUtilCID, &t);
printf("Test 1 - GetService():\n");
if(NS_FAILED(res) || ( t == NULL ) ) {
printf("\t1st GetService failed\n");
} else {
res = nsServiceManager::ReleaseService(kUnicharUtilCID, t);
NS_RELEASE(t);
}
res = nsServiceManager::GetService(kUnicharUtilCID,
kCaseConversionIID,
(nsISupports**) &t);
res = CallGetService(kUnicharUtilCID, &t);
if(NS_FAILED(res) || ( t == NULL ) ) {
printf("\t2nd GetService failed\n");
@ -365,7 +360,7 @@ void TestCaseConversion()
printf("Test 7 - ToTitle(PRUnichar*, PRUnichar*, PRUint32):\n");
printf("!!! To Be Implemented !!!\n");
res = nsServiceManager::ReleaseService(kUnicharUtilCID, t);
NS_RELEASE(t);
}
printf("==============================\n");
printf("Finish nsICaseConversion Test \n");
@ -545,20 +540,16 @@ void TestNormalization()
printf("==============================\n");
nsIUnicodeNormalizer *t = NULL;
nsresult res;
res = nsServiceManager::GetService(kUnicodeNormalizerCID,
NS_GET_IID(nsIUnicodeNormalizer),
(nsISupports**) &t);
res = CallGetService(kUnicodeNormalizerCID, &t);
printf("Test 1 - GetService():\n");
if(NS_FAILED(res) || ( t == NULL ) ) {
printf("\t1st Norm GetService failed\n");
} else {
res = nsServiceManager::ReleaseService(kUnicodeNormalizerCID, t);
NS_RELEASE(t);
}
res = nsServiceManager::GetService(kUnicodeNormalizerCID,
NS_GET_IID(nsIUnicodeNormalizer),
(nsISupports**) &t);
res = CallGetService(kUnicodeNormalizerCID, &t);
if(NS_FAILED(res) || ( t == NULL ) ) {
printf("\t2nd GetService failed\n");
@ -572,8 +563,7 @@ void TestNormalization()
printf(" Failed in NFD UnicodeNormalizer test. \n");
}
res = nsServiceManager::ReleaseService(kUnicodeNormalizerCID, t);
NS_RELEASE(t);
}
printf("==============================\n");
printf("Finish nsIUnicodeNormalizer Test \n");

Просмотреть файл

@ -76,9 +76,7 @@ nsXPConnect::nsXPConnect()
dont_AddRef(XPTI_GetInterfaceInfoManager());
CallQueryInterface(iim, &mInterfaceInfoManager);
nsServiceManager::GetService(XPC_CONTEXT_STACK_CONTRACTID,
NS_GET_IID(nsIThreadJSContextStack),
(nsISupports **)&mContextStack);
CallGetService(XPC_CONTEXT_STACK_CONTRACTID, &mContextStack);
#ifdef XPC_TOOLS_SUPPORT
{

Просмотреть файл

@ -888,11 +888,13 @@ nsJSCID::GetService(nsISupports **_retval)
else
iid = NS_GET_IID(nsISupports);
nsCOMPtr<nsISupports> srvc;
nsresult rv;
nsCOMPtr<nsIServiceManager> svcMgr;
nsresult rv = NS_GetServiceManager(getter_AddRefs(svcMgr));
if (NS_FAILED(rv))
return rv;
rv = nsServiceManager::GetService(*mDetails.GetID(), iid,
getter_AddRefs(srvc), nsnull);
nsCOMPtr<nsISupports> srvc;
rv = svcMgr->GetService(*mDetails.GetID(), iid, getter_AddRefs(srvc));
NS_ASSERTION(NS_FAILED(rv) || srvc, "service manager returned success, but service is null!");
if(NS_FAILED(rv) || !srvc)
return NS_ERROR_XPC_GS_RETURNED_FAILURE;

Просмотреть файл

@ -501,12 +501,10 @@ NS_IMETHODIMP nsIsIndexFrame::GetEncoder(nsIUnicodeEncoder** encoder)
// Get Charset, get the encoder.
nsICharsetConverterManager * ccm = nsnull;
rv = nsServiceManager::GetService(kCharsetConverterManagerCID ,
NS_GET_IID(nsICharsetConverterManager),
(nsISupports**)&ccm);
rv = CallGetService(kCharsetConverterManagerCID, &ccm);
if(NS_SUCCEEDED(rv) && (nsnull != ccm)) {
rv = ccm->GetUnicodeEncoderRaw(charset.get(), encoder);
nsServiceManager::ReleaseService( kCharsetConverterManagerCID, ccm);
NS_RELEASE(ccm);
if (nsnull == encoder) {
rv = NS_ERROR_FAILURE;
}

Просмотреть файл

@ -142,8 +142,7 @@ static nsresult EnsureCaseConv()
{
nsresult res = NS_OK;
if (!gCaseConv) {
res = nsServiceManager::GetService(kUnicharUtilCID, NS_GET_IID(nsICaseConversion),
(nsISupports**)&gCaseConv);
res = CallGetService(kUnicharUtilCID, &gCaseConv);
NS_ASSERTION( NS_SUCCEEDED(res), "cannot get UnicharUtil");
NS_ASSERTION( gCaseConv != NULL, "cannot get UnicharUtil");
}
@ -158,10 +157,7 @@ nsTextTransformer::Shutdown()
nsContentUtils::UnregisterPrefCallback(kWordSelectStopAtPunctuationPref,
WordSelectPrefCallback, nsnull);
if (gCaseConv) {
nsServiceManager::ReleaseService(kUnicharUtilCID, gCaseConv);
gCaseConv = nsnull;
}
NS_IF_RELEASE(gCaseConv);
}
// For now, we have only a couple of characters to strip out. If we get

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,604 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 of 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 "nsIsIndexFrame.h"
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsPresContext.h"
#include "nsIHTMLContent.h"
#include "nsHTMLAtoms.h"
#include "nsIPresState.h"
#include "nsWidgetsCID.h"
#include "nsIComponentManager.h"
#include "nsIView.h"
#include "nsHTMLParts.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsINameSpaceManager.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIStatefulFrame.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsITextContent.h"
#include "nsHTMLParts.h"
#include "nsLinebreakConverter.h"
#include "nsILinkHandler.h"
#include "nsIHTMLDocument.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsNetUtil.h"
#include "nsICharsetConverterManager.h"
#include "nsEscape.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMKeyEvent.h"
#include "nsIFormControlFrame.h"
#include "nsINodeInfo.h"
#include "nsIDOMEventReceiver.h"
#include "nsContentCID.h"
#include "nsNodeInfoManager.h"
#include "nsContentCreatorFunctions.h"
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
nsresult
NS_NewIsIndexFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsIsIndexFrame* it = new (aPresShell) nsIsIndexFrame();
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
}
*aNewFrame = it;
return NS_OK;
}
nsIsIndexFrame::nsIsIndexFrame()
{
//Shrink the area around it's contents
SetFlags(NS_BLOCK_SHRINK_WRAP | NS_BLOCK_SPACE_MGR);
}
nsIsIndexFrame::~nsIsIndexFrame()
{
// remove ourself as a listener of the text control (bug 40533)
if (mInputContent) {
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(mInputContent));
reciever->RemoveEventListenerByIID(this, NS_GET_IID(nsIDOMKeyListener));
}
}
NS_IMETHODIMP
nsIsIndexFrame::Paint(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
PRBool isVisible;
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
return NS_OK;
}
return nsAreaFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
}
NS_IMETHODIMP
nsIsIndexFrame::UpdatePromptLabel()
{
if (!mTextContent) return NS_ERROR_UNEXPECTED;
nsresult result = NS_OK;
// Get the text from the "prompt" attribute.
// If it is zero length, set it to a default value (localized)
nsAutoString prompt;
if (mContent) {
nsCOMPtr<nsIHTMLContent> htmlContent = do_QueryInterface(mContent, &result);
if ((NS_OK == result) && htmlContent) {
nsHTMLValue value;
result = htmlContent->GetHTMLAttribute(nsHTMLAtoms::prompt, value);
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(prompt);
}
}
}
}
if (prompt.IsEmpty()) {
// Generate localized label.
// We can't make any assumption as to what the default would be
// because the value is localized for non-english platforms, thus
// it might not be the string "This is a searchable index. Enter search keywords: "
result = nsFormControlHelper::GetLocalizedString(nsFormControlHelper::GetHTMLPropertiesFileName(),
NS_LITERAL_STRING("IsIndexPrompt").get(), prompt);
}
mTextContent->SetText(prompt, PR_TRUE);
return NS_OK;
}
NS_IMETHODIMP
nsIsIndexFrame::GetInputFrame(nsPresContext* aPresContext,
nsIFormControlFrame** oFrame)
{
nsIPresShell *presShell = aPresContext->GetPresShell();
if (!mInputContent) NS_WARNING("null content - cannot restore state");
if (presShell && mInputContent) {
nsIFrame *frame;
presShell->GetPrimaryFrameFor(mInputContent, &frame);
if (frame) {
return frame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**) oFrame);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsIsIndexFrame::GetInputValue(nsPresContext* aPresContext,
nsString& oString)
{
nsIFormControlFrame* frame = nsnull;
GetInputFrame(aPresContext, &frame);
if (frame) {
((nsNewFrame*)frame)->GetValue(oString, PR_FALSE);
}
return NS_OK;
}
NS_IMETHODIMP
nsIsIndexFrame::SetInputValue(nsPresContext* aPresContext,
const nsString aString)
{
nsIFormControlFrame* frame = nsnull;
GetInputFrame(aPresContext, &frame);
if (frame) {
((nsNewFrame*)frame)->SetValue(aString);
}
return NS_OK;
}
void
nsIsIndexFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{
nsIFormControlFrame* frame = nsnull;
GetInputFrame(mPresContext, &frame);
if (frame) {
frame->SetFocus(aOn, aRepaint);
}
}
NS_IMETHODIMP
nsIsIndexFrame::CreateAnonymousContent(nsPresContext* aPresContext,
nsISupportsArray& aChildList)
{
nsresult result;
// Get the node info manager (used to create hr's and input's)
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
nsNodeInfoManager *nimgr = doc->NodeInfoManager();
// Create an hr
nsCOMPtr<nsINodeInfo> hrInfo;
nimgr->GetNodeInfo(nsHTMLAtoms::hr, nsnull, kNameSpaceID_None,
getter_AddRefs(hrInfo));
nsCOMPtr<nsIContent> prehr;
result = NS_NewHTMLElement(getter_AddRefs(prehr), hrInfo);
NS_ENSURE_SUCCESS(result, result);
result = aChildList.AppendElement(prehr);
// Add a child text content node for the label
if (NS_SUCCEEDED(result)) {
nsCOMPtr<nsITextContent> labelContent;
NS_NewTextNode(getter_AddRefs(labelContent));
if (labelContent) {
// set the value of the text node and add it to the child list
mTextContent.swap(labelContent);
UpdatePromptLabel();
aChildList.AppendElement(mTextContent);
}
}
// Create text input field
nsCOMPtr<nsINodeInfo> inputInfo;
nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None,
getter_AddRefs(inputInfo));
result = NS_NewHTMLElement(getter_AddRefs(mInputContent), inputInfo);
NS_ENSURE_SUCCESS(result, result);
mInputContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE);
aChildList.AppendElement(mInputContent);
// Register as an event listener to submit on Enter press
nsCOMPtr<nsIDOMEventReceiver> receiver(do_QueryInterface(mInputContent));
receiver->AddEventListenerByIID(this, NS_GET_IID(nsIDOMKeyListener));
// Create an hr
nsCOMPtr<nsIContent> posthr;
result = NS_NewHTMLElement(getter_AddRefs(posthr), hrInfo);
NS_ENSURE_SUCCESS(result, result);
aChildList.AppendElement(posthr);
return result;
}
// Frames are not refcounted, no need to AddRef
NS_IMETHODIMP
nsIsIndexFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
} else if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIDOMKeyListener))) {
*aInstancePtr = (void*)(nsIDOMKeyListener*) this;
return NS_OK;
}
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
}
void
nsIsIndexFrame::ScrollIntoView(nsPresContext* aPresContext)
{
if (aPresContext) {
nsIPresShell *presShell = aPresContext->GetPresShell();
if (presShell) {
presShell->ScrollFrameIntoView(this,
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE);
}
}
}
NS_IMETHODIMP nsIsIndexFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsIsIndexFrame", aReflowState.reason);
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
// The Areaframe takes care of all our reflow
// (except for when style is used to change its size?)
nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
if (aDesiredSize.mComputeMEW) {
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return rv;
}
NS_IMETHODIMP
nsIsIndexFrame::AttributeChanged(nsPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
nsresult rv = NS_OK;
if (nsHTMLAtoms::prompt == aAttribute) {
rv = UpdatePromptLabel();
} else {
rv = nsAreaFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aModType);
}
return rv;
}
nsresult
nsIsIndexFrame::KeyPress(nsIDOMEvent* aEvent)
{
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent);
if (keyEvent) {
PRUint32 code;
keyEvent->GetKeyCode(&code);
if (code == 0) {
keyEvent->GetCharCode(&code);
}
if (nsIDOMKeyEvent::DOM_VK_RETURN == code) {
OnSubmit(mPresContext);
aEvent->PreventDefault(); // XXX Needed?
}
}
return NS_OK;
}
#ifdef NS_DEBUG
NS_IMETHODIMP
nsIsIndexFrame::GetFrameName(nsAString& aResult) const
{
return MakeFrameName(NS_LITERAL_STRING("IsIndex"), aResult);
}
#endif
// submission
// much of this is cut and paste from nsFormFrame::OnSubmit
NS_IMETHODIMP
nsIsIndexFrame::OnSubmit(nsPresContext* aPresContext)
{
if (!mContent || !mInputContent) {
return NS_ERROR_UNEXPECTED;
}
nsresult result = NS_OK;
// Begin ProcessAsURLEncoded
nsAutoString data;
nsCOMPtr<nsIUnicodeEncoder> encoder;
if(NS_FAILED(GetEncoder(getter_AddRefs(encoder)))) // Non-fatal error
encoder = nsnull;
nsAutoString value;
GetInputValue(aPresContext, value);
URLEncode(value, encoder, data);
// End ProcessAsURLEncoded
// make the url string
nsILinkHandler *handler = aPresContext->GetLinkHandler();
nsAutoString href;
// Get the document.
// We'll need it now to form the URL we're submitting to.
// We'll also need it later to get the DOM window when notifying form submit observers (bug 33203)
nsCOMPtr<nsIDocument> document = mContent->GetDocument();
if (!document) return NS_OK; // No doc means don't submit, see Bug 28988
// Resolve url to an absolute url
nsIURI *docURL = document->GetBaseURI();
if (!docURL) {
NS_ERROR("No Base URL found in Form Submit!\n");
return NS_OK; // No base URL -> exit early, see Bug 30721
}
// If an action is not specified and we are inside
// a HTML document then reload the URL. This makes us
// compatible with 4.x browsers.
// If we are in some other type of document such as XML or
// XUL, do nothing. This prevents undesirable reloading of
// a document inside XUL.
nsresult rv;
nsCOMPtr<nsIHTMLDocument> htmlDoc;
htmlDoc = do_QueryInterface(document, &rv);
if (NS_FAILED(rv)) {
// Must be a XML, XUL or other non-HTML document type
// so do nothing.
return NS_OK;
}
// Necko's MakeAbsoluteURI doesn't reuse the baseURL's rel path if it is
// passed a zero length rel path.
nsCAutoString relPath;
docURL->GetSpec(relPath);
if (!relPath.IsEmpty()) {
CopyUTF8toUTF16(relPath, href);
// If re-using the same URL, chop off old query string (bug 25330)
PRInt32 queryStart = href.FindChar('?');
if (kNotFound != queryStart) {
href.Truncate(queryStart);
}
} else {
NS_ERROR("Rel path couldn't be formed in form submit!\n");
return NS_ERROR_OUT_OF_MEMORY;
}
// Add the URI encoded form values to the URI
// Get the scheme of the URI.
nsCOMPtr<nsIURI> actionURL;
nsXPIDLCString scheme;
PRBool isJSURL = PR_FALSE;
const nsACString &docCharset = document->GetDocumentCharacterSet();
const nsPromiseFlatCString& flatDocCharset = PromiseFlatCString(docCharset);
if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href,
flatDocCharset.get(),
docURL))) {
result = actionURL->SchemeIs("javascript", &isJSURL);
}
// Append the URI encoded variable/value pairs for GET's
if (!isJSURL) { // Not for JS URIs, see bug 26917
if (href.FindChar('?') == kNotFound) { // Add a ? if needed
href.Append(PRUnichar('?'));
} else { // Adding to existing query string
if (href.Last() != '&' && href.Last() != '?') { // Add a & if needed
href.Append(PRUnichar('&'));
}
}
href.Append(data);
}
nsCOMPtr<nsIURI> uri;
result = NS_NewURI(getter_AddRefs(uri), href,
flatDocCharset.get(), docURL);
if (NS_FAILED(result)) return result;
// Now pass on absolute url to the click handler
if (handler) {
handler->OnLinkClick(mContent, eLinkVerb_Replace,
uri,
nsnull, nsnull);
}
return result;
}
void nsIsIndexFrame::GetSubmitCharset(nsCString& oCharset)
{
oCharset.AssignLiteral("UTF-8"); // default to utf-8
// XXX
// We may want to get it from the HTML 4 Accept-Charset attribute first
// see 17.3 The FORM element in HTML 4 for details
// Get the charset from document
nsIDocument* doc = mContent->GetDocument();
if (doc) {
oCharset = doc->GetDocumentCharacterSet();
}
}
NS_IMETHODIMP nsIsIndexFrame::GetEncoder(nsIUnicodeEncoder** encoder)
{
*encoder = nsnull;
nsCAutoString charset;
nsresult rv = NS_OK;
GetSubmitCharset(charset);
// Get Charset, get the encoder.
nsICharsetConverterManager * ccm = nsnull;
rv = nsServiceManager::GetService(kCharsetConverterManagerCID ,
NS_GET_IID(nsICharsetConverterManager),
(nsISupports**)&ccm);
if(NS_SUCCEEDED(rv) && (nsnull != ccm)) {
rv = ccm->GetUnicodeEncoderRaw(charset.get(), encoder);
nsServiceManager::ReleaseService( kCharsetConverterManagerCID, ccm);
if (nsnull == encoder) {
rv = NS_ERROR_FAILURE;
}
if (NS_SUCCEEDED(rv)) {
rv = (*encoder)->SetOutputErrorBehavior(nsIUnicodeEncoder::kOnError_Replace, nsnull, (PRUnichar)'?');
}
}
return NS_OK;
}
// XXX i18n helper routines
char*
nsIsIndexFrame::UnicodeToNewBytes(const PRUnichar* aSrc, PRUint32 aLen, nsIUnicodeEncoder* encoder)
{
char* res = nsnull;
if(NS_SUCCEEDED(encoder->Reset()))
{
PRInt32 maxByteLen = 0;
if(NS_SUCCEEDED(encoder->GetMaxLength(aSrc, (PRInt32) aLen, &maxByteLen)))
{
res = new char[maxByteLen+1];
if(nsnull != res)
{
PRInt32 reslen = maxByteLen;
PRInt32 reslen2 ;
PRInt32 srclen = aLen;
encoder->Convert(aSrc, &srclen, res, &reslen);
reslen2 = maxByteLen-reslen;
encoder->Finish(res+reslen, &reslen2);
res[reslen+reslen2] = '\0';
}
}
}
return res;
}
// XXX i18n helper routines
void
nsIsIndexFrame::URLEncode(const nsString& aString, nsIUnicodeEncoder* encoder, nsString& oString)
{
char* inBuf = nsnull;
if(encoder)
inBuf = UnicodeToNewBytes(aString.get(), aString.Length(), encoder);
if(nsnull == inBuf)
inBuf = ToNewCString(aString);
// convert to CRLF breaks
char* convertedBuf = nsLinebreakConverter::ConvertLineBreaks(inBuf,
nsLinebreakConverter::eLinebreakAny, nsLinebreakConverter::eLinebreakNet);
delete [] inBuf;
char* outBuf = nsEscape(convertedBuf, url_XPAlphas);
oString.AssignASCII(outBuf);
nsCRT::free(outBuf);
nsMemory::Free(convertedBuf);
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsIsIndexFrame::SaveState(nsPresContext* aPresContext, nsIPresState** aState)
{
NS_ENSURE_ARG_POINTER(aState);
// Get the value string
nsAutoString stateString;
nsresult res = GetInputValue(aPresContext, stateString);
NS_ENSURE_SUCCESS(res, res);
if (! stateString.IsEmpty()) {
// Construct a pres state and store value in it.
res = NS_NewPresState(aState);
NS_ENSURE_SUCCESS(res, res);
res = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), stateString);
}
return res;
}
NS_IMETHODIMP
nsIsIndexFrame::RestoreState(nsPresContext* aPresContext, nsIPresState* aState)
{
NS_ENSURE_ARG_POINTER(aState);
// Set the value to the stored state.
nsAutoString stateString;
nsresult res = aState->GetStateProperty(NS_LITERAL_STRING("value"), stateString);
NS_ENSURE_SUCCESS(res, res);
return SetInputValue(aPresContext, stateString);
}

Просмотреть файл

@ -1655,7 +1655,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
// Release the prefs service
MimeObject *obj = (mdd ? mdd->obj : 0);
if ( (obj) && (obj->options) && (obj->options->prefs) )
nsServiceManager::ReleaseService(kPrefCID, obj->options->prefs);
obj->options->prefs->Release();
mdd->identity = nsnull;
PR_Free(mdd->url_name);
@ -2107,8 +2107,8 @@ mime_bridge_create_draft_stream(
mdd->options->decompose_file_output_fn = mime_decompose_file_output_fn;
mdd->options->decompose_file_close_fn = mime_decompose_file_close_fn;
rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), (nsISupports**)&(mdd->options->prefs));
if (! (mdd->options->prefs && NS_SUCCEEDED(rv)))
rv = CallGetService(kPrefCID, &(mdd->options->prefs));
if (NS_FAILED(rv))
goto FAIL;
#ifdef ENABLE_SMIME

Просмотреть файл

@ -222,7 +222,6 @@ mime_locate_external_content_handler(const char *content_type,
contentTypeHandlerInitStruct *ctHandlerInfo)
{
MimeObjectClass *newObj = NULL;
nsCID classID = {0};
char lookupID[256];
nsCOMPtr<nsIMimeContentTypeHandler> ctHandler;
nsresult rv;

Просмотреть файл

@ -956,7 +956,7 @@ mime_display_stream_complete (nsMIMESession *stream)
// Release the prefs service
if ( (obj->options) && (obj->options->prefs) )
nsServiceManager::ReleaseService(kPrefCID, obj->options->prefs);
obj->options->prefs->Release();
if ((obj->options) && (obj->options->headers == MimeHeadersOnly))
abortNow = PR_TRUE;
@ -1537,7 +1537,7 @@ mime_bridge_create_display_stream(
// memset(msd->options, 0, sizeof(*msd->options));
msd->options->format_out = format_out; // output format
rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), (nsISupports**)&(msd->options->prefs));
rv = CallGetService(kPrefCID, &(msd->options->prefs));
if (! (msd->options->prefs && NS_SUCCEEDED(rv)))
{
PR_FREEIF(msd);
@ -1548,7 +1548,7 @@ mime_bridge_create_display_stream(
rv = CallCreateInstance(MOZ_TXTTOHTMLCONV_CONTRACTID, &(msd->options->conv));
if (NS_FAILED(rv))
{
nsServiceManager::ReleaseService(kPrefCID, msd->options->prefs);
msd->options->prefs->Release();
PR_FREEIF(msd);
return nsnull;
}

Просмотреть файл

@ -58,8 +58,7 @@ extern nsPluginManager* thePluginManager;
PR_IMPLEMENT(void)
JVM_ReleaseJVMMgr(nsJVMManager* mgr)
{
nsresult err = nsServiceManager::ReleaseService(kJVMManagerCID, (nsISupports*)((nsIJVMManager*)mgr));
PR_ASSERT(err == NS_OK);
mgr->Release();
}
static nsIJVMPlugin*

Просмотреть файл

@ -39,8 +39,8 @@
#include <nsIServiceManager.h>
nsresult GetJVMManager(nsIJVMManager** jvmMngr) {
*jvmMngr = nsnull;
nsresult rv = nsServiceManager::GetService(kJVMManagerCID, kIJVMManagerIID, (nsISupports**)jvmMngr);
*jvmMngr;
nsresult rv = CallGetService(kJVMManagerCID, jvmMngr);
if (rv != NS_OK || !jvmMngr) {
fprintf(stderr, "ERROR: Can't get JVM manager !\n");
return NS_ERROR_FAILURE;

Просмотреть файл

@ -41,7 +41,7 @@ nsresult GetJNI(JNIEnv** env) {
nsIJVMManager *jvmMngr = nsnull;
nsresult rv = NS_OK;
*env = nsnull;
rv = nsServiceManager::GetService(kJVMManagerCID, kIJVMManagerIID, (nsISupports**)&jvmMngr);
rv = CallGetService(kJVMManagerCID, &jvmMngr);
if (rv != NS_OK || !jvmMngr) {
fprintf(stderr, "ERROR: Can't get JVM manager !\n");
return NS_ERROR_FAILURE;
@ -51,4 +51,4 @@ nsresult GetJNI(JNIEnv** env) {
fprintf(stderr, "ERROR: Can't get JNI env !\n");
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -41,10 +41,10 @@
nsresult GetLiveConnectManager(nsILiveConnectManager** lcMngr) {
*lcMngr = nsnull;
nsresult rv = NS_OK;
rv = nsServiceManager::GetService(kJVMManagerCID, kILiveConnectManagerIID, (nsISupports**)lcMngr);
rv = CallGetService(kJVMManagerCID, lcMngr);
if (rv != NS_OK || !lcMngr) {
fprintf(stderr, "ERROR: Can't get LiveConnect manager !\n");
return NS_ERROR_FAILURE;
}
return NS_OK;
}
}

Просмотреть файл

@ -41,11 +41,11 @@
nsresult GetThreadManager(nsIThreadManager** thrdMngr) {
*thrdMngr = nsnull;
nsresult rv;
rv = nsServiceManager::GetService(kJVMManagerCID, kIThreadManagerIID, (nsISupports**)thrdMngr);
rv = CallGetService(kJVMManagerCID, thrdMngr);
if (rv != NS_OK || !thrdMngr) {
fprintf(stderr, "ERROR: Can't get Thread manager !\n");
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -454,9 +454,18 @@ SimplePluginInstance::RegisterSelf(nsIComponentManager* aCompMgr,
{
nsresult rv;
nsIServiceManager *svcMgr;
rv = aCompMgr->QueryInterface(NS_GET_IID(nsIServiceManager),
NS_REINTERPRET_CAST(void**, &svcMgr));
if (NS_FAILED(rv))
return rv;
nsIPluginManager* pm;
rv = nsServiceManager::GetService(kPluginManagerCID, NS_GET_IID(nsIPluginManager),
NS_REINTERPRET_CAST(nsISupports**, &pm));
rv = svcMgr->GetService(kPluginManagerCID,
NS_GET_IID(nsIPluginManager),
NS_REINTERPRET_CAST(void**, &pm));
NS_RELEASE(svcMgr);
if (NS_SUCCEEDED(rv)) {
rv = pm->RegisterPlugin(kSimplePluginCID,
kPluginName,
@ -481,9 +490,18 @@ SimplePluginInstance::UnregisterSelf(nsIComponentManager* aCompMgr,
{
nsresult rv;
nsIServiceManager *svcMgr;
rv = aCompMgr->QueryInterface(NS_GET_IID(nsIServiceManager),
NS_REINTERPRET_CAST(void**, &svcMgr));
if (NS_FAILED(rv))
return rv;
nsIPluginManager* pm;
rv = nsServiceManager::GetService(kPluginManagerCID, NS_GET_IID(nsIPluginManager),
NS_REINTERPRET_CAST(nsISupports**, &pm));
rv = svcMgr->GetService(kPluginManagerCID,
NS_GET_IID(nsIPluginManager),
NS_REINTERPRET_CAST(void**, &pm));
NS_RELEASE(svcMgr);
if (NS_SUCCEEDED(rv)) {
rv = pm->UnregisterPlugin(kSimplePluginCID);
NS_RELEASE(pm);

Просмотреть файл

@ -303,9 +303,18 @@ EventsPluginInstance::RegisterSelf(nsIComponentManager* aCompMgr,
{
nsresult rv;
nsIServiceManager *svcMgr;
rv = aCompMgr->QueryInterface(NS_GET_IID(nsIServiceManager),
NS_REINTERPRET_CAST(void**, &svcMgr));
if (NS_FAILED(rv))
return rv;
nsIPluginManager* pm;
rv = nsServiceManager::GetService(kPluginManagerCID, NS_GET_IID(nsIPluginManager),
NS_REINTERPRET_CAST(nsISupports**, &pm));
rv = svcMgr->GetService(kPluginManagerCID,
NS_GET_IID(nsIPluginManager),
NS_REINTERPRET_CAST(void**, &pm));
NS_RELEASE(svcMgr);
if (NS_SUCCEEDED(rv)) {
rv = pm->RegisterPlugin(kEventsPluginCID,
kPluginName,
@ -330,9 +339,18 @@ EventsPluginInstance::UnregisterSelf(nsIComponentManager* aCompMgr,
{
nsresult rv;
nsIServiceManager *svcMgr;
rv = aCompMgr->QueryInterface(NS_GET_IID(nsIServiceManager),
NS_REINTERPRET_CAST(void**, &svcMgr));
if (NS_FAILED(rv))
return rv;
nsIPluginManager* pm;
rv = nsServiceManager::GetService(kPluginManagerCID, NS_GET_IID(nsIPluginManager),
NS_REINTERPRET_CAST(nsISupports**, &pm));
rv = svcMgr->GetService(kPluginManagerCID,
NS_GET_IID(nsIPluginManager),
NS_REINTERPRET_CAST(void**, &pm));
NS_RELEASE(svcMgr);
if (NS_SUCCEEDED(rv)) {
rv = pm->UnregisterPlugin(kEventsPluginCID);
NS_RELEASE(pm);

Просмотреть файл

@ -91,9 +91,7 @@ nsDirIndexParser::Init() {
nsresult rv;
// XXX not threadsafe
if (gRefCntParser++ == 0)
rv = nsServiceManager::GetService(NS_ITEXTTOSUBURI_CONTRACTID,
NS_GET_IID(nsITextToSubURI),
NS_REINTERPRET_CAST(nsISupports**, &gTextToSubURI));
rv = CallGetService(NS_ITEXTTOSUBURI_CONTRACTID, &gTextToSubURI);
else
rv = NS_OK;

Просмотреть файл

@ -293,9 +293,7 @@ nsresult StartLoad(const char *aURISpec) {
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIIOService> serv;
rv = nsServiceManager::GetService(kIOServiceCID, NS_GET_IID(nsIIOService),
getter_AddRefs(serv));
nsCOMPtr<nsIIOService> serv = do_GetService(kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
// create a uri

Просмотреть файл

@ -126,9 +126,7 @@ ContainerEnumeratorImpl::Init()
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
if (NS_FAILED(rv)) return rv;
rv = nsServiceManager::GetService(kRDFContainerUtilsCID,
NS_GET_IID(nsIRDFContainerUtils),
NS_REINTERPRET_CAST(nsISupports**, &gRDFC));
rv = CallGetService(kRDFContainerUtilsCID, &gRDFC);
if (NS_FAILED(rv)) return rv;
}
@ -140,11 +138,7 @@ ContainerEnumeratorImpl::~ContainerEnumeratorImpl()
{
if (--gRefCnt == 0) {
NS_IF_RELEASE(kRDF_nextVal);
if (gRDFC) {
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFC);
gRDFC = nsnull;
}
NS_IF_RELEASE(gRDFC);
}
}

Просмотреть файл

@ -415,23 +415,21 @@ RDFContainerImpl::Init()
if (gRefCnt++ == 0) {
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_FAILED(rv)) return rv;
rv = CallGetService(kRDFServiceCID, &gRDFService);
if (NS_FAILED(rv)) {
NS_ERROR("unable to get RDF service");
return rv;
}
rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"),
&kRDF_nextVal);
if (NS_FAILED(rv)) return rv;
rv = nsServiceManager::GetService(kRDFContainerUtilsCID,
NS_GET_IID(nsIRDFContainerUtils),
(nsISupports**) &gRDFContainerUtils);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF container utils service");
if (NS_FAILED(rv)) return rv;
rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils);
if (NS_FAILED(rv)) {
NS_ERROR("unable to get RDF container utils service");
return rv;
}
}
return NS_OK;
@ -449,16 +447,8 @@ RDFContainerImpl::~RDFContainerImpl()
NS_IF_RELEASE(mDataSource);
if (--gRefCnt == 0) {
if (gRDFContainerUtils) {
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFContainerUtils);
gRDFContainerUtils = nsnull;
}
if (gRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
NS_IF_RELEASE(gRDFContainerUtils);
NS_IF_RELEASE(gRDFService);
NS_IF_RELEASE(kRDF_nextVal);
}
}

Просмотреть файл

@ -358,9 +358,7 @@ RDFContainerUtilsImpl::RDFContainerUtilsImpl()
if (gRefCnt++ == 0) {
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
rv = CallGetService(kRDFServiceCID, &gRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_SUCCEEDED(rv)) {
@ -388,11 +386,7 @@ RDFContainerUtilsImpl::~RDFContainerUtilsImpl()
#endif
if (--gRefCnt == 0) {
if (gRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
NS_IF_RELEASE(gRDFService);
NS_IF_RELEASE(kRDF_instanceOf);
NS_IF_RELEASE(kRDF_nextVal);
NS_IF_RELEASE(kRDF_Bag);

Просмотреть файл

@ -357,10 +357,7 @@ RDFContentSinkImpl::RDFContentSinkImpl()
mDocumentURL(nsnull)
{
if (gRefCnt++ == 0) {
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &gRDFService);
nsresult rv = CallGetService(kRDFServiceCID, &gRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_SUCCEEDED(rv)) {
@ -379,9 +376,7 @@ RDFContentSinkImpl::RDFContentSinkImpl()
}
rv = nsServiceManager::GetService(kRDFContainerUtilsCID,
NS_GET_IID(nsIRDFContainerUtils),
(nsISupports**) &gRDFContainerUtils);
rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils);
NS_RegisterStaticAtoms(rdf_atoms, NS_ARRAY_LENGTH(rdf_atoms));
}
@ -443,24 +438,14 @@ RDFContentSinkImpl::~RDFContentSinkImpl()
if (--gRefCnt == 0) {
if (gRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
if (gRDFContainerUtils) {
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFContainerUtils);
gRDFContainerUtils = nsnull;
}
NS_IF_RELEASE(gRDFService);
NS_IF_RELEASE(gRDFContainerUtils);
NS_IF_RELEASE(kRDF_type);
NS_IF_RELEASE(kRDF_instanceOf);
NS_IF_RELEASE(kRDF_Alt);
NS_IF_RELEASE(kRDF_Bag);
NS_IF_RELEASE(kRDF_Seq);
NS_IF_RELEASE(kRDF_nextVal);
}
}

Просмотреть файл

@ -514,12 +514,8 @@ RDFXMLDataSourceImpl::~RDFXMLDataSourceImpl(void)
NS_RELEASE(mInner);
if (--gRefCnt == 0) {
if (gRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
}
if (--gRefCnt == 0)
NS_IF_RELEASE(gRDFService);
}

Просмотреть файл

@ -112,9 +112,7 @@ nsRDFXMLSerializer::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
&kRDF_Alt);
if (NS_FAILED(rv)) break;
rv = nsServiceManager::GetService("@mozilla.org/rdf/container-utils;1",
NS_GET_IID(nsIRDFContainerUtils),
(nsISupports**) &gRDFC);
rv = CallGetService("@mozilla.org/rdf/container-utils;1", &gRDFC);
if (NS_FAILED(rv)) break;
} while (0);
@ -139,11 +137,7 @@ nsRDFXMLSerializer::~nsRDFXMLSerializer()
NS_IF_RELEASE(kRDF_instanceOf);
NS_IF_RELEASE(kRDF_type);
NS_IF_RELEASE(kRDF_nextVal);
if (gRDFC) {
nsServiceManager::ReleaseService("@mozilla.org/rdf/container-utils;1", gRDFC);
gRDFC = nsnull;
}
NS_IF_RELEASE(gRDFC);
}
}

Просмотреть файл

@ -176,15 +176,8 @@ nsChromeRegistry::~nsChromeRegistry()
delete mDataSourceTable;
}
if (mRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
mRDFService = nsnull;
}
if (mRDFContainerUtils) {
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, mRDFContainerUtils);
mRDFContainerUtils = nsnull;
}
NS_IF_RELEASE(mRDFService);
NS_IF_RELEASE(mRDFContainerUtils);
}
@ -231,14 +224,10 @@ nsChromeRegistry::Init()
gChromeRegistry = this;
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**)&mRDFService);
rv = CallGetService(kRDFServiceCID, &mRDFService);
NS_ENSURE_SUCCESS(rv, rv);
rv = nsServiceManager::GetService(kRDFContainerUtilsCID,
NS_GET_IID(nsIRDFContainerUtils),
(nsISupports**)&mRDFContainerUtils);
rv = CallGetService(kRDFContainerUtilsCID, &mRDFContainerUtils);
NS_ENSURE_SUCCESS(rv, rv);
rv = mRDFService->GetResource(nsDependentCString(kURICHROME_selectedSkin),

Просмотреть файл

@ -67,9 +67,7 @@ nsChromeUIDataSource::nsChromeUIDataSource(nsIRDFDataSource* aComposite)
mComposite->AddObserver(this);
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**)&mRDFService);
rv = CallGetService(kRDFServiceCID, &mRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
mRDFService->RegisterDataSource(this, PR_TRUE);
@ -79,10 +77,7 @@ nsChromeUIDataSource::~nsChromeUIDataSource()
{
mRDFService->UnregisterDataSource(this);
if (mRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
mRDFService = nsnull;
}
NS_IF_RELEASE(mRDFService);
}
// we require a special implementation of Release, which knows about

Просмотреть файл

@ -282,9 +282,7 @@ FileSystemDataSource::FileSystemDataSource(void)
#ifdef DEBUG
nsresult rv =
#endif
nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
rv = CallGetService(kRDFServiceCID, &gRDFService);
PR_ASSERT(NS_SUCCEEDED(rv));
@ -409,8 +407,7 @@ FileSystemDataSource::~FileSystemDataSource (void)
NS_RELEASE(kLiteralFalse);
gFileSystemDataSource = nsnull;
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
NS_RELEASE(gRDFService);
}
}

Просмотреть файл

@ -71,10 +71,8 @@ nsRDFResource::~nsRDFResource(void)
gRDFService->UnregisterResource(this);
if (--gRDFServiceRefCnt == 0) {
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
if (--gRDFServiceRefCnt == 0)
NS_RELEASE(gRDFService);
}
NS_IMPL_THREADSAFE_ISUPPORTS2(nsRDFResource, nsIRDFResource, nsIRDFNode)

Просмотреть файл

@ -1876,29 +1876,19 @@ nsresult
getNSSDialogs(void **_result, REFNSIID aIID, const char *contract)
{
nsresult rv;
nsCOMPtr<nsISupports> result;
nsCOMPtr<nsISupports> proxiedResult;
rv = nsServiceManager::GetService(contract,
aIID,
getter_AddRefs(result));
nsCOMPtr<nsISupports> svc = do_GetService(contract, &rv);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIProxyObjectManager> proxyman(do_GetService(NS_XPCOMPROXY_CONTRACTID));
if (!proxyman)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIProxyObjectManager> proxyman =
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
proxyman->GetProxyForObject(NS_UI_THREAD_EVENTQ,
aIID, result, PROXY_SYNC,
getter_AddRefs(proxiedResult));
if (!proxiedResult) {
return NS_ERROR_FAILURE;
}
rv = proxiedResult->QueryInterface(aIID, _result);
rv = proxyman->GetProxyForObject(NS_UI_THREAD_EVENTQ,
aIID, svc, PROXY_SYNC,
_result);
return rv;
}

Просмотреть файл

@ -542,10 +542,7 @@ nsGlobalHistory::~nsGlobalHistory()
NS_IF_RELEASE(mStore);
if (--gRefCnt == 0) {
if (gRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
NS_IF_RELEASE(gRDFService);
NS_IF_RELEASE(kNC_Page);
NS_IF_RELEASE(kNC_Date);
@ -2482,9 +2479,7 @@ nsGlobalHistory::Init()
}
if (gRefCnt++ == 0) {
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
rv = CallGetService(kRDFServiceCID, &gRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -969,9 +969,7 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
nsIPresShell* shell;
shell = nsnull;
shell = GetPresShell();
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
res = CallGetService(kWalletServiceCID, &walletservice);
if ((NS_OK == res) && (nsnull != walletservice)) {
nsString urlString2;
// res = walletservice->WALLET_Prefill(shell, (PRVCY_QPREFILL == aID));
@ -995,9 +993,7 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
/* set a cookie for the javascript wallet editor */
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
res = CallGetService(kWalletServiceCID, &walletservice);
if ((NS_OK == res) && (nsnull != walletservice)) {
nsIURI * url;
nsCOMPtr<nsIIOService> service(do_GetService(kIOServiceCID, &res));
@ -1031,9 +1027,7 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
#if defined(SingleSignon)
case PRVCY_DISPLAY_SIGNONS:
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
res = CallGetService(kWalletServiceCID, &walletservice);
if ((NS_OK == res) && (nsnull != walletservice)) {
// res = walletservice->SI_DisplaySignonInfoAsHTML();
NS_RELEASE(walletservice);
@ -1215,8 +1209,7 @@ GetTitleSuffix(void)
{
nsString* suffix = new nsString(" - Failed");
nsIStringBundleService* service = nsnull;
nsresult ret = nsServiceManager::GetService(kStringBundleServiceCID,
kIStringBundleServiceIID, (nsISupports**) &service);
nsresult ret = CallGetService(kStringBundleServiceCID, &service);
if (NS_FAILED(ret)) {
return suffix;
}

Просмотреть файл

@ -204,51 +204,6 @@ nsViewerApp::Destroy()
NS_IF_RELEASE(mPrefService);
}
class nsTestFormProcessor : public nsIFormProcessor {
public:
nsTestFormProcessor();
NS_IMETHOD ProcessValue(nsIDOMHTMLElement *aElement,
const nsString& aName,
nsString& aValue);
NS_IMETHOD ProvideContent(const nsString& aFormType,
nsVoidArray& aContent,
nsString& aAttribute);
NS_DECL_ISUPPORTS
};
NS_IMPL_ISUPPORTS1(nsTestFormProcessor, nsIFormProcessor)
nsTestFormProcessor::nsTestFormProcessor()
{
}
NS_METHOD
nsTestFormProcessor::ProcessValue(nsIDOMHTMLElement *aElement,
const nsString& aName,
nsString& aValue)
{
#ifdef DEBUG_kmcclusk
char *name = ToNewCString(aName);
char *value = ToNewCString(aValue);
printf("ProcessValue: name %s value %s\n", name, value);
delete [] name;
delete [] value;
#endif
return NS_OK;
}
NS_METHOD nsTestFormProcessor::ProvideContent(const nsString& aFormType,
nsVoidArray& aContent,
nsString& aAttribute)
{
return NS_OK;
}
nsresult
nsViewerApp::SetupRegistry()
{
@ -275,15 +230,6 @@ nsViewerApp::SetupRegistry()
#endif
}
// Register a form processor. The form processor has the opportunity to
// modify the value's passed during form submission.
nsTestFormProcessor* testFormProcessor = new nsTestFormProcessor();
nsCOMPtr<nsISupports> formProcessor;
rv = testFormProcessor->QueryInterface(kISupportsIID, getter_AddRefs(formProcessor));
if (NS_SUCCEEDED(rv) && formProcessor) {
rv = nsServiceManager::RegisterService(kFormProcessorCID, formProcessor);
}
return NS_OK;
}
@ -356,9 +302,6 @@ nsViewerApp::Exit()
NS_RELEASE(mAppShell);
}
// Unregister the test form processor registered in nsViewerApp::SetupRegistry
rv = nsServiceManager::UnregisterService(kFormProcessorCID);
return rv;
}

Просмотреть файл

@ -985,16 +985,13 @@ static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
static nsresult
QueueEvent(PLEvent* aEvent)
{
nsISupports* is;
nsresult rv = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID,
&is,
nsnull);
nsresult rv;
nsCOMPtr<nsIEventQueueService> eqs =
do_GetService(kEventQueueServiceCID, &rv);
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIEventQueueService> eqs = do_QueryInterface(is);
if (eqs) {
nsCOMPtr<nsIEventQueue> eq;
rv = eqs->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eq));
@ -1003,7 +1000,6 @@ QueueEvent(PLEvent* aEvent)
}
}
nsServiceManager::ReleaseService(kEventQueueServiceCID, is, nsnull);
return rv;
}

Просмотреть файл

@ -147,9 +147,7 @@ nsCocoaWindow :: DragTrackingHandler ( DragTrackingMessage theMessage, WindowPtr
case kDragTrackingEnterWindow:
{
// get our drag service for the duration of the drag.
nsresult rv = nsServiceManager::GetService(kCDragServiceCID,
NS_GET_IID(nsIDragService),
(nsISupports **)&sDragService);
nsresult rv = CallGetService(kCDragServiceCID, &sDragService);
NS_ASSERTION ( sDragService, "Couldn't get a drag service, we're in biiig trouble" );
// tell the session about this drag
@ -217,10 +215,7 @@ nsCocoaWindow :: DragTrackingHandler ( DragTrackingMessage theMessage, WindowPtr
::HideDragHilite ( theDrag );
// we're _really_ done with it, so let go of the service.
if ( sDragService ) {
nsServiceManager::ReleaseService(kCDragServiceCID, sDragService);
sDragService = nsnull;
}
NS_IF_RELEASE( sDragService );
break;
}

Просмотреть файл

@ -137,13 +137,10 @@ void nsGtkIMEHelper::SetupUnicodeDecoder()
charset.AssignLiteral("ISO-8859-1"); // default
}
nsICharsetConverterManager* manager = nsnull;
nsresult res = nsServiceManager::
GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager),
(nsISupports**)&manager);
nsresult res = CallGetService(kCharsetConverterManagerCID, &manager);
if (manager && NS_SUCCEEDED(res)) {
manager->GetUnicodeDecoderRaw(charset.get(), &mDecoder);
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, manager);
NS_RELEASE(manager);
}
}
NS_ASSERTION(mDecoder, "cannot get decoder");

Просмотреть файл

@ -81,9 +81,7 @@ nsNativeDragTarget::nsNativeDragTarget(nsIWidget * aWnd)
/*
* Create/Get the DragService that we have implemented
*/
nsServiceManager::GetService(kCDragServiceCID,
kIDragServiceIID,
(nsISupports**)&mDragService);
CallGetService(kCDragServiceCID, &mDragService);
}
@ -92,7 +90,7 @@ nsNativeDragTarget::nsNativeDragTarget(nsIWidget * aWnd)
//-----------------------------------------------------
nsNativeDragTarget::~nsNativeDragTarget()
{
nsServiceManager::ReleaseService(kCDragServiceCID, mDragService);
NS_RELEASE(mDragService);
}
//-----------------------------------------------------

Просмотреть файл

@ -4442,11 +4442,9 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
case WM_DESTROYCLIPBOARD:
{
nsIClipboard* clipboard;
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
NS_GET_IID(nsIClipboard),
(nsISupports **)&clipboard);
nsresult rv = CallGetService(kCClipboardCID, &clipboard);
clipboard->EmptyClipboard(nsIClipboard::kGlobalClipboard);
nsServiceManager::ReleaseService(kCClipboardCID, clipboard);
NS_RELEASE(clipboard);
}
break;

Просмотреть файл

@ -1172,9 +1172,7 @@ debug_PrefChangedCallback(const char * name,void * closure)
nsIPref * prefs = nsnull;
nsresult rv = nsServiceManager::GetService(kPrefCID,
NS_GET_IID(nsIPref),
(nsISupports**) &prefs);
nsresult rv = CallGetService(kPrefCID, &prefs);
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service.");
NS_ASSERTION(nsnull != prefs,"Prefs services is null.");
@ -1204,9 +1202,7 @@ debug_RegisterPrefCallbacks()
nsIPref * prefs = nsnull;
nsresult rv = nsServiceManager::GetService(kPrefCID,
NS_GET_IID(nsIPref),
(nsISupports**) &prefs);
nsresult rv = CallGetService(kPrefCID, &prefs);
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service.");
NS_ASSERTION(nsnull != prefs,"Prefs services is null.");

Просмотреть файл

@ -802,7 +802,6 @@ nsresult NS_COM NS_ShutdownXPCOM(nsIServiceManager* servMgr)
if (nsComponentManagerImpl::gComponentManager) {
nsComponentManagerImpl::gComponentManager->FreeServices();
}
nsServiceManager::ShutdownGlobalServiceManager(nsnull);
if (currentQ) {
currentQ->ProcessPendingEvents();

Просмотреть файл

@ -200,51 +200,7 @@ public:
{0x81, 0x63, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
}
class nsIShutdownListener;
template <class DestinationType>
inline
nsresult
CallGetService( const nsCID &aClass,
nsIShutdownListener* shutdownListener,
DestinationType** aDestination)
{
NS_PRECONDITION(aDestination, "null parameter");
return nsServiceManager::GetService(aClass,
NS_GET_IID(DestinationType),
NS_REINTERPRET_CAST(nsISupports**, aDestination),
shutdownListener);
}
template <class DestinationType>
inline
nsresult
CallGetService( const char *aContractID,
nsIShutdownListener* shutdownListener,
DestinationType** aDestination)
{
NS_PRECONDITION(aContractID, "null parameter");
NS_PRECONDITION(aDestination, "null parameter");
return nsServiceManager::GetService(aContractID,
NS_GET_IID(DestinationType),
NS_REINTERPRET_CAST(nsISupports**, aDestination),
shutdownListener);
}
////////////////////////////////////////////////////////////////////////////////
#endif /* nsIServiceManagerObsolete_h___ */

Просмотреть файл

@ -62,6 +62,7 @@ nsServiceManager::GetGlobalServiceManager(nsIServiceManager* *result)
nsresult
nsServiceManager::ShutdownGlobalServiceManager(nsIServiceManager* *result)
{
NS_NOTREACHED("nsServiceManager::ShutdownGlobalServiceManager is deprecated");
return NS_OK;
}
@ -70,7 +71,8 @@ nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID,
nsISupports* *result,
nsIShutdownListener* shutdownListener)
{
NS_NOTREACHED("nsServiceManager::GetService is deprecated");
if (nsComponentManagerImpl::gComponentManager == nsnull)
return NS_ERROR_UNEXPECTED;
@ -81,6 +83,8 @@ nsresult
nsServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service,
nsIShutdownListener* shutdownListener)
{
NS_NOTREACHED("nsServiceManager::ReleaseService is deprecated");
NS_IF_RELEASE(service);
return NS_OK;
}
@ -88,6 +92,7 @@ nsServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service,
nsresult
nsServiceManager::RegisterService(const nsCID& aClass, nsISupports* aService)
{
NS_NOTREACHED("nsServiceManager::RegisterService is deprecated");
if (nsComponentManagerImpl::gComponentManager == nsnull)
return NS_ERROR_UNEXPECTED;
@ -98,7 +103,8 @@ nsServiceManager::RegisterService(const nsCID& aClass, nsISupports* aService)
nsresult
nsServiceManager::UnregisterService(const nsCID& aClass)
{
NS_NOTREACHED("nsServiceManager::UnregisterService is deprecated");
if (nsComponentManagerImpl::gComponentManager == nsnull)
return NS_ERROR_UNEXPECTED;
@ -113,6 +119,7 @@ nsServiceManager::GetService(const char* aContractID, const nsIID& aIID,
nsISupports* *result,
nsIShutdownListener* shutdownListener)
{
NS_NOTREACHED("nsServiceManager::GetService is deprecated");
if (nsComponentManagerImpl::gComponentManager == nsnull)
return NS_ERROR_UNEXPECTED;
@ -124,6 +131,8 @@ nsresult
nsServiceManager::ReleaseService(const char* aContractID, nsISupports* service,
nsIShutdownListener* shutdownListener)
{
NS_NOTREACHED("nsServiceManager::ReleaseService is deprecated");
NS_RELEASE(service);
return NS_OK;
}
@ -131,6 +140,7 @@ nsServiceManager::ReleaseService(const char* aContractID, nsISupports* service,
nsresult
nsServiceManager::RegisterService(const char* aContractID, nsISupports* aService)
{
NS_NOTREACHED("nsServiceManager::RegisterService is deprecated");
if (nsComponentManagerImpl::gComponentManager == nsnull)
return NS_ERROR_UNEXPECTED;
@ -141,6 +151,8 @@ nsServiceManager::RegisterService(const char* aContractID, nsISupports* aService
nsresult
nsServiceManager::UnregisterService(const char* aContractID)
{
NS_NOTREACHED("nsServiceManager::UnregisterService is deprecated");
// Don't create the global service manager here because we might
// be shutting down, and releasing all the services in its
// destructor

Просмотреть файл

@ -36,8 +36,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsProxiedServiceManager_h_
#define __nsProxiedServiceManager_h_
#ifndef nsProxiedService_h_
#define nsProxiedService_h_
#include "nsIServiceManager.h"
#include "nsIProxyObjectManager.h"
@ -94,71 +94,45 @@
class nsProxiedService
{
public:
public:
nsProxiedService(const nsCID &aClass, const nsIID &aIID,
nsIEventQueue* pIProxyQueue, PRBool always, nsresult*rv)
nsIEventQueue* aEventQ, PRBool always, nsresult* rv)
{
*rv = nsServiceManager::GetService(aClass,
aIID,
getter_AddRefs(mService));
if (NS_FAILED(*rv)) return;
InitProxy(aIID, pIProxyQueue, always, rv);
nsCOMPtr<nsISupports> svc = do_GetService(aClass, rv);
if (NS_SUCCEEDED(*rv))
InitProxy(svc, aIID, aEventQ, always, rv);
}
nsProxiedService(const char* aContractID, const nsIID &aIID,
nsIEventQueue* pIProxyQueue, PRBool always, nsresult*rv)
nsIEventQueue* aEventQ, PRBool always, nsresult* rv)
{
*rv = nsServiceManager::GetService(aContractID,
aIID,
getter_AddRefs(mService));
if (NS_FAILED(*rv)) return;
InitProxy(aIID, pIProxyQueue, always, rv);
}
void InitProxy(const nsIID &aIID, nsIEventQueue* pIProxyQueue,
PRBool always, nsresult*rv)
{
static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
nsCOMPtr<nsIProxyObjectManager> pIProxyObjectManager =
do_GetService(kProxyObjectManagerCID, rv);
if (NS_FAILED(*rv)) return;
PRInt32 proxyType = PROXY_SYNC;
if (always) proxyType |= PROXY_ALWAYS;
*rv = pIProxyObjectManager->GetProxyForObject(pIProxyQueue,
aIID,
mService,
proxyType,
getter_AddRefs(mProxiedService));
nsCOMPtr<nsISupports> svc = do_GetService(aContractID, rv);
if (NS_SUCCEEDED(*rv))
InitProxy(svc, aIID, aEventQ, always, rv);
}
~nsProxiedService()
operator nsISupports*() const
{
return mProxiedService;
}
nsISupports* operator->() const
{
NS_PRECONDITION(mProxiedService != 0, "Your code should test the error result from the constructor.");
return mProxiedService;
}
private:
PRBool operator==(const nsISupports* other)
{
return ((mProxiedService == other) || (mService == other));
}
void InitProxy(nsISupports *aObj, const nsIID &aIID,
nsIEventQueue* aEventQ, PRBool always, nsresult*rv)
{
PRInt32 proxyType = PROXY_SYNC;
if (always)
proxyType |= PROXY_ALWAYS;
operator nsISupports*() const
{
return mProxiedService;
}
*rv = NS_GetProxyForObject(aEventQ,
aIID,
aObj,
proxyType,
getter_AddRefs(mProxiedService));
}
protected:
nsCOMPtr<nsISupports> mProxiedService;
nsCOMPtr<nsISupports> mService;
};
nsCOMPtr<nsISupports> mProxiedService;
};
#endif //__nsProxiedServiceManager_h_
#endif // nsProxiedService_h_

Просмотреть файл

@ -131,25 +131,21 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsTestXPCFoo2, nsITestProxy)
NS_IMETHODIMP nsTestXPCFoo2::Test(PRInt32 p1, PRInt32 p2, PRInt32* retval)
{
printf("calling back to caller!\n\n");
printf("calling back to caller!\n\n");
nsIProxyObjectManager* manager;
nsITestProxy * proxyObject;
nsServiceManager::GetService( NS_XPCOMPROXY_CONTRACTID,
NS_GET_IID(nsIProxyObjectManager),
(nsISupports **)&manager);
nsCOMPtr<nsIProxyObjectManager> manager =
do_GetService(NS_XPCOMPROXY_CONTRACTID);
printf("ProxyObjectManager: %p \n", manager);
printf("ProxyObjectManager: %p \n", (void *) manager.get());
PR_ASSERT(manager);
manager->GetProxyForObject((nsIEventQueue*)p1, NS_GET_IID(nsITestProxy), this, PROXY_SYNC, (void**)&proxyObject);
nsCOMPtr<nsITestProxy> proxyObject;
manager->GetProxyForObject((nsIEventQueue*)p1, NS_GET_IID(nsITestProxy),
this, PROXY_SYNC, (void**)&proxyObject);
proxyObject->Test3(nsnull, nsnull);
printf("Deleting Proxy Object\n");
NS_RELEASE(proxyObject);
return NS_OK;
}
@ -184,13 +180,10 @@ void TestCase_TwoClassesOneInterface(void *arg)
ArgsStruct *argsStruct = (ArgsStruct*) arg;
nsIProxyObjectManager* manager;
nsServiceManager::GetService( NS_XPCOMPROXY_CONTRACTID,
NS_GET_IID(nsIProxyObjectManager),
(nsISupports **)&manager);
nsCOMPtr<nsIProxyObjectManager> manager =
do_GetService(NS_XPCOMPROXY_CONTRACTID);
printf("ProxyObjectManager: %p \n", manager);
printf("ProxyObjectManager: %p \n", (void *) manager.get());
PR_ASSERT(manager);
@ -254,14 +247,10 @@ void TestCase_NestedLoop(void *arg)
{
ArgsStruct *argsStruct = (ArgsStruct*) arg;
nsCOMPtr<nsIProxyObjectManager> manager =
do_GetService(NS_XPCOMPROXY_CONTRACTID);
nsIProxyObjectManager* manager;
nsServiceManager::GetService( NS_XPCOMPROXY_CONTRACTID,
NS_GET_IID(nsIProxyObjectManager),
(nsISupports **)&manager);
printf("ProxyObjectManager: %p \n", manager);
printf("ProxyObjectManager: %p\n", (void *) manager.get());
PR_ASSERT(manager);
@ -319,11 +308,8 @@ void TestCase_2(void *arg)
ArgsStruct *argsStruct = (ArgsStruct*) arg;
nsIProxyObjectManager* manager;
nsServiceManager::GetService( NS_XPCOMPROXY_CONTRACTID,
NS_GET_IID(nsIProxyObjectManager),
(nsISupports **)&manager);
nsCOMPtr<nsIProxyObjectManager> manager =
do_GetService(NS_XPCOMPROXY_CONTRACTID);
PR_ASSERT(manager);
@ -349,11 +335,8 @@ void TestCase_nsISupports(void *arg)
ArgsStruct *argsStruct = (ArgsStruct*) arg;
nsIProxyObjectManager* manager;
nsServiceManager::GetService( NS_XPCOMPROXY_CONTRACTID,
NS_GET_IID(nsIProxyObjectManager),
(nsISupports **)&manager);
nsCOMPtr<nsIProxyObjectManager> manager =
do_GetService(NS_XPCOMPROXY_CONTRACTID);
PR_ASSERT(manager);
@ -427,11 +410,8 @@ static void PR_CALLBACK EventLoop( void *arg )
printf("Verifing calling Proxy on eventQ thread.\n");
nsIProxyObjectManager* manager;
nsServiceManager::GetService( NS_XPCOMPROXY_CONTRACTID,
NS_GET_IID(nsIProxyObjectManager),
(nsISupports **)&manager);
nsCOMPtr<nsIProxyObjectManager> manager =
do_GetService(NS_XPCOMPROXY_CONTRACTID);
PR_ASSERT(manager);

Просмотреть файл

@ -113,12 +113,8 @@ int main()
CallCreateInstance(NS_TEST_SERVICE_CONTRACTID, &myITestService);
/* Test CallGetService */
nsIShutdownListener *myShutdownListener = nsnull;
CallGetService(kTestServiceCID, &myITestService);
CallGetService(kTestServiceCID, myShutdownListener, &myITestService);
CallGetService(NS_TEST_SERVICE_CONTRACTID, &myITestService);
CallGetService(NS_TEST_SERVICE_CONTRACTID, myShutdownListener,
&myITestService);
/* Test CallGetInterface */
nsIInterfaceRequestor *myInterfaceRequestor =

Просмотреть файл

@ -53,8 +53,7 @@ BeginTest(int testNumber)
{
nsresult err;
NS_ASSERTION(myServ == NULL, "myServ not reset");
err = nsServiceManager::GetService(kIMyServiceCID, NS_GET_IID(IMyService),
(nsISupports**)&myServ);
err = CallGetService(kIMyServiceCID, &myServ);
return err;
}
@ -67,9 +66,7 @@ EndTest(int testNumber)
err = myServ->Doit();
if (err != NS_OK) return err;
err = nsServiceManager::ReleaseService(kIMyServiceCID, myServ);
if (err != NS_OK) return err;
myServ = NULL;
NS_RELEASE(myServ);
}
printf("test %d succeeded\n", testNumber);
@ -93,17 +90,22 @@ SimpleTest(int testNumber)
nsresult
AsyncShutdown(int testNumber)
{
nsresult err;
nsresult err = NS_OK;
// If the AsyncShutdown was truly asynchronous and happened on another
// thread, we'd have to protect all accesses to myServ throughout this
// code with a monitor.
// XXX-darin: say what?!?
/*
err = nsServiceManager::UnregisterService(kIMyServiceCID);
if (err == NS_ERROR_SERVICE_NOT_AVAILABLE) {
printf("async shutdown -- service not found\n");
return NS_OK;
}
*/
return err;
}
@ -125,8 +127,7 @@ AsyncNoShutdownTest(int testNumber)
// Create some other user of kIMyServiceCID, preventing it from
// really going away:
IMyService* otherClient;
err = nsServiceManager::GetService(kIMyServiceCID, NS_GET_IID(IMyService),
(nsISupports**)&otherClient);
err = CallGetService(kIMyServiceCID, &otherClient);
if (err != NS_OK) return err;
err = AsyncShutdown(testNumber);
@ -134,7 +135,7 @@ AsyncNoShutdownTest(int testNumber)
err = EndTest(testNumber);
// Finally, release the other client.
err = nsServiceManager::ReleaseService(kIMyServiceCID, otherClient);
NS_RELEASE(otherClient);
return err;
}

Просмотреть файл

@ -204,26 +204,23 @@ bm_AddRefGlobals()
if (gRefCnt++ == 0)
{
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDF);
rv = CallGetService(kRDFServiceCID, &gRDF);
if (NS_FAILED(rv)) {
NS_ERROR("unable to get RDF service");
return rv;
}
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_FAILED(rv)) return rv;
rv = CallGetService(kRDFContainerUtilsCID, &gRDFC);
if (NS_FAILED(rv)) {
NS_ERROR("unable to get RDF container utils");
return rv;
}
rv = nsServiceManager::GetService(kRDFContainerUtilsCID,
NS_GET_IID(nsIRDFContainerUtils),
(nsISupports**) &gRDFC);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF container utils");
if (NS_FAILED(rv)) return rv;
rv = nsServiceManager::GetService(kCharsetAliasCID,
NS_GET_IID(nsICharsetAlias),
(nsISupports**) &gCharsetAlias);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get charset alias service");
if (NS_FAILED(rv)) return rv;
rv = CallGetService(kCharsetAliasCID, &gCharsetAlias);
if (NS_FAILED(rv)) {
NS_ERROR("unable to get charset alias service");
return rv;
}
nsCOMPtr<nsILocaleService> ls = do_GetService(NS_LOCALESERVICE_CONTRACTID);
if (ls) {
@ -346,23 +343,9 @@ bm_ReleaseGlobals()
{
if (--gRefCnt == 0)
{
if (gRDF)
{
nsServiceManager::ReleaseService(kRDFServiceCID, gRDF);
gRDF = nsnull;
}
if (gRDFC)
{
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFC);
gRDFC = nsnull;
}
if (gCharsetAlias)
{
nsServiceManager::ReleaseService(kCharsetAliasCID, gCharsetAlias);
gCharsetAlias = nsnull;
}
NS_IF_RELEASE(gRDF);
NS_IF_RELEASE(gRDFC);
NS_IF_RELEASE(gCharsetAlias);
NS_IF_RELEASE(gCollation);
@ -1022,11 +1005,9 @@ BookmarkParser::ParseMetaTag(const nsString &aLine, nsIUnicodeDecoder **decoder)
if (charset.Length() < 1) return NS_ERROR_UNEXPECTED;
// found a charset, now try and get a decoder from it to Unicode
nsICharsetConverterManager *charsetConv = nsnull;
rv = nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager),
(nsISupports**)&charsetConv);
if (NS_SUCCEEDED(rv) && (charsetConv))
nsICharsetConverterManager *charsetConv;
rv = CallGetService(kCharsetConverterManagerCID, &charsetConv);
if (NS_SUCCEEDED(rv))
{
rv = charsetConv->GetUnicodeDecoderRaw(charset.get(), decoder);
NS_RELEASE(charsetConv);
@ -1670,17 +1651,19 @@ nsBookmarksService::Init()
if (NS_FAILED(rv)) return rv;
/* create a URL for the string resource file */
nsCOMPtr<nsIURI> uri;
if (NS_SUCCEEDED(rv = mNetService->NewURI(bookmark_properties, nsnull, nsnull,
getter_AddRefs(uri))))
nsCOMPtr<nsIURI> uri;
mNetService->NewURI(bookmark_properties, nsnull, nsnull,
getter_AddRefs(uri));
if (uri)
{
/* create a bundle for the localization */
nsCOMPtr<nsIStringBundleService> stringService;
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kStringBundleServiceCID,
NS_GET_IID(nsIStringBundleService), getter_AddRefs(stringService))))
nsCOMPtr<nsIStringBundleService> stringService =
do_GetService(kStringBundleServiceCID);
if (stringService)
{
nsCAutoString spec;
if (NS_SUCCEEDED(rv = uri->GetSpec(spec)))
uri->GetSpec(spec);
if (!spec.IsEmpty())
{
stringService->CreateBundle(spec.get(), getter_AddRefs(mBundle));
}

Просмотреть файл

@ -529,10 +529,7 @@ nsGlobalHistory::~nsGlobalHistory()
NS_IF_RELEASE(mStore);
if (--gRefCnt == 0) {
if (gRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
NS_IF_RELEASE(gRDFService);
NS_IF_RELEASE(kNC_Page);
NS_IF_RELEASE(kNC_Date);
@ -2463,9 +2460,7 @@ nsGlobalHistory::Init()
}
if (gRefCnt++ == 0) {
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
rv = CallGetService(kRDFServiceCID, &gRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -745,8 +745,7 @@ nsresult nsCharsetMenu::Init()
mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_type), &kRDF_type);
nsIRDFContainerUtils * rdfUtil = NULL;
res = nsServiceManager::GetService(kRDFContainerUtilsCID,
NS_GET_IID(nsIRDFContainerUtils), (nsISupports **)&rdfUtil);
res = CallGetService(kRDFContainerUtilsCID, &rdfUtil);
if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_BrowserAutodetMenuRoot, NULL);
@ -779,7 +778,7 @@ nsresult nsCharsetMenu::Init()
if (NS_FAILED(res)) goto done;
done:
if (rdfUtil != NULL) nsServiceManager::ReleaseService(kRDFContainerUtilsCID,rdfUtil);
NS_IF_RELEASE(rdfUtil);
if (NS_FAILED(res)) return res;
}
mInitialized = NS_SUCCEEDED(res);

Просмотреть файл

@ -196,7 +196,7 @@ RelatedLinksStreamListener::~RelatedLinksStreamListener()
NS_IF_RELEASE(kNC_RelatedLinksRoot);
mUnicodeDecoder = nsnull;
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
NS_IF_RELEASE(gRDFService);
}
}
@ -207,20 +207,16 @@ RelatedLinksStreamListener::Init()
{
if (gRefCnt++ == 0)
{
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
nsresult rv = CallGetService(kRDFServiceCID, &gRDFService);
if (NS_FAILED(rv))
{
NS_ERROR("unable to get RDF service");
return(rv);
}
nsICharsetConverterManager *charsetConv = nsnull;
rv = nsServiceManager::GetService(kCharsetConverterManagerCID,
NS_GET_IID(nsICharsetConverterManager),
(nsISupports**)&charsetConv);
if (NS_SUCCEEDED(rv) && (charsetConv))
nsICharsetConverterManager *charsetConv;
rv = CallGetService(kCharsetConverterManagerCID, &charsetConv);
if (NS_SUCCEEDED(rv))
{
rv = charsetConv->GetUnicodeDecoderRaw("UTF-8",
getter_AddRefs(mUnicodeDecoder));
@ -612,8 +608,7 @@ RelatedLinksHandlerImpl::~RelatedLinksHandlerImpl()
NS_IF_RELEASE(kNC_RelatedLinksTopic);
NS_IF_RELEASE(kNC_Child);
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
NS_IF_RELEASE(gRDFService);
}
}
@ -626,9 +621,7 @@ RelatedLinksHandlerImpl::Init()
if (gRefCnt++ == 0)
{
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
rv = CallGetService(kRDFServiceCID, &gRDFService);
if (NS_FAILED(rv)) return rv;
gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_RelatedLinksRoot),

Просмотреть файл

@ -432,14 +432,10 @@ InternetSearchDataSource::InternetSearchDataSource(void)
{
if (gRefCnt++ == 0)
{
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService), (nsISupports**) &gRDFService);
PR_ASSERT(NS_SUCCEEDED(rv));
rv = nsServiceManager::GetService(kRDFContainerUtilsCID,
NS_GET_IID(nsIRDFContainerUtils),
(nsISupports**) &gRDFC);
nsresult rv = CallGetService(kRDFServiceCID, &gRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
rv = CallGetService(kRDFContainerUtilsCID, &gRDFC);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF container utils");
gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_SearchEngineRoot),
@ -545,8 +541,8 @@ InternetSearchDataSource::InternetSearchDataSource(void)
gRDFService->GetLiteral(NS_LITERAL_STRING("true").get(), &kTrueLiteral);
rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), getter_AddRefs(prefs));
if (NS_SUCCEEDED(rv) && (prefs))
prefs = do_GetService(kPrefCID);
if (prefs)
{
prefs->RegisterCallback("browser.search.mode", searchModePrefCallback, this);
prefs->GetIntPref("browser.search.mode", &gBrowserSearchMode);
@ -635,18 +631,12 @@ InternetSearchDataSource::~InternetSearchDataSource (void)
prefs = nsnull;
}
if (gRDFC)
{
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFC);
gRDFC = nsnull;
}
NS_IF_RELEASE(gRDFC);
if (gRDFService)
{
gRDFService->UnregisterDataSource(this);
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
NS_RELEASE(gRDFService);
}
}
}
@ -956,7 +946,7 @@ InternetSearchDataSource::Init()
return(rv);
rv = NS_NewLoadGroup(getter_AddRefs(mLoadGroup), nsnull);
PR_ASSERT(NS_SUCCEEDED(rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create load group");
if (!mTimer)
{

Просмотреть файл

@ -109,11 +109,9 @@
#endif
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
static NS_DEFINE_IID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_IID(kIStringBundleServiceIID, NS_ISTRINGBUNDLESERVICE_IID);
#define kInstallLocaleProperties "chrome://global/locale/commonDialogs.properties"
@ -182,7 +180,6 @@ nsInstallInfo::~nsInstallInfo()
MOZ_COUNT_DTOR(nsInstallInfo);
}
static NS_DEFINE_IID(kISoftwareUpdateIID, NS_ISOFTWAREUPDATE_IID);
static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
@ -210,9 +207,7 @@ nsInstall::nsInstall(nsIZipReader * theJARFile)
mJarFileData = theJARFile;
nsISoftwareUpdate *su;
nsresult rv = nsServiceManager::GetService(kSoftwareUpdateCID,
kISoftwareUpdateIID,
(nsISupports**) &su);
nsresult rv = CallGetService(kSoftwareUpdateCID, &su);
if (NS_SUCCEEDED(rv))
{
@ -1201,15 +1196,14 @@ nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aRetur
}
// initialize string bundle and related services
ret = nsServiceManager::GetService(kStringBundleServiceCID,
kIStringBundleServiceIID, (nsISupports**) &service);
ret = CallGetService(kStringBundleServiceCID, &service);
if (NS_FAILED(ret))
goto cleanup;
ret = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID, (nsISupports**) &pEventQueueService);
ret = CallGetService(kEventQueueServiceCID, &pEventQueueService);
if (NS_FAILED(ret))
goto cleanup;
ret = pEventQueueService->CreateThreadEventQueue();
NS_RELEASE(pEventQueueService);
if (NS_FAILED(ret))
goto cleanup;
@ -1220,7 +1214,7 @@ nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aRetur
ret = NS_GetURLSpecFromFile(resFile, spec);
if (NS_FAILED(ret)) {
NS_WARNING("cannot get url spec\n");
nsServiceManager::ReleaseService(kStringBundleServiceCID, service);
NS_RELEASE(service);
return ret;
}
ret = service->CreateBundle(spec.get(), &bundle);
@ -1275,7 +1269,6 @@ cleanup:
// release services
NS_IF_RELEASE( service );
NS_IF_RELEASE( pEventQueueService );
// release file, URL, StringBundle, Enumerator
NS_IF_RELEASE( url );

Просмотреть файл

@ -101,11 +101,7 @@ nsXPINotifierImpl::nsXPINotifierImpl()
nsXPINotifierImpl::~nsXPINotifierImpl()
{
if (mRDF)
{
nsServiceManager::ReleaseService(kRDFServiceCID, mRDF);
mRDF = nsnull;
}
NS_IF_RELEASE(mRDF);
NS_IF_RELEASE(kXPI_NotifierSources);
NS_IF_RELEASE(kXPI_NotifierPackages);
@ -202,7 +198,7 @@ nsXPINotifierImpl::Init()
PRBool moreElements;
// Read the distributor registry
rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService), (nsISupports**) &mRDF);
rv = CallGetService(kRDFServiceCID, &mRDF);
if (NS_FAILED(rv)) return rv;
if (! kXPI_NotifierSources)