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 | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Statistics.js b/frontend/beta/js/Clipperz/PM/DataModel/Statistics.js index 3d53adf..f0c229e 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/Statistics.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/Statistics.js | |||
@@ -1,130 +1,128 @@ | |||
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.Statistics = function(args) { | 31 | Clipperz.PM.DataModel.Statistics = function(args) { |
34 | args = args || {}; | 32 | args = args || {}; |
35 | 33 | ||
36 | this._user = args.user; | 34 | this._user = args.user; |
37 | this._data = args.data || null; | 35 | this._data = args.data || null; |
38 | 36 | ||
39 | return this; | 37 | return this; |
40 | } | 38 | } |
41 | 39 | ||
42 | Clipperz.PM.DataModel.Statistics.prototype = MochiKit.Base.update(null, { | 40 | Clipperz.PM.DataModel.Statistics.prototype = MochiKit.Base.update(null, { |
43 | 41 | ||
44 | //------------------------------------------------------------------------- | 42 | //------------------------------------------------------------------------- |
45 | 43 | ||
46 | 'decrypt': function(aVersion, someEncryptedData) { | 44 | 'decrypt': function(aVersion, someEncryptedData) { |
47 | var deferredResult; | 45 | var deferredResult; |
48 | 46 | ||
49 | //MochiKit.Logging.logDebug(">>> Statistics.decrypt"); | 47 | //MochiKit.Logging.logDebug(">>> Statistics.decrypt"); |
50 | if (someEncryptedData == Clipperz.PM.Crypto.nullValue) { | 48 | if (someEncryptedData == Clipperz.PM.Crypto.nullValue) { |
51 | this.setData({}); | 49 | this.setData({}); |
52 | deferredResult = MochiKit.Async.succeed(this.data()); | 50 | deferredResult = MochiKit.Async.succeed(this.data()); |
53 | } else { | 51 | } else { |
54 | varstatistic; | 52 | varstatistic; |
55 | var user; | 53 | var user; |
56 | 54 | ||
57 | statistic = this; | 55 | statistic = this; |
58 | user = this.user(); | 56 | user = this.user(); |
59 | deferredResult = new MochiKit.Async.Deferred(); | 57 | deferredResult = new MochiKit.Async.Deferred(); |
60 | //deferredResult.addCallback(function() { console.time("Statistics.decrypt.deferredDecrypt")}); | 58 | //deferredResult.addCallback(function() { console.time("Statistics.decrypt.deferredDecrypt")}); |
61 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, user.passphrase(), someEncryptedData, aVersion); | 59 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, user.passphrase(), someEncryptedData, aVersion); |
62 | //deferredResult.addCallback(function() { console.timeEnd("Statistics.decrypt.deferredDecrypt")}); | 60 | //deferredResult.addCallback(function() { console.timeEnd("Statistics.decrypt.deferredDecrypt")}); |
63 | //deferredResult.addCallback(function() { console.time("Statistics.decrypt.setup")}); | 61 | //deferredResult.addCallback(function() { console.time("Statistics.decrypt.setup")}); |
64 | deferredResult.addCallbacks( | 62 | deferredResult.addCallbacks( |
65 | MochiKit.Base.partial(function (aStatistic, someData) { | 63 | MochiKit.Base.partial(function (aStatistic, someData) { |
66 | aStatistic.setData(someData); | 64 | aStatistic.setData(someData); |
67 | return aStatistic.data(); | 65 | return aStatistic.data(); |
68 | }, statistic), | 66 | }, statistic), |
69 | MochiKit.Base.partial(function (aStatistic) { | 67 | MochiKit.Base.partial(function (aStatistic) { |
70 | MochiKit.Logging.logWarning("resetting user statistics due to an error while decrypting stored data"); | 68 | MochiKit.Logging.logWarning("resetting user statistics due to an error while decrypting stored data"); |
71 | aStatistic.setData({}); | 69 | aStatistic.setData({}); |
72 | return aStatistic.data(); | 70 | return aStatistic.data(); |
73 | }, statistic) | 71 | }, statistic) |
74 | ); | 72 | ); |
75 | //deferredResult.addCallback(function() { console.timeEnd("Statistics.decrypt.setup")}); | 73 | //deferredResult.addCallback(function() { console.timeEnd("Statistics.decrypt.setup")}); |
76 | 74 | ||
77 | deferredResult.callback(); | 75 | deferredResult.callback(); |
78 | } | 76 | } |
79 | //MochiKit.Logging.logDebug("<<< Statistics.decrypt"); | 77 | //MochiKit.Logging.logDebug("<<< Statistics.decrypt"); |
80 | 78 | ||
81 | return deferredResult; | 79 | return deferredResult; |
82 | }, | 80 | }, |
83 | 81 | ||
84 | //------------------------------------------------------------------------- | 82 | //------------------------------------------------------------------------- |
85 | 83 | ||
86 | 'user': function() { | 84 | 'user': function() { |
87 | return this._user; | 85 | return this._user; |
88 | }, | 86 | }, |
89 | 87 | ||
90 | //------------------------------------------------------------------------- | 88 | //------------------------------------------------------------------------- |
91 | 89 | ||
92 | 'data': function() { | 90 | 'data': function() { |
93 | return this._data; | 91 | return this._data; |
94 | }, | 92 | }, |
95 | 93 | ||
96 | 'setData': function(aValue) { | 94 | 'setData': function(aValue) { |
97 | this._data = aValue; | 95 | this._data = aValue; |
98 | 96 | ||
99 | this.extractInfoFromData(aValue); | 97 | this.extractInfoFromData(aValue); |
100 | }, | 98 | }, |
101 | 99 | ||
102 | //------------------------------------------------------------------------- | 100 | //------------------------------------------------------------------------- |
103 | 101 | ||
104 | 'extractInfoFromData': function(someValues) { | 102 | 'extractInfoFromData': function(someValues) { |
105 | 103 | ||
106 | }, | 104 | }, |
107 | 105 | ||
108 | //------------------------------------------------------------------------- | 106 | //------------------------------------------------------------------------- |
109 | 107 | ||
110 | 'encryptedData': function() { | 108 | 'encryptedData': function() { |
111 | return Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion(this.user().passphrase(), this.serializedData()); | 109 | return Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion(this.user().passphrase(), this.serializedData()); |
112 | }, | 110 | }, |
113 | 111 | ||
114 | //------------------------------------------------------------------------- | 112 | //------------------------------------------------------------------------- |
115 | 113 | ||
116 | 'serializedData': function() { | 114 | 'serializedData': function() { |
117 | var result; | 115 | var result; |
118 | 116 | ||
119 | //MochiKit.Logging.logDebug(">>> Statistics.serializedData"); | 117 | //MochiKit.Logging.logDebug(">>> Statistics.serializedData"); |
120 | result = {}; | 118 | result = {}; |
121 | //MochiKit.Logging.logDebug("<<< Statistics.serializedData"); | 119 | //MochiKit.Logging.logDebug("<<< Statistics.serializedData"); |
122 | 120 | ||
123 | return result; | 121 | return result; |
124 | }, | 122 | }, |
125 | 123 | ||
126 | //------------------------------------------------------------------------- | 124 | //------------------------------------------------------------------------- |
127 | __syntaxFix__: "syntax fix" | 125 | __syntaxFix__: "syntax fix" |
128 | 126 | ||
129 | }); | 127 | }); |
130 | 128 | ||