Fix bug # 170622: Bookmarks deletion cmd needs to go through RDF composite db cmd APIs. Bookmarks need to NS_RDF_ASSERTION_REJECTED on unknown nodes. Bookmarking a group of tabs fix. r=blake sr=jag

This commit is contained in:
rjc%netscape.com 2002-10-08 23:55:39 +00:00
parent 05311863ab
commit 099af79d56
3 changed files with 41 additions and 34 deletions

View File

@ -990,8 +990,9 @@
argsArray.AppendElement(rValue);
}
// Exec the command in the Bookmarks datasource.
this.bookmarksDS.DoCommand(sourcesArray, rCommand, argsArray);
// Exec the command in the Composite (not Bookmarks) datasource
// so that command aggregation works
this.db.DoCommand(sourcesArray, rCommand, argsArray);
]]></body>
</method>
@ -1289,8 +1290,24 @@
// assume its parent is the root
parent = ksRDF.GetResource("NC:BookmarksRoot");
}
ksRDFC.Init(this.bookmarksDS, parent);
ksRDFC.RemoveElement(resource, true);
/*
Use RDF datasource command APIs instead of trying to
directly manipulate the bookmarks datasource graph via:
ksRDFC.Init(this.bookmarksDS, parent);
ksRDFC.RemoveElement(resource, true);
*/
try {
var args = [{ property: this.NC_NS + "parent",
resource: parent.Value }];
this.doBookmarksCommand(resource.Value, this.NC_NS_CMD + "deletebookmark", args);
}
catch (e) {
}
nextIndex = j;
}
}

View File

@ -2620,7 +2620,7 @@ nsresult
nsBookmarksService::InsertResource(nsIRDFResource* aResource,
nsIRDFResource* aParentFolder, PRInt32 aIndex)
{
nsresult rv;
nsresult rv = NS_OK;
// Add to container if the parent folder is non null
if (aParentFolder) {
nsCOMPtr<nsIRDFContainer> container(do_GetService("@mozilla.org/rdf/container;1", &rv));
@ -2864,6 +2864,13 @@ nsBookmarksService::IsBookmarkedInternal(nsIRDFResource *bookmark, PRBool *isBoo
if (!isBookmarkedFlag) return(NS_ERROR_UNEXPECTED);
if (!mInner) return(NS_ERROR_UNEXPECTED);
// bookmark root is special (it isn't contained in a rdf seq)
if (bookmark == kNC_BookmarksRoot)
{
*isBookmarkedFlag = PR_TRUE;
return(NS_OK);
}
*isBookmarkedFlag = PR_FALSE;
// make sure it is referred to by an ordinal (i.e. is contained in a rdf seq)
@ -4277,7 +4284,9 @@ nsBookmarksService::insertBookmarkItem(nsIRDFResource *aRelativeNode,
nsresult
nsBookmarksService::deleteBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, PRInt32 parentArgIndex, nsIRDFResource *objType)
nsBookmarksService::deleteBookmarkItem(nsIRDFResource *src,
nsISupportsArray *aArguments,
PRInt32 parentArgIndex)
{
nsresult rv;
@ -4288,13 +4297,6 @@ nsBookmarksService::deleteBookmarkItem(nsIRDFResource *src, nsISupportsArray *aA
nsCOMPtr<nsIRDFResource> argParent = do_QueryInterface(aNode);
if (!argParent) return(NS_ERROR_NO_INTERFACE);
// make sure its an object of the correct type (bookmark, folder, separator, ...)
PRBool isCorrectObjectType = PR_FALSE;
if (NS_FAILED(rv = mInner->HasAssertion(src, kRDF_type,
objType, PR_TRUE, &isCorrectObjectType)))
return(rv);
if (!isCorrectObjectType) return(NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIRDFContainer> container;
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFContainerCID, nsnull,
NS_GET_IID(nsIRDFContainer), getter_AddRefs(container))))
@ -4538,22 +4540,11 @@ nsBookmarksService::DoCommand(nsISupportsArray *aSources, nsIRDFResource *aComma
if (NS_FAILED(rv)) return(rv);
break;
}
else if (aCommand == kNC_BookmarkCommand_DeleteBookmark)
else if (aCommand == kNC_BookmarkCommand_DeleteBookmark ||
aCommand == kNC_BookmarkCommand_DeleteBookmarkFolder ||
aCommand == kNC_BookmarkCommand_DeleteBookmarkSeparator)
{
if (NS_FAILED(rv = deleteBookmarkItem(src, aArguments,
loop, kNC_Bookmark)))
return(rv);
}
else if (aCommand == kNC_BookmarkCommand_DeleteBookmarkFolder)
{
if (NS_FAILED(rv = deleteBookmarkItem(src, aArguments,
loop, kNC_Folder)))
return(rv);
}
else if (aCommand == kNC_BookmarkCommand_DeleteBookmarkSeparator)
{
if (NS_FAILED(rv = deleteBookmarkItem(src, aArguments,
loop, kNC_BookmarkSeparator)))
if (NS_FAILED(rv = deleteBookmarkItem(src, aArguments, loop)))
return(rv);
}
else if (aCommand == kNC_BookmarkCommand_SetNewBookmarkFolder)
@ -5459,13 +5450,12 @@ nsBookmarksService::CanAccept(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget)
{
// XXX This is really crippled, and needs to be stricter. We want
// to exclude any property that isn't talking about a known
// bookmark.
nsresult rv;
PRBool canAcceptFlag = PR_FALSE, isOrdinal;
PRBool isBookmarkedFlag = PR_FALSE, canAcceptFlag = PR_FALSE, isOrdinal;
if (NS_SUCCEEDED(rv = gRDFC->IsOrdinalProperty(aProperty, &isOrdinal)))
if (NS_SUCCEEDED(rv = IsBookmarkedInternal(aSource, &isBookmarkedFlag)) &&
(isBookmarkedFlag == PR_TRUE) &&
(NS_SUCCEEDED(rv = gRDFC->IsOrdinalProperty(aProperty, &isOrdinal))))
{
if (isOrdinal == PR_TRUE)
{

View File

@ -121,7 +121,7 @@ protected:
nsresult getArgumentN(nsISupportsArray *arguments, nsIRDFResource *res, PRInt32 offset, nsIRDFNode **argValue);
nsresult insertBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, nsIRDFResource *objType);
nsresult deleteBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, PRInt32 parentArgIndex, nsIRDFResource *objType);
nsresult deleteBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, PRInt32 parentArgIndex);
nsresult setFolderHint(nsIRDFResource *src, nsIRDFResource *objType);
nsresult getFolderViaHint(nsIRDFResource *src, PRBool fallbackFlag, nsIRDFResource **folder);
nsresult importBookmarks(nsISupportsArray *aArguments);