Qt 4.8
Public Functions | Static Public Functions | Protected Functions | Protected Variables | Private Functions | Friends | List of all members
QDBusPendingCall Class Reference

The QDBusPendingCall class refers to one pending asynchronous call. More...

#include <qdbuspendingcall.h>

Inheritance diagram for QDBusPendingCall:
QDBusPendingCallWatcher QDBusPendingReply< T1, T2, T3, T4, T5, T6, T7, T8 > QDBusPendingReplyData

Public Functions

QDBusPendingCalloperator= (const QDBusPendingCall &other)
 Creates a copy of the other pending asynchronous call and drops the reference to the previously-referenced call. More...
 
 QDBusPendingCall (const QDBusPendingCall &other)
 Creates a copy of the other pending asynchronous call. More...
 
 ~QDBusPendingCall ()
 Destroys this copy of the QDBusPendingCall object. More...
 

Static Public Functions

static QDBusPendingCall fromCompletedCall (const QDBusMessage &message)
 Creates a QDBusPendingCall object based on the message msg. More...
 
static QDBusPendingCall fromError (const QDBusError &error)
 Creates a QDBusPendingCall object based on the error condition error. More...
 

Protected Functions

 QDBusPendingCall (QDBusPendingCallPrivate *dd)
 

Protected Variables

QExplicitlySharedDataPointer< QDBusPendingCallPrivated
 

Private Functions

 QDBusPendingCall ()
 

Friends

class QDBusConnection
 
class QDBusPendingCallPrivate
 
class QDBusPendingCallWatcher
 

Detailed Description

The QDBusPendingCall class refers to one pending asynchronous call.

Attention
Module: QtDBus
Since
4.5

A QDBusPendingCall object is a reference to a method call that was sent over D-Bus without waiting for a reply. QDBusPendingCall is an opaque type, meant to be used as a handle for a pending reply.

In most programs, the QDBusPendingCall class will not be used directly. It can be safely replaced with the template-based QDBusPendingReply, in order to access the contents of the reply or wait for it to be complete.

The QDBusPendingCallWatcher class allows one to connect to a signal that will indicate when the reply has arrived or if the call has timed out. It also provides the QDBusPendingCallWatcher::waitForFinished() method which will suspend the execution of the program until the reply has arrived.

Note
If you create a copy of a QDBusPendingCall object, all information will be shared among the many copies. Therefore, QDBusPendingCall is an explicitly-shared object and does not provide a method of detaching the copies (since they refer to the same pending call)
See also
QDBusPendingReply, QDBusPendingCallWatcher, QDBusAbstractInterface::asyncCall()

Definition at line 65 of file qdbuspendingcall.h.

Constructors and Destructors

◆ QDBusPendingCall() [1/3]

QDBusPendingCall::QDBusPendingCall ( const QDBusPendingCall other)

Creates a copy of the other pending asynchronous call.

Note that both objects will refer to the same pending call.

Definition at line 258 of file qdbuspendingcall.cpp.

259  : d(other.d)
260 {
261 }
QExplicitlySharedDataPointer< QDBusPendingCallPrivate > d

◆ ~QDBusPendingCall()

QDBusPendingCall::~QDBusPendingCall ( )

Destroys this copy of the QDBusPendingCall object.

If this copy is also the last copy of a pending asynchronous call, the call will be canceled and no further notifications will be received. There will be no way of accessing the reply's contents when it arrives.

Definition at line 282 of file qdbuspendingcall.cpp.

283 {
284  // d deleted by QExplicitlySharedDataPointer
285 }

◆ QDBusPendingCall() [2/3]

QDBusPendingCall::QDBusPendingCall ( QDBusPendingCallPrivate dd)
protected
Warning
This function is not part of the public interface.

Definition at line 266 of file qdbuspendingcall.cpp.

267  : d(dd)
268 {
269  if (dd) {
270  bool r = dd->ref.deref();
271  Q_ASSERT(r);
272  Q_UNUSED(r);
273  }
274 }
QAtomicInt ref
Definition: qshareddata.h:59
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QExplicitlySharedDataPointer< QDBusPendingCallPrivate > d
bool deref()
Atomically decrements the value of this QAtomicInt.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ QDBusPendingCall() [3/3]

QDBusPendingCall::QDBusPendingCall ( )
private

Referenced by fromCompletedCall().

Functions

◆ fromCompletedCall()

QDBusPendingCall QDBusPendingCall::fromCompletedCall ( const QDBusMessage msg)
static

Creates a QDBusPendingCall object based on the message msg.

Since
4.6

The message must be of type QDBusMessage::ErrorMessage or QDBusMessage::ReplyMessage (that is, a message that is typical of a completed call).

This function is useful for code that requires simulating a pending call, but that has already finished.

See also
fromError()

Definition at line 496 of file qdbuspendingcall.cpp.

Referenced by fromError().

497 {
499  if (msg.type() == QDBusMessage::ErrorMessage ||
500  msg.type() == QDBusMessage::ReplyMessage) {
502  d->replyMessage = msg;
503  d->ref = 1;
504  }
505 
506  return QDBusPendingCall(d);
507 }
QAtomicInt ref
Definition: qshareddata.h:59
friend class QDBusPendingCallPrivate
QExplicitlySharedDataPointer< QDBusPendingCallPrivate > d
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
MessageType type() const
Returns the message type.

◆ fromError()

QDBusPendingCall QDBusPendingCall::fromError ( const QDBusError error)
static

Creates a QDBusPendingCall object based on the error condition error.

Since
4.6 The resulting pending call object will be in the "finished" state and QDBusPendingReply::isError() will return true.
See also
fromCompletedCall()

Definition at line 476 of file qdbuspendingcall.cpp.

Referenced by QDBusAbstractInterface::asyncCallWithArgumentList().

477 {
479 }
static QDBusMessage createError(const QString &name, const QString &msg)
Constructs a new DBus message representing an error, with the given name and msg. ...
static QDBusPendingCall fromCompletedCall(const QDBusMessage &message)
Creates a QDBusPendingCall object based on the message msg.

◆ operator=()

QDBusPendingCall & QDBusPendingCall::operator= ( const QDBusPendingCall other)

Creates a copy of the other pending asynchronous call and drops the reference to the previously-referenced call.

Note that both objects will refer to the same pending call after this function.

If this object contained the last reference of a pending asynchronous call, the call will be canceled and no further notifications will be received. There will be no way of accessing the reply's contents when it arrives.

Definition at line 298 of file qdbuspendingcall.cpp.

Referenced by QDBusPendingReplyData::assign().

299 {
300  d = other.d;
301  return *this;
302 }
QExplicitlySharedDataPointer< QDBusPendingCallPrivate > d

Friends and Related Functions

◆ QDBusConnection

friend class QDBusConnection
friend

Definition at line 90 of file qdbuspendingcall.h.

◆ QDBusPendingCallPrivate

Definition at line 88 of file qdbuspendingcall.h.

Referenced by QDBusPendingReplyData::assign(), and fromCompletedCall().

◆ QDBusPendingCallWatcher

Definition at line 89 of file qdbuspendingcall.h.

Properties

◆ d

QExplicitlySharedDataPointer<QDBusPendingCallPrivate> QDBusPendingCall::d
protected

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