summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* Make it possible to disconnect from signals on the client side.Milian Wolff2013-12-054-11/+120
| | | | | | | | To do so, we need to remember the connected functor and pass that to disconnect, in both the client side as well as the QML server side. Change-Id: Ic61fc5d2a203212278c23471c216683e309e2c9f Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* compileThomas McGuire2013-11-271-0/+1
| | | | | | Change-Id: If26e033dcb031678815277890be4ad2ebad3fd4b Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
* Test QObject wrapping, when factory-style methods are called.Milian Wolff2013-11-253-1/+114
| | | | | | | | | | | | | | An HTML client can trigger the creation of new objects, or a published object on the server side might return other objects. These are then wrapped on the fly and can be used like the other objects. Note though that the HTML client can call deleteLater on these objects. Also, it does not yet work to wrap objects on the fly in signal arguments or property values. Change-Id: I92aa8a3e52f42d5325dd0771bbf9e2ae213e88f9 Reviewed-by: Arvid Nilsson <anilsson@blackberry.com> Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Use strict mode in JavaScript files.Milian Wolff2013-11-252-0/+4
| | | | | | | | | No other changes seem to be required. Change-Id: Ie15639f74f09cbd303828c96f75d29283ec4d562 Reviewed-by: Arvid Nilsson <anilsson@blackberry.com> Reviewed-by: Chris H-C <chutten@blackberry.com> Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Optimize QtMetaObjectPublisher::classInfoForObject.Milian Wolff2013-11-251-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | This includes two optimizations which have been forgotten to be upstreamed before: a) For the common case of property notify signals named "...Changed", the string name is now not send anymore to the client. Instead, these cases are special-cased and constructed on the fly. This drastically reduces the size of Qt.init responses and property update messages. b) Furthermore, do not list signals as methods, further reducing the size of Qt.init response messages. Together this shows a noticeable reduce of CPU instructions in the benchmarks as recorded with perf: benchmark_classInfo: down ~10% benchmark_initializeClients: down ~2% benchmark_propertyUpdates: down ~1% Change-Id: I01e59f5c1dceedb893f7a3e3e127acb493baaa7f Reviewed-by: Michael Bruning <michael.bruning@digia.com> Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Add benchmarks for the MetaObjectPublisher.Milian Wolff2013-11-252-0/+175
| | | | | | | | | | | This runs benchmarks on various functions of the MOP with hundred objects each containing ten properties, signals and methods. Furthermore a function is included which benchmarks the whole roundtrip of loading a simple client and waiting for it to be initialized. Change-Id: If51c5b5f606151885611cabc0e1330bd2643ad67 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Cleanup QML code.Milian Wolff2013-11-221-11/+4
| | | | | | | | | Instead of initializing the property maps in Component.onCompleted, use "var foo: ({})" instead. This looks suprising, but the "var foo: {}" syntax won't work - it's an empty binding expression closur, not a map. Change-Id: I9edeeeeeabb3a871a46d8bb8a991a4155040497a Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
* Add a test for the property update grouping.Milian Wolff2013-11-223-2/+51
| | | | | | | | | | | For performance reasons, we group property updates and send a single batch update notification. This is now tested to work as intended. This also uncovered a bug in webchannel.js when multiple functions subscribe to the same id. Change-Id: Ic8648d664dd1fe54df7e25fade6a6088386af992 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
* Add an initial test suite for the MetaObjectPublisherMilian Wolff2013-11-229-74/+359
| | | | | | | | | | | | | | This tests the functionality of publishing a plain QtObject from QML to the HTML client. It tests property binding, i.e. reading and writing of an objects property on the client side, as well as change notification tracking. Furthermore a server-side method is invoked from the client and signal submission from the server to the client is tested. Change-Id: I62e544cddf4483b57535a9bc1e05a36105ec6622 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
* Add test for QWebChannel::ping-sending and pong-receival.Milian Wolff2013-11-201-0/+14
| | | | | Change-Id: Ia449851bd0312435882c0238ab46f8316e38b72f Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Add test for webchannel.respond on the QML and .exec on the HTML side.Milian Wolff2013-11-142-0/+29
| | | | | Change-Id: I5eec7bc87bc56de6dd918d90f2fe9ee86d72b434 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Cleanup sources, mostly by removing QtCreator generated bloat.Milian Wolff2013-11-1433-1228/+92
| | | | | | | | | | | | | | This removes a lot of obsolete files and simplifies the build system of the examples. Furthermore, the examples can now be run without running make install first. It reuses the same import path as the test does. Note that the examples are not installable anymore now though. If this is required, it can be added again. Change-Id: Ic7ff80f734b035a03fb1a11a2df492c97298ceff Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
* Add unit test harness for QWebChannel and two initial tests.Milian Wolff2013-11-149-13/+215
| | | | | | | | | | | | This uncovered a bug in webchannel.js, which stringified strings leading to duplicated quoting. This is also fixed now. Furthermore, some QMake changes are required to make it possible to run the tests without first installing QWebChannel. Change-Id: If7e8f73a748f86f2d5c7d39000e90612367038af Reviewed-by: Zeno Albisser <zeno.albisser@digia.com> Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Remove obsolete CONFIG+=ordered from qmake files.Milian Wolff2013-11-132-3/+1
| | | | | Change-Id: Ide09c6f218bf7af176e03e4741f29cd022f351b8 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Add KDAB/Qt-Project license to files edited by the previous commits.Milian Wolff2013-11-016-0/+18
| | | | | Change-Id: Idf344f46aa09a13dfe4db00203b7644006fbf944 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Update READMEMilian Wolff2013-11-011-6/+12
| | | | | Change-Id: I047bde16950e826d20ec3a191973c1bff95fa320 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Make it possible to wrap QObject's on the fly.Milian Wolff2013-11-0110-59/+275
| | | | | | | | This is required for factory-like methods on the C++/QML side, which we want to access from the HTML side as well. Change-Id: I2852bbc9c8effb6d6f49b5be784241a6e2320823 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Make it possible to start the examples from a different dir.Milian Wolff2013-11-012-2/+2
| | | | | Change-Id: I0a640ee38d642670211b7cae30619fc18307b688 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Greatly optimize WebChannel in various ways.Milian Wolff2013-11-019-111/+467
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a big code drop - sorry for that. The benefits are worth it though, I'm sure. The optimizations were required to make the WebChannel useable even on a low-end embedded device with medium amount of traffic. The changes in this patch can be grouped into different parts: a) Do more in C++: Esp. by leveraging e.g. the new classInfoForObjects in QtMetaObjectPublisher (on the C++ side) one can greatly reduce the time required for initialization of the webchannel. b) Property Caching: Instead of requiring a socket roundtrip whenever a property is read on the HTML side, we now cache the property values on the HTML side. Note that for this to work properly, one needs to add proper notify signals to the property declarations, as otherwise the cache will not get updated. c) Grouping: Instead of sending separate messages to the clients for every property update, these signals are grouped by a 50ms timer, and then send aggregated to the client. This reduces the socket traffic, as more boiler plate can be shared. d) Compression: Some data was previously send repeatedly, such as property name and notify signal. This is now compressed internally where possible (i.e. for the ${propName}Changed naming scheme). e) Message Flood Prevention: Previously, one could easily flood an HTML client by sending data to it. If it could not work off the incoming stream one would freeze the HTML client. Now, we wait for an idle signal of the client prior to sending new data to it. Paired with the message grouping and property cache mentioned above, we are able to only send the newest data once the HTML client becomes active again. I.e. we discard now-obsolete property updates etc. Change-Id: I8f3ae16ed6c1f6a89b644acdce7efbf0f07fc786 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Use QStringLiteral here.Milian Wolff2013-11-011-1/+1
| | | | | Change-Id: Idd32243173775ec49b4a51a55faa85e47e11a4f1 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Optimize: If no callback is given, send data directly without execId.Milian Wolff2013-11-011-0/+5
| | | | | Change-Id: I47345fc52677b68ae75d018484b495fc81949054 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Add debug method to webchannel.Milian Wolff2013-11-011-1/+6
| | | | | Change-Id: Id4400b63f0bd5180194523f1efbac8b82c4dbe91 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Optimize: Share more byte array literals.Milian Wolff2013-11-011-7/+9
| | | | | Change-Id: Id7b35aab5012e1eba84fb3685b3bc6619aa92580 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Optimize: create the web socket header only once.Milian Wolff2013-11-012-11/+13
| | | | | | | | For channels with multiple clients we used to create it once for every client which is not needed. Change-Id: Ib1be0c9f7bc78c0415fe2e9f6f8aa5112d0156c6 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Allow IP's in base url.Milian Wolff2013-11-013-3/+3
| | | | | Change-Id: I2e20aa13a598e65eafa9b9c145931a95e5f51a0e Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Fix wrapping of execIdThomas McGuire2013-11-011-1/+1
| | | | | Change-Id: I18a596c18530b18a833a58e734ce484caa6ae68f Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Make it possible to connect multiple WebChannels to the same server.Milian Wolff2013-11-011-3/+12
| | | | | | | | | | | In principle everything worked before already, with the difference that responses to channel.exec could not properly be distinguished. This is now fixed by adding a UUID to the WebChannel and sending that along with the integer exec ID and comparing it in response messages. Change-Id: I954716b04c1d9a41fffb8b9bb736a1fa45fec7f2 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Use 127.0.0.1. instead of localhost.Milian Wolff2013-11-011-1/+1
| | | | | Change-Id: I5948de7edff3aa8a58c9cc6e3789c4e7fffb7260 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Gracefully handle requests/responses without data.Milian Wolff2013-11-012-2/+2
| | | | | Change-Id: I269ded913b25bb3d3869f2da85ce0ff7449b534b Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Add support for websocket ping/pongs.Milian Wolff2013-11-015-2/+16
| | | | | Change-Id: Id825cc0095398d72922700fa5c0d4f30cf19353c Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Add support for Q_ENUMS access via the web channel.Milian Wolff2013-11-012-0/+14
| | | | | | | | Enums that are marked by Q_ENUMS in a Q_OBJECT or Q_GADGET are thus accessible in JavaScript via obj.EnumName.EnumKey. Change-Id: Ia3e92da9bc05e06011f250ec8f5cf6ac26a3b0f4 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Validate the QWebChannel secret and use the QWebChannel protocol.Milian Wolff2013-11-014-26/+40
| | | | | Change-Id: Idafda1326de072f9fa1853cb54cb0de459186bb1 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Properly support void-returning method invocationsMilian Wolff2013-11-011-1/+4
| | | | | Change-Id: Ic0d9f536eee4e328fb4456fce7b84019dd7ff744 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Refactor QWebChannel to use a custom WebSocket server implementation.Milian Wolff2013-11-0121-703/+934
| | | | | | | | | | | | | | | The code is much simpler in my opinion and much faster and far more stable. Especially the timer issues or multiple signal connects are now properly resolved. Also simplify the QML WebChannel API: - Rename slot to sendRawMessage and signal to rawMessageReceived - Add a QML helper that has a respond and sendMessage method that transforms the input to the expected JSON format. Change-Id: Ic3266329d1a2877bd46227e4ad70b88dc340d289 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Make it possible to build everything in one goMilian Wolff2013-11-014-2/+18
| | | | | | | Disable installation of examples Change-Id: I85092b0a22da871fdf02f197d0b85e7dc33243bc Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Be more forgiving in bad API usage, show proper error messages.Milian Wolff2013-11-012-1/+14
| | | | | Change-Id: I7eeedea7666268a42db3c31c52255f12026e3fa3 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Minor cleanupMilian Wolff2013-11-011-2/+2
| | | | | Change-Id: Iffc3278fd63620837fdc319bcebd4031a3901890 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Add a callback for when the QObject integration is setup.Milian Wolff2013-11-012-8/+12
| | | | | | | | This shows an issue with consecutive signal connections due to some error in the socket communication. WebSockets should resolve this. Change-Id: I091d70e5e7498abdcc449eeca8dfe171d1ce0287 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Fix method invocation and signal submission with multiple arguments.Milian Wolff2013-11-015-23/+53
| | | | | Change-Id: I52a3fc53ba0c76489ffdc0634cfaff5b1c1e02a4 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Simplify code by doing more in QML and less in C++Milian Wolff2013-11-013-55/+43
| | | | | Change-Id: I4f4f101b40b3f509371819100ad70d2b2a5731f4 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Remove dead codeMilian Wolff2013-11-011-3/+0
| | | | | Change-Id: I4bde0ed21e61009f7ac021b6539b2999e9fb14a8 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Silence RemoteHostCloseError.Milian Wolff2013-11-011-1/+5
| | | | | | | This can happen when one changes the webview URL e.g. Change-Id: I24bf4b541e25d84c2e2698c9eaf4807141a775ee Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Ensure proper signal connection and property binding.Milian Wolff2013-11-014-15/+36
| | | | | | | | | When multiple signals or properties exist we must not fall into the usual javascript closure trap - we used to only use the very last signal/property of every object... Change-Id: Ief24630cc4b4ce3935207a170711f66c3ef5d805 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Show error message when webchannel XHR failed and reschedule polling.Milian Wolff2013-11-011-1/+11
| | | | | | | | This makes it somewhat safer but is still error prone. I think we need a proper WebSocket to make it really reliable. Change-Id: I7a7f6305e026b3d75d906c948233a6bf210ed886 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Output TCP server and socket errors.Milian Wolff2013-11-011-0/+14
| | | | | Change-Id: I6ec18a1fd04d9b79f8bfbcb67bb49fc0959f54c5 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Also add content-length to QWebChannelResponder to make it stabler.Milian Wolff2013-11-012-12/+17
| | | | | | | | | | | | | Still, one can trigger XMLHttpRequest errors occasionally e.g.: POST http://localhost:49158/6e933d76-843e-4b01-b273-fc36b0480ab1/POLL Unknown error This will then render the whole QObject bridge useless - I will investigate. Change-Id: Ifb7343414dac82e9af0a30ac008c3940283b1ecd Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Add assertion.Milian Wolff2013-11-011-0/+1
| | | | | Change-Id: Idc1fcbc4e68e68ace751caa41fa58bdffddc2890 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Send a proper Content-Length header for broadcasts.Milian Wolff2013-11-011-2/+4
| | | | | | | | | This is especially required for bigger response bodies, as can happen now for multiple connections. Otherwise the XHR will fail intermittently. Change-Id: Iaac0fc6abda9e0e549acdda8f7e368d88ab17582 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Add warnings if something went wrong in the responder.Milian Wolff2013-11-011-3/+9
| | | | | Change-Id: I498660cac248fa94aa5a25b594f19f925a68adb6 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Dismiss response explicitly if we do not return anythingMilian Wolff2013-11-011-0/+2
| | | | | Change-Id: I108f10584d5cefbfef1ee9981eeb98c43b812391 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>