diff options
author | David Zeuthen <davidz@redhat.com> | 2012-05-18 16:04:12 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2012-05-18 16:04:12 -0400 |
commit | ff18d9a8a23f11f76babc696082750f3f4b74239 (patch) | |
tree | 4bccb3e32163a6d40f32d4e59bf3dbc841af85e9 /src | |
parent | 41e56847bf00f7068a01db4be5f441777859fc84 (diff) | |
download | polkit-ff18d9a8a23f11f76babc696082750f3f4b74239.tar.gz |
Reformat init.js and also avoid quoting non-string properties in toString()
Otherwise it's hard to tell whether 'true' is a string or a boolean...
Signed-off-by: David Zeuthen <davidz@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/polkitbackend/init.js | 94 |
1 files changed, 51 insertions, 43 deletions
diff --git a/src/polkitbackend/init.js b/src/polkitbackend/init.js index 0767d3c..4f1cc72 100644 --- a/src/polkitbackend/init.js +++ b/src/polkitbackend/init.js @@ -1,66 +1,74 @@ /* -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- */ function Details() { - this.toString = function() { - var ret = "[Details"; - for (var i in this) { - if (typeof this[i] != "function") - ret += " " + i + "='" + this[i] + "'"; - } - ret += "]"; - return ret; - }; + this.toString = function() { + var ret = "[Details"; + for (var i in this) { + if (typeof this[i] != "function") { + if (typeof this[i] == "string") + ret += " " + i + "='" + this[i] + "'"; + else + ret += " " + i + "=" + this[i]; + } + } + ret += "]"; + return ret; + }; }; function Subject() { - this.isInGroup = function(group) { - for (var n = 0; n < this.groups.length; n++) { - if (this.groups[n] == group) - return true; - } - return false; - }; + this.isInGroup = function(group) { + for (var n = 0; n < this.groups.length; n++) { + if (this.groups[n] == group) + return true; + } + return false; + }; - this.toString = function() { - var ret = "[Subject"; - for (var i in this) { - if (typeof this[i] != "function") - ret += " " + i + "='" + this[i] + "'"; - } - ret += "]"; - return ret; - }; + this.toString = function() { + var ret = "[Subject"; + for (var i in this) { + if (typeof this[i] != "function") { + if (typeof this[i] == "string") + ret += " " + i + "='" + this[i] + "'"; + else + ret += " " + i + "=" + this[i]; + } + } + ret += "]"; + return ret; + }; }; polkit._administratorRuleFuncs = []; polkit.addAdministratorRule = function(callback) {this._administratorRuleFuncs.push(callback);}; polkit._runAdministratorRules = function(action, subject, details) { - var ret = null; - for (var n = this._administratorRuleFuncs.length - 1; n >= 0; n--) { - var func = this._administratorRuleFuncs[n]; - ret = func(action, subject, details); - if (ret) - break - } - return ret.join(","); + var ret = null; + for (var n = this._administratorRuleFuncs.length - 1; n >= 0; n--) { + var func = this._administratorRuleFuncs[n]; + ret = func(action, subject, details); + if (ret) + break + } + return ret.join(","); }; polkit._authorizationRuleFuncs = []; polkit.addAuthorizationRule = function(callback) {this._authorizationRuleFuncs.push(callback);}; polkit._runAuthorizationRules = function(action, subject, details) { - var ret = null; - for (var n = this._authorizationRuleFuncs.length - 1; n >= 0; n--) { - var func = this._authorizationRuleFuncs[n]; - ret = func(action, subject, details); - if (ret) - break - } - return ret; + var ret = null; + for (var n = this._authorizationRuleFuncs.length - 1; n >= 0; n--) { + var func = this._authorizationRuleFuncs[n]; + ret = func(action, subject, details); + if (ret) + break + } + return ret; }; polkit._deleteRules = function() { - this._administratorRuleFuncs = []; - this._authorizationRuleFuncs = []; + this._administratorRuleFuncs = []; + this._authorizationRuleFuncs = []; }; |