nsIBookmarksService

IID:ccc48346-429d-4931-94dc-beb1afcea292
Inherits From:nsISupports

This interface is intended to be used as a service. To create an object implementing this interface:

var obj = Components.classes["@mozilla.org/browser/bookmarks-service;1"].
            getService(Components.interfaces.nsIBookmarksService);

This interface is implemented by the following components:


Constants

PRUint32 BOOKMARK_DEFAULT_TYPE = 0
PRUint32 BOOKMARK_SEARCH_TYPE = 1
PRUint32 BOOKMARK_FIND_TYPE = 2

Properties

readonly nsITransactionManager transactionManager


Methods

void addBookmarkImmediately ( PRUnichar* URI , PRUnichar* title , PRInt32 bmType , PRUnichar* docCharset ) nsIRDFResource cloneResource ( nsIRDFResource source ) nsIRDFResource createBookmark ( PRUnichar* name , PRUnichar* URL , PRUnichar* shortcutURL , PRUnichar* description , PRUnichar* docCharSet , PRUnichar* postData ) nsIRDFResource createBookmarkInContainer ( PRUnichar* name , PRUnichar* URL , PRUnichar* shortcutURL , PRUnichar* description , PRUnichar* docCharSet , PRUnichar* postData , nsIRDFResource folder , PRInt32 index ) nsIRDFResource createFolder ( PRUnichar* name ) nsIRDFResource createFolderInContainer ( PRUnichar* name , nsIRDFResource parentFolder , PRInt32 index ) nsIRDFResource createLivemark ( PRUnichar* name , PRUnichar* URL , PRUnichar* RSSURL , PRUnichar* description ) nsIRDFResource createLivemarkInContainer ( PRUnichar* name , PRUnichar* URL , PRUnichar* RSSURL , PRUnichar* description , nsIRDFResource folder , PRInt32 index ) nsIRDFResource createSeparator ( ) nsIRDFResource getBookmarksToolbarFolder ( ) AString getLastCharset ( AUTF8String URL ) nsIRDFResource getParent ( nsIRDFResource source ) nsIArray getParentChain ( nsIRDFResource source ) PRBool isBookmarked ( char* URL ) PRBool isBookmarkedResource ( nsIRDFResource source ) PRBool readBookmarks ( ) void removeBookmarkIcon ( char* URL ) char* resolveKeyword ( PRUnichar* name , out PRUnichar* postData ) void setBookmarksToolbarFolder ( nsIRDFResource source ) void updateBookmarkIcon ( char* URL , char* iconMIMEtype , arrayof PRUint8 iconData , PRUint32 iconDataLen ) void updateLastVisitedDate ( char* URL , PRUnichar* docCharset )

void addBookmarkImmediately ( PRUnichar* URI , PRUnichar* title , PRInt32 bmType , PRUnichar* docCharset )

Arguments:
URI
title
bmType
docCharset

nsIRDFResource cloneResource ( nsIRDFResource source )

Arguments:
source

nsIRDFResource createBookmark ( PRUnichar* name , PRUnichar* URL , PRUnichar* shortcutURL , PRUnichar* description , PRUnichar* docCharSet , PRUnichar* postData )

Arguments:
name
URL
shortcutURL
description
docCharSet
postData

nsIRDFResource createBookmarkInContainer ( PRUnichar* name , PRUnichar* URL , PRUnichar* shortcutURL , PRUnichar* description , PRUnichar* docCharSet , PRUnichar* postData , nsIRDFResource folder , PRInt32 index )

Arguments:
name
URL
shortcutURL
description
docCharSet
postData
folder
index

nsIRDFResource createFolder ( PRUnichar* name )

Arguments:
name

nsIRDFResource createFolderInContainer ( PRUnichar* name , nsIRDFResource parentFolder , PRInt32 index )

Arguments:
name
parentFolder
index

nsIRDFResource createLivemark ( PRUnichar* name , PRUnichar* URL , PRUnichar* RSSURL , PRUnichar* description )

Arguments:
name
URL
RSSURL
description

nsIRDFResource createLivemarkInContainer ( PRUnichar* name , PRUnichar* URL , PRUnichar* RSSURL , PRUnichar* description , nsIRDFResource folder , PRInt32 index )

Arguments:
name
URL
RSSURL
description
folder
index

nsIRDFResource createSeparator ( )


nsIRDFResource getBookmarksToolbarFolder ( )


AString getLastCharset ( AUTF8String URL )

Arguments:
URL

nsIRDFResource getParent ( nsIRDFResource source )

Arguments:
source

nsIArray getParentChain ( nsIRDFResource source )

Arguments:
source

PRBool isBookmarked ( char* URL )

Arguments:
URL

PRBool isBookmarkedResource ( nsIRDFResource source )

Arguments:
source

PRBool readBookmarks ( )


void removeBookmarkIcon ( char* URL )

Arguments:
URL

char* resolveKeyword ( PRUnichar* name , out PRUnichar* postData )

Arguments:
name
postData

void setBookmarksToolbarFolder ( nsIRDFResource source )

Arguments:
source

void updateBookmarkIcon ( char* URL , char* iconMIMEtype , arrayof PRUint8 iconData , PRUint32 iconDataLen )

Arguments:
URL
iconMIMEtype
iconData
iconDataLen

void updateLastVisitedDate ( char* URL , PRUnichar* docCharset )

Arguments:
URL
docCharset

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
September 16, 2004, 7:49 pm mromarkhan at gmail dot com
Regarding
PRBool isBookmarked ( char* URL )

Looking at the source for the idl I see
113 //XXXpch: to be removed.

Looking at the CPP source I see that it does
nothing as this comment reads
3073 //XXXpch: useless callers of AddBookmarkImmediately and IsBookmarked in nsInternetSearchService.cpp
3074 //to be removed RSN

However, looking at the old code, if you want
to do something like this in javascript
try the following:

<html><head><title>Bookmarks</title>
<script type="text/javascript">
function bookmarkFun()
{
// Bookmarks use rdf's
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
// Get the built in datasource
var bookmarks = Components.classes["@mozilla.org/rdf/datasource;1?name=bookmarks"]
.getService(Components.interfaces.nsIRDFDataSource);
// Wrap Url Predicate
var urlPredicateResource = rdf.GetResource("http://home.netscape.com/NC-rdf#URL");
// Wrap Url Literal
var urlTargetLiteral = rdf.GetLiteral('https://gmail.google.com/');
// Get source returns the resource
var urlSubjectResource = bookmarks.GetSource(urlPredicateResource, urlTargetLiteral, true);
if(urlSubjectResource)
{
alert('Founded: ' + urlSubjectResource);
// Wrap Name Predicate - case sensitive
var titlePredicate = rdf.GetResource("http://home.netscape.com/NC-rdf#Name");
// Get target from subject and predicate
var titleTargetLiteral = bookmarks.GetTarget(urlSubjectResource, titlePredicate, true);
// Want literal not resource
if (titleTargetLiteral instanceof Components.interfaces.nsIRDFLiteral)
{
// Display the title
alert(titleTargetLiteral.Value);
}

}
else
{
alert('Not found');
}
}
</script>
</head>
<body onload="bookmarkFun();">
</body>
</html>

Copyright © 1999 - 2005 XULPlanet.com