From 516f6b74bcc719dec54b964971660a96b35a38c4 Mon Sep 17 00:00:00 2001 From: "naving%netscape.com" Date: Fri, 21 Sep 2001 04:34:13 +0000 Subject: [PATCH] 70252 62437 r=bienvenu sr=sspitzer Use the platform charset while converting filter name etc from 4x to 6x. --- mailnews/base/search/src/nsMsgFilter.cpp | 11 ++++++---- mailnews/base/search/src/nsMsgFilterList.cpp | 23 ++++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/mailnews/base/search/src/nsMsgFilter.cpp b/mailnews/base/search/src/nsMsgFilter.cpp index f6bd2c1158ed..5d4148899656 100644 --- a/mailnews/base/search/src/nsMsgFilter.cpp +++ b/mailnews/base/search/src/nsMsgFilter.cpp @@ -39,6 +39,7 @@ #include "nsReadableUtils.h" #include "nsEscape.h" #include "nsMsgUtf7Utils.h" +#include "nsIImportService.h" static const char *kImapPrefix = "//imap:"; @@ -381,6 +382,8 @@ nsresult nsMsgFilter::ConvertMoveToFolderValue(nsCString &moveValue) m_filterList->GetVersion(&filterVersion); if (filterVersion <= k60Beta1Version) { + nsCOMPtr impSvc = do_GetService(NS_IMPORTSERVICE_CONTRACTID); + NS_ASSERTION(impSvc, "cannot get importService"); nsCOMPtr rootFolder; nsXPIDLCString folderUri; @@ -391,10 +394,10 @@ nsresult nsMsgFilter::ConvertMoveToFolderValue(nsCString &moveValue) { PRInt32 prefixLen = PL_strlen(kImapPrefix); moveValue.Mid(m_action.m_originalServerPath, prefixLen, moveValue.Length() - prefixLen); - if ( filterVersion == k45Version) + if ( filterVersion == k45Version && impSvc) { nsAutoString unicodeStr; - unicodeStr.AssignWithConversion(m_action.m_originalServerPath.get()); + impSvc->SystemStringToUnicode(m_action.m_originalServerPath.get(), unicodeStr); char *utfNewName = CreateUtf7ConvertedStringFromUnicode(unicodeStr.get()); m_action.m_originalServerPath.Assign(utfNewName); nsCRT::free(utfNewName); @@ -460,10 +463,10 @@ nsresult nsMsgFilter::ConvertMoveToFolderValue(nsCString &moveValue) nsCRT::free(unescapedMoveValue); #endif destFolderUri.Append('/'); - if ( filterVersion == k45Version) + if ( filterVersion == k45Version && impSvc) { nsAutoString unicodeStr; - unicodeStr.AssignWithConversion(moveValue.get()); + impSvc->SystemStringToUnicode(moveValue.get(), unicodeStr); nsXPIDLCString escapedName; rv =NS_MsgEscapeEncodeURLPath(unicodeStr.get(), getter_Copies(escapedName)); if (NS_SUCCEEDED(rv) && escapedName) diff --git a/mailnews/base/search/src/nsMsgFilterList.cpp b/mailnews/base/search/src/nsMsgFilterList.cpp index 2a3f1f13ccdf..29ad4cc0ab31 100644 --- a/mailnews/base/search/src/nsMsgFilterList.cpp +++ b/mailnews/base/search/src/nsMsgFilterList.cpp @@ -33,7 +33,7 @@ #include "nsMsgUtils.h" #include "nsMsgSearchTerm.h" #include "nsXPIDLString.h" - +#include "nsIImportService.h" #include "nsMsgBaseCID.h" #include "nsIMsgFilterService.h" @@ -433,7 +433,7 @@ nsresult nsMsgFilterList::LoadTextFilters(nsIOFileStream *aStream) { nsresult err = NS_OK; nsMsgFilterFileAttribValue attrib; - + nsCOMPtr impSvc; // We'd really like to move lot's of these into the objects that they refer to. aStream->seek(PR_SEEK_SET, 0); do @@ -460,7 +460,12 @@ nsresult nsMsgFilterList::LoadTextFilters(nsIOFileStream *aStream) attrib = nsIMsgFilterList::attribNone; NS_ASSERTION(PR_FALSE, "error parsing filter file version"); } - break; + if (m_fileVersion == k45Version) + { + impSvc = do_GetService(NS_IMPORTSERVICE_CONTRACTID); + NS_ASSERTION(impSvc, "cannot get importService"); + } + break; case nsIMsgFilterList::attribLogging: m_loggingEnabled = StrToBool(value); break; @@ -473,11 +478,11 @@ nsresult nsMsgFilterList::LoadTextFilters(nsIOFileStream *aStream) break; } filter->SetFilterList(NS_STATIC_CAST(nsIMsgFilterList*,this)); - if (m_fileVersion == k45Version) + if (m_fileVersion == k45Version && impSvc) { - nsAutoString unicodeStr; - unicodeStr.AssignWithConversion(value.get()); - filter->SetFilterName(unicodeStr.get()); + nsAutoString unicodeStr; + impSvc->SystemStringToUnicode(value.get(), unicodeStr); + filter->SetFilterName(unicodeStr.get()); } else { @@ -534,10 +539,10 @@ nsresult nsMsgFilterList::LoadTextFilters(nsIOFileStream *aStream) case nsIMsgFilterList::attribCondition: if (m_curFilter) { - if ( m_fileVersion == k45Version) + if ( m_fileVersion == k45Version && impSvc) { nsAutoString unicodeStr; - unicodeStr.AssignWithConversion(value.get()); + impSvc->SystemStringToUnicode(value.get(), unicodeStr); char *utf8 = unicodeStr.ToNewUTF8String(); value.Assign(utf8); nsMemory::Free(utf8);