Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | |
michael@0 | 8 | interface nsIFile; |
michael@0 | 9 | interface nsIURI; |
michael@0 | 10 | interface nsITransaction; |
michael@0 | 11 | interface nsINavHistoryBatchCallback; |
michael@0 | 12 | |
michael@0 | 13 | /** |
michael@0 | 14 | * Observer for bookmarks changes. |
michael@0 | 15 | */ |
michael@0 | 16 | [scriptable, uuid(8ab925f8-af9b-4837-afa0-ffed507212ce)] |
michael@0 | 17 | interface nsINavBookmarkObserver : nsISupports |
michael@0 | 18 | { |
michael@0 | 19 | /** |
michael@0 | 20 | * Notifies that a batch transaction has started. |
michael@0 | 21 | * Other notifications will be sent during the batch, but the observer is |
michael@0 | 22 | * guaranteed that onEndUpdateBatch() will be called at its completion. |
michael@0 | 23 | * During a batch the observer should do its best to reduce the work done to |
michael@0 | 24 | * handle notifications, since multiple changes are going to happen in a short |
michael@0 | 25 | * timeframe. |
michael@0 | 26 | */ |
michael@0 | 27 | void onBeginUpdateBatch(); |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * Notifies that a batch transaction has ended. |
michael@0 | 31 | */ |
michael@0 | 32 | void onEndUpdateBatch(); |
michael@0 | 33 | |
michael@0 | 34 | /** |
michael@0 | 35 | * Notifies that an item (any type) was added. Called after the actual |
michael@0 | 36 | * addition took place. |
michael@0 | 37 | * When a new item is created, all the items following it in the same folder |
michael@0 | 38 | * will have their index shifted down, but no additional notifications will |
michael@0 | 39 | * be sent. |
michael@0 | 40 | * |
michael@0 | 41 | * @param aItemId |
michael@0 | 42 | * The id of the item that was added. |
michael@0 | 43 | * @param aParentId |
michael@0 | 44 | * The id of the folder to which the item was added. |
michael@0 | 45 | * @param aIndex |
michael@0 | 46 | * The item's index in the folder. |
michael@0 | 47 | * @param aItemType |
michael@0 | 48 | * The type of the added item (see TYPE_* constants below). |
michael@0 | 49 | * @param aURI |
michael@0 | 50 | * The URI of the added item if it was TYPE_BOOKMARK, null otherwise. |
michael@0 | 51 | * @param aTitle |
michael@0 | 52 | * The title of the added item. |
michael@0 | 53 | * @param aDateAdded |
michael@0 | 54 | * The stored date added value, in microseconds from the epoch. |
michael@0 | 55 | * @param aGUID |
michael@0 | 56 | * The unique ID associated with the item. |
michael@0 | 57 | * @param aParentGUID |
michael@0 | 58 | * The unique ID associated with the item's parent. |
michael@0 | 59 | */ |
michael@0 | 60 | void onItemAdded(in long long aItemId, |
michael@0 | 61 | in long long aParentId, |
michael@0 | 62 | in long aIndex, |
michael@0 | 63 | in unsigned short aItemType, |
michael@0 | 64 | in nsIURI aURI, |
michael@0 | 65 | in AUTF8String aTitle, |
michael@0 | 66 | in PRTime aDateAdded, |
michael@0 | 67 | in ACString aGUID, |
michael@0 | 68 | in ACString aParentGUID); |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * Notifies that an item was removed. Called after the actual remove took |
michael@0 | 72 | * place. |
michael@0 | 73 | * When an item is removed, all the items following it in the same folder |
michael@0 | 74 | * will have their index shifted down, but no additional notifications will |
michael@0 | 75 | * be sent. |
michael@0 | 76 | * |
michael@0 | 77 | * @param aItemId |
michael@0 | 78 | * The id of the item that was removed. |
michael@0 | 79 | * @param aParentId |
michael@0 | 80 | * The id of the folder from which the item was removed. |
michael@0 | 81 | * @param aIndex |
michael@0 | 82 | * The bookmark's index in the folder. |
michael@0 | 83 | * @param aItemType |
michael@0 | 84 | * The type of the item to be removed (see TYPE_* constants below). |
michael@0 | 85 | * @param aURI |
michael@0 | 86 | * The URI of the added item if it was TYPE_BOOKMARK, null otherwise. |
michael@0 | 87 | * @param aGUID |
michael@0 | 88 | * The unique ID associated with the item. |
michael@0 | 89 | * @param aParentGUID |
michael@0 | 90 | * The unique ID associated with the item's parent. |
michael@0 | 91 | */ |
michael@0 | 92 | void onItemRemoved(in long long aItemId, |
michael@0 | 93 | in long long aParentId, |
michael@0 | 94 | in long aIndex, |
michael@0 | 95 | in unsigned short aItemType, |
michael@0 | 96 | in nsIURI aURI, |
michael@0 | 97 | in ACString aGUID, |
michael@0 | 98 | in ACString aParentGUID); |
michael@0 | 99 | |
michael@0 | 100 | /** |
michael@0 | 101 | * Notifies that an item's information has changed. This will be called |
michael@0 | 102 | * whenever any attributes like "title" are changed. |
michael@0 | 103 | * |
michael@0 | 104 | * @param aItemId |
michael@0 | 105 | * The id of the item that was changed. |
michael@0 | 106 | * @param aProperty |
michael@0 | 107 | * The property which changed. Can be null for the removal of all of |
michael@0 | 108 | * the annotations, in this case aIsAnnotationProperty is true. |
michael@0 | 109 | * @param aIsAnnotationProperty |
michael@0 | 110 | * Whether or not aProperty is the name of an annotation. If true |
michael@0 | 111 | * aNewValue is always an empty string. |
michael@0 | 112 | * @param aNewValue |
michael@0 | 113 | * For certain properties, this is set to the new value of the |
michael@0 | 114 | * property (see the list below). |
michael@0 | 115 | * @param aLastModified |
michael@0 | 116 | * If lastModified changed, this parameter is the new value, otherwise |
michael@0 | 117 | * it's set to 0. |
michael@0 | 118 | * @param aItemType |
michael@0 | 119 | * The type of the item to be removed (see TYPE_* constants below). |
michael@0 | 120 | * @param aParentId |
michael@0 | 121 | * The id of the folder containing the item. |
michael@0 | 122 | * @param aGUID |
michael@0 | 123 | * The unique ID associated with the item. |
michael@0 | 124 | * @param aParentGUID |
michael@0 | 125 | * The unique ID associated with the item's parent. |
michael@0 | 126 | * |
michael@0 | 127 | * @note List of values that may be associated with properties: |
michael@0 | 128 | * aProperty | aNewValue |
michael@0 | 129 | * ===================================================================== |
michael@0 | 130 | * cleartime | Empty string (all visits to this item were removed). |
michael@0 | 131 | * title | The new title. |
michael@0 | 132 | * favicon | The "moz-anno" URL of the new favicon. |
michael@0 | 133 | * uri | new URL. |
michael@0 | 134 | * tags | Empty string (tags for this item changed) |
michael@0 | 135 | * dateAdded | PRTime (as string) when the item was first added. |
michael@0 | 136 | * lastModified | PRTime (as string) when the item was last modified. |
michael@0 | 137 | */ |
michael@0 | 138 | void onItemChanged(in long long aItemId, |
michael@0 | 139 | in ACString aProperty, |
michael@0 | 140 | in boolean aIsAnnotationProperty, |
michael@0 | 141 | in AUTF8String aNewValue, |
michael@0 | 142 | in PRTime aLastModified, |
michael@0 | 143 | in unsigned short aItemType, |
michael@0 | 144 | in long long aParentId, |
michael@0 | 145 | in ACString aGUID, |
michael@0 | 146 | in ACString aParentGUID); |
michael@0 | 147 | |
michael@0 | 148 | /** |
michael@0 | 149 | * Notifies that the item was visited. Can be invoked only for TYPE_BOOKMARK |
michael@0 | 150 | * items. |
michael@0 | 151 | * |
michael@0 | 152 | * @param aItemId |
michael@0 | 153 | * The id of the bookmark that was visited. |
michael@0 | 154 | * @param aVisitId |
michael@0 | 155 | * The id of the visit. |
michael@0 | 156 | * @param aTime |
michael@0 | 157 | * The time of the visit. |
michael@0 | 158 | * @param aTransitionType |
michael@0 | 159 | * The transition for the visit. See nsINavHistoryService::TRANSITION_* |
michael@0 | 160 | * constants for a list of possible values. |
michael@0 | 161 | * @param aURI |
michael@0 | 162 | * The nsIURI for this bookmark. |
michael@0 | 163 | * @param aParentId |
michael@0 | 164 | * The id of the folder containing the item. |
michael@0 | 165 | * @param aGUID |
michael@0 | 166 | * The unique ID associated with the item. |
michael@0 | 167 | * @param aParentGUID |
michael@0 | 168 | * The unique ID associated with the item's parent. |
michael@0 | 169 | * |
michael@0 | 170 | * @see onItemChanged with property = "cleartime" for when all visits to an |
michael@0 | 171 | * item are removed. |
michael@0 | 172 | * |
michael@0 | 173 | * @note The reported time is the time of the visit that was added, which may |
michael@0 | 174 | * be well in the past since the visit time can be specified. This |
michael@0 | 175 | * means that the visit the observer is told about may not be the most |
michael@0 | 176 | * recent visit for that page. |
michael@0 | 177 | */ |
michael@0 | 178 | void onItemVisited(in long long aItemId, |
michael@0 | 179 | in long long aVisitId, |
michael@0 | 180 | in PRTime aTime, |
michael@0 | 181 | in unsigned long aTransitionType, |
michael@0 | 182 | in nsIURI aURI, |
michael@0 | 183 | in long long aParentId, |
michael@0 | 184 | in ACString aGUID, |
michael@0 | 185 | in ACString aParentGUID); |
michael@0 | 186 | |
michael@0 | 187 | /** |
michael@0 | 188 | * Notifies that an item has been moved. |
michael@0 | 189 | * |
michael@0 | 190 | * @param aItemId |
michael@0 | 191 | * The id of the item that was moved. |
michael@0 | 192 | * @param aOldParentId |
michael@0 | 193 | * The id of the old parent. |
michael@0 | 194 | * @param aOldIndex |
michael@0 | 195 | * The old index inside the old parent. |
michael@0 | 196 | * @param aNewParentId |
michael@0 | 197 | * The id of the new parent. |
michael@0 | 198 | * @param aNewIndex |
michael@0 | 199 | * The index inside the new parent. |
michael@0 | 200 | * @param aItemType |
michael@0 | 201 | * The type of the item to be removed (see TYPE_* constants below). |
michael@0 | 202 | * @param aGUID |
michael@0 | 203 | * The unique ID associated with the item. |
michael@0 | 204 | * @param aOldParentGUID |
michael@0 | 205 | * The unique ID associated with the old item's parent. |
michael@0 | 206 | * @param aNewParentGUID |
michael@0 | 207 | * The unique ID associated with the new item's parent. |
michael@0 | 208 | */ |
michael@0 | 209 | void onItemMoved(in long long aItemId, |
michael@0 | 210 | in long long aOldParentId, |
michael@0 | 211 | in long aOldIndex, |
michael@0 | 212 | in long long aNewParentId, |
michael@0 | 213 | in long aNewIndex, |
michael@0 | 214 | in unsigned short aItemType, |
michael@0 | 215 | in ACString aGUID, |
michael@0 | 216 | in ACString aOldParentGUID, |
michael@0 | 217 | in ACString aNewParentGUID); |
michael@0 | 218 | }; |
michael@0 | 219 | |
michael@0 | 220 | /** |
michael@0 | 221 | * The BookmarksService interface provides methods for managing bookmarked |
michael@0 | 222 | * history items. Bookmarks consist of a set of user-customizable |
michael@0 | 223 | * folders. A URI in history can be contained in one or more such folders. |
michael@0 | 224 | */ |
michael@0 | 225 | |
michael@0 | 226 | [scriptable, uuid(A78EA368-E28E-462E-897A-26606D4DDCE6)] |
michael@0 | 227 | interface nsINavBookmarksService : nsISupports |
michael@0 | 228 | { |
michael@0 | 229 | /** |
michael@0 | 230 | * The item ID of the Places root. |
michael@0 | 231 | */ |
michael@0 | 232 | readonly attribute long long placesRoot; |
michael@0 | 233 | |
michael@0 | 234 | /** |
michael@0 | 235 | * The item ID of the bookmarks menu folder. |
michael@0 | 236 | */ |
michael@0 | 237 | readonly attribute long long bookmarksMenuFolder; |
michael@0 | 238 | |
michael@0 | 239 | /** |
michael@0 | 240 | * The item ID of the top-level folder that contain the tag "folders". |
michael@0 | 241 | */ |
michael@0 | 242 | readonly attribute long long tagsFolder; |
michael@0 | 243 | |
michael@0 | 244 | /** |
michael@0 | 245 | * The item ID of the unfiled-bookmarks folder. |
michael@0 | 246 | */ |
michael@0 | 247 | readonly attribute long long unfiledBookmarksFolder; |
michael@0 | 248 | |
michael@0 | 249 | /** |
michael@0 | 250 | * The item ID of the personal toolbar folder. |
michael@0 | 251 | */ |
michael@0 | 252 | readonly attribute long long toolbarFolder; |
michael@0 | 253 | |
michael@0 | 254 | /** |
michael@0 | 255 | * This value should be used for APIs that allow passing in an index |
michael@0 | 256 | * where an index is not known, or not required to be specified. |
michael@0 | 257 | * e.g.: When appending an item to a folder. |
michael@0 | 258 | */ |
michael@0 | 259 | const short DEFAULT_INDEX = -1; |
michael@0 | 260 | |
michael@0 | 261 | const unsigned short TYPE_BOOKMARK = 1; |
michael@0 | 262 | const unsigned short TYPE_FOLDER = 2; |
michael@0 | 263 | const unsigned short TYPE_SEPARATOR = 3; |
michael@0 | 264 | // Dynamic containers are deprecated and unsupported. |
michael@0 | 265 | // This const exists just to avoid reusing the value. |
michael@0 | 266 | const unsigned short TYPE_DYNAMIC_CONTAINER = 4; |
michael@0 | 267 | |
michael@0 | 268 | /** |
michael@0 | 269 | * Inserts a child bookmark into the given folder. |
michael@0 | 270 | * |
michael@0 | 271 | * @param aParentId |
michael@0 | 272 | * The id of the parent folder |
michael@0 | 273 | * @param aURI |
michael@0 | 274 | * The URI to insert |
michael@0 | 275 | * @param aIndex |
michael@0 | 276 | * The index to insert at, or DEFAULT_INDEX to append |
michael@0 | 277 | * @param aTitle |
michael@0 | 278 | * The title for the new bookmark |
michael@0 | 279 | * @param [optional] aGUID |
michael@0 | 280 | * The GUID to be set for the new item. If not set, a new GUID is |
michael@0 | 281 | * generated. Unless you've a very sound reason, such as an undo |
michael@0 | 282 | * manager implementation, do not pass this argument. |
michael@0 | 283 | * @return The ID of the newly-created bookmark. |
michael@0 | 284 | * |
michael@0 | 285 | * @note aTitle will be truncated to TITLE_LENGTH_MAX and |
michael@0 | 286 | * aURI will be truncated to URI_LENGTH_MAX. |
michael@0 | 287 | * @throws if aGUID is malformed. |
michael@0 | 288 | */ |
michael@0 | 289 | long long insertBookmark(in long long aParentId, in nsIURI aURI, |
michael@0 | 290 | in long aIndex, in AUTF8String aTitle, |
michael@0 | 291 | [optional] in ACString aGUID); |
michael@0 | 292 | |
michael@0 | 293 | /** |
michael@0 | 294 | * Removes a child item. Used to delete a bookmark or separator. |
michael@0 | 295 | * @param aItemId |
michael@0 | 296 | * The child item to remove |
michael@0 | 297 | */ |
michael@0 | 298 | void removeItem(in long long aItemId); |
michael@0 | 299 | |
michael@0 | 300 | /** |
michael@0 | 301 | * Creates a new child folder and inserts it under the given parent. |
michael@0 | 302 | * @param aParentFolder |
michael@0 | 303 | * The id of the parent folder |
michael@0 | 304 | * @param aName |
michael@0 | 305 | * The name of the new folder |
michael@0 | 306 | * @param aIndex |
michael@0 | 307 | * The index to insert at, or DEFAULT_INDEX to append |
michael@0 | 308 | * @param [optional] aGUID |
michael@0 | 309 | * The GUID to be set for the new item. If not set, a new GUID is |
michael@0 | 310 | * generated. Unless you've a very sound reason, such as an undo |
michael@0 | 311 | * manager implementation, do not pass this argument. |
michael@0 | 312 | * @return The ID of the newly-inserted folder. |
michael@0 | 313 | * @throws if aGUID is malformed. |
michael@0 | 314 | */ |
michael@0 | 315 | long long createFolder(in long long aParentFolder, in AUTF8String name, |
michael@0 | 316 | in long index, |
michael@0 | 317 | [optional] in ACString aGUID); |
michael@0 | 318 | |
michael@0 | 319 | /** |
michael@0 | 320 | * Gets an undo-able transaction for removing a folder from the bookmarks |
michael@0 | 321 | * tree. |
michael@0 | 322 | * @param aItemId |
michael@0 | 323 | * The id of the folder to remove. |
michael@0 | 324 | * @return An object implementing nsITransaction that can be used to undo |
michael@0 | 325 | * or redo the action. |
michael@0 | 326 | * |
michael@0 | 327 | * This method exists because complex delete->undo operations rely on |
michael@0 | 328 | * recreated folders to have the same ID they had before they were deleted, |
michael@0 | 329 | * so that any other items deleted in different transactions can be |
michael@0 | 330 | * re-inserted correctly. This provides a safe encapsulation of this |
michael@0 | 331 | * functionality without exposing the ability to recreate folders with |
michael@0 | 332 | * specific IDs (potentially dangerous if abused by other code!) in the |
michael@0 | 333 | * public API. |
michael@0 | 334 | */ |
michael@0 | 335 | nsITransaction getRemoveFolderTransaction(in long long aItemId); |
michael@0 | 336 | |
michael@0 | 337 | /** |
michael@0 | 338 | * Convenience function for container services. Removes |
michael@0 | 339 | * all children of the given folder. |
michael@0 | 340 | * @param aItemId |
michael@0 | 341 | * The id of the folder to remove children from. |
michael@0 | 342 | */ |
michael@0 | 343 | void removeFolderChildren(in long long aItemId); |
michael@0 | 344 | |
michael@0 | 345 | /** |
michael@0 | 346 | * Moves an item to a different container, preserving its contents. |
michael@0 | 347 | * @param aItemId |
michael@0 | 348 | * The id of the item to move |
michael@0 | 349 | * @param aNewParentId |
michael@0 | 350 | * The id of the new parent |
michael@0 | 351 | * @param aIndex |
michael@0 | 352 | * The index under aNewParent, or DEFAULT_INDEX to append |
michael@0 | 353 | * |
michael@0 | 354 | * NOTE: When moving down in the same container we take into account the |
michael@0 | 355 | * removal of the original item. If you want to move from index X to |
michael@0 | 356 | * index Y > X you must use moveItem(id, folder, Y + 1) |
michael@0 | 357 | */ |
michael@0 | 358 | void moveItem(in long long aItemId, in long long aNewParentId, in long aIndex); |
michael@0 | 359 | |
michael@0 | 360 | /** |
michael@0 | 361 | * Inserts a bookmark separator into the given folder at the given index. |
michael@0 | 362 | * The separator can be removed using removeChildAt(). |
michael@0 | 363 | * @param aParentId |
michael@0 | 364 | * The id of the parent folder |
michael@0 | 365 | * @param aIndex |
michael@0 | 366 | * The separator's index under folder, or DEFAULT_INDEX to append |
michael@0 | 367 | * @param [optional] aGUID |
michael@0 | 368 | * The GUID to be set for the new item. If not set, a new GUID is |
michael@0 | 369 | * generated. Unless you've a very sound reason, such as an undo |
michael@0 | 370 | * manager implementation, do not pass this argument. |
michael@0 | 371 | * @return The ID of the new separator. |
michael@0 | 372 | * @throws if aGUID is malformed. |
michael@0 | 373 | */ |
michael@0 | 374 | long long insertSeparator(in long long aParentId, in long aIndex, |
michael@0 | 375 | [optional] in ACString aGUID); |
michael@0 | 376 | |
michael@0 | 377 | /** |
michael@0 | 378 | * Get the itemId given the containing folder and the index. |
michael@0 | 379 | * @param aParentId |
michael@0 | 380 | * The id of the diret parent folder of the item |
michael@0 | 381 | * @param aIndex |
michael@0 | 382 | * The index of the item within the parent folder. |
michael@0 | 383 | * Pass DEFAULT_INDEX for the last item. |
michael@0 | 384 | * @return The ID of the found item, -1 if the item does not exists. |
michael@0 | 385 | */ |
michael@0 | 386 | long long getIdForItemAt(in long long aParentId, in long aIndex); |
michael@0 | 387 | |
michael@0 | 388 | /** |
michael@0 | 389 | * Set the title for an item. |
michael@0 | 390 | * @param aItemId |
michael@0 | 391 | * The id of the item whose title should be updated. |
michael@0 | 392 | * @param aTitle |
michael@0 | 393 | * The new title for the bookmark. |
michael@0 | 394 | * |
michael@0 | 395 | * @note aTitle will be truncated to TITLE_LENGTH_MAX. |
michael@0 | 396 | */ |
michael@0 | 397 | void setItemTitle(in long long aItemId, in AUTF8String aTitle); |
michael@0 | 398 | |
michael@0 | 399 | /** |
michael@0 | 400 | * Get the title for an item. |
michael@0 | 401 | * |
michael@0 | 402 | * If no item title is available it will return a void string (null in JS). |
michael@0 | 403 | * |
michael@0 | 404 | * @param aItemId |
michael@0 | 405 | * The id of the item whose title should be retrieved |
michael@0 | 406 | * @return The title of the item. |
michael@0 | 407 | */ |
michael@0 | 408 | AUTF8String getItemTitle(in long long aItemId); |
michael@0 | 409 | |
michael@0 | 410 | /** |
michael@0 | 411 | * Set the date added time for an item. |
michael@0 | 412 | */ |
michael@0 | 413 | void setItemDateAdded(in long long aItemId, in PRTime aDateAdded); |
michael@0 | 414 | /** |
michael@0 | 415 | * Get the date added time for an item. |
michael@0 | 416 | */ |
michael@0 | 417 | PRTime getItemDateAdded(in long long aItemId); |
michael@0 | 418 | |
michael@0 | 419 | /** |
michael@0 | 420 | * Set the last modified time for an item. |
michael@0 | 421 | * |
michael@0 | 422 | * @note This is the only method that will send an itemChanged notification |
michael@0 | 423 | * for the property. lastModified will still be updated in |
michael@0 | 424 | * any other method that changes an item property, but we will send |
michael@0 | 425 | * the corresponding itemChanged notification instead. |
michael@0 | 426 | */ |
michael@0 | 427 | void setItemLastModified(in long long aItemId, in PRTime aLastModified); |
michael@0 | 428 | /** |
michael@0 | 429 | * Get the last modified time for an item. |
michael@0 | 430 | * |
michael@0 | 431 | * @note When an item is added lastModified is set to the same value as |
michael@0 | 432 | * dateAdded. |
michael@0 | 433 | */ |
michael@0 | 434 | PRTime getItemLastModified(in long long aItemId); |
michael@0 | 435 | |
michael@0 | 436 | /** |
michael@0 | 437 | * Get the URI for a bookmark item. |
michael@0 | 438 | */ |
michael@0 | 439 | nsIURI getBookmarkURI(in long long aItemId); |
michael@0 | 440 | |
michael@0 | 441 | /** |
michael@0 | 442 | * Get the index for an item. |
michael@0 | 443 | */ |
michael@0 | 444 | long getItemIndex(in long long aItemId); |
michael@0 | 445 | |
michael@0 | 446 | /** |
michael@0 | 447 | * Changes the index for a item. This method does not change the indices of |
michael@0 | 448 | * any other items in the same folder, so ensure that the new index does not |
michael@0 | 449 | * already exist, or change the index of other items accordingly, otherwise |
michael@0 | 450 | * the indices will become corrupted. |
michael@0 | 451 | * |
michael@0 | 452 | * WARNING: This is API is intended for scenarios such as folder sorting, |
michael@0 | 453 | * where the caller manages the indices of *all* items in the folder. |
michael@0 | 454 | * You must always ensure each index is unique after a reordering. |
michael@0 | 455 | * |
michael@0 | 456 | * @param aItemId The id of the item to modify |
michael@0 | 457 | * @param aNewIndex The new index |
michael@0 | 458 | * |
michael@0 | 459 | * @throws If aNewIndex is out of bounds. |
michael@0 | 460 | */ |
michael@0 | 461 | void setItemIndex(in long long aItemId, in long aNewIndex); |
michael@0 | 462 | |
michael@0 | 463 | /** |
michael@0 | 464 | * Get an item's type (bookmark, separator, folder). |
michael@0 | 465 | * The type is one of the TYPE_* constants defined above. |
michael@0 | 466 | */ |
michael@0 | 467 | unsigned short getItemType(in long long aItemId); |
michael@0 | 468 | |
michael@0 | 469 | /** |
michael@0 | 470 | * Checks whether a folder is marked as read-only. |
michael@0 | 471 | * If this is set to true, UI will not allow the user to add, remove, |
michael@0 | 472 | * or reorder children in this folder. The default for all folders is false. |
michael@0 | 473 | * Note: This does not restrict API calls, only UI actions. |
michael@0 | 474 | * |
michael@0 | 475 | * @param aItemId |
michael@0 | 476 | * the item-id of the folder. |
michael@0 | 477 | */ |
michael@0 | 478 | boolean getFolderReadonly(in long long aItemId); |
michael@0 | 479 | |
michael@0 | 480 | /** |
michael@0 | 481 | * Sets or unsets the readonly flag from a folder. |
michael@0 | 482 | * If this is set to true, UI will not allow the user to add, remove, |
michael@0 | 483 | * or reorder children in this folder. The default for all folders is false. |
michael@0 | 484 | * Note: This does not restrict API calls, only UI actions. |
michael@0 | 485 | * |
michael@0 | 486 | * @param aFolder |
michael@0 | 487 | * the item-id of the folder. |
michael@0 | 488 | * @param aReadOnly |
michael@0 | 489 | * the read-only state (boolean). |
michael@0 | 490 | */ |
michael@0 | 491 | void setFolderReadonly(in long long aFolder, in boolean aReadOnly); |
michael@0 | 492 | |
michael@0 | 493 | /** |
michael@0 | 494 | * Returns true if the given URI is in any bookmark folder. If you want the |
michael@0 | 495 | * results to be redirect-aware, use getBookmarkedURIFor() |
michael@0 | 496 | */ |
michael@0 | 497 | boolean isBookmarked(in nsIURI aURI); |
michael@0 | 498 | |
michael@0 | 499 | /** |
michael@0 | 500 | * Used to see if the given URI is bookmarked, or any page that redirected to |
michael@0 | 501 | * it is bookmarked. For example, if I bookmark "mozilla.org" by manually |
michael@0 | 502 | * typing it in, and follow the bookmark, I will get redirected to |
michael@0 | 503 | * "www.mozilla.org". Logically, this new page is also bookmarked. This |
michael@0 | 504 | * function, if given "www.mozilla.org", will return the URI of the bookmark, |
michael@0 | 505 | * in this case "mozilla.org". |
michael@0 | 506 | * |
michael@0 | 507 | * If there is no bookmarked page found, it will return NULL. |
michael@0 | 508 | * |
michael@0 | 509 | * @note The function will only return bookmarks in the first 2 levels of |
michael@0 | 510 | * redirection (1 -> 2 -> aURI). |
michael@0 | 511 | */ |
michael@0 | 512 | nsIURI getBookmarkedURIFor(in nsIURI aURI); |
michael@0 | 513 | |
michael@0 | 514 | /** |
michael@0 | 515 | * Change the bookmarked URI for a bookmark. |
michael@0 | 516 | * This changes which "place" the bookmark points at, |
michael@0 | 517 | * which means all annotations, etc are carried along. |
michael@0 | 518 | */ |
michael@0 | 519 | void changeBookmarkURI(in long long aItemId, in nsIURI aNewURI); |
michael@0 | 520 | |
michael@0 | 521 | /** |
michael@0 | 522 | * Get the parent folder's id for an item. |
michael@0 | 523 | */ |
michael@0 | 524 | long long getFolderIdForItem(in long long aItemId); |
michael@0 | 525 | |
michael@0 | 526 | /** |
michael@0 | 527 | * Returns the list of bookmark ids that contain the given URI. |
michael@0 | 528 | */ |
michael@0 | 529 | void getBookmarkIdsForURI(in nsIURI aURI, [optional] out unsigned long count, |
michael@0 | 530 | [array, retval, size_is(count)] out long long bookmarks); |
michael@0 | 531 | |
michael@0 | 532 | /** |
michael@0 | 533 | * Associates the given keyword with the given bookmark. |
michael@0 | 534 | * |
michael@0 | 535 | * Use an empty keyword to clear the keyword associated with the URI. |
michael@0 | 536 | * In both of these cases, succeeds but does nothing if the URL/keyword is not found. |
michael@0 | 537 | */ |
michael@0 | 538 | void setKeywordForBookmark(in long long aItemId, in AString aKeyword); |
michael@0 | 539 | |
michael@0 | 540 | /** |
michael@0 | 541 | * Retrieves the keyword for the given URI. Will be void string |
michael@0 | 542 | * (null in JS) if no such keyword is found. |
michael@0 | 543 | */ |
michael@0 | 544 | AString getKeywordForURI(in nsIURI aURI); |
michael@0 | 545 | |
michael@0 | 546 | /** |
michael@0 | 547 | * Retrieves the keyword for the given bookmark. Will be void string |
michael@0 | 548 | * (null in JS) if no such keyword is found. |
michael@0 | 549 | */ |
michael@0 | 550 | AString getKeywordForBookmark(in long long aItemId); |
michael@0 | 551 | |
michael@0 | 552 | /** |
michael@0 | 553 | * Returns the URI associated with the given keyword. Empty if no such |
michael@0 | 554 | * keyword is found. |
michael@0 | 555 | */ |
michael@0 | 556 | nsIURI getURIForKeyword(in AString keyword); |
michael@0 | 557 | |
michael@0 | 558 | /** |
michael@0 | 559 | * Adds a bookmark observer. If ownsWeak is false, the bookmark service will |
michael@0 | 560 | * keep an owning reference to the observer. If ownsWeak is true, then |
michael@0 | 561 | * aObserver must implement nsISupportsWeakReference, and the bookmark |
michael@0 | 562 | * service will keep a weak reference to the observer. |
michael@0 | 563 | */ |
michael@0 | 564 | void addObserver(in nsINavBookmarkObserver observer, in boolean ownsWeak); |
michael@0 | 565 | |
michael@0 | 566 | /** |
michael@0 | 567 | * Removes a bookmark observer. |
michael@0 | 568 | */ |
michael@0 | 569 | void removeObserver(in nsINavBookmarkObserver observer); |
michael@0 | 570 | |
michael@0 | 571 | /** |
michael@0 | 572 | * Runs the passed callback inside of a database transaction. |
michael@0 | 573 | * Use this when a lot of things are about to change, for example |
michael@0 | 574 | * adding or deleting a large number of bookmark items. Calls can |
michael@0 | 575 | * be nested. Observers are notified when batches begin and end, via |
michael@0 | 576 | * nsINavBookmarkObserver.onBeginUpdateBatch/onEndUpdateBatch. |
michael@0 | 577 | * |
michael@0 | 578 | * @param aCallback |
michael@0 | 579 | * nsINavHistoryBatchCallback interface to call. |
michael@0 | 580 | * @param aUserData |
michael@0 | 581 | * Opaque parameter passed to nsINavBookmarksBatchCallback |
michael@0 | 582 | */ |
michael@0 | 583 | void runInBatchMode(in nsINavHistoryBatchCallback aCallback, |
michael@0 | 584 | in nsISupports aUserData); |
michael@0 | 585 | }; |