Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtDBus module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qdbusargument_p.h" | - |
43 | #include "qdbusconnection.h" | - |
44 | #include "qdbusmetatype_p.h" | - |
45 | #include "qdbusutil_p.h" | - |
46 | | - |
47 | #ifndef QT_NO_DBUS | - |
48 | | - |
49 | QT_BEGIN_NAMESPACE | - |
50 | | - |
51 | static void qIterAppend(DBusMessageIter *it, QByteArray *ba, int type, const void *arg) | - |
52 | { | - |
53 | if (ba) evaluated: ba yes Evaluation Count:76 | yes Evaluation Count:1610 |
| 76-1610 |
54 | *ba += char(type); executed: *ba += char(type); Execution Count:76 | 76 |
55 | else | - |
56 | q_dbus_message_iter_append_basic(it, type, arg); executed: q_dbus_message_iter_append_basic(it, type, arg); Execution Count:1610 | 1610 |
57 | } | - |
58 | | - |
59 | QDBusMarshaller::~QDBusMarshaller() | - |
60 | { | - |
61 | close(); executed (the execution status of this line is deduced): close(); | - |
62 | } executed: } Execution Count:2157 | 2157 |
63 | | - |
64 | inline QString QDBusMarshaller::currentSignature() | - |
65 | { | - |
66 | if (message) | 0 |
67 | return QString::fromUtf8(q_dbus_message_get_signature(message)); never executed: return QString::fromUtf8(q_dbus_message_get_signature(message)); | 0 |
68 | return QString(); never executed: return QString(); | 0 |
69 | } | - |
70 | | - |
71 | inline void QDBusMarshaller::append(uchar arg) | - |
72 | { | - |
73 | qIterAppend(&iterator, ba, DBUS_TYPE_BYTE, &arg); never executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 'y'), &arg); | - |
74 | } | 0 |
75 | | - |
76 | inline void QDBusMarshaller::append(bool arg) | - |
77 | { | - |
78 | dbus_bool_t cast = arg; never executed (the execution status of this line is deduced): dbus_bool_t cast = arg; | - |
79 | qIterAppend(&iterator, ba, DBUS_TYPE_BOOLEAN, &cast); never executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 'b'), &cast); | - |
80 | } | 0 |
81 | | - |
82 | inline void QDBusMarshaller::append(short arg) | - |
83 | { | - |
84 | qIterAppend(&iterator, ba, DBUS_TYPE_INT16, &arg); never executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 'n'), &arg); | - |
85 | } | 0 |
86 | | - |
87 | inline void QDBusMarshaller::append(ushort arg) | - |
88 | { | - |
89 | qIterAppend(&iterator, ba, DBUS_TYPE_UINT16, &arg); never executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 'q'), &arg); | - |
90 | } | 0 |
91 | | - |
92 | inline void QDBusMarshaller::append(int arg) | - |
93 | { | - |
94 | qIterAppend(&iterator, ba, DBUS_TYPE_INT32, &arg); executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 'i'), &arg); | - |
95 | } executed: } Execution Count:120 | 120 |
96 | | - |
97 | inline void QDBusMarshaller::append(uint arg) | - |
98 | { | - |
99 | qIterAppend(&iterator, ba, DBUS_TYPE_UINT32, &arg); never executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 'u'), &arg); | - |
100 | } | 0 |
101 | | - |
102 | inline void QDBusMarshaller::append(qlonglong arg) | - |
103 | { | - |
104 | qIterAppend(&iterator, ba, DBUS_TYPE_INT64, &arg); executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 'x'), &arg); | - |
105 | } executed: } Execution Count:6 | 6 |
106 | | - |
107 | inline void QDBusMarshaller::append(qulonglong arg) | - |
108 | { | - |
109 | qIterAppend(&iterator, ba, DBUS_TYPE_UINT64, &arg); never executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 't'), &arg); | - |
110 | } | 0 |
111 | | - |
112 | inline void QDBusMarshaller::append(double arg) | - |
113 | { | - |
114 | qIterAppend(&iterator, ba, DBUS_TYPE_DOUBLE, &arg); executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 'd'), &arg); | - |
115 | } executed: } Execution Count:12 | 12 |
116 | | - |
117 | void QDBusMarshaller::append(const QString &arg) | - |
118 | { | - |
119 | QByteArray data = arg.toUtf8(); executed (the execution status of this line is deduced): QByteArray data = arg.toUtf8(); | - |
120 | const char *cdata = data.constData(); executed (the execution status of this line is deduced): const char *cdata = data.constData(); | - |
121 | qIterAppend(&iterator, ba, DBUS_TYPE_STRING, &cdata); executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 's'), &cdata); | - |
122 | } executed: } Execution Count:1367 | 1367 |
123 | | - |
124 | inline void QDBusMarshaller::append(const QDBusObjectPath &arg) | - |
125 | { | - |
126 | QByteArray data = arg.path().toUtf8(); executed (the execution status of this line is deduced): QByteArray data = arg.path().toUtf8(); | - |
127 | if (!ba && data.isEmpty()) { evaluated: !ba yes Evaluation Count:2 | yes Evaluation Count:2 |
partially evaluated: data.isEmpty() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
128 | error(QLatin1String("Invalid object path passed in arguments")); never executed (the execution status of this line is deduced): error(QLatin1String("Invalid object path passed in arguments")); | - |
129 | } else { | 0 |
130 | const char *cdata = data.constData(); executed (the execution status of this line is deduced): const char *cdata = data.constData(); | - |
131 | qIterAppend(&iterator, ba, DBUS_TYPE_OBJECT_PATH, &cdata); executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 'o'), &cdata); | - |
132 | } executed: } Execution Count:4 | 4 |
133 | } | - |
134 | | - |
135 | inline void QDBusMarshaller::append(const QDBusSignature &arg) | - |
136 | { | - |
137 | QByteArray data = arg.signature().toUtf8(); never executed (the execution status of this line is deduced): QByteArray data = arg.signature().toUtf8(); | - |
138 | if (!ba && data.isEmpty()) { never evaluated: !ba never evaluated: data.isEmpty() | 0 |
139 | error(QLatin1String("Invalid signature passed in arguments")); never executed (the execution status of this line is deduced): error(QLatin1String("Invalid signature passed in arguments")); | - |
140 | } else { | 0 |
141 | const char *cdata = data.constData(); never executed (the execution status of this line is deduced): const char *cdata = data.constData(); | - |
142 | qIterAppend(&iterator, ba, DBUS_TYPE_SIGNATURE, &cdata); never executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, ((int) 'g'), &cdata); | - |
143 | } | 0 |
144 | } | - |
145 | | - |
146 | inline void QDBusMarshaller::append(const QDBusUnixFileDescriptor &arg) | - |
147 | { | - |
148 | int fd = arg.fileDescriptor(); never executed (the execution status of this line is deduced): int fd = arg.fileDescriptor(); | - |
149 | if (!ba && fd == -1) { never evaluated: !ba never evaluated: fd == -1 | 0 |
150 | error(QLatin1String("Invalid file descriptor passed in arguments")); never executed (the execution status of this line is deduced): error(QLatin1String("Invalid file descriptor passed in arguments")); | - |
151 | } else { | 0 |
152 | qIterAppend(&iterator, ba, DBUS_TYPE_UNIX_FD, &fd); never executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, int('h'), &fd); | - |
153 | } | 0 |
154 | } | - |
155 | | - |
156 | inline void QDBusMarshaller::append(const QByteArray &arg) | - |
157 | { | - |
158 | if (ba) { evaluated: ba yes Evaluation Count:3 | yes Evaluation Count:6 |
| 3-6 |
159 | *ba += DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING; executed (the execution status of this line is deduced): *ba += "a" "y"; | - |
160 | return; executed: return; Execution Count:3 | 3 |
161 | } | - |
162 | | - |
163 | const char* cdata = arg.constData(); executed (the execution status of this line is deduced): const char* cdata = arg.constData(); | - |
164 | DBusMessageIter subiterator; executed (the execution status of this line is deduced): DBusMessageIter subiterator; | - |
165 | q_dbus_message_iter_open_container(&iterator, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, executed (the execution status of this line is deduced): q_dbus_message_iter_open_container(&iterator, ((int) 'a'), "y", | - |
166 | &subiterator); executed (the execution status of this line is deduced): &subiterator); | - |
167 | q_dbus_message_iter_append_fixed_array(&subiterator, DBUS_TYPE_BYTE, &cdata, arg.length()); executed (the execution status of this line is deduced): q_dbus_message_iter_append_fixed_array(&subiterator, ((int) 'y'), &cdata, arg.length()); | - |
168 | q_dbus_message_iter_close_container(&iterator, &subiterator); executed (the execution status of this line is deduced): q_dbus_message_iter_close_container(&iterator, &subiterator); | - |
169 | } executed: } Execution Count:6 | 6 |
170 | | - |
171 | inline bool QDBusMarshaller::append(const QDBusVariant &arg) | - |
172 | { | - |
173 | if (ba) { partially evaluated: ba no Evaluation Count:0 | yes Evaluation Count:187 |
| 0-187 |
174 | *ba += DBUS_TYPE_VARIANT_AS_STRING; never executed (the execution status of this line is deduced): *ba += "v"; | - |
175 | return true; never executed: return true; | 0 |
176 | } | - |
177 | | - |
178 | const QVariant &value = arg.variant(); executed (the execution status of this line is deduced): const QVariant &value = arg.variant(); | - |
179 | int id = value.userType(); executed (the execution status of this line is deduced): int id = value.userType(); | - |
180 | if (id == QVariant::Invalid) { partially evaluated: id == QVariant::Invalid no Evaluation Count:0 | yes Evaluation Count:187 |
| 0-187 |
181 | qWarning("QDBusMarshaller: cannot add a null QDBusVariant"); never executed (the execution status of this line is deduced): QMessageLogger("qdbusmarshaller.cpp", 181, __PRETTY_FUNCTION__).warning("QDBusMarshaller: cannot add a null QDBusVariant"); | - |
182 | error(QLatin1String("Variant containing QVariant::Invalid passed in arguments")); never executed (the execution status of this line is deduced): error(QLatin1String("Variant containing QVariant::Invalid passed in arguments")); | - |
183 | return false; never executed: return false; | 0 |
184 | } | - |
185 | | - |
186 | QByteArray tmpSignature; executed (the execution status of this line is deduced): QByteArray tmpSignature; | - |
187 | const char *signature = 0; executed (the execution status of this line is deduced): const char *signature = 0; | - |
188 | if (id == QDBusMetaTypeId::argument()) { partially evaluated: id == QDBusMetaTypeId::argument() no Evaluation Count:0 | yes Evaluation Count:187 |
| 0-187 |
189 | // take the signature from the QDBusArgument object we're marshalling | - |
190 | tmpSignature = never executed (the execution status of this line is deduced): tmpSignature = | - |
191 | qvariant_cast<QDBusArgument>(value).currentSignature().toLatin1(); never executed (the execution status of this line is deduced): qvariant_cast<QDBusArgument>(value).currentSignature().toLatin1(); | - |
192 | signature = tmpSignature.constData(); never executed (the execution status of this line is deduced): signature = tmpSignature.constData(); | - |
193 | } else { | 0 |
194 | // take the signatuer from the metatype we're marshalling | - |
195 | signature = QDBusMetaType::typeToSignature(id); executed (the execution status of this line is deduced): signature = QDBusMetaType::typeToSignature(id); | - |
196 | } executed: } Execution Count:187 | 187 |
197 | if (!signature) { partially evaluated: !signature no Evaluation Count:0 | yes Evaluation Count:187 |
| 0-187 |
198 | qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " never executed (the execution status of this line is deduced): QMessageLogger("qdbusmarshaller.cpp", 198, __PRETTY_FUNCTION__).warning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " | - |
199 | "Use qDBusRegisterMetaType to register it", never executed (the execution status of this line is deduced): "Use qDBusRegisterMetaType to register it", | - |
200 | QMetaType::typeName(id), id); never executed (the execution status of this line is deduced): QMetaType::typeName(id), id); | - |
201 | error(QString::fromLatin1("Unregistered type %1 passed in arguments") never executed (the execution status of this line is deduced): error(QString::fromLatin1("Unregistered type %1 passed in arguments") | - |
202 | .arg(QLatin1String(QMetaType::typeName(id)))); never executed (the execution status of this line is deduced): .arg(QLatin1String(QMetaType::typeName(id)))); | - |
203 | return false; never executed: return false; | 0 |
204 | } | - |
205 | | - |
206 | QDBusMarshaller sub(capabilities); executed (the execution status of this line is deduced): QDBusMarshaller sub(capabilities); | - |
207 | open(sub, DBUS_TYPE_VARIANT, signature); executed (the execution status of this line is deduced): open(sub, ((int) 'v'), signature); | - |
208 | bool isOk = sub.appendVariantInternal(value); executed (the execution status of this line is deduced): bool isOk = sub.appendVariantInternal(value); | - |
209 | // don't call sub.close(): it auto-closes | - |
210 | | - |
211 | return isOk; executed: return isOk; Execution Count:187 | 187 |
212 | } | - |
213 | | - |
214 | inline void QDBusMarshaller::append(const QStringList &arg) | - |
215 | { | - |
216 | if (ba) { evaluated: ba yes Evaluation Count:4 | yes Evaluation Count:2 |
| 2-4 |
217 | *ba += DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING; executed (the execution status of this line is deduced): *ba += "a" "s"; | - |
218 | return; executed: return; Execution Count:4 | 4 |
219 | } | - |
220 | | - |
221 | QDBusMarshaller sub(capabilities); executed (the execution status of this line is deduced): QDBusMarshaller sub(capabilities); | - |
222 | open(sub, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING); executed (the execution status of this line is deduced): open(sub, ((int) 'a'), "s"); | - |
223 | QStringList::ConstIterator it = arg.constBegin(); executed (the execution status of this line is deduced): QStringList::ConstIterator it = arg.constBegin(); | - |
224 | QStringList::ConstIterator end = arg.constEnd(); executed (the execution status of this line is deduced): QStringList::ConstIterator end = arg.constEnd(); | - |
225 | for ( ; it != end; ++it) evaluated: it != end yes Evaluation Count:4 | yes Evaluation Count:2 |
| 2-4 |
226 | sub.append(*it); executed: sub.append(*it); Execution Count:4 | 4 |
227 | // don't call sub.close(): it auto-closes | - |
228 | } executed: } Execution Count:2 | 2 |
229 | | - |
230 | inline QDBusMarshaller *QDBusMarshaller::beginStructure() | - |
231 | { | - |
232 | return beginCommon(DBUS_TYPE_STRUCT, 0); executed: return beginCommon(((int) 'r'), 0); Execution Count:65 | 65 |
233 | } | - |
234 | | - |
235 | inline QDBusMarshaller *QDBusMarshaller::beginArray(int id) | - |
236 | { | - |
237 | const char *signature = QDBusMetaType::typeToSignature( QVariant::Type(id) ); executed (the execution status of this line is deduced): const char *signature = QDBusMetaType::typeToSignature( QVariant::Type(id) ); | - |
238 | if (!signature) { partially evaluated: !signature no Evaluation Count:0 | yes Evaluation Count:32 |
| 0-32 |
239 | qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " never executed (the execution status of this line is deduced): QMessageLogger("qdbusmarshaller.cpp", 239, __PRETTY_FUNCTION__).warning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " | - |
240 | "Use qDBusRegisterMetaType to register it", never executed (the execution status of this line is deduced): "Use qDBusRegisterMetaType to register it", | - |
241 | QMetaType::typeName(id), id); never executed (the execution status of this line is deduced): QMetaType::typeName(id), id); | - |
242 | error(QString::fromLatin1("Unregistered type %1 passed in arguments") never executed (the execution status of this line is deduced): error(QString::fromLatin1("Unregistered type %1 passed in arguments") | - |
243 | .arg(QLatin1String(QMetaType::typeName(id)))); never executed (the execution status of this line is deduced): .arg(QLatin1String(QMetaType::typeName(id)))); | - |
244 | return this; never executed: return this; | 0 |
245 | } | - |
246 | | - |
247 | return beginCommon(DBUS_TYPE_ARRAY, signature); executed: return beginCommon(((int) 'a'), signature); Execution Count:32 | 32 |
248 | } | - |
249 | | - |
250 | inline QDBusMarshaller *QDBusMarshaller::beginMap(int kid, int vid) | - |
251 | { | - |
252 | const char *ksignature = QDBusMetaType::typeToSignature( QVariant::Type(kid) ); executed (the execution status of this line is deduced): const char *ksignature = QDBusMetaType::typeToSignature( QVariant::Type(kid) ); | - |
253 | if (!ksignature) { partially evaluated: !ksignature no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-34 |
254 | qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " never executed (the execution status of this line is deduced): QMessageLogger("qdbusmarshaller.cpp", 254, __PRETTY_FUNCTION__).warning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " | - |
255 | "Use qDBusRegisterMetaType to register it", never executed (the execution status of this line is deduced): "Use qDBusRegisterMetaType to register it", | - |
256 | QMetaType::typeName(kid), kid); never executed (the execution status of this line is deduced): QMetaType::typeName(kid), kid); | - |
257 | error(QString::fromLatin1("Unregistered type %1 passed in arguments") never executed (the execution status of this line is deduced): error(QString::fromLatin1("Unregistered type %1 passed in arguments") | - |
258 | .arg(QLatin1String(QMetaType::typeName(kid)))); never executed (the execution status of this line is deduced): .arg(QLatin1String(QMetaType::typeName(kid)))); | - |
259 | return this; never executed: return this; | 0 |
260 | } | - |
261 | if (ksignature[1] != 0 || !QDBusUtil::isValidBasicType(*ksignature)) { partially evaluated: ksignature[1] != 0 no Evaluation Count:0 | yes Evaluation Count:34 |
partially evaluated: !QDBusUtil::isValidBasicType(*ksignature) no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-34 |
262 | qWarning("QDBusMarshaller: type '%s' (%d) cannot be used as the key type in a D-BUS map.", never executed (the execution status of this line is deduced): QMessageLogger("qdbusmarshaller.cpp", 262, __PRETTY_FUNCTION__).warning("QDBusMarshaller: type '%s' (%d) cannot be used as the key type in a D-BUS map.", | - |
263 | QMetaType::typeName(kid), kid); never executed (the execution status of this line is deduced): QMetaType::typeName(kid), kid); | - |
264 | error(QString::fromLatin1("Type %1 passed in arguments cannot be used as a key in a map") never executed (the execution status of this line is deduced): error(QString::fromLatin1("Type %1 passed in arguments cannot be used as a key in a map") | - |
265 | .arg(QLatin1String(QMetaType::typeName(kid)))); never executed (the execution status of this line is deduced): .arg(QLatin1String(QMetaType::typeName(kid)))); | - |
266 | return this; never executed: return this; | 0 |
267 | } | - |
268 | | - |
269 | const char *vsignature = QDBusMetaType::typeToSignature( QVariant::Type(vid) ); executed (the execution status of this line is deduced): const char *vsignature = QDBusMetaType::typeToSignature( QVariant::Type(vid) ); | - |
270 | if (!vsignature) { partially evaluated: !vsignature no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-34 |
271 | const char *typeName = QMetaType::typeName(vid); never executed (the execution status of this line is deduced): const char *typeName = QMetaType::typeName(vid); | - |
272 | qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " never executed (the execution status of this line is deduced): QMessageLogger("qdbusmarshaller.cpp", 272, __PRETTY_FUNCTION__).warning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " | - |
273 | "Use qDBusRegisterMetaType to register it", never executed (the execution status of this line is deduced): "Use qDBusRegisterMetaType to register it", | - |
274 | typeName, vid); never executed (the execution status of this line is deduced): typeName, vid); | - |
275 | error(QString::fromLatin1("Unregistered type %1 passed in arguments") never executed (the execution status of this line is deduced): error(QString::fromLatin1("Unregistered type %1 passed in arguments") | - |
276 | .arg(QLatin1String(typeName))); never executed (the execution status of this line is deduced): .arg(QLatin1String(typeName))); | - |
277 | return this; never executed: return this; | 0 |
278 | } | - |
279 | | - |
280 | QByteArray signature; executed (the execution status of this line is deduced): QByteArray signature; | - |
281 | signature = DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING; executed (the execution status of this line is deduced): signature = "{"; | - |
282 | signature += ksignature; executed (the execution status of this line is deduced): signature += ksignature; | - |
283 | signature += vsignature; executed (the execution status of this line is deduced): signature += vsignature; | - |
284 | signature += DBUS_DICT_ENTRY_END_CHAR_AS_STRING; executed (the execution status of this line is deduced): signature += "}"; | - |
285 | return beginCommon(DBUS_TYPE_ARRAY, signature); executed: return beginCommon(((int) 'a'), signature); Execution Count:34 | 34 |
286 | } | - |
287 | | - |
288 | inline QDBusMarshaller *QDBusMarshaller::beginMapEntry() | - |
289 | { | - |
290 | return beginCommon(DBUS_TYPE_DICT_ENTRY, 0); executed: return beginCommon(((int) 'e'), 0); Execution Count:54 | 54 |
291 | } | - |
292 | | - |
293 | void QDBusMarshaller::open(QDBusMarshaller &sub, int code, const char *signature) | - |
294 | { | - |
295 | sub.parent = this; executed (the execution status of this line is deduced): sub.parent = this; | - |
296 | sub.ba = ba; executed (the execution status of this line is deduced): sub.ba = ba; | - |
297 | sub.ok = true; executed (the execution status of this line is deduced): sub.ok = true; | - |
298 | sub.capabilities = capabilities; executed (the execution status of this line is deduced): sub.capabilities = capabilities; | - |
299 | | - |
300 | if (ba) evaluated: ba yes Evaluation Count:65 | yes Evaluation Count:309 |
| 65-309 |
301 | switch (code) { | - |
302 | case DBUS_TYPE_ARRAY: | - |
303 | *ba += char(code); executed (the execution status of this line is deduced): *ba += char(code); | - |
304 | *ba += signature; executed (the execution status of this line is deduced): *ba += signature; | - |
305 | // fall through | - |
306 | | - |
307 | case DBUS_TYPE_DICT_ENTRY: code before this statement executed: case ((int) 'e'): Execution Count:32 | 32 |
308 | sub.closeCode = 0; executed (the execution status of this line is deduced): sub.closeCode = 0; | - |
309 | break; executed: break; Execution Count:32 | 32 |
310 | | - |
311 | case DBUS_TYPE_STRUCT: | - |
312 | *ba += DBUS_STRUCT_BEGIN_CHAR; executed (the execution status of this line is deduced): *ba += ((int) '('); | - |
313 | sub.closeCode = DBUS_STRUCT_END_CHAR; executed (the execution status of this line is deduced): sub.closeCode = ((int) ')'); | - |
314 | break; executed: break; Execution Count:33 | 33 |
315 | } | 0 |
316 | else | - |
317 | q_dbus_message_iter_open_container(&iterator, code, signature, &sub.iterator); executed: q_dbus_message_iter_open_container(&iterator, code, signature, &sub.iterator); Execution Count:309 | 309 |
318 | } | - |
319 | | - |
320 | QDBusMarshaller *QDBusMarshaller::beginCommon(int code, const char *signature) | - |
321 | { | - |
322 | QDBusMarshaller *d = new QDBusMarshaller(capabilities); executed (the execution status of this line is deduced): QDBusMarshaller *d = new QDBusMarshaller(capabilities); | - |
323 | open(*d, code, signature); executed (the execution status of this line is deduced): open(*d, code, signature); | - |
324 | return d; executed: return d; Execution Count:185 | 185 |
325 | } | - |
326 | | - |
327 | inline QDBusMarshaller *QDBusMarshaller::endStructure() | - |
328 | { return endCommon(); } executed: return endCommon(); Execution Count:65 | 65 |
329 | | - |
330 | inline QDBusMarshaller *QDBusMarshaller::endArray() | - |
331 | { return endCommon(); } executed: return endCommon(); Execution Count:32 | 32 |
332 | | - |
333 | inline QDBusMarshaller *QDBusMarshaller::endMap() | - |
334 | { return endCommon(); } executed: return endCommon(); Execution Count:34 | 34 |
335 | | - |
336 | inline QDBusMarshaller *QDBusMarshaller::endMapEntry() | - |
337 | { return endCommon(); } executed: return endCommon(); Execution Count:54 | 54 |
338 | | - |
339 | QDBusMarshaller *QDBusMarshaller::endCommon() | - |
340 | { | - |
341 | QDBusMarshaller *retval = parent; executed (the execution status of this line is deduced): QDBusMarshaller *retval = parent; | - |
342 | delete this; executed (the execution status of this line is deduced): delete this; | - |
343 | return retval; executed: return retval; Execution Count:185 | 185 |
344 | } | - |
345 | | - |
346 | void QDBusMarshaller::close() | - |
347 | { | - |
348 | if (ba) { evaluated: ba yes Evaluation Count:126 | yes Evaluation Count:2031 |
| 126-2031 |
349 | if (closeCode) evaluated: closeCode yes Evaluation Count:33 | yes Evaluation Count:93 |
| 33-93 |
350 | *ba += closeCode; executed: *ba += closeCode; Execution Count:33 | 33 |
351 | } else if (parent) { executed: } Execution Count:126 evaluated: parent yes Evaluation Count:309 | yes Evaluation Count:1722 |
| 126-1722 |
352 | q_dbus_message_iter_close_container(&parent->iterator, &iterator); executed (the execution status of this line is deduced): q_dbus_message_iter_close_container(&parent->iterator, &iterator); | - |
353 | } executed: } Execution Count:309 | 309 |
354 | } | - |
355 | | - |
356 | void QDBusMarshaller::error(const QString &msg) | - |
357 | { | - |
358 | ok = false; never executed (the execution status of this line is deduced): ok = false; | - |
359 | if (parent) | 0 |
360 | parent->error(msg); never executed: parent->error(msg); | 0 |
361 | else | - |
362 | errorString = msg; never executed: errorString = msg; | 0 |
363 | } | - |
364 | | - |
365 | bool QDBusMarshaller::appendVariantInternal(const QVariant &arg) | - |
366 | { | - |
367 | int id = arg.userType(); executed (the execution status of this line is deduced): int id = arg.userType(); | - |
368 | if (id == QVariant::Invalid) { partially evaluated: id == QVariant::Invalid no Evaluation Count:0 | yes Evaluation Count:1617 |
| 0-1617 |
369 | qWarning("QDBusMarshaller: cannot add an invalid QVariant"); never executed (the execution status of this line is deduced): QMessageLogger("qdbusmarshaller.cpp", 369, __PRETTY_FUNCTION__).warning("QDBusMarshaller: cannot add an invalid QVariant"); | - |
370 | error(QLatin1String("Variant containing QVariant::Invalid passed in arguments")); never executed (the execution status of this line is deduced): error(QLatin1String("Variant containing QVariant::Invalid passed in arguments")); | - |
371 | return false; never executed: return false; | 0 |
372 | } | - |
373 | | - |
374 | // intercept QDBusArgument parameters here | - |
375 | if (id == QDBusMetaTypeId::argument()) { evaluated: id == QDBusMetaTypeId::argument() yes Evaluation Count:2 | yes Evaluation Count:1615 |
| 2-1615 |
376 | QDBusArgument dbusargument = qvariant_cast<QDBusArgument>(arg); executed (the execution status of this line is deduced): QDBusArgument dbusargument = qvariant_cast<QDBusArgument>(arg); | - |
377 | QDBusArgumentPrivate *d = QDBusArgumentPrivate::d(dbusargument); executed (the execution status of this line is deduced): QDBusArgumentPrivate *d = QDBusArgumentPrivate::d(dbusargument); | - |
378 | if (!d->message) partially evaluated: !d->message no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
379 | return false; // can't append this one... never executed: return false; | 0 |
380 | | - |
381 | QDBusDemarshaller demarshaller(capabilities); executed (the execution status of this line is deduced): QDBusDemarshaller demarshaller(capabilities); | - |
382 | demarshaller.message = q_dbus_message_ref(d->message); executed (the execution status of this line is deduced): demarshaller.message = q_dbus_message_ref(d->message); | - |
383 | | - |
384 | if (d->direction == Demarshalling) { partially evaluated: d->direction == Demarshalling yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
385 | // it's demarshalling; just copy | - |
386 | demarshaller.iterator = static_cast<QDBusDemarshaller *>(d)->iterator; executed (the execution status of this line is deduced): demarshaller.iterator = static_cast<QDBusDemarshaller *>(d)->iterator; | - |
387 | } else { executed: } Execution Count:2 | 2 |
388 | // it's marshalling; start over | - |
389 | if (!q_dbus_message_iter_init(demarshaller.message, &demarshaller.iterator)) never evaluated: !q_dbus_message_iter_init(demarshaller.message, &demarshaller.iterator) | 0 |
390 | return false; // error! never executed: return false; | 0 |
391 | } | 0 |
392 | | - |
393 | return appendCrossMarshalling(&demarshaller); executed: return appendCrossMarshalling(&demarshaller); Execution Count:2 | 2 |
394 | } | - |
395 | | - |
396 | const char *signature = QDBusMetaType::typeToSignature( QVariant::Type(id) ); executed (the execution status of this line is deduced): const char *signature = QDBusMetaType::typeToSignature( QVariant::Type(id) ); | - |
397 | if (!signature) { partially evaluated: !signature no Evaluation Count:0 | yes Evaluation Count:1615 |
| 0-1615 |
398 | qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " never executed (the execution status of this line is deduced): QMessageLogger("qdbusmarshaller.cpp", 398, __PRETTY_FUNCTION__).warning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " | - |
399 | "Use qDBusRegisterMetaType to register it", never executed (the execution status of this line is deduced): "Use qDBusRegisterMetaType to register it", | - |
400 | QMetaType::typeName(id), id); never executed (the execution status of this line is deduced): QMetaType::typeName(id), id); | - |
401 | error(QString::fromLatin1("Unregistered type %1 passed in arguments") never executed (the execution status of this line is deduced): error(QString::fromLatin1("Unregistered type %1 passed in arguments") | - |
402 | .arg(QLatin1String(QMetaType::typeName(id)))); never executed (the execution status of this line is deduced): .arg(QLatin1String(QMetaType::typeName(id)))); | - |
403 | return false; never executed: return false; | 0 |
404 | } | - |
405 | | - |
406 | switch (*signature) { | - |
407 | #ifdef __OPTIMIZE__ | - |
408 | case DBUS_TYPE_BYTE: | - |
409 | case DBUS_TYPE_INT16: | - |
410 | case DBUS_TYPE_UINT16: | - |
411 | case DBUS_TYPE_INT32: | - |
412 | case DBUS_TYPE_UINT32: | - |
413 | case DBUS_TYPE_INT64: | - |
414 | case DBUS_TYPE_UINT64: | - |
415 | case DBUS_TYPE_DOUBLE: | - |
416 | qIterAppend(&iterator, ba, *signature, arg.constData()); executed (the execution status of this line is deduced): qIterAppend(&iterator, ba, *signature, arg.constData()); | - |
417 | return true; executed: return true; Execution Count:177 | 177 |
418 | case DBUS_TYPE_BOOLEAN: | - |
419 | append( arg.toBool() ); never executed (the execution status of this line is deduced): append( arg.toBool() ); | - |
420 | return true; never executed: return true; | 0 |
421 | #else | - |
422 | case DBUS_TYPE_BYTE: | - |
423 | append( qvariant_cast<uchar>(arg) ); | - |
424 | return true; | - |
425 | case DBUS_TYPE_BOOLEAN: | - |
426 | append( arg.toBool() ); | - |
427 | return true; | - |
428 | case DBUS_TYPE_INT16: | - |
429 | append( qvariant_cast<short>(arg) ); | - |
430 | return true; | - |
431 | case DBUS_TYPE_UINT16: | - |
432 | append( qvariant_cast<ushort>(arg) ); | - |
433 | return true; | - |
434 | case DBUS_TYPE_INT32: | - |
435 | append( static_cast<dbus_int32_t>(arg.toInt()) ); | - |
436 | return true; | - |
437 | case DBUS_TYPE_UINT32: | - |
438 | append( static_cast<dbus_uint32_t>(arg.toUInt()) ); | - |
439 | return true; | - |
440 | case DBUS_TYPE_INT64: | - |
441 | append( arg.toLongLong() ); | - |
442 | return true; | - |
443 | case DBUS_TYPE_UINT64: | - |
444 | append( arg.toULongLong() ); | - |
445 | return true; | - |
446 | case DBUS_TYPE_DOUBLE: | - |
447 | append( arg.toDouble() ); | - |
448 | return true; | - |
449 | #endif | - |
450 | | - |
451 | case DBUS_TYPE_STRING: | - |
452 | append( arg.toString() ); executed (the execution status of this line is deduced): append( arg.toString() ); | - |
453 | return true; executed: return true; Execution Count:1237 | 1237 |
454 | case DBUS_TYPE_OBJECT_PATH: | - |
455 | append( qvariant_cast<QDBusObjectPath>(arg) ); never executed (the execution status of this line is deduced): append( qvariant_cast<QDBusObjectPath>(arg) ); | - |
456 | return true; never executed: return true; | 0 |
457 | case DBUS_TYPE_SIGNATURE: | - |
458 | append( qvariant_cast<QDBusSignature>(arg) ); never executed (the execution status of this line is deduced): append( qvariant_cast<QDBusSignature>(arg) ); | - |
459 | return true; never executed: return true; | 0 |
460 | | - |
461 | // compound types: | - |
462 | case DBUS_TYPE_VARIANT: | - |
463 | // nested QVariant | - |
464 | return append( qvariant_cast<QDBusVariant>(arg) ); executed: return append( qvariant_cast<QDBusVariant>(arg) ); Execution Count:139 | 139 |
465 | | - |
466 | case DBUS_TYPE_ARRAY: | - |
467 | // could be many things | - |
468 | // find out what kind of array it is | - |
469 | switch (arg.type()) { | - |
470 | case QVariant::StringList: | - |
471 | append( arg.toStringList() ); executed (the execution status of this line is deduced): append( arg.toStringList() ); | - |
472 | return true; executed: return true; Execution Count:2 | 2 |
473 | | - |
474 | case QVariant::ByteArray: | - |
475 | append( arg.toByteArray() ); executed (the execution status of this line is deduced): append( arg.toByteArray() ); | - |
476 | return true; executed: return true; Execution Count:6 | 6 |
477 | | - |
478 | default: | - |
479 | ; // fall through | - |
480 | } executed: } Execution Count:34 | 34 |
481 | // fall through | - |
482 | | - |
483 | case DBUS_TYPE_STRUCT: | - |
484 | case DBUS_STRUCT_BEGIN_CHAR: | - |
485 | return appendRegisteredType( arg ); executed: return appendRegisteredType( arg ); Execution Count:54 | 54 |
486 | | - |
487 | case DBUS_TYPE_DICT_ENTRY: | - |
488 | case DBUS_DICT_ENTRY_BEGIN_CHAR: | - |
489 | qFatal("QDBusMarshaller::appendVariantInternal got a DICT_ENTRY!"); never executed (the execution status of this line is deduced): QMessageLogger("qdbusmarshaller.cpp", 489, __PRETTY_FUNCTION__).fatal("QDBusMarshaller::appendVariantInternal got a DICT_ENTRY!"); | - |
490 | return false; never executed: return false; | 0 |
491 | | - |
492 | case DBUS_TYPE_UNIX_FD: | - |
493 | if (capabilities & QDBusConnection::UnixFileDescriptorPassing || ba) { never evaluated: capabilities & QDBusConnection::UnixFileDescriptorPassing never evaluated: ba | 0 |
494 | append(qvariant_cast<QDBusUnixFileDescriptor>(arg)); never executed (the execution status of this line is deduced): append(qvariant_cast<QDBusUnixFileDescriptor>(arg)); | - |
495 | return true; never executed: return true; | 0 |
496 | } | - |
497 | // fall through | - |
498 | | - |
499 | default: code before this statement never executed: default: | 0 |
500 | qWarning("QDBusMarshaller::appendVariantInternal: Found unknown D-BUS type '%s'", never executed (the execution status of this line is deduced): QMessageLogger("qdbusmarshaller.cpp", 500, __PRETTY_FUNCTION__).warning("QDBusMarshaller::appendVariantInternal: Found unknown D-BUS type '%s'", | - |
501 | signature); never executed (the execution status of this line is deduced): signature); | - |
502 | return false; never executed: return false; | 0 |
503 | } | - |
504 | | - |
505 | return true; never executed: return true; | 0 |
506 | } | - |
507 | | - |
508 | bool QDBusMarshaller::appendRegisteredType(const QVariant &arg) | - |
509 | { | - |
510 | ref.ref(); // reference up executed (the execution status of this line is deduced): ref.ref(); | - |
511 | QDBusArgument self(QDBusArgumentPrivate::create(this)); executed (the execution status of this line is deduced): QDBusArgument self(QDBusArgumentPrivate::create(this)); | - |
512 | return QDBusMetaType::marshall(self, arg.userType(), arg.constData()); executed: return QDBusMetaType::marshall(self, arg.userType(), arg.constData()); Execution Count:54 | 54 |
513 | } | - |
514 | | - |
515 | bool QDBusMarshaller::appendCrossMarshalling(QDBusDemarshaller *demarshaller) | - |
516 | { | - |
517 | int code = q_dbus_message_iter_get_arg_type(&demarshaller->iterator); executed (the execution status of this line is deduced): int code = q_dbus_message_iter_get_arg_type(&demarshaller->iterator); | - |
518 | if (QDBusUtil::isValidBasicType(code)) { partially evaluated: QDBusUtil::isValidBasicType(code) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
519 | // easy: just append | - |
520 | // do exactly like the D-BUS docs suggest | - |
521 | // (see apidocs for q_dbus_message_iter_get_basic) | - |
522 | | - |
523 | qlonglong value; never executed (the execution status of this line is deduced): qlonglong value; | - |
524 | q_dbus_message_iter_get_basic(&demarshaller->iterator, &value); never executed (the execution status of this line is deduced): q_dbus_message_iter_get_basic(&demarshaller->iterator, &value); | - |
525 | q_dbus_message_iter_next(&demarshaller->iterator); never executed (the execution status of this line is deduced): q_dbus_message_iter_next(&demarshaller->iterator); | - |
526 | q_dbus_message_iter_append_basic(&iterator, code, &value); never executed (the execution status of this line is deduced): q_dbus_message_iter_append_basic(&iterator, code, &value); | - |
527 | return true; never executed: return true; | 0 |
528 | } | - |
529 | | - |
530 | if (code == DBUS_TYPE_ARRAY) { partially evaluated: code == ((int) 'a') yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
531 | int element = q_dbus_message_iter_get_element_type(&demarshaller->iterator); executed (the execution status of this line is deduced): int element = q_dbus_message_iter_get_element_type(&demarshaller->iterator); | - |
532 | if (QDBusUtil::isValidFixedType(element) && element != DBUS_TYPE_UNIX_FD) { partially evaluated: QDBusUtil::isValidFixedType(element) yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: element != int('h') yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
533 | // another optimization: fixed size arrays | - |
534 | // code is exactly like QDBusDemarshaller::toByteArray | - |
535 | DBusMessageIter sub; executed (the execution status of this line is deduced): DBusMessageIter sub; | - |
536 | q_dbus_message_iter_recurse(&demarshaller->iterator, &sub); executed (the execution status of this line is deduced): q_dbus_message_iter_recurse(&demarshaller->iterator, &sub); | - |
537 | q_dbus_message_iter_next(&demarshaller->iterator); executed (the execution status of this line is deduced): q_dbus_message_iter_next(&demarshaller->iterator); | - |
538 | int len; executed (the execution status of this line is deduced): int len; | - |
539 | void* data; executed (the execution status of this line is deduced): void* data; | - |
540 | q_dbus_message_iter_get_fixed_array(&sub,&data,&len); executed (the execution status of this line is deduced): q_dbus_message_iter_get_fixed_array(&sub,&data,&len); | - |
541 | | - |
542 | char signature[2] = { char(element), 0 }; executed (the execution status of this line is deduced): char signature[2] = { char(element), 0 }; | - |
543 | q_dbus_message_iter_open_container(&iterator, DBUS_TYPE_ARRAY, signature, &sub); executed (the execution status of this line is deduced): q_dbus_message_iter_open_container(&iterator, ((int) 'a'), signature, &sub); | - |
544 | q_dbus_message_iter_append_fixed_array(&sub, element, &data, len); executed (the execution status of this line is deduced): q_dbus_message_iter_append_fixed_array(&sub, element, &data, len); | - |
545 | q_dbus_message_iter_close_container(&iterator, &sub); executed (the execution status of this line is deduced): q_dbus_message_iter_close_container(&iterator, &sub); | - |
546 | | - |
547 | return true; executed: return true; Execution Count:2 | 2 |
548 | } | - |
549 | } | 0 |
550 | | - |
551 | // We have to recurse | - |
552 | QDBusDemarshaller *drecursed = demarshaller->beginCommon(); never executed (the execution status of this line is deduced): QDBusDemarshaller *drecursed = demarshaller->beginCommon(); | - |
553 | | - |
554 | QDBusMarshaller mrecursed(capabilities); // create on the stack makes it autoclose never executed (the execution status of this line is deduced): QDBusMarshaller mrecursed(capabilities); | - |
555 | QByteArray subSignature; never executed (the execution status of this line is deduced): QByteArray subSignature; | - |
556 | const char *sig = 0; never executed (the execution status of this line is deduced): const char *sig = 0; | - |
557 | if (code == DBUS_TYPE_VARIANT || code == DBUS_TYPE_ARRAY) { never evaluated: code == ((int) 'v') never evaluated: code == ((int) 'a') | 0 |
558 | subSignature = drecursed->currentSignature().toLatin1(); never executed (the execution status of this line is deduced): subSignature = drecursed->currentSignature().toLatin1(); | - |
559 | if (!subSignature.isEmpty()) never evaluated: !subSignature.isEmpty() | 0 |
560 | sig = subSignature.constData(); never executed: sig = subSignature.constData(); | 0 |
561 | } | 0 |
562 | open(mrecursed, code, sig); never executed (the execution status of this line is deduced): open(mrecursed, code, sig); | - |
563 | | - |
564 | while (!drecursed->atEnd()) { never evaluated: !drecursed->atEnd() | 0 |
565 | if (!mrecursed.appendCrossMarshalling(drecursed)) { never evaluated: !mrecursed.appendCrossMarshalling(drecursed) | 0 |
566 | delete drecursed; never executed (the execution status of this line is deduced): delete drecursed; | - |
567 | return false; never executed: return false; | 0 |
568 | } | - |
569 | } | 0 |
570 | | - |
571 | delete drecursed; never executed (the execution status of this line is deduced): delete drecursed; | - |
572 | return true; never executed: return true; | 0 |
573 | } | - |
574 | | - |
575 | QT_END_NAMESPACE | - |
576 | | - |
577 | #endif // QT_NO_DBUS | - |
578 | | - |
| | |