WARNING: Most of this content (with the exception of the Mozilla 1.9 XPCOM reference) is very old, and can be expected to be out of date and possibly obsolete. For better XUL documentation, please visit the XUL hub at the Mozilla Developer Center.

nsINavBookmarksService

IID:617fe3a9-5c5b-4854-aae6-23a66ddf1c25
Inherits From:nsISupports

This interface is implemented by the following components:


Constants

This value should be used for APIs that allow passing in an index where an index is not known, or not required to be specified. e.g.: When appending an item to a folder.
PRInt16 DEFAULT_INDEX = -1
PRUint16 TYPE_BOOKMARK = 1
PRUint16 TYPE_FOLDER = 2
PRUint16 TYPE_SEPARATOR = 3
PRUint16 TYPE_DYNAMIC_CONTAINER = 4

Properties

readonly PRInt64 bookmarksMenuFolder

The item ID of the bookmarks menu folder.

readonly PRInt64 placesRoot

The item ID of the Places root.

readonly PRInt64 tagsFolder

The item ID of the top-level folder that contain the tag "folders".

readonly PRInt64 toolbarFolder

The item ID of the personal toolbar folder.

readonly PRInt64 unfiledBookmarksFolder

The item ID of the unfiled-bookmarks folder.


Methods

void addObserver ( nsINavBookmarkObserver observer , PRBool ownsWeak ) void changeBookmarkURI ( PRInt64 itemId , nsIURI newURI ) PRInt64 createDynamicContainer ( PRInt64 parentFolder , AUTF8String name , AString contractId , PRInt32 index ) PRInt64 createFolder ( PRInt64 parentFolder , AUTF8String name , PRInt32 index ) nsIURI getBookmarkedURIFor ( nsIURI URI ) void getBookmarkIdsForURI ( nsIURI URI , out PRUint32 count , out arrayof PRInt64 bookmarks ) [noscript] void getBookmarkIdsForURITArray ( nsIURI URI , PRInt64Array* result ) nsIURI getBookmarkURI ( PRInt64 itemId ) PRInt64 getChildFolder ( PRInt64 folder , AString subFolder ) PRInt64 getFolderIdForItem ( PRInt64 itemId ) PRBool getFolderReadonly ( PRInt64 folder ) PRTime getItemDateAdded ( PRInt64 itemId ) AString getItemGUID ( PRInt64 itemId ) PRInt64 getItemIdForGUID ( AString GUID ) PRInt32 getItemIndex ( PRInt64 itemId ) PRTime getItemLastModified ( PRInt64 itemId ) AUTF8String getItemTitle ( PRInt64 itemId ) PRUint16 getItemType ( PRInt64 itemId ) AString getKeywordForBookmark ( PRInt64 itemId ) AString getKeywordForURI ( nsIURI URI ) nsITransaction getRemoveFolderTransaction ( PRInt64 folder ) nsIURI getURIForKeyword ( AString keyword ) PRInt64 insertBookmark ( PRInt64 parentFolder , nsIURI URI , PRInt32 index , AUTF8String title ) PRInt64 insertSeparator ( PRInt64 folder , PRInt32 index ) PRBool isBookmarked ( nsIURI URI ) void moveItem ( PRInt64 folder , PRInt64 newParent , PRInt32 index ) void removeChildAt ( PRInt64 folder , PRInt32 index ) void removeFolder ( PRInt64 folder ) void removeFolderChildren ( PRInt64 folder ) void removeItem ( PRInt64 itemId ) void removeObserver ( nsINavBookmarkObserver observer ) void runInBatchMode ( nsINavHistoryBatchCallback callback , nsISupports userData ) void setFolderReadonly ( PRInt64 folder , PRBool readOnly ) void setItemDateAdded ( PRInt64 itemId , PRTime dateAdded ) void setItemGUID ( PRInt64 itemId , AString GUID ) void setItemIndex ( PRInt64 itemId , PRInt32 newIndex ) void setItemLastModified ( PRInt64 itemId , PRTime lastModified ) void setItemTitle ( PRInt64 itemId , AUTF8String title ) void setKeywordForBookmark ( PRInt64 itemId , AString keyword )

void addObserver ( nsINavBookmarkObserver observer , PRBool ownsWeak )

Adds a bookmark observer. If ownsWeak is false, the bookmark service will keep an owning reference to the observer. If ownsWeak is true, then observer must implement nsISupportsWeakReference, and the bookmark service will keep a weak reference to the observer.

Arguments:
observer
ownsWeak

