зеркало из https://github.com/mozilla/pjs.git
fix for #6919. heed the "news.max_articles" pref.
This commit is contained in:
Родитель
66ab8c86a6
Коммит
415429d454
|
@ -66,7 +66,14 @@ class MSG_Master;
|
|||
#include "nsNewsUtils.h"
|
||||
|
||||
#include "nsMsgDBCID.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
|
||||
#define PREF_NEWS_MAX_ARTICLES "news.max_articles"
|
||||
#define PREF_NEWS_MARK_OLD_READ "news.mark_old_read"
|
||||
|
||||
static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
extern PRInt32 net_NewsChunkSize;
|
||||
|
||||
|
@ -405,10 +412,15 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(
|
|||
|
||||
if (m_getOldMessages || !m_knownArts.set->IsMember(last_possible))
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
|
||||
if (NS_FAILED(rv) || (!prefs)) {
|
||||
return rv;
|
||||
}
|
||||
#ifdef HAVE_PANES
|
||||
PRBool notifyMaxExceededOn = (m_pane && !m_finishingXover && m_pane->GetPrefs() && m_pane->GetPrefs()->GetNewsNotifyOn());
|
||||
#else
|
||||
PRBool notifyMaxExceededOn = PR_FALSE;
|
||||
PRBool notifyMaxExceededOn = PR_TRUE; // check prefs GetPrefs()->GetNewsNotifyOn
|
||||
#endif
|
||||
// if the preference to notify when downloading more than x headers is not on,
|
||||
// and we're downloading new headers, set maxextra to a very large number.
|
||||
|
@ -425,7 +437,7 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(
|
|||
{
|
||||
if (!m_getOldMessages && !m_promptedAlready && notifyMaxExceededOn)
|
||||
{
|
||||
PRBool download = PR_FALSE;
|
||||
PRBool download = PR_TRUE; // yes, I'd like some news messages
|
||||
#ifdef HAVE_PANES
|
||||
nsINNTPNewsgroup *newsFolder = m_pane->GetMaster()->FindNewsFolder(m_host, m_groupName, PR_FALSE);
|
||||
download = FE_NewsDownloadPrompt(m_pane->GetContext(),
|
||||
|
@ -436,17 +448,27 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(
|
|||
{
|
||||
m_maxArticles = 0;
|
||||
|
||||
#ifdef HAVE_PREFS
|
||||
PREF_GetIntPref("news.max_articles", &m_maxArticles);
|
||||
rv = prefs->GetIntPref(PREF_NEWS_MAX_ARTICLES, &m_maxArticles);
|
||||
if (NS_FAILED(rv)) {
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("get pref of PREF_NEWS_MAX_ARTICLES failed\n");
|
||||
#endif
|
||||
m_maxArticles = 0;
|
||||
}
|
||||
|
||||
net_NewsChunkSize = m_maxArticles;
|
||||
maxextra = m_maxArticles;
|
||||
if (!m_downloadAll)
|
||||
{
|
||||
PRBool markOldRead = PR_FALSE;
|
||||
#ifdef HAVE_PREFS
|
||||
PREF_GetBoolPref("news.mark_old_read", &markOldRead);
|
||||
#endif
|
||||
|
||||
rv = prefs->GetBoolPref(PREF_NEWS_MARK_OLD_READ, &markOldRead);
|
||||
if (NS_FAILED(rv)) {
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("get pref of PREF_NEWS_MARK_OLD_READ failed\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (markOldRead && m_set)
|
||||
m_set->AddRange(*first, *last - maxextra);
|
||||
*first = *last - maxextra + 1;
|
||||
|
|
|
@ -60,6 +60,12 @@
|
|||
#include "nsMsgKeySet.h"
|
||||
|
||||
#include "nsNewsUtils.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
#define PREF_NEWS_MAX_ARTICLES "news.max_articles"
|
||||
#define PREF_NEWS_MARK_OLD_READ "news.mark_old_read"
|
||||
|
||||
#define DEFAULT_NEWS_CHUNK_SIZE -1
|
||||
|
||||
/* #define UNREADY_CODE */ /* mscott: generic flag for hiding access to url struct and active entry which are now gone */
|
||||
|
||||
|
@ -72,8 +78,8 @@ char * NET_SACat (char **destination, const char *source);
|
|||
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIWebShell, NS_IWEB_SHELL_IID);
|
||||
static NS_DEFINE_CID(kNntpUrlCID, NS_NNTPURL_CID);
|
||||
static NS_DEFINE_IID(kIWebShell, NS_IWEB_SHELL_IID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
// quiet compiler warnings by defining these function prototypes
|
||||
char *NET_ExplainErrorDetails (int code, ...);
|
||||
|
@ -224,7 +230,7 @@ HG25430
|
|||
*/
|
||||
/* PRIVATE XP_List * nntp_connection_list=0; */
|
||||
PRIVATE PRBool net_news_last_username_probably_valid=PR_FALSE;
|
||||
PRInt32 net_NewsChunkSize=-1; /* default */
|
||||
PRInt32 net_NewsChunkSize=DEFAULT_NEWS_CHUNK_SIZE;
|
||||
/* PRIVATE PRInt32 net_news_timeout = 170; */
|
||||
/* seconds that an idle NNTP conn can live */
|
||||
extern "C"
|
||||
|
@ -356,6 +362,15 @@ nsNNTPProtocol::nsNNTPProtocol(nsIURL * aURL, nsITransport * transportLayer)
|
|||
/* the following macro is used to initialize the ref counting data */
|
||||
NS_INIT_REFCNT();
|
||||
Initialize(aURL, transportLayer);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && (prefs)) {
|
||||
rv = prefs->GetIntPref(PREF_NEWS_MAX_ARTICLES, &net_NewsChunkSize);
|
||||
if (NS_FAILED(rv)) {
|
||||
net_NewsChunkSize = DEFAULT_NEWS_CHUNK_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsNNTPProtocol::~nsNNTPProtocol()
|
||||
|
@ -2005,7 +2020,6 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
|
|||
{
|
||||
char *line;
|
||||
PRUint32 status = 0;
|
||||
nsresult rv = NS_OK;
|
||||
char outputBuffer[OUTPUT_BUFFER_SIZE];
|
||||
|
||||
PRBool pauseForMoreData = PR_FALSE;
|
||||
|
|
|
@ -62,7 +62,7 @@ static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID);
|
|||
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
#define PREF_MAX_NEWS_HEADERS_TO_SHOW "mail.news.maxheaderstoshow"
|
||||
#define PREF_NEWS_MAX_HEADERS_TO_SHOW "news.max_headers_to_show"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -539,7 +539,7 @@ nsMsgNewsFolder::GetMessages(nsIEnumerator* *result)
|
|||
nsresult rv = NS_OK;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && prefs) {
|
||||
rv = prefs->GetIntPref(PREF_MAX_NEWS_HEADERS_TO_SHOW, &number_to_show);
|
||||
rv = prefs->GetIntPref(PREF_NEWS_MAX_HEADERS_TO_SHOW, &number_to_show);
|
||||
if (NS_FAILED(rv)) {
|
||||
// failed to get the pref...show them all the headers
|
||||
number_to_show = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче