summaryrefslogtreecommitdiff
path: root/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote
diff options
context:
space:
mode:
Diffstat (limited to 'webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote')
-rw-r--r--webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/AbstractRemoteTransport.js328
-rw-r--r--webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Exchange.js704
-rw-r--r--webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/IframeTransport.js472
-rw-r--r--webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Request.js545
-rw-r--r--webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/RequestQueue.js392
-rw-r--r--webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Response.js110
-rw-r--r--webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Rpc.js572
-rw-r--r--webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/ScriptTransport.js360
-rw-r--r--webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/XmlHttpTransport.js819
9 files changed, 4302 insertions, 0 deletions
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/AbstractRemoteTransport.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/AbstractRemoteTransport.js
new file mode 100644
index 0000000000..2232394dea
--- /dev/null
+++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/AbstractRemoteTransport.js
@@ -0,0 +1,328 @@
+/* ************************************************************************
+
+ qooxdoo - the new era of web development
+
+ http://qooxdoo.org
+
+ Copyright:
+ 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
+
+ License:
+ LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
+
+ Authors:
+ * Sebastian Werner (wpbasti)
+ * Andreas Ecker (ecker)
+
+************************************************************************ */
+
+/* ************************************************************************
+
+#module(io_remote)
+
+************************************************************************ */
+
+/**
+ * @event created {qx.event.type.Event}
+ * @event configured {qx.event.type.Event}
+ * @event sending {qx.event.type.Event}
+ * @event receiving {qx.event.type.Event}
+ * @event completed {qx.event.type.Event}
+ * @event aborted {qx.event.type.Event}
+ * @event failed {qx.event.type.Event}
+ * @event timeout {qx.event.type.Event}
+ */
+qx.OO.defineClass("qx.io.remote.AbstractRemoteTransport", qx.core.Target,
+function() {
+ qx.core.Target.call(this);
+});
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ PROPERTIES
+---------------------------------------------------------------------------
+*/
+
+/*!
+ Target url to issue the request to
+*/
+qx.OO.addProperty({ name : "url", type : "string" });
+
+/*!
+ Determines what type of request to issue
+*/
+qx.OO.addProperty({ name : "method", type : "string" });
+
+/*!
+ Set the request to asynchronous
+*/
+qx.OO.addProperty({ name : "asynchronous", type : "boolean" });
+
+/*!
+ Set the data to be sent via this request
+*/
+qx.OO.addProperty({ name : "data", type : "string" });
+
+/*!
+ Username to use for HTTP authentication
+*/
+qx.OO.addProperty({ name : "username", type : "string" });
+
+/*!
+ Password to use for HTTP authentication
+*/
+qx.OO.addProperty({ name : "password", type : "string" });
+
+/*!
+ The state of the current request
+*/
+qx.OO.addProperty(
+{
+ name : "state",
+ type : "string",
+ possibleValues : [
+ "created", "configured",
+ "sending", "receiving",
+ "completed", "aborted",
+ "timeout", "failed"
+ ],
+ defaultValue : "created"
+});
+
+/*!
+ Request headers
+*/
+qx.OO.addProperty({ name : "requestHeaders", type: "object" });
+
+/*!
+ Request parameters to send.
+*/
+qx.OO.addProperty({ name : "parameters", type: "object" });
+
+/*!
+ Response Type
+*/
+qx.OO.addProperty({ name : "responseType", type: "string" });
+
+/*!
+ Use Basic HTTP Authentication
+*/
+qx.OO.addProperty({ name : "useBasicHttpAuth", type : "boolean" });
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ USER METHODS
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.send = function() {
+ throw new Error("send is abstract");
+}
+
+qx.Proto.abort = function()
+{
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.warn("Aborting...");
+ }
+
+ this.setState("aborted");
+}
+
+/*!
+
+*/
+qx.Proto.timeout = function()
+{
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.warn("Timeout...");
+ }
+
+ this.setState("timeout");
+}
+
+/*!
+
+ Force the transport into the failed state ("failed").
+
+ Listeners of the "failed" signal are notified about the event.
+*/
+qx.Proto.failed = function()
+{
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.warn("Failed...");
+ }
+
+ this.setState("failed");
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ REQUEST HEADER SUPPORT
+---------------------------------------------------------------------------
+*/
+/*!
+ Add a request header to this transports qx.io.remote.Request.
+
+ This method is virtual and concrete subclasses are supposed to
+ implement it.
+*/
+qx.Proto.setRequestHeader = function(vLabel, vValue) {
+ throw new Error("setRequestHeader is abstract");
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ RESPONSE HEADER SUPPORT
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.getResponseHeader = function(vLabel) {
+ throw new Error("getResponseHeader is abstract");
+}
+
+/*!
+ Provides an hash of all response headers.
+*/
+qx.Proto.getResponseHeaders = function() {
+ throw new Error("getResponseHeaders is abstract");
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ STATUS SUPPORT
+---------------------------------------------------------------------------
+*/
+
+/*!
+ Returns the current status code of the request if available or -1 if not.
+*/
+qx.Proto.getStatusCode = function() {
+ throw new Error("getStatusCode is abstract");
+}
+
+/*!
+ Provides the status text for the current request if available and null otherwise.
+*/
+qx.Proto.getStatusText = function() {
+ throw new Error("getStatusText is abstract");
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ RESPONSE DATA SUPPORT
+---------------------------------------------------------------------------
+*/
+
+/*!
+ Provides the response text from the request when available and null otherwise.
+ By passing true as the "partial" parameter of this method, incomplete data will
+ be made available to the caller.
+*/
+qx.Proto.getResponseText = function() {
+ throw new Error("getResponseText is abstract");
+}
+
+/*!
+ Provides the XML provided by the response if any and null otherwise.
+ By passing true as the "partial" parameter of this method, incomplete data will
+ be made available to the caller.
+*/
+qx.Proto.getResponseXml = function() {
+ throw new Error("getResponseXml is abstract");
+}
+
+/*!
+ Returns the length of the content as fetched thus far
+*/
+qx.Proto.getFetchedLength = function() {
+ throw new Error("getFetchedLength is abstract");
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ MODIFIER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._modifyState = function(propValue, propOldValue, propData)
+{
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.debug("State: " + propValue);
+ }
+
+ switch(propValue)
+ {
+ case "created":
+ this.createDispatchEvent("created");
+ break;
+
+ case "configured":
+ this.createDispatchEvent("configured");
+ break;
+
+ case "sending":
+ this.createDispatchEvent("sending");
+ break;
+
+ case "receiving":
+ this.createDispatchEvent("receiving");
+ break;
+
+ case "completed":
+ this.createDispatchEvent("completed");
+ break;
+
+ case "aborted":
+ this.createDispatchEvent("aborted");
+ break;
+
+ case "failed":
+ this.createDispatchEvent("failed");
+ break;
+
+ case "timeout":
+ this.createDispatchEvent("timeout");
+ break;
+ }
+
+ return true;
+}
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Exchange.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Exchange.js
new file mode 100644
index 0000000000..d9f0738660
--- /dev/null
+++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Exchange.js
@@ -0,0 +1,704 @@
+/* ************************************************************************
+
+ qooxdoo - the new era of web development
+
+ http://qooxdoo.org
+
+ Copyright:
+ 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
+ 2006 by Derrell Lipman
+ 2006 by STZ-IDA, Germany, http://www.stz-ida.de
+
+ License:
+ LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
+
+ Authors:
+ * Sebastian Werner (wpbasti)
+ * Andreas Ecker (ecker)
+ * Derrell Lipman (derrell)
+ * Andreas Junghans (lucidcake)
+
+************************************************************************ */
+
+/* ************************************************************************
+
+#module(io_remote)
+
+************************************************************************ */
+
+/**
+ * @event sending {qx.event.type.Event}
+ * @event receiving {qx.event.type.Event}
+ * @event completed {qx.event.type.Event}
+ * @event aborted {qx.event.type.Event}
+ * @event timeout {qx.event.type.Event}
+ * @event failed {qx.event.type.Event}
+ */
+qx.OO.defineClass("qx.io.remote.Exchange", qx.core.Target,
+function(vRequest)
+{
+ qx.core.Target.call(this);
+
+ this.setRequest(vRequest);
+ vRequest.setTransport(this);
+});
+
+
+/*
+---------------------------------------------------------------------------
+ DEFAULT SETTINGS
+---------------------------------------------------------------------------
+*/
+
+qx.Settings.setDefault("enableDebug", false);
+
+
+
+
+
+
+/* ************************************************************************
+ Class data, properties and methods
+************************************************************************ */
+
+/*
+---------------------------------------------------------------------------
+ TRANSPORT TYPE HANDLING
+---------------------------------------------------------------------------
+*/
+
+qx.io.remote.Exchange.typesOrder = [ "qx.io.remote.XmlHttpTransport", "qx.io.remote.IframeTransport", "qx.io.remote.ScriptTransport" ];
+
+qx.io.remote.Exchange.typesReady = false;
+
+qx.io.remote.Exchange.typesAvailable = {};
+qx.io.remote.Exchange.typesSupported = {};
+
+qx.io.remote.Exchange.registerType = function(vClass, vId) {
+ qx.io.remote.Exchange.typesAvailable[vId] = vClass;
+}
+
+qx.io.remote.Exchange.initTypes = function()
+{
+ if (qx.io.remote.Exchange.typesReady) {
+ return;
+ }
+
+ for (var vId in qx.io.remote.Exchange.typesAvailable)
+ {
+ vTransporterImpl = qx.io.remote.Exchange.typesAvailable[vId];
+
+ if (vTransporterImpl.isSupported()) {
+ qx.io.remote.Exchange.typesSupported[vId] = vTransporterImpl;
+ }
+ }
+
+ qx.io.remote.Exchange.typesReady = true;
+
+ if (qx.lang.Object.isEmpty(qx.io.remote.Exchange.typesSupported)) {
+ throw new Error("No supported transport types were found!");
+ }
+}
+
+qx.io.remote.Exchange.canHandle = function(vImpl, vNeeds, vResponseType)
+{
+ if (!qx.lang.Array.contains(vImpl.handles.responseTypes, vResponseType)) {
+ return false;
+ }
+
+ for (var vKey in vNeeds)
+ {
+ if (!vImpl.handles[vKey]) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ MAPPING
+---------------------------------------------------------------------------
+*/
+
+/*
+http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/0e6a34e4-f90c-489d-acff-cb44242fafc6.asp
+
+0: UNINITIALIZED
+The object has been created, but not initialized (the open method has not been called).
+
+1: LOADING
+The object has been created, but the send method has not been called.
+
+2: LOADED
+The send method has been called, but the status and headers are not yet available.
+
+3: INTERACTIVE
+Some data has been received. Calling the responseBody and responseText properties at this state to obtain partial results will return an error, because status and response headers are not fully available.
+
+4: COMPLETED
+All the data has been received, and the complete data is available in the
+*/
+
+qx.io.remote.Exchange._nativeMap =
+{
+ 0 : "created",
+ 1 : "configured",
+ 2 : "sending",
+ 3 : "receiving",
+ 4 : "completed"
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ UTILS
+---------------------------------------------------------------------------
+*/
+
+qx.io.remote.Exchange.wasSuccessful = function(vStatusCode, vReadyState, vIsLocal)
+{
+ if (vIsLocal)
+ {
+ switch(vStatusCode)
+ {
+ case null:
+ case 0:
+ return true;
+
+ case -1:
+ // Not Available (OK for readystates: MSXML<4=1-3, MSXML>3=1-2, Gecko=1)
+ return vReadyState < 4;
+
+ default:
+ // at least older versions of Safari don't set the status code for local file access
+ return typeof vStatusCode === "undefined";
+ }
+ }
+ else
+ {
+ switch(vStatusCode)
+ {
+ case -1: // Not Available (OK for readystates: MSXML<4=1-3, MSXML>3=1-2, Gecko=1)
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug") && vReadyState > 3) {
+ qx.dev.log.Logger.getClassLogger(qx.io.remote.Exchange).debug("Failed with statuscode: -1 at readyState " + vReadyState);
+ }
+
+ return vReadyState < 4;
+
+
+ case 200: // OK
+ case 304: // Not Modified
+ return true;
+
+
+ case 201: // Created
+ case 202: // Accepted
+ case 203: // Non-Authoritative Information
+ case 204: // No Content
+ case 205: // Reset Content
+ return true;
+
+
+ case 206: // Partial Content
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug") && vReadyState === 4) {
+ qx.dev.log.Logger.getClassLogger(qx.io.remote.Exchange).debug("Failed with statuscode: 206 (Partial content while being complete!)");
+ }
+
+ return vReadyState !== 4;
+
+
+ case 300: // Multiple Choices
+ case 301: // Moved Permanently
+ case 302: // Moved Temporarily
+ case 303: // See Other
+ case 305: // Use Proxy
+ case 400: // Bad Request
+ case 401: // Unauthorized
+ case 402: // Payment Required
+ case 403: // Forbidden
+ case 404: // Not Found
+ case 405: // Method Not Allowed
+ case 406: // Not Acceptable
+ case 407: // Proxy Authentication Required
+ case 408: // Request Time-Out
+ case 409: // Conflict
+ case 410: // Gone
+ case 411: // Length Required
+ case 412: // Precondition Failed
+ case 413: // Request Entity Too Large
+ case 414: // Request-URL Too Large
+ case 415: // Unsupported Media Type
+ case 500: // Server Error
+ case 501: // Not Implemented
+ case 502: // Bad Gateway
+ case 503: // Out of Resources
+ case 504: // Gateway Time-Out
+ case 505: // HTTP Version not supported
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ qx.dev.log.Logger.getClassLogger(qx.io.remote.Exchange).debug("Failed with typical HTTP statuscode: " + vStatusCode);
+ }
+
+ return false;
+
+
+ // The following case labels are wininet.dll error codes that may be encountered.
+ // Server timeout
+ case 12002:
+ // 12029 to 12031 correspond to dropped connections.
+ case 12029:
+ case 12030:
+ case 12031:
+ // Connection closed by server.
+ case 12152:
+ // See above comments for variable status.
+ case 13030:
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ qx.dev.log.Logger.getClassLogger(qx.io.remote.Exchange).debug("Failed with MSHTML specific HTTP statuscode: " + vStatusCode);
+ }
+
+ return false;
+
+
+ default:
+ // Handle all 20x status codes as OK as defined in the corresponding RFC
+ // http://www.w3.org/Protocols/rfc2616/rfc2616.html
+ if (vStatusCode > 206 && vStatusCode < 300) {
+ return true;
+ }
+
+ qx.dev.log.Logger.getClassLogger(qx.io.remote.Exchange).debug("Unknown status code: " + vStatusCode + " (" + vReadyState + ")");
+ throw new Error("Unknown status code: " + vStatusCode);
+ }
+ }
+}
+
+
+qx.io.remote.Exchange.statusCodeToString = function(vStatusCode)
+{
+ switch(vStatusCode)
+ {
+ case -1: return "Not available";
+ case 200: return "Ok";
+ case 304: return "Not modified";
+ case 206: return "Partial content";
+ case 204: return "No content";
+ case 300: return "Multiple choices";
+ case 301: return "Moved permanently";
+ case 302: return "Moved temporarily";
+ case 303: return "See other";
+ case 305: return "Use proxy";
+ case 400: return "Bad request";
+ case 401: return "Unauthorized";
+ case 402: return "Payment required";
+ case 403: return "Forbidden";
+ case 404: return "Not found";
+ case 405: return "Method not allowed";
+ case 406: return "Not acceptable";
+ case 407: return "Proxy authentication required";
+ case 408: return "Request time-out";
+ case 409: return "Conflict";
+ case 410: return "Gone";
+ case 411: return "Length required";
+ case 412: return "Precondition failed";
+ case 413: return "Request entity too large";
+ case 414: return "Request-URL too large";
+ case 415: return "Unsupported media type";
+ case 500: return "Server error";
+ case 501: return "Not implemented";
+ case 502: return "Bad gateway";
+ case 503: return "Out of resources";
+ case 504: return "Gateway time-out";
+ case 505: return "HTTP version not supported";
+ case 12002: return "Server timeout";
+ case 12029: return "Connection dropped";
+ case 12030: return "Connection dropped";
+ case 12031: return "Connection dropped";
+ case 12152: return "Connection closed by server";
+ case 13030: return "MSHTML-specific HTTP status code";
+ default: return "Unknown status code";
+ }
+}
+
+
+
+
+
+
+
+/* ************************************************************************
+ Instance data, properties and methods
+************************************************************************ */
+
+/*
+---------------------------------------------------------------------------
+ PROPERTIES
+---------------------------------------------------------------------------
+*/
+
+/*!
+ Set the request to send with this transport.
+*/
+qx.OO.addProperty({ name : "request", type : "object", instance : "qx.io.remote.Request" });
+/*!
+ Set the implementation to use to send the request with.
+
+ The implementation should be a subclass of qx.io.remote.AbstractRemoteTransport and
+ must implement all methods in the transport API.
+*/
+qx.OO.addProperty({ name : "implementation", type : "object" });
+qx.OO.addProperty(
+{
+ name : "state",
+ type : "string",
+ possibleValues : [
+ "configured", "sending",
+ "receiving", "completed",
+ "aborted", "timeout",
+ "failed"
+ ],
+ defaultValue : "configured"
+});
+
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ CORE METHODS
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.send = function()
+{
+ var vRequest = this.getRequest();
+
+ if (!vRequest) {
+ return this.error("Please attach a request object first");
+ }
+
+ qx.io.remote.Exchange.initTypes();
+
+ var vUsage = qx.io.remote.Exchange.typesOrder;
+ var vSupported = qx.io.remote.Exchange.typesSupported;
+
+ // Mapping settings to contenttype and needs to check later
+ // if the selected transport implementation can handle
+ // fulfill these requirements.
+ var vResponseType = vRequest.getResponseType();
+ var vNeeds = {};
+
+ if (vRequest.getAsynchronous()) {
+ vNeeds.asynchronous = true;
+ } else {
+ vNeeds.synchronous = true;
+ }
+
+ if (vRequest.getCrossDomain()) {
+ vNeeds.crossDomain = true;
+ }
+
+ if (vRequest.getFileUpload()) {
+ vNeeds.fileUpload = true;
+ }
+
+ var vTransportImpl, vTransport;
+ for (var i=0, l=vUsage.length; i<l; i++)
+ {
+ vTransportImpl = vSupported[vUsage[i]];
+
+ if (vTransportImpl)
+ {
+ if (!qx.io.remote.Exchange.canHandle(vTransportImpl, vNeeds, vResponseType)) {
+ continue;
+ }
+
+ try
+ {
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.debug("Using implementation: " + vTransportImpl.classname);
+ }
+
+ vTransport = new vTransportImpl;
+ this.setImplementation(vTransport);
+
+ vTransport.setUseBasicHttpAuth(vRequest.getUseBasicHttpAuth());
+
+ vTransport.send();
+ return true;
+ }
+ catch(ex)
+ {
+ return this.error("Request handler throws error", ex);
+ }
+ }
+ }
+
+ this.error("There is no transport implementation available to handle this request: " + vRequest);
+}
+/*!
+ Force the transport into the aborted ("aborted")
+ state.
+*/
+qx.Proto.abort = function()
+{
+ var vImplementation = this.getImplementation();
+
+ if (vImplementation)
+ {
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.debug("Abort: implementation " + vImplementation.toHashCode());
+ }
+ vImplementation.abort();
+ }
+ else
+ {
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.debug("Abort: forcing state to be aborted");
+ }
+ this.setState("aborted");
+ }
+}
+/*!
+ Force the transport into the timeout state.
+*/
+qx.Proto.timeout = function()
+{
+ var vImplementation = this.getImplementation();
+
+ if (vImplementation)
+ {
+ this.warn("Timeout: implementation " + vImplementation.toHashCode());
+ vImplementation.timeout();
+ }
+ else
+ {
+ this.warn("Timeout: forcing state to timeout");
+ this.setState("timeout");
+ }
+
+ // Disable future timeouts in case user handler blocks
+ if (this.getRequest()) {
+ this.getRequest().setTimeout(0);
+ }
+}
+
+
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ EVENT HANDLER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._onsending = function(e) {
+ this.setState("sending");
+}
+
+qx.Proto._onreceiving = function(e) {
+ this.setState("receiving");
+}
+
+qx.Proto._oncompleted = function(e) {
+ this.setState("completed");
+}
+
+qx.Proto._onabort = function(e) {
+ this.setState("aborted");
+}
+
+qx.Proto._onfailed = function(e) {
+ this.setState("failed");
+}
+
+qx.Proto._ontimeout = function(e) {
+ this.setState("timeout");
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ MODIFIER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._modifyImplementation = function(propValue, propOldValue, propData)
+{
+ if (propOldValue)
+ {
+ propOldValue.removeEventListener("sending", this._onsending, this);
+ propOldValue.removeEventListener("receiving", this._onreceiving, this);
+ propOldValue.removeEventListener("completed", this._oncompleted, this);
+ propOldValue.removeEventListener("aborted", this._onabort, this);
+ propOldValue.removeEventListener("timeout", this._ontimeout, this);
+ propOldValue.removeEventListener("failed", this._onfailed, this);
+ }
+
+ if (propValue)
+ {
+ var vRequest = this.getRequest();
+
+ propValue.setUrl(vRequest.getUrl());
+ propValue.setMethod(vRequest.getMethod());
+ propValue.setAsynchronous(vRequest.getAsynchronous());
+
+ propValue.setUsername(vRequest.getUsername());
+ propValue.setPassword(vRequest.getPassword());
+
+ propValue.setParameters(vRequest.getParameters());
+ propValue.setRequestHeaders(vRequest.getRequestHeaders());
+ propValue.setData(vRequest.getData());
+
+ propValue.setResponseType(vRequest.getResponseType());
+
+ propValue.addEventListener("sending", this._onsending, this);
+ propValue.addEventListener("receiving", this._onreceiving, this);
+ propValue.addEventListener("completed", this._oncompleted, this);
+ propValue.addEventListener("aborted", this._onabort, this);
+ propValue.addEventListener("timeout", this._ontimeout, this);
+ propValue.addEventListener("failed", this._onfailed, this);
+ }
+
+ return true;
+}
+
+qx.Proto._modifyState = function(propValue, propOldValue, propData)
+{
+ var vRequest = this.getRequest();
+
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.debug("State: " + propOldValue + " => " + propValue);
+ }
+
+ switch(propValue)
+ {
+ case "sending":
+ this.createDispatchEvent("sending");
+ break;
+
+ case "receiving":
+ this.createDispatchEvent("receiving");
+ break;
+
+ case "completed":
+ case "aborted":
+ case "timeout":
+ case "failed":
+ var vImpl = this.getImplementation();
+
+ if (! vImpl) {
+ // implementation has already been disposed
+ break;
+ }
+
+ var vResponse = new qx.io.remote.Response;
+
+ if (propValue == "completed") {
+ var vContent = vImpl.getResponseContent();
+ vResponse.setContent(vContent);
+
+ /*
+ * Was there acceptable content? This might occur, for example, if
+ * the web server was shut down unexpectedly and thus the connection
+ * closed with no data having been sent.
+ */
+ if (vContent === null) {
+ // Nope. Change COMPLETED to FAILED.
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.debug("Altered State: " + propValue + " => failed");
+ }
+ propValue = "failed";
+ }
+ }
+
+ vResponse.setStatusCode(vImpl.getStatusCode());
+ vResponse.setResponseHeaders(vImpl.getResponseHeaders());
+
+ // this.debug("Result Text: " + vResponse.getTextContent());
+
+ var vEventType;
+
+ switch(propValue)
+ {
+ case "completed":
+ vEventType = "completed";
+ break;
+
+ case "aborted":
+ vEventType = "aborted";
+ break;
+
+ case "timeout":
+ vEventType = "timeout";
+ break;
+
+ case "failed":
+ vEventType = "failed";
+ break;
+ }
+
+ // Disconnect and dispose implementation
+ this.setImplementation(null);
+ vImpl.dispose();
+
+ // Fire event to listeners
+ this.createDispatchDataEvent(vEventType, vResponse);
+ break;
+ }
+
+ return true;
+}
+
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ DISPOSER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.dispose = function()
+{
+ if (this.getDisposed()) {
+ return;
+ }
+
+ var vImpl = this.getImplementation();
+ if (vImpl)
+ {
+ this.setImplementation(null);
+ vImpl.dispose();
+ }
+
+ this.setRequest(null);
+
+ return qx.core.Target.prototype.dispose.call(this);
+}
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/IframeTransport.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/IframeTransport.js
new file mode 100644
index 0000000000..29126c587b
--- /dev/null
+++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/IframeTransport.js
@@ -0,0 +1,472 @@
+/* ************************************************************************
+
+ qooxdoo - the new era of web development
+
+ http://qooxdoo.org
+
+ Copyright:
+ 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
+ 2006 by Derrell Lipman
+ 2006 by STZ-IDA, Germany, http://www.stz-ida.de
+
+ License:
+ LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
+
+ Authors:
+ * Sebastian Werner (wpbasti)
+ * Andreas Ecker (ecker)
+ * Derrell Lipman (derrell)
+ * Andreas Junghans (lucidcake)
+
+************************************************************************ */
+
+/* ************************************************************************
+
+#module(io_remote)
+#require(qx.io.remote.Exchange)
+
+************************************************************************ */
+
+/*!
+ Transports requests to a server using an IFRAME.
+
+ This class should not be used directly by client programmers.
+ */
+qx.OO.defineClass("qx.io.remote.IframeTransport", qx.io.remote.AbstractRemoteTransport,
+function()
+{
+ qx.io.remote.AbstractRemoteTransport.call(this);
+
+ var vUniqueId = (new Date).valueOf();
+ var vFrameName = "frame_" + vUniqueId;
+ var vFormName = "form_" + vUniqueId;
+
+ // Mshtml allows us to define a full HTML as a parameter for createElement.
+ // Using this method is the only (known) working to register the frame
+ // to the known elements of the Internet Explorer.
+ if (qx.sys.Client.getInstance().isMshtml()) {
+ this._frame = document.createElement('<iframe name="' + vFrameName + '"></iframe>');
+ } else {
+ this._frame = document.createElement("iframe");
+ }
+
+ this._frame.src = "javascript:void(0)";
+ this._frame.id = this._frame.name = vFrameName;
+ this._frame.onload = function(e) { return o._onload(e); }
+
+ this._frame.style.display = "none";
+
+ document.body.appendChild(this._frame);
+
+ this._form = document.createElement("form");
+ this._form.target = vFrameName;
+ this._form.id = this._form.name = vFormName;
+
+ this._form.style.display = "none";
+
+ document.body.appendChild(this._form);
+
+ this._data = document.createElement("textarea");
+ this._data.id = this._data.name = "_data_";
+ this._form.appendChild(this._data);
+
+ var o = this;
+ this._frame.onreadystatechange = function(e) { return o._onreadystatechange(e); }
+});
+
+qx.Proto._lastReadyState = 0;
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ CLASS PROPERTIES AND METHODS
+---------------------------------------------------------------------------
+*/
+
+// basic registration to qx.io.remote.Exchange
+// the real availability check (activeX stuff and so on) follows at the first real request
+qx.io.remote.Exchange.registerType(qx.io.remote.IframeTransport, "qx.io.remote.IframeTransport");
+
+qx.io.remote.IframeTransport.handles =
+{
+ synchronous : false,
+ asynchronous : true,
+ crossDomain : false,
+ fileUpload: true,
+ responseTypes : [ "text/plain", "text/javascript", "text/json", "application/xml", "text/html" ]
+}
+
+qx.io.remote.IframeTransport.isSupported = function() {
+ return true;
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ USER METHODS
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.send = function()
+{
+ var vMethod = this.getMethod();
+ var vUrl = this.getUrl();
+
+
+
+ // --------------------------------------
+ // Adding parameters
+ // --------------------------------------
+
+ var vParameters = this.getParameters();
+ var vParametersList = [];
+ for (var vId in vParameters) {
+ var value = vParameters[vId];
+ if (value instanceof Array) {
+ for (var i = 0; i < value.length; i++) {
+ vParametersList.push(encodeURIComponent(vId) + "=" +
+ encodeURIComponent(value[i]));
+ }
+ } else {
+ vParametersList.push(encodeURIComponent(vId) + "=" +
+ encodeURIComponent(value));
+ }
+ }
+
+ if (vParametersList.length > 0) {
+ vUrl += (vUrl.indexOf("?") >= 0 ?
+ "&" : "?") + vParametersList.join("&");
+ }
+
+
+
+ // --------------------------------------
+ // Preparing form
+ // --------------------------------------
+
+ this._form.action = vUrl;
+ this._form.method = vMethod;
+
+
+
+ // --------------------------------------
+ // Sending data
+ // --------------------------------------
+
+ this._data.appendChild(document.createTextNode(this.getData()));
+ this._form.submit();
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ EVENT LISTENER
+---------------------------------------------------------------------------
+*/
+
+// For reference:
+// http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/readyState_1.asp
+qx.io.remote.IframeTransport._numericMap =
+{
+ "uninitialized" : 1,
+ "loading" : 2,
+ "loaded" : 2,
+ "interactive" : 3,
+ "complete" : 4
+}
+
+/*!
+ Converting complete state to numeric value and update state property
+*/
+qx.Proto._onload = function(e)
+{
+ if (this._form.src) {
+ return;
+ }
+
+ this._switchReadyState(qx.io.remote.IframeTransport._numericMap.complete);
+}
+
+/*!
+ Converting named readyState to numeric value and update state property
+*/
+qx.Proto._onreadystatechange = function(e) {
+ this._switchReadyState(qx.io.remote.IframeTransport._numericMap[this._frame.readyState]);
+}
+
+qx.Proto._switchReadyState = function(vReadyState)
+{
+ // Ignoring already stopped requests
+ switch(this.getState())
+ {
+ case "completed":
+ case "aborted":
+ case "failed":
+ case "timeout":
+ this.warn("Ignore Ready State Change");
+ return;
+ }
+
+ // Updating internal state
+ while (this._lastReadyState < vReadyState) {
+ this.setState(qx.io.remote.Exchange._nativeMap[++this._lastReadyState]);
+ }
+}
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ REQUEST HEADER SUPPORT
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.setRequestHeader = function(vLabel, vValue)
+{
+ // TODO
+ // throw new Error("setRequestHeader is abstract");
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ RESPONSE HEADER SUPPORT
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.getResponseHeader = function(vLabel)
+{
+ return null;
+
+ // TODO
+ // this.error("Need implementation", "getResponseHeader");
+}
+
+/*!
+ Provides an hash of all response headers.
+*/
+qx.Proto.getResponseHeaders = function()
+{
+ return {}
+
+ // TODO
+ // throw new Error("getResponseHeaders is abstract");
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ STATUS SUPPORT
+---------------------------------------------------------------------------
+*/
+
+/*!
+ Returns the current status code of the request if available or -1 if not.
+*/
+qx.Proto.getStatusCode = function()
+{
+ return 200;
+
+ // TODO
+ // this.error("Need implementation", "getStatusCode");
+}
+
+/*!
+ Provides the status text for the current request if available and null otherwise.
+*/
+qx.Proto.getStatusText = function()
+{
+ return "";
+
+ // TODO
+ // this.error("Need implementation", "getStatusText");
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ FRAME UTILITIES
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.getIframeWindow = function() {
+ return qx.dom.Iframe.getWindow(this._frame);
+}
+
+qx.Proto.getIframeDocument = function() {
+ return qx.dom.Iframe.getDocument(this._frame);
+}
+
+qx.Proto.getIframeBody = function() {
+ return qx.dom.Iframe.getBody(this._frame);
+}
+
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ RESPONSE DATA SUPPORT
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.getIframeTextContent = function()
+{
+ var vBody = this.getIframeBody();
+
+ if (!vBody) {
+ return null;
+ }
+
+ // Mshtml returns the content inside a PRE
+ // element if we use plain text
+ if (vBody.firstChild.tagName.toLowerCase() == "pre")
+ {
+ return vBody.firstChild.innerHTML;
+ }
+ else
+ {
+ return vBody.innerHTML;
+ }
+}
+
+qx.Proto.getIframeHtmlContent = function()
+{
+ var vBody = this.getIframeBody();
+ return vBody ? vBody.innerHTML : null;
+}
+
+/*!
+ Returns the length of the content as fetched thus far
+*/
+qx.Proto.getFetchedLength = function()
+{
+ return 0;
+
+ // TODO
+ // throw new Error("getFetchedLength is abstract");
+}
+
+qx.Proto.getResponseContent = function()
+{
+ if (this.getState() !== "completed")
+ {
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.warn("Transfer not complete, ignoring content!");
+ }
+
+ return null;
+ }
+
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.debug("Returning content for responseType: " + this.getResponseType());
+ }
+
+ var vText = this.getIframeTextContent();
+
+ switch(this.getResponseType())
+ {
+ case "text/plain":
+ return vText;
+ break;
+
+ case "text/html":
+ return this.getIframeHtmlContent();
+ break;
+
+ case "text/json":
+ try {
+ return vText && vText.length > 0 ? qx.io.Json.parseQx(vText) : null;
+ } catch(ex) {
+ return this.error("Could not execute json: (" + vText + ")", ex);
+ }
+
+ case "text/javascript":
+ try {
+ return vText && vText.length > 0 ? window.eval(vText) : null;
+ } catch(ex) {
+ return this.error("Could not execute javascript: (" + vText + ")", ex);
+ }
+
+ case "application/xml":
+ return this.getIframeDocument();
+
+ default:
+ this.warn("No valid responseType specified (" + this.getResponseType() + ")!");
+ return null;
+ }
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ DISPOSER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.dispose = function()
+{
+ if (this.getDisposed()) {
+ return true;
+ }
+
+ if (this._frame)
+ {
+ this._frame.onload = null;
+ this._frame.onreadystatechange = null;
+
+ // Reset source to a blank image for gecko
+ // Otherwise it will switch into a load-without-end behaviour
+ if (qx.sys.Client.getInstance().isGecko()) {
+ this._frame.src = qx.manager.object.AliasManager.getInstance().resolvePath("static/image/blank.gif");
+ }
+
+ // Finally remove element node
+ document.body.removeChild(this._frame);
+
+ this._frame = null;
+ }
+
+ if (this._form)
+ {
+ document.body.removeChild(this._form);
+ this._form = null;
+ }
+
+ return qx.io.remote.AbstractRemoteTransport.prototype.dispose.call(this);
+}
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Request.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Request.js
new file mode 100644
index 0000000000..6c398cc528
--- /dev/null
+++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Request.js
@@ -0,0 +1,545 @@
+/* ************************************************************************
+
+ qooxdoo - the new era of web development
+
+ http://qooxdoo.org
+
+ Copyright:
+ 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
+ 2006 by Derrell Lipman
+
+ License:
+ LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
+
+ Authors:
+ * Sebastian Werner (wpbasti)
+ * Andreas Ecker (ecker)
+ * Derrell Lipman (derrell)
+
+************************************************************************ */
+
+/* ************************************************************************
+
+#module(io_remote)
+#require(qx.net.Http)
+
+************************************************************************ */
+
+/*!
+ This class is used to send HTTP requests to the server.
+ @param vUrl Target url to issue the request to.
+ @param vMethod Determines what type of request to issue (GET or
+ POST). Default is GET.
+ @param vResponseType The mime type of the response. Default is text/plain.
+*/
+qx.OO.defineClass("qx.io.remote.Request", qx.core.Target,
+function(vUrl, vMethod, vResponseType)
+{
+ qx.core.Target.call(this);
+
+ this._requestHeaders = {};
+ this._parameters = {};
+
+ this.setUrl(vUrl);
+ this.setMethod(vMethod || qx.net.Http.METHOD_GET);
+ this.setResponseType(vResponseType || "text/plain");
+
+ this.setProhibitCaching(true);
+
+ // Prototype-Style Request Headers
+ this.setRequestHeader("X-Requested-With", "qooxdoo");
+ this.setRequestHeader("X-Qooxdoo-Version", qx.core.Version.toString());
+
+ // Get the next sequence number for this request
+ this._seqNum = ++qx.io.remote.Request._seqNum;
+});
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ PROPERTIES
+---------------------------------------------------------------------------
+*/
+/*!
+ Target url to issue the request to.
+*/
+qx.OO.addProperty({ name : "url", type : "string" });
+/*!
+ Determines what type of request to issue (GET or POST).
+*/
+qx.OO.addProperty(
+{
+ name : "method",
+ type : "string",
+ possibleValues : [
+ qx.net.Http.METHOD_GET, qx.net.Http.METHOD_POST,
+ qx.net.Http.METHOD_PUT, qx.net.Http.METHOD_HEAD,
+ qx.net.Http.METHOD_DELETE
+ ]
+});
+/*!
+ Set the request to asynchronous.
+*/
+qx.OO.addProperty({ name : "asynchronous", type : "boolean", defaultValue : true,
+ getAlias: "isAsynchronous" });
+/*!
+ Set the data to be sent via this request
+*/
+qx.OO.addProperty({ name : "data", type : "string" });
+/*!
+ Username to use for HTTP authentication. Null if HTTP authentication
+ is not used.
+*/
+qx.OO.addProperty({ name : "username", type : "string" });
+/*!
+ Password to use for HTTP authentication. Null if HTTP authentication
+ is not used.
+*/
+qx.OO.addProperty({ name : "password", type : "string" });
+qx.OO.addProperty(
+{
+ name : "state",
+ type : "string",
+ possibleValues : [
+ "configured", "queued",
+ "sending", "receiving",
+ "completed", "aborted",
+ "timeout", "failed"
+ ],
+ defaultValue : "configured"
+});
+/*
+ Response type of request.
+
+ The response type is a MIME type, default is text/plain. Other
+ supported MIME types are text/javascript, text/html, text/json,
+ application/xml.
+*/
+qx.OO.addProperty({
+ name : "responseType",
+ type : "string",
+ possibleValues : [
+ "text/plain",
+ "text/javascript", "text/json",
+ "application/xml", "text/html"
+ ]
+});
+/*!
+ Number of millieseconds before the request is being timed out.
+
+ If this property is null, the timeout for the request comes is the
+ qx.io.remote.RequestQueue's property defaultTimeout.
+*/
+qx.OO.addProperty({ name : "timeout", type : "number" });
+
+/*!
+ Prohibit request from being cached.
+
+ Setting the value to true adds a parameter "nocache" to the request
+ with a value of the current time. Setting the value to false removes
+ the parameter.
+*/
+qx.OO.addProperty({ name : "prohibitCaching", type : "boolean" });
+/*!
+ Indicate that the request is cross domain.
+
+ A request is cross domain if the request's URL points to a host other
+ than the local host. This switches the concrete implementation that
+ is used for sending the request from qx.io.remote.XmlHttpTransport to
+ qx.io.remote.ScriptTransport, because only the latter can handle cross domain
+ requests.
+*/
+qx.OO.addProperty({ name : "crossDomain", type : "boolean", defaultValue : false });
+/*!
+ Indicate that the request will be used for a file upload.
+
+ The request will be used for a file upload. This switches the concrete
+ implementation that is used for sending the request from
+ qx.io.remote.XmlHttpTransport to qx.io.remote.IFrameTransport, because only
+ the latter can handle file uploads.
+*/
+qx.OO.addProperty({ name : "fileUpload", type : "boolean", defaultValue : false });
+/*!
+ The transport instance used for the request.
+
+ This is necessary to be able to abort an asynchronous request.
+*/
+qx.OO.addProperty({ name : "transport", type : "object", instance : "qx.io.remote.Exchange" });
+/*!
+ Use Basic HTTP Authentication
+*/
+qx.OO.addProperty({ name : "useBasicHttpAuth", type : "boolean" });
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ CORE METHODS
+---------------------------------------------------------------------------
+*/
+/*!
+ Schedule this request for transport to server.
+
+ The request is added to the singleton class qx.io.remote.RequestQueue's list of
+ pending requests.
+*/
+qx.Proto.send = function() {
+ qx.io.remote.RequestQueue.getInstance().add(this);
+}
+
+/*!
+ Abort sending this request.
+
+ The request is removed from the singleton class qx.io.remote.RequestQueue's
+ list of pending events. If the request haven't been scheduled this
+ method is a noop.
+*/
+qx.Proto.abort = function() {
+ qx.io.remote.RequestQueue.getInstance().abort(this);
+}
+
+qx.Proto.reset = function()
+{
+ switch(this.getState())
+ {
+ case "sending":
+ case "receiving":
+ this.error("Aborting already sent request!");
+ // no break
+
+ case "queued":
+ this.abort();
+ break;
+ }
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ STATE ALIASES
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.isConfigured = function() {
+ return this.getState() === "configured";
+}
+
+qx.Proto.isQueued = function() {
+ return this.getState() === "queued";
+}
+
+qx.Proto.isSending = function() {
+ return this.getState() === "sending";
+}
+
+qx.Proto.isReceiving = function() {
+ return this.getState() === "receiving";
+}
+
+qx.Proto.isCompleted = function() {
+ return this.getState() === "completed";
+}
+
+qx.Proto.isAborted = function() {
+ return this.getState() === "aborted";
+}
+
+qx.Proto.isTimeout = function() {
+ return this.getState() === "timeout";
+}
+
+/*!
+ Return true if the request is in the failed state
+ ("failed").
+*/
+qx.Proto.isFailed = function() {
+ return this.getState() === "failed";
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ EVENT HANDLER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._onqueued = function(e)
+{
+ // Modify internal state
+ this.setState("queued");
+
+ // Bubbling up
+ this.dispatchEvent(e);
+}
+
+qx.Proto._onsending = function(e)
+{
+ // Modify internal state
+ this.setState("sending");
+
+ // Bubbling up
+ this.dispatchEvent(e);
+}
+
+qx.Proto._onreceiving = function(e)
+{
+ // Modify internal state
+ this.setState("receiving");
+
+ // Bubbling up
+ this.dispatchEvent(e);
+}
+
+qx.Proto._oncompleted = function(e)
+{
+ // Modify internal state
+ this.setState("completed");
+
+ // Bubbling up
+ this.dispatchEvent(e);
+
+ // Automatically dispose after event completion
+ this.dispose();
+}
+
+qx.Proto._onaborted = function(e)
+{
+ // Modify internal state
+ this.setState("aborted");
+
+ // Bubbling up
+ this.dispatchEvent(e);
+
+ // Automatically dispose after event completion
+ this.dispose();
+}
+
+qx.Proto._ontimeout = function(e)
+{
+/*
+ // User's handler can block until timeout.
+ switch(this.getState())
+ {
+ // If we're no longer running...
+ case "completed":
+ case "timeout":
+ case "aborted":
+ case "failed":
+ // then don't bubble up the timeout event
+ return;
+ }
+*/
+
+ // Modify internal state
+ this.setState("timeout");
+
+ // Bubbling up
+ this.dispatchEvent(e);
+
+ // Automatically dispose after event completion
+ this.dispose();
+}
+
+qx.Proto._onfailed = function(e)
+{
+ // Modify internal state
+ this.setState("failed");
+
+ // Bubbling up
+ this.dispatchEvent(e);
+
+ // Automatically dispose after event completion
+ this.dispose();
+}
+
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ MODIFIER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._modifyState = function(propValue, propOldValue, propData)
+{
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.debug("State: " + propValue);
+ }
+
+ return true;
+}
+
+qx.Proto._modifyProhibitCaching = function(propValue, propOldValue, propData)
+{
+ propValue ? this.setParameter("nocache", new Date().valueOf()) : this.removeParameter("nocache");
+
+ return true;
+}
+
+qx.Proto._modifyMethod = function(propValue, propOldValue, propData)
+{
+ if (propValue === qx.net.Http.METHOD_POST) {
+ this.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+
+ return true;
+}
+
+qx.Proto._modifyResponseType = function(propValue, propOldValue, propData)
+{
+ this.setRequestHeader("X-Qooxdoo-Response-Type", propValue);
+ return true;
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ REQUEST HEADER
+---------------------------------------------------------------------------
+*/
+/*!
+ Add a request header to the request.
+
+ Example: request.setRequestHeader("Content-Type", "text/html")
+*/
+qx.Proto.setRequestHeader = function(vId, vValue) {
+ this._requestHeaders[vId] = vValue;
+}
+
+qx.Proto.removeRequestHeader = function(vId) {
+ delete this._requestHeaders[vId];
+}
+
+qx.Proto.getRequestHeader = function(vId) {
+ return this._requestHeaders[vId] || null;
+}
+
+qx.Proto.getRequestHeaders = function() {
+ return this._requestHeaders;
+}
+
+
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ PARAMETERS
+---------------------------------------------------------------------------
+*/
+/*!
+ Add a parameter to the request.
+
+ @param vId String identifier of the parameter to add.
+ @param vValue Value of parameter. May be a string (for one parameter) or an
+ array of strings (for setting multiple parameter values with the same
+ parameter name).
+*/
+qx.Proto.setParameter = function(vId, vValue) {
+ this._parameters[vId] = vValue;
+}
+
+/*!
+ Remove a parameter from the request.
+
+ @param vId String identifier of the parameter to remove.
+*/
+qx.Proto.removeParameter = function(vId) {
+ delete this._parameters[vId];
+}
+
+/*!
+ Get a parameter in the request.
+
+ @param vId String identifier of the parameter to get.
+*/
+qx.Proto.getParameter = function(vId) {
+ return this._parameters[vId] || null;
+}
+
+/*!
+ Returns an object containg all parameters for the request.
+*/
+qx.Proto.getParameters = function() {
+ return this._parameters;
+}
+
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ SEQUENCE NUMBER
+---------------------------------------------------------------------------
+*/
+
+/*
+ * Sequence (id) number of a request, used to associate a response or error
+ * with its initiating request.
+ */
+qx.io.remote.Request._seqNum = 0;
+
+/**
+ * Obtain the sequence (id) number used for this request
+ */
+qx.Proto.getSequenceNumber = function() {
+ return this._seqNum;
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ DISPOSER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.dispose = function()
+{
+ if (this.getDisposed()) {
+ return;
+ }
+
+ this._requestHeaders = null;
+ this._parameters = null;
+
+ this.setTransport(null);
+
+ return qx.core.Target.prototype.dispose.call(this);
+}
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/RequestQueue.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/RequestQueue.js
new file mode 100644
index 0000000000..21d3af56e0
--- /dev/null
+++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/RequestQueue.js
@@ -0,0 +1,392 @@
+/* ************************************************************************
+
+ qooxdoo - the new era of web development
+
+ http://qooxdoo.org
+
+ Copyright:
+ 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
+ 2006 by Derrell Lipman
+
+ License:
+ LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
+
+ Authors:
+ * Sebastian Werner (wpbasti)
+ * Andreas Ecker (ecker)
+ * Derrell Lipman (derrell)
+
+************************************************************************ */
+
+/* ************************************************************************
+
+#module(io_remote)
+
+************************************************************************ */
+/*!
+ Handles scheduling of requests to be sent to a server.
+
+ This class is a singleton and is used by qx.io.remote.Request to schedule its
+ requests. It should not be used directly.
+ */
+qx.OO.defineClass("qx.io.remote.RequestQueue", qx.core.Target,
+function()
+{
+ qx.core.Target.call(this);
+
+ this._queue = [];
+ this._active = [];
+
+ this._totalRequests = 0;
+
+ // timeout handling
+ this._timer = new qx.client.Timer(500);
+ this._timer.addEventListener("interval", this._oninterval, this);
+});
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ PROPERTIES
+---------------------------------------------------------------------------
+*/
+
+qx.OO.addProperty({ name : "maxTotalRequests", type : "number" });
+qx.OO.addProperty({ name : "maxConcurrentRequests", type : "number", defaultValue : 3 });
+qx.OO.addProperty({ name : "defaultTimeout", type : "number", defaultValue : 5000 });
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ QUEUE HANDLING
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._debug = function()
+{
+ // Debug output
+ var vText = this._active.length + "/" + (this._queue.length+this._active.length);
+
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug"))
+ {
+ this.debug("Progress: " + vText);
+ window.status = "Request-Queue Progress: " + vText;
+ }
+}
+
+qx.Proto._check = function()
+{
+ // Debug output
+ this._debug();
+
+ // Check queues and stop timer if not needed anymore
+ if (this._active.length == 0 && this._queue.length == 0) {
+ this._timer.stop();
+ }
+
+ // Checking if enabled
+ if (!this.getEnabled()) {
+ return;
+ }
+
+ // Checking active queue fill
+ if (this._active.length >= this.getMaxConcurrentRequests() || this._queue.length == 0) {
+ return;
+ }
+
+ // Checking number of total requests
+ if (this.getMaxTotalRequests() != null && this._totalRequests >= this.getMaxTotalRequests()) {
+ return;
+ }
+
+ var vRequest = this._queue.shift();
+ var vTransport = new qx.io.remote.Exchange(vRequest);
+
+ // Increment counter
+ this._totalRequests++;
+
+ // Add to active queue
+ this._active.push(vTransport);
+
+ // Debug output
+ this._debug();
+
+ // Establish event connection between qx.io.remote.Exchange instance and qx.io.remote.Request
+ vTransport.addEventListener("sending", vRequest._onsending, vRequest);
+ vTransport.addEventListener("receiving", vRequest._onreceiving, vRequest);
+ vTransport.addEventListener("completed", vRequest._oncompleted, vRequest);
+ vTransport.addEventListener("aborted", vRequest._onaborted, vRequest);
+ vTransport.addEventListener("timeout", vRequest._ontimeout, vRequest);
+ vTransport.addEventListener("failed", vRequest._onfailed, vRequest);
+
+ // Establish event connection between qx.io.remote.Exchange and me.
+ vTransport.addEventListener("sending", this._onsending, this);
+ vTransport.addEventListener("completed", this._oncompleted, this);
+ vTransport.addEventListener("aborted", this._oncompleted, this);
+ vTransport.addEventListener("timeout", this._oncompleted, this);
+ vTransport.addEventListener("failed", this._oncompleted, this);
+
+ // Store send timestamp
+ vTransport._start = (new Date).valueOf();
+
+ // Send
+ vTransport.send();
+
+ // Retry
+ if (this._queue.length > 0) {
+ this._check();
+ }
+}
+
+qx.Proto._remove = function(vTransport)
+{
+ var vRequest = vTransport.getRequest();
+
+ // Destruct event connection between qx.io.remote.Exchange instance and qx.io.remote.Request
+ vTransport.removeEventListener("sending", vRequest._onsending, vRequest);
+ vTransport.removeEventListener("receiving", vRequest._onreceiving, vRequest);
+ vTransport.removeEventListener("completed", vRequest._oncompleted, vRequest);
+ vTransport.removeEventListener("aborted", vRequest._onaborted, vRequest);
+ vTransport.removeEventListener("timeout", vRequest._ontimeout, vRequest);
+ vTransport.removeEventListener("failed", vRequest._onfailed, vRequest);
+
+ // Destruct event connection between qx.io.remote.Exchange and me.
+ vTransport.removeEventListener("sending", this._onsending, this);
+ vTransport.removeEventListener("completed", this._oncompleted, this);
+ vTransport.removeEventListener("aborted", this._oncompleted, this);
+ vTransport.removeEventListener("timeout", this._oncompleted, this);
+ vTransport.removeEventListener("failed", this._oncompleted, this);
+
+ // Remove from active transports
+ qx.lang.Array.remove(this._active, vTransport);
+
+ // Dispose transport object
+ vTransport.dispose();
+
+ // Check again
+ this._check();
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ EVENT HANDLING
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._activeCount = 0;
+
+qx.Proto._onsending = function(e)
+{
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug"))
+ {
+ this._activeCount++;
+ e.getTarget()._counted = true;
+
+ this.debug("ActiveCount: " + this._activeCount);
+ }
+}
+
+qx.Proto._oncompleted = function(e)
+{
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug"))
+ {
+ if (e.getTarget()._counted)
+ {
+ this._activeCount--;
+ this.debug("ActiveCount: " + this._activeCount);
+ }
+ }
+
+ this._remove(e.getTarget());
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ TIMEOUT HANDLING
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._oninterval = function(e)
+{
+ var vActive = this._active;
+
+ if (vActive.length == 0) {
+ return;
+ }
+
+ var vCurrent = (new Date).valueOf();
+ var vTransport;
+ var vRequest;
+ var vDefaultTimeout = this.getDefaultTimeout();
+ var vTimeout;
+ var vTime;
+
+ for (var i=vActive.length-1; i>=0; i--)
+ {
+ vTransport = vActive[i];
+ vRequest = vTransport.getRequest();
+ if (vRequest.isAsynchronous()) {
+ vTimeout = vRequest.getTimeout();
+
+ // if timer is disabled...
+ if (vTimeout == 0) {
+ // then ignore it.
+ continue;
+ }
+
+ if (vTimeout == null) {
+ vTimeout = vDefaultTimeout;
+ }
+
+ vTime = vCurrent - vTransport._start;
+
+ if (vTime > vTimeout)
+ {
+ this.warn("Timeout: transport " + vTransport.toHashCode());
+ this.warn(vTime + "ms > " + vTimeout + "ms");
+ vTransport.timeout();
+ }
+ }
+ }
+}
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ MODIFIERS
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._modifyEnabled = function(propValue, propOldValue, propData)
+{
+ if (propValue) {
+ this._check();
+ }
+
+ this._timer.setEnabled(propValue);
+
+ return true;
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ CORE METHODS
+---------------------------------------------------------------------------
+*/
+/*!
+ Add the request to the pending requests queue.
+*/
+qx.Proto.add = function(vRequest)
+{
+ vRequest.setState("queued");
+
+ this._queue.push(vRequest);
+ this._check();
+
+ if (this.getEnabled()) {
+ this._timer.start();
+ }
+}
+
+/*!
+ Remove the request from the pending requests queue.
+
+ The underlying transport of the request is forced into the aborted
+ state ("aborted") and listeners of the "aborted"
+ signal are notified about the event. If the request isn't in the
+ pending requests queue, this method is a noop.
+*/
+qx.Proto.abort = function(vRequest)
+{
+ var vTransport = vRequest.getTransport();
+
+ if (vTransport)
+ {
+ vTransport.abort();
+ }
+ else if (qx.lang.Array.contains(this._queue, vRequest))
+ {
+ qx.lang.Array.remove(this._queue, vRequest);
+ }
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ DISPOSER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.dispose = function()
+{
+ if (this.getDisposed()) {
+ return true;
+ }
+
+ if (this._active)
+ {
+ for (var i=0, a=this._active, l=a.length; i<l; i++) {
+ this._remove(a[i]);
+ }
+
+ this._active = null;
+ }
+
+ if (this._timer)
+ {
+ this._timer.removeEventListener("interval", this._oninterval, this);
+ this._timer = null;
+ }
+
+ this._queue = null;
+
+ return qx.core.Target.prototype.dispose.call(this);
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ DEFER SINGLETON INSTANCE
+---------------------------------------------------------------------------
+*/
+
+/**
+ * Singleton Instance Getter
+ */
+qx.Class.getInstance = qx.util.Return.returnInstance;
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Response.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Response.js
new file mode 100644
index 0000000000..e35460cb2a
--- /dev/null
+++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Response.js
@@ -0,0 +1,110 @@
+/* ************************************************************************
+
+ qooxdoo - the new era of web development
+
+ http://qooxdoo.org
+
+ Copyright:
+ 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
+
+ License:
+ LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
+
+ Authors:
+ * Sebastian Werner (wpbasti)
+ * Andreas Ecker (ecker)
+
+************************************************************************ */
+
+/* ************************************************************************
+
+#module(io_remote)
+
+************************************************************************ */
+
+qx.OO.defineClass("qx.io.remote.Response", qx.core.Target,
+function() {
+ qx.core.Target.call(this);
+});
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ PROPERTIES
+---------------------------------------------------------------------------
+*/
+
+qx.OO.addProperty({ name : "state", type : "number" });
+/*!
+ Status code of the response.
+*/
+qx.OO.addProperty({ name : "statusCode", type : "number" });
+qx.OO.addProperty({ name : "content" });
+qx.OO.addProperty({ name : "responseHeaders", type : "object" });
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ MODIFIERS
+---------------------------------------------------------------------------
+*/
+
+/*
+qx.Proto._modifyResponseHeaders = function(propValue, propOldValue, propData)
+{
+ for (vKey in propValue) {
+ this.debug("R-Header: " + vKey + "=" + propValue[vKey]);
+ }
+
+ return true;
+}
+*/
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ USER METHODS
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.getResponseHeader = function(vHeader)
+{
+ var vAll = this.getResponseHeaders();
+ if (vAll) {
+ return vAll[vHeader] || null;
+ }
+
+ return null;
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ DISPOSER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.dispose = function()
+{
+ if (this.getDisposed()) {
+ return;
+ }
+
+ return qx.core.Target.prototype.dispose.call(this);
+}
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Rpc.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Rpc.js
new file mode 100644
index 0000000000..65b4f16ad3
--- /dev/null
+++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/Rpc.js
@@ -0,0 +1,572 @@
+/* ************************************************************************
+
+ qooxdoo - the new era of web development
+
+ http://qooxdoo.org
+
+ Copyright:
+ 2006 by STZ-IDA, Germany, http://www.stz-ida.de
+ 2006 by Derrell Lipman
+
+ License:
+ LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
+
+ Authors:
+ * Andreas Junghans (lucidcake)
+ * Derrell Lipman (derrell)
+
+************************************************************************ */
+
+/* ************************************************************************
+
+#module(io_remote)
+
+************************************************************************ */
+
+
+/**
+ * Provides a Remote Procedure Call (RPC) implementation.
+ *
+ * Each instance of this class represents a "Service". These services can
+ * correspond to various concepts on the server side (depending on the
+ * programming language/environment being used), but usually, a service means
+ * a class on the server.
+ *
+ * In case multiple instances of the same service are needed, they can be
+ * distinguished by ids. If such an id is specified, the server routes all
+ * calls to a service that have the same id to the same server-side instance.
+ *
+ * When calling a server-side method, the parameters and return values are
+ * converted automatically. Supported types are int (and Integer), double
+ * (and Double), String, Date, Map, and JavaBeans. Beans must habe a default
+ * constructor on the server side and are represented by simple JavaScript
+ * objects on the client side (used as associative arrays with keys matching
+ * the server-side properties). Beans can also be nested, but be careful to not
+ * create circular references! There are no checks to detect these (which would
+ * be expensive), so you as the user are responsible for avoiding them.
+ *
+ * @param url {string} identifies the url where the service
+ * is found. Note that if the url is to
+ * a domain (server) other than where the
+ * qooxdoo script came from, i.e. it is
+ * cross-domain, then you must also call
+ * the setCrossDomain(true) method to
+ * enable the IframeTrannsport instead of
+ * the XmlHttpTransport, since the latter
+ * can not handle cross-domain requests.
+ *
+ * @param serviceName {string} identifies the service. For the Java
+ * implementation, this is the fully
+ * qualified name of the class that offers
+ * the service methods
+ * (e.g. "my.pkg.MyService").
+ *
+ * @event completed (qx.event.type.DataEvent)
+ * @event failed (qx.event.type.DataEvent)
+ * @event timeout (qx.event.type.DataEvent)
+ * @event aborted (qx.event.type.DataEvent)
+ */
+
+qx.OO.defineClass("qx.io.remote.Rpc", qx.core.Target,
+function(url, serviceName)
+{
+ qx.core.Target.call(this);
+
+ this.setUrl(url);
+ if (serviceName != null) {
+ this.setServiceName(serviceName);
+ }
+ this._previousServerSuffix = null;
+ this._currentServerSuffix = null;
+ if (qx.core.ServerSettings) {
+ this._currentServerSuffix = qx.core.ServerSettings.serverPathSuffix;
+ }
+});
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ PROPERTIES
+---------------------------------------------------------------------------
+*/
+
+/**
+ The timeout for asynchronous calls in milliseconds.
+ */
+qx.OO.addProperty({ name : "timeout", type : "number" });
+
+/**
+ Indicate that the request is cross domain.
+
+ A request is cross domain if the request's URL points to a host other
+ than the local host. This switches the concrete implementation that
+ is used for sending the request from qx.io.remote.XmlHttpTransport to
+ qx.io.remote.ScriptTransport because only the latter can handle cross domain
+ requests.
+*/
+qx.OO.addProperty({ name : "crossDomain", type : "boolean", defaultValue : false });
+
+/**
+ The URL at which the service is located.
+*/
+qx.OO.addProperty({ name : "url", type : "string", defaultValue : null });
+
+/**
+ The service name.
+*/
+qx.OO.addProperty({ name : "serviceName", type : "string", defaultValue : null });
+
+/**
+ Data sent as "out of band" data in the request to the server. The format of
+ the data is opaque to RPC and may be recognized only by particular servers
+ It is up to the server to decide what to do with it: whether to ignore it,
+ handle it locally before calling the specified method, or pass it on to the
+ method. This server data is not sent to the server if it has been set to
+ 'undefined'.
+*/
+qx.OO.addProperty({ name : "serverData", type : "object", defaultValue : undefined });
+
+/**
+ Username to use for HTTP authentication. Null if HTTP authentication
+ is not used.
+*/
+qx.OO.addProperty({ name : "username", type : "string" });
+
+/**
+ Password to use for HTTP authentication. Null if HTTP authentication
+ is not used.
+*/
+qx.OO.addProperty({ name : "password", type : "string" });
+
+/**
+ Use Basic HTTP Authentication
+*/
+qx.OO.addProperty({ name : "useBasicHttpAuth", type : "boolean" });
+
+/**
+ Origins of errors
+*/
+qx.io.remote.Rpc.origin =
+{
+ server : 1,
+ application : 2,
+ transport : 3,
+ local : 4
+}
+
+/**
+ Locally-detected errors
+*/
+qx.io.remote.Rpc.localError =
+{
+ timeout : 1,
+ abort : 2
+}
+
+
+/*
+---------------------------------------------------------------------------
+ CORE METHODS
+---------------------------------------------------------------------------
+*/
+
+/* callType: 0 = sync, 1 = async with handler, 2 = async event listeners */
+qx.Proto._callInternal = function(args, callType, refreshSession) {
+ var self = this;
+ var offset = (callType == 0 ? 0 : 1)
+ var whichMethod = (refreshSession ? "refreshSession" : args[offset]);
+ var handler = args[0];
+ var argsArray = [];
+ var eventTarget = this;
+
+ for (var i = offset + 1; i < args.length; ++i) {
+ argsArray.push(args[i]);
+ }
+ var req = new qx.io.remote.Request(this.getUrl(),
+ qx.net.Http.METHOD_POST,
+ "text/json");
+ var requestObject = {
+ "service": (refreshSession ? null : this.getServiceName()),
+ "method": whichMethod,
+ "id": req.getSequenceNumber(),
+ "params": argsArray
+ // additional field 'server_data' optionally included, below
+ }
+
+ // See if there's any out-of-band data to be sent to the server
+ var serverData = this.getServerData();
+ if (serverData !== undefined) {
+ // There is. Send it.
+ requestObject.server_data = serverData;
+ }
+
+ req.setCrossDomain(this.getCrossDomain());
+
+ if (this.getUsername()) {
+ req.setUseBasicHttpAuth(this.getUseBasicHttpAuth());
+ req.setUsername(this.getUsername());
+ req.setPassword(this.getPassword());
+ }
+
+ req.setTimeout(this.getTimeout());
+ var ex = null;
+ var id = null;
+ var result = null;
+
+ var handleRequestFinished = function(eventType, eventTarget) {
+ switch(callType)
+ {
+ case 0: // sync
+ break;
+
+ case 1: // async with handler function
+ handler(result, ex, id);
+ break;
+
+ case 2: // async with event listeners
+ // Dispatch the event to our listeners.
+ if (! ex) {
+ eventTarget.createDispatchDataEvent(eventType, result);
+ } else {
+ // Add the id to the exception
+ ex.id = id;
+
+ if (args[0]) { // coalesce
+ // They requested that we coalesce all failure types to "failed"
+ eventTarget.createDispatchDataEvent("failed", ex);
+ } else {
+ // No coalese so use original event type
+ eventTarget.createDispatchDataEvent(eventType, ex);
+ }
+ }
+ }
+ }
+
+ var addToStringToObject = function(obj) {
+ obj.toString = function() {
+ switch(obj.origin)
+ {
+ case qx.io.remote.Rpc.origin.server:
+ return "Server error " + obj.code + ": " + obj.message;
+ case qx.io.remote.Rpc.origin.application:
+ return "Application error " + obj.code + ": " + obj.message;
+ case qx.io.remote.Rpc.origin.transport:
+ return "Transport error " + obj.code + ": " + obj.message;
+ case qx.io.remote.Rpc.origin.local:
+ return "Local error " + obj.code + ": " + obj.message;
+ default:
+ return "UNEXPECTED origin " + obj.origin + " error " + obj.code + ": " + obj.message;
+ }
+ }
+ }
+
+ var makeException = function(origin, code, message) {
+ var ex = new Object();
+
+ ex.origin = origin;
+ ex.code = code;
+ ex.message = message;
+ addToStringToObject(ex);
+
+ return ex;
+ }
+
+ req.addEventListener("failed", function(evt) {
+ var code = evt.getData().getStatusCode();
+ ex = makeException(qx.io.remote.Rpc.origin.transport,
+ code,
+ qx.io.remote.Exchange.statusCodeToString(code));
+ id = this.getSequenceNumber();
+ handleRequestFinished("failed", eventTarget);
+ });
+ req.addEventListener("timeout", function(evt) {
+ ex = makeException(qx.io.remote.Rpc.origin.local,
+ qx.io.remote.Rpc.localError.timeout,
+ "Local time-out expired");
+ id = this.getSequenceNumber();
+ handleRequestFinished("timeout", eventTarget);
+ });
+ req.addEventListener("aborted", function(evt) {
+ ex = makeException(qx.io.remote.Rpc.origin.local,
+ qx.io.remote.Rpc.localError.abort,
+ "Aborted");
+ id = this.getSequenceNumber();
+ handleRequestFinished("aborted", eventTarget);
+ });
+ req.addEventListener("completed", function(evt) {
+ result = evt.getData().getContent();
+ id = result["id"];
+ if (id != this.getSequenceNumber()) {
+ this.warn("Received id (" + id + ") does not match requested id (" + this.getSequenceNumber() + ")!");
+ }
+ var exTest = result["error"];
+ if (exTest != null) {
+ result = null;
+ addToStringToObject(exTest);
+ ex = exTest;
+ } else {
+ result = result["result"];
+ if (refreshSession) {
+ result = eval("(" + result + ")");
+ var newSuffix = qx.core.ServerSettings.serverPathSuffix;
+ if (self._currentServerSuffix != newSuffix) {
+ self._previousServerSuffix = self._currentServerSuffix;
+ self._currentServerSuffix = newSuffix;
+ }
+ self.setUrl(self.fixUrl(self.getUrl()));
+ }
+ }
+ handleRequestFinished("completed", eventTarget);
+ });
+ req.setData(qx.io.Json.stringify(requestObject));
+ req.setAsynchronous(callType > 0);
+
+ if (req.getCrossDomain()) {
+ // Our choice here has no effect anyway. This is purely informational.
+ req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ } else {
+ // When not cross-domain, set type to text/json
+ req.setRequestHeader("Content-Type", "text/json");
+ }
+
+ req.send();
+
+ if (callType == 0) {
+ if (ex != null) {
+ var error = new Error(ex.toString());
+ error.rpcdetails = ex;
+ throw error;
+ }
+ return result;
+ } else {
+ return req;
+ }
+}
+
+
+/**
+ * Helper method to rewrite a URL with a stale session id (so that it includes
+ * the correct session id afterwards).
+ *
+ * @param url {string} the URL to examine.
+ *
+ * @return {string} the (possibly re-written) URL.
+ */
+
+qx.Proto.fixUrl = function(url) {
+ if (this._previousServerSuffix == null || this._currentServerSuffix == null ||
+ this._previousServerSuffix == "" ||
+ this._previousServerSuffix == this._currentServerSuffix) {
+ return url;
+ }
+ var index = url.indexOf(this._previousServerSuffix);
+ if (index == -1) {
+ return url;
+ }
+ return url.substring(0, index) + this._currentServerSuffix +
+ url.substring(index + this._previousServerSuffix.length);
+};
+
+
+/**
+ * Makes a synchronous server call. The method arguments (if any) follow
+ * after the method name (as normal JavaScript arguments, separated by commas,
+ * not as an array).
+ * <p>
+ * If a problem occurs when making the call, an exception is thrown.
+ * </p>
+ * <p>
+ * WARNING. With some browsers, the synchronous interface
+ * causes the browser to hang while awaiting a response! If the server
+ * decides to pause for a minute or two, your browser may do nothing
+ * (including refreshing following window changes) until the response is
+ * received. Instead, use the asynchronous interface.
+ * </p>
+ * <p>
+ * YOU HAVE BEEN WARNED.
+ * </p>
+ *
+ * @param methodName {string} the name of the method to call.
+ *
+ * @return {var} the result returned by the server.
+ */
+
+qx.Proto.callSync = function(methodName) {
+ return this._callInternal(arguments, 0);
+}
+
+
+/**
+ * Makes an asynchronous server call. The method arguments (if any) follow
+ * after the method name (as normal JavaScript arguments, separated by commas,
+ * not as an array).
+ * <p>
+ * When an answer from the server arrives, the <code>handler</code> function
+ * is called with the result of the call as the first, an exception as the
+ * second parameter, and the id (aka sequence number) of the invoking request
+ * as the third parameter. If the call was successful, the second parameter is
+ * <code>null</code>. If there was a problem, the second parameter contains an
+ * exception, and the first one is <code>null</code>.
+ * </p>
+ * <p>
+ * The return value of this method is a call reference that you can store if
+ * you want to abort the request later on. This value should be treated as
+ * opaque and can change completely in the future! The only thing you can rely
+ * on is that the <code>abort</code> method will accept this reference and
+ * that you can retrieve the sequence number of the request by invoking the
+ * getSequenceNumber() method (see below).
+ * </p>
+ * <p>
+ * If a specific method is being called, asynchronously, a number of times in
+ * succession, the getSequenceNumber() method may be used to disambiguate
+ * which request a response corresponds to. The sequence number value is a
+ * value which increments with each request.)
+ * </p>
+ *
+ * @param handler {Function} the callback function.
+ *
+ * @param methodName {string} the name of the method to call.
+ *
+ * @return {var} the method call reference.
+ */
+
+qx.Proto.callAsync = function(handler, methodName) {
+ return this._callInternal(arguments, 1);
+}
+
+
+/**
+ * Makes an asynchronous server call and dispatch an event upon completion or
+ * failure. The method arguments (if any) follow after the method name (as
+ * normal JavaScript arguments, separated by commas, not as an array).
+ * <p>
+ * When an answer from the server arrives (or fails to arrive on time), if an
+ * exception occurred, a "failed", "timeout" or "aborted" event, as
+ * appropriate, is dispatched to any waiting event listeners. If no exception
+ * occurred, a "completed" event is dispatched.
+ * </p>
+ * <p>
+ * When a "failed", "timeout" or "aborted" event is dispatched, the event data
+ * contains an object with the properties 'origin', 'code', 'message' and
+ * 'id'. The object has a toString() function which may be called to convert
+ * the exception to a string.
+ * </p>
+ * <p>
+ * When a "completed" event is dispatched, the event data contains the
+ * JSON-RPC result.
+ * </p>
+ * <p>
+ * The return value of this method is a call reference that you can store if
+ * you want to abort the request later on. This value should be treated as
+ * opaque and can change completely in the future! The only thing you can rely
+ * on is that the <code>abort</code> method will accept this reference and
+ * that you can retrieve the sequence number of the request by invoking the
+ * getSequenceNumber() method (see below).
+ * </p>
+ * <p>
+ * If a specific method is being called, asynchronously, a number of times in
+ * succession, the getSequenceNumber() method may be used to disambiguate
+ * which request a response corresponds to. The sequence number value is a
+ * value which increments with each request.)
+ * </p>
+ *
+ * @param coalesce (boolean) coalesce all failure types ("failed",
+ * "timeout", and "aborted") to "failed".
+ * This is reasonable in many cases, as
+ * the provided exception contains adequate
+ * disambiguating information.
+ *
+ * @param methodName (string) the name of the method to call.
+ *
+ * @return (var) the method call reference.
+ */
+
+qx.Proto.callAsyncListeners = function(coalesce, methodName) {
+ return this._callInternal(arguments, 2);
+}
+
+
+/**
+ * Refreshes a server session by retrieving the session id again from the
+ * server.
+ * <p>
+ * The specified handler function is called when the refresh is complete. The
+ * first parameter can be <code>true</code> (indicating that a refresh either
+ * wasn't necessary at this time or it was successful) or <code>false</code>
+ * (indicating that a refresh would have been necessary but can't be performed
+ * because the server backend doesn't support it). If there is a non-null
+ * second parameter, it's an exception indicating that there was an error when
+ * refreshing the session.
+ * </p>
+ *
+ * @param handler {Function} a callback function that is called when the
+ * refresh is complete (or failed).
+ */
+
+qx.Proto.refreshSession = function(handler) {
+ if (this.getCrossDomain()) {
+ if (qx.core.ServerSettings && qx.core.ServerSettings.serverPathSuffix) {
+ var timeDiff = (new Date()).getTime() - qx.core.ServerSettings.lastSessionRefresh;
+ if (timeDiff/1000 > (qx.core.ServerSettings.sessionTimeoutInSeconds - 30)) {
+ //this.info("refreshing session");
+ this._callInternal([handler], 1, true);
+ } else {
+ handler(true); // session refresh was OK (in this case: not needed)
+ }
+ } else {
+ handler(false); // no refresh possible, but would be necessary
+ }
+ } else {
+ handler(true); // session refresh was OK (in this case: not needed)
+ }
+}
+
+
+/**
+ * Aborts an asynchronous server call. Consequently, the callback function
+ * provided to <code>callAsync</code> or <code>callAsyncListeners</code> will
+ * be called with an exception.
+ *
+ * @param opaqueCallRef {var} the call reference as returned by
+ * <code>callAsync</code> or
+ * <code>callAsyncListeners</code>
+ */
+
+qx.Proto.abort = function(opaqueCallRef) {
+ opaqueCallRef.abort();
+}
+
+
+/**
+ * Creates an URL for talking to a local service. A local service is one that
+ * lives in the same application as the page calling the service. For backends
+ * that don't support this auto-generation, this method returns null.
+ *
+ * @param instanceId {string ? null} an optional identifier for the
+ * server side instance that should be
+ * used. All calls to the same service
+ * with the same instance id are
+ * routed to the same object instance
+ * on the server. The instance id can
+ * also be used to provide additional
+ * data for the service instantiation
+ * on the server.
+ *
+ * @return {string} the url.
+ */
+
+qx.Class.makeServerURL = function(instanceId) {
+ var retVal = null;
+ if (qx.core.ServerSettings) {
+ retVal = qx.core.ServerSettings.serverPathPrefix + "/.qxrpc" +
+ qx.core.ServerSettings.serverPathSuffix;
+ if (instanceId != null) {
+ retVal += "?instanceId=" + instanceId;
+ }
+ }
+ return retVal;
+}
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/ScriptTransport.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/ScriptTransport.js
new file mode 100644
index 0000000000..8416988717
--- /dev/null
+++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/ScriptTransport.js
@@ -0,0 +1,360 @@
+/* ************************************************************************
+
+ qooxdoo - the new era of web development
+
+ http://qooxdoo.org
+
+ Copyright:
+ 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
+ 2006 by Derrell Lipman
+ 2006 by STZ-IDA, Germany, http://www.stz-ida.de
+
+ License:
+ LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
+
+ Authors:
+ * Sebastian Werner (wpbasti)
+ * Andreas Ecker (ecker)
+ * Derrell Lipman (derrell)
+ * Andreas Junghans (lucidcake)
+
+************************************************************************ */
+
+/* ************************************************************************
+
+#module(io_remote)
+#require(qx.io.remote.Exchange)
+
+************************************************************************ */
+
+/*!
+ Transports requests to a server using dynamic script tags.
+
+ This class should not be used directly by client programmers.
+ */
+qx.OO.defineClass("qx.io.remote.ScriptTransport", qx.io.remote.AbstractRemoteTransport,
+function()
+{
+ qx.io.remote.AbstractRemoteTransport.call(this);
+
+ var vUniqueId = ++qx.io.remote.ScriptTransport._uniqueId;
+ if (vUniqueId >= 2000000000) {
+ qx.io.remote.ScriptTransport._uniqueId = vUniqueId = 1;
+ }
+
+ this._element = null;
+ this._uniqueId = vUniqueId;
+});
+
+qx.Class._uniqueId = 0;
+qx.Class._instanceRegistry = {};
+qx.Class.ScriptTransport_PREFIX = "_ScriptTransport_";
+qx.Class.ScriptTransport_ID_PARAM = qx.Class.ScriptTransport_PREFIX + "id";
+qx.Class.ScriptTransport_DATA_PARAM = qx.Class.ScriptTransport_PREFIX + "data";
+qx.Proto._lastReadyState = 0;
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ CLASS PROPERTIES AND METHODS
+---------------------------------------------------------------------------
+*/
+
+// basic registration to qx.io.remote.Exchange
+// the real availability check (activeX stuff and so on) follows at the first real request
+qx.io.remote.Exchange.registerType(qx.io.remote.ScriptTransport, "qx.io.remote.ScriptTransport");
+
+qx.io.remote.ScriptTransport.handles =
+{
+ synchronous : false,
+ asynchronous : true,
+ crossDomain : true,
+ fileUpload: false,
+ responseTypes : [ "text/plain", "text/javascript", "text/json" ]
+}
+
+qx.io.remote.ScriptTransport.isSupported = function() {
+ return true;
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ USER METHODS
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.send = function()
+{
+ var vUrl = this.getUrl();
+
+
+
+ // --------------------------------------
+ // Adding parameters
+ // --------------------------------------
+
+ vUrl += (vUrl.indexOf("?") >= 0 ? "&" : "?") + qx.io.remote.ScriptTransport.ScriptTransport_ID_PARAM + "=" + this._uniqueId;
+
+ var vParameters = this.getParameters();
+ var vParametersList = [];
+ for (var vId in vParameters) {
+ if (vId.indexOf(qx.io.remote.ScriptTransport.ScriptTransport_PREFIX) == 0) {
+ this.error("Illegal parameter name. The following prefix is used internally by qooxdoo): " +
+ qx.io.remote.ScriptTransport.ScriptTransport_PREFIX);
+ }
+ var value = vParameters[vId];
+ if (value instanceof Array) {
+ for (var i = 0; i < value.length; i++) {
+ vParametersList.push(encodeURIComponent(vId) + "=" +
+ encodeURIComponent(value[i]));
+ }
+ } else {
+ vParametersList.push(encodeURIComponent(vId) + "=" +
+ encodeURIComponent(value));
+ }
+ }
+
+ if (vParametersList.length > 0) {
+ vUrl += "&" + vParametersList.join("&");
+ }
+
+
+
+ // --------------------------------------
+ // Sending data
+ // --------------------------------------
+
+ vData = this.getData();
+ if (vData != null) {
+ vUrl += "&" + qx.io.remote.ScriptTransport.ScriptTransport_DATA_PARAM + "=" + encodeURIComponent(vData);
+ }
+
+ qx.io.remote.ScriptTransport._instanceRegistry[this._uniqueId] = this;
+ this._element = document.createElement("script");
+ this._element.charset = "utf-8"; // IE needs this (it ignores the
+ // encoding from the header sent by the
+ // server for dynamic script tags)
+ this._element.src = vUrl;
+
+ document.body.appendChild(this._element);
+}
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ EVENT LISTENER
+---------------------------------------------------------------------------
+*/
+
+// For reference:
+// http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/readyState_1.asp
+qx.io.remote.ScriptTransport._numericMap =
+{
+ "uninitialized" : 1,
+ "loading" : 2,
+ "loaded" : 2,
+ "interactive" : 3,
+ "complete" : 4
+}
+
+qx.Proto._switchReadyState = function(vReadyState)
+{
+ // Ignoring already stopped requests
+ switch(this.getState())
+ {
+ case "completed":
+ case "aborted":
+ case "failed":
+ case "timeout":
+ this.warn("Ignore Ready State Change");
+ return;
+ }
+
+ // Updating internal state
+ while (this._lastReadyState < vReadyState) {
+ this.setState(qx.io.remote.Exchange._nativeMap[++this._lastReadyState]);
+ }
+}
+qx.Class._requestFinished = function(id, content) {
+ var vInstance = qx.io.remote.ScriptTransport._instanceRegistry[id];
+ if (vInstance == null) {
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.warn("Request finished for an unknown instance (probably aborted or timed out before)");
+ }
+ } else {
+ vInstance._responseContent = content;
+ vInstance._switchReadyState(qx.io.remote.ScriptTransport._numericMap.complete);
+ }
+}
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ REQUEST HEADER SUPPORT
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.setRequestHeader = function(vLabel, vValue)
+{
+ // TODO
+ // throw new Error("setRequestHeader is abstract");
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ RESPONSE HEADER SUPPORT
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.getResponseHeader = function(vLabel)
+{
+ return null;
+
+ // TODO
+ // this.error("Need implementation", "getResponseHeader");
+}
+
+/*!
+ Provides an hash of all response headers.
+*/
+qx.Proto.getResponseHeaders = function()
+{
+ return {}
+
+ // TODO
+ // throw new Error("getResponseHeaders is abstract");
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ STATUS SUPPORT
+---------------------------------------------------------------------------
+*/
+
+/*!
+ Returns the current status code of the request if available or -1 if not.
+*/
+qx.Proto.getStatusCode = function()
+{
+ return 200;
+
+ // TODO
+ // this.error("Need implementation", "getStatusCode");
+}
+
+/*!
+ Provides the status text for the current request if available and null otherwise.
+*/
+qx.Proto.getStatusText = function()
+{
+ return "";
+
+ // TODO
+ // this.error("Need implementation", "getStatusText");
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ RESPONSE DATA SUPPORT
+---------------------------------------------------------------------------
+*/
+
+/*!
+ Returns the length of the content as fetched thus far
+*/
+qx.Proto.getFetchedLength = function()
+{
+ return 0;
+
+ // TODO
+ // throw new Error("getFetchedLength is abstract");
+}
+
+qx.Proto.getResponseContent = function()
+{
+ if (this.getState() !== "completed")
+ {
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.warn("Transfer not complete, ignoring content!");
+ }
+
+ return null;
+ }
+
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.debug("Returning content for responseType: " + this.getResponseType());
+ }
+
+ switch(this.getResponseType())
+ {
+ case "text/plain":
+ // server is responsible for using a string as the response
+
+ case "text/json":
+
+ case "text/javascript":
+ return this._responseContent;
+
+ default:
+ this.warn("No valid responseType specified (" + this.getResponseType() + ")!");
+ return null;
+ }
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ DISPOSER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.dispose = function()
+{
+ if (this.getDisposed()) {
+ return true;
+ }
+
+ if (this._element != null)
+ {
+ delete qx.io.remote.ScriptTransport._instanceRegistry[this._uniqueId];
+ document.body.removeChild(this._element);
+ this._element = null;
+ }
+
+ return qx.io.remote.AbstractRemoteTransport.prototype.dispose.call(this);
+}
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/XmlHttpTransport.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/XmlHttpTransport.js
new file mode 100644
index 0000000000..b9e4bf29bc
--- /dev/null
+++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/io/remote/XmlHttpTransport.js
@@ -0,0 +1,819 @@
+/* ************************************************************************
+
+ qooxdoo - the new era of web development
+
+ http://qooxdoo.org
+
+ Copyright:
+ 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
+ 2006 by Derrell Lipman
+
+ License:
+ LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
+
+ Authors:
+ * Sebastian Werner (wpbasti)
+ * Andreas Ecker (ecker)
+ * Derrell Lipman (derrell)
+
+************************************************************************ */
+
+/* ************************************************************************
+
+#module(io_remote)
+#require(qx.io.remote.Exchange)
+
+************************************************************************ */
+
+/**
+ * @event created {qx.event.type.Event}
+ * @event configured {qx.event.type.Event}
+ * @event sending {qx.event.type.Event}
+ * @event receiving {qx.event.type.Event}
+ * @event completed {qx.event.type.Event}
+ * @event failed {qx.event.type.Event}
+ * @event aborted {qx.event.type.Event}
+ * @event timeout {qx.event.type.Event}
+ */
+qx.OO.defineClass("qx.io.remote.XmlHttpTransport",
+ qx.io.remote.AbstractRemoteTransport,
+function()
+{
+ qx.io.remote.AbstractRemoteTransport.call(this);
+
+ this._req = qx.io.remote.XmlHttpTransport.createRequestObject();
+
+ var o = this;
+ this._req.onreadystatechange =
+ function(e) { return o._onreadystatechange(e); }
+});
+
+
+
+
+
+/* ************************************************************************
+ Class data, properties and methods
+************************************************************************ */
+
+// basic registration to qx.io.remote.Exchange
+// the real availability check (activeX stuff and so on) follows at the first real request
+qx.io.remote.Exchange.registerType(qx.io.remote.XmlHttpTransport,
+ "qx.io.remote.XmlHttpTransport");
+
+qx.io.remote.XmlHttpTransport.handles =
+{
+ synchronous : true,
+ asynchronous : true,
+ crossDomain : false,
+ fileUpload: false,
+ responseTypes : [
+ "text/plain",
+ "text/javascript",
+ "text/json",
+ "application/xml",
+ "text/html"
+ ]
+}
+
+qx.io.remote.XmlHttpTransport.requestObjects = [];
+qx.io.remote.XmlHttpTransport.requestObjectCount = 0;
+
+qx.io.remote.XmlHttpTransport.isSupported = function()
+{
+ if (window.XMLHttpRequest)
+ {
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange",
+ "enableDebug")) {
+ qx.dev.log.Logger.getClassLogger(qx.io.remote.XmlHttpTransport).debug(
+ "Using XMLHttpRequest");
+ }
+
+ qx.io.remote.XmlHttpTransport.createRequestObject =
+ qx.io.remote.XmlHttpTransport._createNativeRequestObject;
+ return true;
+ }
+
+ if (window.ActiveXObject)
+ {
+ /*
+ According to information on the Microsoft XML Team's WebLog
+ it is recommended to check for availability of MSXML versions 6.0 and 3.0.
+ Other versions are included for completeness, 5.0 is excluded as it is
+ "off-by-default" in IE7 (which could trigger a goldbar).
+
+ http://blogs.msdn.com/xmlteam/archive/2006/10/23/using-the-right-version-of-msxml-in-internet-explorer.aspx
+ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/aabe29a2-bad2-4cea-8387-314174252a74.asp
+
+ See similar code in qx.xml.Core, qx.lang.XmlEmu
+ */
+ var vServers =
+ [
+ "MSXML2.XMLHTTP.6.0",
+ "MSXML2.XMLHTTP.3.0",
+ "MSXML2.XMLHTTP.4.0",
+ "MSXML2.XMLHTTP", // v3.0
+ "Microsoft.XMLHTTP" // v2.x
+ ];
+
+ var vObject;
+ var vServer;
+
+ for (var i=0, l=vServers.length; i<l; i++)
+ {
+ vServer = vServers[i];
+
+ try
+ {
+ vObject = new ActiveXObject(vServer);
+ break;
+ }
+ catch(ex)
+ {
+ vObject = null;
+ }
+ }
+
+ if (vObject)
+ {
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ qx.dev.log.Logger.getClassLogger(qx.io.remote.XmlHttpTransport).debug(
+ "Using ActiveXObject: " + vServer);
+ }
+
+ qx.io.remote.XmlHttpTransport._activeXServer = vServer;
+ qx.io.remote.XmlHttpTransport.createRequestObject = qx.io.remote.XmlHttpTransport._createActiveXRequestObject;
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/*!
+ Return a new request object suitable for the client browser.
+
+ qx.io.remote.XmlHttpTransport's isSupported method scans which request object
+ to use. The createRequestObject method is then replaced with a
+ method that creates request suitable for the client browser. If the
+ client browser doesn't support XMLHTTP requests, the method isn't
+ replaced and the error "XMLHTTP is not supported!" is thrown.
+*/
+qx.io.remote.XmlHttpTransport.createRequestObject = function() {
+ throw new Error("XMLHTTP is not supported!");
+}
+
+qx.io.remote.XmlHttpTransport._createNativeRequestObject = function() {
+ return new XMLHttpRequest;
+}
+
+qx.io.remote.XmlHttpTransport._createActiveXRequestObject = function() {
+ return new ActiveXObject(qx.io.remote.XmlHttpTransport._activeXServer);
+}
+
+
+
+
+
+
+
+
+
+/* ************************************************************************
+ Instance data, properties and methods
+************************************************************************ */
+
+/*
+---------------------------------------------------------------------------
+ CORE METHODS
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._localRequest = false;
+qx.Proto._lastReadyState = 0;
+
+qx.Proto.getRequest = function() {
+ return this._req;
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ USER METHODS
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.send = function()
+{
+ this._lastReadyState = 0;
+
+ var vRequest = this.getRequest();
+ var vMethod = this.getMethod();
+ var vAsynchronous = this.getAsynchronous();
+ var vUrl = this.getUrl();
+
+
+
+ // --------------------------------------
+ // Local handling
+ // --------------------------------------
+
+ var vLocalRequest = (qx.sys.Client.getInstance().getRunsLocally() &&
+ !(/^http(s){0,1}\:/.test(vUrl)));
+ this._localRequest = vLocalRequest;
+
+
+ // --------------------------------------
+ // Adding parameters
+ // --------------------------------------
+
+ var vParameters = this.getParameters();
+ var vParametersList = [];
+ for (var vId in vParameters) {
+ var value = vParameters[vId];
+ if (value instanceof Array) {
+ for (var i = 0; i < value.length; i++) {
+ vParametersList.push(encodeURIComponent(vId) + "=" +
+ encodeURIComponent(value[i]));
+ }
+ } else {
+ vParametersList.push(encodeURIComponent(vId) + "=" +
+ encodeURIComponent(value));
+ }
+ }
+
+ if (vParametersList.length > 0) {
+ vUrl += (vUrl.indexOf("?") >= 0
+ ? "&" : "?") + vParametersList.join("&");
+ }
+
+
+ var encode64 = function (input) {
+ var keyStr =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+ var output = "";
+ var chr1, chr2, chr3;
+ var enc1, enc2, enc3, enc4;
+ var i = 0;
+
+ do {
+ chr1 = input.charCodeAt(i++);
+ chr2 = input.charCodeAt(i++);
+ chr3 = input.charCodeAt(i++);
+
+ enc1 = chr1 >> 2;
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
+ enc4 = chr3 & 63;
+
+ if (isNaN(chr2)) {
+ enc3 = enc4 = 64;
+ } else if (isNaN(chr3)) {
+ enc4 = 64;
+ }
+
+ output +=
+ keyStr.charAt(enc1) +
+ keyStr.charAt(enc2) +
+ keyStr.charAt(enc3) +
+ keyStr.charAt(enc4);
+
+ } while (i < input.length);
+
+ return output;
+ }
+
+ // --------------------------------------
+ // Opening connection
+ // --------------------------------------
+
+ if (this.getUsername()) {
+ if (this.getUseBasicHttpAuth()) {
+ vRequest.open(vMethod, vUrl, vAsynchronous);
+ vRequest.setRequestHeader('Authorization',
+ 'Basic ' + encode64(this.getUsername() +
+ ':' +
+ this.getPassword()));
+ } else {
+ vRequest.open(vMethod, vUrl, vAsynchronous,
+ this.getUsername(), this.getPassword());
+ }
+ } else {
+ vRequest.open(vMethod, vUrl, vAsynchronous);
+ }
+
+
+
+ // --------------------------------------
+ // Appliying request header
+ // --------------------------------------
+
+ var vRequestHeaders = this.getRequestHeaders();
+ for (var vId in vRequestHeaders) {
+ vRequest.setRequestHeader(vId, vRequestHeaders[vId]);
+ }
+
+
+
+ // --------------------------------------
+ // Sending data
+ // --------------------------------------
+
+ try
+ {
+ vRequest.send(this.getData());
+ }
+ catch(ex)
+ {
+ if (vLocalRequest)
+ {
+ this.failedLocally();
+ }
+ else
+ {
+ this.error("Failed to send data: " + ex, "send");
+ this.failed();
+ }
+
+ return;
+ }
+
+
+
+ // --------------------------------------
+ // Readystate for sync reqeusts
+ // --------------------------------------
+
+ if (!vAsynchronous) {
+ this._onreadystatechange();
+ }
+}
+
+/*!
+ Force the transport into the failed state
+ ("failed").
+
+ This method should be used only if the requests URI was local
+ access. I.e. it started with "file://".
+*/
+qx.Proto.failedLocally = function()
+{
+ if (this.getState() === "failed") {
+ return;
+ }
+
+ // should only occur on "file://" access
+ this.warn("Could not load from file: " + this.getUrl());
+
+ this.failed();
+}
+
+
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ EVENT HANDLER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._onreadystatechange = function(e)
+{
+ // Ignoring already stopped requests
+ switch(this.getState())
+ {
+ case "completed":
+ case "aborted":
+ case "failed":
+ case "timeout":
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange", "enableDebug")) {
+ this.warn("Ignore Ready State Change");
+ }
+ return;
+ }
+
+ // Checking status code
+ var vReadyState = this.getReadyState();
+ if (vReadyState == 4) {
+ // The status code is only meaningful when we reach ready state 4.
+ // (Important for Opera since it goes through other states before
+ // reaching 4, and the status code is not valid before 4 is reached.)
+ if (!qx.io.remote.Exchange.wasSuccessful(this.getStatusCode(), vReadyState, this._localRequest)) {
+ return this.failed();
+ }
+ }
+
+ // Updating internal state
+ while (this._lastReadyState < vReadyState) {
+ this.setState(qx.io.remote.Exchange._nativeMap[++this._lastReadyState]);
+ }
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ READY STATE
+---------------------------------------------------------------------------
+*/
+/*!
+ Get the ready state of this transports request.
+
+ For qx.io.remote.XmlHttpTransports, the ready state is a number between 1 to 4.
+*/
+qx.Proto.getReadyState = function()
+{
+ var vReadyState = null;
+
+ try {
+ vReadyState = this._req.readyState;
+ } catch(ex) {}
+
+ return vReadyState;
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ REQUEST HEADER SUPPORT
+---------------------------------------------------------------------------
+*/
+/*!
+ Add a request header to this transports request.
+*/
+qx.Proto.setRequestHeader = function(vLabel, vValue) {
+ this._req.setRequestHeader(vLabel, vValue);
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ RESPONSE HEADER SUPPORT
+---------------------------------------------------------------------------
+*/
+
+/*!
+ Returns a specific header provided by the server upon sending a request,
+ with header name determined by the argument headerName.
+
+ Only available at readyState 3 and 4 universally and in readyState 2
+ in Gecko.
+*/
+qx.Proto.getResponseHeader = function(vLabel)
+{
+ var vResponseHeader = null;
+
+ try {
+ this.getRequest().getResponseHeader(vLabel) || null;
+ } catch(ex) {}
+
+ return vResponseHeader;
+}
+
+qx.Proto.getStringResponseHeaders = function()
+{
+ var vSourceHeader = null;
+
+ try
+ {
+ var vLoadHeader = this._req.getAllResponseHeaders();
+ if (vLoadHeader) {
+ vSourceHeader = vLoadHeader;
+ }
+ } catch(ex) {}
+
+ return vSourceHeader;
+}
+
+/*!
+ Provides a hash of all response headers.
+*/
+qx.Proto.getResponseHeaders = function()
+{
+ var vSourceHeader = this.getStringResponseHeaders();
+ var vHeader = {};
+
+ if (vSourceHeader)
+ {
+ var vValues = vSourceHeader.split(/[\r\n]+/g);
+
+ for(var i=0, l=vValues.length; i<l; i++)
+ {
+ var vPair = vValues[i].match(/^([^:]+)\s*:\s*(.+)$/i);
+ if(vPair) {
+ vHeader[vPair[1]] = vPair[2];
+ }
+ }
+ }
+
+ return vHeader;
+}
+
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ STATUS SUPPORT
+---------------------------------------------------------------------------
+*/
+
+/*!
+ Returns the current status code of the request if available or -1 if not.
+*/
+qx.Proto.getStatusCode = function()
+{
+ var vStatusCode = -1;
+
+ try {
+ vStatusCode = this.getRequest().status;
+ } catch(ex) {}
+
+ return vStatusCode;
+}
+
+/*!
+ Provides the status text for the current request if available and null
+ otherwise.
+*/
+qx.Proto.getStatusText = function()
+{
+ var vStatusText = "";
+
+ try {
+ vStatusText = this.getRequest().statusText;
+ } catch(ex) {}
+
+ return vStatusText;
+}
+
+
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ RESPONSE DATA SUPPORT
+---------------------------------------------------------------------------
+*/
+
+/*!
+ Provides the response text from the request when available and null
+ otherwise. By passing true as the "partial" parameter of this method,
+ incomplete data will be made available to the caller.
+*/
+qx.Proto.getResponseText = function()
+{
+ var vResponseText = null;
+
+ var vStatus = this.getStatusCode();
+ var vReadyState = this.getReadyState();
+ if (qx.io.remote.Exchange.wasSuccessful(vStatus, vReadyState, this._localRequest))
+ {
+ try {
+ vResponseText = this.getRequest().responseText;
+ } catch(ex) {}
+ }
+
+ return vResponseText;
+}
+
+/*!
+ Provides the XML provided by the response if any and null otherwise. By
+ passing true as the "partial" parameter of this method, incomplete data will
+ be made available to the caller.
+*/
+qx.Proto.getResponseXml = function()
+{
+ var vResponseXML = null;
+
+ var vStatus = this.getStatusCode();
+ var vReadyState = this.getReadyState();
+ if (qx.io.remote.Exchange.wasSuccessful(vStatus, vReadyState, this._localRequest))
+ {
+ try {
+ vResponseXML = this.getRequest().responseXML;
+ } catch(ex) {}
+ }
+
+ // Typical behaviour on file:// on mshtml
+ // Could we check this with something like: /^file\:/.test(path); ?
+ // No browser check here, because it doesn't seem to break other browsers
+ // * test for this.req.responseXML's objecthood added by *
+ // * FRM, 20050816 *
+ if (typeof vResponseXML == "object" && vResponseXML != null)
+ {
+ if (!vResponseXML.documentElement)
+ {
+ // Clear xml file declaration, this breaks non unicode files (like ones with Umlauts)
+ var s = String(this.getRequest().responseText).replace(/<\?xml[^\?]*\?>/, "");
+ vResponseXML.loadXML(s);
+ };
+ // Re-check if fixed...
+ if (!vResponseXML.documentElement) {
+ throw new Error("Missing Document Element!");
+ };
+
+ if (vResponseXML.documentElement.tagName == "parseerror") {
+ throw new Error("XML-File is not well-formed!");
+ };
+ }
+ else
+ {
+ throw new Error("Response was not a valid xml document [" + this.getRequest().responseText + "]");
+ };
+
+ return vResponseXML;
+}
+
+/*!
+ Returns the length of the content as fetched thus far
+*/
+qx.Proto.getFetchedLength = function()
+{
+ var vText = this.getResponseText();
+ return qx.util.Validation.isValidString(vText) ? vText.length : 0;
+}
+
+qx.Proto.getResponseContent = function()
+{
+ if (this.getState() !== "completed")
+ {
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange",
+ "enableDebug")) {
+ this.warn("Transfer not complete, ignoring content!");
+ }
+
+ return null;
+ }
+
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange",
+ "enableDebug")) {
+ this.debug("Returning content for responseType: " + this.getResponseType());
+ }
+
+ var vText = this.getResponseText();
+
+ switch(this.getResponseType())
+ {
+ case "text/plain":
+ case "text/html":
+ return vText;
+
+ case "text/json":
+ try {
+ return vText && vText.length > 0 ? qx.io.Json.parseQx(vText) : null;
+ } catch(ex) {
+ this.error("Could not execute json: [" + vText + "]", ex);
+ return "<pre>Could not execute json: \n" + vText + "\n</pre>"
+ }
+
+ case "text/javascript":
+ try {
+ return vText && vText.length > 0 ? window.eval(vText) : null;
+ } catch(ex) {
+ return this.error("Could not execute javascript: [" + vText + "]", ex);
+ }
+
+ case "application/xml":
+ return this.getResponseXml();
+
+ default:
+ this.warn("No valid responseType specified (" + this.getResponseType() + ")!");
+ return null;
+ }
+}
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ MODIFIER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto._modifyState = function(propValue, propOldValue, propData)
+{
+ if (qx.Settings.getValueOfClass("qx.io.remote.Exchange",
+ "enableDebug")) {
+ this.debug("State: " + propValue);
+ }
+
+ switch(propValue)
+ {
+ case "created":
+ this.createDispatchEvent("created");
+ break;
+
+ case "configured":
+ this.createDispatchEvent("configured");
+ break;
+
+ case "sending":
+ this.createDispatchEvent("sending");
+ break;
+
+ case "receiving":
+ this.createDispatchEvent("receiving");
+ break;
+
+ case "completed":
+ this.createDispatchEvent("completed");
+ break;
+
+ case "failed":
+ this.createDispatchEvent("failed");
+ break;
+
+ case "aborted":
+ this.getRequest().abort();
+ this.createDispatchEvent("aborted");
+ break;
+
+ case "timeout":
+ this.getRequest().abort();
+ this.createDispatchEvent("timeout");
+ break;
+ }
+
+ return true;
+}
+
+
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ DISPOSER
+---------------------------------------------------------------------------
+*/
+
+qx.Proto.dispose = function()
+{
+ if (this.getDisposed()) {
+ return;
+ }
+
+ var vRequest = this.getRequest();
+
+ if (vRequest)
+ {
+ // Should be right,
+ // but is not compatible to mshtml (throws an exception)
+ if (!qx.sys.Client.getInstance().isMshtml()) {
+ vRequest.onreadystatechange = null;
+ }
+
+ // Aborting
+ switch(vRequest.readyState)
+ {
+ case 1:
+ case 2:
+ case 3:
+ vRequest.abort();
+ }
+
+ // Cleanup objects
+ this._req = null;
+ }
+
+ return qx.io.remote.AbstractRemoteTransport.prototype.dispose.call(this);
+}