Bug 827237 - Wifi: ap list in settings is empty. r=bent

This commit is contained in:
Gregor Wagner 2013-01-07 15:03:26 +01:00
parent aaec3a9556
commit 25cb6654aa
2 changed files with 38 additions and 15 deletions

View File

@ -111,6 +111,11 @@ SettingsLock.prototype = {
}
};
}
checkKeyRequest.onerror = function(event) {
if (!request.error) {
Services.DOMRequest.fireError(request, checkKeyRequest.error.name)
}
};
}
break;
case "get":

View File

@ -55,10 +55,21 @@ SettingsServiceLock.prototype = {
let message = info.message;
if(typeof(value) == 'object')
debug("object name:" + name + ", val: " + JSON.stringify(value));
req = store.put({ settingName: name, settingValue: value });
let checkKeyRequest = store.get(name);
checkKeyRequest.onsuccess = function (event) {
let defaultValue;
if (event.target.result) {
defaultValue = event.target.result.defaultValue;
} else {
defaultValue = null;
if (DEBUG) debug("MOZSETTINGS-SET-WARNING: " + key + " is not in the database.\n");
}
req = store.put({ settingName: name, defaultValue: defaultValue, userValue: value });
req.onsuccess = function() {
debug("set on success");
if (DEBUG) debug("set on success");
lock._open = true;
if (callback)
callback.handle(name, value);
@ -71,6 +82,9 @@ SettingsServiceLock.prototype = {
};
req.onerror = function(event) { callback ? callback.handleError(event.target.errorMessage) : null; };
}
checkKeyRequest.onerror = function(event) { callback ? callback.handleError(event.target.errorMessage) : null; };
break;
case "get":
req = store.mozGetAll(name);
@ -83,7 +97,11 @@ SettingsServiceLock.prototype = {
if (event.target.result.length > 1) {
debug("Warning: overloaded setting:" + name);
}
callback.handle(name, event.target.result[0].settingValue);
let result = event.target.result[0];
let value = result.userValue !== undefined
? result.userValue
: result.defaultValue;
callback.handle(name, value);
} else
callback.handle(name, null);
} else {