Bug #38374 --> foundation for helper app architecture.

Not part of the build yet. review will come when this is ready to go.
This commit is contained in:
mscott%netscape.com 2000-06-16 21:35:13 +00:00
Родитель ceefda9021
Коммит f51d776b01
6 изменённых файлов: 321 добавлений и 0 удалений

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

@ -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

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

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

@ -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 <mscott@netscape.com>
*/
#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;
}

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

@ -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 <mscott@netscape.com>
*/
#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<nsIFile> mTempFile;
};
#endif // nsExternalHelperAppService_h__

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

@ -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 <mscott@netscape.com>
*/
/* 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);
};

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

@ -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