Fix for 53670.

This commit is contained in:
hyatt%netscape.com 2001-04-04 23:15:02 +00:00
parent 26858c4032
commit fe8a8c8c58
8 changed files with 148 additions and 33 deletions

View File

@ -556,13 +556,15 @@ NS_IMETHODIMP
nsChromeRegistry::GetBaseURL(const nsCString& aPackage, const nsCString& aProvider, nsChromeRegistry::GetBaseURL(const nsCString& aPackage, const nsCString& aProvider,
nsCString& aBaseURL) nsCString& aBaseURL)
{ {
nsCOMPtr<nsIRDFResource> resource;
nsCAutoString resourceStr("urn:mozilla:package:"); nsCAutoString resourceStr("urn:mozilla:package:");
resourceStr += aPackage; resourceStr += aPackage;
// Obtain the resource. // Obtain the resource.
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr<nsIRDFResource> resource; nsCOMPtr<nsIRDFResource> packageResource;
rv = GetResource(resourceStr, getter_AddRefs(resource)); rv = GetResource(resourceStr, getter_AddRefs(packageResource));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_ERROR("Unable to obtain the package resource."); NS_ERROR("Unable to obtain the package resource.");
return rv; return rv;
@ -576,23 +578,52 @@ nsChromeRegistry::GetBaseURL(const nsCString& aPackage, const nsCString& aProvid
else if (aProvider.Equals(nsCAutoString("locale"))) { else if (aProvider.Equals(nsCAutoString("locale"))) {
arc = mSelectedLocale; arc = mSelectedLocale;
} }
else
// We're a package.
resource = packageResource;
if (arc) { if (arc) {
nsCOMPtr<nsIRDFNode> selectedProvider; nsCOMPtr<nsIRDFNode> selectedProvider;
if (NS_FAILED(rv = mChromeDataSource->GetTarget(resource, arc, PR_TRUE, getter_AddRefs(selectedProvider)))) { if (NS_FAILED(rv = mChromeDataSource->GetTarget(packageResource, arc, PR_TRUE, getter_AddRefs(selectedProvider)))) {
NS_ERROR("Unable to obtain the provider."); NS_ERROR("Unable to obtain the provider.");
return rv; return rv;
} }
if (!selectedProvider) { resource = do_QueryInterface(selectedProvider);
rv = FindProvider(aPackage, aProvider, arc, getter_AddRefs(selectedProvider));
if (NS_FAILED(rv)) return rv; if (resource) {
// We found a selected provider, but now we need to verify that the version
// specified by the package and the version specified by the provider are
// one and the same. If they aren't, then we cannot use this provider.
nsCOMPtr<nsIRDFResource> versionArc;
if (arc == mSelectedSkin)
versionArc = mSkinVersion;
else // Locale arc
versionArc = mLocaleVersion;
nsCAutoString packageVersion;
nsChromeRegistry::FollowArc(mChromeDataSource, packageVersion, packageResource, versionArc);
if (!packageVersion.IsEmpty()) {
// The package only wants providers (skins) that say they can work with it. Let's find out
// if our provider (skin) can work with it.
nsCAutoString providerVersion;
nsChromeRegistry::FollowArc(mChromeDataSource, providerVersion, resource, versionArc);
if (!providerVersion.Equals(packageVersion))
selectedProvider = nsnull;
}
} }
if (!selectedProvider) {
// Find provider will attempt to auto-select a version-compatible provider (skin). If none
// exist it will return nsnull in the selectedProvider variable.
FindProvider(aPackage, aProvider, arc, getter_AddRefs(selectedProvider));
resource = do_QueryInterface(selectedProvider);
}
if (!selectedProvider) if (!selectedProvider)
return rv; return rv;
resource = do_QueryInterface(selectedProvider);
if (!resource) if (!resource)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -623,7 +654,7 @@ nsChromeRegistry::FindProvider(const nsCString& aPackage,
nsCOMPtr<nsIRDFResource> resource; nsCOMPtr<nsIRDFResource> resource;
rv = GetResource(rootStr, getter_AddRefs(resource)); rv = GetResource(rootStr, getter_AddRefs(resource));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_ERROR("Unable to obtain the package resource."); NS_ERROR("Unable to obtain the provider root resource.");
return rv; return rv;
} }
@ -672,7 +703,9 @@ nsChromeRegistry::FindProvider(const nsCString& aPackage,
// if aPackage is named in kid's package list, select it and we're done // if aPackage is named in kid's package list, select it and we're done
rv = SelectPackageInProvider(packageList, aPackage, aProvider, providerName, rv = SelectPackageInProvider(packageList, aPackage, aProvider, providerName,
aArc, aSelectedProvider); aArc, aSelectedProvider);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv))
continue; // Don't let this be disastrous. We may find another acceptable match.
if (*aSelectedProvider) if (*aSelectedProvider)
return NS_OK; return NS_OK;
} }
@ -745,7 +778,9 @@ nsChromeRegistry::SelectPackageInProvider(nsIRDFResource *aPackageList,
// install dir for the packages required to bring up the profile UI. // install dir for the packages required to bring up the profile UI.
rv = SelectProviderForPackage(aProvider, providerNameUC.GetUnicode(), rv = SelectProviderForPackage(aProvider, providerNameUC.GetUnicode(),
packageNameUC.GetUnicode(), aArc, useProfile, PR_TRUE); packageNameUC.GetUnicode(), aArc, useProfile, PR_TRUE);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
*aSelectedProvider = kid; *aSelectedProvider = kid;
NS_ADDREF(*aSelectedProvider); NS_ADDREF(*aSelectedProvider);
return NS_OK; return NS_OK;
@ -1602,10 +1637,8 @@ NS_IMETHODIMP nsChromeRegistry::SetProvider(const nsCString& aProvider,
nsCOMPtr<nsIRDFResource> packageResource(do_QueryInterface(packageNode)); nsCOMPtr<nsIRDFResource> packageResource(do_QueryInterface(packageNode));
if (packageResource) { if (packageResource) {
rv = SetProviderForPackage(aProvider, packageResource, entry, aSelectionArc, aUseProfile, aProfilePath, aIsAdding); rv = SetProviderForPackage(aProvider, packageResource, entry, aSelectionArc, aUseProfile, aProfilePath, aIsAdding);
if (NS_FAILED(rv)) { if (NS_FAILED(rv))
NS_ERROR("Unable to set provider for package resource."); continue; // Well, let's set as many sub-packages as we can...
return rv;
}
} }
} }
} }
@ -1731,6 +1764,28 @@ NS_IMETHODIMP nsChromeRegistry::SelectProviderForPackage(const nsCString& aProvi
} }
NS_ASSERTION(providerResource, "failed to get providerResource"); NS_ASSERTION(providerResource, "failed to get providerResource");
// Version-check before selecting. If this skin isn't a compatible version, then
// don't allow the selection.
// We found a selected provider, but now we need to verify that the version
// specified by the package and the version specified by the provider are
// one and the same. If they aren't, then we cannot use this provider.
nsCOMPtr<nsIRDFResource> versionArc;
if (aSelectionArc == mSelectedSkin)
versionArc = mSkinVersion;
else // Locale arc
versionArc = mLocaleVersion;
nsCAutoString packageVersion;
nsChromeRegistry::FollowArc(mChromeDataSource, packageVersion, packageResource, versionArc);
if (!packageVersion.IsEmpty()) {
// The package only wants providers (skins) that say they can work with it. Let's find out
// if our provider (skin) can work with it.
nsCAutoString providerVersion;
nsChromeRegistry::FollowArc(mChromeDataSource, providerVersion, providerResource, versionArc);
if (!providerVersion.Equals(packageVersion))
return NS_ERROR_FAILURE;
}
return SetProviderForPackage(aProviderType, packageResource, providerResource, aSelectionArc, return SetProviderForPackage(aProviderType, packageResource, providerResource, aSelectionArc,
aUseProfile, nsnull, aIsAdding);; aUseProfile, nsnull, aIsAdding);;
} }

