Adopt new str res api prototype.

git-svn-id: svn://10.0.0.236/trunk@40601 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
tao%netscape.com 1999-07-22 04:41:11 +00:00
parent 45e7b75ebd
commit e190b593e4
9 changed files with 116 additions and 5 deletions

View File

@ -553,6 +553,11 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell)
if (NS_SUCCEEDED(result) && service)
{
#if 1
nsILocale* locale = nsnull;
result = service->CreateBundle(EDITOR_BUNDLE_URL, locale,
getter_AddRefs(mStringBundle));
#else
nsCOMPtr<nsIURI> url;
#ifndef NECKO
result = NS_NewURL(getter_AddRefs(url), nsString(EDITOR_BUNDLE_URL));
@ -570,6 +575,7 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell)
} else {
printf("ERROR: Failed to get create URL for StringBundle\n");
}
#endif
// We don't need to keep service around once we created the bundle
nsServiceManager::ReleaseService(kStringBundleServiceCID, service);
} else {
@ -4537,7 +4543,14 @@ nsresult nsEditor::GetString(const nsString& name, nsString& value)
value = "";
if (mStringBundle && (name != ""))
{
#if 1
const PRUnichar *ptrtmp = name.GetUnicode();
PRUnichar *ptrv = nsnull;
result = mStringBundle->GetStringFromName(ptrtmp, &ptrv);
value = ptrv;
#else
result = mStringBundle->GetStringFromName(name, value);
#endif
}
return result;
}

View File

@ -553,6 +553,11 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell)
if (NS_SUCCEEDED(result) && service)
{
#if 1
nsILocale* locale = nsnull;
result = service->CreateBundle(EDITOR_BUNDLE_URL, locale,
getter_AddRefs(mStringBundle));
#else
nsCOMPtr<nsIURI> url;
#ifndef NECKO
result = NS_NewURL(getter_AddRefs(url), nsString(EDITOR_BUNDLE_URL));
@ -570,6 +575,7 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell)
} else {
printf("ERROR: Failed to get create URL for StringBundle\n");
}
#endif
// We don't need to keep service around once we created the bundle
nsServiceManager::ReleaseService(kStringBundleServiceCID, service);
} else {
@ -4537,7 +4543,14 @@ nsresult nsEditor::GetString(const nsString& name, nsString& value)
value = "";
if (mStringBundle && (name != ""))
{
#if 1
const PRUnichar *ptrtmp = name.GetUnicode();
PRUnichar *ptrv = nsnull;
result = mStringBundle->GetStringFromName(ptrtmp, &ptrv);
value = ptrv;
#else
result = mStringBundle->GetStringFromName(name, value);
#endif
}
return result;
}

View File

