From e374477ce9269acc8126408bc1c36d2e687c3d3b Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Mon, 20 Dec 1999 21:48:15 +0000 Subject: [PATCH] NOT IN BUILD. Adding date time protocol handler files git-svn-id: svn://10.0.0.236/trunk@56238 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/datetime/Makefile.in | 41 +++ .../extensions/datetime/nsDateTimeChannel.cpp | 301 ++++++++++++++++++ .../extensions/datetime/nsDateTimeChannel.h | 84 +++++ .../extensions/datetime/nsDateTimeHandler.cpp | 124 ++++++++ .../extensions/datetime/nsDateTimeHandler.h | 51 +++ .../extensions/datetime/nsDateTimeModule.cpp | 34 ++ mozilla/netwerk/protocol/datetime/Makefile.in | 31 ++ .../netwerk/protocol/datetime/makefile.win | 30 ++ .../netwerk/protocol/datetime/src/Makefile.in | 41 +++ .../protocol/datetime/src/makefile.win | 49 +++ .../datetime/src/nsDateTimeChannel.cpp | 301 ++++++++++++++++++ .../protocol/datetime/src/nsDateTimeChannel.h | 84 +++++ .../datetime/src/nsDateTimeHandler.cpp | 124 ++++++++ .../protocol/datetime/src/nsDateTimeHandler.h | 51 +++ .../datetime/src/nsDateTimeModule.cpp | 34 ++ 15 files changed, 1380 insertions(+) create mode 100644 mozilla/extensions/datetime/Makefile.in create mode 100644 mozilla/extensions/datetime/nsDateTimeChannel.cpp create mode 100644 mozilla/extensions/datetime/nsDateTimeChannel.h create mode 100644 mozilla/extensions/datetime/nsDateTimeHandler.cpp create mode 100644 mozilla/extensions/datetime/nsDateTimeHandler.h create mode 100644 mozilla/extensions/datetime/nsDateTimeModule.cpp create mode 100644 mozilla/netwerk/protocol/datetime/Makefile.in create mode 100644 mozilla/netwerk/protocol/datetime/makefile.win create mode 100644 mozilla/netwerk/protocol/datetime/src/Makefile.in create mode 100644 mozilla/netwerk/protocol/datetime/src/makefile.win create mode 100644 mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp create mode 100644 mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.h create mode 100644 mozilla/netwerk/protocol/datetime/src/nsDateTimeHandler.cpp create mode 100644 mozilla/netwerk/protocol/datetime/src/nsDateTimeHandler.h create mode 100644 mozilla/netwerk/protocol/datetime/src/nsDateTimeModule.cpp diff --git a/mozilla/extensions/datetime/Makefile.in b/mozilla/extensions/datetime/Makefile.in new file mode 100644 index 00000000000..323dada6c2b --- /dev/null +++ b/mozilla/extensions/datetime/Makefile.in @@ -0,0 +1,41 @@ +# +# The contents of this file are subject to the Netscape 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/NPL/ +# +# 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. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = necko +LIBRARY_NAME = necko_data +IS_COMPONENT = 1 + +CPPSRCS = \ + nsDateTimeHandler.cpp \ + nsDateTimeChannel.cpp \ + nsDateTimeModule.cpp \ + $(NULL) + +EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/extensions/datetime/nsDateTimeChannel.cpp b/mozilla/extensions/datetime/nsDateTimeChannel.cpp new file mode 100644 index 00000000000..85da11620b0 --- /dev/null +++ b/mozilla/extensions/datetime/nsDateTimeChannel.cpp @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +// datetime implementation + +#include "nsDateTimeChannel.h" +#include "nsIServiceManager.h" +#include "nsILoadGroup.h" +#include "nsIInterfaceRequestor.h" +#include "nsXPIDLString.h" +#include "nsISocketTransportService.h" + +static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); + +// nsDateTimeChannel methods +nsDateTimeChannel::nsDateTimeChannel() { + NS_INIT_REFCNT(); + mContentLength = -1; + mPort = -1; +} + +nsDateTimeChannel::~nsDateTimeChannel() { +} + +NS_IMPL_ISUPPORTS4(nsDateTimeChannel, nsIChannel, nsIRequest, nsIStreamListener, nsIStreamObserver) + +nsresult +nsDateTimeChannel::Init(const char* verb, + nsIURI* uri, + nsILoadGroup* aLoadGroup, + nsIInterfaceRequestor* notificationCallbacks, + nsLoadFlags loadAttributes, + nsIURI* originalURI, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize) +{ + nsresult rv; + + rv = SetLoadAttributes(loadAttributes); + if (NS_FAILED(rv)) return rv; + rv = SetLoadGroup(aLoadGroup); + if (NS_FAILED(rv)) return rv; + rv = SetNotificationCallbacks(notificationCallbacks); + if (NS_FAILED(rv)) return rv; + + mOriginalURI = originalURI ? originalURI : uri; + mUrl = uri; + + rv = mUrl->GetPort(&mPort); + if (NS_FAILED(rv) || mPort < 1) + mPort = DATETIME_PORT; + + rv = mUrl->GetPath(getter_Copies(mHost)); + if (NS_FAILED(rv)) return rv; + return NS_OK; +} + +NS_METHOD +nsDateTimeChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) +{ + nsDateTimeChannel* dc = new nsDateTimeChannel(); + if (dc == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(dc); + nsresult rv = dc->QueryInterface(aIID, aResult); + NS_RELEASE(dc); + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIRequest methods: + +NS_IMETHODIMP +nsDateTimeChannel::IsPending(PRBool *result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::Cancel(void) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::Suspend(void) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::Resume(void) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIChannel methods: + +NS_IMETHODIMP +nsDateTimeChannel::GetOriginalURI(nsIURI * *aURI) +{ + *aURI = mOriginalURI; + NS_ADDREF(*aURI); + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetURI(nsIURI * *aURI) +{ + *aURI = mUrl; + NS_IF_ADDREF(*aURI); + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount, + nsIInputStream **_retval) +{ + nsresult rv = NS_OK; + + NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr channel; + rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel)); + if (NS_FAILED(rv)) return rv; + + return channel->OpenInputStream(startPosition, readCount, _retval); +} + +NS_IMETHODIMP +nsDateTimeChannel::OpenOutputStream(PRUint32 startPosition, nsIOutputStream **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt) +{ + nsresult rv = NS_OK; + + NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr channel; + rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel)); + if (NS_FAILED(rv)) return rv; + + return channel->AsyncOpen(observer, ctxt); +} + +NS_IMETHODIMP +nsDateTimeChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, + nsISupports *ctxt, + nsIStreamListener *aListener) +{ + nsresult rv = NS_OK; + + NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr channel; + rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel)); + if (NS_FAILED(rv)) return rv; + + mListener = aListener; + + return channel->AsyncRead(startPosition, readCount, ctxt, this); +} + +NS_IMETHODIMP +nsDateTimeChannel::AsyncWrite(nsIInputStream *fromStream, + PRUint32 startPosition, + PRInt32 writeCount, + nsISupports *ctxt, + nsIStreamObserver *observer) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetLoadAttributes(PRUint32 *aLoadAttributes) +{ + *aLoadAttributes = mLoadAttributes; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetLoadAttributes(PRUint32 aLoadAttributes) +{ + mLoadAttributes = aLoadAttributes; + return NS_OK; +} + +#define DATETIME_TYPE "text/plain" + +NS_IMETHODIMP +nsDateTimeChannel::GetContentType(char* *aContentType) { + if (!aContentType) return NS_ERROR_NULL_POINTER; + + *aContentType = nsCRT::strdup(DATETIME_TYPE); + if (!*aContentType) return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetContentLength(PRInt32 *aContentLength) +{ + *aContentLength = mContentLength; + return NS_OK; +} + +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; +} + + +// nsIStreamObserver methods +NS_IMETHODIMP +nsDateTimeChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { + return mListener->OnStartRequest(this, aContext); +} + + +NS_IMETHODIMP +nsDateTimeChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, + nsresult aStatus, const PRUnichar* aMsg) { + return mListener->OnStopRequest(this, aContext, aStatus, aMsg); +} + + +// nsIStreamListener method +NS_IMETHODIMP +nsDateTimeChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, + nsIInputStream *aInputStream, PRUint32 aSourceOffset, + PRUint32 aLength) { + mContentLength = aLength; + return mListener->OnDataAvailable(this, aContext, aInputStream, aSourceOffset, aLength); +} + diff --git a/mozilla/extensions/datetime/nsDateTimeChannel.h b/mozilla/extensions/datetime/nsDateTimeChannel.h new file mode 100644 index 00000000000..d8a7979231f --- /dev/null +++ b/mozilla/extensions/datetime/nsDateTimeChannel.h @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +// A datetime channel retrieves date time information from +// RFC 867 compliant datetime servers. The date/time returned +// to the caller is of MIME type "text/plain". + +#ifndef nsDateTimeChannel_h___ +#define nsDateTimeChannel_h___ + +#include "nsString2.h" +#include "nsILoadGroup.h" +#include "nsIInputStream.h" +#include "nsIInterfaceRequestor.h" +#include "nsCOMPtr.h" +#include "nsXPIDLString.h" +#include "nsIChannel.h" +#include "nsIURI.h" +#include "nsDateTimeHandler.h" +#include "nsIStreamListener.h" + + +class nsDateTimeChannel : public nsIChannel, public nsIStreamListener { +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIREQUEST + NS_DECL_NSICHANNEL + NS_DECL_NSISTREAMLISTENER + NS_DECL_NSISTREAMOBSERVER + + // nsDateTimeChannel methods: + nsDateTimeChannel(); + virtual ~nsDateTimeChannel(); + + // Define a Create method to be used with a factory: + static NS_METHOD + Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); + + nsresult Init(const char* verb, + nsIURI* uri, + nsILoadGroup* aLoadGroup, + nsIInterfaceRequestor* notificationCallbacks, + nsLoadFlags loadAttributes, + nsIURI* originalURI, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize); + +protected: + nsCOMPtr mCallbacks; + nsCOMPtr mOriginalURI; + nsCOMPtr mUrl; + nsCOMPtr mListener; + PRUint32 mLoadAttributes; + nsCOMPtr mLoadGroup; + nsCString mContentType; + PRInt32 mContentLength; + nsCOMPtr mOwner; + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; + + PRInt32 mPort; + nsXPIDLCString mHost; +}; + +#endif /* nsDateTimeChannel_h___ */ diff --git a/mozilla/extensions/datetime/nsDateTimeHandler.cpp b/mozilla/extensions/datetime/nsDateTimeHandler.cpp new file mode 100644 index 00000000000..b8e87303515 --- /dev/null +++ b/mozilla/extensions/datetime/nsDateTimeHandler.cpp @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#include "nspr.h" +#include "nsDateTimeChannel.h" +#include "nsDateTimeHandler.h" +#include "nsIURL.h" +#include "nsCRT.h" +#include "nsIComponentManager.h" +#include "nsIServiceManager.h" +#include "nsIInterfaceRequestor.h" +#include "nsIProgressEventSink.h" + +static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID); + +//////////////////////////////////////////////////////////////////////////////// + +nsDateTimeHandler::nsDateTimeHandler() { + NS_INIT_REFCNT(); +} + +nsDateTimeHandler::~nsDateTimeHandler() { +} + +NS_IMPL_ISUPPORTS(nsDateTimeHandler, NS_GET_IID(nsIProtocolHandler)); + +NS_METHOD +nsDateTimeHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) { + + nsDateTimeHandler* ph = new nsDateTimeHandler(); + if (ph == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(ph); + nsresult rv = ph->QueryInterface(aIID, aResult); + NS_RELEASE(ph); + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIProtocolHandler methods: + +NS_IMETHODIMP +nsDateTimeHandler::GetScheme(char* *result) { + *result = nsCRT::strdup("datetime"); + if (!*result) return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeHandler::GetDefaultPort(PRInt32 *result) { + *result = DATETIME_PORT; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, + nsIURI **result) { + nsresult rv; + + // no concept of a relative datetime url + NS_ASSERTION(!aBaseURI, "base url passed into datetime protocol handler"); + + nsIURI* url; + rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull, + NS_GET_IID(nsIURI), + (void**)&url); + if (NS_FAILED(rv)) return rv; + rv = url->SetSpec((char*)aSpec); + if (NS_FAILED(rv)) { + NS_RELEASE(url); + return rv; + } + + *result = url; + return rv; +} + +NS_IMETHODIMP +nsDateTimeHandler::NewChannel(const char* verb, nsIURI* url, + nsILoadGroup* aLoadGroup, + nsIInterfaceRequestor* notificationCallbacks, + nsLoadFlags loadAttributes, + nsIURI* originalURI, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel* *result) +{ + nsresult rv; + + nsDateTimeChannel* channel; + rv = nsDateTimeChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel); + if (NS_FAILED(rv)) return rv; + + rv = channel->Init(verb, url, aLoadGroup, notificationCallbacks, + loadAttributes, originalURI, bufferSegmentSize, bufferMaxSize); + if (NS_FAILED(rv)) { + NS_RELEASE(channel); + return rv; + } + + *result = channel; + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/extensions/datetime/nsDateTimeHandler.h b/mozilla/extensions/datetime/nsDateTimeHandler.h new file mode 100644 index 00000000000..9737e5525f7 --- /dev/null +++ b/mozilla/extensions/datetime/nsDateTimeHandler.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +// The datetime protocol handler creates "datetime" URIs of the form +// "datetime:RFC867Server". + +#ifndef nsDateTimeHandler_h___ +#define nsDateTimeHandler_h___ + +#include "nsIProtocolHandler.h" + +#define DATETIME_PORT 13 + +// {AA27D2A0-B71B-11d3-A1A0-0050041CAF44} +#define NS_DATETIMEHANDLER_CID \ +{ 0xaa27d2a0, 0xb71b, 0x11d3, { 0xa1, 0xa0, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } } + +class nsDateTimeHandler : public nsIProtocolHandler +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPROTOCOLHANDLER + + // nsDateTimeHandler methods: + nsDateTimeHandler(); + virtual ~nsDateTimeHandler(); + + // Define a Create method to be used with a factory: + static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); +}; + +#endif /* nsDateTimeHandler_h___ */ diff --git a/mozilla/extensions/datetime/nsDateTimeModule.cpp b/mozilla/extensions/datetime/nsDateTimeModule.cpp new file mode 100644 index 00000000000..c9d2080be57 --- /dev/null +++ b/mozilla/extensions/datetime/nsDateTimeModule.cpp @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#include "nsIGenericFactory.h" +#include "nsDateTimeHandler.h" + +static nsModuleComponentInfo gResComponents[] = { + { "The DateTime Protocol Handler", + NS_DATETIMEHANDLER_CID, + NS_NETWORK_PROTOCOL_PROGID_PREFIX "datetime", + nsDateTimeHandler::Create + } +}; + +NS_IMPL_NSGETMODULE("datetime", gResComponents) diff --git a/mozilla/netwerk/protocol/datetime/Makefile.in b/mozilla/netwerk/protocol/datetime/Makefile.in new file mode 100644 index 00000000000..561ae8abe12 --- /dev/null +++ b/mozilla/netwerk/protocol/datetime/Makefile.in @@ -0,0 +1,31 @@ +# +# The contents of this file are subject to the Netscape 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/NPL/ +# +# 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. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +DIRS = src + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/netwerk/protocol/datetime/makefile.win b/mozilla/netwerk/protocol/datetime/makefile.win new file mode 100644 index 00000000000..bb1ff4636d7 --- /dev/null +++ b/mozilla/netwerk/protocol/datetime/makefile.win @@ -0,0 +1,30 @@ +#!gmake +# +# The contents of this file are subject to the Netscape 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/NPL/ +# +# 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. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): + +DEPTH = ..\..\.. + +MODULE = necko + +DIRS= \ + src \ + $(NULL) + +include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/netwerk/protocol/datetime/src/Makefile.in b/mozilla/netwerk/protocol/datetime/src/Makefile.in new file mode 100644 index 00000000000..323dada6c2b --- /dev/null +++ b/mozilla/netwerk/protocol/datetime/src/Makefile.in @@ -0,0 +1,41 @@ +# +# The contents of this file are subject to the Netscape 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/NPL/ +# +# 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. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = necko +LIBRARY_NAME = necko_data +IS_COMPONENT = 1 + +CPPSRCS = \ + nsDateTimeHandler.cpp \ + nsDateTimeChannel.cpp \ + nsDateTimeModule.cpp \ + $(NULL) + +EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/netwerk/protocol/datetime/src/makefile.win b/mozilla/netwerk/protocol/datetime/src/makefile.win new file mode 100644 index 00000000000..f4a38766433 --- /dev/null +++ b/mozilla/netwerk/protocol/datetime/src/makefile.win @@ -0,0 +1,49 @@ +# The contents of this file are subject to the Netscape 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/NPL/ +# +# 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. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): + +MODULE = necko + +DEPTH = ..\..\..\.. + +MAKE_OBJ_TYPE=DLL +DLLNAME=nkdata +DLL=.\$(OBJDIR)\$(DLLNAME).dll + +LCFLAGS = -DWIN32_LEAN_AND_MEAN -D_IMPL_NS_NET + +CPP_OBJS = \ + .\$(OBJDIR)\nsDateTimeHandler.obj \ + .\$(OBJDIR)\nsDateTimeChannel.obj \ + .\$(OBJDIR)\nsDateTimeModule.obj \ + $(NULL) + +LLIBS= \ + $(DIST)\lib\necko.lib \ + $(DIST)\lib\xpcom.lib \ + $(LIBNSPR) + +INCS = $(INCS) \ + -I$(DEPTH)\dist\include \ + $(NULL) + +include <$(DEPTH)\config\rules.mak> + +install:: $(DLL) + $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components + diff --git a/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp b/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp new file mode 100644 index 00000000000..85da11620b0 --- /dev/null +++ b/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +// datetime implementation + +#include "nsDateTimeChannel.h" +#include "nsIServiceManager.h" +#include "nsILoadGroup.h" +#include "nsIInterfaceRequestor.h" +#include "nsXPIDLString.h" +#include "nsISocketTransportService.h" + +static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); + +// nsDateTimeChannel methods +nsDateTimeChannel::nsDateTimeChannel() { + NS_INIT_REFCNT(); + mContentLength = -1; + mPort = -1; +} + +nsDateTimeChannel::~nsDateTimeChannel() { +} + +NS_IMPL_ISUPPORTS4(nsDateTimeChannel, nsIChannel, nsIRequest, nsIStreamListener, nsIStreamObserver) + +nsresult +nsDateTimeChannel::Init(const char* verb, + nsIURI* uri, + nsILoadGroup* aLoadGroup, + nsIInterfaceRequestor* notificationCallbacks, + nsLoadFlags loadAttributes, + nsIURI* originalURI, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize) +{ + nsresult rv; + + rv = SetLoadAttributes(loadAttributes); + if (NS_FAILED(rv)) return rv; + rv = SetLoadGroup(aLoadGroup); + if (NS_FAILED(rv)) return rv; + rv = SetNotificationCallbacks(notificationCallbacks); + if (NS_FAILED(rv)) return rv; + + mOriginalURI = originalURI ? originalURI : uri; + mUrl = uri; + + rv = mUrl->GetPort(&mPort); + if (NS_FAILED(rv) || mPort < 1) + mPort = DATETIME_PORT; + + rv = mUrl->GetPath(getter_Copies(mHost)); + if (NS_FAILED(rv)) return rv; + return NS_OK; +} + +NS_METHOD +nsDateTimeChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) +{ + nsDateTimeChannel* dc = new nsDateTimeChannel(); + if (dc == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(dc); + nsresult rv = dc->QueryInterface(aIID, aResult); + NS_RELEASE(dc); + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIRequest methods: + +NS_IMETHODIMP +nsDateTimeChannel::IsPending(PRBool *result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::Cancel(void) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::Suspend(void) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::Resume(void) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIChannel methods: + +NS_IMETHODIMP +nsDateTimeChannel::GetOriginalURI(nsIURI * *aURI) +{ + *aURI = mOriginalURI; + NS_ADDREF(*aURI); + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetURI(nsIURI * *aURI) +{ + *aURI = mUrl; + NS_IF_ADDREF(*aURI); + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount, + nsIInputStream **_retval) +{ + nsresult rv = NS_OK; + + NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr channel; + rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel)); + if (NS_FAILED(rv)) return rv; + + return channel->OpenInputStream(startPosition, readCount, _retval); +} + +NS_IMETHODIMP +nsDateTimeChannel::OpenOutputStream(PRUint32 startPosition, nsIOutputStream **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt) +{ + nsresult rv = NS_OK; + + NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr channel; + rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel)); + if (NS_FAILED(rv)) return rv; + + return channel->AsyncOpen(observer, ctxt); +} + +NS_IMETHODIMP +nsDateTimeChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, + nsISupports *ctxt, + nsIStreamListener *aListener) +{ + nsresult rv = NS_OK; + + NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr channel; + rv = socketService->CreateTransport(mHost, mPort, mHost, 32, 32, getter_AddRefs(channel)); + if (NS_FAILED(rv)) return rv; + + mListener = aListener; + + return channel->AsyncRead(startPosition, readCount, ctxt, this); +} + +NS_IMETHODIMP +nsDateTimeChannel::AsyncWrite(nsIInputStream *fromStream, + PRUint32 startPosition, + PRInt32 writeCount, + nsISupports *ctxt, + nsIStreamObserver *observer) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetLoadAttributes(PRUint32 *aLoadAttributes) +{ + *aLoadAttributes = mLoadAttributes; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetLoadAttributes(PRUint32 aLoadAttributes) +{ + mLoadAttributes = aLoadAttributes; + return NS_OK; +} + +#define DATETIME_TYPE "text/plain" + +NS_IMETHODIMP +nsDateTimeChannel::GetContentType(char* *aContentType) { + if (!aContentType) return NS_ERROR_NULL_POINTER; + + *aContentType = nsCRT::strdup(DATETIME_TYPE); + if (!*aContentType) return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetContentLength(PRInt32 *aContentLength) +{ + *aContentLength = mContentLength; + return NS_OK; +} + +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; +} + + +// nsIStreamObserver methods +NS_IMETHODIMP +nsDateTimeChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { + return mListener->OnStartRequest(this, aContext); +} + + +NS_IMETHODIMP +nsDateTimeChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, + nsresult aStatus, const PRUnichar* aMsg) { + return mListener->OnStopRequest(this, aContext, aStatus, aMsg); +} + + +// nsIStreamListener method +NS_IMETHODIMP +nsDateTimeChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, + nsIInputStream *aInputStream, PRUint32 aSourceOffset, + PRUint32 aLength) { + mContentLength = aLength; + return mListener->OnDataAvailable(this, aContext, aInputStream, aSourceOffset, aLength); +} + diff --git a/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.h b/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.h new file mode 100644 index 00000000000..d8a7979231f --- /dev/null +++ b/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.h @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +// A datetime channel retrieves date time information from +// RFC 867 compliant datetime servers. The date/time returned +// to the caller is of MIME type "text/plain". + +#ifndef nsDateTimeChannel_h___ +#define nsDateTimeChannel_h___ + +#include "nsString2.h" +#include "nsILoadGroup.h" +#include "nsIInputStream.h" +#include "nsIInterfaceRequestor.h" +#include "nsCOMPtr.h" +#include "nsXPIDLString.h" +#include "nsIChannel.h" +#include "nsIURI.h" +#include "nsDateTimeHandler.h" +#include "nsIStreamListener.h" + + +class nsDateTimeChannel : public nsIChannel, public nsIStreamListener { +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIREQUEST + NS_DECL_NSICHANNEL + NS_DECL_NSISTREAMLISTENER + NS_DECL_NSISTREAMOBSERVER + + // nsDateTimeChannel methods: + nsDateTimeChannel(); + virtual ~nsDateTimeChannel(); + + // Define a Create method to be used with a factory: + static NS_METHOD + Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); + + nsresult Init(const char* verb, + nsIURI* uri, + nsILoadGroup* aLoadGroup, + nsIInterfaceRequestor* notificationCallbacks, + nsLoadFlags loadAttributes, + nsIURI* originalURI, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize); + +protected: + nsCOMPtr mCallbacks; + nsCOMPtr mOriginalURI; + nsCOMPtr mUrl; + nsCOMPtr mListener; + PRUint32 mLoadAttributes; + nsCOMPtr mLoadGroup; + nsCString mContentType; + PRInt32 mContentLength; + nsCOMPtr mOwner; + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; + + PRInt32 mPort; + nsXPIDLCString mHost; +}; + +#endif /* nsDateTimeChannel_h___ */ diff --git a/mozilla/netwerk/protocol/datetime/src/nsDateTimeHandler.cpp b/mozilla/netwerk/protocol/datetime/src/nsDateTimeHandler.cpp new file mode 100644 index 00000000000..b8e87303515 --- /dev/null +++ b/mozilla/netwerk/protocol/datetime/src/nsDateTimeHandler.cpp @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#include "nspr.h" +#include "nsDateTimeChannel.h" +#include "nsDateTimeHandler.h" +#include "nsIURL.h" +#include "nsCRT.h" +#include "nsIComponentManager.h" +#include "nsIServiceManager.h" +#include "nsIInterfaceRequestor.h" +#include "nsIProgressEventSink.h" + +static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID); + +//////////////////////////////////////////////////////////////////////////////// + +nsDateTimeHandler::nsDateTimeHandler() { + NS_INIT_REFCNT(); +} + +nsDateTimeHandler::~nsDateTimeHandler() { +} + +NS_IMPL_ISUPPORTS(nsDateTimeHandler, NS_GET_IID(nsIProtocolHandler)); + +NS_METHOD +nsDateTimeHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) { + + nsDateTimeHandler* ph = new nsDateTimeHandler(); + if (ph == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(ph); + nsresult rv = ph->QueryInterface(aIID, aResult); + NS_RELEASE(ph); + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIProtocolHandler methods: + +NS_IMETHODIMP +nsDateTimeHandler::GetScheme(char* *result) { + *result = nsCRT::strdup("datetime"); + if (!*result) return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeHandler::GetDefaultPort(PRInt32 *result) { + *result = DATETIME_PORT; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, + nsIURI **result) { + nsresult rv; + + // no concept of a relative datetime url + NS_ASSERTION(!aBaseURI, "base url passed into datetime protocol handler"); + + nsIURI* url; + rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull, + NS_GET_IID(nsIURI), + (void**)&url); + if (NS_FAILED(rv)) return rv; + rv = url->SetSpec((char*)aSpec); + if (NS_FAILED(rv)) { + NS_RELEASE(url); + return rv; + } + + *result = url; + return rv; +} + +NS_IMETHODIMP +nsDateTimeHandler::NewChannel(const char* verb, nsIURI* url, + nsILoadGroup* aLoadGroup, + nsIInterfaceRequestor* notificationCallbacks, + nsLoadFlags loadAttributes, + nsIURI* originalURI, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel* *result) +{ + nsresult rv; + + nsDateTimeChannel* channel; + rv = nsDateTimeChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel); + if (NS_FAILED(rv)) return rv; + + rv = channel->Init(verb, url, aLoadGroup, notificationCallbacks, + loadAttributes, originalURI, bufferSegmentSize, bufferMaxSize); + if (NS_FAILED(rv)) { + NS_RELEASE(channel); + return rv; + } + + *result = channel; + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/protocol/datetime/src/nsDateTimeHandler.h b/mozilla/netwerk/protocol/datetime/src/nsDateTimeHandler.h new file mode 100644 index 00000000000..9737e5525f7 --- /dev/null +++ b/mozilla/netwerk/protocol/datetime/src/nsDateTimeHandler.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +// The datetime protocol handler creates "datetime" URIs of the form +// "datetime:RFC867Server". + +#ifndef nsDateTimeHandler_h___ +#define nsDateTimeHandler_h___ + +#include "nsIProtocolHandler.h" + +#define DATETIME_PORT 13 + +// {AA27D2A0-B71B-11d3-A1A0-0050041CAF44} +#define NS_DATETIMEHANDLER_CID \ +{ 0xaa27d2a0, 0xb71b, 0x11d3, { 0xa1, 0xa0, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } } + +class nsDateTimeHandler : public nsIProtocolHandler +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPROTOCOLHANDLER + + // nsDateTimeHandler methods: + nsDateTimeHandler(); + virtual ~nsDateTimeHandler(); + + // Define a Create method to be used with a factory: + static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); +}; + +#endif /* nsDateTimeHandler_h___ */ diff --git a/mozilla/netwerk/protocol/datetime/src/nsDateTimeModule.cpp b/mozilla/netwerk/protocol/datetime/src/nsDateTimeModule.cpp new file mode 100644 index 00000000000..c9d2080be57 --- /dev/null +++ b/mozilla/netwerk/protocol/datetime/src/nsDateTimeModule.cpp @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#include "nsIGenericFactory.h" +#include "nsDateTimeHandler.h" + +static nsModuleComponentInfo gResComponents[] = { + { "The DateTime Protocol Handler", + NS_DATETIMEHANDLER_CID, + NS_NETWORK_PROTOCOL_PROGID_PREFIX "datetime", + nsDateTimeHandler::Create + } +}; + +NS_IMPL_NSGETMODULE("datetime", gResComponents)