changes for news over SSL. initial changes needed for SMTP over SSL, but

that isn't going to happen yet.  cleanup changes for nsNewsDownloadDialogArgs (still not used yet.)
This commit is contained in:
sspitzer%netscape.com 2000-03-12 08:58:02 +00:00
Родитель bcb86c8e55
Коммит fa9ec86bb0
13 изменённых файлов: 116 добавлений и 53 удалений

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

@ -54,7 +54,7 @@ nsMsgProtocol::nsMsgProtocol(nsIURI * aURL, nsIURI* originalURI)
nsMsgProtocol::~nsMsgProtocol()
{}
nsresult nsMsgProtocol::OpenNetworkSocketWithInfo(const char * aHostName, PRInt32 aGetPort)
nsresult nsMsgProtocol::OpenNetworkSocketWithInfo(const char * aHostName, PRInt32 aGetPort, const char *connectionType)
{
NS_ENSURE_ARG(aHostName);
@ -65,14 +65,14 @@ nsresult nsMsgProtocol::OpenNetworkSocketWithInfo(const char * aHostName, PRInt3
m_readCount = -1; // with socket connections we want to read as much data as arrives
m_startPosition = 0;
rv = socketService->CreateTransport(aHostName, aGetPort, nsnull, 0, 0, getter_AddRefs(m_channel));
rv = socketService->CreateTransportOfType(connectionType, aHostName, aGetPort, nsnull, 0, 0, getter_AddRefs(m_channel));
if (NS_FAILED(rv)) return rv;
m_socketIsOpen = PR_FALSE;
return SetupTransportState();
}
nsresult nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL) // open a connection on this url
nsresult nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL, const char *connectionType) // open a connection on this url
{
NS_ENSURE_ARG(aURL);
nsresult rv = NS_OK;
@ -83,7 +83,7 @@ nsresult nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL) // open a connection on
aURL->GetPort(&port);
aURL->GetHost(getter_Copies(hostName));
return OpenNetworkSocketWithInfo(hostName, port);
return OpenNetworkSocketWithInfo(hostName, port, connectionType);
}
nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSpec, PRUint32 aStartPosition, PRInt32 aReadCount)

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

@ -68,8 +68,8 @@ protected:
// methods for opening and closing a socket with core netlib....
// mscott -okay this is lame. I should break this up into a file protocol and a socket based
// protocool class instead of cheating and putting both methods here...
virtual nsresult OpenNetworkSocket(nsIURI * aURL); // open a connection on this url
virtual nsresult OpenNetworkSocketWithInfo(const char * aHostName, PRInt32 aGetPort); // open a connection with a specific host and port
virtual nsresult OpenNetworkSocket(nsIURI * aURL, const char *connectionType); // open a connection on this url
virtual nsresult OpenNetworkSocketWithInfo(const char * aHostName, PRInt32 aGetPort, const char *connectionType); // open a connection with a specific host and port
virtual nsresult OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSpec, PRUint32 aStartPosition, PRInt32 aReadCount); // used to open a file socket connection
// a Protocol typically overrides this method. They free any of their own connection state and then

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

@ -317,8 +317,10 @@ void nsSmtpProtocol::Initialize(nsIURI * aURL)
rv = RequestOverrideInfo(smtpServer);
// if we aren't waiting for a login override, then go ahead an
// open the network connection like we normally would have.
if (NS_FAILED(rv) || !TestFlag(SMTP_WAIT_FOR_REDIRECTION))
rv = OpenNetworkSocket(aURL);
if (NS_FAILED(rv) || !TestFlag(SMTP_WAIT_FOR_REDIRECTION)) {
// pass in "ssl" for the last arg if you want this to be over SSL
rv = OpenNetworkSocket(aURL, nsnull);
}
}
const char * nsSmtpProtocol::GetUserDomainName()
@ -1647,7 +1649,8 @@ NS_IMETHODIMP nsSmtpProtocol::OnLogonRedirectionReply(const PRUnichar * aHost, u
// now that we have a host and port to connect to,
// open up the channel...
rv = OpenNetworkSocketWithInfo(nsCAutoString(aHost), aPort);
// pass in "ssl" for the last arg if you want this to be over SSL
rv = OpenNetworkSocketWithInfo(nsCAutoString(aHost), aPort, nsnull);
// we are no longer waiting for a logon redirection reply
ClearFlag(SMTP_WAIT_FOR_REDIRECTION);

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

@ -89,6 +89,12 @@ typedef enum _PrefAuthMethod {
PREF_AUTH_TLS_ONLY = 4
} PrefAuthMethod;
typedef enum _PrefTrySSL {
PREF_NO_SSL = 0,
PREF_TRY_SSL = 1,
PREF_ALWAYS_SSL = 2
} PrefTrySSL;
class nsSmtpProtocol : public nsMsgProtocol,
public nsIMsgLogonRedirectionRequester
{

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

@ -418,7 +418,8 @@ nsresult nsPop3Protocol::Initialize(nsIURI * aURL)
}
m_url = do_QueryInterface(aURL);
rv = OpenNetworkSocket(aURL);
// if the server is secure, pass in "ssl" for the last arg
rv = OpenNetworkSocket(aURL, nsnull);
if(NS_FAILED(rv))
return rv;
} // if we got a url...

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