View File

@ -11,7 +11,8 @@
<RDF:Description about="urn:mozilla:package:editor" <RDF:Description about="urn:mozilla:package:editor"
chrome:displayName="Editor" chrome:displayName="Editor"
chrome:author="mozilla.org" chrome:author="mozilla.org"
chrome:name="editor"> chrome:name="editor"
chrome:skinVersion="1">
</RDF:Description> </RDF:Description>
<!-- overlay information --> <!-- overlay information -->

View File

@ -11,7 +11,8 @@
<RDF:Description about="urn:mozilla:package:messenger" <RDF:Description about="urn:mozilla:package:messenger"
chrome:displayName="Messenger" chrome:displayName="Messenger"
chrome:author="mozilla.org" chrome:author="mozilla.org"
chrome:name="messenger"> chrome:name="messenger"
chrome:skinVersion="1">
</RDF:Description> </RDF:Description>
<!-- overlay information --> <!-- overlay information -->

View File

@ -556,13 +556,15 @@ NS_IMETHODIMP
nsChromeRegistry::GetBaseURL(const nsCString& aPackage, const nsCString& aProvider, nsChromeRegistry::GetBaseURL(const nsCString& aPackage, const nsCString& aProvider,
nsCString& aBaseURL) nsCString& aBaseURL)
{ {
nsCOMPtr<nsIRDFResource> resource;
nsCAutoString resourceStr("urn:mozilla:package:"); nsCAutoString resourceStr("urn:mozilla:package:");
resourceStr += aPackage; resourceStr += aPackage;
// Obtain the resource. // Obtain the resource.
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr<nsIRDFResource> resource; nsCOMPtr<nsIRDFResource> packageResource;
rv = GetResource(resourceStr, getter_AddRefs(resource)); rv = GetResource(resourceStr, getter_AddRefs(packageResource));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_ERROR("Unable to obtain the package resource."); NS_ERROR("Unable to obtain the package resource.");
return rv; return rv;
@ -576,23 +578,52 @@ nsChromeRegistry::GetBaseURL(const nsCString& aPackage, const nsCString& aProvid
else if (aProvider.Equals(nsCAutoString("locale"))) { else if (aProvider.Equals(nsCAutoString("locale"))) {
arc = mSelectedLocale; arc = mSelectedLocale;
} }
else
// We're a package.
resource = packageResource;
if (arc) { if (arc) {
nsCOMPtr<nsIRDFNode> selectedProvider; nsCOMPtr<nsIRDFNode> selectedProvider;
if (NS_FAILED(rv = mChromeDataSource->GetTarget(resource, arc, PR_TRUE, getter_AddRefs(selectedProvider)))) { if (NS_FAILED(rv = mChromeDataSource->GetTarget(packageResource, arc, PR_TRUE, getter_AddRefs(selectedProvider)))) {
NS_ERROR("Unable to obtain the provider."); NS_ERROR("Unable to obtain the provider.");
return rv; return rv;
} }
if (!selectedProvider) { resource = do_QueryInterface(selectedProvider);
rv = FindProvider(aPackage, aProvider, arc, getter_AddRefs(selectedProvider));
if (NS_FAILED(rv)) return rv; if (resource) {
// We found a selected provider, but now we need to verify that the version
// specified by the package and the version specified by the provider are
// one and the same. If they aren't, then we cannot use this provider.
nsCOMPtr<nsIRDFResource> versionArc;
if (arc == mSelectedSkin)
versionArc = mSkinVersion;
else // Locale arc
versionArc = mLocaleVersion;
nsCAutoString packageVersion;
nsChromeRegistry::FollowArc(mChromeDataSource, packageVersion, packageResource, versionArc);
if (!packageVersion.IsEmpty()) {
// The package only wants providers (skins) that say they can work with it. Let's find out
// if our provider (skin) can work with it.
nsCAutoString providerVersion;
nsChromeRegistry::FollowArc(mChromeDataSource, providerVersion, resource, versionArc);
if (!providerVersion.Equals(packageVersion))
selectedProvider = nsnull;
}
} }
if (!selectedProvider) {
// Find provider will attempt to auto-select a version-compatible provider (skin). If none
// exist it will return nsnull in the selectedProvider variable.
FindProvider(aPackage, aProvider, arc, getter_AddRefs(selectedProvider));
resource = do_QueryInterface(selectedProvider);
}
if (!selectedProvider) if (!selectedProvider)
return rv; return rv;
resource = do_QueryInterface(selectedProvider);
if (!resource) if (!resource)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -623,7 +654,7 @@ nsChromeRegistry::FindProvider(const nsCString& aPackage,
nsCOMPtr<nsIRDFResource> resource; nsCOMPtr<nsIRDFResource> resource;
rv = GetResource(rootStr, getter_AddRefs(resource)); rv = GetResource(rootStr, getter_AddRefs(resource));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_ERROR("Unable to obtain the package resource."); NS_ERROR("Unable to obtain the provider root resource.");
return rv; return rv;
} }
@ -672,7 +703,9 @@ nsChromeRegistry::FindProvider(const nsCString& aPackage,
// if aPackage is named in kid's package list, select it and we're done // if aPackage is named in kid's package list, select it and we're done
rv = SelectPackageInProvider(packageList, aPackage, aProvider, providerName, rv = SelectPackageInProvider(packageList, aPackage, aProvider, providerName,
aArc, aSelectedProvider); aArc, aSelectedProvider);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv))
continue; // Don't let this be disastrous. We may find another acceptable match.
if (*aSelectedProvider) if (*aSelectedProvider)
return NS_OK; return NS_OK;
} }
@ -745,7 +778,9 @@ nsChromeRegistry::SelectPackageInProvider(nsIRDFResource *aPackageList,
// install dir for the packages required to bring up the profile UI. // install dir for the packages required to bring up the profile UI.
rv = SelectProviderForPackage(aProvider, providerNameUC.GetUnicode(), rv = SelectProviderForPackage(aProvider, providerNameUC.GetUnicode(),
packageNameUC.GetUnicode(), aArc, useProfile, PR_TRUE); packageNameUC.GetUnicode(), aArc, useProfile, PR_TRUE);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
*aSelectedProvider = kid; *aSelectedProvider = kid;
NS_ADDREF(*aSelectedProvider); NS_ADDREF(*aSelectedProvider);
return NS_OK; return NS_OK;
@ -1602,10 +1637,8 @@ NS_IMETHODIMP nsChromeRegistry::SetProvider(const nsCString& aProvider,
nsCOMPtr<nsIRDFResource> packageResource(do_QueryInterface(packageNode)); nsCOMPtr<nsIRDFResource> packageResource(do_QueryInterface(packageNode));
if (packageResource) { if (packageResource) {
rv = SetProviderForPackage(aProvider, packageResource, entry, aSelectionArc, aUseProfile, aProfilePath, aIsAdding); rv = SetProviderForPackage(aProvider, packageResource, entry, aSelectionArc, aUseProfile, aProfilePath, aIsAdding);
if (NS_FAILED(rv)) { if (NS_FAILED(rv))
NS_ERROR("Unable to set provider for package resource."); continue; // Well, let's set as many sub-packages as we can...
return rv;
}
} }
} }
} }
@ -1731,6 +1764,28 @@ NS_IMETHODIMP nsChromeRegistry::SelectProviderForPackage(const nsCString& aProvi
} }
NS_ASSERTION(providerResource, "failed to get providerResource"); NS_ASSERTION(providerResource, "failed to get providerResource");
// Version-check before selecting. If this skin isn't a compatible version, then
// don't allow the selection.
// We found a selected provider, but now we need to verify that the version
// specified by the package and the version specified by the provider are
// one and the same. If they aren't, then we cannot use this provider.
nsCOMPtr<nsIRDFResource> versionArc;
if (aSelectionArc == mSelectedSkin)
versionArc = mSkinVersion;
else // Locale arc
versionArc = mLocaleVersion;
nsCAutoString packageVersion;
nsChromeRegistry::FollowArc(mChromeDataSource, packageVersion, packageResource, versionArc);
if (!packageVersion.IsEmpty()) {
// The package only wants providers (skins) that say they can work with it. Let's find out
// if our provider (skin) can work with it.
nsCAutoString providerVersion;
nsChromeRegistry::FollowArc(mChromeDataSource, providerVersion, providerResource, versionArc);
if (!providerVersion.Equals(packageVersion))
return NS_ERROR_FAILURE;
}
return SetProviderForPackage(aProviderType, packageResource, providerResource, aSelectionArc, return SetProviderForPackage(aProviderType, packageResource, providerResource, aSelectionArc,
aUseProfile, nsnull, aIsAdding);; aUseProfile, nsnull, aIsAdding);;
} }

