This commit is contained in:
Phil Ringnalda 2013-06-27 14:27:17 -07:00
Родитель 21ec7a4239 232b30805c
Коммит 9063c580e2
4 изменённых файлов: 59 добавлений и 6 удалений

Просмотреть файл

@ -1,4 +1,4 @@
{
"revision": "e4d8c96f60dc17c64cf5374ab4e7f030de585bfa",
"revision": "dfacedfab9048c0b0e7235aa4d8a19714d5a8d54",
"repo_path": "/integration/gaia-central"
}

Просмотреть файл

@ -4,7 +4,12 @@
"use strict";
const DEBUG = false;
let DEBUG = false;
function updateDebug(aResult) {
DEBUG = !!aResult;
}
function debug(s) { dump("-*- ContactManager: " + s + "\n"); }
const Cc = Components.classes;
@ -27,6 +32,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
"@mozilla.org/settingsService;1",
"nsISettingsService");
const CONTACTS_SENDMORE_MINIMUM = 5;
function stringOrBust(aObj) {
@ -919,6 +928,16 @@ ContactManager.prototype = {
"PermissionPromptHelper:AskPermission:OK",
"Contacts:GetAll:Next", "Contacts:Revision",
"Contacts:Count"]);
let lock = gSettingsService.createLock();
lock.get("dom.mozContacts.debugging.enabled", {
handle: function(aName, aResult) {
updateDebug(aResult);
},
handleError: function(aErrorMessage) {
if (DEBUG) debug("Error reading dom.mozContacts.debugging.enabled setting: " + aErrorMessage);
}
});
},
// Called from DOMRequestIpcHelper

Просмотреть файл

@ -6,7 +6,7 @@
this.EXPORTED_SYMBOLS = ['ContactDB'];
const DEBUG = false;
let DEBUG = false;
function debug(s) { dump("-*- ContactDB component: " + s + "\n"); }
const Cu = Components.utils;
@ -945,6 +945,10 @@ ContactDB.prototype = {
this.substringMatching = aDigits;
},
enableDebugging: function(aEnable) {
DEBUG = aEnable;
},
init: function init(aGlobal) {
this.initDBHelper(DB_NAME, DB_VERSION, [STORE_NAME, SAVED_GETALL_STORE_NAME, REVISION_STORE], aGlobal);
}

Просмотреть файл

@ -4,7 +4,7 @@
"use strict";
const DEBUG = false;
let DEBUG = false;
function debug(s) { dump("-*- Fallback ContactService component: " + s + "\n"); }
const Cu = Components.utils;
@ -22,6 +22,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageListenerManager");
XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
"@mozilla.org/settingsService;1",
"nsISettingsService");
let myGlobal = this;
let ContactService = {
@ -52,17 +56,33 @@ let ContactService = {
}
}
let lock = gSettingsService.createLock();
lock.get("dom.mozContacts.debugging.enabled", {
handle: function(aName, aResult) {
updateDebug(aResult);
},
handleError: function(aErrorMessage) {
if (DEBUG) debug("Error reading dom.mozContacts.debugging.enabled setting: " + aErrorMessage);
}
});
Services.obs.addObserver(this, "profile-before-change", false);
Services.obs.addObserver(this, "mozsettings-changed", false);
Services.prefs.addObserver("dom.phonenumber.substringmatching", this, false);
},
enableDebugging: function(aResult) {
this._db.enableDebugging(aResult);
},
observe: function(aSubject, aTopic, aData) {
if (aTopic === 'profile-before-change') {
if (aTopic === "profile-before-change") {
myGlobal = null;
this._messages.forEach(function(msgName) {
ppmm.removeMessageListener(msgName, this);
}.bind(this));
Services.obs.removeObserver(this, "profile-before-change");
Services.obs.removeObserver(this, "mozsettings-changed");
Services.prefs.removeObserver("dom.phonenumber.substringmatching", this);
ppmm = null;
this._messages = null;
@ -71,7 +91,7 @@ let ContactService = {
this._db = null;
this._children = null;
this._cursors = null;
} else if (aTopic === 'nsPref:changed' && aData.contains("dom.phonenumber.substringmatching")) {
} else if (aTopic === "nsPref:changed" && aData.contains("dom.phonenumber.substringmatching")) {
// We don't fully support changing substringMatching during runtime. This is mostly for testing.
let countryName = PhoneNumberUtils.getCountryName();
if (Services.prefs.getPrefType("dom.phonenumber.substringmatching." + countryName) == Ci.nsIPrefBranch.PREF_INT) {
@ -80,6 +100,11 @@ let ContactService = {
this._db.enableSubstringMatching(val);
}
}
} else if (aTopic === "mozsettings-changed") {
let data = JSON.parse(aData);
if (data.key === "dom.mozContacts.debugging.enabled") {
updateDebug(data.value);
}
}
},
@ -251,3 +276,8 @@ let ContactService = {
}
ContactService.init();
function updateDebug(aResult) {
DEBUG = !!aResult;
ContactService.enableDebugging(DEBUG);
}