author | Clipperz <info@clipperz.com> | 2013-01-31 13:42:04 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-31 13:42:04 (UTC) |
commit | 07d0357beef5d9328a2dd8d07ad7b39c87ac55e4 (patch) (unidiff) | |
tree | f7a4aed8848302db153c2a211f8e58b944eb4c5b /frontend/gamma/js/Clipperz/PM/DataModel | |
parent | 767a3dcf48b6ac911c088af5dd7738a728eb6b99 (diff) | |
download | clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.zip clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.tar.gz clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.tar.bz2 |
Updated Copyright claims
- updated reference dates;
- removed reference to Community Edition;
- normalized logging using Clipperz.log[Warn|Error|Debug]
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel') (more/less context) (ignore whitespace changes)
14 files changed, 165 insertions, 262 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js index 8f8696d..507ee31 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js | |||
@@ -1,70 +1,68 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | Clipperz.Base.module('Clipperz.PM.DataModel'); | 24 | Clipperz.Base.module('Clipperz.PM.DataModel'); |
27 | 25 | ||
28 | Clipperz.PM.DataModel.DirectLogin = function(args) { | 26 | Clipperz.PM.DataModel.DirectLogin = function(args) { |
29 | args = args || {}; | 27 | args = args || {}; |
30 | 28 | ||
31 | Clipperz.PM.DataModel.DirectLogin.superclass.constructor.apply(this, arguments); | 29 | Clipperz.PM.DataModel.DirectLogin.superclass.constructor.apply(this, arguments); |
32 | 30 | ||
33 | this._reference =args.reference | 31 | this._reference =args.reference |
34 | ||Clipperz.PM.Crypto.randomKey(); | 32 | ||Clipperz.PM.Crypto.randomKey(); |
35 | this._record =args.record | 33 | this._record =args.record |
36 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 34 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
37 | 35 | ||
38 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction | 36 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction |
39 | ||this.record().retrieveDirectLoginIndexDataFunction() | 37 | ||this.record().retrieveDirectLoginIndexDataFunction() |
40 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 38 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
41 | this._setIndexDataFunction = args.setIndexDataFunction | 39 | this._setIndexDataFunction = args.setIndexDataFunction |
42 | ||this.record().setDirectLoginIndexDataFunction() | 40 | ||this.record().setDirectLoginIndexDataFunction() |
43 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 41 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
44 | this._removeIndexDataFunction =args.removeIndexDataFunction | 42 | this._removeIndexDataFunction =args.removeIndexDataFunction |
45 | ||this.record().removeDirectLoginIndexDataFunction() | 43 | ||this.record().removeDirectLoginIndexDataFunction() |
46 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 44 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
47 | 45 | ||
48 | this._inputs = null; | 46 | this._inputs = null; |
49 | this._bindings = null; | 47 | this._bindings = null; |
50 | this._formValues = null; | 48 | this._formValues = null; |
51 | 49 | ||
52 | // this._inputsDeferredLock = new MochiKit.Async.DeferredLock(); | 50 | // this._inputsDeferredLock = new MochiKit.Async.DeferredLock(); |
53 | // this._bindingsDeferredLock = new MochiKit.Async.DeferredLock(); | 51 | // this._bindingsDeferredLock = new MochiKit.Async.DeferredLock(); |
54 | // this._formValuesDeferredLock = new MochiKit.Async.DeferredLock(); | 52 | // this._formValuesDeferredLock = new MochiKit.Async.DeferredLock(); |
55 | 53 | ||
56 | this._transientState = null; | 54 | this._transientState = null; |
57 | 55 | ||
58 | this._isBrandNew = MochiKit.Base.isUndefinedOrNull(args.reference); | 56 | this._isBrandNew = MochiKit.Base.isUndefinedOrNull(args.reference); |
59 | 57 | ||
60 | this.record().addDirectLogin(this); | 58 | this.record().addDirectLogin(this); |
61 | 59 | ||
62 | return this; | 60 | return this; |
63 | } | 61 | } |
64 | 62 | ||
65 | Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, { | 63 | Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, { |
66 | 64 | ||
67 | 'toString': function() { | 65 | 'toString': function() { |
68 | return "DirectLogin (" + this.reference() + ")"; | 66 | return "DirectLogin (" + this.reference() + ")"; |
69 | }, | 67 | }, |
70 | 68 | ||
@@ -284,97 +282,97 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, { | |||
284 | varresult; | 282 | varresult; |
285 | var type; | 283 | var type; |
286 | 284 | ||
287 | type = anInput['type'] || 'text'; | 285 | type = anInput['type'] || 'text'; |
288 | result = type.toLowerCase() == 'radio'; | 286 | result = type.toLowerCase() == 'radio'; |
289 | 287 | ||
290 | return result; | 288 | return result; |
291 | }, inputs); | 289 | }, inputs); |
292 | 290 | ||
293 | if (radios.length > 0) { | 291 | if (radios.length > 0) { |
294 | var updatedRadios; | 292 | var updatedRadios; |
295 | 293 | ||
296 | updatedRadios = {}; | 294 | updatedRadios = {}; |
297 | MochiKit.Iter.forEach(radios, MochiKit.Base.bind(function(aRadio) { | 295 | MochiKit.Iter.forEach(radios, MochiKit.Base.bind(function(aRadio) { |
298 | varradioConfiguration; | 296 | varradioConfiguration; |
299 | 297 | ||
300 | radioConfiguration = updatedRadios[aRadio['name']]; | 298 | radioConfiguration = updatedRadios[aRadio['name']]; |
301 | if (radioConfiguration == null) { | 299 | if (radioConfiguration == null) { |
302 | radioConfiguration = {type:'radio', name:aRadio['name'], options:[]}; | 300 | radioConfiguration = {type:'radio', name:aRadio['name'], options:[]}; |
303 | updatedRadios[aRadio['name']] = radioConfiguration; | 301 | updatedRadios[aRadio['name']] = radioConfiguration; |
304 | } | 302 | } |
305 | 303 | ||
306 | //TODO: remove the value: field and replace it with element.dom.value = <some value> | 304 | //TODO: remove the value: field and replace it with element.dom.value = <some value> |
307 | radioConfiguration.options.push({value:aRadio['value'], checked:aRadio['checked']}); | 305 | radioConfiguration.options.push({value:aRadio['value'], checked:aRadio['checked']}); |
308 | 306 | ||
309 | //TODO: shoud remove the 'formValues' call, as it is now deferred | 307 | //TODO: shoud remove the 'formValues' call, as it is now deferred |
310 | // if ((aRadio['checked'] == true) && (this.formValues()[aRadio['name']] == null)) { | 308 | // if ((aRadio['checked'] == true) && (this.formValues()[aRadio['name']] == null)) { |
311 | // this.formValues()[aRadio['name']] = aRadio['value']; | 309 | // this.formValues()[aRadio['name']] = aRadio['value']; |
312 | // } | 310 | // } |
313 | }, this)) | 311 | }, this)) |
314 | 312 | ||
315 | updatedInputs = MochiKit.Base.concat(updatedInputs, MochiKit.Base.values(updatedRadios)); | 313 | updatedInputs = MochiKit.Base.concat(updatedInputs, MochiKit.Base.values(updatedRadios)); |
316 | } | 314 | } |
317 | 315 | ||
318 | delete result.inputs; | 316 | delete result.inputs; |
319 | result.inputs = updatedInputs; | 317 | result.inputs = updatedInputs; |
320 | 318 | ||
321 | return result; | 319 | return result; |
322 | }, | 320 | }, |
323 | 321 | ||
324 | '_fixConfiguration': function (aConfiguration) { | 322 | '_fixConfiguration': function (aConfiguration) { |
325 | var fixedConfiguration; | 323 | var fixedConfiguration; |
326 | // var inputs; | 324 | // var inputs; |
327 | // var bindings; | 325 | // var bindings; |
328 | // var i,c; | 326 | // var i,c; |
329 | 327 | ||
330 | fixedConfiguration = Clipperz.Base.deepClone(aConfiguration); | 328 | fixedConfiguration = Clipperz.Base.deepClone(aConfiguration); |
331 | 329 | ||
332 | //console.log("PROCESS CONFIGURATION", aConfiguration); | 330 | //Clipperz.log("PROCESS CONFIGURATION", aConfiguration); |
333 | switch (aConfiguration['bookmarkletVersion']) { | 331 | switch (aConfiguration['bookmarkletVersion']) { |
334 | case '0.1': | 332 | case '0.1': |
335 | fixedConfiguration['formData'] = this.fixFormDataFromBookmarkletVersion_0_1(aConfiguration['formData']); | 333 | fixedConfiguration['formData'] = this.fixFormDataFromBookmarkletVersion_0_1(aConfiguration['formData']); |
336 | break; | 334 | break; |
337 | case '0.2': | 335 | case '0.2': |
338 | fixedConfiguration['formData'] = aConfiguration['formData']; | 336 | fixedConfiguration['formData'] = aConfiguration['formData']; |
339 | break; | 337 | break; |
340 | } | 338 | } |
341 | 339 | ||
342 | / * | 340 | / * |
343 | aConfiguration['_inputs'] = []; | 341 | aConfiguration['_inputs'] = []; |
344 | c = formData['inputs'].length; | 342 | c = formData['inputs'].length; |
345 | for (i=0; i<c; i++) { | 343 | for (i=0; i<c; i++) { |
346 | aConfiguration['_inputs'].push(new Clipperz.PM.DataModel.DirectLoginInput(formData['inputs'][i])); | 344 | aConfiguration['_inputs'].push(new Clipperz.PM.DataModel.DirectLoginInput(formData['inputs'][i])); |
347 | } | 345 | } |
348 | * / | 346 | * / |
349 | / * | 347 | / * |
350 | aConfiguration['_bindings'] = {}; | 348 | aConfiguration['_bindings'] = {}; |
351 | if (aConfiguration['legacyBindingData'] == null) { | 349 | if (aConfiguration['legacyBindingData'] == null) { |
352 | if (aConfiguration['bindingData'] != null) { | 350 | if (aConfiguration['bindingData'] != null) { |
353 | var bindingKey; | 351 | var bindingKey; |
354 | 352 | ||
355 | for (bindingKey in aConfiguration['bindingData']) { | 353 | for (bindingKey in aConfiguration['bindingData']) { |
356 | var newBinding; | 354 | var newBinding; |
357 | 355 | ||
358 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(bindingKey, {fieldKey:aConfiguration['bindingData'][bindingKey]}); | 356 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(bindingKey, {fieldKey:aConfiguration['bindingData'][bindingKey]}); |
359 | aConfiguration['_bindings'][newBinding.key()] = newBinding; | 357 | aConfiguration['_bindings'][newBinding.key()] = newBinding; |
360 | } | 358 | } |
361 | } else { | 359 | } else { |
362 | var editableFields; | 360 | var editableFields; |
363 | 361 | ||
364 | editableFields = MochiKit.Base.filter(function(aField) { | 362 | editableFields = MochiKit.Base.filter(function(aField) { |
365 | var result; | 363 | var result; |
366 | var type; | 364 | var type; |
367 | 365 | ||
368 | type = aField['type'].toLowerCase(); | 366 | type = aField['type'].toLowerCase(); |
369 | result = ((type != 'hidden') && (type != 'submit') && (type != 'checkbox') && (type != 'radio') && (type != 'select')); | 367 | result = ((type != 'hidden') && (type != 'submit') && (type != 'checkbox') && (type != 'radio') && (type != 'select')); |
370 | 368 | ||
371 | return result; | 369 | return result; |
372 | }, aConfiguration['_inputs']); | 370 | }, aConfiguration['_inputs']); |
373 | 371 | ||
374 | MochiKit.Iter.forEach(editableFields, MochiKit.Base.bind(function(anEditableField) { | 372 | MochiKit.Iter.forEach(editableFields, MochiKit.Base.bind(function(anEditableField) { |
375 | var newBinding; | 373 | var newBinding; |
376 | 374 | ||
377 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(anEditableField['name']); | 375 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(anEditableField['name']); |
378 | aConfiguration['_bindings'][newBinding.key()] = newBinding; | 376 | aConfiguration['_bindings'][newBinding.key()] = newBinding; |
379 | }, this)); | 377 | }, this)); |
380 | } | 378 | } |
@@ -436,166 +434,161 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, { | |||
436 | //------------------------------------------------------------------------- | 434 | //------------------------------------------------------------------------- |
437 | 435 | ||
438 | 'resetObjectDataStore': function () { | 436 | 'resetObjectDataStore': function () { |
439 | this._objectDataStore.removeAllData(); | 437 | this._objectDataStore.removeAllData(); |
440 | this._objectDataStore = null; | 438 | this._objectDataStore = null; |
441 | }, | 439 | }, |
442 | */ | 440 | */ |
443 | //========================================================================= | 441 | //========================================================================= |
444 | 442 | ||
445 | 'bookmarkletConfiguration': function () { | 443 | 'bookmarkletConfiguration': function () { |
446 | return Clipperz.Async.callbacks("DirectLogin.bookmarkletConfiguration", [ | 444 | return Clipperz.Async.callbacks("DirectLogin.bookmarkletConfiguration", [ |
447 | Clipperz.Async.collectResults("DirectLogin.bookmarkletConfiguration <inner results>", { | 445 | Clipperz.Async.collectResults("DirectLogin.bookmarkletConfiguration <inner results>", { |
448 | 'label': MochiKit.Base.method(this, 'label'), | 446 | 'label': MochiKit.Base.method(this, 'label'), |
449 | 'configuration': MochiKit.Base.method(this, 'getValue', '') | 447 | 'configuration': MochiKit.Base.method(this, 'getValue', '') |
450 | }, {trace:false}), | 448 | }, {trace:false}), |
451 | function (someValues) { | 449 | function (someValues) { |
452 | var result; | 450 | var result; |
453 | 451 | ||
454 | if (someValues['configuration'] != null) { | 452 | if (someValues['configuration'] != null) { |
455 | varconfiguration; | 453 | varconfiguration; |
456 | 454 | ||
457 | configuration = { | 455 | configuration = { |
458 | 'page': { | 456 | 'page': { |
459 | 'title': someValues['label'] | 457 | 'title': someValues['label'] |
460 | //'favicon' | 458 | //'favicon' |
461 | // 'url' | 459 | // 'url' |
462 | }, | 460 | }, |
463 | 'form': someValues['configuration']['formData'], | 461 | 'form': someValues['configuration']['formData'], |
464 | 'version':someValues['configuration']['bookmarkletVersion'] | 462 | 'version':someValues['configuration']['bookmarkletVersion'] |
465 | } | 463 | } |
466 | 464 | ||
467 | result = Clipperz.Base.formatJSON(configuration); | 465 | result = Clipperz.Base.formatJSON(configuration); |
468 | } else { | 466 | } else { |
469 | result = ''; | 467 | result = ''; |
470 | } | 468 | } |
471 | 469 | ||
472 | return result; | 470 | return result; |
473 | } | 471 | } |
474 | ], {trace:false}); | 472 | ], {trace:false}); |
475 | 473 | ||
476 | }, | 474 | }, |
477 | 475 | ||
478 | //------------------------------------------------------------------------- | 476 | //------------------------------------------------------------------------- |
479 | 477 | ||
480 | 'setBookmarkletConfiguration': function (aValue) { | 478 | 'setBookmarkletConfiguration': function (aValue) { |
481 | var bookmarkletConfiguration; | 479 | var bookmarkletConfiguration; |
482 | 480 | ||
483 | bookmarkletConfiguration = Clipperz.PM.DataModel.DirectLogin.checkBookmarkletConfiguration(aValue); | 481 | bookmarkletConfiguration = Clipperz.PM.DataModel.DirectLogin.checkBookmarkletConfiguration(aValue); |
484 | //console.log("BOOKMARKLET CONFIGURATION", bookmarkletConfiguration); | 482 | |
485 | return Clipperz.Async.callbacks("DirectLogin.setBookmarkletConfiguration", [ | 483 | return Clipperz.Async.callbacks("DirectLogin.setBookmarkletConfiguration", [ |
486 | MochiKit.Base.method(this, 'setValue', 'formData', bookmarkletConfiguration['form']), | 484 | MochiKit.Base.method(this, 'setValue', 'formData', bookmarkletConfiguration['form']), |
487 | //function (aValue) { console.log("SET VALUE - formData", aValue); return aValue; }, | ||
488 | MochiKit.Base.method(this, 'setValue', 'bookmarkletVersion', bookmarkletConfiguration['version']), | 485 | MochiKit.Base.method(this, 'setValue', 'bookmarkletVersion', bookmarkletConfiguration['version']), |
489 | 486 | ||
490 | MochiKit.Base.method(this, 'favicon'), | 487 | MochiKit.Base.method(this, 'favicon'), |
491 | Clipperz.Async.deferredIf("the favicon is not set", [ | 488 | Clipperz.Async.deferredIf("the favicon is not set", [ |
492 | ], [ | 489 | ], [ |
493 | MochiKit.Base.method(this, 'faviconUrlWithBookmarkletConfiguration', bookmarkletConfiguration), | 490 | MochiKit.Base.method(this, 'faviconUrlWithBookmarkletConfiguration', bookmarkletConfiguration), |
494 | MochiKit.Base.method(this, 'setFavicon') | 491 | MochiKit.Base.method(this, 'setFavicon') |
495 | ]), | 492 | ]), |
496 | 493 | ||
497 | MochiKit.Base.method(this, 'updateInputsAfterChangingBookmarkletConfiguration'), | 494 | MochiKit.Base.method(this, 'updateInputsAfterChangingBookmarkletConfiguration'), |
498 | MochiKit.Base.method(this, 'updateFormValuesAfterChangingBookmarkletConfiguration'), | 495 | MochiKit.Base.method(this, 'updateFormValuesAfterChangingBookmarkletConfiguration'), |
499 | MochiKit.Base.method(this, 'updateBindingsAfterChangingBookmarkletConfiguration'), | 496 | MochiKit.Base.method(this, 'updateBindingsAfterChangingBookmarkletConfiguration'), |
500 | 497 | ||
501 | MochiKit.Base.noop | 498 | MochiKit.Base.noop |
502 | ], {trace:false}); | 499 | ], {trace:false}); |
503 | }, | 500 | }, |
504 | 501 | ||
505 | //========================================================================= | 502 | //========================================================================= |
506 | 503 | ||
507 | 'formAttributes': function () { | 504 | 'formAttributes': function () { |
508 | return this.getValue('formData.attributes'); | 505 | return this.getValue('formData.attributes'); |
509 | }, | 506 | }, |
510 | 507 | ||
511 | //========================================================================= | 508 | //========================================================================= |
512 | 509 | ||
513 | 'inputs': function () { | 510 | 'inputs': function () { |
514 | return Clipperz.Async.callbacks("DirectLogin.inputs", [ | 511 | return Clipperz.Async.callbacks("DirectLogin.inputs", [ |
515 | Clipperz.Async.deferredIf("this._inputs is defined", [ | 512 | Clipperz.Async.deferredIf("this._inputs is defined", [ |
516 | ], [ | 513 | ], [ |
517 | MochiKit.Base.method(this, 'updateInputsAfterChangingBookmarkletConfiguration') | 514 | MochiKit.Base.method(this, 'updateInputsAfterChangingBookmarkletConfiguration') |
518 | ]) | 515 | ]) |
519 | ], {trace:false}, this._inputs); | 516 | ], {trace:false}, this._inputs); |
520 | }, | 517 | }, |
521 | 518 | ||
522 | 'setInputWithFormDataConfiguration': function (aFormDataConfiguration) { | 519 | 'setInputWithFormDataConfiguration': function (aFormDataConfiguration) { |
523 | this._inputs = {}; | 520 | this._inputs = {}; |
524 | 521 | ||
525 | if (aFormDataConfiguration != null) { | 522 | if (aFormDataConfiguration != null) { |
526 | MochiKit.Iter.forEach(aFormDataConfiguration['inputs'], MochiKit.Base.bind(function (anInputData) { | 523 | MochiKit.Iter.forEach(aFormDataConfiguration['inputs'], MochiKit.Base.bind(function (anInputData) { |
527 | var newInput; | 524 | var newInput; |
528 | 525 | ||
529 | newInput = new Clipperz.PM.DataModel.DirectLoginInput(anInputData); | 526 | newInput = new Clipperz.PM.DataModel.DirectLoginInput(anInputData); |
530 | this._inputs[newInput.name()] = newInput; | 527 | this._inputs[newInput.name()] = newInput; |
531 | }, this)); | 528 | }, this)); |
532 | } | 529 | } |
533 | 530 | ||
534 | return this._inputs; | 531 | return this._inputs; |
535 | }, | 532 | }, |
536 | 533 | ||
537 | 'updateInputsAfterChangingBookmarkletConfiguration': function () { | 534 | 'updateInputsAfterChangingBookmarkletConfiguration': function () { |
538 | return Clipperz.Async.callbacks("DirectLogin.updateInputsAfterChangingBookmarkletConfiguration", [ | 535 | return Clipperz.Async.callbacks("DirectLogin.updateInputsAfterChangingBookmarkletConfiguration", [ |
539 | // MochiKit.Base.method(this, 'getValue', ''), | ||
540 | //function (aValue) { console.log("VALUE", aValue); return aValue }, | ||
541 | MochiKit.Base.method(this, 'getValue', 'formData'), | 536 | MochiKit.Base.method(this, 'getValue', 'formData'), |
542 | //function (aValue) { console.log("FORM DATA", aValue); return aValue }, | ||
543 | MochiKit.Base.method(this, 'setInputWithFormDataConfiguration') | 537 | MochiKit.Base.method(this, 'setInputWithFormDataConfiguration') |
544 | ], {trace:false}); | 538 | ], {trace:false}); |
545 | }, | 539 | }, |
546 | 540 | ||
547 | //========================================================================= | 541 | //========================================================================= |
548 | 542 | ||
549 | 'inputValues': function () { | 543 | 'inputValues': function () { |
550 | return Clipperz.Async.callbacks("DirectLogin.inputValues", [ | 544 | return Clipperz.Async.callbacks("DirectLogin.inputValues", [ |
551 | MochiKit.Base.method(this, 'inputs'), | 545 | MochiKit.Base.method(this, 'inputs'), |
552 | MochiKit.Base.values, | 546 | MochiKit.Base.values, |
553 | //function (aValue) { console.log("INPUTS", aValue); return aValue; }, | ||
554 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.partial(MochiKit.Base.method(this, 'inputValue'))), | 547 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.partial(MochiKit.Base.method(this, 'inputValue'))), |
555 | Clipperz.Async.collectAll, | 548 | Clipperz.Async.collectAll, |
556 | Clipperz.Base.mergeItems | 549 | Clipperz.Base.mergeItems |
557 | ], {trace:false}); | 550 | ], {trace:false}); |
558 | }, | 551 | }, |
559 | 552 | ||
560 | 'inputValue': function (anInput) { | 553 | 'inputValue': function (anInput) { |
561 | vardeferredResult; | 554 | vardeferredResult; |
562 | 555 | ||
563 | deferredResult = new Clipperz.Async.Deferred("DirectLogin.inputValue", {trace:false}); | 556 | deferredResult = new Clipperz.Async.Deferred("DirectLogin.inputValue", {trace:false}); |
564 | 557 | ||
565 | if (anInput.needsFormValue()) { | 558 | if (anInput.needsFormValue()) { |
566 | deferredResult.addMethod(this, 'formValues'); | 559 | deferredResult.addMethod(this, 'formValues'); |
567 | deferredResult.addCallback(MochiKit.Base.itemgetter(anInput.name())); | 560 | deferredResult.addCallback(MochiKit.Base.itemgetter(anInput.name())); |
568 | deferredResult.addMethodcaller('value'); | 561 | deferredResult.addMethodcaller('value'); |
569 | } else if (anInput.needsBinding()) { | 562 | } else if (anInput.needsBinding()) { |
570 | deferredResult.addMethod(this, 'bindings'); | 563 | deferredResult.addMethod(this, 'bindings'); |
571 | deferredResult.addCallback(MochiKit.Base.itemgetter(anInput.name())); | 564 | deferredResult.addCallback(MochiKit.Base.itemgetter(anInput.name())); |
572 | deferredResult.addMethodcaller('field'); | 565 | deferredResult.addMethodcaller('field'); |
573 | deferredResult.addMethodcaller('value'); | 566 | deferredResult.addMethodcaller('value'); |
574 | } else { | 567 | } else { |
575 | deferredResult.addCallback(MochiKit.Async.succeed, anInput.value()); | 568 | deferredResult.addCallback(MochiKit.Async.succeed, anInput.value()); |
576 | } | 569 | } |
577 | deferredResult.addCallback(function (anActualValue) { | 570 | deferredResult.addCallback(function (anActualValue) { |
578 | return [anInput.name(), anActualValue]; | 571 | return [anInput.name(), anActualValue]; |
579 | }); | 572 | }); |
580 | 573 | ||
581 | deferredResult.callback(); | 574 | deferredResult.callback(); |
582 | 575 | ||
583 | return deferredResult; | 576 | return deferredResult; |
584 | }, | 577 | }, |
585 | 578 | ||
586 | //========================================================================= | 579 | //========================================================================= |
587 | 580 | ||
588 | 'bindings': function () { | 581 | 'bindings': function () { |
589 | return Clipperz.Async.callbacks("DirectLogin.bindings", [ | 582 | return Clipperz.Async.callbacks("DirectLogin.bindings", [ |
590 | Clipperz.Async.deferredIf("this._bindings is defined", [ | 583 | Clipperz.Async.deferredIf("this._bindings is defined", [ |
591 | ], [ | 584 | ], [ |
592 | MochiKit.Base.method(this, 'updateBindingsAfterChangingBookmarkletConfiguration'), | 585 | MochiKit.Base.method(this, 'updateBindingsAfterChangingBookmarkletConfiguration'), |
593 | MochiKit.Base.bind(function () { return this._bindings;}, this) | 586 | MochiKit.Base.bind(function () { return this._bindings;}, this) |
594 | ]) | 587 | ]) |
595 | ], {trace:false}, this._bindings); | 588 | ], {trace:false}, this._bindings); |
596 | }, | 589 | }, |
597 | 590 | ||
598 | 'bindFormFieldWithLabelToRecordFieldWithLabel': function (aFormFieldLabel, aRecordFieldLabel) { | 591 | 'bindFormFieldWithLabelToRecordFieldWithLabel': function (aFormFieldLabel, aRecordFieldLabel) { |
599 | return Clipperz.Async.callbacks("DirectLogin.bindFormFieldWithLabelToCardFieldWithLabel", [ | 592 | return Clipperz.Async.callbacks("DirectLogin.bindFormFieldWithLabelToCardFieldWithLabel", [ |
600 | Clipperz.Async.collectResults("DirectLogin.bindFormFieldWithLabelToCardFieldWithLabel - collect results", { | 593 | Clipperz.Async.collectResults("DirectLogin.bindFormFieldWithLabelToCardFieldWithLabel - collect results", { |
601 | 'binding': [ | 594 | 'binding': [ |
@@ -629,109 +622,106 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, { | |||
629 | 622 | ||
630 | result = {}; | 623 | result = {}; |
631 | for (bindingKey in someData['bindings']) { | 624 | for (bindingKey in someData['bindings']) { |
632 | result[bindingKey] = someData['fieldValues'][someData['bindings'][bindingKey].fieldKey()]['value']; | 625 | result[bindingKey] = someData['fieldValues'][someData['bindings'][bindingKey].fieldKey()]['value']; |
633 | } | 626 | } |
634 | 627 | ||
635 | return result; | 628 | return result; |
636 | } | 629 | } |
637 | ], {trace:false}); | 630 | ], {trace:false}); |
638 | }, | 631 | }, |
639 | */ | 632 | */ |
640 | //------------------------------------------------------------------------- | 633 | //------------------------------------------------------------------------- |
641 | 634 | ||
642 | 'updateBindingsAfterChangingBookmarkletConfiguration': function () { | 635 | 'updateBindingsAfterChangingBookmarkletConfiguration': function () { |
643 | return Clipperz.Async.callbacks("DirectLogin.updateBindingsAfterChangingBookmarkletConfiguration", [ | 636 | return Clipperz.Async.callbacks("DirectLogin.updateBindingsAfterChangingBookmarkletConfiguration", [ |
644 | Clipperz.Async.collectResults("DirectLogin.updateBindingsAfterChangingBookmarkletConfiguration<collect results>", { | 637 | Clipperz.Async.collectResults("DirectLogin.updateBindingsAfterChangingBookmarkletConfiguration<collect results>", { |
645 | 'currentValues':MochiKit.Base.method(this, 'getValue', ''), | 638 | 'currentValues':MochiKit.Base.method(this, 'getValue', ''), |
646 | 'originalValues':MochiKit.Base.method(this, 'originalConfiguration'), | 639 | 'originalValues':MochiKit.Base.method(this, 'originalConfiguration'), |
647 | 'inputs': MochiKit.Base.method(this, 'inputs') | 640 | 'inputs': MochiKit.Base.method(this, 'inputs') |
648 | }, {trace:false}), | 641 | }, {trace:false}), |
649 | MochiKit.Base.bind(function (someValues) { | 642 | MochiKit.Base.bind(function (someValues) { |
650 | var availableBindingValues; | 643 | var availableBindingValues; |
651 | var inputRequiringBindingValues; | 644 | var inputRequiringBindingValues; |
652 | var newBindingValues; | 645 | var newBindingValues; |
653 | 646 | ||
654 | if (MochiKit.Base.isUndefinedOrNull(someValues['originalValues']) || MochiKit.Base.isUndefinedOrNull(someValues['originalValues']['bindingData'])) { | 647 | if (MochiKit.Base.isUndefinedOrNull(someValues['originalValues']) || MochiKit.Base.isUndefinedOrNull(someValues['originalValues']['bindingData'])) { |
655 | availableBindingValues = {}; | 648 | availableBindingValues = {}; |
656 | } else { | 649 | } else { |
657 | availableBindingValues = Clipperz.Base.deepClone(someValues['originalValues']['bindingData']) | 650 | availableBindingValues = Clipperz.Base.deepClone(someValues['originalValues']['bindingData']) |
658 | } | 651 | } |
659 | 652 | ||
660 | if (someValues['currentValues'] != null) { | 653 | if (someValues['currentValues'] != null) { |
661 | MochiKit.Base.update(availableBindingValues, someValues['currentValues']['bindingData']); | 654 | MochiKit.Base.update(availableBindingValues, someValues['currentValues']['bindingData']); |
662 | } | 655 | } |
663 | 656 | ||
664 | this._bindings = {}; | 657 | this._bindings = {}; |
665 | newBindingValues = {} | 658 | newBindingValues = {} |
666 | MochiKit.Iter.forEach(MochiKit.Base.filter(MochiKit.Base.methodcaller('needsBinding'), MochiKit.Base.values(someValues['inputs'])), MochiKit.Base.bind(function (anInput) { | 659 | MochiKit.Iter.forEach(MochiKit.Base.filter(MochiKit.Base.methodcaller('needsBinding'), MochiKit.Base.values(someValues['inputs'])), MochiKit.Base.bind(function (anInput) { |
667 | varnewBinding; | 660 | varnewBinding; |
668 | 661 | ||
669 | newBindingValues[anInput.name()] = availableBindingValues[anInput.name()]; | 662 | newBindingValues[anInput.name()] = availableBindingValues[anInput.name()]; |
670 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { | 663 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { |
671 | 'key': anInput.name(), | 664 | 'key': anInput.name(), |
672 | 'field':availableBindingValues[anInput.name()] | 665 | 'field':availableBindingValues[anInput.name()] |
673 | }); | 666 | }); |
674 | 667 | ||
675 | this._bindings[anInput.name()] = newBinding; | 668 | this._bindings[anInput.name()] = newBinding; |
676 | }, this)) | 669 | }, this)) |
677 | //console.log("THIS._BINDINGS", this._bindings); | ||
678 | 670 | ||
679 | return newBindingValues; | 671 | return newBindingValues; |
680 | 672 | ||
681 | /* | 673 | /* |
682 | this._bindings = {}; | 674 | this._bindings = {}; |
683 | //console.log("CONFIGURATION", aConfiguration); | ||
684 | 675 | ||
685 | if (someValues['currentValues'] != null) { | 676 | if (someValues['currentValues'] != null) { |
686 | if (someValues['currentValues']['bindingData'] != null) { | 677 | if (someValues['currentValues']['bindingData'] != null) { |
687 | var bindingKey; | 678 | var bindingKey; |
688 | 679 | ||
689 | //console.log("BINDING DATA", someValues['currentValues']['bindingData']); | ||
690 | for (bindingKey in someValues['currentValues']['bindingData']) { | 680 | for (bindingKey in someValues['currentValues']['bindingData']) { |
691 | var newBinding; | 681 | var newBinding; |
692 | 682 | ||
693 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { | 683 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { |
694 | 'key': bindingKey, | 684 | 'key': bindingKey, |
695 | 'field':someValues['currentValues']['bindingData'][bindingKey] | 685 | 'field':someValues['currentValues']['bindingData'][bindingKey] |
696 | }); | 686 | }); |
697 | this._bindings[newBinding.key()] = newBinding; | 687 | this._bindings[newBinding.key()] = newBinding; |
698 | } | 688 | } |
699 | } else if (someValues['currentValues']['legacyBindingData'] == null) { | 689 | } else if (someValues['currentValues']['legacyBindingData'] == null) { |
700 | var bindingKey; | 690 | var bindingKey; |
701 | 691 | ||
702 | for (bindingKey in someValues['currentValues']['legacyBindingData']) { | 692 | for (bindingKey in someValues['currentValues']['legacyBindingData']) { |
703 | var newBinding; | 693 | var newBinding; |
704 | 694 | ||
705 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { | 695 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { |
706 | 'key': bindingKey, | 696 | 'key': bindingKey, |
707 | 'field':someValues['currentValues']['legacyBindingData'][bindingKey] | 697 | 'field':someValues['currentValues']['legacyBindingData'][bindingKey] |
708 | }); | 698 | }); |
709 | this._bindings[newBinding.key()] = newBinding; | 699 | this._bindings[newBinding.key()] = newBinding; |
710 | } | 700 | } |
711 | } else { | 701 | } else { |
712 | WTF = TODO; | 702 | WTF = TODO; |
713 | } | 703 | } |
714 | } | 704 | } |
715 | 705 | ||
716 | return this._bindings; | 706 | return this._bindings; |
717 | */ | 707 | */ |
718 | }, this), | 708 | }, this), |
719 | MochiKit.Base.method(this, 'setValue', 'bindingData') | 709 | MochiKit.Base.method(this, 'setValue', 'bindingData') |
720 | ], {trace:false}); | 710 | ], {trace:false}); |
721 | }, | 711 | }, |
722 | 712 | ||
723 | //========================================================================= | 713 | //========================================================================= |
724 | 714 | ||
725 | 'formValues': function () { | 715 | 'formValues': function () { |
726 | return Clipperz.Async.callbacks("DirectLogin.formValues", [ | 716 | return Clipperz.Async.callbacks("DirectLogin.formValues", [ |
727 | Clipperz.Async.deferredIf("this._formValues is defined", [ | 717 | Clipperz.Async.deferredIf("this._formValues is defined", [ |
728 | ], [ | 718 | ], [ |
729 | MochiKit.Base.method(this, 'updateFormValuesAfterChangingBookmarkletConfiguration'), | 719 | MochiKit.Base.method(this, 'updateFormValuesAfterChangingBookmarkletConfiguration'), |
730 | MochiKit.Base.bind(function () { return this._formValues;}, this) | 720 | MochiKit.Base.bind(function () { return this._formValues;}, this) |
731 | ]) | 721 | ]) |
732 | ], {trace:false}, this._formValues); | 722 | ], {trace:false}, this._formValues); |
733 | }, | 723 | }, |
734 | 724 | ||
735 | //------------------------------------------------------------------------- | 725 | //------------------------------------------------------------------------- |
736 | 726 | ||
737 | 'updateFormValuesAfterChangingBookmarkletConfiguration': function () { | 727 | 'updateFormValuesAfterChangingBookmarkletConfiguration': function () { |
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginBinding.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginBinding.js index 4377853..a8ebb97 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginBinding.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginBinding.js | |||
@@ -1,70 +1,68 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 27 | ||
30 | 28 | ||
31 | //############################################################################# | 29 | //############################################################################# |
32 | 30 | ||
33 | Clipperz.PM.DataModel.DirectLoginBinding = function(aDirectLogin, args) { | 31 | Clipperz.PM.DataModel.DirectLoginBinding = function(aDirectLogin, args) { |
34 | args = args || {}; | 32 | args = args || {}; |
35 | 33 | ||
36 | this._directLogin = aDirectLogin|| Clipperz.Base.exception.raise('MandatoryParameter'); | 34 | this._directLogin = aDirectLogin|| Clipperz.Base.exception.raise('MandatoryParameter'); |
37 | 35 | ||
38 | this._key = args.key|| Clipperz.Base.exception.raise('MandatoryParameter'); | 36 | this._key = args.key|| Clipperz.Base.exception.raise('MandatoryParameter'); |
39 | this._fieldKey = args.field || /* this.directLogin().fieldWithName(args.fieldName).reference() || */null; | 37 | this._fieldKey = args.field || /* this.directLogin().fieldWithName(args.fieldName).reference() || */null; |
40 | 38 | ||
41 | return this; | 39 | return this; |
42 | } | 40 | } |
43 | 41 | ||
44 | Clipperz.PM.DataModel.DirectLoginBinding.prototype = MochiKit.Base.update(null, { | 42 | Clipperz.PM.DataModel.DirectLoginBinding.prototype = MochiKit.Base.update(null, { |
45 | 43 | ||
46 | 'toString': function() { | 44 | 'toString': function() { |
47 | return "DirectLoginBinding (" + this.key() + ", " + this.fieldKey() + ")"; | 45 | return "DirectLoginBinding (" + this.key() + ", " + this.fieldKey() + ")"; |
48 | }, | 46 | }, |
49 | 47 | ||
50 | //------------------------------------------------------------------------- | 48 | //------------------------------------------------------------------------- |
51 | 49 | ||
52 | 'directLogin': function () { | 50 | 'directLogin': function () { |
53 | return this._directLogin; | 51 | return this._directLogin; |
54 | }, | 52 | }, |
55 | 53 | ||
56 | //------------------------------------------------------------------------- | 54 | //------------------------------------------------------------------------- |
57 | 55 | ||
58 | 'key': function() { | 56 | 'key': function() { |
59 | return this._key; | 57 | return this._key; |
60 | }, | 58 | }, |
61 | 59 | ||
62 | //------------------------------------------------------------------------- | 60 | //------------------------------------------------------------------------- |
63 | 61 | ||
64 | 'fieldKey': function() { | 62 | 'fieldKey': function() { |
65 | return this._fieldKey; | 63 | return this._fieldKey; |
66 | }, | 64 | }, |
67 | 65 | ||
68 | 'setFieldKey': function(aValue) { | 66 | 'setFieldKey': function(aValue) { |
69 | this._fieldKey = aValue; | 67 | this._fieldKey = aValue; |
70 | 68 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginFormValue.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginFormValue.js index a461197..2429f88 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginFormValue.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginFormValue.js | |||
@@ -1,104 +1,101 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 27 | ||
30 | 28 | ||
31 | //############################################################################# | 29 | //############################################################################# |
32 | 30 | ||
33 | Clipperz.PM.DataModel.DirectLoginFormValue = function(aDirectLogin, args) { | 31 | Clipperz.PM.DataModel.DirectLoginFormValue = function(aDirectLogin, args) { |
34 | args = args || {}; | 32 | args = args || {}; |
35 | 33 | ||
36 | this._directLogin = aDirectLogin|| Clipperz.Base.exception.raise('MandatoryParameter'); | 34 | this._directLogin = aDirectLogin|| Clipperz.Base.exception.raise('MandatoryParameter'); |
37 | 35 | ||
38 | this._key = args.key || Clipperz.Base.exception.raise('MandatoryParameter'); | 36 | this._key = args.key || Clipperz.Base.exception.raise('MandatoryParameter'); |
39 | this._fieldOptions = args.fieldOptions|| Clipperz.Base.exception.raise('MandatoryParameter'); | 37 | this._fieldOptions = args.fieldOptions|| Clipperz.Base.exception.raise('MandatoryParameter'); |
40 | this._value = args.value || null; | 38 | this._value = args.value || null; |
41 | 39 | ||
42 | return this; | 40 | return this; |
43 | } | 41 | } |
44 | 42 | ||
45 | Clipperz.PM.DataModel.DirectLoginFormValue.prototype = MochiKit.Base.update(null, { | 43 | Clipperz.PM.DataModel.DirectLoginFormValue.prototype = MochiKit.Base.update(null, { |
46 | 44 | ||
47 | 'toString': function() { | 45 | 'toString': function() { |
48 | return "DirectLoginFormValue (" + this.key() + ", " + this.value() + ")"; | 46 | return "DirectLoginFormValue (" + this.key() + ", " + this.value() + ")"; |
49 | }, | 47 | }, |
50 | 48 | ||
51 | //------------------------------------------------------------------------- | 49 | //------------------------------------------------------------------------- |
52 | 50 | ||
53 | 'directLogin': function () { | 51 | 'directLogin': function () { |
54 | return this._directLogin; | 52 | return this._directLogin; |
55 | }, | 53 | }, |
56 | 54 | ||
57 | //------------------------------------------------------------------------- | 55 | //------------------------------------------------------------------------- |
58 | 56 | ||
59 | 'key': function() { | 57 | 'key': function() { |
60 | return this._key; | 58 | return this._key; |
61 | }, | 59 | }, |
62 | 60 | ||
63 | //------------------------------------------------------------------------- | 61 | //------------------------------------------------------------------------- |
64 | 62 | ||
65 | 'fieldOptions': function() { | 63 | 'fieldOptions': function() { |
66 | return this._fieldOptions; | 64 | return this._fieldOptions; |
67 | }, | 65 | }, |
68 | 66 | ||
69 | //------------------------------------------------------------------------- | 67 | //------------------------------------------------------------------------- |
70 | 68 | ||
71 | 'type': function () { | 69 | 'type': function () { |
72 | return this.fieldOptions()['type']; | 70 | return this.fieldOptions()['type']; |
73 | }, | 71 | }, |
74 | 72 | ||
75 | //------------------------------------------------------------------------- | 73 | //------------------------------------------------------------------------- |
76 | 74 | ||
77 | 'value': function() { | 75 | 'value': function() { |
78 | varresult; | 76 | varresult; |
79 | 77 | ||
80 | result = this._value; | 78 | result = this._value; |
81 | 79 | ||
82 | // if ((result == null) && (this.type() == 'checkbox')) { | 80 | // if ((result == null) && (this.type() == 'checkbox')) { |
83 | // result = false; | 81 | // result = false; |
84 | // }; | 82 | // }; |
85 | 83 | ||
86 | return result; | 84 | return result; |
87 | }, | 85 | }, |
88 | 86 | ||
89 | 'setValue': function (aValue) { | 87 | 'setValue': function (aValue) { |
90 | //console.log("DirectLoginFormValue.setValue", aValue); | ||
91 | this._value = aValue; | 88 | this._value = aValue; |
92 | return this.directLogin().setValue('formValues' + '.' + this.key(), aValue); | 89 | return this.directLogin().setValue('formValues' + '.' + this.key(), aValue); |
93 | }, | 90 | }, |
94 | 91 | ||
95 | //------------------------------------------------------------------------- | 92 | //------------------------------------------------------------------------- |
96 | /* | 93 | /* |
97 | 'serializedData': function() { | 94 | 'serializedData': function() { |
98 | return this.value(); | 95 | return this.value(); |
99 | }, | 96 | }, |
100 | */ | 97 | */ |
101 | //------------------------------------------------------------------------- | 98 | //------------------------------------------------------------------------- |
102 | __syntaxFix__: "syntax fix" | 99 | __syntaxFix__: "syntax fix" |
103 | }); | 100 | }); |
104 | 101 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js index 8188389..d9995fc 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js | |||
@@ -1,200 +1,192 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 27 | ||
30 | //############################################################################# | 28 | //############################################################################# |
31 | 29 | ||
32 | Clipperz.PM.DataModel.DirectLoginInput = function(args) { | 30 | Clipperz.PM.DataModel.DirectLoginInput = function(args) { |
33 | this._args = args; | 31 | this._args = args; |
34 | 32 | ||
35 | return this; | 33 | return this; |
36 | } | 34 | } |
37 | 35 | ||
38 | Clipperz.PM.DataModel.DirectLoginInput.prototype = MochiKit.Base.update(null, { | 36 | Clipperz.PM.DataModel.DirectLoginInput.prototype = MochiKit.Base.update(null, { |
39 | 37 | ||
40 | 'args': function() { | 38 | 'args': function() { |
41 | return this._args; | 39 | return this._args; |
42 | }, | 40 | }, |
43 | 41 | ||
44 | //------------------------------------------------------------------------- | 42 | //------------------------------------------------------------------------- |
45 | 43 | ||
46 | 'name': function() { | 44 | 'name': function() { |
47 | return this.args()['name']; | 45 | return this.args()['name']; |
48 | }, | 46 | }, |
49 | 47 | ||
50 | //------------------------------------------------------------------------- | 48 | //------------------------------------------------------------------------- |
51 | 49 | ||
52 | 'type': function() { | 50 | 'type': function() { |
53 | var result; | 51 | var result; |
54 | 52 | ||
55 | result = this.args()['type']; | 53 | result = this.args()['type']; |
56 | 54 | ||
57 | if (result != null) { | 55 | if (result != null) { |
58 | result = result.toLowerCase(); | 56 | result = result.toLowerCase(); |
59 | } | 57 | } |
60 | return result; | 58 | return result; |
61 | }, | 59 | }, |
62 | 60 | ||
63 | //------------------------------------------------------------------------- | 61 | //------------------------------------------------------------------------- |
64 | 62 | ||
65 | 'options': function() { | 63 | 'options': function() { |
66 | return this.args()['options']; | 64 | return this.args()['options']; |
67 | }, | 65 | }, |
68 | 66 | ||
69 | //------------------------------------------------------------------------- | 67 | //------------------------------------------------------------------------- |
70 | 68 | ||
71 | 'value': function() { | 69 | 'value': function() { |
72 | return this.args()['value']; | 70 | return this.args()['value']; |
73 | }, | 71 | }, |
74 | 72 | ||
75 | //------------------------------------------------------------------------- | 73 | //------------------------------------------------------------------------- |
76 | /* | 74 | /* |
77 | 'formConfiguration': function(someFormValues, someBindings, someFields) { | 75 | 'formConfiguration': function(someFormValues, someBindings, someFields) { |
78 | var result; | 76 | var result; |
79 | //console.log("### DirectLoginInput.formConfiguration", someFields); | 77 | |
80 | if (this.shouldSetValue()) { | 78 | if (this.shouldSetValue()) { |
81 | switch (this.type()) { | 79 | switch (this.type()) { |
82 | case 'select': | 80 | case 'select': |
83 | var currentValue; | 81 | var currentValue; |
84 | var options; | 82 | var options; |
85 | 83 | ||
86 | // currentValue = this.directLogin()._configuration['formValues'][this.name()]; | 84 | // currentValue = this.directLogin()._configuration['formValues'][this.name()]; |
87 | currentValue = someFormValues[this.name()]; | 85 | currentValue = someFormValues[this.name()]; |
88 | options = this.args()['options']; | 86 | options = this.args()['options']; |
89 | 87 | ||
90 | result = MochiKit.DOM.SELECT({name:this.name()}, | 88 | result = MochiKit.DOM.SELECT({name:this.name()}, |
91 | MochiKit.Base.map(function(anOption) { | 89 | MochiKit.Base.map(function(anOption) { |
92 | var options; | 90 | var options; |
93 | 91 | ||
94 | options = {value:anOption['value']}; | 92 | options = {value:anOption['value']}; |
95 | if (currentValue == anOption['value']) { | 93 | if (currentValue == anOption['value']) { |
96 | options.selected = true; | 94 | options.selected = true; |
97 | } | 95 | } |
98 | 96 | ||
99 | return MochiKit.DOM.OPTION(options, anOption['label']) | 97 | return MochiKit.DOM.OPTION(options, anOption['label']) |
100 | }, options) | 98 | }, options) |
101 | ) | 99 | ) |
102 | break; | 100 | break; |
103 | case 'checkbox': | 101 | case 'checkbox': |
104 | var options; | 102 | var options; |
105 | 103 | ||
106 | options = {type:'checkbox', name: this.name()}; | 104 | options = {type:'checkbox', name: this.name()}; |
107 | // if (this.directLogin()._configuration['formValues'][this.name()] == true) { | 105 | // if (this.directLogin()._configuration['formValues'][this.name()] == true) { |
108 | if (someFormValues[this.name()] == true) { | 106 | if (someFormValues[this.name()] == true) { |
109 | options['checked'] = true; | 107 | options['checked'] = true; |
110 | }; | 108 | }; |
111 | 109 | ||
112 | result = MochiKit.DOM.INPUT(options, null); | 110 | result = MochiKit.DOM.INPUT(options, null); |
113 | break; | 111 | break; |
114 | case 'radio': | 112 | case 'radio': |
115 | var currentName; | 113 | var currentName; |
116 | var currentValue; | 114 | var currentValue; |
117 | var options; | 115 | var options; |
118 | 116 | ||
119 | currentName = this.name(); | 117 | currentName = this.name(); |
120 | // currentValue = this.directLogin()._configuration['formValues'][this.name()]; | 118 | // currentValue = this.directLogin()._configuration['formValues'][this.name()]; |
121 | currentValue = someFormValues[this.name()]; | 119 | currentValue = someFormValues[this.name()]; |
122 | options = this.args()['options']; | 120 | options = this.args()['options']; |
123 | 121 | ||
124 | result = MochiKit.DOM.DIV(null, | 122 | result = MochiKit.DOM.DIV(null, |
125 | MochiKit.Base.map(function(anOption) { | 123 | MochiKit.Base.map(function(anOption) { |
126 | var options; | 124 | var options; |
127 | var isChecked; | 125 | var isChecked; |
128 | var inputNode; | 126 | var inputNode; |
129 | var divNode; | 127 | var divNode; |
130 | 128 | ||
131 | options = {type:'radio', name:currentName, value:anOption['value']} | 129 | options = {type:'radio', name:currentName, value:anOption['value']} |
132 | isChecked = (currentValue == anOption['value']); | 130 | isChecked = (currentValue == anOption['value']); |
133 | if (isChecked) { | 131 | if (isChecked) { |
134 | options.checked = true; | 132 | options.checked = true; |
135 | } | 133 | } |
136 | 134 | ||
137 | if (Clipperz_IEisBroken == true) { | 135 | if (Clipperz_IEisBroken == true) { |
138 | var checkedValue; | 136 | var checkedValue; |
139 | 137 | ||
140 | checkedValue = (isChecked ? " CHECKED" : ""); | 138 | checkedValue = (isChecked ? " CHECKED" : ""); |
141 | inputNode = MochiKit.DOM.currentDocument().createElement("<INPUT TYPE='RADIO' NAME='" + currentName + "' VALUE='" + anOption['value'] + "'" + checkedValue + ">"); | 139 | inputNode = MochiKit.DOM.currentDocument().createElement("<INPUT TYPE='RADIO' NAME='" + currentName + "' VALUE='" + anOption['value'] + "'" + checkedValue + ">"); |
142 | } else { | 140 | } else { |
143 | inputNode = MochiKit.DOM.INPUT(options, anOption['value']); | 141 | inputNode = MochiKit.DOM.INPUT(options, anOption['value']); |
144 | } | 142 | } |
145 | divNode = MochiKit.DOM.DIV(null, inputNode); | 143 | divNode = MochiKit.DOM.DIV(null, inputNode); |
146 | 144 | ||
147 | return divNode; | 145 | return divNode; |
148 | }, options) | 146 | }, options) |
149 | ); | 147 | ); |
150 | break; | 148 | break; |
151 | } | 149 | } |
152 | } else { | 150 | } else { |
153 | var binding; | 151 | var binding; |
154 | // binding = this.directLogin().bindings()[this.name()]; | 152 | // binding = this.directLogin().bindings()[this.name()]; |
155 | binding = someBindings[this.name()]; | 153 | binding = someBindings[this.name()]; |
156 | 154 | ||
157 | //console.log("### binding", binding); | ||
158 | //if (binding != null) { | ||
159 | ///console.log(" binding.field()", binding.field()); | ||
160 | ///console.log(" binding.field().value()", binding.field().value()); | ||
161 | //console.log(" someFields[binding.fieldKey()].value()", someFields[binding.fieldKey()].value()); | ||
162 | //} | ||
163 | result = MochiKit.DOM.INPUT({ | 155 | result = MochiKit.DOM.INPUT({ |
164 | type:((this.type() != 'password') ? this.type() : 'text'), | 156 | type:((this.type() != 'password') ? this.type() : 'text'), |
165 | name:this.name(), | 157 | name:this.name(), |
166 | // value:((binding != null)? binding.field().value() : this.value()) | 158 | // value:((binding != null)? binding.field().value() : this.value()) |
167 | value:((binding != null)? someFields[binding.fieldKey()]['value'] : this.value()) | 159 | value:((binding != null)? someFields[binding.fieldKey()]['value'] : this.value()) |
168 | // value:((binding != null)? someFields[binding.fieldKey()].value() : this.value()) | 160 | // value:((binding != null)? someFields[binding.fieldKey()].value() : this.value()) |
169 | }, null); | 161 | }, null); |
170 | } | 162 | } |
171 | 163 | ||
172 | return result; | 164 | return result; |
173 | }, | 165 | }, |
174 | */ | 166 | */ |
175 | //------------------------------------------------------------------------- | 167 | //------------------------------------------------------------------------- |
176 | 168 | ||
177 | 'needsFormValue': function() { | 169 | 'needsFormValue': function() { |
178 | var type; | 170 | var type; |
179 | var result; | 171 | var result; |
180 | 172 | ||
181 | type = this.type(); | 173 | type = this.type(); |
182 | result = ((type == 'checkbox') || (type == 'radio') || (type == 'select')); | 174 | result = ((type == 'checkbox') || (type == 'radio') || (type == 'select')); |
183 | 175 | ||
184 | return result; | 176 | return result; |
185 | }, | 177 | }, |
186 | 178 | ||
187 | 'needsBinding': function() { | 179 | 'needsBinding': function() { |
188 | var type; | 180 | var type; |
189 | var result; | 181 | var result; |
190 | 182 | ||
191 | type = this.type(); | 183 | type = this.type(); |
192 | result = ((type == 'text') || (type == 'password')); | 184 | result = ((type == 'text') || (type == 'password')); |
193 | 185 | ||
194 | return result; | 186 | return result; |
195 | }, | 187 | }, |
196 | 188 | ||
197 | //------------------------------------------------------------------------- | 189 | //------------------------------------------------------------------------- |
198 | __syntaxFix__: "syntax fix" | 190 | __syntaxFix__: "syntax fix" |
199 | }); | 191 | }); |
200 | 192 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js b/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js index cdeec8b..1aa7a52 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js | |||
@@ -1,70 +1,68 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | try { if (typeof(Clipperz.KeyValueObjectStore) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.KeyValueObjectStore) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.PM.DataModel.EncryptedRemoteObject depends on Clipperz.KeyValueObjectStore!"; | 25 | throw "Clipperz.PM.DataModel.EncryptedRemoteObject depends on Clipperz.KeyValueObjectStore!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 28 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
31 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 29 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
32 | 30 | ||
33 | Clipperz.PM.DataModel.EncryptedRemoteObject = function(args) { | 31 | Clipperz.PM.DataModel.EncryptedRemoteObject = function(args) { |
34 | args = args || {}; | 32 | args = args || {}; |
35 | 33 | ||
36 | this._name = args.name || null; | 34 | this._name = args.name || null; |
37 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); | 35 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); |
38 | this._isBrandNew = ((args.reference == null) && (args.remoteData == null)); | 36 | this._isBrandNew = ((args.reference == null) && (args.remoteData == null)); |
39 | 37 | ||
40 | if ((this._isBrandNew == false) && (args['retrieveKeyFunction'] == null)) { | 38 | if ((this._isBrandNew == false) && (args['retrieveKeyFunction'] == null)) { |
41 | Clipperz.Base.exception.raise('MandatoryParameter'); | 39 | Clipperz.Base.exception.raise('MandatoryParameter'); |
42 | } else { | 40 | } else { |
43 | this._retrieveKeyFunction = args['retrieveKeyFunction']; | 41 | this._retrieveKeyFunction = args['retrieveKeyFunction']; |
44 | } | 42 | } |
45 | 43 | ||
46 | this._retrieveRemoteDataFunction = args.retrieveRemoteDataFunction|| null; | 44 | this._retrieveRemoteDataFunction = args.retrieveRemoteDataFunction|| null; |
47 | this._remoteData = args.remoteData || null; | 45 | this._remoteData = args.remoteData || null; |
48 | // this._remoteData = args.remoteData ? Clipperz.Base.deepClone(args.remoteData) : null; | 46 | // this._remoteData = args.remoteData ? Clipperz.Base.deepClone(args.remoteData) : null; |
49 | if ((!this._isBrandNew) && ((this._retrieveRemoteDataFunction == null) && (this._remoteData == null))) { | 47 | if ((!this._isBrandNew) && ((this._retrieveRemoteDataFunction == null) && (this._remoteData == null))) { |
50 | Clipperz.Base.exception.raise('MandatoryParameter'); | 48 | Clipperz.Base.exception.raise('MandatoryParameter'); |
51 | } | 49 | } |
52 | 50 | ||
53 | 51 | ||
54 | this._encryptedDataKeypath = args.encryptedDataKeypath || 'data'; //Clipperz.Base.exception.raise('MandatoryParameter'); | 52 | this._encryptedDataKeypath = args.encryptedDataKeypath || 'data'; //Clipperz.Base.exception.raise('MandatoryParameter'); |
55 | this._encryptedVersionKeypath = args.encryptedVersionKeypath || 'version';//Clipperz.Base.exception.raise('MandatoryParameter'); | 53 | this._encryptedVersionKeypath = args.encryptedVersionKeypath || 'version';//Clipperz.Base.exception.raise('MandatoryParameter'); |
56 | 54 | ||
57 | 55 | ||
58 | this._transientState = null; | 56 | this._transientState = null; |
59 | this._deferredLocks = {}; | 57 | this._deferredLocks = {}; |
60 | 58 | ||
61 | if (this._isBrandNew == true) { | 59 | if (this._isBrandNew == true) { |
62 | this._objectDataStore = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.objectDataStore [1]'}*/); | 60 | this._objectDataStore = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.objectDataStore [1]'}*/); |
63 | } else { | 61 | } else { |
64 | this._objectDataStore = null; | 62 | this._objectDataStore = null; |
65 | } | 63 | } |
66 | 64 | ||
67 | return this; | 65 | return this; |
68 | } | 66 | } |
69 | 67 | ||
70 | // | 68 | // |
@@ -366,100 +364,96 @@ Clipperz.PM.DataModel.EncryptedRemoteObject.prototype = MochiKit.Base.update(nul | |||
366 | //------------------------------------------------------------------------- | 364 | //------------------------------------------------------------------------- |
367 | 365 | ||
368 | 'getDeferredLockForKey': function (aKey) { | 366 | 'getDeferredLockForKey': function (aKey) { |
369 | var result; | 367 | var result; |
370 | 368 | ||
371 | result = this._deferredLocks[aKey]; | 369 | result = this._deferredLocks[aKey]; |
372 | 370 | ||
373 | if (typeof(result) == 'undefined') { | 371 | if (typeof(result) == 'undefined') { |
374 | result = new MochiKit.Async.DeferredLock(); | 372 | result = new MochiKit.Async.DeferredLock(); |
375 | this._deferredLocks[aKey] = result; | 373 | this._deferredLocks[aKey] = result; |
376 | } | 374 | } |
377 | 375 | ||
378 | return result; | 376 | return result; |
379 | }, | 377 | }, |
380 | 378 | ||
381 | //------------------------------------------------------------------------- | 379 | //------------------------------------------------------------------------- |
382 | 380 | ||
383 | 'unpackData': function (someData) { //++ | 381 | 'unpackData': function (someData) { //++ |
384 | return someData; | 382 | return someData; |
385 | }, | 383 | }, |
386 | 384 | ||
387 | 'packData': function (someData) { //++ | 385 | 'packData': function (someData) { //++ |
388 | return someData; | 386 | return someData; |
389 | }, | 387 | }, |
390 | 388 | ||
391 | //------------------------------------------------------------------------- | 389 | //------------------------------------------------------------------------- |
392 | 390 | ||
393 | 'hasPendingChanges': function () { | 391 | 'hasPendingChanges': function () { |
394 | var deferredResult; | 392 | var deferredResult; |
395 | var tempObj = this; | 393 | var tempObj = this; |
396 | 394 | ||
397 | if (this.isBrandNew()) { | 395 | if (this.isBrandNew()) { |
398 | // deferredResult = MochiKit.Async.succeed(true); | 396 | // deferredResult = MochiKit.Async.succeed(true); |
399 | deferredResult = this.hasPendingChangesWhenBrandNew(); | 397 | deferredResult = this.hasPendingChangesWhenBrandNew(); |
400 | } else if (this.hasInitiatedObjectDataStore()) { | 398 | } else if (this.hasInitiatedObjectDataStore()) { |
401 | deferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject.hasPendingChanges", {trace:false}); | 399 | deferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject.hasPendingChanges", {trace:false}); |
402 | deferredResult.collectResults({ | 400 | deferredResult.collectResults({ |
403 | 'decryptedData': [ | 401 | 'decryptedData': [ |
404 | MochiKit.Base.method(this, 'getDecryptedData'), | 402 | MochiKit.Base.method(this, 'getDecryptedData'), |
405 | Clipperz.Base.serializeJSON | 403 | Clipperz.Base.serializeJSON |
406 | ], | 404 | ], |
407 | 'objectData': [ | 405 | 'objectData': [ |
408 | MochiKit.Base.method(this, '_getObjectDataStore'), | 406 | MochiKit.Base.method(this, '_getObjectDataStore'), |
409 | MochiKit.Base.methodcaller('values'), | 407 | MochiKit.Base.methodcaller('values'), |
410 | Clipperz.Base.serializeJSON | 408 | Clipperz.Base.serializeJSON |
411 | ] | 409 | ] |
412 | }); | 410 | }); |
413 | deferredResult.addCallback(function (someValues) { | 411 | deferredResult.addCallback(function (someValues) { |
414 | //if (someValues['decryptedData'] != someValues['objectData']) { | ||
415 | //console.log("ORIGINAL DATA", '[[[' + someValues['decryptedData'] + ']]]'); | ||
416 | //console.log("CURRENT DATA", '>>>' + someValues['objectData'] + '<<<'); | ||
417 | //} | ||
418 | return (someValues['decryptedData'] != someValues['objectData']); | 412 | return (someValues['decryptedData'] != someValues['objectData']); |
419 | }); | 413 | }); |
420 | deferredResult.callback(); | 414 | deferredResult.callback(); |
421 | } else { | 415 | } else { |
422 | deferredResult = MochiKit.Async.succeed(false); | 416 | deferredResult = MochiKit.Async.succeed(false); |
423 | } | 417 | } |
424 | 418 | ||
425 | return deferredResult; | 419 | return deferredResult; |
426 | }, | 420 | }, |
427 | 421 | ||
428 | 'hasPendingChangesWhenBrandNew': function () { | 422 | 'hasPendingChangesWhenBrandNew': function () { |
429 | return MochiKit.Async.succeed(true); | 423 | return MochiKit.Async.succeed(true); |
430 | }, | 424 | }, |
431 | 425 | ||
432 | //------------------------------------------------------------------------- | 426 | //------------------------------------------------------------------------- |
433 | 427 | ||
434 | 'commitTransientState': function () { | 428 | 'commitTransientState': function () { |
435 | var deferredResult; | 429 | var deferredResult; |
436 | 430 | ||
437 | // if (this.transientState().getValue('__prepareRemoteData') == true) { | 431 | // if (this.transientState().getValue('__prepareRemoteData') == true) { |
438 | if (this.transientState().getValue('packedRemoteData') != null) { | 432 | if (this.transientState().getValue('packedRemoteData') != null) { |
439 | deferredResult = Clipperz.Async.callbacks("EncryptedRemoteObject.commitTransientState - prepareRemoteData", [ | 433 | deferredResult = Clipperz.Async.callbacks("EncryptedRemoteObject.commitTransientState - prepareRemoteData", [ |
440 | MochiKit.Base.bind(function (someData) { | 434 | MochiKit.Base.bind(function (someData) { |
441 | this._remoteData = this.transientState().getValue('packedRemoteData'); | 435 | this._remoteData = this.transientState().getValue('packedRemoteData'); |
442 | }, this), | 436 | }, this), |
443 | 437 | ||
444 | MochiKit.Base.method(this, '_getObjectDataStore'), | 438 | MochiKit.Base.method(this, '_getObjectDataStore'), |
445 | MochiKit.Base.methodcaller('values'), | 439 | MochiKit.Base.methodcaller('values'), |
446 | Clipperz.Base.deepClone, | 440 | Clipperz.Base.deepClone, |
447 | MochiKit.Base.method(this.decryptedDataStore(), 'setValue', 'decryptedData'), | 441 | MochiKit.Base.method(this.decryptedDataStore(), 'setValue', 'decryptedData'), |
448 | 442 | ||
449 | MochiKit.Base.method(this, 'resetTransientState', true) | 443 | MochiKit.Base.method(this, 'resetTransientState', true) |
450 | ], {trace:false}); | 444 | ], {trace:false}); |
451 | 445 | ||
452 | } else { | 446 | } else { |
453 | deferredResult = Clipperz.Async.callbacks("EncryptedRemoteObject.commitTransientState - NO prepareRemoteData", [ | 447 | deferredResult = Clipperz.Async.callbacks("EncryptedRemoteObject.commitTransientState - NO prepareRemoteData", [ |
454 | MochiKit.Base.method(this, 'resetTransientState', true) | 448 | MochiKit.Base.method(this, 'resetTransientState', true) |
455 | ], {trace:false}); | 449 | ], {trace:false}); |
456 | } | 450 | } |
457 | 451 | ||
458 | this._isBrandNew = false; | 452 | this._isBrandNew = false; |
459 | 453 | ||
460 | return deferredResult; | 454 | return deferredResult; |
461 | }, | 455 | }, |
462 | 456 | ||
463 | //------------------------------------------------------------------------- | 457 | //------------------------------------------------------------------------- |
464 | 458 | ||
465 | 'revertChanges': function () { | 459 | 'revertChanges': function () { |
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js b/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js index 834e21b..fbca1ff 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js | |||
@@ -1,70 +1,68 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 27 | ||
30 | 28 | ||
31 | //############################################################################# | 29 | //############################################################################# |
32 | 30 | ||
33 | Clipperz.PM.DataModel.OneTimePassword = function(args) { | 31 | Clipperz.PM.DataModel.OneTimePassword = function(args) { |
34 | args = args || {}; | 32 | args = args || {}; |
35 | 33 | ||
36 | //this._user = args['user']; | 34 | //this._user = args['user']; |
37 | this._reference = args['reference']|| Clipperz.PM.Crypto.randomKey(); | 35 | this._reference = args['reference']|| Clipperz.PM.Crypto.randomKey(); |
38 | this._password = args['password']; | 36 | this._password = args['password']; |
39 | this._passwordValue = Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword(args['password']); | 37 | this._passwordValue = Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword(args['password']); |
40 | this._creationDate = args['created'] ? Clipperz.PM.Date.parseDateWithUTCFormat(args['created']) : new Date(); | 38 | this._creationDate = args['created'] ? Clipperz.PM.Date.parseDateWithUTCFormat(args['created']) : new Date(); |
41 | this._usageDate = args['used'] ? Clipperz.PM.Date.parseDateWithUTCFormat(args['used']) : null; | 39 | this._usageDate = args['used'] ? Clipperz.PM.Date.parseDateWithUTCFormat(args['used']) : null; |
42 | 40 | ||
43 | this._status = args['status'] || 'ACTIVE'; //'REQUESTED', 'USED', 'DISABLED' | 41 | this._status = args['status'] || 'ACTIVE'; //'REQUESTED', 'USED', 'DISABLED' |
44 | this._connectionInfo= null; | 42 | this._connectionInfo= null; |
45 | 43 | ||
46 | this._key = null; | 44 | this._key = null; |
47 | this._keyChecksum= null; | 45 | this._keyChecksum= null; |
48 | 46 | ||
49 | return this; | 47 | return this; |
50 | } | 48 | } |
51 | 49 | ||
52 | Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, { | 50 | Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, { |
53 | 51 | ||
54 | 'toString': function() { | 52 | 'toString': function() { |
55 | return "Clipperz.PM.DataModel.OneTimePassword"; | 53 | return "Clipperz.PM.DataModel.OneTimePassword"; |
56 | }, | 54 | }, |
57 | /* | 55 | /* |
58 | //------------------------------------------------------------------------- | 56 | //------------------------------------------------------------------------- |
59 | 57 | ||
60 | 'user': function() { | 58 | 'user': function() { |
61 | return this._user; | 59 | return this._user; |
62 | }, | 60 | }, |
63 | 61 | ||
64 | //------------------------------------------------------------------------- | 62 | //------------------------------------------------------------------------- |
65 | 63 | ||
66 | 'password': function() { | 64 | 'password': function() { |
67 | return this._password; | 65 | return this._password; |
68 | }, | 66 | }, |
69 | 67 | ||
70 | //------------------------------------------------------------------------- | 68 | //------------------------------------------------------------------------- |
@@ -98,257 +96,255 @@ Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, { | |||
98 | //------------------------------------------------------------------------- | 96 | //------------------------------------------------------------------------- |
99 | 97 | ||
100 | 'keyChecksum': function() { | 98 | 'keyChecksum': function() { |
101 | if (this._keyChecksum == null) { | 99 | if (this._keyChecksum == null) { |
102 | this._keyChecksum = Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword(this.user().username(), this.passwordValue()); | 100 | this._keyChecksum = Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword(this.user().username(), this.passwordValue()); |
103 | } | 101 | } |
104 | 102 | ||
105 | return this._keyChecksum; | 103 | return this._keyChecksum; |
106 | }, | 104 | }, |
107 | */ | 105 | */ |
108 | //------------------------------------------------------------------------- | 106 | //------------------------------------------------------------------------- |
109 | 107 | ||
110 | 'status': function() { | 108 | 'status': function() { |
111 | return this._status; | 109 | return this._status; |
112 | }, | 110 | }, |
113 | 111 | ||
114 | 'setStatus': function(aValue) { | 112 | 'setStatus': function(aValue) { |
115 | this._status = aValue; | 113 | this._status = aValue; |
116 | }, | 114 | }, |
117 | 115 | ||
118 | //------------------------------------------------------------------------- | 116 | //------------------------------------------------------------------------- |
119 | /* | 117 | /* |
120 | 'serializedData': function() { | 118 | 'serializedData': function() { |
121 | var result; | 119 | var result; |
122 | 120 | ||
123 | result = { | 121 | result = { |
124 | 'password': this.password(), | 122 | 'password': this.password(), |
125 | 'created': this.creationDate() ? Clipperz.PM.Date.formatDateWithUTCFormat(this.creationDate()) : null, | 123 | 'created': this.creationDate() ? Clipperz.PM.Date.formatDateWithUTCFormat(this.creationDate()) : null, |
126 | 'used': this.usageDate() ? Clipperz.PM.Date.formatDateWithUTCFormat(this.usageDate()) : null, | 124 | 'used': this.usageDate() ? Clipperz.PM.Date.formatDateWithUTCFormat(this.usageDate()) : null, |
127 | 'status': this.status() | 125 | 'status': this.status() |
128 | }; | 126 | }; |
129 | 127 | ||
130 | return result; | 128 | return result; |
131 | }, | 129 | }, |
132 | 130 | ||
133 | //------------------------------------------------------------------------- | 131 | //------------------------------------------------------------------------- |
134 | 132 | ||
135 | 'packedPassphrase': function() { | 133 | 'packedPassphrase': function() { |
136 | var result; | 134 | var result; |
137 | var packedPassphrase; | 135 | var packedPassphrase; |
138 | var encodedPassphrase; | 136 | var encodedPassphrase; |
139 | varprefixPadding; | 137 | varprefixPadding; |
140 | var suffixPadding; | 138 | var suffixPadding; |
141 | var getRandomBytes; | 139 | var getRandomBytes; |
142 | 140 | ||
143 | getRandomBytes = MochiKit.Base.method(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'getRandomBytes'); | 141 | getRandomBytes = MochiKit.Base.method(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'getRandomBytes'); |
144 | 142 | ||
145 | encodedPassphrase = new Clipperz.ByteArray(this.user().passphrase()).toBase64String(); | 143 | encodedPassphrase = new Clipperz.ByteArray(this.user().passphrase()).toBase64String(); |
146 | //MochiKit.Logging.logDebug("--- encodedPassphrase.length: " + encodedPassphrase.length); | 144 | //Clipperz.logDebug("--- encodedPassphrase.length: " + encodedPassphrase.length); |
147 | prefixPadding = getRandomBytes(getRandomBytes(1).byteAtIndex(0)).toBase64String(); | 145 | prefixPadding = getRandomBytes(getRandomBytes(1).byteAtIndex(0)).toBase64String(); |
148 | //MochiKit.Logging.logDebug("--- prefixPadding.length: " + prefixPadding.length); | 146 | //Clipperz.logDebug("--- prefixPadding.length: " + prefixPadding.length); |
149 | suffixPadding = getRandomBytes((500 - prefixPadding.length - encodedPassphrase.length) * 6 / 8).toBase64String(); | 147 | suffixPadding = getRandomBytes((500 - prefixPadding.length - encodedPassphrase.length) * 6 / 8).toBase64String(); |
150 | //MochiKit.Logging.logDebug("--- suffixPadding.length: " + suffixPadding.length); | 148 | //Clipperz.logDebug("--- suffixPadding.length: " + suffixPadding.length); |
151 | //MochiKit.Logging.logDebug("--- total.length: " + (prefixPadding.length + encodedPassphrase.length + suffixPadding.length)); | 149 | //Clipperz.logDebug("--- total.length: " + (prefixPadding.length + encodedPassphrase.length + suffixPadding.length)); |
152 | 150 | ||
153 | packedPassphrase = { | 151 | packedPassphrase = { |
154 | 'prefix': prefixPadding, | 152 | 'prefix': prefixPadding, |
155 | 'passphrase': encodedPassphrase, | 153 | 'passphrase': encodedPassphrase, |
156 | 'suffix': suffixPadding | 154 | 'suffix': suffixPadding |
157 | }; | 155 | }; |
158 | 156 | ||
159 | // result = Clipperz.Base.serializeJSON(packedPassphrase); | 157 | // result = Clipperz.Base.serializeJSON(packedPassphrase); |
160 | result = packedPassphrase; | 158 | result = packedPassphrase; |
161 | //MochiKit.Logging.logDebug("===== OTP packedPassprase: [" + result.length + "]" + result); | 159 | //Clipperz.logDebug("===== OTP packedPassprase: [" + result.length + "]" + result); |
162 | //MochiKit.Logging.logDebug("<<< OneTimePassword.packedPassphrase"); | 160 | //Clipperz.logDebug("<<< OneTimePassword.packedPassphrase"); |
163 | 161 | ||
164 | return result; | 162 | return result; |
165 | }, | 163 | }, |
166 | 164 | ||
167 | //------------------------------------------------------------------------- | 165 | //------------------------------------------------------------------------- |
168 | 166 | ||
169 | 'encryptedPackedPassphrase': function() { | 167 | 'encryptedPackedPassphrase': function() { |
170 | return Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion(this.passwordValue(), this.packedPassphrase()) | 168 | return Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion(this.passwordValue(), this.packedPassphrase()) |
171 | }, | 169 | }, |
172 | 170 | ||
173 | //------------------------------------------------------------------------- | 171 | //------------------------------------------------------------------------- |
174 | 172 | ||
175 | 'encryptedData': function() { | 173 | 'encryptedData': function() { |
176 | var deferredResult; | 174 | var deferredResult; |
177 | varresult; | 175 | varresult; |
178 | 176 | ||
179 | //MochiKit.Logging.logDebug(">>> OneTimePassword.encryptedData"); | 177 | //Clipperz.logDebug(">>> OneTimePassword.encryptedData"); |
180 | //MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - id: " + this.reference()); | 178 | //Clipperz.logDebug("--- OneTimePassword.encryptedData - id: " + this.reference()); |
181 | result = { | 179 | result = { |
182 | 'reference': this.reference(), | 180 | 'reference': this.reference(), |
183 | 'key': this.key(), | 181 | 'key': this.key(), |
184 | 'keyChecksum': this.keyChecksum(), | 182 | 'keyChecksum': this.keyChecksum(), |
185 | 'data': "", | 183 | 'data': "", |
186 | 'version': Clipperz.PM.Crypto.encryptingFunctions.currentVersion | 184 | 'version': Clipperz.PM.Crypto.encryptingFunctions.currentVersion |
187 | } | 185 | } |
188 | //MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 2: " + Clipperz.Base.serializeJSON(result)); | 186 | //Clipperz.logDebug("--- OneTimePassword.encryptedData - 2: " + Clipperz.Base.serializeJSON(result)); |
189 | deferredResult = new MochiKit.Async.Deferred(); | 187 | deferredResult = new MochiKit.Async.Deferred(); |
190 | //MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 3"); | 188 | //Clipperz.logDebug("--- OneTimePassword.encryptedData - 3"); |
191 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.encryptedData - 1: " + res); return res;}); | 189 | //deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.encryptedData - 1: " + res); return res;}); |
192 | //# deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion, this.passwordValue(), this.packedPassphrase()); | 190 | //# deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion, this.passwordValue(), this.packedPassphrase()); |
193 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedPackedPassphrase')); | 191 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedPackedPassphrase')); |
194 | //MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 4"); | 192 | //Clipperz.logDebug("--- OneTimePassword.encryptedData - 4"); |
195 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.encryptedData - 2: [" + res.length + "]" + res); return res;}); | 193 | //deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.encryptedData - 2: [" + res.length + "]" + res); return res;}); |
196 | deferredResult.addCallback(function(aResult, res) { | 194 | deferredResult.addCallback(function(aResult, res) { |
197 | aResult['data'] = res; | 195 | aResult['data'] = res; |
198 | return aResult; | 196 | return aResult; |
199 | }, result); | 197 | }, result); |
200 | //MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 5"); | 198 | //Clipperz.logDebug("--- OneTimePassword.encryptedData - 5"); |
201 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.encryptedData - 3: " + Clipperz.Base.serializeJSON(res)); return res;}); | 199 | //deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.encryptedData - 3: " + Clipperz.Base.serializeJSON(res)); return res;}); |
202 | deferredResult.callback(); | 200 | deferredResult.callback(); |
203 | //MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 6"); | 201 | //Clipperz.logDebug("--- OneTimePassword.encryptedData - 6"); |
204 | 202 | ||
205 | return deferredResult; | 203 | return deferredResult; |
206 | }, | 204 | }, |
207 | 205 | ||
208 | //------------------------------------------------------------------------- | 206 | //------------------------------------------------------------------------- |
209 | 207 | ||
210 | 'saveChanges': function() { | 208 | 'saveChanges': function() { |
211 | var deferredResult; | 209 | var deferredResult; |
212 | varresult; | 210 | varresult; |
213 | 211 | ||
214 | //MochiKit.Logging.logDebug(">>> OneTimePassword.saveChanges"); | 212 | //Clipperz.logDebug(">>> OneTimePassword.saveChanges"); |
215 | result = {}; | 213 | result = {}; |
216 | deferredResult = new MochiKit.Async.Deferred(); | 214 | deferredResult = new MochiKit.Async.Deferred(); |
217 | 215 | ||
218 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_encryptUserData'); | 216 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_encryptUserData'); |
219 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'encryptedData')); | 217 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'encryptedData')); |
220 | deferredResult.addCallback(function(aResult, res) { | 218 | deferredResult.addCallback(function(aResult, res) { |
221 | aResult['user'] = res; | 219 | aResult['user'] = res; |
222 | return aResult; | 220 | return aResult; |
223 | }, result); | 221 | }, result); |
224 | 222 | ||
225 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_encryptOTPData'); | 223 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_encryptOTPData'); |
226 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); | 224 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); |
227 | deferredResult.addCallback(function(aResult, res) { | 225 | deferredResult.addCallback(function(aResult, res) { |
228 | aResult['oneTimePassword'] = res; | 226 | aResult['oneTimePassword'] = res; |
229 | return aResult; | 227 | return aResult; |
230 | }, result); | 228 | }, result); |
231 | 229 | ||
232 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_sendingData'); | 230 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_sendingData'); |
233 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.saveChanges - 1: " + Clipperz.Base.serializeJSON(res)); return res;}); | 231 | //deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.saveChanges - 1: " + Clipperz.Base.serializeJSON(res)); return res;}); |
234 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewOneTimePassword'); | 232 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewOneTimePassword'); |
235 | 233 | ||
236 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_updatingInterface'); | 234 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_updatingInterface'); |
237 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;}); | 235 | //deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;}); |
238 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'OTPUpdated'); | 236 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'OTPUpdated'); |
239 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'oneTimePassword_saveChanges_done', null); | 237 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'oneTimePassword_saveChanges_done', null); |
240 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;}); | 238 | //deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;}); |
241 | deferredResult.callback(); | 239 | deferredResult.callback(); |
242 | //MochiKit.Logging.logDebug("<<< OneTimePassword.saveChanges"); | 240 | //Clipperz.logDebug("<<< OneTimePassword.saveChanges"); |
243 | 241 | ||
244 | return deferredResult; | 242 | return deferredResult; |
245 | }, | 243 | }, |
246 | 244 | ||
247 | //------------------------------------------------------------------------- | 245 | //------------------------------------------------------------------------- |
248 | 246 | ||
249 | 'usageDate': function() { | 247 | 'usageDate': function() { |
250 | return this._usageDate; | 248 | return this._usageDate; |
251 | }, | 249 | }, |
252 | 250 | ||
253 | 'setUsageDate': function(aValue) { | 251 | 'setUsageDate': function(aValue) { |
254 | this._usageDate = aValue; | 252 | this._usageDate = aValue; |
255 | }, | 253 | }, |
256 | 254 | ||
257 | //------------------------------------------------------------------------- | 255 | //------------------------------------------------------------------------- |
258 | 256 | ||
259 | 'connectionInfo': function() { | 257 | 'connectionInfo': function() { |
260 | return this._connectionInfo; | 258 | return this._connectionInfo; |
261 | }, | 259 | }, |
262 | 260 | ||
263 | 'setConnectionInfo': function(aValue) { | 261 | 'setConnectionInfo': function(aValue) { |
264 | this._connectionInfo = aValue; | 262 | this._connectionInfo = aValue; |
265 | }, | 263 | }, |
266 | 264 | ||
267 | //------------------------------------------------------------------------- | 265 | //------------------------------------------------------------------------- |
268 | 266 | ||
269 | 'isExpired': function() { | 267 | 'isExpired': function() { |
270 | return (this.usageDate() != null); | 268 | return (this.usageDate() != null); |
271 | }, | 269 | }, |
272 | 270 | ||
273 | //------------------------------------------------------------------------- | 271 | //------------------------------------------------------------------------- |
274 | 272 | ||
275 | 'updateStatusWithValues': function(someValues) { | 273 | 'updateStatusWithValues': function(someValues) { |
276 | var result; | 274 | var result; |
277 | 275 | ||
278 | result = false; | 276 | result = false; |
279 | 277 | ||
280 | if (someValues['status'] != this.status()) { | 278 | if (someValues['status'] != this.status()) { |
281 | result = true; | 279 | result = true; |
282 | } | 280 | } |
283 | 281 | ||
284 | this.setStatus(someValues['status']); | 282 | this.setStatus(someValues['status']); |
285 | this.setUsageDate(Clipperz.PM.Date.parseDateWithUTCFormat(someValues['requestDate'])); | 283 | this.setUsageDate(Clipperz.PM.Date.parseDateWithUTCFormat(someValues['requestDate'])); |
286 | this.setConnectionInfo(someValues['connection']); | 284 | this.setConnectionInfo(someValues['connection']); |
287 | 285 | ||
288 | return result; | 286 | return result; |
289 | }, | 287 | }, |
290 | */ | 288 | */ |
291 | //------------------------------------------------------------------------- | 289 | //------------------------------------------------------------------------- |
292 | __syntaxFix__: "syntax fix" | 290 | __syntaxFix__: "syntax fix" |
293 | }); | 291 | }); |
294 | 292 | ||
295 | //############################################################################# | 293 | //############################################################################# |
296 | 294 | ||
297 | Clipperz.PM.DataModel.OneTimePassword.computeKeyWithUsernameAndPassword = function(anUsername, aPassword) { | 295 | Clipperz.PM.DataModel.OneTimePassword.computeKeyWithUsernameAndPassword = function(anUsername, aPassword) { |
298 | return Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aPassword)).toHexString().substring(2); | 296 | return Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aPassword)).toHexString().substring(2); |
299 | } | 297 | } |
300 | 298 | ||
301 | Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword = function(anUsername, aPassword) { | 299 | Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword = function(anUsername, aPassword) { |
302 | return Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(anUsername + aPassword)).toHexString().substring(2); | 300 | return Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(anUsername + aPassword)).toHexString().substring(2); |
303 | } | 301 | } |
304 | 302 | ||
305 | //============================================================================= | 303 | //============================================================================= |
306 | 304 | ||
307 | Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue = function(aPassword) { | 305 | Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue = function(aPassword) { |
308 | var result; | 306 | var result; |
309 | 307 | ||
310 | //"yaxx k7ww - f8y6 tqz5 - 58b6 th44 - 9cwv q0fg" | 308 | //"yaxx k7ww - f8y6 tqz5 - 58b6 th44 - 9cwv q0fg" |
311 | //console.log("Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue", aPassword); | ||
312 | if (aPassword.replace(/[\s\-]/g, '').length == 32) { | 309 | if (aPassword.replace(/[\s\-]/g, '').length == 32) { |
313 | try { | 310 | try { |
314 | var passwordByteArray; | 311 | var passwordByteArray; |
315 | 312 | ||
316 | passwordByteArray = new Clipperz.ByteArray(); | 313 | passwordByteArray = new Clipperz.ByteArray(); |
317 | passwordByteArray.appendBase32String(aPassword); | 314 | passwordByteArray.appendBase32String(aPassword); |
318 | 315 | ||
319 | result = true; | 316 | result = true; |
320 | } catch(exception) { | 317 | } catch(exception) { |
321 | result = false; | 318 | result = false; |
322 | } | 319 | } |
323 | } else { | 320 | } else { |
324 | result = false; | 321 | result = false; |
325 | } | 322 | } |
326 | 323 | ||
327 | return result; | 324 | return result; |
328 | } | 325 | } |
329 | 326 | ||
330 | //============================================================================= | 327 | //============================================================================= |
331 | 328 | ||
332 | Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword = function(aPassword) { | 329 | Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword = function(aPassword) { |
333 | varresult; | 330 | varresult; |
334 | 331 | ||
335 | if (aPassword.replace(/[\s\-]/g, '').length == 32) { | 332 | if (aPassword.replace(/[\s\-]/g, '').length == 32) { |
336 | try { | 333 | try { |
337 | var passwordByteArray; | 334 | var passwordByteArray; |
338 | 335 | ||
339 | passwordByteArray = new Clipperz.ByteArray(); | 336 | passwordByteArray = new Clipperz.ByteArray(); |
340 | passwordByteArray.appendBase32String(aPassword); | 337 | passwordByteArray.appendBase32String(aPassword); |
341 | 338 | ||
342 | result = passwordByteArray.toBase64String(); | 339 | result = passwordByteArray.toBase64String(); |
343 | } catch(exception) { | 340 | } catch(exception) { |
344 | result = aPassword; | 341 | result = aPassword; |
345 | } | 342 | } |
346 | } else { | 343 | } else { |
347 | result = aPassword; | 344 | result = aPassword; |
348 | } | 345 | } |
349 | 346 | ||
350 | //console.log("Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword", aPassword, result); | ||
351 | return result; | 347 | return result; |
352 | } | 348 | } |
353 | 349 | ||
354 | //############################################################################# | 350 | //############################################################################# |
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.Field.js b/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.Field.js index f51bbc2..986db40 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.Field.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.Field.js | |||
@@ -1,70 +1,68 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | try { if (typeof(Clipperz.PM.DataModel.Record.Version) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.PM.DataModel.Record.Version) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.PM.DataModel.Record.Version.Field depends on Clipperz.PM.DataModel.Record.Version!"; | 25 | throw "Clipperz.PM.DataModel.Record.Version.Field depends on Clipperz.PM.DataModel.Record.Version!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | Clipperz.PM.DataModel.Record.Version.Field = function(args) { | 28 | Clipperz.PM.DataModel.Record.Version.Field = function(args) { |
31 | Clipperz.PM.DataModel.Record.Version.Field.superclass.constructor.apply(this, arguments); | 29 | Clipperz.PM.DataModel.Record.Version.Field.superclass.constructor.apply(this, arguments); |
32 | 30 | ||
33 | this._recordVersion = args.recordVersion|| Clipperz.Base.exception.raise('MandatoryParameter'); | 31 | this._recordVersion = args.recordVersion|| Clipperz.Base.exception.raise('MandatoryParameter'); |
34 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); | 32 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); |
35 | 33 | ||
36 | return this; | 34 | return this; |
37 | } | 35 | } |
38 | 36 | ||
39 | 37 | ||
40 | Clipperz.Base.extend(Clipperz.PM.DataModel.Record.Version.Field, Object, { | 38 | Clipperz.Base.extend(Clipperz.PM.DataModel.Record.Version.Field, Object, { |
41 | 39 | ||
42 | 'toString': function() { | 40 | 'toString': function() { |
43 | return "Record.Version.Field (" + this.reference() + ")"; | 41 | return "Record.Version.Field (" + this.reference() + ")"; |
44 | }, | 42 | }, |
45 | 43 | ||
46 | //------------------------------------------------------------------------- | 44 | //------------------------------------------------------------------------- |
47 | 45 | ||
48 | 'recordVersion': function () { | 46 | 'recordVersion': function () { |
49 | return this._recordVersion; | 47 | return this._recordVersion; |
50 | }, | 48 | }, |
51 | 49 | ||
52 | //------------------------------------------------------------------------- | 50 | //------------------------------------------------------------------------- |
53 | 51 | ||
54 | 'reference': function () { | 52 | 'reference': function () { |
55 | return this._reference; | 53 | return this._reference; |
56 | }, | 54 | }, |
57 | 55 | ||
58 | //------------------------------------------------------------------------- | 56 | //------------------------------------------------------------------------- |
59 | 57 | ||
60 | 'getItem': function (aKey) { | 58 | 'getItem': function (aKey) { |
61 | return Clipperz.Async.callbacks("Clipperz.PM.DataModel.Record.Version.Field.getItem", [ | 59 | return Clipperz.Async.callbacks("Clipperz.PM.DataModel.Record.Version.Field.getItem", [ |
62 | MochiKit.Base.method(this, 'recordVersion'), | 60 | MochiKit.Base.method(this, 'recordVersion'), |
63 | MochiKit.Base.methodcaller('getValue', 'fields' + '.' + this.reference() + '.' + aKey) | 61 | MochiKit.Base.methodcaller('getValue', 'fields' + '.' + this.reference() + '.' + aKey) |
64 | ], {trace:false}); | 62 | ], {trace:false}); |
65 | }, | 63 | }, |
66 | 64 | ||
67 | 'setItem': function (aKey, aValue) { | 65 | 'setItem': function (aKey, aValue) { |
68 | return Clipperz.Async.callbacks("Clipperz.PM.DataModel.Record.Version.Field.getItem", [ | 66 | return Clipperz.Async.callbacks("Clipperz.PM.DataModel.Record.Version.Field.getItem", [ |
69 | MochiKit.Base.method(this, 'recordVersion'), | 67 | MochiKit.Base.method(this, 'recordVersion'), |
70 | MochiKit.Base.methodcaller('setValue', 'fields' + '.' + this.reference() + '.' + aKey, aValue) | 68 | MochiKit.Base.methodcaller('setValue', 'fields' + '.' + this.reference() + '.' + aKey, aValue) |
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.js b/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.js index dd35fc9..87b319c 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.js | |||
@@ -1,150 +1,146 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | try { if (typeof(Clipperz.PM.DataModel.Record) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.PM.DataModel.Record) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.PM.DataModel.Record.Version depends on Clipperz.PM.DataModel.Record!"; | 25 | throw "Clipperz.PM.DataModel.Record.Version depends on Clipperz.PM.DataModel.Record!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | Clipperz.PM.DataModel.Record.Version = function(args) { | 28 | Clipperz.PM.DataModel.Record.Version = function(args) { |
31 | //console.log(">>> Record.new"); | ||
32 | Clipperz.PM.DataModel.Record.Version.superclass.constructor.apply(this, arguments); | 29 | Clipperz.PM.DataModel.Record.Version.superclass.constructor.apply(this, arguments); |
33 | 30 | ||
34 | this._getVersionFunction = args.getVersion|| Clipperz.Base.exception.raise('MandatoryParameter'); | 31 | this._getVersionFunction = args.getVersion|| Clipperz.Base.exception.raise('MandatoryParameter'); |
35 | this._fields = null; | 32 | this._fields = null; |
36 | 33 | ||
37 | return this; | 34 | return this; |
38 | } | 35 | } |
39 | 36 | ||
40 | 37 | ||
41 | Clipperz.Base.extend(Clipperz.PM.DataModel.Record.Version, Clipperz.PM.DataModel.EncryptedRemoteObject, { | 38 | Clipperz.Base.extend(Clipperz.PM.DataModel.Record.Version, Clipperz.PM.DataModel.EncryptedRemoteObject, { |
42 | 39 | ||
43 | 'toString': function() { | 40 | 'toString': function() { |
44 | return "Record.Version (" + this.reference() + ")"; | 41 | return "Record.Version (" + this.reference() + ")"; |
45 | }, | 42 | }, |
46 | 43 | ||
47 | //------------------------------------------------------------------------- | 44 | //------------------------------------------------------------------------- |
48 | 45 | ||
49 | 'reference': function () { | 46 | 'reference': function () { |
50 | return this._reference; | 47 | return this._reference; |
51 | }, | 48 | }, |
52 | 49 | ||
53 | //------------------------------------------------------------------------- | 50 | //------------------------------------------------------------------------- |
54 | /* | 51 | /* |
55 | 'hasPendingChanges': function () { | 52 | 'hasPendingChanges': function () { |
56 | var deferredResult; | 53 | var deferredResult; |
57 | 54 | ||
58 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.Version.hasPendingChanges", {trace:false}); | 55 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.Version.hasPendingChanges", {trace:false}); |
59 | deferredResult.addCallback(MochiKit.Base.bind(Clipperz.PM.DataModel.Record.Version.superclass.hasPendingChanges, this)); | 56 | deferredResult.addCallback(MochiKit.Base.bind(Clipperz.PM.DataModel.Record.Version.superclass.hasPendingChanges, this)); |
60 | deferredResult.callback(); | 57 | deferredResult.callback(); |
61 | 58 | ||
62 | return deferredResult; | 59 | return deferredResult; |
63 | }, | 60 | }, |
64 | */ | 61 | */ |
65 | //------------------------------------------------------------------------- | 62 | //------------------------------------------------------------------------- |
66 | 63 | ||
67 | 64 | ||
68 | 'hasPendingChangesWhenBrandNew': function () { | 65 | 'hasPendingChangesWhenBrandNew': function () { |
69 | var deferredResult; | 66 | var deferredResult; |
70 | 67 | ||
71 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.Version.hasPendingChangesWhenBrandNew", {trace:false}); | 68 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.Version.hasPendingChangesWhenBrandNew", {trace:false}); |
72 | deferredResult.addMethod(this, 'fields'); | 69 | deferredResult.addMethod(this, 'fields'); |
73 | deferredResult.addCallback(MochiKit.Base.values); | 70 | deferredResult.addCallback(MochiKit.Base.values); |
74 | deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.methodcaller('isEmpty')) | 71 | deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.methodcaller('isEmpty')) |
75 | deferredResult.addCallback(Clipperz.Async.collectAll); | 72 | deferredResult.addCallback(Clipperz.Async.collectAll); |
76 | deferredResult.addCallback(function(someValues) { | 73 | deferredResult.addCallback(function(someValues) { |
77 | return MochiKit.Iter.every(someValues, MochiKit.Base.operator.identity); | 74 | return MochiKit.Iter.every(someValues, MochiKit.Base.operator.identity); |
78 | }); | 75 | }); |
79 | deferredResult.addCallback(MochiKit.Base.operator.lognot) | 76 | deferredResult.addCallback(MochiKit.Base.operator.lognot) |
80 | deferredResult.callback(); | 77 | deferredResult.callback(); |
81 | 78 | ||
82 | return deferredResult; | 79 | return deferredResult; |
83 | }, | 80 | }, |
84 | 81 | ||
85 | //========================================================================= | 82 | //========================================================================= |
86 | 83 | ||
87 | 'commitTransientState': function () { | 84 | 'commitTransientState': function () { |
88 | var deferredResult; | 85 | var deferredResult; |
89 | 86 | ||
90 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.Version.commitTransientState", {trace:false}); | 87 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.Version.commitTransientState", {trace:false}); |
91 | deferredResult.addCallback(MochiKit.Base.bind(Clipperz.PM.DataModel.Record.Version.superclass.commitTransientState, this)); | 88 | deferredResult.addCallback(MochiKit.Base.bind(Clipperz.PM.DataModel.Record.Version.superclass.commitTransientState, this)); |
92 | deferredResult.callback(); | 89 | deferredResult.callback(); |
93 | 90 | ||
94 | return deferredResult; | 91 | return deferredResult; |
95 | }, | 92 | }, |
96 | 93 | ||
97 | //========================================================================= | 94 | //========================================================================= |
98 | 95 | ||
99 | 'unpackData': function (someData) { //++ | 96 | 'unpackData': function (someData) { //++ |
100 | varresult; | 97 | varresult; |
101 | 98 | ||
102 | //console.log("Record.Version - UNPACK DATA", this, someData); | ||
103 | result = someData; | 99 | result = someData; |
104 | if ((someData['fields'] != null) && (someData['fields'] instanceof Array)) { | 100 | if ((someData['fields'] != null) && (someData['fields'] instanceof Array)) { |
105 | varfields; | 101 | varfields; |
106 | var i,c; | 102 | var i,c; |
107 | 103 | ||
108 | fields = someData['fields']; | 104 | fields = someData['fields']; |
109 | delete someData['fields']; | 105 | delete someData['fields']; |
110 | 106 | ||
111 | someData['fields'] = {}; | 107 | someData['fields'] = {}; |
112 | c = fields.length; | 108 | c = fields.length; |
113 | for (i=0; i<c; i++) { | 109 | for (i=0; i<c; i++) { |
114 | someData['fields'][i] = fields[i]; | 110 | someData['fields'][i] = fields[i]; |
115 | } | 111 | } |
116 | } | 112 | } |
117 | 113 | ||
118 | 114 | ||
119 | 115 | ||
120 | return result; | 116 | return result; |
121 | }, | 117 | }, |
122 | 118 | ||
123 | //========================================================================= | 119 | //========================================================================= |
124 | 120 | ||
125 | 'fields': function () { | 121 | 'fields': function () { |
126 | vardeferredResult; | 122 | vardeferredResult; |
127 | var deferredLock; | 123 | var deferredLock; |
128 | 124 | ||
129 | deferredLock = this.getDeferredLockForKey('fields'); | 125 | deferredLock = this.getDeferredLockForKey('fields'); |
130 | 126 | ||
131 | deferredResult = new Clipperz.Async.Deferred("Record.Version.fields", {trace:false}); | 127 | deferredResult = new Clipperz.Async.Deferred("Record.Version.fields", {trace:false}); |
132 | deferredResult.acquireLock(deferredLock); | 128 | deferredResult.acquireLock(deferredLock); |
133 | deferredResult.addCallback(MochiKit.Base.bind(function () { | 129 | deferredResult.addCallback(MochiKit.Base.bind(function () { |
134 | var innerDeferredResult; | 130 | var innerDeferredResult; |
135 | 131 | ||
136 | if (this._fields == null) { | 132 | if (this._fields == null) { |
137 | innerDeferredResult = new Clipperz.Async.Deferred("Record.Version.fields <inner deferred>", {trace:false}); | 133 | innerDeferredResult = new Clipperz.Async.Deferred("Record.Version.fields <inner deferred>", {trace:false}); |
138 | innerDeferredResult.addMethod(this, 'getValue', 'fields'); | 134 | innerDeferredResult.addMethod(this, 'getValue', 'fields'); |
139 | innerDeferredResult.addCallback(MochiKit.Base.bind(function (someObjectData) { | 135 | innerDeferredResult.addCallback(MochiKit.Base.bind(function (someObjectData) { |
140 | var reference; | 136 | var reference; |
141 | 137 | ||
142 | this._fields = {}; | 138 | this._fields = {}; |
143 | 139 | ||
144 | for (reference in someObjectData) { | 140 | for (reference in someObjectData) { |
145 | varrecordVersionField; | 141 | varrecordVersionField; |
146 | 142 | ||
147 | recordVersionField = new Clipperz.PM.DataModel.Record.Version.Field({ | 143 | recordVersionField = new Clipperz.PM.DataModel.Record.Version.Field({ |
148 | 'recordVersion':this, | 144 | 'recordVersion':this, |
149 | 'reference': reference | 145 | 'reference': reference |
150 | }); | 146 | }); |
@@ -247,87 +243,86 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record.Version, Clipperz.PM.DataModel | |||
247 | 243 | ||
248 | //========================================================================= | 244 | //========================================================================= |
249 | 245 | ||
250 | 'getVersionFunction': function () { | 246 | 'getVersionFunction': function () { |
251 | return this._getVersionFunction; | 247 | return this._getVersionFunction; |
252 | }, | 248 | }, |
253 | 249 | ||
254 | 'previousVersion': function () { | 250 | 'previousVersion': function () { |
255 | return Clipperz.Async.callbacks("Record.Versions.previousVersion", [ | 251 | return Clipperz.Async.callbacks("Record.Versions.previousVersion", [ |
256 | MochiKit.Base.method(this, 'previousVersionReference'), | 252 | MochiKit.Base.method(this, 'previousVersionReference'), |
257 | this.getVersionFunction() | 253 | this.getVersionFunction() |
258 | ], {trace:false}); | 254 | ], {trace:false}); |
259 | }, | 255 | }, |
260 | 256 | ||
261 | 'previousVersionReference': function () { | 257 | 'previousVersionReference': function () { |
262 | return this.getValue('previousVersionReference'); | 258 | return this.getValue('previousVersionReference'); |
263 | }, | 259 | }, |
264 | 260 | ||
265 | 'previousVersionKey': function () { | 261 | 'previousVersionKey': function () { |
266 | //TODO: this value i encrypted on its own. So it can not be saved in the main objectStore!!! | 262 | //TODO: this value i encrypted on its own. So it can not be saved in the main objectStore!!! |
267 | return this.getValue('previousVersionKey'); | 263 | return this.getValue('previousVersionKey'); |
268 | }, | 264 | }, |
269 | 265 | ||
270 | //------------------------------------------------------------------------- | 266 | //------------------------------------------------------------------------- |
271 | 267 | ||
272 | 'setPreviousVersionReferenceAndKey': function (aVersionObjectAndKey) { | 268 | 'setPreviousVersionReferenceAndKey': function (aVersionObjectAndKey) { |
273 | // this._previousVersion = anotherVersion; | 269 | // this._previousVersion = anotherVersion; |
274 | return Clipperz.Async.callbacks("Record.Version.setPreviousVersion", [ | 270 | return Clipperz.Async.callbacks("Record.Version.setPreviousVersion", [ |
275 | MochiKit.Base.method(this, 'setValue', 'previousVersionReference',aVersionObjectAndKey['reference']), | 271 | MochiKit.Base.method(this, 'setValue', 'previousVersionReference',aVersionObjectAndKey['reference']), |
276 | MochiKit.Base.method(this, 'setValue', 'previousVersionKey', aVersionObjectAndKey['key']) | 272 | MochiKit.Base.method(this, 'setValue', 'previousVersionKey', aVersionObjectAndKey['key']) |
277 | ], {trace:false}); | 273 | ], {trace:false}); |
278 | }, | 274 | }, |
279 | 275 | ||
280 | //========================================================================= | 276 | //========================================================================= |
281 | 277 | ||
282 | 'revertChanges': function () { | 278 | 'revertChanges': function () { |
283 | this.setReference(this.transientState()['originalReference']); | 279 | this.setReference(this.transientState()['originalReference']); |
284 | Clipperz.PM.DataModel.Record.Version.superclass.revertChanges.apply(this, arguments); | 280 | Clipperz.PM.DataModel.Record.Version.superclass.revertChanges.apply(this, arguments); |
285 | }, | 281 | }, |
286 | 282 | ||
287 | //------------------------------------------------------------------------- | 283 | //------------------------------------------------------------------------- |
288 | 284 | ||
289 | 'prepareRemoteDataWithKey': function (aKey) { | 285 | 'prepareRemoteDataWithKey': function (aKey) { |
290 | var deferredResult; | 286 | var deferredResult; |
291 | var result; | 287 | var result; |
292 | 288 | ||
293 | result = {}; | 289 | result = {}; |
294 | 290 | ||
295 | //console.log("prepareRemoteDataWithKey", aKey); | ||
296 | deferredResult = new Clipperz.Async.Deferred("Record.Version.prepareRemoteDataWithKey", {trace:false}); | 291 | deferredResult = new Clipperz.Async.Deferred("Record.Version.prepareRemoteDataWithKey", {trace:false}); |
297 | if (this.isBrandNew() == false) { | 292 | if (this.isBrandNew() == false) { |
298 | this.transientState()['originalReference'] = this.reference(); | 293 | this.transientState()['originalReference'] = this.reference(); |
299 | 294 | ||
300 | deferredResult.collectResults({ | 295 | deferredResult.collectResults({ |
301 | 'key':MochiKit.Base.partial(MochiKit.Async.succeed, aKey), | 296 | 'key':MochiKit.Base.partial(MochiKit.Async.succeed, aKey), |
302 | 'value': MochiKit.Base.method(this, 'getKey'), | 297 | 'value': MochiKit.Base.method(this, 'getKey'), |
303 | 'version': MochiKit.Base.partial(MochiKit.Async.succeed, Clipperz.PM.Crypto.encryptingFunctions.currentVersion) | 298 | 'version': MochiKit.Base.partial(MochiKit.Async.succeed, Clipperz.PM.Crypto.encryptingFunctions.currentVersion) |
304 | }); | 299 | }); |
305 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncrypt); | 300 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncrypt); |
306 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'previousVersionKey'); | 301 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'previousVersionKey'); |
307 | } else { | 302 | } else { |
308 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'previousVersionKey', Clipperz.PM.Crypto.nullValue); | 303 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'previousVersionKey', Clipperz.PM.Crypto.nullValue); |
309 | } | 304 | } |
310 | deferredResult.addCallback(MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.prepareRemoteDataWithKey, this, aKey)); | 305 | deferredResult.addCallback(MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.prepareRemoteDataWithKey, this, aKey)); |
311 | deferredResult.addCallback(MochiKit.Base.update, result); | 306 | deferredResult.addCallback(MochiKit.Base.update, result); |
312 | deferredResult.addMethod(this, 'setRemoteData'); | 307 | deferredResult.addMethod(this, 'setRemoteData'); |
313 | 308 | ||
314 | deferredResult.callback(); | 309 | deferredResult.callback(); |
315 | 310 | ||
316 | return deferredResult; | 311 | return deferredResult; |
317 | }, | 312 | }, |
318 | 313 | ||
319 | //========================================================================= | 314 | //========================================================================= |
320 | /* | 315 | /* |
321 | 'deleteAllCleanTextData': function () { | 316 | 'deleteAllCleanTextData': function () { |
322 | return Clipperz.PM.DataModel.Record.Version.superclass.deleteAllCleanTextData.apply(this, arguments); | 317 | return Clipperz.PM.DataModel.Record.Version.superclass.deleteAllCleanTextData.apply(this, arguments); |
323 | }, | 318 | }, |
324 | 319 | ||
325 | 'hasAnyCleanTextData': function () { | 320 | 'hasAnyCleanTextData': function () { |
326 | return Clipperz.PM.DataModel.Record.Version.superclass.hasAnyCleanTextData.apply(this, arguments); | 321 | return Clipperz.PM.DataModel.Record.Version.superclass.hasAnyCleanTextData.apply(this, arguments); |
327 | }, | 322 | }, |
328 | */ | 323 | */ |
329 | //========================================================================= | 324 | //========================================================================= |
330 | __syntaxFix__: "syntax fix" | 325 | __syntaxFix__: "syntax fix" |
331 | }); | 326 | }); |
332 | 327 | ||
333 | 328 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/Record.js b/frontend/gamma/js/Clipperz/PM/DataModel/Record.js index b816f80..3fc1813 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/Record.js | |||
@@ -1,114 +1,109 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 27 | ||
30 | 28 | ||
31 | Clipperz.PM.DataModel.Record = function(args) { | 29 | Clipperz.PM.DataModel.Record = function(args) { |
32 | //console.log(">>> new Clipperz.PM.DataModel.Record", args); | ||
33 | Clipperz.PM.DataModel.Record.superclass.constructor.apply(this, arguments); | 30 | Clipperz.PM.DataModel.Record.superclass.constructor.apply(this, arguments); |
34 | 31 | ||
35 | this._updateDate = (args.updateDate ? Clipperz.PM.Date.parse(args.updateDate) : Clipperz.Base.exception.raise('MandatoryParameter')); | 32 | this._updateDate = (args.updateDate ? Clipperz.PM.Date.parse(args.updateDate) : Clipperz.Base.exception.raise('MandatoryParameter')); |
36 | 33 | ||
37 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); | 34 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); |
38 | this._updateIndexDataFunction = args.updateIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter'); | 35 | this._updateIndexDataFunction = args.updateIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter'); |
39 | 36 | ||
40 | this._retrieveDirectLoginIndexDataFunction = args.retrieveDirectLoginIndexDataFunction|| null; | 37 | this._retrieveDirectLoginIndexDataFunction = args.retrieveDirectLoginIndexDataFunction|| null; |
41 | this._setDirectLoginIndexDataFunction = args.setDirectLoginIndexDataFunction || null; | 38 | this._setDirectLoginIndexDataFunction = args.setDirectLoginIndexDataFunction || null; |
42 | this._removeDirectLoginIndexDataFunction = args.removeDirectLoginIndexDataFunction|| null; | 39 | this._removeDirectLoginIndexDataFunction = args.removeDirectLoginIndexDataFunction|| null; |
43 | 40 | ||
44 | this._createNewDirectLoginFunction = args.createNewDirectLoginFunction || null; | 41 | this._createNewDirectLoginFunction = args.createNewDirectLoginFunction || null; |
45 | 42 | ||
46 | this._directLogins = {}; | 43 | this._directLogins = {}; |
47 | 44 | ||
48 | this._versions = {}; | 45 | this._versions = {}; |
49 | 46 | ||
50 | this._currentRecordVersion = null; | 47 | this._currentRecordVersion = null; |
51 | if (this.isBrandNew()) { | 48 | if (this.isBrandNew()) { |
52 | var newVersion; | 49 | var newVersion; |
53 | 50 | ||
54 | this.setNotes(''); | 51 | this.setNotes(''); |
55 | newVersion = new Clipperz.PM.DataModel.Record.Version({ | 52 | newVersion = new Clipperz.PM.DataModel.Record.Version({ |
56 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), | 53 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), |
57 | 'getVersion': MochiKit.Base.method(this, 'getVersion') | 54 | 'getVersion': MochiKit.Base.method(this, 'getVersion') |
58 | 55 | ||
59 | }); | 56 | }); |
60 | this._versions[newVersion.reference()] = newVersion; | 57 | this._versions[newVersion.reference()] = newVersion; |
61 | this._currentVersionReference = newVersion.reference(); | 58 | this._currentVersionReference = newVersion.reference(); |
62 | // this.setLabel(''); | 59 | // this.setLabel(''); |
63 | } | 60 | } |
64 | 61 | ||
65 | //console.log("<<< new Clipperz.PM.DataModel.Record", args); | ||
66 | |||
67 | return this; | 62 | return this; |
68 | } | 63 | } |
69 | 64 | ||
70 | 65 | ||
71 | Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.EncryptedRemoteObject, { | 66 | Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.EncryptedRemoteObject, { |
72 | 67 | ||
73 | 'toString': function() { | 68 | 'toString': function() { |
74 | return "Record (" + this.reference() + ")"; | 69 | return "Record (" + this.reference() + ")"; |
75 | }, | 70 | }, |
76 | 71 | ||
77 | //------------------------------------------------------------------------- | 72 | //------------------------------------------------------------------------- |
78 | 73 | ||
79 | 'reference': function () { | 74 | 'reference': function () { |
80 | return this._reference; | 75 | return this._reference; |
81 | }, | 76 | }, |
82 | 77 | ||
83 | //========================================================================= | 78 | //========================================================================= |
84 | 79 | ||
85 | 'getIndexData': function () { | 80 | 'getIndexData': function () { |
86 | return this._retrieveIndexDataFunction(this.reference()); | 81 | return this._retrieveIndexDataFunction(this.reference()); |
87 | }, | 82 | }, |
88 | 83 | ||
89 | //......................................................................... | 84 | //......................................................................... |
90 | 85 | ||
91 | 'getIndexDataForKey': function (aKey) { | 86 | 'getIndexDataForKey': function (aKey) { |
92 | return Clipperz.Async.callbacks("Record.getIndexDataForKey", [ | 87 | return Clipperz.Async.callbacks("Record.getIndexDataForKey", [ |
93 | MochiKit.Base.method(this, 'getIndexData'), | 88 | MochiKit.Base.method(this, 'getIndexData'), |
94 | MochiKit.Base.itemgetter(aKey) | 89 | MochiKit.Base.itemgetter(aKey) |
95 | ], {trace:false}); | 90 | ], {trace:false}); |
96 | }, | 91 | }, |
97 | 92 | ||
98 | //------------------------------------------------------------------------- | 93 | //------------------------------------------------------------------------- |
99 | 94 | ||
100 | 'setIndexDataForKey': function (aKey, aValue) { | 95 | 'setIndexDataForKey': function (aKey, aValue) { |
101 | // return this._updateIndexDataFunction(this.reference(), aKey, aValue); | 96 | // return this._updateIndexDataFunction(this.reference(), aKey, aValue); |
102 | 97 | ||
103 | var deferredResult; | 98 | var deferredResult; |
104 | 99 | ||
105 | deferredResult = new Clipperz.Async.Deferred("Record.setIndexDataForKey", {trace:false}); | 100 | deferredResult = new Clipperz.Async.Deferred("Record.setIndexDataForKey", {trace:false}); |
106 | deferredResult.addMethod(this, 'getIndexDataForKey', aKey); | 101 | deferredResult.addMethod(this, 'getIndexDataForKey', aKey); |
107 | deferredResult.addCallback(MochiKit.Base.bind(function (aCurrentValue) { | 102 | deferredResult.addCallback(MochiKit.Base.bind(function (aCurrentValue) { |
108 | var result; | 103 | var result; |
109 | var originalValue; | 104 | var originalValue; |
110 | 105 | ||
111 | originalValue = this.transientState().getValue('originalValues.indexData.' + aKey); | 106 | originalValue = this.transientState().getValue('originalValues.indexData.' + aKey); |
112 | if (originalValue == null) { | 107 | if (originalValue == null) { |
113 | originalValue = this.transientState().setValue('originalValues.indexData.' + aKey, aCurrentValue); | 108 | originalValue = this.transientState().setValue('originalValues.indexData.' + aKey, aCurrentValue); |
114 | } | 109 | } |
@@ -165,238 +160,232 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt | |||
165 | MochiKit.Base.bind(function (someHeaderNotes) { | 160 | MochiKit.Base.bind(function (someHeaderNotes) { |
166 | var result; | 161 | var result; |
167 | 162 | ||
168 | if ((someHeaderNotes == null) || (typeof(someHeaderNotes) == 'undefined')) { | 163 | if ((someHeaderNotes == null) || (typeof(someHeaderNotes) == 'undefined')) { |
169 | result = this.getValue('notes'); | 164 | result = this.getValue('notes'); |
170 | } else { | 165 | } else { |
171 | result = MochiKit.Async.succeed(someHeaderNotes); | 166 | result = MochiKit.Async.succeed(someHeaderNotes); |
172 | } | 167 | } |
173 | 168 | ||
174 | return result; | 169 | return result; |
175 | }, this) | 170 | }, this) |
176 | ], {trace:false}); | 171 | ], {trace:false}); |
177 | }, | 172 | }, |
178 | 173 | ||
179 | //......................................................................... | 174 | //......................................................................... |
180 | 175 | ||
181 | 'setNotes': function (aValue) { | 176 | 'setNotes': function (aValue) { |
182 | return this.setValue('notes', aValue); | 177 | return this.setValue('notes', aValue); |
183 | }, | 178 | }, |
184 | 179 | ||
185 | //========================================================================= | 180 | //========================================================================= |
186 | 181 | ||
187 | 'updateDate': function () { | 182 | 'updateDate': function () { |
188 | return MochiKit.Async.succeed(this._updateDate); | 183 | return MochiKit.Async.succeed(this._updateDate); |
189 | }, | 184 | }, |
190 | 185 | ||
191 | //========================================================================= | 186 | //========================================================================= |
192 | 187 | ||
193 | 'favicon': function () { | 188 | 'favicon': function () { |
194 | var result; | 189 | var result; |
195 | var directLogins; | 190 | var directLogins; |
196 | 191 | ||
197 | directLogins = MochiKit.Base.values(this.directLogins()); | 192 | directLogins = MochiKit.Base.values(this.directLogins()); |
198 | if (directLogins.length > 0) { | 193 | if (directLogins.length > 0) { |
199 | result = directLogins[0].favicon(); | 194 | result = directLogins[0].favicon(); |
200 | // } else if (/* is there an URL to use for searching a favicon */){ | 195 | // } else if (/* is there an URL to use for searching a favicon */){ |
201 | } else { | 196 | } else { |
202 | result = null; //MochiKit.Async.succeed(Clipperz.PM.Strings['defaultFaviconUrl']); | 197 | result = null; //MochiKit.Async.succeed(Clipperz.PM.Strings['defaultFaviconUrl']); |
203 | } | 198 | } |
204 | 199 | ||
205 | return result; | 200 | return result; |
206 | }, | 201 | }, |
207 | 202 | ||
208 | //------------------------------------------------------------------------- | 203 | //------------------------------------------------------------------------- |
209 | 204 | ||
210 | 'searchableContent': function () { | 205 | 'searchableContent': function () { |
211 | var deferredResult; | 206 | var deferredResult; |
212 | 207 | ||
213 | //console.log(">>> searchableContent"); | ||
214 | deferredResult = new Clipperz.Async.Deferred("Record.searchableContent", {trace:false}); | 208 | deferredResult = new Clipperz.Async.Deferred("Record.searchableContent", {trace:false}); |
215 | 209 | ||
216 | deferredResult.collectResults({ | 210 | deferredResult.collectResults({ |
217 | 'recordLabel': MochiKit.Base.method(this, 'label'), | 211 | 'recordLabel': MochiKit.Base.method(this, 'label'), |
218 | 'directLoginLabels': [ | 212 | 'directLoginLabels': [ |
219 | MochiKit.Base.method(this, 'directLoginReferences'), | 213 | MochiKit.Base.method(this, 'directLoginReferences'), |
220 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.itemgetter('label')) | 214 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.itemgetter('label')) |
221 | ] | 215 | ] |
222 | }) | 216 | }) |
223 | deferredResult.addCallback(function (someValues) { | 217 | deferredResult.addCallback(function (someValues) { |
224 | return someValues['recordLabel'] + ' ' + someValues['directLoginLabels'].join(' '); | 218 | return someValues['recordLabel'] + ' ' + someValues['directLoginLabels'].join(' '); |
225 | }); | 219 | }); |
226 | deferredResult.callback(); | 220 | deferredResult.callback(); |
227 | //console.log("<<< searchableContent"); | ||
228 | 221 | ||
229 | return deferredResult; | 222 | return deferredResult; |
230 | }, | 223 | }, |
231 | 224 | ||
232 | //------------------------------------------------------------------------- | 225 | //------------------------------------------------------------------------- |
233 | 226 | ||
234 | 'isMatching': function (aRegExp) { | 227 | 'isMatching': function (aRegExp) { |
235 | return Clipperz.Async.callbacks("deferredFilterFunction", [ | 228 | return Clipperz.Async.callbacks("deferredFilterFunction", [ |
236 | MochiKit.Base.method(this, 'searchableContent'), | 229 | MochiKit.Base.method(this, 'searchableContent'), |
237 | MochiKit.Base.method(aRegExp, 'test'), | 230 | MochiKit.Base.method(aRegExp, 'test'), |
238 | function (doesItMatch) { | 231 | function (doesItMatch) { |
239 | var result; | 232 | var result; |
240 | 233 | ||
241 | if (doesItMatch) { | 234 | if (doesItMatch) { |
242 | result = MochiKit.Async.succeed('match'); | 235 | result = MochiKit.Async.succeed('match'); |
243 | } else { | 236 | } else { |
244 | result = MochiKit.Async.fail('miss'); | 237 | result = MochiKit.Async.fail('miss'); |
245 | } | 238 | } |
246 | 239 | ||
247 | return result; | 240 | return result; |
248 | } | 241 | } |
249 | ], {trace:false}); | 242 | ], {trace:false}); |
250 | }, | 243 | }, |
251 | 244 | ||
252 | //========================================================================= | 245 | //========================================================================= |
253 | 246 | ||
254 | 'directLogins': function () { | 247 | 'directLogins': function () { |
255 | return this._directLogins; | 248 | return this._directLogins; |
256 | }, | 249 | }, |
257 | 250 | ||
258 | 'addDirectLogin': function (aDirectLogin) { | 251 | 'addDirectLogin': function (aDirectLogin) { |
259 | this._directLogins[aDirectLogin.reference()] = aDirectLogin; | 252 | this._directLogins[aDirectLogin.reference()] = aDirectLogin; |
260 | }, | 253 | }, |
261 | 254 | ||
262 | 'directLoginWithReference': function (aDirectLoginReference) { | 255 | 'directLoginWithReference': function (aDirectLoginReference) { |
263 | return this._directLogins[aDirectLoginReference]; | 256 | return this._directLogins[aDirectLoginReference]; |
264 | }, | 257 | }, |
265 | 258 | ||
266 | 'createNewDirectLoginFunction': function () { | 259 | 'createNewDirectLoginFunction': function () { |
267 | return this._createNewDirectLoginFunction; | 260 | return this._createNewDirectLoginFunction; |
268 | }, | 261 | }, |
269 | 262 | ||
270 | 'saveOriginalDirectLoginStatusToTransientState': function () { | 263 | 'saveOriginalDirectLoginStatusToTransientState': function () { |
271 | if (this.transientState().getValue('directLogins') == null) { | 264 | if (this.transientState().getValue('directLogins') == null) { |
272 | // this.transientState().setValue('directLogins', this._directLogins) | 265 | // this.transientState().setValue('directLogins', this._directLogins) |
273 | //console.log("SET TRANSIENT STATE", Clipperz.Base.serializeJSON(MochiKit.Base.keys(this.transientState().getValue('directLogins')))) | ||
274 | MochiKit.Iter.forEach(MochiKit.Base.keys(this._directLogins), MochiKit.Base.bind(function(aKey) { | 266 | MochiKit.Iter.forEach(MochiKit.Base.keys(this._directLogins), MochiKit.Base.bind(function(aKey) { |
275 | this.transientState().setValue('directLogins' + '.' + aKey, this._directLogins[aKey]) | 267 | this.transientState().setValue('directLogins' + '.' + aKey, this._directLogins[aKey]) |
276 | }, this)) | 268 | }, this)) |
277 | } | 269 | } |
278 | }, | 270 | }, |
279 | 271 | ||
280 | 'createNewDirectLogin': function () { | 272 | 'createNewDirectLogin': function () { |
281 | this.saveOriginalDirectLoginStatusToTransientState(); | 273 | this.saveOriginalDirectLoginStatusToTransientState(); |
282 | 274 | ||
283 | return this.createNewDirectLoginFunction()(this); | 275 | return this.createNewDirectLoginFunction()(this); |
284 | }, | 276 | }, |
285 | 277 | ||
286 | 'removeDirectLogin': function(aDirectLogin) { | 278 | 'removeDirectLogin': function(aDirectLogin) { |
287 | this.saveOriginalDirectLoginStatusToTransientState(); | 279 | this.saveOriginalDirectLoginStatusToTransientState(); |
288 | 280 | ||
289 | return Clipperz.Async.callbacks("Record.removeDirectLogin", [ | 281 | return Clipperz.Async.callbacks("Record.removeDirectLogin", [ |
290 | MochiKit.Base.method(this, 'removeValue', 'directLogins' + '.' + aDirectLogin.reference()), | 282 | MochiKit.Base.method(this, 'removeValue', 'directLogins' + '.' + aDirectLogin.reference()), |
291 | MochiKit.Base.bind(function () { | 283 | MochiKit.Base.bind(function () { |
292 | delete this._directLogins[aDirectLogin.reference()] | 284 | delete this._directLogins[aDirectLogin.reference()] |
293 | }, this) | 285 | }, this) |
294 | ], {trace:false}); | 286 | ], {trace:false}); |
295 | 287 | ||
296 | }, | 288 | }, |
297 | 289 | ||
298 | 'directLoginReferences': function () { | 290 | 'directLoginReferences': function () { |
299 | var result; | 291 | var result; |
300 | 292 | ||
301 | result = Clipperz.Async.callbacks("Record.directLoginReferences", [ | 293 | result = Clipperz.Async.callbacks("Record.directLoginReferences", [ |
302 | MochiKit.Base.method(this, 'directLogins'), | 294 | MochiKit.Base.method(this, 'directLogins'), |
303 | MochiKit.Base.values, | 295 | MochiKit.Base.values, |
304 | function (someDirectLogins) { | 296 | function (someDirectLogins) { |
305 | var result; | 297 | var result; |
306 | var i,c; | 298 | var i,c; |
307 | 299 | ||
308 | result = []; | 300 | result = []; |
309 | c = someDirectLogins.length; | 301 | c = someDirectLogins.length; |
310 | for (i=0; i<c; i++) { | 302 | for (i=0; i<c; i++) { |
311 | result.push(Clipperz.Async.collectResults("Record.directLoginReferences - collectResults", { | 303 | result.push(Clipperz.Async.collectResults("Record.directLoginReferences - collectResults", { |
312 | '_rowObject': MochiKit.Async.succeed, | 304 | '_rowObject': MochiKit.Async.succeed, |
313 | '_reference': MochiKit.Base.methodcaller('reference'), | 305 | '_reference': MochiKit.Base.methodcaller('reference'), |
314 | 'label': MochiKit.Base.methodcaller('label'), | 306 | 'label': MochiKit.Base.methodcaller('label'), |
315 | 'favicon': MochiKit.Base.methodcaller('favicon') | 307 | 'favicon': MochiKit.Base.methodcaller('favicon') |
316 | }, {trace:false})(someDirectLogins[i])); | 308 | }, {trace:false})(someDirectLogins[i])); |
317 | }; | 309 | }; |
318 | 310 | ||
319 | return result; | 311 | return result; |
320 | }, | 312 | }, |
321 | Clipperz.Async.collectAll | 313 | Clipperz.Async.collectAll |
322 | ], {trace:false}); | 314 | ], {trace:false}); |
323 | 315 | ||
324 | return result; | 316 | return result; |
325 | }, | 317 | }, |
326 | 318 | ||
327 | //========================================================================= | 319 | //========================================================================= |
328 | 320 | ||
329 | 'unpackRemoteData': function (someData) { | 321 | 'unpackRemoteData': function (someData) { |
330 | var result; | 322 | var result; |
331 | 323 | ||
332 | //console.log("new Clipperz.PM.DataModel.Record.Version [2]"); | ||
333 | /* | 324 | /* |
334 | this._currentRecordVersion = new Clipperz.PM.DataModel.Record.Version({ | 325 | this._currentRecordVersion = new Clipperz.PM.DataModel.Record.Version({ |
335 | 'reference': someData['currentVersion']['reference'], | 326 | 'reference': someData['currentVersion']['reference'], |
336 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getCurrentRecordVersionKey'), | 327 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getCurrentRecordVersionKey'), |
337 | 'remoteData': someData['currentVersion'], | 328 | 'remoteData': someData['currentVersion'], |
338 | }); | 329 | }); |
339 | */ | 330 | */ |
340 | var versionKey; | 331 | var versionKey; |
341 | 332 | ||
342 | for (versionKey in someData['versions']) { | 333 | for (versionKey in someData['versions']) { |
343 | //console.log("### versionKey", versionKey); | ||
344 | this._versions[versionKey] = new Clipperz.PM.DataModel.Record.Version({ | 334 | this._versions[versionKey] = new Clipperz.PM.DataModel.Record.Version({ |
345 | 'reference': versionKey, | 335 | 'reference': versionKey, |
346 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), | 336 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), |
347 | 'remoteData': someData['versions'][versionKey], | 337 | 'remoteData': someData['versions'][versionKey], |
348 | 'getVersion': MochiKit.Base.method(this, 'getVersion') | 338 | 'getVersion': MochiKit.Base.method(this, 'getVersion') |
349 | }) | 339 | }) |
350 | } | 340 | } |
351 | 341 | ||
352 | // this._currentVersionReference = someData['currentVersion']['reference']; | 342 | // this._currentVersionReference = someData['currentVersion']['reference']; |
353 | this._currentVersionReference = someData['currentVersion']; | 343 | this._currentVersionReference = someData['currentVersion']; |
354 | //console.log("=== currentVersionReference", this._currentVersionReference, someData); | ||
355 | 344 | ||
356 | result = Clipperz.PM.DataModel.Record.superclass.unpackRemoteData.apply(this, arguments); | 345 | result = Clipperz.PM.DataModel.Record.superclass.unpackRemoteData.apply(this, arguments); |
357 | 346 | ||
358 | return result; | 347 | return result; |
359 | }, | 348 | }, |
360 | 349 | ||
361 | //------------------------------------------------------------------------- | 350 | //------------------------------------------------------------------------- |
362 | 351 | ||
363 | 'unpackData': function (someData) { | 352 | 'unpackData': function (someData) { |
364 | var result; | 353 | var result; |
365 | 354 | ||
366 | result = Clipperz.PM.DataModel.Record.superclass.unpackData.apply(this, arguments); | 355 | result = Clipperz.PM.DataModel.Record.superclass.unpackData.apply(this, arguments); |
367 | 356 | ||
368 | if (MochiKit.Base.isUndefinedOrNull(result['notes'])) { | 357 | if (MochiKit.Base.isUndefinedOrNull(result['notes'])) { |
369 | result['notes'] = '' | 358 | result['notes'] = '' |
370 | } | 359 | } |
371 | 360 | ||
372 | return result; | 361 | return result; |
373 | }, | 362 | }, |
374 | 363 | ||
375 | //------------------------------------------------------------------------- | 364 | //------------------------------------------------------------------------- |
376 | 365 | ||
377 | 'prepareRemoteDataWithKey': function (aKey) { | 366 | 'prepareRemoteDataWithKey': function (aKey) { |
378 | var deferredResult; | 367 | var deferredResult; |
379 | varnewVersionKey; | 368 | varnewVersionKey; |
380 | var result; | 369 | var result; |
381 | 370 | ||
382 | newVersionKey = Clipperz.PM.Crypto.randomKey(); | 371 | newVersionKey = Clipperz.PM.Crypto.randomKey(); |
383 | result = {}; | 372 | result = {}; |
384 | 373 | ||
385 | deferredResult = new Clipperz.Async.Deferred("Record.prepareRemoteDataWithKey", {trace:false}); | 374 | deferredResult = new Clipperz.Async.Deferred("Record.prepareRemoteDataWithKey", {trace:false}); |
386 | deferredResult.addCallbackList([ | 375 | deferredResult.addCallbackList([ |
387 | Clipperz.Async.collectResults("Record.prepareRemoteDataWithKey - collect results", { | 376 | Clipperz.Async.collectResults("Record.prepareRemoteDataWithKey - collect results", { |
388 | 'isBrandNew': MochiKit.Base.method(this, 'isBrandNew'), | 377 | 'isBrandNew': MochiKit.Base.method(this, 'isBrandNew'), |
389 | 'versionHasPendingChanges':[ | 378 | 'versionHasPendingChanges':[ |
390 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 379 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
391 | // MochiKit.Base.methodcaller('hasPendingChanges') | 380 | // MochiKit.Base.methodcaller('hasPendingChanges') |
392 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'hasPendingChanges') | 381 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'hasPendingChanges') |
393 | ] | 382 | ] |
394 | }), | 383 | }), |
395 | Clipperz.Async.or, | 384 | Clipperz.Async.or, |
396 | 385 | ||
397 | Clipperz.Async.deferredIf("Current Version has pending changes", [ | 386 | Clipperz.Async.deferredIf("Current Version has pending changes", [ |
398 | MochiKit.Base.method(this, 'createNewRecordVersion'), | 387 | MochiKit.Base.method(this, 'createNewRecordVersion'), |
399 | MochiKit.Base.methodcaller('prepareRemoteDataWithKey', newVersionKey), | 388 | MochiKit.Base.methodcaller('prepareRemoteDataWithKey', newVersionKey), |
400 | MochiKit.Base.partial(Clipperz.Async.setItem, result, 'currentRecordVersion'), | 389 | MochiKit.Base.partial(Clipperz.Async.setItem, result, 'currentRecordVersion'), |
401 | MochiKit.Base.method(this, 'setCurrentRecordVersionKey', newVersionKey) | 390 | MochiKit.Base.method(this, 'setCurrentRecordVersionKey', newVersionKey) |
402 | ], []), | 391 | ], []), |
@@ -491,219 +480,208 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt | |||
491 | MochiKit.Base.method(this.transientState(), 'setValue', transientStateKey) | 480 | MochiKit.Base.method(this.transientState(), 'setValue', transientStateKey) |
492 | ],[ | 481 | ],[ |
493 | MochiKit.Async.fail | 482 | MochiKit.Async.fail |
494 | ]) | 483 | ]) |
495 | ], {trace:false}); | 484 | ], {trace:false}); |
496 | } | 485 | } |
497 | 486 | ||
498 | return deferredResult; | 487 | return deferredResult; |
499 | }, | 488 | }, |
500 | 489 | ||
501 | //------------------------------------------------------------------------- | 490 | //------------------------------------------------------------------------- |
502 | 491 | ||
503 | 'versions': function () { | 492 | 'versions': function () { |
504 | return this._versions; | 493 | return this._versions; |
505 | }, | 494 | }, |
506 | 495 | ||
507 | 'getVersions': function () { | 496 | 'getVersions': function () { |
508 | return Clipperz.Async.callbacks("Record.versions", [ | 497 | return Clipperz.Async.callbacks("Record.versions", [ |
509 | MochiKit.Base.method(this, 'getValue', 'fakeKey, just to trigger unpackRemoteData'), | 498 | MochiKit.Base.method(this, 'getValue', 'fakeKey, just to trigger unpackRemoteData'), |
510 | MochiKit.Base.bind(function () { return this._versions; }, this) | 499 | MochiKit.Base.bind(function () { return this._versions; }, this) |
511 | ], {trace:false}); | 500 | ], {trace:false}); |
512 | }, | 501 | }, |
513 | 502 | ||
514 | //------------------------------------------------------------------------- | 503 | //------------------------------------------------------------------------- |
515 | 504 | ||
516 | 'getCurrentRecordVersion': function () { | 505 | 'getCurrentRecordVersion': function () { |
517 | return Clipperz.Async.callbacks("Record.getCurrentRecordVersion", [ | 506 | return Clipperz.Async.callbacks("Record.getCurrentRecordVersion", [ |
518 | // MochiKit.Base.method(this, 'getValue', 'fakeKey, just to trigger unpackRemoteData'), | 507 | // MochiKit.Base.method(this, 'getValue', 'fakeKey, just to trigger unpackRemoteData'), |
519 | // MochiKit.Base.bind(function () { return this._currentRecordVersion; }, this) | 508 | // MochiKit.Base.bind(function () { return this._currentRecordVersion; }, this) |
520 | 509 | ||
521 | MochiKit.Base.method(this, 'versions'), | 510 | MochiKit.Base.method(this, 'versions'), |
522 | MochiKit.Base.itemgetter(this.currentVersionReference()), | 511 | MochiKit.Base.itemgetter(this.currentVersionReference()), |
523 | Clipperz.Async.deferredIf("The current version is available", [ | 512 | Clipperz.Async.deferredIf("The current version is available", [ |
524 | MochiKit.Async.succeed | 513 | MochiKit.Async.succeed |
525 | ], [ | 514 | ], [ |
526 | MochiKit.Base.method(this, 'getVersions'), | 515 | MochiKit.Base.method(this, 'getVersions'), |
527 | MochiKit.Base.bind(function (someVersions) { return someVersions[this.currentVersionReference()]}, this) | 516 | MochiKit.Base.bind(function (someVersions) { return someVersions[this.currentVersionReference()]}, this) |
528 | ]) | 517 | ]) |
529 | ], {trace:false}); | 518 | ], {trace:false}); |
530 | }, | 519 | }, |
531 | 520 | ||
532 | 'setCurrentRecordVersion': function (aRecordVersion) { | 521 | 'setCurrentRecordVersion': function (aRecordVersion) { |
533 | this._currentVersionReference = aRecordVersion.reference(); | 522 | this._currentVersionReference = aRecordVersion.reference(); |
534 | }, | 523 | }, |
535 | 524 | ||
536 | //......................................................................... | 525 | //......................................................................... |
537 | 526 | ||
538 | 'currentVersionReference': function () { | 527 | 'currentVersionReference': function () { |
539 | //console.log("currentVersionReference"); | ||
540 | return this._currentVersionReference; | 528 | return this._currentVersionReference; |
541 | }, | 529 | }, |
542 | 530 | ||
543 | //------------------------------------------------------------------------- | 531 | //------------------------------------------------------------------------- |
544 | 532 | ||
545 | 'createNewRecordVersion': function () { | 533 | 'createNewRecordVersion': function () { |
546 | var deferredResult; | 534 | var deferredResult; |
547 | 535 | ||
548 | if (this.isBrandNew()) { | 536 | if (this.isBrandNew()) { |
549 | deferredResult = this.getCurrentRecordVersion(); | 537 | deferredResult = this.getCurrentRecordVersion(); |
550 | } else { | 538 | } else { |
551 | var newVersion; | 539 | var newVersion; |
552 | 540 | ||
553 | newVersion = new Clipperz.PM.DataModel.Record.Version({ | 541 | newVersion = new Clipperz.PM.DataModel.Record.Version({ |
554 | // 'reference': versionKey, | 542 | // 'reference': versionKey, |
555 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), | 543 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), |
556 | // 'remoteData': {}, | 544 | // 'remoteData': {}, |
557 | 'getVersion': MochiKit.Base.method(this, 'getVersion') | 545 | 'getVersion': MochiKit.Base.method(this, 'getVersion') |
558 | }) | 546 | }) |
559 | this._versions[newVersion.reference()] = newVersion; | 547 | this._versions[newVersion.reference()] = newVersion; |
560 | 548 | ||
561 | deferredResult = Clipperz.Async.callbacks("Record.createNewRecordVersion", [ | 549 | deferredResult = Clipperz.Async.callbacks("Record.createNewRecordVersion", [ |
562 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 550 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
563 | // MochiKit.Base.methodcaller('values'), | 551 | // MochiKit.Base.methodcaller('values'), |
564 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'values'), | 552 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'values'), |
565 | MochiKit.Base.method(newVersion, 'setValues'), | 553 | MochiKit.Base.method(newVersion, 'setValues'), |
566 | 554 | ||
567 | Clipperz.Async.collectResults("Record.createNewRecordVersion [collect results]", { | 555 | Clipperz.Async.collectResults("Record.createNewRecordVersion [collect results]", { |
568 | 'reference':MochiKit.Base.method(this, 'currentVersionReference'), | 556 | 'reference':MochiKit.Base.method(this, 'currentVersionReference'), |
569 | 'key': MochiKit.Base.method(this, 'getCurrentRecordVersionKey') | 557 | 'key': MochiKit.Base.method(this, 'getCurrentRecordVersionKey') |
570 | }, {trace:false}), | 558 | }, {trace:false}), |
571 | MochiKit.Base.method(newVersion, 'setPreviousVersionReferenceAndKey'), | 559 | MochiKit.Base.method(newVersion, 'setPreviousVersionReferenceAndKey'), |
572 | 560 | ||
573 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 561 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
574 | // MochiKit.Base.method(this, 'revertChanges'), | 562 | // MochiKit.Base.method(this, 'revertChanges'), |
575 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'revertChanges'), | 563 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'revertChanges'), |
576 | 564 | ||
577 | MochiKit.Base.method(this, 'setCurrentRecordVersion', newVersion), | 565 | MochiKit.Base.method(this, 'setCurrentRecordVersion', newVersion), |
578 | MochiKit.Base.partial(MochiKit.Async.succeed, newVersion) | 566 | MochiKit.Base.partial(MochiKit.Async.succeed, newVersion) |
579 | ], {trace:false}); | 567 | ], {trace:false}); |
580 | } | 568 | } |
581 | 569 | ||
582 | return deferredResult; | 570 | return deferredResult; |
583 | }, | 571 | }, |
584 | 572 | ||
585 | //------------------------------------------------------------------------- | 573 | //------------------------------------------------------------------------- |
586 | 574 | ||
587 | 'getCurrentRecordVersionKey': function () { | 575 | 'getCurrentRecordVersionKey': function () { |
588 | //console.log("getCurrentRecordVersionKey"); | ||
589 | return Clipperz.Async.callbacks("Record.getCurrentRecordVersionKey", [ | 576 | return Clipperz.Async.callbacks("Record.getCurrentRecordVersionKey", [ |
590 | MochiKit.Base.method(this, 'getValue', 'currentVersionKey'), | 577 | MochiKit.Base.method(this, 'getValue', 'currentVersionKey'), |
591 | Clipperz.Async.deferredIf("currentVersionKey is NOT null", [ | 578 | Clipperz.Async.deferredIf("currentVersionKey is NOT null", [ |
592 | MochiKit.Async.succeed | 579 | MochiKit.Async.succeed |
593 | ], [ | 580 | ], [ |
594 | MochiKit.Base.method(this, 'getKey') | 581 | MochiKit.Base.method(this, 'getKey') |
595 | ]) | 582 | ]) |
596 | ], {trace:false}); | 583 | ], {trace:false}); |
597 | }, | 584 | }, |
598 | 585 | ||
599 | 'setCurrentRecordVersionKey': function (aValue) { | 586 | 'setCurrentRecordVersionKey': function (aValue) { |
600 | //TODO: triple check this method! | 587 | //TODO: triple check this method! |
601 | return Clipperz.Async.callbacks("Record.setCurrentRecordVersionKey", [ | 588 | return Clipperz.Async.callbacks("Record.setCurrentRecordVersionKey", [ |
602 | MochiKit.Base.method(this, 'setValue', 'currentVersionKey', aValue) | 589 | MochiKit.Base.method(this, 'setValue', 'currentVersionKey', aValue) |
603 | ], {trace:false}); | 590 | ], {trace:false}); |
604 | }, | 591 | }, |
605 | 592 | ||
606 | //------------------------------------------------------------------------- | 593 | //------------------------------------------------------------------------- |
607 | 594 | ||
608 | 'invokeCurrentRecordVersionMethod': function (aMethodName, someValues) { | 595 | 'invokeCurrentRecordVersionMethod': function (aMethodName, someValues) { |
609 | //console.log(">>> invokeCurrentRecordVersionMethod", aMethodName); | ||
610 | return Clipperz.Async.callbacks("Record.invokeCurrentRecordVersionMethod", [ | 596 | return Clipperz.Async.callbacks("Record.invokeCurrentRecordVersionMethod", [ |
611 | MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 597 | MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
612 | //function (aValue) { console.log("=== getCurrentRecordVersion", aValue); return aValue}, | ||
613 | MochiKit.Base.methodcaller(aMethodName, someValues) | 598 | MochiKit.Base.methodcaller(aMethodName, someValues) |
614 | ], {trace:false}); | 599 | ], {trace:false}); |
615 | }, | 600 | }, |
616 | 601 | ||
617 | 602 | ||
618 | 'lazilyinvokeCurrentRecordVersionMethod': function (aMethodName, someValues, defaultResult) { | 603 | 'lazilyinvokeCurrentRecordVersionMethod': function (aMethodName, someValues, defaultResult) { |
619 | return Clipperz.Async.callbacks("Record.lazilyinvokeCurrentRecordVersionMethod", [ | 604 | return Clipperz.Async.callbacks("Record.lazilyinvokeCurrentRecordVersionMethod", [ |
620 | MochiKit.Base.method(this, 'currentVersionReference'), | 605 | MochiKit.Base.method(this, 'currentVersionReference'), |
621 | //function (aValue) { console.log("LAZY -> versions", aValue); return aValue; }, | ||
622 | Clipperz.Async.deferredIf("versions has been loaded", [ | 606 | Clipperz.Async.deferredIf("versions has been loaded", [ |
623 | //function (aValue) { console.log("LAZY -> then"); return aValue; }, | ||
624 | MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 607 | MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
625 | MochiKit.Base.methodcaller(aMethodName, someValues), | 608 | MochiKit.Base.methodcaller(aMethodName, someValues), |
626 | //function (aValue) { console.log("LAZY <- then"); return aValue; } | ||
627 | ], [ | 609 | ], [ |
628 | //function (aValue) { console.log("LAZY -> else"); return aValue; }, | ||
629 | MochiKit.Base.partial(MochiKit.Async.succeed, defaultResult), | 610 | MochiKit.Base.partial(MochiKit.Async.succeed, defaultResult), |
630 | //function (aValue) { console.log("LAZY <- else"); return aValue; } | ||
631 | ]) | 611 | ]) |
632 | ], {trace:false}); | 612 | ], {trace:false}); |
633 | }, | 613 | }, |
634 | 614 | ||
635 | //========================================================================= | 615 | //========================================================================= |
636 | 616 | ||
637 | 'hasPendingChanges': function () { | 617 | 'hasPendingChanges': function () { |
638 | var deferredResult; | 618 | var deferredResult; |
639 | 619 | ||
640 | if (this.hasInitiatedObjectDataStore()) { | 620 | if (this.hasInitiatedObjectDataStore()) { |
641 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChanges", {trace:false}); | 621 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChanges", {trace:false}); |
642 | deferredResult.collectResults({ | 622 | deferredResult.collectResults({ |
643 | 'super': MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasPendingChanges, this), | 623 | 'super': MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasPendingChanges, this), |
644 | 'currentVersion': [ | 624 | 'currentVersion': [ |
645 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 625 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
646 | // MochiKit.Base.methodcaller('hasPendingChanges') | 626 | // MochiKit.Base.methodcaller('hasPendingChanges') |
647 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'hasPendingChanges') | 627 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'hasPendingChanges') |
648 | ], | 628 | ], |
649 | 'directLogins': [ | 629 | 'directLogins': [ |
650 | MochiKit.Base.method(this, 'directLogins'), | 630 | MochiKit.Base.method(this, 'directLogins'), |
651 | //function (aValue) { console.log("Record.directLogins", aValue); return aValue; }, | ||
652 | MochiKit.Base.values, | 631 | MochiKit.Base.values, |
653 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasPendingChanges')), | 632 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasPendingChanges')), |
654 | Clipperz.Async.collectAll, | 633 | Clipperz.Async.collectAll, |
655 | Clipperz.Async.or | 634 | Clipperz.Async.or |
656 | // function(someValues) { | 635 | // function(someValues) { |
657 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); | 636 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); |
658 | // } | 637 | // } |
659 | ] | 638 | ] |
660 | }); | 639 | }); |
661 | //deferredResult.addCallback(function (aValue) { console.log("Record.hasPendingResults", aValue); return aValue; }); | ||
662 | deferredResult.addCallback(MochiKit.Base.values); | 640 | deferredResult.addCallback(MochiKit.Base.values); |
663 | deferredResult.addCallback(MochiKit.Base.bind(function(someValues) { | 641 | deferredResult.addCallback(MochiKit.Base.bind(function(someValues) { |
664 | var result; | 642 | var result; |
665 | result = MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); | 643 | result = MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); |
666 | 644 | ||
667 | if ((result == false) && (this.isBrandNew() == false)) { | 645 | if ((result == false) && (this.isBrandNew() == false)) { |
668 | result = MochiKit.Iter.some(MochiKit.Base.values(this.transientState().getValue('hasPendingChanges.indexData')), MochiKit.Base.operator.identity); | 646 | result = MochiKit.Iter.some(MochiKit.Base.values(this.transientState().getValue('hasPendingChanges.indexData')), MochiKit.Base.operator.identity); |
669 | } | 647 | } |
670 | 648 | ||
671 | return result; | 649 | return result; |
672 | }, this)); | 650 | }, this)); |
673 | 651 | ||
674 | deferredResult.callback(); | 652 | deferredResult.callback(); |
675 | } else { | 653 | } else { |
676 | deferredResult = Clipperz.Async.callbacks("Recrod.hasPendingChanges [hasInitiatedObjectDataStore == false]", [ | 654 | deferredResult = Clipperz.Async.callbacks("Recrod.hasPendingChanges [hasInitiatedObjectDataStore == false]", [ |
677 | MochiKit.Base.method(this, 'directLogins'), | 655 | MochiKit.Base.method(this, 'directLogins'), |
678 | MochiKit.Base.values, | 656 | MochiKit.Base.values, |
679 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasPendingChanges')), | 657 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasPendingChanges')), |
680 | Clipperz.Async.collectAll, | 658 | Clipperz.Async.collectAll, |
681 | Clipperz.Async.or | 659 | Clipperz.Async.or |
682 | // function(someValues) { | 660 | // function(someValues) { |
683 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); | 661 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); |
684 | // } | 662 | // } |
685 | ], {trace:false}) | 663 | ], {trace:false}) |
686 | } | 664 | } |
687 | 665 | ||
688 | return deferredResult; | 666 | return deferredResult; |
689 | }, | 667 | }, |
690 | 668 | ||
691 | //------------------------------------------------------------------------- | 669 | //------------------------------------------------------------------------- |
692 | 670 | ||
693 | 'hasPendingChangesWhenBrandNew': function () { | 671 | 'hasPendingChangesWhenBrandNew': function () { |
694 | var deferredResult; | 672 | var deferredResult; |
695 | 673 | ||
696 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChangesWhenBrandNew", {trace:false}); | 674 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChangesWhenBrandNew", {trace:false}); |
697 | deferredResult.collectResults({ | 675 | deferredResult.collectResults({ |
698 | 'label': [ | 676 | 'label': [ |
699 | MochiKit.Base.method(this, 'label'), | 677 | MochiKit.Base.method(this, 'label'), |
700 | MochiKit.Base.partial(MochiKit.Base.operator.ne, '') | 678 | MochiKit.Base.partial(MochiKit.Base.operator.ne, '') |
701 | ], | 679 | ], |
702 | 'notes': [ | 680 | 'notes': [ |
703 | MochiKit.Base.method(this, 'notes'), | 681 | MochiKit.Base.method(this, 'notes'), |
704 | MochiKit.Base.partial(MochiKit.Base.operator.ne, '') | 682 | MochiKit.Base.partial(MochiKit.Base.operator.ne, '') |
705 | ] | 683 | ] |
706 | }); | 684 | }); |
707 | // deferredResult.addCallback(MochiKit.Base.values); | 685 | // deferredResult.addCallback(MochiKit.Base.values); |
708 | // deferredResult.addCallback(function(someValues) { | 686 | // deferredResult.addCallback(function(someValues) { |
709 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); | 687 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); |
@@ -731,137 +709,135 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt | |||
731 | 709 | ||
732 | return deferredResult; | 710 | return deferredResult; |
733 | }, | 711 | }, |
734 | 712 | ||
735 | //========================================================================= | 713 | //========================================================================= |
736 | 714 | ||
737 | 'revertChanges': function () { | 715 | 'revertChanges': function () { |
738 | var deferredResult; | 716 | var deferredResult; |
739 | 717 | ||
740 | if (this.isBrandNew() == false) { | 718 | if (this.isBrandNew() == false) { |
741 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.revertChanges", {trace:false}); | 719 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.revertChanges", {trace:false}); |
742 | deferredResult.addMethod(this, 'hasPendingChanges'); | 720 | deferredResult.addMethod(this, 'hasPendingChanges'); |
743 | deferredResult.addIf([ | 721 | deferredResult.addIf([ |
744 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 722 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
745 | // MochiKit.Base.methodcaller('revertChanges'), | 723 | // MochiKit.Base.methodcaller('revertChanges'), |
746 | MochiKit.Base.method(this,'invokeCurrentRecordVersionMethod', 'revertChanges'), | 724 | MochiKit.Base.method(this,'invokeCurrentRecordVersionMethod', 'revertChanges'), |
747 | 725 | ||
748 | MochiKit.Base.method(this, 'directLogins'), | 726 | MochiKit.Base.method(this, 'directLogins'), |
749 | MochiKit.Base.values, | 727 | MochiKit.Base.values, |
750 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('revertChanges')), | 728 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('revertChanges')), |
751 | 729 | ||
752 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.revertChanges, this) | 730 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.revertChanges, this) |
753 | ], [ | 731 | ], [ |
754 | MochiKit.Async.succeed | 732 | MochiKit.Async.succeed |
755 | ]); | 733 | ]); |
756 | deferredResult.callback(); | 734 | deferredResult.callback(); |
757 | } else { | 735 | } else { |
758 | // this.deleteAllCleanTextData(); | 736 | // this.deleteAllCleanTextData(); |
759 | deferredResult = MochiKit.Async.succeed(); | 737 | deferredResult = MochiKit.Async.succeed(); |
760 | } | 738 | } |
761 | 739 | ||
762 | return deferredResult; | 740 | return deferredResult; |
763 | }, | 741 | }, |
764 | 742 | ||
765 | //------------------------------------------------------------------------- | 743 | //------------------------------------------------------------------------- |
766 | 744 | ||
767 | 'resetTransientState': function (isCommitting) { | 745 | 'resetTransientState': function (isCommitting) { |
768 | // if ((isCommitting == false) && (this.transientState().getValue('directLogins') != null)) { | 746 | // if ((isCommitting == false) && (this.transientState().getValue('directLogins') != null)) { |
769 | // this._directLogins = this.transientState().getValue('directLogins'); | 747 | // this._directLogins = this.transientState().getValue('directLogins'); |
770 | // } | 748 | // } |
771 | 749 | ||
772 | return Clipperz.Async.callbacks("Record.resetTransientState", [ | 750 | return Clipperz.Async.callbacks("Record.resetTransientState", [ |
773 | //- MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 751 | //- MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
774 | //- MochiKit.Base.methodcaller('resetTransientState'), | 752 | //- MochiKit.Base.methodcaller('resetTransientState'), |
775 | // MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'resetTransientState'), | 753 | // MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'resetTransientState'), |
776 | MochiKit.Base.method(this, 'lazilyinvokeCurrentRecordVersionMethod', 'resetTransientState'), | 754 | MochiKit.Base.method(this, 'lazilyinvokeCurrentRecordVersionMethod', 'resetTransientState'), |
777 | 755 | ||
778 | MochiKit.Base.method(this, 'directLogins'), | 756 | MochiKit.Base.method(this, 'directLogins'), |
779 | //function (aValue) { console.log("resetTransientState - directLogins", aValue); return aValue; }, | ||
780 | MochiKit.Base.values, | 757 | MochiKit.Base.values, |
781 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('resetTransientState')), | 758 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('resetTransientState')), |
782 | 759 | ||
783 | MochiKit.Base.bind(function () { | 760 | MochiKit.Base.bind(function () { |
784 | if ((isCommitting == false) && (this.transientState().getValue('directLogins') != null)) { | 761 | if ((isCommitting == false) && (this.transientState().getValue('directLogins') != null)) { |
785 | this._directLogins = this.transientState().getValue('directLogins'); | 762 | this._directLogins = this.transientState().getValue('directLogins'); |
786 | } | 763 | } |
787 | }, this), | 764 | }, this), |
788 | 765 | ||
789 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.resetTransientState, this, isCommitting) | 766 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.resetTransientState, this, isCommitting) |
790 | ], {trace:false}) | 767 | ], {trace:false}) |
791 | }, | 768 | }, |
792 | 769 | ||
793 | //------------------------------------------------------------------------- | 770 | //------------------------------------------------------------------------- |
794 | 771 | ||
795 | 'commitTransientState': function () { | 772 | 'commitTransientState': function () { |
796 | var deferredResult; | 773 | var deferredResult; |
797 | 774 | ||
798 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.commitTransientState", {trace:false}); | 775 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.commitTransientState", {trace:false}); |
799 | deferredResult.addMethod(this, 'hasPendingChanges'); | 776 | deferredResult.addMethod(this, 'hasPendingChanges'); |
800 | deferredResult.addIf([ | 777 | deferredResult.addIf([ |
801 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.commitTransientState, this), | 778 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.commitTransientState, this), |
802 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 779 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
803 | // MochiKit.Base.methodcaller('commitTransientState'), | 780 | // MochiKit.Base.methodcaller('commitTransientState'), |
804 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'commitTransientState'), | 781 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'commitTransientState'), |
805 | MochiKit.Base.method(this, 'directLogins'), | 782 | MochiKit.Base.method(this, 'directLogins'), |
806 | MochiKit.Base.values, | 783 | MochiKit.Base.values, |
807 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('commitTransientState')) | 784 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('commitTransientState')) |
808 | ], [ | 785 | ], [ |
809 | MochiKit.Async.succeed | 786 | MochiKit.Async.succeed |
810 | ]); | 787 | ]); |
811 | deferredResult.callback(); | 788 | deferredResult.callback(); |
812 | 789 | ||
813 | return deferredResult; | 790 | return deferredResult; |
814 | }, | 791 | }, |
815 | 792 | ||
816 | //========================================================================= | 793 | //========================================================================= |
817 | 794 | ||
818 | 'retrieveDirectLoginIndexDataFunction': function () { | 795 | 'retrieveDirectLoginIndexDataFunction': function () { |
819 | //console.log("Record.retrieveDirectLoginIndexDataFunction", this._retrieveDirectLoginIndexDataFunction); | ||
820 | return this._retrieveDirectLoginIndexDataFunction; | 796 | return this._retrieveDirectLoginIndexDataFunction; |
821 | }, | 797 | }, |
822 | 798 | ||
823 | 'setDirectLoginIndexDataFunction': function () { | 799 | 'setDirectLoginIndexDataFunction': function () { |
824 | return this._setDirectLoginIndexDataFunction; | 800 | return this._setDirectLoginIndexDataFunction; |
825 | }, | 801 | }, |
826 | 802 | ||
827 | 'removeDirectLoginIndexDataFunction': function () { | 803 | 'removeDirectLoginIndexDataFunction': function () { |
828 | return this._removeDirectLoginIndexDataFunction; | 804 | return this._removeDirectLoginIndexDataFunction; |
829 | }, | 805 | }, |
830 | 806 | ||
831 | //========================================================================= | 807 | //========================================================================= |
832 | 808 | ||
833 | 'deleteAllCleanTextData': function () { | 809 | 'deleteAllCleanTextData': function () { |
834 | // return Clipperz.PM.DataModel.Record.superclass.deleteAllCleanTextData.apply(this, arguments); | 810 | // return Clipperz.PM.DataModel.Record.superclass.deleteAllCleanTextData.apply(this, arguments); |
835 | 811 | ||
836 | return Clipperz.Async.callbacks("Record.deleteAllCleanTextData", [ | 812 | return Clipperz.Async.callbacks("Record.deleteAllCleanTextData", [ |
837 | MochiKit.Base.method(this, 'versions'), | 813 | MochiKit.Base.method(this, 'versions'), |
838 | MochiKit.Base.values, | 814 | MochiKit.Base.values, |
839 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), | 815 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), |
840 | 816 | ||
841 | MochiKit.Base.method(this, 'directLogins'), | 817 | MochiKit.Base.method(this, 'directLogins'), |
842 | MochiKit.Base.values, | 818 | MochiKit.Base.values, |
843 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), | 819 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), |
844 | 820 | ||
845 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.deleteAllCleanTextData, this) | 821 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.deleteAllCleanTextData, this) |
846 | ], {trace:false}); | 822 | ], {trace:false}); |
847 | }, | 823 | }, |
848 | 824 | ||
849 | 'hasAnyCleanTextData': function () { | 825 | 'hasAnyCleanTextData': function () { |
850 | // return Clipperz.PM.DataModel.Record.superclass.hasAnyCleanTextData.apply(this, arguments); | 826 | // return Clipperz.PM.DataModel.Record.superclass.hasAnyCleanTextData.apply(this, arguments); |
851 | 827 | ||
852 | return Clipperz.Async.callbacks("Record.hasAnyCleanTextData", [ | 828 | return Clipperz.Async.callbacks("Record.hasAnyCleanTextData", [ |
853 | Clipperz.Async.collectResults("Record.hasAnyCleanTextData [collect results]", { | 829 | Clipperz.Async.collectResults("Record.hasAnyCleanTextData [collect results]", { |
854 | 'versions':[ | 830 | 'versions':[ |
855 | MochiKit.Base.method(this, 'versions'), | 831 | MochiKit.Base.method(this, 'versions'), |
856 | MochiKit.Base.values, | 832 | MochiKit.Base.values, |
857 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), | 833 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), |
858 | Clipperz.Async.collectAll | 834 | Clipperz.Async.collectAll |
859 | ], | 835 | ], |
860 | 'directLogins': [ | 836 | 'directLogins': [ |
861 | MochiKit.Base.method(this, 'directLogins'), | 837 | MochiKit.Base.method(this, 'directLogins'), |
862 | MochiKit.Base.values, | 838 | MochiKit.Base.values, |
863 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), | 839 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), |
864 | Clipperz.Async.collectAll | 840 | Clipperz.Async.collectAll |
865 | ], | 841 | ], |
866 | 'super': [ | 842 | 'super': [ |
867 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasAnyCleanTextData, this) | 843 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasAnyCleanTextData, this) |
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js index d6202ff..cda5a41 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js | |||
@@ -1,70 +1,68 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.PM.DataModel.User.Header.Legacy depends on Clipperz.PM.DataModel.User!"; | 25 | throw "Clipperz.PM.DataModel.User.Header.Legacy depends on Clipperz.PM.DataModel.User!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } | 28 | if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } |
31 | 29 | ||
32 | Clipperz.PM.DataModel.User.Header.Legacy = function(args) { | 30 | Clipperz.PM.DataModel.User.Header.Legacy = function(args) { |
33 | //args = args || {}; | 31 | //args = args || {}; |
34 | Clipperz.PM.DataModel.User.Header.Legacy.superclass.constructor.apply(this, arguments); | 32 | Clipperz.PM.DataModel.User.Header.Legacy.superclass.constructor.apply(this, arguments); |
35 | 33 | ||
36 | this._retrieveRecordDetailFunction = args.retrieveRecordDetailFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); | 34 | this._retrieveRecordDetailFunction = args.retrieveRecordDetailFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); |
37 | this._records = null; | 35 | this._records = null; |
38 | //this._directLogins = null; | 36 | //this._directLogins = null; |
39 | 37 | ||
40 | return this; | 38 | return this; |
41 | } | 39 | } |
42 | 40 | ||
43 | 41 | ||
44 | Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.Legacy, Clipperz.PM.DataModel.EncryptedRemoteObject, { | 42 | Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.Legacy, Clipperz.PM.DataModel.EncryptedRemoteObject, { |
45 | 43 | ||
46 | 'toString': function() { | 44 | 'toString': function() { |
47 | return "Clipperz.PM.DataModel.User.Header.Legacy"; | 45 | return "Clipperz.PM.DataModel.User.Header.Legacy"; |
48 | }, | 46 | }, |
49 | 47 | ||
50 | //------------------------------------------------------------------------- | 48 | //------------------------------------------------------------------------- |
51 | 49 | ||
52 | 'retrieveRecordDetailFunction': function () { | 50 | 'retrieveRecordDetailFunction': function () { |
53 | return this._retrieveRecordDetailFunction; | 51 | return this._retrieveRecordDetailFunction; |
54 | }, | 52 | }, |
55 | 53 | ||
56 | //------------------------------------------------------------------------- | 54 | //------------------------------------------------------------------------- |
57 | 55 | ||
58 | 'getRecordKey': function (aRecordReference) { | 56 | 'getRecordKey': function (aRecordReference) { |
59 | var deferredResult; | 57 | var deferredResult; |
60 | 58 | ||
61 | deferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.getRecordKey", {trace:false}); | 59 | deferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.getRecordKey", {trace:false}); |
62 | deferredResult.addMethod(this, 'getRecordIndexData'); | 60 | deferredResult.addMethod(this, 'getRecordIndexData'); |
63 | deferredResult.addCallback(MochiKit.Base.itemgetter('key')) | 61 | deferredResult.addCallback(MochiKit.Base.itemgetter('key')) |
64 | deferredResult.callback(); | 62 | deferredResult.callback(); |
65 | 63 | ||
66 | return deferredResult; | 64 | return deferredResult; |
67 | }, | 65 | }, |
68 | 66 | ||
69 | //========================================================================= | 67 | //========================================================================= |
70 | 68 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js index 3528db6..e82da47 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js | |||
@@ -1,125 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.PM.DataModel.User.Header.OneTimePasswords depends on Clipperz.PM.DataModel.User!"; | 25 | throw "Clipperz.PM.DataModel.User.Header.OneTimePasswords depends on Clipperz.PM.DataModel.User!"; |
28 | } | 26 | } |
29 | if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } | 27 | if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } |
30 | 28 | ||
31 | //----------------------------------------------------------------------------- | 29 | //----------------------------------------------------------------------------- |
32 | 30 | ||
33 | Clipperz.PM.DataModel.User.Header.OneTimePasswords = function(args) { | 31 | Clipperz.PM.DataModel.User.Header.OneTimePasswords = function(args) { |
34 | Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.constructor.apply(this, arguments); | 32 | Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.constructor.apply(this, arguments); |
35 | 33 | ||
36 | this._oneTimePasswords = null; | 34 | this._oneTimePasswords = null; |
37 | 35 | ||
38 | return this; | 36 | return this; |
39 | } | 37 | } |
40 | 38 | ||
41 | //----------------------------------------------------------------------------- | 39 | //----------------------------------------------------------------------------- |
42 | 40 | ||
43 | Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.OneTimePasswords, Clipperz.PM.DataModel.EncryptedRemoteObject, { | 41 | Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.OneTimePasswords, Clipperz.PM.DataModel.EncryptedRemoteObject, { |
44 | 42 | ||
45 | 'toString': function() { | 43 | 'toString': function() { |
46 | return "Clipperz.PM.DataModel.User.Header.OneTimePasswords"; | 44 | return "Clipperz.PM.DataModel.User.Header.OneTimePasswords"; |
47 | }, | 45 | }, |
48 | 46 | ||
49 | //------------------------------------------------------------------------- | 47 | //------------------------------------------------------------------------- |
50 | /* | 48 | /* |
51 | 'packData': function (someData) { //++ | 49 | 'packData': function (someData) { //++ |
52 | var result; | 50 | var result; |
53 | 51 | ||
54 | console.log(">>> OneTimePasswords.packData", someData); | ||
55 | result = Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.packData.apply(this, arguments); | 52 | result = Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.packData.apply(this, arguments); |
56 | console.log("<<< OneTimePasswords.packData"); | ||
57 | 53 | ||
58 | return result; | 54 | return result; |
59 | }, | 55 | }, |
60 | */ | 56 | */ |
61 | //------------------------------------------------------------------------- | 57 | //------------------------------------------------------------------------- |
62 | /* | 58 | /* |
63 | 'packRemoteData': function (someData) { | 59 | 'packRemoteData': function (someData) { |
64 | var result; | 60 | var result; |
65 | 61 | ||
66 | console.log(">>> OneTimePasswords.packRemoteData", someData); | ||
67 | result = Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.packRemoteData.apply(this, arguments); | 62 | result = Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.packRemoteData.apply(this, arguments); |
68 | console.log("<<< OneTimePasswords.packRemoteData"); | ||
69 | 63 | ||
70 | return result; | 64 | return result; |
71 | }, | 65 | }, |
72 | */ | 66 | */ |
73 | //------------------------------------------------------------------------- | 67 | //------------------------------------------------------------------------- |
74 | /* | 68 | /* |
75 | 'prepareRemoteDataWithKey': function (aKey) { | 69 | 'prepareRemoteDataWithKey': function (aKey) { |
76 | var result; | 70 | var result; |
77 | 71 | ||
78 | console.log(">>> OneTimePasswords.prepareRemoteDataWithKey"); | ||
79 | result = Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.prepareRemoteDataWithKey.apply(this, arguments); | 72 | result = Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.prepareRemoteDataWithKey.apply(this, arguments); |
80 | console.log("<<< OneTimePasswords.prepareRemoteDataWithKey"); | ||
81 | 73 | ||
82 | return result; | 74 | return result; |
83 | }, | 75 | }, |
84 | */ | 76 | */ |
85 | //========================================================================= | 77 | //========================================================================= |
86 | 78 | ||
87 | 'oneTimePasswords': function () { | 79 | 'oneTimePasswords': function () { |
88 | vardeferredResult; | 80 | vardeferredResult; |
89 | 81 | ||
90 | deferredResult = new Clipperz.Async.Deferred("User.Header.OneTimePasswords.oneTimePasswords", {trace:false}); | 82 | deferredResult = new Clipperz.Async.Deferred("User.Header.OneTimePasswords.oneTimePasswords", {trace:false}); |
91 | if (this._oneTimePasswords == null) { | 83 | if (this._oneTimePasswords == null) { |
92 | deferredResult.addMethod(this, 'values') | 84 | deferredResult.addMethod(this, 'values') |
93 | deferredResult.addCallback(MochiKit.Base.bind(function (someData) { | 85 | deferredResult.addCallback(MochiKit.Base.bind(function (someData) { |
94 | varotpKey; | 86 | varotpKey; |
95 | 87 | ||
96 | this._oneTimePasswords = {}; | 88 | this._oneTimePasswords = {}; |
97 | 89 | ||
98 | for (otpKey in someData) { | 90 | for (otpKey in someData) { |
99 | var otp; | 91 | var otp; |
100 | var otpParameters; | 92 | var otpParameters; |
101 | 93 | ||
102 | otpParameters = Clipperz.Base.deepClone(someData[otpKey]); | 94 | otpParameters = Clipperz.Base.deepClone(someData[otpKey]); |
103 | otpParameters['reference'] = otpKey; | 95 | otpParameters['reference'] = otpKey; |
104 | 96 | ||
105 | otp = new Clipperz.PM.DataModel.OneTimePassword(otpParameters); | 97 | otp = new Clipperz.PM.DataModel.OneTimePassword(otpParameters); |
106 | this._oneTimePasswords[otpKey] = otp; | 98 | this._oneTimePasswords[otpKey] = otp; |
107 | } | 99 | } |
108 | 100 | ||
109 | return this._oneTimePasswords; | 101 | return this._oneTimePasswords; |
110 | 102 | ||
111 | }, this)); | 103 | }, this)); |
112 | deferredResult.callback(); | 104 | deferredResult.callback(); |
113 | } else { | 105 | } else { |
114 | deferredResult = MochiKit.Async.succeed(this._oneTimePasswords); | 106 | deferredResult = MochiKit.Async.succeed(this._oneTimePasswords); |
115 | } | 107 | } |
116 | 108 | ||
117 | return deferredResult; | 109 | return deferredResult; |
118 | }, | 110 | }, |
119 | 111 | ||
120 | //========================================================================= | 112 | //========================================================================= |
121 | __syntaxFix__: "syntax fix" | 113 | __syntaxFix__: "syntax fix" |
122 | }); | 114 | }); |
123 | 115 | ||
124 | //----------------------------------------------------------------------------- | 116 | //----------------------------------------------------------------------------- |
125 | 117 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Preferences.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Preferences.js index b164889..f1f95e8 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Preferences.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Preferences.js | |||
@@ -1,50 +1,48 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.PM.DataModel.User.Header.Preferences depends on Clipperz.PM.DataModel.User!"; | 25 | throw "Clipperz.PM.DataModel.User.Header.Preferences depends on Clipperz.PM.DataModel.User!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } | 28 | if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } |
31 | 29 | ||
32 | Clipperz.PM.DataModel.User.Header.Preferences = function(args) { | 30 | Clipperz.PM.DataModel.User.Header.Preferences = function(args) { |
33 | Clipperz.PM.DataModel.User.Header.Preferences.superclass.constructor.apply(this, arguments); | 31 | Clipperz.PM.DataModel.User.Header.Preferences.superclass.constructor.apply(this, arguments); |
34 | 32 | ||
35 | return this; | 33 | return this; |
36 | } | 34 | } |
37 | 35 | ||
38 | 36 | ||
39 | Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.Preferences, Clipperz.PM.DataModel.EncryptedRemoteObject, { | 37 | Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.Preferences, Clipperz.PM.DataModel.EncryptedRemoteObject, { |
40 | 38 | ||
41 | 'toString': function() { | 39 | 'toString': function() { |
42 | return "Clipperz.PM.DataModel.User.Header.Preferences"; | 40 | return "Clipperz.PM.DataModel.User.Header.Preferences"; |
43 | }, | 41 | }, |
44 | 42 | ||
45 | //------------------------------------------------------------------------- | 43 | //------------------------------------------------------------------------- |
46 | //========================================================================= | 44 | //========================================================================= |
47 | __syntaxFix__: "syntax fix" | 45 | __syntaxFix__: "syntax fix" |
48 | }); | 46 | }); |
49 | 47 | ||
50 | 48 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.RecordIndex.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.RecordIndex.js index f77ea80..5681f70 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.RecordIndex.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.RecordIndex.js | |||
@@ -1,512 +1,496 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.PM.DataModel.User.Header.RecordIndex depends on Clipperz.PM.DataModel.User!"; | 25 | throw "Clipperz.PM.DataModel.User.Header.RecordIndex depends on Clipperz.PM.DataModel.User!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } | 28 | if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } |
31 | 29 | ||
32 | Clipperz.PM.DataModel.User.Header.RecordIndex = function(args) { | 30 | Clipperz.PM.DataModel.User.Header.RecordIndex = function(args) { |
33 | Clipperz.PM.DataModel.User.Header.RecordIndex.superclass.constructor.apply(this, arguments); | 31 | Clipperz.PM.DataModel.User.Header.RecordIndex.superclass.constructor.apply(this, arguments); |
34 | 32 | ||
35 | //console.log("NEW Clipperz.PM.DataModel.User.Header.RecordIndex", args); | ||
36 | this._recordsData = new Clipperz.PM.DataModel.EncryptedRemoteObject({ | 33 | this._recordsData = new Clipperz.PM.DataModel.EncryptedRemoteObject({ |
37 | 'name':'recordsData', | 34 | 'name':'recordsData', |
38 | 'retrieveKeyFunction': args.retrieveKeyFunction, | 35 | 'retrieveKeyFunction': args.retrieveKeyFunction, |
39 | 'remoteData': { | 36 | 'remoteData': { |
40 | 'data': args.recordsData['data'], | 37 | 'data': args.recordsData['data'], |
41 | 'version': args.encryptedDataVersion, | 38 | 'version': args.encryptedDataVersion, |
42 | 'recordsStats': args.recordsStats | 39 | 'recordsStats': args.recordsStats |
43 | }//, | 40 | }//, |
44 | // 'encryptedDataKeypath': 'data', | 41 | // 'encryptedDataKeypath': 'data', |
45 | // 'encryptedVersionKeypath': 'version' | 42 | // 'encryptedVersionKeypath': 'version' |
46 | }); | 43 | }); |
47 | 44 | ||
48 | this._directLoginsData = new Clipperz.PM.DataModel.EncryptedRemoteObject({ | 45 | this._directLoginsData = new Clipperz.PM.DataModel.EncryptedRemoteObject({ |
49 | 'name':'directLoginsData', | 46 | 'name':'directLoginsData', |
50 | 'retrieveKeyFunction': args.retrieveKeyFunction, | 47 | 'retrieveKeyFunction': args.retrieveKeyFunction, |
51 | 'remoteData': { | 48 | 'remoteData': { |
52 | 'data': args.directLoginsData['data'], | 49 | 'data': args.directLoginsData['data'], |
53 | 'version': args.encryptedDataVersion | 50 | 'version': args.encryptedDataVersion |
54 | }//, | 51 | }//, |
55 | // 'encryptedDataKeypath': 'data', | 52 | // 'encryptedDataKeypath': 'data', |
56 | // 'encryptedVersionKeypath': 'version' | 53 | // 'encryptedVersionKeypath': 'version' |
57 | }); | 54 | }); |
58 | 55 | ||
59 | this._lock = new MochiKit.Async.DeferredLock(); | 56 | this._lock = new MochiKit.Async.DeferredLock(); |
60 | this._transientState = null; | 57 | this._transientState = null; |
61 | 58 | ||
62 | this._retrieveRecordDetailFunction = args.retrieveRecordDetailFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); | 59 | this._retrieveRecordDetailFunction = args.retrieveRecordDetailFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); |
63 | this._recordsIndex = args.recordsData['index'] || Clipperz.Base.exception.raise('MandatoryParameter'); | 60 | this._recordsIndex = args.recordsData['index'] || Clipperz.Base.exception.raise('MandatoryParameter'); |
64 | this._directLoginsIndex = args.directLoginsData['index']|| Clipperz.Base.exception.raise('MandatoryParameter'); | 61 | this._directLoginsIndex = args.directLoginsData['index']|| Clipperz.Base.exception.raise('MandatoryParameter'); |
65 | 62 | ||
66 | this._records = null; | 63 | this._records = null; |
67 | 64 | ||
68 | return this; | 65 | return this; |
69 | } | 66 | } |
70 | 67 | ||
71 | 68 | ||
72 | Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.RecordIndex, Object, { | 69 | Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.RecordIndex, Object, { |
73 | 70 | ||
74 | 'toString': function() { | 71 | 'toString': function() { |
75 | return "Clipperz.PM.DataModel.User.Header.RecordIndex"; | 72 | return "Clipperz.PM.DataModel.User.Header.RecordIndex"; |
76 | }, | 73 | }, |
77 | 74 | ||
78 | //------------------------------------------------------------------------- | 75 | //------------------------------------------------------------------------- |
79 | 76 | ||
80 | 'retrieveRecordDetailFunction': function () { | 77 | 'retrieveRecordDetailFunction': function () { |
81 | return this._retrieveRecordDetailFunction; | 78 | return this._retrieveRecordDetailFunction; |
82 | }, | 79 | }, |
83 | 80 | ||
84 | //------------------------------------------------------------------------- | 81 | //------------------------------------------------------------------------- |
85 | 82 | ||
86 | 'recordsIndex': function () { | 83 | 'recordsIndex': function () { |
87 | return this._recordsIndex; | 84 | return this._recordsIndex; |
88 | }, | 85 | }, |
89 | 86 | ||
90 | 'recordsData': function () { | 87 | 'recordsData': function () { |
91 | return this._recordsData; | 88 | return this._recordsData; |
92 | }, | 89 | }, |
93 | 90 | ||
94 | //------------------------------------------------------------------------- | 91 | //------------------------------------------------------------------------- |
95 | 92 | ||
96 | 'directLoginsIndex': function () { | 93 | 'directLoginsIndex': function () { |
97 | return this._directLoginsIndex; | 94 | return this._directLoginsIndex; |
98 | }, | 95 | }, |
99 | 96 | ||
100 | 'directLoginsData': function () { | 97 | 'directLoginsData': function () { |
101 | return this._directLoginsData; | 98 | return this._directLoginsData; |
102 | }, | 99 | }, |
103 | 100 | ||
104 | //------------------------------------------------------------------------- | 101 | //------------------------------------------------------------------------- |
105 | 102 | ||
106 | 'lock': function () { | 103 | 'lock': function () { |
107 | return this._lock; | 104 | return this._lock; |
108 | }, | 105 | }, |
109 | 106 | ||
110 | //------------------------------------------------------------------------- | 107 | //------------------------------------------------------------------------- |
111 | 108 | ||
112 | 'transientState': function () { | 109 | 'transientState': function () { |
113 | if (this._transientState == null) { | 110 | if (this._transientState == null) { |
114 | this._transientState = new Clipperz.KeyValueObjectStore(/*{'name':'User.Header.RecordIndex.transientState [1]'}*/); | 111 | this._transientState = new Clipperz.KeyValueObjectStore(/*{'name':'User.Header.RecordIndex.transientState [1]'}*/); |
115 | } | 112 | } |
116 | 113 | ||
117 | return this._transientState; | 114 | return this._transientState; |
118 | }, | 115 | }, |
119 | 116 | ||
120 | 'resetTransientState': function (isCommitting) { | 117 | 'resetTransientState': function (isCommitting) { |
121 | //console.log("######## UserHeaderRecordIndex - resetTransientState", Clipperz.Base.deepClone(this._transientState)); | ||
122 | if (this._transientState != null) { | 118 | if (this._transientState != null) { |
123 | this._transientState.removeAllData(); | 119 | this._transientState.removeAllData(); |
124 | } | 120 | } |
125 | 121 | ||
126 | this._transientState = null; | 122 | this._transientState = null; |
127 | }, | 123 | }, |
128 | 124 | ||
129 | //------------------------------------------------------------------------- | 125 | //------------------------------------------------------------------------- |
130 | 126 | ||
131 | 'getRecordKey': function (aRecordReference) { | 127 | 'getRecordKey': function (aRecordReference) { |
132 | return Clipperz.Async.callbacks("User.Header.RecordIndex.getRecordKey", [ | 128 | return Clipperz.Async.callbacks("User.Header.RecordIndex.getRecordKey", [ |
133 | MochiKit.Base.method(this, 'getRecordIndexData', aRecordReference), | 129 | MochiKit.Base.method(this, 'getRecordIndexData', aRecordReference), |
134 | MochiKit.Base.itemgetter('key') | 130 | MochiKit.Base.itemgetter('key') |
135 | ], {trace:false}); | 131 | ], {trace:false}); |
136 | }, | 132 | }, |
137 | 133 | ||
138 | 'setRecordKey': function (aRecordReference, aValue) { | 134 | 'setRecordKey': function (aRecordReference, aValue) { |
139 | return this.updateRecordIndexData(aRecordReference, 'key', aValue); | 135 | return this.updateRecordIndexData(aRecordReference, 'key', aValue); |
140 | }, | 136 | }, |
141 | 137 | ||
142 | //------------------------------------------------------------------------- | 138 | //------------------------------------------------------------------------- |
143 | 139 | ||
144 | 'getRecordIndexData': function (aRecordReference) { | 140 | 'getRecordIndexData': function (aRecordReference) { |
145 | return this.recordsData().getValue(this.recordsIndex()[aRecordReference]); | 141 | return this.recordsData().getValue(this.recordsIndex()[aRecordReference]); |
146 | }, | 142 | }, |
147 | 143 | ||
148 | //......................................................................... | 144 | //......................................................................... |
149 | 145 | ||
150 | 'updateRecordIndexData': function (aRecordReference, aKey, aValue) { | 146 | 'updateRecordIndexData': function (aRecordReference, aKey, aValue) { |
151 | return this.recordsData().setValue(this.recordsIndex()[aRecordReference]+'.'+aKey, aValue); | 147 | return this.recordsData().setValue(this.recordsIndex()[aRecordReference]+'.'+aKey, aValue); |
152 | }, | 148 | }, |
153 | 149 | ||
154 | //------------------------------------------------------------------------- | 150 | //------------------------------------------------------------------------- |
155 | 151 | ||
156 | 'getDirectLoginIndexData': function (aDirectLoginReference) { | 152 | 'getDirectLoginIndexData': function (aDirectLoginReference) { |
157 | return this.directLoginsData().getValue(this.directLoginsIndex()[aDirectLoginReference]); | 153 | return this.directLoginsData().getValue(this.directLoginsIndex()[aDirectLoginReference]); |
158 | }, | 154 | }, |
159 | 155 | ||
160 | 'setDirectLoginIndexData': function (aDirectLoginReference, aKey, aValue) { | 156 | 'setDirectLoginIndexData': function (aDirectLoginReference, aKey, aValue) { |
161 | //console.log("UserHeaderRecordIndex.setDirectLoginIndexData", aDirectLoginReference, this.directLoginsIndex()[aDirectLoginReference], aKey); | ||
162 | //if (MochiKit.Base.isUndefinedOrNull(this.directLoginsIndex()[aDirectLoginReference])) { | 157 | //if (MochiKit.Base.isUndefinedOrNull(this.directLoginsIndex()[aDirectLoginReference])) { |
163 | //throw "PIPPO"; | 158 | //throw "PIPPO"; |
164 | //} | 159 | //} |
165 | return this.directLoginsData().setValue(this.directLoginsIndex()[aDirectLoginReference] + '.' + aKey, aValue); | 160 | return this.directLoginsData().setValue(this.directLoginsIndex()[aDirectLoginReference] + '.' + aKey, aValue); |
166 | }, | 161 | }, |
167 | 162 | ||
168 | 'addDirectLoginIndexData': function (aDirectLoginReference) { | 163 | 'addDirectLoginIndexData': function (aDirectLoginReference) { |
169 | //console.log("UserHeaderRecordIndex.addDirectLoginIndexData", aDirectLoginReference, this.directLoginsIndex()[aDirectLoginReference]); | ||
170 | return this.directLoginsData().setValue(this.directLoginsIndex()[aDirectLoginReference], {}); | 164 | return this.directLoginsData().setValue(this.directLoginsIndex()[aDirectLoginReference], {}); |
171 | }, | 165 | }, |
172 | 166 | ||
173 | 'removeDirectLoginIndexData': function (aDirectLoginReference) { | 167 | 'removeDirectLoginIndexData': function (aDirectLoginReference) { |
174 | return this.directLoginsData().removeValue(this.directLoginsIndex()[aDirectLoginReference]) | 168 | return this.directLoginsData().removeValue(this.directLoginsIndex()[aDirectLoginReference]) |
175 | }, | 169 | }, |
176 | 170 | ||
177 | //------------------------------------------------------------------------- | 171 | //------------------------------------------------------------------------- |
178 | 172 | ||
179 | 'records': function () { | 173 | 'records': function () { |
180 | vardeferredResult; | 174 | vardeferredResult; |
181 | 175 | ||
182 | deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.records", {trace:false}); | 176 | deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.records", {trace:false}); |
183 | deferredResult.acquireLock(this.lock()); | 177 | deferredResult.acquireLock(this.lock()); |
184 | deferredResult.addCallback(MochiKit.Base.bind(function () { | 178 | deferredResult.addCallback(MochiKit.Base.bind(function () { |
185 | var innerDeferredResult; | 179 | var innerDeferredResult; |
186 | 180 | ||
187 | if (this._records == null) { | 181 | if (this._records == null) { |
188 | innerDeferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.records <inner deferred>", {trace:false}); | 182 | innerDeferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.records <inner deferred>", {trace:false}); |
189 | innerDeferredResult.collectResults({ | 183 | innerDeferredResult.collectResults({ |
190 | 'records': [ | 184 | 'records': [ |
191 | // MochiKit.Base.method(this.recordsData(), 'getObjectDataStore'), | 185 | // MochiKit.Base.method(this.recordsData(), 'getObjectDataStore'), |
192 | // MochiKit.Base.methodcaller('values') | 186 | // MochiKit.Base.methodcaller('values') |
193 | MochiKit.Base.method(this.recordsData(), 'values') | 187 | MochiKit.Base.method(this.recordsData(), 'values') |
194 | ], | 188 | ], |
195 | 'recordsStats': [ | 189 | 'recordsStats': [ |
196 | MochiKit.Base.method(this.recordsData(), 'getRemoteData'), | 190 | MochiKit.Base.method(this.recordsData(), 'getRemoteData'), |
197 | MochiKit.Base.itemgetter('recordsStats') | 191 | MochiKit.Base.itemgetter('recordsStats') |
198 | ], | 192 | ], |
199 | 'directLogins': [ | 193 | 'directLogins': [ |
200 | // MochiKit.Base.method(this.directLoginsData(), 'getObjectDataStore'), | 194 | // MochiKit.Base.method(this.directLoginsData(), 'getObjectDataStore'), |
201 | // MochiKit.Base.methodcaller('values') | 195 | // MochiKit.Base.methodcaller('values') |
202 | MochiKit.Base.method(this.directLoginsData(), 'values') | 196 | MochiKit.Base.method(this.directLoginsData(), 'values') |
203 | ] | 197 | ] |
204 | }) | 198 | }) |
205 | innerDeferredResult.addCallback(MochiKit.Base.bind(function (someData) { | 199 | innerDeferredResult.addCallback(MochiKit.Base.bind(function (someData) { |
206 | var indexReference; | 200 | var indexReference; |
207 | var recordsInvertedIndex; | 201 | var recordsInvertedIndex; |
208 | var directLoginsInvertedIndex; | 202 | var directLoginsInvertedIndex; |
209 | 203 | ||
210 | recordsInvertedIndex = Clipperz.PM.DataModel.User.Header.RecordIndex.invertIndex(this.recordsIndex()); | 204 | recordsInvertedIndex = Clipperz.PM.DataModel.User.Header.RecordIndex.invertIndex(this.recordsIndex()); |
211 | directLoginsInvertedIndex= Clipperz.PM.DataModel.User.Header.RecordIndex.invertIndex(this.directLoginsIndex()); | 205 | directLoginsInvertedIndex= Clipperz.PM.DataModel.User.Header.RecordIndex.invertIndex(this.directLoginsIndex()); |
212 | 206 | ||
213 | this._records = {}; | 207 | this._records = {}; |
214 | 208 | ||
215 | for (indexReference in someData['records']) { | 209 | for (indexReference in someData['records']) { |
216 | varrecord; | 210 | varrecord; |
217 | var reference; | 211 | var reference; |
218 | var updateDate; | 212 | var updateDate; |
219 | 213 | ||
220 | reference = recordsInvertedIndex[indexReference]; | 214 | reference = recordsInvertedIndex[indexReference]; |
221 | 215 | ||
222 | if (typeof(someData['recordsStats'][reference]) != 'undefined') { | 216 | if (typeof(someData['recordsStats'][reference]) != 'undefined') { |
223 | updateDate = someData['recordsStats'][reference]['updateDate']; | 217 | updateDate = someData['recordsStats'][reference]['updateDate']; |
224 | 218 | ||
225 | record = new Clipperz.PM.DataModel.Record({ | 219 | record = new Clipperz.PM.DataModel.Record({ |
226 | 'reference': reference, | 220 | 'reference': reference, |
227 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getRecordKey'), | 221 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getRecordKey'), |
228 | 'retrieveRemoteDataFunction':this.retrieveRecordDetailFunction(), | 222 | 'retrieveRemoteDataFunction':this.retrieveRecordDetailFunction(), |
229 | 223 | ||
230 | 'retrieveIndexDataFunction':MochiKit.Base.method(this, 'getRecordIndexData'), | 224 | 'retrieveIndexDataFunction':MochiKit.Base.method(this, 'getRecordIndexData'), |
231 | 'updateIndexDataFunction': MochiKit.Base.method(this, 'updateRecordIndexData'), | 225 | 'updateIndexDataFunction': MochiKit.Base.method(this, 'updateRecordIndexData'), |
232 | 'updateDate': updateDate, | 226 | 'updateDate': updateDate, |
233 | 227 | ||
234 | 'retrieveDirectLoginIndexDataFunction':MochiKit.Base.method(this, 'getDirectLoginIndexData'), | 228 | 'retrieveDirectLoginIndexDataFunction':MochiKit.Base.method(this, 'getDirectLoginIndexData'), |
235 | 'setDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'), | 229 | 'setDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'), |
236 | 'removeDirectLoginIndexDataFunction':MochiKit.Base.method(this, 'removeDirectLoginIndexData'), | 230 | 'removeDirectLoginIndexDataFunction':MochiKit.Base.method(this, 'removeDirectLoginIndexData'), |
237 | 231 | ||
238 | 'createNewDirectLoginFunction': MochiKit.Base.method(this, 'createNewDirectLogin') | 232 | 'createNewDirectLoginFunction': MochiKit.Base.method(this, 'createNewDirectLogin') |
239 | }); | 233 | }); |
240 | 234 | ||
241 | this._records[reference] = record; | 235 | this._records[reference] = record; |
242 | } else { | 236 | } else { |
243 | Clipperz.log("SKIPPING record " + reference + " as there are no stas associated - " + Clipperz.Base.serializeJSON(someData['records'][reference])); | 237 | Clipperz.log("SKIPPING record " + reference + " as there are no stas associated - " + Clipperz.Base.serializeJSON(someData['records'][reference])); |
244 | //# skip the record, as it seems it is not present in the DB | 238 | //# skip the record, as it seems it is not present in the DB |
245 | //updateDate = Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); | 239 | //updateDate = Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); |
246 | } | 240 | } |
247 | } | 241 | } |
248 | 242 | ||
249 | for (indexReference in someData['directLogins']) { | 243 | for (indexReference in someData['directLogins']) { |
250 | // vardirectLogin; | 244 | // vardirectLogin; |
251 | var reference; | 245 | var reference; |
252 | var record; | 246 | var record; |
253 | 247 | ||
254 | reference = directLoginsInvertedIndex[indexReference]; | 248 | reference = directLoginsInvertedIndex[indexReference]; |
255 | record = this._records[recordsInvertedIndex[someData['directLogins'][indexReference]['record']]]; | 249 | record = this._records[recordsInvertedIndex[someData['directLogins'][indexReference]['record']]]; |
256 | 250 | ||
257 | if (record != null) { | 251 | if (record != null) { |
258 | // directLogin = new Clipperz.PM.DataModel.DirectLogin({ | 252 | // directLogin = new Clipperz.PM.DataModel.DirectLogin({ |
259 | new Clipperz.PM.DataModel.DirectLogin({ | 253 | new Clipperz.PM.DataModel.DirectLogin({ |
260 | 'reference': reference, | 254 | 'reference': reference, |
261 | 'record': record | 255 | 'record': record |
262 | }); | 256 | }); |
263 | } else { | 257 | } else { |
264 | Clipperz.log("WARNING: DIRECT LOGIN without a matching RECORD!!"); | 258 | Clipperz.logWarning("WARNING: DIRECT LOGIN without a matching RECORD!!"); |
265 | //console.log("direct login data", someData['directLogins']); | ||
266 | //console.log("current direct login data", someData['directLogins'][indexReference]) | ||
267 | //console.log("reference", reference); | ||
268 | //console.log("record index", this.recordsIndex()); | ||
269 | //console.log("record inverted index", recordsInvertedIndex); | ||
270 | } | 259 | } |
271 | } | 260 | } |
272 | 261 | ||
273 | return this._records; | 262 | return this._records; |
274 | }, this)); | 263 | }, this)); |
275 | innerDeferredResult.callback(); | 264 | innerDeferredResult.callback(); |
276 | } else { | 265 | } else { |
277 | innerDeferredResult = MochiKit.Async.succeed(this._records); | 266 | innerDeferredResult = MochiKit.Async.succeed(this._records); |
278 | } | 267 | } |
279 | 268 | ||
280 | return innerDeferredResult; | 269 | return innerDeferredResult; |
281 | }, this)); | 270 | }, this)); |
282 | deferredResult.releaseLock(this.lock()); | 271 | deferredResult.releaseLock(this.lock()); |
283 | deferredResult.callback(); | 272 | deferredResult.callback(); |
284 | 273 | ||
285 | return deferredResult; | 274 | return deferredResult; |
286 | }, | 275 | }, |
287 | 276 | ||
288 | //------------------------------------------------------------------------- | 277 | //------------------------------------------------------------------------- |
289 | 278 | ||
290 | 'updateRecordIndexForNewRecord': function (aNewRecord) { | 279 | 'updateRecordIndexForNewRecord': function (aNewRecord) { |
291 | var newRecordIndex; | 280 | var newRecordIndex; |
292 | var recordReference; | 281 | var recordReference; |
293 | 282 | ||
294 | recordReference = aNewRecord.reference(); | 283 | recordReference = aNewRecord.reference(); |
295 | newRecordIndex = (MochiKit.Base.listMax(MochiKit.Base.map(MochiKit.Base.partial(MochiKit.Base.operator.mul, 1), MochiKit.Base.values(this.recordsIndex()))) + 1) + ''; | 284 | newRecordIndex = (MochiKit.Base.listMax(MochiKit.Base.map(MochiKit.Base.partial(MochiKit.Base.operator.mul, 1), MochiKit.Base.values(this.recordsIndex()))) + 1) + ''; |
296 | this.recordsIndex()[recordReference] = newRecordIndex; | 285 | this.recordsIndex()[recordReference] = newRecordIndex; |
297 | 286 | ||
298 | this.transientState().setValue('newlyCreatedRecordsIndex' + '.' + recordReference, newRecordIndex); | 287 | this.transientState().setValue('newlyCreatedRecordsIndex' + '.' + recordReference, newRecordIndex); |
299 | this.transientState().setValue('newlyCreatedRecordsReferences'+ '.' + recordReference, aNewRecord); | 288 | this.transientState().setValue('newlyCreatedRecordsReferences'+ '.' + recordReference, aNewRecord); |
300 | }, | 289 | }, |
301 | 290 | ||
302 | //......................................................................... | 291 | //......................................................................... |
303 | 292 | ||
304 | 'createNewRecord': function () { | 293 | 'createNewRecord': function () { |
305 | var deferredResult; | 294 | var deferredResult; |
306 | var newRecord; | 295 | var newRecord; |
307 | 296 | ||
308 | //console.log("#### new Clipperz.PM.DataModel.Record [4]"); | ||
309 | newRecord = new Clipperz.PM.DataModel.Record({ | 297 | newRecord = new Clipperz.PM.DataModel.Record({ |
310 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getRecordKey'), | 298 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getRecordKey'), |
311 | 'retrieveRemoteDataFunction':this.retrieveRecordDetailFunction(), | 299 | 'retrieveRemoteDataFunction':this.retrieveRecordDetailFunction(), |
312 | 300 | ||
313 | 'retrieveIndexDataFunction':MochiKit.Base.method(this, 'getRecordIndexData'), | 301 | 'retrieveIndexDataFunction':MochiKit.Base.method(this, 'getRecordIndexData'), |
314 | 'updateIndexDataFunction': MochiKit.Base.method(this, 'updateRecordIndexData'), | 302 | 'updateIndexDataFunction': MochiKit.Base.method(this, 'updateRecordIndexData'), |
315 | 'updateDate': Clipperz.PM.Date.formatDateWithUTCFormat(new Date()), | 303 | 'updateDate': Clipperz.PM.Date.formatDateWithUTCFormat(new Date()), |
316 | 304 | ||
317 | 'retrieveDirectLoginIndexDataFunction':MochiKit.Base.method(this, 'getDirectLoginIndexData'), | 305 | 'retrieveDirectLoginIndexDataFunction':MochiKit.Base.method(this, 'getDirectLoginIndexData'), |
318 | 'setDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'), | 306 | 'setDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'), |
319 | 'removeDirectLoginIndexDataFunction':MochiKit.Base.method(this, 'removeDirectLoginIndexData'), | 307 | 'removeDirectLoginIndexDataFunction':MochiKit.Base.method(this, 'removeDirectLoginIndexData'), |
320 | 308 | ||
321 | 'createNewDirectLoginFunction': MochiKit.Base.method(this, 'createNewDirectLogin') | 309 | 'createNewDirectLoginFunction': MochiKit.Base.method(this, 'createNewDirectLogin') |
322 | }); | 310 | }); |
323 | 311 | ||
324 | this.transientState().setValue('newRecordsReferences' + '.' + newRecord.reference(), newRecord); | 312 | this.transientState().setValue('newRecordsReferences' + '.' + newRecord.reference(), newRecord); |
325 | this.updateRecordIndexForNewRecord(newRecord); | 313 | this.updateRecordIndexForNewRecord(newRecord); |
326 | 314 | ||
327 | deferredResult = Clipperz.Async.callbacks("User.Header.RecordIndex.createNewRecord", [ | 315 | deferredResult = Clipperz.Async.callbacks("User.Header.RecordIndex.createNewRecord", [ |
328 | MochiKit.Base.method(this, 'records'), | 316 | MochiKit.Base.method(this, 'records'), |
329 | MochiKit.Base.partial(Clipperz.Async.setItemOnObject, newRecord.reference(), newRecord), | 317 | MochiKit.Base.partial(Clipperz.Async.setItemOnObject, newRecord.reference(), newRecord), |
330 | MochiKit.Base.method(this, 'setRecordKey', newRecord.reference(), Clipperz.PM.Crypto.randomKey()), | 318 | MochiKit.Base.method(this, 'setRecordKey', newRecord.reference(), Clipperz.PM.Crypto.randomKey()), |
331 | MochiKit.Base.method(newRecord, 'setLabel', ''), | 319 | MochiKit.Base.method(newRecord, 'setLabel', ''), |
332 | MochiKit.Base.partial(MochiKit.Async.succeed, newRecord) | 320 | MochiKit.Base.partial(MochiKit.Async.succeed, newRecord) |
333 | ], {trace:false}); | 321 | ], {trace:false}); |
334 | 322 | ||
335 | 323 | ||
336 | return deferredResult; | 324 | return deferredResult; |
337 | }, | 325 | }, |
338 | 326 | ||
339 | //------------------------------------------------------------------------- | 327 | //------------------------------------------------------------------------- |
340 | 328 | ||
341 | 'deleteRecord': function (aRecord) { | 329 | 'deleteRecord': function (aRecord) { |
342 | var deferredResult; | 330 | var deferredResult; |
343 | var recordReference; | 331 | var recordReference; |
344 | 332 | ||
345 | recordReference = aRecord.reference(); | 333 | recordReference = aRecord.reference(); |
346 | 334 | ||
347 | deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.deleteRecord", {trace:false}); | 335 | deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.deleteRecord", {trace:false}); |
348 | 336 | ||
349 | deferredResult.addMethod(aRecord, 'directLogins'); | 337 | deferredResult.addMethod(aRecord, 'directLogins'); |
350 | deferredResult.addCallback(MochiKit.Base.values); | 338 | deferredResult.addCallback(MochiKit.Base.values); |
351 | deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'removeDirectLogin')); | 339 | deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'removeDirectLogin')); |
352 | 340 | ||
353 | deferredResult.addMethod(this.recordsData(), 'removeValue', this.recordsIndex()[recordReference]); | 341 | deferredResult.addMethod(this.recordsData(), 'removeValue', this.recordsIndex()[recordReference]); |
354 | deferredResult.addCallback(MochiKit.Base.bind(function () { | 342 | deferredResult.addCallback(MochiKit.Base.bind(function () { |
355 | this.transientState().setValue('deleteRecordsIndex' + '.' + recordReference, this.recordsIndex()[recordReference]); | 343 | this.transientState().setValue('deleteRecordsIndex' + '.' + recordReference, this.recordsIndex()[recordReference]); |
356 | delete this.recordsIndex()[recordReference]; | 344 | delete this.recordsIndex()[recordReference]; |
357 | }, this)); | 345 | }, this)); |
358 | 346 | ||
359 | deferredResult.addMethod(this, 'records'); | 347 | deferredResult.addMethod(this, 'records'); |
360 | deferredResult.addCallback(MochiKit.Base.itemgetter(recordReference)); | 348 | deferredResult.addCallback(MochiKit.Base.itemgetter(recordReference)); |
361 | deferredResult.addMethod(this.transientState(), 'setValue', 'deleteRecordsReferences' + '.' + recordReference); | 349 | deferredResult.addMethod(this.transientState(), 'setValue', 'deleteRecordsReferences' + '.' + recordReference); |
362 | 350 | ||
363 | deferredResult.addMethod(this, 'records'); | 351 | deferredResult.addMethod(this, 'records'); |
364 | deferredResult.addCallback(MochiKit.Base.bind(function (someRecords) { | 352 | deferredResult.addCallback(MochiKit.Base.bind(function (someRecords) { |
365 | delete someRecords[recordReference]; | 353 | delete someRecords[recordReference]; |
366 | }, this)); | 354 | }, this)); |
367 | deferredResult.callback(); | 355 | deferredResult.callback(); |
368 | 356 | ||
369 | return deferredResult; | 357 | return deferredResult; |
370 | }, | 358 | }, |
371 | 359 | ||
372 | //========================================================================= | 360 | //========================================================================= |
373 | 361 | ||
374 | 'removeDirectLogin': function (aDirectLogin) { | 362 | 'removeDirectLogin': function (aDirectLogin) { |
375 | this.directLoginsData().removeValue(this.directLoginsIndex()[aDirectLogin.reference()]); | 363 | this.directLoginsData().removeValue(this.directLoginsIndex()[aDirectLogin.reference()]); |
376 | }, | 364 | }, |
377 | 365 | ||
378 | //------------------------------------------------------------------------- | 366 | //------------------------------------------------------------------------- |
379 | 367 | ||
380 | 'createNewDirectLogin': function (aRecord) { | 368 | 'createNewDirectLogin': function (aRecord) { |
381 | var newDirectLogin; | 369 | var newDirectLogin; |
382 | varnewDirectLoginIndexValue; | 370 | varnewDirectLoginIndexValue; |
383 | 371 | ||
384 | newDirectLogin = new Clipperz.PM.DataModel.DirectLogin({record:aRecord}); | 372 | newDirectLogin = new Clipperz.PM.DataModel.DirectLogin({record:aRecord}); |
385 | newDirectLoginIndexValue = MochiKit.Base.listMax(MochiKit.Base.map(function (aValue) { return aValue * 1; }, MochiKit.Base.values(this.directLoginsIndex()))) + 1; | 373 | newDirectLoginIndexValue = MochiKit.Base.listMax(MochiKit.Base.map(function (aValue) { return aValue * 1; }, MochiKit.Base.values(this.directLoginsIndex()))) + 1; |
386 | 374 | ||
387 | this.transientState().setValue('newDirectLoginReferences' + '.' + newDirectLogin.reference(), newDirectLogin); | 375 | this.transientState().setValue('newDirectLoginReferences' + '.' + newDirectLogin.reference(), newDirectLogin); |
388 | 376 | ||
389 | //console.log("UserHeaderRecordIndex.createNewDirectLogin [1]", newDirectLogin.reference(), newDirectLoginIndexValue); | ||
390 | this.directLoginsIndex()[newDirectLogin.reference()] = newDirectLoginIndexValue; | 377 | this.directLoginsIndex()[newDirectLogin.reference()] = newDirectLoginIndexValue; |
391 | //console.log("UserHeaderRecordIndex.createNewDirectLogin [2]", newDirectLogin.reference(), this.directLoginsIndex()[newDirectLogin.reference()]); | ||
392 | this.directLoginsData().setValue(this.directLoginsIndex()[newDirectLogin.reference()], {'record': this.recordsIndex()[aRecord.reference()]}); | 378 | this.directLoginsData().setValue(this.directLoginsIndex()[newDirectLogin.reference()], {'record': this.recordsIndex()[aRecord.reference()]}); |
393 | 379 | ||
394 | return newDirectLogin; | 380 | return newDirectLogin; |
395 | }, | 381 | }, |
396 | 382 | ||
397 | //========================================================================= | 383 | //========================================================================= |
398 | 384 | ||
399 | 'deleteAllCleanTextData': function () { | 385 | 'deleteAllCleanTextData': function () { |
400 | return Clipperz.Async.callbacks("User.Header.RecordIndex.deleteAllCleanTextData", [ | 386 | return Clipperz.Async.callbacks("User.Header.RecordIndex.deleteAllCleanTextData", [ |
401 | // MochiKit.Base.method(this, 'records'), | 387 | // MochiKit.Base.method(this, 'records'), |
402 | // MochiKit.Base.values, | 388 | // MochiKit.Base.values, |
403 | // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), | 389 | // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), |
404 | 390 | ||
405 | MochiKit.Base.method(this, 'recordsData'), | 391 | MochiKit.Base.method(this, 'recordsData'), |
406 | MochiKit.Base.methodcaller('deleteAllCleanTextData'), | 392 | MochiKit.Base.methodcaller('deleteAllCleanTextData'), |
407 | MochiKit.Base.method(this, 'directLoginsData'), | 393 | MochiKit.Base.method(this, 'directLoginsData'), |
408 | MochiKit.Base.methodcaller('deleteAllCleanTextData') | 394 | MochiKit.Base.methodcaller('deleteAllCleanTextData') |
409 | ], {trace:false}); | 395 | ], {trace:false}); |
410 | }, | 396 | }, |
411 | 397 | ||
412 | //------------------------------------------------------------------------- | 398 | //------------------------------------------------------------------------- |
413 | 399 | ||
414 | 'hasAnyCleanTextData': function () { | 400 | 'hasAnyCleanTextData': function () { |
415 | var deferredResult; | 401 | var deferredResult; |
416 | 402 | ||
417 | deferredResult = new Clipperz.Async.Deferred({trace:false}); | 403 | deferredResult = new Clipperz.Async.Deferred({trace:false}); |
418 | deferredResult.collectResults({ | 404 | deferredResult.collectResults({ |
419 | 'recordsData': [ | 405 | 'recordsData': [ |
420 | MochiKit.Base.method(this, 'recordsData'), | 406 | MochiKit.Base.method(this, 'recordsData'), |
421 | MochiKit.Base.methodcaller('hasAnyCleanTextData') | 407 | MochiKit.Base.methodcaller('hasAnyCleanTextData') |
422 | ], | 408 | ], |
423 | 'directLoginsData':[ | 409 | 'directLoginsData':[ |
424 | MochiKit.Base.method(this, 'directLoginsData'), | 410 | MochiKit.Base.method(this, 'directLoginsData'), |
425 | MochiKit.Base.methodcaller('hasAnyCleanTextData') | 411 | MochiKit.Base.methodcaller('hasAnyCleanTextData') |
426 | ], | 412 | ], |
427 | // 'records': [ | 413 | // 'records': [ |
428 | // MochiKit.Base.method(this, 'records'), | 414 | // MochiKit.Base.method(this, 'records'), |
429 | // MochiKit.Base.values, | 415 | // MochiKit.Base.values, |
430 | // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), | 416 | // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), |
431 | // Clipperz.Async.collectAll | 417 | // Clipperz.Async.collectAll |
432 | // ] | 418 | // ] |
433 | }); | 419 | }); |
434 | //deferredResult.addCallback(function (aValue) { console.log("USER.Header.RecordIndex.hasAnyCleanTextData", aValue); return aValue}); | ||
435 | 420 | ||
436 | // deferredResult.addCallback(MochiKit.Base.values); | 421 | // deferredResult.addCallback(MochiKit.Base.values); |
437 | // deferredResult.addCallback(MochiKit.Base.flattenArguments); | 422 | // deferredResult.addCallback(MochiKit.Base.flattenArguments); |
438 | // deferredResult.addCallback(function(someValues) { | 423 | // deferredResult.addCallback(function(someValues) { |
439 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); | 424 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); |
440 | // }); | 425 | // }); |
441 | deferredResult.addCallback(Clipperz.Async.or); | 426 | deferredResult.addCallback(Clipperz.Async.or); |
442 | 427 | ||
443 | deferredResult.callback(); | 428 | deferredResult.callback(); |
444 | 429 | ||
445 | return deferredResult; | 430 | return deferredResult; |
446 | }, | 431 | }, |
447 | 432 | ||
448 | //------------------------------------------------------------------------- | 433 | //------------------------------------------------------------------------- |
449 | 434 | ||
450 | 'hasPendingChanges': function () { | 435 | 'hasPendingChanges': function () { |
451 | vardeferredResult; | 436 | vardeferredResult; |
452 | 437 | ||
453 | deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.hasPendingChanges", {trace:false}); | 438 | deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.hasPendingChanges", {trace:false}); |
454 | deferredResult.collectResults({ | 439 | deferredResult.collectResults({ |
455 | 'recordsData': [ | 440 | 'recordsData': [ |
456 | MochiKit.Base.method(this, 'recordsData'), | 441 | MochiKit.Base.method(this, 'recordsData'), |
457 | MochiKit.Base.methodcaller('hasPendingChanges') | 442 | MochiKit.Base.methodcaller('hasPendingChanges') |
458 | ], | 443 | ], |
459 | 'directLoginsData': [ | 444 | 'directLoginsData': [ |
460 | MochiKit.Base.method(this, 'directLoginsData'), | 445 | MochiKit.Base.method(this, 'directLoginsData'), |
461 | MochiKit.Base.methodcaller('hasPendingChanges') | 446 | MochiKit.Base.methodcaller('hasPendingChanges') |
462 | ] | 447 | ] |
463 | }); | 448 | }); |
464 | //deferredResult.addCallback(function (aValue) { console.log("UserHeaderIndex.hasPendingResults", aValue); return aValue; }); | ||
465 | deferredResult.addCallback(Clipperz.Async.or); | 449 | deferredResult.addCallback(Clipperz.Async.or); |
466 | // deferredResult.addCallback(MochiKit.Base.values); | 450 | // deferredResult.addCallback(MochiKit.Base.values); |
467 | // deferredResult.addCallback(MochiKit.Base.flattenArguments); | 451 | // deferredResult.addCallback(MochiKit.Base.flattenArguments); |
468 | // deferredResult.addCallback(function(someValues) { | 452 | // deferredResult.addCallback(function(someValues) { |
469 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); | 453 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); |
470 | // }); | 454 | // }); |
471 | deferredResult.callback(); | 455 | deferredResult.callback(); |
472 | 456 | ||
473 | return deferredResult; | 457 | return deferredResult; |
474 | }, | 458 | }, |
475 | 459 | ||
476 | //------------------------------------------------------------------------- | 460 | //------------------------------------------------------------------------- |
477 | 461 | ||
478 | 'commitTransientState': function () { | 462 | 'commitTransientState': function () { |
479 | var deferredResult; | 463 | var deferredResult; |
480 | 464 | ||
481 | deferredResut = Clipperz.Async.callbacks("User.Header.RecordIndex.commitTransientState", [ | 465 | deferredResut = Clipperz.Async.callbacks("User.Header.RecordIndex.commitTransientState", [ |
482 | MochiKit.Base.method(this, 'recordsData'), | 466 | MochiKit.Base.method(this, 'recordsData'), |
483 | MochiKit.Base.methodcaller('commitTransientState'), | 467 | MochiKit.Base.methodcaller('commitTransientState'), |
484 | 468 | ||
485 | MochiKit.Base.method(this, 'directLoginsData'), | 469 | MochiKit.Base.method(this, 'directLoginsData'), |
486 | MochiKit.Base.methodcaller('commitTransientState'), | 470 | MochiKit.Base.methodcaller('commitTransientState'), |
487 | 471 | ||
488 | MochiKit.Base.method(this, 'resetTransientState', true) | 472 | MochiKit.Base.method(this, 'resetTransientState', true) |
489 | ], {trace:false}); | 473 | ], {trace:false}); |
490 | 474 | ||
491 | return deferredResult; | 475 | return deferredResult; |
492 | }, | 476 | }, |
493 | 477 | ||
494 | //------------------------------------------------------------------------- | 478 | //------------------------------------------------------------------------- |
495 | 479 | ||
496 | 'revertChanges': function () { | 480 | 'revertChanges': function () { |
497 | return Clipperz.Async.callbacks("User.Header.RecordIndex.revertChanges", [ | 481 | return Clipperz.Async.callbacks("User.Header.RecordIndex.revertChanges", [ |
498 | MochiKit.Base.method(this, 'recordsData'), | 482 | MochiKit.Base.method(this, 'recordsData'), |
499 | MochiKit.Base.methodcaller('revertChanges'), | 483 | MochiKit.Base.methodcaller('revertChanges'), |
500 | 484 | ||
501 | // MochiKit.Base.method(this, 'directLoginsData'), | 485 | // MochiKit.Base.method(this, 'directLoginsData'), |
502 | // MochiKit.Base.methodcaller('revertChanges'), | 486 | // MochiKit.Base.methodcaller('revertChanges'), |
503 | 487 | ||
504 | MochiKit.Base.method(this, 'records'), | 488 | MochiKit.Base.method(this, 'records'), |
505 | MochiKit.Base.bind(function (someRecords) { | 489 | MochiKit.Base.bind(function (someRecords) { |
506 | varrecordReference; | 490 | varrecordReference; |
507 | 491 | ||
508 | for (recordReference in this.transientState().getValue('deleteRecordsReferences')) { | 492 | for (recordReference in this.transientState().getValue('deleteRecordsReferences')) { |
509 | this.recordsIndex()[recordReference] = this.transientState().getValue('deleteRecordsIndex' + '.' + recordReference); | 493 | this.recordsIndex()[recordReference] = this.transientState().getValue('deleteRecordsIndex' + '.' + recordReference); |
510 | someRecords[recordReference] = this.transientState().getValue('deleteRecordsReferences' + '.' + recordReference); | 494 | someRecords[recordReference] = this.transientState().getValue('deleteRecordsReferences' + '.' + recordReference); |
511 | } | 495 | } |
512 | 496 | ||
@@ -525,97 +509,96 @@ Clipperz.log("WARNING: DIRECT LOGIN without a matching RECORD!!"); | |||
525 | //this.directLoginsIndex()[newDirectLogin.reference()] = newDirectLoginIndexValue; | 509 | //this.directLoginsIndex()[newDirectLogin.reference()] = newDirectLoginIndexValue; |
526 | //this.directLoginsData().setValue(this.directLoginsIndex()[newDirectLogin.reference()], {'record': this.recordsIndex()[aRecord.reference()]}); | 510 | //this.directLoginsData().setValue(this.directLoginsIndex()[newDirectLogin.reference()], {'record': this.recordsIndex()[aRecord.reference()]}); |
527 | 511 | ||
528 | 512 | ||
529 | // for (directLoginReference in this.transientState().getValue('deleteDirectLoginReferences')) { | 513 | // for (directLoginReference in this.transientState().getValue('deleteDirectLoginReferences')) { |
530 | // someDirectLogins[directLoginReference] = this.transientState().getValue('deleteDirectLoginReferences' + '.' + recordReference); | 514 | // someDirectLogins[directLoginReference] = this.transientState().getValue('deleteDirectLoginReferences' + '.' + recordReference); |
531 | // } | 515 | // } |
532 | 516 | ||
533 | for (directLoginReference in this.transientState().getValue('newDirectLoginReferences')) { | 517 | for (directLoginReference in this.transientState().getValue('newDirectLoginReferences')) { |
534 | // this.directLoginsData().removeValue(this.directLoginsIndex()[directLoginReference]); | 518 | // this.directLoginsData().removeValue(this.directLoginsIndex()[directLoginReference]); |
535 | delete this.directLoginsIndex()[directLoginReference]; | 519 | delete this.directLoginsIndex()[directLoginReference]; |
536 | } | 520 | } |
537 | }, this), | 521 | }, this), |
538 | 522 | ||
539 | MochiKit.Base.method(this, 'directLoginsData'), | 523 | MochiKit.Base.method(this, 'directLoginsData'), |
540 | MochiKit.Base.methodcaller('revertChanges'), | 524 | MochiKit.Base.methodcaller('revertChanges'), |
541 | 525 | ||
542 | MochiKit.Base.method(this, 'resetTransientState', false) | 526 | MochiKit.Base.method(this, 'resetTransientState', false) |
543 | ], {trace:false}); | 527 | ], {trace:false}); |
544 | }, | 528 | }, |
545 | 529 | ||
546 | //------------------------------------------------------------------------- | 530 | //------------------------------------------------------------------------- |
547 | 531 | ||
548 | 'prepareRemoteDataWithKey': function (aKey) { | 532 | 'prepareRemoteDataWithKey': function (aKey) { |
549 | // "records": { | 533 | // "records": { |
550 | // "index": { | 534 | // "index": { |
551 | // "eeda70e0392261967bda71c3764da78989c45bbd2bb7be6b941b90f81d9b81b5": "0", | 535 | // "eeda70e0392261967bda71c3764da78989c45bbd2bb7be6b941b90f81d9b81b5": "0", |
552 | // "13a5e52976337ab210903cd04872588e1b21fb72bc183e91aa25c494b8138551": "1", | 536 | // "13a5e52976337ab210903cd04872588e1b21fb72bc183e91aa25c494b8138551": "1", |
553 | // ... | 537 | // ... |
554 | // "465a067a0bd2b470fa834de5397e38494de0c7707938262fae3427932e219744": "18", | 538 | // "465a067a0bd2b470fa834de5397e38494de0c7707938262fae3427932e219744": "18", |
555 | // "4fd1dc2ca860b7fb47cef10a84edb3270da05510b0a30a6b0b083898712d4b9e": "19" | 539 | // "4fd1dc2ca860b7fb47cef10a84edb3270da05510b0a30a6b0b083898712d4b9e": "19" |
556 | // }, | 540 | // }, |
557 | // "data": "n+AzGEEQXaSRSY4d ... BDypotrXgPo94uHfoXvGFzwCn8w=" | 541 | // "data": "n+AzGEEQXaSRSY4d ... BDypotrXgPo94uHfoXvGFzwCn8w=" |
558 | // }, | 542 | // }, |
559 | // "directLogins": { | 543 | // "directLogins": { |
560 | // "index": { | 544 | // "index": { |
561 | // "61e87fdc4f1d9112e3b30c1f6812d095dcdb24f014c83319091eb6c9899ec348":"0", | 545 | // "61e87fdc4f1d9112e3b30c1f6812d095dcdb24f014c83319091eb6c9899ec348":"0", |
562 | // "989593d4c48929f0c8f1581aa96969c622807e99619ed4732026e967530a68ad":"1", | 546 | // "989593d4c48929f0c8f1581aa96969c622807e99619ed4732026e967530a68ad":"1", |
563 | // ... | 547 | // ... |
564 | // "cb9ae0bba1957075ccdbfd3b3481704d62087687a2ac7c411a4f07d444bde0f7":"17", | 548 | // "cb9ae0bba1957075ccdbfd3b3481704d62087687a2ac7c411a4f07d444bde0f7":"17", |
565 | // "7e1d069b7fa57c03bd7bf48807520feb953157834503aaff8c9d493f37dea69d":"18" | 549 | // "7e1d069b7fa57c03bd7bf48807520feb953157834503aaff8c9d493f37dea69d":"18" |
566 | // }, | 550 | // }, |
567 | // "data":"5YG9KKU/OZ5guUgFlms6k1 ... ZG/5Fn0uN+LoAsNfHm+EE62x" | 551 | // "data":"5YG9KKU/OZ5guUgFlms6k1 ... ZG/5Fn0uN+LoAsNfHm+EE62x" |
568 | // }, | 552 | // }, |
569 | 553 | ||
570 | var deferredResult; | 554 | var deferredResult; |
571 | var result; | 555 | var result; |
572 | 556 | ||
573 | //console.log("recordsIndex", this.recordsIndex()); | ||
574 | result = {}; | 557 | result = {}; |
575 | 558 | ||
576 | deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.prepareRemoteDataWithKey", {trace:false}); | 559 | deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.prepareRemoteDataWithKey", {trace:false}); |
577 | deferredResult.collectResults({ | 560 | deferredResult.collectResults({ |
578 | 'index':MochiKit.Base.partial(MochiKit.Async.succeed, this.recordsIndex()), | 561 | 'index':MochiKit.Base.partial(MochiKit.Async.succeed, this.recordsIndex()), |
579 | 'data': [ | 562 | 'data': [ |
580 | MochiKit.Base.method(this.recordsData(), 'prepareRemoteDataWithKey', aKey), | 563 | MochiKit.Base.method(this.recordsData(), 'prepareRemoteDataWithKey', aKey), |
581 | MochiKit.Base.itemgetter('data') | 564 | MochiKit.Base.itemgetter('data') |
582 | ] | 565 | ] |
583 | }); | 566 | }); |
584 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'records'); | 567 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'records'); |
585 | 568 | ||
586 | deferredResult.collectResults({ | 569 | deferredResult.collectResults({ |
587 | 'index':MochiKit.Base.partial(MochiKit.Async.succeed, this.directLoginsIndex()), | 570 | 'index':MochiKit.Base.partial(MochiKit.Async.succeed, this.directLoginsIndex()), |
588 | 'data': [ | 571 | 'data': [ |
589 | MochiKit.Base.method(this.directLoginsData(), 'prepareRemoteDataWithKey', aKey), | 572 | MochiKit.Base.method(this.directLoginsData(), 'prepareRemoteDataWithKey', aKey), |
590 | MochiKit.Base.itemgetter('data') | 573 | MochiKit.Base.itemgetter('data') |
591 | ] | 574 | ] |
592 | }); | 575 | }); |
593 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'directLogins'); | 576 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'directLogins'); |
594 | 577 | ||
595 | deferredResult.addCallback(MochiKit.Async.succeed, result); | 578 | deferredResult.addCallback(MochiKit.Async.succeed, result); |
596 | 579 | ||
597 | deferredResult.callback(); | 580 | deferredResult.callback(); |
598 | 581 | ||
599 | return deferredResult; | 582 | return deferredResult; |
600 | }, | 583 | }, |
601 | 584 | ||
602 | //------------------------------------------------------------------------- | 585 | //------------------------------------------------------------------------- |
603 | 586 | ||
604 | 'updateRecordKeyAndPrepareRemoteData': function (aRecord) { | 587 | 'updateRecordKeyAndPrepareRemoteData': function (aRecord) { |
605 | varnewRecordKey; | 588 | varnewRecordKey; |
606 | var deferredResult; | 589 | var deferredResult; |
607 | 590 | ||
608 | newRecordKey = Clipperz.PM.Crypto.randomKey(); | 591 | newRecordKey = Clipperz.PM.Crypto.randomKey(); |
609 | 592 | ||
610 | deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.updateRecordKeyAndPrepareRemoteData", {trace:false}); | 593 | deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.updateRecordKeyAndPrepareRemoteData", {trace:false}); |
611 | deferredResult.addCallback(MochiKit.Base.method(aRecord, 'prepareRemoteDataWithKey', newRecordKey)); | 594 | deferredResult.addCallback(MochiKit.Base.method(aRecord, 'prepareRemoteDataWithKey', newRecordKey)); |
612 | deferredResult.addCallbackPass(MochiKit.Base.method(this, 'setRecordKey', aRecord.reference(), newRecordKey)); | 595 | deferredResult.addCallbackPass(MochiKit.Base.method(this, 'setRecordKey', aRecord.reference(), newRecordKey)); |
613 | deferredResult.callback(); | 596 | deferredResult.callback(); |
614 | 597 | ||
615 | return deferredResult; | 598 | return deferredResult; |
616 | }, | 599 | }, |
617 | 600 | ||
618 | //......................................................................... | 601 | //......................................................................... |
619 | 602 | ||
620 | 'removeNewRecordWithNoChanges': function (aRecord) { | 603 | 'removeNewRecordWithNoChanges': function (aRecord) { |
621 | var deferredResult; | 604 | var deferredResult; |
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.js index 646ce21..fd18faf 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.js | |||
@@ -1,70 +1,68 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 27 | ||
30 | 28 | ||
31 | //############################################################################# | 29 | //############################################################################# |
32 | 30 | ||
33 | Clipperz.PM.DataModel.User = function (args) { | 31 | Clipperz.PM.DataModel.User = function (args) { |
34 | args = args || {}; | 32 | args = args || {}; |
35 | 33 | ||
36 | Clipperz.PM.DataModel.User.superclass.constructor.apply(this, arguments); | 34 | Clipperz.PM.DataModel.User.superclass.constructor.apply(this, arguments); |
37 | 35 | ||
38 | this._username = args.username || null; | 36 | this._username = args.username || null; |
39 | this._getPassphraseFunction = args.getPassphraseFunction || null; | 37 | this._getPassphraseFunction = args.getPassphraseFunction || null; |
40 | 38 | ||
41 | this._data = null; | 39 | this._data = null; |
42 | 40 | ||
43 | this._connection = null; | 41 | this._connection = null; |
44 | this._connectionVersion = 'current'; | 42 | this._connectionVersion = 'current'; |
45 | 43 | ||
46 | this._serverData = null; | 44 | this._serverData = null; |
47 | //this._serverLockValue = null; | 45 | //this._serverLockValue = null; |
48 | this._transientState = null; | 46 | this._transientState = null; |
49 | 47 | ||
50 | this._deferredLocks = { | 48 | this._deferredLocks = { |
51 | 'passphrase': new MochiKit.Async.DeferredLock(), | 49 | 'passphrase': new MochiKit.Async.DeferredLock(), |
52 | 'serverData': new MochiKit.Async.DeferredLock(), | 50 | 'serverData': new MochiKit.Async.DeferredLock(), |
53 | // 'recordsIndex': new MochiKit.Async.DeferredLock(), | 51 | // 'recordsIndex': new MochiKit.Async.DeferredLock(), |
54 | // 'directLoginsIndex':new MochiKit.Async.DeferredLock() | 52 | // 'directLoginsIndex':new MochiKit.Async.DeferredLock() |
55 | // 'preferences': new MochiKit.Async.DeferredLock() | 53 | // 'preferences': new MochiKit.Async.DeferredLock() |
56 | // 'oneTimePasswords': new MochiKit.Async.DeferredLock() | 54 | // 'oneTimePasswords': new MochiKit.Async.DeferredLock() |
57 | '__syntaxFix__': 'syntax fix' | 55 | '__syntaxFix__': 'syntax fix' |
58 | }; | 56 | }; |
59 | 57 | ||
60 | return this; | 58 | return this; |
61 | } | 59 | } |
62 | 60 | ||
63 | Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | 61 | Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { |
64 | 62 | ||
65 | 'toString': function () { | 63 | 'toString': function () { |
66 | return "Clipperz.PM.DataModel.User - " + this.username(); | 64 | return "Clipperz.PM.DataModel.User - " + this.username(); |
67 | }, | 65 | }, |
68 | 66 | ||
69 | //------------------------------------------------------------------------- | 67 | //------------------------------------------------------------------------- |
70 | 68 | ||
@@ -283,186 +281,184 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
283 | 281 | ||
284 | return result; | 282 | return result; |
285 | }, | 283 | }, |
286 | 284 | ||
287 | //------------------------------------------------------------------------- | 285 | //------------------------------------------------------------------------- |
288 | 286 | ||
289 | 'lock': function () { | 287 | 'lock': function () { |
290 | return Clipperz.Async.callbacks("User.lock", [ | 288 | return Clipperz.Async.callbacks("User.lock", [ |
291 | MochiKit.Base.method(this, 'deleteAllCleanTextData') | 289 | MochiKit.Base.method(this, 'deleteAllCleanTextData') |
292 | ], {trace:false}); | 290 | ], {trace:false}); |
293 | }, | 291 | }, |
294 | 292 | ||
295 | //------------------------------------------------------------------------- | 293 | //------------------------------------------------------------------------- |
296 | 294 | ||
297 | 'logout': function () { | 295 | 'logout': function () { |
298 | return Clipperz.Async.callbacks("User.logout", [ | 296 | return Clipperz.Async.callbacks("User.logout", [ |
299 | MochiKit.Base.method(this, 'deleteAllCleanTextData'), | 297 | MochiKit.Base.method(this, 'deleteAllCleanTextData'), |
300 | MochiKit.Base.method(this.connection(), 'logout') | 298 | MochiKit.Base.method(this.connection(), 'logout') |
301 | ], {trace:false}); | 299 | ], {trace:false}); |
302 | }, | 300 | }, |
303 | 301 | ||
304 | //------------------------------------------------------------------------- | 302 | //------------------------------------------------------------------------- |
305 | 303 | ||
306 | 'headerFormatVersion': function(anHeader) { | 304 | 'headerFormatVersion': function(anHeader) { |
307 | var result; | 305 | var result; |
308 | 306 | ||
309 | if (anHeader.charAt(0) == '{') { | 307 | if (anHeader.charAt(0) == '{') { |
310 | varheaderData; | 308 | varheaderData; |
311 | 309 | ||
312 | headerData = Clipperz.Base.evalJSON(anHeader); | 310 | headerData = Clipperz.Base.evalJSON(anHeader); |
313 | result = headerData['version']; | 311 | result = headerData['version']; |
314 | } else { | 312 | } else { |
315 | result = 'LEGACY'; | 313 | result = 'LEGACY'; |
316 | } | 314 | } |
317 | 315 | ||
318 | return result; | 316 | return result; |
319 | }, | 317 | }, |
320 | 318 | ||
321 | //------------------------------------------------------------------------- | 319 | //------------------------------------------------------------------------- |
322 | 320 | ||
323 | 'unpackServerData': function (someServerData) { | 321 | 'unpackServerData': function (someServerData) { |
324 | var unpackedData; | 322 | var unpackedData; |
325 | var headerVersion; | 323 | var headerVersion; |
326 | 324 | ||
327 | varrecordsIndex; | 325 | varrecordsIndex; |
328 | var preferences; | 326 | var preferences; |
329 | var oneTimePasswords; | 327 | var oneTimePasswords; |
330 | 328 | ||
331 | //console.log(">>> ***************** user.unpackServerData", someServerData); | ||
332 | // this.setServerLockValue(someServerData['lock']); | 329 | // this.setServerLockValue(someServerData['lock']); |
333 | 330 | ||
334 | headerVersion = this.headerFormatVersion(someServerData['header']); | 331 | headerVersion = this.headerFormatVersion(someServerData['header']); |
335 | 332 | ||
336 | switch (headerVersion) { | 333 | switch (headerVersion) { |
337 | case 'LEGACY': | 334 | case 'LEGACY': |
338 | varlegacyHeader; | 335 | varlegacyHeader; |
339 | 336 | ||
340 | legacyHeader = new Clipperz.PM.DataModel.User.Header.Legacy({ | 337 | legacyHeader = new Clipperz.PM.DataModel.User.Header.Legacy({ |
341 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), | 338 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), |
342 | 'remoteData': { | 339 | 'remoteData': { |
343 | 'data': someServerData['header'], | 340 | 'data': someServerData['header'], |
344 | 'version': someServerData['version'], | 341 | 'version': someServerData['version'], |
345 | 'recordsStats': someServerData['recordsStats'] | 342 | 'recordsStats': someServerData['recordsStats'] |
346 | }, | 343 | }, |
347 | // 'encryptedDataKeypath': 'data', | 344 | // 'encryptedDataKeypath': 'data', |
348 | // 'encryptedVersionKeypath': 'version', | 345 | // 'encryptedVersionKeypath': 'version', |
349 | 'retrieveRecordDetailFunction':MochiKit.Base.method(this, 'getRecordDetail') | 346 | 'retrieveRecordDetailFunction':MochiKit.Base.method(this, 'getRecordDetail') |
350 | }); | 347 | }); |
351 | 348 | ||
352 | recordsIndex = legacyHeader; | 349 | recordsIndex = legacyHeader; |
353 | preferences = legacyHeader; | 350 | preferences = legacyHeader; |
354 | oneTimePasswords= legacyHeader; | 351 | oneTimePasswords= legacyHeader; |
355 | break; | 352 | break; |
356 | case '0.1': | 353 | case '0.1': |
357 | varheaderData; | 354 | varheaderData; |
358 | 355 | ||
359 | headerData = Clipperz.Base.evalJSON(someServerData['header']); | 356 | headerData = Clipperz.Base.evalJSON(someServerData['header']); |
360 | 357 | ||
361 | recordsIndex = new Clipperz.PM.DataModel.User.Header.RecordIndex({ | 358 | recordsIndex = new Clipperz.PM.DataModel.User.Header.RecordIndex({ |
362 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), | 359 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), |
363 | 'recordsData': headerData['records'], | 360 | 'recordsData': headerData['records'], |
364 | 'recordsStats': someServerData['recordsStats'], | 361 | 'recordsStats': someServerData['recordsStats'], |
365 | 'directLoginsData': headerData['directLogins'], | 362 | 'directLoginsData': headerData['directLogins'], |
366 | 'encryptedDataVersion': someServerData['version'], | 363 | 'encryptedDataVersion': someServerData['version'], |
367 | 'retrieveRecordDetailFunction':MochiKit.Base.method(this, 'getRecordDetail') | 364 | 'retrieveRecordDetailFunction':MochiKit.Base.method(this, 'getRecordDetail') |
368 | }); | 365 | }); |
369 | 366 | ||
370 | //Still missing a test case that actually fais with the old version of the code, where the check for undefined was missing | 367 | //Still missing a test case that actually fais with the old version of the code, where the check for undefined was missing |
371 | if (typeof(headerData['preferences']) != 'undefined') { | 368 | if (typeof(headerData['preferences']) != 'undefined') { |
372 | preferences= new Clipperz.PM.DataModel.User.Header.Preferences({ | 369 | preferences= new Clipperz.PM.DataModel.User.Header.Preferences({ |
373 | 'name':'preferences', | 370 | 'name':'preferences', |
374 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), | 371 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), |
375 | 'remoteData': { | 372 | 'remoteData': { |
376 | 'data': headerData['preferences']['data'], | 373 | 'data': headerData['preferences']['data'], |
377 | 'version': someServerData['version'] | 374 | 'version': someServerData['version'] |
378 | } | 375 | } |
379 | }); | 376 | }); |
380 | } else { | 377 | } else { |
381 | preferences= new Clipperz.PM.DataModel.User.Header.Preferences({ | 378 | preferences= new Clipperz.PM.DataModel.User.Header.Preferences({ |
382 | 'name':'preferences', | 379 | 'name':'preferences', |
383 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') | 380 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') |
384 | }); | 381 | }); |
385 | } | 382 | } |
386 | 383 | ||
387 | if (typeof(headerData['oneTimePasswords']) != 'undefined') { | 384 | if (typeof(headerData['oneTimePasswords']) != 'undefined') { |
388 | oneTimePasswords = new Clipperz.PM.DataModel.User.Header.OneTimePasswords({ | 385 | oneTimePasswords = new Clipperz.PM.DataModel.User.Header.OneTimePasswords({ |
389 | 'name':'preferences', | 386 | 'name':'preferences', |
390 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), | 387 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), |
391 | 'remoteData': { | 388 | 'remoteData': { |
392 | 'data': headerData['oneTimePasswords']['data'], | 389 | 'data': headerData['oneTimePasswords']['data'], |
393 | 'version': someServerData['version'] | 390 | 'version': someServerData['version'] |
394 | } | 391 | } |
395 | }); | 392 | }); |
396 | } else { | 393 | } else { |
397 | oneTimePasswords = new Clipperz.PM.DataModel.User.Header.OneTimePasswords({ | 394 | oneTimePasswords = new Clipperz.PM.DataModel.User.Header.OneTimePasswords({ |
398 | 'name':'preferences', | 395 | 'name':'preferences', |
399 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') | 396 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') |
400 | }); | 397 | }); |
401 | } | 398 | } |
402 | 399 | ||
403 | break; | 400 | break; |
404 | } | 401 | } |
405 | 402 | ||
406 | unpackedData = { | 403 | unpackedData = { |
407 | 'version': someServerData['version'], | 404 | 'version': someServerData['version'], |
408 | 'statistics': someServerData['statistics'], | 405 | 'statistics': someServerData['statistics'], |
409 | 'header': { | 406 | 'header': { |
410 | 'data': someServerData['header'], | 407 | 'data': someServerData['header'], |
411 | 'version': headerVersion, | 408 | 'version': headerVersion, |
412 | 409 | ||
413 | 'recordsIndex': recordsIndex, | 410 | 'recordsIndex': recordsIndex, |
414 | 'preferences': preferences, | 411 | 'preferences': preferences, |
415 | 'oneTimePasswords': oneTimePasswords | 412 | 'oneTimePasswords': oneTimePasswords |
416 | } | 413 | } |
417 | }; | 414 | }; |
418 | 415 | ||
419 | this._serverData = unpackedData; | 416 | this._serverData = unpackedData; |
420 | //console.log("<<< ***************** user.unpackServerData", this._serverData); | ||
421 | 417 | ||
422 | return this._serverData; | 418 | return this._serverData; |
423 | }, | 419 | }, |
424 | 420 | ||
425 | //------------------------------------------------------------------------- | 421 | //------------------------------------------------------------------------- |
426 | 422 | ||
427 | 'getServerData': function() { | 423 | 'getServerData': function() { |
428 | var deferredResult; | 424 | var deferredResult; |
429 | 425 | ||
430 | deferredResult = new Clipperz.Async.Deferred("User.getServerData", {trace:false}); | 426 | deferredResult = new Clipperz.Async.Deferred("User.getServerData", {trace:false}); |
431 | deferredResult.acquireLock(this.deferredLockForSection('serverData')); | 427 | deferredResult.acquireLock(this.deferredLockForSection('serverData')); |
432 | deferredResult.addCallback(MochiKit.Base.bind(function(aResult) { | 428 | deferredResult.addCallback(MochiKit.Base.bind(function(aResult) { |
433 | var innerDeferredResult; | 429 | var innerDeferredResult; |
434 | 430 | ||
435 | innerDeferredResult = new Clipperz.Async.Deferred("User.getUserDetails.innerDeferred", {trace:false}); | 431 | innerDeferredResult = new Clipperz.Async.Deferred("User.getUserDetails.innerDeferred", {trace:false}); |
436 | if (this._serverData == null) { | 432 | if (this._serverData == null) { |
437 | innerDeferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'loadingUserDetails'); | 433 | innerDeferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'loadingUserDetails'); |
438 | innerDeferredResult.addMethod(this.connection(), 'message', 'getUserDetails'); | 434 | innerDeferredResult.addMethod(this.connection(), 'message', 'getUserDetails'); |
439 | innerDeferredResult.addMethod(this, 'unpackServerData'); | 435 | innerDeferredResult.addMethod(this, 'unpackServerData'); |
440 | innerDeferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'loadedUserDetails'); | 436 | innerDeferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'loadedUserDetails'); |
441 | } | 437 | } |
442 | 438 | ||
443 | innerDeferredResult.addCallback(MochiKit.Base.bind(function () { | 439 | innerDeferredResult.addCallback(MochiKit.Base.bind(function () { |
444 | return this._serverData; | 440 | return this._serverData; |
445 | },this)); | 441 | },this)); |
446 | innerDeferredResult.callback(); | 442 | innerDeferredResult.callback(); |
447 | 443 | ||
448 | return innerDeferredResult; | 444 | return innerDeferredResult; |
449 | }, this)); | 445 | }, this)); |
450 | deferredResult.releaseLock(this.deferredLockForSection('serverData')); | 446 | deferredResult.releaseLock(this.deferredLockForSection('serverData')); |
451 | deferredResult.callback(); | 447 | deferredResult.callback(); |
452 | 448 | ||
453 | return deferredResult; | 449 | return deferredResult; |
454 | }, | 450 | }, |
455 | 451 | ||
456 | //------------------------------------------------------------------------- | 452 | //------------------------------------------------------------------------- |
457 | 453 | ||
458 | 'connectionVersion': function() { | 454 | 'connectionVersion': function() { |
459 | return this._connectionVersion; | 455 | return this._connectionVersion; |
460 | }, | 456 | }, |
461 | 457 | ||
462 | 'setConnectionVersion': function(aValue) { | 458 | 'setConnectionVersion': function(aValue) { |
463 | if (this._connectionVersion != aValue) { | 459 | if (this._connectionVersion != aValue) { |
464 | this.resetConnection(); | 460 | this.resetConnection(); |
465 | } | 461 | } |
466 | this._connectionVersion = aValue; | 462 | this._connectionVersion = aValue; |
467 | }, | 463 | }, |
468 | 464 | ||