QT_BEGIN_NAMESPACE /*! \class QDBusPendingCall \inmodule QtDBus \since 4.5 \brief The QDBusPendingCall class refers to one pending asynchronous call 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) \sa QDBusPendingReply, QDBusPendingCallWatcher, QDBusAbstractInterface::asyncCall() */ /*! \class QDBusPendingCallWatcher \inmodule QtDBus \since 4.5 \brief The QDBusPendingCallWatcher class provides a convenient way for waiting for asynchronous replies The QDBusPendingCallWatcher provides the finished() signal that will be emitted when a reply arrives. It is usually used like the following example: \snippet doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp 0 Note that it is not necessary to keep the original QDBusPendingCall object around since QDBusPendingCallWatcher inherits from that class too. The slot connected to by the above code could be something similar to the following: \snippet doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp 1 Note the use of QDBusPendingReply to validate the argument types in the reply. If the reply did not contain exactly two arguments (one string and one QByteArray), QDBusPendingReply::isError() will return true. \sa QDBusPendingReply, QDBusAbstractInterface::asyncCall() */ /*! \fn void QDBusPendingCallWatcher::finished(QDBusPendingCallWatcher *self) This signal is emitted when the pending call has finished and its reply is available. The \a self parameter is a pointer to the object itself, passed for convenience so that the slot can access the properties and determine the contents of the reply. */ void QDBusPendingCallWatcherHelper::add(QDBusPendingCallWatcher *watcher) { connect(this, SIGNAL(finished()), watcher, SLOT(_q_finished()), Qt::QueuedConnection); }
void QGalleryAbstractRequest::execute() { const int oldError = d_ptr->error; d_ptr->error = NoError; d_ptr->errorString = QString(); if (!d_ptr->gallery) { d_ptr->state = Error; d_ptr->error = NoGallery; d_ptr->errorString = tr("No gallery has been set on the %1.", "%1 = class name") .arg(QString::fromLatin1(metaObject()->className())); if (d_ptr->response) { QScopedPointer<QGalleryAbstractResponse> oldResponse(d_ptr->response.take()); Q_UNUSED(oldResponse); setResponse(0); } emit error(d_ptr->error, d_ptr->errorString); emit errorChanged(); } else { QScopedPointer<QGalleryAbstractResponse> oldResponse( d_ptr->gallery.data()->createResponse(this)); d_ptr->response.swap(oldResponse); if (d_ptr->response) { d_ptr->error = d_ptr->response->error(); if (d_ptr->error != NoError) { d_ptr->errorString = d_ptr->response->errorString(); d_ptr->state = Error; d_ptr->response.reset(); if (oldResponse) setResponse(0); emit error(d_ptr->error, d_ptr->errorString); emit errorChanged(); } else { if (d_ptr->response->isActive()) { d_ptr->state = Active; d_ptr->wasIdle = false; } else if (d_ptr->response->isIdle()) { d_ptr->state = Idle; d_ptr->wasIdle = true; } else { d_ptr->state = Finished; } connect(d_ptr->response.data(), SIGNAL(finished()), this, SLOT(_q_finished())); connect(d_ptr->response.data(), SIGNAL(resumed()), this, SLOT(_q_resumed())); connect(d_ptr->response.data(), SIGNAL(canceled()), this, SLOT(_q_canceled())); connect(d_ptr->response.data(), SIGNAL(progressChanged(int,int)), this, SLOT(_q_progressChanged(int,int))); setResponse(d_ptr->response.data()); } oldResponse.reset(); } else {