diff options
author | David Zeuthen <davidz@redhat.com> | 2012-05-24 14:51:46 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2012-05-24 14:51:46 -0400 |
commit | 0e85f07781f8eab9670e06cee32b38657e3b62ce (patch) | |
tree | 49d2f57f45e52265ab2d678803fa2ade40cde31e /src/polkitbackend/init.js | |
parent | 2ec9e681e0ee17bcc60a0724b201b2e19b573abb (diff) | |
download | polkit-0e85f07781f8eab9670e06cee32b38657e3b62ce.tar.gz |
Combine action and details parameters
This also removes the ability to change detail parameters which is
actually a good thing. If we later need a way to change the
authentication message, we can always add something like
polkit.addAuthenticationMessageRule() so the user can register a
function returning a string.
Signed-off-by: David Zeuthen <davidz@redhat.com>
Diffstat (limited to 'src/polkitbackend/init.js')
-rw-r--r-- | src/polkitbackend/init.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/polkitbackend/init.js b/src/polkitbackend/init.js index 29f13fc..16862d4 100644 --- a/src/polkitbackend/init.js +++ b/src/polkitbackend/init.js @@ -1,14 +1,17 @@ /* -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- */ -function Details() { +function Action() { + this.lookup = function(name) { + return this["_detail_" + name]; + }, + this.toString = function() { - var ret = "[Details"; + var ret = "[Action id='" + this.id + "'"; for (var i in this) { - if (typeof this[i] != "function") { - if (typeof this[i] == "string") - ret += " " + i + "='" + this[i] + "'"; - else - ret += " " + i + "=" + this[i]; + if (i.indexOf("_detail_") == 0) { + var key = i.substr(8); + var value = this[i]; + ret += " " + key + "='" + value + "'"; } } ret += "]"; @@ -17,7 +20,6 @@ function Details() { }; function Subject() { - this.isInGroup = function(group) { for (var n = 0; n < this.groups.length; n++) { if (this.groups[n] == group) @@ -47,11 +49,11 @@ function Subject() { polkit._adminRuleFuncs = []; polkit.addAdminRule = function(callback) {this._adminRuleFuncs.push(callback);}; -polkit._runAdminRules = function(action, subject, details) { +polkit._runAdminRules = function(action, subject) { var ret = null; for (var n = 0; n < this._adminRuleFuncs.length; n++) { var func = this._adminRuleFuncs[n]; - var func_ret = func(action, subject, details); + var func_ret = func(action, subject); if (func_ret) { ret = func_ret; break @@ -62,11 +64,11 @@ polkit._runAdminRules = function(action, subject, details) { polkit._ruleFuncs = []; polkit.addRule = function(callback) {this._ruleFuncs.push(callback);}; -polkit._runRules = function(action, subject, details) { +polkit._runRules = function(action, subject) { var ret = null; for (var n = 0; n < this._ruleFuncs.length; n++) { var func = this._ruleFuncs[n]; - var func_ret = func(action, subject, details); + var func_ret = func(action, subject); if (func_ret) { ret = func_ret; break |