summaryrefslogtreecommitdiff
path: root/src/webchannel/qwebchannel.h
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2013-12-28 19:20:58 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-08 15:59:28 +0100
commit66c0d916131c1e9e896705971f20385c75e753a2 (patch)
tree59b25cd7b9bc1ff688ff46c2b4f4c21fa60019cf /src/webchannel/qwebchannel.h
parent318576f0cc0ebef78c5b27106b1a8429eb54fac8 (diff)
downloadqtwebchannel-66c0d916131c1e9e896705971f20385c75e753a2.tar.gz
Simplify usage of QWebChannel on the server side.
This is achieved by hiding the MetaObjectPublisher completely as private API. The QWebChannel is the only publisher API and now handles both the socket as well as the publisher internally. This now allows us to create a proper QML api in the new QmlWebChannel. Change-Id: I3096364af8485353ca9bc19df4a81a8e4552c3d7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/webchannel/qwebchannel.h')
-rw-r--r--src/webchannel/qwebchannel.h35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/webchannel/qwebchannel.h b/src/webchannel/qwebchannel.h
index 321706e..ec62208 100644
--- a/src/webchannel/qwebchannel.h
+++ b/src/webchannel/qwebchannel.h
@@ -56,16 +56,43 @@ class Q_WEBCHANNEL_EXPORT QWebChannel : public QObject
Q_DISABLE_COPY(QWebChannel)
Q_PROPERTY(QString baseUrl READ baseUrl NOTIFY baseUrlChanged)
Q_PROPERTY(bool useSecret READ useSecret WRITE setUseSecret)
+ Q_PROPERTY(bool blockUpdates READ blockUpdates WRITE setBlockUpdates NOTIFY blockUpdatesChanged);
public:
QWebChannel(QObject *parent = 0);
~QWebChannel();
- QString baseUrl() const;
+ QString baseUrl() const;
void setUseSecret(bool);
bool useSecret() const;
+ /**
+ * Register a map of string ID to QObject* objects.
+ *
+ * The properties, signals and public methods of the QObject are
+ * published to the remote client, where an object with the given identifier
+ * is constructed.
+ *
+ * TODO: This must be called, before clients are initialized.
+ */
+ void registerObjects(const QHash<QString, QObject*> &objects);
+ void registerObject(const QString &id, QObject *object);
+
+ /**
+ * @return true when property updates are blocked, false otherwise.
+ */
+ bool blockUpdates() const;
+
+ /**
+ * Set whether property updates should be blocked or not.
+ *
+ * When they are blocked, the remote clients will not be notified about
+ * property changes. The changes are recorded and sent to the clients once
+ * setBlockUpdates(false) is called.
+ */
+ void setBlockUpdates(bool block);
+
signals:
void baseUrlChanged(const QString& baseUrl);
void rawMessageReceived(const QString& rawMessage);
@@ -74,6 +101,8 @@ signals:
void failed(const QString& reason);
+ void blockUpdatesChanged(bool block);
+
public slots:
void sendMessage(const QJsonValue& id, const QJsonValue& data = QJsonValue()) const;
void respond(const QJsonValue& messageId, const QJsonValue& data = QJsonValue()) const;
@@ -84,7 +113,9 @@ private slots:
void onInitialized();
private:
- QWebChannelPrivate* d;
+ QScopedPointer<QWebChannelPrivate> d;
+ friend class QmlWebChannel;
+ friend class TestWebChannel;
};
#endif // QWEBCHANNEL_H