2003-01-18 05:15:14 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
1999-12-21 00:48:15 +03:00
|
|
|
*
|
2004-04-19 02:14:17 +04:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-12-21 00:48:15 +03:00
|
|
|
*
|
2004-04-19 02:14:17 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-12-21 00:48:15 +03:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-19 02:14:17 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Brian Ryner.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2000
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Brian Ryner <bryner@brianryner.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
1999-12-21 00:48:15 +03:00
|
|
|
*
|
2004-04-19 02:14:17 +04:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-12-21 00:48:15 +03:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
// DateTime implementation
|
1999-12-21 00:48:15 +03:00
|
|
|
|
|
|
|
#include "nsDateTimeChannel.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsILoadGroup.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-06 01:28:38 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
1999-12-21 00:48:15 +03:00
|
|
|
#include "nsXPIDLString.h"
|
|
|
|
#include "nsISocketTransportService.h"
|
2003-01-18 05:15:14 +03:00
|
|
|
#include "nsIStringStream.h"
|
|
|
|
#include "nsMimeTypes.h"
|
|
|
|
#include "nsIStreamConverterService.h"
|
|
|
|
#include "nsITXTToHTMLConv.h"
|
2001-02-21 23:38:08 +03:00
|
|
|
#include "nsIProgressEventSink.h"
|
2003-01-18 05:15:14 +03:00
|
|
|
#include "nsEventQueueUtils.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
|
|
|
|
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
|
|
|
|
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
1999-12-21 00:48:15 +03:00
|
|
|
|
|
|
|
// nsDateTimeChannel methods
|
2003-01-18 05:15:14 +03:00
|
|
|
nsDateTimeChannel::nsDateTimeChannel()
|
|
|
|
: mLoadFlags(LOAD_NORMAL)
|
|
|
|
, mStatus(NS_OK)
|
|
|
|
, mPort(-1)
|
|
|
|
{
|
1999-12-21 00:48:15 +03:00
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsDateTimeChannel::~nsDateTimeChannel()
|
|
|
|
{
|
1999-12-21 00:48:15 +03:00
|
|
|
}
|
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_IMPL_ISUPPORTS4(nsDateTimeChannel,
|
|
|
|
nsIChannel,
|
2003-01-18 05:15:14 +03:00
|
|
|
nsIRequest,
|
2001-02-21 23:38:08 +03:00
|
|
|
nsIStreamListener,
|
2001-04-10 10:01:08 +04:00
|
|
|
nsIRequestObserver)
|
1999-12-21 00:48:15 +03:00
|
|
|
|
|
|
|
nsresult
|
2003-01-18 05:15:14 +03:00
|
|
|
nsDateTimeChannel::Init(nsIURI *uri, nsIProxyInfo *proxyInfo)
|
1999-12-21 00:48:15 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2000-01-12 01:16:19 +03:00
|
|
|
NS_ASSERTION(uri, "no uri");
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
mURI = uri;
|
2001-09-13 06:21:05 +04:00
|
|
|
mProxyInfo = proxyInfo;
|
1999-12-21 22:40:05 +03:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
rv = mURI->GetPort(&mPort);
|
2000-01-12 01:16:19 +03:00
|
|
|
if (NS_FAILED(rv) || mPort < 1)
|
|
|
|
mPort = DATETIME_PORT;
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
rv = mURI->GetPath(mHost);
|
2000-01-12 01:16:19 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
if (mHost.IsEmpty())
|
|
|
|
return NS_ERROR_MALFORMED_URI;
|
2000-01-12 01:16:19 +03:00
|
|
|
|
2004-06-17 04:13:25 +04:00
|
|
|
mContentType.AssignLiteral(TEXT_HTML); // expected content-type
|
1999-12-21 00:48:15 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIRequest methods:
|
|
|
|
|
2000-08-21 12:23:54 +04:00
|
|
|
NS_IMETHODIMP
|
2002-03-21 01:50:33 +03:00
|
|
|
nsDateTimeChannel::GetName(nsACString &result)
|
2000-08-21 12:23:54 +04:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
return mURI->GetSpec(result);
|
2000-08-21 12:23:54 +04:00
|
|
|
}
|
|
|
|
|
1999-12-21 00:48:15 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::IsPending(PRBool *result)
|
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
*result = (mPump != nsnull);
|
|
|
|
return NS_OK;
|
1999-12-21 00:48:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-03-29 07:58:50 +04:00
|
|
|
nsDateTimeChannel::GetStatus(nsresult *status)
|
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
if (NS_SUCCEEDED(mStatus) && mPump)
|
|
|
|
mPump->GetStatus(status);
|
|
|
|
else
|
|
|
|
*status = mStatus;
|
2000-03-29 07:58:50 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::Cancel(nsresult status)
|
1999-12-21 00:48:15 +03:00
|
|
|
{
|
2000-04-12 11:58:24 +04:00
|
|
|
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
2003-01-18 05:15:14 +03:00
|
|
|
|
|
|
|
mStatus = status;
|
|
|
|
if (mPump)
|
|
|
|
mPump->Cancel(status);
|
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
1999-12-21 00:48:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2003-01-18 05:15:14 +03:00
|
|
|
nsDateTimeChannel::Suspend()
|
1999-12-21 00:48:15 +03:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
if (mPump)
|
2003-09-11 16:15:05 +04:00
|
|
|
return mPump->Suspend();
|
2003-01-18 05:15:14 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
1999-12-21 00:48:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2003-01-18 05:15:14 +03:00
|
|
|
nsDateTimeChannel::Resume()
|
1999-12-21 00:48:15 +03:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
if (mPump)
|
2003-09-11 16:15:05 +04:00
|
|
|
return mPump->Resume();
|
2003-01-18 05:15:14 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
1999-12-21 00:48:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIChannel methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-03-29 07:58:50 +04:00
|
|
|
nsDateTimeChannel::GetOriginalURI(nsIURI* *aURI)
|
1999-12-21 00:48:15 +03:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
*aURI = mOriginalURI ? mOriginalURI : mURI;
|
1999-12-21 00:48:15 +03:00
|
|
|
NS_ADDREF(*aURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-03-29 07:58:50 +04:00
|
|
|
nsDateTimeChannel::SetOriginalURI(nsIURI* aURI)
|
|
|
|
{
|
|
|
|
mOriginalURI = aURI;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::GetURI(nsIURI* *aURI)
|
1999-12-21 00:48:15 +03:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
*aURI = mURI;
|
1999-12-21 00:48:15 +03:00
|
|
|
NS_IF_ADDREF(*aURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-29 07:58:50 +04:00
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsDateTimeChannel::Open(nsIInputStream **_retval)
|
2003-01-18 05:15:14 +03:00
|
|
|
{
|
2003-10-08 08:27:13 +04:00
|
|
|
return NS_ImplementChannelOpen(this, _retval);
|
2003-01-18 05:15:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
1999-12-21 00:48:15 +03:00
|
|
|
{
|
2004-11-15 23:16:52 +03:00
|
|
|
// Initialize mProgressSink
|
|
|
|
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup, mProgressSink);
|
2003-01-18 05:15:14 +03:00
|
|
|
|
2004-11-15 23:16:52 +03:00
|
|
|
nsresult rv = NS_CheckPortSafety(mPort, "datetime");
|
2003-01-18 05:15:14 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-12-21 00:48:15 +03:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsCOMPtr<nsIEventQueue> eventQ;
|
|
|
|
rv = NS_GetCurrentEventQ(getter_AddRefs(eventQ));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
//
|
|
|
|
// create transport
|
|
|
|
//
|
2001-09-13 06:21:05 +04:00
|
|
|
nsCOMPtr<nsISocketTransportService> sts =
|
2003-01-18 05:15:14 +03:00
|
|
|
do_GetService(kSocketTransportServiceCID, &rv);
|
1999-12-21 00:48:15 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
rv = sts->CreateTransport(nsnull, 0, mHost, mPort, mProxyInfo,
|
|
|
|
getter_AddRefs(mTransport));
|
1999-12-21 00:48:15 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2004-11-15 23:16:52 +03:00
|
|
|
// not fatal if this fails
|
2003-01-18 05:15:14 +03:00
|
|
|
mTransport->SetEventSink(this, eventQ);
|
1999-12-21 22:40:05 +03:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
//
|
|
|
|
// create TXT to HTML stream converter
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIStreamConverterService> scs =
|
|
|
|
do_GetService(kStreamConverterServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-12-21 00:48:15 +03:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsCOMPtr<nsIStreamListener> convListener;
|
2004-06-29 20:45:07 +04:00
|
|
|
rv = scs->AsyncConvertData("text/plain", "text/html", this, nsnull,
|
2003-01-18 05:15:14 +03:00
|
|
|
getter_AddRefs(convListener));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsITXTToHTMLConv> conv = do_QueryInterface(convListener);
|
|
|
|
if (conv) {
|
|
|
|
nsCAutoString userHost;
|
|
|
|
rv = mURI->GetPath(userHost);
|
|
|
|
|
|
|
|
nsAutoString title;
|
2004-09-17 17:03:33 +04:00
|
|
|
title.AppendLiteral("DateTime according to ");
|
|
|
|
AppendUTF8toUTF16(mHost, title);
|
2003-01-18 05:15:14 +03:00
|
|
|
|
|
|
|
conv->SetTitle(title.get());
|
|
|
|
conv->PreFormatHTML(PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// open input stream, and create input stream pump...
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIInputStream> sockIn;
|
|
|
|
rv = mTransport->OpenInputStream(0, 0, 0, getter_AddRefs(sockIn));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = NS_NewInputStreamPump(getter_AddRefs(mPump), sockIn);
|
1999-12-21 00:48:15 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
rv = mPump->AsyncRead(convListener, nsnull);
|
1999-12-21 00:48:15 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
if (mLoadGroup)
|
|
|
|
mLoadGroup->AddRequest(this, nsnull);
|
1999-12-21 22:40:05 +03:00
|
|
|
|
1999-12-21 00:48:15 +03:00
|
|
|
mListener = aListener;
|
2003-01-18 05:15:14 +03:00
|
|
|
mListenerContext = ctxt;
|
|
|
|
return NS_OK;
|
1999-12-21 00:48:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-04-10 10:01:08 +04:00
|
|
|
nsDateTimeChannel::GetLoadFlags(PRUint32 *aLoadFlags)
|
1999-12-21 00:48:15 +03:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
*aLoadFlags = mLoadFlags;
|
1999-12-21 00:48:15 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-04-10 10:01:08 +04:00
|
|
|
nsDateTimeChannel::SetLoadFlags(PRUint32 aLoadFlags)
|
1999-12-21 00:48:15 +03:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
mLoadFlags = aLoadFlags;
|
1999-12-21 00:48:15 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-21 01:50:33 +03:00
|
|
|
nsDateTimeChannel::GetContentType(nsACString &aContentType)
|
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
aContentType = mContentType;
|
1999-12-21 00:48:15 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-08 09:26:04 +03:00
|
|
|
NS_IMETHODIMP
|
2002-03-21 01:50:33 +03:00
|
|
|
nsDateTimeChannel::SetContentType(const nsACString &aContentType)
|
2000-01-08 09:26:04 +03:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
mContentType = aContentType;
|
|
|
|
return NS_OK;
|
2000-01-08 09:26:04 +03:00
|
|
|
}
|
|
|
|
|
2002-03-21 01:50:33 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::GetContentCharset(nsACString &aContentCharset)
|
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
aContentCharset = mContentCharset;
|
2002-03-21 01:50:33 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::SetContentCharset(const nsACString &aContentCharset)
|
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
mContentCharset = aContentCharset;
|
|
|
|
return NS_OK;
|
2002-03-21 01:50:33 +03:00
|
|
|
}
|
|
|
|
|
1999-12-21 00:48:15 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::GetContentLength(PRInt32 *aContentLength)
|
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
*aContentLength = -1;
|
1999-12-21 00:48:15 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-29 07:58:50 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::SetContentLength(PRInt32 aContentLength)
|
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
// silently ignore this...
|
|
|
|
return NS_OK;
|
2000-03-29 07:58:50 +04:00
|
|
|
}
|
|
|
|
|
1999-12-21 00:48:15 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
|
|
|
{
|
|
|
|
*aLoadGroup = mLoadGroup;
|
|
|
|
NS_IF_ADDREF(*aLoadGroup);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
|
|
|
{
|
|
|
|
mLoadGroup = aLoadGroup;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::GetOwner(nsISupports* *aOwner)
|
|
|
|
{
|
|
|
|
*aOwner = mOwner.get();
|
|
|
|
NS_IF_ADDREF(*aOwner);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::SetOwner(nsISupports* aOwner)
|
|
|
|
{
|
|
|
|
mOwner = aOwner;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
|
|
|
|
{
|
|
|
|
*aNotificationCallbacks = mCallbacks.get();
|
|
|
|
NS_IF_ADDREF(*aNotificationCallbacks);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
|
|
|
{
|
|
|
|
mCallbacks = aNotificationCallbacks;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::GetSecurityInfo(nsISupports **aSecurityInfo)
|
2000-03-18 01:06:32 +03:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
if (mTransport)
|
|
|
|
return mTransport->GetSecurityInfo(aSecurityInfo);
|
|
|
|
|
|
|
|
*aSecurityInfo = nsnull;
|
2000-03-18 01:06:32 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-12-21 00:48:15 +03:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
//-----------------------------------------------------------------------------
|
2001-04-10 10:01:08 +04:00
|
|
|
// nsIRequestObserver methods
|
2003-01-18 05:15:14 +03:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1999-12-21 00:48:15 +03:00
|
|
|
NS_IMETHODIMP
|
2003-01-18 05:15:14 +03:00
|
|
|
nsDateTimeChannel::OnStartRequest(nsIRequest *req, nsISupports *ctx)
|
|
|
|
{
|
|
|
|
return mListener->OnStartRequest(this, mListenerContext);
|
1999-12-21 00:48:15 +03:00
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDateTimeChannel::OnStopRequest(nsIRequest *req, nsISupports *ctx, nsresult status)
|
|
|
|
{
|
|
|
|
if (NS_SUCCEEDED(mStatus))
|
|
|
|
mStatus = status;
|
|
|
|
|
|
|
|
mListener->OnStopRequest(this, mListenerContext, mStatus);
|
|
|
|
mListener = 0;
|
|
|
|
mListenerContext = 0;
|
|
|
|
|
|
|
|
if (mLoadGroup)
|
|
|
|
mLoadGroup->RemoveRequest(this, nsnull, mStatus);
|
|
|
|
|
|
|
|
mPump = 0;
|
|
|
|
mTransport = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-12-21 00:48:15 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2003-01-18 05:15:14 +03:00
|
|
|
nsDateTimeChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx,
|
|
|
|
nsIInputStream *stream, PRUint32 offset,
|
|
|
|
PRUint32 count)
|
|
|
|
{
|
|
|
|
return mListener->OnDataAvailable(this, mListenerContext, stream, offset, count);
|
1999-12-21 00:48:15 +03:00
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// nsITransportEventSink methods
|
|
|
|
//-----------------------------------------------------------------------------
|
1999-12-21 00:48:15 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2003-01-18 05:15:14 +03:00
|
|
|
nsDateTimeChannel::OnTransportStatus(nsITransport *trans, nsresult status,
|
2005-01-09 23:43:35 +03:00
|
|
|
PRUint64 progress, PRUint64 progressMax)
|
2003-01-18 05:15:14 +03:00
|
|
|
{
|
|
|
|
// suppress status notification if channel is no longer pending!
|
2003-05-02 10:31:55 +04:00
|
|
|
if (mProgressSink && NS_SUCCEEDED(mStatus) && mPump && !(mLoadFlags & LOAD_BACKGROUND)) {
|
2005-01-09 23:43:35 +03:00
|
|
|
NS_ConvertUTF8toUTF16 host(mHost);
|
2003-01-18 05:15:14 +03:00
|
|
|
mProgressSink->OnStatus(this, nsnull, status, host.get());
|
|
|
|
|
|
|
|
if (status == nsISocketTransport::STATUS_RECEIVING_FROM ||
|
|
|
|
status == nsISocketTransport::STATUS_SENDING_TO) {
|
|
|
|
mProgressSink->OnProgress(this, nsnull, progress, progressMax);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-12-21 00:48:15 +03:00
|
|
|
}
|