void changeBookmarkURI ( PRInt64 itemId , nsIURI newURI )

Change the bookmarked URI for a bookmark. This changes which "place" the bookmark points at, which means all annotations, etc are carried along.

Arguments:
itemId
newURI

PRInt64 createDynamicContainer ( PRInt64 parentFolder , AUTF8String name , AString contractId , PRInt32 index )

Creates a dynamic container under the given parent folder.

Arguments:
parentFolder: The id of the parent folder
name: The name of the new folder
contractId: The contract id of the service which is to manipulate this container.
index: The index to insert at, or -1 to append

PRInt64 createFolder ( PRInt64 parentFolder , AUTF8String name , PRInt32 index )

Creates a new child folder and inserts it under the given parent.

Arguments:
parentFolder: The id of the parent folder
name: The name of the new folder
index: The index to insert at, or -1 to append

nsIURI getBookmarkedURIFor ( nsIURI URI )

Used to see if the given URI is bookmarked, or any page that redirected to it is bookmarked. For example, if I bookmark "mozilla.org" by manually typing it in, and follow the bookmark, I will get redirected to "www.mozilla.org". Logically, this new page is also bookmarked. This function, if given "www.mozilla.org", will return the URI of the bookmark, in this case "mozilla.org".

If there is no bookmarked page found, it will return NULL.

Arguments:
URI

void getBookmarkIdsForURI ( nsIURI URI , out PRUint32 count , out arrayof PRInt64 bookmarks )

Returns the list of bookmark ids that contain the given URI.

Arguments:
URI
count
bookmarks

void getBookmarkIdsForURITArray ( nsIURI URI , PRInt64Array* result )

TArray version of getBookmarksIdForURI for ease of use in C++ code. Pass in a reference to a TArray; it will get cleared and filled with the resulting list of folder IDs.

Arguments:
URI
result

nsIURI getBookmarkURI ( PRInt64 itemId )

Get the URI for a bookmark item.

Arguments:
itemId

PRInt64 getChildFolder ( PRInt64 folder , AString subFolder )

Returns the ID of a child folder with the given name. This does not recurse, you have to give it an immediate sibling of the given folder. If the given subfolder doesn't exist, it will return 0.

Arguments:
folder: Parent folder whose children we will search
subFolder: Name of the folder to search for in folder

PRInt64 getFolderIdForItem ( PRInt64 itemId )

Get the parent folder's id for an item.

Arguments:
itemId

PRBool getFolderReadonly ( PRInt64 folder )

Checks whether a folder is marked as read-only. If this is set to true, UI will not allow the user to add, remove, or reorder children in this folder. The default for all folders is false. Note: This does not restrict API calls, only UI actions.

Arguments:
folder: the item-id of the folder.

PRTime getItemDateAdded ( PRInt64 itemId )

Get the date added time for an item.

Arguments:
itemId

AString getItemGUID ( PRInt64 itemId )

Get a globally unique identifier for an item, meant to be used in sync scenarios. Even if their contents are exactly the same (including an item in a different profile with the same ItemId), the GUID would be different.

Arguments:
itemId: The ID of the item to get the GUID for

PRInt64 getItemIdForGUID ( AString GUID )

Get the ID of the item with the given GUID.

Arguments:
GUID: The GUID string of the item to search for

PRInt32 getItemIndex ( PRInt64 itemId )

Get the index for an item.

Arguments:
itemId

PRTime getItemLastModified ( PRInt64 itemId )

Get the last modified time for an item.

Arguments:
itemId

AUTF8String getItemTitle ( PRInt64 itemId )

Get the title for an item.

If no item title is available it will return a void string (null in JS).

Arguments:
itemId: The id of the item whose title should be retrieved

PRUint16 getItemType ( PRInt64 itemId )

Get an item's type (bookmark, separator, folder). The type is one of the TYPE_* constants defined above.

Arguments:
itemId

AString getKeywordForBookmark ( PRInt64 itemId )

Retrieves the keyword for the given bookmark. Will be void string (null in JS) if no such keyword is found.

Arguments:
itemId

AString getKeywordForURI ( nsIURI URI )

Retrieves the keyword for the given URI. Will be void string (null in JS) if no such keyword is found.

Arguments:
URI

nsITransaction getRemoveFolderTransaction ( PRInt64 folder )

Gets an undo-able transaction for removing a folder from the bookmarks tree.

