author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-04 23:24:50 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-04 23:24:50 (UTC) |
commit | 3065be1b71e4c40428cfa192de560c970ba7f8b3 (patch) (side-by-side diff) | |
tree | bd030652e7c1e1556125beeaf7f18e174ab79385 /frontend/beta/js/Clipperz | |
parent | c53c209c9b1e86f375aea9262fdb3170cae61ebc (diff) | |
parent | bf22713a7251a2b32700a67456a086a283dbe33a (diff) | |
download | clipperz-3065be1b71e4c40428cfa192de560c970ba7f8b3.zip clipperz-3065be1b71e4c40428cfa192de560c970ba7f8b3.tar.gz clipperz-3065be1b71e4c40428cfa192de560c970ba7f8b3.tar.bz2 |
Merge branch 'timeout'
-rwxr-xr-x | frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js index e7c2bc1..6185fd6 100755 --- a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js +++ b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js @@ -49,211 +49,217 @@ YAHOO.extendX(Clipperz.PM.Proxy.PHP, Clipperz.PM.Proxy, { return "Clipperz.PM.Proxy.PHP - " + this.args(); }, //========================================================================= /* 'tolls': function() { return this._tolls; }, */ //------------------------------------------------------------------------- /* 'payToll': function(aRequestType, someParameters) { var deferredResult; //MochiKit.Logging.logDebug(">>> Proxy.DWR.payToll: " + aRequestType); if (this.tolls()[aRequestType].length > 0) { deferredResult = MochiKit.Async.succeed(this.tolls()[aRequestType].pop()); } else { //MochiKit.Logging.logDebug("### " + aRequestType + " toll NOT immediately available; request queued."); deferredResult = new MochiKit.Async.Deferred(); deferredResult.addCallback(function(someParameters) { return new Clipperz.PM.Toll(someParameters['toll']); }) com_clipperz_pm_Proxy.knock(Clipperz.Base.serializeJSON({requestType:aRequestType}), { callback:MochiKit.Base.method(deferredResult, 'callback'), errorHandler:MochiKit.Base.method(deferredResult, 'errback') }); } deferredResult.addCallback(function(aToll) { return aToll.deferredPay(); }); deferredResult.addCallback(function(someParameters, aToll) { var result; result = { parameters: someParameters, toll: aToll } return result; }, someParameters); return deferredResult; }, */ //------------------------------------------------------------------------- /* 'addToll': function(aToll) { this.tolls()[aToll.requestType()].push(aToll); }, */ //========================================================================= /* 'setTollCallback': function(someParameters) { //MochiKit.Logging.logDebug(">>> Proxy.DWR.setTollCallback"); //MochiKit.Logging.logDebug("--- Proxy.DWR.setTollCallback - " + Clipperz.Base.serializeJSON(someParameters)); if (typeof(someParameters['toll']) != 'undefined') { this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); } return someParameters['result']; }, */ //========================================================================= 'registration': function(someParameters) { return this.sendMessage('registration', someParameters, 'REGISTER'); }, //------------------------------------------------------------------------- 'handshake': function(someParameters) { /* _s = "e8a2162f29aeaabb729f5625e9740edbf0cd80ac77c6b19ab951ed6c88443b8c"; _v = new Clipperz.Crypto.BigInt("955e2db0f7844aca372f5799e5f7e51b5866718493096908bd66abcf1d068108", 16); _b = new Clipperz.Crypto.BigInt("5761e6c84d22ea3c5649de01702d60f674ccfe79238540eb34c61cd020230c53", 16); _B = _v.add(Clipperz.Crypto.SRP.g().powerModule(_b, Clipperz.Crypto.SRP.n())); _u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_B.asString(10))).toHexString(), 16); _A = new Clipperz.Crypto.BigInt("3b3567ec33d73673552e960872eb154d091a2488915941038aef759236a27e64", 16); _S = (_A.multiply(_v.powerModule(_u, Clipperz.Crypto.SRP.n()))).powerModule(_b, Clipperz.Crypto.SRP.n()); _K = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_S.asString(10))).toHexString().slice(2); _M1 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_A.asString(10) + _B.asString(10) + _K)).toHexString().slice(2); _M2 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_A.asString(10) + _M1 + _K)).toHexString().slice(2); // MochiKit.Logging.logDebug("b = " + _b.asString(16)); // MochiKit.Logging.logDebug("v = " + _v.asString(16)); MochiKit.Logging.logDebug("B = " + _B.asString(16)); MochiKit.Logging.logDebug("u = " + _u.asString(16)); MochiKit.Logging.logDebug("S = " + _S.asString(16)); MochiKit.Logging.logDebug("K = " + _K); MochiKit.Logging.logDebug("M1 = " + _M1); MochiKit.Logging.logDebug("M2 = " + _M2); // MochiKit.Logging.logDebug("someParameters.version: " + someParameters.version); */ return this.sendMessage('handshake', someParameters, 'CONNECT'); }, //------------------------------------------------------------------------- 'message': function(someParameters) { return this.sendMessage('message', someParameters, 'MESSAGE'); }, //------------------------------------------------------------------------- 'logout': function(someParameters) { //MochiKit.Logging.logDebug("=== Proxy.DWR.logout"); return this.sendMessage('logout', someParameters, 'MESSAGE'); }, //========================================================================= 'sendMessage': function(aFunctionName, someParameters, aRequestType) { /* var deferredResult; var proxy; //MochiKit.Logging.logDebug(">>> Proxy.DWR.sendMessage - " + aFunctionName + " - " + aRequestType); proxy = this; deferredResult = new MochiKit.Async.Deferred(); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.1 Proxy.DWR.sendMessage - 1: " + res); return res;}); deferredResult.addCallback(MochiKit.Base.method(proxy, 'payToll'), aRequestType); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.2 Proxy.DWR.sendMessage - 2: " + Clipperz.Base.serializeJSON(res)); return res;}); deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + res); return res;}); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + Clipperz.Base.serializeJSON(res)); return res;}); deferredResult.callback(someParameters); //MochiKit.Logging.logDebug("<<< Proxy.DWR.sendMessage"); return deferredResult; */ // return this.sendRemoteMessage(aFunctionName, someParameters); var deferredResult; var proxy; proxy = this; deferredResult = new MochiKit.Async.Deferred(); deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3: " + res); return res;}); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3.1: " + Clipperz.Base.serializeJSON(res)); return res;}); deferredResult.callback(someParameters); return deferredResult; }, //========================================================================= 'sendRemoteMessage': function(aFunctionName, someParameters) { /* var deferredResult; //MochiKit.Logging.logDebug(">>> Proxy.DWR.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this); deferredResult = new MochiKit.Async.Deferred(); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 1: " + res); return res;}); // deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 2: " + res); return res;}); com_clipperz_pm_Proxy[aFunctionName](Clipperz.Base.serializeJSON(someParameters), { callback:MochiKit.Base.method(deferredResult, 'callback'), errorHandler:MochiKit.Base.method(deferredResult, 'errback') }); //MochiKit.Logging.logDebug("<<< Proxy.PHP.sendRemoteMessage - result: " + deferredResult); return deferredResult; */ var deferredResult; var parameters; //MochiKit.Logging.logDebug(">>> Proxy.PHP.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this); parameters = {}; parameters['method'] = aFunctionName; // parameters['version'] = someParameters['version']; // parameters['message'] = someParameters['message']; parameters['parameters'] = Clipperz.Base.serializeJSON(someParameters); //MochiKit.Logging.logDebug("--- Proxy.PHP.sendRemoteMessage('" + Clipperz.Base.serializeJSON(parameters) + ") - " + this); deferredResult = new MochiKit.Async.Deferred(); deferredResult.addCallback(MochiKit.Async.doXHR, "./php/index.php", { method:'POST', sendContent:MochiKit.Base.queryString(parameters), headers:{"Content-Type":"application/x-www-form-urlencoded"} }); //deferredResult.addCallback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - 2: " + res.responseText); return res;}); //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - ERROR: " + res); return res;}); deferredResult.addCallback(MochiKit.Async.evalJSONRequest); + deferredResult.addCallback(function (someValues) { + if (someValues['result'] == 'EXCEPTION') { + throw someValues['message']; + } + return someValues; + }) deferredResult.callback(); return deferredResult; }, //========================================================================= 'isReadOnly': function() { return false; }, //========================================================================= __syntaxFix__: "syntax fix" }); //============================================================================= //Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.PHP("Proxy.PHP - async test"); |