comment out some dumps, printfs.

get unsubscribe working for news.
get ready to fix the problem of selecting a non-subscribable server and hitting subscribe.
This commit is contained in:
sspitzer%netscape.com 2000-05-15 21:44:34 +00:00
Родитель 1699fef9eb
Коммит 151704cc87
4 изменённых файлов: 65 добавлений и 12 удалений

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

@ -317,25 +317,25 @@ function Subscribe(windowTitle, preselectedMsgFolder)
function SubscribeOKCallback(serverURI, changeTable)
{
dump("in SubscribeOKCallback(" + serverURI +")\n");
dump("change table = " + changeTable + "\n");
//dump("in SubscribeOKCallback(" + serverURI +")\n");
//dump("change table = " + changeTable + "\n");
var folder = GetMsgFolderFromUri(serverURI);
var server = folder.server;
var subscribableServer = server.QueryInterface(Components.interfaces.nsISubscribableServer);
for (var name in changeTable) {
dump(name + " = " + changeTable[name] + "\n");
//dump(name + " = " + changeTable[name] + "\n");
if (changeTable[name] == true) {
dump("from js, subscribe to " + name +"\n");
//dump("from js, subscribe to " + name +"\n");
subscribableServer.subscribe(name);
}
else if (changeTable[name] == false) {
dump("from js, unsubscribe to " + name +"\n");
//dump("from js, unsubscribe to " + name +"\n");
subscribableServer.unsubscribe(name);
}
else {
dump("no change to " + name + "\n");
//dump("no change to " + name + "\n");
}
}
}

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

@ -8,6 +8,18 @@ var gStatusBar = null;
var gNameField = null;
var gFolderDelimiter = ".";
function SetUpRDF()
{
if (!RDF) {
RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
}
if (!gSubscribeDS) {
gSubscribeDS = RDF.GetDataSource("rdf:subscribe");
}
}
function Stop()
{
dump("Stop()\n");
@ -59,7 +71,15 @@ function SetUpServerMenu()
var serverMenu = document.getElementById("serverMenu");
var menuitems = serverMenu.getElementsByAttribute("id", gServerURI);
serverMenu.selectedItem = menuitems[0];
try {
dump("menuitems="+menuitems+"\n");
dump("menuitems[0]="+menuitems[0]+"\n");
dump("serverMenu="+serverMenu+"\n");
serverMenu.selectedItem = menuitems[0];
}
catch (ex) {
dump("failed to set the selected server: " + ex + "\n");
}
SetServerTypeSpecificTextValues();
}
@ -76,6 +96,7 @@ var MySubscribeListener = {
function SetUpTree()
{
dump("SetUpTree()\n");
SetUpRDF();
gSubscribeTree.setAttribute('ref',null);
@ -122,10 +143,12 @@ function SubscribeOnLoad()
var uri = window.arguments[0].preselectedURI;
dump("subscribe: got a uri," + uri + "\n");
folder = GetMsgFolderFromUri(uri);
dump("xxx todo: make sure this is a subscribable server\n");
gServerURI = folder.server.serverURI;
}
else {
dump("subscribe: no uri\n");
dump("xxx todo: use the default news server\n");
var serverMenu = document.getElementById("serverMenu");
var menuitems = serverMenu.getElementsByTagName("menuitem");
gServerURI = menuitems[1].id;
@ -134,10 +157,6 @@ function SubscribeOnLoad()
SetUpServerMenu();
SetUpTree();
RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
gSubscribeDS = RDF.GetDataSource("rdf:subscribe");
gNameField.focus();
}

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

@ -1959,7 +1959,7 @@ nsImapIncomingServer::StartPopulatingSubscribeDS()
rv = SetIncomingServer(this);
if (NS_FAILED(rv)) return rv;
rv = SetDelimiter('/'); // not always true?
rv = SetDelimiter('/'); // is this aways the case? need to talk to jefft
if (NS_FAILED(rv)) return rv;
return mInner->StartPopulatingSubscribeDS();
@ -2022,14 +2022,18 @@ nsImapIncomingServer::SubscribeToFolder(const char *aName, PRBool subscribe)
if (NS_FAILED(rv)) return rv;
if (subscribe) {
#ifdef DEBUG_sspitzer
printf("subscribe to folder: %s\n",aName);
#endif
rv = imapService->SubscribeFolder(queue,
rootMsgFolder,
folderName.GetUnicode(),
nsnull, nsnull);
}
else {
#ifdef DEBUG_sspitzer
printf("unsubscribe to folder: %s\n",aName);
#endif
rv = imapService->UnsubscribeFolder(queue,
rootMsgFolder,
folderName.GetUnicode(),

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

@ -288,6 +288,7 @@ nsNntpIncomingServer::WriteNewsrcFile()
newsrcStream.close();
rv = SetNewsrcHasChanged(PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
#ifdef DEBUG_NEWS
else {
@ -797,13 +798,42 @@ nsNntpIncomingServer::GetSubscribeListener(nsISubscribeListener **aListener)
NS_IMETHODIMP
nsNntpIncomingServer::Subscribe(const char *aName)
{
#ifdef DEBUG_NEWS
printf("subscribe to news group: %s\n",aName);
#endif
return SubscribeToNewsgroup(aName);
}
NS_IMETHODIMP
nsNntpIncomingServer::Unsubscribe(const char *aName)
{
nsresult rv;
#ifdef DEBUG_NEWS
printf("unsubscribe to news group: %s\n",aName);
#endif
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
if (NS_FAILED(rv)) return rv;
if (!rootFolder) return NS_ERROR_FAILURE;
nsCOMPtr <nsIMsgFolder> serverFolder = do_QueryInterface(rootFolder, &rv);
if (NS_FAILED(rv)) return rv;
if (!serverFolder) return NS_ERROR_FAILURE;
nsCOMPtr <nsIFolder> subFolder;
rv = serverFolder->FindSubFolder(aName, getter_AddRefs(subFolder));
if (NS_FAILED(rv)) return rv;
nsCOMPtr <nsIMsgFolder> newsgroupFolder = do_QueryInterface(subFolder, &rv);
if (NS_FAILED(rv)) return rv;
if (!newsgroupFolder) return NS_ERROR_FAILURE;
rv = serverFolder->PropagateDelete(newsgroupFolder, PR_TRUE /* delete storage */);
if (NS_FAILED(rv)) return rv;
/* since we've unsubscribed to a newsgroup, the newsrc needs to be written out */
rv = SetNewsrcHasChanged(PR_TRUE);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}