Merge lp:~urbanape/bindwood/thorough-debugging into lp:bindwood
- thorough-debugging
- Merge into trunk
Proposed by
Zachery Bir
Status: | Superseded |
---|---|
Proposed branch: | lp:~urbanape/bindwood/thorough-debugging |
Merge into: | lp:bindwood |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~urbanape/bindwood/thorough-debugging |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
dobey (community) | Needs Resubmitting | ||
Ubuntu One hackers | Pending | ||
Review via email: mp+10858@code.launchpad.net |
This proposal has been superseded by a proposal from 2009-08-31.
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Zachery Bir (urbanape) wrote : | # |
Revision history for this message
dobey (dobey) wrote : | # |
The code/logging looks ok, but I think the packaging should go in a separate branch... like a source package branch at ~ubuntuone-
review:
Needs Fixing
Revision history for this message
dobey (dobey) wrote : | # |
Pull the packaging stuff, and then change the proposal's status to "Resubmit" to create a new proposal which supersedes this one. (Make sure it's the proposal status, and not a review requesting a resubmission, which people seem to get confused by.)
review:
Needs Resubmitting
- 14. By Zachery Bir
-
Removed packaging info
- 15. By Zachery Bir
-
Resetting the time interval back to 30s
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory '.bzr-builddeb' |
2 | === added file '.bzr-builddeb/default.conf' |
3 | --- .bzr-builddeb/default.conf 1970-01-01 00:00:00 +0000 |
4 | +++ .bzr-builddeb/default.conf 2009-08-18 19:21:27 +0000 |
5 | @@ -0,0 +1,4 @@ |
6 | +[BUILDDEB] |
7 | +merge = True |
8 | +export-upstream-revision = revid:elliot@elliotmurphy.com-20090818180924-l23evvtklqqb8tji |
9 | +export-upstream = . |
10 | |
11 | === modified file 'content/sync.js' |
12 | --- content/sync.js 2009-08-18 14:17:30 +0000 |
13 | +++ content/sync.js 2009-08-27 18:45:48 +0000 |
14 | @@ -4,16 +4,17 @@ |
15 | * This program is free software: you can redistribute it and/or modify it |
16 | * under the terms of the GNU General Public License version 3, as published |
17 | * by the Free Software Foundation. |
18 | - * |
19 | + * |
20 | * This program is distributed in the hope that it will be useful, but |
21 | * WITHOUT ANY WARRANTY; without even the implied warranties of |
22 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
23 | * PURPOSE. See the GNU General Public License for more details. |
24 | - * |
25 | + * |
26 | * You should have received a copy of the GNU General Public License along |
27 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
28 | */ |
29 | /* Lots and lots of debugging information */ |
30 | + |
31 | var Bindwood = { |
32 | bookmarksService: Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"] |
33 | .getService(Components.interfaces.nsINavBookmarksService), |
34 | @@ -27,16 +28,20 @@ |
35 | .getService(Components.interfaces.nsINavHistoryService), |
36 | ioService: Components.classes["@mozilla.org/network/io-service;1"] |
37 | .getService(Components.interfaces.nsIIOService), |
38 | + envService: Components.classes["@mozilla.org/process/environment;1"] |
39 | + .getService(Components.interfaces.nsIEnvironment), |
40 | |
41 | annotationKey: "bindwood/uuid", |
42 | uuidItemIdMap: {}, |
43 | |
44 | generateUUIDString: function() { |
45 | - return Bindwood.uuidService.generateUUID().toString(); |
46 | + var uuid = Bindwood.uuidService.generateUUID().toString(); |
47 | + Bindwood.writeMessage("Generated UUID: " + uuid); |
48 | + return uuid; |
49 | }, |
50 | |
51 | - annotateItemWithUUID: function(itemId, uuid) { |
52 | - var uuid = uuid ? uuid : Bindwood.generateUUIDString(); |
53 | + annotateItemWithUUID: function(itemId, seed_uuid) { |
54 | + var uuid = seed_uuid ? seed_uuid : Bindwood.generateUUIDString(); |
55 | Bindwood.annotationService.setItemAnnotation(itemId, Bindwood.annotationKey, uuid, 0, Bindwood.annotationService.EXPIRE_NEVER); |
56 | // Whenever we create a new UUID, stash it and the itemId in |
57 | // our local cache. |
58 | @@ -47,16 +52,24 @@ |
59 | itemIdForUUID: function(uuid) { |
60 | // First, try to look it up in our local cache, barring that |
61 | // (which shouldn't happen), look it up slowly. |
62 | + Bindwood.writeMessage("Looking up itemId for uuid: " + uuid); |
63 | var itemId = Bindwood.uuidItemIdMap[uuid]; |
64 | |
65 | if (!itemId) { |
66 | + Bindwood.writeMessage("Didn't find itemId, looking up annotations"); |
67 | var items = Bindwood.annotationService.getItemsWithAnnotation(Bindwood.annotationKey, {}); |
68 | + var num_items = items.length; |
69 | + Bindwood.writeMessage("Looking through " + num_items + "item" + (num_items != 1 ? "s" : "")); |
70 | for (var i = 0; i < items.length; i++) { |
71 | if (Bindwood.annotationService.getItemAnnotation(items[i], Bindwood.annotationKey) == uuid) { |
72 | Bindwood.uuidItemIdMap[uuid] = itemId = items[i]; |
73 | + Bindwood.writeMessage("Found the matching itemId: " + itemId); |
74 | break; |
75 | } |
76 | } |
77 | + if (!itemId) { |
78 | + Bindwood.writeMessage("XXX: Still haven't found the right itemId!"); |
79 | + } |
80 | } |
81 | return itemId; |
82 | }, |
83 | @@ -64,13 +77,15 @@ |
84 | uuidForItemId: function(itemId) { |
85 | // Try to look up the uuid, and failing that, assign a new one |
86 | // and return it. |
87 | + Bindwood.writeMessage("Looking up a UUID for itemId: " + itemId); |
88 | var uuid; |
89 | - var found = false; |
90 | try { |
91 | uuid = Bindwood.annotationService.getItemAnnotation(itemId, Bindwood.annotationKey); |
92 | - found = true; |
93 | + Bindwood.writeMessage("Found it: " + uuid); |
94 | } catch(e) { |
95 | + Bindwood.writeError("Didn't find a UUID for itemId: " + itemId, e); |
96 | uuid = Bindwood.annotateItemWithUUID(itemId, null); |
97 | + Bindwood.writeMessage("Didn't find it, so made it: " + uuid); |
98 | } |
99 | |
100 | return uuid; |
101 | @@ -78,15 +93,16 @@ |
102 | |
103 | writeMessage: function(aMessage) { |
104 | // convenience method for logging. Way better than alert()s. |
105 | - Bindwood.consoleService.logStringMessage("Bindwood: " + aMessage); |
106 | + if (Bindwood.envService.exists('BINDWOOD_DEBUG')) { |
107 | + Bindwood.consoleService.logStringMessage("Bindwood: " + aMessage); |
108 | + } |
109 | }, |
110 | |
111 | writeError: function(aMessage, e) { |
112 | - Bindwood.writeMessage(aMessage + "message: '" + e.message + "', reason: '" + e.reason + "', description: '" + e.description + "', error: '" + e.error + "'"); |
113 | + // This should fire whether we're in DEBUG or not |
114 | + Bindwood.consoleService.logStringMessage("Bindwood: " + aMessage + " message: '" + e.message + "', reason: '" + e.reason + "', description: '" + e.description + "', error: '" + e.error + "'"); |
115 | }, |
116 | |
117 | - |
118 | - |
119 | init: function() { |
120 | // Start the process and de-register ourself |
121 | // http://forums.mozillazine.org/viewtopic.php?f=19&t=657911&start=0 |
122 | @@ -95,7 +111,7 @@ |
123 | if(Components.classes["@mozilla.org/appshell/window-mediator;1"] |
124 | .getService(Components.interfaces.nsIWindowMediator) |
125 | .getEnumerator("").getNext() == window) { |
126 | - Bindwood.writeMessage("Getting a Couch Port"); |
127 | + Bindwood.writeMessage("First window opened. Getting a Couch Port"); |
128 | Bindwood.getCouchPortNumber(Bindwood.startProcess); |
129 | } |
130 | }, |
131 | @@ -107,10 +123,12 @@ |
132 | |
133 | // find OS temp dir to put the tempfile in |
134 | // https://developer.mozilla.org/index.php?title=File_I%2F%2FO#Getting_special_files |
135 | + Bindwood.writeMessage("Creating temp dir"); |
136 | var tmpdir = Components.classes["@mozilla.org/file/directory_service;1"] |
137 | .getService(Components.interfaces.nsIProperties) |
138 | .get("TmpD", Components.interfaces.nsIFile); |
139 | // create a randomly named tempfile in the tempdir |
140 | + Bindwood.writeMessage("Creating temp file"); |
141 | var tmpfile = Components.classes["@mozilla.org/file/local;1"] |
142 | .createInstance(Components.interfaces.nsILocalFile); |
143 | tmpfile.initWithPath(tmpdir.path + "/desktopcouch." + Math.random()); |
144 | @@ -130,13 +148,14 @@ |
145 | |
146 | // create an nsIProcess2 to execute this bash script |
147 | var process = Components.classes["@mozilla.org/process/util;1"] |
148 | - .createInstance(Components.interfaces.nsIProcess2); |
149 | + .createInstance(Components.interfaces.nsIProcess2); |
150 | process.init(nsifile); |
151 | |
152 | // Run the process, passing the tmpfile path |
153 | var args = [tmpfile.path]; |
154 | + Bindwood.writeMessage("Running dbus script"); |
155 | process.runAsync(args, args.length, { |
156 | - observe: function(process, finishState, data) { |
157 | + observe: function(process, finishState, unused_data) { |
158 | var port = 5984; |
159 | if (finishState == "process-finished") { |
160 | // read temp file to find port number |
161 | @@ -151,7 +170,7 @@ |
162 | let (str = {}) { |
163 | cstream.readString(-1, str); // read the whole file and put it in str.value |
164 | data = str.value; |
165 | - } |
166 | + }; |
167 | cstream.close(); // this closes fstream |
168 | data = data.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); |
169 | if (/^[0-9]+$/.test(data)) { |
170 | @@ -173,11 +192,14 @@ |
171 | Bindwood.writeMessage("Starting process with Couch on port " + couchPortNumber); |
172 | CouchDB.PORT_NUMBER = couchPortNumber; |
173 | try { |
174 | + Bindwood.writeMessage("Pushing bookmarks"); |
175 | Bindwood.pushBookmarks(); |
176 | } catch(e) { |
177 | Bindwood.writeError("Error when calling pushBookmarks: ", e); |
178 | } |
179 | + Bindwood.writeMessage("Creating view, if it's not there already"); |
180 | Bindwood.createView(); |
181 | + Bindwood.writeMessage("Pulling initial bookmarks"); |
182 | Bindwood.pullBookmarks(); |
183 | }, |
184 | |
185 | @@ -231,7 +253,11 @@ |
186 | try { |
187 | couch.createDb(); |
188 | } catch (e) { |
189 | - Bindwood.writeError("Error when creating database in pushBookmarks (file_exists is OK here): ", e); |
190 | + if (e.error == 'file_exists') { |
191 | + Bindwood.writeMessage("Database already exists. We're okay."); |
192 | + } else { |
193 | + Bindwood.writeError("Error when creating database in pushBookmarks: ", e); |
194 | + } |
195 | } |
196 | |
197 | Bindwood.pushBookmarksFromList(Bindwood.bookmarksService.toolbarFolder, |
198 | @@ -252,10 +278,12 @@ |
199 | var node = rootNode.getChild(i); |
200 | if (Bindwood.bookmarksService.getItemType(node.itemId) != |
201 | Bindwood.bookmarksService.TYPE_BOOKMARK) { |
202 | + Bindwood.writeMessage("Got something that isn't a bookmark"); |
203 | continue; |
204 | } |
205 | |
206 | var title = Bindwood.bookmarksService.getItemTitle(node.itemId); |
207 | + Bindwood.writeMessage("Got title: " + title); |
208 | try { |
209 | var metadata = Bindwood.bookmarksService.getBookmarkURI(node.itemId); |
210 | } catch(e) { |
211 | @@ -263,6 +291,7 @@ |
212 | continue; |
213 | } |
214 | var uuid = Bindwood.uuidForItemId(node.itemId); |
215 | + Bindwood.writeMessage("Got uuid: " + uuid); |
216 | retval.push({ |
217 | title: title, |
218 | metadata: metadata, |
219 | @@ -274,13 +303,23 @@ |
220 | }, |
221 | |
222 | pushBookmarksFromList: function(bookmarksList, bookmarksListName, db) { |
223 | + Bindwood.writeMessage("Pushing bookmarks from " + bookmarksListName); |
224 | var bookmarkData = Bindwood.getBookmarksFromList(bookmarksList); |
225 | for (var i = 0; i < bookmarkData.length; i++) { |
226 | // find this bookmark in CouchDB |
227 | - var uuid = Bindwood.uuidForItemId(bookmarkData[i].id); |
228 | + Bindwood.writeMessage("Looking up this record in Couch"); |
229 | + var itemId = bookmarkData[i].id; |
230 | + var uuid = bookmarkData[i].uuid; |
231 | var uri = bookmarkData[i].metadata.spec; |
232 | var title = bookmarkData[i].title; |
233 | |
234 | + Bindwood.writeMessage("Bookmark itemId: " + itemId + |
235 | + " has uuid: " + uuid + |
236 | + " uri: " + uri + |
237 | + " and title: \"" + title + "\""); |
238 | + |
239 | + Bindwood.uuidItemIdMap[uuid] = itemId; |
240 | + |
241 | var results = db.query(function(doc) { |
242 | if (doc.application_annotations && |
243 | doc.application_annotations.Firefox && |
244 | @@ -293,6 +332,7 @@ |
245 | |
246 | if (results.rows.length === 0) { |
247 | // this bookmark is not in CouchDB, so write it |
248 | + Bindwood.writeMessage("No bookmark with uuid: " + uuid + ", so we're making one"); |
249 | var record = { |
250 | record_type: "http://example.com/bookmark", |
251 | uri: uri, |
252 | @@ -306,10 +346,12 @@ |
253 | }; |
254 | try { |
255 | db.save(record); |
256 | + Bindwood.writeMessage("Saved new bookmark to Couch."); |
257 | } catch(e) { |
258 | Bindwood.writeError("Problem saving bookmark to CouchDB; bookmark is " + JSON.stringify(record) + ": ", e); |
259 | } |
260 | } else { |
261 | + Bindwood.writeMessage("This bookmark (" + uuid + ") is already in Couch, skipping"); |
262 | // bookmark is already in CouchDB, so do nothing |
263 | } |
264 | } |
265 | @@ -326,12 +368,14 @@ |
266 | if (doc.record_type == "http://example.com/bookmark") { |
267 | emit(doc._id,doc); |
268 | } |
269 | - }); |
270 | + }); |
271 | + Bindwood.writeMessage("Pulled all bookmark records from Couch"); |
272 | } catch(e) { |
273 | Bindwood.writeError("Problem fetching all bookmarks from Couch: ", e); |
274 | } |
275 | for (var i = 0; i < rows.rows.length; i++) { |
276 | var recordid = rows.rows[i].id; |
277 | + Bindwood.writeMessage("Pulling record: " + recordid); |
278 | var bm = rows.rows[i].value; |
279 | if (bm.application_annotations && |
280 | bm.application_annotations.Firefox && |
281 | @@ -339,7 +383,7 @@ |
282 | // this bookmark has a uuid, so check its values haven't changed |
283 | // find the bookmark with this uuid |
284 | var couch_uuid = bm.application_annotations.Firefox.uuid; |
285 | - Bindwood.writeMessage("Row uuid: " + couch_uuid); |
286 | + Bindwood.writeMessage("This bookmark has a uuid: " + couch_uuid + " so we're looking it up locally"); |
287 | var itemId = Bindwood.itemIdForUUID(couch_uuid); |
288 | if (!itemId) { |
289 | // This bookmark has a uuid, but it's not one of ours. |
290 | @@ -348,24 +392,32 @@ |
291 | // make the uuids the same), or (b) it's a new one |
292 | // that happens to have been created on a different |
293 | // machine. |
294 | + Bindwood.writeMessage("We didn't find that uuid: " + couch_uuid + " in the ItemId map, so we'll need to search for it by URI"); |
295 | try { |
296 | var uri = Bindwood.ioService.newURI(bm.uri, null, null); |
297 | + Bindwood.writeMessage("Made a new URI from the bookmark's uri: " + bm.uri); |
298 | } catch(e) { |
299 | - Bindwood.writeError("Problem creating URI (" + bm.uri + ") for bookmark: ", e); |
300 | + Bindwood.writeError("Problem creating URI (" + bm.uri + ") for bookmark, skipping: ", e); |
301 | continue; |
302 | } |
303 | var ids = Bindwood.bookmarksService.getBookmarkIdsForURI(uri, {}); |
304 | if (ids.length > 1) { |
305 | + Bindwood.writeMessage("Wow, didn't expect that. Multiple (" + ids.length + ") bookmarks found locally for the same URI: " + bm.uri); |
306 | // punt for now, too many problems. |
307 | } else if (ids.length) { |
308 | // Found one local bookmark. Replace its uuid to |
309 | // be the one from Couch. |
310 | - var itemId = ids[0]; |
311 | + Bindwood.writeMessage("We found one bookmark with the URI from Couch, so we're going to stamp Couch's uuid on it"); |
312 | + itemId = ids[0]; |
313 | var old_uuid = Bindwood.uuidForItemId(itemId); |
314 | + Bindwood.writeMessage("Got the old uuid: " + old_uuid); |
315 | delete Bindwood.uuidItemIdMap[old_uuid]; |
316 | + Bindwood.writeMessage("Deleted the old uuid from the ItemId map"); |
317 | Bindwood.annotateItemWithUUID(itemId, couch_uuid); |
318 | + Bindwood.writeMessage("Annotated the local bookmark with the uuid from Couch: " + couch_uuid); |
319 | } else { |
320 | /// No local bookmarks |
321 | + Bindwood.writeMessage("No local bookmark found, must be a new entry in Couch. Creating locally."); |
322 | Bindwood.addLocalBookmark(bm, recordid, couch_uuid); |
323 | } |
324 | } else { |
325 | @@ -374,17 +426,22 @@ |
326 | // flagged for deletion by another Client. We |
327 | // want to respect that, and delete it |
328 | // locally. |
329 | + Bindwood.writeMessage("This bookmark exists on Couch, but has been flagged for deletion, so we're deleting it locally"); |
330 | Bindwood.bookmarksService.removeItem(itemId); |
331 | + Bindwood.writeMessage("Local copy deleted"); |
332 | } else { |
333 | var title = Bindwood.bookmarksService.getItemTitle(itemId); |
334 | var metadata = Bindwood.bookmarksService.getBookmarkURI(itemId); |
335 | if (title != bm.title) { |
336 | + Bindwood.writeMessage("Resetting local title to title from Couch"); |
337 | Bindwood.bookmarksService.setItemTitle(itemId, bm.title); |
338 | } |
339 | if (metadata.spec != bm.uri) { |
340 | + Bindwood.writeMessage("The URI from Couch (" + bm.uri + ") is different from local (" + metadata.spec + ")"); |
341 | try { |
342 | - metadata = Bindwood.ioService.newURI(bm.uri, null, null); |
343 | - Bindwood.bookmarksService.changeBookmarkURI(itemId, metadata); |
344 | + var new_uri = Bindwood.ioService.newURI(bm.uri, null, null); |
345 | + Bindowod.writeMessage("Creating a new URI for our local bookmark"); |
346 | + Bindwood.bookmarksService.changeBookmarkURI(itemId, new_uri); |
347 | } catch(e) { |
348 | Bindwood.writeError("Problem creating a new URI for bookmark: ", e); |
349 | } |
350 | @@ -393,18 +450,20 @@ |
351 | } |
352 | } else { |
353 | // This bookmark has no uuid, so create it from fresh |
354 | - // in Firefox. Passing in null to addLocalBookmar will |
355 | + // in Firefox. Passing in null to addLocalBookmark will |
356 | // generate a new uuid. |
357 | + Bindwood.writeMessage("This bookmark from Couch has no uuid (not sure how that happened - manual creation in Couch?), so we're creating it locally, and saving it back."); |
358 | Bindwood.addLocalBookmark(bm, recordid, null); |
359 | } |
360 | } |
361 | // reschedule ourself |
362 | - setTimeout(Bindwood.pullBookmarks, 30000); |
363 | + Bindwood.writeMessage("Successful run, rescheduling ourself"); |
364 | + setTimeout(Bindwood.pullBookmarks, 300000); |
365 | }, |
366 | |
367 | addLocalBookmark: function(bm, recordid, uuid) { |
368 | var couch = new CouchDB('bookmarks'); |
369 | - var list; |
370 | + var list = Bindwood.bookmarksService.toolbarFolder; |
371 | if (bm.application_annotations && |
372 | bm.application_annotations.Firefox && |
373 | bm.application_annotations.Firefox.list) { |
374 | @@ -416,28 +475,39 @@ |
375 | list = Bindwood.bookmarksService.bookmarksMenuFolder; |
376 | break; |
377 | default: |
378 | - list = Bindwood.bookmarksService.toolbarFolder; |
379 | break; |
380 | } |
381 | - } else { |
382 | - list = Bindwood.bookmarksService.toolbarFolder; |
383 | - } |
384 | - var metadata = Bindwood.ioService.newURI(bm.uri, null, null); |
385 | - |
386 | - var itemId = Bindwood.bookmarksService.insertBookmark(list, |
387 | - metadata, -1, bm.title); |
388 | + } |
389 | + Bindwood.writeMessage("Established the correct list for ths bookmark to reside"); |
390 | + |
391 | + try { |
392 | + var new_uri = Bindwood.ioService.newURI(bm.uri, null, null); |
393 | + Bindowod.writeMessage("Creating a new URI for our local bookmark"); |
394 | + Bindwood.bookmarksService.changeBookmarkURI(itemId, new_uri); |
395 | + } catch(e) { |
396 | + Bindwood.writeError("Problem creating a new URI for bookmark: ", e); |
397 | + } |
398 | + |
399 | + var itemId = Bindwood.bookmarksService.insertBookmark( |
400 | + list, new_uri, -1, bm.title); |
401 | + Bindwood.writeMessage("Inserting the new bookmark, locally"); |
402 | // and then write the new uuid back to the record |
403 | - var uuid = uuid ? uuid : Bindwood.uuidForItemId(itemId); |
404 | + var new_uuid = uuid ? uuid : Bindwood.uuidForItemId(itemId); |
405 | + Bindwood.writeMessage("Since it's a new bookmark, we have a new uuid: " + new_uuid); |
406 | var doc = couch.open(recordid); |
407 | if (!doc.application_annotations) { |
408 | + Bindwood.writeMessage("Adding a new Applications annotation"); |
409 | doc.application_annotations = {}; |
410 | } |
411 | if (!doc.application_annotations.Firefox) { |
412 | + Bindwood.writeMessage("Adding a new Firefox annotation"); |
413 | doc.application_annotations.Firefox = {}; |
414 | } |
415 | - doc.application_annotations.Firefox.uuid = uuid; |
416 | + Bindwood.writeMessage("Adding the new uuid to the Firefox annotation"); |
417 | + doc.application_annotations.Firefox.uuid = new_uuid; |
418 | try { |
419 | couch.save(doc); |
420 | + Bindwood.writeMessage("Saved the doc back to Couch"); |
421 | } catch(e) { |
422 | Bindwood.writeError("Problem writing record for new bookmark: ",e); |
423 | } |
424 | @@ -448,13 +518,17 @@ |
425 | onItemAdded: function(aItemId, aFolder, aIndex) { |
426 | // A bookmark has been added, so we create a blank entry |
427 | // in Couch with our local itemId attached. |
428 | + Bindwood.writeMessage("A new bookmark was created. Its id is: " + aItemId + |
429 | + " at location: " + aIndex + |
430 | + " in folder: " + aFolder ); |
431 | netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead UniversalBrowserWrite"); |
432 | |
433 | var couch = new CouchDB('bookmarks'); |
434 | |
435 | var uuid = Bindwood.uuidForItemId(aItemId); |
436 | + Bindwood.writeMessage("Determined uuid for new bookmark: " + uuid); |
437 | |
438 | - var list; |
439 | + var list = "toolbarFolder"; |
440 | switch(aFolder) { |
441 | case Bindwood.bookmarksService.toolbarFolder: |
442 | list = "toolbarFolder"; |
443 | @@ -463,7 +537,6 @@ |
444 | list = "bookmarksMenuFolder"; |
445 | break; |
446 | default: |
447 | - list = "toolbarFolder"; |
448 | break; |
449 | } |
450 | |
451 | @@ -477,8 +550,11 @@ |
452 | } |
453 | }; |
454 | |
455 | + Bindwood.writeMessage("Created a minimal record document with our uuid"); |
456 | + |
457 | try { |
458 | var result = couch.save(doc); |
459 | + Bindwood.writeMessage("Saved new, bare record to Couch."); |
460 | } catch(e) { |
461 | Bindwood.writeError("Problem saving new bookmark to Couch: ", e); |
462 | } |
463 | @@ -487,6 +563,7 @@ |
464 | // A bookmark has been removed. This is called before it's |
465 | // been removed locally, though we're passed the itemId, |
466 | // which we use to delete from Couch. |
467 | + Bindwood.writeMessage("Record " + aItemId + " is about to be removed locally."); |
468 | netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead UniversalBrowserWrite"); |
469 | |
470 | var couch = new CouchDB('bookmarks'); |
471 | @@ -515,25 +592,30 @@ |
472 | |
473 | try { |
474 | var result = couch.save(doc); |
475 | + Bindwood.writeMessage("Saved document back to Couch with deleted flag set."); |
476 | // Also remove from our local cache and remove |
477 | // annotation from service. |
478 | delete Bindwood.uuidItemIdMap[uuid]; |
479 | + Bindwood.writeMessage("Deleted local reference in the uuid-itemId mapping."); |
480 | } catch(e) { |
481 | Bindwood.writeError("Problem pushing deleted record to Couch: ", e); |
482 | } |
483 | }, |
484 | onItemRemoved: function(aItemId, aFolder, aIndex) { |
485 | Bindwood.annotationService.removeItemAnnotation(aItemId, Bindwood.annotationKey); |
486 | + Bindwood.writeMessage("Removed annotations from bookmark identified by: " + aItemId); |
487 | }, |
488 | onItemChanged: function(aBookmarkId, aProperty, aIsAnnotationProperty, aValue) { |
489 | // A property of a bookmark has changed. On multiple |
490 | // property updates, this will be called multiple times, |
491 | // once per property (i.e., for title and URI) |
492 | + Bindwood.writeMessage("A property (" + aProperty + ") on bookmark id: " + aBookmarkId + " has been set to: " + aValue); |
493 | netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead UniversalBrowserWrite"); |
494 | |
495 | var couch = new CouchDB('bookmarks'); |
496 | |
497 | var uuid = Bindwood.uuidForItemId(aBookmarkId); |
498 | + Bindwood.writeMessage("Determined uuid for this bookmark: " + aBookmarkId + " is: " + uuid); |
499 | |
500 | var results = couch.query(function(doc) { |
501 | if (doc.application_annotations && |
502 | @@ -552,9 +634,11 @@ |
503 | |
504 | var doc = couch.open(results.rows[0].id); |
505 | doc[aProperty.toString()] = aValue.toString(); |
506 | + Bindwood.writeMessage("Set the new property on the document from Couch."); |
507 | |
508 | try { |
509 | var result = couch.save(doc); |
510 | + Bindwood.writeMessage("Saved the document back to Couch"); |
511 | } catch(e) { |
512 | Bindwood.writeError("Problem saving updated bookmark to Couch: ", e); |
513 | } |
514 | |
515 | === added directory 'debian' |
516 | === added file 'debian/changelog' |
517 | --- debian/changelog 1970-01-01 00:00:00 +0000 |
518 | +++ debian/changelog 2009-08-18 19:51:45 +0000 |
519 | @@ -0,0 +1,6 @@ |
520 | +bindwood (0.2~~rev9-0ubuntu1) karmic; urgency=low |
521 | + |
522 | + [ Elliot Murphy ] |
523 | + * Initial packaging. (LP: #408758) |
524 | + |
525 | + -- Elliot Murphy <elliot@ubuntu.com> Tue, 18 Aug 2009 10:21:57 -0400 |
526 | |
527 | === added file 'debian/compat' |
528 | --- debian/compat 1970-01-01 00:00:00 +0000 |
529 | +++ debian/compat 2009-08-06 10:17:44 +0000 |
530 | @@ -0,0 +1,1 @@ |
531 | +7 |
532 | |
533 | === added file 'debian/control' |
534 | --- debian/control 1970-01-01 00:00:00 +0000 |
535 | +++ debian/control 2009-08-18 19:51:07 +0000 |
536 | @@ -0,0 +1,22 @@ |
537 | +Source: bindwood |
538 | +Section: web |
539 | +Priority: optional |
540 | +Maintainer: Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com> |
541 | +XSBC-Original-Maintainer: Elliot Murphy <elliot@ubuntu.com> |
542 | +Build-Depends: debhelper (> 7), cdbs, mozilla-devscripts (>= 0.14), zip |
543 | +Vcs-Bzr: lp:~ubuntu-dev/firefox-extensions/bindwood.ubuntu |
544 | +Vcs-Browser: https://code.launchpad.net/~ubuntu-dev/firefox-extensions/bindwood.ubuntu |
545 | +Standards-Version: 3.8.3 |
546 | + |
547 | +Package: bindwood |
548 | +Architecture: all |
549 | +Depends: ${xpi:Depends}, |
550 | + couchdb, |
551 | + python-desktopcouch |
552 | +Description: Firefox bookmark syncing with desktop couchdb. |
553 | + Extension package for firefox provides bookmark syncing with local desktop |
554 | + couchdb, bookmarks can then be replicated to other couchdb instances. |
555 | + . |
556 | + You can uninstall this package if you don't want to sync bookmarks with your |
557 | + local desktop couchdb. |
558 | + |
559 | |
560 | === added file 'debian/copyright' |
561 | --- debian/copyright 1970-01-01 00:00:00 +0000 |
562 | +++ debian/copyright 2009-08-06 10:17:44 +0000 |
563 | @@ -0,0 +1,43 @@ |
564 | +This is the Ubuntu package of bindwood, a Firefox extension for |
565 | +syncing your bookmarks to desktopcouch. |
566 | + |
567 | +It was packaged by Elliot Murphy <elliot@ubuntu.com> |
568 | + |
569 | +The upstream sources can be found at: |
570 | + |
571 | + https://code.launchpad.net/bindwood |
572 | + |
573 | +content/couch.js: |
574 | + |
575 | +Copyright (C) 2009 Apache Software Foundation |
576 | + |
577 | +License: |
578 | + |
579 | + Licensed under the Apache License, Version 2.0 (the "License"); |
580 | + you may not use this software except in compliance with the License |
581 | + You may obtain a copy of the License at |
582 | + |
583 | + http://www.apache.org/licenses/LICENSE-2.0 |
584 | + |
585 | + |
586 | + Unless required by applicable law or agreed to in writing, software |
587 | + distributed under the License is distributed on an "AS IS" BASIS, |
588 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
589 | + See the License for the specific language governing permissions and |
590 | + limitations under the License. |
591 | + |
592 | +On Debian systems, the complete text of the Apache License can be found |
593 | +in `/usr/share/common-licenses/Apache-2.0'. |
594 | + |
595 | + |
596 | +All other files and debian packaging: |
597 | + |
598 | +Copyright (C) 2009 Canonical Ltd. |
599 | + |
600 | +License: |
601 | + |
602 | +GNU GENERAL PUBLIC LICENSE Version 3 |
603 | + |
604 | +The full text can be found at: |
605 | + /usr/share/common-licenses/GPL-3 or http://www.gnu.org/licenses/gpl.txt |
606 | + |
607 | |
608 | === added file 'debian/rules' |
609 | --- debian/rules 1970-01-01 00:00:00 +0000 |
610 | +++ debian/rules 2009-08-06 10:17:44 +0000 |
611 | @@ -0,0 +1,8 @@ |
612 | +#!/usr/bin/make -f |
613 | + |
614 | +MOZ_EXTENSION_PKG := bindwood |
615 | +MOZ_XPI_BUILD_COMMAND = sh build.sh |
616 | + |
617 | +include /usr/share/cdbs/1/rules/debhelper.mk |
618 | +include /usr/share/mozilla-devscripts/xpi.mk |
619 | + |
This branch adds copious debugging info to the error log, but only in the environmental presence of
$BINDWOOD_DEBUG. With this branch installed, and launching Firefox normally, you'll see precious
little info in the Error console (errors only, in fact).
If you launch Firefox from the CLI, setting BINDWOOD_DEBUG, thus:
$ BINDWOOD_DEBUG=1 firefox &
And you look in the error console under Messages, you'll see all the gory details of pushing and pulling bookmarks, as well as event handling their creation and modification.