Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js b/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js index fc4a45c..69a7d91 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js | |||
@@ -1,118 +1,116 @@ | |||
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.RecordVersion = function(aRecord, args) { | 31 | Clipperz.PM.DataModel.RecordVersion = function(aRecord, args) { |
34 | args = args || {}; | 32 | args = args || {}; |
35 | 33 | ||
36 | this._record = aRecord; | 34 | this._record = aRecord; |
37 | 35 | ||
38 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); | 36 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); |
39 | this._version = args.version || Clipperz.PM.Crypto.encryptingFunctions.currentVersion; | 37 | this._version = args.version || Clipperz.PM.Crypto.encryptingFunctions.currentVersion; |
40 | this._key = args.key || Clipperz.PM.Crypto.randomKey();; | 38 | this._key = args.key || Clipperz.PM.Crypto.randomKey();; |
41 | 39 | ||
42 | this._previousVersion = args.previousVersion || null; | 40 | this._previousVersion = args.previousVersion || null; |
43 | this._previousVersionKey = args.previousVersionKey || null; | 41 | this._previousVersionKey = args.previousVersionKey || null; |
44 | 42 | ||
45 | this.setIsBrandNew(args.reference == null); | 43 | this.setIsBrandNew(args.reference == null); |
46 | 44 | ||
47 | if (this.isBrandNew()) { | 45 | if (this.isBrandNew()) { |
48 | this._fields = {}; | 46 | this._fields = {}; |
49 | 47 | ||
50 | this.setShouldLoadData(false); | 48 | this.setShouldLoadData(false); |
51 | this.setShouldDecryptData(false); | 49 | this.setShouldDecryptData(false); |
52 | this.setShouldProcessData(false); | 50 | this.setShouldProcessData(false); |
53 | } else { | 51 | } else { |
54 | if (typeof(args.fields) != 'undefined') { | 52 | if (typeof(args.fields) != 'undefined') { |
55 | this.processFieldData(args.fields); | 53 | this.processFieldData(args.fields); |
56 | 54 | ||
57 | this.setShouldLoadData(false); | 55 | this.setShouldLoadData(false); |
58 | this.setShouldDecryptData(false); | 56 | this.setShouldDecryptData(false); |
59 | this.setShouldProcessData(false); | 57 | this.setShouldProcessData(false); |
60 | } else { | 58 | } else { |
61 | if (typeof(args.data) != 'undefined') { | 59 | if (typeof(args.data) != 'undefined') { |
62 | this.setShouldLoadData(false); | 60 | this.setShouldLoadData(false); |
63 | } else { | 61 | } else { |
64 | this.setShouldLoadData(true); | 62 | this.setShouldLoadData(true); |
65 | } | 63 | } |
66 | this.setShouldDecryptData(true); | 64 | this.setShouldDecryptData(true); |
67 | this.setShouldProcessData(true); | 65 | this.setShouldProcessData(true); |
68 | } | 66 | } |
69 | } | 67 | } |
70 | 68 | ||
71 | this._serverData = args.data; | 69 | this._serverData = args.data; |
72 | this._decryptedData = null; | 70 | this._decryptedData = null; |
73 | 71 | ||
74 | return this; | 72 | return this; |
75 | } | 73 | } |
76 | 74 | ||
77 | Clipperz.PM.DataModel.RecordVersion.prototype = MochiKit.Base.update(null, { | 75 | Clipperz.PM.DataModel.RecordVersion.prototype = MochiKit.Base.update(null, { |
78 | 76 | ||
79 | 'toString': function() { | 77 | 'toString': function() { |
80 | return "RecordVersion"; | 78 | return "RecordVersion"; |
81 | }, | 79 | }, |
82 | 80 | ||
83 | //------------------------------------------------------------------------- | 81 | //------------------------------------------------------------------------- |
84 | 82 | ||
85 | 'record': function() { | 83 | 'record': function() { |
86 | return this._record; | 84 | return this._record; |
87 | }, | 85 | }, |
88 | 86 | ||
89 | //------------------------------------------------------------------------- | 87 | //------------------------------------------------------------------------- |
90 | 88 | ||
91 | 'reference': function() { | 89 | 'reference': function() { |
92 | return this._reference; | 90 | return this._reference; |
93 | }, | 91 | }, |
94 | 92 | ||
95 | 'setReference': function(aValue) { | 93 | 'setReference': function(aValue) { |
96 | this._reference = aValue; | 94 | this._reference = aValue; |
97 | }, | 95 | }, |
98 | 96 | ||
99 | //------------------------------------------------------------------------- | 97 | //------------------------------------------------------------------------- |
100 | 98 | ||
101 | 'key': function() { | 99 | 'key': function() { |
102 | //MochiKit.Logging.logDebug(">>> RecordVersion.key"); | 100 | //MochiKit.Logging.logDebug(">>> RecordVersion.key"); |
103 | //MochiKit.Logging.logDebug("--- RecordVersion.key - " + this._key); | 101 | //MochiKit.Logging.logDebug("--- RecordVersion.key - " + this._key); |
104 | return this._key; | 102 | return this._key; |
105 | }, | 103 | }, |
106 | 104 | ||
107 | 'setKey': function(aValue) { | 105 | 'setKey': function(aValue) { |
108 | this._key = aValue; | 106 | this._key = aValue; |
109 | }, | 107 | }, |
110 | 108 | ||
111 | //------------------------------------------------------------------------- | 109 | //------------------------------------------------------------------------- |
112 | 110 | ||
113 | 'serverData': function() { | 111 | 'serverData': function() { |
114 | return this._serverData; | 112 | return this._serverData; |
115 | }, | 113 | }, |
116 | 114 | ||
117 | 'setServerData': function(aValue) { | 115 | 'setServerData': function(aValue) { |
118 | this._serverData = aValue; | 116 | this._serverData = aValue; |