Places:History API: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 11: Line 11:


== Using the results ==
== Using the results ==
Write me.
Note: Be careful when accessing nodes and do not keep references to them around. Notifications sent to the result from the history and bookmarks system, as well as commands executed by the programmer such as sorting may cause the structure to change and nodes may be inserted, removed, or replaced.

Revision as of 18:05, 31 January 2006

How to use the "Places" History API (nsNavHistory/nsNavBookmarks)

Most information from the Browser_History and bookmarks system comes from executing queries on the history system (nsINavHistory.executeQuery/executeQueries). This will give you a nsINavHistoryResult object which will contain a tree structure of the results. The definitions of these structures is in browser/components/places/public/nsINavHistoryService.idl

Executing a query

There are two parts of a query: a list of one or more nsINavHistoryQuery objects, and an nsINavHistoryQueryOptions object. You first need to fill out these structures with the parameters you want. Use nsINavHistoryService.getNewQuery and nsINavHistoryService.getNewQueryOptions to retrieve empty objects. These objects typically have empty values for each possible field, so using them in their initial state will give you all of history in a flat list.


Bookmark queries

Using the results

Write me.

Note: Be careful when accessing nodes and do not keep references to them around. Notifications sent to the result from the history and bookmarks system, as well as commands executed by the programmer such as sorting may cause the structure to change and nodes may be inserted, removed, or replaced.