bug 385740: support multiple apps per nsIHandlerInfo via a new nsIHandlerInfo::possibleApplicationHandlers attribute; r=biesi, sr=dmose

This commit is contained in:
myk%mozilla.org 2007-08-13 20:41:34 +00:00
Родитель ff1ada0ffe
Коммит 8096d920c9
9 изменённых файлов: 286 добавлений и 192 удалений

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

@ -2,31 +2,35 @@
<!--
This file is used as a persistent data store for helper application
information.
information about both MIME type and protocol scheme helpers.
The root of the data are the two containers
<RDF:Seq about="urn:mimetypes:root"/> and <RDF:Seq about="urn:schemes:root"/>.
These contain one <RDF:li/> entry per MIME type/protocol. Each <RDF:li/> entry
corresponds to a "urn:<class>:<type>" resource, where <class> is either
"mimetype" or "scheme" and <type> is either a MIME type in "major/minor" format
or a scheme. For example, for HTML we would have "urn:mimetype:text/html",
while for mailto: we would have "urn:scheme:mailto".
The root of the data is the <RDF:Seq about="urn:mimetypes:root"/>. This
contains one <RDF:li/> entry per MIME type. Each <RDF:li/> entry corresponds
to the "urn:mimetype:major/minor" resource, where "major/minor" is the MIME
type. For example, for HTML we would have "urn:mimetype:text/html".
Typically, this resource will be in the <RDF:Description/> node which has the
corresponding "about" attribute.
Each "urn:mimetype:major/minor" resource can have the following properties:
Each "urn:<class>:<type>" resource can have the following properties:
NC:Value - the MIME type string
NC:Value - the MIME type or scheme string
NC:editable - a "true" or "false" depending on whether this entry is
editable
NC:description - a description of the type ("HTML Document" for text/html)
NC:fileExtensions - there will be one of these properties per extension that
corresponds to this MIME type, each one having a single
extension as its value.
NC:fileExtensions - for MIME types, there will be one of these properties
per extension that corresponds to this MIME type,
each one having a single extension as its value.
NC:handlerProp - the way the type should be handled. This corresponds to a
"urn:mimetype:handler:major/minor" resource. Eg, the way
HTML is handled would be stored in the
"urn:mimetype:handler:text/html" resource
"urn:<class>:handler:<type>" resource. Eg, the way HTML is
handled would be stored in the
"urn:mimetype:handler:text/html" resource.
Each "urn:mimetype:handler:major/minor" resource can have the following
properties:
Each "urn:<class>:handler:<type>" resource can have the following properties:
NC:useSystemDefault - "true" if we should handle per default OS setting,
"false" or not set otherwise
@ -35,17 +39,35 @@
(Note - if both of these are false, that means "open in helper app")
NC:alwaysAsk - "true" if the user should always be prompted before handling
data of this type, false otherwise.
NC:externalApplication - the helper application to use for this type. This
corresponds to a
"urn:mimetype:externalApplication:major/minor"
resource
NC:externalApplication - the preferred helper application to use for this
type. This corresponds to a
"urn:<class>:externalApplication:<type>" resource.
NC:possibleApplication - a helper application that can be used for this type.
Since there can be multiple possible applications,
there can be multiple assertions in the graph with
this property for a given handler resource.
Each "urn:mimetype:externalApplication:major/minor" resource can have the
following properties:
Each "urn:<class>:externalApplication:<type>" resource, and each resource
that represents a possible application, can have the following property:
NC:path - the path to the application
NC:prettyName - the "pretty name" of the application ("Acrobat Reader" for
/usr/bin/acroread, eg).
If the resource represents a local application, then it can have the following
property:
NC:path - the path to the application on the local filesystem, for example
/usr/bin/test or C:\windows\system32\cmd.exe.
If the resource represents a web application, then it can have the following
property:
NC:uriTemplate - a URI pointing to the web application to which the type
should be handed off, with %s in the template representing
the place where the content should be inserted. For example,
here is a URI template for a service that lets you email
an address in a mailto: link:
http://www.example.com/sendmail?link=%s
-->
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

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

