whitespace cleanup, no bug, r/sr=me

This commit is contained in:
bienvenu%nventure.com 2003-09-11 02:08:36 +00:00
Родитель 373aa252e0
Коммит 2bd7bc30d7
1 изменённых файлов: 141 добавлений и 139 удалений

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

@ -81,13 +81,13 @@ static PRUnichar *FormatStringWithHostNameByID(PRInt32 stringID, nsIMsgMailNewsU
nsMsgProtocol::nsMsgProtocol(nsIURI * aURL)
{
m_flags = 0;
m_readCount = 0;
mLoadFlags = 0;
m_socketIsOpen = PR_FALSE;
m_flags = 0;
m_readCount = 0;
mLoadFlags = 0;
m_socketIsOpen = PR_FALSE;
m_tempMsgFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
m_tempMsgFileSpec += "tempMessage.eml";
m_tempMsgFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
m_tempMsgFileSpec += "tempMessage.eml";
mSuppressListenerNotifications = PR_FALSE;
InitFromURI(aURL);
}
@ -95,11 +95,11 @@ nsMsgProtocol::nsMsgProtocol(nsIURI * aURL)
nsresult nsMsgProtocol::InitFromURI(nsIURI *aUrl)
{
m_url = aUrl;
nsCOMPtr <nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUrl);
if (mailUrl)
nsCOMPtr <nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUrl);
if (mailUrl)
{
mailUrl->GetLoadGroup(getter_AddRefs(m_loadGroup));
mailUrl->GetLoadGroup(getter_AddRefs(m_loadGroup));
nsCOMPtr<nsIMsgStatusFeedback> statusFeedback;
mailUrl->GetStatusFeedback(getter_AddRefs(statusFeedback));
mProgressEventSink = do_QueryInterface(statusFeedback);
@ -166,7 +166,8 @@ nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL, const char *connectionType,
NS_ASSERTION(pps, "Couldn't get the protocol proxy service!");
if (pps) {
if (pps)
{
nsresult rv = NS_OK;
// Yes, this is ugly. But necko needs to grap a protocol handler
@ -179,12 +180,13 @@ nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL, const char *connectionType,
// do _NOT_ copy this to use in your own code - bbaetz
nsCOMPtr<nsIURI> proxyUri = aURL;
PRBool isSMTP = PR_FALSE;
if (NS_SUCCEEDED(aURL->SchemeIs("smtp", &isSMTP)) && isSMTP) {
if (NS_SUCCEEDED(aURL->SchemeIs("smtp", &isSMTP)) && isSMTP)
{
nsCAutoString spec;
rv = aURL->GetSpec(spec);
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(rv))
proxyUri = do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv);
}
if (NS_SUCCEEDED(rv))
rv = proxyUri->SetSpec(spec);
if (NS_SUCCEEDED(rv))
@ -224,11 +226,11 @@ nsresult nsMsgProtocol::GetFileFromURL(nsIURI * aURL, nsIFile **aResult)
nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, PRUint32 aStartPosition, PRInt32 aReadCount)
{
// mscott - file needs to be encoded directly into aURL. I should be able to get
// rid of this method completely.
// mscott - file needs to be encoded directly into aURL. I should be able to get
// rid of this method completely.
nsresult rv = NS_OK;
m_readCount = aReadCount;
nsresult rv = NS_OK;
m_readCount = aReadCount;
nsCOMPtr <nsIFile> file;
rv = GetFileFromURL(aURL, getter_AddRefs(file));
@ -251,27 +253,27 @@ nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, PRUint32 aStartPosition, P
nsresult nsMsgProtocol::SetupTransportState()
{
if (!m_socketIsOpen && m_transport)
{
if (!m_socketIsOpen && m_transport)
{
nsresult rv;
// open buffered, blocking output stream
rv = m_transport->OpenOutputStream(nsITransport::OPEN_BLOCKING, 0, 0, getter_AddRefs(m_outputStream));
rv = m_transport->OpenOutputStream(nsITransport::OPEN_BLOCKING, 0, 0, getter_AddRefs(m_outputStream));
if (NS_FAILED(rv)) return rv;
// we want to open the stream
} // if m_transport
return NS_OK;
// we want to open the stream
} // if m_transport
return NS_OK;
}
nsresult nsMsgProtocol::CloseSocket()
{
nsresult rv = NS_OK;
// release all of our socket state
m_socketIsOpen = PR_FALSE;
nsresult rv = NS_OK;
// release all of our socket state
m_socketIsOpen = PR_FALSE;
m_inputStream = nsnull;
m_outputStream = nsnull;
m_outputStream = nsnull;
if (m_transport) {
nsCOMPtr<nsISocketTransport> strans = do_QueryInterface(m_transport);
if (strans) {
@ -279,74 +281,72 @@ nsresult nsMsgProtocol::CloseSocket()
strans->SetEventSink(nsnull, nsnull); // break cyclic reference!
}
}
// we need to call Cancel so that we remove the socket transport from the mActiveTransportList. see bug #30648
if (m_request) {
rv = m_request->Cancel(NS_BINDING_ABORTED);
}
// we need to call Cancel so that we remove the socket transport from the mActiveTransportList. see bug #30648
if (m_request) {
rv = m_request->Cancel(NS_BINDING_ABORTED);
}
m_request = 0;
if (m_transport) {
m_transport->Close(NS_BINDING_ABORTED);
m_transport = 0;
}
return rv;
return rv;
}
/*
* Writes the data contained in dataBuffer into the current output stream. It also informs
* the transport layer that this data is now available for transmission.
* Returns a positive number for success, 0 for failure (not all the bytes were written to the
* stream, etc). We need to make another pass through this file to install an error system (mscott)
*
* No logging is done in the base implementation, so aSuppressLogging is ignored.
*/
* Writes the data contained in dataBuffer into the current output stream. It also informs
* the transport layer that this data is now available for transmission.
* Returns a positive number for success, 0 for failure (not all the bytes were written to the
* stream, etc). We need to make another pass through this file to install an error system (mscott)
*
* No logging is done in the base implementation, so aSuppressLogging is ignored.
*/
PRInt32 nsMsgProtocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSuppressLogging)
{
PRUint32 writeCount = 0;
PRInt32 status = 0;
// NS_PRECONDITION(m_outputStream, "oops....we don't have an output stream...how did that happen?");
if (dataBuffer && m_outputStream)
{
status = m_outputStream->Write(dataBuffer, PL_strlen(dataBuffer), &writeCount);
}
return status;
PRUint32 writeCount = 0;
PRInt32 status = 0;
// NS_PRECONDITION(m_outputStream, "oops....we don't have an output stream...how did that happen?");
if (dataBuffer && m_outputStream)
status = m_outputStream->Write(dataBuffer, PL_strlen(dataBuffer), &writeCount);
return status;
}
// Whenever data arrives from the connection, core netlib notifices the protocol by calling
// OnDataAvailable. We then read and process the incoming data from the input stream.
NS_IMETHODIMP nsMsgProtocol::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
{
// right now, this really just means turn around and churn through the state machine
nsCOMPtr<nsIURI> uri = do_QueryInterface(ctxt);
return ProcessProtocolState(uri, inStr, sourceOffset, count);
// right now, this really just means turn around and churn through the state machine
nsCOMPtr<nsIURI> uri = do_QueryInterface(ctxt);
return ProcessProtocolState(uri, inStr, sourceOffset, count);
}
NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
{
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(ctxt, &rv);
if (NS_SUCCEEDED(rv) && aMsgUrl)
{
rv = aMsgUrl->SetUrlState(PR_TRUE, NS_OK);
if (m_loadGroup)
m_loadGroup->AddRequest(NS_STATIC_CAST(nsIRequest *, this), nsnull /* context isupports */);
}
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(ctxt, &rv);
if (NS_SUCCEEDED(rv) && aMsgUrl)
{
rv = aMsgUrl->SetUrlState(PR_TRUE, NS_OK);
if (m_loadGroup)
m_loadGroup->AddRequest(NS_STATIC_CAST(nsIRequest *, this), nsnull /* context isupports */);
}
// if we are set up as a channel, we should notify our channel listener that we are starting...
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
// happens to be using
if (!mSuppressListenerNotifications && m_channelListener)
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
// happens to be using
if (!mSuppressListenerNotifications && m_channelListener)
{
if (!m_channelContext)
m_channelContext = do_QueryInterface(ctxt);
rv = m_channelListener->OnStartRequest(this, m_channelContext);
m_channelContext = do_QueryInterface(ctxt);
rv = m_channelListener->OnStartRequest(this, m_channelContext);
}
NS_ENSURE_SUCCESS(rv, rv);
return rv;
return rv;
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
@ -397,9 +397,11 @@ NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctx
}
NS_ASSERTION(errorID != UNKNOWN_ERROR, "unknown error, but don't alert user.");
if (errorID != UNKNOWN_ERROR) {
if (errorID != UNKNOWN_ERROR)
{
PRUnichar *errorMsg = FormatStringWithHostNameByID(errorID, msgUrl);
if (errorMsg == nsnull) {
if (errorMsg == nsnull)
{
nsAutoString resultString(NS_LITERAL_STRING("[StringID "));
resultString.AppendInt(errorID);
resultString.Append(NS_LITERAL_STRING("?]"));
@ -430,29 +432,29 @@ nsresult nsMsgProtocol::GetPromptDialogFromUrl(nsIMsgMailNewsUrl * aMsgUrl, nsIP
nsresult nsMsgProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
{
// okay now kick us off to the next state...
// our first state is a process state so drive the state machine...
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(aURL, &rv);
// okay now kick us off to the next state...
// our first state is a process state so drive the state machine...
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(aURL, &rv);
if (NS_SUCCEEDED(rv) && aMsgUrl)
{
{
PRBool msgIsInLocalCache;
aMsgUrl->GetMsgIsInLocalCache(&msgIsInLocalCache);
rv = aMsgUrl->SetUrlState(PR_TRUE, NS_OK); // set the url as a url currently being run...
rv = aMsgUrl->SetUrlState(PR_TRUE, NS_OK); // set the url as a url currently being run...
// if the url is given a stream consumer then we should use it to forward calls to...
if (!m_channelListener && aConsumer) // if we don't have a registered listener already
{
m_channelListener = do_QueryInterface(aConsumer);
if (!m_channelContext)
m_channelContext = do_QueryInterface(aURL);
m_channelContext = do_QueryInterface(aURL);
}
if (!m_socketIsOpen)
{
nsCOMPtr<nsISupports> urlSupports = do_QueryInterface(aURL);
if (!m_socketIsOpen)
{
nsCOMPtr<nsISupports> urlSupports = do_QueryInterface(aURL);
if (m_transport)
{
// don't open the input stream more than once
@ -462,25 +464,25 @@ nsresult nsMsgProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
rv = m_transport->OpenInputStream(0, 0, 0, getter_AddRefs(m_inputStream));
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIInputStreamPump> pump;
rv = NS_NewInputStreamPump(getter_AddRefs(pump),
m_inputStream, -1, m_readCount);
m_inputStream, -1, m_readCount);
if (NS_FAILED(rv)) return rv;
m_request = pump; // keep a reference to the pump so we can cancel it
// put us in a state where we are always notified of incoming data
rv = pump->AsyncRead(this, urlSupports);
NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncRead failed");
m_socketIsOpen = PR_TRUE; // mark the channel as open
}
} // if we got an event queue service
else if (!msgIsInLocalCache) // the connection is already open so we should begin processing our new url...
rv = ProcessProtocolState(aURL, nsnull, 0, 0);
}
return rv;
} // if we got an event queue service
else if (!msgIsInLocalCache) // the connection is already open so we should begin processing our new url...
rv = ProcessProtocolState(aURL, nsnull, 0, 0);
}
return rv;
}
///////////////////////////////////////////////////////////////////////
@ -489,14 +491,14 @@ nsresult nsMsgProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
nsresult nsMsgProtocol::SetUrl(nsIURI * aURL)
{
m_url = aURL;
return NS_OK;
m_url = aURL;
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::SetLoadGroup(nsILoadGroup * aLoadGroup)
{
m_loadGroup = aLoadGroup;
return NS_OK;
m_loadGroup = aLoadGroup;
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::GetOriginalURI(nsIURI* *aURI)
@ -522,7 +524,7 @@ NS_IMETHODIMP nsMsgProtocol::GetURI(nsIURI* *aURI)
NS_IMETHODIMP nsMsgProtocol::Open(nsIInputStream **_retval)
{
NS_NOTREACHED("Open");
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt)
@ -542,10 +544,10 @@ NS_IMETHODIMP nsMsgProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports
if (NS_FAILED(rv))
return rv;
// set the stream listener and then load the url
m_channelContext = ctxt;
m_channelListener = listener;
return LoadUrl(m_url, nsnull);
// set the stream listener and then load the url
m_channelContext = ctxt;
m_channelListener = listener;
return LoadUrl(m_url, nsnull);
}
NS_IMETHODIMP nsMsgProtocol::GetLoadFlags(nsLoadFlags *aLoadFlags)
@ -568,10 +570,10 @@ NS_IMETHODIMP nsMsgProtocol::GetContentType(nsACString &aContentType)
// a part in the message that has a content type that is not message/rfc822
if (m_ContentType.IsEmpty())
aContentType = NS_LITERAL_CSTRING("message/rfc822");
aContentType = NS_LITERAL_CSTRING("message/rfc822");
else
aContentType = m_ContentType;
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::SetContentType(const nsACString &aContentType)
@ -620,20 +622,20 @@ NS_IMETHODIMP nsMsgProtocol::GetOwner(nsISupports * *aPrincipal)
{
*aPrincipal = mOwner;
NS_IF_ADDREF(*aPrincipal);
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::SetOwner(nsISupports * aPrincipal)
{
mOwner = aPrincipal;
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::GetLoadGroup(nsILoadGroup * *aLoadGroup)
{
*aLoadGroup = m_loadGroup;
NS_IF_ADDREF(*aLoadGroup);
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP
@ -713,7 +715,7 @@ NS_IMETHODIMP nsMsgProtocol::IsPending(PRBool *result)
NS_IMETHODIMP nsMsgProtocol::GetStatus(nsresult *status)
{
if (m_request)
return m_request->GetStatus(status);
return m_request->GetStatus(status);
*status = NS_OK;
return *status;
@ -721,11 +723,11 @@ NS_IMETHODIMP nsMsgProtocol::GetStatus(nsresult *status)
NS_IMETHODIMP nsMsgProtocol::Cancel(nsresult status)
{
NS_ASSERTION(m_request,"no channel");
if (!m_request)
return NS_ERROR_FAILURE;
return m_request->Cancel(status);
NS_ASSERTION(m_request,"no channel");
if (!m_request)
return NS_ERROR_FAILURE;
return m_request->Cancel(status);
}
NS_IMETHODIMP nsMsgProtocol::Suspend()
@ -1036,7 +1038,7 @@ nsMsgAsyncWriteProtocol::~nsMsgAsyncWriteProtocol()
NS_IMETHODIMP nsMsgAsyncWriteProtocol::Cancel(nsresult status)
{
if (m_request)
if (m_request)
m_request->Cancel(status);
if (mAsyncOutStream)
@ -1261,45 +1263,45 @@ nsresult nsMsgAsyncWriteProtocol::UnblockPostReader()
nsresult nsMsgAsyncWriteProtocol::SetupTransportState()
{
nsresult rv = NS_OK;
if (!m_outputStream && m_transport)
{
nsresult rv = NS_OK;
if (!m_outputStream && m_transport)
{
// first create a pipe which we'll use to write the data we want to send
// into.
rv = NS_NewPipe(getter_AddRefs(mInStream), getter_AddRefs(m_outputStream),
1024, // segmentSize
1024*8, // maxSize
PR_TRUE,
PR_TRUE);
1024, // segmentSize
1024*8, // maxSize
PR_TRUE,
PR_TRUE);
rv = NS_GetCurrentEventQ(getter_AddRefs(mProviderEventQ));
if (NS_FAILED(rv)) return rv;
nsMsgProtocolStreamProvider *provider;
NS_NEWXPCOM(provider, nsMsgProtocolStreamProvider);
if (!provider) return NS_ERROR_OUT_OF_MEMORY;
provider->Init(this, mInStream);
mProvider = provider; // ADDREF
nsCOMPtr<nsIOutputStream> stream;
rv = m_transport->OpenOutputStream(0, 0, 0, getter_AddRefs(stream));
if (NS_FAILED(rv)) return rv;
mAsyncOutStream = do_QueryInterface(stream, &rv);
if (NS_FAILED(rv)) return rv;
// wait for the output stream to become writable
rv = mAsyncOutStream->AsyncWait(mProvider, 0, mProviderEventQ);
} // if m_transport
return rv;
} // if m_transport
return rv;
}
nsresult nsMsgAsyncWriteProtocol::CloseSocket()
{
nsresult rv = NS_OK;
nsresult rv = NS_OK;
if (mAsyncOutStream)
mAsyncOutStream->CloseEx(NS_BINDING_ABORTED);
@ -1385,7 +1387,7 @@ PRUnichar *FormatStringWithHostNameByID(PRInt32 stringID, nsIMsgMailNewsUrl *msg
PRUnichar *ptrv = nsnull;
nsXPIDLCString hostName;
nsCOMPtr<nsIMsgIncomingServer> server;
rv = msgUri->GetServer(getter_AddRefs(server));
rv = msgUri->GetServer(getter_AddRefs(server));
if (NS_SUCCEEDED(rv) && server)
rv = server->GetRealHostName(getter_Copies(hostName));