Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
nsExternalHelperAppService Class Reference

The helper app service. More...

#include <nsExternalHelperAppService.h>

Inheritance diagram for nsExternalHelperAppService:
Inheritance graph
[legend]
Collaboration diagram for nsExternalHelperAppService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIEXTERNALHELPERAPPSERVICE
NS_DECL_NSPIEXTERNALAPPLAUNCHER
NS_DECL_NSIEXTERNALPROTOCOLSERVICE
NS_DECL_NSIMIMESERVICE
NS_DECL_NSIOBSERVER 
nsExternalHelperAppService ()
virtual ~nsExternalHelperAppService ()
 NS_HIDDEN_ (nsresult) InitDataSource()
 Initializes the RDF datasource from the profile.
 NS_HIDDEN_ (nsresult) Init()
 Initializes internal state.
 NS_HIDDEN_ (nsresult) GetMIMEInfoForMimeTypeFromDS(const nsACString &aContentType
 Given a content type, look up the user override information to see if we have a mime info object representing this content type.
 NS_HIDDEN_ (nsresult) GetMIMEInfoForExtensionFromDS(const nsACString &aFileExtension
 Given an extension, look up the user override information to see if we have a mime info object representing this extension.
 NS_HIDDEN_ (PRBool) GetTypeFromDS(const nsACString &aFileExtension
 Looks up the MIME Type for a given extension in the RDF Datasource.
virtual already_AddRefed
< nsIMIMEInfo
GetMIMEInfoFromOS (const nsACString &aMIMEType, const nsACString &aFileExt, PRBool *aFound)=0
 Given a mimetype and an extension, looks up a mime info from the OS.
virtual nsresult GetFileTokenForPath (const PRUnichar *platformAppPath, nsIFile **aFile)
 Given a string identifying an application, create an nsIFile representing it.
 NS_HIDDEN_ (PRBool) MIMETypeIsInDataSource(const char *aContentType)
 Helper routine used to test whether a given mime type is in our mimeTypes.rdf data source.
nsIStreamListener doContent (in ACString aMimeContentType, in nsIRequest aRequest, in nsIInterfaceRequestor aWindowContext)
 Binds an external helper application to a stream listener.
boolean applyDecodingForExtension (in AUTF8String aExtension, in ACString aEncodingType)
 Returns true if data from a URL with this extension combination is to be decoded from aEncodingType prior to saving or passing off to helper apps, false otherwise.
void deleteTemporaryFileOnExit (in nsIFile aTemporaryFile)
 mscott --> eventually I should move this into a new service so other consumers can add temporary files they want deleted on exit.
boolean externalProtocolHandlerExists (in string aProtocolScheme)
 Check whether a handler for a specific protocol exists.
boolean isExposedProtocol (in string aProtocolScheme)
 Check whether a handler for a specific protocol is "exposed" as a visible feature of the current application.
void loadUrl (in nsIURI aURL)
 Used to load a url via an external protocol handler (if one exists)
void loadURI (in nsIURI aURI, in nsIPrompt aPrompt)
 Used to load a URI via an external application.
AString getApplicationDescription (in AUTF8String aScheme)
 Gets a human-readable description for the application responsible for handling a specific protocol.
nsIMIMEInfo getFromTypeAndExtension (in ACString aMIMEType, in AUTF8String aFileExt)
 Retrieves an nsIMIMEInfo using both the extension and the type of a file.
ACString getTypeFromExtension (in AUTF8String aFileExt)
 Retrieves a ACString representation of the MIME type associated with this file extension.
ACString getTypeFromURI (in nsIURI aURI)
 Retrieves a ACString representation of the MIME type associated with this URI.
ACString getTypeFromFile (in nsIFile aFile)
AUTF8String getPrimaryExtension (in ACString aMIMEType, in AUTF8String aFileExt)
 Given a Type/Extension combination, returns the default extension for this type.
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Public Attributes

nsIMIMEInfoaMIMEInfo
nsACString & aType

Protected Member Functions

 NS_HIDDEN_ (nsresult) FillTopLevelProperties(nsIRDFResource *aContentTypeNodeResource
 Helper routines for digesting the data source and filling in a mime info object for a given content type inside that data source.
 NS_HIDDEN_ (nsresult) FillContentHandlerProperties(const char *aContentType
 NS_HIDDEN_ (nsresult) FillLiteralValueFromTarget(nsIRDFResource *aSource
 A small helper function which gets the target for a given source and property.
 NS_HIDDEN_ (nsresult) GetMIMEInfoForMimeTypeFromExtras(const nsACString &aContentType
 Searches the "extra" array of MIMEInfo objects for an object with a specific type.
 NS_HIDDEN_ (nsresult) GetMIMEInfoForExtensionFromExtras(const nsACString &aExtension
 Searches the "extra" array of MIMEInfo objects for an object with a specific extension.
 NS_HIDDEN_ (PRBool) GetTypeFromExtras(const nsACString &aExtension
 Searches the "extra" array for a MIME type, and gets its extension.
virtual void FixFilePermissions (nsILocalFile *aFile)
 Fixes the file permissions to be correct.
 NS_HIDDEN_ (nsresult) ExpungeTemporaryFiles()
 Functions related to the tempory file cleanup service provided by nsExternalHelperAppService.
virtual NS_HIDDEN_ (nsresult) LoadUriInternal(nsIURI *aURL)=0
 OS-specific loading of external URLs.
 NS_HIDDEN_ (PRBool) isExternalLoadOK(nsIURI *aURI
 NS_HIDDEN_ (PRBool) promptForScheme(nsIURI *aURI

Static Protected Member Functions

static void *PR_CALLBACK handleExternalLoadEvent (PLEvent *event)

Protected Attributes

nsCOMPtr< nsIRDFDataSourcemOverRideDataSource
 Pointer to the datasource that contains the user override information.
nsCOMPtr< nsIRDFResourcekNC_Description
nsCOMPtr< nsIRDFResourcekNC_Value
nsCOMPtr< nsIRDFResourcekNC_FileExtensions
nsCOMPtr< nsIRDFResourcekNC_Path
nsCOMPtr< nsIRDFResourcekNC_UseSystemDefault
nsCOMPtr< nsIRDFResourcekNC_SaveToDisk
nsCOMPtr< nsIRDFResourcekNC_AlwaysAsk
nsCOMPtr< nsIRDFResourcekNC_HandleInternal
nsCOMPtr< nsIRDFResourcekNC_PrettyName
PRBool mDataSourceInitialized
 Whether mOverRideDataSource is initialized.
nsIRDFServiceaRDFService
nsIRDFService nsIMIMEInfoaMIMEInfo
nsIRDFResourceaContentTypeNodeResource
nsIRDFResource nsIRDFServiceaRDFService
nsIRDFResource nsIRDFService
nsIMIMEInfo
aMIMEInfo
nsIRDFResourceaProperty
nsIRDFResource const PRUnichar ** aLiteralValue
nsACString & aMIMEType
nsCOMArray< nsILocalFilemTemporaryFilesList
 Array for the files that should be deleted.
nsIPromptaPrompt
nsIPrompt PRBoolaRemember

Friends

class nsExternalAppHandler

Detailed Description

The helper app service.

Responsible for handling content that Mozilla itself can not handle

Definition at line 89 of file nsExternalHelperAppService.h.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_NSIEXTERNALHELPERAPPSERVICE NS_DECL_NSPIEXTERNALAPPLAUNCHER NS_DECL_NSIEXTERNALPROTOCOLSERVICE NS_DECL_NSIMIMESERVICE NS_DECL_NSIOBSERVER nsExternalHelperAppService::nsExternalHelperAppService ( )

Definition at line 515 of file nsExternalHelperAppService.cpp.

{
  sSrv = nsnull;
}

Member Function Documentation

boolean nsIExternalHelperAppService::applyDecodingForExtension ( in AUTF8String  aExtension,
in ACString  aEncodingType 
) [inherited]

Returns true if data from a URL with this extension combination is to be decoded from aEncodingType prior to saving or passing off to helper apps, false otherwise.

mscott --> eventually I should move this into a new service so other consumers can add temporary files they want deleted on exit.

Parameters:
aTemporaryFileA temporary file we should delete on exit.
nsIStreamListener nsIExternalHelperAppService::doContent ( in ACString  aMimeContentType,
in nsIRequest  aRequest,
in nsIInterfaceRequestor  aWindowContext 
) [inherited]

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.

Parameters:
aMimeContentTypeThe content type of the incoming data
aRequestThe request corresponding to the incoming data
aWindowContextUse GetInterface to retrieve properties like the dom window or parent window... The service might need this in order to bring up dialogs.
Returns:
A nsIStreamListener which the caller should pump the data into.

Check whether a handler for a specific protocol exists.

Parameters:
aProtocolSchemeThe scheme from a url: http, ftp, mailto, etc.
Returns:
true if we have a handler and false otherwise.

Fixes the file permissions to be correct.

Base class has a no-op implementation, subclasses can use this to correctly inherit ACLs from the parent directory, to make the permissions obey the umask, etc.

Reimplemented in nsOSHelperAppService.

Definition at line 1367 of file nsExternalHelperAppService.cpp.

{
  // This space intentionally left blank
}

Here is the caller graph for this function:

AString nsIExternalProtocolService::getApplicationDescription ( in AUTF8String  aScheme) [inherited]

Gets a human-readable description for the application responsible for handling a specific protocol.

Parameters:
aSchemeThe scheme to look up. For example, "mms".
Exceptions:
NS_ERROR_NOT_IMPLEMENTEDIf getting descriptions for protocol helpers is not supported
NS_ERROR_NOT_AVAILABLEIf no protocol helper exists for this scheme, or if it is not possible to get a description for it.
nsresult nsExternalHelperAppService::GetFileTokenForPath ( const PRUnichar platformAppPath,
nsIFile **  aFile 
) [virtual]

Given a string identifying an application, create an nsIFile representing it.

This function should look in $PATH for the application. The base class implementation will first try to interpret platformAppPath as an absolute path, and if that fails it will look for a file next to the mozilla executable. Subclasses can override this method if they want a different behaviour.

Parameters:
platformAppPathA platform specific path to an application that we got out of the rdf data source. This can be a mac file spec, a unix path or a windows path depending on the platform
aFile[out] An nsIFile representation of that platform application path.

Reimplemented in nsOSHelperAppService, and nsOSHelperAppService.

Definition at line 999 of file nsExternalHelperAppService.cpp.

{
  nsDependentString platformAppPath(aPlatformAppPath);
  // First, check if we have an absolute path
  nsILocalFile* localFile = nsnull;
  nsresult rv = NS_NewLocalFile(platformAppPath, PR_TRUE, &localFile);
  if (NS_SUCCEEDED(rv)) {
    *aFile = localFile;
    PRBool exists;
    if (NS_FAILED((*aFile)->Exists(&exists)) || !exists) {
      NS_RELEASE(*aFile);
      return NS_ERROR_FILE_NOT_FOUND;
    }
    return NS_OK;
  }


  // Second, check if file exists in mozilla program directory
  rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR, aFile);
  if (NS_SUCCEEDED(rv)) {
    rv = (*aFile)->Append(platformAppPath);
    if (NS_SUCCEEDED(rv)) {
      PRBool exists = PR_FALSE;
      rv = (*aFile)->Exists(&exists);
      if (NS_SUCCEEDED(rv) && exists)
        return NS_OK;
    }
    NS_RELEASE(*aFile);
  }


  return NS_ERROR_NOT_AVAILABLE;
}

Here is the call graph for this function:

nsIMIMEInfo nsIMIMEService::getFromTypeAndExtension ( in ACString  aMIMEType,
in AUTF8String  aFileExt 
) [inherited]

Retrieves an nsIMIMEInfo using both the extension and the type of a file.

The type is given preference during the lookup. One of aMIMEType and aFileExt can be an empty string. At least one of aMIMEType and aFileExt must be nonempty.

virtual already_AddRefed<nsIMIMEInfo> nsExternalHelperAppService::GetMIMEInfoFromOS ( const nsACString &  aMIMEType,
const nsACString &  aFileExt,
PRBool aFound 
) [pure virtual]

Given a mimetype and an extension, looks up a mime info from the OS.

The mime type is given preference. This function follows the same rules as nsIMIMEService::GetFromTypeAndExtension. This is supposed to be overridden by the platform-specific nsOSHelperAppService!

Parameters:
aFileExtThe file extension; may be empty. UTF-8 encoded.
[out]aFoundShould be set to PR_TRUE if the os has a mapping, to PR_FALSE otherwise. Must not be null.
Returns:
A MIMEInfo. This function must return a MIMEInfo object if it can allocate one. The only justifiable reason for not returning one is an out-of-memory error. If null, the value of aFound is unspecified.

Implemented in nsOSHelperAppService, nsOSHelperAppService, nsOSHelperAppService, nsOSHelperAppService, and nsOSHelperAppService.

AUTF8String nsIMIMEService::getPrimaryExtension ( in ACString  aMIMEType,
in AUTF8String  aFileExt 
) [inherited]

Given a Type/Extension combination, returns the default extension for this type.

This may be identical to the passed-in extension.

Parameters:
aMIMETypeThe Type to get information on. Must not be empty.
aFileExtFile Extension. Can be empty.
ACString nsIMIMEService::getTypeFromExtension ( in AUTF8String  aFileExt) [inherited]

Retrieves a ACString representation of the MIME type associated with this file extension.

Parameters:
Afile extension (excluding the dot ('.')).
Returns:
The MIME type, if any.
ACString nsIMIMEService::getTypeFromFile ( in nsIFile  aFile) [inherited]
ACString nsIMIMEService::getTypeFromURI ( in nsIURI  aURI) [inherited]

Retrieves a ACString representation of the MIME type associated with this URI.

The association is purely file extension to MIME type based. No attempt to determine the type via server headers or byte scanning is made.

Parameters:
TheURI the user wants MIME info on.
Returns:
The MIME type, if any.

Definition at line 1095 of file nsExternalHelperAppService.cpp.

{
  extLoadRequest* req = NS_STATIC_CAST(extLoadRequest*, event);
  if (req && sSrv && sSrv->isExternalLoadOK(req->uri, req->prompt))
    sSrv->LoadUriInternal(req->uri);

  return nsnull;
}

Check whether a handler for a specific protocol is "exposed" as a visible feature of the current application.

An exposed protocol handler is one that can be used in all contexts. A non-exposed protocol handler is one that can only be used internally by the application. For example, a non-exposed protocol would not be loaded by the application in response to a link click or a X-remote openURL command. Instead, it would be deferred to the system's external protocol handler.

void nsIExternalProtocolService::loadURI ( in nsIURI  aURI,
in nsIPrompt  aPrompt 
) [inherited]

Used to load a URI via an external application.

Might prompt the user for permission to load the external application. Replaces loadUrl()

Parameters:
aURIThe URI to load
aPromptIf null we grab one from windowwatcher if we need it

Used to load a url via an external protocol handler (if one exists)

Parameters:
aURLThe url to load

Initializes the RDF datasource from the profile.

Return values:
NS_OKLoading was successful
errorcodeLoading failed
See also:
mOverRideDataSource

Initializes internal state.

Will be called automatically when this service is first instantiated.

Given a content type, look up the user override information to see if we have a mime info object representing this content type.

The user over ride information is contained in a in memory data source.

Parameters:
aMIMEInfoThe mime info to fill with the information

Given an extension, look up the user override information to see if we have a mime info object representing this extension.

The user over ride information is contained in an in-memory data source.

Does not change the MIME Type of the MIME Info.

Parameters:
aMIMEInfoThe mime info to fill with the information

Looks up the MIME Type for a given extension in the RDF Datasource.

Parameters:
aExtensionThe extension to look for
aType[out] The type, if found
Returns:
PR_TRUE if found, PR_FALSE otherwise

Helper routine used to test whether a given mime type is in our mimeTypes.rdf data source.

Helper routines for digesting the data source and filling in a mime info object for a given content type inside that data source.

The content type of the MIME Info will not be changed.

See also:
FillTopLevelProperties

A small helper function which gets the target for a given source and property.

QIs to a literal and returns a CONST ptr to the string value of that target

Searches the "extra" array of MIMEInfo objects for an object with a specific type.

If found, it will modify the passed-in MIMEInfo. Otherwise, it will return an error and the MIMEInfo will be untouched.

Parameters:
aContentTypeThe type to search for.
aMIMEInfo[inout] The mime info, if found

Searches the "extra" array of MIMEInfo objects for an object with a specific extension.

Does not change the MIME Type of the MIME Info.

See also:
GetMIMEInfoForMimeTypeFromExtras

Searches the "extra" array for a MIME type, and gets its extension.

Parameters:
aExtensionThe extension to search for
aMIMEType[out] The found MIME type.
Returns:
PR_TRUE if the extension was found, PR_FALSE otherwise.

Functions related to the tempory file cleanup service provided by nsExternalHelperAppService.

virtual nsExternalHelperAppService::NS_HIDDEN_ ( nsresult  ) [protected, pure virtual]

OS-specific loading of external URLs.

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.

Friends And Related Function Documentation

friend class nsExternalAppHandler [friend]

Definition at line 287 of file nsExternalHelperAppService.h.


Member Data Documentation

Definition at line 227 of file nsExternalHelperAppService.h.

Definition at line 237 of file nsExternalHelperAppService.h.

Definition at line 128 of file nsExternalHelperAppService.h.

Definition at line 221 of file nsExternalHelperAppService.h.

Definition at line 227 of file nsExternalHelperAppService.h.

nsACString& nsExternalHelperAppService::aMIMEType [protected]

Definition at line 268 of file nsExternalHelperAppService.h.

Definition at line 303 of file nsExternalHelperAppService.h.

Definition at line 237 of file nsExternalHelperAppService.h.

Definition at line 221 of file nsExternalHelperAppService.h.

Definition at line 227 of file nsExternalHelperAppService.h.

Definition at line 304 of file nsExternalHelperAppService.h.

Definition at line 149 of file nsExternalHelperAppService.h.

Definition at line 206 of file nsExternalHelperAppService.h.

Definition at line 200 of file nsExternalHelperAppService.h.

Definition at line 202 of file nsExternalHelperAppService.h.

Definition at line 207 of file nsExternalHelperAppService.h.

Definition at line 203 of file nsExternalHelperAppService.h.

Definition at line 208 of file nsExternalHelperAppService.h.

Definition at line 205 of file nsExternalHelperAppService.h.

Definition at line 204 of file nsExternalHelperAppService.h.

Definition at line 201 of file nsExternalHelperAppService.h.

Whether mOverRideDataSource is initialized.

Definition at line 213 of file nsExternalHelperAppService.h.

Pointer to the datasource that contains the user override information.

See also:
InitDataSource

Definition at line 198 of file nsExternalHelperAppService.h.

Array for the files that should be deleted.

Definition at line 297 of file nsExternalHelperAppService.h.


The documentation for this class was generated from the following files: