-rw-r--r-- | frontend/beta/html/index_template.html | 4 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/Record.js | 7 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Proxy.js | 3 | ||||
-rwxr-xr-x | frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js | 262 |
4 files changed, 9 insertions, 267 deletions
diff --git a/frontend/beta/html/index_template.html b/frontend/beta/html/index_template.html index 9862518..27a8a64 100644 --- a/frontend/beta/html/index_template.html +++ b/frontend/beta/html/index_template.html | |||
@@ -1,100 +1,100 @@ | |||
1 | <html> | 1 | <html> |
2 | <head> | 2 | <head> |
3 | <title>@page.title@</title> | 3 | <title>@page.title@</title> |
4 | <META http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 | <META http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
5 | <!-- | 5 | <!-- |
6 | @copyright@ | 6 | @copyright@ |
7 | --> | 7 | --> |
8 | 8 | ||
9 | @css@ | 9 | @css@ |
10 | 10 | ||
11 | <link rel="shortcut icon" href="./clipperz.ico" /> | 11 | <link rel="shortcut icon" href="./clipperz.ico" /> |
12 | 12 | ||
13 | <meta name="description" content="Login to your web accounts with just one click. Never type a password again! Use multiple complex passwords and forget them. A password manager that enhances your online security." /> | 13 | <meta name="description" content="Login to your web accounts with just one click. Never type a password again! Use multiple complex passwords and forget them. A password manager that enhances your online security." /> |
14 | <meta name="keywords" content="password manager,gestor de contraseñas,gerenciador de senhas,Kennwortmanager,passwords,security,privacy,cryptography" /> | 14 | <meta name="keywords" content="password manager,gestor de contraseñas,gerenciador de senhas,Kennwortmanager,passwords,security,privacy,cryptography" /> |
15 | <script> | 15 | <script> |
16 | Clipperz_IEisBroken = false; | 16 | Clipperz_IEisBroken = false; |
17 | Clipperz_normalizedNewLine = '\n'; | 17 | Clipperz_normalizedNewLine = '\n'; |
18 | Clipperz_dumpUrl = "/dump/"; | 18 | Clipperz_dumpUrl = "/dump/"; |
19 | </script> | 19 | </script> |
20 | 20 | ||
21 | <!--[if IE]><script> | 21 | <!--[if IE]><script> |
22 | Clipperz_IEisBroken = true; | 22 | Clipperz_IEisBroken = true; |
23 | Clipperz_normalizedNewLine = '\x0d\x0a'; | 23 | Clipperz_normalizedNewLine = '\x0d\x0a'; |
24 | </script><![endif]--> | 24 | </script><![endif]--> |
25 | 25 | ||
26 | @js_DEBUG@ | 26 | @js_LINKED@ |
27 | 27 | ||
28 | </head> | 28 | </head> |
29 | <body> | 29 | <body> |
30 | <div id="mainDiv"> | 30 | <div id="mainDiv"> |
31 | <div id="header"> | 31 | <div id="header"> |
32 | <div id="miscLinks"> | 32 | <div id="miscLinks"> |
33 | <a id="donateHeaderIconLink" href="http://www.clipperz.com/donations" target="_blank"><img id='donateHeaderIcon' src=""></a> | 33 | <a id="donateHeaderIconLink" href="http://www.clipperz.com/donations" target="_blank"><img id='donateHeaderIcon' src=""></a> |
34 | <ul> | 34 | <ul> |
35 | <li><a href="http://www.clipperz.com/donations" id='donateHeaderLink' class='highlightedHeader' target="_blank">donate</a></li> | 35 | <li><a href="http://www.clipperz.com/donations" id='donateHeaderLink' class='highlightedHeader' target="_blank">donate</a></li> |
36 | <li><a href="http://www.clipperz.com/credits" id='creditsHeaderLink' target="_blank">credits</a></li> | 36 | <li><a href="http://www.clipperz.com/credits" id='creditsHeaderLink' target="_blank">credits</a></li> |
37 | <li><a href="http://www.clipperz.com/contact" id='feedbackHeaderLink' target="_blank">feedback</a></li> | 37 | <li><a href="http://www.clipperz.com/contact" id='feedbackHeaderLink' target="_blank">feedback</a></li> |
38 | <li><a href="http://www.clipperz.com/support/user_guide" target="_blank" id='helpHeaderLink'>help</a></li> | 38 | <li><a href="http://www.clipperz.com/support/user_guide" target="_blank" id='helpHeaderLink'>help</a></li> |
39 | <li><a href="http://www.clipperz.com/forum" target="_blank" id='forumHeaderLink'>forum</a></li> | 39 | <li><a href="http://www.clipperz.com/forum" target="_blank" id='forumHeaderLink'>forum</a></li> |
40 | </ul> | 40 | </ul> |
41 | </div> | 41 | </div> |
42 | <div id="logoFrame"> | 42 | <div id="logoFrame"> |
43 | <a href="http://www.clipperz.com" target="_blank"><img id="logo" src="" /></a> | 43 | <a href="http://www.clipperz.com" target="_blank"><img id="logo" src="" /></a> |
44 | <h5 class="clipperzPayoff">keep it to yourself</h5> | 44 | <h5 class="clipperzPayoff">keep it to yourself</h5> |
45 | </div> | 45 | </div> |
46 | <div id="mainTabs"> | 46 | <div id="mainTabs"> |
47 | <ul id="exitLinks"> | 47 | <ul id="exitLinks"> |
48 | <li id="logoutLI"><!--<a href="#">logout</a>--></li> | 48 | <li id="logoutLI"><!--<a href="#">logout</a>--></li> |
49 | <li id="lockLI"><!--<a href="#">lock</a>--></li> | 49 | <li id="lockLI"><!--<a href="#">lock</a>--></li> |
50 | </ul> | 50 | </ul> |
51 | <div id="menus"> | 51 | <div id="menus"> |
52 | <table cellpadding="0" cellspacing="0" border="0"> | 52 | <table cellpadding="0" cellspacing="0" border="0"> |
53 | <tbody> | 53 | <tbody> |
54 | <tr id="menusTR"> | 54 | <tr id="menusTR"> |
55 | <!-- | 55 | <!-- |
56 | <td class="selected"><div><a href="#">records</a></div></td> | 56 | <td class="selected"><div><a href="#">records</a></div></td> |
57 | <td><div><a href="./Account.html">account</a></div></td> | 57 | <td><div><a href="./Account.html">account</a></div></td> |
58 | <td><div><a href="#">data</a></div></td> | 58 | <td><div><a href="#">data</a></div></td> |
59 | <td><div><a href="#">bookmarklet</a></div></td> | 59 | <td><div><a href="#">bookmarklet</a></div></td> |
60 | --> | 60 | --> |
61 | </tr> | 61 | </tr> |
62 | </tbody> | 62 | </tbody> |
63 | </table> | 63 | </table> |
64 | </div> | 64 | </div> |
65 | </div> | 65 | </div> |
66 | </div> | 66 | </div> |
67 | 67 | ||
68 | <div id="main"> | 68 | <div id="main"> |
69 | <h3 class="loading">loading ...</h3> | 69 | <h3 class="loading">loading ...</h3> |
70 | 70 | ||
71 | @js_INSTALL@ | 71 | @js_EMBEDDED@ |
72 | 72 | ||
73 | <script> | 73 | <script> |
74 | Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.JSON({'url':'@request.path@', 'shouldPayTolls':@should.pay.toll@}); | 74 | Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.JSON({'url':'@request.path@', 'shouldPayTolls':@should.pay.toll@}); |
75 | /*offline_data_placeholder*/ | 75 | /*offline_data_placeholder*/ |
76 | </script> | 76 | </script> |
77 | 77 | ||
78 | <div id="javaScriptAlert"> | 78 | <div id="javaScriptAlert"> |
79 | <h1>Attention!</h1> | 79 | <h1>Attention!</h1> |
80 | <p>If you can read this message, the chances are that your browser does not properly support JavaScript? or you have disabled this functionality yourself.</p> | 80 | <p>If you can read this message, the chances are that your browser does not properly support JavaScript? or you have disabled this functionality yourself.</p> |
81 | <h3>Javascript is required to access Clipperz.</h3> | 81 | <h3>Javascript is required to access Clipperz.</h3> |
82 | <h5>Please enable scripting or upgrade your browser.</h5> | 82 | <h5>Please enable scripting or upgrade your browser.</h5> |
83 | </div> | 83 | </div> |
84 | </div> | 84 | </div> |
85 | <div id="footer"> | 85 | <div id="footer"> |
86 | Copyright © 2008 Clipperz Srl - | 86 | Copyright © 2008 Clipperz Srl - |
87 | <a href="http://www.clipperz.com/terms_of_service" target="black">Terms of service</a> - | 87 | <a href="http://www.clipperz.com/terms_of_service" target="black">Terms of service</a> - |
88 | <a href="http://www.clipperz.com/privacy_policy" target="black">Privacy policy</a> | 88 | <a href="http://www.clipperz.com/privacy_policy" target="black">Privacy policy</a> |
89 | - | 89 | - |
90 | Application version: @application.version@ | 90 | Application version: @application.version@ |
91 | </div> | 91 | </div> |
92 | 92 | ||
93 | <div id="recordDetailEditModeHeaderMask"></div> | 93 | <div id="recordDetailEditModeHeaderMask"></div> |
94 | <div id="recordDetailEditModeVerticalMask"></div> | 94 | <div id="recordDetailEditModeVerticalMask"></div> |
95 | </div> | 95 | </div> |
96 | 96 | ||
97 | <div id="applicationVersionType" class="@application.version.type@" /> | 97 | <div id="applicationVersionType" class="@application.version.type@" /> |
98 | 98 | ||
99 | </body> | 99 | </body> |
100 | </html> | 100 | </html> |
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Record.js b/frontend/beta/js/Clipperz/PM/DataModel/Record.js index 270f2ae..ffb45de 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/Record.js | |||
@@ -1,756 +1,761 @@ | |||
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 Community Edition. | 5 | This file is part of Clipperz Community Edition. |
6 | Clipperz Community Edition is an online password manager. | 6 | Clipperz Community Edition is an online password manager. |
7 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 8 | refer to http://www.clipperz.com. |
9 | 9 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
11 | 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 |
12 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
13 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
14 | 14 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
19 | 19 | ||
20 | * 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 |
21 | License along with Clipperz Community Edition. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
22 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
23 | 23 | ||
24 | */ | 24 | */ |
25 | 25 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 29 | ||
30 | 30 | ||
31 | //############################################################################# | 31 | //############################################################################# |
32 | 32 | ||
33 | Clipperz.PM.DataModel.Record = function(args) { | 33 | Clipperz.PM.DataModel.Record = function(args) { |
34 | args = args || {}; | 34 | args = args || {}; |
35 | 35 | ||
36 | this._user = args['user'] || null; | 36 | this._user = args['user'] || null; |
37 | this._reference = args['reference'] || Clipperz.PM.Crypto.randomKey(); | 37 | this._reference = args['reference'] || Clipperz.PM.Crypto.randomKey(); |
38 | this._version = args['version'] || Clipperz.PM.Crypto.encryptingFunctions.currentVersion; | 38 | this._version = args['version'] || Clipperz.PM.Crypto.encryptingFunctions.currentVersion; |
39 | this._key = args['key'] || Clipperz.PM.Crypto.randomKey(); | 39 | this._key = args['key'] || Clipperz.PM.Crypto.randomKey(); |
40 | 40 | ||
41 | this.setLabel(args['label'] || Clipperz.PM.Strings['newRecordTitleLabel']); | 41 | this.setLabel(args['label'] || Clipperz.PM.Strings['newRecordTitleLabel']); |
42 | 42 | ||
43 | this.setHeaderNotes(args['headerNotes'] || null); | 43 | this.setHeaderNotes(args['headerNotes'] || null); |
44 | this.setNotes(args['notes'] || args['headerNotes'] || ""); | 44 | this.setNotes(args['notes'] || args['headerNotes'] || ""); |
45 | //MochiKit.Logging.logDebug("--- new Record ('" + this._label + "')- _headerNotes: '" + this._headerNotes + "'"); | 45 | //MochiKit.Logging.logDebug("--- new Record ('" + this._label + "')- _headerNotes: '" + this._headerNotes + "'"); |
46 | //MochiKit.Logging.logDebug("--- new Record ('" + this._label + "')- _notes: '" + this._notes + "'"); | 46 | //MochiKit.Logging.logDebug("--- new Record ('" + this._label + "')- _notes: '" + this._notes + "'"); |
47 | //this._notes = args.notes || ""; | 47 | //this._notes = args.notes || ""; |
48 | 48 | ||
49 | this._versions = {}; | 49 | this._versions = {}; |
50 | this._directLogins = {}; | 50 | this._directLogins = {}; |
51 | this._removedDirectLogins = []; | 51 | this._removedDirectLogins = []; |
52 | 52 | ||
53 | this.setIsBrandNew(args['reference'] == null); | 53 | this.setIsBrandNew(args['reference'] == null); |
54 | 54 | ||
55 | this.setShouldLoadData(this.isBrandNew() ? false: true); | 55 | this.setShouldLoadData(this.isBrandNew() ? false: true); |
56 | this.setShouldDecryptData(this.isBrandNew() ? false: true); | 56 | this.setShouldDecryptData(this.isBrandNew() ? false: true); |
57 | this.setShouldProcessData(this.isBrandNew() ? false: true); | 57 | this.setShouldProcessData(this.isBrandNew() ? false: true); |
58 | 58 | ||
59 | this.setCurrentVersion(this.isBrandNew() ? new Clipperz.PM.DataModel.RecordVersion(this, null): null); | 59 | this.setCurrentVersion(this.isBrandNew() ? new Clipperz.PM.DataModel.RecordVersion(this, null): null); |
60 | this.setCurrentVersionKey(null); | 60 | this.setCurrentVersionKey(null); |
61 | 61 | ||
62 | this._serverData = null; | 62 | this._serverData = null; |
63 | this._decryptedData = null; | 63 | this._decryptedData = null; |
64 | this._cachedData = null; | 64 | this._cachedData = null; |
65 | 65 | ||
66 | return this; | 66 | return this; |
67 | } | 67 | } |
68 | 68 | ||
69 | Clipperz.PM.DataModel.Record.prototype = MochiKit.Base.update(null, { | 69 | Clipperz.PM.DataModel.Record.prototype = MochiKit.Base.update(null, { |
70 | 70 | ||
71 | 'toString': function() { | 71 | 'toString': function() { |
72 | return "Record (" + this.label() + ")"; | 72 | return "Record (" + this.label() + ")"; |
73 | }, | 73 | }, |
74 | 74 | ||
75 | //------------------------------------------------------------------------- | 75 | //------------------------------------------------------------------------- |
76 | 76 | ||
77 | 'isBrandNew': function() { | 77 | 'isBrandNew': function() { |
78 | return this._isBrandNew; | 78 | return this._isBrandNew; |
79 | }, | 79 | }, |
80 | 80 | ||
81 | 'setIsBrandNew': function(aValue) { | 81 | 'setIsBrandNew': function(aValue) { |
82 | this._isBrandNew = aValue; | 82 | this._isBrandNew = aValue; |
83 | }, | 83 | }, |
84 | 84 | ||
85 | //------------------------------------------------------------------------- | 85 | //------------------------------------------------------------------------- |
86 | /* | 86 | /* |
87 | 'shouldRunTheRecordCreationWizard': function() { | 87 | 'shouldRunTheRecordCreationWizard': function() { |
88 | return (this.isBrandNew() && (MochiKit.Base.keys(this.currentVersion().fields()).length == 0)); | 88 | return (this.isBrandNew() && (MochiKit.Base.keys(this.currentVersion().fields()).length == 0)); |
89 | }, | 89 | }, |
90 | */ | 90 | */ |
91 | //------------------------------------------------------------------------- | 91 | //------------------------------------------------------------------------- |
92 | 92 | ||
93 | 'user': function() { | 93 | 'user': function() { |
94 | return this._user; | 94 | return this._user; |
95 | }, | 95 | }, |
96 | 96 | ||
97 | //------------------------------------------------------------------------- | 97 | //------------------------------------------------------------------------- |
98 | 98 | ||
99 | 'reference': function() { | 99 | 'reference': function() { |
100 | return this._reference; | 100 | return this._reference; |
101 | }, | 101 | }, |
102 | 102 | ||
103 | //------------------------------------------------------------------------- | 103 | //------------------------------------------------------------------------- |
104 | 104 | ||
105 | 'key': function() { | 105 | 'key': function() { |
106 | return this._key; | 106 | return this._key; |
107 | }, | 107 | }, |
108 | 108 | ||
109 | 'updateKey': function() { | 109 | 'updateKey': function() { |
110 | this._key = Clipperz.PM.Crypto.randomKey(); | 110 | this._key = Clipperz.PM.Crypto.randomKey(); |
111 | }, | 111 | }, |
112 | 112 | ||
113 | //------------------------------------------------------------------------- | 113 | //------------------------------------------------------------------------- |
114 | 114 | ||
115 | 'label': function() { | 115 | 'label': function() { |
116 | return this._label; | 116 | return this._label; |
117 | }, | 117 | }, |
118 | 118 | ||
119 | 'setLabel': function(aValue) { | 119 | 'setLabel': function(aValue) { |
120 | this._label = aValue; | 120 | this._label = aValue; |
121 | }, | 121 | }, |
122 | 122 | ||
123 | 'lowerCaseLabel': function() { | 123 | 'lowerCaseLabel': function() { |
124 | return this.label().toLowerCase(); | 124 | return this.label().toLowerCase(); |
125 | }, | 125 | }, |
126 | 126 | ||
127 | //------------------------------------------------------------------------- | 127 | //------------------------------------------------------------------------- |
128 | 128 | ||
129 | 'versions': function() { | 129 | 'versions': function() { |
130 | return this._versions; | 130 | return this._versions; |
131 | }, | 131 | }, |
132 | 132 | ||
133 | //------------------------------------------------------------------------- | 133 | //------------------------------------------------------------------------- |
134 | 134 | ||
135 | 'currentVersion': function() { | 135 | 'currentVersion': function() { |
136 | return this._currentVersion; | 136 | return this._currentVersion; |
137 | }, | 137 | }, |
138 | 138 | ||
139 | 'setCurrentVersion': function(aValue) { | 139 | 'setCurrentVersion': function(aValue) { |
140 | this._currentVersion = aValue; | 140 | this._currentVersion = aValue; |
141 | }, | 141 | }, |
142 | 142 | ||
143 | //------------------------------------------------------------------------- | 143 | //------------------------------------------------------------------------- |
144 | 144 | ||
145 | 'currentVersionKey': function() { | 145 | 'currentVersionKey': function() { |
146 | return this._currentVersionKey; | 146 | return this._currentVersionKey; |
147 | }, | 147 | }, |
148 | 148 | ||
149 | 'setCurrentVersionKey': function(aValue) { | 149 | 'setCurrentVersionKey': function(aValue) { |
150 | this._currentVersionKey = aValue; | 150 | this._currentVersionKey = aValue; |
151 | }, | 151 | }, |
152 | 152 | ||
153 | //------------------------------------------------------------------------- | 153 | //------------------------------------------------------------------------- |
154 | 154 | ||
155 | 'deferredData': function() { | 155 | 'deferredData': function() { |
156 | vardeferredResult; | 156 | vardeferredResult; |
157 | 157 | ||
158 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.deferredData - this: " + this); | 158 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.deferredData - this: " + this); |
159 | deferredResult = new MochiKit.Async.Deferred(); | 159 | deferredResult = new MochiKit.Async.Deferred(); |
160 | deferredResult.addCallback(MochiKit.Base.method(this, 'loadData')); | 160 | deferredResult.addCallback(MochiKit.Base.method(this, 'loadData')); |
161 | deferredResult.addCallback(MochiKit.Base.method(this, 'decryptData')); | 161 | deferredResult.addCallback(MochiKit.Base.method(this, 'decryptData')); |
162 | deferredResult.addCallback(MochiKit.Base.method(this, 'processData')); | 162 | deferredResult.addCallback(MochiKit.Base.method(this, 'processData')); |
163 | deferredResult.addCallback(function(aRecord) { | 163 | deferredResult.addCallback(function(aRecord) { |
164 | return aRecord.currentVersion().deferredData(); | 164 | return aRecord.currentVersion().deferredData(); |
165 | }); | 165 | }); |
166 | deferredResult.addCallback(MochiKit.Base.method(this, 'takeSnapshotOfCurrentData')); | 166 | deferredResult.addCallback(MochiKit.Base.method(this, 'takeSnapshotOfCurrentData')); |
167 | deferredResult.addCallback(MochiKit.Async.succeed, this); | 167 | deferredResult.addCallback(MochiKit.Async.succeed, this); |
168 | deferredResult.callback(); | 168 | deferredResult.callback(); |
169 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.deferredData"); | 169 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.deferredData"); |
170 | 170 | ||
171 | return deferredResult; | 171 | return deferredResult; |
172 | }, | 172 | }, |
173 | 173 | ||
174 | //------------------------------------------------------------------------- | 174 | //------------------------------------------------------------------------- |
175 | 175 | ||
176 | 'exportedData': function() { | 176 | 'exportedData': function() { |
177 | var result; | 177 | var result; |
178 | 178 | ||
179 | result = {}; | 179 | result = {}; |
180 | result['label'] = this.label(); | 180 | result['label'] = this.label(); |
181 | result['data'] = this.serializedData(); | 181 | result['data'] = this.serializedData(); |
182 | result['currentVersion'] = this.currentVersion().serializedData(); | 182 | result['currentVersion'] = this.currentVersion().serializedData(); |
183 | result['currentVersion']['reference'] = this.currentVersion().reference(); | 183 | result['currentVersion']['reference'] = this.currentVersion().reference(); |
184 | // result['versions'] = MochiKit.Base.map(MochiKit.Base.methodcaller("serializedData"), MochiKit.Base.values(this.versions())); | 184 | // result['versions'] = MochiKit.Base.map(MochiKit.Base.methodcaller("serializedData"), MochiKit.Base.values(this.versions())); |
185 | 185 | ||
186 | return Clipperz.Base.serializeJSON(result); | 186 | return Clipperz.Base.serializeJSON(result); |
187 | }, | 187 | }, |
188 | 188 | ||
189 | //------------------------------------------------------------------------- | 189 | //------------------------------------------------------------------------- |
190 | 190 | ||
191 | 'shouldLoadData': function() { | 191 | 'shouldLoadData': function() { |
192 | return this._shouldLoadData; | 192 | return this._shouldLoadData; |
193 | }, | 193 | }, |
194 | 194 | ||
195 | 'setShouldLoadData': function(aValue) { | 195 | 'setShouldLoadData': function(aValue) { |
196 | this._shouldLoadData = aValue; | 196 | this._shouldLoadData = aValue; |
197 | }, | 197 | }, |
198 | 198 | ||
199 | //------------------------------------------------------------------------- | 199 | //------------------------------------------------------------------------- |
200 | 200 | ||
201 | 'shouldDecryptData': function() { | 201 | 'shouldDecryptData': function() { |
202 | return this._shouldDecryptData; | 202 | return this._shouldDecryptData; |
203 | }, | 203 | }, |
204 | 204 | ||
205 | 'setShouldDecryptData': function(aValue) { | 205 | 'setShouldDecryptData': function(aValue) { |
206 | this._shouldDecryptData = aValue; | 206 | this._shouldDecryptData = aValue; |
207 | }, | 207 | }, |
208 | 208 | ||
209 | //------------------------------------------------------------------------- | 209 | //------------------------------------------------------------------------- |
210 | 210 | ||
211 | 'shouldProcessData': function() { | 211 | 'shouldProcessData': function() { |
212 | return this._shouldProcessData; | 212 | return this._shouldProcessData; |
213 | }, | 213 | }, |
214 | 214 | ||
215 | 'setShouldProcessData': function(aValue) { | 215 | 'setShouldProcessData': function(aValue) { |
216 | this._shouldProcessData = aValue; | 216 | this._shouldProcessData = aValue; |
217 | }, | 217 | }, |
218 | 218 | ||
219 | //------------------------------------------------------------------------- | 219 | //------------------------------------------------------------------------- |
220 | 220 | ||
221 | 'loadData': function() { | 221 | 'loadData': function() { |
222 | var result; | 222 | var result; |
223 | 223 | ||
224 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.loadData - this: " + this); | 224 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.loadData - this: " + this); |
225 | if (this.shouldLoadData()) { | 225 | if (this.shouldLoadData()) { |
226 | var deferredResult; | 226 | var deferredResult; |
227 | 227 | ||
228 | deferredResult = new MochiKit.Async.Deferred(); | 228 | deferredResult = new MochiKit.Async.Deferred(); |
229 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'loadingRecordData'); | 229 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'loadingRecordData'); |
230 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'getRecordDetail', {reference: this.reference()}); | 230 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'getRecordDetail', {reference: this.reference()}); |
231 | deferredResult.addCallback(MochiKit.Base.method(this,'setServerData')); | 231 | deferredResult.addCallback(MochiKit.Base.method(this,'setServerData')); |
232 | deferredResult.callback(); | 232 | deferredResult.callback(); |
233 | result = deferredResult; | 233 | result = deferredResult; |
234 | } else { | 234 | } else { |
235 | result = MochiKit.Async.succeed(this.serverData()); | 235 | result = MochiKit.Async.succeed(this.serverData()); |
236 | } | 236 | } |
237 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.loadData"); | 237 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.loadData"); |
238 | 238 | ||
239 | return result; | 239 | return result; |
240 | }, | 240 | }, |
241 | 241 | ||
242 | //------------------------------------------------------------------------- | 242 | //------------------------------------------------------------------------- |
243 | 243 | ||
244 | 'decryptData': function(anEncryptedData) { | 244 | 'decryptData': function(anEncryptedData) { |
245 | var result; | 245 | var result; |
246 | 246 | ||
247 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.decryptData - this: " + this + " (" + anEncryptedData + ")"); | 247 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.decryptData - this: " + this + " (" + anEncryptedData + ")"); |
248 | if (this.shouldDecryptData()) { | 248 | if (this.shouldDecryptData()) { |
249 | var deferredResult; | 249 | var deferredResult; |
250 | 250 | ||
251 | deferredResult = new MochiKit.Async.Deferred(); | 251 | deferredResult = new MochiKit.Async.Deferred(); |
252 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'decryptingRecordData'); | 252 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'decryptingRecordData'); |
253 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, this.key(), anEncryptedData['data'], anEncryptedData['version']); | 253 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, this.key(), anEncryptedData['data'], anEncryptedData['version']); |
254 | deferredResult.addCallback(function(anEncryptedData, someDecryptedValues) { | 254 | deferredResult.addCallback(function(anEncryptedData, someDecryptedValues) { |
255 | varresult; | 255 | varresult; |
256 | 256 | ||
257 | result = anEncryptedData; | 257 | result = anEncryptedData; |
258 | result['data'] = someDecryptedValues; | 258 | result['data'] = someDecryptedValues; |
259 | 259 | ||
260 | return result; | 260 | return result; |
261 | }, anEncryptedData); | 261 | }, anEncryptedData); |
262 | deferredResult.addCallback(MochiKit.Base.method(this, 'setDecryptedData')); | 262 | deferredResult.addCallback(MochiKit.Base.method(this, 'setDecryptedData')); |
263 | deferredResult.callback(); | 263 | deferredResult.callback(); |
264 | 264 | ||
265 | result = deferredResult; | 265 | result = deferredResult; |
266 | } else { | 266 | } else { |
267 | result = MochiKit.Async.succeed(this.decryptedData()); | 267 | result = MochiKit.Async.succeed(this.decryptedData()); |
268 | } | 268 | } |
269 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.decryptData"); | 269 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.decryptData"); |
270 | 270 | ||
271 | return result; | 271 | return result; |
272 | }, | 272 | }, |
273 | 273 | ||
274 | //------------------------------------------------------------------------- | 274 | //------------------------------------------------------------------------- |
275 | 275 | ||
276 | 'processData': function(someValues) { | 276 | 'processData': function(someValues) { |
277 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.processData"); | 277 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.processData"); |
278 | //MochiKit.Logging.logDebug("--- Record.processData: " + Clipperz.Base.serializeJSON(someValues)); | 278 | //MochiKit.Logging.logDebug("--- Record.processData: " + Clipperz.Base.serializeJSON(someValues)); |
279 | if (this.shouldProcessData()) { | 279 | if (this.shouldProcessData()) { |
280 | var currentVersionParameters; | 280 | var currentVersionParameters; |
281 | 281 | ||
282 | console.log("Record.processData", someValues); | ||
282 | this.processDataToExtractLegacyValues(someValues['data']); | 283 | this.processDataToExtractLegacyValues(someValues['data']); |
283 | 284 | ||
284 | if (typeof(someValues['data']['notes']) != 'undefined') { | 285 | if (typeof(someValues['data']['notes']) != 'undefined') { |
285 | this.setNotes(someValues['data']['notes']); | 286 | this.setNotes(someValues['data']['notes']); |
286 | } | 287 | } |
288 | |||
287 | if (someValues['data']['currentVersionKey'] != null) { | 289 | if (someValues['data']['currentVersionKey'] != null) { |
288 | this.setCurrentVersionKey(someValues['data']['currentVersionKey']); | 290 | this.setCurrentVersionKey(someValues['data']['currentVersionKey']); |
289 | } else { | 291 | } else { |
290 | this.setCurrentVersionKey(this.key()); | 292 | this.setCurrentVersionKey(this.key()); |
291 | } | 293 | } |
292 | 294 | ||
293 | currentVersionParameters = someValues['currentVersion']; | 295 | // currentVersionParameters = someValues['currentVersion']; |
296 | currentVersionParameters = someValues['versions'][someValues['currentVersion']]; | ||
297 | console.log("Record.processData - this.currentVersionKey()", this.currentVersionKey()); | ||
298 | console.log("Record.processData - currentVersionParameters", currentVersionParameters); | ||
294 | currentVersionParameters['key'] = this.currentVersionKey(); | 299 | currentVersionParameters['key'] = this.currentVersionKey(); |
295 | this.setCurrentVersion(new Clipperz.PM.DataModel.RecordVersion(this, currentVersionParameters)); | 300 | this.setCurrentVersion(new Clipperz.PM.DataModel.RecordVersion(this, currentVersionParameters)); |
296 | 301 | ||
297 | if (someValues['data']['directLogins'] != null) { | 302 | if (someValues['data']['directLogins'] != null) { |
298 | vardirectLoginReference; | 303 | vardirectLoginReference; |
299 | 304 | ||
300 | for (directLoginReference in someValues['data']['directLogins']) { | 305 | for (directLoginReference in someValues['data']['directLogins']) { |
301 | var directLogin; | 306 | var directLogin; |
302 | var directLoginParameters; | 307 | var directLoginParameters; |
303 | 308 | ||
304 | directLoginParameters = someValues['data']['directLogins'][directLoginReference]; | 309 | directLoginParameters = someValues['data']['directLogins'][directLoginReference]; |
305 | directLoginParameters.record = this; | 310 | directLoginParameters.record = this; |
306 | directLoginParameters.reference = directLoginReference; | 311 | directLoginParameters.reference = directLoginReference; |
307 | 312 | ||
308 | directLogin = new Clipperz.PM.DataModel.DirectLogin(directLoginParameters); | 313 | directLogin = new Clipperz.PM.DataModel.DirectLogin(directLoginParameters); |
309 | this.addDirectLogin(directLogin, true); | 314 | this.addDirectLogin(directLogin, true); |
310 | } | 315 | } |
311 | } | 316 | } |
312 | this.setShouldProcessData(false); | 317 | this.setShouldProcessData(false); |
313 | } | 318 | } |
314 | 319 | ||
315 | Clipperz.NotificationCenter.notify(this, 'recordDataReady'); | 320 | Clipperz.NotificationCenter.notify(this, 'recordDataReady'); |
316 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.processData"); | 321 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.processData"); |
317 | //MochiKit.Logging.logDebug("<<< Record.processData"); | 322 | //MochiKit.Logging.logDebug("<<< Record.processData"); |
318 | 323 | ||
319 | return this; | 324 | return this; |
320 | }, | 325 | }, |
321 | 326 | ||
322 | //------------------------------------------------------------------------- | 327 | //------------------------------------------------------------------------- |
323 | 328 | ||
324 | 'processDataToExtractLegacyValues': function(someValues) { | 329 | 'processDataToExtractLegacyValues': function(someValues) { |
325 | //MochiKit.Logging.logDebug(">>> Record.processDataToExtractLegacyValues"); | 330 | //MochiKit.Logging.logDebug(">>> Record.processDataToExtractLegacyValues"); |
326 | if (someValues['data'] != null) { | 331 | if (someValues['data'] != null) { |
327 | this.setNotes(someValues['data']); | 332 | this.setNotes(someValues['data']); |
328 | } | 333 | } |
329 | 334 | ||
330 | if ( | 335 | if ( |
331 | (typeof(someValues['loginFormData']) != "undefined") | 336 | (typeof(someValues['loginFormData']) != "undefined") |
332 | &&(typeof(someValues['loginBindings'] != "undefined")) | 337 | &&(typeof(someValues['loginBindings'] != "undefined")) |
333 | &&(someValues['loginFormData'] != "") | 338 | &&(someValues['loginFormData'] != "") |
334 | &&(someValues['loginBindings'] != "") | 339 | &&(someValues['loginBindings'] != "") |
335 | ) { | 340 | ) { |
336 | vardirectLogin; | 341 | vardirectLogin; |
337 | 342 | ||
338 | directLogin = new Clipperz.PM.DataModel.DirectLogin({ | 343 | directLogin = new Clipperz.PM.DataModel.DirectLogin({ |
339 | record:this, | 344 | record:this, |
340 | label:this.label() + Clipperz.PM.Strings['newDirectLoginLabelSuffix'], | 345 | label:this.label() + Clipperz.PM.Strings['newDirectLoginLabelSuffix'], |
341 | reference:Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(this.label() + | 346 | reference:Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(this.label() + |
342 | someValues['loginFormData'] + | 347 | someValues['loginFormData'] + |
343 | someValues['loginBindings'])).toHexString().substring(2), | 348 | someValues['loginBindings'])).toHexString().substring(2), |
344 | formData:Clipperz.Base.evalJSON(someValues['loginFormData']), | 349 | formData:Clipperz.Base.evalJSON(someValues['loginFormData']), |
345 | legacyBindingData:Clipperz.Base.evalJSON(someValues['loginBindings']), | 350 | legacyBindingData:Clipperz.Base.evalJSON(someValues['loginBindings']), |
346 | bookmarkletVersion:'0.1' | 351 | bookmarkletVersion:'0.1' |
347 | }); | 352 | }); |
348 | this.addDirectLogin(directLogin, true); | 353 | this.addDirectLogin(directLogin, true); |
349 | } | 354 | } |
350 | //MochiKit.Logging.logDebug("<<< Record.processDataToExtractLegacyValues"); | 355 | //MochiKit.Logging.logDebug("<<< Record.processDataToExtractLegacyValues"); |
351 | }, | 356 | }, |
352 | 357 | ||
353 | //------------------------------------------------------------------------- | 358 | //------------------------------------------------------------------------- |
354 | 359 | ||
355 | 'getReadyBeforeUpdatingVersionValues': function() { | 360 | 'getReadyBeforeUpdatingVersionValues': function() { |
356 | }, | 361 | }, |
357 | 362 | ||
358 | //------------------------------------------------------------------------- | 363 | //------------------------------------------------------------------------- |
359 | 364 | ||
360 | 'addNewField': function() { | 365 | 'addNewField': function() { |
361 | varnewField; | 366 | varnewField; |
362 | 367 | ||
363 | //MochiKit.Logging.logDebug(">>> Record.addNewField - " + this); | 368 | //MochiKit.Logging.logDebug(">>> Record.addNewField - " + this); |
364 | this.getReadyBeforeUpdatingVersionValues(); | 369 | this.getReadyBeforeUpdatingVersionValues(); |
365 | newField = this.currentVersion().addNewField(); | 370 | newField = this.currentVersion().addNewField(); |
366 | Clipperz.NotificationCenter.notify(this, 'recordUpdated'); | 371 | Clipperz.NotificationCenter.notify(this, 'recordUpdated'); |
367 | //MochiKit.Logging.logDebug("<<< Record.addNewField"); | 372 | //MochiKit.Logging.logDebug("<<< Record.addNewField"); |
368 | 373 | ||
369 | return newField; | 374 | return newField; |
370 | }, | 375 | }, |
371 | 376 | ||
372 | //------------------------------------------------------------------------- | 377 | //------------------------------------------------------------------------- |
373 | 378 | ||
374 | 'removeField': function(aField) { | 379 | 'removeField': function(aField) { |
375 | this.getReadyBeforeUpdatingVersionValues(); | 380 | this.getReadyBeforeUpdatingVersionValues(); |
376 | this.currentVersion().removeField(aField); | 381 | this.currentVersion().removeField(aField); |
377 | Clipperz.NotificationCenter.notify(this, 'recordUpdated'); | 382 | Clipperz.NotificationCenter.notify(this, 'recordUpdated'); |
378 | }, | 383 | }, |
379 | 384 | ||
380 | 'removeEmptyFields': function() { | 385 | 'removeEmptyFields': function() { |
381 | MochiKit.Iter.forEach(MochiKit.Base.values(this.currentVersion().fields()), MochiKit.Base.bind(function(aField) { | 386 | MochiKit.Iter.forEach(MochiKit.Base.values(this.currentVersion().fields()), MochiKit.Base.bind(function(aField) { |
382 | if (aField.isEmpty()) { | 387 | if (aField.isEmpty()) { |
383 | this.removeField(aField); | 388 | this.removeField(aField); |
384 | // this.currentVersion().removeField(aField); | 389 | // this.currentVersion().removeField(aField); |
385 | } | 390 | } |
386 | }, this)); | 391 | }, this)); |
387 | }, | 392 | }, |
388 | 393 | ||
389 | //------------------------------------------------------------------------- | 394 | //------------------------------------------------------------------------- |
390 | 395 | ||
391 | 'notes': function() { | 396 | 'notes': function() { |
392 | return this._notes; | 397 | return this._notes; |
393 | }, | 398 | }, |
394 | 399 | ||
395 | 'setNotes': function(aValue) { | 400 | 'setNotes': function(aValue) { |
396 | this._notes = aValue; | 401 | this._notes = aValue; |
397 | this.setHeaderNotes(null); | 402 | this.setHeaderNotes(null); |
398 | }, | 403 | }, |
399 | 404 | ||
400 | //------------------------------------------------------------------------- | 405 | //------------------------------------------------------------------------- |
401 | 406 | ||
402 | 'headerNotes': function() { | 407 | 'headerNotes': function() { |
403 | return this._headerNotes; | 408 | return this._headerNotes; |
404 | }, | 409 | }, |
405 | 410 | ||
406 | 'setHeaderNotes': function(aValue) { | 411 | 'setHeaderNotes': function(aValue) { |
407 | this._headerNotes = aValue; | 412 | this._headerNotes = aValue; |
408 | }, | 413 | }, |
409 | 414 | ||
410 | //------------------------------------------------------------------------- | 415 | //------------------------------------------------------------------------- |
411 | 416 | ||
412 | 'remove': function() { | 417 | 'remove': function() { |
413 | //MochiKit.Logging.logDebug(">>> Record.remove - " + this); | 418 | //MochiKit.Logging.logDebug(">>> Record.remove - " + this); |
414 | MochiKit.Iter.forEach(MochiKit.Base.values(this.directLogins()), MochiKit.Base.method(this, 'removeDirectLogin')); | 419 | MochiKit.Iter.forEach(MochiKit.Base.values(this.directLogins()), MochiKit.Base.method(this, 'removeDirectLogin')); |
415 | 420 | ||
416 | this.syncDirectLoginReferenceValues(); | 421 | this.syncDirectLoginReferenceValues(); |
417 | this.user().removeRecord(this); | 422 | this.user().removeRecord(this); |
418 | //MochiKit.Logging.logDebug("<<< Record.remove"); | 423 | //MochiKit.Logging.logDebug("<<< Record.remove"); |
419 | }, | 424 | }, |
420 | 425 | ||
421 | //------------------------------------------------------------------------- | 426 | //------------------------------------------------------------------------- |
422 | 427 | ||
423 | 'directLogins': function() { | 428 | 'directLogins': function() { |
424 | return this._directLogins; | 429 | return this._directLogins; |
425 | }, | 430 | }, |
426 | 431 | ||
427 | 'addDirectLogin': function(aDirectLogin, shouldUpdateUser) { | 432 | 'addDirectLogin': function(aDirectLogin, shouldUpdateUser) { |
428 | this.directLogins()[aDirectLogin.reference()] = aDirectLogin; | 433 | this.directLogins()[aDirectLogin.reference()] = aDirectLogin; |
429 | if (shouldUpdateUser == true) { | 434 | if (shouldUpdateUser == true) { |
430 | this.user().addDirectLogin(aDirectLogin); | 435 | this.user().addDirectLogin(aDirectLogin); |
431 | } | 436 | } |
432 | }, | 437 | }, |
433 | 438 | ||
434 | 'removeDirectLogin': function(aDirectLogin) { | 439 | 'removeDirectLogin': function(aDirectLogin) { |
435 | this.removedDirectLogins().push(aDirectLogin); | 440 | this.removedDirectLogins().push(aDirectLogin); |
436 | delete this.directLogins()[aDirectLogin.reference()]; | 441 | delete this.directLogins()[aDirectLogin.reference()]; |
437 | // this.user().removeDirectLogin(aDirectLogin); | 442 | // this.user().removeDirectLogin(aDirectLogin); |
438 | }, | 443 | }, |
439 | 444 | ||
440 | 'resetDirectLogins': function() { | 445 | 'resetDirectLogins': function() { |
441 | this._directLogins = {}; | 446 | this._directLogins = {}; |
442 | }, | 447 | }, |
443 | 448 | ||
444 | 'removedDirectLogins': function() { | 449 | 'removedDirectLogins': function() { |
445 | return this._removedDirectLogins; | 450 | return this._removedDirectLogins; |
446 | }, | 451 | }, |
447 | 452 | ||
448 | 'resetRemovedDirectLogins': function() { | 453 | 'resetRemovedDirectLogins': function() { |
449 | this._removedDirectLogins = []; | 454 | this._removedDirectLogins = []; |
450 | }, | 455 | }, |
451 | 456 | ||
452 | //------------------------------------------------------------------------- | 457 | //------------------------------------------------------------------------- |
453 | 458 | ||
454 | 'serverData': function() { | 459 | 'serverData': function() { |
455 | return this._serverData; | 460 | return this._serverData; |
456 | }, | 461 | }, |
457 | 462 | ||
458 | 'setServerData': function(aValue) { | 463 | 'setServerData': function(aValue) { |
459 | this._serverData = aValue; | 464 | this._serverData = aValue; |
460 | this.setShouldLoadData(false); | 465 | this.setShouldLoadData(false); |
461 | return aValue; | 466 | return aValue; |
462 | }, | 467 | }, |
463 | 468 | ||
464 | //------------------------------------------------------------------------- | 469 | //------------------------------------------------------------------------- |
465 | 470 | ||
466 | 'decryptedData': function() { | 471 | 'decryptedData': function() { |
467 | return this._decryptedData; | 472 | return this._decryptedData; |
468 | }, | 473 | }, |
469 | 474 | ||
470 | 'setDecryptedData': function(aValue) { | 475 | 'setDecryptedData': function(aValue) { |
471 | this._decryptedData = aValue; | 476 | this._decryptedData = aValue; |
472 | this.setShouldDecryptData(false); | 477 | this.setShouldDecryptData(false); |
473 | return aValue; | 478 | return aValue; |
474 | }, | 479 | }, |
475 | 480 | ||
476 | //------------------------------------------------------------------------- | 481 | //------------------------------------------------------------------------- |
477 | 482 | ||
478 | 'cachedData': function() { | 483 | 'cachedData': function() { |
479 | return this._cachedData; | 484 | return this._cachedData; |
480 | }, | 485 | }, |
481 | 486 | ||
482 | 'setCachedData': function(aValue) { | 487 | 'setCachedData': function(aValue) { |
483 | //MochiKit.Logging.logDebug(">>> Record.setCachedData"); | 488 | //MochiKit.Logging.logDebug(">>> Record.setCachedData"); |
484 | //MochiKit.Logging.logDebug("--- Record.setCachedData - aValue: " + Clipperz.Base.serializeJSON(aValue)); | 489 | //MochiKit.Logging.logDebug("--- Record.setCachedData - aValue: " + Clipperz.Base.serializeJSON(aValue)); |
485 | this._cachedData = aValue; | 490 | this._cachedData = aValue; |
486 | this.setShouldProcessData(false); | 491 | this.setShouldProcessData(false); |
487 | //MochiKit.Logging.logDebug("<<< Record.setCachedData"); | 492 | //MochiKit.Logging.logDebug("<<< Record.setCachedData"); |
488 | 493 | ||
489 | return aValue; | 494 | return aValue; |
490 | }, | 495 | }, |
491 | 496 | ||
492 | //------------------------------------------------------------------------- | 497 | //------------------------------------------------------------------------- |
493 | 498 | ||
494 | 'hasPendingChanges': function() { | 499 | 'hasPendingChanges': function() { |
495 | var result; | 500 | var result; |
496 | 501 | ||
497 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.hasPendingChanges"); | 502 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.hasPendingChanges"); |
498 | //MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - cachedData: " + this.cachedData()); | 503 | //MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - cachedData: " + this.cachedData()); |
499 | //MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - cachedData: " + Clipperz.Base.serializeJSON(this.cachedData())); | 504 | //MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - cachedData: " + Clipperz.Base.serializeJSON(this.cachedData())); |
500 | //MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - currentSnapshot: " + this.currentDataSnapshot()); | 505 | //MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - currentSnapshot: " + this.currentDataSnapshot()); |
501 | //MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - currentSnapshot: " + Clipperz.Base.serializeJSON(this.currentDataSnapshot())); | 506 | //MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - currentSnapshot: " + Clipperz.Base.serializeJSON(this.currentDataSnapshot())); |
502 | //console.log(">>> Record.hasPendingChanges - cachedData: %o", this.cachedData()); | 507 | //console.log(">>> Record.hasPendingChanges - cachedData: %o", this.cachedData()); |
503 | //console.log(">>> Record.hasPendingChanges - currentSnapshot: %o", this.currentDataSnapshot()); | 508 | //console.log(">>> Record.hasPendingChanges - currentSnapshot: %o", this.currentDataSnapshot()); |
504 | result = (MochiKit.Base.compare(this.cachedData(), this.currentDataSnapshot()) != 0); | 509 | result = (MochiKit.Base.compare(this.cachedData(), this.currentDataSnapshot()) != 0); |
505 | //MochiKit.Logging.logDebug("<<< Record.hasPendingChanges - " + result); | 510 | //MochiKit.Logging.logDebug("<<< Record.hasPendingChanges - " + result); |
506 | 511 | ||
507 | if ((result == false) && this.isBrandNew() && (this.label() != Clipperz.PM.Strings['newRecordTitleLabel'])) { | 512 | if ((result == false) && this.isBrandNew() && (this.label() != Clipperz.PM.Strings['newRecordTitleLabel'])) { |
508 | result = true; | 513 | result = true; |
509 | } | 514 | } |
510 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.hasPendingChanges"); | 515 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.hasPendingChanges"); |
511 | 516 | ||
512 | return result; | 517 | return result; |
513 | }, | 518 | }, |
514 | 519 | ||
515 | //------------------------------------------------------------------------- | 520 | //------------------------------------------------------------------------- |
516 | 521 | ||
517 | 'currentDataSnapshot': function() { | 522 | 'currentDataSnapshot': function() { |
518 | varresult; | 523 | varresult; |
519 | 524 | ||
520 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.currentDataSnapshot"); | 525 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.currentDataSnapshot"); |
521 | result = { | 526 | result = { |
522 | 'label': this.label(), | 527 | 'label': this.label(), |
523 | 'data': this.serializedData(), | 528 | 'data': this.serializedData(), |
524 | 'currentVersion': this.currentVersion().currentDataSnapshot() | 529 | 'currentVersion': this.currentVersion().currentDataSnapshot() |
525 | }; | 530 | }; |
526 | 531 | ||
527 | // result['data']['data'] = this.notes(); | 532 | // result['data']['data'] = this.notes(); |
528 | result = Clipperz.Base.serializeJSON(result); | 533 | result = Clipperz.Base.serializeJSON(result); |
529 | 534 | ||
530 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.currentDataSnapshot"); | 535 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.currentDataSnapshot"); |
531 | //MochiKit.Logging.logDebug("<<< Record.currentDataSnapshot"); | 536 | //MochiKit.Logging.logDebug("<<< Record.currentDataSnapshot"); |
532 | 537 | ||
533 | return result; | 538 | return result; |
534 | }, | 539 | }, |
535 | 540 | ||
536 | //......................................................................... | 541 | //......................................................................... |
537 | 542 | ||
538 | 'takeSnapshotOfCurrentData': function() { | 543 | 'takeSnapshotOfCurrentData': function() { |
539 | this.setCachedData(this.currentDataSnapshot()); | 544 | this.setCachedData(this.currentDataSnapshot()); |
540 | }, | 545 | }, |
541 | 546 | ||
542 | //------------------------------------------------------------------------- | 547 | //------------------------------------------------------------------------- |
543 | 548 | ||
544 | 'headerData': function() { | 549 | 'headerData': function() { |
545 | var result; | 550 | var result; |
546 | 551 | ||
547 | result = { | 552 | result = { |
548 | 'label': this.label(), | 553 | 'label': this.label(), |
549 | 'key': this.key() | 554 | 'key': this.key() |
550 | }; | 555 | }; |
551 | 556 | ||
552 | if (this.headerNotes() != null) { | 557 | if (this.headerNotes() != null) { |
553 | result['headerNotes'] = this.headerNotes(); | 558 | result['headerNotes'] = this.headerNotes(); |
554 | } | 559 | } |
555 | 560 | ||
556 | return result; | 561 | return result; |
557 | }, | 562 | }, |
558 | 563 | ||
559 | //------------------------------------------------------------------------- | 564 | //------------------------------------------------------------------------- |
560 | 565 | ||
561 | 'serializedData': function() { | 566 | 'serializedData': function() { |
562 | var result; | 567 | var result; |
563 | var directLoginReference; | 568 | var directLoginReference; |
564 | 569 | ||
565 | result = {}; | 570 | result = {}; |
566 | result['currentVersionKey'] = this.currentVersion().key(); | 571 | result['currentVersionKey'] = this.currentVersion().key(); |
567 | 572 | ||
568 | result['directLogins'] = {}; | 573 | result['directLogins'] = {}; |
569 | for (directLoginReference in this.directLogins()) { | 574 | for (directLoginReference in this.directLogins()) { |
570 | result['directLogins'][directLoginReference] = this.directLogins()[directLoginReference].serializedData(); | 575 | result['directLogins'][directLoginReference] = this.directLogins()[directLoginReference].serializedData(); |
571 | } | 576 | } |
572 | result['notes'] = this.notes(); | 577 | result['notes'] = this.notes(); |
573 | 578 | ||
574 | return result; | 579 | return result; |
575 | }, | 580 | }, |
576 | 581 | ||
577 | //------------------------------------------------------------------------- | 582 | //------------------------------------------------------------------------- |
578 | 583 | ||
579 | 'encryptedData': function() { | 584 | 'encryptedData': function() { |
580 | var deferredResult; | 585 | var deferredResult; |
581 | varresult; | 586 | varresult; |
582 | 587 | ||
583 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.encryptedData"); | 588 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.encryptedData"); |
584 | result = {} | 589 | result = {} |
585 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 1"); | 590 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 1"); |
586 | deferredResult = new MochiKit.Async.Deferred(); | 591 | deferredResult = new MochiKit.Async.Deferred(); |
587 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 2"); | 592 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 2"); |
588 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 1: " + res); return res;}); | 593 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 1: " + res); return res;}); |
589 | deferredResult.addCallback(function(aResult, aRecord) { | 594 | deferredResult.addCallback(function(aResult, aRecord) { |
590 | aResult['reference'] = aRecord.reference(); | 595 | aResult['reference'] = aRecord.reference(); |
591 | return aResult; | 596 | return aResult; |
592 | }, result, this); | 597 | }, result, this); |
593 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 3"); | 598 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 3"); |
594 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 2: " + res); return res;}); | 599 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 2: " + res); return res;}); |
595 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion, this.key(), this.serializedData()); | 600 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion, this.key(), this.serializedData()); |
596 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 4"); | 601 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 4"); |
597 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 3: " + res); return res;}); | 602 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 3: " + res); return res;}); |
598 | deferredResult.addCallback(function(aResult, res) { | 603 | deferredResult.addCallback(function(aResult, res) { |
599 | aResult['data'] = res; | 604 | aResult['data'] = res; |
600 | return aResult; | 605 | return aResult; |
601 | }, result); | 606 | }, result); |
602 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 5"); | 607 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 5"); |
603 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 4: " + res); return res;}); | 608 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 4: " + res); return res;}); |
604 | deferredResult.addCallback(function(aResult) { | 609 | deferredResult.addCallback(function(aResult) { |
605 | aResult['version'] = Clipperz.PM.Crypto.encryptingFunctions.currentVersion; | 610 | aResult['version'] = Clipperz.PM.Crypto.encryptingFunctions.currentVersion; |
606 | return aResult; | 611 | return aResult; |
607 | }, result); | 612 | }, result); |
608 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 6"); | 613 | //MochiKit.Logging.logDebug("--- Record.encryptedData - 6"); |
609 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 5: " + res); return res;}); | 614 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 5: " + res); return res;}); |
610 | deferredResult.callback(); | 615 | deferredResult.callback(); |
611 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.encryptedData"); | 616 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.encryptedData"); |
612 | 617 | ||
613 | return deferredResult; | 618 | return deferredResult; |
614 | }, | 619 | }, |
615 | 620 | ||
616 | //------------------------------------------------------------------------- | 621 | //------------------------------------------------------------------------- |
617 | 622 | ||
618 | 'syncDirectLoginReferenceValues': function() { | 623 | 'syncDirectLoginReferenceValues': function() { |
619 | //MochiKit.Logging.logDebug(">>> Record.syncDirectLoginReferenceValues"); | 624 | //MochiKit.Logging.logDebug(">>> Record.syncDirectLoginReferenceValues"); |
620 | MochiKit.Iter.forEach(MochiKit.Base.values(this.directLogins()), function(aDirectLogin) { | 625 | MochiKit.Iter.forEach(MochiKit.Base.values(this.directLogins()), function(aDirectLogin) { |
621 | aDirectLogin.record().user().synchronizeDirectLogin(aDirectLogin); | 626 | aDirectLogin.record().user().synchronizeDirectLogin(aDirectLogin); |
622 | }); | 627 | }); |
623 | 628 | ||
624 | MochiKit.Iter.forEach(this.removedDirectLogins(), function(aDirectLogin) { | 629 | MochiKit.Iter.forEach(this.removedDirectLogins(), function(aDirectLogin) { |
625 | aDirectLogin.record().user().removeDirectLogin(aDirectLogin); | 630 | aDirectLogin.record().user().removeDirectLogin(aDirectLogin); |
626 | }); | 631 | }); |
627 | 632 | ||
628 | this.resetRemovedDirectLogins(); | 633 | this.resetRemovedDirectLogins(); |
629 | //MochiKit.Logging.logDebug("<<< Record.syncDirectLoginReferenceValues"); | 634 | //MochiKit.Logging.logDebug("<<< Record.syncDirectLoginReferenceValues"); |
630 | }, | 635 | }, |
631 | 636 | ||
632 | //------------------------------------------------------------------------- | 637 | //------------------------------------------------------------------------- |
633 | 638 | ||
634 | 'saveChanges': function() { | 639 | 'saveChanges': function() { |
635 | var result; | 640 | var result; |
636 | 641 | ||
637 | if (this.isBrandNew() == false) { | 642 | if (this.isBrandNew() == false) { |
638 | result = this.user().saveRecords([this], 'updateData'); | 643 | result = this.user().saveRecords([this], 'updateData'); |
639 | } else { | 644 | } else { |
640 | result = this.user().saveRecords([this], 'addNewRecords'); | 645 | result = this.user().saveRecords([this], 'addNewRecords'); |
641 | } | 646 | } |
642 | 647 | ||
643 | return result; | 648 | return result; |
644 | }, | 649 | }, |
645 | 650 | ||
646 | /* | 651 | /* |
647 | 'saveChanges': function() { | 652 | 'saveChanges': function() { |
648 | var deferredResult; | 653 | var deferredResult; |
649 | varresult; | 654 | varresult; |
650 | 655 | ||
651 | Clipperz.NotificationCenter.notify(this.user(), 'updatedSection', 'records', true); | 656 | Clipperz.NotificationCenter.notify(this.user(), 'updatedSection', 'records', true); |
652 | //MochiKit.Logging.logDebug(">>> Record.saveChanges"); | 657 | //MochiKit.Logging.logDebug(">>> Record.saveChanges"); |
653 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.saveChanges"); | 658 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.saveChanges"); |
654 | if (this.headerNotes() != null) { | 659 | if (this.headerNotes() != null) { |
655 | this.setNotes(this.headerNotes()); | 660 | this.setNotes(this.headerNotes()); |
656 | } | 661 | } |
657 | this.syncDirectLoginReferenceValues(); | 662 | this.syncDirectLoginReferenceValues(); |
658 | this.currentVersion().createNewVersion(); | 663 | this.currentVersion().createNewVersion(); |
659 | 664 | ||
660 | result = {'records': [{}]}; | 665 | result = {'records': [{}]}; |
661 | 666 | ||
662 | deferredResult = new MochiKit.Async.Deferred(); | 667 | deferredResult = new MochiKit.Async.Deferred(); |
663 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_collectRecordInfo'); | 668 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_collectRecordInfo'); |
664 | deferredResult.addCallback(MochiKit.Base.method(this, 'updateKey')); | 669 | deferredResult.addCallback(MochiKit.Base.method(this, 'updateKey')); |
665 | 670 | ||
666 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptUserData'); | 671 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptUserData'); |
667 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'encryptedData')); | 672 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'encryptedData')); |
668 | deferredResult.addCallback(function(aResult, res) { | 673 | deferredResult.addCallback(function(aResult, res) { |
669 | aResult['user'] = res; | 674 | aResult['user'] = res; |
670 | return aResult; | 675 | return aResult; |
671 | }, result); | 676 | }, result); |
672 | 677 | ||
673 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordData'); | 678 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordData'); |
674 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); | 679 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); |
675 | deferredResult.addCallback(function(aResult, res) { | 680 | deferredResult.addCallback(function(aResult, res) { |
676 | //# aResult['record'] = res; | 681 | //# aResult['record'] = res; |
677 | aResult['records'][0]['record'] = res; | 682 | aResult['records'][0]['record'] = res; |
678 | return aResult; | 683 | return aResult; |
679 | }, result); | 684 | }, result); |
680 | 685 | ||
681 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordVersions'); | 686 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordVersions'); |
682 | deferredResult.addCallback(MochiKit.Base.method(this.currentVersion(), 'encryptedData')); | 687 | deferredResult.addCallback(MochiKit.Base.method(this.currentVersion(), 'encryptedData')); |
683 | deferredResult.addCallback(function(aResult, res) { | 688 | deferredResult.addCallback(function(aResult, res) { |
684 | // aResult['currentRecordVersion'] = res; | 689 | // aResult['currentRecordVersion'] = res; |
685 | aResult['records'][0]['currentRecordVersion'] = res; | 690 | aResult['records'][0]['currentRecordVersion'] = res; |
686 | return aResult; | 691 | return aResult; |
687 | }, result); | 692 | }, result); |
688 | 693 | ||
689 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData'); | 694 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData'); |
690 | if (this.isBrandNew() == false) { | 695 | if (this.isBrandNew() == false) { |
691 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'updateData'); | 696 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'updateData'); |
692 | } else { | 697 | } else { |
693 | //# deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewRecord'); | 698 | //# deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewRecord'); |
694 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewRecords'); | 699 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewRecords'); |
695 | } | 700 | } |
696 | 701 | ||
697 | deferredResult.addCallback(MochiKit.Base.method(this, 'takeSnapshotOfCurrentData')); | 702 | deferredResult.addCallback(MochiKit.Base.method(this, 'takeSnapshotOfCurrentData')); |
698 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_updatingInterface'); | 703 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_updatingInterface'); |
699 | deferredResult.addCallback(MochiKit.Base.method(this, 'setIsBrandNew'), false); | 704 | deferredResult.addCallback(MochiKit.Base.method(this, 'setIsBrandNew'), false); |
700 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'recordUpdated'); | 705 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'recordUpdated'); |
701 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'directLoginUpdated'); | 706 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'directLoginUpdated'); |
702 | deferredResult.callback(); | 707 | deferredResult.callback(); |
703 | 708 | ||
704 | return deferredResult; | 709 | return deferredResult; |
705 | }, | 710 | }, |
706 | */ | 711 | */ |
707 | //------------------------------------------------------------------------- | 712 | //------------------------------------------------------------------------- |
708 | 713 | ||
709 | 'cancelChanges': function() { | 714 | 'cancelChanges': function() { |
710 | //MochiKit.Logging.logDebug(">>> Record.cancelChanges"); | 715 | //MochiKit.Logging.logDebug(">>> Record.cancelChanges"); |
711 | //MochiKit.Logging.logDebug("--- Record.cancelChanges - cachedData: " + Clipperz.Base.serializeJSON(this.cachedData())); | 716 | //MochiKit.Logging.logDebug("--- Record.cancelChanges - cachedData: " + Clipperz.Base.serializeJSON(this.cachedData())); |
712 | if (this.isBrandNew()) { | 717 | if (this.isBrandNew()) { |
713 | this.user().removeRecord(this); | 718 | this.user().removeRecord(this); |
714 | } else { | 719 | } else { |
715 | this.restoreValuesFromSnapshot(this.cachedData()); | 720 | this.restoreValuesFromSnapshot(this.cachedData()); |
716 | } | 721 | } |
717 | //MochiKit.Logging.logDebug("<<< Record.cancelChanges"); | 722 | //MochiKit.Logging.logDebug("<<< Record.cancelChanges"); |
718 | }, | 723 | }, |
719 | 724 | ||
720 | //------------------------------------------------------------------------- | 725 | //------------------------------------------------------------------------- |
721 | 726 | ||
722 | 'restoreValuesFromSnapshot': function(someSnapshotData) { | 727 | 'restoreValuesFromSnapshot': function(someSnapshotData) { |
723 | varsnapshotData; | 728 | varsnapshotData; |
724 | 729 | ||
725 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.restoreValuesFromSnapshot"); | 730 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.restoreValuesFromSnapshot"); |
726 | snapshotData = Clipperz.Base.evalJSON(someSnapshotData); | 731 | snapshotData = Clipperz.Base.evalJSON(someSnapshotData); |
727 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - someSnapshotData (1): " + Clipperz.Base.serializeJSON(someSnapshotData)); | 732 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - someSnapshotData (1): " + Clipperz.Base.serializeJSON(someSnapshotData)); |
728 | this.setLabel(snapshotData['label']); | 733 | this.setLabel(snapshotData['label']); |
729 | this.resetDirectLogins(); | 734 | this.resetDirectLogins(); |
730 | this.setShouldProcessData(true); | 735 | this.setShouldProcessData(true); |
731 | this.processData(snapshotData); | 736 | this.processData(snapshotData); |
732 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - snapshotData: (2)" + Clipperz.Base.serializeJSON(snapshotData)); | 737 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - snapshotData: (2)" + Clipperz.Base.serializeJSON(snapshotData)); |
733 | 738 | ||
734 | this.resetRemovedDirectLogins(); | 739 | this.resetRemovedDirectLogins(); |
735 | 740 | ||
736 | { | 741 | { |
737 | var currentSnapshot; | 742 | var currentSnapshot; |
738 | varcomparisonResult; | 743 | varcomparisonResult; |
739 | 744 | ||
740 | currentSnapshot = this.currentDataSnapshot(); | 745 | currentSnapshot = this.currentDataSnapshot(); |
741 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - 1"); | 746 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - 1"); |
742 | //console.log("snapshot data: %o", someSnapshotData.currentVersion); | 747 | //console.log("snapshot data: %o", someSnapshotData.currentVersion); |
743 | //console.log("current data: %o", currentSnapshot.currentVersion); | 748 | //console.log("current data: %o", currentSnapshot.currentVersion); |
744 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - someSnapshotData: " + Clipperz.Base.serializeJSON(someSnapshotData.currentVersion)); | 749 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - someSnapshotData: " + Clipperz.Base.serializeJSON(someSnapshotData.currentVersion)); |
745 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - currentSnapshot: " + Clipperz.Base.serializeJSON(currentSnapshot.currentVersion)); | 750 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - currentSnapshot: " + Clipperz.Base.serializeJSON(currentSnapshot.currentVersion)); |
746 | comparisonResult = MochiKit.Base.compare(someSnapshotData.currentVersion, currentSnapshot.currentVersion); | 751 | comparisonResult = MochiKit.Base.compare(someSnapshotData.currentVersion, currentSnapshot.currentVersion); |
747 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - " + comparisonResult); | 752 | //MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - " + comparisonResult); |
748 | } | 753 | } |
749 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.restoreValuesFromSnapshot"); | 754 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.restoreValuesFromSnapshot"); |
750 | }, | 755 | }, |
751 | 756 | ||
752 | //------------------------------------------------------------------------- | 757 | //------------------------------------------------------------------------- |
753 | __syntaxFix__: "syntax fix" | 758 | __syntaxFix__: "syntax fix" |
754 | }); | 759 | }); |
755 | 760 | ||
756 | 761 | ||
diff --git a/frontend/beta/js/Clipperz/PM/Proxy.js b/frontend/beta/js/Clipperz/PM/Proxy.js index f476196..bec9195 100644 --- a/frontend/beta/js/Clipperz/PM/Proxy.js +++ b/frontend/beta/js/Clipperz/PM/Proxy.js | |||
@@ -1,170 +1,169 @@ | |||
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 Community Edition. | 5 | This file is part of Clipperz Community Edition. |
6 | Clipperz Community Edition is an online password manager. | 6 | Clipperz Community Edition is an online password manager. |
7 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 8 | refer to http://www.clipperz.com. |
9 | 9 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
11 | 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 |
12 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
13 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
14 | 14 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
19 | 19 | ||
20 | * 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 |
21 | License along with Clipperz Community Edition. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
22 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
23 | 23 | ||
24 | */ | 24 | */ |
25 | 25 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | 28 | ||
29 | //============================================================================= | 29 | //============================================================================= |
30 | 30 | ||
31 | Clipperz.PM.Proxy = function(args) { | 31 | Clipperz.PM.Proxy = function(args) { |
32 | args = args || {}; | 32 | args = args || {}; |
33 | 33 | ||
34 | this._shouldPayTolls = args.shouldPayTolls || false; | 34 | this._shouldPayTolls = args.shouldPayTolls || false; |
35 | 35 | ||
36 | this._tolls = { | 36 | this._tolls = { |
37 | 'CONNECT':[], | 37 | 'CONNECT':[], |
38 | 'REGISTER':[], | 38 | 'REGISTER':[], |
39 | 'MESSAGE':[] | 39 | 'MESSAGE':[] |
40 | }; | 40 | }; |
41 | 41 | ||
42 | if (args.isDefault === true) { | 42 | if (args.isDefault === true) { |
43 | Clipperz.PM.Proxy.defaultProxy = this; | 43 | Clipperz.PM.Proxy.defaultProxy = this; |
44 | } | 44 | } |
45 | 45 | ||
46 | return this; | 46 | return this; |
47 | } | 47 | } |
48 | 48 | ||
49 | Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { | 49 | Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { |
50 | 50 | ||
51 | 'toString': function() { | 51 | 'toString': function() { |
52 | return "Clipperz.PM.Proxy"; | 52 | return "Clipperz.PM.Proxy"; |
53 | }, | 53 | }, |
54 | 54 | ||
55 | //========================================================================= | 55 | //========================================================================= |
56 | 56 | ||
57 | 'shouldPayTolls': function() { | 57 | 'shouldPayTolls': function() { |
58 | return this._shouldPayTolls; | 58 | return this._shouldPayTolls; |
59 | }, | 59 | }, |
60 | 60 | ||
61 | //------------------------------------------------------------------------- | 61 | //------------------------------------------------------------------------- |
62 | 62 | ||
63 | 'tolls': function() { | 63 | 'tolls': function() { |
64 | return this._tolls; | 64 | return this._tolls; |
65 | }, | 65 | }, |
66 | 66 | ||
67 | //------------------------------------------------------------------------- | 67 | //------------------------------------------------------------------------- |
68 | 68 | ||
69 | 'payToll': function(aRequestType, someParameters) { | 69 | 'payToll': function(aRequestType, someParameters) { |
70 | vardeferredResult; | 70 | vardeferredResult; |
71 | 71 | ||
72 | //console.log(">>> Proxy.payToll", aRequestType, someParameters); | 72 | //console.log(">>> Proxy.payToll", aRequestType, someParameters); |
73 | if (this.shouldPayTolls()) { | 73 | if (this.shouldPayTolls()) { |
74 | deferredResult = new MochiKit.Async.Deferred(); | 74 | deferredResult = new MochiKit.Async.Deferred(); |
75 | 75 | ||
76 | if (this.tolls()[aRequestType].length == 0) { | 76 | if (this.tolls()[aRequestType].length == 0) { |
77 | deferredResult.addCallback(MochiKit.Base.method(this, 'sendMessage', 'knock', {requestType:aRequestType})); | 77 | deferredResult.addCallback(MochiKit.Base.method(this, 'sendMessage', 'knock', {requestType:aRequestType})); |
78 | deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); | 78 | deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); |
79 | } | 79 | } |
80 | deferredResult.addCallback(MochiKit.Base.method(this.tolls()[aRequestType], 'pop')); | 80 | deferredResult.addCallback(MochiKit.Base.method(this.tolls()[aRequestType], 'pop')); |
81 | deferredResult.addCallback(MochiKit.Base.methodcaller('deferredPay')); | 81 | deferredResult.addCallback(MochiKit.Base.methodcaller('deferredPay')); |
82 | deferredResult.addCallback(function(aToll) { | 82 | deferredResult.addCallback(function(aToll) { |
83 | var result; | 83 | var result; |
84 | 84 | ||
85 | result = { | 85 | result = { |
86 | parameters: someParameters, | 86 | parameters: someParameters, |
87 | toll: aToll | 87 | toll: aToll |
88 | } | 88 | } |
89 | 89 | ||
90 | return result; | 90 | return result; |
91 | }); | 91 | }); |
92 | 92 | ||
93 | deferredResult.callback(); | 93 | deferredResult.callback(); |
94 | } else { | 94 | } else { |
95 | deferredResult = MochiKit.Async.succeed({parameters:someParameters}); | 95 | deferredResult = MochiKit.Async.succeed({parameters:someParameters}); |
96 | } | 96 | } |
97 | //console.log("<<< Proxy.payToll"); | 97 | //console.log("<<< Proxy.payToll"); |
98 | 98 | ||
99 | return deferredResult; | 99 | return deferredResult; |
100 | }, | 100 | }, |
101 | 101 | ||
102 | //------------------------------------------------------------------------- | 102 | //------------------------------------------------------------------------- |
103 | 103 | ||
104 | 'addToll': function(aToll) { | 104 | 'addToll': function(aToll) { |
105 | //console.log(">>> Proxy.addToll", aToll); | 105 | //console.log(">>> Proxy.addToll", aToll); |
106 | this.tolls()[aToll.requestType()].push(aToll); | 106 | this.tolls()[aToll.requestType()].push(aToll); |
107 | //console.log("<<< Proxy.addToll"); | 107 | //console.log("<<< Proxy.addToll"); |
108 | }, | 108 | }, |
109 | 109 | ||
110 | //========================================================================= | 110 | //========================================================================= |
111 | 111 | ||
112 | 'setTollCallback': function(someParameters) { | 112 | 'setTollCallback': function(someParameters) { |
113 | //console.log(">>> Proxy.setTollCallback", someParameters); | 113 | //console.log(">>> Proxy.setTollCallback", someParameters); |
114 | if (typeof(someParameters['toll']) != 'undefined') { | 114 | if (typeof(someParameters['toll']) != 'undefined') { |
115 | //console.log("added a new toll", someParameters['toll']); | 115 | //console.log("added a new toll", someParameters['toll']); |
116 | this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); | 116 | this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); |
117 | } | 117 | } |
118 | //console.log("<<< Proxy.setTallCallback", someParameters['result']); | 118 | //console.log("<<< Proxy.setTallCallback", someParameters['result']); |
119 | //return someParameters['result']; | 119 | return someParameters['result']; |
120 | return someParameters; | ||
121 | }, | 120 | }, |
122 | 121 | ||
123 | //========================================================================= | 122 | //========================================================================= |
124 | 123 | ||
125 | 'registration': function (someParameters) { | 124 | 'registration': function (someParameters) { |
126 | return this.processMessage('registration', someParameters, 'REGISTER'); | 125 | return this.processMessage('registration', someParameters, 'REGISTER'); |
127 | }, | 126 | }, |
128 | 127 | ||
129 | 'handshake': function (someParameters) { | 128 | 'handshake': function (someParameters) { |
130 | return this.processMessage('handshake', someParameters, 'CONNECT'); | 129 | return this.processMessage('handshake', someParameters, 'CONNECT'); |
131 | }, | 130 | }, |
132 | 131 | ||
133 | 'message': function (someParameters) { | 132 | 'message': function (someParameters) { |
134 | return this.processMessage('message', someParameters, 'MESSAGE'); | 133 | return this.processMessage('message', someParameters, 'MESSAGE'); |
135 | }, | 134 | }, |
136 | 135 | ||
137 | 'logout': function (someParameters) { | 136 | 'logout': function (someParameters) { |
138 | return this.processMessage('logout', someParameters, 'MESSAGE'); | 137 | return this.processMessage('logout', someParameters, 'MESSAGE'); |
139 | }, | 138 | }, |
140 | 139 | ||
141 | //========================================================================= | 140 | //========================================================================= |
142 | 141 | ||
143 | 'processMessage': function (aFunctionName, someParameters, aRequestType) { | 142 | 'processMessage': function (aFunctionName, someParameters, aRequestType) { |
144 | vardeferredResult; | 143 | vardeferredResult; |
145 | 144 | ||
146 | deferredResult = new MochiKit.Async.Deferred(); | 145 | deferredResult = new MochiKit.Async.Deferred(); |
147 | deferredResult.addCallback(MochiKit.Base.method(this, 'payToll', aRequestType)); | 146 | deferredResult.addCallback(MochiKit.Base.method(this, 'payToll', aRequestType)); |
148 | deferredResult.addCallback(MochiKit.Base.method(this, 'sendMessage', aFunctionName)); | 147 | deferredResult.addCallback(MochiKit.Base.method(this, 'sendMessage', aFunctionName)); |
149 | deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); | 148 | deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); |
150 | deferredResult.callback(someParameters); | 149 | deferredResult.callback(someParameters); |
151 | 150 | ||
152 | return deferredResult; | 151 | return deferredResult; |
153 | }, | 152 | }, |
154 | 153 | ||
155 | //========================================================================= | 154 | //========================================================================= |
156 | 155 | ||
157 | 'sendMessage': function () { | 156 | 'sendMessage': function () { |
158 | throw Clipperz.Base.exception.AbstractMethod; | 157 | throw Clipperz.Base.exception.AbstractMethod; |
159 | }, | 158 | }, |
160 | 159 | ||
161 | //========================================================================= | 160 | //========================================================================= |
162 | 161 | ||
163 | 'isReadOnly': function () { | 162 | 'isReadOnly': function () { |
164 | return false; | 163 | return false; |
165 | }, | 164 | }, |
166 | 165 | ||
167 | //========================================================================= | 166 | //========================================================================= |
168 | __syntaxFix__: "syntax fix" | 167 | __syntaxFix__: "syntax fix" |
169 | 168 | ||
170 | }); | 169 | }); |
diff --git a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js deleted file mode 100755 index 34a10c2..0000000 --- a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js +++ b/dev/null | |||
@@ -1,262 +0,0 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz Community Edition. | ||
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | ||
8 | refer to http://www.clipperz.com. | ||
9 | |||
10 | * Clipperz Community Edition is free software: you can redistribute | ||
11 | it and/or modify it under the terms of the GNU Affero General Public | ||
12 | License as published by the Free Software Foundation, either version | ||
13 | 3 of the License, or (at your option) any later version. | ||
14 | |||
15 | * Clipperz Community Edition is distributed in the hope that it will | ||
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
18 | See the GNU Affero General Public License for more details. | ||
19 | |||
20 | * You should have received a copy of the GNU Affero General Public | ||
21 | License along with Clipperz Community Edition. If not, see | ||
22 | <http://www.gnu.org/licenses/>. | ||
23 | |||
24 | */ | ||
25 | |||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
28 | |||
29 | //============================================================================= | ||
30 | |||
31 | Clipperz.PM.Proxy.PHP = function(args) { | ||
32 | Clipperz.PM.Proxy.PHP.superclass.constructor.call(this, args); | ||
33 | /* | ||
34 | this._tolls = { | ||
35 | 'CONNECT':[], | ||
36 | 'REGISTER':[], | ||
37 | 'MESSAGE':[] | ||
38 | }; | ||
39 | */ | ||
40 | return this; | ||
41 | } | ||
42 | |||
43 | YAHOO.extendX(Clipperz.PM.Proxy.PHP, Clipperz.PM.Proxy, { | ||
44 | |||
45 | 'toString': function() { | ||
46 | return "Clipperz.PM.Proxy.PHP - " + this.args(); | ||
47 | }, | ||
48 | |||
49 | //========================================================================= | ||
50 | /* | ||
51 | 'tolls': function() { | ||
52 | return this._tolls; | ||
53 | }, | ||
54 | */ | ||
55 | //------------------------------------------------------------------------- | ||
56 | /* | ||
57 | 'payToll': function(aRequestType, someParameters) { | ||
58 | vardeferredResult; | ||
59 | |||
60 | //MochiKit.Logging.logDebug(">>> Proxy.DWR.payToll: " + aRequestType); | ||
61 | if (this.tolls()[aRequestType].length > 0) { | ||
62 | deferredResult = MochiKit.Async.succeed(this.tolls()[aRequestType].pop()); | ||
63 | } else { | ||
64 | //MochiKit.Logging.logDebug("### " + aRequestType + " toll NOT immediately available; request queued."); | ||
65 | deferredResult = new MochiKit.Async.Deferred(); | ||
66 | deferredResult.addCallback(function(someParameters) { | ||
67 | return new Clipperz.PM.Toll(someParameters['toll']); | ||
68 | }) | ||
69 | com_clipperz_pm_Proxy.knock(Clipperz.Base.serializeJSON({requestType:aRequestType}), { | ||
70 | callback:MochiKit.Base.method(deferredResult, 'callback'), | ||
71 | errorHandler:MochiKit.Base.method(deferredResult, 'errback') | ||
72 | }); | ||
73 | } | ||
74 | |||
75 | deferredResult.addCallback(function(aToll) { | ||
76 | return aToll.deferredPay(); | ||
77 | }); | ||
78 | deferredResult.addCallback(function(someParameters, aToll) { | ||
79 | var result; | ||
80 | |||
81 | result = { | ||
82 | parameters: someParameters, | ||
83 | toll: aToll | ||
84 | } | ||
85 | |||
86 | return result; | ||
87 | }, someParameters); | ||
88 | |||
89 | return deferredResult; | ||
90 | }, | ||
91 | */ | ||
92 | //------------------------------------------------------------------------- | ||
93 | /* | ||
94 | 'addToll': function(aToll) { | ||
95 | this.tolls()[aToll.requestType()].push(aToll); | ||
96 | }, | ||
97 | */ | ||
98 | //========================================================================= | ||
99 | /* | ||
100 | 'setTollCallback': function(someParameters) { | ||
101 | //MochiKit.Logging.logDebug(">>> Proxy.DWR.setTollCallback"); | ||
102 | //MochiKit.Logging.logDebug("--- Proxy.DWR.setTollCallback - " + Clipperz.Base.serializeJSON(someParameters)); | ||
103 | if (typeof(someParameters['toll']) != 'undefined') { | ||
104 | this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); | ||
105 | } | ||
106 | return someParameters['result']; | ||
107 | }, | ||
108 | */ | ||
109 | //========================================================================= | ||
110 | |||
111 | 'registration': function(someParameters) { | ||
112 | return this.sendMessage('registration', someParameters, 'REGISTER'); | ||
113 | }, | ||
114 | |||
115 | //------------------------------------------------------------------------- | ||
116 | |||
117 | 'handshake': function(someParameters) { | ||
118 | /* | ||
119 | _s = "e8a2162f29aeaabb729f5625e9740edbf0cd80ac77c6b19ab951ed6c88443b8c"; | ||
120 | _v = new Clipperz.Crypto.BigInt("955e2db0f7844aca372f5799e5f7e51b5866718493096908bd66abcf1d068108", 16); | ||
121 | _b = new Clipperz.Crypto.BigInt("5761e6c84d22ea3c5649de01702d60f674ccfe79238540eb34c61cd020230c53", 16); | ||
122 | |||
123 | _B = _v.add(Clipperz.Crypto.SRP.g().powerModule(_b, Clipperz.Crypto.SRP.n())); | ||
124 | _u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_B.asString(10))).toHexString(), 16); | ||
125 | _A = new Clipperz.Crypto.BigInt("3b3567ec33d73673552e960872eb154d091a2488915941038aef759236a27e64", 16); | ||
126 | _S = (_A.multiply(_v.powerModule(_u, Clipperz.Crypto.SRP.n()))).powerModule(_b, Clipperz.Crypto.SRP.n()); | ||
127 | _K = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_S.asString(10))).toHexString().slice(2); | ||
128 | _M1 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_A.asString(10) + _B.asString(10) + _K)).toHexString().slice(2); | ||
129 | _M2 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_A.asString(10) + _M1 + _K)).toHexString().slice(2); | ||
130 | |||
131 | // MochiKit.Logging.logDebug("b = " + _b.asString(16)); | ||
132 | // MochiKit.Logging.logDebug("v = " + _v.asString(16)); | ||
133 | MochiKit.Logging.logDebug("B = " + _B.asString(16)); | ||
134 | MochiKit.Logging.logDebug("u = " + _u.asString(16)); | ||
135 | MochiKit.Logging.logDebug("S = " + _S.asString(16)); | ||
136 | MochiKit.Logging.logDebug("K = " + _K); | ||
137 | MochiKit.Logging.logDebug("M1 = " + _M1); | ||
138 | MochiKit.Logging.logDebug("M2 = " + _M2); | ||
139 | // MochiKit.Logging.logDebug("someParameters.version: " + someParameters.version); | ||
140 | */ | ||
141 | return this.sendMessage('handshake', someParameters, 'CONNECT'); | ||
142 | }, | ||
143 | |||
144 | //------------------------------------------------------------------------- | ||
145 | |||
146 | 'message': function(someParameters) { | ||
147 | return this.sendMessage('message', someParameters, 'MESSAGE'); | ||
148 | }, | ||
149 | |||
150 | //------------------------------------------------------------------------- | ||
151 | |||
152 | 'logout': function(someParameters) { | ||
153 | //MochiKit.Logging.logDebug("=== Proxy.DWR.logout"); | ||
154 | return this.sendMessage('logout', someParameters, 'MESSAGE'); | ||
155 | }, | ||
156 | |||
157 | //========================================================================= | ||
158 | |||
159 | 'sendMessage': function(aFunctionName, someParameters, aRequestType) { | ||
160 | /* | ||
161 | vardeferredResult; | ||
162 | var proxy; | ||
163 | |||
164 | //MochiKit.Logging.logDebug(">>> Proxy.DWR.sendMessage - " + aFunctionName + " - " + aRequestType); | ||
165 | proxy = this; | ||
166 | |||
167 | deferredResult = new MochiKit.Async.Deferred(); | ||
168 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.1 Proxy.DWR.sendMessage - 1: " + res); return res;}); | ||
169 | deferredResult.addCallback(MochiKit.Base.method(proxy, 'payToll'), aRequestType); | ||
170 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.2 Proxy.DWR.sendMessage - 2: " + Clipperz.Base.serializeJSON(res)); return res;}); | ||
171 | deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName); | ||
172 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + res); return res;}); | ||
173 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + Clipperz.Base.serializeJSON(res)); return res;}); | ||
174 | deferredResult.callback(someParameters); | ||
175 | |||
176 | //MochiKit.Logging.logDebug("<<< Proxy.DWR.sendMessage"); | ||
177 | return deferredResult; | ||
178 | */ | ||
179 | |||
180 | // return this.sendRemoteMessage(aFunctionName, someParameters); | ||
181 | |||
182 | |||
183 | vardeferredResult; | ||
184 | var proxy; | ||
185 | |||
186 | proxy = this; | ||
187 | |||
188 | deferredResult = new MochiKit.Async.Deferred(); | ||
189 | deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName); | ||
190 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3: " + res); return res;}); | ||
191 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3.1: " + Clipperz.Base.serializeJSON(res)); return res;}); | ||
192 | |||
193 | deferredResult.callback(someParameters); | ||
194 | |||
195 | return deferredResult; | ||
196 | }, | ||
197 | |||
198 | //========================================================================= | ||
199 | |||
200 | 'sendRemoteMessage': function(aFunctionName, someParameters) { | ||
201 | /* | ||
202 | vardeferredResult; | ||
203 | |||
204 | //MochiKit.Logging.logDebug(">>> Proxy.DWR.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this); | ||
205 | deferredResult = new MochiKit.Async.Deferred(); | ||
206 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 1: " + res); return res;}); | ||
207 | // deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); | ||
208 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 2: " + res); return res;}); | ||
209 | |||
210 | com_clipperz_pm_Proxy[aFunctionName](Clipperz.Base.serializeJSON(someParameters), { | ||
211 | callback:MochiKit.Base.method(deferredResult, 'callback'), | ||
212 | errorHandler:MochiKit.Base.method(deferredResult, 'errback') | ||
213 | }); | ||
214 | //MochiKit.Logging.logDebug("<<< Proxy.PHP.sendRemoteMessage - result: " + deferredResult); | ||
215 | |||
216 | return deferredResult; | ||
217 | */ | ||
218 | |||
219 | vardeferredResult; | ||
220 | var parameters; | ||
221 | |||
222 | //MochiKit.Logging.logDebug(">>> Proxy.PHP.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this); | ||
223 | parameters = {}; | ||
224 | parameters['method'] = aFunctionName; | ||
225 | // parameters['version'] = someParameters['version']; | ||
226 | // parameters['message'] = someParameters['message']; | ||
227 | parameters['parameters'] = Clipperz.Base.serializeJSON(someParameters); | ||
228 | //MochiKit.Logging.logDebug("--- Proxy.PHP.sendRemoteMessage('" + Clipperz.Base.serializeJSON(parameters) + ") - " + this); | ||
229 | deferredResult = new MochiKit.Async.Deferred(); | ||
230 | deferredResult.addCallback(MochiKit.Async.doXHR, "./php/index.php", { | ||
231 | method:'POST', | ||
232 | sendContent:MochiKit.Base.queryString(parameters), | ||
233 | headers:{"Content-Type":"application/x-www-form-urlencoded"} | ||
234 | }); | ||
235 | //deferredResult.addCallback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - 2: " + res.responseText); return res;}); | ||
236 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - ERROR: " + res); return res;}); | ||
237 | deferredResult.addCallback(MochiKit.Async.evalJSONRequest); | ||
238 | deferredResult.addCallback(function (someValues) { | ||
239 | if (someValues['result'] == 'EXCEPTION') { | ||
240 | throw someValues['message']; | ||
241 | } | ||
242 | return someValues; | ||
243 | }) | ||
244 | deferredResult.callback(); | ||
245 | |||
246 | return deferredResult; | ||
247 | }, | ||
248 | |||
249 | //========================================================================= | ||
250 | |||
251 | 'isReadOnly': function() { | ||
252 | return false; | ||
253 | }, | ||
254 | |||
255 | //========================================================================= | ||
256 | __syntaxFix__: "syntax fix" | ||
257 | |||
258 | }); | ||
259 | |||
260 | //============================================================================= | ||
261 | |||
262 | //Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.PHP("Proxy.PHP - async test"); | ||