@ -2,31 +2,35 @@
<!--
This file is used as a persistent data store for helper application
information.
information about both MIME type and protocol scheme helpers.
The root of the data are the two containers
<RDF:Seq about="urn:mimetypes:root"/> and <RDF:Seq about="urn:schemes:root"/>.
These contain one <RDF:li/> entry per MIME type/protocol. Each <RDF:li/> entry
corresponds to a "urn:<class>:<type>" resource, where <class> is either
"mimetype" or "scheme" and <type> is either a MIME type in "major/minor" format
or a scheme. For example, for HTML we would have "urn:mimetype:text/html",
while for mailto: we would have "urn:scheme:mailto".
The root of the data is the <RDF:Seq about="urn:mimetypes:root"/>. This
contains one <RDF:li/> entry per MIME type. Each <RDF:li/> entry corresponds
to the "urn:mimetype:major/minor" resource, where "major/minor" is the MIME
type. For example, for HTML we would have "urn:mimetype:text/html".
Typically, this resource will be in the <RDF:Description/> node which has the
corresponding "about" attribute.
Each "urn:mimetype:major/minor" resource can have the following properties:
Each "urn:<class>:<type>" resource can have the following properties:
NC:Value - the MIME type string
NC:Value - the MIME type or scheme string
NC:editable - a "true" or "false" depending on whether this entry is
editable
NC:description - a description of the type ("HTML Document" for text/html)
NC:fileExtensions - there will be one of these properties per extension that
corresponds to this MIME type, each one having a single
extension as its value.
NC:fileExtensions - for MIME types, there will be one of these properties
per extension that corresponds to this MIME type,
each one having a single extension as its value.
NC:handlerProp - the way the type should be handled. This corresponds to a
"urn:mimetype:handler:major/minor" resource. Eg, the way
HTML is handled would be stored in the
"urn:mimetype:handler:text/html" resource
"urn:<class>:handler:<type>" resource. Eg, the way HTML is
handled would be stored in the
"urn:mimetype:handler:text/html" resource.
Each "urn:mimetype:handler:major/minor" resource can have the following
properties:
Each "urn:<class>:handler:<type>" resource can have the following properties:
NC:useSystemDefault - "true" if we should handle per default OS setting,
"false" or not set otherwise
@ -35,17 +39,35 @@
(Note - if both of these are false, that means "open in helper app")
NC:alwaysAsk - "true" if the user should always be prompted before handling
data of this type, false otherwise.
NC:externalApplication - the helper application to use for this type. This
corresponds to a
"urn:mimetype:externalApplication:major/minor"
resource
NC:externalApplication - the preferred helper application to use for this
type. This corresponds to a
"urn:<class>:externalApplication:<type>" resource.
NC:possibleApplication - a helper application that can be used for this type.
Since there can be multiple possible applications,
there can be multiple assertions in the graph with
this property for a given handler resource.
Each "urn:mimetype:externalApplication:major/minor" resource can have the
following properties:
Each "urn:<class>:externalApplication:<type>" resource, and each resource
that represents a possible application, can have the following property:
NC:path - the path to the application
NC:prettyName - the "pretty name" of the application ("Acrobat Reader" for
/usr/bin/acroread, eg).
If the resource represents a local application, then it can have the following
property:
NC:path - the path to the application on the local filesystem, for example
/usr/bin/test or C:\windows\system32\cmd.exe.
If the resource represents a web application, then it can have the following
property:
NC:uriTemplate - a URI pointing to the web application to which the type
should be handed off, with %s in the template representing
the place where the content should be inserted. For example,
here is a URI template for a service that lets you email
an address in a mailto: link:
http://www.example.com/sendmail?link=%s
-->
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

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

