diff --git a/mailnews/base/public/nsIMsgIncomingServer.idl b/mailnews/base/public/nsIMsgIncomingServer.idl index 0881c864dde..71a736dc009 100644 --- a/mailnews/base/public/nsIMsgIncomingServer.idl +++ b/mailnews/base/public/nsIMsgIncomingServer.idl @@ -126,10 +126,9 @@ interface nsIMsgIncomingServer : nsISupports { /* do a biff */ void PerformBiff(); - - /* this checks if a Server need's a password, implemented because of biffing Nntp, Tobias A (TAJT) */ - boolean GetServerRequiresPasswordForBiff(); + /* this checks if a server needs a password to do biff */ + readonly attribute boolean serverRequiresPasswordForBiff; /* this gets called when the server is expanded in the folder pane */ void PerformExpand(); diff --git a/mailnews/base/util/nsMsgFolder.cpp b/mailnews/base/util/nsMsgFolder.cpp index 30a1245454c..cc288b18971 100644 --- a/mailnews/base/util/nsMsgFolder.cpp +++ b/mailnews/base/util/nsMsgFolder.cpp @@ -1469,6 +1469,8 @@ NS_IMETHODIMP nsMsgFolder::OnFlagChange(PRUint32 flag) rv = GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(db)); if (NS_SUCCEEDED(rv) && folderInfo) { + nsXPIDLString name; + rv = GetName(getter_Copies(name)); folderInfo->SetFlags((PRInt32) mFlags); if (db) db->Commit(nsMsgDBCommitType::kLargeCommit); diff --git a/mailnews/news/public/nsINntpIncomingServer.idl b/mailnews/news/public/nsINntpIncomingServer.idl index 21385794a7f..66fee49fddd 100644 --- a/mailnews/news/public/nsINntpIncomingServer.idl +++ b/mailnews/news/public/nsINntpIncomingServer.idl @@ -53,8 +53,9 @@ interface nsINntpIncomingServer : nsISupports { attribute boolean newsrcHasChanged; attribute long maximumConnectionsNumber; + /* used when populating the subscribe dialog */ - void addNewNewsgroup(in string name, in string state, in string count); + void addNewNewsgroup(in string name); void addSubscribedNewsgroups(); readonly attribute long numGroupsNeedingCounts; diff --git a/mailnews/news/src/nsNNTPProtocol.cpp b/mailnews/news/src/nsNNTPProtocol.cpp index 37c7ad01b58..4aae8c00606 100644 --- a/mailnews/news/src/nsNNTPProtocol.cpp +++ b/mailnews/news/src/nsNNTPProtocol.cpp @@ -2954,7 +2954,7 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng #else NS_ASSERTION(m_nntpServer, "no nntp incoming server"); if (m_nntpServer) { - rv = m_nntpServer->AddNewNewsgroup(line, "false", "0"); + rv = m_nntpServer->AddNewNewsgroup(line); } else { rv = NS_ERROR_FAILURE; diff --git a/mailnews/news/src/nsNntpIncomingServer.cpp b/mailnews/news/src/nsNntpIncomingServer.cpp index 1dcab269170..91176e67240 100644 --- a/mailnews/news/src/nsNntpIncomingServer.cpp +++ b/mailnews/news/src/nsNntpIncomingServer.cpp @@ -56,9 +56,10 @@ 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_INHERITED(nsNntpIncomingServer, +NS_IMPL_ISUPPORTS_INHERITED2(nsNntpIncomingServer, nsMsgIncomingServer, - nsINntpIncomingServer); + nsINntpIncomingServer, + nsIUrlListener); nsNntpIncomingServer::nsNntpIncomingServer() { @@ -492,7 +493,7 @@ nsNntpIncomingServer::AddSubscribedNewsgroups() rv = currFolder->GetName(getter_Copies(name)); if (NS_SUCCEEDED(rv) && name) { nsCAutoString asciiName(name); - rv = AddNewNewsgroup((const char *)asciiName,"true","0"); + rv = SetNewsgroupAsSubscribed((const char *)asciiName); } } } @@ -502,8 +503,70 @@ nsNntpIncomingServer::AddSubscribedNewsgroups() return NS_OK; } +nsresult +nsNntpIncomingServer::SetNewsgroupAsSubscribed(const char *aName) +{ + nsresult rv; + + NS_ASSERTION(aName,"newsgroup with no name"); + if (!aName) return NS_ERROR_FAILURE; + +#ifdef DEBUG_NEWS + printf("SetNewsgroupAsSubscribed(%s)\n",aName); +#endif + nsXPIDLCString serverUri; + + rv = GetServerURI(getter_Copies(serverUri)); + if (NS_FAILED(rv)) return rv; + + nsCAutoString groupUri; + groupUri = (const char *)serverUri; + groupUri += "/"; + groupUri += aName; + + nsCOMPtr rdfService = do_GetService(kRDFServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + if (!rdfService) return NS_ERROR_FAILURE; + + nsCOMPtr newsgroupResource; + rv = rdfService->GetResource((const char *) groupUri, getter_AddRefs(newsgroupResource)); + +#if 0 + nsCOMPtr totalMessagesLiteral; + nsAutoString totalMessagesString(aTotalMessages); + rv = rdfService->GetLiteral(totalMessagesString.GetUnicode(), getter_AddRefs(totalMessagesLiteral)); + if(NS_FAILED(rv)) return rv; + nsCOMPtr kNC_TotalMessages; + rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#TotalMessages", getter_AddRefs(kNC_TotalMessages)); + if(NS_FAILED(rv)) return rv; +#endif + + nsCOMPtr subscribedLiteral; + nsAutoString subscribedString("true"); + rv = rdfService->GetLiteral(subscribedString.GetUnicode(), getter_AddRefs(subscribedLiteral)); + if(NS_FAILED(rv)) return rv; + nsCOMPtr kNC_Subscribed; + rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#Subscribed", getter_AddRefs(kNC_Subscribed)); + if(NS_FAILED(rv)) return rv; + + nsCOMPtr ds; + rv = rdfService->GetDataSource("rdf:subscribe",getter_AddRefs(ds)); + if(NS_FAILED(rv)) return rv; + if (!ds) return NS_ERROR_FAILURE; + +#if 0 + rv = ds->Assert(newsgroupResource, kNC_TotalMessages, totalMessagesLiteral, PR_TRUE); + if(NS_FAILED(rv)) return rv; +#endif + + rv = ds->Assert(newsgroupResource, kNC_Subscribed, subscribedLiteral, PR_TRUE); + if(NS_FAILED(rv)) return rv; + + return NS_OK; +} + NS_IMETHODIMP -nsNntpIncomingServer::AddNewNewsgroup(const char *aName, const char *aState, const char *aCount) +nsNntpIncomingServer::AddNewNewsgroup(const char *aName) { nsresult rv; @@ -538,22 +601,6 @@ nsNntpIncomingServer::AddNewNewsgroup(const char *aName, const char *aState, con rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#Name", getter_AddRefs(kNC_Name)); if(NS_FAILED(rv)) return rv; - nsCOMPtr subscribedLiteral; - nsAutoString subscribedString(aState); - rv = rdfService->GetLiteral(subscribedString.GetUnicode(), getter_AddRefs(subscribedLiteral)); - if(NS_FAILED(rv)) return rv; - nsCOMPtr kNC_Subscribed; - rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#Subscribed", getter_AddRefs(kNC_Subscribed)); - if(NS_FAILED(rv)) return rv; - - nsCOMPtr countLiteral; - nsAutoString countString(aCount); - rv = rdfService->GetLiteral(countString.GetUnicode(), getter_AddRefs(countLiteral)); - if(NS_FAILED(rv)) return rv; - nsCOMPtr kNC_Count; - rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#Count", getter_AddRefs(kNC_Count)); - if(NS_FAILED(rv)) return rv; - nsCOMPtr ds; rv = rdfService->GetDataSource("rdf:subscribe",getter_AddRefs(ds)); if(NS_FAILED(rv)) return rv; @@ -561,10 +608,6 @@ nsNntpIncomingServer::AddNewNewsgroup(const char *aName, const char *aState, con rv = ds->Assert(newsgroupResource, kNC_Name, nameLiteral, PR_TRUE); if(NS_FAILED(rv)) return rv; - rv = ds->Assert(newsgroupResource, kNC_Subscribed, subscribedLiteral, PR_TRUE); - if(NS_FAILED(rv)) return rv; - rv = ds->Assert(newsgroupResource, kNC_Count, countLiteral, PR_TRUE); - if(NS_FAILED(rv)) return rv; nsCOMPtr kNC_Child; rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#child", getter_AddRefs(kNC_Child)); @@ -585,7 +628,6 @@ nsNntpIncomingServer::AddNewNewsgroup(const char *aName, const char *aState, con if(NS_FAILED(rv)) return rv; } - // if HasAssertion rv = ds->Assert(parent, kNC_Child, newsgroupResource, PR_TRUE); if(NS_FAILED(rv)) return rv; @@ -706,3 +748,17 @@ nsNntpIncomingServer::GetServerRequiresPasswordForBiff(PRBool *_retval) return NS_OK; } + +NS_IMETHODIMP +nsNntpIncomingServer::OnStartRunningUrl(nsIURI *url) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsNntpIncomingServer::OnStopRunningUrl(nsIURI *url, nsresult exitCode) +{ + nsresult rv; + rv = AddSubscribedNewsgroups(); + return rv; +} diff --git a/mailnews/news/src/nsNntpIncomingServer.h b/mailnews/news/src/nsNntpIncomingServer.h index d29dd4fa4d8..46aa20c5e7d 100644 --- a/mailnews/news/src/nsNntpIncomingServer.h +++ b/mailnews/news/src/nsNntpIncomingServer.h @@ -24,6 +24,7 @@ #define __nsNntpIncomingServer_h #include "nsINntpIncomingServer.h" +#include "nsIUrlListener.h" #include "nscore.h" #include "nsMsgIncomingServer.h" @@ -41,12 +42,14 @@ class nsIMsgMailNewsUrl; /* get some implementation from nsMsgIncomingServer */ class nsNntpIncomingServer : public nsMsgIncomingServer, - public nsINntpIncomingServer + public nsINntpIncomingServer, + public nsIUrlListener { public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSINNTPINCOMINGSERVER + NS_DECL_NSIURLLISTENER nsNntpIncomingServer(); virtual ~nsNntpIncomingServer(); @@ -63,6 +66,7 @@ protected: NS_IMETHOD GetServerRequiresPasswordForBiff(PRBool *_retval); private: + nsresult SetNewsgroupAsSubscribed(const char *aName); PRBool mNewsrcHasChanged; nsAdapterEnumerator *mGroupsEnumerator; }; diff --git a/mailnews/news/src/nsNntpService.cpp b/mailnews/news/src/nsNntpService.cpp index bef4b63ddd7..67ff073a56a 100644 --- a/mailnews/news/src/nsNntpService.cpp +++ b/mailnews/news/src/nsNntpService.cpp @@ -1247,17 +1247,15 @@ nsNntpService::BuildSubscribeDatasource(nsINntpIncomingServer *aNntpServer) uriStr += (const char *)serverUri; uriStr += "/*"; - rv = ConstructNntpUrl((const char *)uriStr, "", nsMsgKey_None, nsnull, getter_AddRefs(uri)); + nsCOMPtr listener = do_QueryInterface(aNntpServer, &rv); if (NS_FAILED(rv)) return rv; - -#if 0 - // first add the newsgroups we are subscribed to. - rv = aNntpServer->AddSubscribedNewsgroups(); + if (!listener) return NS_ERROR_FAILURE; + rv = ConstructNntpUrl((const char *)uriStr, "", nsMsgKey_None, listener, getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; -#endif // now run the url to add the rest of the groups - rv = RunNewsUrl(uri, nsnull, nsnull); + // TODO: pass in the nsIMsgWindow for progress. + rv = RunNewsUrl(uri, nsnull /* nsIMsgWindow */, nsnull); if (NS_FAILED(rv)) return rv; return NS_OK;