Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QDBusPendingCallPrivate Class Reference

#include <qdbuspendingcall_p.h>

Inheritance diagram for QDBusPendingCallPrivate:
QSharedData

Public Functions

void checkReceivedSignature ()
 
 QDBusPendingCallPrivate (const QDBusMessage &sent, QDBusConnectionPrivate *connection)
 
void setMetaTypes (int count, const int *types)
 
bool setReplyCallback (QObject *target, const char *member)
 
void waitForFinished ()
 
 ~QDBusPendingCallPrivate ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Static Public Functions

static QDBusPendingCall fromMessage (const QDBusMessage &msg)
 

Public Variables

QDBusConnectionPrivate *const connection
 
int expectedReplyCount
 
QString expectedReplySignature
 
QList< int > metaTypes
 
int methodIdx
 
QMutex mutex
 
DBusPendingCall * pending
 
QPointer< QObjectreceiver
 
QDBusMessage replyMessage
 
const QDBusMessage sentMessage
 
QWaitCondition waitForFinishedCondition
 
volatile bool waitingForFinished
 
QDBusPendingCallWatcherHelperwatcherHelper
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Definition at line 75 of file qdbuspendingcall_p.h.

Constructors and Destructors

◆ QDBusPendingCallPrivate()

QDBusPendingCallPrivate::QDBusPendingCallPrivate ( const QDBusMessage sent,
QDBusConnectionPrivate connection 
)
inline

Definition at line 104 of file qdbuspendingcall_p.h.

105  : sentMessage(sent), connection(connection), watcherHelper(0), pending(0), waitingForFinished(false)
106  { }
const QDBusMessage sentMessage
QDBusPendingCallWatcherHelper * watcherHelper
QDBusConnectionPrivate *const connection
DBusPendingCall * pending
volatile bool waitingForFinished

◆ ~QDBusPendingCallPrivate()

QDBusPendingCallPrivate::~QDBusPendingCallPrivate ( )

Definition at line 139 of file qdbuspendingcall.cpp.

Referenced by QDBusPendingCallPrivate().

140 {
141  if (pending) {
142  q_dbus_pending_call_cancel(pending);
143  q_dbus_pending_call_unref(pending);
144  }
145  delete watcherHelper;
146 }
QDBusPendingCallWatcherHelper * watcherHelper
DBusPendingCall * pending

Functions

◆ checkReceivedSignature()

void QDBusPendingCallPrivate::checkReceivedSignature ( )

Definition at line 220 of file qdbuspendingcall.cpp.

Referenced by QDBusConnectionPrivate::processFinishedCall(), QDBusPendingCallPrivate(), and QDBusPendingReplyData::setMetaTypes().

221 {
222  // MUST BE CALLED WITH A LOCKED MUTEX!
223 
225  return; // not yet finished - no message to
226  // validate against
228  return; // we don't have to check the signature of an error reply
229 
231  return; // no signature to validate against
232 
233  // can't use startsWith here because a null string doesn't start or end with an empty string
235  QString errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", "
236  "expected \"%2\"");
240 
241  }
242 }
static QDBusMessage createError(const QString &name, const QString &msg)
Constructs a new DBus message representing an error, with the given name and msg. ...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString signature() const
Returns the signature of the signal that was received or for the output arguments of a method call...
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
MessageType type() const
Returns the message type.

◆ fromMessage()

static QDBusPendingCall QDBusPendingCallPrivate::fromMessage ( const QDBusMessage msg)
static

Referenced by QDBusPendingCallPrivate().

◆ setMetaTypes()

void QDBusPendingCallPrivate::setMetaTypes ( int  count,
const int *  types 
)

Definition at line 198 of file qdbuspendingcall.cpp.

Referenced by QDBusPendingCallPrivate(), and QDBusPendingReplyData::setMetaTypes().

