OpenCoverage

qdbuspendingreply.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/dbus/qdbuspendingreply.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2016 Intel Corporation.-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtDBus module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include "qdbuspendingreply.h"-
42#include "qdbuspendingcall_p.h"-
43#include "qdbusmetatype.h"-
44-
45#ifndef QT_NO_DBUS-
46-
47/*!-
48 \class QDBusPendingReply-
49 \inmodule QtDBus-
50 \since 4.5-
51-
52 \brief The QDBusPendingReply class contains the reply to an asynchronous method call-
53-
54 The QDBusPendingReply is a template class with up to 8 template-
55 parameters. Those parameters are the types that will be used to-
56 extract the contents of the reply's data.-
57-
58 This class is similar in functionality to QDBusReply, but with two-
59 important differences:-
60-
61 \list-
62 \li QDBusReply accepts exactly one return type, whereas-
63 QDBusPendingReply can have from 1 to 8 types-
64 \li QDBusReply only works on already completed replies, whereas-
65 QDBusPendingReply allows one to wait for replies from pending-
66 calls-
67 \endlist-
68-
69 Where with QDBusReply you would write:-
70-
71 \snippet code/src_qdbus_qdbusreply.cpp 0-
72-
73 with QDBusPendingReply, the equivalent code (including the blocking-
74 wait for the reply) would be:-
75-
76 \snippet code/src_qdbus_qdbuspendingreply.cpp 0-
77-
78 For method calls that have more than one output argument, with-
79 QDBusReply, you would write:-
80-
81 \snippet code/src_qdbus_qdbusreply.cpp 1-
82-
83 whereas with QDBusPendingReply, all of the output arguments should-
84 be template parameters:-
85-
86 \snippet code/src_qdbus_qdbuspendingreply.cpp 2-
87-
88 QDBusPendingReply objects can be associated with-
89 QDBusPendingCallWatcher objects, which emit signals when the reply-
90 arrives.-
91-
92 \sa QDBusPendingCallWatcher, QDBusReply,-
93 QDBusAbstractInterface::asyncCall()-
94*/-
95-
96/*!-
97 \fn QDBusPendingReply::QDBusPendingReply()-
98-
99 Creates an empty QDBusPendingReply object. Without assigning a-
100 QDBusPendingCall object to this reply, QDBusPendingReply cannot do-
101 anything. All functions return their failure values.-
102*/-
103-
104/*!-
105 \fn QDBusPendingReply::QDBusPendingReply(const QDBusPendingReply &other)-
106-
107 Creates a copy of the \a other QDBusPendingReply object. Just like-
108 QDBusPendingCall and QDBusPendingCallWatcher, this QDBusPendingReply-
109 object will share the same pending call reference. All copies-
110 share the same return values.-
111*/-
112-
113/*!-
114 \fn QDBusPendingReply::QDBusPendingReply(const QDBusPendingCall &call)-
115-
116 Creates a QDBusPendingReply object that will take its contents from-
117 the \a call pending asynchronous call. This QDBusPendingReply object-
118 will share the same pending call reference as \a call.-
119*/-
120-
121/*!-
122 \fn QDBusPendingReply::QDBusPendingReply(const QDBusMessage &message)-
123-
124 Creates a QDBusPendingReply object that will take its contents from-
125 the message \a message. In this case, this object will be already-
126 in its finished state and the reply's contents will be accessible.-
127-
128 \sa isFinished()-
129*/-
130-
131/*!-
132 \fn QDBusPendingReply &QDBusPendingReply::operator=(const QDBusPendingReply &other)-
133-
134 Makes a copy of \a other and drops the reference to the current-
135 pending call. If the current reference is to an unfinished pending-
136 call and this is the last reference, the pending call will be-
137 canceled and there will be no way of retrieving the reply's-
138 contents, when they arrive.-
139*/-
140-
141/*!-
142 \fn QDBusPendingReply &QDBusPendingReply::operator=(const QDBusPendingCall &call)-
143-
144 Makes this object take its contents from the \a call pending call-
145 and drops the reference to the current pending call. If the-
146 current reference is to an unfinished pending call and this is the-
147 last reference, the pending call will be canceled and there will-
148 be no way of retrieving the reply's contents, when they arrive.-
149*/-
150-
151/*!-
152 \fn QDBusPendingReply &QDBusPendingReply::operator=(const QDBusMessage &message)-
153-
154 Makes this object take its contents from the \a message message-
155 and drops the reference to the current pending call. If the-
156 current reference is to an unfinished pending call and this is the-
157 last reference, the pending call will be canceled and there will-
158 be no way of retrieving the reply's contents, when they arrive.-
159-
160 After this function is finished, the QDBusPendingReply object will-
161 be in its "finished" state and the \a message contents will be-
162 accessible.-
163-
164 \sa isFinished()-
165*/-
166-
167/*!-
168 \fn int QDBusPendingReply::count() const-
169-
170 Return the number of arguments the reply is supposed to have. This-
171 number matches the number of non-void template parameters in this-
172 class.-
173-
174 If the reply arrives with a different number of arguments (or with-
175 different types), it will be transformed into an error reply-
176 indicating a bad signature.-
177*/-
178-
179/*!-
180 \fn QVariant QDBusPendingReply::argumentAt(int index) const-
181-
182 Returns the argument at position \a index in the reply's-
183 contents. If the reply doesn't have that many elements, this-
184 function's return value is undefined (will probably cause an-
185 assertion failure), so it is important to verify that the-
186 processing is finished and the reply is valid.-
187-
188 If the reply does not contain an argument at position \a index or if the-
189 reply was an error, this function returns an invalid QVariant. Since D-Bus-
190 messages can never contain invalid QVariants, this return can be used to-
191 detect an error condition.-
192*/-
193-
194/*!-
195 \fn Type QDBusPendingReply::argumentAt() const-
196-
197 Returns the argument at position \c Index (which is a template-
198 parameter) cast to type \c Type. This function uses template code-
199 to determine the proper \c Type type, according to the type list-
200 used in the construction of this object.-
201-
202 Note that, if the reply hasn't arrived, this function causes the-
203 calling thread to block until the reply is processed.-
204-
205 If the reply does not contain an argument at position \c Index or if the-
206 reply was an error, this function returns a \c Type object that is default-
207 constructed, which may be indistinguishable from a valid value. To reliably-
208 determine whether the message was an error, use isError().-
209*/-
210-
211/*!-
212 \fn T1 QDBusPendingReply::value() const-
213-
214 Returns the first argument in this reply, cast to type \c T1 (the-
215 first template parameter of this class). This is equivalent to-
216 calling argumentAt<0>().-
217-
218 This function is provided as a convenience, matching the-
219 QDBusReply::value() function.-
220-
221 Note that, if the reply hasn't arrived, this function causes the-
222 calling thread to block until the reply is processed.-
223-
224 If the reply is an error reply, this function returns a default-constructed-
225 \c T1 object, which may be indistinguishable from a valid value. To-
226 reliably determine whether the message was an error, use isError().-
227*/-
228-
229/*!-
230 \fn QDBusPendingReply::operator T1() const-
231-
232 Returns the first argument in this reply, cast to type \c T1 (the-
233 first template parameter of this class). This is equivalent to-
234 calling argumentAt<0>().-
235-
236 This function is provided as a convenience, matching the-
237 QDBusReply::value() function.-
238-
239 Note that, if the reply hasn't arrived, this function causes the-
240 calling thread to block until the reply is processed.-
241-
242 If the reply is an error reply, this function returns a default-constructed-
243 \c T1 object, which may be indistinguishable from a valid value. To-
244 reliably determine whether the message was an error, use isError().-
245*/-
246-
247/*!-
248 \fn void QDBusPendingReply::waitForFinished()-
249-
250 Suspends the execution of the calling thread until the reply is-
251 received and processed. After this function returns, isFinished()-
252 should return true, indicating the reply's contents are ready to-
253 be processed.-
254-
255 \sa QDBusPendingCallWatcher::waitForFinished()-
256*/-
257-
258QDBusPendingReplyData::QDBusPendingReplyData()-
259 : QDBusPendingCall(0) // initialize base class empty-
260{-
261}
executed 274 times by 18 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_qdbuspendingreply - unknown status
274
262-
263QDBusPendingReplyData::~QDBusPendingReplyData()-
264{-
265}-
266-
267void QDBusPendingReplyData::assign(const QDBusPendingCall &other)-
268{-
269 QDBusPendingCall::operator=(other);-
270}
executed 103 times by 18 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_qdbuspendingreply - unknown status
103
271-
272void QDBusPendingReplyData::assign(const QDBusMessage &message)-
273{-
274 d = new QDBusPendingCallPrivate(QDBusMessage(), 0); // drops the reference to the old one-
275 d->replyMessage = message;-
276}
executed 177 times by 17 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_qdbuspendingreply - unknown status
177
277-
278QVariant QDBusPendingReplyData::argumentAt(int index) const-
279{-
280 if (!d)
!dDescription
TRUEnever evaluated
FALSEevaluated 211 times by 18 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_qdbuspendingreply - unknown status
0-211
281 return QVariant();
never executed: return QVariant();
0
282-
283 d->waitForFinished(); // bypasses "const"-
284-
285 return d->replyMessage.arguments().value(index);
executed 211 times by 18 tests: return d->replyMessage.arguments().value(index);
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_qdbuspendingreply - unknown status
211
286}-
287-
288void QDBusPendingReplyData::setMetaTypes(int count, const int *types)-
289{-
290 Q_ASSERT(d);-
291 QMutexLocker locker(&d->mutex);-
292 d->setMetaTypes(count, types);-
293 d->checkReceivedSignature();-
294}
executed 278 times by 18 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_qdbuspendingreply - unknown status
278
295-
296#endif // QT_NO_DBUS-
Source codeSwitch to Preprocessed file

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