more changes to the new download headers dialog.

it isn't complete, but at least the basics are there.
This commit is contained in:
sspitzer%netscape.com 2000-01-03 05:11:51 +00:00
parent 8791b810ba
commit e802ab3643
3 changed files with 75 additions and 8 deletions

View File

@ -24,10 +24,12 @@
var newmessages = "";
var newsgroupname = "";
var Bundle = srGetStrBundle("chrome://messenger/locale/news.properties");
var prefs = Components.classes['component://netscape/preferences'].getService();
prefs = prefs.QueryInterface(Components.interfaces.nsIPref);
function OnLoad()
{
dump("OnLoad()\n");
//dump("OnLoad()\n");
if (window.arguments && window.arguments[0]) {
var args = window.arguments[0];
@ -48,6 +50,17 @@ function OnLoad()
var infotext = downloadHeadersInfoText1 + " " + newmessages + " " + downloadHeadersInfoText2;
setDivText('info',infotext);
}
//dump("TODO: max_articles and mark_old read should be passed in, and per server\n");
var max_articles_value = prefs.GetIntPref("news.max_articles");
var mark_old_read_value = prefs.GetBoolPref("news.mark_old_read");
var numberElement = document.getElementById("number");
numberElement.value = max_articles_value;
var markreadElement = document.getElementById("markread");
markreadElement.checked = mark_old_read_value;
return true;
}

View File

@ -39,19 +39,19 @@ Rights Reserved.
<spring flex="100%"/>
<html:div id="info"/>
<box align="horizontal" flex="100%">
<html:input type="radio" id="all" name="download" check="true"/>
<html:input type="radio" id="all" name="download"/>
<html:label for="all">&all.label;</html:label>
</box>
<box align="horizontal" flex="100%">
<html:input type="radio" id="some" name="download"/>
<html:input type="radio" id="some" name="download" checked="true"/>
<html:label for="some">&download.label;</html:label>
<html:input type="text" id="number" size="10"/>
<html:label>&headers.label;</html:label>
</box>
<box align="horizontal" flex="100%">
<html:input type="checkbox" id="mark"/>
<html:input type="checkbox" id="markread"/>
<html:label>&mark.label;</html:label>
</box>

View File

@ -34,6 +34,12 @@
#include "nsIDBFolderInfo.h"
#include "nsINewsDatabase.h"
#include "nsIMsgStatusFeedback.h"
#include "nsCOMPtr.h"
#include "nsIDOMWindow.h"
#include "nsIAppShellService.h"
#include "nsAppShellCIDs.h"
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
#ifdef HAVE_PANES
class MSG_Master;
@ -197,6 +203,37 @@ nsNNTPNewsgroupList::GetDatabase(const char *uri, nsIMsgDatabase **db)
return NS_OK;
}
static nsresult
openWindow( const PRUnichar *chrome, const PRUnichar *args )
{
nsCOMPtr<nsIDOMWindow> hiddenWindow;
JSContext *jsContext = nsnull;
nsresult rv;
NS_WITH_SERVICE( nsIAppShellService, appShell, kAppShellServiceCID, &rv )
if ( NS_SUCCEEDED( rv ) ) {
rv = appShell->GetHiddenWindowAndJSContext( getter_AddRefs( hiddenWindow ),
&jsContext );
if ( NS_SUCCEEDED( rv ) ) {
// Set up arguments for "window.openDialog"
void *stackPtr;
jsval *argv = JS_PushArguments( jsContext,
&stackPtr,
"WssW",
chrome,
"_blank",
"chrome,modal,dialog",
args );
if ( argv ) {
nsCOMPtr<nsIDOMWindow> newWindow; rv = hiddenWindow->OpenDialog( jsContext,
argv,
4,
getter_AddRefs( newWindow ) ); JS_PopArguments( jsContext, stackPtr );
}
}
}
return rv;
}
nsresult
nsNNTPNewsgroupList::GetRangeOfArtsToDownload(
/*nsINNTPHost* host,
@ -370,16 +407,30 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(
download = FE_NewsDownloadPrompt(m_pane->GetContext(),
*last - *first + 1,
&m_downloadAll, newsFolder);
#endif
#else
#ifdef DEBUG_NEWS
printf("Download Header Dialog: %d\n",*last - *first + 1);
printf("download all = %d\n", m_downloadAll);
#endif /* DEBUG_NEWS */
nsAutoString args = "";
args.Append(*last - *first + 1);
args.Append(",");
args.Append(m_groupName);
rv = openWindow( nsString("chrome://messenger/content/downloadheaders.xul").GetUnicode(), args.GetUnicode() );
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to open download headers dialog");
#endif /* HAVE_PANES */
if (download)
{
m_maxArticles = 0;
#ifdef DEBUG_NEWS
printf("todo: this should be per server!\n");
#endif /* DEBUG_NEWS */
rv = prefs->GetIntPref(PREF_NEWS_MAX_ARTICLES, &m_maxArticles);
if (NS_FAILED(rv)) {
#ifdef DEBUG_NEWS
printf("get pref of PREF_NEWS_MAX_ARTICLES failed\n");
#endif
#endif /* DEBUG_NEWS */
m_maxArticles = 0;
}
@ -388,12 +439,15 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(
if (!m_downloadAll)
{
PRBool markOldRead = PR_FALSE;
#ifdef DEBUG_NEWS
printf("todo: this should be per server!\n");
#endif /* DEBUG_NEWS */
rv = prefs->GetBoolPref(PREF_NEWS_MARK_OLD_READ, &markOldRead);
if (NS_FAILED(rv)) {
#ifdef DEBUG_NEWS
printf("get pref of PREF_NEWS_MARK_OLD_READ failed\n");
#endif
#endif /* DEBUG_NEWS */
}
if (markOldRead && m_set)
@ -413,7 +467,7 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(
}
#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
#endif /* DEBUG_NEWS */
m_firstMsgToDownload = *first;
m_lastMsgToDownload = *last;
if (status) *status=0;