@ -148,5 +148,4 @@
0x196b4b30, 0xe18c, 0x11d2, \
{ 0x80, 0x6e, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e } }
#endif // nsMsgNewsCID_h__

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

@ -24,7 +24,7 @@
#include "nsISupports.idl"
[scriptable, uuid(b5037f06-1dd1-11b2-bf61-fcab5b5837a7)]
interface nsINewsDownloadHeadersDialogArgs: nsISupports {
interface nsINewsDownloadDialogArgs: nsISupports {
attribute string groupName;
attribute long articleCount;
attribute string serverKey;

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

@ -18,6 +18,7 @@
* Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
* Pierre Phaneuf <pp@ludusdesign.com>
*/

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

@ -87,6 +87,9 @@
#include "nsINetPrompt.h"
#include "nntpCore.h"
#undef GetPort // XXX Windows!
#undef SetPort // XXX Windows!
#define DEFAULT_NEWS_CHUNK_SIZE -1
// ***jt -- the following were pirated from xpcom/io/nsByteBufferInputStream
@ -465,6 +468,7 @@ nsresult nsNNTPProtocol::Initialize(void)
{
nsresult rv = NS_OK;
net_NewsChunkSize = DEFAULT_NEWS_CHUNK_SIZE;
PRBool isSecure = PR_FALSE;
rv = m_url->GetHost(getter_Copies(m_hostName));
if (NS_FAILED(rv)) return rv;
@ -472,8 +476,7 @@ nsresult nsNNTPProtocol::Initialize(void)
if (NS_FAILED(rv)) return rv;
// retrieve the AccountManager
NS_WITH_SERVICE(nsIMsgAccountManager, accountManager,
NS_MSGACCOUNTMANAGER_PROGID, &rv);
NS_WITH_SERVICE(nsIMsgAccountManager, accountManager, NS_MSGACCOUNTMANAGER_PROGID, &rv);
if (NS_FAILED(rv)) return rv;
// find the news host
@ -492,8 +495,25 @@ nsresult nsNNTPProtocol::Initialize(void)
net_NewsChunkSize = max_articles;
}
}
rv = server->GetIsSecure(&isSecure);
if (NS_FAILED(rv)) return rv;
}
PRInt32 port = 0;
rv = m_url->GetPort(&port);
if (NS_FAILED(rv) || !port || (port == -1)) {
if (isSecure) {
port = SECURE_NEWS_PORT;
}
else {
port = NEWS_PORT;
}
rv = m_url->SetPort(port);
if (NS_FAILED(rv)) return rv;
}
NS_PRECONDITION(m_url, "invalid URL passed into NNTP Protocol");
// Right now, we haven't written an nsNNTPURL yet. When we do, we'll pull the event sink
@ -517,9 +537,13 @@ nsresult nsNNTPProtocol::Initialize(void)
return rv;
}
// call base class to set up the transport
rv = OpenNetworkSocket(m_url);
if (isSecure) {
rv = OpenNetworkSocket(m_url, "ssl");
}
else {
rv = OpenNetworkSocket(m_url, nsnull);
}
m_dataBuf = (char *) PR_Malloc(sizeof(char) * OUTPUT_BUFFER_SIZE);
m_dataBufSize = OUTPUT_BUFFER_SIZE;
@ -624,7 +648,6 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
if (!m_newsHost)
{
PRInt32 port = 0;
aURL->GetPort(&port);
rv = nsComponentManager::CreateInstance(kNNTPHostCID,
nsnull,
@ -637,20 +660,38 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
// m_newsHost holds m_runningURL (make this a weak reference)
// m_runningURL holds m_newsHost
// need to make sure there is no cycle.
m_newsHost->Initialize(m_runningURL, m_userName, m_hostName, port ? port : NEWS_PORT);
// retrieve the AccountManager
NS_WITH_SERVICE(nsIMsgAccountManager, accountManager, NS_MSGACCOUNTMANAGER_PROGID, &rv);
if (NS_FAILED(rv)) goto FAIL;
// find the news host
nsCOMPtr<nsIMsgIncomingServer> server;
rv = accountManager->FindServer(m_userName,
m_hostName,
"nntp",
getter_AddRefs(server));
if (NS_FAILED(rv)) goto FAIL;
PRBool isSecure = PR_FALSE;
rv = server->GetIsSecure(&isSecure);
if (NS_FAILED(rv)) goto FAIL;
if (!port) {
if (isSecure) {
port = SECURE_NEWS_PORT;
}
else {
port = NEWS_PORT;
}
}
m_newsHost->Initialize(m_runningURL, m_userName, m_hostName, port);
// save it on our url for future use....
m_runningURL->SetNntpHost(m_newsHost);
#if SETH_HACK
// read in the newsrc file now, to build up the host correctly.
char *newshosturi = PR_smprintf("%s/%s", kNewsRootURI, hostAndPort /* really just hostname */);
rv = m_newsHost->LoadNewsrc(newshosturi);
PR_FREEIF(newshosturi);
#endif
if (NS_FAILED(rv))
goto FAIL;
if (NS_FAILED(rv)) goto FAIL;
}
if (NS_FAILED(rv))

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

@ -21,10 +21,10 @@
* Seth Spitzer <sspitzer@netscape.com>
*/
#include "nsNewsDownloadHeadersDialogArgs.h"
#include "nsNewsDownloadDialogArgs.h"
#include "nsCRT.h"
nsNewsDownloadHeadersDialogArgs::nsNewsDownloadHeadersDialogArgs()
nsNewsDownloadDialogArgs::nsNewsDownloadDialogArgs()
{
NS_INIT_REFCNT();
@ -35,13 +35,13 @@ nsNewsDownloadHeadersDialogArgs::nsNewsDownloadHeadersDialogArgs()
mDownloadAll = PR_FALSE;
}
nsNewsDownloadHeadersDialogArgs::~nsNewsDownloadHeadersDialogArgs()
nsNewsDownloadDialogArgs::~nsNewsDownloadDialogArgs()
{
}
NS_IMPL_ISUPPORTS(nsNewsDownloadHeadersDialogArgs, NS_GET_IID(nsINewsDownloadHeadersDialogArgs));
NS_IMPL_ISUPPORTS(nsNewsDownloadDialogArgs, NS_GET_IID(nsINewsDownloadDialogArgs));
NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::GetGroupName(char * *aGroupName)
NS_IMETHODIMP nsNewsDownloadDialogArgs::GetGroupName(char * *aGroupName)
{
NS_ENSURE_ARG_POINTER(aGroupName);
@ -49,7 +49,7 @@ NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::GetGroupName(char * *aGroupName)
return NS_OK;
}
NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::SetGroupName(const char * aGroupName)
NS_IMETHODIMP nsNewsDownloadDialogArgs::SetGroupName(const char * aGroupName)
{
NS_ENSURE_ARG_POINTER(aGroupName);
@ -57,7 +57,7 @@ NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::SetGroupName(const char * aGroupN
return NS_OK;
}
NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::GetArticleCount(PRInt32 *aArticleCount)
NS_IMETHODIMP nsNewsDownloadDialogArgs::GetArticleCount(PRInt32 *aArticleCount)
{
NS_ENSURE_ARG_POINTER(aArticleCount);
@ -65,20 +65,20 @@ NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::GetArticleCount(PRInt32 *aArticle
return NS_OK;
}
NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::SetArticleCount(PRInt32 aArticleCount)
NS_IMETHODIMP nsNewsDownloadDialogArgs::SetArticleCount(PRInt32 aArticleCount)
{
mArticleCount = aArticleCount;
return NS_OK;
}
NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::GetServerKey(char * *aServerKey)
NS_IMETHODIMP nsNewsDownloadDialogArgs::GetServerKey(char * *aServerKey)
{
NS_ENSURE_ARG_POINTER(aServerKey);
*aServerKey = nsCRT::strdup((const char *)mServerKey);
return NS_OK;
}
NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::SetServerKey(const char * aServerKey)
NS_IMETHODIMP nsNewsDownloadDialogArgs::SetServerKey(const char * aServerKey)
{
NS_ENSURE_ARG_POINTER(aServerKey);
@ -86,7 +86,7 @@ NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::SetServerKey(const char * aServer
return NS_OK;
}
NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::GetHitOK(PRBool *aHitOK)
NS_IMETHODIMP nsNewsDownloadDialogArgs::GetHitOK(PRBool *aHitOK)
{
NS_ENSURE_ARG_POINTER(aHitOK);
@ -94,13 +94,13 @@ NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::GetHitOK(PRBool *aHitOK)
return NS_OK;
}
NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::SetHitOK(PRBool aHitOK)
NS_IMETHODIMP nsNewsDownloadDialogArgs::SetHitOK(PRBool aHitOK)
{
mHitOK = aHitOK;
return NS_OK;
}
NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::GetDownloadAll(PRBool *aDownloadAll)
NS_IMETHODIMP nsNewsDownloadDialogArgs::GetDownloadAll(PRBool *aDownloadAll)
{
NS_ENSURE_ARG_POINTER(aDownloadAll);
@ -108,7 +108,7 @@ NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::GetDownloadAll(PRBool *aDownloadA
return NS_OK;
}
NS_IMETHODIMP nsNewsDownloadHeadersDialogArgs::SetDownloadAll(PRBool aDownloadAll)
NS_IMETHODIMP nsNewsDownloadDialogArgs::SetDownloadAll(PRBool aDownloadAll)
{
mDownloadAll = aDownloadAll;

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

@ -21,20 +21,20 @@
* Seth Spitzer <sspitzer@netscape.com>
*/
#ifndef nsNewsDownloadHeadersDialogArgs_h__
#define nsNewsDownloadHeadersDialogArgs_h__
#ifndef nsNewsDownloadDialogArgs_h__
#define nsNewsDownloadDialogArgs_h__
#include "nsINewsDownloadHeadersDialogArgs.h"
#include "nsINewsDownloadDialogArgs.h"
#include "nsString.h"
class nsNewsDownloadHeadersDialogArgs : public nsINewsDownloadHeadersDialogArgs
class nsNewsDownloadDialogArgs : public nsINewsDownloadDialogArgs
{
public:
nsNewsDownloadHeadersDialogArgs();
virtual ~nsNewsDownloadHeadersDialogArgs();
nsNewsDownloadDialogArgs();
virtual ~nsNewsDownloadDialogArgs();
NS_DECL_ISUPPORTS
NS_DECL_NSINEWSDOWNLOADHEADERSDIALOGARGS
NS_DECL_NSINEWSDOWNLOADDIALOGARGS
private:
nsCString mGroupName;
@ -44,4 +44,4 @@ private:
PRBool mDownloadAll;
};
#endif // nsNewsDownloadHeadersDialogArgs_h__
#endif // nsNewsDownloadDialogArgs_h__

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

@ -1195,7 +1195,20 @@ nsresult nsMsgNewsFolder::CreateNewsgroupUrlForSignon(const char *inUriStr, cons
if (NS_FAILED(rv)) return rv;
if (port <= 0) {
rv = url->SetPort(NEWS_PORT);
nsCOMPtr<nsIMsgIncomingServer> server;
rv = GetServer(getter_AddRefs(server));
if (NS_FAILED(rv)) return rv;
PRBool isSecure = PR_FALSE;
rv = server->GetIsSecure(&isSecure);
if (NS_FAILED(rv)) return rv;
if (isSecure) {
rv = url->SetPort(SECURE_NEWS_PORT);
}
else {
rv = url->SetPort(NEWS_PORT);
}
if (NS_FAILED(rv)) return rv;
}

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

@ -18,6 +18,8 @@
* Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
* Scott MacGregor <mscott@netscape.com>
* Pierre Phaneuf <pp@ludusdesign.com>
*/
@ -747,7 +749,6 @@ nsresult nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgro
if (!mailnewsurl) return NS_ERROR_FAILURE;
mailnewsurl->SetSpec((const char *)newsUrlSpec);
mailnewsurl->SetPort(NEWS_PORT);
if (aUrlListener) // register listener if there is one...
mailnewsurl->RegisterListener(aUrlListener);
@ -793,7 +794,6 @@ nsresult nsNntpService::ConstructNntpUrl(const char * urlString, const char * ne
// don't worry this cast is really okay...there'a bug in XPIDL compiler that is preventing
// a "cont char *" in paramemter for uri SetSpec...
mailnewsurl->SetSpec((char *) urlString);
mailnewsurl->SetPort(NEWS_PORT);
if (newsgroupName != "") {
nsCOMPtr <nsINNTPNewsgroup> newsgroup;
@ -1039,7 +1039,6 @@ NS_IMETHODIMP nsNntpService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
// don't worry this cast is really okay...there'a bug in XPIDL compiler that is preventing
// a "cont char *" in paramemter for uri SetSpec...
(*_retval)->SetSpec((char *) aSpec);
(*_retval)->SetPort(NEWS_PORT);
return rv;
}