Updates to include the fact that Initialialzing the protocol instance no longer requires the

transport object to be created. It does it for you. These changes are related to my
nsMsgProtocol changes.
This commit is contained in:
mscott%netscape.com 1999-06-06 18:39:56 +00:00
Родитель 882a2de9af
Коммит d0d08e4abb
1 изменённых файлов: 114 добавлений и 154 удалений

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

@ -260,17 +260,10 @@ nsresult nsNntpService::PostMessage(nsFilePath &pathToFile, const char *subject,
// for now, assume the url is a news url and load it....
nsINntpUrl *nntpUrl = nsnull;
nsCOMPtr<nsINetService> pNetService;
nsCOMPtr<nsITransport> transport;
nsNNTPProtocol *nntpProtocol = nsnull;
nsresult rv = NS_OK;
// make sure we have a netlib service around...
rv = NS_NewINetService(getter_AddRefs(pNetService), nsnull);
if (NS_SUCCEEDED(rv) && pNetService) {
rv = nsComponentManager::CreateInstance(kNntpUrlCID, nsnull, nsINntpUrl::GetIID(), (void **)
&nntpUrl);
rv = nsComponentManager::CreateInstance(kNntpUrlCID, nsnull, nsINntpUrl::GetIID(), (void **) &nntpUrl);
if (NS_SUCCEEDED(rv) && nntpUrl) {
printf("hardcoding the server name. right now, we can only post to news.mozilla.org\n");
@ -296,26 +289,15 @@ nsresult nsNntpService::PostMessage(nsFilePath &pathToFile, const char *subject,
if (aUrlListener) // register listener if there is one...
nntpUrl->RegisterListener(aUrlListener);
rv = nntpUrl->GetHostPort(&port);
if (NS_FAILED(rv)) {
return rv;
}
rv = nntpUrl->GetHost(&hostname);
if (NS_FAILED(rv)) {
return rv;
}
// okay now create a transport to run the url in...
#ifdef DEBUG_NEWS
printf("nsNntpService::RunNewsUrl(): hostname = %s port = %d\n", hostname, port);
#endif
pNetService->CreateSocketTransport(getter_AddRefs(transport), port, hostname);
if (NS_SUCCEEDED(rv) && transport)
{
// almost there...now create a nntp protocol instance to run the url in...
nntpProtocol = new nsNNTPProtocol();
if (nntpProtocol) {
rv = nntpProtocol->Initialize(nntpUrl, transport);
rv = nntpProtocol->Initialize(nntpUrl);
if (NS_FAILED(rv)) return rv;
// get the current identity from the news session....
NS_WITH_SERVICE(nsIMsgMailSession,newsSession,kCMsgMailSessionCID,&rv);
@ -369,10 +351,7 @@ nsresult nsNntpService::PostMessage(nsFilePath &pathToFile, const char *subject,
if (NS_SUCCEEDED(rv)) {
PRInt32 status = 0;
rv = nntpProtocol->LoadURL(nntpUrl, /* aConsumer */ nsnull, &status);
}
}
//delete nntpProtocol?
rv = nntpProtocol->LoadUrl(nntpUrl, /* aConsumer */ nsnull, &status);
}
if (_retval)
@ -395,16 +374,9 @@ nsNntpService::RunNewsUrl(nsString& urlString, nsISupports * aConsumer, nsIUrlLi
#endif
// for now, assume the url is a news url and load it....
nsINntpUrl *nntpUrl = nsnull;
nsCOMPtr<nsINetService> pNetService;
nsCOMPtr<nsITransport> transport;
nsNNTPProtocol *nntpProtocol = nsnull;
nsresult rv = NS_OK;
// make sure we have a netlib service around...
rv = NS_NewINetService(getter_AddRefs(pNetService), nsnull);
if (NS_SUCCEEDED(rv) && pNetService)
{
rv = nsComponentManager::CreateInstance(kNntpUrlCID, nsnull, nsINntpUrl::GetIID(), (void **) &nntpUrl);
if (NS_SUCCEEDED(rv) && nntpUrl) {
@ -426,41 +398,29 @@ nsNntpService::RunNewsUrl(nsString& urlString, nsISupports * aConsumer, nsIUrlLi
nntpUrl->SetNewsgroup(newsgroup);
const char * hostname = nsnull;
PRUint32 port = NEWS_PORT;
if (aUrlListener) // register listener if there is one...
nntpUrl->RegisterListener(aUrlListener);
nntpUrl->GetHostPort(&port);
nntpUrl->GetHost(&hostname);
// okay now create a transport to run the url in...
#ifdef DEBUG_NEWS
printf("nsNntpService::RunNewsUrl(): hostname = %s port = %d\n", hostname, port);
#endif
pNetService->CreateSocketTransport(getter_AddRefs(transport), port, hostname);
//PR_FREEIF(hostname);
if (NS_SUCCEEDED(rv) && transport) {
// almost there...now create a nntp protocol instance to run the url in...
nntpProtocol = new nsNNTPProtocol();
if (nntpProtocol) {
PRInt32 status = 0;
rv = nntpProtocol->Initialize(nntpUrl, transport);
rv = nntpProtocol->Initialize(nntpUrl);
if (NS_FAILED(rv)) return rv;
rv = nntpProtocol->LoadURL(nntpUrl, aConsumer, &status);
rv = nntpProtocol->LoadUrl(nntpUrl, aConsumer, &status);
if (NS_FAILED(rv)) return rv;
}
//delete nntpProtocol;
}
if (_retval)
*_retval = nntpUrl; // transfer ref count
else
NS_RELEASE(nntpUrl);
}
}
return rv;
}