mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-09 13:25:00 +00:00
work to make "Get Messages" work for newsgroups. right now, it is only on a newsgroup
by newsgroup level. getting new news for a news server won't do anything.
This commit is contained in:
parent
716aaad46d
commit
aacb74a83f
@ -65,7 +65,8 @@ public:
|
||||
|
||||
NS_IMETHOD GetNewNews(nsIUrlListener * aUrlListener,
|
||||
nsINntpIncomingServer *nntpServer,
|
||||
nsIURL ** aURL) = 0;
|
||||
nsIURL ** aURL,
|
||||
const char *uri) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsINntpService_h___ */
|
||||
|
@ -139,10 +139,10 @@ PRBool
|
||||
nsMsgNewsFolder::isNewsHost()
|
||||
{
|
||||
// this will do for now. Eventually, this will go away...
|
||||
PRInt32 mURIlen = PL_strlen(mURI);
|
||||
PRInt32 uriLen = PL_strlen(mURI);
|
||||
|
||||
// if we are shorter than news://, we are too short to be a host
|
||||
if (mURIlen <= kNewsRootURILen) {
|
||||
if (uriLen <= kNewsRootURILen) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@ -545,7 +545,6 @@ nsMsgNewsFolder::GetMessages(nsIEnumerator* *result)
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsMsgNewsFolder::BuildFolderURL(char **url)
|
||||
{
|
||||
const char *urlScheme = "news:";
|
||||
@ -1007,8 +1006,13 @@ NS_IMETHODIMP nsMsgNewsFolder::GetNewMessages()
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("GetNewMessages (for news)\n");
|
||||
printf("GetNewMessages (for news) uri = %s\n",mURI);
|
||||
#endif
|
||||
|
||||
if (isNewsHost()) {
|
||||
printf("sorry, can't get news for entire news server yet. try it on a newsgroup by newsgroup level\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -1028,7 +1032,7 @@ NS_IMETHODIMP nsMsgNewsFolder::GetNewMessages()
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("Getting new news articles....\n");
|
||||
#endif
|
||||
rv = nntpService->GetNewNews(nsnull,nntpServer,nsnull);
|
||||
rv = nntpService->GetNewNews(nsnull,nntpServer,nsnull,mURI);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -143,7 +143,6 @@ nsresult nsNntpService::ConvertNewsMessageURI2NewsURI(const char *messageURI, ns
|
||||
PRUint32 key;
|
||||
|
||||
// messageURI is of the form: news_message://news.mcom.com/mcom.linux#1
|
||||
|
||||
rv = nsParseNewsMessageURI(messageURI, folder, &key);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
@ -300,7 +299,9 @@ nsNntpService::RunNewsUrl(const nsString& urlString, nsISupports * aConsumer,
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// make sure we have a netlib service around...
|
||||
rv = NS_NewINetService(&pNetService, nsnull);
|
||||
rv = NS_NewINetService(&pNetService, nsnull);
|
||||
|
||||
|
||||
|
||||
if (NS_SUCCEEDED(rv) && pNetService)
|
||||
{
|
||||
@ -309,19 +310,31 @@ nsNntpService::RunNewsUrl(const nsString& urlString, nsISupports * aConsumer,
|
||||
|
||||
if (NS_SUCCEEDED(rv) && nntpUrl) {
|
||||
char * urlSpec = urlString.ToNewCString();
|
||||
|
||||
nntpUrl->SetSpec(urlSpec);
|
||||
|
||||
char *newsgroupName = nsnull;
|
||||
nsAutoString nameStr;
|
||||
nsNewsURI2Name(kNewsRootURI, urlSpec, nameStr);
|
||||
newsgroupName = nameStr.ToNewCString();
|
||||
|
||||
if (urlSpec) {
|
||||
delete [] urlSpec;
|
||||
}
|
||||
|
||||
|
||||
nsINNTPNewsgroup *newsgroup = nsnull;
|
||||
rv = NS_NewNewsgroup(&newsgroup, nsnull /* line */, nsnull /* set */, PR_FALSE /* subscribed */, nsnull /* host*/, 1 /* depth */);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// hard coded for now, until I get the wiring worked out...
|
||||
newsgroup->SetName("netscape.test");
|
||||
if (NS_SUCCEEDED(rv) && newsgroup) {
|
||||
newsgroup->SetName(newsgroupName);
|
||||
if (newsgroupName) {
|
||||
delete [] newsgroupName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (newsgroupName) {
|
||||
delete [] newsgroupName;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
nntpUrl->SetNewsgroup(newsgroup);
|
||||
@ -362,14 +375,17 @@ nsNntpService::RunNewsUrl(const nsString& urlString, nsISupports * aConsumer,
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult nsNntpService::GetNewNews(nsIUrlListener * aUrlListener,
|
||||
nsINntpIncomingServer *nntpServer,
|
||||
nsIURL ** aURL)
|
||||
nsIURL ** aURL,
|
||||
const char *uri)
|
||||
{
|
||||
if (!uri) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
#if DEBUG_sspitzer
|
||||
printf("nsNntpService::GetNewNews()\n");
|
||||
printf("nsNntpService::GetNewNews(%s)\n", uri);
|
||||
#endif
|
||||
|
||||
NS_LOCK_INSTANCE();
|
||||
@ -384,12 +400,14 @@ nsresult nsNntpService::GetNewNews(nsIUrlListener * aUrlListener,
|
||||
// convert normal host to nntp host.
|
||||
// XXX - this doesn't handle QI failing very well
|
||||
if (server) {
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("server != nsnull\n");
|
||||
#endif
|
||||
// load up required server information
|
||||
server->GetHostName(&nntpHostName);
|
||||
}
|
||||
#ifdef DEBUG_sspitzer
|
||||
else {
|
||||
printf("server == nsnull\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_sspitzer
|
||||
if (nntpHostName) {
|
||||
@ -400,8 +418,7 @@ nsresult nsNntpService::GetNewNews(nsIUrlListener * aUrlListener,
|
||||
}
|
||||
#endif
|
||||
|
||||
// hard coded for now, until I get the wiring worked out.
|
||||
rv = RunNewsUrl("news://news.mozilla.org/netscape.test", nsnull, aUrlListener, aURL);
|
||||
rv = RunNewsUrl(uri, nsnull, aUrlListener, aURL);
|
||||
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return rv;
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
|
||||
NS_IMETHOD PostMessage(nsFilePath &pathToFile, const char *subject, const char *newsgroup, nsIUrlListener * aUrlListener, nsIURL ** aURL);
|
||||
|
||||
NS_IMETHOD GetNewNews(nsIUrlListener * aUrlListener, nsINntpIncomingServer *nntpServer, nsIURL ** aURL);
|
||||
NS_IMETHOD GetNewNews(nsIUrlListener * aUrlListener, nsINntpIncomingServer *nntpServer, nsIURL ** aURL, const char *uri);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// we suppport the nsIMsgMessageService Interface
|
||||
|
Loading…
Reference in New Issue
Block a user