Visit Mozilla.org

nsINavHistoryQuery

From MDC

This article covers features introduced in Firefox 3


The nsINavHistoryQuery interface encapsulates all the query parameters you're likely to need when building up history UI. All parameters are ANDed together.

This is not intended to be a super-general query mechanism. This was designed so that most queries can be done in only one SQL query. This is important because, if the user has their profile on a networked drive, query latency can be non-negligible.

Contents

nsINavHistoryService is defined in toolkit/components/places/public/nsINavHistoryService.idl. It is scriptable and unfrozen (hasn't changed since Mozilla 1.9).

Inherits from: nsISupports

[edit] Method overview

void getFolders(out unsigned long count, [retval,array,size_is(count)] out long long folders);
void setFolders([const,array, size_is(folderCount)] in long long folders, in unsigned long folderCount);
nsINavHistoryQuery clone();

[edit] Attributes

Attribute Type Description
beginTime PRTime Begin time range for results (INCLUSIVE).
beginTimeReference long One of the constants TIME_RELATIVE_* which indicates how to interpret the corresponding begin time value.
hasBeginTime boolean Whether or not, the corresponding begin time is considered.
absoluteBeginTime PRTime Retrieves the begin time value that the currently loaded reference points + offset resolve to.
endTime PRTime End time range for results (INCLUSIVE).
endTimeReference long One of the constants TIME_RELATIVE_* which indicates how to interpret the corresponding end time value.
hasEndTime boolean Whether or not, the corresponding end time is considered.
absoluteEndTime PRTime Retrieves the end time value that the currently loaded reference points + offset resolve to.
searchTerms AString Text search terms.
hasSearchTerms boolean Whether or not, text search terms exists.
minVisits long Set lower limits for how many times an item has been visited. The default value is "-1", and in that case all items are matched regardless of their visit count.
maxVisits long Set upper limits for how many times an item has been visited. The default value is "-1", and in that case all items are matched regardless of their visit count.
onlyBookmarked boolean When set, returns only bookmarked items, when unset, returns anything. Setting this is equivalent to listing all bookmark folders in the folders parameter.
domainIsHost boolean This controls the meaning of domain, and whether it is an exact match domainIsHost = true, or hierarchical (= false).
domain AUTF8String This is the host or domain name (controlled by domainIsHost). When domainIsHost, domain only does exact matching on host names. Otherwise, it will return anything whose host name ends in domain.

This one is a little different than most. Setting it to an empty string is a real query and will match any URI that has no host name (local files and such). Set this to NULL (in C++ use SetIsVoid) if you don't want domain matching.

hasDomain boolean Whether or not, domain exists.
uriIsPrefix boolean Controls the interpretation of uri. When unset (default), the URI will request an exact match of the specified URI. When set, any history entry beginning in uri will match. For example http://bar.com/foo will match http://bar.com/foo as well as http://bar.com/foo/baz.gif.
uri nsIURI This is a URI to match, to, for example, find out every time you visited a given URI. Use uriIsPrefix to control whether this is an exact match.
hasUri boolean Whether or not, uri exists.
annotationIsNot boolean Test for existance or non-existance of a given annotation. We don't currently support >1 annotation name per query. If annotationIsNot is true, we test for the non-existance of the specified annotation. Testing for not annotation will do the same thing as a normal query and remove everything that doesn't have that annotation. Asking for things that DO have a given annotation is a little different. It also includes things that have never been visited. This allows place queries to be returned (which might include bookmark folders -- use the bookmark service's GetFolderURI) as well as anything else that may have been tagged with an annotation. This will only work for RESULTS_AS_URI since there will be no visits for these items.
annotation AUTF8String The annotation name.
hasAnnotation boolean Whether or not, annotation exists.
folderCount long Count of folders.

[edit] Constants

Constant Value Description
TIME_RELATIVE_EPOCH 0 Default value. The time is relative to Jan 1 1970 GMT, (this is a normal PRTime). As a special case, a 0 time relative to TIME_RELATIVE_EPOCH indicates that the time is not part of the query. This is the default, so an empty query will match any time.
TIME_RELATIVE_TODAY 1 The time is relative to this morning at midnight. Normally used for queries relative to today. For example, a "past week" query would be (today-6 days -> today+1 day).
TIME_RELATIVE_NOW 2 The time is relative to right now.
Note: PRTime is in MICROseconds since 1 Jan 1970. Javascript date objects are expressed in MILLIseconds since 1 Jan 1970.

[edit] Methods

[edit] getFolders()

This method retrieves all the folders with the folder count.

 void getFolders(
   out unsigned long count,
   [retval,array,size_is(count)] out long long folders
 );
[edit] Parameters
count
The count of the folders.
folders
The folders to be retrieved.

[edit] setFolders()

This method sets the folders with the given folder count.

 void setFolders(
   [const,array, size_is(folderCount)] in long long folders,
   in unsigned long folderCount
 );
[edit] Parameters
count
The count of the folders.
folders
The folders to be set.

[edit] clone()

This method creates a new query item with the same parameters of this one.

 nsINavHistoryQuery clone();
[edit] Parameters

None.

[edit] Return value

Returns the newly created cloned query.

[edit] See also