fix for #24626. when viewing a cancelled message, display the "error"
in the message pane like we did in 4.x. add the code to display random html in the message pane to nsMsgWindow, so bienvenu can use it for offline imap. known problems: title isn't being set and headers aren't being hidden. but that's next. sr=bienvenu. git-svn-id: svn://10.0.0.236/trunk@83824 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -44,8 +44,10 @@ interface nsIMsgWindow : nsISupports {
|
||||
attribute nsIMessageView messageView;
|
||||
attribute nsIMsgFolder openFolder;
|
||||
attribute nsIDocShell rootDocShell;
|
||||
void displayHTMLInMessageWindow(in wstring title, in wstring body);
|
||||
|
||||
readonly attribute nsIPrompt promptDialog;
|
||||
attribute wstring mailCharacterSet;
|
||||
attribute wstring mailCharacterSet;
|
||||
|
||||
void SetDOMWindow(in nsIDOMWindowInternal window);
|
||||
void StopUrls();
|
||||
|
||||
@@ -42,6 +42,10 @@
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsICharsetConverterManager2.h"
|
||||
|
||||
#include "plbase64.h"
|
||||
#include "nsMsgI18N.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
|
||||
// XXX Remove
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
@@ -495,3 +499,49 @@ NS_IMETHODIMP nsMsgWindow::GetPromptDialog(nsIPrompt **aPrompt)
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgWindow::DisplayHTMLInMessageWindow(const PRUnichar *title, const PRUnichar *body)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCAutoString charSet;
|
||||
charSet.AssignWithConversion(nsMsgI18NFileSystemCharset());
|
||||
|
||||
nsAutoString htmlStr;
|
||||
htmlStr.Append(NS_LITERAL_STRING("<html><head>").get());
|
||||
htmlStr.Append(NS_LITERAL_STRING("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=").get());
|
||||
htmlStr.AppendWithConversion(charSet);
|
||||
htmlStr.Append(NS_LITERAL_STRING("\">").get());
|
||||
htmlStr.Append(NS_LITERAL_STRING("</head><body>").get());
|
||||
htmlStr.Append(body);
|
||||
htmlStr.Append(NS_LITERAL_STRING("</body></html>").get());
|
||||
|
||||
nsCAutoString convertedHtml;
|
||||
rv = nsMsgI18NConvertFromUnicode(charSet,htmlStr,convertedHtml);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
char *encodedHtml = PL_Base64Encode((const char *)convertedHtml, 0, nsnull);
|
||||
if (!encodedHtml) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCAutoString dataSpec;
|
||||
dataSpec = "data:text/html;base64,";
|
||||
dataSpec += encodedHtml;
|
||||
|
||||
PR_FREEIF(encodedHtml);
|
||||
|
||||
nsCOMPtr <nsIURI> uri = do_CreateInstance("@mozilla.org/network/simple-uri;1");
|
||||
if (!uri) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = uri->SetSpec((const char *)dataSpec);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr <nsIDocShell> docShell;
|
||||
GetMessageWindowDocShell(getter_AddRefs(docShell));
|
||||
if (!docShell) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = docShell->LoadURI(uri,nsnull,nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@ downloadHeadersTitlePrefix=Download Headers
|
||||
downloadHeadersInfoText1=There are
|
||||
# LOCALIZATION NOTE ( downloadHeadersInfoText2 ): See note for downloadHeadersInfoText1
|
||||
downloadHeadersInfoText2=new message headers to download for this newsgroup.
|
||||
htmlNewsErrorTitle=Error!
|
||||
# LOCALIZATION NOTE ( htmlNewsError ): In the following item, translate only "Error!" and "newsgroup server responded:"
|
||||
htmlNewsError=<TITLE>Error!</TITLE>\n<H1>Error!</H1> newsgroup server responded: <b>%.256s</b><p>\n
|
||||
htmlNewsError=<H1>Error!</H1>newsgroup server responded:
|
||||
# LOCALIZATION NOTE ( articleExpired ): In the following item, translate only "Perhaps the article has expired"
|
||||
articleExpired=<b><p>Perhaps the article has expired</b><p>\n
|
||||
articleExpired=<B><P>Perhaps the article has expired</P></B>
|
||||
removeExpiredArtLinkText=Click here to remove all expired articles
|
||||
cancelDisallowed=This message does not appear to be from you. You may only cancel your own posts, not those made by others.
|
||||
cancelConfirm=Are you sure you want to cancel this message?
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
* David Bienvenu <bienvenu@netscape.com>
|
||||
* Jeff Tsai <jefft@netscape.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#define FORCE_PR_LOG /* Allow logging in the release build (sorry this breaks the PCH) */
|
||||
@@ -1990,45 +1989,61 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse()
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && group_name) {
|
||||
// the right thing todo is:
|
||||
// get the right docshell, gotten from the nsIMsgWindow
|
||||
// build up a data url
|
||||
// call (docshell)->LoadURL() with that data url
|
||||
#ifdef NOT_WORKING_YET
|
||||
char outputBuffer[OUTPUT_BUFFER_SIZE];
|
||||
PRUint32 count = 0;
|
||||
|
||||
nsXPIDLString titleStr;
|
||||
rv = GetNewsStringByName("htmlNewsErrorTitle", getter_Copies(titleStr));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsXPIDLString newsErrorStr;
|
||||
GetNewsStringByName("htmlNewsError", getter_Copies(newsErrorStr));
|
||||
nsCAutoString cString(newsErrorStr);
|
||||
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE, (const char *) cString, m_responseText);
|
||||
mDisplayOutputStream->Write(outputBuffer, PL_strlen(outputBuffer), &count);
|
||||
|
||||
GetNewsStringByName("articleExpired", getter_Copies(newsErrorStr));
|
||||
nsCAutoString cString2(newsErrorStr);
|
||||
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE, (const char *) cString2);
|
||||
mDisplayOutputStream->Write(outputBuffer, PL_strlen(outputBuffer), &count);
|
||||
rv = GetNewsStringByName("htmlNewsError", getter_Copies(newsErrorStr));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
nsAutoString errorHtml;
|
||||
errorHtml.Append(newsErrorStr);
|
||||
|
||||
errorHtml.Append(NS_LITERAL_STRING("<b>").get());
|
||||
errorHtml.AppendWithConversion(m_responseText);
|
||||
errorHtml.Append(NS_LITERAL_STRING("</b><p>").get());
|
||||
|
||||
rv = GetNewsStringByName("articleExpired", getter_Copies(newsErrorStr));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
errorHtml.Append(newsErrorStr);
|
||||
|
||||
nsMsgKey key = nsMsgKey_None;
|
||||
rv = m_runningURL->GetMessageKey(&key);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
char outputBuffer[OUTPUT_BUFFER_SIZE];
|
||||
|
||||
NS_ASSERTION(m_messageID && (key != nsMsgKey_None), "unexpected");
|
||||
if (m_messageID && (key != nsMsgKey_None)) {
|
||||
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE,"<P><%.512s> (%lu)", m_messageID, key);
|
||||
mDisplayOutputStream->Write(outputBuffer, PL_strlen(outputBuffer), &count);
|
||||
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE,"<P><%.512s> (%lu)", m_messageID, key);
|
||||
errorHtml.AppendWithConversion(outputBuffer);
|
||||
}
|
||||
|
||||
GetNewsStringByName("removeExpiredArtLinkText", getter_Copies(newsErrorStr));
|
||||
nsCAutoString cString3(newsErrorStr);
|
||||
if (m_userName) {
|
||||
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE,"<P> <A HREF=\"%s/%s@%s/%s?list-ids\">%s</A> </P>\n", kNewsRootURI, (const char *)m_userName, (const char *)m_hostName,
|
||||
(const char *) group_name, (const char *) cString3);
|
||||
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE,"<P> <A HREF=\"%s/%s@%s/%s?list-ids\">", kNewsRootURI, (const char *)m_userName, (const char *)m_hostName,
|
||||
(const char *) group_name);
|
||||
}
|
||||
else {
|
||||
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE,"<P> <A HREF=\"%s/%s/%s?list-ids\">%s</A> </P>\n", kNewsRootURI, (const char *)m_hostName,
|
||||
(const char *) group_name, (const char *) cString3);
|
||||
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE,"<P> <A HREF=\"%s/%s/%s?list-ids\">", kNewsRootURI, (const char *)m_hostName, (const char *) group_name);
|
||||
}
|
||||
mDisplayOutputStream->Write(outputBuffer, PL_strlen(outputBuffer), &count);
|
||||
#endif /* NOT_WORKING_YET */
|
||||
|
||||
errorHtml.AppendWithConversion(outputBuffer);
|
||||
|
||||
rv = GetNewsStringByName("removeExpiredArtLinkText", getter_Copies(newsErrorStr));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
errorHtml.Append(newsErrorStr);
|
||||
errorHtml.Append(NS_LITERAL_STRING("</A> </P>").get());
|
||||
|
||||
if (!m_msgWindow) {
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
|
||||
if (mailnewsurl) {
|
||||
rv = mailnewsurl->GetMsgWindow(getter_AddRefs(m_msgWindow));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
}
|
||||
if (!m_msgWindow) return NS_ERROR_FAILURE;
|
||||
rv = m_msgWindow->DisplayHTMLInMessageWindow((const PRUnichar *)titleStr, errorHtml.GetUnicode());
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
return MK_NNTP_SERVER_ERROR;
|
||||
}
|
||||
@@ -4581,6 +4596,7 @@ PRInt32 nsNNTPProtocol::ListGroup()
|
||||
char outputBuffer[OUTPUT_BUFFER_SIZE];
|
||||
PRInt32 status = 0;
|
||||
rv = m_newsgroup->GetName(getter_Copies(group_name));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PR_snprintf(outputBuffer,
|
||||
OUTPUT_BUFFER_SIZE,
|
||||
@@ -4590,9 +4606,10 @@ PRInt32 nsNNTPProtocol::ListGroup()
|
||||
nsnull,
|
||||
NS_GET_IID(nsINNTPArticleList),
|
||||
getter_AddRefs(m_articleList));
|
||||
if (NS_FAILED(rv)) return -1; // ???
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
m_articleList->Initialize(m_newsHost, m_newsgroup);
|
||||
rv = m_articleList->Initialize(m_newsHost, m_newsgroup);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
|
||||
if (mailnewsurl)
|
||||
|
||||
Reference in New Issue
Block a user