author | Clipperz <info@clipperz.com> | 2013-01-08 15:21:04 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-08 15:21:04 (UTC) |
commit | 816fc35420a434b1d54ae5833d617608f7456048 (patch) (unidiff) | |
tree | 95b8caf354083593d7775e4dda6f4c556b44a2d9 /frontend/gamma/js/Clipperz/PM/DataModel | |
parent | 267603e3aa3cf0029411e67ae14018b52344c296 (diff) | |
download | clipperz-816fc35420a434b1d54ae5833d617608f7456048.zip clipperz-816fc35420a434b1d54ae5833d617608f7456048.tar.gz clipperz-816fc35420a434b1d54ae5833d617608f7456048.tar.bz2 |
Updated version of /gamma
Tons of changes, included a new draft of the mobile version (still VERY rough)
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/DataModel/User.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.js index 72d4006..646ce21 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.js | |||
@@ -23,106 +23,106 @@ refer to http://www.clipperz.com. | |||
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.User = function (args) { | 33 | Clipperz.PM.DataModel.User = function (args) { |
34 | args = args || {}; | 34 | args = args || {}; |
35 | 35 | ||
36 | Clipperz.PM.DataModel.User.superclass.constructor.apply(this, arguments); | 36 | Clipperz.PM.DataModel.User.superclass.constructor.apply(this, arguments); |
37 | 37 | ||
38 | this._username = args.username || null; | 38 | this._username = args.username || null; |
39 | this._getPassphraseFunction = args.getPassphraseFunction || null; | 39 | this._getPassphraseFunction = args.getPassphraseFunction || null; |
40 | 40 | ||
41 | this._data = null; | 41 | this._data = null; |
42 | 42 | ||
43 | this._connection = null; | 43 | this._connection = null; |
44 | this._connectionVersion = 'current'; | 44 | this._connectionVersion = 'current'; |
45 | 45 | ||
46 | this._serverData = null; | 46 | this._serverData = null; |
47 | this._serverLockValue = null; | 47 | //this._serverLockValue = null; |
48 | this._transientState = null; | 48 | this._transientState = null; |
49 | 49 | ||
50 | this._deferredLocks = { | 50 | this._deferredLocks = { |
51 | 'passphrase': new MochiKit.Async.DeferredLock(), | 51 | 'passphrase': new MochiKit.Async.DeferredLock(), |
52 | 'serverData': new MochiKit.Async.DeferredLock(), | 52 | 'serverData': new MochiKit.Async.DeferredLock(), |
53 | // 'recordsIndex': new MochiKit.Async.DeferredLock(), | 53 | // 'recordsIndex': new MochiKit.Async.DeferredLock(), |
54 | // 'directLoginsIndex':new MochiKit.Async.DeferredLock() | 54 | // 'directLoginsIndex':new MochiKit.Async.DeferredLock() |
55 | // 'preferences': new MochiKit.Async.DeferredLock() | 55 | // 'preferences': new MochiKit.Async.DeferredLock() |
56 | // 'oneTimePasswords': new MochiKit.Async.DeferredLock() | 56 | // 'oneTimePasswords': new MochiKit.Async.DeferredLock() |
57 | '__syntaxFix__': 'syntax fix' | 57 | '__syntaxFix__': 'syntax fix' |
58 | }; | 58 | }; |
59 | 59 | ||
60 | return this; | 60 | return this; |
61 | } | 61 | } |
62 | 62 | ||
63 | Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | 63 | Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { |
64 | 64 | ||
65 | 'toString': function () { | 65 | 'toString': function () { |
66 | return "Clipperz.PM.DataModel.User - " + this.username(); | 66 | return "Clipperz.PM.DataModel.User - " + this.username(); |
67 | }, | 67 | }, |
68 | 68 | ||
69 | //------------------------------------------------------------------------- | 69 | //------------------------------------------------------------------------- |
70 | 70 | ||
71 | 'username': function () { | 71 | 'username': function () { |
72 | return this._username; | 72 | return this._username; |
73 | }, | 73 | }, |
74 | 74 | ||
75 | 'setUsername': function (aValue) { | 75 | 'setUsername': function (aValue) { |
76 | this._username = aValue; | 76 | this._username = aValue; |
77 | }, | 77 | }, |
78 | 78 | ||
79 | //------------------------------------------------------------------------- | 79 | //------------------------------------------------------------------------- |
80 | 80 | ||
81 | 'displayName': function() { | 81 | 'displayName': function() { |
82 | return "" + this.username() + ""; | 82 | return "" + this.username() + ""; |
83 | }, | 83 | }, |
84 | 84 | ||
85 | //------------------------------------------------------------------------- | 85 | //------------------------------------------------------------------------- |
86 | 86 | ||
87 | 'data': function () { | 87 | 'data': function () { |
88 | if (this._data == null) { | 88 | if (this._data == null) { |
89 | this._data = new Clipperz.KeyValueObjectStore(/*{'name':'User.data [1]'}*/); | 89 | this._data = new Clipperz.KeyValueObjectStore(/*{'name':'User.data [1]'}*/); |
90 | }; | 90 | }; |
91 | 91 | ||
92 | return this._data; | 92 | return this._data; |
93 | }, | 93 | }, |
94 | 94 | ||
95 | //------------------------------------------------------------------------- | 95 | //------------------------------------------------------------------------- |
96 | 96 | /* | |
97 | 'serverLockValue': function () { | 97 | 'serverLockValue': function () { |
98 | return this._serverLockValue; | 98 | return this._serverLockValue; |
99 | }, | 99 | }, |
100 | 100 | ||
101 | 'setServerLockValue': function (aValue) { | 101 | 'setServerLockValue': function (aValue) { |
102 | this._serverLockValue = aValue; | 102 | this._serverLockValue = aValue; |
103 | }, | 103 | }, |
104 | 104 | */ | |
105 | //------------------------------------------------------------------------- | 105 | //------------------------------------------------------------------------- |
106 | 106 | ||
107 | 'transientState': function () { | 107 | 'transientState': function () { |
108 | if (this._transientState == null) { | 108 | if (this._transientState == null) { |
109 | this._transientState = {} | 109 | this._transientState = {} |
110 | } | 110 | } |
111 | 111 | ||
112 | return this._transientState; | 112 | return this._transientState; |
113 | }, | 113 | }, |
114 | 114 | ||
115 | 'resetTransientState': function (isCommitting) { | 115 | 'resetTransientState': function (isCommitting) { |
116 | this._transientState = null; | 116 | this._transientState = null; |
117 | }, | 117 | }, |
118 | 118 | ||
119 | //------------------------------------------------------------------------- | 119 | //------------------------------------------------------------------------- |
120 | 120 | ||
121 | 'deferredLockForSection': function(aSectionName) { | 121 | 'deferredLockForSection': function(aSectionName) { |
122 | return this._deferredLocks[aSectionName]; | 122 | return this._deferredLocks[aSectionName]; |
123 | }, | 123 | }, |
124 | 124 | ||
125 | //------------------------------------------------------------------------- | 125 | //------------------------------------------------------------------------- |
126 | 126 | ||
127 | 'getPassphrase': function() { | 127 | 'getPassphrase': function() { |
128 | var deferredResult; | 128 | var deferredResult; |
@@ -199,76 +199,76 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
199 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') | 199 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') |
200 | }), | 200 | }), |
201 | 'oneTimePasswords': new Clipperz.PM.DataModel.User.Header.OneTimePasswords({ | 201 | 'oneTimePasswords': new Clipperz.PM.DataModel.User.Header.OneTimePasswords({ |
202 | 'name':'preferences', | 202 | 'name':'preferences', |
203 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') | 203 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') |
204 | }) | 204 | }) |
205 | } | 205 | } |
206 | }; | 206 | }; |
207 | 207 | ||
208 | // this._serverLockValue = Clipperz.PM.Crypto.randomKey(); | 208 | // this._serverLockValue = Clipperz.PM.Crypto.randomKey(); |
209 | }, | 209 | }, |
210 | 210 | ||
211 | //......................................................................... | 211 | //......................................................................... |
212 | 212 | ||
213 | 'registerAsNewAccount': function () { | 213 | 'registerAsNewAccount': function () { |
214 | var deferredResult; | 214 | var deferredResult; |
215 | 215 | ||
216 | deferredResult = new Clipperz.Async.Deferred("User.registerAsNewAccount", {trace:false}); | 216 | deferredResult = new Clipperz.Async.Deferred("User.registerAsNewAccount", {trace:false}); |
217 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':3}); | 217 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':3}); |
218 | deferredResult.addMethod(this, 'initialSetupWithNoData') | 218 | deferredResult.addMethod(this, 'initialSetupWithNoData') |
219 | deferredResult.addMethod(this, 'getPassphrase'); | 219 | deferredResult.addMethod(this, 'getPassphrase'); |
220 | deferredResult.addMethod(this, 'prepareRemoteDataWithKey'); | 220 | deferredResult.addMethod(this, 'prepareRemoteDataWithKey'); |
221 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); | 221 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); |
222 | deferredResult.addMethod(this.connection(), 'register'); | 222 | deferredResult.addMethod(this.connection(), 'register'); |
223 | deferredResult.addCallback(MochiKit.Base.itemgetter('lock')); | 223 | // deferredResult.addCallback(MochiKit.Base.itemgetter('lock')); |
224 | deferredResult.addMethod(this, 'setServerLockValue'); | 224 | // deferredResult.addMethod(this, 'setServerLockValue'); |
225 | deferredResult.addCallbackPass(MochiKit.Signal.signal,Clipperz.Signal.NotificationCenter, 'userSuccessfullyRegistered'); | 225 | deferredResult.addCallbackPass(MochiKit.Signal.signal,Clipperz.Signal.NotificationCenter, 'userSuccessfullyRegistered'); |
226 | 226 | ||
227 | // deferredResult.addErrback (MochiKit.Base.method(this, 'handleRegistrationFailure')); | 227 | // deferredResult.addErrback (MochiKit.Base.method(this, 'handleRegistrationFailure')); |
228 | 228 | ||
229 | deferredResult.callback(); | 229 | deferredResult.callback(); |
230 | 230 | ||
231 | return deferredResult; | 231 | return deferredResult; |
232 | }, | 232 | }, |
233 | 233 | ||
234 | //------------------------------------------------------------------------- | 234 | //------------------------------------------------------------------------- |
235 | 235 | ||
236 | 'login': function () { | 236 | 'login': function () { |
237 | var deferredResult; | 237 | var deferredResult; |
238 | 238 | ||
239 | deferredResult = new Clipperz.Async.Deferred("User.login", {trace:false}); | 239 | deferredResult = new Clipperz.Async.Deferred("User.login", {trace:false}); |
240 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':3}); | 240 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':3}); |
241 | deferredResult.addMethod(this, 'getPassphrase'); | 241 | deferredResult.addMethod(this, 'getPassphrase'); |
242 | deferredResult.addCallback(Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue); | 242 | deferredResult.addCallback(Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue); |
243 | deferredResult.addCallback(Clipperz.Async.deferredIf("Is the passphrase an OTP", [ | 243 | deferredResult.addCallback(Clipperz.Async.deferredIf("Is the passphrase an OTP", [ |
244 | MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':1}), | 244 | MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':1}), |
245 | MochiKit.Base.method(this, 'getCredentials'), | 245 | MochiKit.Base.method(this, 'getCredentials'), |
246 | MochiKit.Base.method(this.connection(), 'redeemOneTimePassword'), | 246 | MochiKit.Base.method(this.connection(), 'redeemOneTimePassword'), |
247 | MochiKit.Base.method(this.data(), 'setValue', 'passphrase') | 247 | MochiKit.Base.method(this.data(), 'setValue', 'passphrase') |
248 | ], [])); | 248 | ], [])); |
249 | deferredResult.addErrback(MochiKit.Base.method(this, 'getPassphrase')); | 249 | deferredResult.addErrback(MochiKit.Base.method(this, 'getPassphrase')); |
250 | deferredResult.addMethod(this.connection(), 'login'); | 250 | deferredResult.addMethod(this.connection(), 'login', false); |
251 | deferredResult.addCallbackPass(MochiKit.Signal.signal,Clipperz.Signal.NotificationCenter, 'userSuccessfullyLoggedIn'); | 251 | deferredResult.addCallbackPass(MochiKit.Signal.signal,Clipperz.Signal.NotificationCenter, 'userSuccessfullyLoggedIn'); |
252 | deferredResult.addErrback (MochiKit.Base.method(this, 'handleConnectionFallback')); | 252 | deferredResult.addErrback (MochiKit.Base.method(this, 'handleConnectionFallback')); |
253 | 253 | ||
254 | deferredResult.callback(); | 254 | deferredResult.callback(); |
255 | 255 | ||
256 | return deferredResult; | 256 | return deferredResult; |
257 | }, | 257 | }, |
258 | 258 | ||
259 | //......................................................................... | 259 | //......................................................................... |
260 | 260 | ||
261 | 'handleConnectionFallback': function(aValue) { | 261 | 'handleConnectionFallback': function(aValue) { |
262 | var result; | 262 | var result; |
263 | 263 | ||
264 | if (aValue instanceof MochiKit.Async.CancelledError) { | 264 | if (aValue instanceof MochiKit.Async.CancelledError) { |
265 | result = aValue; | 265 | result = aValue; |
266 | } else { | 266 | } else { |
267 | this.setConnectionVersion(Clipperz.PM.Connection.communicationProtocol.fallbackVersions[this.connectionVersion()]); | 267 | this.setConnectionVersion(Clipperz.PM.Connection.communicationProtocol.fallbackVersions[this.connectionVersion()]); |
268 | 268 | ||
269 | if (this.connectionVersion() != null) { | 269 | if (this.connectionVersion() != null) { |
270 | result = new Clipperz.Async.Deferred("User.handleConnectionFallback - retry"); | 270 | result = new Clipperz.Async.Deferred("User.handleConnectionFallback - retry"); |
271 | 271 | ||
272 | result.addMethod(this, 'login'); | 272 | result.addMethod(this, 'login'); |
273 | result.callback(); | 273 | result.callback(); |
274 | } else { | 274 | } else { |
@@ -308,49 +308,49 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
308 | 308 | ||
309 | if (anHeader.charAt(0) == '{') { | 309 | if (anHeader.charAt(0) == '{') { |
310 | varheaderData; | 310 | varheaderData; |
311 | 311 | ||
312 | headerData = Clipperz.Base.evalJSON(anHeader); | 312 | headerData = Clipperz.Base.evalJSON(anHeader); |
313 | result = headerData['version']; | 313 | result = headerData['version']; |
314 | } else { | 314 | } else { |
315 | result = 'LEGACY'; | 315 | result = 'LEGACY'; |
316 | } | 316 | } |
317 | 317 | ||
318 | return result; | 318 | return result; |
319 | }, | 319 | }, |
320 | 320 | ||
321 | //------------------------------------------------------------------------- | 321 | //------------------------------------------------------------------------- |
322 | 322 | ||
323 | 'unpackServerData': function (someServerData) { | 323 | 'unpackServerData': function (someServerData) { |
324 | var unpackedData; | 324 | var unpackedData; |
325 | var headerVersion; | 325 | var headerVersion; |
326 | 326 | ||
327 | varrecordsIndex; | 327 | varrecordsIndex; |
328 | var preferences; | 328 | var preferences; |
329 | var oneTimePasswords; | 329 | var oneTimePasswords; |
330 | 330 | ||
331 | //console.log(">>> ***************** user.unpackServerData", someServerData); | 331 | //console.log(">>> ***************** user.unpackServerData", someServerData); |
332 | this.setServerLockValue(someServerData['lock']); | 332 | // this.setServerLockValue(someServerData['lock']); |
333 | 333 | ||
334 | headerVersion = this.headerFormatVersion(someServerData['header']); | 334 | headerVersion = this.headerFormatVersion(someServerData['header']); |
335 | 335 | ||
336 | switch (headerVersion) { | 336 | switch (headerVersion) { |
337 | case 'LEGACY': | 337 | case 'LEGACY': |
338 | varlegacyHeader; | 338 | varlegacyHeader; |
339 | 339 | ||
340 | legacyHeader = new Clipperz.PM.DataModel.User.Header.Legacy({ | 340 | legacyHeader = new Clipperz.PM.DataModel.User.Header.Legacy({ |
341 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), | 341 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), |
342 | 'remoteData': { | 342 | 'remoteData': { |
343 | 'data': someServerData['header'], | 343 | 'data': someServerData['header'], |
344 | 'version': someServerData['version'], | 344 | 'version': someServerData['version'], |
345 | 'recordsStats': someServerData['recordsStats'] | 345 | 'recordsStats': someServerData['recordsStats'] |
346 | }, | 346 | }, |
347 | // 'encryptedDataKeypath': 'data', | 347 | // 'encryptedDataKeypath': 'data', |
348 | // 'encryptedVersionKeypath': 'version', | 348 | // 'encryptedVersionKeypath': 'version', |
349 | 'retrieveRecordDetailFunction':MochiKit.Base.method(this, 'getRecordDetail') | 349 | 'retrieveRecordDetailFunction':MochiKit.Base.method(this, 'getRecordDetail') |
350 | }); | 350 | }); |
351 | 351 | ||
352 | recordsIndex = legacyHeader; | 352 | recordsIndex = legacyHeader; |
353 | preferences = legacyHeader; | 353 | preferences = legacyHeader; |
354 | oneTimePasswords= legacyHeader; | 354 | oneTimePasswords= legacyHeader; |
355 | break; | 355 | break; |
356 | case '0.1': | 356 | case '0.1': |
@@ -641,50 +641,50 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
641 | deferredResult.collectResults({ | 641 | deferredResult.collectResults({ |
642 | 'header': [ | 642 | 'header': [ |
643 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'hasPendingChanges'), | 643 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'hasPendingChanges'), |
644 | MochiKit.Base.values | 644 | MochiKit.Base.values |
645 | ], | 645 | ], |
646 | 'records': MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'hasPendingChanges') | 646 | 'records': MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'hasPendingChanges') |
647 | }); | 647 | }); |
648 | deferredResult.addCallback(Clipperz.Async.or); | 648 | deferredResult.addCallback(Clipperz.Async.or); |
649 | deferredResult.callback(); | 649 | deferredResult.callback(); |
650 | // recordsIndex = legacyHeader; | 650 | // recordsIndex = legacyHeader; |
651 | // preferences = legacyHeader; | 651 | // preferences = legacyHeader; |
652 | // oneTimePasswords= legacyHeader; | 652 | // oneTimePasswords= legacyHeader; |
653 | 653 | ||
654 | return deferredResult; | 654 | return deferredResult; |
655 | }, | 655 | }, |
656 | 656 | ||
657 | //========================================================================= | 657 | //========================================================================= |
658 | 658 | ||
659 | 'commitTransientState': function () { | 659 | 'commitTransientState': function () { |
660 | return Clipperz.Async.callbacks("User.commitTransientState", [ | 660 | return Clipperz.Async.callbacks("User.commitTransientState", [ |
661 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'commitTransientState'), | 661 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'commitTransientState'), |
662 | MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'commitTransientState'), | 662 | MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'commitTransientState'), |
663 | 663 | ||
664 | MochiKit.Base.method(this, 'transientState'), | 664 | MochiKit.Base.method(this, 'transientState'), |
665 | MochiKit.Base.itemgetter('lock'), | 665 | // MochiKit.Base.itemgetter('lock'), |
666 | MochiKit.Base.method(this, 'setServerLockValue'), | 666 | // MochiKit.Base.method(this, 'setServerLockValue'), |
667 | MochiKit.Base.method(this, 'resetTransientState', true) | 667 | MochiKit.Base.method(this, 'resetTransientState', true) |
668 | ], {trace:false}); | 668 | ], {trace:false}); |
669 | }, | 669 | }, |
670 | 670 | ||
671 | //------------------------------------------------------------------------- | 671 | //------------------------------------------------------------------------- |
672 | 672 | ||
673 | 'revertChanges': function () { | 673 | 'revertChanges': function () { |
674 | return Clipperz.Async.callbacks("User.revertChanges", [ | 674 | return Clipperz.Async.callbacks("User.revertChanges", [ |
675 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'revertChanges'), | 675 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'revertChanges'), |
676 | MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'revertChanges'), | 676 | MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'revertChanges'), |
677 | MochiKit.Base.method(this, 'resetTransientState', false) | 677 | MochiKit.Base.method(this, 'resetTransientState', false) |
678 | ], {trace:false}); | 678 | ], {trace:false}); |
679 | }, | 679 | }, |
680 | 680 | ||
681 | //========================================================================= | 681 | //========================================================================= |
682 | 682 | ||
683 | 'deleteAllCleanTextData': function () { | 683 | 'deleteAllCleanTextData': function () { |
684 | return Clipperz.Async.callbacks("User.deleteAllCleanTextData", [ | 684 | return Clipperz.Async.callbacks("User.deleteAllCleanTextData", [ |
685 | MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'deleteAllCleanTextData'), | 685 | MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'deleteAllCleanTextData'), |
686 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'deleteAllCleanTextData'), | 686 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'deleteAllCleanTextData'), |
687 | 687 | ||
688 | MochiKit.Base.method(this.data(), 'removeAllData'), | 688 | MochiKit.Base.method(this.data(), 'removeAllData'), |
689 | MochiKit.Base.method(this, 'resetTransientState', false) | 689 | MochiKit.Base.method(this, 'resetTransientState', false) |
690 | ], {trace:false}); | 690 | ], {trace:false}); |
@@ -719,49 +719,49 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
719 | 719 | ||
720 | 'prepareRemoteDataWithKey': function (aKey /*, aCurrentKey*/) { | 720 | 'prepareRemoteDataWithKey': function (aKey /*, aCurrentKey*/) { |
721 | var deferredResult; | 721 | var deferredResult; |
722 | varresult; | 722 | varresult; |
723 | 723 | ||
724 | result = {}; | 724 | result = {}; |
725 | deferredResult = new Clipperz.Async.Deferred("User.prepareRemoteDataWithKey", {trace:false}); | 725 | deferredResult = new Clipperz.Async.Deferred("User.prepareRemoteDataWithKey", {trace:false}); |
726 | deferredResult.addMethod(this, 'invokeMethodNamedOnHeader', 'prepareRemoteDataWithKey', aKey /*, aCurrentKey*/); | 726 | deferredResult.addMethod(this, 'invokeMethodNamedOnHeader', 'prepareRemoteDataWithKey', aKey /*, aCurrentKey*/); |
727 | deferredResult.addCallback(MochiKit.Base.bind(function (aResult, someHeaderPackedData) { | 727 | deferredResult.addCallback(MochiKit.Base.bind(function (aResult, someHeaderPackedData) { |
728 | var header; | 728 | var header; |
729 | 729 | ||
730 | header = {}; | 730 | header = {}; |
731 | header['records'] = someHeaderPackedData['recordIndex']['records']; | 731 | header['records'] = someHeaderPackedData['recordIndex']['records']; |
732 | header['directLogins'] = someHeaderPackedData['recordIndex']['directLogins']; | 732 | header['directLogins'] = someHeaderPackedData['recordIndex']['directLogins']; |
733 | header['preferences'] = {'data': someHeaderPackedData['preferences']['data']}; // this._serverData['header']['preferences']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['preferences']; //??????????? | 733 | header['preferences'] = {'data': someHeaderPackedData['preferences']['data']}; // this._serverData['header']['preferences']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['preferences']; //??????????? |
734 | header['oneTimePasswords'] = {'data': someHeaderPackedData['oneTimePasswords']['data']}; // this._serverData['header']['oneTimePasswords']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['oneTimePasswords']; //??????????? | 734 | header['oneTimePasswords'] = {'data': someHeaderPackedData['oneTimePasswords']['data']}; // this._serverData['header']['oneTimePasswords']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['oneTimePasswords']; //??????????? |
735 | header['version'] = '0.1'; | 735 | header['version'] = '0.1'; |
736 | 736 | ||
737 | aResult['header'] = Clipperz.Base.serializeJSON(header); | 737 | aResult['header'] = Clipperz.Base.serializeJSON(header); |
738 | aResult['statistics'] = this._serverData['statistics']; //"someHeaderPackedData['statistics']['data']"; | 738 | aResult['statistics'] = this._serverData['statistics']; //"someHeaderPackedData['statistics']['data']"; |
739 | 739 | ||
740 | return aResult; | 740 | return aResult; |
741 | }, this), result); | 741 | }, this), result); |
742 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'version', Clipperz.PM.Crypto.encryptingFunctions.currentVersion); | 742 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'version', Clipperz.PM.Crypto.encryptingFunctions.currentVersion); |
743 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'lock', this.serverLockValue()); | 743 | // deferredResult.addCallback(Clipperz.Async.setItem, result, 'lock', this.serverLockValue()); |
744 | deferredResult.callback(); | 744 | deferredResult.callback(); |
745 | 745 | ||
746 | return deferredResult; | 746 | return deferredResult; |
747 | }, | 747 | }, |
748 | 748 | ||
749 | //========================================================================= | 749 | //========================================================================= |
750 | 750 | ||
751 | 'saveChanges': function () { | 751 | 'saveChanges': function () { |
752 | vardeferredResult; | 752 | vardeferredResult; |
753 | var messageParameters; | 753 | var messageParameters; |
754 | 754 | ||
755 | messageParameters = {}; | 755 | messageParameters = {}; |
756 | 756 | ||
757 | deferredResult = new Clipperz.Async.Deferred("User.saveChangaes", {trace:false}); | 757 | deferredResult = new Clipperz.Async.Deferred("User.saveChangaes", {trace:false}); |
758 | 758 | ||
759 | deferredResult.addMethod(this, 'getHeaderIndex', 'recordsIndex'); | 759 | deferredResult.addMethod(this, 'getHeaderIndex', 'recordsIndex'); |
760 | deferredResult.addCallback(MochiKit.Base.methodcaller('prepareRemoteDataForChangedRecords')); | 760 | deferredResult.addCallback(MochiKit.Base.methodcaller('prepareRemoteDataForChangedRecords')); |
761 | deferredResult.addCallback(Clipperz.Async.setItem, messageParameters, 'records'); | 761 | deferredResult.addCallback(Clipperz.Async.setItem, messageParameters, 'records'); |
762 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); | 762 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); |
763 | 763 | ||
764 | deferredResult.addMethod(this, 'getPassphrase'); | 764 | deferredResult.addMethod(this, 'getPassphrase'); |
765 | deferredResult.addMethod(this, 'prepareRemoteDataWithKey'); | 765 | deferredResult.addMethod(this, 'prepareRemoteDataWithKey'); |
766 | deferredResult.addCallback(Clipperz.Async.setItem, messageParameters, 'user'); | 766 | deferredResult.addCallback(Clipperz.Async.setItem, messageParameters, 'user'); |
767 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); | 767 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); |