michael@0: /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsOSHelperAppService_h__ michael@0: #define nsOSHelperAppService_h__ michael@0: michael@0: // The OS helper app service is a subclass of nsExternalHelperAppService and is implemented on each michael@0: // platform. It contains platform specific code for finding helper applications for a given mime type michael@0: // in addition to launching those applications. michael@0: michael@0: #include "nsExternalHelperAppService.h" michael@0: #include "nsCExternalHandlerService.h" michael@0: #include "nsMIMEInfoImpl.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: class nsILineInputStream; michael@0: michael@0: class nsOSHelperAppService : public nsExternalHelperAppService michael@0: { michael@0: public: michael@0: nsOSHelperAppService(); michael@0: virtual ~nsOSHelperAppService(); michael@0: michael@0: // method overrides for mime.types and mime.info look up steps michael@0: already_AddRefed GetMIMEInfoFromOS(const nsACString& aMimeType, michael@0: const nsACString& aFileExt, michael@0: bool *aFound); michael@0: NS_IMETHOD GetProtocolHandlerInfoFromOS(const nsACString &aScheme, michael@0: bool *found, michael@0: nsIHandlerInfo **_retval); michael@0: michael@0: // override nsIExternalProtocolService methods michael@0: nsresult OSProtocolHandlerExists(const char * aProtocolScheme, bool * aHandlerExists); michael@0: NS_IMETHOD GetApplicationDescription(const nsACString& aScheme, nsAString& _retval); michael@0: michael@0: // GetFileTokenForPath must be implemented by each platform. michael@0: // platformAppPath --> a platform specific path to an application that we got out of the michael@0: // rdf data source. This can be a mac file spec, a unix path or a windows path depending on the platform michael@0: // aFile --> an nsIFile representation of that platform application path. michael@0: virtual nsresult GetFileTokenForPath(const char16_t * platformAppPath, nsIFile ** aFile); michael@0: michael@0: protected: michael@0: already_AddRefed GetFromType(const nsCString& aMimeType); michael@0: already_AddRefed GetFromExtension(const nsCString& aFileExt); michael@0: michael@0: private: michael@0: uint32_t mPermissions; michael@0: michael@0: // Helper methods which have to access static members michael@0: static nsresult UnescapeCommand(const nsAString& aEscapedCommand, michael@0: const nsAString& aMajorType, michael@0: const nsAString& aMinorType, michael@0: nsACString& aUnEscapedCommand); michael@0: static nsresult GetFileLocation(const char* aPrefName, michael@0: const char* aEnvVarName, michael@0: nsAString& aFileLocation); michael@0: static nsresult LookUpTypeAndDescription(const nsAString& aFileExtension, michael@0: nsAString& aMajorType, michael@0: nsAString& aMinorType, michael@0: nsAString& aDescription, michael@0: bool aUserData); michael@0: static nsresult CreateInputStream(const nsAString& aFilename, michael@0: nsIFileInputStream ** aFileInputStream, michael@0: nsILineInputStream ** aLineInputStream, michael@0: nsACString& aBuffer, michael@0: bool * aNetscapeFormat, michael@0: bool * aMore); michael@0: michael@0: static nsresult GetTypeAndDescriptionFromMimetypesFile(const nsAString& aFilename, michael@0: const nsAString& aFileExtension, michael@0: nsAString& aMajorType, michael@0: nsAString& aMinorType, michael@0: nsAString& aDescription); michael@0: michael@0: static nsresult LookUpExtensionsAndDescription(const nsAString& aMajorType, michael@0: const nsAString& aMinorType, michael@0: nsAString& aFileExtensions, michael@0: nsAString& aDescription); michael@0: michael@0: static nsresult GetExtensionsAndDescriptionFromMimetypesFile(const nsAString& aFilename, michael@0: const nsAString& aMajorType, michael@0: const nsAString& aMinorType, michael@0: nsAString& aFileExtensions, michael@0: nsAString& aDescription); michael@0: michael@0: static nsresult ParseNetscapeMIMETypesEntry(const nsAString& aEntry, michael@0: nsAString::const_iterator& aMajorTypeStart, michael@0: nsAString::const_iterator& aMajorTypeEnd, michael@0: nsAString::const_iterator& aMinorTypeStart, michael@0: nsAString::const_iterator& aMinorTypeEnd, michael@0: nsAString& aExtensions, michael@0: nsAString::const_iterator& aDescriptionStart, michael@0: nsAString::const_iterator& aDescriptionEnd); michael@0: michael@0: static nsresult ParseNormalMIMETypesEntry(const nsAString& aEntry, michael@0: nsAString::const_iterator& aMajorTypeStart, michael@0: nsAString::const_iterator& aMajorTypeEnd, michael@0: nsAString::const_iterator& aMinorTypeStart, michael@0: nsAString::const_iterator& aMinorTypeEnd, michael@0: nsAString& aExtensions, michael@0: nsAString::const_iterator& aDescriptionStart, michael@0: nsAString::const_iterator& aDescriptionEnd); michael@0: michael@0: static nsresult LookUpHandlerAndDescription(const nsAString& aMajorType, michael@0: const nsAString& aMinorType, michael@0: nsAString& aHandler, michael@0: nsAString& aDescription, michael@0: nsAString& aMozillaFlags); michael@0: michael@0: static nsresult DoLookUpHandlerAndDescription(const nsAString& aMajorType, michael@0: const nsAString& aMinorType, michael@0: nsAString& aHandler, michael@0: nsAString& aDescription, michael@0: nsAString& aMozillaFlags, michael@0: bool aUserData); michael@0: michael@0: static nsresult GetHandlerAndDescriptionFromMailcapFile(const nsAString& aFilename, michael@0: const nsAString& aMajorType, michael@0: const nsAString& aMinorType, michael@0: nsAString& aHandler, michael@0: nsAString& aDescription, michael@0: nsAString& aMozillaFlags); michael@0: }; michael@0: michael@0: #endif // nsOSHelperAppService_h__