@ -42,6 +42,7 @@ interface nsIURI;
interface nsIFile;
interface nsIUTF8StringEnumerator;
interface nsIHandlerApp;
interface nsIMutableArray;
typedef long nsHandlerInfoAction;
@ -49,7 +50,7 @@ typedef long nsHandlerInfoAction;
* nsIHandlerInfo gives access to the information about how a given protocol
* scheme or MIME-type is handled.
*/
[scriptable, uuid(51ddc1c5-7077-4c58-a5bd-327d00777b46)]
[scriptable, uuid(4c7f5603-cfa9-4576-a769-c3343cb0135b)]
interface nsIHandlerInfo : nsISupports {
/**
* The type of this handler info. For MIME handlers, this is the MIME type.
@ -70,6 +71,17 @@ interface nsIHandlerInfo : nsISupports {
*/
attribute nsIHandlerApp preferredApplicationHandler;
/**
* Applications that can handle this content type.
*
* The list will include the preferred handler, if any. Elements of this
* array are nsIHandlerApp objects, and this attribute will always reference
* an array, whether or not there are any possible handlers. If there are
* no possible handlers, the array will contain no elements, so just check
* its length (nsIArray::length) to see if there are any possible handlers.
*/
readonly attribute nsIMutableArray possibleApplicationHandlers;
/**
* Indicates whether a default application handler exists,
* i.e. whether launchWithFile with action = useSystemDefault is possible

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

@ -2,31 +2,35 @@
<!--
This file is used as a persistent data store for helper application
information.
information about both MIME type and protocol scheme helpers.
The root of the data are the two containers
<RDF:Seq about="urn:mimetypes:root"/> and <RDF:Seq about="urn:schemes:root"/>.
These contain one <RDF:li/> entry per MIME type/protocol. Each <RDF:li/> entry
corresponds to a "urn:<class>:<type>" resource, where <class> is either
"mimetype" or "scheme" and <type> is either a MIME type in "major/minor" format
or a scheme. For example, for HTML we would have "urn:mimetype:text/html",
while for mailto: we would have "urn:scheme:mailto".
The root of the data is the <RDF:Seq about="urn:mimetypes:root"/>. This
contains one <RDF:li/> entry per MIME type. Each <RDF:li/> entry corresponds
to the "urn:mimetype:major/minor" resource, where "major/minor" is the MIME
type. For example, for HTML we would have "urn:mimetype:text/html".
Typically, this resource will be in the <RDF:Description/> node which has the
corresponding "about" attribute.
Each "urn:mimetype:major/minor" resource can have the following properties:
Each "urn:<class>:<type>" resource can have the following properties:
NC:Value - the MIME type string
NC:Value - the MIME type or scheme string
NC:editable - a "true" or "false" depending on whether this entry is
editable
NC:description - a description of the type ("HTML Document" for text/html)
NC:fileExtensions - there will be one of these properties per extension that
corresponds to this MIME type, each one having a single
extension as its value.
NC:fileExtensions - for MIME types, there will be one of these properties
per extension that corresponds to this MIME type,
each one having a single extension as its value.
NC:handlerProp - the way the type should be handled. This corresponds to a
"urn:mimetype:handler:major/minor" resource. Eg, the way
HTML is handled would be stored in the
"urn:mimetype:handler:text/html" resource
"urn:<class>:handler:<type>" resource. Eg, the way HTML is
handled would be stored in the
"urn:mimetype:handler:text/html" resource.
Each "urn:mimetype:handler:major/minor" resource can have the following
properties:
Each "urn:<class>:handler:<type>" resource can have the following properties:
NC:useSystemDefault - "true" if we should handle per default OS setting,
"false" or not set otherwise
@ -35,17 +39,35 @@
(Note - if both of these are false, that means "open in helper app")
NC:alwaysAsk - "true" if the user should always be prompted before handling
data of this type, false otherwise.
NC:externalApplication - the helper application to use for this type. This
corresponds to a
"urn:mimetype:externalApplication:major/minor"
resource
NC:externalApplication - the preferred helper application to use for this
type. This corresponds to a
"urn:<class>:externalApplication:<type>" resource.
NC:possibleApplication - a helper application that can be used for this type.
Since there can be multiple possible applications,
there can be multiple assertions in the graph with
this property for a given handler resource.
Each "urn:mimetype:externalApplication:major/minor" resource can have the
following properties:
Each "urn:<class>:externalApplication:<type>" resource, and each resource
that represents a possible application, can have the following property:
NC:path - the path to the application
NC:prettyName - the "pretty name" of the application ("Acrobat Reader" for
/usr/bin/acroread, eg).
If the resource represents a local application, then it can have the following
property:
NC:path - the path to the application on the local filesystem, for example
/usr/bin/test or C:\windows\system32\cmd.exe.
If the resource represents a web application, then it can have the following
property:
NC:uriTemplate - a URI pointing to the web application to which the type
should be handed off, with %s in the template representing
the place where the content should be inserted. For example,
here is a URI template for a service that lets you email
an address in a mailto: link:
http://www.example.com/sendmail?link=%s
-->
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

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

@ -65,6 +65,7 @@
#include "nsIInterfaceRequestor.h"
#include "nsThreadUtils.h"
#include "nsAutoPtr.h"
#include "nsIMutableArray.h"
// used to manage our in memory data source of helper applications
#ifdef MOZ_RDF
@ -570,6 +571,8 @@ nsresult nsExternalHelperAppService::InitDataSource()
getter_AddRefs(kNC_HandleInternal));
rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ALWAYSASK),
getter_AddRefs(kNC_AlwaysAsk));
rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_POSSIBLEAPPLICATION),
getter_AddRefs(kNC_PossibleApplication));
rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_PRETTYNAME),
getter_AddRefs(kNC_PrettyName));
rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_URITEMPLATE),
@ -767,7 +770,9 @@ nsresult nsExternalHelperAppService::FillMIMEExtensionProperties(
return rv;
}
nsresult nsExternalHelperAppService::FillLiteralValueFromTarget(nsIRDFResource * aSource, nsIRDFResource * aProperty, const PRUnichar ** aLiteralValue)
nsresult nsExternalHelperAppService::FillLiteralValueFromTarget(
nsIRDFResource * aSource, nsIRDFResource * aProperty,
const PRUnichar ** aLiteralValue)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIRDFLiteral> literal;
@ -791,6 +796,85 @@ nsresult nsExternalHelperAppService::FillLiteralValueFromTarget(nsIRDFResource *
return rv;
}
nsresult nsExternalHelperAppService::FillHandlerAppFromSource(
nsIRDFResource * aSource, nsIHandlerApp ** aHandlerApp)
{
nsresult rv = NS_OK;
const PRUnichar * appName = nsnull;
FillLiteralValueFromTarget(aSource, kNC_PrettyName, &appName);
// if we've got a path name, this must be a local app
const PRUnichar * path = nsnull;
FillLiteralValueFromTarget(aSource, kNC_Path, &path);
if (path && path[0])
{
nsCOMPtr<nsIFile> application;
GetFileTokenForPath(path, getter_AddRefs(application));
if (application) {
nsLocalHandlerApp *handlerApp(new nsLocalHandlerApp(appName, application));
if (!handlerApp) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aHandlerApp = handlerApp);
}
} else {
// if we got here, there's no path name in the RDF graph, so this must
// be a web app
const PRUnichar * uriTemplate = nsnull;
FillLiteralValueFromTarget(aSource, kNC_UriTemplate, &uriTemplate);
if (uriTemplate && uriTemplate[0]) {
nsWebHandlerApp *handlerApp(new nsWebHandlerApp(appName,
NS_ConvertUTF16toUTF8(uriTemplate)));
if (!handlerApp) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aHandlerApp = handlerApp);
} else {
return NS_ERROR_FAILURE; // no path name _and_ no uri template
}
}
return rv;
}
nsresult nsExternalHelperAppService::FillPossibleAppsFromSource(
nsIRDFResource * aSource, nsIMutableArray * aPossibleApps)
{
nsresult rv = NS_OK;
rv = InitDataSource();
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISimpleEnumerator> possibleAppResources;
rv = mOverRideDataSource->GetTargets(aSource, kNC_PossibleApplication, PR_TRUE,
getter_AddRefs(possibleAppResources));
if (NS_FAILED(rv)) return rv;
PRBool more;
nsCOMPtr<nsISupports> supports;
while (NS_SUCCEEDED(possibleAppResources->HasMoreElements(&more)) && more) {
rv = possibleAppResources->GetNext(getter_AddRefs(supports));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFResource> possibleAppResource = do_QueryInterface(supports);
if (possibleAppResource) {
nsCOMPtr<nsIHandlerApp> possibleApp;
rv = FillHandlerAppFromSource(possibleAppResource, getter_AddRefs(possibleApp));
// It's ok if we failed to get one of the possible apps, as some of the
// others might still be good, so merely continue on failure.
if (NS_FAILED(rv)) continue;
rv = aPossibleApps->AppendElement(possibleApp, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
}
return NS_OK;
}
nsresult nsExternalHelperAppService::FillContentHandlerProperties(
const char * aContentType, const char * aTypeNodePrefix,
nsIRDFService * aRDFService, nsIHandlerInfo * aHandlerInfo)
@ -836,58 +920,41 @@ nsresult nsExternalHelperAppService::FillContentHandlerProperties(
// Only skip asking if we are absolutely sure the user does not want
// to be asked. Any sort of bofus data should mean we ask.
aHandlerInfo->SetAlwaysAskBeforeHandling(!stringValue ||
!falseString.Equals(stringValue));
!falseString.Equals(stringValue));
// now digest the external application information
// Clear out any possibly set applications to match the datasource.
aHandlerInfo->SetPreferredApplicationHandler(nsnull);
// Get the preferred application, if any.
nsCAutoString externalAppNodeName(aTypeNodePrefix);
externalAppNodeName.AppendLiteral(NC_EXTERNALAPP_SUFFIX);
externalAppNodeName.Append(aContentType);
nsCOMPtr<nsIRDFResource> externalAppNodeResource;
aRDFService->GetResource(externalAppNodeName, getter_AddRefs(externalAppNodeResource));
// Clear out any possibly set preferred application, to match the datasource
aHandlerInfo->SetPreferredApplicationHandler(nsnull);
if (externalAppNodeResource)
{
const PRUnichar * appName;
FillLiteralValueFromTarget(externalAppNodeResource, kNC_PrettyName,
&appName);
nsCOMPtr<nsIHandlerApp> preferredApp;
rv = FillHandlerAppFromSource(externalAppNodeResource, getter_AddRefs(preferredApp));
// if we've got a path name, this must be a local app
FillLiteralValueFromTarget(externalAppNodeResource, kNC_Path, &stringValue);
if (stringValue && stringValue[0])
{
nsCOMPtr<nsIFile> application;
GetFileTokenForPath(stringValue, getter_AddRefs(application));
if (application) {
nsLocalHandlerApp *handlerApp(new nsLocalHandlerApp(appName, application));
if (!handlerApp) {
return NS_ERROR_OUT_OF_MEMORY;
}
return aHandlerInfo->SetPreferredApplicationHandler(handlerApp);
}
} else {
// maybe we've get a uri template, which would indicate that this is a
// web-handler
FillLiteralValueFromTarget(externalAppNodeResource, kNC_UriTemplate,
&stringValue);
if (stringValue && stringValue[0]) {
nsWebHandlerApp *handlerApp(new nsWebHandlerApp(appName,
NS_ConvertUTF16toUTF8(stringValue)));
if (!handlerApp) {
return NS_ERROR_OUT_OF_MEMORY;
}
return aHandlerInfo->SetPreferredApplicationHandler(handlerApp);
}
// otherwise, no handler at all; fall through to return NS_OK
}
if (NS_SUCCEEDED(rv))
aHandlerInfo->SetPreferredApplicationHandler(preferredApp);
}
return NS_OK;
// Get the possible applications, if any.
nsCOMPtr<nsIMutableArray> possibleApps;
rv = aHandlerInfo->GetPossibleApplicationHandlers(getter_AddRefs(possibleApps));
if (NS_FAILED(rv)) return rv;
// Clear out any possibly set applications to match the datasource.
possibleApps->Clear();
rv = FillPossibleAppsFromSource(contentTypeHandlerNodeResource, possibleApps);
return rv;
}
#endif /* MOZ_RDF */

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

@ -252,6 +252,7 @@ protected:
nsCOMPtr<nsIRDFResource> kNC_HandleInternal;
nsCOMPtr<nsIRDFResource> kNC_PrettyName;
nsCOMPtr<nsIRDFResource> kNC_UriTemplate;
nsCOMPtr<nsIRDFResource> kNC_PossibleApplication;
#endif
/**
@ -260,9 +261,9 @@ protected:
PRBool mDataSourceInitialized;
/**
* 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.
* Helper routines for digesting the data source and filling in a handler
* info object for a given content type inside that data source. The content
* type of the handler info object will not be changed.
*/
#ifdef MOZ_RDF
NS_HIDDEN_(nsresult) FillMIMEExtensionProperties(
@ -285,6 +286,19 @@ protected:
NS_HIDDEN_(nsresult) FillLiteralValueFromTarget(nsIRDFResource * aSource,
nsIRDFResource * aProperty,
const PRUnichar ** aLiteralValue);
/**
* Returns the nsIHandlerApp represented by the source node.
*/
NS_HIDDEN_(nsresult) FillHandlerAppFromSource(nsIRDFResource * aSource,
nsIHandlerApp ** aHandlerApp);
/**
* Returns an array of nsIHandlerApp objects representing possible apps
* for the handler represented by the source node.
*/
NS_HIDDEN_(nsresult) FillPossibleAppsFromSource(nsIRDFResource * aSource,
nsIMutableArray * aPossibleApps);
#endif
/**

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

@ -1,82 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/** @file
* This file holds our vocabulary definition for the helper
* app data source. The helper app data source contains user specified helper
* application override information.
*
* @see profile/defaults/mimeTypes.rdf for documentation on these properties
*/
#define NC_RDF_MIMETYPES NC_NAMESPACE_URI"MIME-Types"
// a mime type has the following properties...
#define NC_RDF_MIMETYPE NC_NAMESPACE_URI"MIME-Type"
#define NC_RDF_DESCRIPTION NC_NAMESPACE_URI"description"
#define NC_RDF_VALUE NC_NAMESPACE_URI"value"
#define NC_RDF_EDITABLE NC_NAMESPACE_URI"editable"
#define NC_RDF_LARGEICON NC_NAMESPACE_URI"largeIcon"
#define NC_RDF_SMALLICON NC_NAMESPACE_URI"smallIcon"
#define NC_RDF_HANDLER NC_NAMESPACE_URI"handler"
#define NC_RDF_FILEEXTENSIONS NC_NAMESPACE_URI"fileExtensions"
#define NC_RDF_CHILD NC_NAMESPACE_URI"child"
#define NC_RDF_ROOT "NC:HelperAppRoot"
#define NC_CONTENT_NODE_PREFIX "urn:mimetype:"
#define NC_HANDLER_SUFFIX "handler:"
#define NC_EXTERNALAPP_SUFFIX "externalApplication:"
// for URI schemes. We re-use NC_RDF_HANDLER as an arc from these nodes.
#define NC_SCHEME_NODE_PREFIX "urn:scheme:"
#define NS_RDF_PROTOCOLSCHEMES NC_NAMESPACE_URI"Protocol-Schemes"
// File Extensions have file extension properties....
#define NC_RDF_FILEEXTENSION NC_NAMESPACE_URI"fileExtension"
// handler properties
#define NC_RDF_SAVETODISK NC_NAMESPACE_URI"saveToDisk"
#define NC_RDF_USESYSTEMDEFAULT NC_NAMESPACE_URI"useSystemDefault"
#define NC_RDF_HANDLEINTERNAL NC_NAMESPACE_URI"handleInternal"
#define NC_RDF_ALWAYSASK NC_NAMESPACE_URI"alwaysAsk"
#define NC_RDF_EXTERNALAPPLICATION NC_NAMESPACE_URI"externalApplication"
// external applications properties....
#define NC_RDF_PRETTYNAME NC_NAMESPACE_URI"prettyName"
// for local apps, we'll have the path (but not uriTemplate)
#define NC_RDF_PATH NC_NAMESPACE_URI"path"
// for web apps, we'll have the uriTemplate (but not path)
#define NC_RDF_URITEMPLATE NC_NAMESPACE_URI"uriTemplate"

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

@ -286,6 +286,20 @@ nsMIMEInfoBase::SetPreferredApplicationHandler(nsIHandlerApp * aPreferredAppHand
return NS_OK;
}
NS_IMETHODIMP
nsMIMEInfoBase::GetPossibleApplicationHandlers(nsIMutableArray ** aPossibleAppHandlers)
{
if (!mPossibleApplications)
mPossibleApplications = do_CreateInstance(NS_ARRAY_CONTRACTID);
if (!mPossibleApplications)
return NS_ERROR_OUT_OF_MEMORY;
*aPossibleAppHandlers = mPossibleApplications;
NS_IF_ADDREF(*aPossibleAppHandlers);
return NS_OK;
}
NS_IMETHODIMP
nsMIMEInfoBase::GetPreferredAction(nsHandlerInfoAction * aPreferredAction)
{

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

@ -43,6 +43,7 @@
#include "nsIAtom.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsIMutableArray.h"
#include "nsIFile.h"
#include "nsCOMPtr.h"
#include "nsIURI.h"
@ -83,8 +84,9 @@ class nsMIMEInfoBase : public nsIMIMEInfo {
NS_IMETHOD GetMacCreator(PRUint32 *aMacCreator);
NS_IMETHOD SetMacCreator(PRUint32 aMacCreator);
NS_IMETHOD Equals(nsIMIMEInfo *aMIMEInfo, PRBool *_retval);
NS_IMETHOD GetPreferredApplicationHandler(nsIHandlerApp * *aPreferredApplicationHandler);
NS_IMETHOD SetPreferredApplicationHandler(nsIHandlerApp * aPreferredApplicationHandler);
NS_IMETHOD GetPreferredApplicationHandler(nsIHandlerApp * *aPreferredAppHandler);
NS_IMETHOD SetPreferredApplicationHandler(nsIHandlerApp * aPreferredAppHandler);
NS_IMETHOD GetPossibleApplicationHandlers(nsIMutableArray * *aPossibleAppHandlers);
NS_IMETHOD GetDefaultDescription(nsAString & aDefaultDescription);
NS_IMETHOD LaunchWithURI(nsIURI *aURI);
NS_IMETHOD GetPreferredAction(nsHandlerInfoAction *aPreferredAction);
@ -175,6 +177,7 @@ class nsMIMEInfoBase : public nsIMIMEInfo {
nsCString mType;
HandlerClass mClass;
nsCOMPtr<nsIHandlerApp> mPreferredApplication;
nsCOMPtr<nsIMutableArray> mPossibleApplications;
nsHandlerInfoAction mPreferredAction; ///< preferred action to associate with this type
nsString mPreferredAppDescription;
nsString mDefaultAppDescription;