From f062d901b2fb3d2a95097fb5f81e210eea2d2ac2 Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Fri, 16 Jun 2000 21:35:13 +0000 Subject: [PATCH] Bug #38374 --> foundation for helper app architecture. Not part of the build yet. review will come when this is ready to go. git-svn-id: svn://10.0.0.236/trunk@72419 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/uriloader/exthandler/makefile.win | 60 ++++++++++++ .../exthandler/nsCExternalHelperApp.idl | 40 ++++++++ .../exthandler/nsExternalHelperAppService.cpp | 98 +++++++++++++++++++ .../exthandler/nsExternalHelperAppService.h | 64 ++++++++++++ .../nsIExternalHelperAppService.idl | 54 ++++++++++ mozilla/uriloader/exthandler/win/makefile.win | 45 +++++++++ 6 files changed, 361 insertions(+) create mode 100644 mozilla/uriloader/exthandler/makefile.win create mode 100644 mozilla/uriloader/exthandler/nsCExternalHelperApp.idl create mode 100644 mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp create mode 100644 mozilla/uriloader/exthandler/nsExternalHelperAppService.h create mode 100644 mozilla/uriloader/exthandler/nsIExternalHelperAppService.idl create mode 100644 mozilla/uriloader/exthandler/win/makefile.win diff --git a/mozilla/uriloader/exthandler/makefile.win b/mozilla/uriloader/exthandler/makefile.win new file mode 100644 index 00000000000..6d753a2ad44 --- /dev/null +++ b/mozilla/uriloader/exthandler/makefile.win @@ -0,0 +1,60 @@ +# 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) 1999 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): + +MODULE = exthandler + +DIRS=win + +DEPTH = ..\.. +include <$(DEPTH)/config/config.mak> + +include <$(DEPTH)\config\config.mak> + +################################################################################ +## exports + + +XPIDLSRCS= \ + .\nsIExternalHelperAppService.idl \ + .\nsCExternalHelperApp.idl \ + $(NULL) + +LIBRARY_NAME=exthandlers_s + +CPP_OBJS = \ + .\$(OBJDIR)\nsExternalHelperAppService.obj \ + $(NULL) + +INCS = $(INCS) \ + -I$(DEPTH)\dist\include \ + $(NULL) + +LLIBS= \ + $(DIST)\lib\extprotocolwin_s.lib \ + $(NULL) + +WIN_LIBS= shell32.lib + +include <$(DEPTH)\config\rules.mak> + +install:: $(LIBRARY) + $(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib + +clobber:: + rm -f $(DIST)\lib\$(LIBRARY_NAME).lib diff --git a/mozilla/uriloader/exthandler/nsCExternalHelperApp.idl b/mozilla/uriloader/exthandler/nsCExternalHelperApp.idl new file mode 100644 index 00000000000..d139bc507d2 --- /dev/null +++ b/mozilla/uriloader/exthandler/nsCExternalHelperApp.idl @@ -0,0 +1,40 @@ +/* -*- Mode: IDL; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Scott MacGregor + */ + +#include "nsIExternalHelperAppService.idl" + +/* +nsCExternalHelperApp implements: +------------------------- +nsIExternalHelperAppService +*/ + +%{ C++ + +/* A7F800E0-4306-11d4-98D0-001083010E9B */ +#define NS_EXTERNALHELPERAPPSERVICE_CID \ + { 0xa7f800e0, 0x4306, 0x11d4, { 0x98, 0xd0, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } } + +#define NS_EXTERNALHELPERAPPSERVICE_PROGID \ +"component://netscape/uriloader/external-helper-app-service" + +%} diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp new file mode 100644 index 00000000000..bdbd1d5f6b3 --- /dev/null +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Scott MacGregor + */ + +#include "nsExternalHelperAppService.h" +#include "nsIURI.h" +#include "nsIFile.h" +#include "nsIStreamListener.h" + +NS_IMPL_THREADSAFE_ADDREF(nsExternalHelperAppService) +NS_IMPL_THREADSAFE_RELEASE(nsExternalHelperAppService) + +NS_INTERFACE_MAP_BEGIN(nsExternalHelperAppService) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIExternalHelperAppService) + NS_INTERFACE_MAP_ENTRY(nsIExternalHelperAppService) +NS_INTERFACE_MAP_END_THREADSAFE + +nsExternalHelperAppService::nsExternalHelperAppService() +{ + NS_INIT_ISUPPORTS(); +} + +nsExternalHelperAppService::~nsExternalHelperAppService() +{ +} + +/* boolean canHandleContent (in string aMimeContentType); */ +NS_IMETHODIMP nsExternalHelperAppService::CanHandleContent(const char *aMimeContentType, PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIStreamListener doContent (in string aMimeContentType, in nsIURI aURI, in nsISupports aWindowContext, out boolean aAbortProcess); */ +NS_IMETHODIMP nsExternalHelperAppService::DoContent(const char *aMimeContentType, nsIURI *aURI, nsISupports *aWindowContext, PRBool *aAbortProcess, nsIStreamListener **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// begin external app handler implementation +////////////////////////////////////////////////////////////////////////////////////////////////////// + +NS_IMPL_THREADSAFE_ADDREF(nsExternalAppHandler) +NS_IMPL_THREADSAFE_RELEASE(nsExternalAppHandler) + +NS_INTERFACE_MAP_BEGIN(nsExternalAppHandler) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStreamListener) + NS_INTERFACE_MAP_ENTRY(nsIStreamListener) + NS_INTERFACE_MAP_ENTRY(nsIStreamObserver) +NS_INTERFACE_MAP_END_THREADSAFE + +nsExternalAppHandler::nsExternalAppHandler() +{ + NS_INIT_ISUPPORTS(); +} + +nsExternalAppHandler::~nsExternalAppHandler() +{ +} + +NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt) +{ + // create a temp file for the data...and open it for writing. + return NS_OK; +} + +NS_IMETHODIMP nsExternalAppHandler::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, + nsIInputStream * inStr, PRUint32 sourceOffset, PRUint32 count) +{ + // read the data out of the stream and write it to the temp file. + return NS_OK; +} + +NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIChannel * aChannel, nsISupports *aCtxt, + nsresult aStatus, const PRUnichar * errorMsg) +{ + // go ahead and execute the application passing in our temp file as an argument + return NS_OK; +} + diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.h b/mozilla/uriloader/exthandler/nsExternalHelperAppService.h new file mode 100644 index 00000000000..60d1891e55b --- /dev/null +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.h @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Scott MacGregor + */ + +#ifndef nsExternalHelperAppService_h__ +#define nsExternalHelperAppService_h__ + +#include "nsIExternalHelperAppService.h" +#include "nsIStreamListener.h" +#include "nsIFile.h" +#include "nsCOMPtr.h" + +class nsExternalHelperAppService : public nsIExternalHelperAppService +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIEXTERNALHELPERAPPSERVICE + + nsExternalHelperAppService(); + virtual ~nsExternalHelperAppService(); + +protected: + +}; + +// An external app handler is just a small little class that presents itself as +// a nsIStreamListener. It saves the incoming data into a temp file. The handler +// is bound to an application when it is created. When it receives an OnStopRequest +// it launches the application using the temp file it has stored the data into. + +class nsExternalAppHandler : public nsIStreamListener +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSISTREAMLISTENER + NS_DECL_NSISTREAMOBSERVER + + nsExternalAppHandler(); + virtual ~nsExternalAppHandler(); + +protected: + nsCOMPtr mTempFile; + +}; + +#endif // nsExternalHelperAppService_h__ diff --git a/mozilla/uriloader/exthandler/nsIExternalHelperAppService.idl b/mozilla/uriloader/exthandler/nsIExternalHelperAppService.idl new file mode 100644 index 00000000000..b09c8a2a91d --- /dev/null +++ b/mozilla/uriloader/exthandler/nsIExternalHelperAppService.idl @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Scott MacGregor + */ + +/* The external helper app service is used for finding and launching + platform specific external applications for a given mime content type. + */ + +#include "nsISupports.idl" + +interface nsIURI; +interface nsIStreamListener; +interface nsIFile; + + +[scriptable, uuid(663CC0AA-42EA-11d4-98D0-001083010E9B)] +interface nsIExternalHelperAppService : nsISupports +{ + // canHandleContent: determines if we have an external helper application for a given mime type + // aMimeContentType --> the specified mime type we are attempting to get a helper application for + // returns TRUE if we have such an app and FALSE otherwise. + boolean canHandleContent (in string aMimeContentType); + + // doContent: binds an external helper application to a stream listener. The caller should pump data + // into the returned stream listener. When the OnStopRequest is issued, the stream listener implementation + // will launch the helper app with this data. + // aMimeContentType --> the content type of the incoming data + // aURI --> the URI corresponding to the incoming data + // aWindowContext --> use GetInterface to retrieve properties like the dom window or parent window... + // the service might need this in order to bring up dialogs. + // aAbortProcess --> set to TRUE by the helper service if the caller should just forget about loading the document + // (typically this occurs if the helper app just wants the URI to run and not the data) + // returns a nsIStreamListener which the caller should pump the data into. + nsIStreamListener doContent (in string aMimeContentType, in nsIURI aURI, + in nsISupports aWindowContext, out boolean aAbortProcess); +}; diff --git a/mozilla/uriloader/exthandler/win/makefile.win b/mozilla/uriloader/exthandler/win/makefile.win new file mode 100644 index 00000000000..46496a5da88 --- /dev/null +++ b/mozilla/uriloader/exthandler/win/makefile.win @@ -0,0 +1,45 @@ +#!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=exthandler + +LIBRARY_NAME=exthandlerwin_s + +CPP_OBJS=\ + .\$(OBJDIR)\nsOSHelperAppService.obj \ + $(NULL) + +INCS = $(INCS) \ + -I$(DEPTH)\dist\include \ + -I..\ \ + $(NULL) + + +include <$(DEPTH)\config\rules.mak> + +install:: $(LIBRARY) + $(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib + + +clobber:: + rm -f $(DIST)\lib\$(LIBRARY_NAME).lib +