summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusmarshaller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dbus/qdbusmarshaller.cpp')
-rw-r--r--src/dbus/qdbusmarshaller.cpp81
1 files changed, 24 insertions, 57 deletions
diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp
index 25749b66b5..b2ed2586fb 100644
--- a/src/dbus/qdbusmarshaller.cpp
+++ b/src/dbus/qdbusmarshaller.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtDBus module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbusargument_p.h"
#include "qdbusconnection.h"
@@ -46,6 +10,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static void qIterAppend(DBusMessageIter *it, QByteArray *ba, int type, const void *arg)
{
if (ba)
@@ -62,11 +28,11 @@ QDBusMarshaller::~QDBusMarshaller()
void QDBusMarshaller::unregisteredTypeError(QMetaType id)
{
const char *name = id.name();
- qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
+ qWarning("QDBusMarshaller: type '%s' (%d) is not registered with D-Bus. "
"Use qDBusRegisterMetaType to register it",
name ? name : "", id.id());
- error(QLatin1String("Unregistered type %1 passed in arguments")
- .arg(QLatin1String(id.name())));
+ error("Unregistered type %1 passed in arguments"_L1
+ .arg(QLatin1StringView(id.name())));
}
inline QString QDBusMarshaller::currentSignature()
@@ -143,7 +109,7 @@ inline void QDBusMarshaller::append(const QDBusObjectPath &arg)
{
QByteArray data = arg.path().toUtf8();
if (!ba && data.isEmpty()) {
- error(QLatin1String("Invalid object path passed in arguments"));
+ error("Invalid object path passed in arguments"_L1);
} else {
const char *cdata = data.constData();
if (!skipSignature)
@@ -155,7 +121,7 @@ inline void QDBusMarshaller::append(const QDBusSignature &arg)
{
QByteArray data = arg.signature().toUtf8();
if (!ba && data.isEmpty()) {
- error(QLatin1String("Invalid signature passed in arguments"));
+ error("Invalid signature passed in arguments"_L1);
} else {
const char *cdata = data.constData();
if (!skipSignature)
@@ -167,7 +133,7 @@ inline void QDBusMarshaller::append(const QDBusUnixFileDescriptor &arg)
{
int fd = arg.fileDescriptor();
if (!ba && fd == -1) {
- error(QLatin1String("Invalid file descriptor passed in arguments"));
+ error("Invalid file descriptor passed in arguments"_L1);
} else {
if (!skipSignature)
qIterAppend(&iterator, ba, DBUS_TYPE_UNIX_FD, &fd);
@@ -186,7 +152,7 @@ inline void QDBusMarshaller::append(const QByteArray &arg)
DBusMessageIter subiterator;
q_dbus_message_iter_open_container(&iterator, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING,
&subiterator);
- q_dbus_message_iter_append_fixed_array(&subiterator, DBUS_TYPE_BYTE, &cdata, arg.length());
+ q_dbus_message_iter_append_fixed_array(&subiterator, DBUS_TYPE_BYTE, &cdata, arg.size());
q_dbus_message_iter_close_container(&iterator, &subiterator);
}
@@ -202,7 +168,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg)
QMetaType id = value.metaType();
if (!id.isValid()) {
qWarning("QDBusMarshaller: cannot add a null QDBusVariant");
- error(QLatin1String("Invalid QVariant passed in arguments"));
+ error("Invalid QVariant passed in arguments"_L1);
return false;
}
@@ -240,10 +206,8 @@ inline void QDBusMarshaller::append(const QStringList &arg)
QDBusMarshaller sub(capabilities);
open(sub, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING);
- QStringList::ConstIterator it = arg.constBegin();
- QStringList::ConstIterator end = arg.constEnd();
- for ( ; it != end; ++it)
- sub.append(*it);
+ for (const QString &s : arg)
+ sub.append(s);
// don't call sub.close(): it auto-closes
}
@@ -271,10 +235,13 @@ inline QDBusMarshaller *QDBusMarshaller::beginMap(QMetaType kid, QMetaType vid)
return this;
}
if (ksignature[1] != 0 || !QDBusUtil::isValidBasicType(*ksignature)) {
- qWarning("QDBusMarshaller: type '%s' (%d) cannot be used as the key type in a D-BUS map.",
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wformat-overflow")
+ qWarning("QDBusMarshaller: type '%s' (%d) cannot be used as the key type in a D-Bus map.",
kid.name(), kid.id());
- error(QLatin1String("Type %1 passed in arguments cannot be used as a key in a map")
- .arg(QLatin1String(kid.name())));
+QT_WARNING_POP
+ error("Type %1 passed in arguments cannot be used as a key in a map"_L1
+ .arg(QLatin1StringView(kid.name())));
return this;
}
@@ -379,7 +346,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
QMetaType id = arg.metaType();
if (!id.isValid()) {
qWarning("QDBusMarshaller: cannot add an invalid QVariant");
- error(QLatin1String("Invalid QVariant passed in arguments"));
+ error("Invalid QVariant passed in arguments"_L1);
return false;
}
@@ -393,7 +360,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
QDBusDemarshaller demarshaller(capabilities);
demarshaller.message = q_dbus_message_ref(d->message);
- if (d->direction == Demarshalling) {
+ if (d->direction == Direction::Demarshalling) {
// it's demarshalling; just copy
demarshaller.iterator = static_cast<QDBusDemarshaller *>(d)->iterator;
} else {
@@ -505,7 +472,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
Q_FALLTHROUGH();
default:
- qWarning("QDBusMarshaller::appendVariantInternal: Found unknown D-BUS type '%s'",
+ qWarning("QDBusMarshaller::appendVariantInternal: Found unknown D-Bus type '%s'",
signature);
return false;
}
@@ -525,7 +492,7 @@ bool QDBusMarshaller::appendCrossMarshalling(QDBusDemarshaller *demarshaller)
int code = q_dbus_message_iter_get_arg_type(&demarshaller->iterator);
if (QDBusUtil::isValidBasicType(code)) {
// easy: just append
- // do exactly like the D-BUS docs suggest
+ // do exactly like the D-Bus docs suggest
// (see apidocs for q_dbus_message_iter_get_basic)
qlonglong value;