-rw-r--r-- | backend/php/src/configuration.php | 6 | ||||
-rw-r--r-- | backend/php/src/index.php | 189 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/Record.js | 7 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Proxy.js | 3 | ||||
-rwxr-xr-x | frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js | 262 | ||||
-rw-r--r-- | frontend/gamma/html/index_template.html | 5 | ||||
-rw-r--r-- | frontend/gamma/js/Clipperz/Async.js | 19 | ||||
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/Proxy.js | 2 |
8 files changed, 205 insertions, 288 deletions
diff --git a/backend/php/src/configuration.php b/backend/php/src/configuration.php index 291e3a1..85f680e 100644 --- a/backend/php/src/configuration.php +++ b/backend/php/src/configuration.php @@ -15,12 +15,12 @@ $configuration['setup_password'] = ''; $configuration['db_encoding'] = 0; // edit the information below to match your database settings -$configuration['db'] = 'clipperz'; // database name +$configuration['db'] = 'clipperz'; // database name $configuration['host'] = 'localhost'; // database host -$configuration['user'] = 'root'; // database user -$configuration['pass'] = 'pass'; // database password +$configuration['user'] = 'clipperz'; // database user +$configuration['pass'] = 'clipperz'; // database password $configuration['port'] = '3306'; // database port //proxy settings - if you are behnd a proxy, change the settings below diff --git a/backend/php/src/index.php b/backend/php/src/index.php index 214ac01..da7c60c 100644 --- a/backend/php/src/index.php +++ b/backend/php/src/index.php @@ -139,9 +139,11 @@ function updateUserCredentials($parameters, &$user) { function updateUserData($parameters, &$user) { $user->header = $parameters["header"]; $user->statistics = $parameters["statistics"]; $user->version = $parameters["version"]; - $user->lock = $parameters["lock"]; + if (array_key_exists("lock", $parameters)) { + $user->lock = $parameters["lock"]; + } } function updateRecordData($parameters, &$record, &$recordVersion) { $recordData = $parameters["record"]; @@ -152,9 +154,11 @@ function updateRecordData($parameters, &$record, &$recordVersion) { $recordVersionData = $parameters["currentRecordVersion"]; $recordVersion->reference = $recordVersionData ["reference"]; $recordVersion->data = $recordVersionData ["data"]; $recordVersion->version = $recordVersionData ["version"]; - $recordVersion->previous_version_id = $recordVersionData ["previousVersion"]; + if (array_key_exists("previousVersion", $recordVersionData)) { + $recordVersion->previous_version_id = $recordVersionData ["previousVersion"]; + } $recordVersion->previous_version_key = $recordVersionData ["previousVersionKey"]; } //----------------------------------------------------------------------------- @@ -364,8 +368,9 @@ error_log("oneTimePassword"); break; case "message": error_log("message"); +//error_log("message: ".json_encode($parameters)); if ($parameters["srpSharedSecret"] == $_SESSION["K"]) { $message = $parameters["message"]; //============================================================= @@ -446,8 +451,90 @@ error_log("message"); $result["lock"] = $user->lock; $result["result"] = "done"; //============================================================= + } else if ($message == "saveChanges") { + +//{ +// "message":"saveChanges", +// "srpSharedSecret":"edc78508907c942173818f7247fa64869ba80672a7aa8d27b8fa6bfe524fb9c8", +// "parameters":{ +// "records":{ +// "updated":[ +// { +// "currentRecordVersion":{ +// "previousVersionKey":"####", +// "reference":"08c8eb7ec528fbf987bbfb84fe2e960cf9ae937b19fbb5f05d8d90a7039fac6a", +// "data":"WYQ16AjodjsmyZDXa4MKxOju0F…beD/zXlbVb0Zj0ZI/N55bZ", +// "version":"0.3" +// }, +// "record":{ +// "reference":"83de5304f60a808e48a815c6203d7d3f24874d3f40faba420bbc60b376fcc356", +// "data":"B6uBuBE Aly0knvgrUppodDTGZQC…guizL9QvHCWyM bQQBGBVvHZ6LfA==", +// "version":"0.3" +// } +// } +// ], +// "deleted":[ +// +// ] +// }, +// "user":{ +// "header":"{\"rec…sion\":\"0.1\"}", +// "statistics":"e6iXVEM4i8ZatPZFCCads/9F", +// "version":"0.3" +// } +// } +//} + $user = new user(); + $user = $user->Get($_SESSION["userId"]); + updateUserData($parameters["parameters"]["user"], $user); + + $recordToUpdateParameterList = $parameters["parameters"]["records"]["updated"]; + $c = count($recordToUpdateParameterList); + for ($i=0; $i<$c; $i++) { + $recordList = $user->GetRecordList(array(array("reference", "=", $recordToUpdateParameterList [$i]["record"]["reference"]))); + if (count($recordList) == 0) { + $currentRecord = new record(); + $currentVersion = new recordversion(); + $isNewRecord = true; + } else { + $currentRecord = $recordList[0]; + $currentRecordVersions = $currentRecord->GetRecordversionList(); + $currentVersion = $currentRecordVersions[0]; + $isNewRecord = false; + } + + updateRecordData($recordToUpdateParameterList[$i], $currentRecord, $currentVersion); + + if ($isNewRecord == true) { + $currentRecord->SaveNew(); + $currentVersion->SaveNew(); + + $currentRecord->AddRecordversion($currentVersion); + $user->AddRecord($currentRecord); + } + + $currentRecord->Save(); + $currentVersion->Save(); + } + + $user->Save(); + + $recordToDeleteReferenceList = $parameters["parameters"]["records"]["deleted"]; + $recordList = array(); + $c = count($recordToDeleteReferenceList); + for ($i=0; $i<$c; $i++) { + array_push($recordList, array("reference", "=", $recordToDeleteReferenceList[$i])); + } + + $record = new record(); + $record->DeleteList($recordList, true); + + $result["lock"] = $user->lock; + $result["result"] = "done"; + + //============================================================= } else if ($message == "getRecordDetail") { //{ // "message":"getRecordDetail", // "srpSharedSecret":"4c00dcb66a9f2aea41a87e4707c526874e2eb29cc72d2c7086837e53d6bf2dfe", @@ -473,23 +560,96 @@ error_log("message"); // version:"0.2", // updatedDate:"Tue, 17 April 2007 17:17:52 UTC", // data:"0/BjzyY6jeh71h...pAw2++NEyylGhMC5C5f5m8pBApYziN84s4O3JQ3khW/1UttQl4=" // } + + +// # Actual result (causing error in /gamma) +// { +// "result" : { +// "currentVersion" : { +// "reference" : "cb05177f96a832062c6b936d24323cb74a64e2ef1d97ee026cd1003755af7495", +// "data" : "RAnoHmikp7RmiZ2WVyEMW+Ia", +// "header" : "", +// "version" : "0.3", +// "creationDate" : "0000-00-00 00:00:00", +// "updateDate" : "2011-10-09 19:49:11", +// "accessDate" : "2011-10-09 19:49:11" +// }, +// "reference" : "b07e2afa2ba782b9f379649b36ded6de0452b43c27e6b887c7ce4f2a93f44346", +// "data" : "NtK1nkLUabbJQx5uO8ept...ZJ5dkJYYkyh3VQ==", +// "version" : "0.3", +// "creationDate" : "2011-10-09 19:49:11", +// "updateDate" : "Tue, 30 Nov 1999 00:00:00 +0000", +// "accessDate" : "0000-00-00 00:00:00", +// "oldestUsedEncryptedVersion" : "---" +// } +// } + + +// # Response from the online /gamma version +// { +// "result" : { +// "versions" : { +// "e2c193f017ad4f6babf51de59f7550a40596afc0c27373b6a360e426b5bc06de" : { +// "reference" : "e2c193f017ad4f6babf51de59f7550a40596afc0c27373b6a360e426b5bc06de", +// "data" : "s\/3ClggH4uCcf+BkIMqQ...+W0PVt\/MJ3t7s1g0g", +// "creationDate" : "Mon, 10 October 2011 14:42:42 UTC", +// "header" : "####", +// "updateDate" : "Mon, 10 October 2011 14:42:42 UTC", +// "previousVersion" : "a96a6d8b9ac73fcdf874d8a8534ffb2d43da8f5222e96a4a29bd2ae437619463", +// "version" : "0.3", +// "accessDate" : "Mon, 10 October 2011 14:42:42 UTC", +// "previousVersionKey" : "####" +// }, +// [...] +// "a96a6d8b9ac73fcdf874d8a8534ffb2d43da8f5222e96a4a29bd2ae437619463" : { +// "reference" : "a96a6d8b9ac73fcdf874d8a8534ffb2d43da8f5222e96a4a29bd2ae437619463", +// "accessDate" : "Mon, 10 October 2011 14:41:17 UTC", +// "creationDate" : "Mon, 27 October 2008 08:16:14 UTC", +// "version" : "0.3", +// "data" : "m3yhZu81UAjCY6U2Kn...IUCb9suV0fldGOg=", +// "updateDate" : "Mon, 27 October 2008 08:16:14 UTC", +// "header" : "####" +// } +// }, +// "oldestUsedEncryptedVersion" : "0.2", +// "reference" : "36ec1a41118813ced3553534fa2607d781cba687768db305beed368a8e06e113", +// "data" : "frlUkTbaOWD9j2ROat...ruWioCK0Mss27oHjPg==", +// "creationDate" : "Wed, 14 March 2007 17:39:35 UTC", +// "version" : "0.3", +// "accessDate" : "Mon, 10 October 2011 14:45:12 UTC", +// "currentVersion" : "e2c193f017ad4f6babf51de59f7550a40596afc0c27373b6a360e426b5bc06de", +// "updatedDate" : "Mon, 10 October 2011 14:45:12 UTC" +// }, +// "toll" : { +// "requestType" : "MESSAGE", +// "targetValue" : "a516c942a3792cc620775a41f8870a6c7b51796d9a94da978a75da6a52eb1e10", +// "cost" : 2 +// } +// } + $record = new record(); $recordList = $record->GetList(array(array("reference", "=", $parameters["parameters"]["reference"]))); $currentRecord = $recordList[0]; $currentRecordVersions = $currentRecord->GetRecordversionList(); $currentVersion = $currentRecordVersions[0]; - - $result["currentVersion"] = array(); - $result["currentVersion"]["reference"] = $currentVersion->reference; - $result["currentVersion"]["data"] = $currentVersion->data; - $result["currentVersion"]["header"] = $currentVersion->header; - $result["currentVersion"]["version"] = $currentVersion->version; - $result["currentVersion"]["creationDate"] = $currentVersion->creation_date; - $result["currentVersion"]["updateDate"] = $currentVersion->update_date; - $result["currentVersion"]["accessDate"] = $currentVersion->access_date; + + $result["versions"] = array(); +// foreach ($currentRecordVersions as $currentVersion) { + $result["versions"][$currentVersion->reference] = array(); + $result["versions"][$currentVersion->reference]["reference"] = $currentVersion->reference; + $result["versions"][$currentVersion->reference]["data"] = $currentVersion->data; + $result["versions"][$currentVersion->reference]["header"] = $currentVersion->header; + $result["versions"][$currentVersion->reference]["version"] = $currentVersion->version; + $result["versions"][$currentVersion->reference]["creationDate"] = $currentVersion->creation_date; + $result["versions"][$currentVersion->reference]["updateDate"] = $currentVersion->update_date; + $result["versions"][$currentVersion->reference]["accessDate"] = $currentVersion->access_date; + +// } + $result["currentVersion"] = $currentVersion->reference; +// $result["currentVersion"] = $currentRecord->currentVersion; // ???? $result["reference"] = $currentRecord->reference; $result["data"] = $currentRecord->data; $result["version"] = $currentRecord->version; @@ -748,8 +908,11 @@ error_log("default"); break; } session_write_close(); + + $finalResult = Array(); + $finalResult["result"] = $result; - echo(json_encode($result)); -error_log("result: ".json_encode($result)); + echo(json_encode($finalResult)); +error_log("result: ".json_encode($finalResult)); ?> diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Record.js b/frontend/beta/js/Clipperz/PM/DataModel/Record.js index 270f2ae..ffb45de 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/Record.js @@ -278,20 +278,25 @@ Clipperz.PM.DataModel.Record.prototype = MochiKit.Base.update(null, { //MochiKit.Logging.logDebug("--- Record.processData: " + Clipperz.Base.serializeJSON(someValues)); if (this.shouldProcessData()) { var currentVersionParameters; +console.log("Record.processData", someValues); this.processDataToExtractLegacyValues(someValues['data']); if (typeof(someValues['data']['notes']) != 'undefined') { this.setNotes(someValues['data']['notes']); } + if (someValues['data']['currentVersionKey'] != null) { this.setCurrentVersionKey(someValues['data']['currentVersionKey']); } else { this.setCurrentVersionKey(this.key()); } - currentVersionParameters = someValues['currentVersion']; +// currentVersionParameters = someValues['currentVersion']; + currentVersionParameters = someValues['versions'][someValues['currentVersion']]; +console.log("Record.processData - this.currentVersionKey()", this.currentVersionKey()); +console.log("Record.processData - currentVersionParameters", currentVersionParameters); currentVersionParameters['key'] = this.currentVersionKey(); this.setCurrentVersion(new Clipperz.PM.DataModel.RecordVersion(this, currentVersionParameters)); if (someValues['data']['directLogins'] != null) { diff --git a/frontend/beta/js/Clipperz/PM/Proxy.js b/frontend/beta/js/Clipperz/PM/Proxy.js index f476196..bec9195 100644 --- a/frontend/beta/js/Clipperz/PM/Proxy.js +++ b/frontend/beta/js/Clipperz/PM/Proxy.js @@ -115,10 +115,9 @@ Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { //console.log("added a new toll", someParameters['toll']); this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); } //console.log("<<< Proxy.setTallCallback", someParameters['result']); - //return someParameters['result']; - return someParameters; + return someParameters['result']; }, //========================================================================= diff --git a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js deleted file mode 100755 index 34a10c2..0000000 --- a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js +++ b/dev/null @@ -1,262 +0,0 @@ -/* - -Copyright 2008-2011 Clipperz Srl - -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an 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 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. - 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/>. - -*/ - -if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } -if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } - -//============================================================================= - -Clipperz.PM.Proxy.PHP = function(args) { - Clipperz.PM.Proxy.PHP.superclass.constructor.call(this, args); -/* - this._tolls = { - 'CONNECT': [], - 'REGISTER': [], - 'MESSAGE': [] - }; -*/ - return this; -} - -YAHOO.extendX(Clipperz.PM.Proxy.PHP, Clipperz.PM.Proxy, { - - 'toString': function() { - 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"); diff --git a/frontend/gamma/html/index_template.html b/frontend/gamma/html/index_template.html index 8cf838c..bedb243 100644 --- a/frontend/gamma/html/index_template.html +++ b/frontend/gamma/html/index_template.html @@ -38,8 +38,13 @@ Clipperz_normalizedNewLine = '\x0d\x0a'; </div> <div id="applicationVersionType" class="@application.version.type@"></div> +<script> + Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.JSON({'url':'@request.path@', 'shouldPayTolls':@should.pay.toll@}); + /*offline_data_placeholder*/ +</script> + <!-- --> <div id="javaScriptAlert"> <div class="mask"></div> <div class="message"> diff --git a/frontend/gamma/js/Clipperz/Async.js b/frontend/gamma/js/Clipperz/Async.js index 7c9d783..97d8ecf 100644 --- a/frontend/gamma/js/Clipperz/Async.js +++ b/frontend/gamma/js/Clipperz/Async.js @@ -61,9 +61,10 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, { //----------------------------------------------------------------------------- 'callback': function (aValue) { if (this._shouldTrace) { - Clipperz.log("CALLBACK " + this._name, aValue); + // Clipperz.log("CALLBACK " + this._name, aValue); + console.log("CALLBACK " + this._name, aValue); } if (this.chained == false) { var message; @@ -81,9 +82,10 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, { resultMessage = "RESULT " + this._name + " <=="; // this.addCallback(function(aResult) { Clipperz.Async.Deferred.superclass.addCallback.call(this, function(aResult) { - Clipperz.log(resultMessage, aResult); + // Clipperz.log(resultMessage, aResult); + console.log(resultMessage, aResult); return aResult; }); } @@ -105,20 +107,24 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, { this._count ++; message = "[" + this._count + "] " + this._name + " "; // this.addBoth(function(aResult) {Clipperz.log(message + "-->", aResult); return aResult;}); this.addCallbacks( - function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, - function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} + // function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, + function(aResult) {console.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, + // function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} + function(aResult) {console.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} ); } Clipperz.Async.Deferred.superclass.addCallback.apply(this, arguments); if (this._shouldTrace) { // this.addBoth(function(aResult) {Clipperz.log(message + "<--", aResult); return aResult;}); this.addCallbacks( - function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;}, - function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;} + // function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;}, + function(aResult) {console.log("-OK- " + message + "<--", aResult); return aResult;}, + // function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;} + function(aResult) {console.log("FAIL " + message + "<--", aResult); return aResult;} ); } }, @@ -405,8 +411,9 @@ MochiKit.Base.update(Clipperz.Async.DeferredSynchronizer.prototype, { // nothing to do here other than possibly log something } else if (this.numberOfMethodsDone() == this.methods().length) { this.result().callback(); } else if (this.numberOfMethodsDone() > this.methods().length) { + alert("Clipperz.Async.Deferred.handleMethodCallDone -> WTF!"); // WTF!!! :( } }, diff --git a/frontend/gamma/js/Clipperz/PM/Proxy.js b/frontend/gamma/js/Clipperz/PM/Proxy.js index 190bffd..9817eac 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy.js @@ -141,9 +141,9 @@ Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { 'processMessage': function (aFunctionName, someParameters, aRequestType) { var deferredResult; - deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:false}); + deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:true}); deferredResult.addMethod(this, 'payToll', aRequestType); deferredResult.addMethod(this, 'sendMessage', aFunctionName); deferredResult.addMethod(this, 'setTollCallback'); deferredResult.callback(someParameters); |