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