Qt 4.8
Classes | Public Types | Public Functions | Public Variables | Protected Functions | List of all members
QDBusAdaptorConnector Class Reference

#include <qdbusabstractadaptor_p.h>

Inheritance diagram for QDBusAdaptorConnector:
QObject

Classes

struct  AdaptorData
 

Public Types

typedef QVector< AdaptorDataAdaptorMap
 

Public Functions

void addAdaptor (QDBusAbstractAdaptor *adaptor)
 
void connectAllSignals (QObject *object)
 
void disconnectAllSignals (QObject *object)
 
void polish ()
 
 QDBusAdaptorConnector (QObject *parent)
 
void relay (QObject *sender, int id, void **)
 
void relaySlot (void **)
 
 ~QDBusAdaptorConnector ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Public Variables

AdaptorMap adaptors
 
bool waitingForPolish: 1
 

Protected Functions

void relaySignal (QObject *obj, const QMetaObject *metaObject, int sid, const QVariantList &args)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 91 of file qdbusabstractadaptor_p.h.

Typedefs

◆ AdaptorMap

Definition at line 108 of file qdbusabstractadaptor_p.h.

Constructors and Destructors

◆ QDBusAdaptorConnector()

QDBusAdaptorConnector::QDBusAdaptorConnector ( QObject parent)
explicit

Definition at line 198 of file qdbusabstractadaptor.cpp.

199  : QObject(obj), waitingForPolish(false)
200 {
201 }
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ ~QDBusAdaptorConnector()

QDBusAdaptorConnector::~QDBusAdaptorConnector ( )

Definition at line 203 of file qdbusabstractadaptor.cpp.

204 {
205 }

Functions

◆ addAdaptor()

void QDBusAdaptorConnector::addAdaptor ( QDBusAbstractAdaptor adaptor)

Definition at line 207 of file qdbusabstractadaptor.cpp.

Referenced by polish().

208 {
209  // find the interface name
210  const QMetaObject *mo = adaptor->metaObject();
212  if (ciid != -1) {
213  QMetaClassInfo mci = mo->classInfo(ciid);
214  if (*mci.value()) {
215  // find out if this interface exists first
216  const char *interface = mci.value();
218  QByteArray(interface));
219  if (it != adaptors.end() && qstrcmp(interface, it->interface) == 0) {
220  // exists. Replace it (though it's probably the same)
221  if (it->adaptor != adaptor) {
222  // reconnect the signals
223  disconnectAllSignals(it->adaptor);
224  connectAllSignals(adaptor);
225  }
226  it->adaptor = adaptor;
227  } else {
228  // create a new one
229  AdaptorData entry;
230  entry.interface = interface;
231  entry.adaptor = adaptor;
232  adaptors << entry;
233 
234  // connect the adaptor's signals to our relaySlot slot
235  connectAllSignals(adaptor);
236  }
237  }
238  }
239 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
#define it(className, varName)
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void disconnectAllSignals(QObject *object)
const char * value() const
Returns the value of this item.
iterator Iterator
Qt-style synonym for QVector::iterator.
Definition: qvector.h:278
void connectAllSignals(QObject *object)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:250
#define QCLASSINFO_DBUS_INTERFACE
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:227
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
Definition: qvector.h:247
The QMetaClassInfo class provides additional information about a class.
Definition: qmetaobject.h:224
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ connectAllSignals()

void QDBusAdaptorConnector::connectAllSignals ( QObject object)

Definition at line 246 of file qdbusabstractadaptor.cpp.

Referenced by addAdaptor(), and QDBusConnectionPrivate::registerObject().

247 {
248  QMetaObject::connect(obj, -1, this, metaObject()->methodOffset(), Qt::DirectConnection);
249 }
static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=0)
Definition: qobject.cpp:3194
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ disconnectAllSignals()

void QDBusAdaptorConnector::disconnectAllSignals ( QObject object)

Definition at line 241 of file qdbusabstractadaptor.cpp.

Referenced by addAdaptor(), and QDBusConnectionPrivate::registerObject().

242 {
243  QMetaObject::disconnect(obj, -1, this, metaObject()->methodOffset());
244 }
static bool disconnect(const QObject *sender, int signal_index, const QObject *receiver, int method_index)
Definition: qobject.cpp:3276
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ polish()

void QDBusAdaptorConnector::polish ( )

Definition at line 251 of file qdbusabstractadaptor.cpp.

Referenced by qDBusFindAdaptorConnector().