199 {
200  expectedReplyCount = count;
201  if (count == 0) {
202  expectedReplySignature = QLatin1String(""); // not null
203  return;
204  }
205 
206  QByteArray sig;
207  sig.reserve(count + count / 2);
208  for (int i = 0; i < count; ++i) {
209  const char *typeSig = QDBusMetaType::typeToSignature(types[i]);
210  if (!typeSig) {
211  qFatal("QDBusPendingReply: type %s is not registered with QtDBus",
213  }
214  sig += typeSig;
215  }
216 
218 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static const char * typeToSignature(int type)
Returns the D-Bus signature equivalent to the supplied meta type id type.
Q_CORE_EXPORT void qFatal(const char *,...)
static const struct @32 types[]
static const char * typeName(int type)
Returns the type name associated with the given type, or 0 if no matching type was found...
Definition: qmetatype.cpp:406
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void reserve(int size)
Attempts to allocate memory for at least size bytes.
Definition: qbytearray.h:449

◆ setReplyCallback()

bool QDBusPendingCallPrivate::setReplyCallback ( QObject target,
const char *  member 
)

Definition at line 148 of file qdbuspendingcall.cpp.

Referenced by QDBusPendingCall::operator=(), QDBusPendingCallPrivate(), and QDBusConnectionPrivate::sendWithReplyAsync().

149 {
150  receiver = target;
151  metaTypes.clear();
152  methodIdx = -1;
153  if (!target)
154  return true;; // unsetting
155 
156  if (!member || !*member) {
157  // would not be able to deliver a reply
158  qWarning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)",
159  target ? target->metaObject()->className() : "(null)",
160  member ? member + 1 : "(null)",
161  target ? qPrintable(target->objectName()) : "no name");
162  return false;
163  }
164 
166  if (methodIdx == -1) {
167  QByteArray normalizedName = QMetaObject::normalizedSignature(member + 1);
168  methodIdx = QDBusConnectionPrivate::findSlot(target, normalizedName, metaTypes);
169  }
170  if (methodIdx == -1) {
171  // would not be able to deliver a reply
172  qWarning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)",
173  target->metaObject()->className(),
174  member + 1, qPrintable(target->objectName()));
175  return false;
176  }
177 
178  // success
179  // construct the expected signature
180  int count = metaTypes.count() - 1;
181  if (count == 1 && metaTypes.at(1) == QDBusMetaTypeId::message) {
182  // wildcard slot, can receive anything, so don't set the signature
183  return true;
184  }
185 
186  if (metaTypes.at(count) == QDBusMetaTypeId::message)
187  --count;
188 
189  if (count == 0) {
190  setMetaTypes(count, 0);
191  } else {
193  setMetaTypes(count, types.constData() + 1);
194  }
195  return true;
196 }
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
QString objectName
the name of this object
Definition: qobject.h:114
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static int findSlot(QObject *obj, const QByteArray &normalizedName, QList< int > &params)
static int message
void setMetaTypes(int count, const int *types)
QPointer< QObject > receiver
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QVector< T > fromList(const QList< T > &list)
Returns a QVector object with the data contained in list.
Definition: qvector.h:789
Q_CORE_EXPORT void qWarning(const char *,...)
void clear()
Removes all items from the list.
Definition: qlist.h:764
static const struct @32 types[]
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
#define qPrintable(string)
Definition: qglobal.h:1750
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ waitForFinished()

void QDBusPendingCallPrivate::waitForFinished ( )

Definition at line 244 of file qdbuspendingcall.cpp.

Referenced by QDBusPendingReplyData::argumentAt(), QDBusPendingCall::operator=(), QDBusPendingCallPrivate(), and QDBusPendingCallWatcher::waitForFinished().

245 {
246  QMutexLocker locker(&mutex);
247 
249  return; // already finished
250 
252 }
void waitForFinished(QDBusPendingCallPrivate *pcall)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QDBusConnectionPrivate *const connection
MessageType type() const
Returns the message type.

Properties

◆ connection

QDBusConnectionPrivate* const QDBusPendingCallPrivate::connection

Definition at line 81 of file qdbuspendingcall_p.h.

Referenced by QDBusConnectionPrivate::processFinishedCall().

◆ expectedReplyCount

int QDBusPendingCallPrivate::expectedReplyCount

Definition at line 101 of file qdbuspendingcall_p.h.

◆ expectedReplySignature

QString QDBusPendingCallPrivate::expectedReplySignature

Definition at line 100 of file qdbuspendingcall_p.h.

◆ metaTypes

QList<int> QDBusPendingCallPrivate::metaTypes

Definition at line 85 of file qdbuspendingcall_p.h.

Referenced by QDBusConnectionPrivate::processFinishedCall().

◆ methodIdx

int QDBusPendingCallPrivate::methodIdx

Definition at line 86 of file qdbuspendingcall_p.h.

Referenced by QDBusConnectionPrivate::processFinishedCall().

◆ mutex

QMutex QDBusPendingCallPrivate::mutex
mutable

◆ pending

DBusPendingCall* QDBusPendingCallPrivate::pending

◆ receiver

QPointer<QObject> QDBusPendingCallPrivate::receiver

Definition at line 84 of file qdbuspendingcall_p.h.

Referenced by QDBusConnectionPrivate::processFinishedCall().

◆ replyMessage

QDBusMessage QDBusPendingCallPrivate::replyMessage

◆ sentMessage

const QDBusMessage QDBusPendingCallPrivate::sentMessage

Definition at line 80 of file qdbuspendingcall_p.h.

Referenced by QDBusConnectionPrivate::processFinishedCall().

◆ waitForFinishedCondition

QWaitCondition QDBusPendingCallPrivate::waitForFinishedCondition

Definition at line 91 of file qdbuspendingcall_p.h.

Referenced by QDBusConnectionPrivate::waitForFinished().

◆ waitingForFinished

volatile bool QDBusPendingCallPrivate::waitingForFinished

◆ watcherHelper

QDBusPendingCallWatcherHelper* QDBusPendingCallPrivate::watcherHelper

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