toolkit/components/places/nsINavHistoryService.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /**
michael@0 7 * Using Places services after quit-application is not reliable, so make
michael@0 8 * sure to do any shutdown work on quit-application, or history
michael@0 9 * synchronization could fail, losing latest changes.
michael@0 10 */
michael@0 11
michael@0 12 #include "nsISupports.idl"
michael@0 13
michael@0 14 interface nsIArray;
michael@0 15 interface nsIURI;
michael@0 16 interface nsIVariant;
michael@0 17 interface nsIFile;
michael@0 18
michael@0 19 interface nsINavHistoryContainerResultNode;
michael@0 20 interface nsINavHistoryQueryResultNode;
michael@0 21 interface nsINavHistoryQuery;
michael@0 22 interface nsINavHistoryQueryOptions;
michael@0 23 interface nsINavHistoryResult;
michael@0 24 interface nsINavHistoryBatchCallback;
michael@0 25
michael@0 26 [scriptable, uuid(91d104bb-17ef-404b-9f9a-d9ed8de6824c)]
michael@0 27 interface nsINavHistoryResultNode : nsISupports
michael@0 28 {
michael@0 29 /**
michael@0 30 * Indentifies the parent result node in the result set. This is null for
michael@0 31 * top level nodes.
michael@0 32 */
michael@0 33 readonly attribute nsINavHistoryContainerResultNode parent;
michael@0 34
michael@0 35 /**
michael@0 36 * The history-result to which this node belongs.
michael@0 37 */
michael@0 38 readonly attribute nsINavHistoryResult parentResult;
michael@0 39
michael@0 40 /**
michael@0 41 * URI of the resource in question. For visits and URLs, this is the URL of
michael@0 42 * the page. For folders and queries, this is the place: URI of the
michael@0 43 * corresponding folder or query. This may be empty for other types of
michael@0 44 * objects like host containers.
michael@0 45 */
michael@0 46 readonly attribute AUTF8String uri;
michael@0 47
michael@0 48 /**
michael@0 49 * Identifies the type of this node. This node can then be QI-ed to the
michael@0 50 * corresponding specialized result node interface.
michael@0 51 */
michael@0 52 const unsigned long RESULT_TYPE_URI = 0; // nsINavHistoryResultNode
michael@0 53
michael@0 54 // Visit nodes are deprecated and unsupported.
michael@0 55 // This line exists just to avoid reusing the value:
michael@0 56 // const unsigned long RESULT_TYPE_VISIT = 1;
michael@0 57
michael@0 58 // Full visit nodes are deprecated and unsupported.
michael@0 59 // This line exists just to avoid reusing the value:
michael@0 60 // const unsigned long RESULT_TYPE_FULL_VISIT = 2;
michael@0 61
michael@0 62 // Dynamic containers are deprecated and unsupported.
michael@0 63 // This const exists just to avoid reusing the value:
michael@0 64 // const unsigned long RESULT_TYPE_DYNAMIC_CONTAINER = 4; // nsINavHistoryContainerResultNode
michael@0 65
michael@0 66 const unsigned long RESULT_TYPE_QUERY = 5; // nsINavHistoryQueryResultNode
michael@0 67 const unsigned long RESULT_TYPE_FOLDER = 6; // nsINavHistoryQueryResultNode
michael@0 68 const unsigned long RESULT_TYPE_SEPARATOR = 7; // nsINavHistoryResultNode
michael@0 69 const unsigned long RESULT_TYPE_FOLDER_SHORTCUT = 9; // nsINavHistoryQueryResultNode
michael@0 70 readonly attribute unsigned long type;
michael@0 71
michael@0 72 /**
michael@0 73 * Title of the web page, or of the node's query (day, host, folder, etc)
michael@0 74 */
michael@0 75 readonly attribute AUTF8String title;
michael@0 76
michael@0 77 /**
michael@0 78 * Total number of times the URI has ever been accessed. For hosts, this
michael@0 79 * is the total of the children under it, NOT the total times the host has
michael@0 80 * been accessed (this would require an additional query, so is not given
michael@0 81 * by default when most of the time it is never needed).
michael@0 82 */
michael@0 83 readonly attribute unsigned long accessCount;
michael@0 84
michael@0 85 /**
michael@0 86 * This is the time the user accessed the page.
michael@0 87 *
michael@0 88 * If this is a visit, it is the exact time that the page visit occurred.
michael@0 89 *
michael@0 90 * If this is a URI, it is the most recent time that the URI was visited.
michael@0 91 * Even if you ask for all URIs for a given date range long ago, this might
michael@0 92 * contain today's date if the URI was visited today.
michael@0 93 *
michael@0 94 * For hosts, or other node types with children, this is the most recent
michael@0 95 * access time for any of the children.
michael@0 96 *
michael@0 97 * For days queries this is the respective endTime - a maximum possible
michael@0 98 * visit time to fit in the day range.
michael@0 99 */
michael@0 100 readonly attribute PRTime time;
michael@0 101
michael@0 102 /**
michael@0 103 * This URI can be used as an image source URI and will give you the favicon
michael@0 104 * for the page. It is *not* the URI of the favicon, but rather something
michael@0 105 * that will resolve to the actual image.
michael@0 106 *
michael@0 107 * In most cases, this is an annotation URI that will query the favicon
michael@0 108 * service. If the entry has no favicon, this is the chrome URI of the
michael@0 109 * default favicon. If the favicon originally lived in chrome, this will
michael@0 110 * be the original chrome URI of the icon.
michael@0 111 */
michael@0 112 readonly attribute AUTF8String icon;
michael@0 113
michael@0 114 /**
michael@0 115 * This is the number of levels between this node and the top of the
michael@0 116 * hierarchy. The members of result.children have indentLevel = 0, their
michael@0 117 * children have indentLevel = 1, etc. The indent level of the root node is
michael@0 118 * set to -1.
michael@0 119 */
michael@0 120 readonly attribute long indentLevel;
michael@0 121
michael@0 122 /**
michael@0 123 * When this item is in a bookmark folder (parent is of type folder), this is
michael@0 124 * the index into that folder of this node. These indices start at 0 and
michael@0 125 * increase in the order that they appear in the bookmark folder. For items
michael@0 126 * that are not in a bookmark folder, this value is -1.
michael@0 127 */
michael@0 128 readonly attribute long bookmarkIndex;
michael@0 129
michael@0 130 /**
michael@0 131 * If the node is an item (bookmark, folder or a separator) this value is the
michael@0 132 * row ID of that bookmark in the database. For other nodes, this value is
michael@0 133 * set to -1.
michael@0 134 */
michael@0 135 readonly attribute long long itemId;
michael@0 136
michael@0 137 /**
michael@0 138 * If the node is an item (bookmark, folder or a separator) this value is the
michael@0 139 * time that the item was created. For other nodes, this value is 0.
michael@0 140 */
michael@0 141 readonly attribute PRTime dateAdded;
michael@0 142
michael@0 143 /**
michael@0 144 * If the node is an item (bookmark, folder or a separator) this value is the
michael@0 145 * time that the item was last modified. For other nodes, this value is 0.
michael@0 146 *
michael@0 147 * @note When an item is added lastModified is set to the same value as
michael@0 148 * dateAdded.
michael@0 149 */
michael@0 150 readonly attribute PRTime lastModified;
michael@0 151
michael@0 152 /**
michael@0 153 * For uri nodes, this is a sorted list of the tags, delimited with commans,
michael@0 154 * for the uri represented by this node. Otherwise this is an empty string.
michael@0 155 */
michael@0 156 readonly attribute AString tags;
michael@0 157
michael@0 158 /**
michael@0 159 * The unique ID associated with the page. It my return an empty string
michael@0 160 * if the result node is a non-URI node.
michael@0 161 */
michael@0 162 readonly attribute ACString pageGuid;
michael@0 163
michael@0 164 /**
michael@0 165 * The unique ID associated with the bookmark. It returns an empty string
michael@0 166 * if the result node is not associated with a bookmark, a folder or a
michael@0 167 * separator.
michael@0 168 */
michael@0 169 readonly attribute ACString bookmarkGuid;
michael@0 170 };
michael@0 171
michael@0 172
michael@0 173 /**
michael@0 174 * Base class for container results. This includes all types of groupings.
michael@0 175 * Bookmark folders and places queries will be QueryResultNodes which extends
michael@0 176 * these items.
michael@0 177 */
michael@0 178 [scriptable, uuid(5bac9734-c0ff-44eb-8d19-da88462ff6da)]
michael@0 179 interface nsINavHistoryContainerResultNode : nsINavHistoryResultNode
michael@0 180 {
michael@0 181
michael@0 182 /**
michael@0 183 * Set this to allow descent into the container. When closed, attempting
michael@0 184 * to call getChildren or childCount will result in an error. You should
michael@0 185 * set this to false when you are done reading.
michael@0 186 *
michael@0 187 * For HOST and DAY groupings, doing this is free since the children have
michael@0 188 * been precomputed. For queries and bookmark folders, being open means they
michael@0 189 * will keep themselves up-to-date by listening for updates and re-querying
michael@0 190 * as needed.
michael@0 191 */
michael@0 192 attribute boolean containerOpen;
michael@0 193
michael@0 194 /**
michael@0 195 * Indicates whether the container is closed, loading, or opened. Loading
michael@0 196 * implies that the container has been opened asynchronously and has not yet
michael@0 197 * fully opened.
michael@0 198 */
michael@0 199 readonly attribute unsigned short state;
michael@0 200 const unsigned short STATE_CLOSED = 0;
michael@0 201 const unsigned short STATE_LOADING = 1;
michael@0 202 const unsigned short STATE_OPENED = 2;
michael@0 203
michael@0 204 /**
michael@0 205 * This indicates whether this node "may" have children, and can be used
michael@0 206 * when the container is open or closed. When the container is closed, it
michael@0 207 * will give you an exact answer if the node can easily be populated (for
michael@0 208 * example, a bookmark folder). If not (for example, a complex history query),
michael@0 209 * it will return true. When the container is open, it will always be
michael@0 210 * accurate. It is intended to be used to see if we should draw the "+" next
michael@0 211 * to a tree item.
michael@0 212 */
michael@0 213 readonly attribute boolean hasChildren;
michael@0 214
michael@0 215 /**
michael@0 216 * This gives you the children of the nodes. It is preferrable to use this
michael@0 217 * interface over the array one, since it avoids creating an nsIArray object
michael@0 218 * and the interface is already the correct type.
michael@0 219 *
michael@0 220 * @throws NS_ERROR_NOT_AVAILABLE if containerOpen is false.
michael@0 221 */
michael@0 222 readonly attribute unsigned long childCount;
michael@0 223 nsINavHistoryResultNode getChild(in unsigned long aIndex);
michael@0 224
michael@0 225 /**
michael@0 226 * Get the index of a direct child in this container.
michael@0 227 *
michael@0 228 * @param aNode
michael@0 229 * a result node.
michael@0 230 *
michael@0 231 * @return aNode's index in this container.
michael@0 232 * @throws NS_ERROR_NOT_AVAILABLE if containerOpen is false.
michael@0 233 * @throws NS_ERROR_INVALID_ARG if aNode isn't a direct child of this
michael@0 234 * container.
michael@0 235 */
michael@0 236 unsigned long getChildIndex(in nsINavHistoryResultNode aNode);
michael@0 237
michael@0 238 /**
michael@0 239 * Look for a node in the container by some of its details. Does not search
michael@0 240 * closed containers.
michael@0 241 *
michael@0 242 * @param aURI
michael@0 243 * the node's uri attribute value
michael@0 244 * @param aTime
michael@0 245 * the node's time attribute value.
michael@0 246 * @param aItemId
michael@0 247 * the node's itemId attribute value.
michael@0 248 * @param aRecursive
michael@0 249 * whether or not to search recursively.
michael@0 250 *
michael@0 251 * @throws NS_ERROR_NOT_AVAILABLE if this container is closed.
michael@0 252 * @return a result node that matches the given details if any, null
michael@0 253 * otherwise.
michael@0 254 */
michael@0 255 nsINavHistoryResultNode findNodeByDetails(in AUTF8String aURIString,
michael@0 256 in PRTime aTime,
michael@0 257 in long long aItemId,
michael@0 258 in boolean aRecursive);
michael@0 259
michael@0 260 /**
michael@0 261 * Returns false if this node's list of children can be modified
michael@0 262 * (adding or removing children, or reordering children), or true if
michael@0 263 * the UI should not allow the list of children to be modified.
michael@0 264 * This is false for bookmark folder nodes unless setFolderReadOnly() has
michael@0 265 * been called to override it, and true for non-folder nodes.
michael@0 266 */
michael@0 267 readonly attribute boolean childrenReadOnly;
michael@0 268 };
michael@0 269
michael@0 270
michael@0 271 /**
michael@0 272 * Used for places queries and as a base for bookmark folders.
michael@0 273 *
michael@0 274 * Note that if you request places to *not* be expanded in the options that
michael@0 275 * generated this node, this item will report it has no children and never try
michael@0 276 * to populate itself.
michael@0 277 */
michael@0 278 [scriptable, uuid(a4144c3e-8125-46d5-a719-831bec8095f4)]
michael@0 279 interface nsINavHistoryQueryResultNode : nsINavHistoryContainerResultNode
michael@0 280 {
michael@0 281 /**
michael@0 282 * Get the queries which build this node's children.
michael@0 283 * Only valid for RESULT_TYPE_QUERY nodes.
michael@0 284 */
michael@0 285 void getQueries([optional] out unsigned long queryCount,
michael@0 286 [retval,array,size_is(queryCount)] out nsINavHistoryQuery queries);
michael@0 287
michael@0 288 /**
michael@0 289 * Get the options which group this node's children.
michael@0 290 * Only valid for RESULT_TYPE_QUERY nodes.
michael@0 291 */
michael@0 292 readonly attribute nsINavHistoryQueryOptions queryOptions;
michael@0 293
michael@0 294 /**
michael@0 295 * For both simple folder nodes and simple-folder-query nodes, this is set
michael@0 296 * to the concrete itemId of the folder. Otherwise, this is set to -1.
michael@0 297 */
michael@0 298 readonly attribute long long folderItemId;
michael@0 299 };
michael@0 300
michael@0 301
michael@0 302 /**
michael@0 303 * Allows clients to observe what is happening to a result as it updates itself
michael@0 304 * according to history and bookmark system events. Register this observer on a
michael@0 305 * result using nsINavHistoryResult::addObserver.
michael@0 306 */
michael@0 307 [scriptable, uuid(f62d8b6b-3c4e-4a9f-a897-db605d0b7a0f)]
michael@0 308 interface nsINavHistoryResultObserver : nsISupports
michael@0 309 {
michael@0 310 /**
michael@0 311 * Called when 'aItem' is inserted into 'aParent' at index 'aNewIndex'.
michael@0 312 * The item previously at index (if any) and everything below it will have
michael@0 313 * been shifted down by one. The item may be a container or a leaf.
michael@0 314 */
michael@0 315 void nodeInserted(in nsINavHistoryContainerResultNode aParent,
michael@0 316 in nsINavHistoryResultNode aNode,
michael@0 317 in unsigned long aNewIndex);
michael@0 318
michael@0 319 /**
michael@0 320 * Called whan 'aItem' is removed from 'aParent' at 'aOldIndex'. The item
michael@0 321 * may be a container or a leaf. This function will be called after the item
michael@0 322 * has been removed from its parent list, but before anything else (including
michael@0 323 * NULLing out the item's parent) has happened.
michael@0 324 */
michael@0 325 void nodeRemoved(in nsINavHistoryContainerResultNode aParent,
michael@0 326 in nsINavHistoryResultNode aItem,
michael@0 327 in unsigned long aOldIndex);
michael@0 328
michael@0 329 /**
michael@0 330 * Called whan 'aItem' is moved from 'aOldParent' at 'aOldIndex' to
michael@0 331 * aNewParent at aNewIndex. The item may be a container or a leaf.
michael@0 332 *
michael@0 333 * XXX: at the moment, this method is called only when an item is moved
michael@0 334 * within the same container. When an item is moved between containers,
michael@0 335 * a new node is created for the item, and the itemRemoved/itemAdded methods
michael@0 336 * are used.
michael@0 337 */
michael@0 338 void nodeMoved(in nsINavHistoryResultNode aNode,
michael@0 339 in nsINavHistoryContainerResultNode aOldParent,
michael@0 340 in unsigned long aOldIndex,
michael@0 341 in nsINavHistoryContainerResultNode aNewParent,
michael@0 342 in unsigned long aNewIndex);
michael@0 343
michael@0 344 /**
michael@0 345 * Called right after aNode's title has changed.
michael@0 346 *
michael@0 347 * @param aNode
michael@0 348 * a result node
michael@0 349 * @param aNewTitle
michael@0 350 * the new title
michael@0 351 */
michael@0 352 void nodeTitleChanged(in nsINavHistoryResultNode aNode,
michael@0 353 in AUTF8String aNewTitle);
michael@0 354
michael@0 355 /**
michael@0 356 * Called right after aNode's uri property has changed.
michael@0 357 *
michael@0 358 * @param aNode
michael@0 359 * a result node
michael@0 360 * @param aNewURI
michael@0 361 * the new uri
michael@0 362 */
michael@0 363 void nodeURIChanged(in nsINavHistoryResultNode aNode,
michael@0 364 in AUTF8String aNewURI);
michael@0 365
michael@0 366 /**
michael@0 367 * Called right after aNode's icon property has changed.
michael@0 368 *
michael@0 369 * @param aNode
michael@0 370 * a result node
michael@0 371 *
michael@0 372 * @note: The new icon is accessible through aNode.icon.
michael@0 373 */
michael@0 374 void nodeIconChanged(in nsINavHistoryResultNode aNode);
michael@0 375
michael@0 376 /**
michael@0 377 * Called right after aNode's time property or accessCount property, or both,
michael@0 378 * have changed.
michael@0 379 *
michael@0 380 * @param aNode
michael@0 381 * a uri result node
michael@0 382 * @param aNewVisitDate
michael@0 383 * the new visit date
michael@0 384 * @param aNewAccessCount
michael@0 385 * the new access-count
michael@0 386 */
michael@0 387 void nodeHistoryDetailsChanged(in nsINavHistoryResultNode aNode,
michael@0 388 in PRTime aNewVisitDate,
michael@0 389 in unsigned long aNewAccessCount);
michael@0 390
michael@0 391 /**
michael@0 392 * Called when the tags set on the uri represented by aNode have changed.
michael@0 393 *
michael@0 394 * @param aNode
michael@0 395 * a uri result node
michael@0 396 *
michael@0 397 * @note: The new tags list is accessible through aNode.tags.
michael@0 398 */
michael@0 399 void nodeTagsChanged(in nsINavHistoryResultNode aNode);
michael@0 400
michael@0 401 /**
michael@0 402 * Called right after the aNode's keyword property has changed.
michael@0 403 *
michael@0 404 * @param aNode
michael@0 405 * a uri result node
michael@0 406 * @param aNewKeyword
michael@0 407 * the new keyword
michael@0 408 */
michael@0 409 void nodeKeywordChanged(in nsINavHistoryResultNode aNode,
michael@0 410 in AUTF8String aNewKeyword);
michael@0 411
michael@0 412 /**
michael@0 413 * Called right after an annotation of aNode's has changed (set, altered, or
michael@0 414 * unset).
michael@0 415 *
michael@0 416 * @param aNode
michael@0 417 * a result node
michael@0 418 * @param aAnnoName
michael@0 419 * the name of the annotation that changed
michael@0 420 */
michael@0 421 void nodeAnnotationChanged(in nsINavHistoryResultNode aNode,
michael@0 422 in AUTF8String aAnnoName);
michael@0 423
michael@0 424 /**
michael@0 425 * Called right after aNode's dateAdded property has changed.
michael@0 426 *
michael@0 427 * @param aNode
michael@0 428 * a result node
michael@0 429 * @param aNewValue
michael@0 430 * the new value of the dateAdded property
michael@0 431 */
michael@0 432 void nodeDateAddedChanged(in nsINavHistoryResultNode aNode,
michael@0 433 in PRTime aNewValue);
michael@0 434
michael@0 435 /**
michael@0 436 * Called right after aNode's dateModified property has changed.
michael@0 437 *
michael@0 438 * @param aNode
michael@0 439 * a result node
michael@0 440 * @param aNewValue
michael@0 441 * the new value of the dateModified property
michael@0 442 */
michael@0 443 void nodeLastModifiedChanged(in nsINavHistoryResultNode aNode,
michael@0 444 in PRTime aNewValue);
michael@0 445
michael@0 446 /**
michael@0 447 * Called after a container changes state.
michael@0 448 *
michael@0 449 * @param aContainerNode
michael@0 450 * The container that has changed state.
michael@0 451 * @param aOldState
michael@0 452 * The state that aContainerNode has transitioned out of.
michael@0 453 * @param aNewState
michael@0 454 * The state that aContainerNode has transitioned into.
michael@0 455 */
michael@0 456 void containerStateChanged(in nsINavHistoryContainerResultNode aContainerNode,
michael@0 457 in unsigned long aOldState,
michael@0 458 in unsigned long aNewState);
michael@0 459
michael@0 460 /**
michael@0 461 * Called when something significant has happened within the container. The
michael@0 462 * contents of the container should be re-built.
michael@0 463 *
michael@0 464 * @param aContainerNode
michael@0 465 * the container node to invalidate
michael@0 466 */
michael@0 467 void invalidateContainer(in nsINavHistoryContainerResultNode aContainerNode);
michael@0 468
michael@0 469 /**
michael@0 470 * This is called to indicate to the UI that the sort has changed to the
michael@0 471 * given mode. For trees, for example, this would update the column headers
michael@0 472 * to reflect the sorting. For many other types of views, this won't be
michael@0 473 * applicable.
michael@0 474 *
michael@0 475 * @param sortingMode One of nsINavHistoryQueryOptions.SORT_BY_* that
michael@0 476 * indicates the new sorting mode.
michael@0 477 *
michael@0 478 * This only is expected to update the sorting UI. invalidateAll() will also
michael@0 479 * get called if the sorting changes to update everything.
michael@0 480 */
michael@0 481 void sortingChanged(in unsigned short sortingMode);
michael@0 482
michael@0 483 /**
michael@0 484 * This is called to indicate that a batch operation is about to start or end.
michael@0 485 * The observer could want to disable some events or updates during batches,
michael@0 486 * since multiple operations are packed in a short time.
michael@0 487 * For example treeviews could temporarily suppress select notifications.
michael@0 488 *
michael@0 489 * @param aToggleMode
michael@0 490 * true if a batch is starting, false if it's ending.
michael@0 491 */
michael@0 492 void batching(in boolean aToggleMode);
michael@0 493
michael@0 494 /**
michael@0 495 * Called by the result when this observer is added.
michael@0 496 */
michael@0 497 attribute nsINavHistoryResult result;
michael@0 498 };
michael@0 499
michael@0 500
michael@0 501 /**
michael@0 502 * TODO: Bug 517719.
michael@0 503 *
michael@0 504 * A predefined view adaptor for interfacing results with an nsITree. This
michael@0 505 * object will remove itself from its associated result when the tree has been
michael@0 506 * detached. This prevents circular references. Users should be aware of this,
michael@0 507 * if you want to re-use the same viewer, you will need to keep your own
michael@0 508 * reference to it and re-initialize it when the tree changes. If you use this
michael@0 509 * object, attach it to a result, never attach it to a tree, and forget about
michael@0 510 * it, it will leak!
michael@0 511 */
michael@0 512 [scriptable, uuid(f8b518c0-1faf-11df-8a39-0800200c9a66)]
michael@0 513 interface nsINavHistoryResultTreeViewer : nsINavHistoryResultObserver
michael@0 514 {
michael@0 515 /**
michael@0 516 * This allows you to get at the real node for a given row index. This is
michael@0 517 * only valid when a tree is attached.
michael@0 518 */
michael@0 519 nsINavHistoryResultNode nodeForTreeIndex(in unsigned long aIndex);
michael@0 520
michael@0 521 /**
michael@0 522 * Reverse of nodeForFlatIndex, returns the row index for a given result node.
michael@0 523 * Returns INDEX_INVISIBLE if the item is not visible (for example, its
michael@0 524 * parent is collapsed). This is only valid when a tree is attached. The
michael@0 525 * the result will always be INDEX_INVISIBLE if not.
michael@0 526 *
michael@0 527 * Note: This sounds sort of obvious, but it got me: aNode must be a node
michael@0 528 * retrieved from the same result that this viewer is for. If you
michael@0 529 * execute another query and get a node from a _different_ result, this
michael@0 530 * function will always return the index of that node in the tree that
michael@0 531 * is attached to that result.
michael@0 532 */
michael@0 533 const unsigned long INDEX_INVISIBLE = 0xffffffff;
michael@0 534 unsigned long treeIndexForNode(in nsINavHistoryResultNode aNode);
michael@0 535 };
michael@0 536
michael@0 537
michael@0 538 /**
michael@0 539 * The result of a history/bookmark query.
michael@0 540 */
michael@0 541 [scriptable, uuid(c2229ce3-2159-4001-859c-7013c52f7619)]
michael@0 542 interface nsINavHistoryResult : nsISupports
michael@0 543 {
michael@0 544 /**
michael@0 545 * Sorts all nodes recursively by the given parameter, one of
michael@0 546 * nsINavHistoryQueryOptions.SORT_BY_* This will update the corresponding
michael@0 547 * options for this result, so that re-using the current options/queries will
michael@0 548 * always give you the current view.
michael@0 549 */
michael@0 550 attribute unsigned short sortingMode;
michael@0 551
michael@0 552 /**
michael@0 553 * The annotation to use in SORT_BY_ANNOTATION_* sorting modes, set this
michael@0 554 * before setting the sortingMode attribute.
michael@0 555 */
michael@0 556 attribute AUTF8String sortingAnnotation;
michael@0 557
michael@0 558 /**
michael@0 559 * Whether or not notifications on result changes are suppressed.
michael@0 560 * Initially set to false.
michael@0 561 *
michael@0 562 * Use this to avoid flickering and to improve performance when you
michael@0 563 * do temporary changes to the result structure (e.g. when searching for a
michael@0 564 * node recursively).
michael@0 565 */
michael@0 566 attribute boolean suppressNotifications;
michael@0 567
michael@0 568 /**
michael@0 569 * Adds an observer for changes done in the result.
michael@0 570 *
michael@0 571 * @param aObserver
michael@0 572 * a result observer.
michael@0 573 * @param aOwnsWeak
michael@0 574 * If false, the result will keep an owning reference to the observer,
michael@0 575 * which must be removed using removeObserver.
michael@0 576 * If true, the result will keep a weak reference to the observer, which
michael@0 577 * must implement nsISupportsWeakReference.
michael@0 578 *
michael@0 579 * @see nsINavHistoryResultObserver
michael@0 580 */
michael@0 581 void addObserver(in nsINavHistoryResultObserver aObserver, in boolean aOwnsWeak);
michael@0 582
michael@0 583 /**
michael@0 584 * Removes an observer that was added by addObserver.
michael@0 585 *
michael@0 586 * @param aObserver
michael@0 587 * a result observer that was added by addObserver.
michael@0 588 */
michael@0 589 void removeObserver(in nsINavHistoryResultObserver aObserver);
michael@0 590
michael@0 591 /**
michael@0 592 * This is the root of the results. Remember that you need to open all
michael@0 593 * containers for their contents to be valid.
michael@0 594 *
michael@0 595 * When a result goes out of scope it will continue to observe changes till
michael@0 596 * it is cycle collected. While the result waits to be collected it will stay
michael@0 597 * in memory, and continue to update itself, potentially causing unwanted
michael@0 598 * additional work. When you close the root node the result will stop
michael@0 599 * observing changes, so it is good practice to close the root node when you
michael@0 600 * are done with a result, since that will avoid unwanted performance hits.
michael@0 601 */
michael@0 602 readonly attribute nsINavHistoryContainerResultNode root;
michael@0 603 };
michael@0 604
michael@0 605
michael@0 606 /**
michael@0 607 * Similar to nsIRDFObserver for history. Note that we don't pass the data
michael@0 608 * source since that is always the global history.
michael@0 609 *
michael@0 610 * DANGER! If you are in the middle of a batch transaction, there may be a
michael@0 611 * database transaction active. You can still access the DB, but be careful.
michael@0 612 */
michael@0 613 [scriptable, uuid(0f0f45b0-13a1-44ae-a0ab-c6046ec6d4da)]
michael@0 614 interface nsINavHistoryObserver : nsISupports
michael@0 615 {
michael@0 616 /**
michael@0 617 * Notifies you that a bunch of things are about to change, don't do any
michael@0 618 * heavy-duty processing until onEndUpdateBatch is called.
michael@0 619 */
michael@0 620 void onBeginUpdateBatch();
michael@0 621
michael@0 622 /**
michael@0 623 * Notifies you that we are done doing a bunch of things and you should go
michael@0 624 * ahead and update UI, etc.
michael@0 625 */
michael@0 626 void onEndUpdateBatch();
michael@0 627
michael@0 628 /**
michael@0 629 * Called when a resource is visited. This is called the first time a
michael@0 630 * resource (page, image, etc.) is seen as well as every subsequent time.
michael@0 631 *
michael@0 632 * Normally, transition types of TRANSITION_EMBED (corresponding to images in
michael@0 633 * a page, for example) are not displayed in history results (unless
michael@0 634 * includeHidden is set). Many observers can ignore _EMBED notifications
michael@0 635 * (which will comprise the majority of visit notifications) to save work.
michael@0 636 *
michael@0 637 * @param aVisitID ID of the visit that was just created.
michael@0 638 * @param aTime Time of the visit
michael@0 639 * @param aSessionID No longer supported (always set to 0).
michael@0 640 * @param aReferringID The ID of the visit the user came from. 0 if empty.
michael@0 641 * @param aTransitionType One of nsINavHistory.TRANSITION_*
michael@0 642 * @param aGUID The unique ID associated with the page.
michael@0 643 * @param aHidden Whether the visited page is marked as hidden.
michael@0 644 */
michael@0 645 void onVisit(in nsIURI aURI,
michael@0 646 in long long aVisitID,
michael@0 647 in PRTime aTime,
michael@0 648 in long long aSessionID,
michael@0 649 in long long aReferringID,
michael@0 650 in unsigned long aTransitionType,
michael@0 651 in ACString aGUID,
michael@0 652 in boolean aHidden);
michael@0 653
michael@0 654 /**
michael@0 655 * Called whenever either the "real" title or the custom title of the page
michael@0 656 * changed. BOTH TITLES ARE ALWAYS INCLUDED in this notification, even though
michael@0 657 * only one will change at a time. Often, consumers will want to display the
michael@0 658 * user title if it is available, and fall back to the page title (the one
michael@0 659 * specified in the <title> tag of the page).
michael@0 660 *
michael@0 661 * Note that there is a difference between an empty title and a NULL title.
michael@0 662 * An empty string means that somebody specifically set the title to be
michael@0 663 * nothing. NULL means nobody set it. From C++: use IsVoid() and SetIsVoid()
michael@0 664 * to see whether an empty string is "null" or not (it will always be an
michael@0 665 * empty string in either case).
michael@0 666 *
michael@0 667 * @param aURI
michael@0 668 * The URI of the page.
michael@0 669 * @param aPageTitle
michael@0 670 * The new title of the page.
michael@0 671 * @param aGUID
michael@0 672 * The unique ID associated with the page.
michael@0 673 */
michael@0 674 void onTitleChanged(in nsIURI aURI,
michael@0 675 in AString aPageTitle,
michael@0 676 in ACString aGUID);
michael@0 677
michael@0 678 /**
michael@0 679 * Called when an individual page's frecency has changed.
michael@0 680 *
michael@0 681 * This is not called for pages whose frecencies change as the result of some
michael@0 682 * large operation where some large or unknown number of frecencies change at
michael@0 683 * once. Use onManyFrecenciesChanged to detect such changes.
michael@0 684 *
michael@0 685 * @param aURI
michael@0 686 * The page's URI.
michael@0 687 * @param aNewFrecency
michael@0 688 * The page's new frecency.
michael@0 689 * @param aGUID
michael@0 690 * The page's GUID.
michael@0 691 * @param aHidden
michael@0 692 * True if the page is marked as hidden.
michael@0 693 * @param aVisitDate
michael@0 694 * The page's last visit date.
michael@0 695 */
michael@0 696 void onFrecencyChanged(in nsIURI aURI,
michael@0 697 in long aNewFrecency,
michael@0 698 in ACString aGUID,
michael@0 699 in boolean aHidden,
michael@0 700 in PRTime aVisitDate);
michael@0 701
michael@0 702 /**
michael@0 703 * Called when the frecencies of many pages have changed at once.
michael@0 704 *
michael@0 705 * onFrecencyChanged is not called for each of those pages.
michael@0 706 */
michael@0 707 void onManyFrecenciesChanged();
michael@0 708
michael@0 709 /**
michael@0 710 * Removed by the user.
michael@0 711 */
michael@0 712 const unsigned short REASON_DELETED = 0;
michael@0 713 /**
michael@0 714 * Removed by automatic expiration.
michael@0 715 */
michael@0 716 const unsigned short REASON_EXPIRED = 1;
michael@0 717
michael@0 718 /**
michael@0 719 * This page and all of its visits are being deleted. Note: the page may not
michael@0 720 * necessarily have actually existed for this function to be called.
michael@0 721 *
michael@0 722 * Delete notifications are only 99.99% accurate. Batch delete operations
michael@0 723 * must be done in two steps, so first come notifications, then a bulk
michael@0 724 * delete. If there is some error in the middle (for example, out of memory)
michael@0 725 * then you'll get a notification and it won't get deleted. There's no easy
michael@0 726 * way around this.
michael@0 727 *
michael@0 728 * @param aURI
michael@0 729 * The URI that was deleted.
michael@0 730 * @param aGUID
michael@0 731 * The unique ID associated with the page.
michael@0 732 * @param aReason
michael@0 733 * Indicates the reason for the removal. see REASON_* constants.
michael@0 734 */
michael@0 735 void onDeleteURI(in nsIURI aURI,
michael@0 736 in ACString aGUID,
michael@0 737 in unsigned short aReason);
michael@0 738
michael@0 739 /**
michael@0 740 * Notification that all of history is being deleted.
michael@0 741 */
michael@0 742 void onClearHistory();
michael@0 743
michael@0 744 /**
michael@0 745 * onPageChanged attribute indicating that favicon has been updated.
michael@0 746 * aNewValue parameter will be set to the new favicon URI string.
michael@0 747 */
michael@0 748 const unsigned long ATTRIBUTE_FAVICON = 3;
michael@0 749
michael@0 750 /**
michael@0 751 * An attribute of this page changed.
michael@0 752 *
michael@0 753 * @param aURI
michael@0 754 * The URI of the page on which an attribute changed.
michael@0 755 * @param aChangedAttribute
michael@0 756 * The attribute whose value changed. See ATTRIBUTE_* constants.
michael@0 757 * @param aNewValue
michael@0 758 * The attribute's new value.
michael@0 759 * @param aGUID
michael@0 760 * The unique ID associated with the page.
michael@0 761 */
michael@0 762 void onPageChanged(in nsIURI aURI,
michael@0 763 in unsigned long aChangedAttribute,
michael@0 764 in AString aNewValue,
michael@0 765 in ACString aGUID);
michael@0 766
michael@0 767 /**
michael@0 768 * Called when some visits of an history entry are expired.
michael@0 769 *
michael@0 770 * @param aURI
michael@0 771 * The page whose visits have been expired.
michael@0 772 * @param aVisitTime
michael@0 773 * The largest visit time in microseconds that has been expired. We
michael@0 774 * guarantee that we don't have any visit older than this date.
michael@0 775 * @param aGUID
michael@0 776 * The unique ID associated with the page.
michael@0 777 *
michael@0 778 * @note: when all visits for a page are expired and also the full page entry
michael@0 779 * is expired, you will only get an onDeleteURI notification. If a
michael@0 780 * page entry is removed, then you can be sure that we don't have
michael@0 781 * anymore visits for it.
michael@0 782 * @param aReason
michael@0 783 * Indicates the reason for the removal. see REASON_* constants.
michael@0 784 * @param aTransitionType
michael@0 785 * If it's a valid TRANSITION_* value, all visits of the specified type
michael@0 786 * have been removed.
michael@0 787 */
michael@0 788 void onDeleteVisits(in nsIURI aURI,
michael@0 789 in PRTime aVisitTime,
michael@0 790 in ACString aGUID,
michael@0 791 in unsigned short aReason,
michael@0 792 in unsigned long aTransitionType);
michael@0 793 };
michael@0 794
michael@0 795
michael@0 796 /**
michael@0 797 * This object encapsulates all the query parameters you're likely to need
michael@0 798 * when building up history UI. All parameters are ANDed together.
michael@0 799 *
michael@0 800 * This is not intended to be a super-general query mechanism. This was designed
michael@0 801 * so that most queries can be done in only one SQL query. This is important
michael@0 802 * because, if the user has their profile on a networked drive, query latency
michael@0 803 * can be non-negligible.
michael@0 804 */
michael@0 805
michael@0 806 [scriptable, uuid(dc87ae79-22f1-4dcf-975b-852b01d210cb)]
michael@0 807 interface nsINavHistoryQuery : nsISupports
michael@0 808 {
michael@0 809 /**
michael@0 810 * Time range for results (INCLUSIVE). The *TimeReference is one of the
michael@0 811 * constants TIME_RELATIVE_* which indicates how to interpret the
michael@0 812 * corresponding time value.
michael@0 813 * TIME_RELATIVE_EPOCH (default):
michael@0 814 * The time is relative to Jan 1 1970 GMT, (this is a normal PRTime)
michael@0 815 * TIME_RELATIVE_TODAY:
michael@0 816 * The time is relative to this morning at midnight. Normally used for
michael@0 817 * queries relative to today. For example, a "past week" query would be
michael@0 818 * today-6 days -> today+1 day
michael@0 819 * TIME_RELATIVE_NOW:
michael@0 820 * The time is relative to right now.
michael@0 821 *
michael@0 822 * Note: PRTime is in MICROseconds since 1 Jan 1970. Javascript date objects
michael@0 823 * are expressed in MILLIseconds since 1 Jan 1970.
michael@0 824 *
michael@0 825 * As a special case, a 0 time relative to TIME_RELATIVE_EPOCH indicates that
michael@0 826 * the time is not part of the query. This is the default, so an empty query
michael@0 827 * will match any time. The has* functions return whether the corresponding
michael@0 828 * time is considered.
michael@0 829 *
michael@0 830 * You can read absolute*Time to get the time value that the currently loaded
michael@0 831 * reference points + offset resolve to.
michael@0 832 */
michael@0 833 const unsigned long TIME_RELATIVE_EPOCH = 0;
michael@0 834 const unsigned long TIME_RELATIVE_TODAY = 1;
michael@0 835 const unsigned long TIME_RELATIVE_NOW = 2;
michael@0 836
michael@0 837 attribute PRTime beginTime;
michael@0 838 attribute unsigned long beginTimeReference;
michael@0 839 readonly attribute boolean hasBeginTime;
michael@0 840 readonly attribute PRTime absoluteBeginTime;
michael@0 841
michael@0 842 attribute PRTime endTime;
michael@0 843 attribute unsigned long endTimeReference;
michael@0 844 readonly attribute boolean hasEndTime;
michael@0 845 readonly attribute PRTime absoluteEndTime;
michael@0 846
michael@0 847 /**
michael@0 848 * Text search terms.
michael@0 849 */
michael@0 850 attribute AString searchTerms;
michael@0 851 readonly attribute boolean hasSearchTerms;
michael@0 852
michael@0 853 /**
michael@0 854 * Set lower or upper limits for how many times an item has been
michael@0 855 * visited. The default is -1, and in that case all items are
michael@0 856 * matched regardless of their visit count.
michael@0 857 */
michael@0 858 attribute long minVisits;
michael@0 859 attribute long maxVisits;
michael@0 860
michael@0 861 /**
michael@0 862 * When the set of transitions is nonempty, results are limited to pages which
michael@0 863 * have at least one visit for each of the transition types.
michael@0 864 * @note: For searching on more than one transition this can be very slow.
michael@0 865 *
michael@0 866 * Limit results to the specified list of transition types.
michael@0 867 */
michael@0 868 void setTransitions([const,array, size_is(count)] in unsigned long transitions,
michael@0 869 in unsigned long count);
michael@0 870
michael@0 871 /**
michael@0 872 * Get the transitions set for this query.
michael@0 873 */
michael@0 874 void getTransitions([optional] out unsigned long count,
michael@0 875 [retval,array,size_is(count)] out unsigned long transitions);
michael@0 876
michael@0 877 /**
michael@0 878 * Get the count of the set query transitions.
michael@0 879 */
michael@0 880 readonly attribute unsigned long transitionCount;
michael@0 881
michael@0 882 /**
michael@0 883 * When set, returns only bookmarked items, when unset, returns anything. Setting this
michael@0 884 * is equivalent to listing all bookmark folders in the 'folders' parameter.
michael@0 885 */
michael@0 886 attribute boolean onlyBookmarked;
michael@0 887
michael@0 888 /**
michael@0 889 * This controls the meaning of 'domain', and whether it is an exact match
michael@0 890 * 'domainIsHost' = true, or hierarchical (= false).
michael@0 891 */
michael@0 892 attribute boolean domainIsHost;
michael@0 893
michael@0 894 /**
michael@0 895 * This is the host or domain name (controlled by domainIsHost). When
michael@0 896 * domainIsHost, domain only does exact matching on host names. Otherwise,
michael@0 897 * it will return anything whose host name ends in 'domain'.
michael@0 898 *
michael@0 899 * This one is a little different than most. Setting it to an empty string
michael@0 900 * is a real query and will match any URI that has no host name (local files
michael@0 901 * and such). Set this to NULL (in C++ use SetIsVoid) if you don't want
michael@0 902 * domain matching.
michael@0 903 */
michael@0 904 attribute AUTF8String domain;
michael@0 905 readonly attribute boolean hasDomain;
michael@0 906
michael@0 907 /**
michael@0 908 * Controls the interpretation of 'uri'. When unset (default), the URI will
michael@0 909 * request an exact match of the specified URI. When set, any history entry
michael@0 910 * beginning in 'uri' will match. For example "http://bar.com/foo" will match
michael@0 911 * "http://bar.com/foo" as well as "http://bar.com/foo/baz.gif".
michael@0 912 */
michael@0 913 attribute boolean uriIsPrefix;
michael@0 914
michael@0 915 /**
michael@0 916 * This is a URI to match, to, for example, find out every time you visited
michael@0 917 * a given URI. Use uriIsPrefix to control whether this is an exact match.
michael@0 918 */
michael@0 919 attribute nsIURI uri;
michael@0 920 readonly attribute boolean hasUri;
michael@0 921
michael@0 922 /**
michael@0 923 * Test for existence or non-existence of a given annotation. We don't
michael@0 924 * currently support >1 annotation name per query. If 'annotationIsNot' is
michael@0 925 * true, we test for the non-existence of the specified annotation.
michael@0 926 *
michael@0 927 * Testing for not annotation will do the same thing as a normal query and
michael@0 928 * remove everything that doesn't have that annotation. Asking for things
michael@0 929 * that DO have a given annotation is a little different. It also includes
michael@0 930 * things that have never been visited. This allows place queries to be
michael@0 931 * returned as well as anything else that may have been tagged with an
michael@0 932 * annotation. This will only work for RESULTS_AS_URI since there will be
michael@0 933 * no visits for these items.
michael@0 934 */
michael@0 935 attribute boolean annotationIsNot;
michael@0 936 attribute AUTF8String annotation;
michael@0 937 readonly attribute boolean hasAnnotation;
michael@0 938
michael@0 939 /**
michael@0 940 * Limit results to items that are tagged with all of the given tags. This
michael@0 941 * attribute must be set to an array of strings. When called as a getter it
michael@0 942 * will return an array of strings sorted ascending in lexicographical order.
michael@0 943 * The array may be empty in either case. Duplicate tags may be specified
michael@0 944 * when setting the attribute, but the getter returns only unique tags.
michael@0 945 *
michael@0 946 * To search for items that are tagged with any given tags rather than all,
michael@0 947 * multiple queries may be passed to nsINavHistoryService.executeQueries().
michael@0 948 */
michael@0 949 attribute nsIVariant tags;
michael@0 950
michael@0 951 /**
michael@0 952 * If 'tagsAreNot' is true, the results are instead limited to items that
michael@0 953 * are not tagged with any of the given tags. This attribute is used in
michael@0 954 * conjunction with the 'tags' attribute.
michael@0 955 */
michael@0 956 attribute boolean tagsAreNot;
michael@0 957
michael@0 958 /**
michael@0 959 * Limit results to items that are in all of the given folders.
michael@0 960 */
michael@0 961 void getFolders([optional] out unsigned long count,
michael@0 962 [retval,array,size_is(count)] out long long folders);
michael@0 963 readonly attribute unsigned long folderCount;
michael@0 964
michael@0 965 /**
michael@0 966 * For the special result type RESULTS_AS_TAG_CONTENTS we can define only
michael@0 967 * one folder that must be a tag folder. This is not recursive so results
michael@0 968 * will be returned from the first level of that folder.
michael@0 969 */
michael@0 970 void setFolders([const,array, size_is(folderCount)] in long long folders,
michael@0 971 in unsigned long folderCount);
michael@0 972
michael@0 973 /**
michael@0 974 * Creates a new query item with the same parameters of this one.
michael@0 975 */
michael@0 976 nsINavHistoryQuery clone();
michael@0 977 };
michael@0 978
michael@0 979 /**
michael@0 980 * This object represents the global options for executing a query.
michael@0 981 */
michael@0 982 [scriptable, uuid(8198dfa7-8061-4766-95cb-fa86b3c00a47)]
michael@0 983 interface nsINavHistoryQueryOptions : nsISupports
michael@0 984 {
michael@0 985 /**
michael@0 986 * You can ask for the results to be pre-sorted. Since the DB has indices
michael@0 987 * of many items, it can produce sorted results almost for free. These should
michael@0 988 * be self-explanatory.
michael@0 989 *
michael@0 990 * Note: re-sorting is slower, as is sorting by title or when you have a
michael@0 991 * host name.
michael@0 992 *
michael@0 993 * For bookmark items, SORT_BY_NONE means sort by the natural bookmark order.
michael@0 994 */
michael@0 995 const unsigned short SORT_BY_NONE = 0;
michael@0 996 const unsigned short SORT_BY_TITLE_ASCENDING = 1;
michael@0 997 const unsigned short SORT_BY_TITLE_DESCENDING = 2;
michael@0 998 const unsigned short SORT_BY_DATE_ASCENDING = 3;
michael@0 999 const unsigned short SORT_BY_DATE_DESCENDING = 4;
michael@0 1000 const unsigned short SORT_BY_URI_ASCENDING = 5;
michael@0 1001 const unsigned short SORT_BY_URI_DESCENDING = 6;
michael@0 1002 const unsigned short SORT_BY_VISITCOUNT_ASCENDING = 7;
michael@0 1003 const unsigned short SORT_BY_VISITCOUNT_DESCENDING = 8;
michael@0 1004 const unsigned short SORT_BY_KEYWORD_ASCENDING = 9;
michael@0 1005 const unsigned short SORT_BY_KEYWORD_DESCENDING = 10;
michael@0 1006 const unsigned short SORT_BY_DATEADDED_ASCENDING = 11;
michael@0 1007 const unsigned short SORT_BY_DATEADDED_DESCENDING = 12;
michael@0 1008 const unsigned short SORT_BY_LASTMODIFIED_ASCENDING = 13;
michael@0 1009 const unsigned short SORT_BY_LASTMODIFIED_DESCENDING = 14;
michael@0 1010 const unsigned short SORT_BY_TAGS_ASCENDING = 17;
michael@0 1011 const unsigned short SORT_BY_TAGS_DESCENDING = 18;
michael@0 1012 const unsigned short SORT_BY_ANNOTATION_ASCENDING = 19;
michael@0 1013 const unsigned short SORT_BY_ANNOTATION_DESCENDING = 20;
michael@0 1014 const unsigned short SORT_BY_FRECENCY_ASCENDING = 21;
michael@0 1015 const unsigned short SORT_BY_FRECENCY_DESCENDING = 22;
michael@0 1016
michael@0 1017 /**
michael@0 1018 * "URI" results, one for each URI visited in the range. Individual result
michael@0 1019 * nodes will be of type "URI".
michael@0 1020 */
michael@0 1021 const unsigned short RESULTS_AS_URI = 0;
michael@0 1022
michael@0 1023 /**
michael@0 1024 * "Visit" results, with one for each time a page was visited (this will
michael@0 1025 * often give you multiple results for one URI). Individual result nodes will
michael@0 1026 * have type "Visit"
michael@0 1027 *
michael@0 1028 * @note This result type is only supported by QUERY_TYPE_HISTORY.
michael@0 1029 */
michael@0 1030 const unsigned short RESULTS_AS_VISIT = 1;
michael@0 1031
michael@0 1032 /**
michael@0 1033 * This is identical to RESULT_TYPE_VISIT except that individual result nodes
michael@0 1034 * will have type "FullVisit". This is used for the attributes that are not
michael@0 1035 * commonly accessed to save space in the common case (the lists can be very
michael@0 1036 * long).
michael@0 1037 *
michael@0 1038 * @note Not yet implemented. See bug 409662.
michael@0 1039 * @note This result type is only supported by QUERY_TYPE_HISTORY.
michael@0 1040 */
michael@0 1041 const unsigned short RESULTS_AS_FULL_VISIT = 2;
michael@0 1042
michael@0 1043 /**
michael@0 1044 * This returns query nodes for each predefined date range where we
michael@0 1045 * had visits. The node contains information how to load its content:
michael@0 1046 * - visits for the given date range will be loaded.
michael@0 1047 *
michael@0 1048 * @note This result type is only supported by QUERY_TYPE_HISTORY.
michael@0 1049 */
michael@0 1050 const unsigned short RESULTS_AS_DATE_QUERY = 3;
michael@0 1051
michael@0 1052 /**
michael@0 1053 * This returns nsINavHistoryQueryResultNode nodes for each site where we
michael@0 1054 * have visits. The node contains information how to load its content:
michael@0 1055 * - last visit for each url in the given host will be loaded.
michael@0 1056 *
michael@0 1057 * @note This result type is only supported by QUERY_TYPE_HISTORY.
michael@0 1058 */
michael@0 1059 const unsigned short RESULTS_AS_SITE_QUERY = 4;
michael@0 1060
michael@0 1061 /**
michael@0 1062 * This returns nsINavHistoryQueryResultNode nodes for each day where we
michael@0 1063 * have visits. The node contains information how to load its content:
michael@0 1064 * - list of hosts visited in the given period will be loaded.
michael@0 1065 *
michael@0 1066 * @note This result type is only supported by QUERY_TYPE_HISTORY.
michael@0 1067 */
michael@0 1068 const unsigned short RESULTS_AS_DATE_SITE_QUERY = 5;
michael@0 1069
michael@0 1070 /**
michael@0 1071 * This returns nsINavHistoryQueryResultNode nodes for each tag.
michael@0 1072 * The node contains information how to load its content:
michael@0 1073 * - list of bookmarks with the given tag will be loaded.
michael@0 1074 *
michael@0 1075 * @note Setting this resultType will force queryType to QUERY_TYPE_BOOKMARKS.
michael@0 1076 */
michael@0 1077 const unsigned short RESULTS_AS_TAG_QUERY = 6;
michael@0 1078
michael@0 1079 /**
michael@0 1080 * This is a container with an URI result type that contains the last
michael@0 1081 * modified bookmarks for the given tag.
michael@0 1082 * Tag folder id must be defined in the query.
michael@0 1083 *
michael@0 1084 * @note Setting this resultType will force queryType to QUERY_TYPE_BOOKMARKS.
michael@0 1085 */
michael@0 1086 const unsigned short RESULTS_AS_TAG_CONTENTS = 7;
michael@0 1087
michael@0 1088 /**
michael@0 1089 * The sorting mode to be used for this query.
michael@0 1090 * mode is one of SORT_BY_*
michael@0 1091 */
michael@0 1092 attribute unsigned short sortingMode;
michael@0 1093
michael@0 1094 /**
michael@0 1095 * The annotation to use in SORT_BY_ANNOTATION_* sorting modes.
michael@0 1096 */
michael@0 1097 attribute AUTF8String sortingAnnotation;
michael@0 1098
michael@0 1099 /**
michael@0 1100 * Sets the result type. One of RESULT_TYPE_* which includes how URIs are
michael@0 1101 * represented.
michael@0 1102 */
michael@0 1103 attribute unsigned short resultType;
michael@0 1104
michael@0 1105 /**
michael@0 1106 * This option excludes all URIs and separators from a bookmarks query.
michael@0 1107 * This would be used if you just wanted a list of bookmark folders and
michael@0 1108 * queries (such as the left pane of the places page).
michael@0 1109 * Defaults to false.
michael@0 1110 */
michael@0 1111 attribute boolean excludeItems;
michael@0 1112
michael@0 1113 /**
michael@0 1114 * Set to true to exclude queries ("place:" URIs) from the query results.
michael@0 1115 * Simple folder queries (bookmark folder symlinks) will still be included.
michael@0 1116 * Defaults to false.
michael@0 1117 */
michael@0 1118 attribute boolean excludeQueries;
michael@0 1119
michael@0 1120 /**
michael@0 1121 * Set to true to exclude read-only folders from the query results. This is
michael@0 1122 * designed for cases where you want to give the user the option of filing
michael@0 1123 * something into a list of folders. It only affects cases where the actual
michael@0 1124 * folder result node would appear in its parent folder and filters it out.
michael@0 1125 * It doesn't affect the query at all, and doesn't affect more complex
michael@0 1126 * queries (such as "folders with annotation X").
michael@0 1127 */
michael@0 1128 attribute boolean excludeReadOnlyFolders;
michael@0 1129
michael@0 1130 /**
michael@0 1131 * When set, allows items with "place:" URIs to appear as containers,
michael@0 1132 * with the container's contents filled in from the stored query.
michael@0 1133 * If not set, these will appear as normal items. Doesn't do anything if
michael@0 1134 * excludeQueries is set. Defaults to false.
michael@0 1135 *
michael@0 1136 * Note that this has no effect on folder links, which are place: URIs
michael@0 1137 * returned by nsINavBookmarkService.GetFolderURI. These are always expanded
michael@0 1138 * and will appear as bookmark folders.
michael@0 1139 */
michael@0 1140 attribute boolean expandQueries;
michael@0 1141
michael@0 1142 /**
michael@0 1143 * Some pages in history are marked "hidden" and thus don't appear by default
michael@0 1144 * in queries. These include automatic framed visits and redirects. Setting
michael@0 1145 * this attribute will return all pages, even hidden ones. Does nothing for
michael@0 1146 * bookmark queries. Defaults to false.
michael@0 1147 */
michael@0 1148 attribute boolean includeHidden;
michael@0 1149
michael@0 1150 /**
michael@0 1151 * This is the maximum number of results that you want. The query is exeucted,
michael@0 1152 * the results are sorted, and then the top 'maxResults' results are taken
michael@0 1153 * and returned. Set to 0 (the default) to get all results.
michael@0 1154 *
michael@0 1155 * THIS DOES NOT WORK IN CONJUNCTION WITH SORTING BY TITLE. This is because
michael@0 1156 * sorting by title requires us to sort after using locale-sensetive sorting
michael@0 1157 * (as opposed to letting the database do it for us).
michael@0 1158 *
michael@0 1159 * Instead, we get the result ordered by date, pick the maxResult most recent
michael@0 1160 * ones, and THEN sort by title.
michael@0 1161 */
michael@0 1162 attribute unsigned long maxResults;
michael@0 1163
michael@0 1164 const unsigned short QUERY_TYPE_HISTORY = 0;
michael@0 1165 const unsigned short QUERY_TYPE_BOOKMARKS = 1;
michael@0 1166 /* Unified queries are not yet implemented. See bug 378798 */
michael@0 1167 const unsigned short QUERY_TYPE_UNIFIED = 2;
michael@0 1168
michael@0 1169 /**
michael@0 1170 * The type of search to use when querying the DB; This attribute is only
michael@0 1171 * honored by query nodes. It is silently ignored for simple folder queries.
michael@0 1172 */
michael@0 1173 attribute unsigned short queryType;
michael@0 1174
michael@0 1175 /**
michael@0 1176 * When this is true, the root container node generated by these options and
michael@0 1177 * its descendant containers will be opened asynchronously if they support it.
michael@0 1178 * This is false by default.
michael@0 1179 *
michael@0 1180 * @note Currently only bookmark folder containers support being opened
michael@0 1181 * asynchronously.
michael@0 1182 */
michael@0 1183 attribute boolean asyncEnabled;
michael@0 1184
michael@0 1185 /**
michael@0 1186 * Creates a new options item with the same parameters of this one.
michael@0 1187 */
michael@0 1188 nsINavHistoryQueryOptions clone();
michael@0 1189 };
michael@0 1190
michael@0 1191 [scriptable, uuid(baebc597-9daf-4103-a325-e41ef9e7608a)]
michael@0 1192 interface nsINavHistoryService : nsISupports
michael@0 1193 {
michael@0 1194 /**
michael@0 1195 * System Notifications:
michael@0 1196 *
michael@0 1197 * places-init-complete - Sent once the History service is completely
michael@0 1198 * initialized successfully.
michael@0 1199 * places-database-locked - Sent if initialization of the History service
michael@0 1200 * failed due to the inability to open the places.sqlite
michael@0 1201 * for access reasons.
michael@0 1202 */
michael@0 1203
michael@0 1204 /**
michael@0 1205 * This transition type means the user followed a link and got a new toplevel
michael@0 1206 * window.
michael@0 1207 */
michael@0 1208 const unsigned long TRANSITION_LINK = 1;
michael@0 1209
michael@0 1210 /**
michael@0 1211 * This transition type means that the user typed the page's URL in the
michael@0 1212 * URL bar or selected it from URL bar autocomplete results, clicked on
michael@0 1213 * it from a history query (from the History sidebar, History menu,
michael@0 1214 * or history query in the personal toolbar or Places organizer.
michael@0 1215 */
michael@0 1216 const unsigned long TRANSITION_TYPED = 2;
michael@0 1217
michael@0 1218 /**
michael@0 1219 * This transition is set when the user followed a bookmark to get to the
michael@0 1220 * page.
michael@0 1221 */
michael@0 1222 const unsigned long TRANSITION_BOOKMARK = 3;
michael@0 1223
michael@0 1224 /**
michael@0 1225 * This transition type is set when some inner content is loaded. This is
michael@0 1226 * true of all images on a page, and the contents of the iframe. It is also
michael@0 1227 * true of any content in a frame if the user did not explicitly follow
michael@0 1228 * a link to get there.
michael@0 1229 */
michael@0 1230 const unsigned long TRANSITION_EMBED = 4;
michael@0 1231
michael@0 1232 /**
michael@0 1233 * Set when the transition was a permanent redirect.
michael@0 1234 */
michael@0 1235 const unsigned long TRANSITION_REDIRECT_PERMANENT = 5;
michael@0 1236
michael@0 1237 /**
michael@0 1238 * Set when the transition was a temporary redirect.
michael@0 1239 */
michael@0 1240 const unsigned long TRANSITION_REDIRECT_TEMPORARY = 6;
michael@0 1241
michael@0 1242 /**
michael@0 1243 * Set when the transition is a download.
michael@0 1244 */
michael@0 1245 const unsigned long TRANSITION_DOWNLOAD = 7;
michael@0 1246
michael@0 1247 /**
michael@0 1248 * This transition type means the user followed a link and got a visit in
michael@0 1249 * a frame.
michael@0 1250 */
michael@0 1251 const unsigned long TRANSITION_FRAMED_LINK = 8;
michael@0 1252
michael@0 1253 /**
michael@0 1254 * Set when database is coherent
michael@0 1255 */
michael@0 1256 const unsigned short DATABASE_STATUS_OK = 0;
michael@0 1257
michael@0 1258 /**
michael@0 1259 * Set when database did not exist and we created a new one
michael@0 1260 */
michael@0 1261 const unsigned short DATABASE_STATUS_CREATE = 1;
michael@0 1262
michael@0 1263 /**
michael@0 1264 * Set when database was corrupt and we replaced it
michael@0 1265 */
michael@0 1266 const unsigned short DATABASE_STATUS_CORRUPT = 2;
michael@0 1267
michael@0 1268 /**
michael@0 1269 * Set when database schema has been upgraded
michael@0 1270 */
michael@0 1271 const unsigned short DATABASE_STATUS_UPGRADED = 3;
michael@0 1272
michael@0 1273 /**
michael@0 1274 * Returns the current database status
michael@0 1275 */
michael@0 1276 readonly attribute unsigned short databaseStatus;
michael@0 1277
michael@0 1278 /**
michael@0 1279 * True if there is any history. This can be used in UI to determine whether
michael@0 1280 * the "clear history" button should be enabled or not. This is much better
michael@0 1281 * than using BrowserHistory.count since that can be very slow if there is
michael@0 1282 * a lot of history (it must enumerate each item). This is pretty fast.
michael@0 1283 */
michael@0 1284 readonly attribute boolean hasHistoryEntries;
michael@0 1285
michael@0 1286 /**
michael@0 1287 * Gets the original title of the page.
michael@0 1288 * @deprecated use mozIAsyncHistory.getPlacesInfo instead.
michael@0 1289 */
michael@0 1290 AString getPageTitle(in nsIURI aURI);
michael@0 1291
michael@0 1292 /**
michael@0 1293 * This is just like markPageAsTyped (in nsIBrowserHistory, also implemented
michael@0 1294 * by the history service), but for bookmarks. It declares that the given URI
michael@0 1295 * is being opened as a result of following a bookmark. If this URI is loaded
michael@0 1296 * soon after this message has been received, that transition will be marked
michael@0 1297 * as following a bookmark.
michael@0 1298 */
michael@0 1299 void markPageAsFollowedBookmark(in nsIURI aURI);
michael@0 1300
michael@0 1301 /**
michael@0 1302 * Designates the url as having been explicitly typed in by the user.
michael@0 1303 *
michael@0 1304 * @param aURI
michael@0 1305 * URI of the page to be marked.
michael@0 1306 */
michael@0 1307 void markPageAsTyped(in nsIURI aURI);
michael@0 1308
michael@0 1309 /**
michael@0 1310 * Designates the url as coming from a link explicitly followed by
michael@0 1311 * the user (for example by clicking on it).
michael@0 1312 *
michael@0 1313 * @param aURI
michael@0 1314 * URI of the page to be marked.
michael@0 1315 */
michael@0 1316 void markPageAsFollowedLink(in nsIURI aURI);
michael@0 1317
michael@0 1318 /**
michael@0 1319 * Gets the stored character-set for an URI.
michael@0 1320 *
michael@0 1321 * @param aURI
michael@0 1322 * URI to retrieve character-set for
michael@0 1323 * @return character-set, empty string if not found
michael@0 1324 */
michael@0 1325 AString getCharsetForURI(in nsIURI aURI);
michael@0 1326
michael@0 1327 /**
michael@0 1328 * Sets the character-set for an URI.
michael@0 1329 *
michael@0 1330 * @param aURI
michael@0 1331 * URI to set the character-set for
michael@0 1332 * @param aCharset
michael@0 1333 * character-set to be set
michael@0 1334 */
michael@0 1335 void setCharsetForURI(in nsIURI aURI, in AString aCharset);
michael@0 1336
michael@0 1337 /**
michael@0 1338 * Returns true if this URI would be added to the history. You don't have to
michael@0 1339 * worry about calling this, adding a visit will always check before
michael@0 1340 * actually adding the page. This function is public because some components
michael@0 1341 * may want to check if this page would go in the history (i.e. for
michael@0 1342 * annotations).
michael@0 1343 */
michael@0 1344 boolean canAddURI(in nsIURI aURI);
michael@0 1345
michael@0 1346 /**
michael@0 1347 * This returns a new query object that you can pass to executeQuer[y/ies].
michael@0 1348 * It will be initialized to all empty (so using it will give you all history).
michael@0 1349 */
michael@0 1350 nsINavHistoryQuery getNewQuery();
michael@0 1351
michael@0 1352 /**
michael@0 1353 * This returns a new options object that you can pass to executeQuer[y/ies]
michael@0 1354 * after setting the desired options.
michael@0 1355 */
michael@0 1356 nsINavHistoryQueryOptions getNewQueryOptions();
michael@0 1357
michael@0 1358 /**
michael@0 1359 * Executes a single query.
michael@0 1360 */
michael@0 1361 nsINavHistoryResult executeQuery(in nsINavHistoryQuery aQuery,
michael@0 1362 in nsINavHistoryQueryOptions options);
michael@0 1363
michael@0 1364 /**
michael@0 1365 * Executes an array of queries. All of the query objects are ORed
michael@0 1366 * together. Within a query, all the terms are ANDed together as in
michael@0 1367 * executeQuery. See executeQuery()
michael@0 1368 */
michael@0 1369 nsINavHistoryResult executeQueries(
michael@0 1370 [array,size_is(aQueryCount)] in nsINavHistoryQuery aQueries,
michael@0 1371 in unsigned long aQueryCount,
michael@0 1372 in nsINavHistoryQueryOptions options);
michael@0 1373
michael@0 1374 /**
michael@0 1375 * Converts a query URI-like string to an array of actual query objects for
michael@0 1376 * use to executeQueries(). The output query array may be empty if there is
michael@0 1377 * no information. However, there will always be an options structure returned
michael@0 1378 * (if nothing is defined, it will just have the default values).
michael@0 1379 */
michael@0 1380 void queryStringToQueries(in AUTF8String aQueryString,
michael@0 1381 [array, size_is(aResultCount)] out nsINavHistoryQuery aQueries,
michael@0 1382 out unsigned long aResultCount,
michael@0 1383 out nsINavHistoryQueryOptions options);
michael@0 1384
michael@0 1385 /**
michael@0 1386 * Converts a query into an equivalent string that can be persisted. Inverse
michael@0 1387 * of queryStringToQueries()
michael@0 1388 */
michael@0 1389 AUTF8String queriesToQueryString(
michael@0 1390 [array, size_is(aQueryCount)] in nsINavHistoryQuery aQueries,
michael@0 1391 in unsigned long aQueryCount,
michael@0 1392 in nsINavHistoryQueryOptions options);
michael@0 1393
michael@0 1394 /**
michael@0 1395 * Adds a history observer. If ownsWeak is false, the history service will
michael@0 1396 * keep an owning reference to the observer. If ownsWeak is true, then
michael@0 1397 * aObserver must implement nsISupportsWeakReference, and the history service
michael@0 1398 * will keep a weak reference to the observer.
michael@0 1399 */
michael@0 1400 void addObserver(in nsINavHistoryObserver observer, in boolean ownsWeak);
michael@0 1401
michael@0 1402 /**
michael@0 1403 * Removes a history observer.
michael@0 1404 */
michael@0 1405 void removeObserver(in nsINavHistoryObserver observer);
michael@0 1406
michael@0 1407 /**
michael@0 1408 * Runs the passed callback in batch mode. Use this when a lot of things
michael@0 1409 * are about to change. Calls can be nested, observers will only be
michael@0 1410 * notified when all batches begin/end.
michael@0 1411 *
michael@0 1412 * @param aCallback
michael@0 1413 * nsINavHistoryBatchCallback interface to call.
michael@0 1414 * @param aUserData
michael@0 1415 * Opaque parameter passed to nsINavBookmarksBatchCallback
michael@0 1416 */
michael@0 1417 void runInBatchMode(in nsINavHistoryBatchCallback aCallback,
michael@0 1418 in nsISupports aClosure);
michael@0 1419
michael@0 1420 /**
michael@0 1421 * True if history is disabled. currently,
michael@0 1422 * history is disabled if the places.history.enabled pref is false.
michael@0 1423 */
michael@0 1424 readonly attribute boolean historyDisabled;
michael@0 1425 };
michael@0 1426
michael@0 1427 /**
michael@0 1428 * @see runInBatchMode of nsINavHistoryService/nsINavBookmarksService
michael@0 1429 */
michael@0 1430 [scriptable, uuid(5143f2bb-be0a-4faf-9acb-b0ed3f82952c)]
michael@0 1431 interface nsINavHistoryBatchCallback : nsISupports {
michael@0 1432 void runBatched(in nsISupports aUserData);
michael@0 1433 };

mercurial