summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js
Side-by-side diff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js26
1 files changed, 10 insertions, 16 deletions
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 @@
/*
-Copyright 2008-2011 Clipperz Srl
+Copyright 2008-2013 Clipperz Srl
-This file is part of Clipperz Community Edition.
-Clipperz Community Edition is an online password manager.
+This file is part of Clipperz, the online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
-* Clipperz Community Edition is free software: you can redistribute
- it and/or modify it under the terms of the GNU Affero General Public
- License as published by the Free Software Foundation, either version
- 3 of the License, or (at your option) any later version.
+* Clipperz is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
-* Clipperz Community Edition is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied
- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* Clipperz is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
- License along with Clipperz Community Edition. If not, see
- <http://www.gnu.org/licenses/>.
+ License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
try { if (typeof(Clipperz.KeyValueObjectStore) == 'undefined') { throw ""; }} catch (e) {
throw "Clipperz.PM.DataModel.EncryptedRemoteObject depends on Clipperz.KeyValueObjectStore!";
}
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
Clipperz.PM.DataModel.EncryptedRemoteObject = function(args) {
args = args || {};
this._name = args.name || null;
this._reference = args.reference || Clipperz.PM.Crypto.randomKey();
this._isBrandNew = ((args.reference == null) && (args.remoteData == null));
if ((this._isBrandNew == false) && (args['retrieveKeyFunction'] == null)) {
Clipperz.Base.exception.raise('MandatoryParameter');
} else {
this._retrieveKeyFunction = args['retrieveKeyFunction'];
}
this._retrieveRemoteDataFunction = args.retrieveRemoteDataFunction || null;
this._remoteData = args.remoteData || null;
// this._remoteData = args.remoteData ? Clipperz.Base.deepClone(args.remoteData) : null;
if ((!this._isBrandNew) && ((this._retrieveRemoteDataFunction == null) && (this._remoteData == null))) {
Clipperz.Base.exception.raise('MandatoryParameter');
}
this._encryptedDataKeypath = args.encryptedDataKeypath || 'data'; //Clipperz.Base.exception.raise('MandatoryParameter');
this._encryptedVersionKeypath = args.encryptedVersionKeypath || 'version'; //Clipperz.Base.exception.raise('MandatoryParameter');
this._transientState = null;
this._deferredLocks = {};
if (this._isBrandNew == true) {
this._objectDataStore = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.objectDataStore [1]'}*/);
} else {
this._objectDataStore = null;
}
return this;
}
//
@@ -366,100 +364,96 @@ Clipperz.PM.DataModel.EncryptedRemoteObject.prototype = MochiKit.Base.update(nul
//-------------------------------------------------------------------------
'getDeferredLockForKey': function (aKey) {
var result;
result = this._deferredLocks[aKey];
if (typeof(result) == 'undefined') {
result = new MochiKit.Async.DeferredLock();
this._deferredLocks[aKey] = result;
}
return result;
},
//-------------------------------------------------------------------------
'unpackData': function (someData) { // ++
return someData;
},
'packData': function (someData) { // ++
return someData;
},
//-------------------------------------------------------------------------
'hasPendingChanges': function () {
var deferredResult;
var tempObj = this;
if (this.isBrandNew()) {
// deferredResult = MochiKit.Async.succeed(true);
deferredResult = this.hasPendingChangesWhenBrandNew();
} else if (this.hasInitiatedObjectDataStore()) {
deferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject.hasPendingChanges", {trace:false});
deferredResult.collectResults({
'decryptedData': [
MochiKit.Base.method(this, 'getDecryptedData'),
Clipperz.Base.serializeJSON
],
'objectData': [
MochiKit.Base.method(this, '_getObjectDataStore'),
MochiKit.Base.methodcaller('values'),
Clipperz.Base.serializeJSON
]
});
deferredResult.addCallback(function (someValues) {
-//if (someValues['decryptedData'] != someValues['objectData']) {
-// console.log("ORIGINAL DATA", '[[[' + someValues['decryptedData'] + ']]]');
-// console.log("CURRENT DATA", '>>>' + someValues['objectData'] + '<<<');
-//}
return (someValues['decryptedData'] != someValues['objectData']);
});
deferredResult.callback();
} else {
deferredResult = MochiKit.Async.succeed(false);
}
return deferredResult;
},
'hasPendingChangesWhenBrandNew': function () {
return MochiKit.Async.succeed(true);
},
//-------------------------------------------------------------------------
'commitTransientState': function () {
var deferredResult;
// if (this.transientState().getValue('__prepareRemoteData') == true) {
if (this.transientState().getValue('packedRemoteData') != null) {
deferredResult = Clipperz.Async.callbacks("EncryptedRemoteObject.commitTransientState - prepareRemoteData", [
MochiKit.Base.bind(function (someData) {
this._remoteData = this.transientState().getValue('packedRemoteData');
}, this),
MochiKit.Base.method(this, '_getObjectDataStore'),
MochiKit.Base.methodcaller('values'),
Clipperz.Base.deepClone,
MochiKit.Base.method(this.decryptedDataStore(), 'setValue', 'decryptedData'),
MochiKit.Base.method(this, 'resetTransientState', true)
], {trace:false});
} else {
deferredResult = Clipperz.Async.callbacks("EncryptedRemoteObject.commitTransientState - NO prepareRemoteData", [
MochiKit.Base.method(this, 'resetTransientState', true)
], {trace:false});
}
this._isBrandNew = false;
return deferredResult;
},
//-------------------------------------------------------------------------
'revertChanges': function () {