qdbuspendingcall.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/dbus/qdbuspendingcall.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6void QDBusPendingCallWatcherHelper::add(QDBusPendingCallWatcher *watcher)-
7{-
8 connect(this, qFlagLocation("2""finished()" "\0" __FILE__ ":" "125""131"), watcher, qFlagLocation("1""_q_finished()" "\0" __FILE__ ":" "125""131"), Qt::QueuedConnection);-
9}-
10-
11QDBusPendingCallPrivate::~QDBusPendingCallPrivate()-
12{-
13 if (pending) {-
14 q_dbus_pending_call_cancel(pending);-
15 q_dbus_pending_call_unref(pending);-
16 }-
17 delete watcherHelper;-
18}-
19-
20bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *member)-
21{-
22 receiver = target;-
23 metaTypes.clear();-
24 methodIdx = -1;-
25 if (!target)-
26 return true;;-
27-
28 if (!member || !*member) {-
29-
30 QMessageLogger(__FILE__, 147153, __PRETTY_FUNCTION__).warning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)",-
31 target ? target->metaObject()->className() : "(null)",-
32 member ? member + 1 : "(null)",-
33 target ? QString(target->objectName()).toLocal8Bit().constData() : "no name");-
34 return false;-
35 }-
36-
37 methodIdx = QDBusConnectionPrivate::findSlot(target, member + 1, metaTypes);-
38 if (methodIdx == -1) {-
39 QByteArray normalizedName = QMetaObject::normalizedSignature(member + 1);-
40 methodIdx = QDBusConnectionPrivate::findSlot(target, normalizedName, metaTypes);-
41 }-
42 if (methodIdx == -1) {-
43-
44 QMessageLogger(__FILE__, 161167, __PRETTY_FUNCTION__).warning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)",-
45 target->metaObject()->className(),-
46 member + 1, QString(target->objectName()).toLocal8Bit().constData());-
47 return false;-
48 }-
49-
50-
51-
52 int count = metaTypes.count() - 1;-
53 if (count == 1 && metaTypes.at(1) == QDBusMetaTypeId::message()) {-
54-
55 return true;-
56 }-
57-
58 if (metaTypes.at(count) == QDBusMetaTypeId::message())-
59 --count;-
60-
61 setMetaTypes(count, count ? metaTypes.constData() + 1 : 0);-
62 return true;-
63}-
64-
65void QDBusPendingCallPrivate::setMetaTypes(int count, const int *types)-
66{-
67 if (count == 0
count == 0Description
TRUEevaluated 14 times by 5 tests
Evaluated by:
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusconnection - unknown status
  • tst_qdbusconnection_spyhook - unknown status
  • tst_qdbuspendingreply - unknown status
  • tst_qdbusthreading - unknown status
FALSEevaluated 274 times by 19 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbuspendingcall - unknown status
  • tst_qdbuspendingreply - unknown status
) {
14-274
68 expectedReplySignature = QLatin1String("");-
69 return;
executed 14 times by 5 tests: return;
Executed by:
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusconnection - unknown status
  • tst_qdbusconnection_spyhook - unknown status
  • tst_qdbuspendingreply - unknown status
  • tst_qdbusthreading - unknown status
14
70 }-
71-
72 QByteArray sig;-
73 sig.reserve(count + count / 2);-
74 for (int i = 0; i < count
i < countDescription
TRUEevaluated 278 times by 19 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbuspendingcall - unknown status
  • tst_qdbuspendingreply - unknown status
FALSEevaluated 274 times by 19 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbuspendingcall - unknown status
  • tst_qdbuspendingreply - unknown status
; ++i) {
274-278
75 const char *typeSig = QDBusMetaType::typeToSignature(types[i]);-
76 if (!(__builtin_expect(!!(!
__builtin_expe...peSig), false)Description
TRUEnever evaluated
FALSEevaluated 278 times by 19 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbuspendingcall - unknown status
  • tst_qdbuspendingreply - unknown status
typeSig)), false)
__builtin_expe...peSig), false)Description
TRUEnever evaluated
FALSEevaluated 278 times by 19 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbuspendingcall - unknown status
  • tst_qdbuspendingreply - unknown status
) {
0-278
77 QMessageLogger(__FILE__, 194200, __PRETTY_FUNCTION__).fatal("QDBusPendingReply: type %s is not registered with QtDBus",-
78 QMetaType::typeName(types[i]));-
79 }
never executed: end of block
0
80 sig += typeSig;-
81 }
executed 278 times by 19 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbuspendingcall - unknown status
  • tst_qdbuspendingreply - unknown status
278
82-
83 expectedReplySignature = QString::fromLatin1(sig);-
84}
executed 274 times by 19 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbuspendingcall - unknown status
  • tst_qdbuspendingreply - unknown status
