Bug 492329 - Polish the error message for an expired newsgroup article. r=Neil,jorgk

This commit is contained in:
Jim Porter 2017-06-24 22:24:56 +02:00
Родитель 213c6d6a2b
Коммит f5abac4a7c
13 изменённых файлов: 209 добавлений и 70 удалений

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

@ -17,6 +17,8 @@ AboutRedirector.prototype = {
// value as a record with url and flags entries. Note that each addition here
// should be coupled with a corresponding addition in mailComponents.manifest.
_redirMap: {
"newserror": {url: "chrome://messenger/content/newsError.xhtml",
flags: Ci.nsIAboutModule.ALLOW_SCRIPT},
"rights": {url: "chrome://messenger/content/aboutRights.xhtml",
flags: (Ci.nsIAboutModule.ALLOW_SCRIPT |
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT)},

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

@ -1,6 +1,7 @@
component {8cc51368-6aa0-43e8-b762-bde9b9fd828c} aboutRedirector.js
# Each addition here should be coupled with a corresponding addition in
# aboutRedirector.js.
contract @mozilla.org/network/protocol/about;1?what=newserror {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
contract @mozilla.org/network/protocol/about;1?what=rights {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
contract @mozilla.org/network/protocol/about;1?what=support {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
contract @mozilla.org/network/protocol/about;1?what=preferences {8cc51368-6aa0-43e8-b762-bde9b9fd828c}

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

@ -3,12 +3,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
downloadHeadersTitlePrefix=Download Headers
downloadHeadersInfoText=There are %S 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=<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</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?
messageCancelled=Message cancelled.

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

@ -0,0 +1,31 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!-- LOCALIZATION NOTE (newsError.title): The title of the news error page.
Not generally visible. -->
<!ENTITY newsError.title "Problem Loading Article">
<!-- LOCALIZATION NOTE (articleNotFound.title): The main heading for the news
error page. -->
<!ENTITY articleNotFound.title "Article not found">
<!-- LOCALIZATION NOTE (articleNotFound.desc): A longer description for the news
error page. -->
<!ENTITY articleNotFound.desc "The newsgroup server reports that it can't find the article.">
<!-- LOCALIZATION NOTE (serverResponded.title): A string preceding the text
response from the newsgroup server describing the error. -->
<!ENTITY serverResponded.title "Newsgroup server responded:">
<!-- LOCALIZATION NOTE (articleExpired.title): A string explaining that the
article may have expired. -->
<!ENTITY articleExpired.title "Perhaps the article has expired?">
<!-- LOCALIZATION NOTE (trySearching.title): A string preceding the message's
ID. -->
<!ENTITY trySearching.title "Try searching for article:">
<!-- LOCALIZATION NOTE (removeExpiredArticles.title): The label for the button
to remove all expired articles from the newsgroup. -->
<!ENTITY removeExpiredArticles.title "Remove All Expired Articles">

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

@ -189,6 +189,7 @@
locale/@AB_CD@/messenger/activity.properties (%chrome/messenger/activity.properties)
locale/@AB_CD@/messenger/downloads/settingsChange.dtd (%chrome/overrides/settingsChange.dtd)
locale/@AB_CD@/messenger/netError.dtd (%chrome/overrides/netError.dtd)
locale/@AB_CD@/messenger/newsError.dtd (%chrome/messenger/newsError.dtd)
locale/@AB_CD@/messenger/downloadsOverlay.dtd (%chrome/messenger/downloadsOverlay.dtd)
locale/@AB_CD@/messenger/chat.dtd (%chrome/messenger/chat.dtd)
locale/@AB_CD@/messenger/chat.properties (%chrome/messenger/chat.properties)

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

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html [
<!ENTITY % htmlDTD
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
%htmlDTD;
<!ENTITY % netErrorDTD
SYSTEM "chrome://messenger/locale/newsError.dtd">
%netErrorDTD;
<!ENTITY % globalDTD
SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>&newsError.title;</title>
<link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all" />
<!-- If the location of the favicon is changed here, the FAVICON_ERRORPAGE_URL symbol in
toolkit/components/places/src/nsFaviconService.h should be updated. -->
<link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/warning-16.png"/>
<script type="application/javascript;version=1.8"><![CDATA[
// Error url must be formatted like this:
// about:newserror?r=response&m=messageid&k=messagekey&f=folderuri
// "r" is required; "m" and "f" are optional, but "k" always comes with "m".
var folderUri;
function removeExpired() {
document.location.href = folderUri + "?list-ids";
}
function initPage() {
let uri = document.documentURI;
let query = uri.slice(uri.indexOf("?")+1);
let params = {};
for (let [,piece] in Iterator(query.split("&"))) {
let [key, value] = piece.split("=");
params[key] = decodeURIComponent(value);
}
document.getElementById("ngResp").textContent = params.r;
if ("m" in params) {
document.getElementById("msgId").textContent = params.m;
document.getElementById("msgKey").textContent = params.k;
} else {
document.getElementById("messageIdDesc").hidden = true;
}
if ("f" in params) {
folderUri = params.f;
} else {
document.getElementById("errorTryAgain").hidden = true;
}
}
]]></script>
</head>
<body dir="&locale.dir;">
<div id="errorPageContainer">
<div id="errorTitle">
<h1 id="errorTitleText">&articleNotFound.title;</h1>
</div>
<div id="errorLongContent">
<div id="errorShortDesc">
<p id="errorShortDescText"><b>&articleNotFound.desc;</b></p>
</div>
<div id="errorLongDesc">
<ul>
<li>&serverResponded.title; <span id="ngResp"/></li>
<li>&articleExpired.title;</li>
<li id="messageIdDesc">&trySearching.title; &lt;<span id="msgId"/>&gt; (<span id="msgKey"/>)</li>
</ul>
</div>
</div>
<!-- This button really means "remove all expired articles", but we use
the "errorTryAgain" id to piggyback on toolkit's CSS. -->
<button id="errorTryAgain"
onclick="removeExpired();">&removeExpiredArticles.title;</button>
</div>
<script type="application/javascript">initPage();</script>
</body>
</html>

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

@ -14,6 +14,7 @@ interface nsIMsgHeaderSink;
interface nsIPrompt;
interface nsIInterfaceRequestor;
interface nsIAuthPrompt;
interface nsIPrincipal;
[scriptable, uuid(7B8F4A65-CFC4-4b3f-BF5C-152AA8D5CD10)]
interface nsIMsgWindowCommands : nsISupports {
@ -56,7 +57,9 @@ interface nsIMsgWindow : nsISupports {
* protocol channels to handle things like bad cert exceptions.
*/
attribute nsIInterfaceRequestor notificationCallbacks;
void displayURIInMessagePane(in wstring uri, in boolean clearMsgHdr, in nsIPrincipal principal);
void displayHTMLInMessagePane(in AString title, in AString body, in boolean clearMsgHdr);
readonly attribute nsIPrompt promptDialog;

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

@ -250,19 +250,19 @@ NS_IMETHODIMP nsMsgWindow::SetRootDocShell(nsIDocShell * aDocShell)
nsCOMPtr<nsIWebProgressListener> contentPolicyListener =
do_GetService(NS_MSGCONTENTPOLICY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// remove the content policy webProgressListener from the root doc shell
// we're currently holding, so we don't keep listening for loads that
// we don't care about
if (mRootDocShellWeak) {
nsCOMPtr<nsIWebProgress> oldWebProgress =
nsCOMPtr<nsIWebProgress> oldWebProgress =
do_QueryReferent(mRootDocShellWeak, &rv);
if (NS_SUCCEEDED(rv)) {
rv = oldWebProgress->RemoveProgressListener(contentPolicyListener);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to remove old progress listener");
}
}
}
// Query for the doc shell and release it
mRootDocShellWeak = nullptr;
if (aDocShell)
@ -274,13 +274,13 @@ NS_IMETHODIMP nsMsgWindow::SetRootDocShell(nsIDocShell * aDocShell)
nsCOMPtr<nsIURIContentListener> listener(do_GetInterface(messagePaneDocShell));
if (listener)
listener->SetParentContentListener(this);
// set the contentPolicy webProgressListener on the root docshell for this
// window so that it can allow JavaScript for non-message content
nsCOMPtr<nsIWebProgress> docShellProgress =
nsCOMPtr<nsIWebProgress> docShellProgress =
do_QueryInterface(aDocShell, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = docShellProgress->AddProgressListener(contentPolicyListener,
nsIWebProgress::NOTIFY_LOCATION);
NS_ENSURE_SUCCESS(rv, rv);
@ -500,11 +500,26 @@ NS_IMETHODIMP nsMsgWindow::SetPromptDialog(nsIPrompt* aPromptDialog)
}
NS_IMETHODIMP
nsMsgWindow::DisplayHTMLInMessagePane(const nsAString& title, const nsAString& body, bool clearMsgHdr)
nsMsgWindow::DisplayURIInMessagePane(const char16_t *uri, bool clearMsgHdr, nsIPrincipal *principal)
{
if (clearMsgHdr && mMsgWindowCommands)
mMsgWindowCommands->ClearMsgPane();
nsCOMPtr <nsIDocShell> docShell;
GetMessageWindowDocShell(getter_AddRefs(docShell));
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
return webNav->LoadURI(uri, nsIWebNavigation::LOAD_FLAGS_NONE,
nullptr, nullptr, nullptr,
principal);
}
NS_IMETHODIMP
nsMsgWindow::DisplayHTMLInMessagePane(const nsAString& title, const nsAString& body, bool clearMsgHdr)
{
nsString htmlStr;
htmlStr.Append(NS_LITERAL_STRING("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>"));
htmlStr.Append(body);
@ -520,22 +535,13 @@ nsMsgWindow::DisplayHTMLInMessagePane(const nsAString& title, const nsAString& b
PR_FREEIF(encodedHtml);
nsCOMPtr <nsIDocShell> docShell;
GetMessageWindowDocShell(getter_AddRefs(docShell));
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
nsresult rv;
nsCOMPtr<nsIPrincipal> nullPrincipal =
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
return webNav->LoadURI(NS_ConvertASCIItoUTF16(dataSpec).get(),
nsIWebNavigation::LOAD_FLAGS_NONE,
nullptr, nullptr, nullptr,
nullPrincipal);
return DisplayURIInMessagePane(NS_ConvertASCIItoUTF16(dataSpec).get(),
clearMsgHdr, nullPrincipal);
}
NS_IMPL_GETSET(nsMsgWindow, Stopped, bool, m_stopped)

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

@ -117,6 +117,7 @@ messenger.jar:
content/messenger/dateFormat.js (base/content/dateFormat.js)
content/messenger/shutdownWindow.xul (base/content/shutdownWindow.xul)
content/messenger/shutdownWindow.js (base/content/shutdownWindow.js)
content/messenger/newsError.xhtml (base/content/newsError.xhtml)
#ifndef XP_MACOSX
content/messenger/newmailalert.css (base/content/newmailalert.css)
content/messenger/newmailalert.js (base/content/newmailalert.js)

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

@ -29,6 +29,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/Services.h"
#include "mozilla/mailnews/MimeHeaderParser.h"
#include "nsContentUtils.h"
#include "prprf.h"
#include <algorithm>
@ -451,7 +452,7 @@ NS_IMETHODIMP nsNNTPProtocol::SetIsBusy(bool aIsBusy)
{
MOZ_LOG(NNTP, LogLevel::Info,("(%p) setting busy to %d",this, aIsBusy));
m_connectionBusy = aIsBusy;
// Maybe we could load another URI.
if (!aIsBusy && m_nntpServer)
m_nntpServer->PrepareForNextUrl(this);
@ -1960,32 +1961,21 @@ nsresult nsNNTPProtocol::SendFirstNNTPCommandResponse()
FinishMemCacheEntry(false); // cleanup mem cache entry
if (NS_SUCCEEDED(rv) && !group_name.IsEmpty() && !savingArticleOffline) {
nsString titleStr;
rv = GetNewsStringByName("htmlNewsErrorTitle", getter_Copies(titleStr));
NS_ENSURE_SUCCESS(rv,rv);
nsString newsErrorStr;
rv = GetNewsStringByName("htmlNewsError", getter_Copies(newsErrorStr));
NS_ENSURE_SUCCESS(rv,rv);
nsAutoString errorHtml;
errorHtml.Append(newsErrorStr);
errorHtml.AppendLiteral("<b>");
errorHtml.Append(NS_ConvertASCIItoUTF16(m_responseText));
errorHtml.AppendLiteral("</b><p>");
rv = GetNewsStringByName("articleExpired", getter_Copies(newsErrorStr));
NS_ENSURE_SUCCESS(rv,rv);
errorHtml.Append(newsErrorStr);
char outputBuffer[OUTPUT_BUFFER_SIZE];
nsCString uri(NS_LITERAL_CSTRING("about:newserror?r="));
nsCString escapedResponse;
MsgEscapeURL(nsDependentCString(m_responseText), nsINetUtil::ESCAPE_URL_QUERY, escapedResponse);
uri.Append(escapedResponse);
if ((m_key != nsMsgKey_None) && m_newsFolder) {
nsCString messageID;
nsCString escapedMessageID;
rv = m_newsFolder->GetMessageIdForKey(m_key, messageID);
if (NS_SUCCEEDED(rv)) {
PR_snprintf(outputBuffer, OUTPUT_BUFFER_SIZE,"<P>&lt;%.512s&gt; (%lu)", messageID.get(), m_key);
errorHtml.Append(NS_ConvertASCIItoUTF16(outputBuffer));
uri.AppendLiteral("&m=");
MsgEscapeURL(messageID, nsINetUtil::ESCAPE_URL_QUERY, escapedMessageID);
uri.Append(escapedMessageID);
uri.AppendLiteral("&k=");
uri.AppendInt(m_key);
}
}
@ -1993,20 +1983,16 @@ nsresult nsNNTPProtocol::SendFirstNNTPCommandResponse()
nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
if (NS_SUCCEEDED(rv) && folder) {
nsCString folderURI;
nsCString escapedFolderURI;
rv = folder->GetURI(folderURI);
if (NS_SUCCEEDED(rv)) {
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE,"<P> <A HREF=\"%s?list-ids\">", folderURI.get());
uri.AppendLiteral("&f=");
MsgEscapeURL(folderURI, nsINetUtil::ESCAPE_URL_QUERY, escapedFolderURI);
uri.Append(escapedFolderURI);
}
}
}
errorHtml.Append(NS_ConvertASCIItoUTF16(outputBuffer));
rv = GetNewsStringByName("removeExpiredArtLinkText", getter_Copies(newsErrorStr));
NS_ENSURE_SUCCESS(rv,rv);
errorHtml.Append(newsErrorStr);
errorHtml.AppendLiteral("</A> </P>");
if (!m_msgWindow) {
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
if (mailnewsurl) {
@ -2021,7 +2007,8 @@ nsresult nsNNTPProtocol::SendFirstNNTPCommandResponse()
// call nsDocShell::Stop(STOP_NETWORK), which will eventually
// call nsNNTPProtocol::Cancel(), which will close the socket.
// we need to fix this, since the connection is still valid.
rv = m_msgWindow->DisplayHTMLInMessagePane(titleStr, errorHtml, true);
rv = m_msgWindow->DisplayURIInMessagePane(NS_ConvertASCIItoUTF16(uri).get(), true,
nsContentUtils::GetSystemPrincipal());
NS_ENSURE_SUCCESS(rv,rv);
}
// let's take the opportunity of removing the hdr from the db so we don't try to download
@ -2034,7 +2021,6 @@ nsresult nsNNTPProtocol::SendFirstNNTPCommandResponse()
}
return NS_ERROR_FAILURE;
}
}
nsresult nsNNTPProtocol::SendGroupForArticle()
@ -2355,7 +2341,7 @@ nsresult nsNNTPProtocol::BeginAuthorization()
// Get the key to coalesce auth prompts.
bool singleSignon = false;
m_nntpServer->GetSingleSignon(&singleSignon);
nsCString queueKey;
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_nntpServer);
server->GetKey(queueKey);
@ -2521,7 +2507,7 @@ NS_IMETHODIMP nsNNTPProtocol::OnPromptStart(bool *authAvailable)
{
NS_ENSURE_ARG_POINTER(authAvailable);
NS_ENSURE_STATE(m_nextState == NNTP_SUSPENDED);
if (!m_newsFolder)
{
// If we don't have a news folder, we may have been closed already.
@ -2557,7 +2543,7 @@ NS_IMETHODIMP nsNNTPProtocol::OnPromptAuthAvailable()
NS_IMETHODIMP nsNNTPProtocol::OnPromptCanceled()
{
NS_ENSURE_STATE(m_nextState == NNTP_SUSPENDED);
// We previously suspended the request; now resume it to read input
if (m_request)
m_request->Resume();
@ -3227,7 +3213,7 @@ nsresult nsNNTPProtocol::XhdrSend()
m_nextState = NNTP_FIGURE_NEXT_CHUNK;
return NS_OK;
}
char outputBuffer[OUTPUT_BUFFER_SIZE];
PR_snprintf(outputBuffer, OUTPUT_BUFFER_SIZE, "XHDR %s %d-%d" CRLF,
header.get(), m_firstArticle, m_lastArticle);
@ -3250,7 +3236,7 @@ nsresult nsNNTPProtocol::XhdrResponse(nsIInputStream *inputStream)
SetFlag(NNTP_NO_XOVER_SUPPORT);
return NS_OK;
}
char *line, *lineToFree;
nsresult rv;
uint32_t status = 1;
@ -3709,7 +3695,7 @@ nsresult nsNNTPProtocol::DoCancel()
}
else
confirmCancelResult = 0; // Default to Yes.
if (confirmCancelResult != 0) {
// they cancelled the cancel
status = MK_NNTP_NOT_CANCELLED;

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

@ -3,12 +3,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
downloadHeadersTitlePrefix=Download Headers
downloadHeadersInfoText=There are %S 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=<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</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?
messageCancelled=Message cancelled.

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

@ -0,0 +1,31 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!-- LOCALIZATION NOTE (newsError.title): The title of the news error page.
Not generally visible. -->
<!ENTITY newsError.title "Problem Loading Article">
<!-- LOCALIZATION NOTE (articleNotFound.title): The main heading for the news
error page. -->
<!ENTITY articleNotFound.title "Article not found">
<!-- LOCALIZATION NOTE (articleNotFound.desc): A longer description for the news
error page. -->
<!ENTITY articleNotFound.desc "The newsgroup server reports that it can't find the article.">
<!-- LOCALIZATION NOTE (serverResponded.title): A string preceding the text
response from the newsgroup server describing the error. -->
<!ENTITY serverResponded.title "Newsgroup server responded:">
<!-- LOCALIZATION NOTE (articleExpired.title): A string explaining that the
article may have expired. -->
<!ENTITY articleExpired.title "Perhaps the article has expired?">
<!-- LOCALIZATION NOTE (trySearching.title): A string preceding the message's
ID. -->
<!ENTITY trySearching.title "Try searching for article:">
<!-- LOCALIZATION NOTE (removeExpiredArticles.title): The label for the button
to remove all expired articles from the newsgroup. -->
<!ENTITY removeExpiredArticles.title "Remove All Expired Articles">

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

@ -309,6 +309,7 @@
locale/@AB_CD@/messenger/msgViewPickerOverlay.dtd (%chrome/mailnews/msgViewPickerOverlay.dtd)
locale/@AB_CD@/messenger/newFolderDialog.dtd (%chrome/mailnews/newFolderDialog.dtd)
locale/@AB_CD@/messenger/news.properties (%chrome/mailnews/news.properties)
locale/@AB_CD@/messenger/newsError.dtd (%chrome/mailnews/newsError.dtd)
locale/@AB_CD@/messenger/oeImportMsgs.properties (%chrome/mailnews/oeImportMsgs.properties)
locale/@AB_CD@/messenger/offline.properties (%chrome/mailnews/offline.properties)
locale/@AB_CD@/messenger/offlineStartup.properties (%chrome/mailnews/offlineStartup.properties)