2008-06-06 19:28:01 -07:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Bookmarks Sync.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Mozilla.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2007
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Dan Mills <thunder@mozilla.com>
|
|
|
|
* Jono DiCarlo <jdicarlo@mozilla.org>
|
2008-08-04 17:23:23 -07:00
|
|
|
* Anant Narayanan <anant@kix.in>
|
2008-06-06 19:28:01 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2008-06-30 18:50:06 -07:00
|
|
|
const EXPORTED_SYMBOLS = ['BookmarksEngine', 'BookmarksSharingManager'];
|
2008-06-03 12:38:48 -07:00
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
|
2008-06-09 11:48:52 -07:00
|
|
|
// Annotation to use for shared bookmark folders, incoming and outgoing:
|
|
|
|
const INCOMING_SHARED_ANNO = "weave/shared-incoming";
|
|
|
|
const OUTGOING_SHARED_ANNO = "weave/shared-outgoing";
|
2008-06-18 12:26:51 -07:00
|
|
|
const SERVER_PATH_ANNO = "weave/shared-server-path";
|
|
|
|
// Standard names for shared files on the server
|
|
|
|
const KEYRING_FILE_NAME = "keyring";
|
|
|
|
const SHARED_BOOKMARK_FILE_NAME = "shared_bookmarks";
|
2008-06-24 18:38:29 -07:00
|
|
|
// Information for the folder that contains all incoming shares
|
|
|
|
const INCOMING_SHARE_ROOT_ANNO = "weave/mounted-shares-folder";
|
|
|
|
const INCOMING_SHARE_ROOT_NAME = "Shared Folders";
|
|
|
|
|
2008-12-11 14:26:20 -08:00
|
|
|
const SERVICE_NOT_SUPPORTED = "Service not supported on this platform";
|
|
|
|
|
2008-06-29 11:44:27 -07:00
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
2008-06-03 12:38:48 -07:00
|
|
|
Cu.import("resource://weave/log4moz.js");
|
|
|
|
Cu.import("resource://weave/util.js");
|
|
|
|
Cu.import("resource://weave/async.js");
|
|
|
|
Cu.import("resource://weave/engines.js");
|
|
|
|
Cu.import("resource://weave/stores.js");
|
|
|
|
Cu.import("resource://weave/trackers.js");
|
2008-06-20 17:19:10 -07:00
|
|
|
Cu.import("resource://weave/identity.js");
|
2008-06-26 17:00:55 -07:00
|
|
|
Cu.import("resource://weave/notifications.js");
|
2008-11-03 15:00:38 -08:00
|
|
|
Cu.import("resource://weave/resource.js");
|
2008-12-28 19:59:44 -08:00
|
|
|
Cu.import("resource://weave/type_records/bookmark.js");
|
2008-06-03 12:38:48 -07:00
|
|
|
|
|
|
|
Function.prototype.async = Async.sugar;
|
|
|
|
|
2008-12-09 12:26:14 -08:00
|
|
|
function BookmarksEngine() {
|
|
|
|
this._init();
|
2008-06-24 21:15:14 -07:00
|
|
|
}
|
|
|
|
BookmarksEngine.prototype = {
|
2008-12-05 00:39:54 -08:00
|
|
|
__proto__: SyncEngine.prototype,
|
2009-01-06 13:54:18 -08:00
|
|
|
name: "bookmarks",
|
|
|
|
displayName: "Bookmarks",
|
|
|
|
logName: "Bookmarks",
|
|
|
|
_storeObj: BookmarksStore,
|
|
|
|
_trackerObj: BookmarksTracker
|
2008-06-03 12:38:48 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
function BookmarksStore() {
|
|
|
|
this._init();
|
2009-04-07 17:22:36 -07:00
|
|
|
|
|
|
|
// Initialize the special top level folders
|
|
|
|
[["menu", "bookmarksMenuFolder"],
|
|
|
|
["toolbar", "toolbarFolder"],
|
|
|
|
["unfiled", "unfiledBookmarksFolder"],
|
|
|
|
].forEach(function(top) this.specialIds[top[0]] = this._bms[top[1]], this);
|
2008-06-03 12:38:48 -07:00
|
|
|
}
|
|
|
|
BookmarksStore.prototype = {
|
2008-11-06 19:18:46 -08:00
|
|
|
__proto__: Store.prototype,
|
2008-06-03 12:38:48 -07:00
|
|
|
_logName: "BStore",
|
2009-04-07 17:22:36 -07:00
|
|
|
specialIds: {},
|
2008-06-03 12:38:48 -07:00
|
|
|
|
|
|
|
__bms: null,
|
|
|
|
get _bms() {
|
|
|
|
if (!this.__bms)
|
|
|
|
this.__bms = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
|
|
|
|
getService(Ci.nsINavBookmarksService);
|
|
|
|
return this.__bms;
|
|
|
|
},
|
|
|
|
|
|
|
|
__hsvc: null,
|
|
|
|
get _hsvc() {
|
|
|
|
if (!this.__hsvc)
|
|
|
|
this.__hsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
|
|
|
getService(Ci.nsINavHistoryService);
|
|
|
|
return this.__hsvc;
|
|
|
|
},
|
|
|
|
|
|
|
|
__ls: null,
|
|
|
|
get _ls() {
|
|
|
|
if (!this.__ls)
|
|
|
|
this.__ls = Cc["@mozilla.org/browser/livemark-service;2"].
|
|
|
|
getService(Ci.nsILivemarkService);
|
|
|
|
return this.__ls;
|
|
|
|
},
|
|
|
|
|
|
|
|
get _ms() {
|
2008-12-28 19:59:44 -08:00
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
ms = Cc["@mozilla.org/microsummary/service;1"].
|
|
|
|
getService(Ci.nsIMicrosummaryService);
|
|
|
|
} catch (e) {
|
|
|
|
ms = null;
|
|
|
|
this._log.warn("Could not load microsummary service");
|
|
|
|
this._log.debug(e);
|
|
|
|
}
|
|
|
|
this.__defineGetter__("_ms", function() ms);
|
|
|
|
return ms;
|
2008-06-03 12:38:48 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
__ts: null,
|
|
|
|
get _ts() {
|
|
|
|
if (!this.__ts)
|
|
|
|
this.__ts = Cc["@mozilla.org/browser/tagging-service;1"].
|
|
|
|
getService(Ci.nsITaggingService);
|
|
|
|
return this.__ts;
|
|
|
|
},
|
|
|
|
|
|
|
|
__ans: null,
|
|
|
|
get _ans() {
|
|
|
|
if (!this.__ans)
|
|
|
|
this.__ans = Cc["@mozilla.org/browser/annotation-service;1"].
|
|
|
|
getService(Ci.nsIAnnotationService);
|
|
|
|
return this.__ans;
|
|
|
|
},
|
|
|
|
|
|
|
|
_getItemIdForGUID: function BStore__getItemIdForGUID(GUID) {
|
2009-04-07 17:22:36 -07:00
|
|
|
if (GUID in this.specialIds)
|
|
|
|
return this.specialIds[GUID];
|
|
|
|
|
|
|
|
return this._bms.getItemIdForGUID(GUID);
|
2008-06-03 12:38:48 -07:00
|
|
|
},
|
2008-06-29 11:44:27 -07:00
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
_getWeaveIdForItem: function BStore__getWeaveIdForItem(placeId) {
|
2009-04-07 17:22:36 -07:00
|
|
|
for (let [weaveId, id] in Iterator(this.specialIds))
|
|
|
|
if (placeId == id)
|
|
|
|
return weaveId;
|
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
return this._bms.getItemGUID(placeId);
|
|
|
|
},
|
|
|
|
|
|
|
|
_isToplevel: function BStore__isToplevel(placeId) {
|
2009-04-07 17:22:36 -07:00
|
|
|
for (let [weaveId, id] in Iterator(this.specialIds))
|
|
|
|
if (placeId == id)
|
|
|
|
return true;
|
|
|
|
|
2009-01-06 13:54:18 -08:00
|
|
|
if (this._bms.getFolderIdForItem(placeId) <= 0)
|
|
|
|
return true;
|
2008-12-28 19:59:44 -08:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2008-12-29 23:28:17 -08:00
|
|
|
itemExists: function BStore_itemExists(id) {
|
2009-01-06 13:54:18 -08:00
|
|
|
return this._getItemIdForGUID(id) > 0;
|
2008-11-19 16:21:12 -08:00
|
|
|
},
|
|
|
|
|
2008-12-16 17:06:45 -08:00
|
|
|
create: function BStore_create(record) {
|
2008-06-03 12:38:48 -07:00
|
|
|
let newId;
|
2008-12-23 11:30:31 -08:00
|
|
|
let parentId = this._getItemIdForGUID(record.parentid);
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2009-01-06 13:54:18 -08:00
|
|
|
if (parentId <= 0) {
|
2008-06-03 12:38:48 -07:00
|
|
|
this._log.warn("Creating node with unknown parent -> reparenting to root");
|
|
|
|
parentId = this._bms.bookmarksMenuFolder;
|
|
|
|
}
|
|
|
|
|
2008-12-23 11:30:31 -08:00
|
|
|
switch (record.cleartext.type) {
|
2008-06-03 12:38:48 -07:00
|
|
|
case "query":
|
|
|
|
case "bookmark":
|
|
|
|
case "microsummary": {
|
2008-12-23 11:30:31 -08:00
|
|
|
this._log.debug(" -> creating bookmark \"" + record.cleartext.title + "\"");
|
2008-12-28 19:59:44 -08:00
|
|
|
let uri = Utils.makeURI(record.cleartext.uri);
|
2009-02-04 19:51:20 -08:00
|
|
|
this._log.debug(" -> -> ParentID is " + parentId);
|
|
|
|
this._log.debug(" -> -> uri is " + record.cleartext.uri);
|
|
|
|
this._log.debug(" -> -> sortindex is " + record.sortindex);
|
|
|
|
this._log.debug(" -> -> title is " + record.cleartext.title);
|
2008-12-28 19:59:44 -08:00
|
|
|
newId = this._bms.insertBookmark(parentId, uri, record.sortindex,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.title);
|
2008-12-28 19:59:44 -08:00
|
|
|
this._ts.untagURI(uri, null);
|
|
|
|
this._ts.tagURI(uri, record.cleartext.tags);
|
2008-12-23 11:30:31 -08:00
|
|
|
this._bms.setKeywordForBookmark(newId, record.cleartext.keyword);
|
|
|
|
if (record.cleartext.description) {
|
2008-06-03 12:38:48 -07:00
|
|
|
this._ans.setItemAnnotation(newId, "bookmarkProperties/description",
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.description, 0,
|
2008-12-16 17:06:45 -08:00
|
|
|
this._ans.EXPIRE_NEVER);
|
2008-06-03 12:38:48 -07:00
|
|
|
}
|
|
|
|
|
2008-12-23 11:30:31 -08:00
|
|
|
if (record.cleartext.type == "microsummary") {
|
2008-06-03 12:38:48 -07:00
|
|
|
this._log.debug(" \-> is a microsummary");
|
|
|
|
this._ans.setItemAnnotation(newId, "bookmarks/staticTitle",
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.staticTitle || "", 0, this._ans.EXPIRE_NEVER);
|
|
|
|
let genURI = Utils.makeURI(record.cleartext.generatorURI);
|
2008-12-29 23:28:17 -08:00
|
|
|
if (this._ms) {
|
2008-12-11 14:26:20 -08:00
|
|
|
try {
|
2008-12-28 19:59:44 -08:00
|
|
|
let micsum = this._ms.createMicrosummary(uri, genURI);
|
2008-12-11 14:26:20 -08:00
|
|
|
this._ms.setMicrosummary(newId, micsum);
|
|
|
|
}
|
|
|
|
catch(ex) { /* ignore "missing local generator" exceptions */ }
|
2008-12-29 23:28:17 -08:00
|
|
|
} else {
|
|
|
|
this._log.warn("Can't create microsummary -- not supported.");
|
2008-12-11 14:26:20 -08:00
|
|
|
}
|
2008-06-03 12:38:48 -07:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case "folder":
|
2008-12-23 11:30:31 -08:00
|
|
|
this._log.debug(" -> creating folder \"" + record.cleartext.title + "\"");
|
2008-06-03 12:38:48 -07:00
|
|
|
newId = this._bms.createFolder(parentId,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.title,
|
|
|
|
record.sortindex);
|
2008-06-24 18:09:41 -07:00
|
|
|
// If folder is an outgoing share, put the annotations on it:
|
2008-12-23 11:30:31 -08:00
|
|
|
if ( record.cleartext.outgoingSharedAnno != undefined ) {
|
2008-06-24 18:09:41 -07:00
|
|
|
this._ans.setItemAnnotation(newId,
|
2008-06-24 18:28:01 -07:00
|
|
|
OUTGOING_SHARED_ANNO,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.outgoingSharedAnno,
|
2008-06-24 18:09:41 -07:00
|
|
|
0,
|
|
|
|
this._ans.EXPIRE_NEVER);
|
|
|
|
this._ans.setItemAnnotation(newId,
|
|
|
|
SERVER_PATH_ANNO,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.serverPathAnno,
|
2008-06-24 18:09:41 -07:00
|
|
|
0,
|
|
|
|
this._ans.EXPIRE_NEVER);
|
|
|
|
|
|
|
|
}
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
|
|
|
case "livemark":
|
2008-12-23 11:30:31 -08:00
|
|
|
this._log.debug(" -> creating livemark \"" + record.cleartext.title + "\"");
|
2008-06-03 12:38:48 -07:00
|
|
|
newId = this._ls.createLivemark(parentId,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.title,
|
|
|
|
Utils.makeURI(record.cleartext.siteURI),
|
|
|
|
Utils.makeURI(record.cleartext.feedURI),
|
|
|
|
record.sortindex);
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
2008-06-24 18:09:41 -07:00
|
|
|
case "incoming-share":
|
2008-06-24 18:23:43 -07:00
|
|
|
/* even though incoming shares are folders according to the
|
|
|
|
* bookmarkService, _wrap() wraps them as type=incoming-share, so we
|
|
|
|
* handle them separately, like so: */
|
2008-12-23 11:30:31 -08:00
|
|
|
this._log.debug(" -> creating incoming-share \"" + record.cleartext.title + "\"");
|
2008-06-24 18:09:41 -07:00
|
|
|
newId = this._bms.createFolder(parentId,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.title,
|
|
|
|
record.sortindex);
|
2008-06-24 18:28:01 -07:00
|
|
|
this._ans.setItemAnnotation(newId,
|
|
|
|
INCOMING_SHARED_ANNO,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.incomingSharedAnno,
|
2008-06-24 18:28:01 -07:00
|
|
|
0,
|
|
|
|
this._ans.EXPIRE_NEVER);
|
|
|
|
this._ans.setItemAnnotation(newId,
|
|
|
|
SERVER_PATH_ANNO,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.serverPathAnno,
|
2008-06-24 18:28:01 -07:00
|
|
|
0,
|
|
|
|
this._ans.EXPIRE_NEVER);
|
2008-06-24 18:09:41 -07:00
|
|
|
break;
|
2008-06-03 12:38:48 -07:00
|
|
|
case "separator":
|
|
|
|
this._log.debug(" -> creating separator");
|
2008-12-23 11:30:31 -08:00
|
|
|
newId = this._bms.insertSeparator(parentId, record.sortindex);
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-23 11:30:31 -08:00
|
|
|
this._log.error("_create: Unknown item type: " + record.cleartext.type);
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
|
|
|
}
|
2008-12-05 00:39:54 -08:00
|
|
|
if (newId) {
|
2008-12-23 11:30:31 -08:00
|
|
|
this._log.trace("Setting GUID of new item " + newId + " to " + record.id);
|
2008-12-06 00:12:40 -08:00
|
|
|
let cur = this._bms.getItemGUID(newId);
|
2008-12-23 11:30:31 -08:00
|
|
|
if (cur == record.id)
|
|
|
|
this._log.warn("Item " + newId + " already has GUID " + record.id);
|
2008-12-06 00:12:40 -08:00
|
|
|
else {
|
2008-12-23 11:30:31 -08:00
|
|
|
this._bms.setItemGUID(newId, record.id);
|
|
|
|
Engines.get("bookmarks")._tracker._all[newId] = record.id; // HACK - see tracker
|
2008-12-06 00:12:40 -08:00
|
|
|
}
|
2008-12-05 00:39:54 -08:00
|
|
|
}
|
2008-06-03 12:38:48 -07:00
|
|
|
},
|
|
|
|
|
2008-12-16 17:06:45 -08:00
|
|
|
remove: function BStore_remove(record) {
|
2009-04-07 17:22:36 -07:00
|
|
|
if (record.id in this.specialIds) {
|
2008-12-16 17:06:45 -08:00
|
|
|
this._log.warn("Attempted to remove root node (" + record.id +
|
|
|
|
"). Skipping record removal.");
|
2008-06-03 12:38:48 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-16 17:06:45 -08:00
|
|
|
var itemId = this._bms.getItemIdForGUID(record.id);
|
2009-01-06 13:54:18 -08:00
|
|
|
if (itemId <= 0) {
|
2008-12-19 11:48:09 -08:00
|
|
|
this._log.debug("Item " + record.id + " already removed");
|
2008-06-03 12:38:48 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var type = this._bms.getItemType(itemId);
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case this._bms.TYPE_BOOKMARK:
|
2008-12-16 17:06:45 -08:00
|
|
|
this._log.debug(" -> removing bookmark " + record.id);
|
2008-06-03 12:38:48 -07:00
|
|
|
this._bms.removeItem(itemId);
|
|
|
|
break;
|
|
|
|
case this._bms.TYPE_FOLDER:
|
2008-12-16 17:06:45 -08:00
|
|
|
this._log.debug(" -> removing folder " + record.id);
|
2008-06-03 12:38:48 -07:00
|
|
|
this._bms.removeFolder(itemId);
|
|
|
|
break;
|
|
|
|
case this._bms.TYPE_SEPARATOR:
|
2008-12-16 17:06:45 -08:00
|
|
|
this._log.debug(" -> removing separator " + record.id);
|
2008-06-03 12:38:48 -07:00
|
|
|
this._bms.removeItem(itemId);
|
|
|
|
break;
|
|
|
|
default:
|
2008-12-16 17:06:45 -08:00
|
|
|
this._log.error("remove: Unknown item type: " + type);
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-12-16 17:06:45 -08:00
|
|
|
update: function BStore_update(record) {
|
2008-12-23 11:30:31 -08:00
|
|
|
let itemId = this._getItemIdForGUID(record.id);
|
2008-12-16 17:06:45 -08:00
|
|
|
|
2009-04-07 17:22:36 -07:00
|
|
|
if (record.id in this.specialIds) {
|
2008-12-23 11:30:31 -08:00
|
|
|
this._log.debug("Skipping update for root node.");
|
2008-06-03 12:38:48 -07:00
|
|
|
return;
|
|
|
|
}
|
2009-01-06 13:54:18 -08:00
|
|
|
if (itemId <= 0) {
|
2008-12-23 11:30:31 -08:00
|
|
|
this._log.debug("Skipping update for unknown item: " + record.id);
|
2008-06-03 12:38:48 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-23 11:30:31 -08:00
|
|
|
this._log.trace("Updating " + record.id + " (" + itemId + ")");
|
|
|
|
|
|
|
|
if ((this._bms.getItemIndex(itemId) != record.sortindex) ||
|
|
|
|
(this._bms.getFolderIdForItem(itemId) !=
|
|
|
|
this._getItemIdForGUID(record.parentid))) {
|
|
|
|
this._log.trace("Moving item (changing folder/index)");
|
|
|
|
let parentid = this._getItemIdForGUID(record.parentid);
|
|
|
|
this._bms.moveItem(itemId, parentid, record.sortindex);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let key in record.cleartext) {
|
2008-06-03 12:38:48 -07:00
|
|
|
switch (key) {
|
|
|
|
case "title":
|
2008-12-23 11:30:31 -08:00
|
|
|
this._bms.setItemTitle(itemId, record.cleartext.title);
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
2008-12-28 19:59:44 -08:00
|
|
|
case "uri":
|
|
|
|
this._bms.changeBookmarkURI(itemId, Utils.makeURI(record.cleartext.uri));
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
|
|
|
case "tags": {
|
2008-07-31 00:21:22 -07:00
|
|
|
// filter out null/undefined/empty tags
|
2008-12-23 11:30:31 -08:00
|
|
|
let tags = record.cleartext.tags.filter(function(t) t);
|
2008-06-03 12:38:48 -07:00
|
|
|
let tagsURI = this._bms.getBookmarkURI(itemId);
|
|
|
|
this._ts.untagURI(tagsURI, null);
|
2008-07-31 00:21:22 -07:00
|
|
|
this._ts.tagURI(tagsURI, tags);
|
2008-06-03 12:38:48 -07:00
|
|
|
} break;
|
|
|
|
case "keyword":
|
2008-12-23 11:30:31 -08:00
|
|
|
this._bms.setKeywordForBookmark(itemId, record.cleartext.keyword);
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
|
|
|
case "description":
|
2008-12-23 11:30:31 -08:00
|
|
|
this._ans.setItemAnnotation(itemId, "bookmarkProperties/description",
|
|
|
|
record.cleartext.description, 0,
|
|
|
|
this._ans.EXPIRE_NEVER);
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
|
|
|
case "generatorURI": {
|
2009-01-21 19:04:13 -08:00
|
|
|
try {
|
|
|
|
let micsumURI = Utils.makeURI(this._bms.getBookmarkURI(itemId));
|
|
|
|
let genURI = Utils.makeURI(record.cleartext.generatorURI);
|
|
|
|
if (this._ms == SERVICE_NOT_SUPPORTED) {
|
|
|
|
this._log.warn("Can't create microsummary -- not supported.");
|
|
|
|
} else {
|
|
|
|
let micsum = this._ms.createMicrosummary(micsumURI, genURI);
|
|
|
|
this._ms.setMicrosummary(itemId, micsum);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
this._log.debug("Could not set microsummary generator URI: " + e);
|
|
|
|
}
|
2008-06-03 12:38:48 -07:00
|
|
|
} break;
|
|
|
|
case "siteURI":
|
2008-12-23 11:30:31 -08:00
|
|
|
this._ls.setSiteURI(itemId, Utils.makeURI(record.cleartext.siteURI));
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
|
|
|
case "feedURI":
|
2008-12-23 11:30:31 -08:00
|
|
|
this._ls.setFeedURI(itemId, Utils.makeURI(record.cleartext.feedURI));
|
2008-06-03 12:38:48 -07:00
|
|
|
break;
|
2008-06-24 18:28:01 -07:00
|
|
|
case "outgoingSharedAnno":
|
|
|
|
this._ans.setItemAnnotation(itemId, OUTGOING_SHARED_ANNO,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.outgoingSharedAnno, 0,
|
2008-06-24 18:15:17 -07:00
|
|
|
this._ans.EXPIRE_NEVER);
|
|
|
|
break;
|
2008-06-24 18:28:01 -07:00
|
|
|
case "incomingSharedAnno":
|
|
|
|
this._ans.setItemAnnotation(itemId, INCOMING_SHARED_ANNO,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.incomingSharedAnno, 0,
|
2008-06-24 18:15:17 -07:00
|
|
|
this._ans.EXPIRE_NEVER);
|
|
|
|
break;
|
|
|
|
case "serverPathAnno":
|
|
|
|
this._ans.setItemAnnotation(itemId, SERVER_PATH_ANNO,
|
2008-12-23 11:30:31 -08:00
|
|
|
record.cleartext.serverPathAnno, 0,
|
2008-06-24 18:15:17 -07:00
|
|
|
this._ans.EXPIRE_NEVER);
|
|
|
|
break;
|
2008-06-03 12:38:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-12-08 13:21:25 -08:00
|
|
|
changeItemID: function BStore_changeItemID(oldID, newID) {
|
2008-12-05 00:39:54 -08:00
|
|
|
var itemId = this._getItemIdForGUID(oldID);
|
|
|
|
if (itemId == null) // toplevel folder
|
|
|
|
return;
|
2009-01-06 13:54:18 -08:00
|
|
|
if (itemId <= 0) {
|
2008-11-26 07:25:28 -08:00
|
|
|
this._log.warn("Can't change GUID " + oldID + " to " +
|
|
|
|
newID + ": Item does not exist");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var collision = this._getItemIdForGUID(newID);
|
2009-01-06 13:54:18 -08:00
|
|
|
if (collision > 0) {
|
2008-11-26 07:25:28 -08:00
|
|
|
this._log.warn("Can't change GUID " + oldID + " to " +
|
|
|
|
newID + ": new ID already in use");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._log.debug("Changing GUID " + oldID + " to " + newID);
|
|
|
|
this._bms.setItemGUID(itemId, newID);
|
2008-12-06 00:12:40 -08:00
|
|
|
Engines.get("bookmarks")._tracker._all[itemId] = newID; // HACK - see tracker
|
2008-11-26 07:25:28 -08:00
|
|
|
},
|
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
_getNode: function BStore__getNode(folder) {
|
2008-06-03 12:38:48 -07:00
|
|
|
let query = this._hsvc.getNewQuery();
|
|
|
|
query.setFolders([folder], 1);
|
|
|
|
return this._hsvc.executeQuery(query, this._hsvc.getNewQueryOptions()).root;
|
|
|
|
},
|
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
// XXX a little inefficient - isToplevel calls getFolderIdForItem too
|
|
|
|
_itemDepth: function BStore__itemDepth(id) {
|
|
|
|
if (this._isToplevel(id))
|
|
|
|
return 0;
|
|
|
|
return this._itemDepth(this._bms.getFolderIdForItem(id)) + 1;
|
|
|
|
},
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
_getTags: function BStore__getTags(uri) {
|
|
|
|
try {
|
|
|
|
if (typeof(uri) == "string")
|
|
|
|
uri = Utils.makeURI(uri);
|
|
|
|
} catch(e) {
|
|
|
|
this._log.warn("Could not parse URI \"" + uri + "\": " + e);
|
2008-06-03 12:38:48 -07:00
|
|
|
}
|
2008-12-28 19:59:44 -08:00
|
|
|
return this._ts.getTagsForURI(uri, {});
|
|
|
|
},
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
_getDescription: function BStore__getDescription(id) {
|
|
|
|
try {
|
|
|
|
return this._ans.getItemAnnotation(id, "bookmarkProperties/description");
|
|
|
|
} catch (e) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_getStaticTitle: function BStore__getStaticTitle(id) {
|
|
|
|
try {
|
|
|
|
return this._ans.getItemAnnotation(id, "bookmarks/staticTitle");
|
|
|
|
} catch (e) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Create a record starting from the weave id (places guid)
|
2009-02-19 00:36:55 -08:00
|
|
|
createRecord: function BStore_createRecord(guid, cryptoMetaURL) {
|
2008-12-30 23:52:20 -08:00
|
|
|
let record = this.cache.get(guid);
|
|
|
|
if (record)
|
|
|
|
return record;
|
2008-12-28 19:59:44 -08:00
|
|
|
|
|
|
|
let placeId = this._bms.getItemIdForGUID(guid);
|
2009-01-06 13:54:18 -08:00
|
|
|
if (placeId <= 0) { // deleted item
|
2008-12-28 19:59:44 -08:00
|
|
|
record = new PlacesItem();
|
2009-01-27 17:23:23 -08:00
|
|
|
record.id = guid;
|
2009-04-03 10:38:47 -07:00
|
|
|
record.deleted = true;
|
2009-03-11 01:40:04 -07:00
|
|
|
this.cache.put(guid, record);
|
2008-12-28 19:59:44 -08:00
|
|
|
return record;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (this._bms.getItemType(placeId)) {
|
|
|
|
case this._bms.TYPE_BOOKMARK:
|
|
|
|
if (this._ms && this._ms.hasMicrosummary(placeId)) {
|
|
|
|
record = new BookmarkMicsum();
|
|
|
|
let micsum = this._ms.getMicrosummary(placeId);
|
|
|
|
record.generatorURI = micsum.generator.uri; // breaks local generators
|
|
|
|
record.staticTitle = this._getStaticTitle(placeId);
|
2008-06-24 18:09:41 -07:00
|
|
|
|
2008-06-03 12:38:48 -07:00
|
|
|
} else {
|
2008-12-28 19:59:44 -08:00
|
|
|
record = new Bookmark();
|
|
|
|
record.title = this._bms.getItemTitle(placeId);
|
2008-06-03 12:38:48 -07:00
|
|
|
}
|
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
record.bmkUri = this._bms.getBookmarkURI(placeId);
|
|
|
|
record.tags = this._getTags(record.bmkUri);
|
|
|
|
record.keyword = this._bms.getKeywordForBookmark(placeId);
|
|
|
|
record.description = this._getDescription(placeId);
|
|
|
|
break;
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
case this._bms.TYPE_FOLDER:
|
|
|
|
if (this._ls.isLivemark(placeId)) {
|
|
|
|
record = new Livemark();
|
|
|
|
record.siteURI = this._ls.getSiteURI(placeId);
|
|
|
|
record.feedURI = this._ls.getFeedURI(placeId);
|
2008-06-04 13:40:53 -07:00
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
} else {
|
|
|
|
record = new BookmarkFolder();
|
2008-06-04 13:40:53 -07:00
|
|
|
}
|
2009-04-01 15:12:08 -07:00
|
|
|
|
|
|
|
record.title = this._bms.getItemTitle(placeId);
|
2008-12-28 19:59:44 -08:00
|
|
|
break;
|
2008-06-04 13:40:53 -07:00
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
case this._bms.TYPE_SEPARATOR:
|
|
|
|
record = new BookmarkSeparator();
|
|
|
|
break;
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
case this._bms.TYPE_DYNAMIC_CONTAINER:
|
|
|
|
record = new PlacesItem();
|
|
|
|
this._log.warn("Don't know how to serialize dynamic containers yet");
|
|
|
|
break;
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
default:
|
|
|
|
record = new PlacesItem();
|
|
|
|
this._log.warn("Unknown item type, cannot serialize: " +
|
|
|
|
this._bms.getItemType(placeId));
|
2008-06-03 12:38:48 -07:00
|
|
|
}
|
|
|
|
|
2009-01-27 16:54:54 -08:00
|
|
|
record.id = guid;
|
2009-01-02 13:49:19 -08:00
|
|
|
record.parentid = this._getWeaveParentIdForItem(placeId);
|
2008-12-28 19:59:44 -08:00
|
|
|
record.depth = this._itemDepth(placeId);
|
|
|
|
record.sortindex = this._bms.getItemIndex(placeId);
|
2009-02-19 00:36:55 -08:00
|
|
|
record.encryption = cryptoMetaURL;
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2008-12-30 23:52:20 -08:00
|
|
|
this.cache.put(guid, record);
|
2008-12-28 19:59:44 -08:00
|
|
|
return record;
|
2008-06-03 12:38:48 -07:00
|
|
|
},
|
|
|
|
|
2009-01-13 13:40:40 -08:00
|
|
|
_createMiniRecord: function BStore__createMiniRecord(placesId, depthIndex) {
|
|
|
|
let foo = {id: this._bms.getItemGUID(placesId)};
|
|
|
|
if (depthIndex) {
|
|
|
|
foo.depth = this._itemDepth(placesId);
|
|
|
|
foo.sortindex = this._bms.getItemIndex(placesId);
|
|
|
|
}
|
|
|
|
return foo;
|
|
|
|
},
|
|
|
|
|
2009-01-02 13:49:19 -08:00
|
|
|
_getWeaveParentIdForItem: function BStore__getWeaveParentIdForItem(itemId) {
|
2009-01-08 21:33:59 -08:00
|
|
|
let parentid = this._bms.getFolderIdForItem(itemId);
|
|
|
|
if (parentid == -1) {
|
|
|
|
this._log.debug("Found orphan bookmark, reparenting to unfiled");
|
|
|
|
parentid = this._bms.unfiledBookmarksFolder;
|
|
|
|
this._bms.moveItem(itemId, parentid, -1);
|
|
|
|
}
|
|
|
|
return this._getWeaveIdForItem(parentid);
|
2009-01-02 13:49:19 -08:00
|
|
|
},
|
|
|
|
|
2009-01-02 21:13:32 -08:00
|
|
|
_getChildren: function BStore_getChildren(guid, depthIndex, items) {
|
2009-01-02 13:49:19 -08:00
|
|
|
if (typeof(items) == "undefined")
|
|
|
|
items = {};
|
2009-01-02 21:13:32 -08:00
|
|
|
let node = guid; // the recursion case
|
|
|
|
if (typeof(node) == "string") // callers will give us the guid as the first arg
|
|
|
|
node = this._getNode(this._getItemIdForGUID(guid));
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
if (node.type == node.RESULT_TYPE_FOLDER &&
|
|
|
|
!this._ls.isLivemark(node.itemId)) {
|
|
|
|
node.QueryInterface(Ci.nsINavHistoryQueryResultNode);
|
|
|
|
node.containerOpen = true;
|
|
|
|
for (var i = 0; i < node.childCount; i++) {
|
|
|
|
let child = node.getChild(i);
|
2009-03-11 02:02:58 -07:00
|
|
|
let foo = this._createMiniRecord(child.itemId, true);
|
2009-01-02 13:49:19 -08:00
|
|
|
items[foo.id] = foo;
|
2009-01-02 21:13:32 -08:00
|
|
|
this._getChildren(child, depthIndex, items);
|
2008-12-28 19:59:44 -08:00
|
|
|
}
|
|
|
|
}
|
2008-12-08 09:53:32 -08:00
|
|
|
|
2008-12-28 19:59:44 -08:00
|
|
|
return items;
|
2008-12-08 09:53:32 -08:00
|
|
|
},
|
|
|
|
|
2009-01-02 21:13:32 -08:00
|
|
|
_getSiblings: function BStore__getSiblings(guid, depthIndex, items) {
|
|
|
|
if (typeof(items) == "undefined")
|
|
|
|
items = {};
|
|
|
|
|
|
|
|
let parentid = this._bms.getFolderIdForItem(this._getItemIdForGUID(guid));
|
|
|
|
let parent = this._getNode(parentid);
|
|
|
|
parent.QueryInterface(Ci.nsINavHistoryQueryResultNode);
|
|
|
|
parent.containerOpen = true;
|
|
|
|
|
|
|
|
for (var i = 0; i < parent.childCount; i++) {
|
|
|
|
let child = parent.getChild(i);
|
2009-03-11 02:02:58 -07:00
|
|
|
let foo = this._createMiniRecord(child.itemId, true);
|
2009-01-02 21:13:32 -08:00
|
|
|
items[foo.id] = foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
return items;
|
|
|
|
},
|
|
|
|
|
|
|
|
getAllIDs: function BStore_getAllIDs() {
|
|
|
|
let items = {};
|
2009-04-07 17:22:36 -07:00
|
|
|
for (let [weaveId, id] in Iterator(this.specialIds))
|
|
|
|
this._getChildren(weaveId, true, items);
|
2009-01-02 21:13:32 -08:00
|
|
|
return items;
|
|
|
|
},
|
|
|
|
|
2009-01-02 13:49:19 -08:00
|
|
|
createMetaRecords: function BStore_createMetaRecords(guid, items) {
|
2009-01-02 21:13:32 -08:00
|
|
|
this._getChildren(guid, true, items);
|
|
|
|
this._getSiblings(guid, true, items);
|
2009-01-02 13:49:19 -08:00
|
|
|
return items;
|
|
|
|
},
|
|
|
|
|
2008-06-03 12:38:48 -07:00
|
|
|
wipe: function BStore_wipe() {
|
2009-04-07 17:22:36 -07:00
|
|
|
for (let [weaveId, id] in Iterator(this.specialIds))
|
|
|
|
this._bms.removeFolderChildren(id);
|
2008-06-03 12:38:48 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-12-05 00:39:54 -08:00
|
|
|
function BookmarksTracker() {
|
|
|
|
this._init();
|
2008-06-03 12:38:48 -07:00
|
|
|
}
|
|
|
|
BookmarksTracker.prototype = {
|
2008-11-06 19:18:46 -08:00
|
|
|
__proto__: Tracker.prototype,
|
2008-12-05 00:39:54 -08:00
|
|
|
_logName: "BmkTracker",
|
|
|
|
file: "bookmarks",
|
|
|
|
|
|
|
|
get _bms() {
|
|
|
|
let bms = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
|
|
|
|
getService(Ci.nsINavBookmarksService);
|
|
|
|
this.__defineGetter__("_bms", function() bms);
|
|
|
|
return bms;
|
|
|
|
},
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2009-01-15 13:58:59 -08:00
|
|
|
get _ls() {
|
|
|
|
let ls = Cc["@mozilla.org/browser/livemark-service;2"].
|
|
|
|
getService(Ci.nsILivemarkService);
|
|
|
|
this.__defineGetter__("_ls", function() ls);
|
|
|
|
return ls;
|
|
|
|
},
|
|
|
|
|
2008-11-19 16:21:12 -08:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavBookmarkObserver]),
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2008-12-05 00:39:54 -08:00
|
|
|
_init: function BMT__init() {
|
|
|
|
this.__proto__.__proto__._init.call(this);
|
2008-12-06 00:12:40 -08:00
|
|
|
|
|
|
|
// NOTE: since the callbacks give us item IDs (not GUIDs), we use
|
|
|
|
// getItemGUID to get it within the callback. For removals, however,
|
|
|
|
// that doesn't work because the item is already gone! (and worse, Places
|
|
|
|
// has a bug where it will generate a new one instead of throwing).
|
|
|
|
// Our solution: cache item IDs -> GUIDs
|
|
|
|
|
|
|
|
// FIXME: very roundabout way of getting id -> guid mapping!
|
|
|
|
let store = new BookmarksStore();
|
2008-12-28 19:59:44 -08:00
|
|
|
let all = store.getAllIDs();
|
2008-12-06 00:12:40 -08:00
|
|
|
this._all = {};
|
|
|
|
for (let guid in all) {
|
|
|
|
this._all[this._bms.getItemIdForGUID(guid)] = guid;
|
|
|
|
}
|
|
|
|
|
2009-04-07 17:22:36 -07:00
|
|
|
// Ignore changes to the special roots. We use special names for them, so
|
|
|
|
// ignore their "real" places guid as well as ours, just in case
|
|
|
|
for (let [weaveId, id] in Iterator(store.specialIds)) {
|
|
|
|
this.ignoreID(weaveId);
|
|
|
|
this.ignoreID(this._all[id]);
|
|
|
|
}
|
2009-01-13 14:43:21 -08:00
|
|
|
|
2008-12-05 00:39:54 -08:00
|
|
|
this._bms.addObserver(this, false);
|
2008-06-03 12:38:48 -07:00
|
|
|
},
|
|
|
|
|
2008-11-19 16:21:12 -08:00
|
|
|
/* Every add/remove/change is worth 10 points */
|
2008-12-06 00:12:40 -08:00
|
|
|
_upScore: function BMT__upScore() {
|
2008-11-19 16:21:12 -08:00
|
|
|
this._score += 10;
|
2008-06-03 12:38:48 -07:00
|
|
|
},
|
2008-11-19 16:21:12 -08:00
|
|
|
|
2008-12-06 00:12:40 -08:00
|
|
|
onItemAdded: function BMT_onEndUpdateBatch(itemId, folder, index) {
|
2009-02-02 11:43:06 -08:00
|
|
|
if (this.ignoreAll ||
|
|
|
|
this._ls.isLivemark(folder))
|
2009-01-15 13:58:59 -08:00
|
|
|
return;
|
2009-02-02 11:43:06 -08:00
|
|
|
|
2008-12-19 11:48:09 -08:00
|
|
|
this._log.trace("onItemAdded: " + itemId);
|
2009-02-02 11:43:06 -08:00
|
|
|
|
2009-01-13 15:55:35 -08:00
|
|
|
this._all[itemId] = this._bms.getItemGUID(itemId);
|
|
|
|
if (this.addChangedID(this._all[itemId]))
|
|
|
|
this._upScore();
|
2008-12-06 00:12:40 -08:00
|
|
|
},
|
|
|
|
|
2008-12-02 16:46:24 -08:00
|
|
|
onItemRemoved: function BMT_onItemRemoved(itemId, folder, index) {
|
2009-02-02 11:43:06 -08:00
|
|
|
if (this.ignoreAll ||
|
|
|
|
this._ls.isLivemark(folder))
|
2009-01-15 13:58:59 -08:00
|
|
|
return;
|
2009-02-02 11:43:06 -08:00
|
|
|
|
2008-12-06 00:12:40 -08:00
|
|
|
this._log.trace("onItemRemoved: " + itemId);
|
2009-02-02 11:43:06 -08:00
|
|
|
|
2009-01-13 15:55:35 -08:00
|
|
|
if (this.addChangedID(this._all[itemId]))
|
|
|
|
this._upScore();
|
2009-01-13 14:43:21 -08:00
|
|
|
delete this._all[itemId];
|
2008-06-03 12:38:48 -07:00
|
|
|
},
|
2008-11-19 16:21:12 -08:00
|
|
|
|
2009-01-13 15:55:35 -08:00
|
|
|
onItemChanged: function BMT_onItemChanged(itemId, property, isAnno, value) {
|
2009-02-02 11:43:06 -08:00
|
|
|
if (this.ignoreAll)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// ignore annotations except for the ones that we sync
|
|
|
|
if (isAnno && (property != "livemark/feedURI" ||
|
|
|
|
property != "livemark/siteURI" ||
|
|
|
|
property != "microsummary/generatorURI"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// ignore if parent is a livemark
|
2009-01-15 15:53:34 -08:00
|
|
|
if (this._ls.isLivemark(this._bms.getFolderIdForItem(itemId)))
|
2009-01-15 13:58:59 -08:00
|
|
|
return;
|
2009-02-02 11:43:06 -08:00
|
|
|
|
2009-01-13 15:55:35 -08:00
|
|
|
this._log.trace("onItemChanged: " + itemId +
|
2009-01-13 16:55:51 -08:00
|
|
|
(", " + property + (isAnno? " (anno)" : "")) +
|
|
|
|
(value? (" = \"" + value + "\"") : ""));
|
2009-01-13 15:55:35 -08:00
|
|
|
// 1) notifications for already-deleted items are ignored
|
|
|
|
// 2) note that engine/store are responsible for manually updating the
|
|
|
|
// tracker's placesId->weaveId cache
|
|
|
|
if ((itemId in this._all) &&
|
2009-01-27 16:54:54 -08:00
|
|
|
(this._bms.getItemGUID(itemId) == this._all[itemId]) &&
|
2009-01-13 15:55:35 -08:00
|
|
|
this.addChangedID(this._all[itemId]))
|
|
|
|
this._upScore();
|
2008-06-03 12:38:48 -07:00
|
|
|
},
|
|
|
|
|
2008-12-02 16:46:24 -08:00
|
|
|
onItemMoved: function BMT_onItemMoved(itemId, oldParent, oldIndex, newParent, newIndex) {
|
2009-02-02 11:43:06 -08:00
|
|
|
if (this.ignoreAll)
|
|
|
|
return;
|
|
|
|
|
2008-12-06 00:12:40 -08:00
|
|
|
this._log.trace("onItemMoved: " + itemId);
|
2009-02-02 11:43:06 -08:00
|
|
|
|
2009-01-21 19:04:13 -08:00
|
|
|
if (!this._all[itemId])
|
|
|
|
this._all[itemId] = this._bms.itemGUID(itemId);
|
2009-01-13 15:55:35 -08:00
|
|
|
if (this.addChangedID(this._all[itemId]))
|
|
|
|
this._upScore();
|
2008-11-19 16:21:12 -08:00
|
|
|
},
|
2008-06-03 12:38:48 -07:00
|
|
|
|
2008-11-19 16:21:12 -08:00
|
|
|
onBeginUpdateBatch: function BMT_onBeginUpdateBatch() {},
|
|
|
|
onEndUpdateBatch: function BMT_onEndUpdateBatch() {},
|
2008-12-02 16:46:24 -08:00
|
|
|
onItemVisited: function BMT_onItemVisited(itemId, aVisitID, time) {}
|
2008-11-06 19:18:46 -08:00
|
|
|
};
|