/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel Project *
+ * Copyright (C) 2005-09 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include <QByteArray>
#include <QTimer>
-class SignalRelay;
class SyncableObject;
struct QMetaObject;
class IODevicePeer;
class SignalProxyPeer;
+ class SignalRelay;
+
public:
enum ProxyMode {
Server,
void synchronize(SyncableObject *obj);
-// void setInitialized(SyncableObject *obj);
-// bool isInitialized(SyncableObject *obj) const;
- void detachObject(QObject *obj);
- void detachSignals(QObject *sender);
- void detachSlots(QObject *receiver);
- void stopSync(SyncableObject *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
static bool readDataFromDevice(QIODevice *dev, quint32 &blockSize, QVariant &item, bool compressed = false);
class ExtendedMetaObject;
- ExtendedMetaObject *extendedMetaObject(const QObject *obj) const;
- void createExtendedMetaObject(const QObject *obj);
+ ExtendedMetaObject *extendedMetaObject(const QMetaObject *meta) const;
+ ExtendedMetaObject *createExtendedMetaObject(const QMetaObject *meta);
+ inline ExtendedMetaObject *extendedMetaObject(const QObject *obj) const { return extendedMetaObject(metaObject(obj)); }
+ inline ExtendedMetaObject *createExtendedMetaObject(const QObject *obj) { return createExtendedMetaObject(metaObject(obj)); }
bool isSecure() const { return _secure; }
void dumpProxyStats();
+public slots:
+ void detachObject(QObject *obj);
+ void detachSignals(QObject *sender);
+ void detachSlots(QObject *receiver);
+ void stopSync(QObject *obj);
+
protected:
void customEvent(QEvent *event);
+ void syncCall(const SyncableObject *obj, ProxyMode modeType, const char *funcname, va_list ap);
private slots:
void dataAvailable();
- void detachSender();
void removePeerBySender();
void objectRenamed(const QString &newname, const QString &oldname);
void objectRenamed(const QByteArray &classname, const QString &newname, const QString &oldname);
// containg a list of argtypes for fast access
QHash<const QMetaObject *, ExtendedMetaObject *> _extendedMetaObjects;
- // we use one SignalRelay per QObject
- QHash<QObject*, SignalRelay *> _relayHash;
+ // SignalRelay for all manually attached signals
+ SignalRelay *_signalRelay;
// RPC function -> (object, slot ID)
typedef QPair<QObject*, int> MethodId;
bool _secure; // determines if all connections are in a secured state (using ssl or internal connections)
friend class SignalRelay;
+ friend class SyncableObject;
};
// ExtendedMetaObject
// ==================================================
class SignalProxy::ExtendedMetaObject {
+ class MethodDescriptor {
+ public:
+ MethodDescriptor(const QMetaMethod &method);
+ MethodDescriptor() : _returnType(-1), _minArgCount(-1) {}
+
+ inline const QByteArray &methodName() const { return _methodName; }
+ inline const QList<int> &argTypes() const { return _argTypes; }
+ inline int returnType() const { return _returnType; }
+ inline int minArgCount() const { return _minArgCount; }
+
+ private:
+ QByteArray _methodName;
+ QList<int> _argTypes;
+ int _returnType;
+ int _minArgCount;
+ };
+
public:
ExtendedMetaObject(const QMetaObject *meta);
- const QList<int> &argTypes(int methodId);
- const int &returnType(int methodId);
- const int &minArgCount(int methodId);
- const QByteArray &methodName(int methodId);
+ inline const QByteArray &methodName(int methodId) { return methodDescriptor(methodId).methodName(); }
+ inline const QList<int> &argTypes(int methodId) { return methodDescriptor(methodId).argTypes(); }
+ inline int returnType(int methodId) { return methodDescriptor(methodId).returnType(); }
+ inline int minArgCount(int methodId) { return methodDescriptor(methodId).minArgCount(); }
+
+ inline int updatedRemotelyId() { return _updatedRemotelyId; }
+
+ int methodId(const QByteArray &methodName);
const QHash<QByteArray, int> &syncMap();
const QHash<int, int> &receiveMap();
- int updatedRemotelyId();
+
+ const QMetaObject *metaObject() const { return _meta; }
static QByteArray methodName(const QMetaMethod &method);
static bool methodsMatch(const QMetaMethod &signal, const QMetaMethod &slot);
static QString methodBaseName(const QMetaMethod &method);
private:
- typedef QHash<int, QList<int> > ArgHash;
- typedef QHash<int, QByteArray> MethodNameHash;
+ const MethodDescriptor &methodDescriptor(int methodId);
const QMetaObject *_meta;
- ArgHash _argTypes;
- QHash<int, int> _returnType;
- QHash<int, int> _minArgCount;
- MethodNameHash _methodNames;
+ QHash<int, MethodDescriptor> _methods;
+ QHash<QByteArray, int> _methodIds;
+
int _updatedRemotelyId; // id of the updatedRemotely() signal - makes things faster
+
QHash<QByteArray, int> _syncMap;
QHash<int, int> _receiveMap;
};