зеркало из https://github.com/mozilla/pjs.git
part of mailnews audit --> Conversion to NS_WITH_SERVICE
This commit is contained in:
Родитель
0d585f0670
Коммит
e35294dadf
|
@ -49,11 +49,8 @@ static nsresult GetMessage(nsIURL *aURL, nsIMessage **message)
|
|||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsIRDFService *rdfService;
|
||||
|
||||
if(NS_SUCCEEDED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &rdfService)))
|
||||
NS_WITH_SERVICE(nsIRDFService, rdfService, kRDFServiceCID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsIRDFResource *messageResource;
|
||||
if(NS_SUCCEEDED(rdfService->GetResource(uri, &messageResource)))
|
||||
|
@ -61,7 +58,6 @@ static nsresult GetMessage(nsIURL *aURL, nsIMessage **message)
|
|||
messageResource->QueryInterface(nsIMessage::GetIID(), (void**)message);
|
||||
NS_RELEASE(messageResource);
|
||||
}
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, rdfService);
|
||||
}
|
||||
delete[] uri;
|
||||
|
||||
|
|
|
@ -94,19 +94,17 @@ nsMessengerBootstrap::Initialize()
|
|||
nsresult rv;
|
||||
|
||||
printf("Messenger has been bootstrapped!\n");
|
||||
nsIScriptNameSetRegistry* registry;
|
||||
rv = nsServiceManager::GetService(kCScriptNameSetRegistryCID,
|
||||
nsIScriptNameSetRegistry::GetIID(),
|
||||
(nsISupports**)®istry);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_WITH_SERVICE(nsIScriptNameSetRegistry, registry, kCScriptNameSetRegistryCID, &rv);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsMessengerNameSet* nameSet = new nsMessengerNameSet();
|
||||
|
||||
if (nameSet == nsnull)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
rv = registry->AddExternalNameSet(nameSet);
|
||||
(void)nsServiceManager::ReleaseService(kCScriptNameSetRegistryCID,
|
||||
registry);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,12 +103,10 @@ nsresult ConvertFromUnicode(const nsString aCharset,
|
|||
const nsString inString,
|
||||
char** outCString)
|
||||
{
|
||||
nsICharsetConverterManager * ccm = nsnull;
|
||||
nsresult res;
|
||||
|
||||
res = nsServiceManager::GetService(kCharsetConverterManagerCID,
|
||||
kICharsetConverterManagerIID,
|
||||
(nsISupports**)&ccm);
|
||||
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
|
||||
|
||||
if(NS_SUCCEEDED(res) && (nsnull != ccm)) {
|
||||
nsIUnicodeEncoder* encoder = nsnull;
|
||||
nsString convCharset;
|
||||
|
@ -155,7 +153,6 @@ nsresult ConvertFromUnicode(const nsString aCharset,
|
|||
}
|
||||
NS_IF_RELEASE(encoder);
|
||||
}
|
||||
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccm);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -165,12 +162,9 @@ nsresult ConvertToUnicode(const nsString aCharset,
|
|||
const char *inCString,
|
||||
nsString &outString)
|
||||
{
|
||||
nsICharsetConverterManager * ccm = nsnull;
|
||||
nsresult res;
|
||||
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
|
||||
|
||||
res = nsServiceManager::GetService(kCharsetConverterManagerCID,
|
||||
kICharsetConverterManagerIID,
|
||||
(nsISupports**)&ccm);
|
||||
if(NS_SUCCEEDED(res) && (nsnull != ccm)) {
|
||||
nsIUnicodeDecoder* decoder = nsnull;
|
||||
PRUnichar *unichars;
|
||||
|
@ -201,7 +195,6 @@ nsresult ConvertToUnicode(const nsString aCharset,
|
|||
}
|
||||
NS_IF_RELEASE(decoder);
|
||||
}
|
||||
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccm);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -100,19 +100,16 @@ nsComposerBootstrap::Initialize()
|
|||
nsresult rv;
|
||||
|
||||
printf("Composer has been bootstrapped!\n");
|
||||
nsIScriptNameSetRegistry* registry;
|
||||
rv = nsServiceManager::GetService(kCScriptNameSetRegistryCID,
|
||||
nsIScriptNameSetRegistry::GetIID(),
|
||||
(nsISupports**)®istry);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_WITH_SERVICE(nsIScriptNameSetRegistry, registry, kCScriptNameSetRegistryCID, &rv);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsComposerNameSet* nameSet = new nsComposerNameSet();
|
||||
if (nameSet == nsnull)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
rv = registry->AddExternalNameSet(nameSet);
|
||||
(void)nsServiceManager::ReleaseService(kCScriptNameSetRegistryCID,
|
||||
registry);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,15 +32,11 @@ nsMsgCompPrefs::nsMsgCompPrefs(void * identiy /*= nsnull*/)
|
|||
m_userEmail = nsnull;
|
||||
|
||||
// get the current identity from the mail session....
|
||||
nsIMsgMailSession * mailSession = nsnull;
|
||||
res = nsServiceManager::GetService(kCMsgMailSessionCID,
|
||||
nsIMsgMailSession::GetIID(),
|
||||
(nsISupports **) &mailSession);
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kCMsgMailSessionCID, &res);
|
||||
if (NS_SUCCEEDED(res) && mailSession) {
|
||||
nsIMsgIdentity * identity = nsnull;
|
||||
res = mailSession->GetCurrentIdentity(&identity);
|
||||
// now release the mail service because we are done with it
|
||||
nsServiceManager::ReleaseService(kCMsgMailSessionCID, mailSession);
|
||||
if (NS_SUCCEEDED(res) && identity) {
|
||||
char * aString = nsnull;
|
||||
|
||||
|
|
|
@ -1182,17 +1182,13 @@ static PRInt32 INTL_ConvertCharset(const char* from_charset, const char* to_char
|
|||
{
|
||||
char *dstPtr = nsnull;
|
||||
PRInt32 dstLength = 0;
|
||||
nsICharsetConverterManager * ccm = nsnull;
|
||||
nsresult res;
|
||||
|
||||
if (nsnull == from_charset || nsnull == to_charset ||
|
||||
'\0' == *from_charset || '\0' == *to_charset || nsnull == inBuffer) {
|
||||
'\0' == *from_charset || '\0' == *to_charset || nsnull == inBuffer)
|
||||
return -1;
|
||||
}
|
||||
|
||||
res = nsServiceManager::GetService(kCharsetConverterManagerCID,
|
||||
kICharsetConverterManagerIID,
|
||||
(nsISupports**)&ccm);
|
||||
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
|
||||
|
||||
if(NS_SUCCEEDED(res) && (nsnull != ccm)) {
|
||||
nsString aCharset(from_charset);
|
||||
|
@ -1243,7 +1239,6 @@ static PRInt32 INTL_ConvertCharset(const char* from_charset, const char* to_char
|
|||
}
|
||||
NS_IF_RELEASE(decoder);
|
||||
}
|
||||
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccm);
|
||||
}
|
||||
|
||||
// set the results
|
||||
|
@ -1255,16 +1250,13 @@ static PRInt32 INTL_ConvertCharset(const char* from_charset, const char* to_char
|
|||
static PRInt32 INTL_ConvertToUnicode(const char* from_charset, const char* aBuffer, const PRInt32 aLength,
|
||||
void** uniBuffer, PRInt32* uniLength)
|
||||
{
|
||||
nsICharsetConverterManager * ccm = nsnull;
|
||||
nsresult res;
|
||||
|
||||
if (nsnull == from_charset || '\0' == *from_charset|| nsnull == aBuffer) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
res = nsServiceManager::GetService(kCharsetConverterManagerCID,
|
||||
kICharsetConverterManagerIID,
|
||||
(nsISupports**)&ccm);
|
||||
|
||||
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
|
||||
if(NS_SUCCEEDED(res) && (nsnull != ccm)) {
|
||||
nsString aCharset(from_charset);
|
||||
nsIUnicodeDecoder* decoder = nsnull;
|
||||
|
@ -1287,8 +1279,7 @@ static PRInt32 INTL_ConvertToUnicode(const char* from_charset, const char* aBuff
|
|||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_IF_RELEASE(decoder);
|
||||
}
|
||||
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccm);
|
||||
}
|
||||
}
|
||||
return NS_SUCCEEDED(res) ? 0 : -1;
|
||||
}
|
||||
|
@ -1296,16 +1287,13 @@ static PRInt32 INTL_ConvertToUnicode(const char* from_charset, const char* aBuff
|
|||
static PRInt32 INTL_ConvertFromUnicode(const char* to_charset, const void* uniBuffer, const PRInt32 uniLength,
|
||||
char** aBuffer)
|
||||
{
|
||||
nsICharsetConverterManager * ccm = nsnull;
|
||||
nsresult res;
|
||||
|
||||
if (nsnull == to_charset || '\0' == *to_charset|| nsnull == uniBuffer) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
res = nsServiceManager::GetService(kCharsetConverterManagerCID,
|
||||
kICharsetConverterManagerIID,
|
||||
(nsISupports**)&ccm);
|
||||
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
|
||||
if(NS_SUCCEEDED(res) && (nsnull != ccm)) {
|
||||
nsString aCharset(to_charset);
|
||||
nsIUnicodeEncoder* encoder = nsnull;
|
||||
|
@ -1327,8 +1315,7 @@ static PRInt32 INTL_ConvertFromUnicode(const char* to_charset, const void* uniBu
|
|||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_IF_RELEASE(encoder);
|
||||
}
|
||||
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccm);
|
||||
}
|
||||
}
|
||||
return NS_SUCCEEDED(res) ? 0 : -1;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче