author | Clipperz <info@clipperz.com> | 2013-01-08 15:17:30 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-08 15:17:30 (UTC) |
commit | 267603e3aa3cf0029411e67ae14018b52344c296 (patch) (unidiff) | |
tree | 055e8f8d8543ed6bfa342dbf4641fea308c2ec5a | |
parent | b6a11a37ec3271bd44fc23b9da00c5b052b0d8b9 (diff) | |
download | clipperz-267603e3aa3cf0029411e67ae14018b52344c296.zip clipperz-267603e3aa3cf0029411e67ae14018b52344c296.tar.gz clipperz-267603e3aa3cf0029411e67ae14018b52344c296.tar.bz2 |
Fixed corrupted card problem
Changes that check for a weird condition that was causing cards to get corrupted.
A similar change has been applied also to /gamma (in a different commit, though)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Connection.js | 9 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/Record.js | 12 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/User.js | 17 |
3 files changed, 24 insertions, 14 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Connection.js b/frontend/beta/js/Clipperz/PM/Connection.js index 85aea21..e81c7a6 100644 --- a/frontend/beta/js/Clipperz/PM/Connection.js +++ b/frontend/beta/js/Clipperz/PM/Connection.js | |||
@@ -275,53 +275,57 @@ deferredResult.addErrback(MochiKit.Base.bind(function(res) {MochiKit.Logging.log | |||
275 | args.message = 'credentialCheck'; | 275 | args.message = 'credentialCheck'; |
276 | args.version = this.clipperz_pm_crypto_version(); | 276 | args.version = this.clipperz_pm_crypto_version(); |
277 | args.parameters = {}; | 277 | args.parameters = {}; |
278 | args.parameters['M1'] = this.srpConnection().M1(); | 278 | args.parameters['M1'] = this.srpConnection().M1(); |
279 | 279 | ||
280 | return args; | 280 | return args; |
281 | }, this)); | 281 | }, this)); |
282 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.3.6 - Connection.login - 6: "/* + res*/); return res;}); | 282 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.3.6 - Connection.login - 6: "/* + res*/); return res;}); |
283 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | 283 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); |
284 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Proxy.defaultProxy, 'handshake')); | 284 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Proxy.defaultProxy, 'handshake')); |
285 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.3.7 - Connection.login - 7: "/* + res*/); return res;}); | 285 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.3.7 - Connection.login - 7: "/* + res*/); return res;}); |
286 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | 286 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); |
287 | //# deferredResult.addCallback(MochiKit.Base.method(this, 'loginDone')); | 287 | //# deferredResult.addCallback(MochiKit.Base.method(this, 'loginDone')); |
288 | deferredResult.addCallback(MochiKit.Base.bind(function(someParameters) { | 288 | deferredResult.addCallback(MochiKit.Base.bind(function(someParameters) { |
289 | var result; | 289 | var result; |
290 | 290 | ||
291 | //MochiKit.Logging.logDebug(">>> Connection.loginDone: " + this + " (M2: " + this.srpConnection().M2() + ")"); | 291 | //MochiKit.Logging.logDebug(">>> Connection.loginDone: " + this + " (M2: " + this.srpConnection().M2() + ")"); |
292 | if (someParameters['M2'] == this.srpConnection().M2()) { | 292 | if (someParameters['M2'] == this.srpConnection().M2()) { |
293 | result = new MochiKit.Async.Deferred(); | 293 | result = new MochiKit.Async.Deferred(); |
294 | 294 | ||
295 | //MochiKit.Logging.logDebug("--- Connection.loginDone - someParameters: " + Clipperz.Base.serializeJSON(someParameters)); | 295 | //MochiKit.Logging.logDebug("--- Connection.loginDone - someParameters: " + Clipperz.Base.serializeJSON(someParameters)); |
296 | this.setConnectionId(someParameters['connectionId']); | 296 | this.setConnectionId(someParameters['connectionId']); |
297 | this.user().setLoginInfo(someParameters['loginInfo']); | 297 | this.user().setLoginInfo(someParameters['loginInfo']); |
298 | this.user().setShouldDownloadOfflineCopy(someParameters['offlineCopyNeeded']); | 298 | this.user().setShouldDownloadOfflineCopy(someParameters['offlineCopyNeeded']); |
299 | this.user().setLock(someParameters['lock']); | 299 | |
300 | if ((isReconnecting == true) && (this.user().lock() != someParameters['lock'])) { | ||
301 | throw Clipperz.PM.Connection.exception.StaleData; | ||
302 | } | ||
300 | 303 | ||
301 | if (this.oneTimePassword() != null) { | 304 | if (this.oneTimePassword() != null) { |
302 | result.addCallback(MochiKit.Base.method(this.user().oneTimePasswordManager(), 'archiveOneTimePassword', this.oneTimePassword())); | 305 | result.addCallback(MochiKit.Base.method(this.user().oneTimePasswordManager(), 'archiveOneTimePassword', this.oneTimePassword())); |
303 | } | 306 | } |
307 | |||
304 | result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_loggedIn'); | 308 | result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_loggedIn'); |
305 | result.addCallback(MochiKit.Async.succeed, someParameters); | 309 | result.addCallback(MochiKit.Async.succeed, someParameters); |
306 | 310 | ||
307 | result.callback(); | 311 | result.callback(); |
308 | //MochiKit.Logging.logDebug("--- Connection.loginDone - 1 - result: "/* + Clipperz.Base.serializeJSON(result)*/); | 312 | //MochiKit.Logging.logDebug("--- Connection.loginDone - 1 - result: "/* + Clipperz.Base.serializeJSON(result)*/); |
309 | } else { | 313 | } else { |
310 | //MochiKit.Logging.logDebug("--- Connection.loginDone - 2 - ERROR"); | 314 | //MochiKit.Logging.logDebug("--- Connection.loginDone - 2 - ERROR"); |
311 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | 315 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); |
312 | result = MochiKit.Async.fail(Clipperz.PM.Connection.exception.WrongChecksum); | 316 | result = MochiKit.Async.fail(Clipperz.PM.Connection.exception.WrongChecksum); |
313 | } | 317 | } |
314 | //MochiKit.Logging.logDebug("<<< Connection.loginDone - result: " + Clipperz.Base.serializeJSON(result)); | 318 | //MochiKit.Logging.logDebug("<<< Connection.loginDone - result: " + Clipperz.Base.serializeJSON(result)); |
315 | 319 | ||
316 | return result; | 320 | return result; |
317 | }, this)); | 321 | }, this)); |
318 | 322 | ||
319 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.3.8 - Connection.login - 8: "/* + res*/); return res;}); | 323 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.3.8 - Connection.login - 8: "/* + res*/); return res;}); |
320 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | 324 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); |
321 | deferredResult.callback(this); | 325 | deferredResult.callback(this); |
322 | //MochiKit.Logging.logDebug("<<< Connection.login"); | 326 | //MochiKit.Logging.logDebug("<<< Connection.login"); |
323 | 327 | ||
324 | return deferredResult; | 328 | return deferredResult; |
325 | }, | 329 | }, |
326 | 330 | ||
327 | //========================================================================= | 331 | //========================================================================= |
@@ -556,26 +560,27 @@ Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz. | |||
556 | }, | 560 | }, |
557 | 561 | ||
558 | //----------------------------------------------------------------------------- | 562 | //----------------------------------------------------------------------------- |
559 | 563 | ||
560 | 'P': function() { | 564 | 'P': function() { |
561 | if (this._P == null) { | 565 | if (this._P == null) { |
562 | this._P = this.hash()(new Clipperz.ByteArray(this.user().passphrase() + this.user().username())).toHexString().substring(2); | 566 | this._P = this.hash()(new Clipperz.ByteArray(this.user().passphrase() + this.user().username())).toHexString().substring(2); |
563 | } | 567 | } |
564 | 568 | ||
565 | return this._P; | 569 | return this._P; |
566 | }, | 570 | }, |
567 | 571 | ||
568 | //----------------------------------------------------------------------------- | 572 | //----------------------------------------------------------------------------- |
569 | 573 | ||
570 | 'hash': function() { | 574 | 'hash': function() { |
571 | return Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].hash; | 575 | return Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].hash; |
572 | }, | 576 | }, |
573 | 577 | ||
574 | //----------------------------------------------------------------------------- | 578 | //----------------------------------------------------------------------------- |
575 | __syntaxFix__: "syntax fix" | 579 | __syntaxFix__: "syntax fix" |
576 | 580 | ||
577 | }); | 581 | }); |
578 | 582 | ||
579 | Clipperz.PM.Connection.exception = { | 583 | Clipperz.PM.Connection.exception = { |
580 | WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue") | 584 | WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue"), |
585 | StaleData: new MochiKit.Base.NamedError("Stale data") | ||
581 | }; | 586 | }; |
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Record.js b/frontend/beta/js/Clipperz/PM/DataModel/Record.js index ffb45de..ecb6c37 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/Record.js | |||
@@ -618,53 +618,55 @@ console.log("Record.processData - currentVersionParameters", currentVersionParam | |||
618 | return deferredResult; | 618 | return deferredResult; |
619 | }, | 619 | }, |
620 | 620 | ||
621 | //------------------------------------------------------------------------- | 621 | //------------------------------------------------------------------------- |
622 | 622 | ||
623 | 'syncDirectLoginReferenceValues': function() { | 623 | 'syncDirectLoginReferenceValues': function() { |
624 | //MochiKit.Logging.logDebug(">>> Record.syncDirectLoginReferenceValues"); | 624 | //MochiKit.Logging.logDebug(">>> Record.syncDirectLoginReferenceValues"); |
625 | MochiKit.Iter.forEach(MochiKit.Base.values(this.directLogins()), function(aDirectLogin) { | 625 | MochiKit.Iter.forEach(MochiKit.Base.values(this.directLogins()), function(aDirectLogin) { |
626 | aDirectLogin.record().user().synchronizeDirectLogin(aDirectLogin); | 626 | aDirectLogin.record().user().synchronizeDirectLogin(aDirectLogin); |
627 | }); | 627 | }); |
628 | 628 | ||
629 | MochiKit.Iter.forEach(this.removedDirectLogins(), function(aDirectLogin) { | 629 | MochiKit.Iter.forEach(this.removedDirectLogins(), function(aDirectLogin) { |
630 | aDirectLogin.record().user().removeDirectLogin(aDirectLogin); | 630 | aDirectLogin.record().user().removeDirectLogin(aDirectLogin); |
631 | }); | 631 | }); |
632 | 632 | ||
633 | this.resetRemovedDirectLogins(); | 633 | this.resetRemovedDirectLogins(); |
634 | //MochiKit.Logging.logDebug("<<< Record.syncDirectLoginReferenceValues"); | 634 | //MochiKit.Logging.logDebug("<<< Record.syncDirectLoginReferenceValues"); |
635 | }, | 635 | }, |
636 | 636 | ||
637 | //------------------------------------------------------------------------- | 637 | //------------------------------------------------------------------------- |
638 | 638 | ||
639 | 'saveChanges': function() { | 639 | 'saveChanges': function() { |
640 | var result; | 640 | var result; |
641 | 641 | ||
642 | if (this.isBrandNew() == false) { | 642 | // if (this.isBrandNew() == false) { |
643 | result = this.user().saveRecords([this], 'updateData'); | 643 | // result = this.user().saveRecords([this], 'updateData'); |
644 | } else { | 644 | // } else { |
645 | result = this.user().saveRecords([this], 'addNewRecords'); | 645 | // result = this.user().saveRecords([this], 'addNewRecords'); |
646 | } | 646 | // } |
647 | |||
648 | result = this.user().saveRecords([this]); | ||
647 | 649 | ||
648 | return result; | 650 | return result; |
649 | }, | 651 | }, |
650 | 652 | ||
651 | /* | 653 | /* |
652 | 'saveChanges': function() { | 654 | 'saveChanges': function() { |
653 | var deferredResult; | 655 | var deferredResult; |
654 | varresult; | 656 | varresult; |
655 | 657 | ||
656 | Clipperz.NotificationCenter.notify(this.user(), 'updatedSection', 'records', true); | 658 | Clipperz.NotificationCenter.notify(this.user(), 'updatedSection', 'records', true); |
657 | //MochiKit.Logging.logDebug(">>> Record.saveChanges"); | 659 | //MochiKit.Logging.logDebug(">>> Record.saveChanges"); |
658 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.saveChanges"); | 660 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.saveChanges"); |
659 | if (this.headerNotes() != null) { | 661 | if (this.headerNotes() != null) { |
660 | this.setNotes(this.headerNotes()); | 662 | this.setNotes(this.headerNotes()); |
661 | } | 663 | } |
662 | this.syncDirectLoginReferenceValues(); | 664 | this.syncDirectLoginReferenceValues(); |
663 | this.currentVersion().createNewVersion(); | 665 | this.currentVersion().createNewVersion(); |
664 | 666 | ||
665 | result = {'records': [{}]}; | 667 | result = {'records': [{}]}; |
666 | 668 | ||
667 | deferredResult = new MochiKit.Async.Deferred(); | 669 | deferredResult = new MochiKit.Async.Deferred(); |
668 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_collectRecordInfo'); | 670 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_collectRecordInfo'); |
669 | deferredResult.addCallback(MochiKit.Base.method(this, 'updateKey')); | 671 | deferredResult.addCallback(MochiKit.Base.method(this, 'updateKey')); |
670 | 672 | ||
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/User.js b/frontend/beta/js/Clipperz/PM/DataModel/User.js index dbbe9a0..b065557 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/User.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/User.js | |||
@@ -264,56 +264,56 @@ MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anExc | |||
264 | this.records()[aValue.reference()] = aValue; | 264 | this.records()[aValue.reference()] = aValue; |
265 | 265 | ||
266 | if (isBatchUpdate != true) { | 266 | if (isBatchUpdate != true) { |
267 | Clipperz.NotificationCenter.notify(aValue, 'recordAdded', null, true); | 267 | Clipperz.NotificationCenter.notify(aValue, 'recordAdded', null, true); |
268 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | 268 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); |
269 | } | 269 | } |
270 | }, | 270 | }, |
271 | 271 | ||
272 | //----------------------------------------------------------------------------- | 272 | //----------------------------------------------------------------------------- |
273 | 273 | ||
274 | 'addNewRecord': function() { | 274 | 'addNewRecord': function() { |
275 | varrecord; | 275 | varrecord; |
276 | 276 | ||
277 | //MochiKit.Logging.logDebug(">>> User.addNewRecord"); | 277 | //MochiKit.Logging.logDebug(">>> User.addNewRecord"); |
278 | record = new Clipperz.PM.DataModel.Record({user:this}); | 278 | record = new Clipperz.PM.DataModel.Record({user:this}); |
279 | this.addRecord(record); | 279 | this.addRecord(record); |
280 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | 280 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); |
281 | //MochiKit.Logging.logDebug("<<< User.addNewRecord"); | 281 | //MochiKit.Logging.logDebug("<<< User.addNewRecord"); |
282 | 282 | ||
283 | return record; | 283 | return record; |
284 | }, | 284 | }, |
285 | 285 | ||
286 | //------------------------------------------------------------------------- | 286 | //------------------------------------------------------------------------- |
287 | 287 | ||
288 | 'saveRecords': function(someRecords, aMethodName) { | 288 | 'saveRecords': function(someRecords /*, aMethodName*/) { |
289 | var deferredResult; | 289 | var deferredResult; |
290 | var methodName; | 290 | // var methodName; |
291 | varresult; | 291 | varresult; |
292 | var i,c; | 292 | var i,c; |
293 | 293 | ||
294 | //console.log("User.saveRecords - someRecords", someRecords); | 294 | //console.log("User.saveRecords - someRecords", someRecords); |
295 | methodName = aMethodName || 'addNewRecords'; | 295 | // methodName = aMethodName || 'addNewRecords'; |
296 | 296 | ||
297 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | 297 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); |
298 | //MochiKit.Logging.logDebug(">>> User.saveRecords"); | 298 | //MochiKit.Logging.logDebug(">>> User.saveRecords"); |
299 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] User.saveRecords"); | 299 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] User.saveRecords"); |
300 | /* | 300 | /* |
301 | MochiKit.Logging.logDebug("--- User.saveRecords - 1"); | 301 | MochiKit.Logging.logDebug("--- User.saveRecords - 1"); |
302 | MochiKit.Iter.forEach(someRecords, function(aRecord) { | 302 | MochiKit.Iter.forEach(someRecords, function(aRecord) { |
303 | if (aRecord.headerNotes() != null) { | 303 | if (aRecord.headerNotes() != null) { |
304 | aRecord.setNotes(aRecord.headerNotes()); | 304 | aRecord.setNotes(aRecord.headerNotes()); |
305 | } | 305 | } |
306 | aRecord.syncDirectLoginReferenceValues(); | 306 | aRecord.syncDirectLoginReferenceValues(); |
307 | aRecord.currentVersion().createNewVersion(); | 307 | aRecord.currentVersion().createNewVersion(); |
308 | aRecord.updateKey(); | 308 | aRecord.updateKey(); |
309 | }); | 309 | }); |
310 | MochiKit.Logging.logDebug("--- User.saveRecords - 2"); | 310 | MochiKit.Logging.logDebug("--- User.saveRecords - 2"); |
311 | */ | 311 | */ |
312 | 312 | ||
313 | result = {'records': []}; | 313 | result = {'records': []}; |
314 | 314 | ||
315 | deferredResult = new MochiKit.Async.Deferred(); | 315 | deferredResult = new MochiKit.Async.Deferred(); |
316 | c = someRecords.length; | 316 | c = someRecords.length; |
317 | for (i=0; i<c; i++) { | 317 | for (i=0; i<c; i++) { |
318 | deferredResult.addCallback(function(aRecord) { | 318 | deferredResult.addCallback(function(aRecord) { |
319 | if (aRecord.headerNotes() != null) { | 319 | if (aRecord.headerNotes() != null) { |
@@ -346,58 +346,59 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2"); | |||
346 | recordData = {}; | 346 | recordData = {}; |
347 | 347 | ||
348 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.1 " + res); return res;}); | 348 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.1 " + res); return res;}); |
349 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordData'); | 349 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordData'); |
350 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.2 " + res); return res;}); | 350 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.2 " + res); return res;}); |
351 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'encryptedData')); | 351 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'encryptedData')); |
352 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.3 " + res); return res;}); | 352 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.3 " + res); return res;}); |
353 | deferredResult.addCallback(function(aResult, res) { | 353 | deferredResult.addCallback(function(aResult, res) { |
354 | aResult['record'] = res; | 354 | aResult['record'] = res; |
355 | return aResult; | 355 | return aResult; |
356 | }, recordData); | 356 | }, recordData); |
357 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.4 " + res); return res;}); | 357 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.4 " + res); return res;}); |
358 | 358 | ||
359 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {} /*'saveCard_encryptRecordVersions'*/); | 359 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {} /*'saveCard_encryptRecordVersions'*/); |
360 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.5 " + res); return res;}); | 360 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.5 " + res); return res;}); |
361 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i].currentVersion(), 'encryptedData')); | 361 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i].currentVersion(), 'encryptedData')); |
362 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.6 " + res); return res;}); | 362 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.6 " + res); return res;}); |
363 | deferredResult.addCallback(function(aResult, res) { | 363 | deferredResult.addCallback(function(aResult, res) { |
364 | aResult['currentRecordVersion'] = res; | 364 | aResult['currentRecordVersion'] = res; |
365 | return aResult; | 365 | return aResult; |
366 | }, recordData); | 366 | }, recordData); |
367 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.7 " + res); return res;}); | 367 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.7 " + res); return res;}); |
368 | 368 | ||
369 | deferredResult.addCallback(function(aResult, res) { | 369 | deferredResult.addCallback(function(aResult, res) { |
370 | aResult['records'].push(res); | 370 | aResult['records'] = { 'updated': [res] }; |
371 | return aResult; | 371 | return aResult; |
372 | }, result); | 372 | }, result); |
373 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.8 " + res); return res;}); | 373 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.8 " + res); return res;}); |
374 | } | 374 | } |
375 | 375 | ||
376 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 7 " + res); return res;}); | 376 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 7 " + res); return res;}); |
377 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData'); | 377 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData'); |
378 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 8 " + res); return res;}); | 378 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 8 " + res); return res;}); |
379 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName); | 379 | // deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName); |
380 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); | ||
380 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9 " + res); return res;}); | 381 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9 " + res); return res;}); |
381 | 382 | ||
382 | for (i=0; i<c; i++) { | 383 | for (i=0; i<c; i++) { |
383 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.1 " + res); return res;}); | 384 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.1 " + res); return res;}); |
384 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'takeSnapshotOfCurrentData')); | 385 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'takeSnapshotOfCurrentData')); |
385 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.2 " + res); return res;}); | 386 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.2 " + res); return res;}); |
386 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'setIsBrandNew'), false); | 387 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'setIsBrandNew'), false); |
387 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.3 " + res); return res;}); | 388 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.3 " + res); return res;}); |
388 | } | 389 | } |
389 | 390 | ||
390 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 10 " + res); return res;}); | 391 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 10 " + res); return res;}); |
391 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'recordUpdated'); | 392 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'recordUpdated'); |
392 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 11 " + res); return res;}); | 393 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 11 " + res); return res;}); |
393 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'directLoginUpdated'); | 394 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'directLoginUpdated'); |
394 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 12 " + res); return res;}); | 395 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 12 " + res); return res;}); |
395 | deferredResult.callback(); | 396 | deferredResult.callback(); |
396 | 397 | ||
397 | return deferredResult; | 398 | return deferredResult; |
398 | }, | 399 | }, |
399 | 400 | ||
400 | //------------------------------------------------------------------------- | 401 | //------------------------------------------------------------------------- |
401 | 402 | ||
402 | 'removeRecord': function(aRecord) { | 403 | 'removeRecord': function(aRecord) { |
403 | //MochiKit.Logging.logDebug(">>> User.removeRecord"); | 404 | //MochiKit.Logging.logDebug(">>> User.removeRecord"); |
@@ -410,66 +411,68 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2"); | |||
410 | 411 | ||
411 | //------------------------------------------------------------------------- | 412 | //------------------------------------------------------------------------- |
412 | 413 | ||
413 | 'deleteRecordsAction': function(someRecords) { | 414 | 'deleteRecordsAction': function(someRecords) { |
414 | vardeferredResult; | 415 | vardeferredResult; |
415 | var parameters; | 416 | var parameters; |
416 | 417 | ||
417 | //MochiKit.Logging.logDebug(">>> User.deleteRecordsAction - someRecords.length: " + someRecords.length); | 418 | //MochiKit.Logging.logDebug(">>> User.deleteRecordsAction - someRecords.length: " + someRecords.length); |
418 | parameters = {}; | 419 | parameters = {}; |
419 | deferredResult = new MochiKit.Async.Deferred(); | 420 | deferredResult = new MochiKit.Async.Deferred(); |
420 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 1 " + res); return res;}); | 421 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 1 " + res); return res;}); |
421 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_collectData'); | 422 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_collectData'); |
422 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 2 " + res); return res;}); | 423 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 2 " + res); return res;}); |
423 | deferredResult.addCallback(function(someParameters, someRecords) { | 424 | deferredResult.addCallback(function(someParameters, someRecords) { |
424 | var recordReferences; | 425 | var recordReferences; |
425 | 426 | ||
426 | recordReferences = MochiKit.Base.map(function(aRecord) { | 427 | recordReferences = MochiKit.Base.map(function(aRecord) { |
427 | var result; | 428 | var result; |
428 | 429 | ||
429 | result = aRecord.reference(); | 430 | result = aRecord.reference(); |
430 | aRecord.remove(); | 431 | aRecord.remove(); |
431 | 432 | ||
432 | return result; | 433 | return result; |
433 | }, someRecords); | 434 | }, someRecords); |
434 | someParameters.recordReferences = recordReferences; | 435 | // someParameters.recordReferences = recordReferences; |
436 | someParameters['records'] = { 'deleted': recordReferences}; | ||
435 | 437 | ||
436 | return someParameters; | 438 | return someParameters; |
437 | }, parameters); | 439 | }, parameters); |
438 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 3 " + res); return res;}); | 440 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 3 " + res); return res;}); |
439 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_encryptData'); | 441 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_encryptData'); |
440 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 4 " + res); return res;}); | 442 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 4 " + res); return res;}); |
441 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); | 443 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); |
442 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 5 " + res); return res;}); | 444 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 5 " + res); return res;}); |
443 | deferredResult.addCallback(function(someParameters, anUserEncryptedData) { | 445 | deferredResult.addCallback(function(someParameters, anUserEncryptedData) { |
444 | someParameters.user = anUserEncryptedData; | 446 | someParameters.user = anUserEncryptedData; |
445 | return someParameters; | 447 | return someParameters; |
446 | }, parameters); | 448 | }, parameters); |
447 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 6 " + res); return res;}); | 449 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 6 " + res); return res;}); |
448 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_sendingData'); | 450 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_sendingData'); |
449 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecords parameters: " + Clipperz.Base.serializeJSON(res)); return res;}); | 451 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecords parameters: " + Clipperz.Base.serializeJSON(res)); return res;}); |
450 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 7 " + res); return res;}); | 452 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 7 " + res); return res;}); |
451 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords'); | 453 | // deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords'); |
454 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); | ||
452 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 8 " + res); return res;}); | 455 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 8 " + res); return res;}); |
453 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_updatingInterface'); | 456 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_updatingInterface'); |
454 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 9 " + res); return res;}); | 457 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 9 " + res); return res;}); |
455 | deferredResult.callback(someRecords); | 458 | deferredResult.callback(someRecords); |
456 | //MochiKit.Logging.logDebug("<<< User.deleteRecordsAction"); | 459 | //MochiKit.Logging.logDebug("<<< User.deleteRecordsAction"); |
457 | 460 | ||
458 | return deferredResult; | 461 | return deferredResult; |
459 | }, | 462 | }, |
460 | 463 | ||
461 | //------------------------------------------------------------------------- | 464 | //------------------------------------------------------------------------- |
462 | 465 | ||
463 | 'resetAllLocalData': function() { | 466 | 'resetAllLocalData': function() { |
464 | this.resetConnection(); | 467 | this.resetConnection(); |
465 | 468 | ||
466 | this.setUsername(""); | 469 | this.setUsername(""); |
467 | this.setPassphrase(""); | 470 | this.setPassphrase(""); |
468 | 471 | ||
469 | this._header = null; | 472 | this._header = null; |
470 | this._statistics = null; | 473 | this._statistics = null; |
471 | this._preferences = null; | 474 | this._preferences = null; |
472 | this._records = {}; | 475 | this._records = {}; |
473 | this._directLoginReferences = {}; | 476 | this._directLoginReferences = {}; |
474 | }, | 477 | }, |
475 | 478 | ||