diff options
-rw-r--r-- | examples/hybridshell/index.html | 4 | ||||
-rw-r--r-- | examples/qmlapp/index.html | 4 | ||||
-rw-r--r-- | examples/qtobject/index.html | 9 | ||||
-rw-r--r-- | examples/standalone/index.html | 34 | ||||
-rw-r--r-- | src/webchannel/qwebchannel.js (renamed from src/webchannel/qobject.js) | 211 | ||||
-rw-r--r-- | src/webchannel/resources.qrc | 3 | ||||
-rw-r--r-- | src/webchannel/webchannel.js | 129 | ||||
-rw-r--r-- | src/webchannel/webchannel.pro | 3 | ||||
-rw-r--r-- | tests/qml/data/bench_init.html | 7 | ||||
-rw-r--r-- | tests/qml/data/disconnect.html | 17 | ||||
-rw-r--r-- | tests/qml/data/grouping.html | 9 | ||||
-rw-r--r-- | tests/qml/data/method.html | 9 | ||||
-rw-r--r-- | tests/qml/data/property.html | 17 | ||||
-rw-r--r-- | tests/qml/data/receiveRaw.html | 4 | ||||
-rw-r--r-- | tests/qml/data/respond.html | 4 | ||||
-rw-r--r-- | tests/qml/data/send.html | 4 | ||||
-rw-r--r-- | tests/qml/data/signal.html | 9 | ||||
-rw-r--r-- | tests/qml/data/wrapper.html | 29 |
18 files changed, 218 insertions, 288 deletions
diff --git a/examples/hybridshell/index.html b/examples/hybridshell/index.html index 23a765c..91c447a 100644 --- a/examples/hybridshell/index.html +++ b/examples/hybridshell/index.html @@ -37,7 +37,7 @@ background-image: -webkit-linear-gradient(left,#eeeeee, #cccccc) } </style> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> function out(line) { @@ -69,7 +69,7 @@ window.navigator.webChannel = webChannel; out("Ready"); webChannel.subscribe("stdout", out); - }); + }, true); } </script> </head> diff --git a/examples/qmlapp/index.html b/examples/qmlapp/index.html index 6601fa2..b3b8bb1 100644 --- a/examples/qmlapp/index.html +++ b/examples/qmlapp/index.html @@ -1,7 +1,7 @@ <!DOCTYPE html> <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> function output(x) { @@ -25,7 +25,7 @@ ); }; window.send(); - }); + }, true); }; </script> </head> diff --git a/examples/qtobject/index.html b/examples/qtobject/index.html index af2b940..4987116 100644 --- a/examples/qtobject/index.html +++ b/examples/qtobject/index.html @@ -1,7 +1,6 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> - <script type="text/javascript" src="qrc:///qwebchannel/qobject.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN HELPER function output(x) { @@ -70,10 +69,8 @@ //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); new QWebChannel(baseUrl, function(channel) { - setupQObjectWebChannel(channel, function() { - // do stuff with registered QObjects - addObject(initialTestObject); - }); + // do stuff with registered QObjects + addObject(initialTestObject); }); //END SETUP </script> diff --git a/examples/standalone/index.html b/examples/standalone/index.html index 5efee77..a1aa3e4 100644 --- a/examples/standalone/index.html +++ b/examples/standalone/index.html @@ -2,34 +2,28 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <script type="text/javascript" src="../../src/webchannel/webchannel.js"></script> - <script type="text/javascript" src="../../src/webchannel/qobject.js"></script> + <script type="text/javascript" src="../../src/webchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); new QWebChannel(baseUrl, function(channel) { - setupQObjectWebChannel(channel, function() { - document.getElementById("send").onclick = function() { - var input = document.getElementById("input"); - var text = input.value; - if (!text) { - return; - } - var output = document.getElementById("output"); - output.innerHTML = output.innerHTML + "Send message: " + text + "\n"; - input.value = ""; - dialog.receiveText(text); + document.getElementById("send").onclick = function() { + var input = document.getElementById("input"); + var text = input.value; + if (!text) { + return; } + var output = document.getElementById("output"); + output.innerHTML = output.innerHTML + "Send message: " + text + "\n"; + input.value = ""; + dialog.receiveText(text); + } - dialog.sendText.connect(function(text) { - var output = document.getElementById("output"); - output.innerHTML = output.innerHTML + "Received message: " + text + "\n"; - }); + dialog.sendText.connect(function(text) { + var output = document.getElementById("output"); + output.innerHTML = output.innerHTML + "Received message: " + text + "\n"; }); }); - - window.onload = function() { - } //END SETUP </script> <style type="text/css"> diff --git a/src/webchannel/qobject.js b/src/webchannel/qwebchannel.js index 5fae44c..fe3c650 100644 --- a/src/webchannel/qobject.js +++ b/src/webchannel/qwebchannel.js @@ -42,6 +42,157 @@ "use strict"; +var QWebChannel = function(baseUrl, initCallback, rawChannel) +{ + var channel = this; + // support multiple channels listening to the same socket + // the responses to channel.exec must be distinguishable + // see: http://stackoverflow.com/a/2117523/35250 + this.id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); + ///TODO: use ssl? + var socketUrl = "ws://" + baseUrl; + this.socket = new WebSocket(socketUrl, "QWebChannel"); + this.send = function(data) + { + if (typeof(data) !== "string") { + data = JSON.stringify(data); + } + channel.socket.send(data); + }; + + this.socket.onopen = function() + { + if (rawChannel) { + initCallback(channel); + } else { + channel.initMetaObjectPublisher(initCallback); + } + }; + this.socket.onclose = function() + { + console.error("web channel closed"); + }; + this.socket.onerror = function(error) + { + console.error("web channel error: " + error); + }; + this.socket.onmessage = function(message) + { + var jsonData = JSON.parse(message.data); + if (jsonData.id === undefined) { + console.error("invalid message received:", message.data); + return; + } + if (jsonData.data === undefined) { + jsonData.data = {}; + } + if (jsonData.response) { + if (jsonData.id[0] === channel.id) { + channel.execCallbacks[jsonData.id[1]](jsonData.data); + delete channel.execCallbacks[jsonData.id]; + } + } else if (channel.subscriptions[jsonData.id]) { + channel.subscriptions[jsonData.id].forEach(function(callback) { + (callback)(jsonData.data); } + ); + } + }; + + this.subscriptions = {}; + this.subscribe = function(id, callback) + { + if (channel.subscriptions[id]) { + channel.subscriptions[id].push(callback); + } else { + channel.subscriptions[id] = [callback]; + } + }; + + this.execCallbacks = {}; + this.execId = 0; + this.exec = function(data, callback) + { + if (!callback) { + // if no callback is given, send directly + channel.send({data: data}); + return; + } + if (channel.execId === Number.MAX_VALUE) { + // wrap + channel.execId = Number.MIN_VALUE; + } + var id = channel.execId++; + channel.execCallbacks[id] = callback; + channel.send({"id": [channel.id, id], "data": data}); + }; + + this.objectMap = {}; + + this.initMetaObjectPublisher = function(doneCallback) + { + // prevent multiple initialization which might happen with multiple webchannel clients. + var initialized = false; + + console.log(channel); + channel.subscribe( + "Qt.signal", + function(payload) { + var object = window[payload.object] || channel.objectMap[payload.object]; + if (object) { + object.signalEmitted(payload.signal, payload.args); + } else { + console.warn("Unhandled signal: " + payload.object + "::" + payload.signal); + } + } + ); + + channel.subscribe( + "Qt.propertyUpdate", + function(payload) { + for (var i in payload) { + var data = payload[i]; + var object = window[data.object] || channel.objectMap[data.object]; + if (object) { + object.propertyUpdate(data.signals, data.properties); + } else { + console.warn("Unhandled property update: " + data.object + "::" + data.signal); + } + } + setTimeout(function() { channel.exec({type: "Qt.idle"}); }, 0); + } + ); + + channel.subscribe( + "Qt.init", + function(payload) { + if (initialized) { + return; + } + initialized = true; + for (var objectName in payload) { + var data = payload[objectName]; + var object = new QObject(objectName, data, channel); + window[objectName] = object; + } + if (doneCallback) { + doneCallback(channel); + } + setTimeout(function() { channel.exec({type: "Qt.idle"}); }, 0); + } + ); + + channel.debug = function(message) + { + channel.send({"data" : {"type" : "Qt.Debug", "message" : message}}); + }; + + channel.exec({type:"Qt.init"}); + } +}; + function QObject(name, data, webChannel) { this.__id__ = name; @@ -244,63 +395,3 @@ function QObject(name, data, webChannel) object[name] = data.enums[name]; } } - -window.setupQObjectWebChannel = function(webChannel, doneCallback) -{ - // prevent multiple initialization which might happen with multiple webchannel clients. - var initialized = false; - - webChannel.subscribe( - "Qt.signal", - function(payload) { - var object = window[payload.object] || webChannel.objectMap[payload.object]; - if (object) { - object.signalEmitted(payload.signal, payload.args); - } else { - console.warn("Unhandled signal: " + payload.object + "::" + payload.signal); - } - } - ); - - webChannel.subscribe( - "Qt.propertyUpdate", - function(payload) { - for (var i in payload) { - var data = payload[i]; - var object = window[data.object] || webChannel.objectMap[data.object]; - if (object) { - object.propertyUpdate(data.signals, data.properties); - } else { - console.warn("Unhandled property update: " + data.object + "::" + data.signal); - } - } - setTimeout(function() { webChannel.exec({type: "Qt.idle"}); }, 0); - } - ); - - webChannel.subscribe( - "Qt.init", - function(payload) { - if (initialized) { - return; - } - initialized = true; - for (var objectName in payload) { - var data = payload[objectName]; - var object = new QObject(objectName, data, webChannel); - window[objectName] = object; - } - if (doneCallback) { - doneCallback(); - } - setTimeout(function() { webChannel.exec({type: "Qt.idle"}); }, 0); - } - ); - - webChannel.exec({type:"Qt.init"}); - - webChannel.debug = function(message) - { - webChannel.send({"data" : {"type" : "Qt.Debug", "message" : message}}); - }; -}; diff --git a/src/webchannel/resources.qrc b/src/webchannel/resources.qrc index 821e911..30a3e96 100644 --- a/src/webchannel/resources.qrc +++ b/src/webchannel/resources.qrc @@ -1,6 +1,5 @@ <RCC> <qresource prefix="/qwebchannel/"> - <file>webchannel.js</file> - <file>qobject.js</file> + <file>qwebchannel.js</file> </qresource> </RCC> diff --git a/src/webchannel/webchannel.js b/src/webchannel/webchannel.js deleted file mode 100644 index 8827cbf..0000000 --- a/src/webchannel/webchannel.js +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com> -** Contact: http://www.qt-project.org/legal -* -** This file is part of the QtWebChannel module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -"use strict"; - -var QWebChannel = function(baseUrl, initCallback) -{ - var channel = this; - // support multiple channels listening to the same socket - // the responses to channel.exec must be distinguishable - // see: http://stackoverflow.com/a/2117523/35250 - this.id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); - return v.toString(16); - }); - ///TODO: use ssl? - var socketUrl = "ws://" + baseUrl; - this.socket = new WebSocket(socketUrl, "QWebChannel"); - this.send = function(data) - { - if (typeof(data) !== "string") { - data = JSON.stringify(data); - } - channel.socket.send(data); - }; - - this.socket.onopen = function() - { - initCallback(channel); - }; - this.socket.onclose = function() - { - console.error("web channel closed"); - }; - this.socket.onerror = function(error) - { - console.error("web channel error: " + error); - }; - this.socket.onmessage = function(message) - { - var jsonData = JSON.parse(message.data); - if (jsonData.id === undefined) { - console.error("invalid message received:", message.data); - return; - } - if (jsonData.data === undefined) { - jsonData.data = {}; - } - if (jsonData.response) { - if (jsonData.id[0] === channel.id) { - channel.execCallbacks[jsonData.id[1]](jsonData.data); - delete channel.execCallbacks[jsonData.id]; - } - } else if (channel.subscriptions[jsonData.id]) { - channel.subscriptions[jsonData.id].forEach(function(callback) { - (callback)(jsonData.data); } - ); - } - }; - - this.subscriptions = {}; - this.subscribe = function(id, callback) - { - if (channel.subscriptions[id]) { - channel.subscriptions[id].push(callback); - } else { - channel.subscriptions[id] = [callback]; - } - }; - - this.execCallbacks = {}; - this.execId = 0; - this.exec = function(data, callback) - { - if (!callback) { - // if no callback is given, send directly - channel.send({data: data}); - return; - } - if (channel.execId === Number.MAX_VALUE) { - // wrap - channel.execId = Number.MIN_VALUE; - } - var id = channel.execId++; - channel.execCallbacks[id] = callback; - channel.send({"id": [channel.id, id], "data": data}); - }; - - this.objectMap = {}; -}; diff --git a/src/webchannel/webchannel.pro b/src/webchannel/webchannel.pro index a0041bf..376711d 100644 --- a/src/webchannel/webchannel.pro +++ b/src/webchannel/webchannel.pro @@ -8,8 +8,7 @@ RESOURCES += \ resources.qrc OTHER_FILES = \ - webchannel.js \ - qobject.js + qwebchannel.js PUBLIC_HEADERS += \ qwebchannel.h \ diff --git a/tests/qml/data/bench_init.html b/tests/qml/data/bench_init.html index ef18650..cb1b488 100644 --- a/tests/qml/data/bench_init.html +++ b/tests/qml/data/bench_init.html @@ -1,13 +1,10 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> - <script type="text/javascript" src="qrc:///qwebchannel/qobject.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) { - setupQObjectWebChannel(channel, function() {}); - }); + new QWebChannel(baseUrl, function(channel) {}); //END SETUP </script> </head> diff --git a/tests/qml/data/disconnect.html b/tests/qml/data/disconnect.html index f4cbb0a..dc771b9 100644 --- a/tests/qml/data/disconnect.html +++ b/tests/qml/data/disconnect.html @@ -1,19 +1,16 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> - <script type="text/javascript" src="qrc:///qwebchannel/qobject.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); new QWebChannel(baseUrl, function(channel) { - setupQObjectWebChannel(channel, function() { - myObj.mySignal.connect(function(arg) { - channel.exec({label: "mySignalReceived", args: [arg]}); - myObj.mySignal.disconnect(this); - }); - channel.subscribe("report", function() { - channel.exec({label: "report"}); - }); + myObj.mySignal.connect(function(arg) { + channel.exec({label: "mySignalReceived", args: [arg]}); + myObj.mySignal.disconnect(this); + }); + channel.subscribe("report", function() { + channel.exec({label: "report"}); }); }); //END SETUP diff --git a/tests/qml/data/grouping.html b/tests/qml/data/grouping.html index bb804f4..2a6c158 100644 --- a/tests/qml/data/grouping.html +++ b/tests/qml/data/grouping.html @@ -1,15 +1,12 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> - <script type="text/javascript" src="qrc:///qwebchannel/qobject.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); window.channel = new QWebChannel(baseUrl, function(channel) { - setupQObjectWebChannel(channel, function() { - channel.subscribe("Qt.propertyUpdate", function() { - channel.exec({label: "gotPropertyUpdate", values: [myObj.myProperty(), myOtherObj.foo(), myOtherObj.bar()]}); - }); + channel.subscribe("Qt.propertyUpdate", function() { + channel.exec({label: "gotPropertyUpdate", values: [myObj.myProperty(), myOtherObj.foo(), myOtherObj.bar()]}); }); }); //END SETUP diff --git a/tests/qml/data/method.html b/tests/qml/data/method.html index 618550f..04048a6 100644 --- a/tests/qml/data/method.html +++ b/tests/qml/data/method.html @@ -1,15 +1,12 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> - <script type="text/javascript" src="qrc:///qwebchannel/qobject.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); new QWebChannel(baseUrl, function(channel) { - setupQObjectWebChannel(channel, function() { - channel.subscribe("invokeMethod", function(arg) { - myObj.myMethod(arg); - }); + channel.subscribe("invokeMethod", function(arg) { + myObj.myMethod(arg); }); }); //END SETUP diff --git a/tests/qml/data/property.html b/tests/qml/data/property.html index 1a8360a..5d03118 100644 --- a/tests/qml/data/property.html +++ b/tests/qml/data/property.html @@ -1,19 +1,16 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> - <script type="text/javascript" src="qrc:///qwebchannel/qobject.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); new QWebChannel(baseUrl, function(channel) { - setupQObjectWebChannel(channel, function() { - channel.exec({label: "init", value: myObj.myProperty()}); - myObj.myPropertyChanged.connect(function() { - channel.exec({label: "changed", value: myObj.myProperty()}); - }); - channel.subscribe("setProperty", function(newValue) { - myObj.myProperty = newValue; - }); + channel.exec({label: "init", value: myObj.myProperty()}); + myObj.myPropertyChanged.connect(function() { + channel.exec({label: "changed", value: myObj.myProperty()}); + }); + channel.subscribe("setProperty", function(newValue) { + myObj.myProperty = newValue; }); }); //END SETUP diff --git a/tests/qml/data/receiveRaw.html b/tests/qml/data/receiveRaw.html index cfe685e..7c98bab 100644 --- a/tests/qml/data/receiveRaw.html +++ b/tests/qml/data/receiveRaw.html @@ -1,12 +1,12 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); new QWebChannel(baseUrl, function(channel) { channel.send("foobar"); - }); + }, true); //END SETUP </script> </head> diff --git a/tests/qml/data/respond.html b/tests/qml/data/respond.html index 29e47b8..6c8db0d 100644 --- a/tests/qml/data/respond.html +++ b/tests/qml/data/respond.html @@ -1,6 +1,6 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); @@ -8,7 +8,7 @@ channel.exec("foobar", function(response) { channel.send("received:"+response); }); - }); + }, true); //END SETUP </script> </head> diff --git a/tests/qml/data/send.html b/tests/qml/data/send.html index f30e9c8..7d601a8 100644 --- a/tests/qml/data/send.html +++ b/tests/qml/data/send.html @@ -1,6 +1,6 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); @@ -8,7 +8,7 @@ channel.subscribe("myMessage", function(payload) { channel.send("myMessagePong:" + payload); }); - }); + }, true); //END SETUP </script> </head> diff --git a/tests/qml/data/signal.html b/tests/qml/data/signal.html index e3815cb..92b0ed5 100644 --- a/tests/qml/data/signal.html +++ b/tests/qml/data/signal.html @@ -1,15 +1,12 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> - <script type="text/javascript" src="qrc:///qwebchannel/qobject.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); new QWebChannel(baseUrl, function(channel) { - setupQObjectWebChannel(channel, function() { - myObj.mySignal.connect(function(arg) { - channel.exec({label: "signalReceived", value: arg}); - }); + myObj.mySignal.connect(function(arg) { + channel.exec({label: "signalReceived", value: arg}); }); }); //END SETUP diff --git a/tests/qml/data/wrapper.html b/tests/qml/data/wrapper.html index 54f456b..9c4386c 100644 --- a/tests/qml/data/wrapper.html +++ b/tests/qml/data/wrapper.html @@ -1,26 +1,23 @@ <html> <head> - <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> - <script type="text/javascript" src="qrc:///qwebchannel/qobject.js"></script> + <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); new QWebChannel(baseUrl, function(channel) { - setupQObjectWebChannel(channel, function() { - myFactory.create("testObj", function(obj) { - window[obj.objectName()] = obj; - obj.mySignal.connect(function(arg1, arg2) { - channel.exec({label: "signalReceived", args: [arg1, arg2]}); - }); - obj.myProperty = 42; - obj.myMethod("foobar"); - }); - channel.subscribe("triggerDelete", function() { - testObj.deleteLater(); - }); - channel.subscribe("report", function() { - channel.exec({label:"report", obj: testObj}) + myFactory.create("testObj", function(obj) { + window[obj.objectName()] = obj; + obj.mySignal.connect(function(arg1, arg2) { + channel.exec({label: "signalReceived", args: [arg1, arg2]}); }); + obj.myProperty = 42; + obj.myMethod("foobar"); + }); + channel.subscribe("triggerDelete", function() { + testObj.deleteLater(); + }); + channel.subscribe("report", function() { + channel.exec({label:"report", obj: testObj}) }); }); //END SETUP |