252 {
253  if (!waitingForPolish)
254  return; // avoid working multiple times if multiple adaptors were added
255 
256  waitingForPolish = false;
257  const QObjectList &objs = parent()->children();
260  for ( ; it != end; ++it) {
262  if (adaptor)
263  addAdaptor(adaptor);
264  }
265 
266  // sort the adaptor list
267  qSort(adaptors);
268 }
#define it(className, varName)
The QDBusAbstractAdaptor class is the base class of D-Bus adaptor classes.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void qSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:177
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Definition: qlist.h:279
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
static const KeyPair *const end
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
void addAdaptor(QDBusAbstractAdaptor *adaptor)

◆ relay()

void QDBusAdaptorConnector::relay ( QObject sender,
int  id,
void **  argv 
)

Definition at line 284 of file qdbusabstractadaptor.cpp.

Referenced by relaySlot().

285 {
286  if (lastSignalIdx < QObject::staticMetaObject.methodCount())
287  // QObject signal (destroyed(QObject *)) -- ignore
288  return;
289 
290  const QMetaObject *senderMetaObject = senderObj->metaObject();
291  QMetaMethod mm = senderMetaObject->method(lastSignalIdx);
292 
293  QObject *realObject = senderObj;
294  if (qobject_cast<QDBusAbstractAdaptor *>(senderObj))
295  // it's an adaptor, so the real object is in fact its parent
296  realObject = realObject->parent();
297 
298  // break down the parameter list
300  int inputCount = qDBusParametersForMethod(mm, types);
301  if (inputCount == -1)
302  // invalid signal signature
303  // qDBusParametersForMethod has already complained
304  return;
305  if (inputCount + 1 != types.count() ||
306  types.at(inputCount) == QDBusMetaTypeId::message) {
307  // invalid signal signature
308  // qDBusParametersForMethod has not yet complained about this one
309  qWarning("QDBusAbstractAdaptor: Cannot relay signal %s::%s",
310  senderMetaObject->className(), mm.signature());
311  return;
312  }
313 
314  QVariantList args;
315  for (int i = 1; i < types.count(); ++i)
316  args << QVariant(types.at(i), argv[i]);
317 
318  // now emit the signal with all the information
319  emit relaySignal(realObject, senderMetaObject, lastSignalIdx, args);
320 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
int qDBusParametersForMethod(const QMetaMethod &mm, QList< int > &metaTypes)
Definition: qdbusmisc.cpp:137
static int message
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
Q_CORE_EXPORT void qWarning(const char *,...)
static const struct @32 types[]
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
void relaySignal(QObject *obj, const QMetaObject *metaObject, int sid, const QVariantList &args)
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56

◆ relaySignal()

void QDBusAdaptorConnector::relaySignal ( QObject obj,
const QMetaObject metaObject,
int  sid,
const QVariantList args 
)
protected

Definition at line 387 of file qdbusabstractadaptor.cpp.

Referenced by relay().

388 {
389  void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)), const_cast<void*>(reinterpret_cast<const void*>(&_t3)), const_cast<void*>(reinterpret_cast<const void*>(&_t4)) };
391 }
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
static void activate(QObject *sender, int signal_index, void **argv)
Definition: qobject.cpp:3690

◆ relaySlot()

void QDBusAdaptorConnector::relaySlot ( void **  argv)

Definition at line 270 of file qdbusabstractadaptor.cpp.

271 {
272  QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr.data());
273  if (Q_LIKELY(d->currentSender)) {
275  } else {
276  qWarning("QtDBus: cannot relay signals from parent %s(%p \"%s\") unless they are emitted in the object's thread %s(%p \"%s\"). "
277  "Current thread is %s(%p \"%s\").",
281  }
282 }
double d
Definition: qnumeric_p.h:62
T * data() const
Returns the value of the pointer referenced by this object.
Sender * currentSender
Definition: qobject_p.h:200
const char * className
Definition: qwizard.cpp:137
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
Q_CORE_EXPORT void qWarning(const char *,...)
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QString objectName() const
#define Q_LIKELY(x)
Hints to the compiler that the enclosed condition, expr, is likely to evaluate to true...
Definition: qglobal.h:820
QScopedPointer< QObjectData > d_ptr
Definition: qobject.h:320
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419
void relay(QObject *sender, int id, void **)
#define qPrintable(string)
Definition: qglobal.h:1750
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

Properties

◆ adaptors

AdaptorMap QDBusAdaptorConnector::adaptors

◆ waitingForPolish

bool QDBusAdaptorConnector::waitingForPolish

Definition at line 129 of file qdbusabstractadaptor_p.h.

Referenced by polish(), and QDBusAbstractAdaptor::QDBusAbstractAdaptor().


The documentation for this class was generated from the following files: