@qooxdoo/framework 7.0.0-beta.3 → 7.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/Manifest.json +1 -1
  3. package/README.md +9 -3
  4. package/lib/compiler/compile-info.json +60 -58
  5. package/lib/compiler/index.js +3242 -1883
  6. package/lib/resource/qx/tool/cli/templates/skeleton/mobile/source/theme/custom/css/custom.css.map +1 -1
  7. package/lib/resource/qx/tool/loadsass.js +6 -4
  8. package/lib/resource/qx/tool/schema/compile-1-0-0.json +6 -11
  9. package/package.json +17 -3
  10. package/source/class/qx/Bootstrap.js +22 -1
  11. package/source/class/qx/bom/Blocker.js +2 -1
  12. package/source/class/qx/core/Environment.js +3 -12
  13. package/source/class/qx/core/MProperty.js +1 -1
  14. package/source/class/qx/dev/unit/Sinon.js +1 -1
  15. package/source/class/qx/io/__init__.js +5 -3
  16. package/source/class/qx/io/exception/Cancel.js +34 -0
  17. package/source/class/qx/io/exception/Exception.js +38 -0
  18. package/source/class/qx/io/exception/Protocol.js +26 -0
  19. package/source/class/qx/io/exception/Transport.js +39 -0
  20. package/source/class/qx/io/exception/__init__.js +4 -0
  21. package/source/class/qx/io/graphql/Client.js +112 -0
  22. package/source/class/qx/io/graphql/__init__.js +9 -0
  23. package/source/class/qx/io/graphql/protocol/Message.js +65 -0
  24. package/source/class/qx/io/graphql/protocol/Request.js +95 -0
  25. package/source/class/qx/io/graphql/protocol/Response.js +61 -0
  26. package/source/class/qx/io/graphql/protocol/__init__.js +6 -0
  27. package/source/class/qx/io/jsonrpc/Client.js +323 -0
  28. package/source/class/qx/io/jsonrpc/__init__.js +15 -0
  29. package/source/class/qx/io/jsonrpc/protocol/Batch.js +97 -0
  30. package/source/class/qx/io/jsonrpc/protocol/Error.js +63 -0
  31. package/source/class/qx/io/jsonrpc/protocol/Message.js +48 -0
  32. package/source/class/qx/io/jsonrpc/protocol/Notification.js +45 -0
  33. package/source/class/qx/io/jsonrpc/protocol/Parser.js +81 -0
  34. package/source/class/qx/io/jsonrpc/protocol/Request.js +93 -0
  35. package/source/class/qx/io/jsonrpc/protocol/Result.js +48 -0
  36. package/source/class/qx/io/jsonrpc/protocol/__init__.js +5 -0
  37. package/source/class/qx/io/request/authentication/Bearer.js +52 -0
  38. package/source/class/qx/io/transport/AbstractClient.js +100 -0
  39. package/source/class/qx/io/transport/AbstractTransport.js +41 -0
  40. package/source/class/qx/io/transport/Fetch.js +95 -0
  41. package/source/class/qx/io/transport/ITransport.js +40 -0
  42. package/source/class/qx/io/transport/PostMessage.js +55 -0
  43. package/source/class/qx/io/transport/Websocket.js +97 -0
  44. package/source/class/qx/io/transport/Xhr.js +139 -0
  45. package/source/class/qx/io/transport/__init__.js +18 -0
  46. package/source/class/qx/test/core/Assert.js +1 -1
  47. package/source/class/qx/test/core/Environment.js +0 -3
  48. package/source/class/qx/test/io/MAssert.js +46 -0
  49. package/source/class/qx/test/io/graphql/Client.js +169 -0
  50. package/source/class/qx/test/io/graphql/ClientFetch.js +34 -0
  51. package/source/class/qx/test/io/graphql/Request.js +42 -0
  52. package/source/class/qx/test/io/jsonrpc/Client.js +267 -0
  53. package/source/class/qx/test/io/jsonrpc/Protocol.js +80 -0
  54. package/source/class/qx/test/io/transport/PostMessage.js +56 -0
  55. package/source/class/qx/test/io/transport/Websocket.js +63 -0
  56. package/source/class/qx/test/ui/embed/Iframe.js +1 -1
  57. package/source/class/qx/test/util/DateFormat.js +45 -6
  58. package/source/class/qx/tool/cli/Cli.js +1 -0
  59. package/source/class/qx/tool/cli/commands/Compile.js +13 -3
  60. package/source/class/qx/tool/cli/commands/Es6ify.js +93 -0
  61. package/source/class/qx/tool/cli/commands/package/Install.js +1 -1
  62. package/source/class/qx/tool/cli/commands/package/Publish.js +14 -0
  63. package/source/class/qx/tool/compiler/ClassFile.js +67 -27
  64. package/source/class/qx/tool/compiler/Es6ify.js +368 -0
  65. package/source/class/qx/tool/compiler/makers/AppMaker.js +2 -1
  66. package/source/class/qx/tool/compiler/targets/Target.js +57 -47
  67. package/source/class/qx/tool/compiler/targets/meta/AbstractJavascriptMeta.js +25 -18
  68. package/source/class/qx/tool/compiler/targets/meta/BootJs.js +16 -16
  69. package/source/class/qx/tool/compiler/targets/meta/PolyfillJs.js +11 -3
  70. package/source/class/qx/tool/compiler/targets/meta/Uglify.js +10 -10
  71. package/source/class/qx/ui/core/Widget.js +70 -0
  72. package/source/class/qx/ui/decoration/MLinearBackgroundGradient.js +2 -1
  73. package/source/class/qx/ui/form/ComboBox.js +8 -3
  74. package/source/class/qx/ui/form/DateField.js +16 -1
  75. package/source/class/qx/ui/form/MenuButton.js +8 -4
  76. package/source/class/qx/ui/form/SelectBox.js +8 -3
  77. package/source/class/qx/ui/menu/AbstractButton.js +12 -8
  78. package/source/class/qx/ui/menu/Menu.js +18 -8
  79. package/source/class/qx/ui/table/pane/Model.js +10 -4
  80. package/source/class/qx/ui/window/Window.js +8 -0
  81. package/source/class/qx/util/format/DateFormat.js +44 -17
  82. package/source/resource/qx/tool/loadsass.js +6 -4
  83. package/source/resource/qx/tool/schema/compile-1-0-0.json +6 -11
  84. package/source/translation/hr.po +297 -0
  85. package/lib/resource/qx/static/blank.gif +0 -0
  86. package/source/class/qx/io/remote/Exchange.js +0 -1063
  87. package/source/class/qx/io/remote/Request.js +0 -1021
  88. package/source/class/qx/io/remote/RequestQueue.js +0 -521
  89. package/source/class/qx/io/remote/Response.js +0 -137
  90. package/source/class/qx/io/remote/Rpc.js +0 -1075
  91. package/source/class/qx/io/remote/RpcError.js +0 -198
  92. package/source/class/qx/io/remote/__init__.js +0 -88
  93. package/source/class/qx/io/remote/transport/Abstract.js +0 -513
  94. package/source/class/qx/io/remote/transport/Iframe.js +0 -652
  95. package/source/class/qx/io/remote/transport/Script.js +0 -475
  96. package/source/class/qx/io/remote/transport/XmlHttp.js +0 -1019
  97. package/source/class/qx/io/remote/transport/__init__.js +0 -3
  98. package/source/class/qx/test/io/remote/AbstractRequest.js +0 -150
  99. package/source/class/qx/test/io/remote/RequestIframe.js +0 -105
  100. package/source/class/qx/test/io/remote/RequestXhr.js +0 -151
  101. package/source/class/qx/test/io/remote/Rpc.js +0 -205
  102. package/source/class/qx/test/io/remote/__init__.js +0 -4
  103. package/source/class/qx/test/io/remote/transport/Iframe.js +0 -67
  104. package/source/class/qx/test/io/remote/transport/XmlHttp.js +0 -133
  105. package/source/class/qx/test/io/remote/transport/__init__.js +0 -4
