Bug #38374 --> more updates for external helper application support. (NOT PART OF THE BUILD) r=mscott

This commit is contained in:
sspitzer%netscape.com 2000-06-20 20:43:54 +00:00
Родитель 589df04ae3
Коммит 5614a99a6a
3 изменённых файлов: 94 добавлений и 14 удалений

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

@ -0,0 +1 @@
Makefile

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

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

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

@ -26,6 +26,7 @@
#include "nsXPIDLString.h"
#include "nsIURL.h"
#include "nsILocalFile.h"
#include <stdlib.h> // 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<nsISupports> 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;
}