toolkit/components/places/nsINavHistoryService.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/nsINavHistoryService.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1433 @@
     1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/**
    1.10 + * Using Places services after quit-application is not reliable, so make
    1.11 + * sure to do any shutdown work on quit-application, or history
    1.12 + * synchronization could fail, losing latest changes.
    1.13 + */
    1.14 +
    1.15 +#include "nsISupports.idl"
    1.16 +
    1.17 +interface nsIArray;
    1.18 +interface nsIURI;
    1.19 +interface nsIVariant;
    1.20 +interface nsIFile;
    1.21 +
    1.22 +interface nsINavHistoryContainerResultNode;
    1.23 +interface nsINavHistoryQueryResultNode;
    1.24 +interface nsINavHistoryQuery;
    1.25 +interface nsINavHistoryQueryOptions;
    1.26 +interface nsINavHistoryResult;
    1.27 +interface nsINavHistoryBatchCallback;
    1.28 +
    1.29 +[scriptable, uuid(91d104bb-17ef-404b-9f9a-d9ed8de6824c)]
    1.30 +interface nsINavHistoryResultNode : nsISupports
    1.31 +{
    1.32 +  /**
    1.33 +   * Indentifies the parent result node in the result set. This is null for
    1.34 +   * top level nodes.
    1.35 +   */
    1.36 +  readonly attribute nsINavHistoryContainerResultNode parent;
    1.37 +
    1.38 +  /**
    1.39 +   * The history-result to which this node belongs.
    1.40 +   */
    1.41 +  readonly attribute nsINavHistoryResult parentResult;
    1.42 +
    1.43 +  /**
    1.44 +   * URI of the resource in question. For visits and URLs, this is the URL of
    1.45 +   * the page. For folders and queries, this is the place: URI of the
    1.46 +   * corresponding folder or query. This may be empty for other types of
    1.47 +   * objects like host containers.
    1.48 +   */
    1.49 +  readonly attribute AUTF8String uri;
    1.50 +
    1.51 +  /**
    1.52 +   * Identifies the type of this node. This node can then be QI-ed to the
    1.53 +   * corresponding specialized result node interface.
    1.54 +   */
    1.55 +  const unsigned long RESULT_TYPE_URI = 0;               // nsINavHistoryResultNode
    1.56 +
    1.57 +  // Visit nodes are deprecated and unsupported.
    1.58 +  // This line exists just to avoid reusing the value:
    1.59 +  // const unsigned long RESULT_TYPE_VISIT = 1;
    1.60 +
    1.61 +  // Full visit nodes are deprecated and unsupported.
    1.62 +  // This line exists just to avoid reusing the value:
    1.63 +  // const unsigned long RESULT_TYPE_FULL_VISIT = 2;
    1.64 +
    1.65 +  // Dynamic containers are deprecated and unsupported.
    1.66 +  // This const exists just to avoid reusing the value:
    1.67 +  // const unsigned long RESULT_TYPE_DYNAMIC_CONTAINER = 4; // nsINavHistoryContainerResultNode
    1.68 +
    1.69 +  const unsigned long RESULT_TYPE_QUERY = 5;             // nsINavHistoryQueryResultNode
    1.70 +  const unsigned long RESULT_TYPE_FOLDER = 6;            // nsINavHistoryQueryResultNode
    1.71 +  const unsigned long RESULT_TYPE_SEPARATOR = 7;         // nsINavHistoryResultNode
    1.72 +  const unsigned long RESULT_TYPE_FOLDER_SHORTCUT = 9;   // nsINavHistoryQueryResultNode
    1.73 +  readonly attribute unsigned long type;
    1.74 +
    1.75 +  /**
    1.76 +   * Title of the web page, or of the node's query (day, host, folder, etc)
    1.77 +   */
    1.78 +  readonly attribute AUTF8String title;
    1.79 +
    1.80 +  /**
    1.81 +   * Total number of times the URI has ever been accessed. For hosts, this
    1.82 +   * is the total of the children under it, NOT the total times the host has
    1.83 +   * been accessed (this would require an additional query, so is not given
    1.84 +   * by default when most of the time it is never needed).
    1.85 +   */
    1.86 +  readonly attribute unsigned long accessCount;
    1.87 +
    1.88 +  /**
    1.89 +   * This is the time the user accessed the page.
    1.90 +   *
    1.91 +   * If this is a visit, it is the exact time that the page visit occurred.
    1.92 +   *
    1.93 +   * If this is a URI, it is the most recent time that the URI was visited.
    1.94 +   * Even if you ask for all URIs for a given date range long ago, this might
    1.95 +   * contain today's date if the URI was visited today.
    1.96 +   *
    1.97 +   * For hosts, or other node types with children, this is the most recent
    1.98 +   * access time for any of the children.
    1.99 +   *
   1.100 +   * For days queries this is the respective endTime - a maximum possible
   1.101 +   * visit time to fit in the day range.
   1.102 +   */
   1.103 +  readonly attribute PRTime time;
   1.104 +
   1.105 +  /**
   1.106 +   * This URI can be used as an image source URI and will give you the favicon
   1.107 +   * for the page. It is *not* the URI of the favicon, but rather something
   1.108 +   * that will resolve to the actual image.
   1.109 +   *
   1.110 +   * In most cases, this is an annotation URI that will query the favicon
   1.111 +   * service. If the entry has no favicon, this is the chrome URI of the
   1.112 +   * default favicon. If the favicon originally lived in chrome, this will
   1.113 +   * be the original chrome URI of the icon.
   1.114 +   */
   1.115 +  readonly attribute AUTF8String icon;
   1.116 +
   1.117 +  /**
   1.118 +   * This is the number of levels between this node and the top of the
   1.119 +   * hierarchy. The members of result.children have indentLevel = 0, their
   1.120 +   * children have indentLevel = 1, etc. The indent level of the root node is
   1.121 +   * set to -1.
   1.122 +   */
   1.123 +  readonly attribute long indentLevel;
   1.124 +
   1.125 +  /**
   1.126 +   * When this item is in a bookmark folder (parent is of type folder), this is
   1.127 +   * the index into that folder of this node. These indices start at 0 and
   1.128 +   * increase in the order that they appear in the bookmark folder. For items
   1.129 +   * that are not in a bookmark folder, this value is -1.
   1.130 +   */
   1.131 +  readonly attribute long bookmarkIndex;
   1.132 +
   1.133 +  /**
   1.134 +   * If the node is an item (bookmark, folder or a separator) this value is the
   1.135 +   * row ID of that bookmark in the database. For other nodes, this value is
   1.136 +   * set to -1.
   1.137 +   */
   1.138 +  readonly attribute long long itemId;
   1.139 +
   1.140 +  /**
   1.141 +   * If the node is an item (bookmark, folder or a separator) this value is the 
   1.142 +   * time that the item was created. For other nodes, this value is 0.
   1.143 +   */
   1.144 +  readonly attribute PRTime dateAdded;
   1.145 +
   1.146 +  /**
   1.147 +   * If the node is an item (bookmark, folder or a separator) this value is the 
   1.148 +   * time that the item was last modified. For other nodes, this value is 0.
   1.149 +   *
   1.150 +   *  @note When an item is added lastModified is set to the same value as
   1.151 +   *        dateAdded.
   1.152 +   */
   1.153 +  readonly attribute PRTime lastModified;
   1.154 +
   1.155 +  /**
   1.156 +   * For uri nodes, this is a sorted list of the tags, delimited with commans,
   1.157 +   * for the uri represented by this node. Otherwise this is an empty string.
   1.158 +   */
   1.159 +  readonly attribute AString tags;
   1.160 +
   1.161 +  /**
   1.162 +   * The unique ID associated with the page. It my return an empty string
   1.163 +   * if the result node is a non-URI node.
   1.164 +   */
   1.165 +  readonly attribute ACString pageGuid;
   1.166 +
   1.167 +  /**
   1.168 +   * The unique ID associated with the bookmark. It returns an empty string
   1.169 +   * if the result node is not associated with a bookmark, a folder or a
   1.170 +   * separator.
   1.171 +   */
   1.172 +  readonly attribute ACString bookmarkGuid;
   1.173 +};
   1.174 +
   1.175 +
   1.176 +/**
   1.177 + * Base class for container results. This includes all types of groupings.
   1.178 + * Bookmark folders and places queries will be QueryResultNodes which extends
   1.179 + * these items.
   1.180 + */
   1.181 +[scriptable, uuid(5bac9734-c0ff-44eb-8d19-da88462ff6da)]
   1.182 +interface nsINavHistoryContainerResultNode : nsINavHistoryResultNode
   1.183 +{
   1.184 +
   1.185 +  /**
   1.186 +   * Set this to allow descent into the container. When closed, attempting
   1.187 +   * to call getChildren or childCount will result in an error. You should
   1.188 +   * set this to false when you are done reading.
   1.189 +   *
   1.190 +   * For HOST and DAY groupings, doing this is free since the children have
   1.191 +   * been precomputed. For queries and bookmark folders, being open means they
   1.192 +   * will keep themselves up-to-date by listening for updates and re-querying
   1.193 +   * as needed.
   1.194 +   */
   1.195 +  attribute boolean containerOpen;
   1.196 +
   1.197 +  /**
   1.198 +   * Indicates whether the container is closed, loading, or opened.  Loading
   1.199 +   * implies that the container has been opened asynchronously and has not yet
   1.200 +   * fully opened.
   1.201 +   */
   1.202 +  readonly attribute unsigned short state;
   1.203 +  const unsigned short STATE_CLOSED = 0;
   1.204 +  const unsigned short STATE_LOADING = 1;
   1.205 +  const unsigned short STATE_OPENED = 2;
   1.206 +
   1.207 +  /**
   1.208 +   * This indicates whether this node "may" have children, and can be used
   1.209 +   * when the container is open or closed. When the container is closed, it
   1.210 +   * will give you an exact answer if the node can easily be populated (for
   1.211 +   * example, a bookmark folder). If not (for example, a complex history query),
   1.212 +   * it will return true. When the container is open, it will always be
   1.213 +   * accurate. It is intended to be used to see if we should draw the "+" next
   1.214 +   * to a tree item.
   1.215 +   */
   1.216 +  readonly attribute boolean hasChildren;
   1.217 +
   1.218 +  /**
   1.219 +   * This gives you the children of the nodes. It is preferrable to use this
   1.220 +   * interface over the array one, since it avoids creating an nsIArray object
   1.221 +   * and the interface is already the correct type.
   1.222 +   *
   1.223 +   * @throws NS_ERROR_NOT_AVAILABLE if containerOpen is false.
   1.224 +   */
   1.225 +  readonly attribute unsigned long childCount;
   1.226 +  nsINavHistoryResultNode getChild(in unsigned long aIndex);
   1.227 +
   1.228 +  /**
   1.229 +   * Get the index of a direct child in this container.
   1.230 +   *
   1.231 +   * @param aNode
   1.232 +   *        a result node.
   1.233 +   *
   1.234 +   * @return aNode's index in this container.
   1.235 +   * @throws NS_ERROR_NOT_AVAILABLE if containerOpen is false.
   1.236 +   * @throws NS_ERROR_INVALID_ARG if aNode isn't a direct child of this
   1.237 +   * container.
   1.238 +   */
   1.239 +  unsigned long getChildIndex(in nsINavHistoryResultNode aNode);
   1.240 +
   1.241 +  /**
   1.242 +   * Look for a node in the container by some of its details.  Does not search
   1.243 +   * closed containers.
   1.244 +   *
   1.245 +   * @param aURI
   1.246 +   *        the node's uri attribute value
   1.247 +   * @param aTime
   1.248 +   *        the node's time attribute value.
   1.249 +   * @param aItemId
   1.250 +   *        the node's itemId attribute value.
   1.251 +   * @param aRecursive
   1.252 +   *        whether or not to search recursively.
   1.253 +   *
   1.254 +   * @throws NS_ERROR_NOT_AVAILABLE if this container is closed.
   1.255 +   * @return a result node that matches the given details if any, null
   1.256 +   *         otherwise.
   1.257 +   */
   1.258 +  nsINavHistoryResultNode findNodeByDetails(in AUTF8String aURIString,
   1.259 +                                            in PRTime aTime,
   1.260 +                                            in long long aItemId,
   1.261 +                                            in boolean aRecursive);
   1.262 +
   1.263 +  /**
   1.264 +   * Returns false if this node's list of children can be modified
   1.265 +   * (adding or removing children, or reordering children), or true if
   1.266 +   * the UI should not allow the list of children to be modified.
   1.267 +   * This is false for bookmark folder nodes unless setFolderReadOnly() has
   1.268 +   * been called to override it, and true for non-folder nodes.
   1.269 +   */
   1.270 +  readonly attribute boolean childrenReadOnly;
   1.271 +};
   1.272 +
   1.273 +
   1.274 +/**
   1.275 + * Used for places queries and as a base for bookmark folders.
   1.276 + *
   1.277 + * Note that if you request places to *not* be expanded in the options that
   1.278 + * generated this node, this item will report it has no children and never try
   1.279 + * to populate itself.
   1.280 + */
   1.281 +[scriptable, uuid(a4144c3e-8125-46d5-a719-831bec8095f4)]
   1.282 +interface nsINavHistoryQueryResultNode : nsINavHistoryContainerResultNode
   1.283 +{
   1.284 +  /**
   1.285 +   * Get the queries which build this node's children.
   1.286 +   * Only valid for RESULT_TYPE_QUERY nodes.
   1.287 +   */
   1.288 +  void getQueries([optional] out unsigned long queryCount,
   1.289 +                  [retval,array,size_is(queryCount)] out nsINavHistoryQuery queries);
   1.290 +
   1.291 +  /**
   1.292 +   * Get the options which group this node's children.
   1.293 +   * Only valid for RESULT_TYPE_QUERY nodes.
   1.294 +   */
   1.295 +  readonly attribute nsINavHistoryQueryOptions queryOptions;
   1.296 +
   1.297 +  /**
   1.298 +   * For both simple folder nodes and simple-folder-query nodes, this is set
   1.299 +   * to the concrete itemId of the folder. Otherwise, this is set to -1.
   1.300 +   */
   1.301 +  readonly attribute long long folderItemId;
   1.302 +};
   1.303 +
   1.304 +
   1.305 +/**
   1.306 + * Allows clients to observe what is happening to a result as it updates itself
   1.307 + * according to history and bookmark system events. Register this observer on a
   1.308 + * result using nsINavHistoryResult::addObserver.
   1.309 + */
   1.310 +[scriptable, uuid(f62d8b6b-3c4e-4a9f-a897-db605d0b7a0f)]
   1.311 +interface nsINavHistoryResultObserver : nsISupports
   1.312 +{
   1.313 +  /**
   1.314 +   * Called when 'aItem' is inserted into 'aParent' at index 'aNewIndex'.
   1.315 +   * The item previously at index (if any) and everything below it will have
   1.316 +   * been shifted down by one. The item may be a container or a leaf.
   1.317 +   */
   1.318 +  void nodeInserted(in nsINavHistoryContainerResultNode aParent,
   1.319 +                    in nsINavHistoryResultNode aNode,
   1.320 +                    in unsigned long aNewIndex);
   1.321 +
   1.322 +  /**
   1.323 +   * Called whan 'aItem' is removed from 'aParent' at 'aOldIndex'. The item
   1.324 +   * may be a container or a leaf. This function will be called after the item
   1.325 +   * has been removed from its parent list, but before anything else (including
   1.326 +   * NULLing out the item's parent) has happened.
   1.327 +   */
   1.328 +  void nodeRemoved(in nsINavHistoryContainerResultNode aParent,
   1.329 +                   in nsINavHistoryResultNode aItem,
   1.330 +                   in unsigned long aOldIndex);
   1.331 +
   1.332 +  /**
   1.333 +   * Called whan 'aItem' is moved from 'aOldParent' at 'aOldIndex' to
   1.334 +   * aNewParent at aNewIndex. The item may be a container or a leaf.
   1.335 +   *
   1.336 +   * XXX: at the moment, this method is called only when an item is moved
   1.337 +   * within the same container. When an item is moved between containers,
   1.338 +   * a new node is created for the item, and the itemRemoved/itemAdded methods
   1.339 +   * are used.
   1.340 +   */
   1.341 +  void nodeMoved(in nsINavHistoryResultNode aNode,
   1.342 +                 in nsINavHistoryContainerResultNode aOldParent,
   1.343 +                 in unsigned long aOldIndex,
   1.344 +                 in nsINavHistoryContainerResultNode aNewParent,
   1.345 +                 in unsigned long aNewIndex);
   1.346 +
   1.347 +  /**
   1.348 +   * Called right after aNode's title has changed.
   1.349 +   * 
   1.350 +   * @param aNode
   1.351 +   *        a result node
   1.352 +   * @param aNewTitle
   1.353 +   *        the new title
   1.354 +   */
   1.355 +  void nodeTitleChanged(in nsINavHistoryResultNode aNode,
   1.356 +                        in AUTF8String aNewTitle);
   1.357 +
   1.358 +  /**
   1.359 +   * Called right after aNode's uri property has changed.
   1.360 +   * 
   1.361 +   * @param aNode
   1.362 +   *        a result node
   1.363 +   * @param aNewURI
   1.364 +   *        the new uri
   1.365 +   */
   1.366 +  void nodeURIChanged(in nsINavHistoryResultNode aNode,
   1.367 +                      in AUTF8String aNewURI);
   1.368 +
   1.369 +  /**
   1.370 +   * Called right after aNode's icon property has changed.
   1.371 +   *
   1.372 +   * @param aNode
   1.373 +   *        a result node
   1.374 +   *
   1.375 +   * @note: The new icon is accessible through aNode.icon.
   1.376 +   */
   1.377 +  void nodeIconChanged(in nsINavHistoryResultNode aNode);
   1.378 +
   1.379 +  /**
   1.380 +   * Called right after aNode's time property or accessCount property, or both,
   1.381 +   * have changed.
   1.382 +   *
   1.383 +   * @param aNode
   1.384 +   *        a uri result node
   1.385 +   * @param aNewVisitDate
   1.386 +   *        the new visit date
   1.387 +   * @param aNewAccessCount
   1.388 +   *        the new access-count
   1.389 +   */
   1.390 +  void nodeHistoryDetailsChanged(in nsINavHistoryResultNode aNode,
   1.391 +                                 in PRTime aNewVisitDate,
   1.392 +                                 in unsigned long aNewAccessCount);
   1.393 +
   1.394 +  /**
   1.395 +   * Called when the tags set on the uri represented by aNode have changed.
   1.396 +   *
   1.397 +   * @param aNode
   1.398 +   *        a uri result node
   1.399 +   *
   1.400 +   * @note: The new tags list is accessible through aNode.tags.
   1.401 +   */
   1.402 +  void nodeTagsChanged(in nsINavHistoryResultNode aNode);
   1.403 +
   1.404 +  /**
   1.405 +   * Called right after the aNode's keyword property has changed.
   1.406 +   * 
   1.407 +   * @param aNode
   1.408 +   *        a uri result node
   1.409 +   * @param aNewKeyword
   1.410 +   *        the new keyword
   1.411 +   */
   1.412 +  void nodeKeywordChanged(in nsINavHistoryResultNode aNode,
   1.413 +                          in AUTF8String aNewKeyword);
   1.414 +
   1.415 +  /**
   1.416 +   * Called right after an annotation of aNode's has changed (set, altered, or
   1.417 +   * unset).
   1.418 +   * 
   1.419 +   * @param aNode
   1.420 +   *        a result node
   1.421 +   * @param aAnnoName
   1.422 +   *        the name of the annotation that changed
   1.423 +   */
   1.424 +  void nodeAnnotationChanged(in nsINavHistoryResultNode aNode,
   1.425 +                             in AUTF8String aAnnoName);
   1.426 +
   1.427 +  /**
   1.428 +   * Called right after aNode's dateAdded property has changed.
   1.429 +   *
   1.430 +   * @param aNode
   1.431 +   *        a result node
   1.432 +   * @param aNewValue
   1.433 +   *        the new value of the dateAdded property
   1.434 +   */
   1.435 +  void nodeDateAddedChanged(in nsINavHistoryResultNode aNode,
   1.436 +                            in PRTime aNewValue);
   1.437 +
   1.438 +  /**
   1.439 +   * Called right after aNode's dateModified property has changed.
   1.440 +   *
   1.441 +   * @param aNode
   1.442 +   *        a result node
   1.443 +   * @param aNewValue
   1.444 +   *        the new value of the dateModified property
   1.445 +   */
   1.446 +  void nodeLastModifiedChanged(in nsINavHistoryResultNode aNode,
   1.447 +                               in PRTime aNewValue);
   1.448 +
   1.449 +  /**
   1.450 +   * Called after a container changes state.
   1.451 +   *
   1.452 +   * @param aContainerNode
   1.453 +   *        The container that has changed state.
   1.454 +   * @param aOldState
   1.455 +   *        The state that aContainerNode has transitioned out of.
   1.456 +   * @param aNewState
   1.457 +   *        The state that aContainerNode has transitioned into.
   1.458 +   */
   1.459 +  void containerStateChanged(in nsINavHistoryContainerResultNode aContainerNode,
   1.460 +                             in unsigned long aOldState,
   1.461 +                             in unsigned long aNewState);
   1.462 +
   1.463 +  /**
   1.464 +   * Called when something significant has happened within the container. The
   1.465 +   * contents of the container should be re-built.
   1.466 +   *
   1.467 +   * @param aContainerNode
   1.468 +   *        the container node to invalidate
   1.469 +   */
   1.470 +  void invalidateContainer(in nsINavHistoryContainerResultNode aContainerNode);
   1.471 +
   1.472 +  /**
   1.473 +   * This is called to indicate to the UI that the sort has changed to the
   1.474 +   * given mode. For trees, for example, this would update the column headers
   1.475 +   * to reflect the sorting. For many other types of views, this won't be
   1.476 +   * applicable.
   1.477 +   *
   1.478 +   * @param sortingMode  One of nsINavHistoryQueryOptions.SORT_BY_* that
   1.479 +   *                     indicates the new sorting mode.
   1.480 +   *
   1.481 +   * This only is expected to update the sorting UI. invalidateAll() will also
   1.482 +   * get called if the sorting changes to update everything.
   1.483 +   */
   1.484 +  void sortingChanged(in unsigned short sortingMode);
   1.485 +
   1.486 +  /**
   1.487 +   * This is called to indicate that a batch operation is about to start or end.
   1.488 +   * The observer could want to disable some events or updates during batches,
   1.489 +   * since multiple operations are packed in a short time.
   1.490 +   * For example treeviews could temporarily suppress select notifications.
   1.491 +   *
   1.492 +   * @param aToggleMode
   1.493 +   *        true if a batch is starting, false if it's ending.
   1.494 +   */
   1.495 +  void batching(in boolean aToggleMode);
   1.496 +
   1.497 +  /**
   1.498 +   * Called by the result when this observer is added.
   1.499 +   */
   1.500 +  attribute nsINavHistoryResult result;
   1.501 +};
   1.502 +
   1.503 +
   1.504 +/**
   1.505 + * TODO: Bug 517719.
   1.506 + *
   1.507 + * A predefined view adaptor for interfacing results with an nsITree. This
   1.508 + * object will remove itself from its associated result when the tree has been
   1.509 + * detached. This prevents circular references. Users should be aware of this,
   1.510 + * if you want to re-use the same viewer, you will need to keep your own
   1.511 + * reference to it and re-initialize it when the tree changes. If you use this
   1.512 + * object, attach it to a result, never attach it to a tree, and forget about
   1.513 + * it, it will leak!
   1.514 + */
   1.515 +[scriptable, uuid(f8b518c0-1faf-11df-8a39-0800200c9a66)]
   1.516 +interface nsINavHistoryResultTreeViewer : nsINavHistoryResultObserver
   1.517 +{
   1.518 +  /**
   1.519 +   * This allows you to get at the real node for a given row index. This is
   1.520 +   * only valid when a tree is attached.
   1.521 +   */
   1.522 +  nsINavHistoryResultNode nodeForTreeIndex(in unsigned long aIndex);
   1.523 +
   1.524 +  /**
   1.525 +   * Reverse of nodeForFlatIndex, returns the row index for a given result node.
   1.526 +   * Returns INDEX_INVISIBLE if the item is not visible (for example, its
   1.527 +   * parent is collapsed). This is only valid when a tree is attached. The
   1.528 +   * the result will always be INDEX_INVISIBLE if not.
   1.529 +   * 
   1.530 +   * Note: This sounds sort of obvious, but it got me: aNode must be a node
   1.531 +   *       retrieved from the same result that this viewer is for. If you 
   1.532 +   *       execute another query and get a node from a _different_ result, this 
   1.533 +   *       function will always return the index of that node in the tree that
   1.534 +   *       is attached to that result.
   1.535 +   */
   1.536 +  const unsigned long INDEX_INVISIBLE = 0xffffffff;
   1.537 +  unsigned long treeIndexForNode(in nsINavHistoryResultNode aNode);
   1.538 +};
   1.539 +
   1.540 +
   1.541 +/**
   1.542 + * The result of a history/bookmark query.
   1.543 + */
   1.544 +[scriptable, uuid(c2229ce3-2159-4001-859c-7013c52f7619)]
   1.545 +interface nsINavHistoryResult : nsISupports
   1.546 +{
   1.547 +  /**
   1.548 +   * Sorts all nodes recursively by the given parameter, one of
   1.549 +   * nsINavHistoryQueryOptions.SORT_BY_*  This will update the corresponding
   1.550 +   * options for this result, so that re-using the current options/queries will
   1.551 +   * always give you the current view.
   1.552 +   */
   1.553 +  attribute unsigned short sortingMode;
   1.554 +
   1.555 +  /**
   1.556 +   * The annotation to use in SORT_BY_ANNOTATION_* sorting modes, set this
   1.557 +   * before setting the sortingMode attribute.
   1.558 +   */
   1.559 +  attribute AUTF8String sortingAnnotation;
   1.560 +
   1.561 +  /**
   1.562 +   * Whether or not notifications on result changes are suppressed.
   1.563 +   * Initially set to false.
   1.564 +   *
   1.565 +   * Use this to avoid flickering and to improve performance when you
   1.566 +   * do temporary changes to the result structure (e.g. when searching for a
   1.567 +   * node recursively).
   1.568 +   */
   1.569 +  attribute boolean suppressNotifications;
   1.570 +
   1.571 +  /**
   1.572 +   * Adds an observer for changes done in the result.
   1.573 +   *
   1.574 +   * @param aObserver
   1.575 +   *        a result observer.
   1.576 +   * @param aOwnsWeak
   1.577 +   *        If false, the result will keep an owning reference to the observer,
   1.578 +   *        which must be removed using removeObserver.
   1.579 +   *        If true, the result will keep a weak reference to the observer, which
   1.580 +   *        must implement nsISupportsWeakReference.
   1.581 +   *
   1.582 +   * @see nsINavHistoryResultObserver
   1.583 +   */
   1.584 +  void addObserver(in nsINavHistoryResultObserver aObserver, in boolean aOwnsWeak);
   1.585 +
   1.586 +  /**
   1.587 +   * Removes an observer that was added by addObserver.
   1.588 +   *
   1.589 +   * @param aObserver
   1.590 +   *        a result observer that was added by addObserver.
   1.591 +   */
   1.592 +  void removeObserver(in nsINavHistoryResultObserver aObserver);
   1.593 +
   1.594 +  /**
   1.595 +   * This is the root of the results. Remember that you need to open all
   1.596 +   * containers for their contents to be valid.
   1.597 +   *
   1.598 +   * When a result goes out of scope it will continue to observe changes till
   1.599 +   * it is cycle collected.  While the result waits to be collected it will stay
   1.600 +   * in memory, and continue to update itself, potentially causing unwanted
   1.601 +   * additional work.  When you close the root node the result will stop
   1.602 +   * observing changes, so it is good practice to close the root node when you
   1.603 +   * are done with a result, since that will avoid unwanted performance hits.
   1.604 +   */
   1.605 +  readonly attribute nsINavHistoryContainerResultNode root;
   1.606 +};
   1.607 +
   1.608 +
   1.609 +/**
   1.610 + * Similar to nsIRDFObserver for history. Note that we don't pass the data
   1.611 + * source since that is always the global history.
   1.612 + *
   1.613 + * DANGER! If you are in the middle of a batch transaction, there may be a
   1.614 + * database transaction active. You can still access the DB, but be careful.
   1.615 + */
   1.616 +[scriptable, uuid(0f0f45b0-13a1-44ae-a0ab-c6046ec6d4da)]
   1.617 +interface nsINavHistoryObserver : nsISupports
   1.618 +{
   1.619 +  /**
   1.620 +   * Notifies you that a bunch of things are about to change, don't do any
   1.621 +   * heavy-duty processing until onEndUpdateBatch is called.
   1.622 +   */
   1.623 +  void onBeginUpdateBatch();
   1.624 +
   1.625 +  /**
   1.626 +   * Notifies you that we are done doing a bunch of things and you should go
   1.627 +   * ahead and update UI, etc.
   1.628 +   */
   1.629 +  void onEndUpdateBatch();
   1.630 +
   1.631 +  /**
   1.632 +   * Called when a resource is visited. This is called the first time a
   1.633 +   * resource (page, image, etc.) is seen as well as every subsequent time.
   1.634 +   *
   1.635 +   * Normally, transition types of TRANSITION_EMBED (corresponding to images in
   1.636 +   * a page, for example) are not displayed in history results (unless
   1.637 +   * includeHidden is set). Many observers can ignore _EMBED notifications
   1.638 +   * (which will comprise the majority of visit notifications) to save work.
   1.639 +   *
   1.640 +   * @param aVisitID        ID of the visit that was just created.
   1.641 +   * @param aTime           Time of the visit
   1.642 +   * @param aSessionID      No longer supported (always set to 0).
   1.643 +   * @param aReferringID    The ID of the visit the user came from. 0 if empty.
   1.644 +   * @param aTransitionType One of nsINavHistory.TRANSITION_*
   1.645 +   * @param aGUID           The unique ID associated with the page.
   1.646 +   * @param aHidden         Whether the visited page is marked as hidden.
   1.647 +   */
   1.648 +  void onVisit(in nsIURI aURI,
   1.649 +               in long long aVisitID,
   1.650 +               in PRTime aTime,
   1.651 +               in long long aSessionID,
   1.652 +               in long long aReferringID,
   1.653 +               in unsigned long aTransitionType,
   1.654 +               in ACString aGUID,
   1.655 +               in boolean aHidden);
   1.656 +
   1.657 +  /**
   1.658 +   * Called whenever either the "real" title or the custom title of the page
   1.659 +   * changed. BOTH TITLES ARE ALWAYS INCLUDED in this notification, even though
   1.660 +   * only one will change at a time. Often, consumers will want to display the
   1.661 +   * user title if it is available, and fall back to the page title (the one
   1.662 +   * specified in the <title> tag of the page).
   1.663 +   *
   1.664 +   * Note that there is a difference between an empty title and a NULL title.
   1.665 +   * An empty string means that somebody specifically set the title to be
   1.666 +   * nothing. NULL means nobody set it. From C++: use IsVoid() and SetIsVoid()
   1.667 +   * to see whether an empty string is "null" or not (it will always be an
   1.668 +   * empty string in either case).
   1.669 +   *
   1.670 +   * @param aURI
   1.671 +   *        The URI of the page.
   1.672 +   * @param aPageTitle
   1.673 +   *        The new title of the page.
   1.674 +   * @param aGUID
   1.675 +   *        The unique ID associated with the page.
   1.676 +   */
   1.677 +  void onTitleChanged(in nsIURI aURI,
   1.678 +                      in AString aPageTitle,
   1.679 +                      in ACString aGUID);
   1.680 +
   1.681 +  /**
   1.682 +   * Called when an individual page's frecency has changed.
   1.683 +   *
   1.684 +   * This is not called for pages whose frecencies change as the result of some
   1.685 +   * large operation where some large or unknown number of frecencies change at
   1.686 +   * once.  Use onManyFrecenciesChanged to detect such changes.
   1.687 +   *
   1.688 +   * @param aURI
   1.689 +   *        The page's URI.
   1.690 +   * @param aNewFrecency
   1.691 +   *        The page's new frecency.
   1.692 +   * @param aGUID
   1.693 +   *        The page's GUID.
   1.694 +   * @param aHidden
   1.695 +   *        True if the page is marked as hidden.
   1.696 +   * @param aVisitDate
   1.697 +   *        The page's last visit date.
   1.698 +   */
   1.699 +  void onFrecencyChanged(in nsIURI aURI,
   1.700 +                         in long aNewFrecency,
   1.701 +                         in ACString aGUID,
   1.702 +                         in boolean aHidden,
   1.703 +                         in PRTime aVisitDate);
   1.704 +
   1.705 +  /**
   1.706 +   * Called when the frecencies of many pages have changed at once.
   1.707 +   *
   1.708 +   * onFrecencyChanged is not called for each of those pages.
   1.709 +   */
   1.710 +  void onManyFrecenciesChanged();
   1.711 +
   1.712 +  /**
   1.713 +   * Removed by the user.
   1.714 +   */
   1.715 +  const unsigned short REASON_DELETED = 0;
   1.716 +  /**
   1.717 +   * Removed by automatic expiration.
   1.718 +   */
   1.719 +  const unsigned short REASON_EXPIRED = 1;
   1.720 +
   1.721 +  /**
   1.722 +   * This page and all of its visits are being deleted. Note: the page may not
   1.723 +   * necessarily have actually existed for this function to be called.
   1.724 +   *
   1.725 +   * Delete notifications are only 99.99% accurate. Batch delete operations
   1.726 +   * must be done in two steps, so first come notifications, then a bulk
   1.727 +   * delete. If there is some error in the middle (for example, out of memory)
   1.728 +   * then you'll get a notification and it won't get deleted. There's no easy
   1.729 +   * way around this.
   1.730 +   *
   1.731 +   * @param aURI
   1.732 +   *        The URI that was deleted.
   1.733 +   * @param aGUID
   1.734 +   *        The unique ID associated with the page.
   1.735 +   * @param aReason
   1.736 +   *        Indicates the reason for the removal.  see REASON_* constants.
   1.737 +   */
   1.738 +  void onDeleteURI(in nsIURI aURI,
   1.739 +                   in ACString aGUID,
   1.740 +                   in unsigned short aReason);
   1.741 +
   1.742 +  /**
   1.743 +   * Notification that all of history is being deleted.
   1.744 +   */
   1.745 +  void onClearHistory();
   1.746 +
   1.747 +  /**
   1.748 +   * onPageChanged attribute indicating that favicon has been updated.
   1.749 +   * aNewValue parameter will be set to the new favicon URI string.
   1.750 +   */
   1.751 +  const unsigned long ATTRIBUTE_FAVICON = 3;
   1.752 +
   1.753 +  /**
   1.754 +   * An attribute of this page changed.
   1.755 +   *
   1.756 +   * @param aURI
   1.757 +   *        The URI of the page on which an attribute changed.
   1.758 +   * @param aChangedAttribute
   1.759 +   *        The attribute whose value changed.  See ATTRIBUTE_* constants.
   1.760 +   * @param aNewValue
   1.761 +   *        The attribute's new value.
   1.762 +   * @param aGUID
   1.763 +   *        The unique ID associated with the page.
   1.764 +   */
   1.765 +  void onPageChanged(in nsIURI aURI,
   1.766 +                     in unsigned long aChangedAttribute,
   1.767 +                     in AString aNewValue,
   1.768 +                     in ACString aGUID);
   1.769 +
   1.770 +  /**
   1.771 +   * Called when some visits of an history entry are expired.
   1.772 +   *
   1.773 +   * @param aURI
   1.774 +   *        The page whose visits have been expired.
   1.775 +   * @param aVisitTime
   1.776 +   *        The largest visit time in microseconds that has been expired.  We
   1.777 +   *        guarantee that we don't have any visit older than this date.
   1.778 +   * @param aGUID
   1.779 +   *        The unique ID associated with the page.
   1.780 +   *
   1.781 +   * @note: when all visits for a page are expired and also the full page entry
   1.782 +   *        is expired, you will only get an onDeleteURI notification.  If a
   1.783 +   *        page entry is removed, then you can be sure that we don't have
   1.784 +   *        anymore visits for it.
   1.785 +   * @param aReason
   1.786 +   *        Indicates the reason for the removal.  see REASON_* constants.
   1.787 +   * @param aTransitionType
   1.788 +   *        If it's a valid TRANSITION_* value, all visits of the specified type
   1.789 +   *        have been removed.
   1.790 +   */
   1.791 +  void onDeleteVisits(in nsIURI aURI,
   1.792 +                      in PRTime aVisitTime,
   1.793 +                      in ACString aGUID,
   1.794 +                      in unsigned short aReason,
   1.795 +                      in unsigned long aTransitionType);
   1.796 +};
   1.797 +
   1.798 +
   1.799 +/**
   1.800 + * This object encapsulates all the query parameters you're likely to need
   1.801 + * when building up history UI. All parameters are ANDed together.
   1.802 + *
   1.803 + * This is not intended to be a super-general query mechanism. This was designed
   1.804 + * so that most queries can be done in only one SQL query. This is important
   1.805 + * because, if the user has their profile on a networked drive, query latency
   1.806 + * can be non-negligible.
   1.807 + */
   1.808 +
   1.809 +[scriptable, uuid(dc87ae79-22f1-4dcf-975b-852b01d210cb)]
   1.810 +interface nsINavHistoryQuery : nsISupports
   1.811 +{
   1.812 +  /**
   1.813 +   * Time range for results (INCLUSIVE). The *TimeReference is one of the
   1.814 +   * constants TIME_RELATIVE_* which indicates how to interpret the
   1.815 +   * corresponding time value.
   1.816 +   *   TIME_RELATIVE_EPOCH (default):
   1.817 +   *     The time is relative to Jan 1 1970 GMT, (this is a normal PRTime)
   1.818 +   *   TIME_RELATIVE_TODAY:
   1.819 +   *     The time is relative to this morning at midnight. Normally used for
   1.820 +   *     queries relative to today. For example, a "past week" query would be
   1.821 +   *     today-6 days -> today+1 day
   1.822 +   *   TIME_RELATIVE_NOW:
   1.823 +   *     The time is relative to right now.
   1.824 +   *
   1.825 +   * Note: PRTime is in MICROseconds since 1 Jan 1970. Javascript date objects
   1.826 +   * are expressed in MILLIseconds since 1 Jan 1970.
   1.827 +   *
   1.828 +   * As a special case, a 0 time relative to TIME_RELATIVE_EPOCH indicates that
   1.829 +   * the time is not part of the query. This is the default, so an empty query
   1.830 +   * will match any time. The has* functions return whether the corresponding
   1.831 +   * time is considered.
   1.832 +   *
   1.833 +   * You can read absolute*Time to get the time value that the currently loaded
   1.834 +   * reference points + offset resolve to.
   1.835 +   */
   1.836 +  const unsigned long TIME_RELATIVE_EPOCH = 0;
   1.837 +  const unsigned long TIME_RELATIVE_TODAY = 1;
   1.838 +  const unsigned long TIME_RELATIVE_NOW = 2;
   1.839 +
   1.840 +  attribute PRTime beginTime;
   1.841 +  attribute unsigned long beginTimeReference;
   1.842 +  readonly attribute boolean hasBeginTime;
   1.843 +  readonly attribute PRTime absoluteBeginTime;
   1.844 +
   1.845 +  attribute PRTime endTime;
   1.846 +  attribute unsigned long endTimeReference;
   1.847 +  readonly attribute boolean hasEndTime;
   1.848 +  readonly attribute PRTime absoluteEndTime;
   1.849 +
   1.850 +  /**
   1.851 +   * Text search terms.
   1.852 +   */
   1.853 +  attribute AString searchTerms;
   1.854 +  readonly attribute boolean hasSearchTerms;
   1.855 +
   1.856 +  /**
   1.857 +   * Set lower or upper limits for how many times an item has been
   1.858 +   * visited.  The default is -1, and in that case all items are
   1.859 +   * matched regardless of their visit count.
   1.860 +   */
   1.861 +  attribute long minVisits;
   1.862 +  attribute long maxVisits;
   1.863 +
   1.864 +  /**
   1.865 +   * When the set of transitions is nonempty, results are limited to pages which
   1.866 +   * have at least one visit for each of the transition types.
   1.867 +   * @note: For searching on more than one transition this can be very slow.
   1.868 +   *
   1.869 +   * Limit results to the specified list of transition types.
   1.870 +   */
   1.871 +  void setTransitions([const,array, size_is(count)] in unsigned long transitions,
   1.872 +                      in unsigned long count);
   1.873 +
   1.874 +  /**
   1.875 +   * Get the transitions set for this query.
   1.876 +   */
   1.877 +  void getTransitions([optional] out unsigned long count,
   1.878 +                      [retval,array,size_is(count)] out unsigned long transitions);
   1.879 +
   1.880 +  /**
   1.881 +   * Get the count of the set query transitions.
   1.882 +   */
   1.883 +  readonly attribute unsigned long transitionCount;
   1.884 +
   1.885 +  /**
   1.886 +   * When set, returns only bookmarked items, when unset, returns anything. Setting this
   1.887 +   * is equivalent to listing all bookmark folders in the 'folders' parameter.
   1.888 +   */
   1.889 +  attribute boolean onlyBookmarked;
   1.890 +
   1.891 +  /**
   1.892 +   * This controls the meaning of 'domain', and whether it is an exact match
   1.893 +   * 'domainIsHost' = true, or hierarchical (= false).
   1.894 +   */
   1.895 +  attribute boolean domainIsHost;
   1.896 +
   1.897 +  /**
   1.898 +   * This is the host or domain name (controlled by domainIsHost). When
   1.899 +   * domainIsHost, domain only does exact matching on host names. Otherwise,
   1.900 +   * it will return anything whose host name ends in 'domain'.
   1.901 +   *
   1.902 +   * This one is a little different than most. Setting it to an empty string
   1.903 +   * is a real query and will match any URI that has no host name (local files
   1.904 +   * and such). Set this to NULL (in C++ use SetIsVoid) if you don't want
   1.905 +   * domain matching.
   1.906 +   */
   1.907 +  attribute AUTF8String domain;
   1.908 +  readonly attribute boolean hasDomain;
   1.909 +
   1.910 +  /**
   1.911 +   * Controls the interpretation of 'uri'. When unset (default), the URI will
   1.912 +   * request an exact match of the specified URI. When set, any history entry
   1.913 +   * beginning in 'uri' will match. For example "http://bar.com/foo" will match
   1.914 +   * "http://bar.com/foo" as well as "http://bar.com/foo/baz.gif".
   1.915 +   */
   1.916 +  attribute boolean uriIsPrefix;
   1.917 +
   1.918 +  /**
   1.919 +   * This is a URI to match, to, for example, find out every time you visited
   1.920 +   * a given URI. Use uriIsPrefix to control whether this is an exact match.
   1.921 +   */
   1.922 +  attribute nsIURI uri;
   1.923 +  readonly attribute boolean hasUri;
   1.924 +
   1.925 +  /**
   1.926 +   * Test for existence or non-existence of a given annotation. We don't
   1.927 +   * currently support >1 annotation name per query. If 'annotationIsNot' is
   1.928 +   * true, we test for the non-existence of the specified annotation.
   1.929 +   *
   1.930 +   * Testing for not annotation will do the same thing as a normal query and
   1.931 +   * remove everything that doesn't have that annotation. Asking for things
   1.932 +   * that DO have a given annotation is a little different. It also includes
   1.933 +   * things that have never been visited. This allows place queries to be
   1.934 +   * returned as well as anything else that may have been tagged with an
   1.935 +   * annotation. This will only work for RESULTS_AS_URI since there will be
   1.936 +   * no visits for these items.
   1.937 +   */
   1.938 +  attribute boolean annotationIsNot;
   1.939 +  attribute AUTF8String annotation;
   1.940 +  readonly attribute boolean hasAnnotation;
   1.941 +
   1.942 +  /**
   1.943 +   * Limit results to items that are tagged with all of the given tags.  This
   1.944 +   * attribute must be set to an array of strings.  When called as a getter it
   1.945 +   * will return an array of strings sorted ascending in lexicographical order.
   1.946 +   * The array may be empty in either case.  Duplicate tags may be specified
   1.947 +   * when setting the attribute, but the getter returns only unique tags.
   1.948 +   *
   1.949 +   * To search for items that are tagged with any given tags rather than all,
   1.950 +   * multiple queries may be passed to nsINavHistoryService.executeQueries().
   1.951 +   */
   1.952 +  attribute nsIVariant tags;
   1.953 +
   1.954 +  /**
   1.955 +   * If 'tagsAreNot' is true, the results are instead limited to items that
   1.956 +   * are not tagged with any of the given tags.  This attribute is used in
   1.957 +   * conjunction with the 'tags' attribute.
   1.958 +   */
   1.959 +  attribute boolean tagsAreNot;
   1.960 +
   1.961 +  /**
   1.962 +   * Limit results to items that are in all of the given folders.
   1.963 +   */
   1.964 +  void getFolders([optional] out unsigned long count,
   1.965 +                  [retval,array,size_is(count)] out long long folders);
   1.966 +  readonly attribute unsigned long folderCount;
   1.967 +
   1.968 +  /**
   1.969 +   * For the special result type RESULTS_AS_TAG_CONTENTS we can define only
   1.970 +   * one folder that must be a tag folder. This is not recursive so results
   1.971 +   * will be returned from the first level of that folder.
   1.972 +   */
   1.973 +  void setFolders([const,array, size_is(folderCount)] in long long folders,
   1.974 +                  in unsigned long folderCount);
   1.975 +
   1.976 +  /**
   1.977 +   * Creates a new query item with the same parameters of this one.
   1.978 +   */
   1.979 +  nsINavHistoryQuery clone();
   1.980 +};
   1.981 +
   1.982 +/**
   1.983 + * This object represents the global options for executing a query.
   1.984 + */
   1.985 +[scriptable, uuid(8198dfa7-8061-4766-95cb-fa86b3c00a47)]
   1.986 +interface nsINavHistoryQueryOptions : nsISupports
   1.987 +{
   1.988 +  /**
   1.989 +   * You can ask for the results to be pre-sorted. Since the DB has indices
   1.990 +   * of many items, it can produce sorted results almost for free. These should
   1.991 +   * be self-explanatory.
   1.992 +   *
   1.993 +   * Note: re-sorting is slower, as is sorting by title or when you have a
   1.994 +   * host name.
   1.995 +   *
   1.996 +   * For bookmark items, SORT_BY_NONE means sort by the natural bookmark order.
   1.997 +   */
   1.998 +  const unsigned short SORT_BY_NONE = 0;
   1.999 +  const unsigned short SORT_BY_TITLE_ASCENDING = 1;
  1.1000 +  const unsigned short SORT_BY_TITLE_DESCENDING = 2;
  1.1001 +  const unsigned short SORT_BY_DATE_ASCENDING = 3;
  1.1002 +  const unsigned short SORT_BY_DATE_DESCENDING = 4;
  1.1003 +  const unsigned short SORT_BY_URI_ASCENDING = 5;
  1.1004 +  const unsigned short SORT_BY_URI_DESCENDING = 6;
  1.1005 +  const unsigned short SORT_BY_VISITCOUNT_ASCENDING = 7;
  1.1006 +  const unsigned short SORT_BY_VISITCOUNT_DESCENDING = 8;
  1.1007 +  const unsigned short SORT_BY_KEYWORD_ASCENDING = 9;
  1.1008 +  const unsigned short SORT_BY_KEYWORD_DESCENDING = 10;
  1.1009 +  const unsigned short SORT_BY_DATEADDED_ASCENDING = 11;
  1.1010 +  const unsigned short SORT_BY_DATEADDED_DESCENDING = 12;
  1.1011 +  const unsigned short SORT_BY_LASTMODIFIED_ASCENDING = 13;
  1.1012 +  const unsigned short SORT_BY_LASTMODIFIED_DESCENDING = 14;
  1.1013 +  const unsigned short SORT_BY_TAGS_ASCENDING = 17;
  1.1014 +  const unsigned short SORT_BY_TAGS_DESCENDING = 18;
  1.1015 +  const unsigned short SORT_BY_ANNOTATION_ASCENDING = 19;
  1.1016 +  const unsigned short SORT_BY_ANNOTATION_DESCENDING = 20;
  1.1017 +  const unsigned short SORT_BY_FRECENCY_ASCENDING = 21;
  1.1018 +  const unsigned short SORT_BY_FRECENCY_DESCENDING = 22;
  1.1019 +
  1.1020 +  /**
  1.1021 +   * "URI" results, one for each URI visited in the range. Individual result
  1.1022 +   * nodes will be of type "URI".
  1.1023 +   */
  1.1024 +  const unsigned short RESULTS_AS_URI = 0;
  1.1025 +
  1.1026 +  /**
  1.1027 +   * "Visit" results, with one for each time a page was visited (this will
  1.1028 +   * often give you multiple results for one URI). Individual result nodes will
  1.1029 +   * have type "Visit"
  1.1030 +   *
  1.1031 +   * @note This result type is only supported by QUERY_TYPE_HISTORY.
  1.1032 +   */
  1.1033 +  const unsigned short RESULTS_AS_VISIT = 1;
  1.1034 +
  1.1035 +  /**
  1.1036 +   * This is identical to RESULT_TYPE_VISIT except that individual result nodes
  1.1037 +   * will have type "FullVisit".  This is used for the attributes that are not
  1.1038 +   * commonly accessed to save space in the common case (the lists can be very
  1.1039 +   * long).
  1.1040 +   *
  1.1041 +   * @note Not yet implemented. See bug 409662.
  1.1042 +   * @note This result type is only supported by QUERY_TYPE_HISTORY.
  1.1043 +   */
  1.1044 +  const unsigned short RESULTS_AS_FULL_VISIT = 2;
  1.1045 +
  1.1046 +  /**
  1.1047 +   * This returns query nodes for each predefined date range where we 
  1.1048 +   * had visits. The node contains information how to load its content:
  1.1049 +   * - visits for the given date range will be loaded.
  1.1050 +   *
  1.1051 +   * @note This result type is only supported by QUERY_TYPE_HISTORY.
  1.1052 +   */
  1.1053 +  const unsigned short RESULTS_AS_DATE_QUERY = 3;
  1.1054 +
  1.1055 +  /**
  1.1056 +   * This returns nsINavHistoryQueryResultNode nodes for each site where we 
  1.1057 +   * have visits. The node contains information how to load its content:
  1.1058 +   * - last visit for each url in the given host will be loaded.
  1.1059 +   *
  1.1060 +   * @note This result type is only supported by QUERY_TYPE_HISTORY.
  1.1061 +   */
  1.1062 +  const unsigned short RESULTS_AS_SITE_QUERY = 4;
  1.1063 +
  1.1064 +  /**
  1.1065 +   * This returns nsINavHistoryQueryResultNode nodes for each day where we 
  1.1066 +   * have visits. The node contains information how to load its content:
  1.1067 +   * - list of hosts visited in the given period will be loaded.
  1.1068 +   *
  1.1069 +   * @note This result type is only supported by QUERY_TYPE_HISTORY.
  1.1070 +   */
  1.1071 +  const unsigned short RESULTS_AS_DATE_SITE_QUERY = 5;
  1.1072 +
  1.1073 +  /**
  1.1074 +   * This returns nsINavHistoryQueryResultNode nodes for each tag.
  1.1075 +   * The node contains information how to load its content:
  1.1076 +   * - list of bookmarks with the given tag will be loaded.
  1.1077 +   *
  1.1078 +   * @note Setting this resultType will force queryType to QUERY_TYPE_BOOKMARKS.
  1.1079 +   */
  1.1080 +  const unsigned short RESULTS_AS_TAG_QUERY = 6;
  1.1081 +
  1.1082 +  /**
  1.1083 +   * This is a container with an URI result type that contains the last
  1.1084 +   * modified bookmarks for the given tag.
  1.1085 +   * Tag folder id must be defined in the query.
  1.1086 +   *
  1.1087 +   * @note Setting this resultType will force queryType to QUERY_TYPE_BOOKMARKS.
  1.1088 +   */
  1.1089 +  const unsigned short RESULTS_AS_TAG_CONTENTS = 7;
  1.1090 +
  1.1091 +  /**
  1.1092 +   * The sorting mode to be used for this query.
  1.1093 +   * mode is one of SORT_BY_*
  1.1094 +   */
  1.1095 +  attribute unsigned short sortingMode;
  1.1096 +
  1.1097 +  /**
  1.1098 +   * The annotation to use in SORT_BY_ANNOTATION_* sorting modes.
  1.1099 +   */
  1.1100 +  attribute AUTF8String sortingAnnotation;
  1.1101 +
  1.1102 +  /**
  1.1103 +   * Sets the result type. One of RESULT_TYPE_* which includes how URIs are
  1.1104 +   * represented.
  1.1105 +   */
  1.1106 +  attribute unsigned short resultType;
  1.1107 +
  1.1108 +  /**
  1.1109 +   * This option excludes all URIs and separators from a bookmarks query.
  1.1110 +   * This would be used if you just wanted a list of bookmark folders and
  1.1111 +   * queries (such as the left pane of the places page).
  1.1112 +   * Defaults to false.
  1.1113 +   */
  1.1114 +  attribute boolean excludeItems;
  1.1115 +
  1.1116 +  /**
  1.1117 +   * Set to true to exclude queries ("place:" URIs) from the query results.
  1.1118 +   * Simple folder queries (bookmark folder symlinks) will still be included.
  1.1119 +   * Defaults to false.
  1.1120 +   */
  1.1121 +  attribute boolean excludeQueries;
  1.1122 +
  1.1123 +  /**
  1.1124 +   * Set to true to exclude read-only folders from the query results. This is
  1.1125 +   * designed for cases where you want to give the user the option of filing
  1.1126 +   * something into a list of folders. It only affects cases where the actual
  1.1127 +   * folder result node would appear in its parent folder and filters it out.
  1.1128 +   * It doesn't affect the query at all, and doesn't affect more complex
  1.1129 +   * queries (such as "folders with annotation X").
  1.1130 +   */
  1.1131 +  attribute boolean excludeReadOnlyFolders;
  1.1132 +
  1.1133 +  /**
  1.1134 +   * When set, allows items with "place:" URIs to appear as containers,
  1.1135 +   * with the container's contents filled in from the stored query.
  1.1136 +   * If not set, these will appear as normal items. Doesn't do anything if
  1.1137 +   * excludeQueries is set. Defaults to false.
  1.1138 +   *
  1.1139 +   * Note that this has no effect on folder links, which are place: URIs
  1.1140 +   * returned by nsINavBookmarkService.GetFolderURI. These are always expanded
  1.1141 +   * and will appear as bookmark folders.
  1.1142 +   */
  1.1143 +  attribute boolean expandQueries;
  1.1144 +
  1.1145 +  /**
  1.1146 +   * Some pages in history are marked "hidden" and thus don't appear by default
  1.1147 +   * in queries.  These include automatic framed visits and redirects.  Setting
  1.1148 +   * this attribute will return all pages, even hidden ones.  Does nothing for
  1.1149 +   * bookmark queries. Defaults to false.
  1.1150 +   */
  1.1151 +  attribute boolean includeHidden;
  1.1152 +
  1.1153 +  /**
  1.1154 +   * This is the maximum number of results that you want. The query is exeucted,
  1.1155 +   * the results are sorted, and then the top 'maxResults' results are taken
  1.1156 +   * and returned. Set to 0 (the default) to get all results.
  1.1157 +   *
  1.1158 +   * THIS DOES NOT WORK IN CONJUNCTION WITH SORTING BY TITLE. This is because
  1.1159 +   * sorting by title requires us to sort after using locale-sensetive sorting
  1.1160 +   * (as opposed to letting the database do it for us).
  1.1161 +   *
  1.1162 +   * Instead, we get the result ordered by date, pick the maxResult most recent
  1.1163 +   * ones, and THEN sort by title.
  1.1164 +   */
  1.1165 +  attribute unsigned long maxResults;
  1.1166 +
  1.1167 +  const unsigned short QUERY_TYPE_HISTORY = 0;
  1.1168 +  const unsigned short QUERY_TYPE_BOOKMARKS = 1;
  1.1169 +  /* Unified queries are not yet implemented. See bug 378798 */
  1.1170 +  const unsigned short QUERY_TYPE_UNIFIED = 2;
  1.1171 +
  1.1172 +  /**
  1.1173 +   * The type of search to use when querying the DB; This attribute is only
  1.1174 +   * honored by query nodes. It is silently ignored for simple folder queries.
  1.1175 +   */
  1.1176 +  attribute unsigned short queryType;
  1.1177 +
  1.1178 +  /**
  1.1179 +   * When this is true, the root container node generated by these options and
  1.1180 +   * its descendant containers will be opened asynchronously if they support it.
  1.1181 +   * This is false by default.
  1.1182 +   *
  1.1183 +   * @note Currently only bookmark folder containers support being opened
  1.1184 +   *       asynchronously.
  1.1185 +   */
  1.1186 +  attribute boolean asyncEnabled;
  1.1187 +
  1.1188 +  /**
  1.1189 +   * Creates a new options item with the same parameters of this one.
  1.1190 +   */
  1.1191 +  nsINavHistoryQueryOptions clone();
  1.1192 +};
  1.1193 +
  1.1194 +[scriptable, uuid(baebc597-9daf-4103-a325-e41ef9e7608a)]
  1.1195 +interface nsINavHistoryService : nsISupports
  1.1196 +{
  1.1197 +  /**
  1.1198 +   * System Notifications:
  1.1199 +   *
  1.1200 +   * places-init-complete - Sent once the History service is completely
  1.1201 +   *                        initialized successfully.
  1.1202 +   * places-database-locked - Sent if initialization of the History service
  1.1203 +   *                          failed due to the inability to open the places.sqlite
  1.1204 +   *                          for access reasons.
  1.1205 +   */
  1.1206 +
  1.1207 +  /**
  1.1208 +   * This transition type means the user followed a link and got a new toplevel
  1.1209 +   * window.
  1.1210 +   */
  1.1211 +  const unsigned long TRANSITION_LINK = 1;
  1.1212 +
  1.1213 +  /**
  1.1214 +   * This transition type means that the user typed the page's URL in the
  1.1215 +   * URL bar or selected it from URL bar autocomplete results, clicked on
  1.1216 +   * it from a history query (from the History sidebar, History menu, 
  1.1217 +   * or history query in the personal toolbar or Places organizer.
  1.1218 +   */
  1.1219 +  const unsigned long TRANSITION_TYPED = 2;
  1.1220 +
  1.1221 +  /**
  1.1222 +   * This transition is set when the user followed a bookmark to get to the
  1.1223 +   * page.
  1.1224 +   */
  1.1225 +  const unsigned long TRANSITION_BOOKMARK = 3;
  1.1226 +
  1.1227 +  /**
  1.1228 +   * This transition type is set when some inner content is loaded. This is
  1.1229 +   * true of all images on a page, and the contents of the iframe. It is also
  1.1230 +   * true of any content in a frame if the user did not explicitly follow
  1.1231 +   * a link to get there.
  1.1232 +   */
  1.1233 +  const unsigned long TRANSITION_EMBED = 4;
  1.1234 +
  1.1235 +  /**
  1.1236 +   * Set when the transition was a permanent redirect.
  1.1237 +   */
  1.1238 +  const unsigned long TRANSITION_REDIRECT_PERMANENT = 5;
  1.1239 +
  1.1240 +  /**
  1.1241 +   * Set when the transition was a temporary redirect.
  1.1242 +   */
  1.1243 +  const unsigned long TRANSITION_REDIRECT_TEMPORARY = 6;
  1.1244 +
  1.1245 +  /**
  1.1246 +   * Set when the transition is a download.
  1.1247 +   */
  1.1248 +  const unsigned long TRANSITION_DOWNLOAD = 7;
  1.1249 +
  1.1250 +  /**
  1.1251 +   * This transition type means the user followed a link and got a visit in
  1.1252 +   * a frame.
  1.1253 +   */
  1.1254 +  const unsigned long TRANSITION_FRAMED_LINK = 8;
  1.1255 +
  1.1256 +  /**
  1.1257 +   * Set when database is coherent
  1.1258 +   */
  1.1259 +  const unsigned short DATABASE_STATUS_OK = 0;
  1.1260 +
  1.1261 +  /**
  1.1262 +   * Set when database did not exist and we created a new one
  1.1263 +   */
  1.1264 +  const unsigned short DATABASE_STATUS_CREATE = 1;
  1.1265 +
  1.1266 +  /**
  1.1267 +   * Set when database was corrupt and we replaced it
  1.1268 +   */
  1.1269 +  const unsigned short DATABASE_STATUS_CORRUPT = 2;
  1.1270 +
  1.1271 +  /**
  1.1272 +   * Set when database schema has been upgraded
  1.1273 +   */
  1.1274 +  const unsigned short DATABASE_STATUS_UPGRADED = 3;
  1.1275 +
  1.1276 +  /**
  1.1277 +   * Returns the current database status
  1.1278 +   */
  1.1279 +  readonly attribute unsigned short databaseStatus;
  1.1280 +
  1.1281 +  /**
  1.1282 +   * True if there is any history. This can be used in UI to determine whether
  1.1283 +   * the "clear history" button should be enabled or not. This is much better
  1.1284 +   * than using BrowserHistory.count since that can be very slow if there is
  1.1285 +   * a lot of history (it must enumerate each item). This is pretty fast.
  1.1286 +   */
  1.1287 +  readonly attribute boolean hasHistoryEntries;
  1.1288 +
  1.1289 +  /**
  1.1290 +   * Gets the original title of the page.
  1.1291 +   * @deprecated use mozIAsyncHistory.getPlacesInfo instead.
  1.1292 +   */
  1.1293 +  AString getPageTitle(in nsIURI aURI);
  1.1294 +
  1.1295 +  /**
  1.1296 +   * This is just like markPageAsTyped (in nsIBrowserHistory, also implemented
  1.1297 +   * by the history service), but for bookmarks. It declares that the given URI
  1.1298 +   * is being opened as a result of following a bookmark. If this URI is loaded
  1.1299 +   * soon after this message has been received, that transition will be marked
  1.1300 +   * as following a bookmark.
  1.1301 +   */
  1.1302 +  void markPageAsFollowedBookmark(in nsIURI aURI);
  1.1303 +
  1.1304 +  /**
  1.1305 +   * Designates the url as having been explicitly typed in by the user.
  1.1306 +   *
  1.1307 +   * @param aURI
  1.1308 +   *        URI of the page to be marked.
  1.1309 +   */
  1.1310 +  void markPageAsTyped(in nsIURI aURI);
  1.1311 +
  1.1312 +  /**
  1.1313 +   * Designates the url as coming from a link explicitly followed by
  1.1314 +   * the user (for example by clicking on it).
  1.1315 +   *
  1.1316 +   * @param aURI
  1.1317 +   *        URI of the page to be marked.
  1.1318 +   */
  1.1319 +  void markPageAsFollowedLink(in nsIURI aURI);
  1.1320 +
  1.1321 +  /**
  1.1322 +   * Gets the stored character-set for an URI.
  1.1323 +   *
  1.1324 +   * @param aURI
  1.1325 +   *        URI to retrieve character-set for
  1.1326 +   * @return character-set, empty string if not found
  1.1327 +   */
  1.1328 +  AString getCharsetForURI(in nsIURI aURI);
  1.1329 +
  1.1330 +  /**
  1.1331 +   * Sets the character-set for an URI.
  1.1332 +   *
  1.1333 +   * @param aURI
  1.1334 +   *        URI to set the character-set for
  1.1335 +   * @param aCharset
  1.1336 +   *        character-set to be set
  1.1337 +   */
  1.1338 +  void setCharsetForURI(in nsIURI aURI, in AString aCharset);
  1.1339 +
  1.1340 +  /**
  1.1341 +   * Returns true if this URI would be added to the history. You don't have to
  1.1342 +   * worry about calling this, adding a visit will always check before
  1.1343 +   * actually adding the page. This function is public because some components
  1.1344 +   * may want to check if this page would go in the history (i.e. for
  1.1345 +   * annotations).
  1.1346 +   */
  1.1347 +  boolean canAddURI(in nsIURI aURI);
  1.1348 +
  1.1349 +  /**
  1.1350 +   * This returns a new query object that you can pass to executeQuer[y/ies].
  1.1351 +   * It will be initialized to all empty (so using it will give you all history).
  1.1352 +   */
  1.1353 +  nsINavHistoryQuery getNewQuery();
  1.1354 +
  1.1355 +  /**
  1.1356 +   * This returns a new options object that you can pass to executeQuer[y/ies]
  1.1357 +   * after setting the desired options.
  1.1358 +   */
  1.1359 +  nsINavHistoryQueryOptions getNewQueryOptions();
  1.1360 +
  1.1361 +  /**
  1.1362 +   * Executes a single query.
  1.1363 +   */
  1.1364 +  nsINavHistoryResult executeQuery(in nsINavHistoryQuery aQuery,
  1.1365 +                                   in nsINavHistoryQueryOptions options);
  1.1366 +
  1.1367 +  /**
  1.1368 +   * Executes an array of queries. All of the query objects are ORed
  1.1369 +   * together. Within a query, all the terms are ANDed together as in
  1.1370 +   * executeQuery. See executeQuery()
  1.1371 +   */
  1.1372 +  nsINavHistoryResult executeQueries(
  1.1373 +    [array,size_is(aQueryCount)] in nsINavHistoryQuery aQueries,
  1.1374 +    in unsigned long aQueryCount,
  1.1375 +    in nsINavHistoryQueryOptions options);
  1.1376 +
  1.1377 +  /**
  1.1378 +   * Converts a query URI-like string to an array of actual query objects for
  1.1379 +   * use to executeQueries(). The output query array may be empty if there is
  1.1380 +   * no information. However, there will always be an options structure returned
  1.1381 +   * (if nothing is defined, it will just have the default values).
  1.1382 +   */
  1.1383 +  void queryStringToQueries(in AUTF8String aQueryString,
  1.1384 +    [array, size_is(aResultCount)] out nsINavHistoryQuery aQueries,
  1.1385 +    out unsigned long aResultCount,
  1.1386 +    out nsINavHistoryQueryOptions options);
  1.1387 +
  1.1388 +  /**
  1.1389 +   * Converts a query into an equivalent string that can be persisted. Inverse
  1.1390 +   * of queryStringToQueries()
  1.1391 +   */
  1.1392 +  AUTF8String queriesToQueryString(
  1.1393 +    [array, size_is(aQueryCount)] in nsINavHistoryQuery aQueries,
  1.1394 +    in unsigned long aQueryCount,
  1.1395 +    in nsINavHistoryQueryOptions options);
  1.1396 +
  1.1397 +  /**
  1.1398 +   * Adds a history observer. If ownsWeak is false, the history service will
  1.1399 +   * keep an owning reference to the observer.  If ownsWeak is true, then
  1.1400 +   * aObserver must implement nsISupportsWeakReference, and the history service
  1.1401 +   * will keep a weak reference to the observer.
  1.1402 +   */
  1.1403 +  void addObserver(in nsINavHistoryObserver observer, in boolean ownsWeak);
  1.1404 +
  1.1405 +  /**
  1.1406 +   * Removes a history observer.
  1.1407 +   */
  1.1408 +  void removeObserver(in nsINavHistoryObserver observer);
  1.1409 +
  1.1410 +  /**
  1.1411 +   * Runs the passed callback in batch mode. Use this when a lot of things
  1.1412 +   * are about to change. Calls can be nested, observers will only be
  1.1413 +   * notified when all batches begin/end.
  1.1414 +   *
  1.1415 +   * @param aCallback
  1.1416 +   *        nsINavHistoryBatchCallback interface to call.
  1.1417 +   * @param aUserData
  1.1418 +   *        Opaque parameter passed to nsINavBookmarksBatchCallback
  1.1419 +   */
  1.1420 +  void runInBatchMode(in nsINavHistoryBatchCallback aCallback,
  1.1421 +                      in nsISupports aClosure);
  1.1422 +
  1.1423 +  /** 
  1.1424 +   * True if history is disabled. currently, 
  1.1425 +   * history is disabled if the places.history.enabled pref is false.
  1.1426 +   */
  1.1427 +  readonly attribute boolean historyDisabled;
  1.1428 +};
  1.1429 +
  1.1430 +/**
  1.1431 + * @see runInBatchMode of nsINavHistoryService/nsINavBookmarksService
  1.1432 + */
  1.1433 +[scriptable, uuid(5143f2bb-be0a-4faf-9acb-b0ed3f82952c)]
  1.1434 +interface nsINavHistoryBatchCallback : nsISupports {
  1.1435 +  void runBatched(in nsISupports aUserData);
  1.1436 +};

mercurial