@@ -1,1063 +0,0 @@
1
- /* ************************************************************************
2
-
3
- qooxdoo - the new era of web development
4
-
5
- http://qooxdoo.org
6
-
7
- Copyright:
8
- 2004-2008 1&1 Internet AG, Germany, http://www.1und1.de
9
- 2006 Derrell Lipman
10
- 2006 STZ-IDA, Germany, http://www.stz-ida.de
11
-
12
- License:
13
- MIT: https://opensource.org/licenses/MIT
14
- See the LICENSE file in the project's top-level directory for details.
15
-
16
- Authors:
17
- * Sebastian Werner (wpbasti)
18
- * Andreas Ecker (ecker)
19
- * Derrell Lipman (derrell)
20
- * Andreas Junghans (lucidcake)
21
-
22
- ************************************************************************ */
23
-
24
- /**
25
- * Transport layer to control which transport class (XmlHttp, Iframe or Script)
26
- * can be used.
27
- *
28
- * NOTE: Instances of this class must be disposed of after use
29
- *
30
- * @use(qx.io.remote.transport.Iframe)
31
- * @use(qx.io.remote.transport.Script)
32
- * @internal
33
- */
34
- qx.Class.define("qx.io.remote.Exchange",
35
- {
36
- extend : qx.core.Object,
37
- implement : [ qx.core.IDisposable ],
38
-
39
-
40
-
41
-
42
- /*
43
- *****************************************************************************
44
- CONSTRUCTOR
45
- *****************************************************************************
46
- */
47
-
48
- /**
49
- * Constructor method.
50
- *
51
- * @param vRequest {qx.io.remote.Request} request object
52
- */
53
- construct : function(vRequest)
54
- {
55
- this.base(arguments);
56
-
57
- this.setRequest(vRequest);
58
- vRequest.setTransport(this);
59
- },
60
-
61
-
62
-
63
-
64
- /*
65
- *****************************************************************************
66
- EVENTS
67
- *****************************************************************************
68
- */
69
-
70
- events : {
71
- /** Fired whenever a request is send */
72
- "sending" : "qx.event.type.Event",
73
-
74
- /** Fired whenever a request is received */
75
- "receiving" : "qx.event.type.Event",
76
-
77
- /** Fired whenever a request is completed */
78
- "completed" : "qx.io.remote.Response",
79
-
80
- /** Fired whenever a request is aborted */
81
- "aborted" : "qx.event.type.Event",
82
-
83
- /** Fired whenever a request has failed */
84
- "failed" : "qx.io.remote.Response",
85
-
86
- /** Fired whenever a request has timed out */
87
- "timeout" : "qx.io.remote.Response"
88
- },
89
-
90
-
91
-
92
- /*
93
- *****************************************************************************
94
- STATICS
95
- *****************************************************************************
96
- */
97
-
98
- statics :
99
- {
100
- /* ************************************************************************
101
- Class data, properties and methods
102
- ************************************************************************ */
103
-
104
- /*
105
- ---------------------------------------------------------------------------
106
- TRANSPORT TYPE HANDLING
107
- ---------------------------------------------------------------------------
108
- */
109
-
110
- /**
111
- * Predefined order of types.
112
- *
113
- * @internal
114
- */
115
- typesOrder : [ "qx.io.remote.transport.XmlHttp", "qx.io.remote.transport.Iframe", "qx.io.remote.transport.Script" ],
116
-
117
- /**
118
- * Marker for initialized types.
119
- *
120
- * @internal
121
- */
122
- typesReady : false,
123
-
124
- /**
125
- * Map of all available types.
126
- *
127
- * @internal
128
- */
129
- typesAvailable : {},
130
-
131
- /**
132
- * Map of all supported types.
133
- *
134
- * @internal
135
- */
136
- typesSupported : {},
137
-
138
-
139
- /**
140
- * Registers a transport type.
141
- * At the moment one out of XmlHttp, Iframe or Script.
142
- *
143
- * @param vClass {Object} transport class
144
- * @param vId {String} unique id
145
- */
146
- registerType : function(vClass, vId) {
147
- qx.io.remote.Exchange.typesAvailable[vId] = vClass;
148
- },
149
-
150
-
151
- /**
152
- * Initializes the available type of transport classes and
153
- * checks for the supported ones.
154
- *
155
- * @throws {Error} an error if no supported transport type is available
156
- */
157
- initTypes : function()
158
- {
159
- if (qx.io.remote.Exchange.typesReady) {
160
- return;
161
- }
162
-
163
- for (var vId in qx.io.remote.Exchange.typesAvailable)
164
- {
165
- var vTransporterImpl = qx.io.remote.Exchange.typesAvailable[vId];
166
-
167
- if (vTransporterImpl.isSupported()) {
168
- qx.io.remote.Exchange.typesSupported[vId] = vTransporterImpl;
169
- }
170
- }
171
-
172
- qx.io.remote.Exchange.typesReady = true;
173
-
174
- if (qx.lang.Object.isEmpty(qx.io.remote.Exchange.typesSupported)) {
175
- throw new Error("No supported transport types were found!");
176
- }
177
- },
178
-
179
-
180
- /**
181
- * Checks which supported transport class can handle the request with the
182
- * given content type.
183
- *
184
- * @param vImpl {Object} transport implementation
185
- * @param vNeeds {Map} requirements for the request like e.g. "cross-domain"
186
- * @param vResponseType {String} content type
187
- * @return {Boolean} <code>true</code> if the transport implementation supports
188
- * the request's requirements
189
- */
190
- canHandle : function(vImpl, vNeeds, vResponseType)
191
- {
192
- if (!vImpl.handles.responseTypes.includes(vResponseType)) {
193
- return false;
194
- }
195
-
196
- for (var vKey in vNeeds)
197
- {
198
- if (!vImpl.handles[vKey]) {
199
- return false;
200
- }
201
- }
202
-
203
- return true;
204
- },
205
-
206
-
207
-
208
-
209
- /*
210
- ---------------------------------------------------------------------------
211
- MAPPING
212
- ---------------------------------------------------------------------------
213
- */
214
-
215
- /**
216
- * http://msdn.microsoft.com/en-us/library/ie/ms534359%28v=vs.85%29.aspx
217
- *
218
- * 0: UNINITIALIZED
219
- * The object has been created, but not initialized (the open method has not been called).
220
- *
221
- * 1: LOADING
222
- * The object has been created, but the send method has not been called.
223
- *
224
- * 2: LOADED
225
- * The send method has been called, but the status and headers are not yet available.
226
- *
227
- * 3: INTERACTIVE
228
- * 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.
229
- *
230
- * 4: COMPLETED
231
- * All the data has been received, and the complete data is available in the
232
- *
233
- * @internal
234
- */
235
- _nativeMap :
236
- {
237
- 0 : "created",
238
- 1 : "configured",
239
- 2 : "sending",
240
- 3 : "receiving",
241
- 4 : "completed"
242
- },
243
-
244
-
245
-
246
-
247
- /*
248
- ---------------------------------------------------------------------------
249
- UTILS
250
- ---------------------------------------------------------------------------
251
- */
252
-
253
- /**
254
- * Called from the transport class when a request was completed.
255
- *
256
- * @param vStatusCode {Integer} status code of the request
257
- * @param vReadyState {String} readystate of the request
258
- * @param vIsLocal {Boolean} whether the request is a local one
259
- * @return {Boolean | var} Returns boolean value depending on the status code
260
- */
261
- wasSuccessful : function(vStatusCode, vReadyState, vIsLocal)
262
- {
263
- if (vIsLocal)
264
- {
265
- switch(vStatusCode)
266
- {
267
- case null:
268
- case 0:
269
- return true;
270
-
271
- case -1:
272
- // Not Available (OK for readystates: MSXML<4=1-3, MSXML>3=1-2, Gecko=1)
273
- return vReadyState < 4;
274
-
275
- default:
276
- // at least older versions of Safari don't set the status code for local file access
277
- return typeof vStatusCode === "undefined";
278
- }
279
- }
280
- else
281
- {
282
- switch(vStatusCode)
283
- {
284
- case -1: // Not Available (OK for readystates: MSXML<4=1-3, MSXML>3=1-2, Gecko=1)
285
- if (qx.core.Environment.get("qx.debug"))
286
- {
287
- if (qx.core.Environment.get("qx.debug.io.remote") && vReadyState > 3) {
288
- qx.log.Logger.debug(this, "Failed with statuscode: -1 at readyState " + vReadyState);
289
- }
290
- }
291
-
292
- return vReadyState < 4;
293
-
294
- case 200: // OK
295
- case 304: // Not Modified
296
- return true;
297
-
298
- case 201: // Created
299
- case 202: // Accepted
300
- case 203: // Non-Authoritative Information
301
- case 204: // No Content
302
- case 205: // Reset Content
303
- return true;
304
-
305
- case 206: // Partial Content
306
- if (qx.core.Environment.get("qx.debug"))
307
- {
308
- if (qx.core.Environment.get("qx.debug.io.remote") && vReadyState === 4) {
309
- qx.log.Logger.debug(this, "Failed with statuscode: 206 (Partial content while being complete!)");
310
- }
311
- }
312
-
313
- return vReadyState !== 4;
314
-
315
- case 300: // Multiple Choices
316
- case 301: // Moved Permanently
317
- case 302: // Moved Temporarily
318
- case 303: // See Other
319
- case 305: // Use Proxy
320
- case 400: // Bad Request
321
- case 401: // Unauthorized
322
- case 402: // Payment Required
323
- case 403: // Forbidden
324
- case 404: // Not Found
325
- case 405: // Method Not Allowed
326
- case 406: // Not Acceptable
327
- case 407: // Proxy Authentication Required
328
- case 408: // Request Time-Out
329
- case 409: // Conflict
330
- case 410: // Gone
331
- case 411: // Length Required
332
- case 412: // Precondition Failed
333
- case 413: // Request Entity Too Large
334
- case 414: // Request-URL Too Large
335
- case 415: // Unsupported Media Type
336
- case 500: // Server Error
337
- case 501: // Not Implemented
338
- case 502: // Bad Gateway
339
- case 503: // Out of Resources
340
- case 504: // Gateway Time-Out
341
- case 505: // HTTP Version not supported
342
- if (qx.core.Environment.get("qx.debug"))
343
- {
344
- if (qx.core.Environment.get("qx.debug.io.remote")) {
345
- qx.log.Logger.debug(this, "Failed with typical HTTP statuscode: " + vStatusCode);
346
- }
347
- }
348
-
349
- return false;
350
-
351
-
352
- // The following case labels are wininet.dll error codes that may
353
- // be encountered.
354
-
355
- // Server timeout
356
- case 12002:
357
- // Internet Name Not Resolved
358
- case 12007:
359
- // 12029 to 12031 correspond to dropped connections.
360
- case 12029:
361
- case 12030:
362
- case 12031:
363
- // Connection closed by server.
364
- case 12152:
365
- // See above comments for variable status.
366
- case 13030:
367
- if (qx.core.Environment.get("qx.debug"))
368
- {
369
- if (qx.core.Environment.get("qx.debug.io.remote")) {
370
- qx.log.Logger.debug(this, "Failed with MSHTML specific HTTP statuscode: " + vStatusCode);
371
- }
372
- }
373
-
374
- return false;
375
-
376
- default:
377
- // Handle all 20x status codes as OK as defined in the corresponding RFC
378
- // http://www.w3.org/Protocols/rfc2616/rfc2616.html
379
- if (vStatusCode > 206 && vStatusCode < 300) {
380
- return true;
381
- }
382
-
383
- qx.log.Logger.debug(this, "Unknown status code: " + vStatusCode + " (" + vReadyState + ")");
384
- return false;
385
- }
386
- }
387
- },
388
-
389
-
390
- /**
391
- * Status code to string conversion
392
- *
393
- * @param vStatusCode {Integer} request status code
394
- * @return {String} String presentation of status code
395
- */
396
- statusCodeToString : function(vStatusCode)
397
- {
398
- switch(vStatusCode)
399
- {
400
- case -1:
401
- return "Not available";
402
-
403
- case 0:
404
- // Attempt to generate a potentially meaningful error.
405
- // Get the current URL
406
- var url = window.location.href;
407
-
408
- // Are we on a local page obtained via file: protocol?
409
- if (url.toLowerCase().startsWith("file:"))
410
- {
411
- // Yup. Can't issue remote requests from here.
412
- return ("Unknown status code. " +
413
- "Possibly due to application URL using 'file:' protocol?");
414
- }
415
- else
416
- {
417
- return ("Unknown status code. " +
418
- "Possibly due to a cross-domain request?");
419
- }
420
-
421
- case 200:
422
- return "Ok";
423
-
424
- case 304:
425
- return "Not modified";
426
-
427
- case 206:
428
- return "Partial content";
429
-
430
- case 204:
431
- return "No content";
432
-
433
- case 300:
434
- return "Multiple choices";
435
-
436
- case 301:
437
- return "Moved permanently";
438
-
439
- case 302:
440
- return "Moved temporarily";
441
-
442
- case 303:
443
- return "See other";
444
-
445
- case 305:
446
- return "Use proxy";
447
-
448
- case 400:
449
- return "Bad request";
450
-
451
- case 401:
452
- return "Unauthorized";
453
-
454
- case 402:
455
- return "Payment required";
456
-
457
- case 403:
458
- return "Forbidden";
459
-
460
- case 404:
461
- return "Not found";
462
-
463
- case 405:
464
- return "Method not allowed";
465
-
466
- case 406:
467
- return "Not acceptable";
468
-
469
- case 407:
470
- return "Proxy authentication required";
471
-
472
- case 408:
473
- return "Request time-out";
474
-
475
- case 409:
476
- return "Conflict";
477
-
478
- case 410:
479
- return "Gone";
480
-
481
- case 411:
482
- return "Length required";
483
-
484
- case 412:
485
- return "Precondition failed";
486
-
487
- case 413:
488
- return "Request entity too large";
489
-
490
- case 414:
491
- return "Request-URL too large";
492
-
493
- case 415:
494
- return "Unsupported media type";
495
-
496
- case 500:
497
- return "Server error";
498
-
499
- case 501:
500
- return "Not implemented";
501
-
502
- case 502:
503
- return "Bad gateway";
504
-
505
- case 503:
506
- return "Out of resources";
507
-
508
- case 504:
509
- return "Gateway time-out";
510
-
511
- case 505:
512
- return "HTTP version not supported";
513
-
514
- case 12002:
515
- return "Server timeout";
516
-
517
- case 12029:
518
- return "Connection dropped";
519
-
520
- case 12030:
521
- return "Connection dropped";
522
-
523
- case 12031:
524
- return "Connection dropped";
525
-
526
- case 12152:
527
- return "Connection closed by server";
528
-
529
- case 13030:
530
- return "MSHTML-specific HTTP status code";
531
-
532
- default:
533
- return "Unknown status code";
534
- }
535
- }
536
- },
537
-
538
-
539
-
540
-
541
- /*
542
- *****************************************************************************
543
- PROPERTIES
544
- *****************************************************************************
545
- */
546
-
547
- properties :
548
- {
549
- /** Set the request to send with this transport. */
550
- request :
551
- {
552
- check : "qx.io.remote.Request",
553
- nullable : true
554
- },
555
-
556
-
557
- /**
558
- * Set the implementation to use to send the request with.
559
- *
560
- * The implementation should be a subclass of qx.io.remote.transport.Abstract and
561
- * must implement all methods in the transport API.
562
- */
563
- implementation :
564
- {
565
- check : "qx.io.remote.transport.Abstract",
566
- nullable : true,
567
- apply : "_applyImplementation"
568
- },
569
-
570
- /** Current state of the transport layer. */
571
- state :
572
- {
573
- check : [ "configured", "sending", "receiving", "completed", "aborted", "timeout", "failed" ],
574
- init : "configured",
575
- event : "changeState",
576
- apply : "_applyState"
577
- }
578
- },
579
-
580
-
581
-
582
-
583
- /*
584
- *****************************************************************************
585
- MEMBERS
586
- *****************************************************************************
587
- */
588
-
589
- members :
590
- {
591
- /*
592
- ---------------------------------------------------------------------------
593
- CORE METHODS
594
- ---------------------------------------------------------------------------
595
- */
596
-
597
- /**
598
- * Sends the request.
599
- *
600
- * @return {var | Boolean} Returns true if the request was sent.
601
- * @lint ignoreUnused(field)
602
- */
603
- send : function()
604
- {
605
- var vRequest = this.getRequest();
606
-
607
- if (!vRequest) {
608
- return this.error("Please attach a request object first");
609
- }
610
-
611
- qx.io.remote.Exchange.initTypes();
612
-
613
- var vUsage = qx.io.remote.Exchange.typesOrder;
614
- var vSupported = qx.io.remote.Exchange.typesSupported;
615
-
616
- // Mapping settings to contenttype and needs to check later
617
- // if the selected transport implementation can handle
618
- // fulfill these requirements.
619
- var vResponseType = vRequest.getResponseType();
620
- var vNeeds = {};
621
-
622
- if (vRequest.getAsynchronous()) {
623
- vNeeds.asynchronous = true;
624
- } else {
625
- vNeeds.synchronous = true;
626
- }
627
-
628
- if (vRequest.getCrossDomain()) {
629
- vNeeds.crossDomain = true;
630
- }
631
-
632
- if (vRequest.getFileUpload()) {
633
- vNeeds.fileUpload = true;
634
- }
635
-
636
- // See if there are any programmatic form fields requested
637
- for (var field in vRequest.getFormFields())
638
- {
639
- // There are.
640
- vNeeds.programmaticFormFields = true;
641
-
642
- // No need to search further
643
- break;
644
- }
645
-
646
- var vTransportImpl, vTransport;
647
-
648
- for (var i=0, l=vUsage.length; i<l; i++)
649
- {
650
- vTransportImpl = vSupported[vUsage[i]];
651
-
652
- if (vTransportImpl)
653
- {
654
- if (!qx.io.remote.Exchange.canHandle(vTransportImpl, vNeeds, vResponseType)) {
655
- continue;
656
- }
657
-
658
- try
659
- {
660
- if (qx.core.Environment.get("qx.debug"))
661
- {
662
- if (qx.core.Environment.get("qx.debug.io.remote")) {
663
- this.debug("Using implementation: " + vTransportImpl.classname);
664
- }
665
- }
666
-
667
- vTransport = new vTransportImpl;
668
- this.setImplementation(vTransport);
669
-
670
- vTransport.setUseBasicHttpAuth(vRequest.getUseBasicHttpAuth());
671
-
672
- vTransport.send();
673
- return true;
674
- }
675
- catch(ex)
676
- {
677
- this.error("Request handler throws error");
678
- this.error(ex);
679
- return false;
680
- }
681
- }
682
- }
683
-
684
- this.error("There is no transport implementation available to handle this request: " + vRequest);
685
- },
686
-
687
-
688
- /**
689
- * Force the transport into the aborted ("aborted")
690
- * state.
691
- *
692
- */
693
- abort : function()
694
- {
695
- var vImplementation = this.getImplementation();
696
-
697
- if (vImplementation)
698
- {
699
- if (qx.core.Environment.get("qx.debug"))
700
- {
701
- if (qx.core.Environment.get("qx.debug.io.remote")) {
702
- this.debug("Abort: implementation " + vImplementation.toHashCode());
703
- }
704
- }
705
-
706
- vImplementation.abort();
707
- }
708
- else
709
- {
710
- if (qx.core.Environment.get("qx.debug"))
711
- {
712
- if (qx.core.Environment.get("qx.debug.io.remote")) {
713
- this.debug("Abort: forcing state to be aborted");
714
- }
715
- }
716
-
717
- this.setState("aborted");
718
- }
719
- },
720
-
721
-
722
- /**
723
- * Force the transport into the timeout state.
724
- *
725
- */
726
- timeout : function()
727
- {
728
- var vImplementation = this.getImplementation();
729
-
730
- if (vImplementation)
731
- {
732
- var str = "";
733
- for (var key in vImplementation.getParameters())
734
- {
735
- str += "&" + key + "=" + vImplementation.getParameters()[key];
736
- }
737
- this.warn("Timeout: implementation " + vImplementation.toHashCode() + ", "
738
- + vImplementation.getUrl() + " [" + vImplementation.getMethod() + "], " + str);
739
- vImplementation.timeout();
740
- }
741
- else
742
- {
743
- this.warn("Timeout: forcing state to timeout");
744
- this.setState("timeout");
745
- }
746
-
747
- // Disable future timeouts in case user handler blocks
748
- this.__disableRequestTimeout();
749
- },
750
-
751
-
752
- /*
753
- ---------------------------------------------------------------------------
754
- PRIVATES
755
- ---------------------------------------------------------------------------
756
- */
757
-
758
- /**
759
- * Disables the timer of the request to prevent that the timer is expiring
760
- * even if the user handler (e.g. "completed") was already called.
761
- *
762
- */
763
- __disableRequestTimeout : function() {
764
- var vRequest = this.getRequest();
765
- if (vRequest) {
766
- vRequest.setTimeout(0);
767
- }
768
- },
769
-
770
-
771
-
772
-
773
- /*
774
- ---------------------------------------------------------------------------
775
- EVENT HANDLER
776
- ---------------------------------------------------------------------------
777
- */
778
-
779
- /**
780
- * Event listener for "sending" event.
781
- *
782
- * @param e {qx.event.type.Event} event object
783
- */
784
- _onsending : function(e) {
785
- this.setState("sending");
786
- },
787
-
788
-
789
- /**
790
- * Event listener for "receiving" event.
791
- *
792
- * @param e {qx.event.type.Event} event object
793
- */
794
- _onreceiving : function(e) {
795
- this.setState("receiving");
796
- },
797
-
798
-
799
- /**
800
- * Event listener for "completed" event.
801
- *
802
- * @param e {qx.event.type.Event} event object
803
- */
804
- _oncompleted : function(e) {
805
- this.setState("completed");
806
- },
807
-
808
-
809
- /**
810
- * Event listener for "abort" event.
811
- *
812
- * @param e {qx.event.type.Event} event object
813
- */
814
- _onabort : function(e) {
815
- this.setState("aborted");
816
- },
817
-
818
-
819
- /**
820
- * Event listener for "failed" event.
821
- *
822
- * @param e {qx.event.type.Event} event object
823
- */
824
- _onfailed : function(e) {
825
- this.setState("failed");
826
- },
827
-
828
-
829
- /**
830
- * Event listener for "timeout" event.
831
- *
832
- * @param e {qx.event.type.Event} event object
833
- */
834
- _ontimeout : function(e) {
835
- this.setState("timeout");
836
- },
837
-
838
-
839
-
840
-
841
- /*
842
- ---------------------------------------------------------------------------
843
- APPLY ROUTINES
844
- ---------------------------------------------------------------------------
845
- */
846
-
847
- /**
848
- * Apply method for the implementation property.
849
- *
850
- * @param value {var} Current value
851
- * @param old {var} Previous value
852
- */
853
- _applyImplementation : function(value, old)
854
- {
855
- if (old)
856
- {
857
- old.removeListener("sending", this._onsending, this);
858
- old.removeListener("receiving", this._onreceiving, this);
859
- old.removeListener("completed", this._oncompleted, this);
860
- old.removeListener("aborted", this._onabort, this);
861
- old.removeListener("timeout", this._ontimeout, this);
862
- old.removeListener("failed", this._onfailed, this);
863
- }
864
-
865
- if (value)
866
- {
867
- var vRequest = this.getRequest();
868
-
869
- value.setUrl(vRequest.getUrl());
870
- value.setMethod(vRequest.getMethod());
871
- value.setAsynchronous(vRequest.getAsynchronous());
872
-
873
- value.setUsername(vRequest.getUsername());
874
- value.setPassword(vRequest.getPassword());
875
-
876
- value.setParameters(vRequest.getParameters(false));
877
- value.setFormFields(vRequest.getFormFields());
878
- value.setRequestHeaders(vRequest.getRequestHeaders());
879
-
880
- // Set the parseJson property which is currently only supported for XmlHttp transport
881
- // (which is the only transport supporting JSON parsing so far).
882
- if (value instanceof qx.io.remote.transport.XmlHttp){
883
- value.setParseJson(vRequest.getParseJson());
884
- }
885
-
886
- var data = vRequest.getData();
887
- if (data === null)
888
- {
889
- var vParameters = vRequest.getParameters(true);
890
- var vParametersList = [];
891
-
892
- for (var vId in vParameters)
893
- {
894
- var paramValue = vParameters[vId];
895
-
896
- if (paramValue instanceof Array)
897
- {
898
- for (var i=0; i<paramValue.length; i++)
899
- {
900
- vParametersList.push(encodeURIComponent(vId) +
901
- "=" +
902
- encodeURIComponent(paramValue[i]));
903
- }
904
- }
905
- else
906
- {
907
- vParametersList.push(encodeURIComponent(vId) +
908
- "=" +
909
- encodeURIComponent(paramValue));
910
- }
911
- }
912
-
913
- if (vParametersList.length > 0)
914
- {
915
- value.setData(vParametersList.join("&"));
916
- }
917
- }
918
- else
919
- {
920
- value.setData(data);
921
- }
922
-
923
- value.setResponseType(vRequest.getResponseType());
924
-
925
- value.addListener("sending", this._onsending, this);
926
- value.addListener("receiving", this._onreceiving, this);
927
- value.addListener("completed", this._oncompleted, this);
928
- value.addListener("aborted", this._onabort, this);
929
- value.addListener("timeout", this._ontimeout, this);
930
- value.addListener("failed", this._onfailed, this);
931
- }
932
- },
933
-
934
-
935
- /**
936
- * Apply method for the state property.
937
- *
938
- * @param value {var} Current value
939
- * @param old {var} Previous value
940
- */
941
- _applyState : function(value, old)
942
- {
943
- if (qx.core.Environment.get("qx.debug"))
944
- {
945
- if (qx.core.Environment.get("qx.debug.io.remote")) {
946
- this.debug("State: " + old + " => " + value);
947
- }
948
- }
949
-
950
- switch(value)
951
- {
952
- case "sending":
953
- this.fireEvent("sending");
954
- break;
955
-
956
- case "receiving":
957
- this.fireEvent("receiving");
958
- break;
959
-
960
- case "completed":
961
- case "aborted":
962
- case "timeout":
963
- case "failed":
964
- var vImpl = this.getImplementation();
965
-
966
- if (!vImpl)
967
- {
968
- // implementation has already been disposed
969
- break;
970
- }
971
-
972
-
973
- // Disable future timeouts in case user handler blocks
974
- this.__disableRequestTimeout();
975
-
976
- if (this.hasListener(value))
977
- {
978
- var vResponse = qx.event.Registration.createEvent(value, qx.io.remote.Response);
979
-
980
- if (value == "completed")
981
- {
982
- var vContent = vImpl.getResponseContent();
983
- vResponse.setContent(vContent);
984
-
985
- /*
986
- * Was there acceptable content? This might occur, for example, if
987
- * the web server was shut down unexpectedly and thus the connection
988
- * closed with no data having been sent.
989
- */
990
-
991
- if (vContent === null)
992
- {
993
- // Nope. Change COMPLETED to FAILED.
994
- if (qx.core.Environment.get("qx.debug"))
995
- {
996
- if (qx.core.Environment.get("qx.debug.io.remote")) {
997
- this.debug("Altered State: " + value + " => failed");
998
- }
999
- }
1000
-
1001
- value = "failed";
1002
- }
1003
- }
1004
- else if (value == "failed")
1005
- {
1006
- vResponse.setContent(vImpl.getResponseContent());
1007
- }
1008
-
1009
- vResponse.setStatusCode(vImpl.getStatusCode());
1010
- vResponse.setResponseHeaders(vImpl.getResponseHeaders());
1011
-
1012
- this.dispatchEvent(vResponse);
1013
-
1014
- }
1015
-
1016
- // Disconnect and dispose implementation
1017
- this.setImplementation(null);
1018
- vImpl.dispose();
1019
-
1020
- // Fire event to listeners
1021
- //this.fireDataEvent(vEventType, vResponse);
1022
-
1023
- break;
1024
- }
1025
- }
1026
- },
1027
-
1028
-
1029
-
1030
-
1031
- /*
1032
- *****************************************************************************
1033
- ENVIRONMENT SETTINGS
1034
- *****************************************************************************
1035
- */
1036
-
1037
- environment : {
1038
- "qx.debug.io.remote" : false,
1039
- "qx.debug.io.remote.data" : false
1040
- },
1041
-
1042
-
1043
-
1044
-
1045
- /*
1046
- *****************************************************************************
1047
- DESTRUCTOR
1048
- *****************************************************************************
1049
- */
1050
-
1051
- destruct : function()
1052
- {
1053
- var vImpl = this.getImplementation();
1054
-
1055
- if (vImpl)
1056
- {
1057
- this.setImplementation(null);
1058
- vImpl.dispose();
1059
- }
1060
-
1061
- this.setRequest(null);
1062
- }
1063
- });