This method exists because complex delete->undo operations rely on recreated folders to have the same ID they had before they were deleted, so that any other items deleted in different transactions can be re-inserted correctly. This provides a safe encapsulation of this functionality without exposing the ability to recreate folders with specific IDs (potentially dangerous if abused by other code!) in the public API.

Arguments:
folder: The id of the folder to remove.

nsIURI getURIForKeyword ( AString keyword )

Returns the URI associated with the given keyword. Empty if no such keyword is found.

Arguments:
keyword

PRInt64 insertBookmark ( PRInt64 parentFolder , nsIURI URI , PRInt32 index , AUTF8String title )

Inserts a child bookmark into the given folder.

Arguments:
parentFolder: The id of the parent folder
URI: The URI to insert
index: The index to insert at, or -1 to append
title: The title for the new bookmark

PRInt64 insertSeparator ( PRInt64 folder , PRInt32 index )

Inserts a bookmark separator into the given folder at the given index. The separator can be removed using removeChildAt().

Arguments:
folder: Parent folder of the separator
index: The separator's index under folder, or -1 to append

PRBool isBookmarked ( nsIURI URI )

Returns true if the given URI is in any bookmark folder. If you want the results to be redirect-aware, use getBookmarkedURIFor()

Arguments:
URI

void moveItem ( PRInt64 folder , PRInt64 newParent , PRInt32 index )

Moves an item to a different container, preserving its contents.

Arguments:
folder
newParent: The id of the new parent
index: The index under newParent, or -1 to append

void removeChildAt ( PRInt64 folder , PRInt32 index )

Removes any type of child (item, folder, or separator) at the given index.

Arguments:
folder: The folder to remove a child from
index: The index of the child to remove

void removeFolder ( PRInt64 folder )

Removes a folder from the bookmarks tree.

Arguments:
folder: The id of the folder to remove.

void removeFolderChildren ( PRInt64 folder )

Convenience function for container services. Removes all children of the given folder.

Arguments:
folder: The id of the folder to remove children from.

void removeItem ( PRInt64 itemId )

Removes a child item. Used to delete a bookmark or separator.

Arguments:
itemId: The child item to remove

void removeObserver ( nsINavBookmarkObserver observer )

Removes a bookmark observer.

Arguments:
observer

void runInBatchMode ( nsINavHistoryBatchCallback callback , nsISupports userData )

Runs the passed callback in batch mode. Use this when a lot of things are about to change. Calls can be nested, observers will only be notified when all batches begin/end.

Arguments:
callback: nsINavHistoryBatchCallback interface to call.
userData: Opaque parameter passed to nsINavBookmarksBatchCallback

void setFolderReadonly ( PRInt64 folder , PRBool readOnly )

Sets or unsets the readonly flag from a folder. If this is set to true, UI will not allow the user to add, remove, or reorder children in this folder. The default for all folders is false. Note: This does not restrict API calls, only UI actions.

Arguments:
folder: the item-id of the folder.
readOnly: the read-only state (boolean).

void setItemDateAdded ( PRInt64 itemId , PRTime dateAdded )

Set the date added time for an item.

Arguments:
itemId
dateAdded

void setItemGUID ( PRInt64 itemId , AString GUID )

Set a globally unique identifier. This can be useful when a sync algorithm deems two independently created items (on different profiles) to be the same item.

Arguments:
itemId: The id of the item to set the GUID of
GUID: The GUID string

void setItemIndex ( PRInt64 itemId , PRInt32 newIndex )

Changes the index for a item. This method does not change the indices of any other items in the same folder, so ensure that the new index does not already exist, or change the index of other items accordingly, otherwise the indices will become corrupted.

WARNING: This is API is intended for scenarios such as folder sorting, where the caller manages the indices of *all* items in the folder.

Arguments:
itemId: The id of the item to modify
newIndex: The new index

void setItemLastModified ( PRInt64 itemId , PRTime lastModified )

Set the last modified time for an item.

Arguments:
itemId
lastModified

void setItemTitle ( PRInt64 itemId , AUTF8String title )

Set the title for an item.

Arguments:
itemId: The id of the item whose title should be updated
title: The new title for the bookmark.

void setKeywordForBookmark ( PRInt64 itemId , AString keyword )

Associates the given keyword with the given bookmark.

Use an empty keyword to clear the keyword associated with the URI. In both of these cases, succeeds but does nothing if the URL/keyword is not found.

Arguments:
itemId
keyword

References

This interface is passed as an argument to the following methods:

nsILivemarkService.createLivemarkFolderOnly

Reference documentation is generated from Mozilla's source.

Copyright © 1999-2006 XULPlanet.com