Added folderCharsetOverride to nsIMsgI18NUrl, implemented getter for each protocols, changed libmime to use it,

bug 39756, r=sspitzer, sr=bienvenu.
This commit is contained in:
nhotta%netscape.com 2001-01-12 21:56:47 +00:00
Родитель b25a2890b7
Коммит a11d58fa42
8 изменённых файлов: 141 добавлений и 63 удалений

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

@ -113,6 +113,7 @@ interface nsIMsgMessageUrl : nsISupports {
interface nsIMsgI18NUrl : nsISupports {
// the charset associated with a folder for this url.....
readonly attribute wstring folderCharset;
readonly attribute boolean folderCharsetOverride;
// the charsetOverRide is a charset the user may have specified via the menu for
// a particular message
attribute wstring charsetOverRide;

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

@ -1390,7 +1390,7 @@ void nsImapUrl::ParseListOfMessageIds()
// nsIMsgI18NUrl support
NS_IMETHODIMP nsImapUrl::GetFolderCharset(PRUnichar ** aCharacterSet)
nsresult nsImapUrl::GetMsgFolder(nsIMsgFolder **msgFolder)
{
// if we have a RDF URI, then try to get the folder for that URI and then ask the folder
// for it's charset....
@ -1405,13 +1405,33 @@ NS_IMETHODIMP nsImapUrl::GetFolderCharset(PRUnichar ** aCharacterSet)
NS_ENSURE_TRUE(resource, NS_ERROR_FAILURE);
nsCOMPtr<nsIMessage> msg (do_QueryInterface(resource));
NS_ENSURE_TRUE(msg, NS_ERROR_FAILURE);
nsresult rv = msg->GetMsgFolder(msgFolder);
NS_ENSURE_SUCCESS(rv,rv);
NS_ENSURE_TRUE(msgFolder, NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP nsImapUrl::GetFolderCharset(PRUnichar ** aCharacterSet)
{
nsCOMPtr<nsIMsgFolder> folder;
msg->GetMsgFolder(getter_AddRefs(folder));
nsresult rv = GetMsgFolder(getter_AddRefs(folder));
NS_ENSURE_SUCCESS(rv,rv);
NS_ENSURE_TRUE(folder, NS_ERROR_FAILURE);
folder->GetCharset(aCharacterSet);
return NS_OK;
}
NS_IMETHODIMP nsImapUrl::GetFolderCharsetOverride(PRBool * aCharacterSetOverride)
{
nsCOMPtr<nsIMsgFolder> folder;
nsresult rv = GetMsgFolder(getter_AddRefs(folder));
NS_ENSURE_SUCCESS(rv,rv);
NS_ENSURE_TRUE(folder, NS_ERROR_FAILURE);
folder->GetCharsetOverride(aCharacterSetOverride);
return NS_OK;
}
NS_IMETHODIMP nsImapUrl::GetCharsetOverRide(PRUnichar ** aCharacterSet)
{
if (!mCharsetOverride.IsEmpty())

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

@ -84,6 +84,8 @@ protected:
void ParseMsgFlags();
void ParseListOfMessageIds();
nsresult GetMsgFolder(nsIMsgFolder **msgFolder);
char *m_sourceCanonicalFolderPathSubString;
char *m_destinationCanonicalFolderPathSubString;
char *m_tokenPlaceHolder;

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

@ -428,7 +428,7 @@ char * extractAttributeValue(const char * searchString, const char * attributeNa
// nsIMsgI18NUrl support
NS_IMETHODIMP nsMailboxUrl::GetFolderCharset(PRUnichar ** aCharacterSet)
nsresult nsMailboxUrl::GetMsgFolder(nsIMsgFolder **msgFolder)
{
// if we have a RDF URI, then try to get the folder for that URI and then ask the folder
// for it's charset....
@ -443,13 +443,34 @@ NS_IMETHODIMP nsMailboxUrl::GetFolderCharset(PRUnichar ** aCharacterSet)
NS_ENSURE_TRUE(resource, NS_ERROR_FAILURE);
nsCOMPtr<nsIMessage> msg (do_QueryInterface(resource));
NS_ENSURE_TRUE(msg, NS_ERROR_FAILURE);
nsresult rv = msg->GetMsgFolder(getter_AddRefs(msgFolder));
NS_ENSURE_SUCCESS(rv,rv);
NS_ENSURE_TRUE(msgFolder, NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP nsMailboxUrl::GetFolderCharset(PRUnichar ** aCharacterSet)
{
nsCOMPtr<nsIMsgFolder> folder;
msg->GetMsgFolder(getter_AddRefs(folder));
nsresult rv = GetMsgFolder(getter_AddRefs(folder));
NS_ENSURE_SUCCESS(rv,rv);
NS_ENSURE_TRUE(folder, NS_ERROR_FAILURE);
folder->GetCharset(aCharacterSet);
return NS_OK;
}
NS_IMETHODIMP nsMailboxUrl::GetFolderCharsetOverride(PRBool * aCharacterSetOverride)
{
nsCOMPtr<nsIMsgFolder> folder;
nsresult rv = GetMsgFolder(getter_AddRefs(folder));
NS_ENSURE_SUCCESS(rv,rv);
NS_ENSURE_TRUE(folder, NS_ERROR_FAILURE);
folder->GetCharsetOverride(aCharacterSetOverride);
return NS_OK;
}
NS_IMETHODIMP nsMailboxUrl::GetCharsetOverRide(PRUnichar ** aCharacterSet)
{
if (!mCharsetOverride.IsEmpty())

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

@ -79,6 +79,8 @@ protected:
PRBool m_canonicalLineEnding;
nsresult ParseSearchPart();
nsresult GetMsgFolder(nsIMsgFolder **msgFolder);
// truncated message support
nsXPIDLCString m_originalSpec;
nsCString mURI; // the RDF URI associated with this url.

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

@ -164,6 +164,16 @@ bridge_new_new_uri(void *bridgeStream, nsIURI *aURI, PRInt32 aOutputType)
if (NS_SUCCEEDED(rv) && !charset.IsEmpty() )
*override_charset = charset.ToNewCString();
// if there is no manual override and a folder charset exists
// then check if we have a folder level override
if (!(*override_charset) && *default_charset && **default_charset)
{
PRBool folderCharsetOverride;
rv = i18nUrl->GetFolderCharsetOverride(&folderCharsetOverride);
if (NS_SUCCEEDED(rv) && folderCharsetOverride)
*override_charset = nsCRT::strdup(*default_charset);
}
// if the pref says always override and no manual override then set the folder charset to override
// in future, the override flag to be per folder instead of a global pref
if (charset.IsEmpty()) {

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

@ -432,69 +432,89 @@ nsNntpUrl::SetOriginalSpec(const char *aSpec)
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult nsNntpUrl::GetMsgFolder(nsIMsgFolder **msgFolder)
{
/*
well, not proud of this. but it will all get fixed when
the news code gets the beating it deserves.
ideally, we'd keep a weak reference to the current news folder
and just use that to determine the char set, but for now
we'll just get the folder from the url we are running.
this code takes the current uri, which is for a news message
and turns it into a news folder uri,
and then get the folder for that URI, and the ask the folder
for it's charset....
*/
nsresult rv;
nsXPIDLCString uriStr;
rv = GetUri(getter_Copies(uriStr));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIURI> uri = do_CreateInstance("@mozilla.org/network/standard-url;1", &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = uri->SetSpec((const char *)uriStr);
NS_ENSURE_SUCCESS(rv,rv);
// XXX todo?
// could the url already be a folder url?
//
// get the path, check for @ or %40. if has them,
// this is an article url, and we need to replace
// the path with the newsgroup name.
// for now, assume it is always an article url
if (!((const char *)m_newsgroupName)) {
NS_ASSERTION(NS_ERROR_FAILURE,"no group name");
return NS_ERROR_FAILURE;
}
nsCAutoString groupPath("/");
groupPath += m_newsgroupName;
rv = uri->SetPath((const char *)groupPath);
NS_ENSURE_SUCCESS(rv,rv);
rv = uri->GetSpec(getter_Copies(uriStr));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIRDFService> rdfService = do_GetService(NS_RDF_CONTRACTID "/rdf-service;1", &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIRDFResource> resource;
rv = rdfService->GetResource((const char *)uriStr, getter_AddRefs(resource));
NS_ENSURE_SUCCESS(rv,rv);
rv = resource->QueryInterface(NS_GET_IID(nsIMsgFolder), (void**) msgFolder);
NS_ENSURE_SUCCESS(rv,rv);
return rv;
}
NS_IMETHODIMP
nsNntpUrl::GetFolderCharset(PRUnichar ** aCharacterSet)
{
/*
well, not proud of this. but it will all get fixed when
the news code gets the beating it deserves.
nsCOMPtr<nsIMsgFolder> folder;
nsresult rv = GetMsgFolder(getter_AddRefs(folder));
NS_ENSURE_SUCCESS(rv,rv);
NS_ENSURE_TRUE(folder, NS_ERROR_FAILURE);
rv = folder->GetCharset(aCharacterSet);
NS_ENSURE_SUCCESS(rv,rv);
return rv;
}
ideally, we'd keep a weak reference to the current news folder
and just use that to determine the char set, but for now
we'll just get the folder from the url we are running.
this code takes the current uri, which is for a news message
and turns it into a news folder uri,
and then get the folder for that URI, and the ask the folder
for it's charset....
*/
nsresult rv;
nsXPIDLCString uriStr;
rv = GetUri(getter_Copies(uriStr));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIURI> uri = do_CreateInstance("@mozilla.org/network/standard-url;1", &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = uri->SetSpec((const char *)uriStr);
NS_ENSURE_SUCCESS(rv,rv);
// XXX todo?
// could the url already be a folder url?
//
// get the path, check for @ or %40. if has them,
// this is an article url, and we need to replace
// the path with the newsgroup name.
// for now, assume it is always an article url
if (!((const char *)m_newsgroupName)) {
NS_ASSERTION(NS_ERROR_FAILURE,"no group name");
return NS_ERROR_FAILURE;
}
nsCAutoString groupPath("/");
groupPath += m_newsgroupName;
rv = uri->SetPath((const char *)groupPath);
NS_ENSURE_SUCCESS(rv,rv);
rv = uri->GetSpec(getter_Copies(uriStr));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIRDFService> rdfService = do_GetService(NS_RDF_CONTRACTID "/rdf-service;1", &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIRDFResource> resource;
rv = rdfService->GetResource((const char *)uriStr, getter_AddRefs(resource));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(resource, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = folder->GetCharset(aCharacterSet);
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
NS_IMETHODIMP nsNntpUrl::GetFolderCharsetOverride(PRBool * aCharacterSetOverride)
{
nsCOMPtr<nsIMsgFolder> folder;
nsresult rv = GetMsgFolder(getter_AddRefs(folder));
NS_ENSURE_SUCCESS(rv,rv);
NS_ENSURE_TRUE(folder, NS_ERROR_FAILURE);
rv = folder->GetCharsetOverride(aCharacterSetOverride);
NS_ENSURE_SUCCESS(rv,rv);
return rv;
}
NS_IMETHODIMP nsNntpUrl::GetCharsetOverRide(PRUnichar ** aCharacterSet)

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

@ -56,6 +56,8 @@ protected:
PRBool m_addDummyEnvelope;
PRBool m_canonicalLineEnding;
nsresult GetMsgFolder(nsIMsgFolder **msgFolder);
/* NNTP specific event sinks */
nsINNTPHost * m_newsHost;
nsINNTPArticleList * m_articleList;