fix i18n sorting of sender

git-svn-id: svn://10.0.0.236/trunk@43461 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bienvenu%netscape.com
1999-08-18 04:05:57 +00:00
parent 53fb20e6e2
commit 290a132e15
5 changed files with 57 additions and 5 deletions

View File

@@ -73,6 +73,8 @@ public:
NS_IMETHOD SetImapUnreadPendingMessages(PRInt32 unreadPending) ;
NS_IMETHOD GetCharacterSet(nsString *result) ;
NS_IMETHOD SetCharacterSet(nsString *charSet) ;
NS_IMETHOD GetCharPtrCharacterSet(char **result);
NS_IMETHOD GetLocale(nsString *result) ;
NS_IMETHOD SetLocale(nsString *locale) ;
@@ -94,6 +96,7 @@ public:
NS_IMETHOD GetProperty(const char *propertyName, nsString *resultProperty);
NS_IMETHOD SetProperty(const char *propertyName, nsString *propertyStr);
NS_IMETHOD GetCharPtrProperty(const char *propertyName, char **resultProperty);
NS_IMETHOD SetUint32Property(const char *propertyName, PRUint32 propertyValue);
NS_IMETHOD GetUint32Property(const char *propertyName, PRUint32 *propertyValue);

View File

@@ -53,6 +53,9 @@ interface nsIDBFolderInfo : nsISupports {
[noscript] void GetCharacterSet(in nsString result);
[noscript] void SetCharacterSet(in nsString result);
void GetCharPtrCharacterSet(out string result);
[noscript] void GetLocale(in nsString result);
[noscript] void SetLocale(in nsString locale);

View File

@@ -533,8 +533,13 @@ PRBool nsDBFolderInfo::TestFlag(PRInt32 flags)
NS_IMETHODIMP
nsDBFolderInfo::GetCharacterSet(nsString *result)
{
GetProperty(kCharacterSetColumnName, result);
return NS_OK;
return GetProperty(kCharacterSetColumnName, result);
}
NS_IMETHODIMP
nsDBFolderInfo::GetCharPtrCharacterSet(char **result)
{
return GetCharPtrProperty(kCharacterSetColumnName, result);
}
NS_IMETHODIMP nsDBFolderInfo::SetCharacterSet(nsString *charSet)
@@ -636,6 +641,22 @@ NS_IMETHODIMP nsDBFolderInfo::GetProperty(const char *propertyName, nsString *re
return err;
}
// Caller must PR_FREEIF resultProperty.
NS_IMETHODIMP nsDBFolderInfo::GetCharPtrProperty(const char *propertyName, char **resultProperty)
{
nsresult err = NS_OK;
mdb_token property_token;
if (!resultProperty)
return NS_ERROR_NULL_POINTER;
err = m_mdb->GetStore()->StringToToken(m_mdb->GetEnv(), propertyName, &property_token);
if (err == NS_OK)
err = m_mdb->RowCellColumnToCharPtr(m_mdbRow, property_token, resultProperty);
return err;
}
NS_IMETHODIMP nsDBFolderInfo::SetUint32Property(const char *propertyName, PRUint32 propertyValue)
{
struct mdbYarn yarn;

View File

@@ -2195,6 +2195,7 @@ nsresult nsMsgDatabase::CharPtrToRowCellColumn(nsIMdbRow *row, mdb_token columnT
return row->AddColumn(GetEnv(), columnToken, &yarn);
}
// caller must PR_FREEIF result
nsresult nsMsgDatabase::RowCellColumnToCharPtr(nsIMdbRow *row, mdb_token columnToken, char **result)
{
nsresult err = NS_ERROR_NULL_POINTER;
@@ -2215,6 +2216,8 @@ nsresult nsMsgDatabase::RowCellColumnToCharPtr(nsIMdbRow *row, mdb_token columnT
hdrCell->CutStrongRef(GetEnv()); // always release ref
}
else if (err == NS_OK) // guarantee a non-null result
*result = nsCRT::strdup("");
}
return err;
}

View File

@@ -21,9 +21,12 @@
#include "nsMsgDatabase.h"
#include "nsMsgUtils.h"
#include "nsIMsgHeaderParser.h"
#include "nsIMimeConverter.h"
NS_IMPL_ISUPPORTS(nsMsgHdr, nsIMsgDBHdr::GetIID())
static NS_DEFINE_CID(kCMimeConverterCID, NS_MIME_CONVERTER_CID);
nsMsgHdr::nsMsgHdr(nsMsgDatabase *db, nsIMdbRow *dbRow)
{
NS_INIT_REFCNT();
@@ -507,9 +510,28 @@ NS_IMETHODIMP nsMsgHdr::GetAuthorCollationKey(nsString *resultAuthor)
nsIMsgHeaderParser *headerParser = m_mdb->GetHeaderParser();
if (headerParser)
{
//XXXOnce we get the csid, use Intl version
if(NS_SUCCEEDED(ret = headerParser->ExtractHeaderAddressName (nsnull, cSender, &name)))
*resultAuthor = name;
// apply mime decode
nsIMimeConverter *converter;
ret = nsComponentManager::CreateInstance(kCMimeConverterCID, nsnull,
nsIMimeConverter::GetIID(), (void **)&converter);
if (NS_SUCCEEDED(ret) && nsnull != converter)
{
char *resultStr = nsnull;
char *charset = nsnull;
m_mdb->m_dbFolderInfo->GetCharPtrCharacterSet(&charset);
char charsetName[128];
PL_strncpy(charsetName, charset, sizeof(charsetName));
ret = converter->DecodeMimePartIIStr(cSender.GetBuffer(), charsetName, &resultStr);
if (NS_SUCCEEDED(ret))
{
ret = headerParser->ExtractHeaderAddressName (charsetName, resultStr, &name);
}
NS_RELEASE(converter);
PR_FREEIF(resultStr);
PR_FREEIF(charset);
}
}
}