зеркало из https://github.com/mozilla/pjs.git
fix for #61791. use nsINewsDownloadDialogArgs instead of nsIDialogParamBlock
and some general cleanup. sr=bienvenu
This commit is contained in:
Родитель
fbdbf00a3c
Коммит
de135d1a06
|
@ -139,4 +139,14 @@
|
|||
0x196b4b30, 0xe18c, 0x11d2, \
|
||||
{ 0x80, 0x6e, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e } }
|
||||
|
||||
//
|
||||
// nsNewsDownloadDialogArgs
|
||||
//
|
||||
#define NS_NEWSDOWNLOADDIALOGARGS_CONTRACTID \
|
||||
"@mozilla.org/messenger/newsdownloaddialogargs;1"
|
||||
#define NS_NEWSDOWNLOADDIALOGARGS_CID \
|
||||
{ /* 1540689e-1dd2-11b2-933d-f0d1e460ef4a */ \
|
||||
0x1540689e, 0x1dd2, 0x11b2, \
|
||||
{ 0x93, 0x3d, 0xf0, 0xd1, 0xe4, 0x60, 0xef, 0x4a} }
|
||||
|
||||
#endif // nsMsgNewsCID_h__
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsNNTPNewsgroupList.h"
|
||||
#include "nsNNTPArticleList.h"
|
||||
#include "nsNNTPHost.h"
|
||||
#include "nsNewsDownloadDialogArgs.h"
|
||||
#include "nsIContentHandler.h"
|
||||
#include "nsCURILoader.h"
|
||||
|
||||
|
@ -56,6 +57,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsNNTPNewsgroup)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNNTPNewsgroupPost)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNNTPNewsgroupList)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgNewsFolder)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNewsDownloadDialogArgs)
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
|
@ -124,7 +126,11 @@ static nsModuleComponentInfo components[] =
|
|||
{ "NNTP Host",
|
||||
NS_NNTPHOST_CID,
|
||||
NS_NNTPHOST_CONTRACTID,
|
||||
nsNNTPHostConstructor }
|
||||
nsNNTPHostConstructor },
|
||||
{ "News download dialog args",
|
||||
NS_NEWSDOWNLOADDIALOGARGS_CID,
|
||||
NS_NEWSDOWNLOADDIALOGARGS_CONTRACTID,
|
||||
nsNewsDownloadDialogArgsConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("nsMsgNewsModule", components)
|
||||
|
|
|
@ -42,6 +42,7 @@ XPIDLSRCS = \
|
|||
nsINNTPNewsgroupPost.idl \
|
||||
nsINntpUrl.idl \
|
||||
nsIMsgNewsFolder.idl \
|
||||
nsINewsDownloadDialogArgs.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -36,6 +36,7 @@ XPIDLSRCS= \
|
|||
.\nsINntpService.idl \
|
||||
.\nsINntpUrl.idl \
|
||||
.\nsIMsgNewsFolder.idl \
|
||||
.\nsINewsDownloadDialogArgs.idl \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -42,39 +42,29 @@ function OnLoad()
|
|||
doSetOKCancel(OkButtonCallback, CancelButtonCallback);
|
||||
|
||||
if (window.arguments && window.arguments[0]) {
|
||||
//dump ("param = " + window.arguments[0] + "\n");
|
||||
param = window.arguments[0].QueryInterface( Components.interfaces.nsIDialogParamBlock );
|
||||
//dump ("after QI param = " + window.arguments[0] + "\n");
|
||||
args = window.arguments[0].QueryInterface( Components.interfaces.nsINewsDownloadDialogArgs);
|
||||
|
||||
newmessages = param.GetInt(2);
|
||||
newsgroupname = param.GetString(0);
|
||||
serverid = param.GetString(1);
|
||||
|
||||
param.SetInt(0, 0); /* by default, act like the user hit cancel */
|
||||
param.SetInt(1, 0); /* by default, act like the user did not select download all */
|
||||
|
||||
//dump("new message count = " + newmessages + "\n");
|
||||
//dump("newsgroup name = " + newsgroupname + "\n");
|
||||
//dump("serverid = " + serverid + "\n");
|
||||
args.hitOK = false; /* by default, act like the user hit cancel */
|
||||
args.downloadAll = false; /* by default, act like the user did not select download all */
|
||||
|
||||
var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
|
||||
server = accountManager.getIncomingServer(serverid);
|
||||
server = accountManager.getIncomingServer(args.serverKey);
|
||||
nntpServer = server.QueryInterface(Components.interfaces.nsINntpIncomingServer);
|
||||
|
||||
var downloadHeadersTitlePrefix = Bundle.GetStringFromName("downloadHeadersTitlePrefix");
|
||||
var downloadHeadersInfoText1 = Bundle.GetStringFromName("downloadHeadersInfoText1");
|
||||
var downloadHeadersInfoText2 = Bundle.GetStringFromName("downloadHeadersInfoText2");
|
||||
var okButtonText = Bundle.GetStringFromName("okButtonText");
|
||||
var okButtonText = Bundle.GetStringFromName("okButtonText");
|
||||
|
||||
// doesn't JS have a printf?
|
||||
window.title = downloadHeadersTitlePrefix;
|
||||
var infotext = downloadHeadersInfoText1 + " " + newmessages + " " + downloadHeadersInfoText2;
|
||||
setText('info',infotext);
|
||||
var okbutton = document.getElementById("ok");
|
||||
okbutton.setAttribute("value", okButtonText);
|
||||
setText("newsgroupLabel", newsgroupname);
|
||||
}
|
||||
|
||||
// this is not i18n friendly, fix this
|
||||
var infotext = downloadHeadersInfoText1 + " " + args.articleCount + " " + downloadHeadersInfoText2;
|
||||
setText('info',infotext);
|
||||
var okbutton = document.getElementById("ok");
|
||||
okbutton.setAttribute("value", okButtonText);
|
||||
setText("newsgroupLabel", args.groupName);
|
||||
}
|
||||
|
||||
numberElement = document.getElementById("number");
|
||||
numberElement.value = nntpServer.maxArticles;
|
||||
|
@ -88,7 +78,7 @@ function OnLoad()
|
|||
function setText(id, value) {
|
||||
var element = document.getElementById(id);
|
||||
if (!element) return;
|
||||
if (element.hasChildNodes())
|
||||
if (element.hasChildNodes())
|
||||
element.removeChild(element.firstChild);
|
||||
var textNode = document.createTextNode(value);
|
||||
element.appendChild(textNode);
|
||||
|
@ -101,22 +91,15 @@ function OkButtonCallback() {
|
|||
|
||||
var radio = document.getElementById("all");
|
||||
if (radio) {
|
||||
//dump("all radio value " + radio.checked + "\n");
|
||||
if (radio.checked) {
|
||||
param.SetInt(1, 1); /* the user selected download all */
|
||||
}
|
||||
else {
|
||||
param.SetInt(1, 0); /* the user did not select download all */
|
||||
}
|
||||
args.downloadAll = radio.checked;
|
||||
}
|
||||
|
||||
param.SetInt(0, 1); /* user hit OK */
|
||||
|
||||
args.hitOK = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
function CancelButtonCallback() {
|
||||
param.SetInt(0, 0); /* user hit Cancel */
|
||||
args.hitOK = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ CPPSRCS = \
|
|||
nsNntpIncomingServer.cpp \
|
||||
nsNewsMessage.cpp \
|
||||
nsNewsUtils.cpp \
|
||||
nsNewsDownloadDialogArgs.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
@ -60,6 +61,7 @@ EXPORTS = \
|
|||
nsNewsUtils.h \
|
||||
nsNNTPHost.h \
|
||||
nsNNTPCategoryContainer.h \
|
||||
nsNewsDownloadDialogArgs.h \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
|
|
|
@ -40,6 +40,7 @@ EXPORTS= nsNNTPProtocol.h \
|
|||
nsNewsUtils.h \
|
||||
nsNNTPHost.h \
|
||||
nsNNTPCategoryContainer.h \
|
||||
nsNewsDownloadDialogArgs.h \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
|
@ -59,6 +60,7 @@ CPP_OBJS= .\$(OBJDIR)\nsNNTPProtocol.obj \
|
|||
.\$(OBJDIR)\nsNewsFolder.obj \
|
||||
.\$(OBJDIR)\nsNntpIncomingServer.obj \
|
||||
.\$(OBJDIR)\nsNewsUtils.obj \
|
||||
.\$(OBJDIR)\nsNewsDownloadDialogArgs.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
#include "nsMsgDBCID.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsINewsDownloadDialogArgs.h"
|
||||
|
||||
#include "nsIScriptGlobalObjectOwner.h"
|
||||
#include "nsIMsgWindow.h"
|
||||
|
@ -85,16 +85,6 @@
|
|||
|
||||
static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID);
|
||||
static NS_DEFINE_CID(kCPrefServiceCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
|
||||
|
||||
#define DOWNLOAD_HEADERS_URL "chrome://messenger/content/downloadheaders.xul"
|
||||
|
||||
#define USER_HIT_OK_INT_ARG 0
|
||||
#define DOWNLOAD_ALL_INT_ARG 1
|
||||
#define ARTICLE_COUNT_INT_ARG 2
|
||||
|
||||
#define GROUPNAME_STRING_ARG 0
|
||||
#define SERVERKEY_STRING_ARG 1
|
||||
|
||||
extern PRInt32 net_NewsChunkSize;
|
||||
|
||||
|
@ -224,7 +214,7 @@ nsNNTPNewsgroupList::GetDatabase(const char *uri, nsIMsgDatabase **db)
|
|||
}
|
||||
|
||||
static nsresult
|
||||
openWindow(nsIMsgWindow *aMsgWindow, const char *chromeURL, nsIDialogParamBlock *ioParamBlock)
|
||||
openWindow(nsIMsgWindow *aMsgWindow, const char *chromeURL, nsINewsDownloadDialogArgs *param)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -257,8 +247,8 @@ openWindow(nsIMsgWindow *aMsgWindow, const char *chromeURL, nsIDialogParamBlock
|
|||
chromeURL,
|
||||
"_blank",
|
||||
"chrome,modal,titlebar",
|
||||
(const nsIID*)(&NS_GET_IID(nsIDialogParamBlock)),
|
||||
(nsISupports*)ioParamBlock);
|
||||
(const nsIID*)(&NS_GET_IID(nsINewsDownloadDialogArgs)),
|
||||
(nsISupports*)param);
|
||||
|
||||
if (!argv) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -456,60 +446,36 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow * aMsgWindow,
|
|||
{
|
||||
if (!m_getOldMessages && !m_promptedAlready && notifyMaxExceededOn)
|
||||
{
|
||||
PRBool download = PR_TRUE;
|
||||
m_downloadAll = PR_FALSE;
|
||||
|
||||
// todo list:
|
||||
// use nsINewsDownloadHeadersDialogArgs instead of nsIDialogParamBlock
|
||||
// don't use prefs for dialog values, use the arg block
|
||||
// m_promptedAlready may not be saved
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("Download Header Dialog: %d\n",*last - *first + 1);
|
||||
printf("download = %d\n", download);
|
||||
printf("download all = %d\n", m_downloadAll);
|
||||
#endif /* DEBUG_NEWS */
|
||||
|
||||
nsCOMPtr<nsIDialogParamBlock> ioParamBlock = do_CreateInstance(kDialogParamBlockCID, &rv);
|
||||
nsCOMPtr<nsINewsDownloadDialogArgs> args = do_CreateInstance("@mozilla.org/messenger/newsdownloaddialogargs;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = ioParamBlock->SetInt(ARTICLE_COUNT_INT_ARG, *last - *first + 1);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = args->SetArticleCount(*last - *first + 1);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = ioParamBlock->SetString(GROUPNAME_STRING_ARG, NS_ConvertASCIItoUCS2(m_groupName).GetUnicode());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = args->SetGroupName((const char *)m_groupName);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// get the server key
|
||||
nsXPIDLCString serverKey;
|
||||
rv = server->GetKey(getter_Copies(serverKey));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = ioParamBlock->SetString(SERVERKEY_STRING_ARG, NS_ConvertASCIItoUCS2((const char *)serverKey).GetUnicode());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = args->SetServerKey((const char *)serverKey);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = openWindow(aMsgWindow, DOWNLOAD_HEADERS_URL, ioParamBlock);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to open download headers dialog");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 buttonPressed = 0;
|
||||
rv = ioParamBlock->GetInt(USER_HIT_OK_INT_ARG,&buttonPressed);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (buttonPressed) {
|
||||
download = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
download = PR_FALSE;
|
||||
}
|
||||
rv = openWindow(aMsgWindow, DOWNLOAD_HEADERS_URL, args);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRBool download = PR_TRUE;
|
||||
rv = args->GetHitOK(&download);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (download) {
|
||||
rv = ioParamBlock->GetInt(DOWNLOAD_ALL_INT_ARG,&buttonPressed);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (buttonPressed) {
|
||||
m_downloadAll = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
m_downloadAll = PR_FALSE;
|
||||
}
|
||||
rv = args->GetDownloadAll(&m_downloadAll);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
m_maxArticles = 0;
|
||||
|
||||
|
@ -540,9 +506,7 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow * aMsgWindow,
|
|||
*first = *last - maxextra + 1;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("GetRangeOfArtsToDownload(first possible = %d, last possible = %d, first = %d, last = %d maxextra = %d\n",first_possible, last_possible, *first, *last, maxextra);
|
||||
#endif /* DEBUG_NEWS */
|
||||
|
||||
m_firstMsgToDownload = *first;
|
||||
m_lastMsgToDownload = *last;
|
||||
if (status) *status=0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче