Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/Statistics.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/Statistics.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Statistics.js b/frontend/beta/js/Clipperz/PM/DataModel/Statistics.js index fb5eb01..3d53adf 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/Statistics.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/Statistics.js | |||
@@ -1,120 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
31 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
32 | 29 | ||
33 | 30 | ||
34 | //############################################################################# | 31 | //############################################################################# |
35 | 32 | ||
36 | Clipperz.PM.DataModel.Statistics = function(args) { | 33 | Clipperz.PM.DataModel.Statistics = function(args) { |
37 | args = args || {}; | 34 | args = args || {}; |
38 | 35 | ||
39 | this._user = args.user; | 36 | this._user = args.user; |
40 | this._data = args.data || null; | 37 | this._data = args.data || null; |
41 | 38 | ||
42 | return this; | 39 | return this; |
43 | } | 40 | } |
44 | 41 | ||
45 | Clipperz.PM.DataModel.Statistics.prototype = MochiKit.Base.update(null, { | 42 | Clipperz.PM.DataModel.Statistics.prototype = MochiKit.Base.update(null, { |
46 | 43 | ||
47 | //------------------------------------------------------------------------- | 44 | //------------------------------------------------------------------------- |
48 | 45 | ||
49 | 'decrypt': function(aVersion, someEncryptedData) { | 46 | 'decrypt': function(aVersion, someEncryptedData) { |
50 | var deferredResult; | 47 | var deferredResult; |
51 | 48 | ||
52 | //MochiKit.Logging.logDebug(">>> Statistics.decrypt"); | 49 | //MochiKit.Logging.logDebug(">>> Statistics.decrypt"); |
53 | if (someEncryptedData == Clipperz.PM.Crypto.nullValue) { | 50 | if (someEncryptedData == Clipperz.PM.Crypto.nullValue) { |
54 | this.setData({}); | 51 | this.setData({}); |
55 | deferredResult = MochiKit.Async.succeed(this.data()); | 52 | deferredResult = MochiKit.Async.succeed(this.data()); |
56 | } else { | 53 | } else { |
57 | varstatistic; | 54 | varstatistic; |
58 | var user; | 55 | var user; |
59 | 56 | ||
60 | statistic = this; | 57 | statistic = this; |
61 | user = this.user(); | 58 | user = this.user(); |
62 | deferredResult = new MochiKit.Async.Deferred(); | 59 | deferredResult = new MochiKit.Async.Deferred(); |
63 | //deferredResult.addCallback(function() { console.time("Statistics.decrypt.deferredDecrypt")}); | 60 | //deferredResult.addCallback(function() { console.time("Statistics.decrypt.deferredDecrypt")}); |
64 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, user.passphrase(), someEncryptedData, aVersion); | 61 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, user.passphrase(), someEncryptedData, aVersion); |
65 | //deferredResult.addCallback(function() { console.timeEnd("Statistics.decrypt.deferredDecrypt")}); | 62 | //deferredResult.addCallback(function() { console.timeEnd("Statistics.decrypt.deferredDecrypt")}); |
66 | //deferredResult.addCallback(function() { console.time("Statistics.decrypt.setup")}); | 63 | //deferredResult.addCallback(function() { console.time("Statistics.decrypt.setup")}); |
67 | deferredResult.addCallbacks( | 64 | deferredResult.addCallbacks( |
68 | MochiKit.Base.partial(function (aStatistic, someData) { | 65 | MochiKit.Base.partial(function (aStatistic, someData) { |
69 | aStatistic.setData(someData); | 66 | aStatistic.setData(someData); |
70 | return aStatistic.data(); | 67 | return aStatistic.data(); |
71 | }, statistic), | 68 | }, statistic), |
72 | MochiKit.Base.partial(function (aStatistic) { | 69 | MochiKit.Base.partial(function (aStatistic) { |
73 | MochiKit.Logging.logWarning("resetting user statistics due to an error while decrypting stored data"); | 70 | MochiKit.Logging.logWarning("resetting user statistics due to an error while decrypting stored data"); |
74 | aStatistic.setData({}); | 71 | aStatistic.setData({}); |
75 | return aStatistic.data(); | 72 | return aStatistic.data(); |
76 | }, statistic) | 73 | }, statistic) |
77 | ); | 74 | ); |
78 | //deferredResult.addCallback(function() { console.timeEnd("Statistics.decrypt.setup")}); | 75 | //deferredResult.addCallback(function() { console.timeEnd("Statistics.decrypt.setup")}); |
79 | 76 | ||
80 | deferredResult.callback(); | 77 | deferredResult.callback(); |
81 | } | 78 | } |
82 | //MochiKit.Logging.logDebug("<<< Statistics.decrypt"); | 79 | //MochiKit.Logging.logDebug("<<< Statistics.decrypt"); |
83 | 80 | ||
84 | return deferredResult; | 81 | return deferredResult; |
85 | }, | 82 | }, |
86 | 83 | ||
87 | //------------------------------------------------------------------------- | 84 | //------------------------------------------------------------------------- |
88 | 85 | ||
89 | 'user': function() { | 86 | 'user': function() { |
90 | return this._user; | 87 | return this._user; |
91 | }, | 88 | }, |
92 | 89 | ||
93 | //------------------------------------------------------------------------- | 90 | //------------------------------------------------------------------------- |
94 | 91 | ||
95 | 'data': function() { | 92 | 'data': function() { |
96 | return this._data; | 93 | return this._data; |
97 | }, | 94 | }, |
98 | 95 | ||
99 | 'setData': function(aValue) { | 96 | 'setData': function(aValue) { |
100 | this._data = aValue; | 97 | this._data = aValue; |
101 | 98 | ||
102 | this.extractInfoFromData(aValue); | 99 | this.extractInfoFromData(aValue); |
103 | }, | 100 | }, |
104 | 101 | ||
105 | //------------------------------------------------------------------------- | 102 | //------------------------------------------------------------------------- |
106 | 103 | ||
107 | 'extractInfoFromData': function(someValues) { | 104 | 'extractInfoFromData': function(someValues) { |
108 | 105 | ||
109 | }, | 106 | }, |
110 | 107 | ||
111 | //------------------------------------------------------------------------- | 108 | //------------------------------------------------------------------------- |
112 | 109 | ||
113 | 'encryptedData': function() { | 110 | 'encryptedData': function() { |
114 | return Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion(this.user().passphrase(), this.serializedData()); | 111 | return Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion(this.user().passphrase(), this.serializedData()); |
115 | }, | 112 | }, |
116 | 113 | ||
117 | //------------------------------------------------------------------------- | 114 | //------------------------------------------------------------------------- |
118 | 115 | ||
119 | 'serializedData': function() { | 116 | 'serializedData': function() { |
120 | var result; | 117 | var result; |