View File

@ -11,7 +11,8 @@
<RDF:Description about="urn:mozilla:package:navigator" <RDF:Description about="urn:mozilla:package:navigator"
chrome:displayName="Navigator" chrome:displayName="Navigator"
chrome:author="mozilla.org" chrome:author="mozilla.org"
chrome:name="navigator"> chrome:name="navigator"
chrome:skinVersion="1">
</RDF:Description> </RDF:Description>
</RDF:RDF> </RDF:RDF>

View File

@ -11,7 +11,8 @@
<RDF:Description about="urn:mozilla:package:communicator" <RDF:Description about="urn:mozilla:package:communicator"
chrome:displayName="Communicator Shared" chrome:displayName="Communicator Shared"
chrome:author="mozilla.org" chrome:author="mozilla.org"
chrome:name="communicator"> chrome:name="communicator"
chrome:skinVersion="1">
</RDF:Description> </RDF:Description>
</RDF:RDF> </RDF:RDF>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 31 B

View File

@ -11,6 +11,7 @@
<RDF:Description about="urn:mozilla:package:global" <RDF:Description about="urn:mozilla:package:global"
chrome:displayName="Toolkit" chrome:displayName="Toolkit"
chrome:author="mozilla.org" chrome:author="mozilla.org"
chrome:name="global"> chrome:name="global"
chrome:skinVersion="1">
</RDF:Description> </RDF:Description>
</RDF:RDF> </RDF:RDF>