Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Proxy.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Proxy.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Proxy.js b/frontend/beta/js/Clipperz/PM/Proxy.js index d05a5e0..f476196 100644 --- a/frontend/beta/js/Clipperz/PM/Proxy.js +++ b/frontend/beta/js/Clipperz/PM/Proxy.js | |||
@@ -1,120 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
31 | 28 | ||
32 | //============================================================================= | 29 | //============================================================================= |
33 | 30 | ||
34 | Clipperz.PM.Proxy = function(args) { | 31 | Clipperz.PM.Proxy = function(args) { |
35 | args = args || {}; | 32 | args = args || {}; |
36 | 33 | ||
37 | this._shouldPayTolls = args.shouldPayTolls || false; | 34 | this._shouldPayTolls = args.shouldPayTolls || false; |
38 | 35 | ||
39 | this._tolls = { | 36 | this._tolls = { |
40 | 'CONNECT':[], | 37 | 'CONNECT':[], |
41 | 'REGISTER':[], | 38 | 'REGISTER':[], |
42 | 'MESSAGE':[] | 39 | 'MESSAGE':[] |
43 | }; | 40 | }; |
44 | 41 | ||
45 | if (args.isDefault === true) { | 42 | if (args.isDefault === true) { |
46 | Clipperz.PM.Proxy.defaultProxy = this; | 43 | Clipperz.PM.Proxy.defaultProxy = this; |
47 | } | 44 | } |
48 | 45 | ||
49 | return this; | 46 | return this; |
50 | } | 47 | } |
51 | 48 | ||
52 | Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { | 49 | Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { |
53 | 50 | ||
54 | 'toString': function() { | 51 | 'toString': function() { |
55 | return "Clipperz.PM.Proxy"; | 52 | return "Clipperz.PM.Proxy"; |
56 | }, | 53 | }, |
57 | 54 | ||
58 | //========================================================================= | 55 | //========================================================================= |
59 | 56 | ||
60 | 'shouldPayTolls': function() { | 57 | 'shouldPayTolls': function() { |
61 | return this._shouldPayTolls; | 58 | return this._shouldPayTolls; |
62 | }, | 59 | }, |
63 | 60 | ||
64 | //------------------------------------------------------------------------- | 61 | //------------------------------------------------------------------------- |
65 | 62 | ||
66 | 'tolls': function() { | 63 | 'tolls': function() { |
67 | return this._tolls; | 64 | return this._tolls; |
68 | }, | 65 | }, |
69 | 66 | ||
70 | //------------------------------------------------------------------------- | 67 | //------------------------------------------------------------------------- |
71 | 68 | ||
72 | 'payToll': function(aRequestType, someParameters) { | 69 | 'payToll': function(aRequestType, someParameters) { |
73 | vardeferredResult; | 70 | vardeferredResult; |
74 | 71 | ||
75 | //console.log(">>> Proxy.payToll", aRequestType, someParameters); | 72 | //console.log(">>> Proxy.payToll", aRequestType, someParameters); |
76 | if (this.shouldPayTolls()) { | 73 | if (this.shouldPayTolls()) { |
77 | deferredResult = new MochiKit.Async.Deferred(); | 74 | deferredResult = new MochiKit.Async.Deferred(); |
78 | 75 | ||
79 | if (this.tolls()[aRequestType].length == 0) { | 76 | if (this.tolls()[aRequestType].length == 0) { |
80 | deferredResult.addCallback(MochiKit.Base.method(this, 'sendMessage', 'knock', {requestType:aRequestType})); | 77 | deferredResult.addCallback(MochiKit.Base.method(this, 'sendMessage', 'knock', {requestType:aRequestType})); |
81 | deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); | 78 | deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); |
82 | } | 79 | } |
83 | deferredResult.addCallback(MochiKit.Base.method(this.tolls()[aRequestType], 'pop')); | 80 | deferredResult.addCallback(MochiKit.Base.method(this.tolls()[aRequestType], 'pop')); |
84 | deferredResult.addCallback(MochiKit.Base.methodcaller('deferredPay')); | 81 | deferredResult.addCallback(MochiKit.Base.methodcaller('deferredPay')); |
85 | deferredResult.addCallback(function(aToll) { | 82 | deferredResult.addCallback(function(aToll) { |
86 | var result; | 83 | var result; |
87 | 84 | ||
88 | result = { | 85 | result = { |
89 | parameters: someParameters, | 86 | parameters: someParameters, |
90 | toll: aToll | 87 | toll: aToll |
91 | } | 88 | } |
92 | 89 | ||
93 | return result; | 90 | return result; |
94 | }); | 91 | }); |
95 | 92 | ||
96 | deferredResult.callback(); | 93 | deferredResult.callback(); |
97 | } else { | 94 | } else { |
98 | deferredResult = MochiKit.Async.succeed({parameters:someParameters}); | 95 | deferredResult = MochiKit.Async.succeed({parameters:someParameters}); |
99 | } | 96 | } |
100 | //console.log("<<< Proxy.payToll"); | 97 | //console.log("<<< Proxy.payToll"); |
101 | 98 | ||
102 | return deferredResult; | 99 | return deferredResult; |
103 | }, | 100 | }, |
104 | 101 | ||
105 | //------------------------------------------------------------------------- | 102 | //------------------------------------------------------------------------- |
106 | 103 | ||
107 | 'addToll': function(aToll) { | 104 | 'addToll': function(aToll) { |
108 | //console.log(">>> Proxy.addToll", aToll); | 105 | //console.log(">>> Proxy.addToll", aToll); |
109 | this.tolls()[aToll.requestType()].push(aToll); | 106 | this.tolls()[aToll.requestType()].push(aToll); |
110 | //console.log("<<< Proxy.addToll"); | 107 | //console.log("<<< Proxy.addToll"); |
111 | }, | 108 | }, |
112 | 109 | ||
113 | //========================================================================= | 110 | //========================================================================= |
114 | 111 | ||
115 | 'setTollCallback': function(someParameters) { | 112 | 'setTollCallback': function(someParameters) { |
116 | //console.log(">>> Proxy.setTollCallback", someParameters); | 113 | //console.log(">>> Proxy.setTollCallback", someParameters); |
117 | if (typeof(someParameters['toll']) != 'undefined') { | 114 | if (typeof(someParameters['toll']) != 'undefined') { |
118 | //console.log("added a new toll", someParameters['toll']); | 115 | //console.log("added a new toll", someParameters['toll']); |
119 | this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); | 116 | this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); |
120 | } | 117 | } |