summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/Record.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Record.js b/frontend/beta/js/Clipperz/PM/DataModel/Record.js
index ffb45de..9e496de 100644
--- a/frontend/beta/js/Clipperz/PM/DataModel/Record.js
+++ b/frontend/beta/js/Clipperz/PM/DataModel/Record.js
@@ -231,130 +231,136 @@ Clipperz.PM.DataModel.Record.prototype = MochiKit.Base.update(null, {
231 deferredResult.addCallback(MochiKit.Base.method(this,'setServerData')); 231 deferredResult.addCallback(MochiKit.Base.method(this,'setServerData'));
232 deferredResult.callback(); 232 deferredResult.callback();
233 result = deferredResult; 233 result = deferredResult;
234 } else { 234 } else {
235 result = MochiKit.Async.succeed(this.serverData()); 235 result = MochiKit.Async.succeed(this.serverData());
236 } 236 }
237//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.loadData"); 237//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.loadData");
238 238
239 return result; 239 return result;
240 }, 240 },
241 241
242 //------------------------------------------------------------------------- 242 //-------------------------------------------------------------------------
243 243
244 'decryptData': function(anEncryptedData) { 244 'decryptData': function(anEncryptedData) {
245 var result; 245 var result;
246 246
247//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.decryptData - this: " + this + " (" + anEncryptedData + ")"); 247//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.decryptData - this: " + this + " (" + anEncryptedData + ")");
248 if (this.shouldDecryptData()) { 248 if (this.shouldDecryptData()) {
249 var deferredResult; 249 var deferredResult;
250 250
251 deferredResult = new MochiKit.Async.Deferred(); 251 deferredResult = new MochiKit.Async.Deferred();
252 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'decryptingRecordData'); 252 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'decryptingRecordData');
253 deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, this.key(), anEncryptedData['data'], anEncryptedData['version']); 253 deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, this.key(), anEncryptedData['data'], anEncryptedData['version']);
254 deferredResult.addCallback(function(anEncryptedData, someDecryptedValues) { 254 deferredResult.addCallback(function(anEncryptedData, someDecryptedValues) {
255 varresult; 255 varresult;
256 256
257 result = anEncryptedData; 257 result = anEncryptedData;
258 result['data'] = someDecryptedValues; 258 result['data'] = someDecryptedValues;
259 259
260 return result; 260 return result;
261 }, anEncryptedData); 261 }, anEncryptedData);
262 deferredResult.addCallback(MochiKit.Base.method(this, 'setDecryptedData')); 262 deferredResult.addCallback(MochiKit.Base.method(this, 'setDecryptedData'));
263 deferredResult.callback(); 263 deferredResult.callback();
264 264
265 result = deferredResult; 265 result = deferredResult;
266 } else { 266 } else {
267 result = MochiKit.Async.succeed(this.decryptedData()); 267 result = MochiKit.Async.succeed(this.decryptedData());
268 } 268 }
269//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.decryptData"); 269//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.decryptData");
270 270
271 return result; 271 return result;
272 }, 272 },
273 273
274 //------------------------------------------------------------------------- 274 //-------------------------------------------------------------------------
275 275
276 'processData': function(someValues) { 276 'processData': function(someValues) {
277//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.processData"); 277//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.processData");
278//MochiKit.Logging.logDebug("--- Record.processData: " + Clipperz.Base.serializeJSON(someValues)); 278//MochiKit.Logging.logDebug("--- Record.processData: " + Clipperz.Base.serializeJSON(someValues));
279 if (this.shouldProcessData()) { 279 if (this.shouldProcessData()) {
280 var currentVersionParameters; 280 var currentVersionParameters;
281 281
282console.log("Record.processData", someValues); 282console.log("Record.processData", someValues);
283 this.processDataToExtractLegacyValues(someValues['data']); 283 this.processDataToExtractLegacyValues(someValues['data']);
284 284
285 if (typeof(someValues['data']['notes']) != 'undefined') { 285 if (typeof(someValues['data']['notes']) != 'undefined') {
286 this.setNotes(someValues['data']['notes']); 286 this.setNotes(someValues['data']['notes']);
287 } 287 }
288 288
289 if (someValues['data']['currentVersionKey'] != null) { 289 if (someValues['data']['currentVersionKey'] != null) {
290 this.setCurrentVersionKey(someValues['data']['currentVersionKey']); 290 this.setCurrentVersionKey(someValues['data']['currentVersionKey']);
291 } else { 291 } else {
292 this.setCurrentVersionKey(this.key()); 292 this.setCurrentVersionKey(this.key());
293 } 293 }
294 294
295 // currentVersionParameters = someValues['currentVersion']; 295 // community edition doesn't currently pass version
296 currentVersionParameters = someValues['versions'][someValues['currentVersion']]; 296 // information
297 if (someValues['versions'] == null) {
298 currentVersionParameters = someValues['currentVersion'];
299 } else {
300 currentVersionParameters = someValues['versions'][someValues['currentVersion']];
301 }
302
297console.log("Record.processData - this.currentVersionKey()", this.currentVersionKey()); 303console.log("Record.processData - this.currentVersionKey()", this.currentVersionKey());
298console.log("Record.processData - currentVersionParameters", currentVersionParameters); 304console.log("Record.processData - currentVersionParameters", currentVersionParameters);
299 currentVersionParameters['key'] = this.currentVersionKey(); 305 currentVersionParameters['key'] = this.currentVersionKey();
300 this.setCurrentVersion(new Clipperz.PM.DataModel.RecordVersion(this, currentVersionParameters)); 306 this.setCurrentVersion(new Clipperz.PM.DataModel.RecordVersion(this, currentVersionParameters));
301 307
302 if (someValues['data']['directLogins'] != null) { 308 if (someValues['data']['directLogins'] != null) {
303 vardirectLoginReference; 309 vardirectLoginReference;
304 310
305 for (directLoginReference in someValues['data']['directLogins']) { 311 for (directLoginReference in someValues['data']['directLogins']) {
306 var directLogin; 312 var directLogin;
307 var directLoginParameters; 313 var directLoginParameters;
308 314
309 directLoginParameters = someValues['data']['directLogins'][directLoginReference]; 315 directLoginParameters = someValues['data']['directLogins'][directLoginReference];
310 directLoginParameters.record = this; 316 directLoginParameters.record = this;
311 directLoginParameters.reference = directLoginReference; 317 directLoginParameters.reference = directLoginReference;
312 318
313 directLogin = new Clipperz.PM.DataModel.DirectLogin(directLoginParameters); 319 directLogin = new Clipperz.PM.DataModel.DirectLogin(directLoginParameters);
314 this.addDirectLogin(directLogin, true); 320 this.addDirectLogin(directLogin, true);
315 } 321 }
316 } 322 }
317 this.setShouldProcessData(false); 323 this.setShouldProcessData(false);
318 } 324 }
319 325
320 Clipperz.NotificationCenter.notify(this, 'recordDataReady'); 326 Clipperz.NotificationCenter.notify(this, 'recordDataReady');
321//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.processData"); 327//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.processData");
322//MochiKit.Logging.logDebug("<<< Record.processData"); 328//MochiKit.Logging.logDebug("<<< Record.processData");
323 329
324 return this; 330 return this;
325 }, 331 },
326 332
327 //------------------------------------------------------------------------- 333 //-------------------------------------------------------------------------
328 334
329 'processDataToExtractLegacyValues': function(someValues) { 335 'processDataToExtractLegacyValues': function(someValues) {
330//MochiKit.Logging.logDebug(">>> Record.processDataToExtractLegacyValues"); 336//MochiKit.Logging.logDebug(">>> Record.processDataToExtractLegacyValues");
331 if (someValues['data'] != null) { 337 if (someValues['data'] != null) {
332 this.setNotes(someValues['data']); 338 this.setNotes(someValues['data']);
333 } 339 }
334 340
335 if ( 341 if (
336 (typeof(someValues['loginFormData']) != "undefined") 342 (typeof(someValues['loginFormData']) != "undefined")
337 &&(typeof(someValues['loginBindings'] != "undefined")) 343 &&(typeof(someValues['loginBindings'] != "undefined"))
338 &&(someValues['loginFormData'] != "") 344 &&(someValues['loginFormData'] != "")
339 &&(someValues['loginBindings'] != "") 345 &&(someValues['loginBindings'] != "")
340 ) { 346 ) {
341 vardirectLogin; 347 vardirectLogin;
342 348
343 directLogin = new Clipperz.PM.DataModel.DirectLogin({ 349 directLogin = new Clipperz.PM.DataModel.DirectLogin({
344 record:this, 350 record:this,
345 label:this.label() + Clipperz.PM.Strings['newDirectLoginLabelSuffix'], 351 label:this.label() + Clipperz.PM.Strings['newDirectLoginLabelSuffix'],
346 reference:Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(this.label() + 352 reference:Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(this.label() +
347 someValues['loginFormData'] + 353 someValues['loginFormData'] +
348 someValues['loginBindings'])).toHexString().substring(2), 354 someValues['loginBindings'])).toHexString().substring(2),
349 formData:Clipperz.Base.evalJSON(someValues['loginFormData']), 355 formData:Clipperz.Base.evalJSON(someValues['loginFormData']),
350 legacyBindingData:Clipperz.Base.evalJSON(someValues['loginBindings']), 356 legacyBindingData:Clipperz.Base.evalJSON(someValues['loginBindings']),
351 bookmarkletVersion:'0.1' 357 bookmarkletVersion:'0.1'
352 }); 358 });
353 this.addDirectLogin(directLogin, true); 359 this.addDirectLogin(directLogin, true);
354 } 360 }
355//MochiKit.Logging.logDebug("<<< Record.processDataToExtractLegacyValues"); 361//MochiKit.Logging.logDebug("<<< Record.processDataToExtractLegacyValues");
356 }, 362 },
357 363
358 //------------------------------------------------------------------------- 364 //-------------------------------------------------------------------------
359 365
360 'getReadyBeforeUpdatingVersionValues': function() { 366 'getReadyBeforeUpdatingVersionValues': function() {