From 186a45955770c3f7ff76db0a56cc640aabd0d35a Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Sun, 23 Apr 2000 01:19:51 +0000 Subject: [PATCH] changes for subscribe. it needs to be general, not just for news, since imap will use the subscribe dialog as well. also, some minor changes, the humble beginnings of the hostinfo.dat support. --- mailnews/base/public/Makefile.in | 1 + mailnews/base/public/makefile.win | 1 + mailnews/base/resources/content/subscribe.js | 15 +++++---- mailnews/news/public/nsINntpService.idl | 4 +-- mailnews/news/src/nsNntpIncomingServer.cpp | 33 ++++++++++++++++---- mailnews/news/src/nsNntpIncomingServer.h | 7 ++++- mailnews/news/src/nsNntpService.cpp | 5 ++- 7 files changed, 48 insertions(+), 18 deletions(-) diff --git a/mailnews/base/public/Makefile.in b/mailnews/base/public/Makefile.in index 2cff9abee2d..2c1ca03eca6 100644 --- a/mailnews/base/public/Makefile.in +++ b/mailnews/base/public/Makefile.in @@ -76,6 +76,7 @@ XPIDLSRCS = \ nsIMsgStringService.idl \ nsIMsgViewNavigationService.idl \ nsIMsgPrintEngine.idl \ + nsISubscribableServer.idl \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/mailnews/base/public/makefile.win b/mailnews/base/public/makefile.win index fc3dfc0ad53..637cc770a0a 100644 --- a/mailnews/base/public/makefile.win +++ b/mailnews/base/public/makefile.win @@ -61,6 +61,7 @@ XPIDLSRCS = \ .\nsIMsgStringService.idl \ .\nsIMsgViewNavigationService.idl \ .\nsIMsgPrintEngine.idl \ + .\nsISubscribableServer.idl \ $(NULL) ################################################################################ diff --git a/mailnews/base/resources/content/subscribe.js b/mailnews/base/resources/content/subscribe.js index 7d1a19fba44..69ddb13332f 100644 --- a/mailnews/base/resources/content/subscribe.js +++ b/mailnews/base/resources/content/subscribe.js @@ -36,13 +36,16 @@ function SetUpTree() var folder = GetMsgFolderFromUri(gServerURI); var server = folder.server; - /* todo: this should be server.buildSubscribeDatasource() which does the right thing with its server. for imap */ - var nntpService = Components.classes['component://netscape/messenger/nntpservice'].getService(Components.interfaces.nsINntpService); - nntpService = nntpService.QueryInterface(Components.interfaces.nsINntpService); - nntpService.buildSubscribeDatasource(server); + try { + subscribableServer = server.QueryInterface(Components.interfaces.nsISubscribableServer); + subscribableServer.populateSubscribeDatasource(null /* eventual, a nsIMsgWindow */); - dump("root subscribe tree at: "+ gServerURI +"\n"); - gSubscribeTree.setAttribute('ref',gServerURI); + dump("root subscribe tree at: "+ gServerURI +"\n"); + gSubscribeTree.setAttribute('ref',gServerURI); + } + catch (ex) { + dump("failed to populate subscribe ds: " + ex + "\n"); + } } function SubscribeOnLoad() diff --git a/mailnews/news/public/nsINntpService.idl b/mailnews/news/public/nsINntpService.idl index 58738a670e8..2db2617aa6f 100644 --- a/mailnews/news/public/nsINntpService.idl +++ b/mailnews/news/public/nsINntpService.idl @@ -41,8 +41,8 @@ interface nsINntpService : nsISupports { nsIURI getNewNews (in nsINntpIncomingServer nntpServer, in string uri, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow); nsIURI cancelMessages (in string hostname, in string newsgroupname, in nsISupportsArray messages, in nsISupports aConsumer, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow); - - void buildSubscribeDatasource(in nsINntpIncomingServer nntpServer); + + void buildSubscribeDatasource(in nsINntpIncomingServer nntpServer, in nsIMsgWindow aMsgWindow); void updateCounts(in nsINntpIncomingServer nntpServer, in nsIMsgWindow aMsgWindow); }; diff --git a/mailnews/news/src/nsNntpIncomingServer.cpp b/mailnews/news/src/nsNntpIncomingServer.cpp index e414eacfb8d..2638c46a0e0 100644 --- a/mailnews/news/src/nsNntpIncomingServer.cpp +++ b/mailnews/news/src/nsNntpIncomingServer.cpp @@ -36,6 +36,7 @@ #include "nsRDFCID.h" #include "nsMsgNewsCID.h" #include "nsNNTPProtocol.h" +#include "nsISubscribableServer.h" #define NEW_NEWS_DIR_NAME "News" #define PREF_MAIL_NEWSRC_ROOT "mail.newsrc_root" @@ -56,18 +57,24 @@ static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kNntpServiceCID, NS_NNTPSERVICE_CID); -NS_IMPL_ISUPPORTS_INHERITED2(nsNntpIncomingServer, - nsMsgIncomingServer, - nsINntpIncomingServer, - nsIUrlListener); +NS_IMPL_ADDREF_INHERITED(nsNntpIncomingServer, nsMsgIncomingServer) +NS_IMPL_RELEASE_INHERITED(nsNntpIncomingServer, nsMsgIncomingServer) + +NS_INTERFACE_MAP_BEGIN(nsNntpIncomingServer) + NS_INTERFACE_MAP_ENTRY(nsINntpIncomingServer) + NS_INTERFACE_MAP_ENTRY(nsIUrlListener) + NS_INTERFACE_MAP_ENTRY(nsISubscribableServer) +NS_INTERFACE_MAP_END_INHERITING(nsMsgIncomingServer) nsNntpIncomingServer::nsNntpIncomingServer() { NS_INIT_REFCNT(); mNewsrcHasChanged = PR_FALSE; - mGroupsEnumerator = nsnull; - NS_NewISupportsArray(getter_AddRefs(m_connectionCache)); + mGroupsEnumerator = nsnull; + NS_NewISupportsArray(getter_AddRefs(m_connectionCache)); + mHostInfoLoaded = PR_FALSE; + mHostInfoHasChanged = PR_FALSE; } @@ -828,3 +835,17 @@ nsNntpIncomingServer::SubscribeToNewsgroup(const char *name) return NS_OK; } +NS_IMETHODIMP +nsNntpIncomingServer::PopulateSubscribeDatasource(nsIMsgWindow *aMsgWindow) +{ + nsresult rv; + printf("in PopulateSubscribeDatasource()\n"); + nsCOMPtr nntpService = do_GetService(kNntpServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + if (!nntpService) return NS_ERROR_FAILURE; + + rv = nntpService->BuildSubscribeDatasource(this, aMsgWindow); + if (NS_FAILED(rv)) return rv; + + return NS_OK; +} diff --git a/mailnews/news/src/nsNntpIncomingServer.h b/mailnews/news/src/nsNntpIncomingServer.h index b5417fa3e15..e1a95fb721c 100644 --- a/mailnews/news/src/nsNntpIncomingServer.h +++ b/mailnews/news/src/nsNntpIncomingServer.h @@ -37,6 +37,7 @@ #include "nsEnumeratorUtils.h" #include "nsIMsgWindow.h" +#include "nsISubscribableServer.h" class nsINntpUrl; class nsIMsgMailNewsUrl; @@ -44,13 +45,15 @@ class nsIMsgMailNewsUrl; /* get some implementation from nsMsgIncomingServer */ class nsNntpIncomingServer : public nsMsgIncomingServer, public nsINntpIncomingServer, - public nsIUrlListener + public nsIUrlListener, + public nsISubscribableServer { public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSINNTPINCOMINGSERVER NS_DECL_NSIURLLISTENER + NS_DECL_NSISUBSCRIBABLESERVER nsNntpIncomingServer(); virtual ~nsNntpIncomingServer(); @@ -70,6 +73,8 @@ private: nsresult SetNewsgroupAsSubscribed(const char *aName); PRBool mNewsrcHasChanged; nsAdapterEnumerator *mGroupsEnumerator; + PRBool mHostInfoLoaded; + PRBool mHostInfoHasChanged; }; #endif diff --git a/mailnews/news/src/nsNntpService.cpp b/mailnews/news/src/nsNntpService.cpp index bfcf075896a..35db8b7c86b 100644 --- a/mailnews/news/src/nsNntpService.cpp +++ b/mailnews/news/src/nsNntpService.cpp @@ -1291,7 +1291,7 @@ nsNntpService::UpdateCounts(nsINntpIncomingServer *aNntpServer, nsIMsgWindow *aM } NS_IMETHODIMP -nsNntpService::BuildSubscribeDatasource(nsINntpIncomingServer *aNntpServer) +nsNntpService::BuildSubscribeDatasource(nsINntpIncomingServer *aNntpServer, nsIMsgWindow *aMsgWindow) { nsresult rv; #ifdef DEBUG_NEWS @@ -1318,8 +1318,7 @@ nsNntpService::BuildSubscribeDatasource(nsINntpIncomingServer *aNntpServer) if (NS_FAILED(rv)) return rv; // now run the url to add the rest of the groups - // TODO: pass in the nsIMsgWindow for progress. - rv = RunNewsUrl(uri, nsnull /* nsIMsgWindow */, nsnull); + rv = RunNewsUrl(uri, aMsgWindow, nsnull); if (NS_FAILED(rv)) return rv; return NS_OK;