| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/dbus/qdbusdemarshaller.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtDBus module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||
| 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 The Qt Company. For licensing terms | - | ||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free | - | ||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||
| 25 | ** | - | ||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||
| 29 | ** | - | ||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||
| 31 | ** | - | ||||||
| 32 | ****************************************************************************/ | - | ||||||
| 33 | - | |||||||
| 34 | #include "qdbusargument_p.h" | - | ||||||
| 35 | #include "qdbusconnection.h" | - | ||||||
| 36 | - | |||||||
| 37 | #include <qscopedpointer.h> | - | ||||||
| 38 | - | |||||||
| 39 | #include <stdlib.h> | - | ||||||
| 40 | - | |||||||
| 41 | QT_BEGIN_NAMESPACE | - | ||||||
| 42 | - | |||||||
| 43 | template <typename T> | - | ||||||
| 44 | static inline T qIterGet(DBusMessageIter *it) | - | ||||||
| 45 | { | - | ||||||
| 46 | // Use a union of expected and largest type q_dbus_message_iter_get_basic | - | ||||||
| 47 | // will return to ensure reading the wrong basic type does not result in | - | ||||||
| 48 | // stack overwrite | - | ||||||
| 49 | union { | - | ||||||
| 50 | // The value to be extracted | - | ||||||
| 51 | T t; | - | ||||||
| 52 | // Largest type that q_dbus_message_iter_get_basic will return | - | ||||||
| 53 | // according to dbus_message_iter_get_basic API documentation | - | ||||||
| 54 | dbus_uint64_t maxValue; | - | ||||||
| 55 | // A pointer to ensure no stack overwrite in case there is a platform | - | ||||||
| 56 | // where sizeof(void*) > sizeof(dbus_uint64_t) | - | ||||||
| 57 | void* ptr; | - | ||||||
| 58 | } value; | - | ||||||
| 59 | - | |||||||
| 60 | // Initialize the value in case a narrower type is extracted to it. | - | ||||||
| 61 | // Note that the result of extracting a narrower type in place of a wider | - | ||||||
| 62 | // one and vice-versa will be platform-dependent. | - | ||||||
| 63 | value.t = T(); | - | ||||||
| 64 | - | |||||||
| 65 | q_dbus_message_iter_get_basic(it, &value); | - | ||||||
| 66 | q_dbus_message_iter_next(it); | - | ||||||
| 67 | return value.t; executed 10412 times by 282 tests: return value.t;Executed by:
| 10412 | ||||||
| 68 | } | - | ||||||
| 69 | - | |||||||
| 70 | QDBusDemarshaller::~QDBusDemarshaller() | - | ||||||
| 71 | { | - | ||||||
| 72 | } | - | ||||||
| 73 | - | |||||||
| 74 | inline QString QDBusDemarshaller::currentSignature() | - | ||||||
| 75 | { | - | ||||||
| 76 | char *sig = q_dbus_message_iter_get_signature(&iterator); | - | ||||||
| 77 | QString retval = QString::fromUtf8(sig); | - | ||||||
| 78 | q_dbus_free(sig); | - | ||||||
| 79 | - | |||||||
| 80 | return retval; executed 1086 times by 5 tests: return retval;Executed by:
| 1086 | ||||||
| 81 | } | - | ||||||
| 82 | - | |||||||
| 83 | inline uchar QDBusDemarshaller::toByte() | - | ||||||
| 84 | { | - | ||||||
| 85 | return qIterGet<uchar>(&iterator); executed 17 times by 1 test: return qIterGet<uchar>(&iterator);Executed by:
| 17 | ||||||
| 86 | } | - | ||||||
| 87 | - | |||||||
| 88 | inline bool QDBusDemarshaller::toBool() | - | ||||||
| 89 | { | - | ||||||
| 90 | return bool(qIterGet<dbus_bool_t>(&iterator)); executed 865 times by 150 tests: return bool(qIterGet<dbus_bool_t>(&iterator));Executed by:
| 865 | ||||||
| 91 | } | - | ||||||
| 92 | - | |||||||
| 93 | inline ushort QDBusDemarshaller::toUShort() | - | ||||||
| 94 | { | - | ||||||
| 95 | return qIterGet<dbus_uint16_t>(&iterator); executed 37 times by 1 test: return qIterGet<dbus_uint16_t>(&iterator);Executed by:
| 37 | ||||||
| 96 | } | - | ||||||
| 97 | - | |||||||
| 98 | inline short QDBusDemarshaller::toShort() | - | ||||||
| 99 | { | - | ||||||
| 100 | return qIterGet<dbus_int16_t>(&iterator); executed 57 times by 2 tests: return qIterGet<dbus_int16_t>(&iterator);Executed by:
| 57 | ||||||
| 101 | } | - | ||||||
| 102 | - | |||||||
| 103 | inline int QDBusDemarshaller::toInt() | - | ||||||
| 104 | { | - | ||||||
| 105 | return qIterGet<dbus_int32_t>(&iterator); executed 664 times by 26 tests: return qIterGet<dbus_int32_t>(&iterator);Executed by:
| 664 | ||||||
| 106 | } | - | ||||||
| 107 | - | |||||||
| 108 | inline uint QDBusDemarshaller::toUInt() | - | ||||||
| 109 | { | - | ||||||
| 110 | return qIterGet<dbus_uint32_t>(&iterator); executed 511 times by 27 tests: return qIterGet<dbus_uint32_t>(&iterator);Executed by:
| 511 | ||||||
| 111 | } | - | ||||||
| 112 | - | |||||||
| 113 | inline qlonglong QDBusDemarshaller::toLongLong() | - | ||||||
| 114 | { | - | ||||||
| 115 | return qIterGet<qlonglong>(&iterator); executed 57 times by 3 tests: return qIterGet<qlonglong>(&iterator);Executed by:
| 57 | ||||||
| 116 | } | - | ||||||
| 117 | - | |||||||
| 118 | inline qulonglong QDBusDemarshaller::toULongLong() | - | ||||||
| 119 | { | - | ||||||
| 120 | return qIterGet<qulonglong>(&iterator); executed 51 times by 17 tests: return qIterGet<qulonglong>(&iterator);Executed by:
| 51 | ||||||
| 121 | } | - | ||||||
| 122 | - | |||||||
| 123 | inline double QDBusDemarshaller::toDouble() | - | ||||||
| 124 | { | - | ||||||
| 125 | return qIterGet<double>(&iterator); executed 73 times by 1 test: return qIterGet<double>(&iterator);Executed by:
| 73 | ||||||
| 126 | } | - | ||||||
| 127 | - | |||||||
| 128 | inline QString QDBusDemarshaller::toStringUnchecked() | - | ||||||
| 129 | { | - | ||||||
| 130 | return QString::fromUtf8(qIterGet<char *>(&iterator)); executed 7351 times by 282 tests: return QString::fromUtf8(qIterGet<char *>(&iterator));Executed by:
| 7351 | ||||||
| 131 | } | - | ||||||
| 132 | - | |||||||
| 133 | inline QString QDBusDemarshaller::toString() | - | ||||||
| 134 | { | - | ||||||
| 135 | if (isCurrentTypeStringLike())
| 10-2630 | ||||||
| 136 | return toStringUnchecked(); executed 2630 times by 21 tests: return toStringUnchecked();Executed by:
| 2630 | ||||||
| 137 | else | - | ||||||
| 138 | return QString(); executed 10 times by 1 test: return QString();Executed by:
| 10 | ||||||
| 139 | } | - | ||||||
| 140 | - | |||||||
| 141 | inline QDBusObjectPath QDBusDemarshaller::toObjectPathUnchecked() | - | ||||||
| 142 | { | - | ||||||
| 143 | return QDBusObjectPath(QString::fromUtf8(qIterGet<char *>(&iterator))); executed 680 times by 18 tests: return QDBusObjectPath(QString::fromUtf8(qIterGet<char *>(&iterator)));Executed by:
| 680 | ||||||
| 144 | } | - | ||||||
| 145 | - | |||||||
| 146 | inline QDBusObjectPath QDBusDemarshaller::toObjectPath() | - | ||||||
| 147 | { | - | ||||||
| 148 | if (isCurrentTypeStringLike())
| 10-141 | ||||||
| 149 | return toObjectPathUnchecked(); executed 141 times by 18 tests: return toObjectPathUnchecked();Executed by:
| 141 | ||||||
| 150 | else | - | ||||||
| 151 | return QDBusObjectPath(); executed 10 times by 1 test: return QDBusObjectPath();Executed by:
| 10 | ||||||
| 152 | } | - | ||||||
| 153 | - | |||||||
| 154 | inline QDBusSignature QDBusDemarshaller::toSignatureUnchecked() | - | ||||||
| 155 | { | - | ||||||
| 156 | return QDBusSignature(QString::fromUtf8(qIterGet<char *>(&iterator))); executed 32 times by 1 test: return QDBusSignature(QString::fromUtf8(qIterGet<char *>(&iterator)));Executed by:
| 32 | ||||||
| 157 | } | - | ||||||
| 158 | - | |||||||
| 159 | inline QDBusSignature QDBusDemarshaller::toSignature() | - | ||||||
| 160 | { | - | ||||||
| 161 | if (isCurrentTypeStringLike())
| 10-14 | ||||||
| 162 | return toSignatureUnchecked(); executed 14 times by 1 test: return toSignatureUnchecked();Executed by:
| 14 | ||||||
| 163 | else | - | ||||||
| 164 | return QDBusSignature(); executed 10 times by 1 test: return QDBusSignature();Executed by:
| 10 | ||||||
| 165 | } | - | ||||||
| 166 | - | |||||||
| 167 | inline QDBusUnixFileDescriptor QDBusDemarshaller::toUnixFileDescriptor() | - | ||||||
| 168 | { | - | ||||||
| 169 | QDBusUnixFileDescriptor fd; | - | ||||||
| 170 | fd.giveFileDescriptor(qIterGet<dbus_int32_t>(&iterator)); | - | ||||||
| 171 | return fd; executed 17 times by 1 test: return fd;Executed by:
| 17 | ||||||
| 172 | } | - | ||||||
| 173 | - | |||||||
| 174 | inline QDBusVariant QDBusDemarshaller::toVariant() | - | ||||||
| 175 | { | - | ||||||
| 176 | QDBusDemarshaller sub(capabilities); | - | ||||||
| 177 | sub.message = q_dbus_message_ref(message); | - | ||||||
| 178 | q_dbus_message_iter_recurse(&iterator, &sub.iterator); | - | ||||||
| 179 | q_dbus_message_iter_next(&iterator); | - | ||||||
| 180 | - | |||||||
| 181 | return QDBusVariant( sub.toVariantInternal() ); executed 2994 times by 150 tests: return QDBusVariant( sub.toVariantInternal() );Executed by:
| 2994 | ||||||
| 182 | } | - | ||||||
| 183 | - | |||||||
| 184 | QDBusArgument::ElementType QDBusDemarshaller::currentType() | - | ||||||
| 185 | { | - | ||||||
| 186 | switch (q_dbus_message_iter_get_arg_type(&iterator)) { | - | ||||||
| 187 | case DBUS_TYPE_BYTE: executed 1 time by 1 test: case ((int) 'y'):Executed by:
| 1 | ||||||
| 188 | case DBUS_TYPE_INT16: executed 13 times by 1 test: case ((int) 'n'):Executed by:
| 13 | ||||||
| 189 | case DBUS_TYPE_UINT16: executed 11 times by 1 test: case ((int) 'q'):Executed by:
| 11 | ||||||
| 190 | case DBUS_TYPE_INT32: executed 160 times by 1 test: case ((int) 'i'):Executed by:
| 160 | ||||||
| 191 | case DBUS_TYPE_UINT32: executed 9 times by 1 test: case ((int) 'u'):Executed by:
| 9 | ||||||
| 192 | case DBUS_TYPE_INT64: executed 9 times by 1 test: case ((int) 'x'):Executed by:
| 9 | ||||||
| 193 | case DBUS_TYPE_UINT64: executed 7 times by 1 test: case ((int) 't'):Executed by:
| 7 | ||||||
| 194 | case DBUS_TYPE_BOOLEAN: executed 8 times by 1 test: case ((int) 'b'):Executed by:
| 8 | ||||||
| 195 | case DBUS_TYPE_DOUBLE: executed 27 times by 1 test: case ((int) 'd'):Executed by:
| 27 | ||||||
| 196 | case DBUS_TYPE_STRING: executed 40 times by 1 test: case ((int) 's'):Executed by:
| 40 | ||||||
| 197 | case DBUS_TYPE_OBJECT_PATH: executed 3 times by 1 test: case ((int) 'o'):Executed by:
| 3 | ||||||
| 198 | case DBUS_TYPE_SIGNATURE: executed 1 time by 1 test: case ((int) 'g'):Executed by:
| 1 | ||||||
| 199 | return QDBusArgument::BasicType; executed 289 times by 1 test: return QDBusArgument::BasicType;Executed by:
| 289 | ||||||
| 200 | - | |||||||
| 201 | case DBUS_TYPE_VARIANT: executed 62 times by 1 test: case ((int) 'v'):Executed by:
| 62 | ||||||
| 202 | return QDBusArgument::VariantType; executed 62 times by 1 test: return QDBusArgument::VariantType;Executed by:
| 62 | ||||||
| 203 | - | |||||||
| 204 | case DBUS_TYPE_ARRAY: executed 148 times by 1 test: case ((int) 'a'):Executed by:
| 148 | ||||||
| 205 | switch (q_dbus_message_iter_get_element_type(&iterator)) { | - | ||||||
| 206 | case DBUS_TYPE_BYTE: executed 7 times by 1 test: case ((int) 'y'):Executed by:
| 7 | ||||||
| 207 | case DBUS_TYPE_STRING: executed 5 times by 1 test: case ((int) 's'):Executed by:
| 5 | ||||||
| 208 | // QByteArray and QStringList | - | ||||||
| 209 | return QDBusArgument::BasicType; executed 12 times by 1 test: return QDBusArgument::BasicType;Executed by:
| 12 | ||||||
| 210 | case DBUS_TYPE_DICT_ENTRY: executed 27 times by 1 test: case ((int) 'e'):Executed by:
| 27 | ||||||
| 211 | return QDBusArgument::MapType; executed 27 times by 1 test: return QDBusArgument::MapType;Executed by:
| 27 | ||||||
| 212 | default: executed 109 times by 1 test: default:Executed by:
| 109 | ||||||
| 213 | return QDBusArgument::ArrayType; executed 109 times by 1 test: return QDBusArgument::ArrayType;Executed by:
| 109 | ||||||
| 214 | } | - | ||||||
| 215 | - | |||||||
| 216 | case DBUS_TYPE_STRUCT: executed 90 times by 1 test: case ((int) 'r'):Executed by:
| 90 | ||||||
| 217 | return QDBusArgument::StructureType; executed 90 times by 1 test: return QDBusArgument::StructureType;Executed by:
| 90 | ||||||
| 218 | case DBUS_TYPE_DICT_ENTRY: executed 79 times by 1 test: case ((int) 'e'):Executed by:
| 79 | ||||||
| 219 | return QDBusArgument::MapEntryType; executed 79 times by 1 test: return QDBusArgument::MapEntryType;Executed by:
| 79 | ||||||
| 220 | - | |||||||
| 221 | case DBUS_TYPE_UNIX_FD: executed 5 times by 1 test: case ((int) 'h'):Executed by:
| 5 | ||||||
| 222 | return capabilities & QDBusConnection::UnixFileDescriptorPassing ? executed 5 times by 1 test: return capabilities & QDBusConnection::UnixFileDescriptorPassing ? QDBusArgument::BasicType : QDBusArgument::UnknownType;Executed by:
| 0-5 | ||||||
| 223 | QDBusArgument::BasicType : QDBusArgument::UnknownType; executed 5 times by 1 test: return capabilities & QDBusConnection::UnixFileDescriptorPassing ? QDBusArgument::BasicType : QDBusArgument::UnknownType;Executed by:
| 5 | ||||||
| 224 | - | |||||||
| 225 | case DBUS_TYPE_INVALID: executed 21 times by 1 test: case ((int) '\0'):Executed by:
| 21 | ||||||
| 226 | return QDBusArgument::UnknownType; executed 21 times by 1 test: return QDBusArgument::UnknownType;Executed by:
| 21 | ||||||
| 227 | - | |||||||
| 228 | // default: | - | ||||||
| 229 | // qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'", | - | ||||||
| 230 | // q_dbus_message_iter_get_arg_type(&iterator), | - | ||||||
| 231 | // q_dbus_message_iter_get_arg_type(&iterator)); | - | ||||||
| 232 | } | - | ||||||
| 233 | return QDBusArgument::UnknownType; never executed: return QDBusArgument::UnknownType; | 0 | ||||||
| 234 | } | - | ||||||
| 235 | - | |||||||
| 236 | QVariant QDBusDemarshaller::toVariantInternal() | - | ||||||
| 237 | { | - | ||||||
| 238 | switch (q_dbus_message_iter_get_arg_type(&iterator)) { | - | ||||||
| 239 | case DBUS_TYPE_BYTE: executed 7 times by 1 test: case ((int) 'y'):Executed by:
| 7 | ||||||
| 240 | return QVariant::fromValue(toByte()); executed 7 times by 1 test: return QVariant::fromValue(toByte());Executed by:
| 7 | ||||||
| 241 | case DBUS_TYPE_INT16: executed 35 times by 2 tests: case ((int) 'n'):Executed by:
| 35 | ||||||
| 242 | return QVariant::fromValue(toShort()); executed 35 times by 2 tests: return QVariant::fromValue(toShort());Executed by:
| 35 | ||||||
| 243 | case DBUS_TYPE_UINT16: executed 17 times by 1 test: case ((int) 'q'):Executed by:
| 17 | ||||||
| 244 | return QVariant::fromValue(toUShort()); executed 17 times by 1 test: return QVariant::fromValue(toUShort());Executed by:
| 17 | ||||||
| 245 | case DBUS_TYPE_INT32: executed 404 times by 26 tests: case ((int) 'i'):Executed by:
| 404 | ||||||
| 246 | return toInt(); executed 404 times by 26 tests: return toInt();Executed by:
| 404 | ||||||
| 247 | case DBUS_TYPE_UINT32: executed 493 times by 27 tests: case ((int) 'u'):Executed by:
| 493 | ||||||
| 248 | return toUInt(); executed 493 times by 27 tests: return toUInt();Executed by:
| 493 | ||||||
| 249 | case DBUS_TYPE_DOUBLE: executed 37 times by 1 test: case ((int) 'd'):Executed by:
| 37 | ||||||
| 250 | return toDouble(); executed 37 times by 1 test: return toDouble();Executed by:
| 37 | ||||||
| 251 | case DBUS_TYPE_BOOLEAN: executed 849 times by 150 tests: case ((int) 'b'):Executed by:
| 849 | ||||||
| 252 | return toBool(); executed 849 times by 150 tests: return toBool();Executed by:
| 849 | ||||||
| 253 | case DBUS_TYPE_INT64: executed 29 times by 2 tests: case ((int) 'x'):Executed by:
| 29 | ||||||
| 254 | return toLongLong(); executed 29 times by 2 tests: return toLongLong();Executed by:
| 29 | ||||||
| 255 | case DBUS_TYPE_UINT64: executed 35 times by 17 tests: case ((int) 't'):Executed by:
| 35 | ||||||
| 256 | return toULongLong(); executed 35 times by 17 tests: return toULongLong();Executed by:
| 35 | ||||||
| 257 | case DBUS_TYPE_STRING: executed 2530 times by 282 tests: case ((int) 's'):Executed by:
| 2530 | ||||||
| 258 | return toStringUnchecked(); executed 2530 times by 282 tests: return toStringUnchecked();Executed by:
| 2530 | ||||||
| 259 | case DBUS_TYPE_OBJECT_PATH: executed 539 times by 17 tests: case ((int) 'o'):Executed by:
| 539 | ||||||
| 260 | return QVariant::fromValue(toObjectPathUnchecked()); executed 539 times by 17 tests: return QVariant::fromValue(toObjectPathUnchecked());Executed by:
| 539 | ||||||
| 261 | case DBUS_TYPE_SIGNATURE: executed 18 times by 1 test: case ((int) 'g'):Executed by:
| 18 | ||||||
| 262 | return QVariant::fromValue(toSignatureUnchecked()); executed 18 times by 1 test: return QVariant::fromValue(toSignatureUnchecked());Executed by:
| 18 | ||||||
| 263 | case DBUS_TYPE_VARIANT: executed 474 times by 135 tests: case ((int) 'v'):Executed by:
| 474 | ||||||
| 264 | return QVariant::fromValue(toVariant()); executed 474 times by 135 tests: return QVariant::fromValue(toVariant());Executed by:
| 474 | ||||||
| 265 | - | |||||||
| 266 | case DBUS_TYPE_ARRAY: executed 724 times by 28 tests: case ((int) 'a'):Executed by:
| 724 | ||||||
| 267 | switch (q_dbus_message_iter_get_element_type(&iterator)) { | - | ||||||
| 268 | case DBUS_TYPE_BYTE: executed 33 times by 4 tests: case ((int) 'y'):Executed by:
| 33 | ||||||
| 269 | // QByteArray | - | ||||||
| 270 | return toByteArrayUnchecked(); executed 33 times by 4 tests: return toByteArrayUnchecked();Executed by:
| 33 | ||||||
| 271 | case DBUS_TYPE_STRING: executed 37 times by 8 tests: case ((int) 's'):Executed by:
| 37 | ||||||
| 272 | return toStringListUnchecked(); executed 37 times by 8 tests: return toStringListUnchecked();Executed by:
| 37 | ||||||
| 273 | case DBUS_TYPE_DICT_ENTRY: executed 219 times by 21 tests: case ((int) 'e'):Executed by:
| 219 | ||||||
| 274 | return QVariant::fromValue(duplicate()); executed 219 times by 21 tests: return QVariant::fromValue(duplicate());Executed by:
| 219 | ||||||
| 275 | - | |||||||
| 276 | default: executed 435 times by 22 tests: default:Executed by:
| 435 | ||||||
| 277 | return QVariant::fromValue(duplicate()); executed 435 times by 22 tests: return QVariant::fromValue(duplicate());Executed by:
| 435 | ||||||
| 278 | } | - | ||||||
| 279 | - | |||||||
| 280 | case DBUS_TYPE_STRUCT: executed 542 times by 21 tests: case ((int) 'r'):Executed by:
| 542 | ||||||
| 281 | return QVariant::fromValue(duplicate()); executed 542 times by 21 tests: return QVariant::fromValue(duplicate());Executed by:
| 542 | ||||||
| 282 | - | |||||||
| 283 | case DBUS_TYPE_UNIX_FD: executed 16 times by 1 test: case ((int) 'h'):Executed by:
| 16 | ||||||
| 284 | if (capabilities & QDBusConnection::UnixFileDescriptorPassing)
| 3-13 | ||||||
| 285 | return QVariant::fromValue(toUnixFileDescriptor()); executed 13 times by 1 test: return QVariant::fromValue(toUnixFileDescriptor());Executed by:
| 13 | ||||||
| 286 | // fall through | - | ||||||
| 287 | - | |||||||
| 288 | default: code before this statement executed 3 times by 1 test: default:Executed by:
never executed: default: | 0-3 | ||||||
| 289 | // qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'", | - | ||||||
| 290 | // q_dbus_message_iter_get_arg_type(&iterator), | - | ||||||
| 291 | // q_dbus_message_iter_get_arg_type(&iterator)); | - | ||||||
| 292 | char *ptr = 0; | - | ||||||
| 293 | ptr += q_dbus_message_iter_get_arg_type(&iterator); | - | ||||||
| 294 | q_dbus_message_iter_next(&iterator); | - | ||||||
| 295 | - | |||||||
| 296 | // I hope you never dereference this pointer! | - | ||||||
| 297 | return QVariant::fromValue<void *>(ptr); executed 3 times by 1 test: return QVariant::fromValue<void *>(ptr);Executed by:
| 3 | ||||||
| 298 | }; | - | ||||||
| 299 | } | - | ||||||
| 300 | - | |||||||
| 301 | bool QDBusDemarshaller::isCurrentTypeStringLike() | - | ||||||
| 302 | { | - | ||||||
| 303 | const int type = q_dbus_message_iter_get_arg_type(&iterator); | - | ||||||
| 304 | switch (type) { | - | ||||||
| 305 | case DBUS_TYPE_STRING: //FALLTHROUGH executed 2636 times by 21 tests: case ((int) 's'):Executed by:
| 2636 | ||||||
| 306 | case DBUS_TYPE_OBJECT_PATH: //FALLTHROUGH executed 138 times by 18 tests: case ((int) 'o'):Executed by:
| 138 | ||||||
| 307 | case DBUS_TYPE_SIGNATURE: executed 11 times by 1 test: case ((int) 'g'):Executed by:
| 11 | ||||||
| 308 | return true; executed 2785 times by 21 tests: return true;Executed by:
| 2785 | ||||||
| 309 | default: executed 30 times by 1 test: default:Executed by:
| 30 | ||||||
| 310 | return false; executed 30 times by 1 test: return false;Executed by:
| 30 | ||||||
| 311 | } | - | ||||||
| 312 | } | - | ||||||
| 313 | - | |||||||
| 314 | QStringList QDBusDemarshaller::toStringListUnchecked() | - | ||||||
| 315 | { | - | ||||||
| 316 | QStringList list; | - | ||||||
| 317 | - | |||||||
| 318 | QDBusDemarshaller sub(capabilities); | - | ||||||
| 319 | q_dbus_message_iter_recurse(&iterator, &sub.iterator); | - | ||||||
| 320 | q_dbus_message_iter_next(&iterator); | - | ||||||
| 321 | while (!sub.atEnd())
| 42-2191 | ||||||
| 322 | list.append(sub.toStringUnchecked()); executed 2191 times by 8 tests: list.append(sub.toStringUnchecked());Executed by:
| 2191 | ||||||
| 323 | - | |||||||
| 324 | return list; executed 42 times by 8 tests: return list;Executed by:
| 42 | ||||||
| 325 | } | - | ||||||
| 326 | - | |||||||
| 327 | QStringList QDBusDemarshaller::toStringList() | - | ||||||
| 328 | { | - | ||||||
| 329 | if (q_dbus_message_iter_get_arg_type(&iterator) == DBUS_TYPE_ARRAY
| 9-15 | ||||||
| 330 | && q_dbus_message_iter_get_element_type(&iterator) == DBUS_TYPE_STRING)
| 4-5 | ||||||
| 331 | return toStringListUnchecked(); executed 5 times by 1 test: return toStringListUnchecked();Executed by:
| 5 | ||||||
| 332 | else | - | ||||||
| 333 | return QStringList(); executed 19 times by 1 test: return QStringList();Executed by:
| 19 | ||||||
| 334 | } | - | ||||||
| 335 | - | |||||||
| 336 | QByteArray QDBusDemarshaller::toByteArrayUnchecked() | - | ||||||
| 337 | { | - | ||||||
| 338 | DBusMessageIter sub; | - | ||||||
| 339 | q_dbus_message_iter_recurse(&iterator, &sub); | - | ||||||
| 340 | q_dbus_message_iter_next(&iterator); | - | ||||||
| 341 | int len; | - | ||||||
| 342 | char* data; | - | ||||||
| 343 | q_dbus_message_iter_get_fixed_array(&sub,&data,&len); | - | ||||||
| 344 | return QByteArray(data,len); executed 40 times by 4 tests: return QByteArray(data,len);Executed by:
| 40 | ||||||
| 345 | } | - | ||||||
| 346 | - | |||||||
| 347 | QByteArray QDBusDemarshaller::toByteArray() | - | ||||||
| 348 | { | - | ||||||
| 349 | if (q_dbus_message_iter_get_arg_type(&iterator) == DBUS_TYPE_ARRAY
| 11-15 | ||||||
| 350 | && q_dbus_message_iter_get_element_type(&iterator) == DBUS_TYPE_BYTE) {
| 4-7 | ||||||
| 351 | return toByteArrayUnchecked(); executed 7 times by 1 test: return toByteArrayUnchecked();Executed by:
| 7 | ||||||
| 352 | } | - | ||||||
| 353 | return QByteArray(); executed 19 times by 1 test: return QByteArray();Executed by:
| 19 | ||||||
| 354 | } | - | ||||||
| 355 | - | |||||||
| 356 | bool QDBusDemarshaller::atEnd() | - | ||||||
| 357 | { | - | ||||||
| 358 | // dbus_message_iter_has_next is broken if the list has one single element | - | ||||||
| 359 | return q_dbus_message_iter_get_arg_type(&iterator) == DBUS_TYPE_INVALID; executed 14889 times by 282 tests: return q_dbus_message_iter_get_arg_type(&iterator) == ((int) '\0');Executed by:
| 14889 | ||||||
| 360 | } | - | ||||||
| 361 | - | |||||||
| 362 | inline QDBusDemarshaller *QDBusDemarshaller::beginStructure() | - | ||||||
| 363 | { | - | ||||||
| 364 | return beginCommon(); executed 371 times by 5 tests: return beginCommon();Executed by:
| 371 | ||||||
| 365 | } | - | ||||||
| 366 | - | |||||||
| 367 | inline QDBusDemarshaller *QDBusDemarshaller::beginArray() | - | ||||||
| 368 | { | - | ||||||
| 369 | return beginCommon(); executed 339 times by 22 tests: return beginCommon();Executed by:
| 339 | ||||||
| 370 | } | - | ||||||
| 371 | - | |||||||
| 372 | inline QDBusDemarshaller *QDBusDemarshaller::beginMap() | - | ||||||
| 373 | { | - | ||||||
| 374 | return beginCommon(); executed 274 times by 21 tests: return beginCommon();Executed by:
| 274 | ||||||
| 375 | } | - | ||||||
| 376 | - | |||||||
| 377 | inline QDBusDemarshaller *QDBusDemarshaller::beginMapEntry() | - | ||||||
| 378 | { | - | ||||||
| 379 | return beginCommon(); executed 2678 times by 21 tests: return beginCommon();Executed by:
| 2678 | ||||||
| 380 | } | - | ||||||
| 381 | - | |||||||
| 382 | QDBusDemarshaller *QDBusDemarshaller::beginCommon() | - | ||||||
| 383 | { | - | ||||||
| 384 | QDBusDemarshaller *d = new QDBusDemarshaller(capabilities); | - | ||||||
| 385 | d->parent = this; | - | ||||||
| 386 | d->message = q_dbus_message_ref(message); | - | ||||||
| 387 | - | |||||||
| 388 | // recurse | - | ||||||
| 389 | q_dbus_message_iter_recurse(&iterator, &d->iterator); | - | ||||||
| 390 | q_dbus_message_iter_next(&iterator); | - | ||||||
| 391 | return d; executed 4418 times by 23 tests: return d;Executed by:
| 4418 | ||||||
| 392 | } | - | ||||||
| 393 | - | |||||||
| 394 | inline QDBusDemarshaller *QDBusDemarshaller::endStructure() | - | ||||||
| 395 | { | - | ||||||
| 396 | return endCommon(); executed 371 times by 5 tests: return endCommon();Executed by:
| 371 | ||||||
| 397 | } | - | ||||||
| 398 | - | |||||||
| 399 | inline QDBusDemarshaller *QDBusDemarshaller::endArray() | - | ||||||
| 400 | { | - | ||||||
| 401 | return endCommon(); executed 339 times by 22 tests: return endCommon();Executed by:
| 339 | ||||||
| 402 | } | - | ||||||
| 403 | - | |||||||
| 404 | inline QDBusDemarshaller *QDBusDemarshaller::endMap() | - | ||||||
| 405 | { | - | ||||||
| 406 | return endCommon(); executed 274 times by 21 tests: return endCommon();Executed by:
| 274 | ||||||
| 407 | } | - | ||||||
| 408 | - | |||||||
| 409 | inline QDBusDemarshaller *QDBusDemarshaller::endMapEntry() | - | ||||||
| 410 | { | - | ||||||
| 411 | return endCommon(); executed 2678 times by 21 tests: return endCommon();Executed by:
| 2678 | ||||||
| 412 | } | - | ||||||
| 413 | - | |||||||
| 414 | QDBusDemarshaller *QDBusDemarshaller::endCommon() | - | ||||||
| 415 | { | - | ||||||
| 416 | QDBusDemarshaller *retval = parent; | - | ||||||
| 417 | delete this; | - | ||||||
| 418 | return retval; executed 3662 times by 23 tests: return retval;Executed by:
| 3662 | ||||||
| 419 | } | - | ||||||
| 420 | - | |||||||
| 421 | QDBusArgument QDBusDemarshaller::duplicate() | - | ||||||
| 422 | { | - | ||||||
| 423 | QScopedPointer<QDBusDemarshaller> d(new QDBusDemarshaller(capabilities)); | - | ||||||
| 424 | d->iterator = iterator; | - | ||||||
| 425 | d->message = q_dbus_message_ref(message); | - | ||||||
| 426 | - | |||||||
| 427 | q_dbus_message_iter_next(&iterator); | - | ||||||
| 428 | return QDBusArgumentPrivate::create(d.take()); executed 1196 times by 23 tests: return QDBusArgumentPrivate::create(d.take());Executed by:
| 1196 | ||||||
| 429 | } | - | ||||||
| 430 | - | |||||||
| 431 | QT_END_NAMESPACE | - | ||||||
| Source code | Switch to Preprocessed file |