summaryrefslogtreecommitdiff
path: root/frontend/delta/js/Clipperz/PM/Proxy/Proxy.JSON.js
Unidiff
Diffstat (limited to 'frontend/delta/js/Clipperz/PM/Proxy/Proxy.JSON.js') (more/less context) (ignore whitespace changes)
-rwxr-xr-xfrontend/delta/js/Clipperz/PM/Proxy/Proxy.JSON.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/frontend/delta/js/Clipperz/PM/Proxy/Proxy.JSON.js b/frontend/delta/js/Clipperz/PM/Proxy/Proxy.JSON.js
new file mode 100755
index 0000000..1638d99
--- a/dev/null
+++ b/frontend/delta/js/Clipperz/PM/Proxy/Proxy.JSON.js
@@ -0,0 +1,86 @@
1/*
2
3Copyright 2008-2013 Clipperz Srl
4
5This file is part of Clipperz, the online password manager.
6For further information about its features and functionalities please
7refer to http://www.clipperz.com.
8
9* Clipperz is free software: you can redistribute it and/or modify it
10 under the terms of the GNU Affero General Public License as published
11 by the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14* Clipperz is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 See the GNU Affero General Public License for more details.
18
19* You should have received a copy of the GNU Affero General Public
20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
21
22*/
23
24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
25if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
26
27//=============================================================================
28
29Clipperz.PM.Proxy.JSON = function(args) {
30 Clipperz.PM.Proxy.JSON.superclass.constructor.call(this, args);
31
32 this._url = args.url || Clipperz.Base.exception.raise('MandatoryParameter');
33
34 return this;
35}
36
37Clipperz.Base.extend(Clipperz.PM.Proxy.JSON, Clipperz.PM.Proxy, {
38
39 'toString': function() {
40 return "Clipperz.PM.Proxy.JSON";
41 },
42
43 //=========================================================================
44
45 'url': function () {
46 return this._url;
47 },
48
49 //=========================================================================
50
51 '_sendMessage': function(aFunctionName, aVersion, someParameters) {
52 vardeferredResult;
53 var parameters;
54
55 parameters = {
56 method: aFunctionName,
57 version: aVersion,
58 parameters: Clipperz.Base.serializeJSON(someParameters)
59 };
60
61 deferredResult = new Clipperz.Async.Deferred("Proxy.JSON.sendMessage", {trace:false});
62 deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'remoteRequestSent');
63 deferredResult.addCallback(MochiKit.Async.doXHR, this.url(), {
64 method:'POST',
65 sendContent:MochiKit.Base.queryString(parameters),
66 headers:{"Content-Type":"application/x-www-form-urlencoded"}
67 });
68 deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'remoteRequestReceived');
69 deferredResult.addCallback(MochiKit.Base.itemgetter('responseText'));
70 deferredResult.addCallback(Clipperz.Base.evalJSON);
71 deferredResult.addCallback(function (someValues) {
72 if (someValues['result'] == 'EXCEPTION') {
73 throw someValues['message'];
74 }
75
76 return someValues;
77 })
78 deferredResult.callback();
79
80 return deferredResult;
81 },
82
83 //=========================================================================
84 __syntaxFix__: "syntax fix"
85
86});