author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
commit | 541bb378ddece2eab135a8066a16994e94436dea (patch) (unidiff) | |
tree | ff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/beta/js/Clipperz/PM/DataModel/User.js | |
parent | 1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff) | |
parent | ecad5e895831337216544e81f1a467e0c68c4a6a (diff) | |
download | clipperz-541bb378ddece2eab135a8066a16994e94436dea.zip clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2 |
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/User.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/User.js | 904 |
1 files changed, 904 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/User.js b/frontend/beta/js/Clipperz/PM/DataModel/User.js new file mode 100644 index 0000000..5aaaff7 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/DataModel/User.js | |||
@@ -0,0 +1,904 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer to http://www.clipperz.com | ||
12 | |||
13 | * Javascript Crypto Library is free software: you can redistribute | ||
14 | it and/or modify it under the terms of the GNU Affero General Public | ||
15 | License as published by the Free Software Foundation, either version | ||
16 | 3 of the License, or (at your option) any later version. | ||
17 | |||
18 | * Javascript Crypto Library is distributed in the hope that it will | ||
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | See the GNU Affero General Public License for more details. | ||
22 | |||
23 | * You should have received a copy of the GNU Affero General Public | ||
24 | License along with Javascript Crypto Library. If not, see | ||
25 | <http://www.gnu.org/licenses/>. | ||
26 | |||
27 | */ | ||
28 | |||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | ||
32 | |||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.DataModel.User = function(args) { | ||
37 | //MochiKit.Logging.logDebug(">>> new User"); | ||
38 | args = args || {}; | ||
39 | |||
40 | this._username = args.username || null; | ||
41 | this._passphrase = args.passphrase || null; | ||
42 | |||
43 | this._connection = null; | ||
44 | this._connectionVersion = 'current'; | ||
45 | |||
46 | this._header = null; | ||
47 | this._statistics = null; | ||
48 | this._lock = 'new lock'; | ||
49 | |||
50 | this._preferences = null; | ||
51 | this._records = {}; | ||
52 | this._directLoginReferences = {}; | ||
53 | this._oneTimePasswordManager = null; | ||
54 | |||
55 | this._isLoadingUserDetails = false; | ||
56 | this._loadingUserDetailsPendingQueue = []; | ||
57 | |||
58 | this._maxNumberOfRecords = Number.MAX_VALUE; | ||
59 | |||
60 | this._shouldDownloadOfflineCopy = false; | ||
61 | |||
62 | this._loginInfo = null; | ||
63 | this._loginHistory = null; | ||
64 | |||
65 | this._serverData = null; | ||
66 | //MochiKit.Logging.logDebug("<<< new User"); | ||
67 | |||
68 | return this; | ||
69 | } | ||
70 | |||
71 | Clipperz.PM.DataModel.User.prototype = MochiKit.Base.update(null, { | ||
72 | |||
73 | 'toString': function() { | ||
74 | return "Clipperz.PM.DataModel.User - " + this.username(); | ||
75 | }, | ||
76 | |||
77 | //------------------------------------------------------------------------- | ||
78 | |||
79 | 'username': function() { | ||
80 | return this._username; | ||
81 | }, | ||
82 | |||
83 | 'setUsername': function(aValue) { | ||
84 | this._username = aValue; | ||
85 | }, | ||
86 | |||
87 | //------------------------------------------------------------------------- | ||
88 | |||
89 | 'passphrase': function() { | ||
90 | return this._passphrase; | ||
91 | }, | ||
92 | |||
93 | 'setPassphrase': function(aValue) { | ||
94 | this._passphrase = aValue; | ||
95 | }, | ||
96 | |||
97 | //------------------------------------------------------------------------- | ||
98 | |||
99 | 'maxNumberOfRecords': function() { | ||
100 | return this._maxNumberOfRecords; | ||
101 | }, | ||
102 | |||
103 | 'setMaxNumberOfRecords': function(aValue) { | ||
104 | this._maxNumberOfRecords = aValue; | ||
105 | }, | ||
106 | |||
107 | //------------------------------------------------------------------------- | ||
108 | |||
109 | 'errorHandler': function(anErrorString, anException) { | ||
110 | MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anException + ")"); | ||
111 | }, | ||
112 | |||
113 | //------------------------------------------------------------------------- | ||
114 | |||
115 | 'connectionVersion': function() { | ||
116 | return this._connectionVersion; | ||
117 | }, | ||
118 | |||
119 | 'setConnectionVersion': function(aValue) { | ||
120 | this._connectionVersion = aValue; | ||
121 | }, | ||
122 | |||
123 | //------------------------------------------------------------------------- | ||
124 | |||
125 | 'connection': function() { | ||
126 | if ((this._connection == null) && (this.connectionVersion() != null) ){ | ||
127 | this._connection = new Clipperz.PM.Crypto.communicationProtocol.versions[this.connectionVersion()]({user:this}); | ||
128 | } | ||
129 | |||
130 | return this._connection; | ||
131 | }, | ||
132 | |||
133 | 'resetConnection': function(aValue) { | ||
134 | this._connection = null; | ||
135 | }, | ||
136 | |||
137 | //========================================================================= | ||
138 | |||
139 | 'register': function(anInvitationCode) { | ||
140 | vardeferredResult; | ||
141 | var prng; | ||
142 | |||
143 | //MochiKit.Logging.logError(">>> User.register: " + this); | ||
144 | prng = Clipperz.Crypto.PRNG.defaultRandomGenerator(); | ||
145 | |||
146 | deferredResult = new MochiKit.Async.Deferred() | ||
147 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.register - 1: " + res); return res;}); | ||
148 | deferredResult.addCallback(MochiKit.Base.method(prng, 'deferredEntropyCollection')); | ||
149 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.register - 2: " + res); return res;}); | ||
150 | deferredResult.addCallback(MochiKit.Base.method(this.header(), 'updateAllSections'), anInvitationCode); | ||
151 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.register - 2.1: " + res); return res;}); | ||
152 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'register'), anInvitationCode); | ||
153 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.register - 3: " + res); return res;}); | ||
154 | deferredResult.callback(); | ||
155 | //MochiKit.Logging.logError("<<< User.register"); | ||
156 | |||
157 | return deferredResult; | ||
158 | }, | ||
159 | |||
160 | //========================================================================= | ||
161 | |||
162 | 'connect': function(aValue) { | ||
163 | vardeferredResult; | ||
164 | var prng; | ||
165 | |||
166 | prng = Clipperz.Crypto.PRNG.defaultRandomGenerator(); | ||
167 | |||
168 | //MochiKit.Logging.logDebug(">>> User.connect"); | ||
169 | deferredResult = new MochiKit.Async.Deferred(); | ||
170 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.1 - User.connect - 1: "/* + res*/); return res;}); | ||
171 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
172 | deferredResult.addCallback(MochiKit.Base.method(prng, 'deferredEntropyCollection')); | ||
173 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.2 - User.connect - 2: "/* + res*/); return res;}); | ||
174 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
175 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'login')); | ||
176 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.3 - User.connect - 3: "/* + res*/); return res;}); | ||
177 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
178 | |||
179 | // TODO:add an addErrback call here to manage a wrong login. Any error after this point is due to some other causes. | ||
180 | // possibly the same exact 'handleConnectionFallback use at the end of this same method. | ||
181 | |||
182 | if (this.connectionVersion() != 'current') { | ||
183 | varcurrentConnection; | ||
184 | |||
185 | currentVersionConnection = new Clipperz.PM.Crypto.communicationProtocol.versions['current']({user:this}); | ||
186 | |||
187 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.4 - User.connect - 4: "/* + res*/); return res;}); | ||
188 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
189 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_upgrading'); | ||
190 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.5 - User.connect - 5: "/* + res*/); return res;}); | ||
191 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
192 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'upgradeUserCredentials', currentVersionConnection.serverSideUserCredentials()); | ||
193 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.6 - User.connect - 6: "/* + res*/); return res;}); | ||
194 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
195 | } | ||
196 | |||
197 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.7 - User.connect - 7: "/* + res*/); return res;}); | ||
198 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
199 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'userConnected', null); | ||
200 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.8 - User.connect - 8: "/* + res*/); return res;}); | ||
201 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
202 | deferredResult.addErrback(MochiKit.Base.method(this, 'handleConnectionFallback')); | ||
203 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.9 - User.connect - 9: "/* + res*/); return res;}); | ||
204 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
205 | |||
206 | deferredResult.callback(aValue); | ||
207 | //MochiKit.Logging.logDebug("<<< User.connect"); | ||
208 | |||
209 | return deferredResult; | ||
210 | }, | ||
211 | |||
212 | //......................................................................... | ||
213 | |||
214 | 'handleConnectionFallback': function(aValue) { | ||
215 | var result; | ||
216 | //MochiKit.Logging.logDebug(">>> User.handleConnectionFallback"); | ||
217 | if (aValue instanceof MochiKit.Async.CancelledError) { | ||
218 | //MochiKit.Logging.logDebug("--- User.handleConnectionFallback - operation cancelled"); | ||
219 | result = aValue; | ||
220 | } else { | ||
221 | |||
222 | //MochiKit.Logging.logDebug("--- User.handleConnectionFallback - an ERROR has occurred - " + aValue); | ||
223 | this.resetConnection(); | ||
224 | this.setConnectionVersion(Clipperz.PM.Crypto.communicationProtocol.fallbackVersions[this.connectionVersion()]); | ||
225 | |||
226 | if (this.connectionVersion() != null) { | ||
227 | result = new MochiKit.Async.Deferred(); | ||
228 | |||
229 | result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_tryOlderSchema'); | ||
230 | result.addCallback(MochiKit.Base.method(this, 'connect')); | ||
231 | result.callback(); | ||
232 | } else { | ||
233 | result = MochiKit.Async.fail(Clipperz.PM.DataModel.User.exception.LoginFailed); | ||
234 | } | ||
235 | } | ||
236 | //MochiKit.Logging.logDebug("<<< User.handleConnectionFallback"); | ||
237 | return result; | ||
238 | }, | ||
239 | |||
240 | //========================================================================= | ||
241 | |||
242 | 'header': function() { | ||
243 | if (this._header == null) { | ||
244 | this._header = new Clipperz.PM.DataModel.Header({user:this}); | ||
245 | } | ||
246 | return this._header; | ||
247 | }, | ||
248 | |||
249 | //------------------------------------------------------------------------- | ||
250 | |||
251 | 'statistics': function() { | ||
252 | if (this._statistics == null) { | ||
253 | this._statistics = new Clipperz.PM.DataModel.Statistics({user:this}); | ||
254 | } | ||
255 | return this._statistics; | ||
256 | }, | ||
257 | |||
258 | //------------------------------------------------------------------------- | ||
259 | |||
260 | 'records': function() { | ||
261 | return this._records; | ||
262 | }, | ||
263 | |||
264 | //......................................................................... | ||
265 | |||
266 | 'addRecord': function(aValue, isBatchUpdate) { | ||
267 | this.records()[aValue.reference()] = aValue; | ||
268 | |||
269 | if (isBatchUpdate != true) { | ||
270 | Clipperz.NotificationCenter.notify(aValue, 'recordAdded', null, true); | ||
271 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | ||
272 | } | ||
273 | }, | ||
274 | |||
275 | //----------------------------------------------------------------------------- | ||
276 | |||
277 | 'addNewRecord': function() { | ||
278 | varrecord; | ||
279 | |||
280 | //MochiKit.Logging.logDebug(">>> User.addNewRecord"); | ||
281 | record = new Clipperz.PM.DataModel.Record({user:this}); | ||
282 | this.addRecord(record); | ||
283 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | ||
284 | //MochiKit.Logging.logDebug("<<< User.addNewRecord"); | ||
285 | |||
286 | return record; | ||
287 | }, | ||
288 | |||
289 | //------------------------------------------------------------------------- | ||
290 | |||
291 | 'saveRecords': function(someRecords, aMethodName) { | ||
292 | var deferredResult; | ||
293 | var methodName; | ||
294 | varresult; | ||
295 | var i,c; | ||
296 | |||
297 | //console.log("User.saveRecords - someRecords", someRecords); | ||
298 | methodName = aMethodName || 'addNewRecords'; | ||
299 | |||
300 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | ||
301 | //MochiKit.Logging.logDebug(">>> User.saveRecords"); | ||
302 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] User.saveRecords"); | ||
303 | /* | ||
304 | MochiKit.Logging.logDebug("--- User.saveRecords - 1"); | ||
305 | MochiKit.Iter.forEach(someRecords, function(aRecord) { | ||
306 | if (aRecord.headerNotes() != null) { | ||
307 | aRecord.setNotes(aRecord.headerNotes()); | ||
308 | } | ||
309 | aRecord.syncDirectLoginReferenceValues(); | ||
310 | aRecord.currentVersion().createNewVersion(); | ||
311 | aRecord.updateKey(); | ||
312 | }); | ||
313 | MochiKit.Logging.logDebug("--- User.saveRecords - 2"); | ||
314 | */ | ||
315 | |||
316 | result = {'records': []}; | ||
317 | |||
318 | deferredResult = new MochiKit.Async.Deferred(); | ||
319 | c = someRecords.length; | ||
320 | for (i=0; i<c; i++) { | ||
321 | deferredResult.addCallback(function(aRecord) { | ||
322 | if (aRecord.headerNotes() != null) { | ||
323 | aRecord.setNotes(aRecord.headerNotes()); | ||
324 | } | ||
325 | aRecord.syncDirectLoginReferenceValues(); | ||
326 | aRecord.currentVersion().createNewVersion(); | ||
327 | aRecord.updateKey(); | ||
328 | }, someRecords[i]); | ||
329 | deferredResult.addCallback(MochiKit.Async.wait, 0.1); | ||
330 | } | ||
331 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 1 " + res); return res;}); | ||
332 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_collectRecordInfo'); | ||
333 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 2 " + res); return res;}); | ||
334 | |||
335 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptUserData'); | ||
336 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 3 " + res); return res;}); | ||
337 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); | ||
338 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 4 " + res); return res;}); | ||
339 | deferredResult.addCallback(function(aResult, res) { | ||
340 | aResult['user'] = res; | ||
341 | return aResult; | ||
342 | }, result); | ||
343 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 5 " + res); return res;}); | ||
344 | |||
345 | c = someRecords.length; | ||
346 | for (i=0; i<c; i++) { | ||
347 | var recordData; | ||
348 | |||
349 | recordData = {}; | ||
350 | |||
351 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.1 " + res); return res;}); | ||
352 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordData'); | ||
353 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.2 " + res); return res;}); | ||
354 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'encryptedData')); | ||
355 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.3 " + res); return res;}); | ||
356 | deferredResult.addCallback(function(aResult, res) { | ||
357 | aResult['record'] = res; | ||
358 | return aResult; | ||
359 | }, recordData); | ||
360 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.4 " + res); return res;}); | ||
361 | |||
362 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {} /*'saveCard_encryptRecordVersions'*/); | ||
363 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.5 " + res); return res;}); | ||
364 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i].currentVersion(), 'encryptedData')); | ||
365 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.6 " + res); return res;}); | ||
366 | deferredResult.addCallback(function(aResult, res) { | ||
367 | aResult['currentRecordVersion'] = res; | ||
368 | return aResult; | ||
369 | }, recordData); | ||
370 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.7 " + res); return res;}); | ||
371 | |||
372 | deferredResult.addCallback(function(aResult, res) { | ||
373 | aResult['records'].push(res); | ||
374 | return aResult; | ||
375 | }, result); | ||
376 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.8 " + res); return res;}); | ||
377 | } | ||
378 | |||
379 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 7 " + res); return res;}); | ||
380 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData'); | ||
381 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 8 " + res); return res;}); | ||
382 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName); | ||
383 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9 " + res); return res;}); | ||
384 | |||
385 | for (i=0; i<c; i++) { | ||
386 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.1 " + res); return res;}); | ||
387 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'takeSnapshotOfCurrentData')); | ||
388 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.2 " + res); return res;}); | ||
389 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'setIsBrandNew'), false); | ||
390 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.3 " + res); return res;}); | ||
391 | } | ||
392 | |||
393 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 10 " + res); return res;}); | ||
394 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'recordUpdated'); | ||
395 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 11 " + res); return res;}); | ||
396 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'directLoginUpdated'); | ||
397 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 12 " + res); return res;}); | ||
398 | deferredResult.callback(); | ||
399 | |||
400 | return deferredResult; | ||
401 | }, | ||
402 | |||
403 | //------------------------------------------------------------------------- | ||
404 | |||
405 | 'removeRecord': function(aRecord) { | ||
406 | //MochiKit.Logging.logDebug(">>> User.removeRecord"); | ||
407 | delete this.records()[aRecord.reference()]; | ||
408 | //MochiKit.Logging.logDebug("--- User.removeRecord - 1"); | ||
409 | Clipperz.NotificationCenter.notify(aRecord, 'recordRemoved', null, false); | ||
410 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | ||
411 | //MochiKit.Logging.logDebug("<<< User.removeRecord"); | ||
412 | }, | ||
413 | |||
414 | //------------------------------------------------------------------------- | ||
415 | |||
416 | 'deleteRecordsAction': function(someRecords) { | ||
417 | vardeferredResult; | ||
418 | var parameters; | ||
419 | |||
420 | //MochiKit.Logging.logDebug(">>> User.deleteRecordsAction - someRecords.length: " + someRecords.length); | ||
421 | parameters = {}; | ||
422 | deferredResult = new MochiKit.Async.Deferred(); | ||
423 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 1 " + res); return res;}); | ||
424 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_collectData'); | ||
425 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 2 " + res); return res;}); | ||
426 | deferredResult.addCallback(function(someParameters, someRecords) { | ||
427 | var recordReferences; | ||
428 | |||
429 | recordReferences = MochiKit.Base.map(function(aRecord) { | ||
430 | var result; | ||
431 | |||
432 | result = aRecord.reference(); | ||
433 | aRecord.remove(); | ||
434 | |||
435 | return result; | ||
436 | }, someRecords); | ||
437 | someParameters.recordReferences = recordReferences; | ||
438 | |||
439 | return someParameters; | ||
440 | }, parameters); | ||
441 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 3 " + res); return res;}); | ||
442 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_encryptData'); | ||
443 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 4 " + res); return res;}); | ||
444 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); | ||
445 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 5 " + res); return res;}); | ||
446 | deferredResult.addCallback(function(someParameters, anUserEncryptedData) { | ||
447 | someParameters.user = anUserEncryptedData; | ||
448 | return someParameters; | ||
449 | }, parameters); | ||
450 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 6 " + res); return res;}); | ||
451 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_sendingData'); | ||
452 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecords parameters: " + Clipperz.Base.serializeJSON(res)); return res;}); | ||
453 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 7 " + res); return res;}); | ||
454 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords'); | ||
455 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 8 " + res); return res;}); | ||
456 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_updatingInterface'); | ||
457 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 9 " + res); return res;}); | ||
458 | deferredResult.callback(someRecords); | ||
459 | //MochiKit.Logging.logDebug("<<< User.deleteRecordsAction"); | ||
460 | |||
461 | return deferredResult; | ||
462 | }, | ||
463 | |||
464 | //------------------------------------------------------------------------- | ||
465 | |||
466 | 'resetAllLocalData': function() { | ||
467 | this.resetConnection(); | ||
468 | |||
469 | this.setUsername(""); | ||
470 | this.setPassphrase(""); | ||
471 | |||
472 | this._header = null; | ||
473 | this._statistics = null; | ||
474 | this._preferences = null; | ||
475 | this._records = {}; | ||
476 | this._directLoginReferences = {}; | ||
477 | }, | ||
478 | |||
479 | //------------------------------------------------------------------------- | ||
480 | |||
481 | 'deleteAccountAction': function() { | ||
482 | var deferredResult; | ||
483 | |||
484 | //MochiKit.Logging.logDebug(">>> user.deleteAccountAction - " + this); | ||
485 | deferredResult = new MochiKit.Async.Deferred(); | ||
486 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteUser'); | ||
487 | deferredResult.addCallback(MochiKit.Base.method(this, 'resetAllLocalData')); | ||
488 | deferredResult.callback(); | ||
489 | //MochiKit.Logging.logDebug("<<< user.deleteAccountAction - " + this); | ||
490 | |||
491 | return deferredResult; | ||
492 | }, | ||
493 | |||
494 | //------------------------------------------------------------------------- | ||
495 | |||
496 | 'encryptedData': function() { | ||
497 | var deferredResult; | ||
498 | varresult; | ||
499 | |||
500 | result = {}; | ||
501 | |||
502 | deferredResult = new MochiKit.Async.Deferred(); | ||
503 | |||
504 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.encryptedData - 0: " + res); return res;}); | ||
505 | deferredResult.addCallback(MochiKit.Base.method(this.header(), 'encryptedData')); | ||
506 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.encryptedData - 1: " + res); return res;}); | ||
507 | deferredResult.addCallback(function(aResult, aValue) { | ||
508 | aResult['header'] = aValue; | ||
509 | }, result); | ||
510 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.encryptedData - 2: " + res); return res;}); | ||
511 | |||
512 | deferredResult.addCallback(MochiKit.Base.method(this.statistics(), 'encryptedData')); | ||
513 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.encryptedData - 3: " + res); return res;}); | ||
514 | deferredResult.addCallback(function(aResult, aValue) { | ||
515 | aResult['statistics'] = aValue; | ||
516 | }, result); | ||
517 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.encryptedData - 4: " + res); return res;}); | ||
518 | |||
519 | deferredResult.addCallback(MochiKit.Base.bind(function(aResult, aValue) { | ||
520 | aResult['version'] = Clipperz.PM.Crypto.encryptingFunctions.currentVersion; | ||
521 | aResult['lock'] = this.lock(); | ||
522 | |||
523 | return aResult; | ||
524 | }, this), result); | ||
525 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.encryptedData - 5: " + res); return res;}); | ||
526 | deferredResult.callback(); | ||
527 | |||
528 | return deferredResult; | ||
529 | }, | ||
530 | |||
531 | //------------------------------------------------------------------------- | ||
532 | |||
533 | 'preferences': function() { | ||
534 | if (this._preferences == null) { | ||
535 | this._preferences = new Clipperz.PM.DataModel.UserPreferences({user:this}); | ||
536 | } | ||
537 | |||
538 | return this._preferences; | ||
539 | }, | ||
540 | /* | ||
541 | 'setPreferences': function(aValue) { | ||
542 | this._preferences = aValue; | ||
543 | |||
544 | if (this._preferences.preferredLanguage() != null) { | ||
545 | Clipperz.PM.Strings.Languages.setSelectedLanguage(this._preferences.preferredLanguage()); | ||
546 | } else { | ||
547 | //MochiKit.Logging.logDebug("### keepping the browser selected language: " + Clipperz.PM.Strings.selectedLanguage); | ||
548 | } | ||
549 | }, | ||
550 | */ | ||
551 | //------------------------------------------------------------------------- | ||
552 | |||
553 | 'oneTimePasswordManager': function() { | ||
554 | if (this._oneTimePasswordManager == null) { | ||
555 | this._oneTimePasswordManager = new Clipperz.PM.DataModel.OneTimePasswordManager(this, null); | ||
556 | } | ||
557 | |||
558 | return this._oneTimePasswordManager; | ||
559 | }, | ||
560 | |||
561 | //------------------------------------------------------------------------- | ||
562 | |||
563 | 'directLoginReferences': function() { | ||
564 | return this._directLoginReferences; | ||
565 | }, | ||
566 | |||
567 | 'addDirectLoginReference': function(aDirectLoginReference, isBatchUpdate) { | ||
568 | //MochiKit.Logging.logDebug(">>> User.addDirectLoginReference"); | ||
569 | this.directLoginReferences()[aDirectLoginReference.reference()] = aDirectLoginReference; | ||
570 | |||
571 | if (isBatchUpdate != true) { | ||
572 | Clipperz.NotificationCenter.notify(aDirectLoginReference, 'directLoginAdded'); | ||
573 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'directLogins', true); | ||
574 | } | ||
575 | }, | ||
576 | |||
577 | 'removeDirectLoginReference': function(aDirectLoginReference) { | ||
578 | delete this.directLoginReferences()[aDirectLoginReference.reference()]; | ||
579 | Clipperz.NotificationCenter.notify(aDirectLoginReference, 'directLoginRemoved'); | ||
580 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'directLogins', true); | ||
581 | }, | ||
582 | |||
583 | //......................................................................... | ||
584 | |||
585 | 'addDirectLogin': function(aDirectLogin) { | ||
586 | varnewDirectLoginReference; | ||
587 | |||
588 | newDirectLoginReference = new Clipperz.PM.DataModel.DirectLoginReference({user:this, directLogin:aDirectLogin}) | ||
589 | this.addDirectLoginReference(newDirectLoginReference); | ||
590 | }, | ||
591 | |||
592 | 'synchronizeDirectLogin': function(aDirectLogin) { | ||
593 | var directLoginReference; | ||
594 | |||
595 | directLoginReference = this.directLoginReferences()[aDirectLogin.reference()]; | ||
596 | if (typeof(directLoginReference) != 'undefined') { | ||
597 | directLoginReference.synchronizeValues(aDirectLogin); | ||
598 | } else { | ||
599 | this.addDirectLogin(aDirectLogin); | ||
600 | } | ||
601 | }, | ||
602 | |||
603 | 'removeDirectLogin': function(aDirectLogin) { | ||
604 | this.removeDirectLoginReference(aDirectLogin); | ||
605 | }, | ||
606 | |||
607 | //------------------------------------------------------------------------- | ||
608 | |||
609 | 'changeCredentials': function(aUsername, aPassphrase) { | ||
610 | vardeferredResult; | ||
611 | var result; | ||
612 | |||
613 | result = {}; | ||
614 | |||
615 | deferredResult = new MochiKit.Async.Deferred(); | ||
616 | |||
617 | deferredResult.addCallback(MochiKit.Base.method(this.header(), 'loadAllSections')); | ||
618 | deferredResult.addCallback(MochiKit.Base.method(this.header(), 'updateAllSections')); | ||
619 | |||
620 | deferredResult.addCallback(MochiKit.Base.bind(function(aUsername, aPssphrase) { | ||
621 | this.setUsername(aUsername); | ||
622 | this.setPassphrase(aPassphrase); | ||
623 | }, this), aUsername, aPassphrase) | ||
624 | |||
625 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 1: " + res); return res;}); | ||
626 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'changeCredentials_encryptingData'); | ||
627 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 2: " + res); return res;}); | ||
628 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); | ||
629 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 3: " + res); return res;}); | ||
630 | deferredResult.addCallback(function(aResult, anEncryptedData) { | ||
631 | aResult['user'] = anEncryptedData; | ||
632 | |||
633 | return aResult; | ||
634 | }, result); | ||
635 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 4: " + res); return res;}); | ||
636 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'changeCredentials_creatingNewCredentials'); | ||
637 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 5: " + res); return res;}); | ||
638 | deferredResult.addCallback(function(aResult, anUser) { | ||
639 | varnewConnection; | ||
640 | |||
641 | newConnection = new Clipperz.PM.Crypto.communicationProtocol.versions[Clipperz.PM.Crypto.communicationProtocol.currentVersion]({user:anUser}) | ||
642 | aResult['credentials'] = newConnection.serverSideUserCredentials(); | ||
643 | |||
644 | return aResult; | ||
645 | }, result, this); | ||
646 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 6: " + res); return res;}); | ||
647 | deferredResult.addCallback(MochiKit.Base.method(this.oneTimePasswordManager(), 'encryptedData')); | ||
648 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 7: " + res); return res;}); | ||
649 | deferredResult.addCallback(function(aResult, anEncryptedData) { | ||
650 | aResult['oneTimePasswords'] = anEncryptedData; | ||
651 | |||
652 | return aResult; | ||
653 | }, result); | ||
654 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 8: " + res); return res;}); | ||
655 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'changeCredentials_sendingCredentials'); | ||
656 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 9: " + res); return res;}); | ||
657 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'upgradeUserCredentials'); | ||
658 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 10: " + res); return res;}); | ||
659 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'changeCredentials_done'); | ||
660 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.changeCredentials - 11: " + res); return res;}); | ||
661 | deferredResult.callback(); | ||
662 | |||
663 | return deferredResult; | ||
664 | }, | ||
665 | |||
666 | //------------------------------------------------------------------------- | ||
667 | |||
668 | 'doLogout': function() { | ||
669 | var deferredResult; | ||
670 | |||
671 | deferredResult = new MochiKit.Async.Deferred(); | ||
672 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.doLogout - 1: " + res); return res;}); | ||
673 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'logout')); | ||
674 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.doLogout - 2: " + res); return res;}); | ||
675 | deferredResult.addCallback(MochiKit.Base.method(this, 'resetAllLocalData')); | ||
676 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.doLogout - 3: " + res); return res;}); | ||
677 | |||
678 | deferredResult.callback(); | ||
679 | |||
680 | return deferredResult; | ||
681 | }, | ||
682 | |||
683 | //------------------------------------------------------------------------- | ||
684 | |||
685 | 'lock': function() { | ||
686 | this.setPassphrase("") | ||
687 | this.connection().logout(); | ||
688 | this.connection().resetSrpConnection(); | ||
689 | }, | ||
690 | |||
691 | 'unlockWithPassphrase': function(aValue) { | ||
692 | vardeferredResult; | ||
693 | // varconnection; | ||
694 | |||
695 | // connection = this.connection(); | ||
696 | |||
697 | deferredResult = new MochiKit.Async.Deferred(); | ||
698 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.unlockWithPassphrase 1: " + res); return res;}); | ||
699 | deferredResult.addCallback(MochiKit.Base.method(this, 'setPassphrase')); | ||
700 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.unlockWithPassphrase 2: " + res); return res;}); | ||
701 | // deferredResult.addCallback(MochiKit.Base.method(connection, 'message'), 'echo', {'echo':"echo"}); | ||
702 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'reestablishConnection')); | ||
703 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.unlockWithPassphrase 3: " + res); return res;}); | ||
704 | // deferredResult.addErrback(MochiKit.Base.method(this, 'setPassphrase', "")); | ||
705 | deferredResult.addErrback(MochiKit.Base.bind(function(anError) { | ||
706 | this.setPassphrase(""); | ||
707 | this.connection().resetSrpConnection(); | ||
708 | |||
709 | return anError; | ||
710 | }, this)); | ||
711 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.unlockWithPassphrase 4: " + res); return res;}); | ||
712 | deferredResult.callback(aValue); | ||
713 | |||
714 | return deferredResult; | ||
715 | }, | ||
716 | |||
717 | //------------------------------------------------------------------------- | ||
718 | //------------------------------------------------------------------------- | ||
719 | //------------------------------------------------------------------------- | ||
720 | //------------------------------------------------------------------------- | ||
721 | //------------------------------------------------------------------------- | ||
722 | //------------------------------------------------------------------------- | ||
723 | //------------------------------------------------------------------------- | ||
724 | //------------------------------------------------------------------------- | ||
725 | //------------------------------------------------------------------------- | ||
726 | //------------------------------------------------------------------------- | ||
727 | //------------------------------------------------------------------------- | ||
728 | //------------------------------------------------------------------------- | ||
729 | |||
730 | 'serverData': function() { | ||
731 | return this._serverData; | ||
732 | }, | ||
733 | |||
734 | 'setServerData': function(aValue) { | ||
735 | //MochiKit.Logging.logDebug(">>> User.setServerData"); | ||
736 | this._serverData = aValue; | ||
737 | |||
738 | if (typeof(aValue.maxNumberOfRecords) != 'undefined') { | ||
739 | this.setMaxNumberOfRecords(aValue.maxNumberOfRecords); | ||
740 | } | ||
741 | //MochiKit.Logging.logDebug("<<< User.setServerData"); | ||
742 | }, | ||
743 | |||
744 | //------------------------------------------------------------------------- | ||
745 | |||
746 | 'isLoadingUserDetails': function() { | ||
747 | return this._isLoadingUserDetails; | ||
748 | }, | ||
749 | |||
750 | 'setIsLoadingUserDetails': function(aValue) { | ||
751 | this._isLoadingUserDetails = aValue; | ||
752 | }, | ||
753 | |||
754 | //------------------------------------------------------------------------- | ||
755 | |||
756 | 'loadingUserDetailsPendingQueue': function() { | ||
757 | return this._loadingUserDetailsPendingQueue; | ||
758 | }, | ||
759 | |||
760 | 'flushLoadingUserDetailsPendingQueue': function() { | ||
761 | var queue; | ||
762 | |||
763 | //MochiKit.Logging.logDebug(">>> User.flushLoadingUserDetailsPendingQueue"); | ||
764 | queue = this.loadingUserDetailsPendingQueue(); | ||
765 | |||
766 | while(queue.length > 0) { | ||
767 | //MochiKit.Logging.logDebug("--- User.flushLoadingUserDetailsPendingQueue - pop"); | ||
768 | queue.pop().callback(); | ||
769 | } | ||
770 | //MochiKit.Logging.logDebug("<<< User.flushLoadingUserDetailsPendingQueue"); | ||
771 | }, | ||
772 | |||
773 | //------------------------------------------------------------------------- | ||
774 | |||
775 | 'getUserDetails': function() { | ||
776 | var deferredResult; | ||
777 | |||
778 | //MochiKit.Logging.logDebug(">>> User.getUserDetails"); | ||
779 | deferredResult = new MochiKit.Async.Deferred(); | ||
780 | if ((this.serverData() == null) && (this.isLoadingUserDetails() == false)) { | ||
781 | deferredResult.addCallback(MochiKit.Base.method(this, 'setIsLoadingUserDetails', true)); | ||
782 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'getUserDetails'); | ||
783 | deferredResult.addCallback(MochiKit.Base.method(this, 'setServerData')); | ||
784 | deferredResult.addCallback(MochiKit.Base.method(this, 'flushLoadingUserDetailsPendingQueue')); | ||
785 | deferredResult.addCallback(MochiKit.Base.method(this, 'setIsLoadingUserDetails', false)); | ||
786 | } | ||
787 | |||
788 | deferredResult.addCallback(MochiKit.Base.method(this, 'serverData')); | ||
789 | |||
790 | if (this.isLoadingUserDetails() == false) { | ||
791 | deferredResult.callback(); | ||
792 | } else { | ||
793 | this.loadingUserDetailsPendingQueue().push(deferredResult); | ||
794 | } | ||
795 | //MochiKit.Logging.logDebug("<<< User.getUserDetails"); | ||
796 | |||
797 | return deferredResult; | ||
798 | }, | ||
799 | |||
800 | //------------------------------------------------------------------------- | ||
801 | |||
802 | 'loadRecords': function() { | ||
803 | return this.header().loadRecords(); | ||
804 | }, | ||
805 | |||
806 | 'loadDirectLogins': function() { | ||
807 | return this.header().loadDirectLogins(); | ||
808 | }, | ||
809 | |||
810 | 'loadPreferences': function() { | ||
811 | return this.header().loadPreferences(); | ||
812 | }, | ||
813 | |||
814 | 'loadOneTimePasswords': function() { | ||
815 | return this.header().loadOneTimePasswords(); | ||
816 | }, | ||
817 | |||
818 | //------------------------------------------------------------------------- | ||
819 | |||
820 | 'loadLoginHistory': function() { | ||
821 | var deferredResult; | ||
822 | |||
823 | deferredResult = new MochiKit.Async.Deferred(); | ||
824 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'getLoginHistory'); | ||
825 | deferredResult.addCallback(function(aResult) { | ||
826 | return aResult['result']; | ||
827 | }); | ||
828 | deferredResult.addCallback(MochiKit.Base.method(this, 'setLoginHistory')); | ||
829 | deferredResult.addCallback(MochiKit.Base.method(this, 'loginHistory')); | ||
830 | deferredResult.callback(); | ||
831 | |||
832 | return deferredResult; | ||
833 | }, | ||
834 | |||
835 | //------------------------------------------------------------------------- | ||
836 | |||
837 | 'shouldDownloadOfflineCopy': function() { | ||
838 | return this._shouldDownloadOfflineCopy; | ||
839 | }, | ||
840 | |||
841 | 'setShouldDownloadOfflineCopy': function(aValue) { | ||
842 | this._shouldDownloadOfflineCopy = aValue; | ||
843 | }, | ||
844 | |||
845 | //------------------------------------------------------------------------- | ||
846 | |||
847 | 'loginInfo': function() { | ||
848 | return this._loginInfo; | ||
849 | }, | ||
850 | |||
851 | 'setLoginInfo': function(aValue) { | ||
852 | this._loginInfo = aValue; | ||
853 | //MochiKit.Logging.logDebug("### LoginInfo: " + Clipperz.Base.serializeJSON(aValue)); | ||
854 | }, | ||
855 | |||
856 | //------------------------------------------------------------------------- | ||
857 | |||
858 | 'loginHistory': function() { | ||
859 | return this._loginHistory; | ||
860 | }, | ||
861 | |||
862 | 'setLoginHistory': function(aValue) { | ||
863 | this._loginHistory = aValue; | ||
864 | }, | ||
865 | /* | ||
866 | 'loginInfoWithOneTimePasswordReference': function(aOneTimePasswordReference) { | ||
867 | var result; | ||
868 | var i,c; | ||
869 | |||
870 | result = null; | ||
871 | c = this.loginHistory().length; | ||
872 | for (i=0; (i<c) && (result == null); i++) { | ||
873 | var currentLoginInfo; | ||
874 | |||
875 | currentLoginInfo = this.loginHistory()[i]; | ||
876 | if (currentLoginInfo['oneTimePasswordReference'] == aOneTimePasswordReference) { | ||
877 | result = currentLoginInfo; | ||
878 | } | ||
879 | } | ||
880 | |||
881 | return result; | ||
882 | }, | ||
883 | */ | ||
884 | //------------------------------------------------------------------------- | ||
885 | |||
886 | 'lock': function() { | ||
887 | return this._lock; | ||
888 | }, | ||
889 | |||
890 | 'setLock': function(aValue) { | ||
891 | //MochiKit.Logging.logDebug("=== User.setLock: " + aValue); | ||
892 | this._lock = aValue; | ||
893 | }, | ||
894 | |||
895 | //------------------------------------------------------------------------- | ||
896 | __syntaxFix__: "syntax fix" | ||
897 | |||
898 | }); | ||
899 | |||
900 | |||
901 | Clipperz.PM.DataModel.User.exception = { | ||
902 | LoginFailed: new MochiKit.Base.NamedError("Clipperz.PM.DataModel.User.exception.LoginFailed") | ||
903 | }; | ||
904 | |||