changes to get news to work at the same time as imap and pop. the news part of the fix for #6405

git-svn-id: svn://10.0.0.236/trunk@32098 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sspitzer%netscape.com
1999-05-18 21:46:56 +00:00
parent 512e2c9a82
commit 5d61031095
4 changed files with 60 additions and 10 deletions

View File

@@ -1083,8 +1083,8 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetNewMessages()
NS_WITH_SERVICE(nsIPop3Service, pop3Service, kCPop3ServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgIncomingServer> server;
rv = GetServer(getter_AddRefs(server));
nsCOMPtr<nsIMsgIncomingServer> server;
rv = GetServer(getter_AddRefs(server));
nsCOMPtr<nsIPop3IncomingServer> popServer;
rv = server->QueryInterface(nsIPop3IncomingServer::GetIID(),

View File

@@ -1013,7 +1013,19 @@ NS_IMETHODIMP nsMsgNewsFolder::GetUsersName(char** userName)
NS_IMETHODIMP nsMsgNewsFolder::GetHostName(char** hostName)
{
return NS_OK;
nsresult rv;
char *host = nsnull;
rv = nsGetNewsHostName(kNewsRootURI, mURI, &host);
//I'm recopying it because otherwise we'll have a free mismatched memory.
//We should really be using allocators to do all of this.
if(NS_SUCCEEDED(rv) && host)
{
*hostName = PL_strdup(host);
delete[] host;
if(!*hostName)
return NS_ERROR_OUT_OF_MEMORY;
}
return rv;
}
NS_IMETHODIMP nsMsgNewsFolder::UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *authenticate)
@@ -1090,16 +1102,13 @@ NS_IMETHODIMP nsMsgNewsFolder::GetNewMessages()
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;
NS_WITH_SERVICE(nsINntpService, nntpService, kNntpServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
//Are we assured this is the server for this folder?
nsCOMPtr<nsIMsgIncomingServer> server;
rv = mailSession->GetCurrentServer(getter_AddRefs(server));
rv = GetServer(getter_AddRefs(server));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsINntpIncomingServer> nntpServer;
@@ -1111,8 +1120,8 @@ NS_IMETHODIMP nsMsgNewsFolder::GetNewMessages()
#endif
rv = nntpService->GetNewNews(nsnull,nntpServer,nsnull,mURI);
}
return rv;
return rv;
}
NS_IMETHODIMP nsMsgNewsFolder::CreateMessageFromMsgDBHdr(nsIMsgDBHdr *msgDBHdr, nsIMessage **message)

View File

@@ -75,6 +75,44 @@ nsGetNewsRoot(const char *hostname, nsFileSpec &result)
return rv;
}
// copy-and-paste from nsGetMailboxHostName()
// we could probably combine them in a common place to save
// space.
nsresult nsGetNewsHostName(const char *rootURI, const char *uriStr, char **hostName)
{
if(!hostName)
return NS_ERROR_NULL_POINTER;
nsAutoString uri = uriStr;
if (uri.Find(rootURI) != 0) // if doesn't start with rootURI
return NS_ERROR_FAILURE;
// start parsing the uriStr
const char* curPos = uriStr;
// skip past schema
while (*curPos != ':') curPos++;
curPos++;
while (*curPos == '/') curPos++;
char *slashPos = PL_strchr(curPos, '/');
int length;
// if there are no more /'s then we just copy the rest of the string
if (slashPos)
length = (slashPos - curPos) + 1;
else
length = PL_strlen(curPos) + 1;
*hostName = new char[length];
if(!*hostName)
return NS_ERROR_OUT_OF_MEMORY;
PL_strncpyz(*hostName, curPos, length);
return NS_OK;
}
nsresult
nsNewsURI2Path(const char* rootURI, const char* uriStr, nsFileSpec& pathResult)
{

View File

@@ -53,6 +53,9 @@ static const char kNewsMessageRootURI[] = "news_message:/";
extern nsresult
nsGetNewsRoot(const char* hostname, nsFileSpec &result);
extern nsresult
nsGetNewsHostName(const char *rootURI, const char *uriStr, char **hostName);
extern nsresult
nsNewsURI2Path(const char* rootURI, const char* uriStr, nsFileSpec& pathResult);