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