Bug 769805 - Contacts API broken due to IndexedDB API Change. r=khuey
authorGuillermo Lopez <willyaranda@mozilla-hispano.org>
Mon, 02 Jul 2012 12:03:49 -0700
changeset 98126 3fa201aec65200cf2db0e2998438f1d3ec986989
parent 98125 b1b127541ba8e17df37686f782e197b5075d3de8
child 98127 4a5f794edd2d03d83a9836f749665ac874b7320c
push id23025
push userryanvm@gmail.com
push dateTue, 03 Jul 2012 02:00:12 +0000
treeherdermozilla-central@e43bc4698687 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs769805
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 769805 - Contacts API broken due to IndexedDB API Change. r=khuey
dom/contacts/fallback/ContactDB.jsm
--- a/dom/contacts/fallback/ContactDB.jsm
+++ b/dom/contacts/fallback/ContactDB.jsm
@@ -9,17 +9,17 @@ const EXPORTED_SYMBOLS = ['ContactDB'];
 let DEBUG = 0;
 /* static functions */
 if (DEBUG) {
   debug = function (s) { dump("-*- ContactDB component: " + s + "\n"); }
 } else {
   debug = function (s) {}
 }
 
-const Cu = Components.utils; 
+const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
 
 const DB_NAME = "contacts";
 const DB_VERSION = 2;
@@ -71,36 +71,36 @@ ContactDB.prototype = {
         objectStore.createIndex("familyNameLowerCase", "search.familyName", { unique: false, multiEntry: true });
         objectStore.createIndex("givenNameLowerCase",  "search.givenName",  { unique: false, multiEntry: true });
         objectStore.createIndex("telLowerCase",        "search.tel",        { unique: false, multiEntry: true });
         objectStore.createIndex("emailLowerCase",      "search.email",      { unique: false, multiEntry: true });
         objectStore.createIndex("noteLowerCase",       "search.note",       { unique: false, multiEntry: true });
       } else if (currVersion == 1) {
         debug("upgrade 1");
 
-        // Create a new scheme for the tel field. We move from an array of tel-numbers to an array of 
+        // Create a new scheme for the tel field. We move from an array of tel-numbers to an array of
         // ContactTelephone.
         if (!objectStore) {
           objectStore = aTransaction.objectStore(STORE_NAME);
         }
         // Delete old tel index.
         objectStore.deleteIndex("tel");
 
         // Upgrade existing tel field in the DB.
-        objectStore.openCursor().onsuccess = function(event) {  
+        objectStore.openCursor().onsuccess = function(event) {
           let cursor = event.target.result;
           if (cursor) {
             debug("upgrade tel1: " + JSON.stringify(cursor.value));
             for (let number in cursor.value.properties.tel) {
               cursor.value.properties.tel[number] = {number: number};
             }
             cursor.update(cursor.value);
             debug("upgrade tel2: " + JSON.stringify(cursor.value));
             cursor.continue();
-          } 
+          }
         };
 
         // Create new searchable indexes.
         objectStore.createIndex("tel", "search.tel", { unique: false, multiEntry: true });
         objectStore.createIndex("category", "properties.category", { unique: false, multiEntry: true });
       }
     }
   },
@@ -150,17 +150,17 @@ ContactDB.prototype = {
 
     for (let field in aContact.properties) {
       contact.properties[field] = aContact.properties[field];
       // Add search fields
       if (aContact.properties[field] && contact.search[field]) {
         for (let i = 0; i <= aContact.properties[field].length; i++) {
           if (aContact.properties[field][i]) {
             if (field == "tel") {
-              // Special case telephone number. 
+              // Special case telephone number.
               // "+1-234-567" should also be found with 1234, 234-56, 23456
 
               // Chop off the first characters
               let number = aContact.properties[field][i].number;
               for(let i = 0; i < number.length; i++) {
                 contact.search[field].push(number.substring(i, number.length));
               }
               // Store +1-234-567 as ["1234567", "234567"...]
@@ -303,31 +303,31 @@ ContactDB.prototype = {
     // Sorting functions takes care of limit if set.
     let limit = options.sortBy === 'undefined' ? options.filterLimit : null;
 
     let filter_keys = fields.slice();
     for (let key = filter_keys.shift(); key; key = filter_keys.shift()) {
       let request;
       if (key == "id") {
         // store.get would return an object and not an array
-        request = store.getAll(options.filterValue);
+        request = store.mozGetAll(options.filterValue);
       } else if (key == "category") {
         let index = store.index(key);
-        request = index.getAll(options.filterValue, limit);
+        request = index.mozGetAll(options.filterValue, limit);
       } else if (options.filterOp == "equals") {
         debug("Getting index: " + key);
         // case sensitive
         let index = store.index(key);
-        request = index.getAll(options.filterValue, limit);
+        request = index.mozGetAll(options.filterValue, limit);
       } else {
         // not case sensitive
         let tmp = options.filterValue.toLowerCase();
         let range = this._global.IDBKeyRange.bound(tmp, tmp + "\uFFFF");
         let index = store.index(key + "LowerCase");
-        request = index.getAll(range, limit);
+        request = index.mozGetAll(range, limit);
       }
       if (!txn.result)
         txn.result = {};
 
       request.onsuccess = function (event) {
         debug("Request successful. Record count:" + event.target.result.length);
         for (let i in event.target.result)
           txn.result[event.target.result[i].id] = this.makeExport(event.target.result[i]);
@@ -336,17 +336,17 @@ ContactDB.prototype = {
   },
 
   _findAll: function _findAll(txn, store, options) {
     debug("ContactDB:_findAll:  " + JSON.stringify(options));
     if (!txn.result)
       txn.result = {};
     // Sorting functions takes care of limit if set.
     let limit = options.sortBy === 'undefined' ? options.filterLimit : null;
-    store.getAll(null, limit).onsuccess = function (event) {
+    store.mozGetAll(null, limit).onsuccess = function (event) {
       debug("Request successful. Record count:", event.target.result.length);
       for (let i in event.target.result)
         txn.result[event.target.result[i].id] = this.makeExport(event.target.result[i]);
     }.bind(this);
   },
 
   init: function init(aGlobal) {
       this.initDBHelper(DB_NAME, DB_VERSION, STORE_NAME, aGlobal);