274
85-
86void QDBusPendingCallPrivate::checkReceivedSignature()-
87{-
88-
89-
90 if (replyMessage.type() == QDBusMessage::InvalidMessage)-
91 return;-
92-
93 if (replyMessage.type() == QDBusMessage::ErrorMessage)-
94 return;-
95-
96 if (expectedReplySignature.isNull())-
97 return;-
98-
99-
100 if (replyMessage.signature().indexOf(expectedReplySignature) != 0) {-
101 QString errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", "-
102 "expected \"%2\"");-
103 replyMessage = QDBusMessage::createError(-
104 QDBusError::InvalidSignature,-
105 errorMsg.arg(replyMessage.signature(), expectedReplySignature));-
106-
107 }-
108}-
109-
110void QDBusPendingCallPrivate::waitForFinished()-
111{-
112 QMutexLocker locker(&mutex);-
113-
114 if (replyMessage.type() != QDBusMessage::InvalidMessage)-
115 return;-
116-
117 waitForFinishedCondition.wait(&mutex);-
118}-
119-
120-
121-
122-
123-
124QDBusPendingCall::QDBusPendingCall(const QDBusPendingCall &other)-
125 : d(other.d)-
126{-
127}-
128-
129-
130-
131-
132QDBusPendingCall::QDBusPendingCall(QDBusPendingCallPrivate *dd)-
133 : d(dd)-
134{-
135 if (dd) {-
136 bool r = dd->ref.deref();-
137 ((!(r)) ? qt_assert("r",__FILE__,254260) : qt_noop());-
138 (void)r;;-
139 }-
140}-
141-
142-
143-
144-
145-
146-
147-
148QDBusPendingCall::~QDBusPendingCall()-
149{-
150-
151}-
152QDBusPendingCall &QDBusPendingCall::operator=(const QDBusPendingCall &other)-
153{-
154 d = other.d;-
155 return *this;-
156}-
157bool QDBusPendingCall::isFinished() const-
158{-
159 if (!d)-
160 return true;-
161-
162 QMutexLocker locker(&d->mutex);-
163 return d->replyMessage.type() != QDBusMessage::InvalidMessage;-
164}-
165-
166void QDBusPendingCall::waitForFinished()-
167{-
168 if (d) d->waitForFinished();-
169}-
170bool QDBusPendingCall::isValid() const-
171{-
172 if (!d)-
173 return false;-
174 QMutexLocker locker(&d->mutex);-
175 return d->replyMessage.type() == QDBusMessage::ReplyMessage;-
176}-
177bool QDBusPendingCall::isError() const-
178{-
179 if (!d)-
180 return true;-
181 QMutexLocker locker(&d->mutex);-
182 return d->replyMessage.type() == QDBusMessage::ErrorMessage;-
183}-
184QDBusError QDBusPendingCall::error() const-
185{-
186 if (d) {-
187 QMutexLocker locker(&d->mutex);-
188 return QDBusError(d->replyMessage);-
189 }-
190-
191-
192 QDBusError err = QDBusError(QDBusError::Disconnected,-
193 QDBusUtil::disconnectedErrorMessage());-
194 return err;-
195}-
196QDBusMessage QDBusPendingCall::reply() const-
197{-
198 if (!d)-
199 return QDBusMessage::createError(error());-
200 QMutexLocker locker(&d->mutex);-
201 return d->replyMessage;-
202}-
203QDBusPendingCall QDBusPendingCall::fromError(const QDBusError &error)-
204{-
205 return fromCompletedCall(QDBusMessage::createError(error));-
206}-
207QDBusPendingCall QDBusPendingCall::fromCompletedCall(const QDBusMessage &msg)-
208{-
209 QDBusPendingCallPrivate *d = 0;-
210 if (msg.type() == QDBusMessage::ErrorMessage ||-
211 msg.type() == QDBusMessage::ReplyMessage) {-
212 d = new QDBusPendingCallPrivate(QDBusMessage(), 0);-
213 d->replyMessage = msg;-
214 d->ref.store(1);-
215 }-
216-
217 return QDBusPendingCall(d);-
218}-
219-
220-
221class QDBusPendingCallWatcherPrivate: public QObjectPrivate-
222{-
223public:-
224 void _q_finished();-
225-
226 inline QDBusPendingCallWatcher* q_func() { return static_cast<QDBusPendingCallWatcher *>(q_ptr); } inline const QDBusPendingCallWatcher* q_func() const { return static_cast<const QDBusPendingCallWatcher *>(q_ptr); } friend class QDBusPendingCallWatcher;-
227};-
228-
229inline void QDBusPendingCallWatcherPrivate::_q_finished()-
230{-
231 QDBusPendingCallWatcher * const q = q_func();-
232 q->finished(q);-
233}-
234-
235-
236-
237-
238-
239-
240QDBusPendingCallWatcher::QDBusPendingCallWatcher(const QDBusPendingCall &call, QObject *parent)-
241 : QObject(*new QDBusPendingCallWatcherPrivate, parent), QDBusPendingCall(call)-
242{-
243 if (d) {-
244 QMutexLocker locker(&d->mutex);-
245 if (!d->watcherHelper) {-
246 d->watcherHelper = new QDBusPendingCallWatcherHelper;-
247 if (d->replyMessage.type() != QDBusMessage::InvalidMessage) {-
248-
249 QMetaObject::invokeMethod(d->watcherHelper, "finished", Qt::QueuedConnection);-
250 }-
251 }-
252 d->watcherHelper->add(this);-
253 }-
254}-
255-
256-
257-
258-
259-
260-
261QDBusPendingCallWatcher::~QDBusPendingCallWatcher()-
262{-
263}-
264void QDBusPendingCallWatcher::waitForFinished()-
265{-
266 if (d) {-
267 d->waitForFinished();-
268-
269-
270 QCoreApplication::sendPostedEvents(d->watcherHelper, QEvent::MetaCall);-
271 QCoreApplication::sendPostedEvents(this, QEvent::MetaCall);-
272 }-
273}-
274-
275-
276-
277-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9