@ -398,7 +398,18 @@ Wallet_Localize(char* genericString) {
}
nsILocale* locale = nsnull;
nsIStringBundle* bundle = nsnull;
#if 1
const char* spec = nsnull;
ret = url->GetSpec(&spec);
if (NS_FAILED(ret)) {
printf("cannot get url spec\n");
nsServiceManager::ReleaseService(kStringBundleServiceCID, pStringService);
return v.ToNewCString();
}
ret = pStringService->CreateBundle(spec, locale, &bundle);
#else
ret = pStringService->CreateBundle(url, locale, &bundle);
#endif
if (NS_FAILED(ret)) {
printf("cannot create instance\n");
nsServiceManager::ReleaseService(kStringBundleServiceCID, pStringService);
@ -407,7 +418,15 @@ Wallet_Localize(char* genericString) {
nsServiceManager::ReleaseService(kStringBundleServiceCID, pStringService);
/* localize the given string */
#if 1
nsString strtmp(genericString);
const PRUnichar *ptrtmp = strtmp.GetUnicode();
PRUnichar *ptrv = nsnull;
ret = bundle->GetStringFromName(ptrtmp, &ptrv);
v = ptrv;
#else
ret = bundle->GetStringFromName(nsString(genericString), v);
#endif
NS_RELEASE(bundle);
if (NS_FAILED(ret)) {
printf("cannot get string from name\n");

View File

@ -58,6 +58,10 @@ ComposeBEGetStringByIDREAL(PRInt32 stringID)
nsIURI *url = nsnull;
nsILocale *locale = nsnull;
#if 1
nsIStringBundle* sBundle = nsnull;
res = sBundleService->CreateBundle(propertyURL, locale, &sBundle);
#else
res = pNetService->CreateURL(&url, nsString(propertyURL), nsnull, nsnull, nsnull);
// cleanup...if necessary
if (propertyURL != COMPOSE_BE_URL)
@ -73,13 +77,20 @@ ComposeBEGetStringByIDREAL(PRInt32 stringID)
nsIStringBundle* sBundle = nsnull;
res = sBundleService->CreateBundle(url, locale, &sBundle);
#endif
if (NS_FAILED(res))
{
return PL_strdup("???"); // Don't I18N this string...failsafe return value
}
nsAutoString v("");
#if 1
PRUnichar *ptrv = nsnull;
res = sBundle->GetStringFromID(stringID, &ptrv);
v = ptrv;
#else
res = sBundle->GetStringFromID(stringID, v);
#endif
if (NS_FAILED(res))
{
char buf[128];

View File

@ -1976,7 +1976,11 @@ VCardGetStringByIDREAL(PRInt32 stringID)
nsIURI *url = nsnull;
nsILocale *locale = nsnull;
res = pNetService->CreateURL(&url, nsString(VCARD_URL), nsnull, nsnull, nsnull);
#if 1
nsIStringBundle* sBundle = nsnull;
res = sBundleService->CreateBundle(VCARD_URL, locale, &sBundle);
#else
res = pNetService->CreateURL(&url, nsString(VCARD_URL), nsnull, nsnull, nsnull);
if (NS_FAILED(res))
{
return PL_strdup("???"); // Don't I18N this string...failsafe return value
@ -1984,13 +1988,20 @@ VCardGetStringByIDREAL(PRInt32 stringID)
nsIStringBundle* sBundle = nsnull;
res = sBundleService->CreateBundle(url, locale, &sBundle);
#endif
if (NS_FAILED(res))
{
return PL_strdup("???"); // Don't I18N this string...failsafe return value
}
nsAutoString v("");
#if 1
PRUnichar *ptrv = nsnull;
res = sBundle->GetStringFromID(stringID, &ptrv);
v = ptrv;
#else
res = sBundle->GetStringFromID(stringID, v);
#endif
if (NS_FAILED(res))
{
char buf[128];

View File

@ -1434,6 +1434,10 @@ MimeGetStringByIDREAL(PRInt32 stringID)
nsIURI *url = nsnull;
nsILocale *locale = nsnull;
#if 1
nsIStringBundle* sBundle = nsnull;
res = sBundleService->CreateBundle(propertyURL, locale, &sBundle);
#else
res = pNetService->CreateURL(&url, nsString(propertyURL), nsnull, nsnull, nsnull);
// Cleanup property URL
if (propertyURL != MIME_URL)
@ -1446,13 +1450,20 @@ MimeGetStringByIDREAL(PRInt32 stringID)
nsIStringBundle* sBundle = nsnull;
res = sBundleService->CreateBundle(url, locale, &sBundle);
#endif
if (NS_FAILED(res))
{
return PL_strdup("???"); // Don't I18N this string...failsafe return value
}
nsAutoString v("");
#if 1
PRUnichar *ptrv = nsnull;
res = sBundle->GetStringFromID(stringID, &ptrv);
v = ptrv;
#else
res = sBundle->GetStringFromID(stringID, v);
#endif
if (NS_FAILED(res))
{
char buf[128];

View File

@ -169,7 +169,18 @@ cookie_Localize(char* genericString) {
}
nsILocale* locale = nsnull;
nsIStringBundle* bundle = nsnull;
#if 1
const char* spec = nsnull;
ret = url->GetSpec(&spec);
if (NS_FAILED(ret)) {
printf("cannot get url spec\n");
nsServiceManager::ReleaseService(kStringBundleServiceCID, pStringService);
return v.ToNewCString();
}
ret = pStringService->CreateBundle(spec, locale, &bundle);
#else
ret = pStringService->CreateBundle(url, locale, &bundle);
#endif
if (NS_FAILED(ret)) {
printf("cannot create instance\n");
nsServiceManager::ReleaseService(kStringBundleServiceCID, pStringService);
@ -178,7 +189,15 @@ cookie_Localize(char* genericString) {
nsServiceManager::ReleaseService(kStringBundleServiceCID, pStringService);
/* localize the given string */
#if 1
nsString strtmp(genericString);
const PRUnichar *ptrtmp = strtmp.GetUnicode();
PRUnichar *ptrv = nsnull;
ret = bundle->GetStringFromName(ptrtmp, &ptrv);
v = ptrv;
#else
ret = bundle->GetStringFromName(nsString(genericString), v);
#endif
PR_Free(bundle);
if (NS_FAILED(ret)) {
printf("cannot get string from name\n");

View File

@ -85,8 +85,8 @@ NS_SetupRegistry()
pEventQService = nsnull;
nsresult result = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID,
(nsISupports **)&pEventQService);
kIEventQueueServiceIID,
(nsISupports **)&pEventQService);
if (NS_SUCCEEDED(result)) {
// XXX: What if this fails?
result = pEventQService->CreateThreadEventQueue();
@ -112,8 +112,9 @@ main(int argc, char* argv[])
#ifndef NECKO
nsINetService* pNetService = nsnull;
ret = nsServiceManager::GetService(kNetServiceCID, kINetServiceIID,
(nsISupports**) &pNetService);
ret = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports**) &pNetService);
if (NS_FAILED(ret) || (!pNetService)) {
printf("cannot get net service\n");
return 1;

View File

@ -993,7 +993,20 @@ nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aRetur
goto cleanup;
// get the string bundle using the extracted properties file
#if 1
{
const char* spec = nsnull;
ret = url->GetSpec(&spec);
if (NS_FAILED(ret)) {
printf("cannot get url spec\n");
nsServiceManager::ReleaseService(kStringBundleServiceCID, service);
return ret;
}
ret = service->CreateBundle(spec, locale, &bundle);
}
#else
ret = service->CreateBundle(url, locale, &bundle);
#endif
if (NS_FAILED(ret))
goto cleanup;
ret = bundle->GetEnumeration(&propEnum);