Added mailCharacterSet to nsIMsgWindow to keep the charset used by libmime, bug 28869, r=mscott.

This commit is contained in:
nhotta%netscape.com 2000-07-11 23:51:21 +00:00
parent b8bd1adb30
commit fbd57efd15
3 changed files with 36 additions and 0 deletions

View File

@ -45,6 +45,7 @@ interface nsIMsgWindow : nsISupports {
attribute nsIMsgFolder openFolder;
attribute nsIDocShell rootDocShell;
readonly attribute nsIPrompt promptDialog;
attribute wstring mailCharacterSet;
void SetDOMWindow(in nsIDOMWindow window);
void StopUrls();

View File

@ -39,6 +39,8 @@
#include "nsIWebProgressListener.h"
#include "nsPIDOMWindow.h"
#include "nsIPrompt.h"
#include "nsICharsetConverterManager.h"
#include "nsICharsetConverterManager2.h"
// XXX Remove
#include "nsIWebShell.h"
@ -230,6 +232,37 @@ NS_IMETHODIMP nsMsgWindow::SetRootDocShell(nsIDocShell * aDocShell)
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::GetMailCharacterSet(PRUnichar * *aMailCharacterSet)
{
if(!aMailCharacterSet)
return NS_ERROR_NULL_POINTER;
*aMailCharacterSet = mMailCharacterSet.ToNewUnicode();
if (!(*aMailCharacterSet))
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::SetMailCharacterSet(const PRUnichar * aMailCharacterSet)
{
mMailCharacterSet.Assign(aMailCharacterSet);
// Convert to a canonical charset name instead of using the charset name from the message header as is.
// This is needed for charset menu item to have a check mark correctly.
nsresult rv;
nsCOMPtr<nsICharsetConverterManager2> ccm2 = do_GetService(NS_CHARSETCONVERTERMANAGER_PROGID, &rv);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr <nsIAtom> charsetAtom;
rv = ccm2->GetCharsetAtom(mMailCharacterSet.GetUnicode(), getter_AddRefs(charsetAtom));
if (NS_SUCCEEDED(rv))
rv = charsetAtom->ToString(mMailCharacterSet);
}
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::SetDOMWindow(nsIDOMWindow *aWindow)
{
if (!aWindow)

View File

@ -57,6 +57,8 @@ protected:
// let's not make this a strong ref - we don't own it.
nsIDocShell *mRootDocShell;
nsIDocShell *mMessageWindowDocShell;
nsString mMailCharacterSet;
};
#endif