Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / toolkit / components / places / public / nsINavBookmarksService.idl
blob542dcbe86b031779619c75a1d3951be2034f96ea
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Places.
17 * The Initial Developer of the Original Code is
18 * Google Inc.
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Brian Ryner <bryner@brianryner.com> (original author)
24 * Joe Hughes <joe@retrovirus.com>
25 * Dietrich Ayala <dietrich@mozilla.com>
26 * Asaf Romano <mano@mozilla.com>
28 * Alternatively, the contents of this file may be used under the terms of
29 * either the GNU General Public License Version 2 or later (the "GPL"), or
30 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 * in which case the provisions of the GPL or the LGPL are applicable instead
32 * of those above. If you wish to allow use of your version of this file only
33 * under the terms of either the GPL or the LGPL, and not to allow others to
34 * use your version of this file under the terms of the MPL, indicate your
35 * decision by deleting the provisions above and replace them with the notice
36 * and other provisions required by the GPL or the LGPL. If you do not delete
37 * the provisions above, a recipient may use your version of this file under
38 * the terms of any one of the MPL, the GPL or the LGPL.
40 * ***** END LICENSE BLOCK ***** */
42 #include "nsISupports.idl"
44 %{C++
45 #include "nsTArray.h"
46 #include "prtypes.h"
49 interface nsIFile;
50 interface nsIURI;
51 interface nsITransaction;
52 interface nsINavHistoryBatchCallback;
54 [ptr] native PRInt64Array(nsTArray<PRInt64>);
56 /**
57 * Observer for bookmark changes.
60 [scriptable, uuid(f9828ba8-9c70-4d95-b926-60d9e4378d7d)]
61 interface nsINavBookmarkObserver : nsISupports
63 /**
64 * Notify this observer that a batch transaction has started.
65 * Other notifications will be sent during the batch change,
66 * but the observer is guaranteed that onEndUpdateBatch() will be called
67 * at the completion of changes.
69 void onBeginUpdateBatch();
71 /**
72 * Notify this observer that a batch transaction has ended.
74 void onEndUpdateBatch();
76 /**
77 * Notify this observer that an item was added. Called after the actual
78 * add took place. The items following the index will be shifted down, but
79 * no additional notifications will be sent.
81 * @param aItemId
82 * The id of the bookmark that was added.
83 * @param aFolder
84 * The folder that the item was added to.
85 * @param aIndex
86 * The item's index in the folder.
88 void onItemAdded(in long long aItemId, in long long aFolder,
89 in long aIndex);
91 /**
92 * Notify this observer that an item was removed. Called after the actual
93 * remove took place. The items following the index will be shifted up, but
94 * no additional notifications will be sent.
96 * @param aItemId
97 * The id of the bookmark that was removed.
98 * @param aFolder
99 * The folder that the item was removed from.
100 * @param aIndex
101 * The bookmark's index in the folder.
103 void onItemRemoved(in long long aItemId, in long long aFolder,
104 in long aIndex);
107 * Notify this observer that an item's information has changed. This
108 * will be called whenever any attributes like "title" are changed.
110 * @param aItemId
111 * The id of the item that was changed.
112 * @param aProperty
113 * The property which changed.
114 * @param aIsAnnotationProperty
115 * Is aProperty the name of an item annotation
117 * property = "cleartime": (history was deleted, there is no last visit date):
118 * value = empty string.
119 * property = "title": value = new title.
120 * property = "favicon": value = new "moz-anno" URL of favicon image
121 * property = "uri": value = new uri spec.
122 * property = "tags: (tags set for the bookmarked uri have changed)
123 * value = empty string.
124 * property = "dateAdded": value = PRTime when the item was first added
125 * property = "lastModified": value = PRTime when the item was last modified
126 * aIsAnnotationProperty = true: value = empty string.
128 void onItemChanged(in long long aBookmarkId, in ACString aProperty,
129 in boolean aIsAnnotationProperty,
130 in AUTF8String aValue);
133 * Notify that the item was visited. Normally in bookmarks we use the last
134 * visit date, and normally the time will be a new visit that will be more
135 * recent, but this is not guaranteed. You should check to see if it's
136 * actually more recent before using this new time.
138 * @param aBookmarkId
139 * The id of the bookmark that was visited.
140 * @see onItemChanged property = "cleartime" for when all visit dates are
141 * deleted for the URI.
143 void onItemVisited(in long long aBookmarkId, in long long aVisitID,
144 in PRTime time);
147 * Notify this observer that an item has been moved.
148 * @param aItemId
149 * The id of the item that was moved.
150 * @param aOldParent
151 * The id of the old parent.
152 * @param aOldIndex
153 * The old index inside aOldParent.
154 * @param aNewParent
155 * The id of the new parent.
156 * @param aNewIndex
157 * The foindex inside aNewParent.
159 void onItemMoved(in long long aItemId,
160 in long long aOldParent, in long aOldIndex,
161 in long long aNewParent, in long aNewIndex);
165 * The BookmarksService interface provides methods for managing bookmarked
166 * history items. Bookmarks consist of a set of user-customizable
167 * folders. A URI in history can be contained in one or more such folders.
170 [scriptable, uuid(3b6ff5c5-0ab4-4aab-b1be-d569763a6ce0)]
171 interface nsINavBookmarksService : nsISupports
174 * The item ID of the Places root.
176 readonly attribute long long placesRoot;
179 * The item ID of the bookmarks menu folder.
181 readonly attribute long long bookmarksMenuFolder;
184 * The item ID of the top-level folder that contain the tag "folders".
186 readonly attribute long long tagsFolder;
189 * The item ID of the unfiled-bookmarks folder.
191 readonly attribute long long unfiledBookmarksFolder;
194 * The item ID of the personal toolbar folder.
196 readonly attribute long long toolbarFolder;
199 * This value should be used for APIs that allow passing in an index
200 * where an index is not known, or not required to be specified.
201 * e.g.: When appending an item to a folder.
203 const short DEFAULT_INDEX = -1;
205 const unsigned short TYPE_BOOKMARK = 1;
206 const unsigned short TYPE_FOLDER = 2;
207 const unsigned short TYPE_SEPARATOR = 3;
208 const unsigned short TYPE_DYNAMIC_CONTAINER = 4;
211 * Inserts a child bookmark into the given folder.
213 * @param aParentFolder
214 * The id of the parent folder
215 * @param aURI
216 * The URI to insert
217 * @param aIndex
218 * The index to insert at, or DEFAULT_INDEX to append
219 * @param aTitle
220 * The title for the new bookmark
221 * @returns The ID of the newly-created bookmark
223 long long insertBookmark(in long long aParentFolder, in nsIURI aURI,
224 in long aIndex, in AUTF8String aTitle);
227 * Removes a child item. Used to delete a bookmark or separator.
228 * @param aItemId
229 * The child item to remove
231 void removeItem(in long long aItemId);
234 * Creates a new child folder and inserts it under the given parent.
235 * @param aParentFolder
236 * The id of the parent folder
237 * @param aName
238 * The name of the new folder
239 * @param aIndex
240 * The index to insert at, or DEFAULT_INDEX to append
241 * @returns the ID of the newly-inserted folder
243 long long createFolder(in long long aParentFolder, in AUTF8String name,
244 in long index);
247 * Creates a dynamic container under the given parent folder.
249 * @param aParentFolder
250 * The id of the parent folder
251 * @param aName
252 * The name of the new folder
253 * @param aContractId
254 * The contract id of the service which is to manipulate this
255 * container.
256 * @param aIndex
257 * The index to insert at, or DEFAULT_INDEX to append
259 * @returns the ID of the newly-inserted folder
261 long long createDynamicContainer(in long long aParentFolder, in AUTF8String aName,
262 in AString aContractId, in long aIndex);
265 * Removes a folder from the bookmarks tree.
267 * NOTE: This API is deprecated. The correct method to use is removeItem.
268 * This will be removed in the next release after Firefox 3.0. The
269 * removal is in bug 428558.
271 * @param aFolder
272 * The id of the folder to remove.
274 void removeFolder(in long long aFolder);
277 * Gets an undo-able transaction for removing a folder from the bookmarks
278 * tree.
279 * @param folder
280 * The id of the folder to remove.
281 * @returns An object implementing nsITransaction that can be used to undo
282 * or redo the action.
284 * This method exists because complex delete->undo operations rely on
285 * recreated folders to have the same ID they had before they were deleted,
286 * so that any other items deleted in different transactions can be
287 * re-inserted correctly. This provides a safe encapsulation of this
288 * functionality without exposing the ability to recreate folders with
289 * specific IDs (potentially dangerous if abused by other code!) in the
290 * public API.
292 nsITransaction getRemoveFolderTransaction(in long long aFolder);
295 * Convenience function for container services. Removes
296 * all children of the given folder.
297 * @param aFolder
298 * The id of the folder to remove children from.
300 void removeFolderChildren(in long long aFolder);
303 * Moves an item to a different container, preserving its contents.
304 * @param aItemId
305 * The id of the item to move
306 * @param aNewParent
307 * The id of the new parent
308 * @param aIndex
309 * The index under aNewParent, or DEFAULT_INDEX to append
311 * NOTE: When moving down in the same container we take into account the
312 * removal of the original item. If you want to move from index X to
313 * index Y > X you must use moveItem(id, folder, Y + 1)
315 void moveItem(in long long aItemId, in long long aNewParent, in long aIndex);
318 * Returns the ID of a child folder with the given name. This does not
319 * recurse, you have to give it an immediate sibling of the given folder.
320 * If the given subfolder doesn't exist, it will return 0.
321 * @param aFolder
322 * Parent folder whose children we will search
323 * @param aSubFolder
324 * Name of the folder to search for in folder
326 long long getChildFolder(in long long aFolder, in AString aSubFolder);
329 * Inserts a bookmark separator into the given folder at the given index.
330 * The separator can be removed using removeChildAt().
331 * @param aFolder
332 * Parent folder of the separator
333 * @param aIndex
334 * The separator's index under folder, or DEFAULT_INDEX to append
335 * @returns the id of the new separator
337 long long insertSeparator(in long long aFolder, in long aIndex);
340 * Removes any type of child (item, folder, or separator) at the given index.
341 * @param aFolder
342 * The folder to remove a child from
343 * @param aIndex
344 * The index of the child to remove
346 void removeChildAt(in long long aFolder, in long aIndex);
349 * Get the itemId given the containing folder and the index.
350 * @param aFolder
351 * The direct parent folder of the item
352 * @param aIndex
353 * The index of the item within aFolder, DEFAULT_INDEX for the last item
354 * @returns the id of the found item
355 * @throws if the item does not exist
357 long long getIdForItemAt(in long long aFolder, in long aIndex);
360 * Get a globally unique identifier for an item, meant to be used in
361 * sync scenarios. Even if their contents are exactly the same
362 * (including an item in a different profile with the same ItemId),
363 * the GUID would be different.
364 * @param aItemId
365 * The ID of the item to get the GUID for
366 * @returns The GUID string
368 AString getItemGUID(in long long aItemId);
371 * Set a globally unique identifier. This can be useful when a sync
372 * algorithm deems two independently created items (on different
373 * profiles) to be the same item.
374 * @param aItemId
375 * The id of the item to set the GUID of
376 * @param aGUID
377 * The GUID string
379 void setItemGUID(in long long aItemId, in AString aGUID);
382 * Get the ID of the item with the given GUID.
383 * @param aGUID
384 * The GUID string of the item to search for
385 * @returns The item ID, or -1 if not found
387 long long getItemIdForGUID(in AString aGUID);
390 * Set the title for an item.
391 * @param aItemId
392 * The id of the item whose title should be updated
393 * @param aTitle
394 * The new title for the bookmark.
396 void setItemTitle(in long long aItemId, in AUTF8String aTitle);
399 * Get the title for an item.
401 * If no item title is available it will return a void string (null in JS).
403 * @param aItemId
404 * The id of the item whose title should be retrieved
405 * @returns The title of the item.
407 AUTF8String getItemTitle(in long long aItemId);
410 * Set the date added time for an item.
412 void setItemDateAdded(in long long aItemId, in PRTime aDateAdded);
414 * Get the date added time for an item.
416 PRTime getItemDateAdded(in long long aItemId);
419 * Set the last modified time for an item.
421 void setItemLastModified(in long long aItemId, in PRTime aLastModified);
423 * Get the last modified time for an item.
425 PRTime getItemLastModified(in long long aItemId);
428 * Get the URI for a bookmark item.
430 nsIURI getBookmarkURI(in long long aItemId);
433 * Get the index for an item.
435 long getItemIndex(in long long aItemId);
438 * Changes the index for a item. This method does not change the indices of
439 * any other items in the same folder, so ensure that the new index does not
440 * already exist, or change the index of other items accordingly, otherwise
441 * the indices will become corrupted.
443 * WARNING: This is API is intended for scenarios such as folder sorting,
444 * where the caller manages the indices of *all* items in the folder.
446 * @param aItemId The id of the item to modify
447 * @param aNewIndex The new index
449 void setItemIndex(in long long aItemId, in long aNewIndex);
452 * Get an item's type (bookmark, separator, folder).
453 * The type is one of the TYPE_* constants defined above.
455 unsigned short getItemType(in long long aItemId);
458 * Checks whether a folder is marked as read-only.
459 * If this is set to true, UI will not allow the user to add, remove,
460 * or reorder children in this folder. The default for all folders is false.
461 * Note: This does not restrict API calls, only UI actions.
463 * @param aFolder
464 * the item-id of the folder.
466 boolean getFolderReadonly(in long long aFolder);
469 * Sets or unsets the readonly flag from a folder.
470 * If this is set to true, UI will not allow the user to add, remove,
471 * or reorder children in this folder. The default for all folders is false.
472 * Note: This does not restrict API calls, only UI actions.
474 * @param aFolder
475 * the item-id of the folder.
476 * @param aReadOnly
477 * the read-only state (boolean).
479 void setFolderReadonly(in long long aFolder, in boolean aReadOnly);
482 * Returns true if the given URI is in any bookmark folder. If you want the
483 * results to be redirect-aware, use getBookmarkedURIFor()
485 boolean isBookmarked(in nsIURI aURI);
488 * Used to see if the given URI is bookmarked, or any page that redirected to
489 * it is bookmarked. For example, if I bookmark "mozilla.org" by manually
490 * typing it in, and follow the bookmark, I will get redirected to
491 * "www.mozilla.org". Logically, this new page is also bookmarked. This
492 * function, if given "www.mozilla.org", will return the URI of the bookmark,
493 * in this case "mozilla.org".
495 * If there is no bookmarked page found, it will return NULL.
497 nsIURI getBookmarkedURIFor(in nsIURI aURI);
500 * Change the bookmarked URI for a bookmark.
501 * This changes which "place" the bookmark points at,
502 * which means all annotations, etc are carried along.
504 void changeBookmarkURI(in long long aItemId, in nsIURI aNewURI);
507 * Get the parent folder's id for an item.
509 long long getFolderIdForItem(in long long aItemId);
512 * Returns the list of bookmark ids that contain the given URI.
514 void getBookmarkIdsForURI(in nsIURI aURI, out unsigned long count,
515 [array, retval, size_is(count)] out long long bookmarks);
518 * TArray version of getBookmarksIdForURI for ease of use in C++ code.
519 * Pass in a reference to a TArray; it will get cleared and filled with
520 * the resulting list of folder IDs.
522 [noscript] void getBookmarkIdsForURITArray(in nsIURI aURI,
523 in PRInt64Array aResult);
526 * Associates the given keyword with the given bookmark.
528 * Use an empty keyword to clear the keyword associated with the URI.
529 * In both of these cases, succeeds but does nothing if the URL/keyword is not found.
531 void setKeywordForBookmark(in long long aItemId, in AString aKeyword);
534 * Retrieves the keyword for the given URI. Will be void string
535 * (null in JS) if no such keyword is found.
537 AString getKeywordForURI(in nsIURI aURI);
540 * Retrieves the keyword for the given bookmark. Will be void string
541 * (null in JS) if no such keyword is found.
543 AString getKeywordForBookmark(in long long aItemId);
546 * Returns the URI associated with the given keyword. Empty if no such
547 * keyword is found.
549 nsIURI getURIForKeyword(in AString keyword);
552 * Adds a bookmark observer. If ownsWeak is false, the bookmark service will
553 * keep an owning reference to the observer. If ownsWeak is true, then
554 * aObserver must implement nsISupportsWeakReference, and the bookmark
555 * service will keep a weak reference to the observer.
557 void addObserver(in nsINavBookmarkObserver observer, in boolean ownsWeak);
560 * Removes a bookmark observer.
562 void removeObserver(in nsINavBookmarkObserver observer);
565 * Runs the passed callback inside of a database transaction.
566 * Use this when a lot of things are about to change, for example
567 * adding or deleting a large number of bookmark items. Calls can
568 * be nested. Observers are notified when batches begin and end, via
569 * nsINavBookmarkObserver.onBeginUpdateBatch/onEndUpdateBatch.
571 * @param aCallback
572 * nsINavHistoryBatchCallback interface to call.
573 * @param aUserData
574 * Opaque parameter passed to nsINavBookmarksBatchCallback
576 void runInBatchMode(in nsINavHistoryBatchCallback aCallback,
577 in nsISupports aUserData);