1/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2/* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6/** 7 * Using Places services after quit-application is not reliable, so make 8 * sure to do any shutdown work on quit-application, or history 9 * synchronization could fail, losing latest changes. 10 */ 11 12#include "nsISupports.idl" 13 14interface nsIArray; 15interface nsIFile; 16interface nsIObserver; 17interface nsIVariant; 18interface nsIURI; 19 20interface mozIStorageConnection; 21interface mozIStorageStatementCallback; 22interface mozIStoragePendingStatement; 23interface nsIAsyncShutdownClient; 24 25interface nsINavHistoryContainerResultNode; 26interface nsINavHistoryQueryResultNode; 27interface nsINavHistoryQuery; 28interface nsINavHistoryQueryOptions; 29interface nsINavHistoryResult; 30interface nsINavHistoryBatchCallback; 31 32[scriptable, uuid(91d104bb-17ef-404b-9f9a-d9ed8de6824c)] 33interface nsINavHistoryResultNode : nsISupports 34{ 35 /** 36 * Indentifies the parent result node in the result set. This is null for 37 * top level nodes. 38 */ 39 readonly attribute nsINavHistoryContainerResultNode parent; 40 41 /** 42 * The history-result to which this node belongs. 43 */ 44 readonly attribute nsINavHistoryResult parentResult; 45 46 /** 47 * URI of the resource in question. For visits and URLs, this is the URL of 48 * the page. For folders and queries, this is the place: URI of the 49 * corresponding folder or query. This may be empty for other types of 50 * objects like host containers. 51 */ 52 readonly attribute AUTF8String uri; 53 54 /** 55 * Identifies the type of this node. This node can then be QI-ed to the 56 * corresponding specialized result node interface. 57 */ 58 const unsigned long RESULT_TYPE_URI = 0; // nsINavHistoryResultNode 59 60 // Visit nodes are deprecated and unsupported. 61 // This line exists just to avoid reusing the value: 62 // const unsigned long RESULT_TYPE_VISIT = 1; 63 64 // Full visit nodes are deprecated and unsupported. 65 // This line exists just to avoid reusing the value: 66 // const unsigned long RESULT_TYPE_FULL_VISIT = 2; 67 68 // Dynamic containers are deprecated and unsupported. 69 // This const exists just to avoid reusing the value: 70 // const unsigned long RESULT_TYPE_DYNAMIC_CONTAINER = 4; // nsINavHistoryContainerResultNode 71 72 const unsigned long RESULT_TYPE_QUERY = 5; // nsINavHistoryQueryResultNode 73 const unsigned long RESULT_TYPE_FOLDER = 6; // nsINavHistoryQueryResultNode 74 const unsigned long RESULT_TYPE_SEPARATOR = 7; // nsINavHistoryResultNode 75 const unsigned long RESULT_TYPE_FOLDER_SHORTCUT = 9; // nsINavHistoryQueryResultNode 76 readonly attribute unsigned long type; 77 78 /** 79 * Title of the web page, or of the node's query (day, host, folder, etc) 80 */ 81 readonly attribute AUTF8String title; 82 83 /** 84 * Total number of times the URI has ever been accessed. For hosts, this 85 * is the total of the children under it, NOT the total times the host has 86 * been accessed (this would require an additional query, so is not given 87 * by default when most of the time it is never needed). 88 */ 89 readonly attribute unsigned long accessCount; 90 91 /** 92 * This is the time the user accessed the page. 93 * 94 * If this is a visit, it is the exact time that the page visit occurred. 95 * 96 * If this is a URI, it is the most recent time that the URI was visited. 97 * Even if you ask for all URIs for a given date range long ago, this might 98 * contain today's date if the URI was visited today. 99 * 100 * For hosts, or other node types with children, this is the most recent 101 * access time for any of the children. 102 * 103 * For days queries this is the respective endTime - a maximum possible 104 * visit time to fit in the day range. 105 */ 106 readonly attribute PRTime time; 107 108 /** 109 * This URI can be used as an image source URI and will give you the favicon 110 * for the page. It is *not* the URI of the favicon, but rather something 111 * that will resolve to the actual image. 112 * 113 * In most cases, this is an annotation URI that will query the favicon 114 * service. If the entry has no favicon, this is the chrome URI of the 115 * default favicon. If the favicon originally lived in chrome, this will 116 * be the original chrome URI of the icon. 117 */ 118 readonly attribute AUTF8String icon; 119 120 /** 121 * This is the number of levels between this node and the top of the 122 * hierarchy. The members of result.children have indentLevel = 0, their 123 * children have indentLevel = 1, etc. The indent level of the root node is 124 * set to -1. 125 */ 126 readonly attribute long indentLevel; 127 128 /** 129 * When this item is in a bookmark folder (parent is of type folder), this is 130 * the index into that folder of this node. These indices start at 0 and 131 * increase in the order that they appear in the bookmark folder. For items 132 * that are not in a bookmark folder, this value is -1. 133 */ 134 readonly attribute long bookmarkIndex; 135 136 /** 137 * If the node is an item (bookmark, folder or a separator) this value is the 138 * row ID of that bookmark in the database. For other nodes, this value is 139 * set to -1. 140 */ 141 readonly attribute long long itemId; 142 143 /** 144 * If the node is an item (bookmark, folder or a separator) this value is the 145 * time that the item was created. For other nodes, this value is 0. 146 */ 147 readonly attribute PRTime dateAdded; 148 149 /** 150 * If the node is an item (bookmark, folder or a separator) this value is the 151 * time that the item was last modified. For other nodes, this value is 0. 152 * 153 * @note When an item is added lastModified is set to the same value as 154 * dateAdded. 155 */ 156 readonly attribute PRTime lastModified; 157 158 /** 159 * For uri nodes, this is a sorted list of the tags, delimited with commans, 160 * for the uri represented by this node. Otherwise this is an empty string. 161 */ 162 readonly attribute AString tags; 163 164 /** 165 * The unique ID associated with the page. It my return an empty string 166 * if the result node is a non-URI node. 167 */ 168 readonly attribute ACString pageGuid; 169 170 /** 171 * The unique ID associated with the bookmark. It returns an empty string 172 * if the result node is not associated with a bookmark, a folder or a 173 * separator. 174 */ 175 readonly attribute ACString bookmarkGuid; 176 177 /** 178 * The unique ID associated with the history visit. For node types other than 179 * history visit nodes, this value is -1. 180 */ 181 readonly attribute long long visitId; 182 183 /** 184 * The unique ID associated with visit node which was the referrer of this 185 * history visit. For node types other than history visit nodes, or visits 186 * without any known referrer, this value is -1. 187 */ 188 readonly attribute long long fromVisitId; 189 190 /** 191 * The transition type associated with this visit. For node types other than 192 * history visit nodes, this value is 0. 193 */ 194 readonly attribute unsigned long visitType; 195}; 196 197 198/** 199 * Base class for container results. This includes all types of groupings. 200 * Bookmark folders and places queries will be QueryResultNodes which extends 201 * these items. 202 */ 203[scriptable, uuid(3E9CC95F-0D93-45F1-894F-908EEB9866D7)] 204interface nsINavHistoryContainerResultNode : nsINavHistoryResultNode 205{ 206 207 /** 208 * Set this to allow descent into the container. When closed, attempting 209 * to call getChildren or childCount will result in an error. You should 210 * set this to false when you are done reading. 211 * 212 * For HOST and DAY groupings, doing this is free since the children have 213 * been precomputed. For queries and bookmark folders, being open means they 214 * will keep themselves up-to-date by listening for updates and re-querying 215 * as needed. 216 */ 217 attribute boolean containerOpen; 218 219 /** 220 * Indicates whether the container is closed, loading, or opened. Loading 221 * implies that the container has been opened asynchronously and has not yet 222 * fully opened. 223 */ 224 readonly attribute unsigned short state; 225 const unsigned short STATE_CLOSED = 0; 226 const unsigned short STATE_LOADING = 1; 227 const unsigned short STATE_OPENED = 2; 228 229 /** 230 * This indicates whether this node "may" have children, and can be used 231 * when the container is open or closed. When the container is closed, it 232 * will give you an exact answer if the node can easily be populated (for 233 * example, a bookmark folder). If not (for example, a complex history query), 234 * it will return true. When the container is open, it will always be 235 * accurate. It is intended to be used to see if we should draw the "+" next 236 * to a tree item. 237 */ 238 readonly attribute boolean hasChildren; 239 240 /** 241 * This gives you the children of the nodes. It is preferrable to use this 242 * interface over the array one, since it avoids creating an nsIArray object 243 * and the interface is already the correct type. 244 * 245 * @throws NS_ERROR_NOT_AVAILABLE if containerOpen is false. 246 */ 247 readonly attribute unsigned long childCount; 248 nsINavHistoryResultNode getChild(in unsigned long aIndex); 249 250 /** 251 * Get the index of a direct child in this container. 252 * 253 * @param aNode 254 * a result node. 255 * 256 * @return aNode's index in this container. 257 * @throws NS_ERROR_NOT_AVAILABLE if containerOpen is false. 258 * @throws NS_ERROR_INVALID_ARG if aNode isn't a direct child of this 259 * container. 260 */ 261 unsigned long getChildIndex(in nsINavHistoryResultNode aNode); 262}; 263 264 265/** 266 * Used for places queries and as a base for bookmark folders. 267 * 268 * Note that if you request places to *not* be expanded in the options that 269 * generated this node, this item will report it has no children and never try 270 * to populate itself. 271 */ 272[scriptable, uuid(62817759-4FEE-44A3-B58C-3E2F5AFC9D0A)] 273interface nsINavHistoryQueryResultNode : nsINavHistoryContainerResultNode 274{ 275 /** 276 * Get the query which builds this node's children. 277 * Only valid for RESULT_TYPE_QUERY nodes. 278 */ 279 readonly attribute nsINavHistoryQuery query; 280 281 /** 282 * Get the options which group this node's children. 283 * Only valid for RESULT_TYPE_QUERY nodes. 284 */ 285 readonly attribute nsINavHistoryQueryOptions queryOptions; 286 287 /** 288 * For both simple folder queries and folder shortcut queries, this is set to 289 * the concrete itemId of the folder (i.e. for folder shortcuts it's the 290 * target folder id). Otherwise, this is set to -1. 291 */ 292 readonly attribute long long folderItemId; 293 294 /** 295 * For both simple folder queries and folder shortcut queries, this is set to 296 * the concrete guid of the folder (i.e. for folder shortcuts it's the target 297 * folder guid). Otherwise, this is set to an empty string. 298 */ 299 readonly attribute ACString targetFolderGuid; 300}; 301 302 303/** 304 * Allows clients to observe what is happening to a result as it updates itself 305 * according to history and bookmark system events. Register this observer on a 306 * result using nsINavHistoryResult::addObserver. 307 */ 308[scriptable, uuid(f62d8b6b-3c4e-4a9f-a897-db605d0b7a0f)] 309interface nsINavHistoryResultObserver : nsISupports 310{ 311 /** 312 * Whether the observer is interested into history details changes. 313 * Those include visits additions and removals. If the observer doesn't 314 * provide this attribute, it will default to true. 315 * In practice, the observer won't receive nodeHistoryDetailsChanged. 316 * Note: this is only read when the observer is added, it cannot be changed 317 * dynamically. 318 */ 319 readonly attribute boolean observeHistoryDetails; 320 321 /** 322 * Called when 'aItem' is inserted into 'aParent' at index 'aNewIndex'. 323 * The item previously at index (if any) and everything below it will have 324 * been shifted down by one. The item may be a container or a leaf. 325 */ 326 void nodeInserted(in nsINavHistoryContainerResultNode aParent, 327 in nsINavHistoryResultNode aNode, 328 in unsigned long aNewIndex); 329 330 /** 331 * Called whan 'aItem' is removed from 'aParent' at 'aOldIndex'. The item 332 * may be a container or a leaf. This function will be called after the item 333 * has been removed from its parent list, but before anything else (including 334 * NULLing out the item's parent) has happened. 335 */ 336 void nodeRemoved(in nsINavHistoryContainerResultNode aParent, 337 in nsINavHistoryResultNode aItem, 338 in unsigned long aOldIndex); 339 340 /** 341 * Called whan 'aItem' is moved from 'aOldParent' at 'aOldIndex' to 342 * aNewParent at aNewIndex. The item may be a container or a leaf. 343 * 344 * XXX: at the moment, this method is called only when an item is moved 345 * within the same container. When an item is moved between containers, 346 * a new node is created for the item, and the itemRemoved/itemAdded methods 347 * are used. 348 */ 349 void nodeMoved(in nsINavHistoryResultNode aNode, 350 in nsINavHistoryContainerResultNode aOldParent, 351 in unsigned long aOldIndex, 352 in nsINavHistoryContainerResultNode aNewParent, 353 in unsigned long aNewIndex); 354 355 /** 356 * Called right after aNode's title has changed. 357 * 358 * @param aNode 359 * a result node 360 * @param aNewTitle 361 * the new title 362 */ 363 void nodeTitleChanged(in nsINavHistoryResultNode aNode, 364 in AUTF8String aNewTitle); 365 366 /** 367 * Called right after aNode's uri property has changed. 368 * 369 * @param aNode 370 * a result node 371 * @param aNewURI 372 * the old uri 373 */ 374 void nodeURIChanged(in nsINavHistoryResultNode aNode, 375 in AUTF8String aOldURI); 376 377 /** 378 * Called right after aNode's icon property has changed. 379 * 380 * @param aNode 381 * a result node 382 * 383 * @note: The new icon is accessible through aNode.icon. 384 */ 385 void nodeIconChanged(in nsINavHistoryResultNode aNode); 386 387 /** 388 * Called right after aNode's time property or accessCount property, or both, 389 * have changed. 390 * 391 * @param aNode 392 * a uri result node 393 * @param aOldVisitDate 394 * the old visit date 395 * @param aOldAccessCount 396 * the old access-count 397 */ 398 void nodeHistoryDetailsChanged(in nsINavHistoryResultNode aNode, 399 in PRTime aOldVisitDate, 400 in unsigned long aOldAccessCount); 401 402 /** 403 * Called when the tags set on the uri represented by aNode have changed. 404 * 405 * @param aNode 406 * a uri result node 407 * 408 * @note: The new tags list is accessible through aNode.tags. 409 */ 410 void nodeTagsChanged(in nsINavHistoryResultNode aNode); 411 412 /** 413 * Called right after the aNode's keyword property has changed. 414 * 415 * @param aNode 416 * a uri result node 417 * @param aNewKeyword 418 * the new keyword 419 */ 420 void nodeKeywordChanged(in nsINavHistoryResultNode aNode, 421 in AUTF8String aNewKeyword); 422 423 /** 424 * Called right after aNode's dateAdded property has changed. 425 * 426 * @param aNode 427 * a result node 428 * @param aNewValue 429 * the new value of the dateAdded property 430 */ 431 void nodeDateAddedChanged(in nsINavHistoryResultNode aNode, 432 in PRTime aNewValue); 433 434 /** 435 * Called right after aNode's dateModified property has changed. 436 * 437 * @param aNode 438 * a result node 439 * @param aNewValue 440 * the new value of the dateModified property 441 */ 442 void nodeLastModifiedChanged(in nsINavHistoryResultNode aNode, 443 in PRTime aNewValue); 444 445 /** 446 * Called after a container changes state. 447 * 448 * @param aContainerNode 449 * The container that has changed state. 450 * @param aOldState 451 * The state that aContainerNode has transitioned out of. 452 * @param aNewState 453 * The state that aContainerNode has transitioned into. 454 */ 455 void containerStateChanged(in nsINavHistoryContainerResultNode aContainerNode, 456 in unsigned long aOldState, 457 in unsigned long aNewState); 458 459 /** 460 * Called when something significant has happened within the container. The 461 * contents of the container should be re-built. 462 * 463 * @param aContainerNode 464 * the container node to invalidate 465 */ 466 void invalidateContainer(in nsINavHistoryContainerResultNode aContainerNode); 467 468 /** 469 * This is called to indicate to the UI that the sort has changed to the 470 * given mode. For trees, for example, this would update the column headers 471 * to reflect the sorting. For many other types of views, this won't be 472 * applicable. 473 * 474 * @param sortingMode One of nsINavHistoryQueryOptions.SORT_BY_* that 475 * indicates the new sorting mode. 476 * 477 * This only is expected to update the sorting UI. invalidateAll() will also 478 * get called if the sorting changes to update everything. 479 */ 480 void sortingChanged(in unsigned short sortingMode); 481 482 /** 483 * This is called to indicate that a batch operation is about to start or end. 484 * The observer could want to disable some events or updates during batches, 485 * since multiple operations are packed in a short time. 486 * For example treeviews could temporarily suppress select notifications. 487 * 488 * @param aToggleMode 489 * true if a batch is starting, false if it's ending. 490 */ 491 void batching(in boolean aToggleMode); 492 493 /** 494 * Called by the result when this observer is added. 495 */ 496 attribute nsINavHistoryResult result; 497}; 498 499 500/** 501 * The result of a history/bookmark query. 502 */ 503[scriptable, uuid(c2229ce3-2159-4001-859c-7013c52f7619)] 504interface nsINavHistoryResult : nsISupports 505{ 506 /** 507 * Sorts all nodes recursively by the given parameter, one of 508 * nsINavHistoryQueryOptions.SORT_BY_* This will update the corresponding 509 * options for this result, so that re-using the current options/queries will 510 * always give you the current view. 511 */ 512 attribute unsigned short sortingMode; 513 514 /** 515 * Whether or not notifications on result changes are suppressed. 516 * Initially set to false. 517 * 518 * Use this to avoid flickering and to improve performance when you 519 * do temporary changes to the result structure (e.g. when searching for a 520 * node recursively). 521 */ 522 attribute boolean suppressNotifications; 523 524 /** 525 * Adds an observer for changes done in the result. 526 * 527 * @param aObserver 528 * a result observer. 529 * @param aOwnsWeak 530 * If false, the result will keep an owning reference to the observer, 531 * which must be removed using removeObserver. 532 * If true, the result will keep a weak reference to the observer, which 533 * must implement nsISupportsWeakReference. 534 * 535 * @see nsINavHistoryResultObserver 536 */ 537 void addObserver(in nsINavHistoryResultObserver aObserver, 538 [optional] in boolean aOwnsWeak); 539 540 /** 541 * Removes an observer that was added by addObserver. 542 * 543 * @param aObserver 544 * a result observer that was added by addObserver. 545 */ 546 void removeObserver(in nsINavHistoryResultObserver aObserver); 547 548 /** 549 * This is the root of the results. Remember that you need to open all 550 * containers for their contents to be valid. 551 * 552 * When a result goes out of scope it will continue to observe changes till 553 * it is cycle collected. While the result waits to be collected it will stay 554 * in memory, and continue to update itself, potentially causing unwanted 555 * additional work. When you close the root node the result will stop 556 * observing changes, so it is good practice to close the root node when you 557 * are done with a result, since that will avoid unwanted performance hits. 558 */ 559 readonly attribute nsINavHistoryContainerResultNode root; 560 561 /** 562 * Notifies you that a bunch of things are about to change, don't do any 563 * heavy-duty processing until onEndUpdateBatch is called. 564 */ 565 void onBeginUpdateBatch(); 566 567 /** 568 * Notifies you that we are done doing a bunch of things and you should go 569 * ahead and update UI, etc. 570 */ 571 void onEndUpdateBatch(); 572}; 573 574 575/** 576 * This object encapsulates all the query parameters you're likely to need 577 * when building up history UI. All parameters are ANDed together. 578 * 579 * This is not intended to be a super-general query mechanism. This was designed 580 * so that most queries can be done in only one SQL query. This is important 581 * because, if the user has their profile on a networked drive, query latency 582 * can be non-negligible. 583 */ 584 585[scriptable, uuid(dc87ae79-22f1-4dcf-975b-852b01d210cb)] 586interface nsINavHistoryQuery : nsISupports 587{ 588 /** 589 * Time range for results (INCLUSIVE). The *TimeReference is one of the 590 * constants TIME_RELATIVE_* which indicates how to interpret the 591 * corresponding time value. 592 * TIME_RELATIVE_EPOCH (default): 593 * The time is relative to Jan 1 1970 GMT, (this is a normal PRTime) 594 * TIME_RELATIVE_TODAY: 595 * The time is relative to this morning at midnight. Normally used for 596 * queries relative to today. For example, a "past week" query would be 597 * today-6 days -> today+1 day 598 * TIME_RELATIVE_NOW: 599 * The time is relative to right now. 600 * 601 * Note: PRTime is in MICROseconds since 1 Jan 1970. Javascript date objects 602 * are expressed in MILLIseconds since 1 Jan 1970. 603 * 604 * As a special case, a 0 time relative to TIME_RELATIVE_EPOCH indicates that 605 * the time is not part of the query. This is the default, so an empty query 606 * will match any time. The has* functions return whether the corresponding 607 * time is considered. 608 * 609 * You can read absolute*Time to get the time value that the currently loaded 610 * reference points + offset resolve to. 611 */ 612 const unsigned long TIME_RELATIVE_EPOCH = 0; 613 const unsigned long TIME_RELATIVE_TODAY = 1; 614 const unsigned long TIME_RELATIVE_NOW = 2; 615 616 attribute PRTime beginTime; 617 attribute unsigned long beginTimeReference; 618 readonly attribute boolean hasBeginTime; 619 readonly attribute PRTime absoluteBeginTime; 620 621 attribute PRTime endTime; 622 attribute unsigned long endTimeReference; 623 readonly attribute boolean hasEndTime; 624 readonly attribute PRTime absoluteEndTime; 625 626 /** 627 * Text search terms. 628 */ 629 attribute AString searchTerms; 630 readonly attribute boolean hasSearchTerms; 631 632 /** 633 * Set lower or upper limits for how many times an item has been 634 * visited. The default is -1, and in that case all items are 635 * matched regardless of their visit count. 636 */ 637 attribute long minVisits; 638 attribute long maxVisits; 639 640 /** 641 * When the set of transitions is nonempty, results are limited to pages which 642 * have at least one visit for each of the transition types. 643 * @note: For searching on more than one transition this can be very slow. 644 * 645 * Limit results to the specified list of transition types. 646 */ 647 void setTransitions(in Array<unsigned long> transitions); 648 649 /** 650 * Get the transitions set for this query. 651 */ 652 Array<unsigned long> getTransitions(); 653 654 /** 655 * Get the count of the set query transitions. 656 */ 657 readonly attribute unsigned long transitionCount; 658 659 /** 660 * When set, returns only bookmarked items, when unset, returns anything. Setting this 661 * is equivalent to listing all bookmark folders in the 'folders' parameter. 662 */ 663 attribute boolean onlyBookmarked; 664 665 /** 666 * This controls the meaning of 'domain', and whether it is an exact match 667 * 'domainIsHost' = true, or hierarchical (= false). 668 */ 669 attribute boolean domainIsHost; 670 671 /** 672 * This is the host or domain name (controlled by domainIsHost). When 673 * domainIsHost, domain only does exact matching on host names. Otherwise, 674 * it will return anything whose host name ends in 'domain'. 675 * 676 * This one is a little different than most. Setting it to an empty string 677 * is a real query and will match any URI that has no host name (local files 678 * and such). Set this to NULL (in C++ use SetIsVoid) if you don't want 679 * domain matching. 680 */ 681 attribute AUTF8String domain; 682 readonly attribute boolean hasDomain; 683 684 /** 685 * This is a URI to match, to, for example, find out every time you visited 686 * a given URI. This is an exact match. 687 */ 688 attribute nsIURI uri; 689 readonly attribute boolean hasUri; 690 691 /** 692 * Test for existence or non-existence of a given annotation. We don't 693 * currently support >1 annotation name per query. If 'annotationIsNot' is 694 * true, we test for the non-existence of the specified annotation. 695 * 696 * Testing for not annotation will do the same thing as a normal query and 697 * remove everything that doesn't have that annotation. Asking for things 698 * that DO have a given annotation is a little different. It also includes 699 * things that have never been visited. This allows place queries to be 700 * returned as well as anything else that may have been tagged with an 701 * annotation. This will only work for RESULTS_AS_URI since there will be 702 * no visits for these items. 703 */ 704 attribute boolean annotationIsNot; 705 attribute AUTF8String annotation; 706 readonly attribute boolean hasAnnotation; 707 708 /** 709 * Limit results to items that are tagged with all of the given tags. This 710 * attribute must be set to an array of strings. When called as a getter it 711 * will return an array of strings sorted ascending in lexicographical order. 712 * The array may be empty in either case. Duplicate tags may be specified 713 * when setting the attribute, but the getter returns only unique tags. 714 */ 715 attribute nsIVariant tags; 716 717 /** 718 * If 'tagsAreNot' is true, the results are instead limited to items that 719 * are not tagged with any of the given tags. This attribute is used in 720 * conjunction with the 'tags' attribute. 721 */ 722 attribute boolean tagsAreNot; 723 724 /** 725 * Limit results to items that are in all of the given folders. 726 */ 727 Array<ACString> getParents(); 728 readonly attribute unsigned long parentCount; 729 730 /** 731 * This is not recursive so results will be returned from the first level of 732 * that folder. 733 */ 734 void setParents(in Array<ACString> aGuids); 735 736 /** 737 * Creates a new query item with the same parameters of this one. 738 */ 739 nsINavHistoryQuery clone(); 740}; 741 742/** 743 * This object represents the global options for executing a query. 744 */ 745[scriptable, uuid(8198dfa7-8061-4766-95cb-fa86b3c00a47)] 746interface nsINavHistoryQueryOptions : nsISupports 747{ 748 /** 749 * You can ask for the results to be pre-sorted. Since the DB has indices 750 * of many items, it can produce sorted results almost for free. These should 751 * be self-explanatory. 752 * 753 * Note: re-sorting is slower, as is sorting by title or when you have a 754 * host name. 755 * 756 * For bookmark items, SORT_BY_NONE means sort by the natural bookmark order. 757 */ 758 const unsigned short SORT_BY_NONE = 0; 759 const unsigned short SORT_BY_TITLE_ASCENDING = 1; 760 const unsigned short SORT_BY_TITLE_DESCENDING = 2; 761 const unsigned short SORT_BY_DATE_ASCENDING = 3; 762 const unsigned short SORT_BY_DATE_DESCENDING = 4; 763 const unsigned short SORT_BY_URI_ASCENDING = 5; 764 const unsigned short SORT_BY_URI_DESCENDING = 6; 765 const unsigned short SORT_BY_VISITCOUNT_ASCENDING = 7; 766 const unsigned short SORT_BY_VISITCOUNT_DESCENDING = 8; 767 const unsigned short SORT_BY_DATEADDED_ASCENDING = 11; 768 const unsigned short SORT_BY_DATEADDED_DESCENDING = 12; 769 const unsigned short SORT_BY_LASTMODIFIED_ASCENDING = 13; 770 const unsigned short SORT_BY_LASTMODIFIED_DESCENDING = 14; 771 const unsigned short SORT_BY_TAGS_ASCENDING = 17; 772 const unsigned short SORT_BY_TAGS_DESCENDING = 18; 773 const unsigned short SORT_BY_FRECENCY_ASCENDING = 21; 774 const unsigned short SORT_BY_FRECENCY_DESCENDING = 22; 775 776 /** 777 * "URI" results, one for each URI visited in the range. Individual result 778 * nodes will be of type "URI". 779 */ 780 const unsigned short RESULTS_AS_URI = 0; 781 782 /** 783 * "Visit" results, with one for each time a page was visited (this will 784 * often give you multiple results for one URI). Individual result nodes will 785 * have type "Visit" 786 * 787 * @note This result type is only supported by QUERY_TYPE_HISTORY. 788 */ 789 const unsigned short RESULTS_AS_VISIT = 1; 790 791 /** 792 * This returns query nodes for each predefined date range where we 793 * had visits. The node contains information how to load its content: 794 * - visits for the given date range will be loaded. 795 * 796 * @note This result type is only supported by QUERY_TYPE_HISTORY. 797 */ 798 const unsigned short RESULTS_AS_DATE_QUERY = 3; 799 800 /** 801 * This returns nsINavHistoryQueryResultNode nodes for each site where we 802 * have visits. The node contains information how to load its content: 803 * - last visit for each url in the given host will be loaded. 804 * 805 * @note This result type is only supported by QUERY_TYPE_HISTORY. 806 */ 807 const unsigned short RESULTS_AS_SITE_QUERY = 4; 808 809 /** 810 * This returns nsINavHistoryQueryResultNode nodes for each day where we 811 * have visits. The node contains information how to load its content: 812 * - list of hosts visited in the given period will be loaded. 813 * 814 * @note This result type is only supported by QUERY_TYPE_HISTORY. 815 */ 816 const unsigned short RESULTS_AS_DATE_SITE_QUERY = 5; 817 818 /** 819 * This returns nsINavHistoryQueryResultNode nodes for each tag. 820 * The node contains information how to load its content: 821 * - list of bookmarks with the given tag will be loaded. 822 * 823 * @note Setting this resultType will force queryType to QUERY_TYPE_BOOKMARKS. 824 */ 825 const unsigned short RESULTS_AS_TAGS_ROOT = 6; 826 827 /** 828 * DEPRECATED: This exists for Sync and also to avoid reusing this number. 829 */ 830 const unsigned short RESULTS_AS_TAG_CONTENTS = 7; 831 832 /** 833 * This returns nsINavHistoryQueryResultNode nodes for each top-level bookmark 834 * root. 835 * 836 * @note Setting this resultType will force queryType to QUERY_TYPE_BOOKMARKS. 837 */ 838 const unsigned short RESULTS_AS_ROOTS_QUERY = 8; 839 840 /** 841 * This returns nsINavHistoryQueryResultNode for each left-pane root. 842 */ 843 const unsigned short RESULTS_AS_LEFT_PANE_QUERY = 9; 844 845 /** 846 * The sorting mode to be used for this query. 847 * mode is one of SORT_BY_* 848 */ 849 attribute unsigned short sortingMode; 850 851 /** 852 * Sets the result type. One of RESULT_TYPE_* which includes how URIs are 853 * represented. 854 */ 855 attribute unsigned short resultType; 856 857 /** 858 * This option excludes all URIs and separators from a bookmarks query. 859 * This would be used if you just wanted a list of bookmark folders and 860 * queries (such as the left pane of the places page). 861 * Defaults to false. 862 */ 863 attribute boolean excludeItems; 864 865 /** 866 * Set to true to exclude queries ("place:" URIs) from the query results. 867 * Simple folder queries (bookmark folder symlinks) will still be included. 868 * Defaults to false. 869 */ 870 attribute boolean excludeQueries; 871 872 /** 873 * When set, allows items with "place:" URIs to appear as containers, 874 * with the container's contents filled in from the stored query. 875 * If not set, these will appear as normal items. Doesn't do anything if 876 * excludeQueries is set. Defaults to false. 877 * 878 * Note that this has no effect on folder links, which are place: URIs 879 * returned by nsINavBookmarkService.GetFolderURI. These are always expanded 880 * and will appear as bookmark folders. 881 */ 882 attribute boolean expandQueries; 883 884 /** 885 * Some pages in history are marked "hidden" and thus don't appear by default 886 * in queries. These include automatic framed visits and redirects. Setting 887 * this attribute will return all pages, even hidden ones. Does nothing for 888 * bookmark queries. Defaults to false. 889 */ 890 attribute boolean includeHidden; 891 892 /** 893 * This is the maximum number of results that you want. The query is executed, 894 * the results are sorted, and then the top 'maxResults' results are taken 895 * and returned. Set to 0 (the default) to get all results. 896 * 897 * THIS DOES NOT WORK IN CONJUNCTION WITH SORTING BY TITLE. This is because 898 * sorting by title requires us to sort after using locale-sensetive sorting 899 * (as opposed to letting the database do it for us). 900 * 901 * Instead, we get the result ordered by date, pick the maxResult most recent 902 * ones, and THEN sort by title. 903 */ 904 attribute unsigned long maxResults; 905 906 const unsigned short QUERY_TYPE_HISTORY = 0; 907 const unsigned short QUERY_TYPE_BOOKMARKS = 1; 908 /* Unified queries are not yet implemented. See bug 378798 */ 909 const unsigned short QUERY_TYPE_UNIFIED = 2; 910 911 /** 912 * The type of search to use when querying the DB; This attribute is only 913 * honored by query nodes. It is silently ignored for simple folder queries. 914 */ 915 attribute unsigned short queryType; 916 917 /** 918 * When this is true, the root container node generated by these options and 919 * its descendant containers will be opened asynchronously if they support it. 920 * This is false by default. 921 * 922 * @note Currently only bookmark folder containers support being opened 923 * asynchronously. 924 */ 925 attribute boolean asyncEnabled; 926 927 /** 928 * Creates a new options item with the same parameters of this one. 929 */ 930 nsINavHistoryQueryOptions clone(); 931}; 932 933[scriptable, uuid(20c974ff-ee16-4828-9326-1b7c9e036622)] 934interface nsINavHistoryService : nsISupports 935{ 936 /** 937 * System Notifications: 938 * 939 * places-init-complete - Sent once the History service is completely 940 * initialized successfully. 941 * places-database-locked - Sent if initialization of the History service 942 * failed due to the inability to open the places.sqlite 943 * for access reasons. 944 */ 945 946 /** 947 * This transition type means the user followed a link and got a new toplevel 948 * window. 949 */ 950 const unsigned long TRANSITION_LINK = 1; 951 952 /** 953 * This transition type means that the user typed the page's URL in the 954 * URL bar or selected it from URL bar autocomplete results, clicked on 955 * it from a history query (from the History sidebar, History menu, 956 * or history query in the personal toolbar or Places organizer. 957 */ 958 const unsigned long TRANSITION_TYPED = 2; 959 960 /** 961 * This transition is set when the user followed a bookmark to get to the 962 * page. 963 */ 964 const unsigned long TRANSITION_BOOKMARK = 3; 965 966 /** 967 * This transition type is set when some inner content is loaded. This is 968 * true of all images on a page, and the contents of the iframe. It is also 969 * true of any content in a frame if the user did not explicitly follow 970 * a link to get there. 971 */ 972 const unsigned long TRANSITION_EMBED = 4; 973 974 /** 975 * Set when the transition was a permanent redirect. 976 */ 977 const unsigned long TRANSITION_REDIRECT_PERMANENT = 5; 978 979 /** 980 * Set when the transition was a temporary redirect. 981 */ 982 const unsigned long TRANSITION_REDIRECT_TEMPORARY = 6; 983 984 /** 985 * Set when the transition is a download. 986 */ 987 const unsigned long TRANSITION_DOWNLOAD = 7; 988 989 /** 990 * This transition type means the user followed a link and got a visit in 991 * a frame. 992 */ 993 const unsigned long TRANSITION_FRAMED_LINK = 8; 994 995 /** 996 * This transition type means the page has been reloaded. 997 */ 998 const unsigned long TRANSITION_RELOAD = 9; 999 1000 /** 1001 * Set when database is coherent 1002 */ 1003 const unsigned short DATABASE_STATUS_OK = 0; 1004 1005 /** 1006 * Set when database did not exist and we created a new one. 1007 */ 1008 const unsigned short DATABASE_STATUS_CREATE = 1; 1009 1010 /** 1011 * Set when database was corrupt and we replaced it with a new one. 1012 */ 1013 const unsigned short DATABASE_STATUS_CORRUPT = 2; 1014 1015 /** 1016 * Set when database schema has been upgraded. 1017 */ 1018 const unsigned short DATABASE_STATUS_UPGRADED = 3; 1019 1020 /** 1021 * Set when database couldn't be opened. 1022 */ 1023 const unsigned short DATABASE_STATUS_LOCKED = 4; 1024 1025 /** 1026 * Returns the current database status 1027 */ 1028 readonly attribute unsigned short databaseStatus; 1029 1030 /** 1031 * This is just like markPageAsTyped (in nsIBrowserHistory, also implemented 1032 * by the history service), but for bookmarks. It declares that the given URI 1033 * is being opened as a result of following a bookmark. If this URI is loaded 1034 * soon after this message has been received, that transition will be marked 1035 * as following a bookmark. 1036 */ 1037 void markPageAsFollowedBookmark(in nsIURI aURI); 1038 1039 /** 1040 * Designates the url as having been explicitly typed in by the user. 1041 * 1042 * @param aURI 1043 * URI of the page to be marked. 1044 */ 1045 void markPageAsTyped(in nsIURI aURI); 1046 1047 /** 1048 * Designates the url as coming from a link explicitly followed by 1049 * the user (for example by clicking on it). 1050 * 1051 * @param aURI 1052 * URI of the page to be marked. 1053 */ 1054 void markPageAsFollowedLink(in nsIURI aURI); 1055 1056 /** 1057 * Returns true if this URI would be added to the history. You don't have to 1058 * worry about calling this, adding a visit will always check before 1059 * actually adding the page. This function is public because some components 1060 * may want to check if this page would go in the history (i.e. for 1061 * annotations). 1062 */ 1063 boolean canAddURI(in nsIURI aURI); 1064 1065 /** 1066 * This returns a new query object that you can pass to executeQuer[y/ies]. 1067 * It will be initialized to all empty (so using it will give you all history). 1068 */ 1069 nsINavHistoryQuery getNewQuery(); 1070 1071 /** 1072 * This returns a new options object that you can pass to executeQuer[y/ies] 1073 * after setting the desired options. 1074 */ 1075 nsINavHistoryQueryOptions getNewQueryOptions(); 1076 1077 /** 1078 * Executes a single query. 1079 */ 1080 nsINavHistoryResult executeQuery(in nsINavHistoryQuery aQuery, 1081 in nsINavHistoryQueryOptions options); 1082 1083 /** 1084 * Converts a query URI-like string to a query object. 1085 */ 1086 void queryStringToQuery(in AUTF8String aQueryString, 1087 out nsINavHistoryQuery aQuery, 1088 out nsINavHistoryQueryOptions options); 1089 1090 /** 1091 * Converts a query into an equivalent string that can be persisted. Inverse 1092 * of queryStringToQuery() 1093 */ 1094 AUTF8String queryToQueryString(in nsINavHistoryQuery aQuery, 1095 in nsINavHistoryQueryOptions options); 1096 1097 /** 1098 * True if history is disabled. currently, 1099 * history is disabled if the places.history.enabled pref is false. 1100 */ 1101 readonly attribute boolean historyDisabled; 1102 1103 /** 1104 * Generate a guid. 1105 * Guids can be used for any places purposes (history, bookmarks, etc.) 1106 * Returns null if the generation of the guid failed. 1107 */ 1108 ACString makeGuid(); 1109 1110 /** 1111 * Returns a 48-bit hash for a URI spec. 1112 * 1113 * @param aSpec 1114 * The URI spec to hash. 1115 * @param aMode 1116 * The hash mode: `""` (default), `"prefix_lo"`, or `"prefix_hi"`. 1117 */ 1118 unsigned long long hashURL(in ACString aSpec, [optional] in ACString aMode); 1119 1120 /** 1121 * Resets and recalculates the origin frecency statistics that are kept in the 1122 * moz_meta table. 1123 * 1124 * @param aCallback 1125 * Called when the recalculation is complete. The arguments passed to 1126 * the observer are not defined. 1127 */ 1128 void recalculateOriginFrecencyStats([optional] in nsIObserver aCallback); 1129 1130 /** 1131 * The database connection used by Places. 1132 */ 1133 readonly attribute mozIStorageConnection DBConnection; 1134 1135 /** 1136 * Asynchronously executes the statement created from a query. 1137 * 1138 * @see nsINavHistoryService::executeQuery 1139 * @note THIS IS A TEMPORARY API. Don't rely on it, since it will be replaced 1140 * in future versions by a real async querying API. 1141 * @note Results obtained from this method differ from results obtained from 1142 * executeQuery, because there is additional filtering and sorting 1143 * done by the latter. Thus you should use executeQuery, unless you 1144 * are absolutely sure that the returned results are fine for 1145 * your use-case. 1146 */ 1147 mozIStoragePendingStatement asyncExecuteLegacyQuery( 1148 in nsINavHistoryQuery aQuery, 1149 in nsINavHistoryQueryOptions aOptions, 1150 in mozIStorageStatementCallback aCallback); 1151 1152 /** 1153 * Hook for clients who need to perform actions during/by the end of 1154 * the shutdown of the database. 1155 * May be null if it's too late to get one. 1156 */ 1157 readonly attribute nsIAsyncShutdownClient shutdownClient; 1158 1159 /** 1160 * Hook for internal clients who need to perform actions just before the 1161 * connection gets closed. 1162 * May be null if it's too late to get one. 1163 */ 1164 readonly attribute nsIAsyncShutdownClient connectionShutdownClient; 1165 1166 /** 1167 * Asynchronously recalculates frecency for all pages where frecency < 0, then 1168 * decays frecency and inputhistory values. 1169 */ 1170 void decayFrecency(); 1171}; 1172