making string conversions explicit

This commit is contained in:
scc%netscape.com 2000-04-23 11:54:43 +00:00
Родитель fe3beb97e3
Коммит af88b827ee
5 изменённых файлов: 27 добавлений и 27 удалений

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

@ -474,7 +474,7 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow * aMsgWindow,
rv = ioParamBlock->SetInt(ARTICLE_COUNT_INT_ARG, *last - *first + 1); rv = ioParamBlock->SetInt(ARTICLE_COUNT_INT_ARG, *last - *first + 1);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = ioParamBlock->SetString(GROUPNAME_STRING_ARG, nsString(m_groupName).GetUnicode()); rv = ioParamBlock->SetString(GROUPNAME_STRING_ARG, NS_ConvertASCIItoUCS2(m_groupName).GetUnicode());
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
// get the server key // get the server key
@ -482,7 +482,7 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow * aMsgWindow,
rv = server->GetKey(getter_Copies(serverKey)); rv = server->GetKey(getter_Copies(serverKey));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = ioParamBlock->SetString(SERVERKEY_STRING_ARG, nsString((const char *)serverKey).GetUnicode()); rv = ioParamBlock->SetString(SERVERKEY_STRING_ARG, NS_ConvertASCIItoUCS2((const char *)serverKey).GetUnicode());
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = openWindow(aMsgWindow, DOWNLOAD_HEADERS_URL, ioParamBlock); rv = openWindow(aMsgWindow, DOWNLOAD_HEADERS_URL, ioParamBlock);
@ -584,7 +584,7 @@ nsNNTPNewsgroupList::AddToKnownArticles(PRInt32 first, PRInt32 last)
if (NS_SUCCEEDED(rv) && newsGroupInfo) { if (NS_SUCCEEDED(rv) && newsGroupInfo) {
char *output = m_knownArts.set->Output(); char *output = m_knownArts.set->Output();
if (output) { if (output) {
nsString str(output); nsString str; str.AssignWithConversion(output);
newsGroupInfo->SetKnownArtsSet(&str); newsGroupInfo->SetKnownArtsSet(&str);
} }
delete [] output; delete [] output;
@ -1116,7 +1116,7 @@ nsNNTPNewsgroupList::SetProgressStatus(char *message)
char *printfString = PR_smprintf("%s", message); char *printfString = PR_smprintf("%s", message);
if (printfString) { if (printfString) {
nsString formattedString(printfString); nsString formattedString; formattedString.AssignWithConversion(printfString);
progressMsg = nsCRT::strdup(formattedString.GetUnicode()); progressMsg = nsCRT::strdup(formattedString.GetUnicode());
PR_FREEIF(printfString); PR_FREEIF(printfString);
} }

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

@ -849,7 +849,7 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
news:/GROUP news:/GROUP
news://HOST/GROUP news://HOST/GROUP
*/ */
m_currentGroup = group; m_currentGroup.Assign(group);
if (PL_strchr ((const char *)m_currentGroup, '*')) { if (PL_strchr ((const char *)m_currentGroup, '*')) {
m_typeWanted = LIST_WANTED; m_typeWanted = LIST_WANTED;
@ -1254,7 +1254,7 @@ PRInt32 nsNNTPProtocol::NewsResponse(nsIInputStream * inputStream, PRUint32 leng
nsXPIDLString errorText; nsXPIDLString errorText;
GetNewsStringByName("errorFromServer", getter_Copies(errorText)); GetNewsStringByName("errorFromServer", getter_Copies(errorText));
nsAutoString combinedMsg = NS_STATIC_CAST(const PRUnichar*, errorText); nsAutoString combinedMsg = NS_STATIC_CAST(const PRUnichar*, errorText);
combinedMsg += m_responseText; combinedMsg.AppendWithConversion(m_responseText);
rv = dialog->Alert(combinedMsg.GetUnicode()); rv = dialog->Alert(combinedMsg.GetUnicode());
// XXX: todo, check rv? // XXX: todo, check rv?
} }
@ -3310,7 +3310,7 @@ static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
nsresult nsNNTPProtocol::GetNewsStringByName(const char *aName, PRUnichar **aString) nsresult nsNNTPProtocol::GetNewsStringByName(const char *aName, PRUnichar **aString)
{ {
nsresult res; nsresult res;
nsAutoString resultString = "???"; nsAutoString resultString; resultString.AssignWithConversion("???");
if (!m_stringBundle) if (!m_stringBundle)
{ {
char* propertyURL = NEWS_MSGS_URL; char* propertyURL = NEWS_MSGS_URL;
@ -3325,16 +3325,16 @@ nsresult nsNNTPProtocol::GetNewsStringByName(const char *aName, PRUnichar **aStr
} }
if (m_stringBundle) if (m_stringBundle)
{ {
nsAutoString unicodeName(aName); nsAutoString unicodeName; unicodeName.AssignWithConversion(aName);
PRUnichar *ptrv = nsnull; PRUnichar *ptrv = nsnull;
res = m_stringBundle->GetStringFromName(unicodeName.GetUnicode(), &ptrv); res = m_stringBundle->GetStringFromName(unicodeName.GetUnicode(), &ptrv);
if (NS_FAILED(res)) if (NS_FAILED(res))
{ {
resultString = "[StringName"; resultString.AssignWithConversion("[StringName");
resultString.Append(aName); resultString.AppendWithConversion(aName);
resultString += "?]"; resultString.AppendWithConversion("?]");
*aString = resultString.ToNewUnicode(); *aString = resultString.ToNewUnicode();
} }
else else
@ -3537,7 +3537,7 @@ PRInt32 nsNNTPProtocol::DisplayNewsRC()
if (!name) return -1; if (!name) return -1;
// do I need asciiName? // do I need asciiName?
nsCAutoString asciiName(name); nsCAutoString asciiName; asciiName.AssignWithConversion(name);
m_currentGroup = (const char *)asciiName; m_currentGroup = (const char *)asciiName;
if(NS_SUCCEEDED(rv) && ((const char *)m_currentGroup)) if(NS_SUCCEEDED(rv) && ((const char *)m_currentGroup))
@ -5011,7 +5011,7 @@ void nsNNTPProtocol::SetProgressBarPercent(int percent)
char *printfString = PR_smprintf("%d%%", percent); char *printfString = PR_smprintf("%d%%", percent);
if (printfString) { if (printfString) {
nsString formattedString(printfString); nsString formattedString; formattedString.AssignWithConversion(printfString);
progressMsg = nsCRT::strdup(formattedString.GetUnicode()); progressMsg = nsCRT::strdup(formattedString.GetUnicode());
} }
if (feedback) { if (feedback) {
@ -5038,7 +5038,7 @@ nsNNTPProtocol::SetProgressStatus(char *message)
char *printfString = PR_smprintf("%s", message); char *printfString = PR_smprintf("%s", message);
if (printfString) { if (printfString) {
nsString formattedString(printfString); nsString formattedString; formattedString.AssignWithConversion(printfString);
progressMsg = nsCRT::strdup(formattedString.GetUnicode()); progressMsg = nsCRT::strdup(formattedString.GetUnicode());
} }
if (feedback) { if (feedback) {

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

@ -290,7 +290,7 @@ nsMsgNewsFolder::AddDirectorySeparator(nsFileSpec &path)
// unfortunately we can't just say: // unfortunately we can't just say:
// path += sep; // path += sep;
// here because of the way nsFileSpec concatenates // here because of the way nsFileSpec concatenates
nsAutoString str((nsFilePath)path); nsAutoString str; str.AssignWithConversion(NS_STATIC_CAST(nsFilePath, path));
str += sep; str += sep;
path = nsFilePath(str); path = nsFilePath(str);
} }
@ -503,7 +503,7 @@ NS_IMETHODIMP nsMsgNewsFolder::CreateSubfolder(const PRUnichar *uninewsgroupname
if (!uninewsgroupname) return NS_ERROR_NULL_POINTER; if (!uninewsgroupname) return NS_ERROR_NULL_POINTER;
if (nsCRT::strlen(uninewsgroupname) == 0) return NS_ERROR_FAILURE; if (nsCRT::strlen(uninewsgroupname) == 0) return NS_ERROR_FAILURE;
nsCAutoString newsgroupname(uninewsgroupname); nsCAutoString newsgroupname; newsgroupname.AssignWithConversion(uninewsgroupname);
nsFileSpec path; nsFileSpec path;
nsCOMPtr<nsIFileSpec> pathSpec; nsCOMPtr<nsIFileSpec> pathSpec;
rv = GetPath(getter_AddRefs(pathSpec)); rv = GetPath(getter_AddRefs(pathSpec));
@ -933,7 +933,7 @@ NS_IMETHODIMP nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages,
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsXPIDLString newsgroupname; nsXPIDLString newsgroupname;
rv = GetName(getter_Copies(newsgroupname)); rv = GetName(getter_Copies(newsgroupname));
nsCAutoString asciiName(newsgroupname); nsCAutoString asciiName; asciiName.AssignWithConversion(newsgroupname);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -1430,7 +1430,7 @@ nsMsgNewsFolder::GetGroupPasswordWithUI(const PRUnichar * aPromptMessage, const
} }
// we got a password back...so remember it // we got a password back...so remember it
nsCString aCStr(uniGroupPassword); nsCString aCStr; aCStr.AssignWithConversion(uniGroupPassword);
rv = SetGroupPassword((const char *) aCStr); rv = SetGroupPassword((const char *) aCStr);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -1482,7 +1482,7 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const
} }
// we got a username back, remember it // we got a username back, remember it
nsCString aCStr(uniGroupUsername); nsCString aCStr; aCStr.AssignWithConversion(uniGroupUsername);
rv = SetGroupUsername((const char *) aCStr); rv = SetGroupUsername((const char *) aCStr);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -1512,7 +1512,7 @@ nsMsgNewsFolder::GetNewsrcLine(char **newsrcLine)
rv = GetName(getter_Copies(newsgroupname)); rv = GetName(getter_Copies(newsgroupname));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCAutoString newsrcLineStr(newsgroupname); nsCAutoString newsrcLineStr; newsrcLineStr.AssignWithConversion(newsgroupname);
newsrcLineStr += ":"; newsrcLineStr += ":";
char *setStr = nsnull; char *setStr = nsnull;

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

@ -498,7 +498,7 @@ nsNntpIncomingServer::AddSubscribedNewsgroups()
nsXPIDLString name; nsXPIDLString name;
rv = currFolder->GetName(getter_Copies(name)); rv = currFolder->GetName(getter_Copies(name));
if (NS_SUCCEEDED(rv) && name) { if (NS_SUCCEEDED(rv) && name) {
nsCAutoString asciiName(name); nsCAutoString asciiName; asciiName.AssignWithConversion(name);
rv = SetNewsgroupAsSubscribed((const char *)asciiName); rv = SetNewsgroupAsSubscribed((const char *)asciiName);
} }
} }
@ -548,7 +548,7 @@ nsNntpIncomingServer::SetNewsgroupAsSubscribed(const char *aName)
#endif #endif
nsCOMPtr<nsIRDFLiteral> subscribedLiteral; nsCOMPtr<nsIRDFLiteral> subscribedLiteral;
nsAutoString subscribedString("true"); nsAutoString subscribedString; subscribedString.AssignWithConversion("true");
rv = rdfService->GetLiteral(subscribedString.GetUnicode(), getter_AddRefs(subscribedLiteral)); rv = rdfService->GetLiteral(subscribedString.GetUnicode(), getter_AddRefs(subscribedLiteral));
if(NS_FAILED(rv)) return rv; if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFResource> kNC_Subscribed; nsCOMPtr<nsIRDFResource> kNC_Subscribed;
@ -604,7 +604,7 @@ nsNntpIncomingServer::AddNewNewsgroup(const char *aName)
rv = rdfService->GetResource((const char *) groupUri, getter_AddRefs(newsgroupResource)); rv = rdfService->GetResource((const char *) groupUri, getter_AddRefs(newsgroupResource));
nsCOMPtr<nsIRDFLiteral> nameLiteral; nsCOMPtr<nsIRDFLiteral> nameLiteral;
nsAutoString nameString(aName); nsAutoString nameString; nameString.AssignWithConversion(aName);
rv = rdfService->GetLiteral(nameString.GetUnicode(), getter_AddRefs(nameLiteral)); rv = rdfService->GetLiteral(nameString.GetUnicode(), getter_AddRefs(nameLiteral));
if(NS_FAILED(rv)) return rv; if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFResource> kNC_Name; nsCOMPtr<nsIRDFResource> kNC_Name;
@ -612,7 +612,7 @@ nsNntpIncomingServer::AddNewNewsgroup(const char *aName)
if(NS_FAILED(rv)) return rv; if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFLiteral> subscribedLiteral; nsCOMPtr<nsIRDFLiteral> subscribedLiteral;
nsAutoString subscribedString("false"); nsAutoString subscribedString; subscribedString.AssignWithConversion("false");
rv = rdfService->GetLiteral(subscribedString.GetUnicode(), getter_AddRefs(subscribedLiteral)); rv = rdfService->GetLiteral(subscribedString.GetUnicode(), getter_AddRefs(subscribedLiteral));
if(NS_FAILED(rv)) return rv; if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFResource> kNC_Subscribed; nsCOMPtr<nsIRDFResource> kNC_Subscribed;
@ -837,7 +837,7 @@ nsNntpIncomingServer::SubscribeToNewsgroup(const char *name)
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (!msgfolder) return NS_ERROR_FAILURE; if (!msgfolder) return NS_ERROR_FAILURE;
nsAutoString newsgroupName(name); nsAutoString newsgroupName; newsgroupName.AssignWithConversion(name);
rv = msgfolder->CreateSubfolder(newsgroupName.GetUnicode()); rv = msgfolder->CreateSubfolder(newsgroupName.GetUnicode());
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;

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

@ -1046,7 +1046,7 @@ NS_IMETHODIMP nsNntpService::CancelMessages(const char *hostname, const char *ne
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (!messages) { if (!messages) {
nsAutoString alertText("No articles are selected."); nsAutoString alertText; alertText.AssignWithConversion("No articles are selected.");
if (dialog) if (dialog)
rv = dialog->Alert(alertText.GetUnicode()); rv = dialog->Alert(alertText.GetUnicode());
@ -1062,7 +1062,7 @@ NS_IMETHODIMP nsNntpService::CancelMessages(const char *hostname, const char *ne
} }
if (count != 1) { if (count != 1) {
nsAutoString alertText("You can only cancel one article at a time."); nsAutoString alertText; alertText.AssignWithConversion("You can only cancel one article at a time.");
if (dialog) if (dialog)
rv = dialog->Alert(alertText.GetUnicode()); rv = dialog->Alert(alertText.GetUnicode());
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;