mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
Removing unnecessary CreateUtf7ConvertedString,
bug 180166, r=naving, sr=bienvenu.
This commit is contained in:
parent
61b529e662
commit
2520f79e24
@ -45,89 +45,6 @@
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
||||
|
||||
// convert back and forth between imap utf7 and unicode.
|
||||
char*
|
||||
CreateUtf7ConvertedString(const char * aSourceString,
|
||||
PRBool aConvertToUtf7Imap)
|
||||
{
|
||||
nsresult res;
|
||||
char *dstPtr = nsnull;
|
||||
PRInt32 dstLength = 0;
|
||||
char *convertedString = NULL;
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(kCharsetConverterManagerCID, &res);
|
||||
|
||||
if(NS_SUCCEEDED(res) && (nsnull != ccm))
|
||||
{
|
||||
nsString aCharset(NS_LITERAL_STRING("x-imap4-modified-utf7"));
|
||||
PRUnichar *unichars = nsnull;
|
||||
PRInt32 unicharLength;
|
||||
|
||||
if (!aConvertToUtf7Imap)
|
||||
{
|
||||
// convert utf7 to unicode
|
||||
nsIUnicodeDecoder* decoder = nsnull;
|
||||
|
||||
res = ccm->GetUnicodeDecoder(&aCharset, &decoder);
|
||||
if(NS_SUCCEEDED(res) && (nsnull != decoder))
|
||||
{
|
||||
PRInt32 srcLen = PL_strlen(aSourceString);
|
||||
res = decoder->GetMaxLength(aSourceString, srcLen, &unicharLength);
|
||||
// temporary buffer to hold unicode string
|
||||
unichars = new PRUnichar[unicharLength + 1];
|
||||
if (unichars == nsnull)
|
||||
{
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = decoder->Convert(aSourceString, &srcLen, unichars, &unicharLength);
|
||||
unichars[unicharLength] = 0;
|
||||
}
|
||||
NS_IF_RELEASE(decoder);
|
||||
// convert the unicode to 8 bit ascii.
|
||||
nsString unicodeStr(unichars);
|
||||
convertedString = (char *) PR_Malloc(unicharLength + 1);
|
||||
if (convertedString)
|
||||
unicodeStr.ToCString(convertedString, unicharLength + 1, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// convert from 8 bit ascii string to modified utf7
|
||||
nsString unicodeStr; unicodeStr.AssignWithConversion(aSourceString);
|
||||
nsIUnicodeEncoder* encoder = nsnull;
|
||||
aCharset.Assign(NS_LITERAL_STRING("x-imap4-modified-utf7"));
|
||||
res = ccm->GetUnicodeEncoder(&aCharset, &encoder);
|
||||
if(NS_SUCCEEDED(res) && (nsnull != encoder))
|
||||
{
|
||||
res = encoder->GetMaxLength(unicodeStr.get(), unicodeStr.Length(), &dstLength);
|
||||
// allocale an output buffer
|
||||
dstPtr = (char *) PR_CALLOC(dstLength + 1);
|
||||
unicharLength = unicodeStr.Length();
|
||||
if (dstPtr == nsnull)
|
||||
{
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = encoder->Convert(unicodeStr.get(), &unicharLength, dstPtr, &dstLength);
|
||||
dstPtr[dstLength] = 0;
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(encoder);
|
||||
nsString unicodeStr2; unicodeStr2.AssignWithConversion(dstPtr);
|
||||
convertedString = (char *) PR_Malloc(dstLength + 1);
|
||||
if (convertedString)
|
||||
unicodeStr2.ToCString(convertedString, dstLength + 1, 0);
|
||||
}
|
||||
delete [] unichars;
|
||||
}
|
||||
PR_FREEIF(dstPtr);
|
||||
return convertedString;
|
||||
}
|
||||
|
||||
// convert back and forth between imap utf7 and unicode.
|
||||
char*
|
||||
CreateUtf7ConvertedStringFromUnicode(const PRUnichar * aSourceString)
|
||||
|
@ -41,8 +41,6 @@
|
||||
#include "msgCore.h"
|
||||
#include "nsError.h"
|
||||
|
||||
NS_MSG_BASE char* CreateUtf7ConvertedString(const char * aSourceString, PRBool aConvertToUtf7Imap);
|
||||
|
||||
NS_MSG_BASE nsresult CreateUnicodeStringFromUtf7(const char *aSourceString, PRUnichar **result);
|
||||
|
||||
NS_MSG_BASE char * CreateUtf7ConvertedStringFromUnicode(const PRUnichar *aSourceString);
|
||||
|
@ -6668,26 +6668,20 @@ void nsImapProtocol::NthLevelChildList(const char* onlineMailboxPrefix,
|
||||
if (truncatedPrefix.Last() == slash)
|
||||
truncatedPrefix.SetLength(truncatedPrefix.Length()-1);
|
||||
|
||||
char *utf7ListArg =
|
||||
CreateUtf7ConvertedString(truncatedPrefix.get(),PR_TRUE);
|
||||
if (utf7ListArg)
|
||||
{
|
||||
nsCString pattern(utf7ListArg);
|
||||
nsCString suffix;
|
||||
int count = 0;
|
||||
char separator = 0;
|
||||
m_runningUrl->GetOnlineSubDirSeparator(&separator);
|
||||
suffix.Assign(separator);
|
||||
suffix += '%';
|
||||
|
||||
while (count < depth)
|
||||
{
|
||||
pattern += suffix;
|
||||
count++;
|
||||
List(pattern.get(), PR_FALSE);
|
||||
}
|
||||
PR_Free(utf7ListArg);
|
||||
}
|
||||
nsCAutoString pattern(truncatedPrefix);
|
||||
nsCAutoString suffix;
|
||||
int count = 0;
|
||||
char separator = 0;
|
||||
m_runningUrl->GetOnlineSubDirSeparator(&separator);
|
||||
suffix.Assign(separator);
|
||||
suffix += '%';
|
||||
|
||||
while (count < depth)
|
||||
{
|
||||
pattern += suffix;
|
||||
count++;
|
||||
List(pattern.get(), PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void nsImapProtocol::ProcessAuthenticatedStateURL()
|
||||
|
Loading…
Reference in New Issue
Block a user