+public:
+ enum ProxyMode {
+ Server,
+ Client
+ };
+
+ enum RequestType {
+ Sync = 0,
+ InitRequest,
+ InitData
+ };
+
+ SignalProxy(QObject *parent);
+ SignalProxy(ProxyMode mode, QObject *parent);
+ SignalProxy(ProxyMode mode, QIODevice *device, QObject *parent);
+ virtual ~SignalProxy();
+
+ void setProxyMode(ProxyMode mode);
+ ProxyMode proxyMode() const;
+
+ bool addPeer(QIODevice *iodev);
+ void removePeer(QIODevice *iodev = 0);
+
+ bool attachSignal(QObject *sender, const char *signal, const QByteArray& sigName = QByteArray());
+ bool attachSlot(const QByteArray& sigName, QObject *recv, const char *slot);
+
+ void synchronize(QObject *obj);
+ void synchronizeAsMaster(QObject *obj);
+ void synchronizeAsSlave(QObject *obj);
+
+ void setInitialized(QObject *obj);
+ bool initialized(QObject *obj);
+ void requestInit(QObject *obj);
+
+ void detachObject(QObject *obj);
+ void detachSignals(QObject *sender);
+ void detachSlots(QObject *receiver);
+ void stopSync(QObject *obj);
+
+ //! Writes a QVariant to a device.
+ /** The data item is prefixed with the resulting blocksize,
+ * so the corresponding function readDataFromDevice() can check if enough data is available
+ * at the device to reread the item.
+ */
+ static void writeDataToDevice(QIODevice *dev, const QVariant &item);
+
+ //! Reads a data item from a device that has been written by writeDataToDevice().
+ /** If not enough data bytes are available, the function returns false and the QVariant reference
+ * remains untouched.
+ */
+ static bool readDataFromDevice(QIODevice *dev, quint32 &blockSize, QVariant &item);
+
+ static QString methodBaseName(const QMetaMethod &method);
+
+ const QList<int> &argTypes(QObject *obj, int methodId);
+ const QByteArray &methodName(QObject *obj, int methodId);
+ const QHash<int, int> &syncMap(QObject *obj);
+
+ typedef QHash<int, QList<int> > ArgHash;
+ typedef QHash<int, QByteArray> MethodNameHash;
+ struct ClassInfo {
+ ArgHash argTypes;
+ MethodNameHash methodNames;
+ QHash<int, int> syncMap;
+ };
+
+ void dumpProxyStats();
+
+private slots:
+ void dataAvailable();
+ void detachSender();
+ void removePeerBySender();
+ void objectRenamed(QString oldname, QString newname);
+ void objectRenamed(QByteArray classname, QString oldname, QString newname);
+
+signals:
+ void peerRemoved(QIODevice *obj);
+ void connected();
+ void disconnected();