From 5614a99a6ad0caecd9aa94fc99308aa145674e7c Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Tue, 20 Jun 2000 20:43:54 +0000 Subject: [PATCH] Bug #38374 --> more updates for external helper application support. (NOT PART OF THE BUILD) r=mscott --- uriloader/exthandler/.cvsignore | 1 + uriloader/exthandler/Makefile.in | 53 ++++++++++++++++++ .../exthandler/unix/nsOSHelperAppService.cpp | 54 ++++++++++++++----- 3 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 uriloader/exthandler/.cvsignore create mode 100644 uriloader/exthandler/Makefile.in diff --git a/uriloader/exthandler/.cvsignore b/uriloader/exthandler/.cvsignore new file mode 100644 index 000000000000..f3c7a7c5da68 --- /dev/null +++ b/uriloader/exthandler/.cvsignore @@ -0,0 +1 @@ +Makefile diff --git a/uriloader/exthandler/Makefile.in b/uriloader/exthandler/Makefile.in new file mode 100644 index 000000000000..5729a3a06cdc --- /dev/null +++ b/uriloader/exthandler/Makefile.in @@ -0,0 +1,53 @@ +# +# 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@ + +MODULE = exthandler +LIBRARY_NAME = exthandler_s + +include $(DEPTH)/config/autoconf.mk + +EXPORTS = nsExternalHelperAppService.h \ + unix/nsOSHelperAppService.h \ + $(NULL) + +XPIDLSRCS = \ + nsCExternalHandlerService.idl \ + nsIExternalProtocolService.idl \ + nsIExternalHelperAppService.idl \ + $(NULL) + +CPPSRCS = \ + nsExternalHelperAppService.cpp \ + unix/nsOSHelperAppService.cpp \ + $(NULL) + + +# we don't want the shared lib, but we want to force the creation of a static lib. +override NO_SHARED_LIB=1 +override NO_STATIC_LIB= + +include $(topsrcdir)/config/rules.mk + diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp index 42c5358857c0..c4fca6480d34 100644 --- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp +++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp @@ -26,6 +26,7 @@ #include "nsXPIDLString.h" #include "nsIURL.h" #include "nsILocalFile.h" +#include // for system() // this is a platform specific class that abstracts an application. // we treat this object as a cookie when we pass it to an external app handler.. @@ -80,17 +81,26 @@ nsresult nsExternalApplication::LaunchApplication(nsIFile * aTempFile) if (!mAppRegistryName.IsEmpty() && aTempFile) { + nsCAutoString command; nsXPIDLCString path; aTempFile->GetPath(getter_Copies(path)); - - // use the app registry name to launch a shell execute.... - LONG r = (LONG) ::ShellExecute( NULL, "open", (const char *) path, NULL, NULL, SW_SHOWNORMAL); - if (r < 32) - { - rv = NS_ERROR_FAILURE; - } - else - rv = NS_OK; + + // build the command to run + command = (const char *)mAppRegistryName; + command += " "; + command += (const char *)path; + +#ifdef DEBUG_seth + printf("spawn this: %s\n",(const char *)command); +#endif + int err = system((const char *)command); + + if (err == 0) { + rv = NS_OK; + } + else { + rv = NS_ERROR_FAILURE; + } } return rv; @@ -98,7 +108,7 @@ nsresult nsExternalApplication::LaunchApplication(nsIFile * aTempFile) nsOSHelperAppService::nsOSHelperAppService() : nsExternalHelperAppService() { - nsExternalHelperAppService::Init(); + //nsExternalHelperAppService::Init(); } nsOSHelperAppService::~nsOSHelperAppService() @@ -121,8 +131,6 @@ NS_IMETHODIMP nsOSHelperAppService::CanHandleContent(const char *aMimeContentTyp NS_IMETHODIMP nsOSHelperAppService::DoContent(const char *aMimeContentType, nsIURI *aURI, nsISupports *aWindowContext, PRBool *aAbortProcess, nsIStreamListener ** aStreamListener) { - nsresult rv = NS_OK; - // look up the content type and get a platform specific handle to the app we want to use for this // download...create a nsExternalAppHandler, bind the application token to it (as a nsIFile??) and return this // as the stream listener to use... @@ -132,7 +140,26 @@ NS_IMETHODIMP nsOSHelperAppService::DoContent(const char *aMimeContentType, nsIU // now bind the handler to the application we want to launch when we the handler is done // receiving all the data... - *aStreamListener = nsnull; + + + printf("fix this hardcoding\n"); + + nsCAutoString fileExtension; + fileExtension = ".mp3"; + + // create an application that represents this app name... + nsExternalApplication * application = nsnull; + NS_NEWXPCOM(application, nsExternalApplication); + + if (application) + application->SetAppRegistryName("xmms"); + + nsCOMPtr appSupports = do_QueryInterface(application); + + // this code is incomplete and just here to get things started.. + nsExternalAppHandler * handler = CreateNewExternalHandler(appSupports, fileExtension); + handler->QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aStreamListener); + return NS_OK; } @@ -156,6 +183,5 @@ NS_IMETHODIMP nsOSHelperAppService::ExternalProtocolHandlerExists(const char * a NS_IMETHODIMP nsOSHelperAppService::LoadUrl(nsIURI * aURL) { - nsresult rv = NS_OK; return NS_ERROR_FAILURE; }