summaryrefslogtreecommitdiffstats
path: root/src/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/CMakeLists.txt21
-rw-r--r--src/dbus/Qt6DBusMacros.cmake88
-rw-r--r--src/dbus/dbus_minimal_p.h44
-rw-r--r--src/dbus/doc/qtdbus.qdocconf8
-rw-r--r--src/dbus/doc/snippets/CMakeLists.txt5
-rw-r--r--src/dbus/doc/snippets/cmake/examples.cmake3
-rw-r--r--src/dbus/doc/snippets/code/doc_src_introtodbus.qdoc51
-rw-r--r--src/dbus/doc/snippets/code/doc_src_qdbusadaptors.cpp51
-rw-r--r--src/dbus/doc/snippets/code/src_qdbus_qdbusabstractinterface.cpp79
-rw-r--r--src/dbus/doc/snippets/code/src_qdbus_qdbusargument.cpp51
-rw-r--r--src/dbus/doc/snippets/code/src_qdbus_qdbuscontext.cpp53
-rw-r--r--src/dbus/doc/snippets/code/src_qdbus_qdbusinterface.cpp51
-rw-r--r--src/dbus/doc/snippets/code/src_qdbus_qdbusmetatype.cpp51
-rw-r--r--src/dbus/doc/snippets/code/src_qdbus_qdbuspendingcall.cpp55
-rw-r--r--src/dbus/doc/snippets/code/src_qdbus_qdbuspendingreply.cpp51
-rw-r--r--src/dbus/doc/snippets/code/src_qdbus_qdbusreply.cpp51
-rw-r--r--src/dbus/doc/snippets/qdbusextratypes/qdbusextratypes.cpp51
-rw-r--r--src/dbus/doc/src/dbus-adaptors.qdoc44
-rw-r--r--src/dbus/doc/src/dontdocument.qdoc28
-rw-r--r--src/dbus/doc/src/includes/cmake-find-package-dbus.qdocinc5
-rw-r--r--src/dbus/doc/src/qdbusxml2cpp.qdoc28
-rw-r--r--src/dbus/doc/src/qt6-changes.qdoc30
-rw-r--r--src/dbus/doc/src/qtdbus-cmake.qdoc147
-rw-r--r--src/dbus/doc/src/qtdbus-examples.qdoc28
-rw-r--r--src/dbus/doc/src/qtdbus-index.qdoc229
-rw-r--r--src/dbus/doc/src/qtdbus-module.qdoc30
-rw-r--r--src/dbus/doc/src/qtdbus-overview.qdoc176
-rw-r--r--src/dbus/qdbus_symbols.cpp67
-rw-r--r--src/dbus/qdbus_symbols_p.h96
-rw-r--r--src/dbus/qdbusabstractadaptor.cpp83
-rw-r--r--src/dbus/qdbusabstractadaptor.h40
-rw-r--r--src/dbus/qdbusabstractadaptor_p.h43
-rw-r--r--src/dbus/qdbusabstractinterface.cpp123
-rw-r--r--src/dbus/qdbusabstractinterface.h43
-rw-r--r--src/dbus/qdbusabstractinterface_p.h43
-rw-r--r--src/dbus/qdbusargument.cpp104
-rw-r--r--src/dbus/qdbusargument.h72
-rw-r--r--src/dbus/qdbusargument_p.h98
-rw-r--r--src/dbus/qdbusconnection.cpp380
-rw-r--r--src/dbus/qdbusconnection.h44
-rw-r--r--src/dbus/qdbusconnection_p.h112
-rw-r--r--src/dbus/qdbusconnectioninterface.cpp62
-rw-r--r--src/dbus/qdbusconnectioninterface.h40
-rw-r--r--src/dbus/qdbusconnectionmanager.cpp334
-rw-r--r--src/dbus/qdbusconnectionmanager_p.h93
-rw-r--r--src/dbus/qdbuscontext.cpp40
-rw-r--r--src/dbus/qdbuscontext.h40
-rw-r--r--src/dbus/qdbuscontext_p.h40
-rw-r--r--src/dbus/qdbusdemarshaller.cpp40
-rw-r--r--src/dbus/qdbuserror.cpp56
-rw-r--r--src/dbus/qdbuserror.h48
-rw-r--r--src/dbus/qdbusextratypes.cpp61
-rw-r--r--src/dbus/qdbusextratypes.h65
-rw-r--r--src/dbus/qdbusintegrator.cpp686
-rw-r--r--src/dbus/qdbusintegrator_p.h87
-rw-r--r--src/dbus/qdbusinterface.cpp46
-rw-r--r--src/dbus/qdbusinterface.h40
-rw-r--r--src/dbus/qdbusinterface_p.h40
-rw-r--r--src/dbus/qdbusinternalfilters.cpp172
-rw-r--r--src/dbus/qdbusintrospection.cpp63
-rw-r--r--src/dbus/qdbusintrospection_p.h88
-rw-r--r--src/dbus/qdbusmarshaller.cpp81
-rw-r--r--src/dbus/qdbusmessage.cpp184
-rw-r--r--src/dbus/qdbusmessage.h48
-rw-r--r--src/dbus/qdbusmessage_p.h48
-rw-r--r--src/dbus/qdbusmetaobject.cpp223
-rw-r--r--src/dbus/qdbusmetaobject_p.h40
-rw-r--r--src/dbus/qdbusmetatype.cpp130
-rw-r--r--src/dbus/qdbusmetatype.h40
-rw-r--r--src/dbus/qdbusmetatype_p.h63
-rw-r--r--src/dbus/qdbusmisc.cpp141
-rw-r--r--src/dbus/qdbuspendingcall.cpp110
-rw-r--r--src/dbus/qdbuspendingcall.h49
-rw-r--r--src/dbus/qdbuspendingcall_p.h45
-rw-r--r--src/dbus/qdbuspendingreply.cpp42
-rw-r--r--src/dbus/qdbuspendingreply.h42
-rw-r--r--src/dbus/qdbusreply.cpp68
-rw-r--r--src/dbus/qdbusreply.h40
-rw-r--r--src/dbus/qdbusserver.cpp95
-rw-r--r--src/dbus/qdbusserver.h43
-rw-r--r--src/dbus/qdbusservicewatcher.cpp117
-rw-r--r--src/dbus/qdbusservicewatcher.h45
-rw-r--r--src/dbus/qdbusthreaddebug_p.h46
-rw-r--r--src/dbus/qdbusunixfiledescriptor.cpp42
-rw-r--r--src/dbus/qdbusunixfiledescriptor.h44
-rw-r--r--src/dbus/qdbusutil.cpp206
-rw-r--r--src/dbus/qdbusutil_p.h68
-rw-r--r--src/dbus/qdbusvirtualobject.cpp43
-rw-r--r--src/dbus/qdbusvirtualobject.h40
-rw-r--r--src/dbus/qdbusxmlgenerator.cpp142
-rw-r--r--src/dbus/qdbusxmlparser.cpp444
-rw-r--r--src/dbus/qdbusxmlparser_p.h61
-rw-r--r--src/dbus/qt_attribution.json6
-rw-r--r--src/dbus/qtdbusglobal.h40
-rw-r--r--src/dbus/qtdbusglobal_p.h40
95 files changed, 2677 insertions, 5237 deletions
diff --git a/src/dbus/CMakeLists.txt b/src/dbus/CMakeLists.txt
index 5e4ee48ee7..9c3f6d23d2 100644
--- a/src/dbus/CMakeLists.txt
+++ b/src/dbus/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from dbus.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## DBus Module:
@@ -14,7 +15,7 @@ qt_internal_add_module(DBus
qdbusargument.cpp qdbusargument.h qdbusargument_p.h
qdbusconnection.cpp qdbusconnection.h qdbusconnection_p.h
qdbusconnectioninterface.cpp qdbusconnectioninterface.h
- qdbusconnectionmanager_p.h
+ qdbusconnectionmanager.cpp qdbusconnectionmanager_p.h
qdbuscontext.cpp qdbuscontext.h qdbuscontext_p.h
qdbuserror.cpp qdbuserror.h
qdbusextratypes.cpp qdbusextratypes.h
@@ -24,8 +25,8 @@ qt_internal_add_module(DBus
qdbusintrospection.cpp qdbusintrospection_p.h
qdbusmarshaller.cpp
qdbusmessage.cpp qdbusmessage.h qdbusmessage_p.h
- qdbusmetaobject.cpp
- qdbusmetatype.cpp qdbusmetatype.h
+ qdbusmetaobject.cpp qdbusmetaobject_p.h
+ qdbusmetatype.cpp qdbusmetatype.h qdbusmetatype_p.h
qdbusmisc.cpp
qdbuspendingcall.cpp qdbuspendingcall.h qdbuspendingcall_p.h
qdbuspendingreply.cpp qdbuspendingreply.h
@@ -39,9 +40,14 @@ qt_internal_add_module(DBus
qdbusxmlgenerator.cpp
qdbusxmlparser.cpp qdbusxmlparser_p.h
qtdbusglobal.h qtdbusglobal_p.h
+ NO_UNITY_BUILD_SOURCES
+ qdbusconnectionmanager.cpp # qt_windows.h clashing with "interface"
DEFINES
DBUS_API_SUBJECT_TO_CHANGE
+ QT_NO_CONTEXTLESS_CONNECT
QT_NO_FOREACH
+ QT_NO_QPAIR
+ QT_USE_NODISCARD_FILE_OPEN
LIBRARIES
Qt::CorePrivate
PUBLIC_LIBRARIES
@@ -51,11 +57,9 @@ qt_internal_add_module(DBus
GENERATE_CPP_EXPORTS
)
+# This file is included by qdbusargument.cpp
set_source_files_properties(qdbusmarshaller.cpp
- PROPERTIES HEADER_FILE_ONLY ON) # special case: This file is included by qdbusargument.cpp
-
-#### Keys ignored in scope 1:.:.:dbus.pro:<TRUE>:
-# MODULE_CONFIG = "dbusadaptors" "dbusinterfaces"
+ PROPERTIES HEADER_FILE_ONLY ON)
## Scopes:
#####################################################################
@@ -77,4 +81,3 @@ qt_internal_extend_target(DBus CONDITION WIN32
qt_internal_add_docs(DBus
doc/qtdbus.qdocconf
)
-
diff --git a/src/dbus/Qt6DBusMacros.cmake b/src/dbus/Qt6DBusMacros.cmake
index e35a9954fe..57a4a0735e 100644
--- a/src/dbus/Qt6DBusMacros.cmake
+++ b/src/dbus/Qt6DBusMacros.cmake
@@ -1,44 +1,20 @@
-#=============================================================================
# Copyright 2005-2011 Kitware, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# * Neither the name of Kitware, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#=============================================================================
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
include(MacroAddFileDependencies)
-include(CMakeParseArguments)
-
-function(qt6_add_dbus_interface _sources _interface _basename)
+function(qt6_add_dbus_interface _sources _interface _relativename)
get_filename_component(_infile ${_interface} ABSOLUTE)
- set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h")
- set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp")
- set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc")
+ get_filename_component(_basepath ${_relativename} DIRECTORY)
+ get_filename_component(_basename ${_relativename} NAME)
+ set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_relativename}.h")
+ set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_relativename}.cpp")
+ if(_basepath)
+ set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/moc_${_basename}.cpp")
+ else()
+ set(_moc "${CMAKE_CURRENT_BINARY_DIR}/moc_${_basename}.cpp")
+ endif()
get_source_file_property(_nonamespace ${_interface} NO_NAMESPACE)
if(_nonamespace)
@@ -58,7 +34,7 @@ function(qt6_add_dbus_interface _sources _interface _basename)
endif()
add_custom_command(OUTPUT "${_impl}" "${_header}"
- COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp ${_params} -p ${_basename} ${_infile}
+ COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp ${_params} -p ${_relativename} ${_infile}
DEPENDS ${_infile} ${QT_CMAKE_EXPORT_NAMESPACE}::qdbuscpp2xml
VERBATIM
)
@@ -70,7 +46,7 @@ function(qt6_add_dbus_interface _sources _interface _basename)
qt6_generate_moc("${_header}" "${_moc}")
- list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
+ list(APPEND ${_sources} "${_impl}" "${_header}")
macro_add_file_dependencies("${_impl}" "${_moc}")
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()
@@ -80,14 +56,14 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
# arguments, so we can preserve them exactly. As an added bonus, if the
# caller doesn't provide enough arguments, they will get an error message
# for their call site instead of here in the wrapper.
- function(qt_add_dbus_interface sources interface basename)
+ function(qt_add_dbus_interface sources interface relativename)
if(ARGC GREATER 3)
message(FATAL_ERROR "Unexpected arguments: ${ARGN}")
endif()
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
- qt5_add_dbus_interface("${sources}" "${interface}" "${basename}")
+ qt5_add_dbus_interface("${sources}" "${interface}" "${relativename}")
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
- qt6_add_dbus_interface("${sources}" "${interface}" "${basename}")
+ qt6_add_dbus_interface("${sources}" "${interface}" "${relativename}")
endif()
set("${sources}" "${${sources}}" PARENT_SCOPE)
endfunction()
@@ -164,7 +140,7 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
endif()
-function(qt6_add_dbus_adaptor _sources _xml_file _include) # _optionalParentClass _optionalBasename _optionalClassName)
+function(qt6_add_dbus_adaptor _sources _xml_file _include) # _optionalParentClass _optionalRelativename _optionalClassName)
get_filename_component(_infile ${_xml_file} ABSOLUTE)
set(_optionalParentClass "${ARGV3}")
@@ -173,28 +149,34 @@ function(qt6_add_dbus_adaptor _sources _xml_file _include) # _optionalParentClas
set(_parentClass "${_optionalParentClass}")
endif()
- set(_optionalBasename "${ARGV4}")
- if(_optionalBasename)
- set(_basename ${_optionalBasename} )
+ set(_optionalRelativename "${ARGV4}")
+ if(_optionalRelativename)
+ set(_relativename ${_optionalRelativename})
else()
- string(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
- string(TOLOWER ${_basename} _basename)
+ string(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _relativename ${_infile})
+ string(TOLOWER ${_relativename} _relativename)
endif()
+ get_filename_component(_basepath ${_relativename} DIRECTORY)
+ get_filename_component(_basename ${_relativename} NAME)
set(_optionalClassName "${ARGV5}")
- set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h")
- set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp")
- set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc")
+ set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_relativename}.h")
+ set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_relativename}.cpp")
+ if(_basepath)
+ set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/moc_${_basename}.cpp")
+ else()
+ set(_moc "${CMAKE_CURRENT_BINARY_DIR}/moc_${_basename}.cpp")
+ endif()
if(_optionalClassName)
add_custom_command(OUTPUT "${_impl}" "${_header}"
- COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp -m -a ${_basename} -c ${_optionalClassName} -i ${_include} ${_parentClassOption} ${_parentClass} ${_infile}
+ COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp -m -a ${_relativename} -c ${_optionalClassName} -i ${_include} ${_parentClassOption} ${_parentClass} ${_infile}
DEPENDS ${_infile} ${QT_CMAKE_EXPORT_NAMESPACE}::qdbuscpp2xml
VERBATIM
)
else()
add_custom_command(OUTPUT "${_impl}" "${_header}"
- COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp -m -a ${_basename} -i ${_include} ${_parentClassOption} ${_parentClass} ${_infile}
+ COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp -m -a ${_relativename} -i ${_include} ${_parentClassOption} ${_parentClass} ${_infile}
DEPENDS ${_infile} ${QT_CMAKE_EXPORT_NAMESPACE}::qdbuscpp2xml
VERBATIM
)
@@ -207,7 +189,7 @@ function(qt6_add_dbus_adaptor _sources _xml_file _include) # _optionalParentClas
)
macro_add_file_dependencies("${_impl}" "${_moc}")
- list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
+ list(APPEND ${_sources} "${_impl}" "${_header}")
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()
diff --git a/src/dbus/dbus_minimal_p.h b/src/dbus/dbus_minimal_p.h
index 243c8ceaba..36e7fab55d 100644
--- a/src/dbus/dbus_minimal_p.h
+++ b/src/dbus/dbus_minimal_p.h
@@ -1,41 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Intel Corporation.
-** 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) 2002, 2003 CodeFactory AB
+// Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
#ifndef DBUS_MINIMAL_P_H
#define DBUS_MINIMAL_P_H
@@ -51,6 +17,8 @@
// We mean it.
//
+// These structures are not ours, so ELFVERSION:stop
+
extern "C" {
// Equivalent to dbus-arch-deps.h (generated from dbus-arch-deps.h.in)
diff --git a/src/dbus/doc/qtdbus.qdocconf b/src/dbus/doc/qtdbus.qdocconf
index 35f17b1f34..90ee5743ff 100644
--- a/src/dbus/doc/qtdbus.qdocconf
+++ b/src/dbus/doc/qtdbus.qdocconf
@@ -63,6 +63,8 @@ qhp.QtDBus.subprojects.examples.selectors = fake:example
navigation.landingpage = "Qt D-Bus"
navigation.cppclassespage = "Qt D-Bus C++ Classes"
-manifestmeta.thumbnail.names = "QtDBus/D-Bus List Names Example" \
- "QtDBus/D-Bus Ping Pong Example" \
- "QtDBus/D-Bus Complex Ping Pong Example"
+manifestmeta.thumbnail.names = "QtDBus/D-Bus Ping Pong" \
+ "QtDBus/D-Bus Complex Ping Pong"
+
+# Enforce zero documentation warnings
+warninglimit = 0
diff --git a/src/dbus/doc/snippets/CMakeLists.txt b/src/dbus/doc/snippets/CMakeLists.txt
index 825a088019..4b4751d4fa 100644
--- a/src/dbus/doc/snippets/CMakeLists.txt
+++ b/src/dbus/doc/snippets/CMakeLists.txt
@@ -1,4 +1,7 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
#! [cmake_use]
-find_package(Qt6 COMPONENTS DBus REQUIRED)
+find_package(Qt6 REQUIRED COMPONENTS DBus)
target_link_libraries(mytarget PRIVATE Qt6::DBus)
#! [cmake_use]
diff --git a/src/dbus/doc/snippets/cmake/examples.cmake b/src/dbus/doc/snippets/cmake/examples.cmake
index 3aa1f013bd..2bb6b63abb 100644
--- a/src/dbus/doc/snippets/cmake/examples.cmake
+++ b/src/dbus/doc/snippets/cmake/examples.cmake
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
#! [qt_add_dbus_adaptor]
qt_add_dbus_adaptor(GENERATED_SOURCES org.example.chat.xml chat.h ChatMainWindow)
#! [qt_add_dbus_adaptor]
diff --git a/src/dbus/doc/snippets/code/doc_src_introtodbus.qdoc b/src/dbus/doc/snippets/code/doc_src_introtodbus.qdoc
index 5bade40a0b..61afa69790 100644
--- a/src/dbus/doc/snippets/code/doc_src_introtodbus.qdoc
+++ b/src/dbus/doc/snippets/code/doc_src_introtodbus.qdoc
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
//! [0]
org.freedesktop.DBus
diff --git a/src/dbus/doc/snippets/code/doc_src_qdbusadaptors.cpp b/src/dbus/doc/snippets/code/doc_src_qdbusadaptors.cpp
index d5de866ae0..1cfb77db99 100644
--- a/src/dbus/doc/snippets/code/doc_src_qdbusadaptors.cpp
+++ b/src/dbus/doc/snippets/code/doc_src_qdbusadaptors.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QString>
#include <QDBusMessage>
#include <QDBusConnection>
diff --git a/src/dbus/doc/snippets/code/src_qdbus_qdbusabstractinterface.cpp b/src/dbus/doc/snippets/code/src_qdbus_qdbusabstractinterface.cpp
index e8fb8c81fb..92b9dea909 100644
--- a/src/dbus/doc/snippets/code/src_qdbus_qdbusabstractinterface.cpp
+++ b/src/dbus/doc/snippets/code/src_qdbus_qdbusabstractinterface.cpp
@@ -1,58 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QString>
#include <QDBusMessage>
#include <QDBusReply>
#include <QDBusInterface>
+using namespace Qt::StringLiterals;
+
class Abstract_DBus_Interface : public QObject
{
Q_OBJECT
@@ -81,23 +36,33 @@ void Abstract_DBus_Interface::interfaceMain()
QString value = retrieveValue();
QDBusMessage reply;
-QDBusReply<int> api = interface->call(QLatin1String("GetAPIVersion"));
+QDBusReply<int> api = interface->call("GetAPIVersion"_L1);
if (api >= 14)
- reply = interface->call(QLatin1String("ProcessWorkUnicode"), value);
+ reply = interface->call("ProcessWorkUnicode"_L1, value);
else
- reply = interface->call(QLatin1String("ProcessWork"), QLatin1String("UTF-8"), value.toUtf8());
+ reply = interface->call("ProcessWork"_L1, "UTF-8"_L1, value.toUtf8());
//! [0]
}
void Abstract_DBus_Interface::asyncCall()
{
//! [1]
-QString value = retrieveValue();
-QDBusPendingCall pcall = interface->asyncCall(QLatin1String("Process"), value);
+QDBusPendingCall pcall = interface->asyncCall("GetAPIVersion"_L1);
+auto watcher = new QDBusPendingCallWatcher(pcall, this);
-QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall);
+QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this,
+ [&](QDBusPendingCallWatcher *w) {
+ QString value = retrieveValue();
+ QDBusPendingReply<int> reply(*w);
+ QDBusPendingCall pcall;
+ if (reply.argumentAt<0>() >= 14)
+ pcall = interface->asyncCall("ProcessWorkUnicode"_L1, value);
+ else
+ pcall = interface->asyncCall("ProcessWork"_L1, "UTF-8"_L1, value.toUtf8());
-QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));
+ w = new QDBusPendingCallWatcher(pcall);
+ QObject::connect(w, &QDBusPendingCallWatcher::finished, this,
+ &Abstract_DBus_Interface::callFinishedSlot);
+});
//! [1]
}
diff --git a/src/dbus/doc/snippets/code/src_qdbus_qdbusargument.cpp b/src/dbus/doc/snippets/code/src_qdbus_qdbusargument.cpp
index cf698c79bf..5cb6ce5bb2 100644
--- a/src/dbus/doc/snippets/code/src_qdbus_qdbusargument.cpp
+++ b/src/dbus/doc/snippets/code/src_qdbus_qdbusargument.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QString>
#include <QDBusArgument>
diff --git a/src/dbus/doc/snippets/code/src_qdbus_qdbuscontext.cpp b/src/dbus/doc/snippets/code/src_qdbus_qdbuscontext.cpp
index 901b29e205..75b4394595 100644
--- a/src/dbus/doc/snippets/code/src_qdbus_qdbuscontext.cpp
+++ b/src/dbus/doc/snippets/code/src_qdbus_qdbuscontext.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QString>
#include <QDBusConnection>
@@ -84,7 +37,7 @@ QString MyObject::methodWithDelayedReply()
conn = connection();
msg = message();
setDelayedReply(true);
- QMetaObject::invokeMethod(this, "process", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, &MyObject::process, Qt::QueuedConnection);
return QString();
}
//! [0]
diff --git a/src/dbus/doc/snippets/code/src_qdbus_qdbusinterface.cpp b/src/dbus/doc/snippets/code/src_qdbus_qdbusinterface.cpp
index d08ced6ece..06d654b97b 100644
--- a/src/dbus/doc/snippets/code/src_qdbus_qdbusinterface.cpp
+++ b/src/dbus/doc/snippets/code/src_qdbus_qdbusinterface.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QDBusInterface>
#include <QDBusReply>
diff --git a/src/dbus/doc/snippets/code/src_qdbus_qdbusmetatype.cpp b/src/dbus/doc/snippets/code/src_qdbus_qdbusmetatype.cpp
index e295358b60..c9e5281cdb 100644
--- a/src/dbus/doc/snippets/code/src_qdbus_qdbusmetatype.cpp
+++ b/src/dbus/doc/snippets/code/src_qdbus_qdbusmetatype.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtCore/qlist.h>
typedef QList<QString> MyClass;
diff --git a/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingcall.cpp b/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingcall.cpp
index d75a19b62f..67b019a67d 100644
--- a/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingcall.cpp
+++ b/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingcall.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QDBusPendingCall>
#include <QDBusInterface>
#include <QDBusPendingReply>
@@ -80,8 +33,8 @@ void DBus_PendingCall_Interface::callInterfaceMain()
QDBusPendingCall async = iface->asyncCall("RemoteMethod", value1, value2);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
- QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));
+ QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this,
+ &DBus_PendingCall_Interface::callFinishedSlot);
//! [0]
}
diff --git a/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingreply.cpp b/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingreply.cpp
index 9a37e7bb09..04f707dba8 100644
--- a/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingreply.cpp
+++ b/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingreply.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QDBusPendingCall>
#include <QDBusInterface>
#include <QDBusPendingReply>
diff --git a/src/dbus/doc/snippets/code/src_qdbus_qdbusreply.cpp b/src/dbus/doc/snippets/code/src_qdbus_qdbusreply.cpp
index 30bd422d2c..2def08bdfe 100644
--- a/src/dbus/doc/snippets/code/src_qdbus_qdbusreply.cpp
+++ b/src/dbus/doc/snippets/code/src_qdbus_qdbusreply.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QDBusPendingCall>
#include <QDBusInterface>
#include <QDBusPendingReply>
diff --git a/src/dbus/doc/snippets/qdbusextratypes/qdbusextratypes.cpp b/src/dbus/doc/snippets/qdbusextratypes/qdbusextratypes.cpp
index 92b4be9829..9029fa8cf7 100644
--- a/src/dbus/doc/snippets/qdbusextratypes/qdbusextratypes.cpp
+++ b/src/dbus/doc/snippets/qdbusextratypes/qdbusextratypes.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtCore>
diff --git a/src/dbus/doc/src/dbus-adaptors.qdoc b/src/dbus/doc/src/dbus-adaptors.qdoc
index d2a5ac27a8..e57cc095b9 100644
--- a/src/dbus/doc/src/dbus-adaptors.qdoc
+++ b/src/dbus/doc/src/dbus-adaptors.qdoc
@@ -1,36 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page usingadaptors.html
\title Using Qt D-Bus Adaptors
\brief How to create and use DBus adaptors in Qt.
- \ingroup best-practices
+ \ingroup how-to
Adaptors are special classes that are attached to any QObject-derived class
and provide the interface to the external world using D-Bus. Adaptors are
@@ -68,7 +44,7 @@
\li \l{Declaring Slots in D-Bus Adaptors}
\li \l{Declaring Signals in D-Bus Adaptors}
\li \l{The Qt D-Bus Type System}
- \li In the \l{D-Bus Complex Ping Pong Example}, \c complexpong.h and
+ \li In the \l{D-Bus Complex Ping Pong} example, \c complexpong.h and
\c complexpong.cpp show an implementation of QDBusAbstractAdaptor.
\endlist
@@ -111,15 +87,15 @@
Asynchronous slots are marked by the keyword \l Q_NOREPLY in the method
signature, before the \c void return type and the slot name. The \c quit()
- slot in the \l {D-Bus Complex Ping Pong Example} is an example of this.
+ slot in the \l {D-Bus Complex Ping Pong} example is an example of this.
\section1 Input-Only Slots
Input-only slots are normal slots that take parameters passed by value or
by constant reference. However, unlike asynchronous slots, the caller is
usually waiting for completion of the callee before resuming operation.
- Therefore, non-asynchronous slots should not block or should state it its
- documentation that they may do so.
+ Therefore, non-asynchronous slots should not block or should explicitly
+ state it will block in its documentation that they may do so.
Input-only slots have no special marking in their signature, except that
they take only parameters passed by value or by constant reference.
@@ -190,7 +166,7 @@
The delayed reply itself is requested from Qt D-Bus by calling
QDBusMessage::reply() on the original message. It then becomes the
- resposibility of the called code to eventually send a reply to the
+ responsibility of the called code to eventually send a reply to the
caller.
\warning When a caller places a method call and waits for a reply, it will
@@ -217,8 +193,8 @@
However, signals must still be emitted. The easiest way to emit an adaptor
signal is to connect another signal to it, so that Qt's signals and slots
mechanism automatically emits the adaptor signal, too. This can be done in
- the adaptor's constructor, as you can see in the \l {D-Bus Complex Ping
- Pong Example}.
+ the adaptor's constructor, as you can see in the \l {D-Bus Complex Ping Pong}
+ example.
The QDBusAbstractAdaptor::setAutoRelaySignals() convenience function can also
be used to make and break connections between signals in the real object and
diff --git a/src/dbus/doc/src/dontdocument.qdoc b/src/dbus/doc/src/dontdocument.qdoc
index bbb8acb53c..c217ca9276 100644
--- a/src/dbus/doc/src/dontdocument.qdoc
+++ b/src/dbus/doc/src/dontdocument.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\dontdocument (QTypeInfo QMetaTypeId QDBusAbstractInterfaceBase QDBusPendingReplyData QMetaTypeId2)
diff --git a/src/dbus/doc/src/includes/cmake-find-package-dbus.qdocinc b/src/dbus/doc/src/includes/cmake-find-package-dbus.qdocinc
new file mode 100644
index 0000000000..1ed1c6a8ec
--- /dev/null
+++ b/src/dbus/doc/src/includes/cmake-find-package-dbus.qdocinc
@@ -0,0 +1,5 @@
+The command is defined in the \c DBus component of the \c Qt6 package. Load the package with:
+
+\code
+find_package(Qt6 REQUIRED COMPONENTS DBus)
+\endcode
diff --git a/src/dbus/doc/src/qdbusxml2cpp.qdoc b/src/dbus/doc/src/qdbusxml2cpp.qdoc
index 1dd8a9af7a..d63453bf78 100644
--- a/src/dbus/doc/src/qdbusxml2cpp.qdoc
+++ b/src/dbus/doc/src/qdbusxml2cpp.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qdbusxml2cpp.html
diff --git a/src/dbus/doc/src/qt6-changes.qdoc b/src/dbus/doc/src/qt6-changes.qdoc
index dc1553b360..80cd56c627 100644
--- a/src/dbus/doc/src/qt6-changes.qdoc
+++ b/src/dbus/doc/src/qt6-changes.qdoc
@@ -1,35 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page dbus-changes-qt6.html
\title Changes to Qt D-Bus
\ingroup changes-qt-5-to-6
- \brief Migrate Qt DBus to Qt 6.
+ \brief Minimal porting effort to be able to switch to Qt 6.
Qt 6 is a result of the conscious effort to make the framework more
efficient and easy to use.
diff --git a/src/dbus/doc/src/qtdbus-cmake.qdoc b/src/dbus/doc/src/qtdbus-cmake.qdoc
index f4432fb741..86807af6e5 100644
--- a/src/dbus/doc/src/qtdbus-cmake.qdoc
+++ b/src/dbus/doc/src/qtdbus-cmake.qdoc
@@ -1,39 +1,34 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+\group cmake-commands-qtdbus
+\title CMake Commands in Qt6 DBus
+\brief Lists CMake commands defined in Qt6::DBus.
+
+The following CMake commands are defined when Qt6::DBus is loaded, for instance
+with
+
+\code
+find_package(Qt6 REQUIRED COMPONENTS DBus)
+\endcode
+
+\sa{CMake Command Reference}
+*/
/*!
\page qtdbus-cmake-qt-add-dbus-interface.html
\ingroup cmake-commands-qtdbus
\title qt_add_dbus_interface
-\target qt6_add_dbus_interface
+\keyword qt6_add_dbus_interface
+
+\summary {Generates C++ sources implementing an interface for a D-Bus interface
+description file.}
+
+\include cmake-find-package-dbus.qdocinc
-\brief Generates C++ sources implementing an interface for a D-Bus interface
-description file.
+\cmakecommandsince 6.0
\section1 Synopsis
@@ -67,7 +62,7 @@ class named after the interface name, with a namespaced alias:
\section1 Options
-Options can be set using \c set_source_file_property on the \c dbus_spec:
+Options can be set using \c set_source_files_properties on the \c dbus_spec:
\table
\header
@@ -94,10 +89,14 @@ Options can be set using \c set_source_file_property on the \c dbus_spec:
\ingroup cmake-commands-qtdbus
\title qt_add_dbus_interfaces
-\target qt6_add_dbus_interface
+\keyword qt6_add_dbus_interfaces
-\brief Generates C++ sources implementing interfaces for D-Bus interface
-description files.
+\summary {Generates C++ sources implementing interfaces for D-Bus interface
+description files.}
+
+\include cmake-find-package-dbus.qdocinc
+
+\cmakecommandsince 6.0
\section1 Synopsis
@@ -123,7 +122,7 @@ The generated C++ source files are named after the XML file: For the file
\section1 Options
-Options can be set using \c set_source_file_property on each of the file
+Options can be set using \c set_source_files_properties on each of the file
arguments:
\table
@@ -151,9 +150,13 @@ arguments:
\ingroup cmake-commands-qtdbus
\title qt_generate_dbus_interface
-\target qt6_generate_dbus_interface
+\keyword qt6_generate_dbus_interface
+
+\summary {Generates a D-Bus interface from a header file.}
-\brief Generates a D-Bus interface from a header file.
+\include cmake-find-package-dbus.qdocinc
+
+\cmakecommandsince 6.0
\section1 Synopsis
@@ -169,7 +172,7 @@ qt_generate_dbus_interface(header
\section1 Description
Parses the C++ source or header file containing a QObject-derived class
-declaration and generates a file containing the D-BUS Introspection XML.
+declaration and generates a file containing the D-Bus Introspection XML.
By default, the generated XML file is stored in the current binary directory,
and has the same base name as the header. You can specify a different name or
@@ -186,9 +189,13 @@ arguments to the tool can be set after \c{OPTIONS}.
\ingroup cmake-commands-qtdbus
\title qt_add_dbus_adaptor
-\target qt6_add_dbus_adaptor
+\keyword qt6_add_dbus_adaptor
+
+\summary {Generates an adaptor class for a D-Bus interface.}
+
+\include cmake-find-package-dbus.qdocinc
-\brief Generates an adaptor class for a D-Bus interface.
+\cmakecommandsince 6.0
\section1 Synopsis
@@ -236,3 +243,65 @@ argument.
\snippet cmake/examples.cmake qt_add_dbus_adaptor
*/
+
+/*!
+\group cmake-source-file-properties-qtdbus
+\title CMake Source File Properties in Qt6 DBus
+\brief Lists CMake file properties used in Qt6::DBus.
+
+\l{CMake Commands in Qt6 DBus}{CMake Commands} know about the following CMake
+source file properties:
+
+\sa{CMake Property Reference}
+*/
+
+/*!
+\page cmake-source-file-property-classname.html
+\ingroup cmake-source-file-properties-qtdbus
+
+\title CLASSNAME
+\target cmake-source-file-property-CLASSNAME
+
+\summary {Overrides the default interface class name.}
+
+\cmakepropertysince 5.0
+
+When this property is set, the generated C++ class name is overridden
+with the provided property value.
+
+\sa{qt6_add_dbus_interface}{qt_add_dbus_interface}
+*/
+
+/*!
+\page cmake-source-file-property-include.html
+\ingroup cmake-source-file-properties-qtdbus
+
+\title INCLUDE
+\target cmake-source-file-property-INCLUDE
+
+\summary {Adds an include path.}
+
+\cmakepropertysince 5.0
+
+When this property is set, an #include "path" is added
+to the generated C++ file.
+
+\sa{qt6_add_dbus_interface}{qt_add_dbus_interface}
+*/
+
+/*!
+\page cmake-source-file-property-no-namespace.html
+\ingroup cmake-source-file-properties-qtdbus
+
+\title NO_NAMESPACE
+\target cmake-source-file-property-NO_NAMESPACE
+
+\summary {Disables generation of a namespaced name.}
+
+\cmakepropertysince 5.0
+
+When this property is set, the generated C++ class will not contain a namespaced alias.
+
+\sa{qt6_add_dbus_interface}{qt_add_dbus_interface}
+*/
+
diff --git a/src/dbus/doc/src/qtdbus-examples.qdoc b/src/dbus/doc/src/qtdbus-examples.qdoc
index a35207ddee..9b55e3f3f7 100644
--- a/src/dbus/doc/src/qtdbus-examples.qdoc
+++ b/src/dbus/doc/src/qtdbus-examples.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\group examples-dbus
diff --git a/src/dbus/doc/src/qtdbus-index.qdoc b/src/dbus/doc/src/qtdbus-index.qdoc
index afd70c2f7c..05ca38a207 100644
--- a/src/dbus/doc/src/qtdbus-index.qdoc
+++ b/src/dbus/doc/src/qtdbus-index.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtdbus-index.html
@@ -32,188 +8,62 @@
\keyword QtDBus
-
- \section1 Introduction
-
D-Bus is an Inter-Process Communication (IPC) and Remote Procedure
Calling (RPC) mechanism originally developed for Linux to replace
existing and competing IPC solutions with one unified protocol. It
- has also been designed to allow communication between system-level
+ was also designed to allow communication between system-level
processes (such as printer and hardware driver services) and
normal user processes.
It uses a fast, binary message-passing protocol, which is suitable
for same-machine communication due to its low latency and low
overhead. Its specification is currently defined by the
- \tt{freedesktop.org} project, and is available to all parties.
+ \tt{freedesktop.org} project and is available to all parties.
- Communication in general happens through a central server
- application, called the "bus" (hence the name), but direct
+ Communication, in general, happens through a central server
+ application called the "bus" (hence the name), but direct
application-to-application communication is also possible. When
communicating on a bus, applications can query which other
applications and services are available, as well as activate one
on demand.
- \section1 The Buses
-
- D-Bus buses are used to when many-to-many communication is
- desired. In order to achieve that, a central server is launched
- before any applications can connect to the bus: this server is
- responsible for keeping track of the applications that are
- connected and for properly routing messages from their source to
- their destination.
-
- In addition, D-Bus defines two well-known buses, called the
- system bus and the session bus. These buses are special in the
- sense that they have well-defined semantics: some services are
- defined to be found in one or both of these buses.
-
- For example, an application wishing to query the list of hardware
- devices attached to the computer will probably communicate to a
- service available on the system bus, while the service providing
- opening of the user's web browser will be probably found on the
- session bus.
-
- On the system bus, one can also expect to find restrictions on
- what services each application is allowed to offer. Therefore, one
- can be reasonably certain that, if a certain service is present,
- it is being offered by a trusted application.
-
- \section1 Concepts
-
- \section2 Messages
-
- On the low level, applications communicate over D-Bus by sending
- messages to one another. Messages are used to relay the remote
- procedure calls as well as the replies and errors associated
- with them. When used over a bus, messages have a destination,
- which means they are routed only to the interested parties,
- avoiding congestion due to "swarming" or broadcasting.
-
- A special kind of message called a "signal message"
- (a concept based on Qt's \l {Signals and Slots} mechanism),
- however, does not have a pre-defined destination. Since its
- purpose is to be used in a one-to-many context, signal messages
- are designed to work over an "opt-in" mechanism.
-
- The Qt D-Bus module fully encapsulates the low-level concept of
- messages into a simpler, object-oriented approach familiar to Qt
- developers. In most cases, the developer need not worry about
- sending or receiving messages.
-
- \section2 Service Names
-
- When communicating over a bus, applications obtain what is
- called a "service name": it is how that application chooses to be
- known by other applications on the same bus. The service names
- are brokered by the D-Bus bus daemon and are used to
- route messages from one application to another. An analogous
- concept to service names are IP addresses and hostnames: a
- computer normally has one IP address and may have one or more
- hostnames associated with it, according to the services that it
- provides to the network.
-
- On the other hand, if a bus is not used, service names are also
- not used. If we compare this to a computer network again, this
- would equate to a point-to-point network: since the peer is
- known, there is no need to use hostnames to find it or its IP
- address.
-
- The format of a D-Bus service name is in fact very similar to a
- host name: it is a dot-separated sequence of letters and
- digits. The common practice is even to name one's service name
- according to the domain name of the organization that defined
- that service.
-
- For example, the D-Bus service is defined by
- \tt{freedesktop.org} and can be found on the bus under the
- service name:
-
- \snippet code/doc_src_introtodbus.qdoc 0
-
- \section2 Object Paths
-
- Like network hosts, applications provide specific services to
- other applications by exporting objects. Those objects are
- hierarchically organised, much like the parent-child
- relationship that classes derived from QObject possess. One
- difference, however, is that there is the concept of "root
- object", that all objects have as ultimate parent.
-
- If we continue our analogy with Web services, object paths
- equate to the path part of a URL:
-
- \image qurl-ftppath.png
-
- Like them, object paths in D-Bus are formed resembling path
- names on the filesystem: they are slash-separated labels, each
- consisting of letters, digits and the underscore character
- ("_"). They must always start with a slash and must not end with
- one.
-
- \section2 Interfaces
+ \section1 Using the Module
- Interfaces are similar to C++ abstract classes and Java's
- \c interface keyword and declare the "contract" that is
- established between caller and callee. That is, they establish
- the names of the methods, signals and properties that are
- available as well as the behavior that is expected from either
- side when communication is established.
+ \include {module-use.qdocinc} {using the c++ api}
- Qt uses a very similar mechanism in its \l {How to Create Qt
- Plugins}{Plugin system}: Base classes in C++ are associated
- with a unique identifier by way of the Q_DECLARE_INTERFACE()
- macro.
+ \include {module-use.qdocinc} {building with cmake} {DBus}
- D-Bus interface names are, in fact, named in a manner similar to
- what is suggested by the Qt Plugin System: an identifier usually
- constructed from the domain name of the entity that defined that
- interface.
+ \section1 Articles and Guides
- \section2 Cheat Sheet
-
- To facilitate remembering of the naming formats and their
- purposes, the following table can be used:
-
- \table 90%
- \header \li D-Bus Concept \li Analogy \li Name format
- \row \li Service name \li Network hostnames \li Dot-separated
- ("looks like a hostname")
- \row \li Object path \li URL path component \li Slash-separated
- ("looks like a path")
- \row \li Interface \li Plugin identifier \li Dot-separated
- \endtable
-
- \section1 Debugging
-
- When developing applications that use D-Bus, it is sometimes useful to be able
- to see information about the messages that are sent and received across the
- bus by each application.
-
- This feature can be enabled on a per-application basis by setting the
- \c QDBUS_DEBUG environment variable before running each application.
- For example, we can enable debugging only for the car in the
- \l{D-Bus Remote Controlled Car Example} by running the controller and the
- car in the following way:
-
- \snippet code/doc_src_introtodbus.qdoc QDBUS_DEBUG
-
- Information about the messages will be written to the console the application
- was launched from.
+ The following documents contain information about Qt's D-Bus integration
+ features and provide details about the mechanisms used to send and receive
+ type information over the bus:
+ \list
+ \li \l {Qt D-Bus Overview}
+ \li \l {Using Qt D-Bus Adaptors}
+ \li \l {The Qt D-Bus Type System}
+ \li \l {Qt D-Bus XML compiler (qdbusxml2cpp)}
+ \li \l{D-Bus Viewer}
+ \endlist
- \include module-use.qdocinc using qt module
- \snippet snippets/CMakeLists.txt cmake_use
+ \section1 Examples
- See also the \l {Build with CMake} overview.
+ \list
+ \li \l{Qt D-Bus Examples}
+ \endlist
- \include module-use.qdocinc building with qmake
- \snippet snippets/snippets.pro qmake_use
+ \section1 Reference
+ \list
+ \li \l{Qt D-Bus C++ Classes}
+ \li \l{CMake Commands in Qt6 DBus}
+ \endlist
\section1 Module Evolution
+
\l{Changes to Qt D-Bus} lists important changes in the module API
- and functionality that were done for the Qt 6 series of Qt.
+ and functionality that were made for the Qt 6 series of Qt.
\section1 Licenses and Attributions
@@ -224,24 +74,9 @@
See \l{Qt Licensing} for further details.
Furthermore, Qt D-Bus in Qt \QtVersion may contain third party
- modules under following permissive licenses:
+ modules under the following permissive licenses:
\generatelist{groupsbymodule attributions-qtdbus}
-
- \section1 Further Reading
-
- The following documents contain information about Qt's D-Bus integration
- features, and provide details about the mechanisms used to send and receive
- type information over the bus:
-
- \list
- \li \l{Using Qt D-Bus Adaptors}
- \li \l{The Qt D-Bus Type System}
- \li \l{Qt D-Bus XML compiler (qdbusxml2cpp)}
- \li \l{Qt D-Bus C++ Classes}
- \li \l{Qt D-Bus Examples}
- \li \l{D-Bus Viewer}
- \endlist
*/
/*!
diff --git a/src/dbus/doc/src/qtdbus-module.qdoc b/src/dbus/doc/src/qtdbus-module.qdoc
index 04b729bfde..c89b4dc937 100644
--- a/src/dbus/doc/src/qtdbus-module.qdoc
+++ b/src/dbus/doc/src/qtdbus-module.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\module QtDBus
@@ -32,7 +8,7 @@
to perform Inter-Process Communication using the \l{Qt D-Bus}{D-Bus} protocol.
\ingroup modules
- \qtcmakepackage Dbus
+ \qtcmakepackage DBus
\qtvariable dbus
\keyword The QDBus compiler
diff --git a/src/dbus/doc/src/qtdbus-overview.qdoc b/src/dbus/doc/src/qtdbus-overview.qdoc
new file mode 100644
index 0000000000..6342e674fd
--- /dev/null
+++ b/src/dbus/doc/src/qtdbus-overview.qdoc
@@ -0,0 +1,176 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \page qtdbus-overview.html
+ \title Qt D-Bus Overview
+ \brief Provides insight into the Qt Qt D-Bus module.
+ \ingroup explanations-networkingandconnectivity
+
+ D-Bus is an Inter-Process Communication (IPC) and Remote Procedure
+ Calling (RPC) mechanism originally developed for Linux to replace
+ existing and competing IPC solutions with one unified protocol. It
+ was also designed to allow communication between system-level
+ processes (such as printer and hardware driver services) and
+ normal user processes.
+
+ It uses a fast, binary message-passing protocol, which is suitable
+ for same-machine communication due to its low latency and low
+ overhead. Its specification is currently defined by the
+ \tt{freedesktop.org} project and is available to all parties.
+
+ Communication, in general, happens through a central server
+ application called the "bus" (hence the name), but direct
+ application-to-application communication is also possible. When
+ communicating on a bus, applications can query which other
+ applications and services are available, as well as activate one
+ on demand.
+
+ \section1 The Buses
+
+ D-Bus buses are used when many-to-many communication is
+ desired. In order to achieve that, a central server is launched
+ before any application can connect to the bus. This server is
+ responsible for keeping track of the applications that are
+ connected and for properly routing messages from their source to
+ their destination.
+
+ In addition, D-Bus defines two well-known buses, called the
+ system bus and the session bus. These buses are special in the
+ sense that they have well-defined semantics: some services are
+ defined to be found in one or both of these buses.
+
+ For example, an application wishing to query the list of hardware
+ devices attached to the computer will probably communicate to a
+ service available on the system bus, while the service providing
+ opening of the user's web browser will probably be found on the
+ session bus.
+
+ On the system bus, you can also expect to find restrictions on
+ what services each application is allowed to offer. Therefore, you
+ can be reasonably certain that if a certain service is present,
+ it's being offered by a trusted application.
+
+ \section1 Concepts
+
+ \section2 Messages
+
+ On the low level, applications communicate over D-Bus by sending
+ messages to one another. Messages are used to relay the remote
+ procedure calls as well as the replies and errors associated
+ with them. When used over a bus, messages have a destination,
+ which means they are routed only to the interested parties,
+ avoiding congestion due to "swarming" or broadcasting.
+
+ A special kind of message called a "signal message"
+ (a concept based on Qt's \l {Signals and Slots} mechanism),
+ however, does not have a pre-defined destination. Since its
+ purpose is to be used in a one-to-many context, signal messages
+ are designed to work over an "opt-in" mechanism.
+
+ The Qt D-Bus module fully encapsulates the low-level concept of
+ messages into a simpler, object-oriented approach familiar to Qt
+ developers. In most cases, the developer need not worry about
+ sending or receiving messages.
+
+ \section2 Service Names
+
+ When communicating over a bus, applications obtain what is
+ called a "service name": it is how that application chooses to be
+ known by other applications on the same bus. The service names
+ are brokered by the D-Bus bus daemon and are used to
+ route messages from one application to another. An analogous
+ concept to service names are IP addresses and hostnames: a
+ computer normally has one IP address and may have one or more
+ hostnames associated with it, according to the services that it
+ provides to the network.
+
+ On the other hand, if a bus is not used, service names are also
+ not used. If we compare this to a computer network again, this
+ would equate to a point-to-point network: since the peer is
+ known, there is no need to use hostnames to find it or its IP
+ address.
+
+ The format of a D-Bus service name is in fact very similar to a
+ host name: it is a dot-separated sequence of letters and
+ digits. The common practice is even to name your service name
+ according to the domain name of the organization that defined
+ that service.
+
+ For example, the D-Bus service is defined by
+ \tt{freedesktop.org} and can be found on the bus under the
+ service name:
+
+ \snippet code/doc_src_introtodbus.qdoc 0
+
+ \section2 Object Paths
+
+ Like network hosts, applications provide specific services to
+ other applications by exporting objects. Those objects are
+ hierarchically organized, much like the parent-child
+ relationship that classes derived from QObject possess. One
+ difference, however, is that there is the concept of "root
+ object", which all objects have as the ultimate parent.
+
+ If we continue our analogy with Web services, object paths
+ equate to the path part of a URL:
+
+ \image qurl-ftppath.png
+
+ Like them, object paths in D-Bus are formed resembling path
+ names on the filesystem: they are slash-separated labels, each
+ consisting of letters, digits and the underscore character
+ ("\_"). They must always start with a slash and must not end with
+ one.
+
+ \section2 Interfaces
+
+ Interfaces are similar to C++ abstract classes and Java's
+ \c interface keyword and declare the "contract" that is
+ established between caller and callee. That is, they establish
+ the names of the methods, signals, and properties that are
+ available as well as the behavior that is expected from either
+ side when communication is established.
+
+ Qt uses a very similar mechanism in its \l {How to Create Qt
+ Plugins}{Plugin system}: Base classes in C++ are associated
+ with a unique identifier by way of the Q_DECLARE_INTERFACE()
+ macro.
+
+ D-Bus interface names are, in fact, named in a manner similar to
+ what is suggested by the Qt Plugin System: an identifier usually
+ constructed from the domain name of the entity that defined that
+ interface.
+
+ \section2 Cheat Sheet
+
+ To facilitate remembering of the naming formats and their
+ purposes, the following table can be used:
+
+ \table 90%
+ \header \li D-Bus Concept \li Analogy \li Name format
+ \row \li Service name \li Network hostnames \li Dot-separated
+ ("looks like a hostname")
+ \row \li Object path \li URL path component \li Slash-separated
+ ("looks like a path")
+ \row \li Interface \li Plugin identifier \li Dot-separated
+ \endtable
+
+ \section1 Debugging
+
+ When developing applications that use D-Bus, it is sometimes useful to be able
+ to see information about the messages that are sent and received across the
+ bus by each application.
+
+ This feature can be enabled on a per-application basis by setting the
+ \c QDBUS_DEBUG environment variable before running each application.
+ For example, we can enable debugging only for the car in the
+ \l{D-Bus Remote Controlled Car} example by running the controller and the
+ car in the following way:
+
+ \snippet code/doc_src_introtodbus.qdoc QDBUS_DEBUG
+
+ Information about the messages will be written to the console the application
+ was launched from.
+
+*/
diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp
index bd4299809b..9788bb98bc 100644
--- a/src/dbus/qdbus_symbols.cpp
+++ b/src/dbus/qdbus_symbols.cpp
@@ -1,44 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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$
-**
-****************************************************************************/
-
-#include <QtCore/qglobal.h>
+// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qdbus_symbols_p.h"
+#include <QtCore/qlatin1stringview.h>
#if QT_CONFIG(library)
#include <QtCore/qlibrary.h>
#include <QtCore/private/qlocking_p.h>
@@ -47,16 +12,14 @@
#ifndef QT_NO_DBUS
-extern "C" void dbus_shutdown();
-
QT_BEGIN_NAMESPACE
-void (*qdbus_resolve_me(const char *name))();
+using namespace Qt::StringLiterals;
#if !defined QT_LINKED_LIBDBUS
#if QT_CONFIG(library)
-static QLibrary *qdbus_libdbus = nullptr;
+Q_CONSTINIT static QLibrary *qdbus_libdbus = nullptr;
void qdbus_unloadLibDBus()
{
@@ -79,8 +42,8 @@ bool qdbus_loadLibDBus()
return false;
#endif
- static bool triedToLoadLibrary = false;
- static QBasicMutex mutex;
+ Q_CONSTINIT static bool triedToLoadLibrary = false;
+ Q_CONSTINIT static QBasicMutex mutex;
const auto locker = qt_scoped_lock(mutex);
QLibrary *&lib = qdbus_libdbus;
@@ -91,12 +54,12 @@ bool qdbus_loadLibDBus()
lib->setLoadHints(QLibrary::ExportExternalSymbolsHint); // make libdbus symbols available for apps that need more advanced control over the dbus
triedToLoadLibrary = true;
- static int majorversions[] = { 3, 2, -1 };
+ static constexpr int majorversions[] = { 3, 2, -1 };
const QString baseNames[] = {
#ifdef Q_OS_WIN
- QLatin1String("dbus-1"),
+ "dbus-1"_L1,
#endif
- QLatin1String("libdbus-1")
+ "libdbus-1"_L1
};
lib->unload();
@@ -125,7 +88,7 @@ bool qdbus_loadLibDBus()
#endif
}
-void (*qdbus_resolve_conditionally(const char *name))()
+QFunctionPointer qdbus_resolve_conditionally(const char *name)
{
#if QT_CONFIG(library)
if (qdbus_loadLibDBus())
@@ -136,7 +99,7 @@ void (*qdbus_resolve_conditionally(const char *name))()
return nullptr;
}
-void (*qdbus_resolve_me(const char *name))()
+QFunctionPointer qdbus_resolve_me(const char *name)
{
#if QT_CONFIG(library)
if (Q_UNLIKELY(!qdbus_loadLibDBus()))
diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h
index accaa4f5ed..78b7e049ef 100644
--- a/src/dbus/qdbus_symbols_p.h
+++ b/src/dbus/qdbus_symbols_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
@@ -63,6 +27,8 @@
# include "dbus_minimal_p.h"
#endif
+#include <atomic>
+
#ifdef interface
# undef interface
#endif
@@ -71,8 +37,8 @@ QT_BEGIN_NAMESPACE
#if !defined QT_LINKED_LIBDBUS
-void (*qdbus_resolve_conditionally(const char *name))(); // doesn't print a warning
-void (*qdbus_resolve_me(const char *name))(); // prints a warning
+QFunctionPointer qdbus_resolve_conditionally(const char *name); // doesn't print a warning
+QFunctionPointer qdbus_resolve_me(const char *name); // prints a warning
bool qdbus_loadLibDBus();
//# define TRACE_DBUS_CALLS
@@ -88,7 +54,7 @@ struct TraceDBusCall
static inline ThreadData &td()
{
- static thread_local ThreadData value;
+ Q_CONSTINIT static thread_local ThreadData value;
return value;
}
@@ -150,28 +116,34 @@ template <> struct TraceReturn<void> { typedef void Type; };
# define DEBUGRET(ret)
# endif
-# define DEFINEFUNC(ret, func, args, argcall, funcret) \
- typedef ret (* _q_PTR_##func) args; \
- static inline ret q_##func args \
- { \
- static _q_PTR_##func ptr; \
- DEBUGCALL(#func, argcall); \
- if (!ptr) \
- ptr = (_q_PTR_##func) qdbus_resolve_me(#func); \
- funcret DEBUGRET(ret) ptr argcall; \
+# define DEFINEFUNC(ret, func, args, argcall, funcret) \
+ static inline ret q_##func args \
+ { \
+ using func_ptr = ret (*) args; \
+ static std::atomic<func_ptr> atomic_ptr; \
+ func_ptr ptr = atomic_ptr.load(std::memory_order_relaxed); \
+ DEBUGCALL(#func, argcall); \
+ if (!ptr) { \
+ ptr = reinterpret_cast<func_ptr>(qdbus_resolve_me(#func)); \
+ atomic_ptr.store(ptr, std::memory_order_relaxed); \
+ } \
+ funcret DEBUGRET(ret) ptr argcall; \
}
-# define DEFINEFUNC_CONDITIONALLY(ret, func, args, argcall, funcret, failret) \
- typedef ret (* _q_PTR_##func) args; \
- static inline ret q_##func args \
- { \
- static _q_PTR_##func ptr; \
- DEBUGCALL(#func, argcall); \
- if (!ptr) \
- ptr = (_q_PTR_##func) qdbus_resolve_conditionally(#func); \
- if (!ptr) \
- failret; \
- funcret DEBUGRET(ret) ptr argcall; \
+# define DEFINEFUNC_CONDITIONALLY(ret, func, args, argcall, funcret, failret) \
+ static inline ret q_##func args \
+ { \
+ using func_ptr = ret (*) args; \
+ static std::atomic<func_ptr> atomic_ptr; \
+ func_ptr ptr = atomic_ptr.load(std::memory_order_relaxed); \
+ DEBUGCALL(#func, argcall); \
+ if (!ptr) { \
+ ptr = reinterpret_cast<func_ptr>(qdbus_resolve_conditionally(#func)); \
+ atomic_ptr.store(ptr, std::memory_order_relaxed); \
+ } \
+ if (!ptr) \
+ failret; \
+ funcret DEBUGRET(ret) ptr argcall; \
}
#else // defined QT_LINKED_LIBDBUS
diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp
index 4f749b0f9d..afe769fcd0 100644
--- a/src/dbus/qdbusabstractadaptor.cpp
+++ b/src/dbus/qdbusabstractadaptor.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbusabstractadaptor.h"
#include "qdbusabstractadaptor_p.h"
@@ -58,14 +22,10 @@
QT_BEGIN_NAMESPACE
-static int cachedRelaySlotMethodIndex = -1;
-
int QDBusAdaptorConnector::relaySlotMethodIndex()
{
- if (cachedRelaySlotMethodIndex == -1) {
- cachedRelaySlotMethodIndex = staticMetaObject.indexOfMethod("relaySlot()");
- Q_ASSERT(cachedRelaySlotMethodIndex != -1);
- }
+ static const int cachedRelaySlotMethodIndex = staticMetaObject.indexOfMethod("relaySlot()");
+ Q_ASSERT(cachedRelaySlotMethodIndex != 0); // 0 should be deleteLater() or destroyed()
return cachedRelaySlotMethodIndex;
}
@@ -73,11 +33,9 @@ QDBusAdaptorConnector *qDBusFindAdaptorConnector(QObject *obj)
{
if (!obj)
return nullptr;
- const QObjectList &children = obj->children();
- QObjectList::ConstIterator it = children.constBegin();
- QObjectList::ConstIterator end = children.constEnd();
- for ( ; it != end; ++it) {
- QDBusAdaptorConnector *connector = qobject_cast<QDBusAdaptorConnector *>(*it);
+
+ for (QObject *child : std::as_const(obj->children())) {
+ QDBusAdaptorConnector *connector = qobject_cast<QDBusAdaptorConnector *>(child);
if (connector) {
connector->polish();
return connector;
@@ -146,10 +104,13 @@ void QDBusAbstractAdaptorPrivate::saveIntrospectionXml(QDBusAbstractAdaptor *ada
QDBusAbstractAdaptor::QDBusAbstractAdaptor(QObject* obj)
: QObject(*new QDBusAbstractAdaptorPrivate, obj)
{
+
+ Q_ASSERT_X(obj, Q_FUNC_INFO, "Expected non-null parent");
+
QDBusAdaptorConnector *connector = qDBusCreateAdaptorConnector(obj);
connector->waitingForPolish = true;
- QMetaObject::invokeMethod(connector, "polish", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(connector, &QDBusAdaptorConnector::polish, Qt::QueuedConnection);
}
/*!
@@ -166,7 +127,7 @@ QDBusAbstractAdaptor::~QDBusAbstractAdaptor()
Toggles automatic signal relaying from the real object (see object()).
Automatic signal relaying consists of signal-to-signal connection of the signals on the parent
- that have the exact same method signatue in both classes.
+ that have the exact same method signature in both classes.
If \a enable is set to true, connect the signals; if set to false, disconnect all signals.
*/
@@ -263,11 +224,8 @@ void QDBusAdaptorConnector::polish()
return; // avoid working multiple times if multiple adaptors were added
waitingForPolish = false;
- const QObjectList &objs = parent()->children();
- QObjectList::ConstIterator it = objs.constBegin();
- QObjectList::ConstIterator end = objs.constEnd();
- for ( ; it != end; ++it) {
- QDBusAbstractAdaptor *adaptor = qobject_cast<QDBusAbstractAdaptor *>(*it);
+ for (QObject *child : std::as_const(parent()->children())) {
+ QDBusAbstractAdaptor *adaptor = qobject_cast<QDBusAbstractAdaptor *>(child);
if (adaptor)
addAdaptor(adaptor);
}
@@ -296,8 +254,8 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
// QObject signal (destroyed(QObject *)) -- ignore
return;
- const QMetaObject *senderMetaObject = senderObj->metaObject();
- QMetaMethod mm = senderMetaObject->method(lastSignalIdx);
+ QMetaMethod mm = senderObj->metaObject()->method(lastSignalIdx);
+ const QMetaObject *senderMetaObject = mm.enclosingMetaObject();
QObject *realObject = senderObj;
if (qobject_cast<QDBusAbstractAdaptor *>(senderObj))
@@ -315,7 +273,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
qPrintable(errorMsg));
return;
}
- if (inputCount + 1 != types.count() ||
+ if (inputCount + 1 != types.size() ||
types.at(inputCount) == QDBusMetaTypeId::message()) {
// invalid signal signature
qWarning("QDBusAbstractAdaptor: Cannot relay signal %s::%s",
@@ -324,7 +282,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
}
QVariantList args;
- const int numTypes = types.count();
+ const int numTypes = types.size();
args.reserve(numTypes - 1);
for (int i = 1; i < numTypes; ++i)
args << QVariant(QMetaType(types.at(i)), argv[i]);
@@ -335,4 +293,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
QT_END_NAMESPACE
+#include "moc_qdbusabstractadaptor_p.cpp"
+#include "moc_qdbusabstractadaptor.cpp"
+
#endif // QT_NO_DBUS
diff --git a/src/dbus/qdbusabstractadaptor.h b/src/dbus/qdbusabstractadaptor.h
index f86d939fae..f143056b43 100644
--- a/src/dbus/qdbusabstractadaptor.h
+++ b/src/dbus/qdbusabstractadaptor.h
@@ -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
#ifndef QDBUSABSTRACTADAPTOR_H
#define QDBUSABSTRACTADAPTOR_H
diff --git a/src/dbus/qdbusabstractadaptor_p.h b/src/dbus/qdbusabstractadaptor_p.h
index 212878c29b..f4b69799a5 100644
--- a/src/dbus/qdbusabstractadaptor_p.h
+++ b/src/dbus/qdbusabstractadaptor_p.h
@@ -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
//
// W A R N I N G
@@ -58,7 +22,6 @@
#include <QtCore/qlist.h>
#include <QtCore/qmap.h>
#include <QtCore/qobject.h>
-#include <QtCore/qreadwritelock.h>
#include <QtCore/qvariant.h>
#include "private/qobject_p.h"
@@ -103,7 +66,7 @@ public: // typedefs
inline bool operator<(const AdaptorData &other) const
{ return QByteArray(interface) < other.interface; }
inline bool operator<(const QString &other) const
- { return QLatin1String(interface) < other; }
+ { return QLatin1StringView(interface) < other; }
inline bool operator<(const QByteArray &other) const
{ return interface < other; }
};
diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp
index 0a873ad5ad..0c6dbf1b3b 100644
--- a/src/dbus/qdbusabstractinterface.cpp
+++ b/src/dbus/qdbusabstractinterface.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbusabstractinterface.h"
#include "qdbusabstractinterface_p.h"
@@ -58,6 +22,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace {
// ### Qt6: change to a regular QEvent (customEvent)
// We need to use a QMetaCallEvent here because we can't override customEvent() in
@@ -113,6 +79,7 @@ QDBusAbstractInterfacePrivate::QDBusAbstractInterfacePrivate(const QString &serv
lastError(checkIfValid(serv, p, iface, isDynamic, (connectionPrivate() &&
connectionPrivate()->mode == QDBusConnectionPrivate::PeerMode))),
timeout(-1),
+ interactiveAuthorizationAllowed(false),
isValid(!lastError.isValid())
{
if (!isValid)
@@ -163,9 +130,8 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
qWarning("QDBusAbstractInterface: type %s must be registered with Qt D-Bus before it can be "
"used to read property %s.%s",
mp.typeName(), qPrintable(interface), mp.name());
- lastError = QDBusError(QDBusError::Failed,
- QLatin1String("Unregistered type %1 cannot be handled")
- .arg(QLatin1String(mp.typeName())));
+ lastError = QDBusError(QDBusError::Failed, "Unregistered type %1 cannot be handled"_L1
+ .arg(QLatin1StringView(mp.typeName())));
return false;
}
}
@@ -182,9 +148,9 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
lastError = QDBusError(reply);
return false;
}
- if (reply.signature() != QLatin1String("v")) {
- QString errmsg = QLatin1String("Invalid signature `%1' in return from call to "
- DBUS_INTERFACE_PROPERTIES);
+ if (reply.signature() != "v"_L1) {
+ QString errmsg =
+ "Invalid signature '%1' in return from call to " DBUS_INTERFACE_PROPERTIES ""_L1;
lastError = QDBusError(QDBusError::InvalidSignature, std::move(errmsg).arg(reply.signature()));
return false;
}
@@ -220,15 +186,15 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
}
// there was an error...
- const auto errmsg = QLatin1String("Unexpected `%1' (%2) when retrieving property `%3.%4' "
- "(expected type `%5' (%6))");
+ const auto errmsg = "Unexpected '%1' (%2) when retrieving property '%3.%4' "
+ "(expected type '%5' (%6))"_L1;
lastError = QDBusError(QDBusError::InvalidSignature,
- errmsg.arg(QLatin1String(foundType),
- QLatin1String(foundSignature),
+ errmsg.arg(QLatin1StringView(foundType),
+ QLatin1StringView(foundSignature),
interface,
- QLatin1String(mp.name()),
- QLatin1String(mp.typeName()),
- QLatin1String(expectedSignature)));
+ QLatin1StringView(mp.name()),
+ QLatin1StringView(mp.typeName()),
+ QLatin1StringView(expectedSignature)));
return false;
}
@@ -257,7 +223,6 @@ void QDBusAbstractInterfacePrivate::_q_serviceOwnerChanged(const QString &name,
const QString &newOwner)
{
Q_UNUSED(oldOwner);
- Q_UNUSED(name);
//qDebug() << "QDBusAbstractInterfacePrivate serviceOwnerChanged" << name << oldOwner << newOwner;
Q_ASSERT(name == service);
currentOwner = newOwner;
@@ -433,6 +398,43 @@ int QDBusAbstractInterface::timeout() const
}
/*!
+ Configures whether, for asynchronous calls, the caller
+ is prepared to wait for interactive authorization.
+
+ If \a enable is set to \c true, the D-Bus messages generated for
+ asynchronous calls via this interface will set the
+ \c ALLOW_INTERACTIVE_AUTHORIZATION flag.
+
+ This flag is only useful when unprivileged code calls a more privileged
+ method call, and an authorization framework is deployed that allows
+ possibly interactive authorization.
+
+ The default is \c false.
+
+ \since 6.7
+ \sa QDBusMessage::setInteractiveAuthorizationAllowed()
+*/
+void QDBusAbstractInterface::setInteractiveAuthorizationAllowed(bool enable)
+{
+ d_func()->interactiveAuthorizationAllowed = enable;
+}
+
+/*!
+ Returns whether, for asynchronous calls, the caller
+ is prepared to wait for interactive authorization.
+
+ The default is \c false.
+
+ \since 6.7
+ \sa setInteractiveAuthorizationAllowed(),
+ QDBusMessage::setInteractiveAuthorizationAllowed()
+*/
+bool QDBusAbstractInterface::isInteractiveAuthorizationAllowed() const
+{
+ return d_func()->interactiveAuthorizationAllowed;
+}
+
+/*!
Places a call to the remote method specified by \a method on this interface, using \a args as
arguments. This function returns the message that was received as a reply, which can be a normal
QDBusMessage::ReplyMessage (indicating success) or QDBusMessage::ErrorMessage (if the call
@@ -460,7 +462,7 @@ QDBusMessage QDBusAbstractInterface::callWithArgumentList(QDBus::CallMode mode,
QString m = method;
// split out the signature from the method
- int pos = method.indexOf(QLatin1Char('.'));
+ int pos = method.indexOf(u'.');
if (pos != -1)
m.truncate(pos);
@@ -511,6 +513,9 @@ QDBusMessage QDBusAbstractInterface::callWithArgumentList(QDBus::CallMode mode,
Normally, you should place calls using asyncCall().
+ \note Method calls to objects registered by the application itself are never
+ asynchronous due to implementation limitations.
+
\threadsafe
*/
QDBusPendingCall QDBusAbstractInterface::asyncCallWithArgumentList(const QString& method,
@@ -524,6 +529,8 @@ QDBusPendingCall QDBusAbstractInterface::asyncCallWithArgumentList(const QString
QDBusMessage msg = QDBusMessage::createMethodCall(service(), path(), interface(), method);
QDBusMessagePrivate::setParametersValidated(msg, true);
msg.setArguments(args);
+ if (d->interactiveAuthorizationAllowed)
+ msg.setInteractiveAuthorizationAllowed(true);
return d->connection.asyncCall(msg, d->timeout);
}
@@ -545,6 +552,9 @@ QDBusPendingCall QDBusAbstractInterface::asyncCallWithArgumentList(const QString
parameter as its last or only parameter. The \a errorMethod must
have a QDBusError as its only parameter.
+ \note Method calls to objects registered by the application itself are never
+ asynchronous due to implementation limitations.
+
\since 4.3
\sa QDBusError, QDBusMessage
*/
@@ -712,6 +722,7 @@ void QDBusAbstractInterface::internalPropSet(const char *propname, const QVarian
This example illustrates function calling with 0, 1 and 2 parameters and illustrates different
parameter types passed in each (the first call to \c "ProcessWorkUnicode" will contain one
Unicode string, the second call to \c "ProcessWork" will contain one string and one byte array).
+ See asyncCall() for the same example in non-blocking (asynchronous) calls.
\note Before Qt 5.14, this function accepted a maximum of just eight (8) arguments.
@@ -769,9 +780,13 @@ void QDBusAbstractInterface::internalPropSet(const char *propname, const QVarian
This example illustrates function calling with 0, 1 and 2 parameters and illustrates different
parameter types passed in each (the first call to \c "ProcessWorkUnicode" will contain one
Unicode string, the second call to \c "ProcessWork" will contain one string and one byte array).
+ See call() for the same example in blocking (synchronous) calls.
\note Before Qt 5.14, this function accepted a maximum of just eight (8) arguments.
+ \note Method calls to local \c{QDBusServer}'s are never asynchronous
+ due to implementation limitations.
+
\sa asyncCallWithArgumentList()
*/
diff --git a/src/dbus/qdbusabstractinterface.h b/src/dbus/qdbusabstractinterface.h
index 989994cff8..8d36fb3728 100644
--- a/src/dbus/qdbusabstractinterface.h
+++ b/src/dbus/qdbusabstractinterface.h
@@ -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
#ifndef QDBUSABSTRACTINTERFACE_H
#define QDBUSABSTRACTINTERFACE_H
@@ -99,6 +63,9 @@ public:
void setTimeout(int timeout);
int timeout() const;
+ void setInteractiveAuthorizationAllowed(bool enable);
+ bool isInteractiveAuthorizationAllowed() const;
+
QDBusMessage call(const QString &method)
{
return doCall(QDBus::AutoDetect, method, nullptr, 0);
diff --git a/src/dbus/qdbusabstractinterface_p.h b/src/dbus/qdbusabstractinterface_p.h
index 8e45bae88b..1bd5e96f2d 100644
--- a/src/dbus/qdbusabstractinterface_p.h
+++ b/src/dbus/qdbusabstractinterface_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
@@ -78,6 +42,7 @@ public:
QString interface;
mutable QDBusError lastError;
int timeout;
+ bool interactiveAuthorizationAllowed;
// this is set during creation and never changed
// it can't be const because QDBusInterfacePrivate has one more check
diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp
index e17b40e58c..99e60244da 100644
--- a/src/dbus/qdbusargument.cpp
+++ b/src/dbus/qdbusargument.cpp
@@ -1,55 +1,20 @@
-/****************************************************************************
-**
-** 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.h"
#include "qdbusargument_p.h"
#include <qatomic.h>
#include <qbytearray.h>
+#include <qdatetime.h>
+#include <qline.h>
#include <qlist.h>
#include <qmap.h>
#include <qstring.h>
#include <qstringlist.h>
-#include <qvariant.h>
-#include <qdatetime.h>
#include <qrect.h>
-#include <qline.h>
+#include <qtimezone.h>
+#include <qvariant.h>
#include "qdbusmetatype_p.h"
#include "qdbusutil_p.h"
@@ -58,23 +23,25 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QDBusArgument)
+
QDBusArgumentPrivate::~QDBusArgumentPrivate()
{
if (message)
q_dbus_message_unref(message);
}
-QByteArray QDBusArgumentPrivate::createSignature(int id)
+QByteArray QDBusArgumentPrivate::createSignature(QMetaType type)
{
if (!qdbus_loadLibDBus())
return "";
QByteArray signature;
- QDBusMarshaller *marshaller = new QDBusMarshaller(0);
+ QDBusMarshaller *marshaller = new QDBusMarshaller;
marshaller->ba = &signature;
// run it
- QVariant v{QMetaType(id)};
+ QVariant v{type};
QDBusArgument arg(marshaller);
QDBusMetaType::marshall(arg, v.metaType(), v.constData());
arg.d = nullptr;
@@ -84,18 +51,16 @@ QByteArray QDBusArgumentPrivate::createSignature(int id)
delete marshaller;
if (signature.isEmpty() || !ok || !QDBusUtil::isValidSingleSignature(QString::fromLatin1(signature))) {
- qWarning("QDBusMarshaller: type `%s' produces invalid D-BUS signature `%s' "
+ qWarning("QDBusMarshaller: type '%s' produces invalid D-Bus signature '%s' "
"(Did you forget to call beginStructure() ?)",
- QMetaType(id).name(),
- signature.isEmpty() ? "<empty>" : signature.constData());
+ type.name(), signature.isEmpty() ? "<empty>" : signature.constData());
return "";
} else if ((signature.at(0) != DBUS_TYPE_ARRAY && signature.at(0) != DBUS_STRUCT_BEGIN_CHAR) ||
(signature.at(0) == DBUS_TYPE_ARRAY && (signature.at(1) == DBUS_TYPE_BYTE ||
signature.at(1) == DBUS_TYPE_STRING))) {
- qWarning("QDBusMarshaller: type `%s' attempts to redefine basic D-BUS type '%s' (%s) "
+ qWarning("QDBusMarshaller: type '%s' attempts to redefine basic D-Bus type '%s' (%s) "
"(Did you forget to call beginStructure() ?)",
- QMetaType(id).name(),
- signature.constData(),
+ type.name(), signature.constData(),
QDBusMetaType::signatureToMetaType(signature).name());
return "";
}
@@ -106,7 +71,7 @@ bool QDBusArgumentPrivate::checkWrite(QDBusArgumentPrivate *&d)
{
if (!d)
return false;
- if (d->direction == Marshalling) {
+ if (d->direction == Direction::Marshalling) {
if (!d->marshaller()->ok)
return false;
@@ -134,7 +99,7 @@ bool QDBusArgumentPrivate::checkRead(QDBusArgumentPrivate *d)
{
if (!d)
return false;
- if (d->direction == Demarshalling)
+ if (d->direction == Direction::Demarshalling)
return true;
#ifdef QT_DEBUG
@@ -295,7 +260,7 @@ QDBusArgument::QDBusArgument()
return;
}
- QDBusMarshaller *dd = new QDBusMarshaller(0);
+ QDBusMarshaller *dd = new QDBusMarshaller;
d = dd;
// create a new message with any type, we won't sent it anyways
@@ -572,7 +537,7 @@ QString QDBusArgument::currentSignature() const
{
if (!d)
return QString();
- if (d->direction == QDBusArgumentPrivate::Demarshalling)
+ if (d->direction == QDBusArgumentPrivate::Direction::Demarshalling)
return d->demarshaller()->currentSignature();
else
return d->marshaller()->currentSignature();
@@ -591,14 +556,14 @@ QDBusArgument::ElementType QDBusArgument::currentType() const
{
if (!d)
return UnknownType;
- if (d->direction == QDBusArgumentPrivate::Demarshalling)
+ if (d->direction == QDBusArgumentPrivate::Direction::Demarshalling)
return d->demarshaller()->currentType();
return UnknownType;
}
/*!
- Extracts one D-BUS primitive argument of type \c{BYTE} from the
- D-BUS stream and puts it into \a arg.
+ Extracts one D-Bus primitive argument of type \c{BYTE} from the
+ D-Bus stream and puts it into \a arg.
*/
const QDBusArgument &QDBusArgument::operator>>(uchar &arg) const
{
@@ -710,7 +675,7 @@ const QDBusArgument &QDBusArgument::operator>>(qulonglong &arg) const
/*!
\overload
Extracts one D-Bus primitive argument of type \c{DOUBLE}
- (double-precision floating pount) from the D-Bus stream.
+ (double-precision floating point) from the D-Bus stream.
*/
const QDBusArgument &QDBusArgument::operator>>(double &arg) const
{
@@ -1205,12 +1170,33 @@ const QDBusArgument &operator>>(const QDBusArgument &a, QDateTime &dt)
a >> date >> time >> timespec;
a.endStructure();
- dt = QDateTime(date, time, Qt::TimeSpec(timespec));
+ switch (Qt::TimeSpec(timespec)) {
+ case Qt::TimeZone:
+ qWarning("Restoring zoned date-time without zone info");
+ Q_FALLTHROUGH(); // Treat as local time.
+ case Qt::LocalTime:
+ dt = QDateTime(date, time);
+ break;
+ case Qt::OffsetFromUTC:
+ qWarning("Restoring date-time without its offset");
+ Q_FALLTHROUGH(); // Use zero offset
+ case Qt::UTC:
+ dt = QDateTime(date, time, QTimeZone::UTC);
+ break;
+ }
return a;
}
QDBusArgument &operator<<(QDBusArgument &a, const QDateTime &dt)
{
+ // TODO: Only viable for UTC and LocalTime
+ if (Q_UNLIKELY(dt.timeSpec() != Qt::UTC && dt.timeSpec() != Qt::LocalTime)) {
+ qWarning() << "Serializing a date-time with unsupported time-spec" << dt.timeSpec();
+ // Coerce to a supported timespec. When a time-zone is the current
+ // system zone, local time is suitable; so map all time-zones to local,
+ // plain offsets to UTC.
+ return a << (dt.timeSpec() == Qt::OffsetFromUTC ? dt.toUTC() : dt.toLocalTime());
+ }
a.beginStructure();
a << dt.date() << dt.time() << int(dt.timeSpec());
a.endStructure();
diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h
index cf09543912..70f6703d2f 100644
--- a/src/dbus/qdbusargument.h
+++ b/src/dbus/qdbusargument.h
@@ -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
#ifndef QDBUSARGUMENT_H
#define QDBUSARGUMENT_H
@@ -81,9 +45,9 @@ public:
QDBusArgument &operator=(const QDBusArgument &other);
~QDBusArgument();
- void swap(QDBusArgument &other) noexcept { qSwap(d, other.d); }
+ void swap(QDBusArgument &other) noexcept { qt_ptr_swap(d, other.d); }
- // used for marshalling (Qt -> D-BUS)
+ // used for marshalling (Qt -> D-Bus)
QDBusArgument &operator<<(uchar arg);
QDBusArgument &operator<<(bool arg);
QDBusArgument &operator<<(short arg);
@@ -116,7 +80,7 @@ public:
void appendVariant(const QVariant &v);
- // used for de-marshalling (D-BUS -> Qt)
+ // used for de-marshalling (D-Bus -> Qt)
QString currentSignature() const;
ElementType currentType() const;
@@ -157,7 +121,7 @@ protected:
Q_DECLARE_SHARED(QDBusArgument)
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDBusArgument)
+QT_DECL_METATYPE_EXTERN(QDBusArgument, Q_DBUS_EXPORT)
QT_BEGIN_NAMESPACE
template<typename T> inline T qdbus_cast(const QDBusArgument &arg)
@@ -258,10 +222,8 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &l
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantList &list)
{
arg.beginArray(QMetaType::fromType<QDBusVariant>());
- QVariantList::ConstIterator it = list.constBegin();
- QVariantList::ConstIterator end = list.constEnd();
- for ( ; it != end; ++it)
- arg << QDBusVariant(*it);
+ for (const QVariant &value : list)
+ arg << QDBusVariant(value);
arg.endArray();
return arg;
}
@@ -300,7 +262,7 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const Container<Key, T> &ma
}
template <template <typename, typename> class Container, typename Key, typename T,
- typename = typename Container<Key, T>::iterator>
+ QtPrivate::IfAssociativeIteratorHasKeyAndValue<typename Container<Key, T>::iterator> = true>
inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<Key, T> &map)
{
arg.beginMap();
@@ -320,11 +282,9 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<Key,
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantMap &map)
{
arg.beginMap(QMetaType::fromType<QString>(), QMetaType::fromType<QDBusVariant>());
- QVariantMap::ConstIterator it = map.constBegin();
- QVariantMap::ConstIterator end = map.constEnd();
- for ( ; it != end; ++it) {
+ for (const auto &[key, value] : map.asKeyValueRange()) {
arg.beginMapEntry();
- arg << it.key() << QDBusVariant(it.value());
+ arg << key << QDBusVariant(value);
arg.endMapEntry();
}
arg.endMap();
@@ -334,11 +294,9 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantMap &map)
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map)
{
arg.beginMap(QMetaType::fromType<QString>(), QMetaType::fromType<QDBusVariant>());
- QVariantHash::ConstIterator it = map.constBegin();
- QVariantHash::ConstIterator end = map.constEnd();
- for ( ; it != end; ++it) {
+ for (const auto &[key, value] : map.asKeyValueRange()) {
arg.beginMapEntry();
- arg << it.key() << QDBusVariant(it.value());
+ arg << key << QDBusVariant(value);
arg.endMapEntry();
}
arg.endMap();
@@ -346,7 +304,7 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map)
}
template <typename T1, typename T2>
-inline QDBusArgument &operator<<(QDBusArgument &arg, const QPair<T1, T2> &pair)
+inline QDBusArgument &operator<<(QDBusArgument &arg, const std::pair<T1, T2> &pair)
{
arg.beginStructure();
arg << pair.first << pair.second;
@@ -355,7 +313,7 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const QPair<T1, T2> &pair)
}
template <typename T1, typename T2>
-inline const QDBusArgument &operator>>(const QDBusArgument &arg, QPair<T1, T2> &pair)
+inline const QDBusArgument &operator>>(const QDBusArgument &arg, std::pair<T1, T2> &pair)
{
arg.beginStructure();
arg >> pair.first >> pair.second;
diff --git a/src/dbus/qdbusargument_p.h b/src/dbus/qdbusargument_p.h
index 92ff25e81c..d9a7382742 100644
--- a/src/dbus/qdbusargument_p.h
+++ b/src/dbus/qdbusargument_p.h
@@ -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
#ifndef QDBUSARGUMENT_P_H
#define QDBUSARGUMENT_P_H
@@ -53,6 +17,7 @@
#include <QtDBus/private/qtdbusglobal_p.h>
#include <qdbusargument.h>
+#include "qdbusconnection.h"
#include "qdbusunixfiledescriptor.h"
#include "qdbus_symbols_p.h"
@@ -69,10 +34,10 @@ class QDBusMarshaller;
class QDBusDemarshaller;
class QDBusArgumentPrivate
{
+ Q_DISABLE_COPY_MOVE(QDBusArgumentPrivate)
public:
- inline QDBusArgumentPrivate(int flags = 0)
- : message(nullptr), ref(1), capabilities(flags)
- { }
+ enum class Direction { Marshalling, Demarshalling };
+
virtual ~QDBusArgumentPrivate();
static bool checkRead(QDBusArgumentPrivate *d);
@@ -82,7 +47,7 @@ public:
QDBusMarshaller *marshaller();
QDBusDemarshaller *demarshaller();
- static QByteArray createSignature(int id);
+ static QByteArray createSignature(QMetaType type);
static inline QDBusArgument create(QDBusArgumentPrivate *d)
{
QDBusArgument q(d);
@@ -91,21 +56,26 @@ public:
static inline QDBusArgumentPrivate *d(QDBusArgument &q)
{ return q.d; }
-public:
- DBusMessage *message;
- QAtomicInt ref;
- int capabilities;
- enum Direction {
- Marshalling,
- Demarshalling
- } direction;
+ DBusMessage *message = nullptr;
+ QAtomicInt ref = 1;
+ QDBusConnection::ConnectionCapabilities capabilities;
+ Direction direction;
+
+protected:
+ explicit QDBusArgumentPrivate(Direction direction,
+ QDBusConnection::ConnectionCapabilities flags = {})
+ : capabilities(flags), direction(direction)
+ {
+ }
};
-class QDBusMarshaller: public QDBusArgumentPrivate
+class QDBusMarshaller final : public QDBusArgumentPrivate
{
public:
- QDBusMarshaller(int flags) : QDBusArgumentPrivate(flags), parent(nullptr), ba(nullptr), closeCode(0), ok(true), skipSignature(false)
- { direction = Marshalling; }
+ explicit QDBusMarshaller(QDBusConnection::ConnectionCapabilities flags = {})
+ : QDBusArgumentPrivate(Direction::Marshalling, flags)
+ {
+ }
~QDBusMarshaller();
QString currentSignature();
@@ -145,25 +115,26 @@ public:
bool appendRegisteredType(const QVariant &arg);
bool appendCrossMarshalling(QDBusDemarshaller *arg);
-public:
DBusMessageIter iterator;
- QDBusMarshaller *parent;
- QByteArray *ba;
+ QDBusMarshaller *parent = nullptr;
+ QByteArray *ba = nullptr;
QString errorString;
- char closeCode;
- bool ok;
- bool skipSignature;
+ char closeCode = 0;
+ bool ok = true;
+ bool skipSignature = false;
private:
Q_DECL_COLD_FUNCTION void unregisteredTypeError(QMetaType t);
Q_DISABLE_COPY_MOVE(QDBusMarshaller)
};
-class QDBusDemarshaller: public QDBusArgumentPrivate
+class QDBusDemarshaller final : public QDBusArgumentPrivate
{
public:
- inline QDBusDemarshaller(int flags) : QDBusArgumentPrivate(flags), parent(nullptr)
- { direction = Demarshalling; }
+ explicit QDBusDemarshaller(QDBusConnection::ConnectionCapabilities flags = {})
+ : QDBusArgumentPrivate(Direction::Demarshalling, flags)
+ {
+ }
~QDBusDemarshaller();
QString currentSignature();
@@ -204,9 +175,8 @@ public:
QDBusArgument::ElementType currentType();
bool isCurrentTypeStringLike();
-public:
DBusMessageIter iterator;
- QDBusDemarshaller *parent;
+ QDBusDemarshaller *parent = nullptr;
private:
Q_DISABLE_COPY_MOVE(QDBusDemarshaller)
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index c4f5e2a0fa..f6918b70b0 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -1,62 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbusconnection.h"
#include "qdbusconnection_p.h"
#include <qdebug.h>
-#include <qcoreapplication.h>
#include <qstringlist.h>
-#include <qtimer.h>
-#include <qthread.h>
-#include <QtCore/private/qlocking_p.h>
#include "qdbusconnectioninterface.h"
#include "qdbuserror.h"
#include "qdbusmessage.h"
-#include "qdbusmessage_p.h"
-#include "qdbusinterface_p.h"
#include "qdbusutil_p.h"
#include "qdbusconnectionmanager_p.h"
#include "qdbuspendingcall_p.h"
-
#include "qdbusthreaddebug_p.h"
#include <algorithm>
@@ -69,219 +26,6 @@
QT_BEGIN_NAMESPACE
-#ifdef Q_OS_WIN
-static void preventDllUnload();
-#endif
-
-Q_GLOBAL_STATIC(QDBusConnectionManager, _q_manager)
-
-QDBusConnectionPrivate *QDBusConnectionManager::busConnection(QDBusConnection::BusType type)
-{
- static_assert(int(QDBusConnection::SessionBus) + int(QDBusConnection::SystemBus) == 1);
- Q_ASSERT(type == QDBusConnection::SessionBus || type == QDBusConnection::SystemBus);
-
- if (!qdbus_loadLibDBus())
- return nullptr;
-
- // we'll start in suspended delivery mode if we're in the main thread
- // (the event loop will resume delivery)
- bool suspendedDelivery = qApp && qApp->thread() == QThread::currentThread();
-
- const auto locker = qt_scoped_lock(defaultBusMutex);
- if (defaultBuses[type])
- return defaultBuses[type];
-
- QString name = QStringLiteral("qt_default_session_bus");
- if (type == QDBusConnection::SystemBus)
- name = QStringLiteral("qt_default_system_bus");
- return defaultBuses[type] = connectToBus(type, name, suspendedDelivery);
-}
-
-QDBusConnectionPrivate *QDBusConnectionManager::connection(const QString &name) const
-{
- return connectionHash.value(name, nullptr);
-}
-
-void QDBusConnectionManager::removeConnection(const QString &name)
-{
- QDBusConnectionPrivate *d = nullptr;
- d = connectionHash.take(name);
- if (d && !d->ref.deref())
- d->deleteLater();
-
- // Static objects may be keeping the connection open.
- // However, it is harmless to have outstanding references to a connection that is
- // closing as long as those references will be soon dropped without being used.
-
- // ### Output a warning if connections are being used after they have been removed.
-}
-
-QDBusConnectionManager::QDBusConnectionManager()
-{
- connect(this, &QDBusConnectionManager::connectionRequested,
- this, &QDBusConnectionManager::executeConnectionRequest, Qt::BlockingQueuedConnection);
- connect(this, &QDBusConnectionManager::serverRequested,
- this, &QDBusConnectionManager::createServer, Qt::BlockingQueuedConnection);
- moveToThread(this); // ugly, don't do this in other projects
-
-#ifdef Q_OS_WIN
- // prevent the library from being unloaded on Windows. See comments in the function.
- preventDllUnload();
-#endif
- defaultBuses[0] = defaultBuses[1] = nullptr;
- start();
-}
-
-QDBusConnectionManager::~QDBusConnectionManager()
-{
- quit();
- wait();
-}
-
-QDBusConnectionManager* QDBusConnectionManager::instance()
-{
- return _q_manager();
-}
-
-Q_DBUS_EXPORT void qDBusBindToApplication();
-void qDBusBindToApplication()
-{
-}
-
-void QDBusConnectionManager::setConnection(const QString &name, QDBusConnectionPrivate *c)
-{
- connectionHash[name] = c;
- c->name = name;
-}
-
-void QDBusConnectionManager::run()
-{
- exec();
-
- // cleanup:
- const auto locker = qt_scoped_lock(mutex);
- for (QHash<QString, QDBusConnectionPrivate *>::const_iterator it = connectionHash.constBegin();
- it != connectionHash.constEnd(); ++it) {
- QDBusConnectionPrivate *d = it.value();
- if (!d->ref.deref()) {
- delete d;
- } else {
- d->closeConnection();
- d->moveToThread(nullptr); // allow it to be deleted in another thread
- }
- }
- connectionHash.clear();
-
- // allow deletion from any thread without warning
- moveToThread(nullptr);
-}
-
-QDBusConnectionPrivate *QDBusConnectionManager::connectToBus(QDBusConnection::BusType type, const QString &name,
- bool suspendedDelivery)
-{
- ConnectionRequestData data;
- data.type = ConnectionRequestData::ConnectToStandardBus;
- data.busType = type;
- data.name = &name;
- data.suspendedDelivery = suspendedDelivery;
-
- emit connectionRequested(&data);
- if (suspendedDelivery && data.result->connection) {
- data.result->ref.ref();
- QDBusConnectionDispatchEnabler *o = new QDBusConnectionDispatchEnabler(data.result);
- QTimer::singleShot(0, o, SLOT(execute()));
- o->moveToThread(qApp->thread()); // qApp was checked in the caller
- }
- return data.result;
-}
-
-QDBusConnectionPrivate *QDBusConnectionManager::connectToBus(const QString &address, const QString &name)
-{
- ConnectionRequestData data;
- data.type = ConnectionRequestData::ConnectToBusByAddress;
- data.busAddress = &address;
- data.name = &name;
- data.suspendedDelivery = false;
-
- emit connectionRequested(&data);
- return data.result;
-}
-
-QDBusConnectionPrivate *QDBusConnectionManager::connectToPeer(const QString &address, const QString &name)
-{
- ConnectionRequestData data;
- data.type = ConnectionRequestData::ConnectToPeerByAddress;
- data.busAddress = &address;
- data.name = &name;
- data.suspendedDelivery = false;
-
- emit connectionRequested(&data);
- return data.result;
-}
-
-void QDBusConnectionManager::executeConnectionRequest(QDBusConnectionManager::ConnectionRequestData *data)
-{
- const auto locker = qt_scoped_lock(mutex);
- const QString &name = *data->name;
- QDBusConnectionPrivate *&d = data->result;
-
- // check if the connection exists by name
- d = connection(name);
- if (d || name.isEmpty())
- return;
-
- d = new QDBusConnectionPrivate;
- DBusConnection *c = nullptr;
- QDBusErrorInternal error;
- switch (data->type) {
- case ConnectionRequestData::ConnectToStandardBus:
- switch (data->busType) {
- case QDBusConnection::SystemBus:
- c = q_dbus_bus_get_private(DBUS_BUS_SYSTEM, error);
- break;
- case QDBusConnection::SessionBus:
- c = q_dbus_bus_get_private(DBUS_BUS_SESSION, error);
- break;
- case QDBusConnection::ActivationBus:
- c = q_dbus_bus_get_private(DBUS_BUS_STARTER, error);
- break;
- }
- break;
-
- case ConnectionRequestData::ConnectToBusByAddress:
- case ConnectionRequestData::ConnectToPeerByAddress:
- c = q_dbus_connection_open_private(data->busAddress->toUtf8().constData(), error);
- if (c && data->type == ConnectionRequestData::ConnectToBusByAddress) {
- // register on the bus
- if (!q_dbus_bus_register(c, error)) {
- q_dbus_connection_unref(c);
- c = nullptr;
- }
- }
- break;
- }
-
- setConnection(name, d);
- if (data->type == ConnectionRequestData::ConnectToPeerByAddress) {
- d->setPeer(c, error);
- } else {
- // create the bus service
- // will lock in QDBusConnectionPrivate::connectRelay()
- d->setConnection(c, error);
- d->createBusService();
- if (c && data->suspendedDelivery)
- d->setDispatchEnabled(false);
- }
-}
-
-void QDBusConnectionManager::createServer(const QString &address, void *server)
-{
- QDBusErrorInternal error;
- QDBusConnectionPrivate *d = new QDBusConnectionPrivate;
- d->setServer(static_cast<QDBusServer *>(server),
- q_dbus_server_listen(address.toUtf8().constData(), error), error);
-}
-
/*!
\class QDBusConnection
\inmodule QtDBus
@@ -406,13 +150,17 @@ void QDBusConnectionManager::createServer(const QString &address, void *server)
*/
QDBusConnection::QDBusConnection(const QString &name)
{
- if (name.isEmpty() || _q_manager.isDestroyed()) {
+ if (name.isEmpty()) {
+ d = nullptr;
+ return;
+ }
+
+ auto *manager = QDBusConnectionManager::instance();
+
+ if (!manager) {
d = nullptr;
} else {
- const auto locker = qt_scoped_lock(_q_manager()->mutex);
- d = _q_manager()->connection(name);
- if (d)
- d->ref.ref();
+ d = manager->existingConnection(name);
}
}
@@ -465,17 +213,19 @@ QDBusConnection &QDBusConnection::operator=(const QDBusConnection &other)
}
/*!
- Opens a connection of type \a type to one of the known busses and
+ Opens a connection of type \a type to one of the known buses and
associate with it the connection name \a name. Returns a
QDBusConnection object associated with that connection.
*/
QDBusConnection QDBusConnection::connectToBus(BusType type, const QString &name)
{
- if (_q_manager.isDestroyed() || !qdbus_loadLibDBus()) {
+ auto *manager = QDBusConnectionManager::instance();
+
+ if (!manager || !qdbus_loadLibDBus()) {
QDBusConnectionPrivate *d = nullptr;
return QDBusConnection(d);
}
- return QDBusConnection(_q_manager()->connectToBus(type, name, false));
+ return QDBusConnection(manager->connectToBus(type, name, false));
}
/*!
@@ -485,11 +235,13 @@ QDBusConnection QDBusConnection::connectToBus(BusType type, const QString &name)
QDBusConnection QDBusConnection::connectToBus(const QString &address,
const QString &name)
{
- if (_q_manager.isDestroyed() || !qdbus_loadLibDBus()) {
+ auto *manager = QDBusConnectionManager::instance();
+
+ if (!manager || !qdbus_loadLibDBus()) {
QDBusConnectionPrivate *d = nullptr;
return QDBusConnection(d);
}
- return QDBusConnection(_q_manager()->connectToBus(address, name));
+ return QDBusConnection(manager->connectToBus(address, name));
}
/*!
\since 4.8
@@ -500,11 +252,13 @@ QDBusConnection QDBusConnection::connectToBus(const QString &address,
QDBusConnection QDBusConnection::connectToPeer(const QString &address,
const QString &name)
{
- if (_q_manager.isDestroyed() || !qdbus_loadLibDBus()) {
+ auto *manager = QDBusConnectionManager::instance();
+
+ if (!manager || !qdbus_loadLibDBus()) {
QDBusConnectionPrivate *d = nullptr;
return QDBusConnection(d);
}
- return QDBusConnection(_q_manager()->connectToPeer(address, name));
+ return QDBusConnection(manager->connectToPeer(address, name));
}
/*!
@@ -517,13 +271,11 @@ QDBusConnection QDBusConnection::connectToPeer(const QString &address,
*/
void QDBusConnection::disconnectFromBus(const QString &name)
{
- if (_q_manager()) {
- const auto locker = qt_scoped_lock(_q_manager()->mutex);
- QDBusConnectionPrivate *d = _q_manager()->connection(name);
- if (d && d->mode != QDBusConnectionPrivate::ClientMode)
- return;
- _q_manager()->removeConnection(name);
- }
+ auto *manager = QDBusConnectionManager::instance();
+ if (!manager)
+ return;
+
+ manager->disconnectFrom(name, QDBusConnectionPrivate::ClientMode);
}
/*!
@@ -538,13 +290,11 @@ void QDBusConnection::disconnectFromBus(const QString &name)
*/
void QDBusConnection::disconnectFromPeer(const QString &name)
{
- if (_q_manager()) {
- const auto locker = qt_scoped_lock(_q_manager()->mutex);
- QDBusConnectionPrivate *d = _q_manager()->connection(name);
- if (d && d->mode != QDBusConnectionPrivate::PeerMode)
- return;
- _q_manager()->removeConnection(name);
- }
+ auto *manager = QDBusConnectionManager::instance();
+ if (!manager)
+ return;
+
+ manager->disconnectFrom(name, QDBusConnectionPrivate::PeerMode);
}
/*!
@@ -681,6 +431,9 @@ QDBusMessage QDBusConnection::call(const QDBusMessage &message, QDBus::CallMode
See the QDBusInterface::asyncCall() function for a more friendly way
of placing calls.
+
+ \note Method calls to objects registered by the application itself are never
+ asynchronous due to implementation limitations.
*/
QDBusPendingCall QDBusConnection::asyncCall(const QDBusMessage &message, int timeout) const
{
@@ -889,16 +642,16 @@ bool QDBusConnection::registerObject(const QString &path, const QString &interfa
if (!d || !d->connection || !object || !options || !QDBusUtil::isValidObjectPath(path))
return false;
- auto pathComponents = QStringView{path}.split(QLatin1Char('/'));
+ auto pathComponents = QStringView{path}.split(u'/');
if (pathComponents.constLast().isEmpty())
pathComponents.removeLast();
QDBusWriteLocker locker(RegisterObjectAction, d);
// lower-bound search for where this object should enter in the tree
- QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator node = &d->rootNode;
+ QDBusConnectionPrivate::ObjectTreeNode *node = &d->rootNode;
int i = 1;
while (node) {
- if (pathComponents.count() == i) {
+ if (pathComponents.size() == i) {
// this node exists
// consider it free if there's no object here and the user is not trying to
// replace the object sub-tree
@@ -934,7 +687,7 @@ bool QDBusConnection::registerObject(const QString &path, const QString &interfa
std::lower_bound(node->children.begin(), node->children.end(), pathComponents.at(i));
if (it != node->children.end() && it->name == pathComponents.at(i)) {
// match: this node exists
- node = it;
+ node = &(*it);
// are we allowed to go deeper?
if (node->flags & ExportChildObjects) {
@@ -945,7 +698,8 @@ bool QDBusConnection::registerObject(const QString &path, const QString &interfa
}
} else {
// add entry
- node = node->children.insert(it, pathComponents.at(i).toString());
+ it = node->children.insert(it, pathComponents.at(i).toString());
+ node = &(*it);
}
// iterate
@@ -997,7 +751,7 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const
if (!d || !d->connection || !QDBusUtil::isValidObjectPath(path))
return nullptr;
- auto pathComponents = QStringView{path}.split(QLatin1Char('/'));
+ auto pathComponents = QStringView{path}.split(u'/');
if (pathComponents.constLast().isEmpty())
pathComponents.removeLast();
@@ -1007,7 +761,7 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const
int i = 1;
while (node) {
- if (pathComponents.count() == i)
+ if (pathComponents.size() == i)
return node->obj;
if ((node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath))
return node->obj;
@@ -1017,7 +771,7 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const
if (it == node->children.constEnd() || it->name != pathComponents.at(i))
break; // node not found
- node = it;
+ node = &(*it);
++i;
}
return nullptr;
@@ -1163,9 +917,11 @@ bool QDBusConnection::unregisterService(const QString &serviceName)
*/
QDBusConnection QDBusConnection::sessionBus()
{
- if (_q_manager.isDestroyed())
+ auto *manager = QDBusConnectionManager::instance();
+
+ if (!manager)
return QDBusConnection(nullptr);
- return QDBusConnection(_q_manager()->busConnection(SessionBus));
+ return QDBusConnection(manager->busConnection(SessionBus));
}
/*!
@@ -1177,9 +933,11 @@ QDBusConnection QDBusConnection::sessionBus()
*/
QDBusConnection QDBusConnection::systemBus()
{
- if (_q_manager.isDestroyed())
+ auto *manager = QDBusConnectionManager::instance();
+
+ if (!manager)
return QDBusConnection(nullptr);
- return QDBusConnection(_q_manager()->busConnection(SystemBus));
+ return QDBusConnection(manager->busConnection(SystemBus));
}
/*!
@@ -1254,31 +1012,7 @@ QByteArray QDBusConnection::localMachineId()
QT_END_NAMESPACE
-#ifdef Q_OS_WIN
-# include <qt_windows.h>
-
-QT_BEGIN_NAMESPACE
-static void preventDllUnload()
-{
- // Thread termination is really wacky on Windows. For some reason we don't
- // understand, exiting from the thread may try to unload the DLL. Since the
- // QDBusConnectionManager thread runs until the DLL is unloaded, we've got
- // a deadlock: the main thread is waiting for the manager thread to exit,
- // but the manager thread is attempting to acquire a lock to unload the DLL.
- //
- // We work around the issue by preventing the unload from happening in the
- // first place.
- //
- // For this trick, see
- // https://blogs.msdn.microsoft.com/oldnewthing/20131105-00/?p=2733
-
- static HMODULE self;
- GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
- GET_MODULE_HANDLE_EX_FLAG_PIN,
- reinterpret_cast<const wchar_t *>(&self), // any address in this DLL
- &self);
-}
-QT_END_NAMESPACE
-#endif
+#include "moc_qdbusconnection_p.cpp"
+#include "moc_qdbusconnection.cpp"
#endif // QT_NO_DBUS
diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h
index 43bc547894..be8acdc4ea 100644
--- a/src/dbus/qdbusconnection.h
+++ b/src/dbus/qdbusconnection.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QDBUSCONNECTION_H
#define QDBUSCONNECTION_H
@@ -138,7 +102,7 @@ public:
QDBusConnection &operator=(const QDBusConnection &other);
~QDBusConnection();
- void swap(QDBusConnection &other) noexcept { qSwap(d, other.d); }
+ void swap(QDBusConnection &other) noexcept { qt_ptr_swap(d, other.d); }
bool isConnected() const;
QString baseService() const;
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index b8a1b7bbfd..53e6874818 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
@@ -151,9 +115,11 @@ public:
{
typedef QList<ObjectTreeNode> DataList;
- inline ObjectTreeNode() : obj(nullptr), flags(0) { }
+ inline ObjectTreeNode() : obj(nullptr) { }
inline ObjectTreeNode(const QString &n) // intentionally implicit
- : name(n), obj(nullptr), flags(0) { }
+ : name(n), obj(nullptr)
+ {
+ }
inline bool operator<(const QString &other) const
{ return name < other; }
inline bool operator<(QStringView other) const
@@ -167,12 +133,11 @@ public:
QObject *obj;
QDBusVirtualObject *treeNode;
};
- int flags;
+ QDBusConnection::RegisterOptions flags;
DataList children;
};
-public:
// typedefs
typedef QMultiHash<qintptr, Watcher> WatcherHash;
typedef QHash<int, DBusTimeout *> TimeoutHash;
@@ -193,9 +158,8 @@ public:
};
typedef QHash<QString, WatchedServiceData> WatchedServicesHash;
-public:
// public methods are entry points from other objects
- explicit QDBusConnectionPrivate(QObject *parent = nullptr);
+ QDBusConnectionPrivate();
~QDBusConnectionPrivate();
void createBusService();
@@ -213,7 +177,7 @@ public:
QObject *obj, const char *member);
bool send(const QDBusMessage &message);
- QDBusMessage sendWithReply(const QDBusMessage &message, int mode, int timeout = -1);
+ QDBusMessage sendWithReply(const QDBusMessage &message, QDBus::CallMode mode, int timeout = -1);
QDBusMessage sendWithReplyLocal(const QDBusMessage &message);
QDBusPendingCallPrivate *sendWithReplyAsync(const QDBusMessage &message, QObject *receiver,
const char *returnMethod, const char *errorMethod,int timeout = -1);
@@ -248,6 +212,8 @@ public:
void postEventToThread(int action, QObject *target, QEvent *event);
+ void enableDispatchDelayed(QObject *context);
+
private:
void checkThread();
bool handleError(const QDBusErrorInternal &error);
@@ -259,12 +225,13 @@ private:
void activateSignal(const SignalHook& hook, const QDBusMessage &msg);
void activateObject(ObjectTreeNode &node, const QDBusMessage &msg, int pathStartPos);
bool activateInternalFilters(const ObjectTreeNode &node, const QDBusMessage &msg);
- bool activateCall(QObject *object, int flags, const QDBusMessage &msg);
+ bool activateCall(QObject *object, QDBusConnection::RegisterOptions flags,
+ const QDBusMessage &msg);
void sendInternal(QDBusPendingCallPrivate *pcall, void *msg, int timeout);
void sendError(const QDBusMessage &msg, QDBusError::ErrorType code);
- void deliverCall(QObject *object, int flags, const QDBusMessage &msg,
- const QList<QMetaType> &metaTypes, int slotIdx);
+ void deliverCall(QObject *object, const QDBusMessage &msg, const QList<QMetaType> &metaTypes,
+ int slotIdx);
SignalHookHash::Iterator removeSignalHookNoLock(SignalHookHash::Iterator it);
void collectAllObjects(ObjectTreeNode &node, QSet<QObject *> &set);
@@ -275,10 +242,14 @@ private:
void watchForDBusDisconnection();
- void _q_newConnection(QDBusConnectionPrivate *newConnection);
-
void handleAuthentication();
+ bool addSignalHook(const QString &key, const SignalHook &hook);
+ bool removeSignalHook(const QString &key, const SignalHook &hook);
+
+ bool addSignalHookImpl(const QString &key, const SignalHook &hook);
+ bool removeSignalHookImpl(const QString &key, const SignalHook &hook);
+
protected:
void timerEvent(QTimerEvent *e) override;
@@ -290,8 +261,6 @@ public slots:
void socketWrite(qintptr);
void objectDestroyed(QObject *o);
void relaySignal(QObject *obj, const QMetaObject *, int signalId, const QVariantList &args);
- bool addSignalHook(const QString &key, const SignalHook &hook);
- bool removeSignalHook(const QString &key, const SignalHook &hook);
private slots:
void serviceOwnerChangedNoLock(const QString &name, const QString &oldOwner, const QString &newOwner);
@@ -303,11 +272,8 @@ signals:
void dispatchStatusChanged();
void spyHooksFinished(const QDBusMessage &msg);
void messageNeedsSending(QDBusPendingCallPrivate *pcall, void *msg, int timeout = -1);
- bool signalNeedsConnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook);
- bool signalNeedsDisconnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook);
void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
void callWithCallbackFailed(const QDBusError &error, const QDBusMessage &message);
- void newServerConnection(QDBusConnectionPrivate *newConnection);
public:
QAtomicInt ref;
@@ -350,16 +316,14 @@ public:
bool dispatchEnabled; // protected by the dispatch lock, not the main lock
bool isAuthenticated;
-public:
// static methods
- static int findSlot(QObject *obj, const QByteArray &normalizedName, QList<QMetaType> &params);
+ static int findSlot(QObject *obj, const QByteArray &normalizedName, QList<QMetaType> &params,
+ QString &errorMsg);
static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
- const QString &service,
- const QString &path, const QString &interface, const QString &name,
- const ArgMatchRules &argMatch,
- QObject *receiver, const char *signal, int minMIdx,
- bool buildSignature);
- static DBusHandlerResult messageFilter(DBusConnection *, DBusMessage *, void *);
+ const QString &service, const QString &path, const QString &interface,
+ const QString &name, const ArgMatchRules &argMatch, QObject *receiver,
+ const char *signal, int minMIdx, bool buildSignature,
+ QString &errorMsg);
static QDBusCallDeliveryEvent *prepareReply(QDBusConnectionPrivate *target, QObject *object,
int idx, const QList<QMetaType> &metaTypes,
const QDBusMessage &msg);
@@ -392,26 +356,6 @@ extern QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNod
extern QDBusMessage qDBusPropertyGetAll(const QDBusConnectionPrivate::ObjectTreeNode &node,
const QDBusMessage &msg);
-// can be replaced with a lambda in Qt 5.7
-class QDBusConnectionDispatchEnabler : public QObject
-{
- Q_OBJECT
- QDBusConnectionPrivate *con;
-public:
- QDBusConnectionDispatchEnabler(QDBusConnectionPrivate *con) : con(con) {}
-
-public slots:
- void execute()
- {
- // This call cannot race with something disabling dispatch only because dispatch is
- // never re-disabled from Qt code on an in-use connection once it has been enabled.
- QMetaObject::invokeMethod(con, "setDispatchEnabled", Qt::QueuedConnection, Q_ARG(bool, true));
- if (!con->ref.deref())
- con->deleteLater();
- deleteLater();
- }
-};
-
#endif // QT_BOOTSTRAPPED
QT_END_NAMESPACE
diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp
index a2335a1795..0e886dcc04 100644
--- a/src/dbus/qdbusconnectioninterface.cpp
+++ b/src/dbus/qdbusconnectioninterface.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 "qdbusconnectioninterface.h"
@@ -54,6 +18,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*
* Implementation of interface class QDBusConnectionInterface
*/
@@ -184,7 +150,7 @@ QDBusConnectionInterface::~QDBusConnectionInterface()
*/
QDBusReply<QString> QDBusConnectionInterface::serviceOwner(const QString &name) const
{
- return internalConstCall(QDBus::AutoDetect, QLatin1String("GetNameOwner"), QList<QVariant>() << name);
+ return internalConstCall(QDBus::AutoDetect, "GetNameOwner"_L1, QList<QVariant>() << name);
}
/*!
@@ -195,7 +161,7 @@ QDBusReply<QString> QDBusConnectionInterface::serviceOwner(const QString &name)
*/
QDBusReply<QStringList> QDBusConnectionInterface::registeredServiceNames() const
{
- return internalConstCall(QDBus::AutoDetect, QLatin1String("ListNames"));
+ return internalConstCall(QDBus::AutoDetect, "ListNames"_L1);
}
/*!
@@ -207,7 +173,7 @@ QDBusReply<QStringList> QDBusConnectionInterface::registeredServiceNames() const
*/
QDBusReply<QStringList> QDBusConnectionInterface::activatableServiceNames() const
{
- return internalConstCall(QDBus::AutoDetect, QLatin1String("ListActivatableNames"));
+ return internalConstCall(QDBus::AutoDetect, "ListActivatableNames"_L1);
}
/*!
@@ -216,7 +182,7 @@ QDBusReply<QStringList> QDBusConnectionInterface::activatableServiceNames() cons
*/
QDBusReply<bool> QDBusConnectionInterface::isServiceRegistered(const QString &serviceName) const
{
- return internalConstCall(QDBus::AutoDetect, QLatin1String("NameHasOwner"),
+ return internalConstCall(QDBus::AutoDetect, "NameHasOwner"_L1,
QList<QVariant>() << serviceName);
}
@@ -226,7 +192,7 @@ QDBusReply<bool> QDBusConnectionInterface::isServiceRegistered(const QString &se
*/
QDBusReply<uint> QDBusConnectionInterface::servicePid(const QString &serviceName) const
{
- return internalConstCall(QDBus::AutoDetect, QLatin1String("GetConnectionUnixProcessID"),
+ return internalConstCall(QDBus::AutoDetect, "GetConnectionUnixProcessID"_L1,
QList<QVariant>() << serviceName);
}
@@ -236,7 +202,7 @@ QDBusReply<uint> QDBusConnectionInterface::servicePid(const QString &serviceName
*/
QDBusReply<uint> QDBusConnectionInterface::serviceUid(const QString &serviceName) const
{
- return internalConstCall(QDBus::AutoDetect, QLatin1String("GetConnectionUnixUser"),
+ return internalConstCall(QDBus::AutoDetect, "GetConnectionUnixUser"_L1,
QList<QVariant>() << serviceName);
}
@@ -245,7 +211,7 @@ QDBusReply<uint> QDBusConnectionInterface::serviceUid(const QString &serviceName
*/
QDBusReply<void> QDBusConnectionInterface::startService(const QString &name)
{
- return call(QLatin1String("StartServiceByName"), name, uint(0));
+ return call("StartServiceByName"_L1, name, uint(0));
}
/*!
@@ -290,7 +256,7 @@ QDBusConnectionInterface::registerService(const QString &serviceName,
break;
}
- QDBusMessage reply = call(QLatin1String("RequestName"), serviceName, flags);
+ QDBusMessage reply = call("RequestName"_L1, serviceName, flags);
// qDebug() << "QDBusConnectionInterface::registerService" << serviceName << "Reply:" << reply;
// convert the low-level flags to something that we can use
@@ -328,7 +294,7 @@ QDBusConnectionInterface::registerService(const QString &serviceName,
QDBusReply<bool>
QDBusConnectionInterface::unregisterService(const QString &serviceName)
{
- QDBusMessage reply = call(QLatin1String("ReleaseName"), serviceName);
+ QDBusMessage reply = call("ReleaseName"_L1, serviceName);
if (reply.type() == QDBusMessage::ReplyMessage) {
bool success = reply.arguments().at(0).toUInt() == DBUS_RELEASE_NAME_REPLY_RELEASED;
reply.setArguments(QVariantList() << success);
@@ -442,4 +408,6 @@ void QDBusConnectionInterface::disconnectNotify(const QMetaMethod &signal)
QT_END_NAMESPACE
+#include "moc_qdbusconnectioninterface.cpp"
+
#endif // QT_NO_DBUS
diff --git a/src/dbus/qdbusconnectioninterface.h b/src/dbus/qdbusconnectioninterface.h
index d19e116c53..e664e4e0e7 100644
--- a/src/dbus/qdbusconnectioninterface.h
+++ b/src/dbus/qdbusconnectioninterface.h
@@ -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
#ifndef QDBUSCONNECTIONINTERFACE_H
#define QDBUSCONNECTIONINTERFACE_H
diff --git a/src/dbus/qdbusconnectionmanager.cpp b/src/dbus/qdbusconnectionmanager.cpp
new file mode 100644
index 0000000000..ce52c9fa63
--- /dev/null
+++ b/src/dbus/qdbusconnectionmanager.cpp
@@ -0,0 +1,334 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qdbusconnectionmanager_p.h"
+
+#include <qcoreapplication.h>
+#include <qthread.h>
+#include <qstringlist.h>
+#include <QtCore/private/qlocking_p.h>
+
+#include "qdbuserror.h"
+#include "qdbuspendingcall_p.h"
+#include "qdbusmetatype_p.h"
+
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+
+#ifdef Q_OS_WIN
+static void preventDllUnload();
+#endif
+
+Q_GLOBAL_STATIC(QDBusConnectionManager, _q_manager)
+
+QDBusConnectionPrivate *QDBusConnectionManager::busConnection(QDBusConnection::BusType type)
+{
+ static_assert(int(QDBusConnection::SessionBus) + int(QDBusConnection::SystemBus) == 1);
+ Q_ASSERT(type == QDBusConnection::SessionBus || type == QDBusConnection::SystemBus);
+
+ if (!qdbus_loadLibDBus())
+ return nullptr;
+
+ // we'll start in suspended delivery mode if we're in the main thread
+ // (the event loop will resume delivery)
+ bool suspendedDelivery = qApp && qApp->thread() == QThread::currentThread();
+
+ const auto locker = qt_scoped_lock(defaultBusMutex);
+ if (defaultBuses[type])
+ return defaultBuses[type];
+
+ QString name = QStringLiteral("qt_default_session_bus");
+ if (type == QDBusConnection::SystemBus)
+ name = QStringLiteral("qt_default_system_bus");
+ return defaultBuses[type] = connectToBus(type, name, suspendedDelivery);
+}
+
+QDBusConnectionPrivate *QDBusConnectionManager::connection(const QString &name) const
+{
+ return connectionHash.value(name, nullptr);
+}
+
+QDBusConnectionPrivate *QDBusConnectionManager::existingConnection(const QString &name) const
+{
+ const auto locker = qt_scoped_lock(mutex);
+ auto *conn = connection(name);
+ if (conn)
+ conn->ref.ref();
+ return conn;
+}
+
+void QDBusConnectionManager::removeConnection(const QString &name)
+{
+ QDBusConnectionPrivate *d = nullptr;
+ d = connectionHash.take(name);
+ if (d && !d->ref.deref())
+ d->deleteLater();
+
+ // Static objects may be keeping the connection open.
+ // However, it is harmless to have outstanding references to a connection that is
+ // closing as long as those references will be soon dropped without being used.
+
+ // ### Output a warning if connections are being used after they have been removed.
+}
+
+void QDBusConnectionManager::removeConnections(const QStringList &names)
+{
+ const auto locker = qt_scoped_lock(mutex);
+
+ for (const auto &name : names)
+ removeConnection(name);
+}
+
+void QDBusConnectionManager::disconnectFrom(const QString &name,
+ QDBusConnectionPrivate::ConnectionMode mode)
+{
+ const auto locker = qt_scoped_lock(mutex);
+
+ QDBusConnectionPrivate *d = connection(name);
+ if (d && d->mode != mode)
+ return;
+ removeConnection(name);
+}
+
+QDBusConnectionManager::QDBusConnectionManager()
+{
+ // Ensure that the custom metatype registry is created before the instance
+ // of this class. This will ensure that the registry is not destroyed before
+ // the connection manager at application exit (see also QTBUG-58732). This
+ // works with compilers that use mechanism similar to atexit() to call
+ // destructurs for global statics.
+ QDBusMetaTypeId::init();
+
+ moveToThread(this); // ugly, don't do this in other projects
+
+#ifdef Q_OS_WIN
+ // prevent the library from being unloaded on Windows. See comments in the function.
+ preventDllUnload();
+#endif
+ defaultBuses[0] = defaultBuses[1] = nullptr;
+ start();
+}
+
+QDBusConnectionManager::~QDBusConnectionManager()
+{
+ quit();
+ wait();
+}
+
+QDBusConnectionManager* QDBusConnectionManager::instance()
+{
+ return _q_manager();
+}
+
+Q_DBUS_EXPORT void qDBusBindToApplication();
+void qDBusBindToApplication()
+{
+}
+
+void QDBusConnectionManager::setConnection(const QString &name, QDBusConnectionPrivate *c)
+{
+ connectionHash[name] = c;
+ c->name = name;
+}
+
+void QDBusConnectionManager::addConnection(const QString &name, QDBusConnectionPrivate *c)
+{
+ const auto locker = qt_scoped_lock(mutex);
+ setConnection(name, c);
+}
+
+void QDBusConnectionManager::run()
+{
+ exec();
+
+ // cleanup:
+ const auto locker = qt_scoped_lock(mutex);
+ for (QDBusConnectionPrivate *d : std::as_const(connectionHash)) {
+ if (!d->ref.deref()) {
+ delete d;
+ } else {
+ d->closeConnection();
+ d->moveToThread(nullptr); // allow it to be deleted in another thread
+ }
+ }
+ connectionHash.clear();
+
+ // allow deletion from any thread without warning
+ moveToThread(nullptr);
+}
+
+QDBusConnectionPrivate *QDBusConnectionManager::connectToBus(QDBusConnection::BusType type, const QString &name,
+ bool suspendedDelivery)
+{
+ QDBusConnectionPrivate *result = nullptr;
+
+ QMetaObject::invokeMethod(this, &QDBusConnectionManager::doConnectToStandardBus,
+ Qt::BlockingQueuedConnection, qReturnArg(result), type, name,
+ suspendedDelivery);
+
+ if (suspendedDelivery && result && result->connection)
+ result->enableDispatchDelayed(qApp); // qApp was checked in the caller
+
+ return result;
+}
+
+QDBusConnectionPrivate *QDBusConnectionManager::connectToBus(const QString &address, const QString &name)
+{
+ QDBusConnectionPrivate *result = nullptr;
+
+ QMetaObject::invokeMethod(this, &QDBusConnectionManager::doConnectToBus,
+ Qt::BlockingQueuedConnection, qReturnArg(result), address, name);
+
+ return result;
+}
+
+QDBusConnectionPrivate *QDBusConnectionManager::connectToPeer(const QString &address, const QString &name)
+{
+ QDBusConnectionPrivate *result = nullptr;
+
+ QMetaObject::invokeMethod(this, &QDBusConnectionManager::doConnectToPeer,
+ Qt::BlockingQueuedConnection, qReturnArg(result), address, name);
+
+ return result;
+}
+
+QDBusConnectionPrivate *
+QDBusConnectionManager::doConnectToStandardBus(QDBusConnection::BusType type, const QString &name,
+ bool suspendedDelivery)
+{
+ const auto locker = qt_scoped_lock(mutex);
+
+ // check if the connection exists by name
+ QDBusConnectionPrivate *d = connection(name);
+ if (d || name.isEmpty())
+ return d;
+
+ d = new QDBusConnectionPrivate;
+ DBusConnection *c = nullptr;
+ QDBusErrorInternal error;
+
+ switch (type) {
+ case QDBusConnection::SystemBus:
+ c = q_dbus_bus_get_private(DBUS_BUS_SYSTEM, error);
+ break;
+ case QDBusConnection::SessionBus:
+ c = q_dbus_bus_get_private(DBUS_BUS_SESSION, error);
+ break;
+ case QDBusConnection::ActivationBus:
+ c = q_dbus_bus_get_private(DBUS_BUS_STARTER, error);
+ break;
+ }
+
+ setConnection(name, d);
+
+ // create the bus service
+ // will lock in QDBusConnectionPrivate::connectRelay()
+ d->setConnection(c, error);
+ d->createBusService();
+ if (c && suspendedDelivery)
+ d->setDispatchEnabled(false);
+
+ return d;
+}
+
+QDBusConnectionPrivate *QDBusConnectionManager::doConnectToBus(const QString &address,
+ const QString &name)
+{
+ const auto locker = qt_scoped_lock(mutex);
+
+ // check if the connection exists by name
+ QDBusConnectionPrivate *d = connection(name);
+ if (d || name.isEmpty())
+ return d;
+
+ d = new QDBusConnectionPrivate;
+ QDBusErrorInternal error;
+
+ DBusConnection *c = q_dbus_connection_open_private(address.toUtf8().constData(), error);
+ if (c) {
+ // register on the bus
+ if (!q_dbus_bus_register(c, error)) {
+ q_dbus_connection_close(c);
+ q_dbus_connection_unref(c);
+ c = nullptr;
+ }
+ }
+
+ setConnection(name, d);
+
+ // create the bus service
+ // will lock in QDBusConnectionPrivate::connectRelay()
+ d->setConnection(c, error);
+ d->createBusService();
+
+ return d;
+}
+
+QDBusConnectionPrivate *QDBusConnectionManager::doConnectToPeer(const QString &address,
+ const QString &name)
+{
+ const auto locker = qt_scoped_lock(mutex);
+
+ // check if the connection exists by name
+ QDBusConnectionPrivate *d = connection(name);
+ if (d || name.isEmpty())
+ return d;
+
+ d = new QDBusConnectionPrivate;
+ QDBusErrorInternal error;
+
+ DBusConnection *c = q_dbus_connection_open_private(address.toUtf8().constData(), error);
+
+ setConnection(name, d);
+ d->setPeer(c, error);
+
+ return d;
+}
+
+void QDBusConnectionManager::createServer(const QString &address, QDBusServer *server)
+{
+ QMetaObject::invokeMethod(
+ this,
+ [&address, server] {
+ QDBusErrorInternal error;
+ QDBusConnectionPrivate *d = new QDBusConnectionPrivate;
+ d->setServer(server, q_dbus_server_listen(address.toUtf8().constData(), error),
+ error);
+ },
+ Qt::BlockingQueuedConnection);
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qdbusconnectionmanager_p.cpp"
+
+#ifdef Q_OS_WIN
+# include <qt_windows.h>
+
+QT_BEGIN_NAMESPACE
+static void preventDllUnload()
+{
+ // Thread termination is really wacky on Windows. For some reason we don't
+ // understand, exiting from the thread may try to unload the DLL. Since the
+ // QDBusConnectionManager thread runs until the DLL is unloaded, we've got
+ // a deadlock: the main thread is waiting for the manager thread to exit,
+ // but the manager thread is attempting to acquire a lock to unload the DLL.
+ //
+ // We work around the issue by preventing the unload from happening in the
+ // first place.
+ //
+ // For this trick, see the blog post titled "What is the point of FreeLibraryAndExitThread?"
+ // https://devblogs.microsoft.com/oldnewthing/20131105-00/?p=2733
+
+ static HMODULE self;
+ GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
+ GET_MODULE_HANDLE_EX_FLAG_PIN,
+ reinterpret_cast<const wchar_t *>(&self), // any address in this DLL
+ &self);
+}
+QT_END_NAMESPACE
+#endif
+
+#endif // QT_NO_DBUS
diff --git a/src/dbus/qdbusconnectionmanager_p.h b/src/dbus/qdbusconnectionmanager_p.h
index e080abca5e..644c3c8fb1 100644
--- a/src/dbus/qdbusconnectionmanager_p.h
+++ b/src/dbus/qdbusconnectionmanager_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
@@ -61,63 +25,46 @@
QT_BEGIN_NAMESPACE
+class QDBusServer;
+
class QDBusConnectionManager : public QDaemonThread
{
Q_OBJECT
- struct ConnectionRequestData;
public:
QDBusConnectionManager();
~QDBusConnectionManager();
static QDBusConnectionManager* instance();
QDBusConnectionPrivate *busConnection(QDBusConnection::BusType type);
- QDBusConnectionPrivate *connection(const QString &name) const;
- void removeConnection(const QString &name);
- void setConnection(const QString &name, QDBusConnectionPrivate *c);
+ QDBusConnectionPrivate *existingConnection(const QString &name) const;
+
+ void removeConnections(const QStringList &names);
+ void disconnectFrom(const QString &name, QDBusConnectionPrivate::ConnectionMode mode);
+ void addConnection(const QString &name, QDBusConnectionPrivate *c);
+
QDBusConnectionPrivate *connectToBus(QDBusConnection::BusType type, const QString &name, bool suspendedDelivery);
QDBusConnectionPrivate *connectToBus(const QString &address, const QString &name);
QDBusConnectionPrivate *connectToPeer(const QString &address, const QString &name);
- mutable QMutex mutex;
-
-signals:
- void connectionRequested(ConnectionRequestData *);
- void serverRequested(const QString &address, void *server);
+ void createServer(const QString &address, QDBusServer *server);
protected:
void run() override;
private:
- void executeConnectionRequest(ConnectionRequestData *data);
- void createServer(const QString &address, void *server);
+ QDBusConnectionPrivate *doConnectToStandardBus(QDBusConnection::BusType type,
+ const QString &name, bool suspendedDelivery);
+ QDBusConnectionPrivate *doConnectToBus(const QString &address, const QString &name);
+ QDBusConnectionPrivate *doConnectToPeer(const QString &address, const QString &name);
+ mutable QMutex mutex;
QHash<QString, QDBusConnectionPrivate *> connectionHash;
+ QDBusConnectionPrivate *connection(const QString &name) const;
+ void removeConnection(const QString &name);
+ void setConnection(const QString &name, QDBusConnectionPrivate *c);
QMutex defaultBusMutex;
QDBusConnectionPrivate *defaultBuses[2];
-
- mutable QMutex senderMutex;
- QString senderName; // internal; will probably change
-};
-
-// TODO: move into own header and use Q_MOC_INCLUDE
-struct QDBusConnectionManager::ConnectionRequestData
-{
- enum RequestType {
- ConnectToStandardBus,
- ConnectToBusByAddress,
- ConnectToPeerByAddress
- } type;
-
- union {
- QDBusConnection::BusType busType;
- const QString *busAddress;
- };
- const QString *name;
-
- QDBusConnectionPrivate *result;
-
- bool suspendedDelivery;
};
QT_END_NAMESPACE
diff --git a/src/dbus/qdbuscontext.cpp b/src/dbus/qdbuscontext.cpp
index de0482be70..b8cb1dc8b1 100644
--- a/src/dbus/qdbuscontext.cpp
+++ b/src/dbus/qdbuscontext.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 "qdbusmessage.h"
#include "qdbusconnection.h"
diff --git a/src/dbus/qdbuscontext.h b/src/dbus/qdbuscontext.h
index fedfcbd98e..02620449e1 100644
--- a/src/dbus/qdbuscontext.h
+++ b/src/dbus/qdbuscontext.h
@@ -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
#ifndef QDBUSCONTEXT_H
#define QDBUSCONTEXT_H
diff --git a/src/dbus/qdbuscontext_p.h b/src/dbus/qdbuscontext_p.h
index 087ded8b4f..1a544b8e44 100644
--- a/src/dbus/qdbuscontext_p.h
+++ b/src/dbus/qdbuscontext_p.h
@@ -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
//
// W A R N I N G
diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp
index 39d2dd0354..ee5a6874da 100644
--- a/src/dbus/qdbusdemarshaller.cpp
+++ b/src/dbus/qdbusdemarshaller.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"
diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp
index decd345ece..49c30e5b25 100644
--- a/src/dbus/qdbuserror.cpp
+++ b/src/dbus/qdbuserror.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 "qdbuserror.h"
@@ -53,6 +17,8 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QDBusError)
+
static constexpr const auto errorMessages = qOffsetStringArray(
"NoError",
"other",
@@ -210,7 +176,7 @@ QDBusError::QDBusError(const DBusError *error)
if (!error || !q_dbus_error_is_set(error))
return;
- code = ::get(error->name);
+ code = get(error->name);
msg = QString::fromUtf8(error->message);
nm = QString::fromUtf8(error->name);
}
@@ -225,7 +191,7 @@ QDBusError::QDBusError(const QDBusMessage &qdmsg)
if (qdmsg.type() != QDBusMessage::ErrorMessage)
return;
- code = ::get(qdmsg.errorName().toUtf8().constData());
+ code = get(qdmsg.errorName().toUtf8().constData());
nm = qdmsg.errorName();
msg = qdmsg.errorMessage();
}
@@ -238,7 +204,7 @@ QDBusError::QDBusError(const QDBusMessage &qdmsg)
QDBusError::QDBusError(ErrorType error, const QString &mess)
: code(error)
{
- nm = QLatin1String(errorMessages[error]);
+ nm = QLatin1StringView(errorMessages[error]);
msg = mess;
}
@@ -272,7 +238,7 @@ QDBusError &QDBusError::operator=(const QDBusError &other)
QDBusError &QDBusError::operator=(const QDBusMessage &qdmsg)
{
if (qdmsg.type() == QDBusMessage::ErrorMessage) {
- code = ::get(qdmsg.errorName().toUtf8().constData());
+ code = get(qdmsg.errorName().toUtf8().constData());
nm = qdmsg.errorName();
msg = qdmsg.errorMessage();
} else {
@@ -334,7 +300,7 @@ bool QDBusError::isValid() const
*/
QString QDBusError::errorString(ErrorType error)
{
- return QLatin1String(errorMessages[error]);
+ return QLatin1StringView(errorMessages[error]);
}
#ifndef QT_NO_DEBUG_STREAM
@@ -354,12 +320,14 @@ QDebug operator<<(QDebug dbg, const QDBusError &msg)
QT_END_NAMESPACE
+#include "moc_qdbuserror.cpp"
+
#endif // QT_NO_DBUS
/*
MSVC2015 has the warning C4503 at the end of the file:
QtPrivate::StaticStringBuilder<QtPrivate::IndexesList<...> - decorated name length exceeded, name was truncated
-It is used by qOffsetStringArray in a constexpr evaulation and this code does not exist in the object file,
+It is used by qOffsetStringArray in a constexpr evaluation and this code does not exist in the object file,
but we still have the warning or even error with -WX flag
*/
QT_WARNING_DISABLE_MSVC(4503)
diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h
index 7fe5b45f8e..292f967acb 100644
--- a/src/dbus/qdbuserror.h
+++ b/src/dbus/qdbuserror.h
@@ -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
#ifndef QDBUSERROR_H
#define QDBUSERROR_H
@@ -112,9 +76,9 @@ public:
void swap(QDBusError &other) noexcept
{
- qSwap(code, other.code);
- qSwap(msg, other.msg);
- qSwap(nm, other.nm);
+ std::swap(code, other.code);
+ msg.swap(other.msg);
+ nm.swap(other.nm);
}
ErrorType type() const;
@@ -140,7 +104,7 @@ Q_DBUS_EXPORT QDebug operator<<(QDebug, const QDBusError &);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDBusError)
+QT_DECL_METATYPE_EXTERN(QDBusError, Q_DBUS_EXPORT)
#else
QT_BEGIN_NAMESPACE
class Q_DBUS_EXPORT QDBusError {}; // dummy class for moc
diff --git a/src/dbus/qdbusextratypes.cpp b/src/dbus/qdbusextratypes.cpp
index 06fbd6062e..61f2075443 100644
--- a/src/dbus/qdbusextratypes.cpp
+++ b/src/dbus/qdbusextratypes.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 "qdbusextratypes.h"
#include "qdbusutil_p.h"
@@ -44,6 +8,19 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QDBusVariant)
+QT_IMPL_METATYPE_EXTERN(QDBusObjectPath)
+QT_IMPL_METATYPE_EXTERN(QDBusSignature)
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QDBusObjectPath &path)
+{
+ QDebugStateSaver saver(dbg);
+ dbg.nospace() << "QDBusObjectPath(" << path.path() << ')';
+ return dbg;
+}
+#endif
+
void QDBusObjectPath::doCheck()
{
if (!QDBusUtil::isValidObjectPath(m_path)) {
@@ -139,9 +116,9 @@ void QDBusSignature::doCheck()
*/
/*!
- \fn QDBusObjectPath::QDBusObjectPath(QLatin1String path)
+ \fn QDBusObjectPath::QDBusObjectPath(QLatin1StringView path)
- Constructs a new object path from the given \a path.
+ Constructs a new object path from the Latin-1 string viewed by \a path.
*/
/*!
@@ -200,9 +177,9 @@ QDBusObjectPath::operator QVariant() const { return QVariant::fromValue(*this);
*/
/*!
- \fn QDBusSignature::QDBusSignature(QLatin1String signature)
+ \fn QDBusSignature::QDBusSignature(QLatin1StringView signature)
- Constructs a new signature from the given \a signature.
+ Constructs a new signature from the Latin-1 string viewed by \a signature.
*/
/*!
diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h
index c4e05062c3..1bc0f3086d 100644
--- a/src/dbus/qdbusextratypes.h
+++ b/src/dbus/qdbusextratypes.h
@@ -1,46 +1,10 @@
-/****************************************************************************
-**
-** 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
#ifndef QDBUSEXTRATYPES_H
#define QDBUSEXTRATYPES_H
-// define some useful types for D-BUS
+// define some useful types for D-Bus
#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qvariant.h>
@@ -60,11 +24,11 @@ public:
// compiler-generated destructor is ok!
inline explicit QDBusObjectPath(const char *path);
- inline explicit QDBusObjectPath(QLatin1String path);
+ inline explicit QDBusObjectPath(QLatin1StringView path);
inline explicit QDBusObjectPath(const QString &path);
explicit QDBusObjectPath(QString &&p) : m_path(std::move(p)) { doCheck(); }
- void swap(QDBusObjectPath &other) noexcept { qSwap(m_path, other.m_path); }
+ void swap(QDBusObjectPath &other) noexcept { m_path.swap(other.m_path); }
inline void setPath(const QString &path);
@@ -82,7 +46,7 @@ inline QDBusObjectPath::QDBusObjectPath(const char *objectPath)
: m_path(QString::fromLatin1(objectPath))
{ doCheck(); }
-inline QDBusObjectPath::QDBusObjectPath(QLatin1String objectPath)
+inline QDBusObjectPath::QDBusObjectPath(QLatin1StringView objectPath)
: m_path(objectPath)
{ doCheck(); }
@@ -105,6 +69,9 @@ inline bool operator<(const QDBusObjectPath &lhs, const QDBusObjectPath &rhs)
inline size_t qHash(const QDBusObjectPath &objectPath, size_t seed = 0)
{ return qHash(objectPath.path(), seed); }
+#ifndef QT_NO_DEBUG_STREAM
+Q_DBUS_EXPORT QDebug operator<<(QDebug, const QDBusObjectPath &);
+#endif
class Q_DBUS_EXPORT QDBusSignature
{
@@ -115,11 +82,11 @@ public:
// compiler-generated destructor is ok!
inline explicit QDBusSignature(const char *signature);
- inline explicit QDBusSignature(QLatin1String signature);
+ inline explicit QDBusSignature(QLatin1StringView signature);
inline explicit QDBusSignature(const QString &signature);
explicit QDBusSignature(QString &&sig) : m_signature(std::move(sig)) { doCheck(); }
- void swap(QDBusSignature &other) noexcept { qSwap(m_signature, other.m_signature); }
+ void swap(QDBusSignature &other) noexcept { m_signature.swap(other.m_signature); }
inline void setSignature(const QString &signature);
@@ -135,7 +102,7 @@ inline QDBusSignature::QDBusSignature(const char *dBusSignature)
: m_signature(QString::fromLatin1(dBusSignature))
{ doCheck(); }
-inline QDBusSignature::QDBusSignature(QLatin1String dBusSignature)
+inline QDBusSignature::QDBusSignature(QLatin1StringView dBusSignature)
: m_signature(dBusSignature)
{ doCheck(); }
@@ -169,7 +136,7 @@ public:
inline explicit QDBusVariant(const QVariant &variant);
explicit QDBusVariant(QVariant &&v) noexcept : m_variant(std::move(v)) {}
- void swap(QDBusVariant &other) noexcept { qSwap(m_variant, other.m_variant); }
+ void swap(QDBusVariant &other) noexcept { m_variant.swap(other.m_variant); }
inline void setVariant(const QVariant &variant);
@@ -189,9 +156,9 @@ inline bool operator==(const QDBusVariant &v1, const QDBusVariant &v2)
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDBusVariant)
-Q_DECLARE_METATYPE(QDBusObjectPath)
-Q_DECLARE_METATYPE(QDBusSignature)
+QT_DECL_METATYPE_EXTERN(QDBusVariant, Q_DBUS_EXPORT)
+QT_DECL_METATYPE_EXTERN(QDBusObjectPath, Q_DBUS_EXPORT)
+QT_DECL_METATYPE_EXTERN(QDBusSignature, Q_DBUS_EXPORT)
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 6bf9ad7786..89b9b2d17e 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -1,48 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbusintegrator_p.h"
#include <qcoreapplication.h>
#include <qelapsedtimer.h>
-#include <qdebug.h>
+#include <qloggingcategory.h>
#include <qmetaobject.h>
#include <qobject.h>
#include <qsocketnotifier.h>
@@ -50,6 +14,7 @@
#include <qtimer.h>
#include <qthread.h>
#include <private/qlocking_p.h>
+#include <QtCore/qset.h>
#include "qdbusargument.h"
#include "qdbusconnection_p.h"
@@ -78,11 +43,17 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
+QT_IMPL_METATYPE_EXTERN(QDBusSlotCache)
+
// used with dbus_server_allocate_data_slot
static dbus_int32_t server_slot = -1;
-static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1);
-#define qDBusDebug if (::isDebugging == 0); else qDebug
+Q_LOGGING_CATEGORY(dbusIntegration, "qt.dbus.integration", QtWarningMsg)
+
+Q_CONSTINIT static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1);
+#define qDBusDebug if (::isDebugging.loadRelaxed() == 0); else qDebug
static inline QDebug operator<<(QDebug dbg, const QThread *th)
{
@@ -130,7 +101,34 @@ void qdbusDefaultThreadDebug(int action, int condition, QDBusConnectionPrivate *
qdbusThreadDebugFunc qdbusThreadDebug = nullptr;
#endif
-typedef QVarLengthArray<QDBusSpyCallEvent::Hook, 4> QDBusSpyHookList;
+class QDBusSpyHookList
+{
+public:
+ void add(QDBusSpyCallEvent::Hook hook)
+ {
+ const auto locker = qt_scoped_lock(lock);
+ list.append(hook);
+ }
+
+ void invoke(const QDBusMessage &msg)
+ {
+ // Create a copy of the hook list here, so that the hooks can be called
+ // without holding the lock.
+ QList<QDBusSpyCallEvent::Hook> hookListCopy;
+ {
+ const auto locker = qt_scoped_lock(lock);
+ hookListCopy = list;
+ }
+
+ for (auto hook : std::as_const(hookListCopy))
+ hook(msg);
+ }
+
+private:
+ QBasicMutex lock;
+ QList<QDBusSpyCallEvent::Hook> list;
+};
+
Q_GLOBAL_STATIC(QDBusSpyHookList, qDBusSpyHookList)
extern "C" {
@@ -153,8 +151,7 @@ static dbus_bool_t qDBusAddTimeout(DBusTimeout *timeout, void *data)
Q_ASSERT(d->timeouts.key(timeout, 0) == 0);
- int timerId = d->startTimer(q_dbus_timeout_get_interval(timeout));
- Q_ASSERT_X(timerId, "QDBusConnection", "Failed to start a timer");
+ int timerId = d->startTimer(std::chrono::milliseconds{q_dbus_timeout_get_interval(timeout)});
if (!timerId)
return false;
@@ -280,7 +277,6 @@ static void qDBusToggleWatch(DBusWatch *watch, void *data)
static void qDBusUpdateDispatchStatus(DBusConnection *connection, DBusDispatchStatus new_status, void *data)
{
Q_ASSERT(connection);
- Q_UNUSED(connection);
QDBusConnectionPrivate *d = static_cast<QDBusConnectionPrivate *>(data);
if (new_status == DBUS_DISPATCH_DATA_REMAINS)
emit d->dispatchStatusChanged();
@@ -290,11 +286,11 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v
{
// ### We may want to separate the server from the QDBusConnectionPrivate
Q_ASSERT(server);
- Q_UNUSED(server);
Q_ASSERT(connection);
Q_ASSERT(data);
- if (!QDBusConnectionManager::instance())
+ auto *manager = QDBusConnectionManager::instance();
+ if (!manager)
return;
// keep the connection alive
@@ -305,35 +301,35 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v
if (serverConnection->anonymousAuthenticationAllowed)
q_dbus_connection_set_allow_anonymous(connection, true);
- QDBusConnectionPrivate *newConnection = new QDBusConnectionPrivate(serverConnection->parent());
- const auto locker = qt_scoped_lock(QDBusConnectionManager::instance()->mutex);
- QDBusConnectionManager::instance()->setConnection(QLatin1String("QDBusServer-") + QString::number(reinterpret_cast<qulonglong>(newConnection), 16), newConnection);
- serverConnection->serverConnectionNames << newConnection->name;
+ QDBusConnectionPrivate *newConnection = new QDBusConnectionPrivate;
+
+ manager->addConnection(
+ "QDBusServer-"_L1 + QString::number(reinterpret_cast<qulonglong>(newConnection), 16),
+ newConnection);
+ {
+ QWriteLocker locker(&serverConnection->lock);
+ serverConnection->serverConnectionNames << newConnection->name;
+ }
// setPeer does the error handling for us
QDBusErrorInternal error;
newConnection->setPeer(connection, error);
newConnection->setDispatchEnabled(false);
+ QReadLocker serverLock(&serverConnection->lock);
+ if (!serverConnection->serverObject)
+ return;
+
// this is a queued connection and will resume in the QDBusServer's thread
- emit serverConnection->newServerConnection(newConnection);
+ QMetaObject::invokeMethod(serverConnection->serverObject, &QDBusServer::newConnection,
+ Qt::QueuedConnection, QDBusConnectionPrivate::q(newConnection));
// we've disabled dispatching of events, so now we post an event to the
// QDBusServer's thread in order to enable it after the
// QDBusServer::newConnection() signal has been received by the
// application's code
- newConnection->ref.ref();
- QReadLocker serverLock(&serverConnection->lock);
- QDBusConnectionDispatchEnabler *o = new QDBusConnectionDispatchEnabler(newConnection);
- QTimer::singleShot(0, o, SLOT(execute()));
- if (serverConnection->serverObject)
- o->moveToThread(serverConnection->serverObject->thread());
-}
-void QDBusConnectionPrivate::_q_newConnection(QDBusConnectionPrivate *newConnection)
-{
- Q_ASSERT(mode == ServerMode);
- emit serverObject->newConnection(QDBusConnectionPrivate::q(newConnection));
+ newConnection->enableDispatchDelayed(serverConnection->serverObject);
}
} // extern "C"
@@ -343,27 +339,27 @@ static QByteArray buildMatchRule(const QString &service,
const QString &member, const QDBusConnectionPrivate::ArgMatchRules &argMatch, const QString & /*signature*/)
{
QString result;
- result += QLatin1String("type='signal',");
- const auto keyValue = QLatin1String("%1='%2',");
+ result += "type='signal',"_L1;
+ const auto keyValue = "%1='%2',"_L1;
if (!service.isEmpty())
- result += keyValue.arg(QLatin1String("sender"), service);
+ result += keyValue.arg("sender"_L1, service);
if (!objectPath.isEmpty())
- result += keyValue.arg(QLatin1String("path"), objectPath);
+ result += keyValue.arg("path"_L1, objectPath);
if (!interface.isEmpty())
- result += keyValue.arg(QLatin1String("interface"), interface);
+ result += keyValue.arg("interface"_L1, interface);
if (!member.isEmpty())
- result += keyValue.arg(QLatin1String("member"), member);
+ result += keyValue.arg("member"_L1, member);
// add the argument string-matching now
if (!argMatch.args.isEmpty()) {
- const QString keyValue = QLatin1String("arg%1='%2',");
- for (int i = 0; i < argMatch.args.count(); ++i)
+ const QString keyValue = "arg%1='%2',"_L1;
+ for (int i = 0; i < argMatch.args.size(); ++i)
if (!argMatch.args.at(i).isNull())
result += keyValue.arg(i).arg(argMatch.args.at(i));
}
if (!argMatch.arg0namespace.isEmpty()) {
- result += QLatin1String("arg0namespace='%1',").arg(argMatch.arg0namespace);
+ result += "arg0namespace='%1',"_L1.arg(argMatch.arg0namespace);
}
result.chop(1); // remove ending comma
@@ -374,24 +370,24 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
const QString &fullpath, int &usedLength,
QDBusConnectionPrivate::ObjectTreeNode &result)
{
- if (!fullpath.compare(QLatin1String("/")) && root->obj) {
+ if (!fullpath.compare("/"_L1) && root->obj) {
usedLength = 1;
result = *root;
return root;
}
int start = 0;
- int length = fullpath.length();
- if (fullpath.at(0) == QLatin1Char('/'))
+ int length = fullpath.size();
+ if (fullpath.at(0) == u'/')
start = 1;
// walk the object tree
- QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator node = root;
+ const QDBusConnectionPrivate::ObjectTreeNode *node = root;
while (start < length && node) {
if (node->flags & QDBusConnection::ExportChildObjects)
break;
if ((node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath))
break;
- int end = fullpath.indexOf(QLatin1Char('/'), start);
+ int end = fullpath.indexOf(u'/', start);
end = (end == -1 ? length : end);
QStringView pathComponent = QStringView{fullpath}.mid(start, end - start);
@@ -399,7 +395,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
std::lower_bound(node->children.constBegin(), node->children.constEnd(), pathComponent);
if (it != node->children.constEnd() && it->name == pathComponent)
// match
- node = it;
+ node = &(*it);
else
node = nullptr;
@@ -422,7 +418,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
const QString &fullpath, int start)
{
- int length = fullpath.length();
+ int length = fullpath.size();
// any object in the tree can tell us to switch to its own object tree:
const QDBusConnectionPrivate::ObjectTreeNode *node = root;
@@ -434,21 +430,18 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro
// we're at the correct level
return obj;
- int pos = fullpath.indexOf(QLatin1Char('/'), start);
+ int pos = fullpath.indexOf(u'/', start);
pos = (pos == -1 ? length : pos);
auto pathComponent = QStringView{fullpath}.mid(start, pos - start);
- const QObjectList children = obj->children();
-
// find a child with the proper name
QObject *next = nullptr;
- QObjectList::ConstIterator it = children.constBegin();
- QObjectList::ConstIterator end = children.constEnd();
- for ( ; it != end; ++it)
- if ((*it)->objectName() == pathComponent) {
- next = *it;
+ for (QObject *child : std::as_const(obj->children())) {
+ if (child->objectName() == pathComponent) {
+ next = child;
break;
}
+ }
if (!next)
break;
@@ -465,7 +458,7 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro
static QDBusConnectionPrivate::ArgMatchRules matchArgsForService(const QString &service, QDBusServiceWatcher::WatchMode mode)
{
QDBusConnectionPrivate::ArgMatchRules matchArgs;
- if (service.endsWith(QLatin1Char('*'))) {
+ if (service.endsWith(u'*')) {
matchArgs.arg0namespace = service.chopped(1);
matchArgs.args << QString();
}
@@ -491,7 +484,11 @@ static QDBusConnectionPrivate::ArgMatchRules matchArgsForService(const QString &
extern Q_DBUS_EXPORT void qDBusAddSpyHook(QDBusSpyCallEvent::Hook);
void qDBusAddSpyHook(QDBusSpyCallEvent::Hook hook)
{
- qDBusSpyHookList()->append(hook);
+ auto *hooks = qDBusSpyHookList();
+ if (!hooks)
+ return;
+
+ hooks->add(hook);
}
QDBusSpyCallEvent::~QDBusSpyCallEvent()
@@ -506,14 +503,15 @@ QDBusSpyCallEvent::~QDBusSpyCallEvent()
void QDBusSpyCallEvent::placeMetaCall(QObject *)
{
- invokeSpyHooks(msg, hooks, hookCount);
+ invokeSpyHooks(msg);
}
-inline void QDBusSpyCallEvent::invokeSpyHooks(const QDBusMessage &msg, const Hook *hooks, int hookCount)
+inline void QDBusSpyCallEvent::invokeSpyHooks(const QDBusMessage &msg)
{
- // call the spy hook list
- for (int i = 0; i < hookCount; ++i)
- hooks[i](msg);
+ if (!qDBusSpyHookList.exists())
+ return;
+
+ qDBusSpyHookList->invoke(msg);
}
extern "C" {
@@ -562,15 +560,14 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
// a) if it's a local message, we're in the caller's thread, so invoke the filter directly
// b) if it's an external message, post to the main thread
if (Q_UNLIKELY(qDBusSpyHookList.exists()) && qApp) {
- const QDBusSpyHookList &list = *qDBusSpyHookList;
if (isLocal) {
Q_ASSERT(QThread::currentThread() != thread());
qDBusDebug() << this << "invoking message spies directly";
- QDBusSpyCallEvent::invokeSpyHooks(amsg, list.constData(), list.size());
+ QDBusSpyCallEvent::invokeSpyHooks(amsg);
} else {
qDBusDebug() << this << "invoking message spies via event";
- QCoreApplication::postEvent(qApp, new QDBusSpyCallEvent(this, QDBusConnection(this),
- amsg, list.constData(), list.size()));
+ QCoreApplication::postEvent(
+ qApp, new QDBusSpyCallEvent(this, QDBusConnection(this), amsg));
// we'll be called back, so return
return true;
@@ -590,7 +587,7 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNode &haystack)
{
- for (auto &node : haystack.children)
+ for (QDBusConnectionPrivate::ObjectTreeNode &node : haystack.children)
huntAndDestroy(needle, node);
auto isInactive = [](const QDBusConnectionPrivate::ObjectTreeNode &node) { return !node.isActive(); };
@@ -598,7 +595,7 @@ static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNo
if (needle == haystack.obj) {
haystack.obj = nullptr;
- haystack.flags = 0;
+ haystack.flags = {};
}
}
@@ -606,10 +603,10 @@ static void huntAndUnregister(const QList<QStringView> &pathComponents, int i,
QDBusConnection::UnregisterMode mode,
QDBusConnectionPrivate::ObjectTreeNode *node)
{
- if (pathComponents.count() == i) {
+ if (pathComponents.size() == i) {
// found it
node->obj = nullptr;
- node->flags = 0;
+ node->flags = {};
if (mode == QDBusConnection::UnregisterTree) {
// clear the sub-tree as well
@@ -624,7 +621,7 @@ static void huntAndUnregister(const QList<QStringView> &pathComponents, int i,
if (it == end || it->name != pathComponents.at(i))
return; // node not found
- huntAndUnregister(pathComponents, i + 1, mode, it);
+ huntAndUnregister(pathComponents, i + 1, mode, &(*it));
if (!it->isActive())
node->children.erase(it);
}
@@ -634,11 +631,11 @@ static void huntAndEmit(DBusConnection *connection, DBusMessage *msg,
QObject *needle, const QDBusConnectionPrivate::ObjectTreeNode &haystack,
bool isScriptable, bool isAdaptor, const QString &path = QString())
{
- QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it = haystack.children.constBegin();
- QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator end = haystack.children.constEnd();
- for ( ; it != end; ++it) {
- if (it->isActive())
- huntAndEmit(connection, msg, needle, *it, isScriptable, isAdaptor, path + QLatin1Char('/') + it->name);
+ for (const QDBusConnectionPrivate::ObjectTreeNode &node : std::as_const(haystack.children)) {
+ if (node.isActive()) {
+ huntAndEmit(connection, msg, needle, node, isScriptable, isAdaptor,
+ path + u'/' + node.name);
+ }
}
if (needle == haystack.obj) {
@@ -668,6 +665,7 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
const QString &signature_, QList<QMetaType> &metaTypes)
{
QByteArray msgSignature = signature_.toLatin1();
+ QString parametersErrorMsg;
for (int idx = mo->methodCount() - 1 ; idx >= QObject::staticMetaObject.methodCount(); --idx) {
QMetaMethod mm = mo->method(idx);
@@ -694,8 +692,10 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
QString errorMsg;
int inputCount = qDBusParametersForMethod(mm, metaTypes, errorMsg);
- if (inputCount == -1)
+ if (inputCount == -1) {
+ parametersErrorMsg = errorMsg;
continue; // problem parsing
+ }
metaTypes[0] = returnType;
bool hasMessage = false;
@@ -730,14 +730,14 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
continue;
bool ok = true;
- for (int j = i; ok && j < metaTypes.count(); ++j)
+ for (int j = i; ok && j < metaTypes.size(); ++j)
if (QDBusMetaType::typeToSignature(metaTypes.at(i)) == nullptr)
ok = false;
if (!ok)
continue;
// consistency check:
- if (isAsync && metaTypes.count() > i + 1)
+ if (isAsync && metaTypes.size() > i + 1)
continue;
if (mm.methodType() == QMetaMethod::Slot) {
@@ -757,6 +757,13 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
}
// no slot matched
+ if (!parametersErrorMsg.isEmpty()) {
+ qCWarning(dbusIntegration, "QDBusConnection: couldn't handle call to %s: %ls",
+ name.constData(), qUtf16Printable(parametersErrorMsg));
+ } else {
+ qCWarning(dbusIntegration, "QDBusConnection: couldn't handle call to %s, no slot matched",
+ name.constData());
+ }
return -1;
}
@@ -782,13 +789,12 @@ QDBusCallDeliveryEvent *QDBusConnectionPrivate::prepareReply(QDBusConnectionPriv
const QDBusMessage &msg)
{
Q_ASSERT(object);
- Q_UNUSED(object);
- int n = metaTypes.count() - 1;
+ int n = metaTypes.size() - 1;
if (metaTypes[n] == QDBusMetaTypeId::message())
--n;
- if (msg.arguments().count() < n)
+ if (msg.arguments().size() < n)
return nullptr; // too few arguments
// check that types match
@@ -818,14 +824,15 @@ void QDBusConnectionPrivate::activateSignal(const QDBusConnectionPrivate::Signal
if (call == DIRECT_DELIVERY) {
// short-circuit delivery
Q_ASSERT(this == hook.obj);
- deliverCall(this, 0, msg, hook.params, hook.midx);
+ deliverCall(this, msg, hook.params, hook.midx);
return;
}
if (call)
postEventToThread(ActivateSignalAction, hook.obj, call);
}
-bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBusMessage &msg)
+bool QDBusConnectionPrivate::activateCall(QObject *object, QDBusConnection::RegisterOptions flags,
+ const QDBusMessage &msg)
{
// This is called by QDBusConnectionPrivate::handleObjectCall to place a call
// to a slot on the object.
@@ -860,60 +867,59 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu
qvariant_cast<QDBusSlotCache>(object->property(cachePropertyName));
QString cacheKey = msg.member(), signature = msg.signature();
if (!signature.isEmpty()) {
- cacheKey.reserve(cacheKey.length() + 1 + signature.length());
- cacheKey += QLatin1Char('.');
+ cacheKey.reserve(cacheKey.size() + 1 + signature.size());
+ cacheKey += u'.';
cacheKey += signature;
}
- QDBusSlotCache::Hash::ConstIterator cacheIt = slotCache.hash.constFind(cacheKey);
- while (cacheIt != slotCache.hash.constEnd() && cacheIt->flags != flags &&
- cacheIt.key() == cacheKey)
- ++cacheIt;
- if (cacheIt == slotCache.hash.constEnd() || cacheIt.key() != cacheKey)
- {
+ QDBusSlotCache::Key compoundKey{ std::move(cacheKey), flags };
+ QDBusSlotCache::Hash::ConstIterator cacheIt = slotCache.hash.constFind(compoundKey);
+ if (cacheIt == slotCache.hash.constEnd()) {
// not cached, analyze the meta object
const QMetaObject *mo = object->metaObject();
QByteArray memberName = msg.member().toUtf8();
// find a slot that matches according to the rules above
QDBusSlotCache::Data slotData;
- slotData.flags = flags;
slotData.slotIdx = ::findSlot(mo, memberName, flags, msg.signature(), slotData.metaTypes);
if (slotData.slotIdx == -1) {
// ### this is where we want to add the connection as an arg too
// try with no parameters, but with a QDBusMessage
slotData.slotIdx = ::findSlot(mo, memberName, flags, QString(), slotData.metaTypes);
- if (slotData.metaTypes.count() != 2 ||
+ if (slotData.metaTypes.size() != 2 ||
slotData.metaTypes.at(1) != QDBusMetaTypeId::message()) {
// not found
// save the negative lookup
slotData.slotIdx = -1;
slotData.metaTypes.clear();
- slotCache.hash.insert(cacheKey, slotData);
+ slotCache.hash.insert(compoundKey, slotData);
object->setProperty(cachePropertyName, QVariant::fromValue(slotCache));
+
+ qCWarning(dbusIntegration).nospace() << "Could not find slot " << mo->className()
+ << "::" << memberName.constData();
return false;
}
}
// save to the cache
- slotCache.hash.insert(cacheKey, slotData);
+ slotCache.hash.insert(compoundKey, slotData);
object->setProperty(cachePropertyName, QVariant::fromValue(slotCache));
// found the slot to be called
- deliverCall(object, flags, msg, slotData.metaTypes, slotData.slotIdx);
+ deliverCall(object, msg, slotData.metaTypes, slotData.slotIdx);
return true;
} else if (cacheIt->slotIdx == -1) {
// negative cache
return false;
} else {
// use the cache
- deliverCall(object, flags, msg, cacheIt->metaTypes, cacheIt->slotIdx);
+ deliverCall(object, msg, cacheIt->metaTypes, cacheIt->slotIdx);
return true;
}
return false;
}
-void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const QDBusMessage &msg,
+void QDBusConnectionPrivate::deliverCall(QObject *object, const QDBusMessage &msg,
const QList<QMetaType> &metaTypes, int slotIdx)
{
Q_ASSERT_X(!object || QThread::currentThread() == object->thread(),
@@ -921,10 +927,10 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
"function called for an object that is in another thread!!");
QVarLengthArray<void *, 10> params;
- params.reserve(metaTypes.count());
+ params.reserve(metaTypes.size());
QVarLengthArray<QVariant, 10> auxParameters; // we cannot allow reallocation here, since we
- auxParameters.reserve(metaTypes.count()); // keep references to the entries
+ auxParameters.reserve(metaTypes.size()); // keep references to the entries
// let's create the parameter list
@@ -933,13 +939,14 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
// add the input parameters
int i;
- int pCount = qMin(msg.arguments().count(), metaTypes.count() - 1);
+ int pCount = qMin(msg.arguments().size(), metaTypes.size() - 1);
for (i = 1; i <= pCount; ++i) {
auto id = metaTypes[i];
if (id == QDBusMetaTypeId::message())
break;
- const QVariant &arg = msg.arguments().at(i - 1);
+ const QList<QVariant> args = msg.arguments();
+ const QVariant &arg = args.at(i - 1);
if (arg.metaType() == id)
// no conversion needed
params.append(const_cast<void *>(arg.constData()));
@@ -949,7 +956,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
const QDBusArgument &in =
*reinterpret_cast<const QDBusArgument *>(arg.constData());
- QVariant &out = auxParameters[auxParameters.count() - 1];
+ QVariant &out = auxParameters[auxParameters.size() - 1];
if (Q_UNLIKELY(!QDBusMetaType::demarshall(in, out.metaType(), out.data())))
qFatal("Internal error: demarshalling function for type '%s' (%d) failed!",
@@ -964,19 +971,19 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
}
}
- if (metaTypes.count() > i && metaTypes[i] == QDBusMetaTypeId::message()) {
+ if (metaTypes.size() > i && metaTypes[i] == QDBusMetaTypeId::message()) {
params.append(const_cast<void*>(static_cast<const void*>(&msg)));
++i;
}
// output arguments
- const int numMetaTypes = metaTypes.count();
+ const int numMetaTypes = metaTypes.size();
QVariantList outputArgs;
if (metaTypes[0].id() != QMetaType::Void && metaTypes[0].isValid()) {
outputArgs.reserve(numMetaTypes - i + 1);
QVariant arg{QMetaType(metaTypes[0])};
outputArgs.append( arg );
- params[0] = const_cast<void*>(outputArgs.at( outputArgs.count() - 1 ).constData());
+ params[0] = const_cast<void*>(outputArgs.at( outputArgs.size() - 1 ).constData());
} else {
outputArgs.reserve(numMetaTypes - i);
}
@@ -984,7 +991,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
for ( ; i < numMetaTypes; ++i) {
QVariant arg{QMetaType(metaTypes[i])};
outputArgs.append( arg );
- params.append(const_cast<void*>(outputArgs.at( outputArgs.count() - 1 ).constData()));
+ params.append(const_cast<void*>(outputArgs.at( outputArgs.size() - 1 ).constData()));
}
// make call:
@@ -1013,35 +1020,31 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
send(msg.createReply(outputArgs));
} else {
// generate internal error
- qWarning("Internal error: Failed to deliver message");
- send(msg.createErrorReply(QDBusError::InternalError,
- QLatin1String("Failed to deliver message")));
+ qCWarning(dbusIntegration, "Internal error: Failed to deliver message");
+ send(msg.createErrorReply(QDBusError::InternalError, "Failed to deliver message"_L1));
}
}
return;
}
-extern bool qDBusInitThreads();
-
-QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
- : QObject(p),
- ref(1),
+QDBusConnectionPrivate::QDBusConnectionPrivate()
+ : ref(1),
mode(InvalidMode),
busService(nullptr),
connection(nullptr),
- rootNode(QString(QLatin1Char('/'))),
+ rootNode(QStringLiteral("/")),
anonymousAuthenticationAllowed(false),
dispatchEnabled(true),
isAuthenticated(false)
{
static const bool threads = q_dbus_threads_init_default();
- if (::isDebugging == -1)
- ::isDebugging = qEnvironmentVariableIntValue("QDBUS_DEBUG");
Q_UNUSED(threads);
+ if (::isDebugging.loadRelaxed() == -1)
+ ::isDebugging.storeRelaxed(qEnvironmentVariableIntValue("QDBUS_DEBUG"));
#ifdef QDBUS_THREAD_DEBUG
- if (::isDebugging > 1)
+ if (::isDebugging.loadRelaxed() > 1)
qdbusThreadDebug = qdbusDefaultThreadDebug;
#endif
@@ -1052,12 +1055,8 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
this, &QDBusConnectionPrivate::handleObjectCall, Qt::QueuedConnection);
connect(this, &QDBusConnectionPrivate::messageNeedsSending,
this, &QDBusConnectionPrivate::sendInternal);
- connect(this, &QDBusConnectionPrivate::signalNeedsConnecting,
- this, &QDBusConnectionPrivate::addSignalHook, Qt::BlockingQueuedConnection);
- connect(this, &QDBusConnectionPrivate::signalNeedsDisconnecting,
- this, &QDBusConnectionPrivate::removeSignalHook, Qt::BlockingQueuedConnection);
- rootNode.flags = 0;
+ rootNode.flags = {};
// prepopulate watchedServices:
// we know that the owner of org.freedesktop.DBus is itself
@@ -1071,9 +1070,10 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
QDBusConnectionPrivate::~QDBusConnectionPrivate()
{
if (thread() && thread() != QThread::currentThread())
- qWarning("QDBusConnection(name=\"%s\")'s last reference in not in its creation thread! "
- "Timer and socket errors will follow and the program will probably crash",
- qPrintable(name));
+ qCWarning(dbusIntegration,
+ "QDBusConnection(name=\"%s\")'s last reference in not in its creation thread! "
+ "Timer and socket errors will follow and the program will probably crash",
+ qPrintable(name));
auto lastMode = mode; // reset on connection close
closeConnection();
@@ -1101,12 +1101,8 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate()
void QDBusConnectionPrivate::collectAllObjects(QDBusConnectionPrivate::ObjectTreeNode &haystack,
QSet<QObject *> &set)
{
- QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = haystack.children.begin();
-
- while (it != haystack.children.end()) {
- collectAllObjects(*it, set);
- it++;
- }
+ for (ObjectTreeNode &child : haystack.children)
+ collectAllObjects(child, set);
if (haystack.obj)
set.insert(haystack.obj);
@@ -1134,7 +1130,11 @@ void QDBusConnectionPrivate::closeConnection()
}
}
- qDeleteAll(pendingCalls);
+ for (QDBusPendingCallPrivate *call : pendingCalls) {
+ if (!call->ref.deref())
+ delete call;
+ }
+ pendingCalls.clear();
// Disconnect all signals from signal hooks and from the object tree to
// avoid QObject::destroyed being sent to dbus daemon thread which has
@@ -1143,18 +1143,12 @@ void QDBusConnectionPrivate::closeConnection()
// dangling pointer.
QSet<QObject *> allObjects;
collectAllObjects(rootNode, allObjects);
- SignalHookHash::const_iterator sit = signalHooks.constBegin();
- while (sit != signalHooks.constEnd()) {
- allObjects.insert(sit.value().obj);
- ++sit;
- }
+ for (const SignalHook &signalHook : std::as_const(signalHooks))
+ allObjects.insert(signalHook.obj);
// now disconnect ourselves
- QSet<QObject *>::const_iterator oit = allObjects.constBegin();
- while (oit != allObjects.constEnd()) {
- (*oit)->disconnect(this);
- ++oit;
- }
+ for (QObject *obj : std::as_const(allObjects))
+ obj->disconnect(this);
}
void QDBusConnectionPrivate::handleDBusDisconnection()
@@ -1194,17 +1188,15 @@ void QDBusConnectionPrivate::timerEvent(QTimerEvent *e)
void QDBusConnectionPrivate::doDispatch()
{
if (mode == ClientMode || mode == PeerMode) {
- while (q_dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS) ;
if (dispatchEnabled && !pendingMessages.isEmpty()) {
// dispatch previously queued messages
- PendingMessageList::Iterator it = pendingMessages.begin();
- PendingMessageList::Iterator end = pendingMessages.end();
- for ( ; it != end; ++it) {
- qDBusDebug() << this << "dequeueing message" << *it;
- handleMessage(std::move(*it));
+ for (QDBusMessage &message : pendingMessages) {
+ qDBusDebug() << this << "dequeueing message" << message;
+ handleMessage(std::move(message));
}
pendingMessages.clear();
}
+ while (q_dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS) ;
}
}
@@ -1276,16 +1268,16 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in
checkThread();
QDBusReadLocker locker(RelaySignalAction, this);
- QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/"), interface,
- QLatin1String(memberName));
+ QDBusMessage message = QDBusMessage::createSignal("/"_L1, interface,
+ QLatin1StringView(memberName));
QDBusMessagePrivate::setParametersValidated(message, true);
message.setArguments(args);
QDBusError error;
DBusMessage *msg =
QDBusMessagePrivate::toDBusMessage(message, connectionCapabilities(), &error);
if (!msg) {
- qWarning("QDBusConnection: Could not emit signal %s.%s: %s", qPrintable(interface), memberName.constData(),
- qPrintable(error.message()));
+ qCWarning(dbusIntegration, "QDBusConnection: Could not emit signal %s.%s: %s",
+ qPrintable(interface), memberName.constData(), qPrintable(error.message()));
lastError = error;
return;
}
@@ -1300,46 +1292,46 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in
void QDBusConnectionPrivate::serviceOwnerChangedNoLock(const QString &name,
const QString &oldOwner, const QString &newOwner)
{
- Q_UNUSED(oldOwner);
// QDBusWriteLocker locker(UpdateSignalHookOwnerAction, this);
WatchedServicesHash::Iterator it = watchedServices.find(name);
if (it == watchedServices.end())
return;
if (oldOwner != it->owner)
- qWarning("QDBusConnection: name '%s' had owner '%s' but we thought it was '%s'",
- qPrintable(name), qPrintable(oldOwner), qPrintable(it->owner));
+ qCWarning(dbusIntegration,
+ "QDBusConnection: name '%s' had owner '%s' but we thought it was '%s'",
+ qPrintable(name), qPrintable(oldOwner), qPrintable(it->owner));
qDBusDebug() << this << "Updating name" << name << "from" << oldOwner << "to" << newOwner;
it->owner = newOwner;
}
int QDBusConnectionPrivate::findSlot(QObject *obj, const QByteArray &normalizedName,
- QList<QMetaType> &params)
+ QList<QMetaType> &params, QString &errorMsg)
{
+ errorMsg.clear();
int midx = obj->metaObject()->indexOfMethod(normalizedName);
if (midx == -1)
return -1;
- QString errorMsg;
int inputCount = qDBusParametersForMethod(obj->metaObject()->method(midx), params, errorMsg);
- if ( inputCount == -1 || inputCount + 1 != params.count() )
- return -1; // failed to parse or invalid arguments or output arguments
+ if (inputCount == -1 || inputCount + 1 != params.size())
+ return -1;
return midx;
}
bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
- const QString &service,
- const QString &path, const QString &interface, const QString &name,
- const ArgMatchRules &argMatch,
- QObject *receiver, const char *signal, int minMIdx,
- bool buildSignature)
+ const QString &service, const QString &path,
+ const QString &interface, const QString &name,
+ const ArgMatchRules &argMatch, QObject *receiver,
+ const char *signal, int minMIdx, bool buildSignature,
+ QString &errorMsg)
{
QByteArray normalizedName = signal + 1;
- hook.midx = findSlot(receiver, signal + 1, hook.params);
+ hook.midx = findSlot(receiver, signal + 1, hook.params, errorMsg);
if (hook.midx == -1) {
normalizedName = QMetaObject::normalizedSignature(signal + 1);
- hook.midx = findSlot(receiver, normalizedName, hook.params);
+ hook.midx = findSlot(receiver, normalizedName, hook.params, errorMsg);
}
if (hook.midx < minMIdx) {
return false;
@@ -1359,15 +1351,15 @@ bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hoo
mname = QString::fromUtf8(normalizedName);
}
key = mname;
- key.reserve(interface.length() + 1 + mname.length());
- key += QLatin1Char(':');
+ key.reserve(interface.size() + 1 + mname.size());
+ key += u':';
key += interface;
if (buildSignature) {
hook.signature.clear();
- for (int i = 1; i < hook.params.count(); ++i)
+ for (int i = 1; i < hook.params.size(); ++i)
if (hook.params.at(i) != QDBusMetaTypeId::message())
- hook.signature += QLatin1String( QDBusMetaType::typeToSignature( hook.params.at(i) ) );
+ hook.signature += QLatin1StringView(QDBusMetaType::typeToSignature(hook.params.at(i)));
}
hook.matchRule = buildMatchRule(service, path, interface, mname, argMatch, hook.signature);
@@ -1379,21 +1371,20 @@ void QDBusConnectionPrivate::sendError(const QDBusMessage &msg, QDBusError::Erro
if (code == QDBusError::UnknownMethod) {
QString interfaceMsg;
if (msg.interface().isEmpty())
- interfaceMsg = QLatin1String("any interface");
+ interfaceMsg = "any interface"_L1;
else
- interfaceMsg = QLatin1String("interface '%1'").arg(msg.interface());
+ interfaceMsg = "interface '%1'"_L1.arg(msg.interface());
- send(msg.createErrorReply(code,
- QLatin1String("No such method '%1' in %2 at object path '%3' "
- "(signature '%4')")
+ send(msg.createErrorReply(code, "No such method '%1' in %2 at object path '%3' "
+ "(signature '%4')"_L1
.arg(msg.member(), interfaceMsg, msg.path(), msg.signature())));
} else if (code == QDBusError::UnknownInterface) {
send(msg.createErrorReply(QDBusError::UnknownInterface,
- QLatin1String("No such interface '%1' at object path '%2'")
+ "No such interface '%1' at object path '%2'"_L1
.arg(msg.interface(), msg.path())));
} else if (code == QDBusError::UnknownObject) {
send(msg.createErrorReply(QDBusError::UnknownObject,
- QLatin1String("No such object path '%1'").arg(msg.path())));
+ "No such object path '%1'"_L1.arg(msg.path())));
}
}
@@ -1404,7 +1395,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node,
const QString interface = msg.interface();
if (interface.isEmpty() || interface == QDBusUtil::dbusInterfaceIntrospectable()) {
- if (msg.member() == QLatin1String("Introspect") && msg.signature().isEmpty()) {
+ if (msg.member() == "Introspect"_L1 && msg.signature().isEmpty()) {
//qDebug() << "QDBusConnectionPrivate::activateInternalFilters introspect" << msg.d_ptr->msg;
QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node, msg.path()));
send(reply);
@@ -1420,15 +1411,15 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node,
if (node.obj && (interface.isEmpty() ||
interface == QDBusUtil::dbusInterfaceProperties())) {
//qDebug() << "QDBusConnectionPrivate::activateInternalFilters properties" << msg.d_ptr->msg;
- if (msg.member() == QLatin1String("Get") && msg.signature() == QLatin1String("ss")) {
+ if (msg.member() == "Get"_L1 && msg.signature() == "ss"_L1) {
QDBusMessage reply = qDBusPropertyGet(node, msg);
send(reply);
return true;
- } else if (msg.member() == QLatin1String("Set") && msg.signature() == QLatin1String("ssv")) {
+ } else if (msg.member() == "Set"_L1 && msg.signature() == "ssv"_L1) {
QDBusMessage reply = qDBusPropertySet(node, msg);
send(reply);
return true;
- } else if (msg.member() == QLatin1String("GetAll") && msg.signature() == QLatin1String("s")) {
+ } else if (msg.member() == "GetAll"_L1 && msg.signature() == "s"_L1) {
QDBusMessage reply = qDBusPropertyGetAll(node, msg);
send(reply);
return true;
@@ -1462,7 +1453,7 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes
}
}
- if (pathStartPos != msg.path().length()) {
+ if (pathStartPos != msg.path().size()) {
node.flags &= ~QDBusConnection::ExportAllSignals;
node.obj = findChildObject(&node, msg.path(), pathStartPos);
if (!node.obj) {
@@ -1474,25 +1465,22 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes
QDBusAdaptorConnector *connector;
if (node.flags & QDBusConnection::ExportAdaptors &&
(connector = qDBusFindAdaptorConnector(node.obj))) {
- int newflags = node.flags | QDBusConnection::ExportAllSlots;
+ auto newflags = node.flags | QDBusConnection::ExportAllSlots;
if (msg.interface().isEmpty()) {
// place the call in all interfaces
// let the first one that handles it to work
- QDBusAdaptorConnector::AdaptorMap::ConstIterator it =
- connector->adaptors.constBegin();
- QDBusAdaptorConnector::AdaptorMap::ConstIterator end =
- connector->adaptors.constEnd();
-
- for ( ; it != end; ++it)
- if (activateCall(it->adaptor, newflags, msg))
+ for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
+ std::as_const(connector->adaptors)) {
+ if (activateCall(adaptorData.adaptor, newflags, msg))
return;
+ }
} else {
// check if we have an interface matching the name that was asked:
QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
it = std::lower_bound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
msg.interface());
- if (it != connector->adaptors.constEnd() && msg.interface() == QLatin1String(it->interface)) {
+ if (it != connector->adaptors.constEnd() && msg.interface() == QLatin1StringView(it->interface)) {
if (!activateCall(it->adaptor, newflags, msg))
sendError(msg, QDBusError::UnknownMethod);
return;
@@ -1563,8 +1551,8 @@ void QDBusConnectionPrivate::handleObjectCall(const QDBusMessage &msg)
objThread = result.obj->thread();
if (!objThread) {
send(msg.createErrorReply(QDBusError::InternalError,
- QLatin1String("Object '%1' (at path '%2')"
- " has no thread. Cannot deliver message.")
+ "Object '%1' (at path '%2')"
+ " has no thread. Cannot deliver message."_L1
.arg(result.obj->objectName(), msg.path())));
return;
}
@@ -1662,8 +1650,8 @@ void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage
if (arguments.size() < 1)
continue;
const QString param = arguments.at(0).toString();
- if (param != hook.argumentMatch.arg0namespace
- && !param.startsWith(hook.argumentMatch.arg0namespace + QLatin1Char('.')))
+ const QStringView ns = hook.argumentMatch.arg0namespace;
+ if (!param.startsWith(ns) || (param.size() != ns.size() && param[ns.size()] != u'.'))
continue;
}
activateSignal(hook, msg);
@@ -1680,17 +1668,17 @@ void QDBusConnectionPrivate::handleSignal(const QDBusMessage& msg)
// (but not both)
QString key = msg.member();
- key.reserve(key.length() + 1 + msg.interface().length());
- key += QLatin1Char(':');
+ key.reserve(key.size() + 1 + msg.interface().size());
+ key += u':';
key += msg.interface();
- QDBusReadLocker locker(HandleSignalAction, this);
+ QDBusWriteLocker locker(HandleSignalAction, this);
handleSignal(key, msg); // one try
- key.truncate(msg.member().length() + 1); // keep the ':'
+ key.truncate(msg.member().size() + 1); // keep the ':'
handleSignal(key, msg); // second try
- key = QLatin1Char(':');
+ key = u':';
key += msg.interface();
handleSignal(key, msg); // third try
}
@@ -1705,7 +1693,7 @@ void QDBusConnectionPrivate::watchForDBusDisconnection()
hook.params << QMetaType(QMetaType::Void);
hook.midx = staticMetaObject.indexOfSlot("handleDBusDisconnection()");
Q_ASSERT(hook.midx != -1);
- signalHooks.insert(QLatin1String("Disconnected:" DBUS_INTERFACE_LOCAL), hook);
+ signalHooks.insert("Disconnected:" DBUS_INTERFACE_LOCAL ""_L1, hook);
}
void QDBusConnectionPrivate::setServer(QDBusServer *object, DBusServer *s, const QDBusErrorInternal &error)
@@ -1775,10 +1763,10 @@ void QDBusConnectionPrivate::setPeer(DBusConnection *c, const QDBusErrorInternal
watchForDBusDisconnection();
- QMetaObject::invokeMethod(this, "doDispatch", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, &QDBusConnectionPrivate::doDispatch, Qt::QueuedConnection);
}
-static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnection *connection)
+static QDBusConnection::ConnectionCapabilities connectionCapabilities(DBusConnection *connection)
{
QDBusConnection::ConnectionCapabilities result;
typedef dbus_bool_t (*can_send_type_t)(DBusConnection *, int);
@@ -1804,7 +1792,7 @@ static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnecti
void QDBusConnectionPrivate::handleAuthentication()
{
- capabilities.storeRelaxed(connectionCapabilies(connection));
+ capabilities.storeRelaxed(::connectionCapabilities(connection));
isAuthenticated = true;
}
@@ -1843,11 +1831,11 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
hook.midx = staticMetaObject.indexOfSlot("registerServiceNoLock(QString)");
Q_ASSERT(hook.midx != -1);
- signalHooks.insert(QLatin1String("NameAcquired:" DBUS_INTERFACE_DBUS), hook);
+ signalHooks.insert("NameAcquired:" DBUS_INTERFACE_DBUS ""_L1, hook);
hook.midx = staticMetaObject.indexOfSlot("unregisterServiceNoLock(QString)");
Q_ASSERT(hook.midx != -1);
- signalHooks.insert(QLatin1String("NameLost:" DBUS_INTERFACE_DBUS), hook);
+ signalHooks.insert("NameLost:" DBUS_INTERFACE_DBUS ""_L1, hook);
// And initialize the hook for the NameOwnerChanged signal;
// we don't use connectSignal here because the rules are added by connectSignal on a per-need basis
@@ -1856,14 +1844,14 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
hook.params << QMetaType(QMetaType::Void) << QMetaType(QMetaType::QString) << QMetaType(QMetaType::QString) << QMetaType(QMetaType::QString);
hook.midx = staticMetaObject.indexOfSlot("serviceOwnerChangedNoLock(QString,QString,QString)");
Q_ASSERT(hook.midx != -1);
- signalHooks.insert(QLatin1String("NameOwnerChanged:" DBUS_INTERFACE_DBUS), hook);
+ signalHooks.insert("NameOwnerChanged:" DBUS_INTERFACE_DBUS ""_L1, hook);
watchForDBusDisconnection();
qDBusDebug() << this << ": connected successfully";
// schedule a dispatch:
- QMetaObject::invokeMethod(this, "doDispatch", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, &QDBusConnectionPrivate::doDispatch, Qt::QueuedConnection);
}
extern "C"{
@@ -1871,7 +1859,6 @@ static void qDBusResultReceived(DBusPendingCall *pending, void *user_data)
{
QDBusPendingCallPrivate *call = reinterpret_cast<QDBusPendingCallPrivate *>(user_data);
Q_ASSERT(call->pending == pending);
- Q_UNUSED(pending);
QDBusConnectionPrivate::processFinishedCall(call);
}
}
@@ -1949,22 +1936,26 @@ bool QDBusConnectionPrivate::send(const QDBusMessage& message)
QDBusMessagePrivate::toDBusMessage(message, connectionCapabilities(), &error);
if (!msg) {
if (message.type() == QDBusMessage::MethodCallMessage)
- qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s",
- qPrintable(message.service()), qPrintable(message.path()),
- qPrintable(message.interface()), qPrintable(message.member()),
- qPrintable(error.message()));
+ qCWarning(dbusIntegration,
+ "QDBusConnection: error: could not send message to service \"%s\" path "
+ "\"%s\" interface \"%s\" member \"%s\": %s",
+ qPrintable(message.service()), qPrintable(message.path()),
+ qPrintable(message.interface()), qPrintable(message.member()),
+ qPrintable(error.message()));
else if (message.type() == QDBusMessage::SignalMessage)
- qWarning("QDBusConnection: error: could not send signal to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s",
- qPrintable(message.service()),
- qPrintable(message.path()), qPrintable(message.interface()),
- qPrintable(message.member()),
- qPrintable(error.message()));
+ qCWarning(dbusIntegration,
+ "QDBusConnection: error: could not send signal to service \"%s\" path \"%s\" "
+ "interface \"%s\" member \"%s\": %s",
+ qPrintable(message.service()), qPrintable(message.path()),
+ qPrintable(message.interface()), qPrintable(message.member()),
+ qPrintable(error.message()));
else
- qWarning("QDBusConnection: error: could not send %s message to service \"%s\": %s",
- message.type() == QDBusMessage::ReplyMessage ? "reply" :
- message.type() == QDBusMessage::ErrorMessage ? "error" :
- "invalid", qPrintable(message.service()),
- qPrintable(error.message()));
+ qCWarning(dbusIntegration,
+ "QDBusConnection: error: could not send %s message to service \"%s\": %s",
+ message.type() == QDBusMessage::ReplyMessage ? "reply"
+ : message.type() == QDBusMessage::ErrorMessage ? "error"
+ : "invalid",
+ qPrintable(message.service()), qPrintable(error.message()));
lastError = error;
return false;
}
@@ -1984,20 +1975,20 @@ bool QDBusConnectionPrivate::send(const QDBusMessage& message)
class QDBusBlockingCallWatcher
{
public:
- QDBusBlockingCallWatcher(const QDBusMessage &message)
+ Q_NODISCARD_CTOR QDBusBlockingCallWatcher(const QDBusMessage &message)
: m_message(message), m_maxCallTimeoutMs(0)
{
#if defined(QT_NO_DEBUG)
// when in a release build, we default these to off.
// this means that we only affect code that explicitly enables the warning.
- static int mainThreadWarningAmount = -1;
- static int otherThreadWarningAmount = -1;
+ Q_CONSTINIT static int mainThreadWarningAmount = -1;
+ Q_CONSTINIT static int otherThreadWarningAmount = -1;
#else
- static int mainThreadWarningAmount = 200;
- static int otherThreadWarningAmount = 500;
+ Q_CONSTINIT static int mainThreadWarningAmount = 200;
+ Q_CONSTINIT static int otherThreadWarningAmount = 500;
#endif
- static bool initializedAmounts = false;
- static QBasicMutex initializeMutex;
+ Q_CONSTINIT static bool initializedAmounts = false;
+ Q_CONSTINIT static QBasicMutex initializeMutex;
auto locker = qt_unique_lock(initializeMutex);
if (!initializedAmounts) {
@@ -2011,7 +2002,10 @@ public:
if (ok)
mainThreadWarningAmount = tmp;
else
- qWarning("QDBusBlockingCallWatcher: Q_DBUS_BLOCKING_CALL_MAIN_THREAD_WARNING_MS must be an integer; value ignored");
+ qCWarning(
+ dbusIntegration,
+ "QDBusBlockingCallWatcher: Q_DBUS_BLOCKING_CALL_MAIN_THREAD_WARNING_MS "
+ "must be an integer; value ignored");
}
env = qgetenv("Q_DBUS_BLOCKING_CALL_OTHER_THREAD_WARNING_MS");
@@ -2020,7 +2014,10 @@ public:
if (ok)
otherThreadWarningAmount = tmp;
else
- qWarning("QDBusBlockingCallWatcher: Q_DBUS_BLOCKING_CALL_OTHER_THREAD_WARNING_MS must be an integer; value ignored");
+ qCWarning(dbusIntegration,
+ "QDBusBlockingCallWatcher: "
+ "Q_DBUS_BLOCKING_CALL_OTHER_THREAD_WARNING_MS must be an integer; "
+ "value ignored");
}
initializedAmounts = true;
@@ -2045,10 +2042,13 @@ public:
return; // disabled
if (m_callTimer.elapsed() >= m_maxCallTimeoutMs) {
- qWarning("QDBusConnection: warning: blocking call took a long time (%d ms, max for this thread is %d ms) to service \"%s\" path \"%s\" interface \"%s\" member \"%s\"",
- int(m_callTimer.elapsed()), m_maxCallTimeoutMs,
- qPrintable(m_message.service()), qPrintable(m_message.path()),
- qPrintable(m_message.interface()), qPrintable(m_message.member()));
+ qCWarning(
+ dbusIntegration,
+ "QDBusConnection: warning: blocking call took a long time (%d ms, max for this "
+ "thread is %d ms) to service \"%s\" path \"%s\" interface \"%s\" member \"%s\"",
+ int(m_callTimer.elapsed()), m_maxCallTimeoutMs, qPrintable(m_message.service()),
+ qPrintable(m_message.path()), qPrintable(m_message.interface()),
+ qPrintable(m_message.member()));
}
}
@@ -2058,29 +2058,18 @@ private:
QElapsedTimer m_callTimer;
};
-
QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message,
- int sendMode, int timeout)
+ QDBus::CallMode mode, int timeout)
{
QDBusBlockingCallWatcher watcher(message);
QDBusPendingCallPrivate *pcall = sendWithReplyAsync(message, nullptr, nullptr, nullptr, timeout);
Q_ASSERT(pcall);
- if (pcall->replyMessage.type() == QDBusMessage::InvalidMessage) {
- // need to wait for the reply
- if (sendMode == QDBus::BlockWithGui) {
- pcall->watcherHelper = new QDBusPendingCallWatcherHelper;
- QEventLoop loop;
- loop.connect(pcall->watcherHelper, &QDBusPendingCallWatcherHelper::reply, &loop, &QEventLoop::quit);
- loop.connect(pcall->watcherHelper, &QDBusPendingCallWatcherHelper::error, &loop, &QEventLoop::quit);
-
- // enter the event loop and wait for a reply
- loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
- } else {
- pcall->waitForFinished();
- }
- }
+ if (mode == QDBus::BlockWithGui)
+ pcall->waitForFinishedWithGui();
+ else
+ pcall->waitForFinished();
QDBusMessage reply = pcall->replyMessage;
lastError = QDBusError(reply); // set or clear error
@@ -2100,9 +2089,9 @@ QDBusMessage QDBusConnectionPrivate::sendWithReplyLocal(const QDBusMessage &mess
if (!handled) {
QString interface = message.interface();
if (interface.isEmpty())
- interface = QLatin1String("<no-interface>");
+ interface = "<no-interface>"_L1;
return QDBusMessage::createError(QDBusError::InternalError,
- QLatin1String("Internal error trying to call %1.%2 at %3 (signature '%4'")
+ "Internal error trying to call %1.%2 at %3 (signature '%4'"_L1
.arg(interface, message.member(),
message.path(), message.signature()));
}
@@ -2110,12 +2099,15 @@ QDBusMessage QDBusConnectionPrivate::sendWithReplyLocal(const QDBusMessage &mess
// if the message was handled, there might be a reply
QDBusMessage localReplyMsg = QDBusMessagePrivate::makeLocalReply(*this, localCallMsg);
if (localReplyMsg.type() == QDBusMessage::InvalidMessage) {
- qWarning("QDBusConnection: cannot call local method '%s' at object %s (with signature '%s') "
- "on blocking mode", qPrintable(message.member()), qPrintable(message.path()),
- qPrintable(message.signature()));
+ qCWarning(
+ dbusIntegration,
+ "QDBusConnection: cannot call local method '%s' at object %s (with signature '%s') "
+ "on blocking mode",
+ qPrintable(message.member()), qPrintable(message.path()),
+ qPrintable(message.signature()));
return QDBusMessage::createError(
QDBusError(QDBusError::InternalError,
- QLatin1String("local-loop message cannot have delayed replies")));
+ "local-loop message cannot have delayed replies"_L1));
}
// there is a reply
@@ -2138,6 +2130,7 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM
pcall->setReplyCallback(receiver, returnMethod);
if (errorMethod) {
+ Q_ASSERT(!pcall->watcherHelper);
pcall->watcherHelper = new QDBusPendingCallWatcherHelper;
connect(pcall->watcherHelper, SIGNAL(error(QDBusError,QDBusMessage)), receiver, errorMethod,
Qt::QueuedConnection);
@@ -2163,10 +2156,12 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM
DBusMessage *msg =
QDBusMessagePrivate::toDBusMessage(message, connectionCapabilities(), &error);
if (!msg) {
- qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s",
- qPrintable(message.service()), qPrintable(message.path()),
- qPrintable(message.interface()), qPrintable(message.member()),
- qPrintable(error.message()));
+ qCWarning(dbusIntegration,
+ "QDBusConnection: error: could not send message to service \"%s\" path \"%s\" "
+ "interface \"%s\" member \"%s\": %s",
+ qPrintable(message.service()), qPrintable(message.path()),
+ qPrintable(message.interface()), qPrintable(message.member()),
+ qPrintable(error.message()));
pcall->replyMessage = QDBusMessage::createError(error);
lastError = error;
processFinishedCall(pcall);
@@ -2237,15 +2232,30 @@ bool QDBusConnectionPrivate::connectSignal(const QString &service,
QString key;
hook.signature = signature;
- if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, false))
+ QString errorMsg;
+ if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0,
+ false, errorMsg)) {
+ qCWarning(dbusIntegration)
+ << "Could not connect" << interface << "to" << slot + 1 << ":" << qPrintable(errorMsg);
return false; // don't connect
+ }
Q_ASSERT(thread() != QThread::currentThread());
- return emit signalNeedsConnecting(key, hook);
+ return addSignalHook(key, hook);
}
bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook &hook)
{
+ bool result = false;
+
+ QMetaObject::invokeMethod(this, &QDBusConnectionPrivate::addSignalHookImpl,
+ Qt::BlockingQueuedConnection, qReturnArg(result), key, hook);
+
+ return result;
+}
+
+bool QDBusConnectionPrivate::addSignalHookImpl(const QString &key, const SignalHook &hook)
+{
QDBusWriteLocker locker(ConnectAction, this);
// avoid duplicating:
@@ -2327,15 +2337,30 @@ bool QDBusConnectionPrivate::disconnectSignal(const QString &service,
name2.detach();
hook.signature = signature;
- if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, false))
+ QString errorMsg;
+ if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0,
+ false, errorMsg)) {
+ qCWarning(dbusIntegration)
+ << "Could not disconnect" << interface << "to" << slot + 1 << ":" << qPrintable(errorMsg);
return false; // don't disconnect
+ }
Q_ASSERT(thread() != QThread::currentThread());
- return emit signalNeedsDisconnecting(key, hook);
+ return removeSignalHook(key, hook);
}
bool QDBusConnectionPrivate::removeSignalHook(const QString &key, const SignalHook &hook)
{
+ bool result = false;
+
+ QMetaObject::invokeMethod(this, &QDBusConnectionPrivate::removeSignalHookImpl,
+ Qt::BlockingQueuedConnection, qReturnArg(result), key, hook);
+
+ return result;
+}
+
+bool QDBusConnectionPrivate::removeSignalHookImpl(const QString &key, const SignalHook &hook)
+{
// remove it from our list:
QDBusWriteLocker locker(ConnectAction, this);
QDBusConnectionPrivate::SignalHookHash::Iterator it = signalHooks.find(key);
@@ -2366,7 +2391,9 @@ QDBusConnectionPrivate::removeSignalHookNoLock(SignalHookHash::Iterator it)
bool erase = false;
MatchRefCountHash::iterator i = matchRefCounts.find(hook.matchRule);
if (i == matchRefCounts.end()) {
- qWarning("QDBusConnectionPrivate::disconnectSignal: MatchRule not found in matchRefCounts!!");
+ qCWarning(dbusIntegration,
+ "QDBusConnectionPrivate::disconnectSignal: MatchRule not found in "
+ "matchRefCounts!!");
} else {
if (i.value() == 1) {
erase = true;
@@ -2420,8 +2447,8 @@ void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node)
connector->connectAllSignals(node->obj);
}
- connect(connector, SIGNAL(relaySignal(QObject*,const QMetaObject*,int,QVariantList)),
- this, SLOT(relaySignal(QObject*,const QMetaObject*,int,QVariantList)),
+ connect(connector, &QDBusAdaptorConnector::relaySignal, this,
+ &QDBusConnectionPrivate::relaySignal,
Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection));
}
}
@@ -2431,10 +2458,10 @@ void QDBusConnectionPrivate::unregisterObject(const QString &path, QDBusConnecti
QDBusConnectionPrivate::ObjectTreeNode *node = &rootNode;
QList<QStringView> pathComponents;
int i;
- if (path == QLatin1String("/")) {
+ if (path == "/"_L1) {
i = 0;
} else {
- pathComponents = QStringView{path}.split(QLatin1Char('/'));
+ pathComponents = QStringView{path}.split(u'/');
i = 1;
}
@@ -2454,12 +2481,16 @@ void QDBusConnectionPrivate::connectRelay(const QString &service,
QByteArray sig;
sig.append(QSIGNAL_CODE + '0');
sig.append(signal.methodSignature());
+ QString errorMsg;
if (!prepareHook(hook, key, service, path, interface, QString(), ArgMatchRules(), receiver, sig,
- QDBusAbstractInterface::staticMetaObject.methodCount(), true))
+ QDBusAbstractInterface::staticMetaObject.methodCount(), true, errorMsg)) {
+ qCWarning(dbusIntegration)
+ << "Could not connect" << interface << "to" << signal.name() << ":" << qPrintable(errorMsg);
return; // don't connect
+ }
Q_ASSERT(thread() != QThread::currentThread());
- emit signalNeedsConnecting(key, hook);
+ addSignalHook(key, hook);
}
void QDBusConnectionPrivate::disconnectRelay(const QString &service,
@@ -2475,12 +2506,16 @@ void QDBusConnectionPrivate::disconnectRelay(const QString &service,
QByteArray sig;
sig.append(QSIGNAL_CODE + '0');
sig.append(signal.methodSignature());
+ QString errorMsg;
if (!prepareHook(hook, key, service, path, interface, QString(), ArgMatchRules(), receiver, sig,
- QDBusAbstractInterface::staticMetaObject.methodCount(), true))
+ QDBusAbstractInterface::staticMetaObject.methodCount(), true, errorMsg)) {
+ qCWarning(dbusIntegration) << "Could not disconnect" << interface << "to"
+ << signal.methodSignature() << ":" << qPrintable(errorMsg);
return; // don't disconnect
+ }
Q_ASSERT(thread() != QThread::currentThread());
- emit signalNeedsDisconnecting(key, hook);
+ removeSignalHook(key, hook);
}
bool QDBusConnectionPrivate::shouldWatchService(const QString &service)
@@ -2583,6 +2618,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
if (mo)
return mo;
}
+ if (path.isEmpty()) {
+ error = QDBusError(QDBusError::InvalidObjectPath, "Object path cannot be empty"_L1);
+ lastError = error;
+ return nullptr;
+ }
// introspect the target object
QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
@@ -2603,7 +2643,7 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
QString xml;
if (reply.type() == QDBusMessage::ReplyMessage) {
- if (reply.signature() == QLatin1String("s"))
+ if (reply.signature() == "s"_L1)
// fetch the XML description
xml = reply.arguments().at(0).toString();
} else {
@@ -2660,6 +2700,28 @@ void QDBusConnectionPrivate::postEventToThread(int action, QObject *object, QEve
QDBusLockerBase::reportThreadAction(action, QDBusLockerBase::AfterPost, this);
}
+/*
+ * Enable dispatch of D-Bus events for this connection, but only after
+ * context's thread's event loop has started and processed any already
+ * pending events. The event dispatch is then enabled in the DBus aux thread.
+ */
+void QDBusConnectionPrivate::enableDispatchDelayed(QObject *context)
+{
+ ref.ref();
+ QMetaObject::invokeMethod(
+ context,
+ [this]() {
+ // This call cannot race with something disabling dispatch only
+ // because dispatch is never re-disabled from Qt code on an
+ // in-use connection once it has been enabled.
+ QMetaObject::invokeMethod(this, &QDBusConnectionPrivate::setDispatchEnabled,
+ Qt::QueuedConnection, true);
+ if (!ref.deref())
+ deleteLater();
+ },
+ Qt::QueuedConnection);
+}
+
QT_END_NAMESPACE
#endif // QT_NO_DBUS
diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h
index 3a459251f7..b0c349799a 100644
--- a/src/dbus/qdbusintegrator_p.h
+++ b/src/dbus/qdbusintegrator_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
@@ -82,18 +46,34 @@ struct QDBusSlotCache
{
struct Data
{
- int flags;
int slotIdx;
QList<QMetaType> metaTypes;
void swap(Data &other) noexcept
{
- qSwap(flags, other.flags);
qSwap(slotIdx, other.slotIdx);
qSwap(metaTypes, other.metaTypes);
}
};
- typedef QMultiHash<QString, Data> Hash;
+
+ struct Key
+ {
+ QString memberWithSignature;
+ QDBusConnection::RegisterOptions flags;
+
+ friend bool operator==(const Key &lhs, const Key &rhs) noexcept
+ {
+ return lhs.memberWithSignature == rhs.memberWithSignature && lhs.flags == rhs.flags;
+ }
+
+ friend size_t qHash(const QDBusSlotCache::Key &key, size_t seed = 0) noexcept
+ {
+ return qHashMulti(seed, key.memberWithSignature, key.flags);
+ }
+ };
+
+ using Hash = QHash<Key, Data>;
+
Hash hash;
void swap(QDBusSlotCache &other) noexcept { qSwap(hash, other.hash); }
@@ -105,19 +85,14 @@ class QDBusCallDeliveryEvent: public QAbstractMetaCallEvent
{
public:
QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender,
- const QDBusMessage &msg, const QList<QMetaType> &types, int f = 0)
- : QAbstractMetaCallEvent(sender, -1),
- connection(c),
- message(msg),
- metaTypes(types),
- id(id),
- flags(f)
+ const QDBusMessage &msg, const QList<QMetaType> &types)
+ : QAbstractMetaCallEvent(sender, -1), connection(c), message(msg), metaTypes(types), id(id)
{
}
void placeMetaCall(QObject *object) override
{
- QDBusConnectionPrivate::d(connection)->deliverCall(object, flags, message, metaTypes, id);
+ QDBusConnectionPrivate::d(connection)->deliverCall(object, message, metaTypes, id);
}
private:
@@ -125,7 +100,6 @@ private:
QDBusMessage message;
QList<QMetaType> metaTypes;
int id;
- int flags;
};
class QDBusActivateObjectEvent: public QAbstractMetaCallEvent
@@ -153,23 +127,20 @@ class QDBusSpyCallEvent : public QAbstractMetaCallEvent
{
public:
typedef void (*Hook)(const QDBusMessage&);
- QDBusSpyCallEvent(QDBusConnectionPrivate *cp, const QDBusConnection &c, const QDBusMessage &msg,
- const Hook *hooks, int count)
- : QAbstractMetaCallEvent(cp, 0), conn(c), msg(msg), hooks(hooks), hookCount(count)
+ QDBusSpyCallEvent(QDBusConnectionPrivate *cp, const QDBusConnection &c, const QDBusMessage &msg)
+ : QAbstractMetaCallEvent(cp, 0), conn(c), msg(msg)
{}
~QDBusSpyCallEvent() override;
void placeMetaCall(QObject *) override;
- static inline void invokeSpyHooks(const QDBusMessage &msg, const Hook *hooks, int hookCount);
+ static inline void invokeSpyHooks(const QDBusMessage &msg);
QDBusConnection conn; // keeps the refcount in QDBusConnectionPrivate up
QDBusMessage msg;
- const Hook *hooks;
- int hookCount;
};
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDBusSlotCache)
+QT_DECL_METATYPE_EXTERN(QDBusSlotCache, Q_DBUS_EXPORT)
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp
index 3d6cf6c1f2..d4da36b35c 100644
--- a/src/dbus/qdbusinterface.cpp
+++ b/src/dbus/qdbusinterface.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 "qdbusinterface.h"
#include "qdbusinterface_p.h"
@@ -51,6 +15,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static void copyArgument(void *to, int id, const QVariant &arg)
{
if (id == arg.metaType().id()) {
@@ -137,7 +103,7 @@ static void copyArgument(void *to, int id, const QVariant &arg)
// is it the same signature?
QDBusArgument dbarg = qvariant_cast<QDBusArgument>(arg);
- if (dbarg.currentSignature() != QLatin1String(userSignature)) {
+ if (dbarg.currentSignature() != QLatin1StringView(userSignature)) {
// not the same signature, another mismatch
//qWarning?
return;
@@ -161,7 +127,7 @@ QDBusInterfacePrivate::QDBusInterfacePrivate(const QString &serv, const QString
// those are not fatal errors, so we continue working
if (!lastError.isValid())
- lastError = QDBusError(QDBusError::InternalError, QLatin1String("Unknown error"));
+ lastError = QDBusError(QDBusError::InternalError, "Unknown error"_L1);
}
}
}
diff --git a/src/dbus/qdbusinterface.h b/src/dbus/qdbusinterface.h
index c147d07d50..fc02463ac7 100644
--- a/src/dbus/qdbusinterface.h
+++ b/src/dbus/qdbusinterface.h
@@ -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
#ifndef QDBUSINTERFACE_H
#define QDBUSINTERFACE_H
diff --git a/src/dbus/qdbusinterface_p.h b/src/dbus/qdbusinterface_p.h
index b726925306..caf24e589d 100644
--- a/src/dbus/qdbusinterface_p.h
+++ b/src/dbus/qdbusinterface_p.h
@@ -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
//
// W A R N I N G
diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp
index 4d8d4ca254..721564ed3c 100644
--- a/src/dbus/qdbusinternalfilters.cpp
+++ b/src/dbus/qdbusinternalfilters.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbusconnection_p.h"
@@ -63,9 +27,11 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// defined in qdbusxmlgenerator.cpp
-extern QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo,
- const QMetaObject *base, int flags);
+extern Q_DBUS_EXPORT QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo,
+ const QMetaObject *base, int flags);
static const char introspectableInterfaceXml[] =
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
@@ -107,16 +73,13 @@ static const char peerInterfaceXml[] =
" </method>\n"
" </interface>\n";
-static QString generateSubObjectXml(QObject *object)
+static QString generateSubObjectXml(const QObject *object)
{
QString retval;
- const QObjectList &objs = object->children();
- QObjectList::ConstIterator it = objs.constBegin();
- QObjectList::ConstIterator end = objs.constEnd();
- for ( ; it != end; ++it) {
- QString name = (*it)->objectName();
+ for (const QObject *child : object->children()) {
+ QString name = child->objectName();
if (!name.isEmpty() && QDBusUtil::isValidPartOfObjectPath(name))
- retval += QLatin1String(" <node name=\"") + name + QLatin1String("\"/>\n");
+ retval += " <node name=\""_L1 + name + "\"/>\n"_L1;
}
return retval;
}
@@ -127,8 +90,8 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
{
// object may be null
- QString xml_data(QLatin1String(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE));
- xml_data += QLatin1String("<node>\n");
+ QString xml_data(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE ""_L1);
+ xml_data += "<node>\n"_L1;
if (node.obj) {
Q_ASSERT_X(QThread::currentThread() == node.obj->thread(),
@@ -150,20 +113,22 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
(connector = qDBusFindAdaptorConnector(node.obj))) {
// trasverse every adaptor in this object
- QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin();
- QDBusAdaptorConnector::AdaptorMap::ConstIterator end = connector->adaptors.constEnd();
- for ( ; it != end; ++it) {
+ for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
+ std::as_const(connector->adaptors)) {
// add the interface:
- QString ifaceXml = QDBusAbstractAdaptorPrivate::retrieveIntrospectionXml(it->adaptor);
+ QString ifaceXml =
+ QDBusAbstractAdaptorPrivate::retrieveIntrospectionXml(adaptorData.adaptor);
if (ifaceXml.isEmpty()) {
// add the interface's contents:
- ifaceXml += qDBusGenerateMetaObjectXml(QString::fromLatin1(it->interface),
- it->adaptor->metaObject(),
- &QDBusAbstractAdaptor::staticMetaObject,
- QDBusConnection::ExportScriptableContents
- | QDBusConnection::ExportNonScriptableContents);
-
- QDBusAbstractAdaptorPrivate::saveIntrospectionXml(it->adaptor, ifaceXml);
+ ifaceXml += qDBusGenerateMetaObjectXml(
+ QString::fromLatin1(adaptorData.interface),
+ adaptorData.adaptor->metaObject(),
+ &QDBusAbstractAdaptor::staticMetaObject,
+ QDBusConnection::ExportScriptableContents
+ | QDBusConnection::ExportNonScriptableContents);
+
+ QDBusAbstractAdaptorPrivate::saveIntrospectionXml(adaptorData.adaptor,
+ ifaceXml);
}
xml_data += ifaceXml;
@@ -175,26 +140,23 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
xml_data += node.treeNode->introspect(path);
}
- xml_data += QLatin1String( propertiesInterfaceXml );
+ xml_data += QLatin1StringView(propertiesInterfaceXml);
}
- xml_data += QLatin1String( introspectableInterfaceXml );
- xml_data += QLatin1String( peerInterfaceXml );
+ xml_data += QLatin1StringView(introspectableInterfaceXml);
+ xml_data += QLatin1StringView(peerInterfaceXml);
if (node.flags & QDBusConnection::ExportChildObjects) {
xml_data += generateSubObjectXml(node.obj);
} else {
// generate from the object tree
- QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it =
- node.children.constBegin();
- QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator end =
- node.children.constEnd();
- for ( ; it != end; ++it)
- if (it->obj || !it->children.isEmpty())
- xml_data += QLatin1String(" <node name=\"") + it->name + QLatin1String("\"/>\n");
+ for (const QDBusConnectionPrivate::ObjectTreeNode &node : node.children) {
+ if (node.obj || !node.children.isEmpty())
+ xml_data += " <node name=\""_L1 + node.name + "\"/>\n"_L1;
+ }
}
- xml_data += QLatin1String("</node>\n");
+ xml_data += "</node>\n"_L1;
return xml_data;
}
@@ -203,7 +165,7 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
static inline QDBusMessage interfaceNotFoundError(const QDBusMessage &msg, const QString &interface_name)
{
return msg.createErrorReply(QDBusError::UnknownInterface,
- QLatin1String("Interface %1 was not found in object %2")
+ "Interface %1 was not found in object %2"_L1
.arg(interface_name, msg.path()));
}
@@ -211,17 +173,17 @@ static inline QDBusMessage
propertyNotFoundError(const QDBusMessage &msg, const QString &interface_name, const QByteArray &property_name)
{
return msg.createErrorReply(QDBusError::UnknownProperty,
- QLatin1String("Property %1%2%3 was not found in object %4")
+ "Property %1%2%3 was not found in object %4"_L1
.arg(interface_name,
- QLatin1String(interface_name.isEmpty() ? "" : "."),
- QLatin1String(property_name),
+ interface_name.isEmpty() ? ""_L1 : "."_L1,
+ QLatin1StringView(property_name),
msg.path()));
}
QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node,
const QDBusMessage &msg)
{
- Q_ASSERT(msg.arguments().count() == 2);
+ Q_ASSERT(msg.arguments().size() == 2);
Q_ASSERT_X(!node.obj || QThread::currentThread() == node.obj->thread(),
"QDBusConnection: internal threading error",
"function called for an object that is in another thread!!");
@@ -229,7 +191,7 @@ QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node
QString interface_name = msg.arguments().at(0).toString();
QByteArray property_name = msg.arguments().at(1).toString().toUtf8();
- QDBusAdaptorConnector *connector;
+ const QDBusAdaptorConnector *connector;
QVariant value;
bool interfaceFound = false;
if (node.flags & QDBusConnection::ExportAdaptors &&
@@ -238,12 +200,11 @@ QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node
// find the class that implements interface_name or try until we've found the property
// in case of an empty interface
if (interface_name.isEmpty()) {
- for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
- end = connector->adaptors.constEnd(); it != end; ++it) {
- const QMetaObject *mo = it->adaptor->metaObject();
+ for (const QDBusAdaptorConnector::AdaptorData &adaptorData : connector->adaptors) {
+ const QMetaObject *mo = adaptorData.adaptor->metaObject();
int pidx = mo->indexOfProperty(property_name);
if (pidx != -1) {
- value = mo->property(pidx).read(it->adaptor);
+ value = mo->property(pidx).read(adaptorData.adaptor);
break;
}
}
@@ -251,7 +212,7 @@ QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node
QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
it = std::lower_bound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
interface_name);
- if (it != connector->adaptors.constEnd() && interface_name == QLatin1String(it->interface)) {
+ if (it != connector->adaptors.constEnd() && interface_name == QLatin1StringView(it->interface)) {
interfaceFound = true;
value = it->adaptor->property(property_name);
}
@@ -302,16 +263,16 @@ static QDBusMessage propertyWriteReply(const QDBusMessage &msg, const QString &i
return propertyNotFoundError(msg, interface_name, property_name);
case PropertyTypeMismatch:
return msg.createErrorReply(QDBusError::InvalidArgs,
- QLatin1String("Invalid arguments for writing to property %1%2%3")
+ "Invalid arguments for writing to property %1%2%3"_L1
.arg(interface_name,
- QLatin1String(interface_name.isEmpty() ? "" : "."),
- QLatin1String(property_name)));
+ interface_name.isEmpty() ? ""_L1 : "."_L1,
+ QLatin1StringView(property_name)));
case PropertyReadOnly:
return msg.createErrorReply(QDBusError::PropertyReadOnly,
- QLatin1String("Property %1%2%3 is read-only")
+ "Property %1%2%3 is read-only"_L1
.arg(interface_name,
- QLatin1String(interface_name.isEmpty() ? "" : "."),
- QLatin1String(property_name)));
+ interface_name.isEmpty() ? ""_L1 : "."_L1,
+ QLatin1StringView(property_name)));
case PropertyWriteFailed:
return msg.createErrorReply(QDBusError::InternalError,
QString::fromLatin1("Internal error"));
@@ -360,26 +321,26 @@ static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant
// we have to demarshall before writing
QVariant other{QMetaType(id)};
if (!QDBusMetaType::demarshall(qvariant_cast<QDBusArgument>(value), other.metaType(), other.data())) {
- qWarning("QDBusConnection: type `%s' (%d) is not registered with QtDBus. "
+ qWarning("QDBusConnection: type '%s' (%d) is not registered with QtDBus. "
"Use qDBusRegisterMetaType to register it",
mp.typeName(), id.id());
return PropertyWriteFailed;
}
- value = other;
+ value = std::move(other);
}
if (mp.metaType() == QMetaType::fromType<QDBusVariant>())
value = QVariant::fromValue(QDBusVariant(value));
// the property type here should match
- return mp.write(obj, value) ? PropertyWriteSuccess : PropertyWriteFailed;
+ return mp.write(obj, std::move(value)) ? PropertyWriteSuccess : PropertyWriteFailed;
}
QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node,
const QDBusMessage &msg)
{
- Q_ASSERT(msg.arguments().count() == 3);
+ Q_ASSERT(msg.arguments().size() == 3);
Q_ASSERT_X(!node.obj || QThread::currentThread() == node.obj->thread(),
"QDBusConnection: internal threading error",
"function called for an object that is in another thread!!");
@@ -395,9 +356,9 @@ QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node
// find the class that implements interface_name or try until we've found the property
// in case of an empty interface
if (interface_name.isEmpty()) {
- for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
- end = connector->adaptors.constEnd(); it != end; ++it) {
- int status = writeProperty(it->adaptor, property_name, value);
+ for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
+ std::as_const(connector->adaptors)) {
+ int status = writeProperty(adaptorData.adaptor, property_name, value);
if (status == PropertyNotFound)
continue;
return propertyWriteReply(msg, interface_name, property_name, status);
@@ -406,7 +367,7 @@ QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node
QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
it = std::lower_bound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
interface_name);
- if (it != connector->adaptors.cend() && interface_name == QLatin1String(it->interface)) {
+ if (it != connector->adaptors.cend() && interface_name == QLatin1StringView(it->interface)) {
return propertyWriteReply(msg, interface_name, property_name,
writeProperty(it->adaptor, property_name, value));
}
@@ -435,10 +396,8 @@ QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node
// unite two QVariantMaps, but don't generate duplicate keys
static QVariantMap &operator+=(QVariantMap &lhs, const QVariantMap &rhs)
{
- QVariantMap::ConstIterator it = rhs.constBegin(),
- end = rhs.constEnd();
- for ( ; it != end; ++it)
- lhs.insert(it.key(), it.value());
+ for (const auto &[key, value] : rhs.asKeyValueRange())
+ lhs.insert(key, value);
return lhs;
}
@@ -479,7 +438,7 @@ static QVariantMap readAllProperties(QObject *object, int flags)
QDBusMessage qDBusPropertyGetAll(const QDBusConnectionPrivate::ObjectTreeNode &node,
const QDBusMessage &msg)
{
- Q_ASSERT(msg.arguments().count() == 1);
+ Q_ASSERT(msg.arguments().size() == 1);
Q_ASSERT_X(!node.obj || QThread::currentThread() == node.obj->thread(),
"QDBusConnection: internal threading error",
"function called for an object that is in another thread!!");
@@ -495,16 +454,17 @@ QDBusMessage qDBusPropertyGetAll(const QDBusConnectionPrivate::ObjectTreeNode &n
if (interface_name.isEmpty()) {
// iterate over all interfaces
- for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
- end = connector->adaptors.constEnd(); it != end; ++it) {
- result += readAllProperties(it->adaptor, QDBusConnection::ExportAllProperties);
+ for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
+ std::as_const(connector->adaptors)) {
+ result += readAllProperties(adaptorData.adaptor,
+ QDBusConnection::ExportAllProperties);
}
} else {
// find the class that implements interface_name
QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
it = std::lower_bound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
interface_name);
- if (it != connector->adaptors.constEnd() && interface_name == QLatin1String(it->interface)) {
+ if (it != connector->adaptors.constEnd() && interface_name == QLatin1StringView(it->interface)) {
interfaceFound = true;
result = readAllProperties(it->adaptor, QDBusConnection::ExportAllProperties);
}
diff --git a/src/dbus/qdbusintrospection.cpp b/src/dbus/qdbusintrospection.cpp
index 6e406f7616..04b5ab7751 100644
--- a/src/dbus/qdbusintrospection.cpp
+++ b/src/dbus/qdbusintrospection.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 "qdbusintrospection_p.h"
#include "qdbusxmlparser_p.h"
@@ -57,6 +21,9 @@ QT_BEGIN_NAMESPACE
But they may prove useful if the XML data was obtained through other means (like parsing a file).
*/
+QDBusIntrospection::DiagnosticsReporter::~DiagnosticsReporter()
+ = default;
+
/*!
\class QDBusIntrospection::Argument
\inmodule QtDBus
@@ -333,11 +300,11 @@ QT_BEGIN_NAMESPACE
If there are multiple interfaces in this XML data, it is undefined which one will be
returned.
*/
-QDBusIntrospection::Interface
-QDBusIntrospection::parseInterface(const QString &xml)
+QDBusIntrospection::Interface QDBusIntrospection::parseInterface(const QString &xml,
+ DiagnosticsReporter *reporter)
{
// be lazy
- Interfaces ifs = parseInterfaces(xml);
+ Interfaces ifs = parseInterfaces(xml, reporter);
if (ifs.isEmpty())
return Interface();
@@ -351,11 +318,11 @@ QDBusIntrospection::parseInterface(const QString &xml)
If the first element tag in this document fragment is \<node\>, the interfaces parsed will
be those found as child elements of the \<node\> tag.
*/
-QDBusIntrospection::Interfaces
-QDBusIntrospection::parseInterfaces(const QString &xml)
+QDBusIntrospection::Interfaces QDBusIntrospection::parseInterfaces(const QString &xml,
+ DiagnosticsReporter *reporter)
{
QString null;
- QDBusXmlParser parser(null, null, xml);
+ QDBusXmlParser parser(null, null, xml, reporter);
return parser.interfaces();
}
@@ -370,10 +337,12 @@ QDBusIntrospection::parseInterfaces(const QString &xml)
This function does not parse the interfaces contained in the node, nor sub-object's contents.
It will only list their names.
*/
-QDBusIntrospection::Object
-QDBusIntrospection::parseObject(const QString &xml, const QString &service, const QString &path)
+QDBusIntrospection::Object QDBusIntrospection::parseObject(const QString &xml,
+ const QString &service,
+ const QString &path,
+ DiagnosticsReporter *reporter)
{
- QDBusXmlParser parser(service, path, xml);
+ QDBusXmlParser parser(service, path, xml, reporter);
QSharedDataPointer<QDBusIntrospection::Object> retval = parser.object();
if (!retval)
return QDBusIntrospection::Object();
diff --git a/src/dbus/qdbusintrospection_p.h b/src/dbus/qdbusintrospection_p.h
index 9afa0a3420..766cdffb62 100644
--- a/src/dbus/qdbusintrospection_p.h
+++ b/src/dbus/qdbusintrospection_p.h
@@ -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
#ifndef QDBUSINTROSPECTION_P_H
#define QDBUSINTROSPECTION_P_H
@@ -54,7 +18,6 @@
#include <QtDBus/private/qtdbusglobal_p.h>
#include <QtCore/qlist.h>
#include <QtCore/qmap.h>
-#include <QtCore/qpair.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
@@ -74,9 +37,10 @@ public:
struct Interface;
struct Object;
struct ObjectTree;
+ struct Annotation;
// typedefs
- typedef QMap<QString, QString> Annotations;
+ typedef QMap<QString, Annotation> Annotations;
typedef QList<Argument> Arguments;
typedef QMultiMap<QString, Method> Methods;
typedef QMultiMap<QString, Signal> Signals;
@@ -87,8 +51,40 @@ public:
public:
// the structs
+ // Line and column numbers have the same meaning as in QXmlStreamReader.
+ struct SourceLocation
+ {
+ qint64 lineNumber = 1;
+ qint64 columnNumber = 0;
+ };
+
+ class Q_DBUS_EXPORT DiagnosticsReporter
+ {
+ Q_DISABLE_COPY_MOVE(DiagnosticsReporter)
+ public:
+ DiagnosticsReporter() = default;
+ virtual ~DiagnosticsReporter();
+ virtual void warning(const SourceLocation &location, const char *msg, ...)
+ Q_ATTRIBUTE_FORMAT_PRINTF(3, 4) = 0;
+ virtual void error(const SourceLocation &location, const char *msg, ...)
+ Q_ATTRIBUTE_FORMAT_PRINTF(3, 4) = 0;
+ };
+
+ struct Annotation
+ {
+ SourceLocation location;
+ QString name;
+ QString value;
+
+ inline bool operator==(const Annotation &other) const
+ {
+ return name == other.name && value == other.value;
+ }
+ };
+
struct Argument
{
+ SourceLocation location;
QString type;
QString name;
@@ -98,6 +94,7 @@ public:
struct Method
{
+ SourceLocation location;
QString name;
Arguments inputArgs;
Arguments outputArgs;
@@ -110,6 +107,7 @@ public:
struct Signal
{
+ SourceLocation location;
QString name;
Arguments outputArgs;
Annotations annotations;
@@ -122,6 +120,7 @@ public:
struct Property
{
enum Access { Read, Write, ReadWrite };
+ SourceLocation location;
QString name;
QString type;
Access access;
@@ -134,6 +133,7 @@ public:
struct Interface: public QSharedData
{
+ SourceLocation location;
QString name;
QString introspection;
@@ -148,6 +148,7 @@ public:
struct Object: public QSharedData
{
+ SourceLocation location;
QString service;
QString path;
@@ -156,10 +157,11 @@ public:
};
public:
- static Interface parseInterface(const QString &xml);
- static Interfaces parseInterfaces(const QString &xml);
+ static Interface parseInterface(const QString &xml, DiagnosticsReporter *reporter = nullptr);
+ static Interfaces parseInterfaces(const QString &xml, DiagnosticsReporter *reporter = nullptr);
static Object parseObject(const QString &xml, const QString &service = QString(),
- const QString &path = QString());
+ const QString &path = QString(),
+ DiagnosticsReporter *reporter = nullptr);
private:
QDBusIntrospection();
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;
diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp
index 1ae6ea9c0c..6ef762f225 100644
--- a/src/dbus/qdbusmessage.cpp
+++ b/src/dbus/qdbusmessage.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbusmessage.h"
#include "qdbusmessage_p.h"
@@ -56,6 +20,10 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
+QT_IMPL_METATYPE_EXTERN(QDBusMessage)
+
static_assert(QDBusMessage::InvalidMessage == DBUS_MESSAGE_TYPE_INVALID);
static_assert(QDBusMessage::MethodCallMessage == DBUS_MESSAGE_TYPE_METHOD_CALL);
static_assert(QDBusMessage::ReplyMessage == DBUS_MESSAGE_TYPE_METHOD_RETURN);
@@ -68,22 +36,37 @@ static inline const char *data(const QByteArray &arr)
}
QDBusMessagePrivate::QDBusMessagePrivate()
- : msg(nullptr), reply(nullptr), localReply(nullptr), ref(1), type(QDBusMessage::InvalidMessage),
- delayedReply(false), localMessage(false),
- parametersValidated(false), autoStartService(true),
- interactiveAuthorizationAllowed(false)
+ : localReply(nullptr), ref(1), type(QDBusMessage::InvalidMessage),
+ delayedReply(false), parametersValidated(false),
+ localMessage(false), autoStartService(true),
+ interactiveAuthorizationAllowed(false), isReplyRequired(false)
{
}
QDBusMessagePrivate::~QDBusMessagePrivate()
{
- if (msg)
- q_dbus_message_unref(msg);
- if (reply)
- q_dbus_message_unref(reply);
delete localReply;
}
+void QDBusMessagePrivate::createResponseLink(const QDBusMessagePrivate *call)
+{
+ if (Q_UNLIKELY(call->type != QDBusMessage::MethodCallMessage)) {
+ qWarning("QDBusMessage: replying to a message that isn't a method call");
+ return;
+ }
+
+ if (call->localMessage) {
+ localMessage = true;
+ call->localReply = new QDBusMessage(*this); // keep an internal copy
+ } else {
+ serial = call->serial;
+ service = call->service;
+ }
+
+ // the reply must have a serial or be a local-loop optimization
+ Q_ASSERT(serial || localMessage);
+}
+
/*!
\since 4.3
Returns the human-readable message associated with the error that was received.
@@ -112,7 +95,7 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
QDBusError *error)
{
if (!qdbus_loadLibDBus()) {
- *error = QDBusError(QDBusError::Failed, QLatin1String("Could not open lidbus-1 library"));
+ *error = QDBusError(QDBusError::Failed, "Could not open lidbus-1 library"_L1);
return nullptr;
}
@@ -145,8 +128,8 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
case QDBusMessage::ReplyMessage:
msg = q_dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
if (!d_ptr->localMessage) {
- q_dbus_message_set_destination(msg, q_dbus_message_get_sender(d_ptr->reply));
- q_dbus_message_set_reply_serial(msg, q_dbus_message_get_serial(d_ptr->reply));
+ q_dbus_message_set_destination(msg, data(d_ptr->service.toUtf8()));
+ q_dbus_message_set_reply_serial(msg, d_ptr->serial);
}
break;
case QDBusMessage::ErrorMessage:
@@ -158,8 +141,8 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
msg = q_dbus_message_new(DBUS_MESSAGE_TYPE_ERROR);
q_dbus_message_set_error_name(msg, d_ptr->name.toUtf8());
if (!d_ptr->localMessage) {
- q_dbus_message_set_destination(msg, q_dbus_message_get_sender(d_ptr->reply));
- q_dbus_message_set_reply_serial(msg, q_dbus_message_get_serial(d_ptr->reply));
+ q_dbus_message_set_destination(msg, data(d_ptr->service.toUtf8()));
+ q_dbus_message_set_reply_serial(msg, d_ptr->serial);
}
break;
case QDBusMessage::SignalMessage:
@@ -187,14 +170,12 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
d_ptr->parametersValidated = true;
QDBusMarshaller marshaller(capabilities);
- QVariantList::ConstIterator it = d_ptr->arguments.constBegin();
- QVariantList::ConstIterator cend = d_ptr->arguments.constEnd();
q_dbus_message_iter_init_append(msg, &marshaller.iterator);
if (!d_ptr->message.isEmpty())
// prepend the error message
marshaller.append(d_ptr->message);
- for ( ; it != cend; ++it)
- marshaller.appendVariantInternal(*it);
+ for (const QVariant &argument : std::as_const(d_ptr->arguments))
+ marshaller.appendVariantInternal(argument);
// check if everything is ok
if (marshaller.ok)
@@ -202,7 +183,7 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
// not ok;
q_dbus_message_unref(msg);
- *error = QDBusError(QDBusError::Failed, QLatin1String("Marshalling failed: ") + marshaller.errorString);
+ *error = QDBusError(QDBusError::Failed, "Marshalling failed: "_L1 + marshaller.errorString);
return nullptr;
}
@@ -238,6 +219,7 @@ QDBusMessage QDBusMessagePrivate::fromDBusMessage(DBusMessage *dmsg, QDBusConnec
return message;
message.d_ptr->type = QDBusMessage::MessageType(q_dbus_message_get_type(dmsg));
+ message.d_ptr->serial = q_dbus_message_get_serial(dmsg);
message.d_ptr->path = QString::fromUtf8(q_dbus_message_get_path(dmsg));
message.d_ptr->interface = QString::fromUtf8(q_dbus_message_get_interface(dmsg));
message.d_ptr->name = message.d_ptr->type == DBUS_MESSAGE_TYPE_ERROR ?
@@ -246,7 +228,7 @@ QDBusMessage QDBusMessagePrivate::fromDBusMessage(DBusMessage *dmsg, QDBusConnec
message.d_ptr->service = QString::fromUtf8(q_dbus_message_get_sender(dmsg));
message.d_ptr->signature = QString::fromUtf8(q_dbus_message_get_signature(dmsg));
message.d_ptr->interactiveAuthorizationAllowed = q_dbus_message_get_allow_interactive_authorization(dmsg);
- message.d_ptr->msg = q_dbus_message_ref(dmsg);
+ message.d_ptr->isReplyRequired = !q_dbus_message_get_no_reply(dmsg);
QDBusDemarshaller demarshaller(capabilities);
demarshaller.message = q_dbus_message_ref(dmsg);
@@ -271,10 +253,8 @@ QDBusMessage QDBusMessagePrivate::makeLocal(const QDBusConnectionPrivate &conn,
// determine if we are carrying any complex types
QString computedSignature;
- QVariantList::ConstIterator it = asSent.d_ptr->arguments.constBegin();
- QVariantList::ConstIterator end = asSent.d_ptr->arguments.constEnd();
- for ( ; it != end; ++it) {
- QMetaType id = it->metaType();
+ for (const QVariant &argument : std::as_const(asSent.d_ptr->arguments)) {
+ QMetaType id = argument.metaType();
const char *signature = QDBusMetaType::typeToSignature(id);
if ((id.id() != QMetaType::QStringList && id.id() != QMetaType::QByteArray &&
qstrlen(signature) != 1) || id == QMetaType::fromType<QDBusVariant>()) {
@@ -297,7 +277,7 @@ QDBusMessage QDBusMessagePrivate::makeLocal(const QDBusConnectionPrivate &conn,
retval.d_ptr->service = conn.baseService;
return retval;
} else {
- computedSignature += QLatin1String(signature);
+ computedSignature += QLatin1StringView(signature);
}
}
@@ -438,6 +418,7 @@ QDBusMessage QDBusMessage::createMethodCall(const QString &service, const QStrin
message.d_ptr->path = path;
message.d_ptr->interface = interface;
message.d_ptr->name = method;
+ message.d_ptr->isReplyRequired = true;
return message;
}
@@ -480,15 +461,7 @@ QDBusMessage QDBusMessage::createReply(const QVariantList &arguments) const
QDBusMessage reply;
reply.setArguments(arguments);
reply.d_ptr->type = ReplyMessage;
- if (d_ptr->msg)
- reply.d_ptr->reply = q_dbus_message_ref(d_ptr->msg);
- if (d_ptr->localMessage) {
- reply.d_ptr->localMessage = true;
- d_ptr->localReply = new QDBusMessage(reply); // keep an internal copy
- }
-
- // the reply must have a msg or be a local-loop optimization
- Q_ASSERT(reply.d_ptr->reply || reply.d_ptr->localMessage);
+ reply.d_ptr->createResponseLink(d_ptr);
return reply;
}
@@ -499,24 +472,18 @@ QDBusMessage QDBusMessage::createReply(const QVariantList &arguments) const
QDBusMessage QDBusMessage::createErrorReply(const QString &name, const QString &msg) const
{
QDBusMessage reply = QDBusMessage::createError(name, msg);
- if (d_ptr->msg)
- reply.d_ptr->reply = q_dbus_message_ref(d_ptr->msg);
- if (d_ptr->localMessage) {
- reply.d_ptr->localMessage = true;
- d_ptr->localReply = new QDBusMessage(reply); // keep an internal copy
- }
-
- // the reply must have a msg or be a local-loop optimization
- Q_ASSERT(reply.d_ptr->reply || reply.d_ptr->localMessage);
+ reply.d_ptr->createResponseLink(d_ptr);
return reply;
}
/*!
- \fn QDBusMessage QDBusMessage::createReply(const QVariant &argument) const
-
Constructs a new DBus message representing a reply, with the
given \a argument.
*/
+QDBusMessage QDBusMessage::createReply(const QVariant &argument) const
+{
+ return createReply(QList{argument});
+}
/*!
\fn QDBusMessage QDBusMessage::createErrorReply(const QDBusError &error) const
@@ -589,6 +556,8 @@ QDBusMessage &QDBusMessage::operator=(const QDBusMessage &other)
*/
QString QDBusMessage::service() const
{
+ if (d_ptr->type == ErrorMessage || d_ptr->type == ReplyMessage)
+ return QString(); // d_ptr->service holds the destination
return d_ptr->service;
}
@@ -651,9 +620,9 @@ bool QDBusMessage::isReplyRequired() const
if (d_ptr->type != QDBusMessage::MethodCallMessage)
return false;
- if (!d_ptr->msg)
- return d_ptr->localMessage; // if it's a local message, reply is required
- return !q_dbus_message_get_no_reply(d_ptr->msg);
+ if (d_ptr->localMessage) // if it's a local message, reply is required
+ return true;
+ return d_ptr->isReplyRequired;
}
/*!
@@ -725,20 +694,26 @@ bool QDBusMessage::autoStartService() const
}
/*!
- Sets the interactive authorization flag to \a enable.
- This flag only makes sense for method call messages, where it
- tells the D-Bus server that the caller of the method is prepared
- to wait for interactive authorization to take place (for instance
- via Polkit) before the actual method is processed.
+ Enables or disables the \c ALLOW_INTERACTIVE_AUTHORIZATION flag
+ in a message.
- By default this flag is false and the other end is expected to
- make any authorization decisions non-interactively and promptly.
+ This flag only makes sense for method call messages
+ (\l QDBusMessage::MethodCallMessage). If \a enable
+ is set to \c true, the flag indicates to the callee that the
+ caller of the method is prepared to wait for interactive authorization
+ to take place (for instance via Polkit) before the actual method
+ is processed.
+
+ If \a enable is set to \c false, the flag is not
+ set, meaning that the other end is expected to make any authorization
+ decisions non-interactively and promptly. This is the default.
The \c org.freedesktop.DBus.Error.InteractiveAuthorizationRequired
error indicates that authorization failed, but could have succeeded
if this flag had been set.
- \sa isInteractiveAuthorizationAllowed()
+ \sa isInteractiveAuthorizationAllowed(),
+ QDBusAbstractInterface::setInteractiveAuthorizationAllowed()
\since 5.12
*/
@@ -748,12 +723,11 @@ void QDBusMessage::setInteractiveAuthorizationAllowed(bool enable)
}
/*!
- Returns the interactive authorization allowed flag, as set by
- setInteractiveAuthorizationAllowed(). By default this flag
- is false and the other end is expected to make any authorization
- decisions non-interactively and promptly.
+ Returns whether the message has the
+ \c ALLOW_INTERACTIVE_AUTHORIZATION flag set.
- \sa setInteractiveAuthorizationAllowed()
+ \sa setInteractiveAuthorizationAllowed(),
+ QDBusAbstractInterface::isInteractiveAuthorizationAllowed()
\since 5.12
*/
@@ -793,6 +767,12 @@ QDBusMessage &QDBusMessage::operator<<(const QVariant &arg)
return *this;
}
+QDBusMessage::QDBusMessage(QDBusMessagePrivate &dd)
+ : d_ptr(&dd)
+{
+ d_ptr->ref.ref();
+}
+
/*!
Returns the message type.
*/
@@ -834,12 +814,10 @@ static QDebug operator<<(QDebug dbg, QDBusMessage::MessageType t)
static void debugVariantList(QDebug dbg, const QVariantList &list)
{
bool first = true;
- QVariantList::ConstIterator it = list.constBegin();
- QVariantList::ConstIterator end = list.constEnd();
- for ( ; it != end; ++it) {
+ for (const QVariant &elem : list) {
if (!first)
dbg.nospace() << ", ";
- dbg.nospace() << qPrintable(QDBusUtil::argumentToString(*it));
+ dbg.nospace() << qPrintable(QDBusUtil::argumentToString(elem));
first = false;
}
}
diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h
index 31ce8169a2..f6db3bc21e 100644
--- a/src/dbus/qdbusmessage.h
+++ b/src/dbus/qdbusmessage.h
@@ -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
#ifndef QDBUSMESSAGE_H
#define QDBUSMESSAGE_H
@@ -71,7 +35,7 @@ public:
QDBusMessage &operator=(const QDBusMessage &other);
~QDBusMessage();
- void swap(QDBusMessage &other) noexcept { qSwap(d_ptr, other.d_ptr); }
+ void swap(QDBusMessage &other) noexcept { qt_ptr_swap(d_ptr, other.d_ptr); }
static QDBusMessage createSignal(const QString &path, const QString &interface,
const QString &name);
@@ -86,8 +50,7 @@ public:
{ return createError(QDBusError::errorString(type), msg); }
QDBusMessage createReply(const QList<QVariant> &arguments = QList<QVariant>()) const;
- inline QDBusMessage createReply(const QVariant &argument) const
- { return createReply(QList<QVariant>() << argument); }
+ QDBusMessage createReply(const QVariant &argument) const;
QDBusMessage createErrorReply(const QString &name, const QString &msg) const;
inline QDBusMessage createErrorReply(const QDBusError &err) const
@@ -121,6 +84,7 @@ public:
QDBusMessage &operator<<(const QVariant &arg);
private:
+ explicit QDBusMessage(QDBusMessagePrivate &dd);
friend class QDBusMessagePrivate;
QDBusMessagePrivate *d_ptr;
};
@@ -132,7 +96,7 @@ Q_DBUS_EXPORT QDebug operator<<(QDebug, const QDBusMessage &);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDBusMessage)
+QT_DECL_METATYPE_EXTERN(QDBusMessage, Q_DBUS_EXPORT)
#else
class Q_DBUS_EXPORT QDBusMessage {}; // dummy class for moc
diff --git a/src/dbus/qdbusmessage_p.h b/src/dbus/qdbusmessage_p.h
index f921c33832..88ba78025e 100644
--- a/src/dbus/qdbusmessage_p.h
+++ b/src/dbus/qdbusmessage_p.h
@@ -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
#ifndef QDBUSMESSAGE_P_H
#define QDBUSMESSAGE_P_H
@@ -75,20 +39,22 @@ public:
// the following parameters are "const": they are not changed after the constructors
// the parametersValidated member below controls whether they've been validated already
+ // (service is also used to store the destination of reply-type messages)
QString service, path, interface, name, message, signature;
- DBusMessage *msg;
- DBusMessage *reply;
mutable QDBusMessage *localReply;
QAtomicInt ref;
QDBusMessage::MessageType type;
+ uint32_t serial; // if type == MethodCall; the incoming serial; if type == Reply or Error, the serial we're replying to
mutable uint delayedReply : 1;
- uint localMessage : 1;
mutable uint parametersValidated : 1;
+ uint localMessage : 1;
uint autoStartService : 1;
uint interactiveAuthorizationAllowed : 1;
+ uint isReplyRequired : 1;
+ void createResponseLink(const QDBusMessagePrivate *call);
static void setParametersValidated(QDBusMessage &msg, bool enable)
{ msg.d_ptr->parametersValidated = enable; }
diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp
index bf42736eab..543b185df9 100644
--- a/src/dbus/qdbusmetaobject.cpp
+++ b/src/dbus/qdbusmetaobject.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbusmetaobject_p.h"
@@ -59,6 +23,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
class QDBusMetaObjectGenerator
{
public:
@@ -75,22 +41,23 @@ private:
QVarLengthArray<int, 4> inputTypes;
QVarLengthArray<int, 4> outputTypes;
QByteArray rawReturnType;
- int flags;
+ quint32 flags;
};
struct Property {
QByteArray typeName;
QByteArray signature;
int type;
- int flags;
+ quint32 flags;
};
struct Type {
int id;
QByteArray name;
};
- QMap<QByteArray, Method> signals_;
- QMap<QByteArray, Method> methods;
+ using MethodMap = QMap<QByteArray, Method>;
+ MethodMap signals_;
+ MethodMap methods;
QMap<QByteArray, Property> properties;
const QDBusIntrospection::Interface *data;
@@ -104,11 +71,11 @@ private:
void parseSignals();
void parseProperties();
- static int aggregateParameterCount(const QMap<QByteArray, Method> &map);
+ static qsizetype aggregateParameterCount(const MethodMap &map);
};
-static const int intsPerProperty = 2;
-static const int intsPerMethod = 2;
+static const qsizetype intsPerProperty = 2;
+static const qsizetype intsPerMethod = 2;
struct QDBusMetaObjectPrivate : public QMetaObjectPrivate
{
@@ -144,8 +111,8 @@ static int registerComplexDBusType(const QByteArray &typeName)
{}
};
- static QBasicMutex mutex;
- static struct Hash : QHash<QByteArray, QMetaType>
+ Q_CONSTINIT static QBasicMutex mutex;
+ Q_CONSTINIT static struct Hash : QHash<QByteArray, QMetaType>
{
~Hash()
{
@@ -177,11 +144,12 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
QString annotationName = QString::fromLatin1("org.qtproject.QtDBus.QtTypeName");
if (id >= 0)
annotationName += QString::fromLatin1(".%1%2")
- .arg(QLatin1String(direction))
+ .arg(QLatin1StringView(direction))
.arg(id);
// extract from annotations:
- QByteArray typeName = annotations.value(annotationName).toLatin1();
+ auto annotation = annotations.value(annotationName);
+ QByteArray typeName = annotation.value.toLatin1();
// verify that it's a valid one
if (typeName.isEmpty()) {
@@ -189,9 +157,10 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
annotationName = QString::fromLatin1("com.trolltech.QtDBus.QtTypeName");
if (id >= 0)
annotationName += QString::fromLatin1(".%1%2")
- .arg(QLatin1String(direction))
+ .arg(QLatin1StringView(direction))
.arg(id);
- typeName = annotations.value(annotationName).toLatin1();
+ annotation = annotations.value(annotationName);
+ typeName = annotation.value.toLatin1();
}
if (!typeName.isEmpty()) {
@@ -242,10 +211,7 @@ void QDBusMetaObjectGenerator::parseMethods()
// Add cloned methods when the remote object has return types
//
- QDBusIntrospection::Methods::ConstIterator method_it = data->methods.constBegin();
- QDBusIntrospection::Methods::ConstIterator method_end = data->methods.constEnd();
- for ( ; method_it != method_end; ++method_it) {
- const QDBusIntrospection::Method &m = *method_it;
+ for (const QDBusIntrospection::Method &m : std::as_const(data->methods)) {
Method mm;
mm.name = m.name.toLatin1();
@@ -255,7 +221,7 @@ void QDBusMetaObjectGenerator::parseMethods()
bool ok = true;
// build the input argument list
- for (int i = 0; i < m.inputArgs.count(); ++i) {
+ for (qsizetype i = 0; i < m.inputArgs.size(); ++i) {
const QDBusIntrospection::Argument &arg = m.inputArgs.at(i);
Type type = findType(arg.type.toLatin1(), m.annotations, "In", i);
@@ -274,7 +240,7 @@ void QDBusMetaObjectGenerator::parseMethods()
if (!ok) continue;
// build the output argument list:
- for (int i = 0; i < m.outputArgs.count(); ++i) {
+ for (qsizetype i = 0; i < m.outputArgs.size(); ++i) {
const QDBusIntrospection::Argument &arg = m.outputArgs.at(i);
Type type = findType(arg.type.toLatin1(), m.annotations, "Out", i);
@@ -300,12 +266,12 @@ void QDBusMetaObjectGenerator::parseMethods()
// convert the last commas:
if (!mm.parameterNames.isEmpty())
- prototype[prototype.length() - 1] = ')';
+ prototype[prototype.size() - 1] = ')';
else
prototype.append(')');
// check the async tag
- if (m.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true"))
+ if (m.annotations.value(ANNOTATION_NO_WAIT ""_L1).value == "true"_L1)
mm.tag = "Q_NOREPLY";
// meta method flags
@@ -318,10 +284,7 @@ void QDBusMetaObjectGenerator::parseMethods()
void QDBusMetaObjectGenerator::parseSignals()
{
- QDBusIntrospection::Signals::ConstIterator signal_it = data->signals_.constBegin();
- QDBusIntrospection::Signals::ConstIterator signal_end = data->signals_.constEnd();
- for ( ; signal_it != signal_end; ++signal_it) {
- const QDBusIntrospection::Signal &s = *signal_it;
+ for (const QDBusIntrospection::Signal &s : std::as_const(data->signals_)) {
Method mm;
mm.name = s.name.toLatin1();
@@ -331,7 +294,7 @@ void QDBusMetaObjectGenerator::parseSignals()
bool ok = true;
// build the output argument list
- for (int i = 0; i < s.outputArgs.count(); ++i) {
+ for (qsizetype i = 0; i < s.outputArgs.size(); ++i) {
const QDBusIntrospection::Argument &arg = s.outputArgs.at(i);
Type type = findType(arg.type.toLatin1(), s.annotations, "Out", i);
@@ -351,7 +314,7 @@ void QDBusMetaObjectGenerator::parseSignals()
// convert the last commas:
if (!mm.parameterNames.isEmpty())
- prototype[prototype.length() - 1] = ')';
+ prototype[prototype.size() - 1] = ')';
else
prototype.append(')');
@@ -365,10 +328,7 @@ void QDBusMetaObjectGenerator::parseSignals()
void QDBusMetaObjectGenerator::parseProperties()
{
- QDBusIntrospection::Properties::ConstIterator prop_it = data->properties.constBegin();
- QDBusIntrospection::Properties::ConstIterator prop_end = data->properties.constEnd();
- for ( ; prop_it != prop_end; ++prop_it) {
- const QDBusIntrospection::Property &p = *prop_it;
+ for (const QDBusIntrospection::Property &p : std::as_const(data->properties)) {
Property mp;
Type type = findType(p.type.toLatin1(), p.annotations);
if (type.id == QMetaType::UnknownType)
@@ -394,14 +354,11 @@ void QDBusMetaObjectGenerator::parseProperties()
// Returns the sum of all parameters (including return type) for the given
// \a map of methods. This is needed for calculating the size of the methods'
// parameter type/name meta-data.
-int QDBusMetaObjectGenerator::aggregateParameterCount(const QMap<QByteArray, Method> &map)
+qsizetype QDBusMetaObjectGenerator::aggregateParameterCount(const MethodMap &map)
{
- int sum = 0;
- QMap<QByteArray, Method>::const_iterator it;
- for (it = map.constBegin(); it != map.constEnd(); ++it) {
- const Method &m = it.value();
+ qsizetype sum = 0;
+ for (const Method &m : map)
sum += m.inputTypes.size() + qMax(qsizetype(1), m.outputTypes.size());
- }
return sum;
}
@@ -411,61 +368,67 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
// with a few modifications to make it cleaner
QString className = interface;
- className.replace(QLatin1Char('.'), QLatin1String("::"));
+ className.replace(u'.', "::"_L1);
if (className.isEmpty())
- className = QLatin1String("QDBusInterface");
+ className = "QDBusInterface"_L1;
- QVarLengthArray<int> idata;
- idata.resize(sizeof(QDBusMetaObjectPrivate) / sizeof(int));
+ QVarLengthArray<uint> idata;
+ idata.resize(sizeof(QDBusMetaObjectPrivate) / sizeof(uint));
- int methodParametersDataSize =
+ qsizetype methodParametersDataSize =
((aggregateParameterCount(signals_)
+ aggregateParameterCount(methods)) * 2) // types and parameter names
- - signals_.count() // return "parameters" don't have names
- - methods.count(); // ditto
+ - signals_.size() // return "parameters" don't have names
+ - methods.size(); // ditto
QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data());
- static_assert(QMetaObjectPrivate::OutputRevision == 10, "QtDBus meta-object generator should generate the same version as moc");
+ static_assert(QMetaObjectPrivate::OutputRevision == 12, "QtDBus meta-object generator should generate the same version as moc");
header->revision = QMetaObjectPrivate::OutputRevision;
header->className = 0;
header->classInfoCount = 0;
header->classInfoData = 0;
- header->methodCount = signals_.count() + methods.count();
- header->methodData = idata.size();
- header->propertyCount = properties.count();
- header->propertyData = header->methodData + header->methodCount * QMetaObjectPrivate::IntsPerMethod + methodParametersDataSize;
+ header->methodCount = int(signals_.size() + methods.size());
+ header->methodData = int(idata.size());
+ header->propertyCount = int(properties.size());
+ header->propertyData = int(header->methodData + header->methodCount *
+ QMetaObjectPrivate::IntsPerMethod + methodParametersDataSize);
header->enumeratorCount = 0;
header->enumeratorData = 0;
header->constructorCount = 0;
header->constructorData = 0;
header->flags = RequiresVariantMetaObject;
- header->signalCount = signals_.count();
+ header->signalCount = signals_.size();
// These are specific to QDBusMetaObject:
- header->propertyDBusData = header->propertyData + header->propertyCount * QMetaObjectPrivate::IntsPerProperty;
- header->methodDBusData = header->propertyDBusData + header->propertyCount * intsPerProperty;
+ header->propertyDBusData = int(header->propertyData + header->propertyCount
+ * QMetaObjectPrivate::IntsPerProperty);
+ header->methodDBusData = int(header->propertyDBusData + header->propertyCount * intsPerProperty);
- int data_size = idata.size() +
+ qsizetype data_size = idata.size() +
(header->methodCount * (QMetaObjectPrivate::IntsPerMethod+intsPerMethod)) + methodParametersDataSize +
(header->propertyCount * (QMetaObjectPrivate::IntsPerProperty+intsPerProperty));
- for (const Method &mm : qAsConst(signals_))
- data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count();
- for (const Method &mm : qAsConst(methods))
- data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count();
+
+ // Signals must be added before other methods, to match moc.
+ std::array<std::reference_wrapper<const MethodMap>, 2> methodMaps = { signals_, methods };
+
+ for (const auto &methodMap : methodMaps) {
+ for (const Method &mm : methodMap.get())
+ data_size += 2 + mm.inputTypes.size() + mm.outputTypes.size();
+ }
idata.resize(data_size + 1);
QMetaStringTable strings(className.toLatin1());
- int offset = header->methodData;
- int parametersOffset = offset + header->methodCount * QMetaObjectPrivate::IntsPerMethod;
- int signatureOffset = header->methodDBusData;
- int typeidOffset = header->methodDBusData + header->methodCount * intsPerMethod;
+ qsizetype offset = header->methodData;
+ qsizetype parametersOffset = offset + header->methodCount * QMetaObjectPrivate::IntsPerMethod;
+ qsizetype signatureOffset = header->methodDBusData;
+ qsizetype typeidOffset = header->methodDBusData + header->methodCount * intsPerMethod;
idata[typeidOffset++] = 0; // eod
- int totalMetaTypeCount = properties.count();
+ qsizetype totalMetaTypeCount = properties.size();
++totalMetaTypeCount; // + 1 for metatype of dynamic metaobject
- for (const auto& methodContainer: {signals_, methods}) {
- for (const auto& method: methodContainer) {
- int argc = method.inputTypes.size() + qMax(qsizetype(0), method.outputTypes.size() - 1);
+ for (const auto &methodMap : methodMaps) {
+ for (const Method &mm : methodMap.get()) {
+ qsizetype argc = mm.inputTypes.size() + qMax(qsizetype(0), mm.outputTypes.size() - 1);
totalMetaTypeCount += argc + 1;
}
}
@@ -473,15 +436,11 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
int propertyId = 0;
// add each method:
- int currentMethodMetaTypeOffset = properties.count() + 1;
- for (int x = 0; x < 2; ++x) {
- // Signals must be added before other methods, to match moc.
- QMap<QByteArray, Method> &map = (x == 0) ? signals_ : methods;
- for (QMap<QByteArray, Method>::ConstIterator it = map.constBegin();
- it != map.constEnd(); ++it) {
- const Method &mm = it.value();
+ qsizetype currentMethodMetaTypeOffset = properties.size() + 1;
- int argc = mm.inputTypes.size() + qMax(qsizetype(0), mm.outputTypes.size() - 1);
+ for (const auto &methodMap : methodMaps) {
+ for (const Method &mm : methodMap.get()) {
+ qsizetype argc = mm.inputTypes.size() + qMax(qsizetype(0), mm.outputTypes.size() - 1);
idata[offset++] = strings.enter(mm.name);
idata[offset++] = argc;
@@ -491,7 +450,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
idata[offset++] = currentMethodMetaTypeOffset;
// Parameter types
- for (int i = -1; i < argc; ++i) {
+ for (qsizetype i = -1; i < argc; ++i) {
int type;
QByteArray typeName;
if (i < 0) { // Return type
@@ -511,29 +470,29 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
// Output parameters are references; type id not available
typeName = QMetaType(type).name();
typeName.append('&');
+ type = QMetaType::UnknownType;
}
- Q_ASSERT(type != QMetaType::UnknownType);
int typeInfo;
if (!typeName.isEmpty())
typeInfo = IsUnresolvedType | strings.enter(typeName);
else
typeInfo = type;
- metaTypes[currentMethodMetaTypeOffset++] = QMetaType (type);
+ metaTypes[currentMethodMetaTypeOffset++] = QMetaType(type);
idata[parametersOffset++] = typeInfo;
}
// Parameter names
- for (int i = 0; i < argc; ++i)
+ for (qsizetype i = 0; i < argc; ++i)
idata[parametersOffset++] = strings.enter(mm.parameterNames.at(i));
idata[signatureOffset++] = typeidOffset;
- idata[typeidOffset++] = mm.inputTypes.count();
- memcpy(idata.data() + typeidOffset, mm.inputTypes.data(), mm.inputTypes.count() * sizeof(int));
- typeidOffset += mm.inputTypes.count();
+ idata[typeidOffset++] = mm.inputTypes.size();
+ memcpy(idata.data() + typeidOffset, mm.inputTypes.data(), mm.inputTypes.size() * sizeof(uint));
+ typeidOffset += mm.inputTypes.size();
idata[signatureOffset++] = typeidOffset;
- idata[typeidOffset++] = mm.outputTypes.count();
- memcpy(idata.data() + typeidOffset, mm.outputTypes.data(), mm.outputTypes.count() * sizeof(int));
- typeidOffset += mm.outputTypes.count();
+ idata[typeidOffset++] = mm.outputTypes.size();
+ memcpy(idata.data() + typeidOffset, mm.outputTypes.data(), mm.outputTypes.size() * sizeof(uint));
+ typeidOffset += mm.outputTypes.size();
}
}
@@ -546,12 +505,9 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
// add each property
signatureOffset = header->propertyDBusData;
- for (QMap<QByteArray, Property>::ConstIterator it = properties.constBegin();
- it != properties.constEnd(); ++it) {
- const Property &mp = it.value();
-
+ for (const auto &[name, mp] : std::as_const(properties).asKeyValueRange()) {
// form is name, typeinfo, flags
- idata[offset++] = strings.enter(it.key()); // name
+ idata[offset++] = strings.enter(name);
Q_ASSERT(mp.type != QMetaType::UnknownType);
idata[offset++] = mp.type;
idata[offset++] = mp.flags;
@@ -572,7 +528,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
strings.writeBlob(string_data);
uint *uint_data = new uint[idata.size()];
- memcpy(uint_data, idata.data(), idata.size() * sizeof(int));
+ memcpy(uint_data, idata.data(), idata.size() * sizeof(uint));
// put the metaobject together
obj->d.data = uint_data;
@@ -589,7 +545,7 @@ void QDBusMetaObjectGenerator::writeWithoutXml(const QString &interface)
{
// no XML definition
QString tmp(interface);
- tmp.replace(QLatin1Char('.'), QLatin1String("::"));
+ tmp.replace(u'.', "::"_L1);
QByteArray name(tmp.toLatin1());
QDBusMetaObjectPrivate *header = new QDBusMetaObjectPrivate;
@@ -628,13 +584,13 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con
bool us = it.key() == interface;
QDBusMetaObject *obj = cache.value(it.key(), 0);
- if ( !obj && ( us || !interface.startsWith( QLatin1String("local.") ) ) ) {
+ if (!obj && (us || !interface.startsWith("local."_L1 ))) {
// not in cache; create
obj = new QDBusMetaObject;
QDBusMetaObjectGenerator generator(it.key(), it.value().constData());
generator.write(obj);
- if ( (obj->cached = !it.key().startsWith( QLatin1String("local.") )) )
+ if ((obj->cached = !it.key().startsWith("local."_L1)))
// cache it
cache.insert(it.key(), obj);
else if (!us)
@@ -670,7 +626,7 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con
merged.properties.insert(it.value()->properties);
}
- merged.name = QLatin1String("local.Merged");
+ merged.name = "local.Merged"_L1;
merged.introspection.clear();
we = new QDBusMetaObject;
@@ -682,8 +638,7 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con
// mark as an error
error = QDBusError(QDBusError::UnknownInterface,
- QLatin1String("Interface '%1' was not found")
- .arg(interface));
+ "Interface '%1' was not found"_L1.arg(interface));
return nullptr;
}
diff --git a/src/dbus/qdbusmetaobject_p.h b/src/dbus/qdbusmetaobject_p.h
index a4ed3c355c..97d16d99d0 100644
--- a/src/dbus/qdbusmetaobject_p.h
+++ b/src/dbus/qdbusmetaobject_p.h
@@ -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
#ifndef QDBUSMETAOBJECT_P_H
#define QDBUSMETAOBJECT_P_H
diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp
index 2d0324d9cb..3ae7589480 100644
--- a/src/dbus/qdbusmetatype.cpp
+++ b/src/dbus/qdbusmetatype.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 "qdbusmetatype.h"
#include "qdbusmetatype_p.h"
@@ -84,19 +48,19 @@ public:
void QDBusMetaTypeId::init()
{
- static QBasicAtomicInt initialized = Q_BASIC_ATOMIC_INITIALIZER(false);
+ Q_CONSTINIT static QBasicAtomicInt initialized = Q_BASIC_ATOMIC_INITIALIZER(false);
// reentrancy is not a problem since everything else is locked on their own
// set the guard variable at the end
if (!initialized.loadRelaxed()) {
- // register our types with Qt Core (calling qMetaTypeId<T>() does this implicitly)
- (void)message();
- (void)argument();
- (void)variant();
- (void)objectpath();
- (void)signature();
- (void)error();
- (void)unixfd();
+ // register our types with Qt Core
+ message().registerType();
+ argument().registerType();
+ variant().registerType();
+ objectpath().registerType();
+ signature().registerType();
+ error().registerType();
+ unixfd().registerType();
#ifndef QDBUS_NO_SPECIALTYPES
// and register Qt Core's with us
@@ -123,6 +87,9 @@ void QDBusMetaTypeId::init()
qDBusRegisterMetaType<QList<qlonglong> >();
qDBusRegisterMetaType<QList<qulonglong> >();
qDBusRegisterMetaType<QList<double> >();
+
+ // plus lists of our own types
+ qDBusRegisterMetaType<QList<QDBusVariant> >();
qDBusRegisterMetaType<QList<QDBusObjectPath> >();
qDBusRegisterMetaType<QList<QDBusSignature> >();
qDBusRegisterMetaType<QList<QDBusUnixFileDescriptor> >();
@@ -132,9 +99,13 @@ void QDBusMetaTypeId::init()
}
}
-using QDBusCustomTypeHash = QHash<int, QDBusCustomTypeInfo>;
-Q_GLOBAL_STATIC(QDBusCustomTypeHash, customTypes)
-Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock)
+struct QDBusCustomTypes
+{
+ QReadWriteLock lock;
+ QHash<int, QDBusCustomTypeInfo> hash;
+};
+
+Q_GLOBAL_STATIC(QDBusCustomTypes, customTypes)
/*!
\class QDBusMetaType
@@ -158,7 +129,7 @@ Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock)
*/
/*!
- \fn int qDBusRegisterMetaType()
+ \fn template<typename T> QMetaType qDBusRegisterMetaType()
\relates QDBusArgument
\threadsafe
\since 4.2
@@ -215,12 +186,15 @@ void QDBusMetaType::registerMarshallOperators(QMetaType metaType, MarshallFuncti
DemarshallFunction df)
{
int id = metaType.id();
- auto *ct = customTypes();
- if (id < 0 || !mf || !df || !ct)
+ if (id < 0 || !mf || !df)
return; // error!
- QWriteLocker locker(customTypesLock());
- QDBusCustomTypeInfo &info = (*ct)[id];
+ auto *ct = customTypes();
+ if (!ct)
+ return;
+
+ QWriteLocker locker(&ct->lock);
+ QDBusCustomTypeInfo &info = ct->hash[id];
info.marshall = mf;
info.demarshall = df;
}
@@ -233,15 +207,19 @@ void QDBusMetaType::registerMarshallOperators(QMetaType metaType, MarshallFuncti
*/
bool QDBusMetaType::marshall(QDBusArgument &arg, QMetaType metaType, const void *data)
{
+ auto *ct = customTypes();
+ if (!ct)
+ return false;
+
int id = metaType.id();
QDBusMetaTypeId::init();
MarshallFunction mf;
{
- QReadLocker locker(customTypesLock());
- auto *ct = customTypes();
- auto it = ct->constFind(id);
- if (it == ct->cend())
+ QReadLocker locker(&ct->lock);
+
+ auto it = ct->hash.constFind(id);
+ if (it == ct->hash.cend())
return false; // non-existent
const QDBusCustomTypeInfo &info = *it;
@@ -264,15 +242,19 @@ bool QDBusMetaType::marshall(QDBusArgument &arg, QMetaType metaType, const void
*/
bool QDBusMetaType::demarshall(const QDBusArgument &arg, QMetaType metaType, void *data)
{
+ auto *ct = customTypes();
+ if (!ct)
+ return false;
+
int id = metaType.id();
QDBusMetaTypeId::init();
DemarshallFunction df;
{
- QReadLocker locker(customTypesLock());
- auto *ct = customTypes();
- auto it = ct->constFind(id);
- if (it == ct->cend())
+ QReadLocker locker(&ct->lock);
+
+ auto it = ct->hash.constFind(id);
+ if (it == ct->hash.cend())
return false; // non-existent
const QDBusCustomTypeInfo &info = *it;
@@ -390,8 +372,11 @@ QMetaType QDBusMetaType::signatureToMetaType(const char *signature)
void QDBusMetaType::registerCustomType(QMetaType type, const QByteArray &signature)
{
auto *ct = customTypes();
- QWriteLocker locker(customTypesLock());
- auto &info = (*ct)[type.id()];
+ if (!ct)
+ return;
+
+ QWriteLocker locker(&ct->lock);
+ auto &info = ct->hash[type.id()];
info.signature = signature;
// note how marshall/demarshall are not set, the type is never used at runtime
}
@@ -463,10 +448,13 @@ const char *QDBusMetaType::typeToSignature(QMetaType type)
// try the database
auto *ct = customTypes();
+ if (!ct)
+ return nullptr;
+
{
- QReadLocker locker(customTypesLock());
- auto it = ct->constFind(type.id());
- if (it == ct->end())
+ QReadLocker locker(&ct->lock);
+ auto it = ct->hash.constFind(type.id());
+ if (it == ct->hash.end())
return nullptr;
const QDBusCustomTypeInfo &info = *it;
@@ -483,11 +471,11 @@ const char *QDBusMetaType::typeToSignature(QMetaType type)
{
// createSignature will never return a null QByteArray
// if there was an error, it'll return ""
- QByteArray signature = QDBusArgumentPrivate::createSignature(type.id());
+ QByteArray signature = QDBusArgumentPrivate::createSignature(type);
// re-acquire lock
- QWriteLocker locker(customTypesLock());
- info = &(*ct)[type.id()];
+ QWriteLocker locker(&ct->lock);
+ info = &ct->hash[type.id()];
info->signature = signature;
}
return info->signature;
diff --git a/src/dbus/qdbusmetatype.h b/src/dbus/qdbusmetatype.h
index 3cce56ce85..3304a69e1e 100644
--- a/src/dbus/qdbusmetatype.h
+++ b/src/dbus/qdbusmetatype.h
@@ -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
#ifndef QDBUSMETATYPE_H
#define QDBUSMETATYPE_H
diff --git a/src/dbus/qdbusmetatype_p.h b/src/dbus/qdbusmetatype_p.h
index 71a621b059..86a59f587d 100644
--- a/src/dbus/qdbusmetatype_p.h
+++ b/src/dbus/qdbusmetatype_p.h
@@ -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
#ifndef QDBUSMETATYPE_P_H
#define QDBUSMETATYPE_P_H
@@ -64,18 +28,17 @@
QT_BEGIN_NAMESPACE
-struct QDBusMetaTypeId
-{
- static QMetaType message(); // QDBusMessage
- static QMetaType argument(); // QDBusArgument
- static QMetaType variant(); // QDBusVariant
- static QMetaType objectpath(); // QDBusObjectPath
- static QMetaType signature(); // QDBusSignature
- static QMetaType error(); // QDBusError
- static QMetaType unixfd(); // QDBusUnixFileDescriptor
-
- static void init();
-};
+namespace QDBusMetaTypeId {
+QMetaType message(); // QDBusMessage
+QMetaType argument(); // QDBusArgument
+QMetaType variant(); // QDBusVariant
+QMetaType objectpath(); // QDBusObjectPath
+QMetaType signature(); // QDBusSignature
+QMetaType error(); // QDBusError
+QMetaType unixfd(); // QDBusUnixFileDescriptor
+
+Q_DBUS_EXPORT void init();
+}; // namespace QDBusMetaTypeId
inline QMetaType QDBusMetaTypeId::message()
{ return QMetaType::fromType<QDBusMessage>(); }
diff --git a/src/dbus/qdbusmisc.cpp b/src/dbus/qdbusmisc.cpp
index 29d13ca40b..635258c86d 100644
--- a/src/dbus/qdbusmisc.cpp
+++ b/src/dbus/qdbusmisc.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 <string.h>
@@ -44,6 +8,7 @@
#include <QtCore/qlist.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qvariant.h>
+#include <private/qurl_p.h>
#include "qdbusutil_p.h"
#include "qdbusconnection_p.h"
@@ -55,6 +20,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
bool qDBusCheckAsyncTag(const char *tag)
{
static const char noReplyTag[] = "Q_NOREPLY";
@@ -78,37 +45,56 @@ QString qDBusInterfaceFromMetaObject(const QMetaObject *mo)
int idx = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTERFACE);
if (idx >= mo->classInfoOffset()) {
- interface = QLatin1String(mo->classInfo(idx).value());
+ interface = QLatin1StringView(mo->classInfo(idx).value());
} else {
- interface = QLatin1String(mo->className());
- interface.replace(QLatin1String("::"), QLatin1String("."));
+ interface = QLatin1StringView(mo->className());
+ interface.replace("::"_L1, "."_L1);
- if (interface.startsWith(QLatin1String("QDBus"))) {
- interface.prepend(QLatin1String("org.qtproject.QtDBus."));
- } else if (interface.startsWith(QLatin1Char('Q')) &&
- interface.length() >= 2 && interface.at(1).isUpper()) {
+ if (interface.startsWith("QDBus"_L1)) {
+ interface.prepend("org.qtproject.QtDBus."_L1);
+ } else if (interface.startsWith(u'Q') &&
+ interface.size() >= 2 && interface.at(1).isUpper()) {
// assume it's Qt
- interface.prepend(QLatin1String("org.qtproject.Qt."));
+ interface.prepend("org.qtproject.Qt."_L1);
} else if (!QCoreApplication::instance()||
QCoreApplication::instance()->applicationName().isEmpty()) {
- interface.prepend(QLatin1String("local."));
- } else {
- interface.prepend(QLatin1Char('.')).prepend(QCoreApplication::instance()->applicationName());
+ interface.prepend("local."_L1);
+ } else {
+ QString domainName = QCoreApplication::instance()->applicationName();
const QString organizationDomain = QCoreApplication::instance()->organizationDomain();
- const auto domainName = QStringView{organizationDomain}.split(QLatin1Char('.'), Qt::SkipEmptyParts);
- if (domainName.isEmpty()) {
- interface.prepend(QLatin1String("local."));
- } else {
- QString composedDomain;
- // + 1 for additional dot, e.g. organizationDomain equals "example.com",
- // then composedDomain will be equal "com.example."
- composedDomain.reserve(organizationDomain.size() + 1);
- for (auto it = domainName.rbegin(), end = domainName.rend(); it != end; ++it)
- composedDomain += *it + QLatin1Char('.');
-
- interface.prepend(composedDomain);
+ if (organizationDomain.isEmpty())
+ domainName.append(".local"_L1);
+ else
+ domainName.append(u'.').append(organizationDomain);
+
+ // Domain names used to produce interface names should be IDN-encoded.
+ QString encodedDomainName = qt_ACE_do(domainName, ToAceOnly, ForbidLeadingDot);
+ if (encodedDomainName.isEmpty()) {
+ interface.prepend("local."_L1);
+ return interface;
+ }
+
+ // Hyphens are not allowed in interface names and should be replaced
+ // by underscores.
+ encodedDomainName.replace(u'-', u'_');
+
+ auto nameParts = QStringView{ encodedDomainName }.split(u'.', Qt::SkipEmptyParts);
+
+ QString composedDomain;
+ // + 1 for additional dot, e.g. domainName equals "App.example.com",
+ // then composedDomain will be equal "com.example.App."
+ composedDomain.reserve(encodedDomainName.size() + nameParts.size() + 1);
+ for (auto it = nameParts.rbegin(), end = nameParts.rend(); it != end; ++it) {
+ // An interface name cannot start with a digit, and cannot
+ // contain digits immediately following a period. Prefix such
+ // digits with underscores.
+ if (it->first().isDigit())
+ composedDomain += u'_';
+ composedDomain += *it + u'.';
}
- }
+
+ interface.prepend(composedDomain);
+ }
}
return interface;
@@ -137,7 +123,19 @@ bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name)
// sig must be the normalised signature for the method
int qDBusParametersForMethod(const QMetaMethod &mm, QList<QMetaType> &metaTypes, QString &errorMsg)
{
- return qDBusParametersForMethod(mm.parameterTypes(), metaTypes, errorMsg);
+ QList<QByteArray> parameterTypes;
+ parameterTypes.reserve(mm.parameterCount());
+
+ // Not using QMetaMethod::parameterTypes() since we call QMetaType::fromName below
+ // where we need any typedefs resolved already.
+ for (int i = 0; i < mm.parameterCount(); ++i) {
+ QByteArray typeName = mm.parameterMetaType(i).name();
+ if (typeName.isEmpty())
+ typeName = mm.parameterTypeName(i);
+ parameterTypes.append(typeName);
+ }
+
+ return qDBusParametersForMethod(parameterTypes, metaTypes, errorMsg);
}
#endif // QT_BOOTSTRAPPED
@@ -151,22 +149,19 @@ int qDBusParametersForMethod(const QList<QByteArray> &parameterTypes, QList<QMet
metaTypes.append(QMetaType()); // return type
int inputCount = 0;
bool seenMessage = false;
- QList<QByteArray>::ConstIterator it = parameterTypes.constBegin();
- QList<QByteArray>::ConstIterator end = parameterTypes.constEnd();
- for ( ; it != end; ++it) {
- QByteArray type = *it;
+ for (QByteArray type : parameterTypes) {
if (type.endsWith('*')) {
- errorMsg = QLatin1String("Pointers are not supported: ") + QLatin1String(type);
+ errorMsg = "Pointers are not supported: "_L1 + QLatin1StringView(type);
return -1;
}
if (type.endsWith('&')) {
QByteArray basictype = type;
- basictype.truncate(type.length() - 1);
+ basictype.truncate(type.size() - 1);
QMetaType id = QMetaType::fromName(basictype);
if (!id.isValid()) {
- errorMsg = QLatin1String("Unregistered output type in parameter list: ") + QLatin1String(type);
+ errorMsg = "Unregistered output type in parameter list: "_L1 + QLatin1StringView(type);
return -1;
} else if (QDBusMetaType::typeToSignature(id) == nullptr)
return -1;
@@ -177,7 +172,7 @@ int qDBusParametersForMethod(const QList<QByteArray> &parameterTypes, QList<QMet
}
if (seenMessage) { // && !type.endsWith('&')
- errorMsg = QLatin1String("Invalid method, non-output parameters after message or after output parameters: ") + QLatin1String(type);
+ errorMsg = "Invalid method, non-output parameters after message or after output parameters: "_L1 + QLatin1StringView(type);
return -1; // not allowed
}
@@ -193,14 +188,14 @@ int qDBusParametersForMethod(const QList<QByteArray> &parameterTypes, QList<QMet
#endif
if (!id.isValid()) {
- errorMsg = QLatin1String("Unregistered input type in parameter list: ") + QLatin1String(type);
+ errorMsg = "Unregistered input type in parameter list: "_L1 + QLatin1StringView(type);
return -1;
}
if (id == QDBusMetaTypeId::message())
seenMessage = true;
else if (QDBusMetaType::typeToSignature(id) == nullptr) {
- errorMsg = QLatin1String("Type not registered with QtDBus in parameter list: ") + QLatin1String(type);
+ errorMsg = "Type not registered with QtDBus in parameter list: "_L1 + QLatin1StringView(type);
return -1;
}
diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp
index 74aa1629fa..f9d414d1bd 100644
--- a/src/dbus/qdbuspendingcall.cpp
+++ b/src/dbus/qdbuspendingcall.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbuspendingcall.h"
#include "qdbuspendingcall_p.h"
@@ -53,6 +17,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\class QDBusPendingCall
\inmodule QtDBus
@@ -128,7 +94,8 @@ QT_BEGIN_NAMESPACE
void QDBusPendingCallWatcherHelper::add(QDBusPendingCallWatcher *watcher)
{
- connect(this, SIGNAL(finished()), watcher, SLOT(_q_finished()), Qt::QueuedConnection);
+ connect(this, &QDBusPendingCallWatcherHelper::finished, watcher,
+ [watcher] { Q_EMIT watcher->finished(watcher); }, Qt::QueuedConnection);
}
QDBusPendingCallPrivate::~QDBusPendingCallPrivate()
@@ -157,22 +124,24 @@ bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *memb
return false;
}
- methodIdx = QDBusConnectionPrivate::findSlot(target, member + 1, metaTypes);
+ QString errorMsg;
+ methodIdx = QDBusConnectionPrivate::findSlot(target, member + 1, metaTypes, errorMsg);
if (methodIdx == -1) {
QByteArray normalizedName = QMetaObject::normalizedSignature(member + 1);
- methodIdx = QDBusConnectionPrivate::findSlot(target, normalizedName, metaTypes);
+ methodIdx = QDBusConnectionPrivate::findSlot(target, normalizedName, metaTypes, errorMsg);
}
if (methodIdx == -1) {
// would not be able to deliver a reply
- qWarning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)",
- target->metaObject()->className(),
- member + 1, qPrintable(target->objectName()));
+ qWarning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s) "
+ "because %s",
+ target->metaObject()->className(), member + 1, qPrintable(target->objectName()),
+ qPrintable(errorMsg));
return false;
}
// success
// construct the expected signature
- int count = metaTypes.count() - 1;
+ int count = metaTypes.size() - 1;
if (count == 1 && metaTypes.at(1) == QDBusMetaTypeId::message()) {
// wildcard slot, can receive anything, so don't set the signature
return true;
@@ -188,7 +157,7 @@ bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *memb
void QDBusPendingCallPrivate::setMetaTypes(int count, const QMetaType *types)
{
if (count == 0) {
- expectedReplySignature = QLatin1String(""); // not null
+ expectedReplySignature = ""_L1; // not null
return;
}
@@ -219,8 +188,7 @@ void QDBusPendingCallPrivate::checkReceivedSignature()
// can't use startsWith here because a null string doesn't start or end with an empty string
if (replyMessage.signature().indexOf(expectedReplySignature) != 0) {
- const auto errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", "
- "expected \"%2\"");
+ const auto errorMsg = "Unexpected reply signature: got \"%1\", expected \"%2\""_L1;
replyMessage = QDBusMessage::createError(
QDBusError::InvalidSignature,
errorMsg.arg(replyMessage.signature(), expectedReplySignature));
@@ -238,6 +206,26 @@ void QDBusPendingCallPrivate::waitForFinished()
waitForFinishedCondition.wait(&mutex);
}
+void QDBusPendingCallPrivate::waitForFinishedWithGui()
+{
+ QEventLoop loop;
+
+ {
+ const auto locker = qt_scoped_lock(mutex);
+ if (replyMessage.type() != QDBusMessage::InvalidMessage)
+ return; // already finished
+
+ Q_ASSERT(!watcherHelper);
+ watcherHelper = new QDBusPendingCallWatcherHelper;
+ loop.connect(watcherHelper, &QDBusPendingCallWatcherHelper::reply, &loop,
+ &QEventLoop::quit);
+ loop.connect(watcherHelper, &QDBusPendingCallWatcherHelper::error, &loop,
+ &QEventLoop::quit);
+ }
+
+ loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
+}
+
/*!
Creates a copy of the \a other pending asynchronous call. Note
that both objects will refer to the same pending call.
@@ -256,7 +244,6 @@ QDBusPendingCall::QDBusPendingCall(QDBusPendingCallPrivate *dd)
if (dd) {
bool r = dd->ref.deref();
Q_ASSERT(r);
- Q_UNUSED(r);
}
}
@@ -478,28 +465,13 @@ QDBusPendingCall QDBusPendingCall::fromCompletedCall(const QDBusMessage &msg)
return QDBusPendingCall(d);
}
-
-class QDBusPendingCallWatcherPrivate: public QObjectPrivate
-{
-public:
- void _q_finished();
-
- Q_DECLARE_PUBLIC(QDBusPendingCallWatcher)
-};
-
-inline void QDBusPendingCallWatcherPrivate::_q_finished()
-{
- Q_Q(QDBusPendingCallWatcher);
- emit q->finished(q);
-}
-
/*!
Creates a QDBusPendingCallWatcher object to watch for replies on the
asynchronous pending call \a call and sets this object's parent
to \a parent.
*/
QDBusPendingCallWatcher::QDBusPendingCallWatcher(const QDBusPendingCall &call, QObject *parent)
- : QObject(*new QDBusPendingCallWatcherPrivate, parent), QDBusPendingCall(call)
+ : QObject(parent), QDBusPendingCall(call)
{
if (d) { // QDBusPendingCall::d
const auto locker = qt_scoped_lock(d->mutex);
@@ -507,7 +479,9 @@ QDBusPendingCallWatcher::QDBusPendingCallWatcher(const QDBusPendingCall &call, Q
d->watcherHelper = new QDBusPendingCallWatcherHelper;
if (d->replyMessage.type() != QDBusMessage::InvalidMessage) {
// cause a signal emission anyways
- QMetaObject::invokeMethod(d->watcherHelper, "finished", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(d->watcherHelper,
+ &QDBusPendingCallWatcherHelper::finished,
+ Qt::QueuedConnection);
}
}
d->watcherHelper->add(this);
@@ -545,6 +519,8 @@ void QDBusPendingCallWatcher::waitForFinished()
}
QT_END_NAMESPACE
+#include "moc_qdbuspendingcall_p.cpp"
+
#endif // QT_NO_DBUS
#include "moc_qdbuspendingcall.cpp"
diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h
index dd99346301..c276376223 100644
--- a/src/dbus/qdbuspendingcall.h
+++ b/src/dbus/qdbuspendingcall.h
@@ -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
#ifndef QDBUSPENDINGCALL_H
#define QDBUSPENDINGCALL_H
@@ -63,9 +27,9 @@ public:
QDBusPendingCall &operator=(QDBusPendingCall &&other) noexcept { swap(other); return *this; }
QDBusPendingCall &operator=(const QDBusPendingCall &other);
- void swap(QDBusPendingCall &other) noexcept { qSwap(d, other.d); }
+ void swap(QDBusPendingCall &other) noexcept { d.swap(other.d); }
-#ifndef Q_CLANG_QDOC
+#ifndef Q_QDOC
// pretend that they aren't here
bool isFinished() const;
void waitForFinished();
@@ -93,7 +57,6 @@ private:
Q_DECLARE_SHARED(QDBusPendingCall)
-class QDBusPendingCallWatcherPrivate;
class Q_DBUS_EXPORT QDBusPendingCallWatcher: public QObject, public QDBusPendingCall
{
Q_OBJECT
@@ -109,10 +72,6 @@ public:
Q_SIGNALS:
void finished(QDBusPendingCallWatcher *self = nullptr);
-
-private:
- Q_DECLARE_PRIVATE(QDBusPendingCallWatcher)
- Q_PRIVATE_SLOT(d_func(), void _q_finished())
};
QT_END_NAMESPACE
diff --git a/src/dbus/qdbuspendingcall_p.h b/src/dbus/qdbuspendingcall_p.h
index 8d53b0e665..2795cc3ecf 100644
--- a/src/dbus/qdbuspendingcall_p.h
+++ b/src/dbus/qdbuspendingcall_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
@@ -104,10 +68,9 @@ public:
~QDBusPendingCallPrivate();
bool setReplyCallback(QObject *target, const char *member);
void waitForFinished();
+ void waitForFinishedWithGui();
void setMetaTypes(int count, const QMetaType *types);
void checkReceivedSignature();
-
- static QDBusPendingCall fromMessage(const QDBusMessage &msg);
};
class QDBusPendingCallWatcherHelper: public QObject
diff --git a/src/dbus/qdbuspendingreply.cpp b/src/dbus/qdbuspendingreply.cpp
index 2eb2526160..fef68579d3 100644
--- a/src/dbus/qdbuspendingreply.cpp
+++ b/src/dbus/qdbuspendingreply.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbuspendingreply.h"
#include "qdbuspendingcall_p.h"
diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h
index 5cea314dd9..580b967b3b 100644
--- a/src/dbus/qdbuspendingreply.h
+++ b/src/dbus/qdbuspendingreply.h
@@ -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
#ifndef QDBUSPENDINGREPLY_H
#define QDBUSPENDINGREPLY_H
@@ -117,7 +81,7 @@ public:
return qdbus_cast<ResultType>(argumentAt(Index));
}
-#if defined(Q_CLANG_QDOC)
+#if defined(Q_QDOC)
bool isFinished() const;
void waitForFinished();
QVariant argumentAt(int index) const;
diff --git a/src/dbus/qdbusreply.cpp b/src/dbus/qdbusreply.cpp
index 1a3278ff52..5b26250b10 100644
--- a/src/dbus/qdbusreply.cpp
+++ b/src/dbus/qdbusreply.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 "qdbusreply.h"
#include "qdbusmetatype.h"
@@ -46,6 +10,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\class QDBusReply
\inmodule QtDBus
@@ -175,7 +141,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn template <typename T> QDBusReply<T>::value() const
+ \fn template <typename T> Type QDBusReply<T>::value() const
Returns the remote function's calls return value. If the remote call returned with an error,
the return value of this function is undefined and may be undistinguishable from a valid return
value.
@@ -203,7 +169,7 @@ void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data
return;
}
- if (reply.arguments().count() >= 1 && reply.arguments().at(0).metaType() == data.metaType()) {
+ if (reply.arguments().size() >= 1 && reply.arguments().at(0).metaType() == data.metaType()) {
data = reply.arguments().at(0);
return;
}
@@ -212,7 +178,7 @@ void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data
const char *receivedType = nullptr;
QByteArray receivedSignature;
- if (reply.arguments().count() >= 1) {
+ if (reply.arguments().size() >= 1) {
if (reply.arguments().at(0).metaType() == QDBusMetaTypeId::argument()) {
// compare signatures instead
QDBusArgument arg = qvariant_cast<QDBusArgument>(reply.arguments().at(0));
@@ -235,18 +201,16 @@ void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data
receivedSignature = "<empty signature>";
QString errorMsg;
if (receivedType) {
- errorMsg = QLatin1String("Unexpected reply signature: got \"%1\" (%4), "
- "expected \"%2\" (%3)")
- .arg(QLatin1String(receivedSignature),
- QLatin1String(expectedSignature),
- QLatin1String(data.typeName()),
- QLatin1String(receivedType));
+ errorMsg = "Unexpected reply signature: got \"%1\" (%4), expected \"%2\" (%3)"_L1
+ .arg(QLatin1StringView(receivedSignature),
+ QLatin1StringView(expectedSignature),
+ QLatin1StringView(data.typeName()),
+ QLatin1StringView(receivedType));
} else {
- errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", "
- "expected \"%2\" (%3)")
- .arg(QLatin1String(receivedSignature),
- QLatin1String(expectedSignature),
- QLatin1String(data.typeName()));
+ errorMsg = "Unexpected reply signature: got \"%1\", expected \"%2\" (%3)"_L1
+ .arg(QLatin1StringView(receivedSignature),
+ QLatin1StringView(expectedSignature),
+ QLatin1StringView(data.typeName()));
}
error = QDBusError(QDBusError::InvalidSignature, errorMsg);
diff --git a/src/dbus/qdbusreply.h b/src/dbus/qdbusreply.h
index 03dfe4a4f0..df488208c8 100644
--- a/src/dbus/qdbusreply.h
+++ b/src/dbus/qdbusreply.h
@@ -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
#ifndef QDBUSREPLY_H
#define QDBUSREPLY_H
diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp
index eccffc3d3e..e9131a14c4 100644
--- a/src/dbus/qdbusserver.cpp
+++ b/src/dbus/qdbusserver.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbusserver.h"
#include "qdbusconnection_p.h"
@@ -74,9 +38,8 @@ QDBusServer::QDBusServer(const QString &address, QObject *parent)
if (!instance)
return;
- emit instance->serverRequested(address, this);
- QObject::connect(d, SIGNAL(newServerConnection(QDBusConnectionPrivate*)),
- this, SLOT(_q_newConnection(QDBusConnectionPrivate*)), Qt::QueuedConnection);
+ instance->createServer(address, this);
+ Q_ASSERT(d != nullptr);
}
/*!
@@ -85,25 +48,15 @@ QDBusServer::QDBusServer(const QString &address, QObject *parent)
localhost (elsewhere).
*/
QDBusServer::QDBusServer(QObject *parent)
- : QObject(parent), d(nullptr)
-{
+ : QDBusServer(
#ifdef Q_OS_UNIX
- // Use Unix sockets on Unix systems only
- const QString address = QStringLiteral("unix:tmpdir=/tmp");
+ // Use Unix sockets on Unix systems only
+ QStringLiteral("unix:tmpdir=/tmp"),
#else
- const QString address = QStringLiteral("tcp:");
+ QStringLiteral("tcp:"),
#endif
-
- if (!qdbus_loadLibDBus())
- return;
-
- QDBusConnectionManager *instance = QDBusConnectionManager::instance();
- if (!instance)
- return;
-
- emit instance->serverRequested(address, this);
- QObject::connect(d, SIGNAL(newServerConnection(QDBusConnectionPrivate*)),
- this, SLOT(_q_newConnection(QDBusConnectionPrivate*)), Qt::QueuedConnection);
+ parent)
+{
}
/*!
@@ -111,17 +64,17 @@ QDBusServer::QDBusServer(QObject *parent)
*/
QDBusServer::~QDBusServer()
{
- QMutex *managerMutex = nullptr;
- if (QDBusConnectionManager::instance())
- managerMutex = &QDBusConnectionManager::instance()->mutex;
- QMutexLocker locker(managerMutex);
+ if (!d)
+ return;
+
+ auto manager = QDBusConnectionManager::instance();
+ if (!manager)
+ return;
+
QWriteLocker writeLocker(&d->lock);
- if (QDBusConnectionManager::instance()) {
- for (const QString &name : qAsConst(d->serverConnectionNames))
- QDBusConnectionManager::instance()->removeConnection(name);
- d->serverConnectionNames.clear();
- locker.unlock();
- }
+ manager->removeConnections(d->serverConnectionNames);
+ d->serverConnectionNames.clear();
+
d->serverObject = nullptr;
d->ref.storeRelaxed(0);
d->deleteLater();
@@ -174,6 +127,9 @@ QString QDBusServer::address() const
*/
void QDBusServer::setAnonymousAuthenticationAllowed(bool value)
{
+ if (!d)
+ return;
+
d->anonymousAuthenticationAllowed = value;
}
@@ -186,6 +142,9 @@ void QDBusServer::setAnonymousAuthenticationAllowed(bool value)
*/
bool QDBusServer::isAnonymousAuthenticationAllowed() const
{
+ if (!d)
+ return false;
+
return d->anonymousAuthenticationAllowed;
}
diff --git a/src/dbus/qdbusserver.h b/src/dbus/qdbusserver.h
index 668b8705b1..34985cc055 100644
--- a/src/dbus/qdbusserver.h
+++ b/src/dbus/qdbusserver.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QDBUSSERVER_H
#define QDBUSSERVER_H
@@ -73,7 +37,6 @@ Q_SIGNALS:
private:
Q_DISABLE_COPY(QDBusServer)
- Q_PRIVATE_SLOT(d, void _q_newConnection(QDBusConnectionPrivate*))
QDBusConnectionPrivate *d;
friend class QDBusConnectionPrivate;
};
diff --git a/src/dbus/qdbusservicewatcher.cpp b/src/dbus/qdbusservicewatcher.cpp
index 47cb4441c3..bf94f54f56 100644
--- a/src/dbus/qdbusservicewatcher.cpp
+++ b/src/dbus/qdbusservicewatcher.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 "qdbusservicewatcher.h"
#include "qdbusconnection.h"
@@ -76,10 +40,11 @@ public:
&QDBusServiceWatcherPrivate::setWatchModeForwardToQ)
void _q_serviceOwnerChanged(const QString &, const QString &, const QString &);
- void setConnection(const QStringList &services, const QDBusConnection &c, QDBusServiceWatcher::WatchMode watchMode);
+ void setConnection(const QStringList &newServices, const QDBusConnection &newConnection,
+ QDBusServiceWatcher::WatchMode newMode);
- void addService(const QString &service);
- void removeService(const QString &service);
+ void addService(const QString &service, QDBusServiceWatcher::WatchMode mode);
+ void removeService(const QString &service, QDBusServiceWatcher::WatchMode mode);
};
void QDBusServiceWatcherPrivate::_q_serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner)
@@ -92,39 +57,43 @@ void QDBusServiceWatcherPrivate::_q_serviceOwnerChanged(const QString &service,
emit q->serviceUnregistered(service);
}
-void QDBusServiceWatcherPrivate::setConnection(const QStringList &services,
- const QDBusConnection &c,
- QDBusServiceWatcher::WatchMode wm)
+void QDBusServiceWatcherPrivate::setConnection(const QStringList &newServices,
+ const QDBusConnection &newConnection,
+ QDBusServiceWatcher::WatchMode newMode)
{
+ const QStringList oldServices = watchedServicesData.valueBypassingBindings();
+ const QDBusServiceWatcher::WatchMode oldMode = watchMode.valueBypassingBindings();
if (connection.isConnected()) {
// remove older rules
- for (const QString &s : qAsConst(watchedServicesData.value()))
- removeService(s);
+ for (const QString &s : oldServices)
+ removeService(s, oldMode);
}
- connection = c;
- watchMode.setValueBypassingBindings(wm); // caller has to call notify()
- watchedServicesData.setValueBypassingBindings(services); // caller has to call notify()
+ connection = newConnection;
+ watchMode.setValueBypassingBindings(newMode); // caller has to call notify()
+ watchedServicesData.setValueBypassingBindings(newServices); // caller has to call notify()
if (connection.isConnected()) {
// add new rules
- for (const QString &s : qAsConst(watchedServicesData.value()))
- addService(s);
+ for (const QString &s : newServices)
+ addService(s, newMode);
}
}
-void QDBusServiceWatcherPrivate::addService(const QString &service)
+void QDBusServiceWatcherPrivate::addService(const QString &service,
+ QDBusServiceWatcher::WatchMode mode)
{
QDBusConnectionPrivate *d = QDBusConnectionPrivate::d(connection);
if (d && d->shouldWatchService(service))
- d->watchService(service, watchMode, q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+ d->watchService(service, mode, q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
}
-void QDBusServiceWatcherPrivate::removeService(const QString &service)
+void QDBusServiceWatcherPrivate::removeService(const QString &service,
+ QDBusServiceWatcher::WatchMode mode)
{
QDBusConnectionPrivate *d = QDBusConnectionPrivate::d(connection);
if (d && d->shouldWatchService(service))
- d->unwatchService(service, watchMode, q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+ d->unwatchService(service, mode, q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
}
/*!
@@ -296,8 +265,9 @@ void QDBusServiceWatcher::setWatchedServices(const QStringList &services)
{
Q_D(QDBusServiceWatcher);
d->watchedServicesData.removeBindingUnlessInWrapper();
- if (services == d->watchedServicesData)
+ if (services == d->watchedServicesData.valueBypassingBindings())
return;
+ // trigger watchMode re-evaluation, but only once for the setter
d->setConnection(services, d->connection, d->watchMode);
d->watchedServicesData.notify();
}
@@ -319,13 +289,14 @@ void QDBusServiceWatcher::addWatchedService(const QString &newService)
{
Q_D(QDBusServiceWatcher);
d->watchedServicesData.removeBindingUnlessInWrapper();
- if (d->watchedServicesData.value().contains(newService))
+ auto services = d->watchedServicesData.valueBypassingBindings();
+ if (services.contains(newService))
return;
- d->addService(newService);
+ // re-evaluate watch mode
+ d->addService(newService, d->watchMode);
- auto templist = d->watchedServicesData.valueBypassingBindings();
- templist << newService;
- d->watchedServicesData.setValueBypassingBindings(templist);
+ services << newService;
+ d->watchedServicesData.setValueBypassingBindings(services);
d->watchedServicesData.notify();
}
@@ -344,17 +315,16 @@ bool QDBusServiceWatcher::removeWatchedService(const QString &service)
{
Q_D(QDBusServiceWatcher);
d->watchedServicesData.removeBindingUnlessInWrapper();
- d->removeService(service);
- auto tempList = d->watchedServicesData.value();
- bool result = tempList.removeOne(service);
- if (result) {
- d->watchedServicesData.setValueBypassingBindings(tempList);
- d->watchedServicesData.notify();
- return true;
- } else {
- // nothing changed
- return false;
- }
+ auto tempList = d->watchedServicesData.valueBypassingBindings();
+ const bool result = tempList.removeOne(service);
+ if (!result)
+ return false; // nothing changed
+
+ // re-evaluate watch mode
+ d->removeService(service, d->watchMode);
+ d->watchedServicesData.setValueBypassingBindings(tempList);
+ d->watchedServicesData.notify();
+ return true;
}
QDBusServiceWatcher::WatchMode QDBusServiceWatcher::watchMode() const
@@ -371,8 +341,9 @@ void QDBusServiceWatcher::setWatchMode(WatchMode mode)
{
Q_D(QDBusServiceWatcher);
d->watchMode.removeBindingUnlessInWrapper();
- if (mode == d->watchMode.value())
+ if (mode == d->watchMode.valueBypassingBindings())
return;
+ // trigger watchedServicesData re-evaluation, but only once for the setter
d->setConnection(d->watchedServicesData, d->connection, mode);
d->watchMode.notify();
}
diff --git a/src/dbus/qdbusservicewatcher.h b/src/dbus/qdbusservicewatcher.h
index 2d5720d63b..71c63084b1 100644
--- a/src/dbus/qdbusservicewatcher.h
+++ b/src/dbus/qdbusservicewatcher.h
@@ -1,51 +1,20 @@
-/****************************************************************************
-**
-** 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
#ifndef QDBUSSERVICEWATCHER_H
#define QDBUSSERVICEWATCHER_H
+#include <QtCore/QObject>
+#include <QtCore/qcontainerfwd.h> // Q(String)List
#include <QtDBus/qtdbusglobal.h>
#if !defined(QT_NO_DBUS) && !defined(QT_NO_QOBJECT)
QT_BEGIN_NAMESPACE
+class QString;
+template<typename T>
+class QBindable;
class QDBusConnection;
diff --git a/src/dbus/qdbusthreaddebug_p.h b/src/dbus/qdbusthreaddebug_p.h
index ad0984e26c..a1d3a420ec 100644
--- a/src/dbus/qdbusthreaddebug_p.h
+++ b/src/dbus/qdbusthreaddebug_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QDBUSTHREADDEBUG_P_H
#define QDBUSTHREADDEBUG_P_H
@@ -129,7 +93,7 @@ struct QDBusReadLocker: QDBusLockerBase
{
QDBusConnectionPrivate *self;
ThreadAction action;
- inline QDBusReadLocker(ThreadAction a, QDBusConnectionPrivate *s)
+ Q_NODISCARD_CTOR QDBusReadLocker(ThreadAction a, QDBusConnectionPrivate *s)
: self(s), action(a)
{
reportThreadAction(action, BeforeLock, self);
@@ -149,7 +113,7 @@ struct QDBusWriteLocker: QDBusLockerBase
{
QDBusConnectionPrivate *self;
ThreadAction action;
- inline QDBusWriteLocker(ThreadAction a, QDBusConnectionPrivate *s)
+ Q_NODISCARD_CTOR QDBusWriteLocker(ThreadAction a, QDBusConnectionPrivate *s)
: self(s), action(a)
{
reportThreadAction(action, BeforeLock, self);
diff --git a/src/dbus/qdbusunixfiledescriptor.cpp b/src/dbus/qdbusunixfiledescriptor.cpp
index 87cabb93f6..943c593acb 100644
--- a/src/dbus/qdbusunixfiledescriptor.cpp
+++ b/src/dbus/qdbusunixfiledescriptor.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 "qdbusunixfiledescriptor.h"
@@ -48,6 +12,8 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_DBUS
+QT_IMPL_METATYPE_EXTERN(QDBusUnixFileDescriptor)
+
/*!
\class QDBusUnixFileDescriptor
\inmodule QtDBus
diff --git a/src/dbus/qdbusunixfiledescriptor.h b/src/dbus/qdbusunixfiledescriptor.h
index fcd73b2ec5..cbcd8b53a9 100644
--- a/src/dbus/qdbusunixfiledescriptor.h
+++ b/src/dbus/qdbusunixfiledescriptor.h
@@ -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
#ifndef QDBUSUNIXFILEDESCRIPTOR_H
@@ -64,7 +28,7 @@ public:
~QDBusUnixFileDescriptor();
void swap(QDBusUnixFileDescriptor &other) noexcept
- { qSwap(d, other.d); }
+ { d.swap(other.d); }
bool isValid() const;
@@ -85,7 +49,7 @@ Q_DECLARE_SHARED(QDBusUnixFileDescriptor)
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDBusUnixFileDescriptor)
+QT_DECL_METATYPE_EXTERN(QDBusUnixFileDescriptor, Q_DBUS_EXPORT)
#endif // QT_NO_DBUS
#endif // QDBUSUNIXFILEDESCRIPTOR_H
diff --git a/src/dbus/qdbusutil.cpp b/src/dbus/qdbusutil.cpp
index 8322ff02c4..827418c487 100644
--- a/src/dbus/qdbusutil.cpp
+++ b/src/dbus/qdbusutil.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 "qdbusutil_p.h"
@@ -43,6 +7,7 @@
#include <QtCore/qlist.h>
#include <QtCore/qstringlist.h>
+#include <private/qtools_p.h>
#include "qdbusargument.h"
#include "qdbusunixfiledescriptor.h"
@@ -51,28 +16,25 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+using namespace QtMiscUtils;
+
static inline bool isValidCharacterNoDash(QChar c)
{
ushort u = c.unicode();
- return (u >= 'a' && u <= 'z')
- || (u >= 'A' && u <= 'Z')
- || (u >= '0' && u <= '9')
- || (u == '_');
+ return isAsciiLetterOrNumber(u) || (u == '_');
}
static inline bool isValidCharacter(QChar c)
{
ushort u = c.unicode();
- return (u >= 'a' && u <= 'z')
- || (u >= 'A' && u <= 'Z')
- || (u >= '0' && u <= '9')
+ return isAsciiLetterOrNumber(u)
|| (u == '_') || (u == '-');
}
static inline bool isValidNumber(QChar c)
{
- ushort u = c.unicode();
- return (u >= '0' && u <= '9');
+ return (isAsciiDigit(c.toLatin1()));
}
#ifndef QT_BOOTSTRAPPED
@@ -83,34 +45,34 @@ static bool variantToString(const QVariant &arg, QString &out)
int argType = arg.metaType().id();
if (argType == QMetaType::QStringList) {
- out += QLatin1Char('{');
+ out += u'{';
const QStringList list = arg.toStringList();
for (const QString &item : list)
- out += QLatin1Char('\"') + item + QLatin1String("\", ");
+ out += u'\"' + item + "\", "_L1;
if (!list.isEmpty())
out.chop(2);
- out += QLatin1Char('}');
+ out += u'}';
} else if (argType == QMetaType::QByteArray) {
- out += QLatin1Char('{');
+ out += u'{';
QByteArray list = arg.toByteArray();
- for (int i = 0; i < list.count(); ++i) {
+ for (int i = 0; i < list.size(); ++i) {
out += QString::number(list.at(i));
- out += QLatin1String(", ");
+ out += ", "_L1;
}
if (!list.isEmpty())
out.chop(2);
- out += QLatin1Char('}');
+ out += u'}';
} else if (argType == QMetaType::QVariantList) {
- out += QLatin1Char('{');
+ out += u'{';
const QList<QVariant> list = arg.toList();
for (const QVariant &item : list) {
if (!variantToString(item, out))
return false;
- out += QLatin1String(", ");
+ out += ", "_L1;
}
if (!list.isEmpty())
out.chop(2);
- out += QLatin1Char('}');
+ out += u'}';
} else if (argType == QMetaType::Char || argType == QMetaType::Short || argType == QMetaType::Int
|| argType == QMetaType::Long || argType == QMetaType::LongLong) {
out += QString::number(arg.toLongLong());
@@ -120,40 +82,40 @@ static bool variantToString(const QVariant &arg, QString &out)
} else if (argType == QMetaType::Double) {
out += QString::number(arg.toDouble());
} else if (argType == QMetaType::Bool) {
- out += QLatin1String(arg.toBool() ? "true" : "false");
+ out += arg.toBool() ? "true"_L1 : "false"_L1;
} else if (argType == qMetaTypeId<QDBusArgument>()) {
argToString(qvariant_cast<QDBusArgument>(arg), out);
} else if (argType == qMetaTypeId<QDBusObjectPath>()) {
const QString path = qvariant_cast<QDBusObjectPath>(arg).path();
- out += QLatin1String("[ObjectPath: ");
+ out += "[ObjectPath: "_L1;
out += path;
- out += QLatin1Char(']');
+ out += u']';
} else if (argType == qMetaTypeId<QDBusSignature>()) {
- out += QLatin1String("[Signature: ") + qvariant_cast<QDBusSignature>(arg).signature();
- out += QLatin1Char(']');
+ out += "[Signature: "_L1 + qvariant_cast<QDBusSignature>(arg).signature();
+ out += u']';
} else if (argType == qMetaTypeId<QDBusUnixFileDescriptor>()) {
- out += QLatin1String("[Unix FD: ");
- out += QLatin1String(qvariant_cast<QDBusUnixFileDescriptor>(arg).isValid() ? "valid" : "not valid");
- out += QLatin1Char(']');
+ out += "[Unix FD: "_L1;
+ out += qvariant_cast<QDBusUnixFileDescriptor>(arg).isValid() ? "valid"_L1 : "not valid"_L1;
+ out += u']';
} else if (argType == qMetaTypeId<QDBusVariant>()) {
const QVariant v = qvariant_cast<QDBusVariant>(arg).variant();
- out += QLatin1String("[Variant");
+ out += "[Variant"_L1;
QMetaType vUserType = v.metaType();
if (vUserType != QMetaType::fromType<QDBusVariant>()
&& vUserType != QMetaType::fromType<QDBusSignature>()
&& vUserType != QMetaType::fromType<QDBusObjectPath>()
&& vUserType != QMetaType::fromType<QDBusArgument>())
- out += QLatin1Char('(') + QLatin1String(v.typeName()) + QLatin1Char(')');
- out += QLatin1String(": ");
+ out += u'(' + QLatin1StringView(v.typeName()) + u')';
+ out += ": "_L1;
if (!variantToString(v, out))
return false;
- out += QLatin1Char(']');
+ out += u']';
} else if (arg.canConvert<QString>()) {
- out += QLatin1Char('\"') + arg.toString() + QLatin1Char('\"');
+ out += u'\"' + arg.toString() + u'\"';
} else {
- out += QLatin1Char('[');
- out += QLatin1String(arg.typeName());
- out += QLatin1Char(']');
+ out += u'[';
+ out += QLatin1StringView(arg.typeName());
+ out += u']';
}
return true;
@@ -167,7 +129,7 @@ bool argToString(const QDBusArgument &busArg, QString &out)
if (elementType != QDBusArgument::BasicType && elementType != QDBusArgument::VariantType
&& elementType != QDBusArgument::MapEntryType)
- out += QLatin1String("[Argument: ") + busSig + QLatin1Char(' ');
+ out += "[Argument: "_L1 + busSig + u' ';
switch (elementType) {
case QDBusArgument::BasicType:
@@ -181,33 +143,33 @@ bool argToString(const QDBusArgument &busArg, QString &out)
break;
case QDBusArgument::ArrayType:
busArg.beginArray();
- out += QLatin1Char('{');
+ out += u'{';
doIterate = true;
break;
case QDBusArgument::MapType:
busArg.beginMap();
- out += QLatin1Char('{');
+ out += u'{';
doIterate = true;
break;
case QDBusArgument::MapEntryType:
busArg.beginMapEntry();
if (!variantToString(busArg.asVariant(), out))
return false;
- out += QLatin1String(" = ");
+ out += " = "_L1;
if (!argToString(busArg, out))
return false;
busArg.endMapEntry();
break;
case QDBusArgument::UnknownType:
default:
- out += QLatin1String("<ERROR - Unknown Type>");
+ out += "<ERROR - Unknown Type>"_L1;
return false;
}
if (doIterate && !busArg.atEnd()) {
while (!busArg.atEnd()) {
if (!argToString(busArg, out))
return false;
- out += QLatin1String(", ");
+ out += ", "_L1;
}
out.chop(2);
}
@@ -222,18 +184,18 @@ bool argToString(const QDBusArgument &busArg, QString &out)
busArg.endStructure();
break;
case QDBusArgument::ArrayType:
- out += QLatin1Char('}');
+ out += u'}';
busArg.endArray();
break;
case QDBusArgument::MapType:
- out += QLatin1Char('}');
+ out += u'}';
busArg.endMap();
break;
}
if (elementType != QDBusArgument::BasicType && elementType != QDBusArgument::VariantType
&& elementType != QDBusArgument::MapEntryType)
- out += QLatin1Char(']');
+ out += u']';
return true;
}
@@ -244,6 +206,21 @@ static const char oneLetterTypes[] = "vsogybnqiuxtdh";
static const char basicTypes[] = "sogybnqiuxtdh";
static const char fixedTypes[] = "ybnqiuxtdh";
+/*
+ D-Bus signature grammar (in ABNF), as of 0.42 (2023-08-21):
+ https://dbus.freedesktop.org/doc/dbus-specification.html#type-system
+
+ <signature> = *<single-complete-type>
+ <single-complete-type> = <basic-type> / <variant> / <struct> / <array>
+ <fixed-type> = "y" / "b" / "n" / "q" / "i" / "u" / "x" / "t" / "d" / "h"
+ <variable-length-type> = "s" / "o" / "g"
+ <basic-type> = <variable-length-type> / <fixed-type>
+ <variant> = "v"
+ <struct> = "(" 1*<single-complete-type> ")"
+ <array> = "a" ( <single-complete-type> / <dict-entry> )
+ <dict-entry> = "{" <basic-type> <single-complete-type> "}"
+*/
+
static bool isBasicType(int c)
{
return c != DBUS_TYPE_INVALID && strchr(basicTypes, c) != nullptr;
@@ -340,7 +317,7 @@ namespace QDBusUtil
return false; // can't be valid if it's empty
const QChar *c = part.data();
- for (int i = 0; i < part.length(); ++i)
+ for (int i = 0; i < part.size(); ++i)
if (!isValidCharacterNoDash(c[i]))
return false;
@@ -348,13 +325,6 @@ namespace QDBusUtil
}
/*!
- \internal
- \fn bool isValidPartOfObjectPath(const QString &part)
-
- \overload
- */
-
- /*!
\fn bool isValidInterfaceName(const QString &ifaceName)
Returns \c true if this is \a ifaceName is a valid interface name.
@@ -369,11 +339,11 @@ namespace QDBusUtil
*/
bool isValidInterfaceName(const QString& ifaceName)
{
- if (ifaceName.isEmpty() || ifaceName.length() > DBUS_MAXIMUM_NAME_LENGTH)
+ if (ifaceName.isEmpty() || ifaceName.size() > DBUS_MAXIMUM_NAME_LENGTH)
return false;
- const auto parts = QStringView{ifaceName}.split(QLatin1Char('.'));
- if (parts.count() < 2)
+ const auto parts = QStringView{ifaceName}.split(u'.');
+ if (parts.size() < 2)
return false; // at least two parts
for (auto part : parts)
@@ -392,12 +362,12 @@ namespace QDBusUtil
*/
bool isValidUniqueConnectionName(QStringView connName)
{
- if (connName.isEmpty() || connName.length() > DBUS_MAXIMUM_NAME_LENGTH ||
- !connName.startsWith(QLatin1Char(':')))
+ if (connName.isEmpty() || connName.size() > DBUS_MAXIMUM_NAME_LENGTH ||
+ !connName.startsWith(u':'))
return false;
- const auto parts = connName.mid(1).split(QLatin1Char('.'));
- if (parts.count() < 1)
+ const auto parts = connName.mid(1).split(u'.');
+ if (parts.size() < 1)
return false;
for (QStringView part : parts) {
@@ -405,7 +375,7 @@ namespace QDBusUtil
return false;
const QChar* c = part.data();
- for (int j = 0; j < part.length(); ++j)
+ for (int j = 0; j < part.size(); ++j)
if (!isValidCharacter(c[j]))
return false;
}
@@ -414,12 +384,6 @@ namespace QDBusUtil
}
/*!
- \fn bool isValidUniqueConnectionName(const QString &connName)
-
- \overload
- */
-
- /*!
\fn bool isValidBusName(const QString &busName)
Returns \c true if \a busName is a valid bus name.
@@ -436,16 +400,13 @@ namespace QDBusUtil
*/
bool isValidBusName(const QString &busName)
{
- if (busName.isEmpty() || busName.length() > DBUS_MAXIMUM_NAME_LENGTH)
+ if (busName.isEmpty() || busName.size() > DBUS_MAXIMUM_NAME_LENGTH)
return false;
- if (busName.startsWith(QLatin1Char(':')))
+ if (busName.startsWith(u':'))
return isValidUniqueConnectionName(busName);
- const auto parts = QStringView{busName}.split(QLatin1Char('.'));
- if (parts.count() < 1)
- return false;
-
+ const auto parts = QStringView{busName}.split(u'.');
for (QStringView part : parts) {
if (part.isEmpty())
return false;
@@ -453,7 +414,7 @@ namespace QDBusUtil
const QChar *c = part.data();
if (isValidNumber(c[0]))
return false;
- for (int j = 0; j < part.length(); ++j)
+ for (int j = 0; j < part.size(); ++j)
if (!isValidCharacter(c[j]))
return false;
}
@@ -469,25 +430,19 @@ namespace QDBusUtil
*/
bool isValidMemberName(QStringView memberName)
{
- if (memberName.isEmpty() || memberName.length() > DBUS_MAXIMUM_NAME_LENGTH)
+ if (memberName.isEmpty() || memberName.size() > DBUS_MAXIMUM_NAME_LENGTH)
return false;
const QChar* c = memberName.data();
if (isValidNumber(c[0]))
return false;
- for (int j = 0; j < memberName.length(); ++j)
+ for (int j = 0; j < memberName.size(); ++j)
if (!isValidCharacterNoDash(c[j]))
return false;
return true;
}
/*!
- \fn bool isValidMemberName(const QString &memberName)
-
- \overload
- */
-
- /*!
\fn bool isValidErrorName(const QString &errorName)
Returns \c true if \a errorName is a valid error name. Valid error names are valid interface
names and vice-versa, so this function is actually an alias for isValidInterfaceName.
@@ -505,22 +460,21 @@ namespace QDBusUtil
\list
\li start with the slash character ("/")
\li do not end in a slash, unless the path is just the initial slash
- \li do not contain any two slashes in sequence
- \li contain slash-separated parts, each of which is composed of ASCII letters, digits and
- underscores ("_")
+ \li contain slash-separated parts, each of which is not empty, and composed
+ only of ASCII letters, digits and underscores ("_").
\endlist
*/
bool isValidObjectPath(const QString &path)
{
- if (path == QLatin1String("/"))
+ if (path == "/"_L1)
return true;
- if (!path.startsWith(QLatin1Char('/')) || path.indexOf(QLatin1String("//")) != -1 ||
- path.endsWith(QLatin1Char('/')))
+ if (!path.startsWith(u'/') || path.indexOf("//"_L1) != -1 ||
+ path.endsWith(u'/'))
return false;
// it starts with /, so we skip the empty first part
- const auto parts = QStringView{path}.mid(1).split(QLatin1Char('/'));
+ const auto parts = QStringView{path}.mid(1).split(u'/');
for (QStringView part : parts)
if (!isValidPartOfObjectPath(part))
return false;
diff --git a/src/dbus/qdbusutil_p.h b/src/dbus/qdbusutil_p.h
index 50a2490fd0..3db9384968 100644
--- a/src/dbus/qdbusutil_p.h
+++ b/src/dbus/qdbusutil_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
@@ -63,7 +27,7 @@
QT_BEGIN_NAMESPACE
-#define Q_DBUS_NO_EXPORT // force findclasslist.pl looking into this namespace
+#define Q_DBUS_NO_EXPORT // force syncqt looking into this namespace
namespace Q_DBUS_NO_EXPORT QDBusUtil
{
Q_DBUS_EXPORT bool isValidInterfaceName(const QString &ifaceName);
@@ -99,11 +63,11 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
{
if (name.isEmpty()) {
if (empty == EmptyAllowed) return true;
- *error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Interface name cannot be empty"));
+ *error = QDBusError(QDBusError::InvalidInterface, QLatin1StringView("Interface name cannot be empty"));
return false;
}
if (isValidInterfaceName(name)) return true;
- *error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Invalid interface class: %1").arg(name));
+ *error = QDBusError(QDBusError::InvalidInterface, QLatin1StringView("Invalid interface class: %1").arg(name));
return false;
}
@@ -111,11 +75,11 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
{
if (name.isEmpty()) {
if (empty == EmptyAllowed) return true;
- *error = QDBusError(QDBusError::InvalidService, QLatin1String("Service name cannot be empty"));
+ *error = QDBusError(QDBusError::InvalidService, QLatin1StringView("Service name cannot be empty"));
return false;
}
if (isValidBusName(name)) return true;
- *error = QDBusError(QDBusError::InvalidService, QLatin1String("Invalid service name: %1").arg(name));
+ *error = QDBusError(QDBusError::InvalidService, QLatin1StringView("Invalid service name: %1").arg(name));
return false;
}
@@ -123,11 +87,11 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
{
if (path.isEmpty()) {
if (empty == EmptyAllowed) return true;
- *error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
+ *error = QDBusError(QDBusError::InvalidObjectPath, QLatin1StringView("Object path cannot be empty"));
return false;
}
if (isValidObjectPath(path)) return true;
- *error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Invalid object path: %1").arg(path));
+ *error = QDBusError(QDBusError::InvalidObjectPath, QLatin1StringView("Invalid object path: %1").arg(path));
return false;
}
@@ -136,12 +100,12 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
if (!nameType) nameType = "member";
if (name.isEmpty()) {
if (empty == EmptyAllowed) return true;
- *error = QDBusError(QDBusError::InvalidMember, QLatin1String(nameType) + QLatin1String(" name cannot be empty"));
+ *error = QDBusError(QDBusError::InvalidMember, QLatin1StringView(nameType) + QLatin1StringView(" name cannot be empty"));
return false;
}
if (isValidMemberName(name)) return true;
- *error = QDBusError(QDBusError::InvalidMember, QLatin1String("Invalid %1 name: %2")
- .arg(QLatin1String(nameType), name));
+ *error = QDBusError(QDBusError::InvalidMember, QLatin1StringView("Invalid %1 name: %2")
+ .arg(QLatin1StringView(nameType), name));
return false;
}
@@ -149,11 +113,11 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
{
if (name.isEmpty()) {
if (empty == EmptyAllowed) return true;
- *error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Error name cannot be empty"));
+ *error = QDBusError(QDBusError::InvalidInterface, QLatin1StringView("Error name cannot be empty"));
return false;
}
if (isValidErrorName(name)) return true;
- *error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Invalid error name: %1").arg(name));
+ *error = QDBusError(QDBusError::InvalidInterface, QLatin1StringView("Invalid error name: %1").arg(name));
return false;
}
@@ -166,7 +130,7 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
inline QString dbusInterface()
{
// it's the same string, but just be sure
- Q_ASSERT(dbusService() == QLatin1String(DBUS_INTERFACE_DBUS));
+ Q_ASSERT(dbusService() == QLatin1StringView(DBUS_INTERFACE_DBUS));
return dbusService();
}
inline QString dbusInterfaceProperties()
diff --git a/src/dbus/qdbusvirtualobject.cpp b/src/dbus/qdbusvirtualobject.cpp
index 25dd49c34d..2e5df125d2 100644
--- a/src/dbus/qdbusvirtualobject.cpp
+++ b/src/dbus/qdbusvirtualobject.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 "qdbusvirtualobject.h"
@@ -60,6 +24,7 @@ QDBusVirtualObject::~QDBusVirtualObject()
QT_END_NAMESPACE
+#include "moc_qdbusvirtualobject.cpp"
/*!
\class QDBusVirtualObject
@@ -74,7 +39,7 @@ QT_END_NAMESPACE
This function needs to handle all messages to the path of the
virtual object, when the SubPath option is specified.
- The service, path, interface and methos are all part of the \a message.
+ The service, path, interface and methods are all part of the \a message.
Parameter \a connection is the connection handle.
Must return \c true when the message is handled, otherwise \c false (will generate dbus error message).
*/
diff --git a/src/dbus/qdbusvirtualobject.h b/src/dbus/qdbusvirtualobject.h
index b69e21b378..573d731d20 100644
--- a/src/dbus/qdbusvirtualobject.h
+++ b/src/dbus/qdbusvirtualobject.h
@@ -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
#ifndef QDBUSVIRTUALOBJECT_H
#define QDBUSVIRTUALOBJECT_H
diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp
index e00a03360c..412ac18095 100644
--- a/src/dbus/qdbusxmlgenerator.cpp
+++ b/src/dbus/qdbusxmlgenerator.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 <QtCore/qmetaobject.h>
#include <QtCore/qstringlist.h>
@@ -52,6 +16,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
extern Q_DBUS_EXPORT QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo,
const QMetaObject *base, int flags);
@@ -59,28 +25,28 @@ static inline QString typeNameToXml(const char *typeName)
{
// ### copied from qtextdocument.cpp
// ### move this into Qt Core at some point
- const QLatin1String plain(typeName);
+ const QLatin1StringView plain(typeName);
QString rich;
rich.reserve(int(plain.size() * 1.1));
for (int i = 0; i < plain.size(); ++i) {
- if (plain.at(i) == QLatin1Char('<'))
- rich += QLatin1String("&lt;");
- else if (plain.at(i) == QLatin1Char('>'))
- rich += QLatin1String("&gt;");
- else if (plain.at(i) == QLatin1Char('&'))
- rich += QLatin1String("&amp;");
+ if (plain.at(i) == u'<')
+ rich += "&lt;"_L1;
+ else if (plain.at(i) == u'>')
+ rich += "&gt;"_L1;
+ else if (plain.at(i) == u'&')
+ rich += "&amp;"_L1;
else
rich += plain.at(i);
}
return rich;
}
-static inline QLatin1String accessAsString(bool read, bool write)
+static inline QLatin1StringView accessAsString(bool read, bool write)
{
if (read)
- return write ? QLatin1String("readwrite") : QLatin1String("read") ;
+ return write ? "readwrite"_L1 : "read"_L1 ;
else
- return write ? QLatin1String("write") : QLatin1String("") ;
+ return write ? "write"_L1 : ""_L1 ;
}
// implement the D-Bus org.freedesktop.DBus.Introspectable interface
@@ -108,17 +74,17 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
if (!signature)
continue;
- retval += QLatin1String(" <property name=\"%1\" type=\"%2\" access=\"%3\"")
- .arg(QLatin1String(mp.name()),
- QLatin1String(signature),
+ retval += " <property name=\"%1\" type=\"%2\" access=\"%3\""_L1
+ .arg(QLatin1StringView(mp.name()),
+ QLatin1StringView(signature),
accessAsString(mp.isReadable(), mp.isWritable()));
if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
const char *typeName = type.name();
- retval += QLatin1String(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n")
+ retval += ">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n"_L1
.arg(typeNameToXml(typeName));
} else {
- retval += QLatin1String("/>\n");
+ retval += "/>\n"_L1;
}
}
}
@@ -160,12 +126,12 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
if (typeId.isValid() && typeId.id() != QMetaType::Void) {
const char *typeName = QDBusMetaType::typeToSignature(typeId);
if (typeName) {
- xml += QLatin1String(" <arg type=\"%1\" direction=\"out\"/>\n")
+ xml += " <arg type=\"%1\" direction=\"out\"/>\n"_L1
.arg(typeNameToXml(typeName));
// do we need to describe this argument?
if (!QDBusMetaType::signatureToMetaType(typeName).isValid())
- xml += QLatin1String(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
+ xml += " <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n"_L1
.arg(typeNameToXml(QMetaType(typeId).name()));
} else {
qWarning() << "Unsupported return type" << typeId.id() << typeId.name() << "in method" << mm.name();
@@ -185,7 +151,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
qWarning() << "Skipped method" << mm.name() << ":" << qPrintable(errorMsg);
continue; // invalid form
}
- if (isSignal && inputCount + 1 != types.count())
+ if (isSignal && inputCount + 1 != types.size())
continue; // signal with output arguments?
if (isSignal && types.at(inputCount) == QDBusMetaTypeId::message())
continue; // signal with QDBusMessage argument?
@@ -193,7 +159,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
continue; // cloned signal?
int j;
- for (j = 1; j < types.count(); ++j) {
+ for (j = 1; j < types.size(); ++j) {
// input parameter for a slot or output for a signal
if (types.at(j) == QDBusMetaTypeId::message()) {
isScriptable = true;
@@ -202,7 +168,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
QString name;
if (!names.at(j - 1).isEmpty())
- name = QLatin1String("name=\"%1\" ").arg(QLatin1String(names.at(j - 1)));
+ name = "name=\"%1\" "_L1.arg(QLatin1StringView(names.at(j - 1)));
bool isOutput = isSignal || j > inputCount;
@@ -214,7 +180,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
const char *typeName = QMetaType(types.at(j)).name();
xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n")
- .arg(isOutput ? QLatin1String("Out") : QLatin1String("In"))
+ .arg(isOutput ? "Out"_L1 : "In"_L1)
.arg(isOutput && !isSignal ? j - inputCount : j - 1)
.arg(typeNameToXml(typeName));
}
@@ -234,12 +200,10 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
if (qDBusCheckAsyncTag(mm.tag()))
// add the no-reply annotation
- xml += QLatin1String(" <annotation name=\"" ANNOTATION_NO_WAIT "\""
- " value=\"true\"/>\n");
+ xml += " <annotation name=\"" ANNOTATION_NO_WAIT "\" value=\"true\"/>\n"_L1;
retval += xml;
- retval += QLatin1String(" </%1>\n")
- .arg(isSignal ? QLatin1String("signal") : QLatin1String("method"));
+ retval += " </%1>\n"_L1.arg(isSignal ? "signal"_L1 : "method"_L1);
}
return retval;
@@ -261,60 +225,10 @@ QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo,
if (xml.isEmpty())
return QString(); // don't add an empty interface
- return QLatin1String(" <interface name=\"%1\">\n%2 </interface>\n")
- .arg(interface, xml);
-}
-#if 0
-QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, const QMetaObject *base,
- int flags)
-{
- if (interface.isEmpty()) {
- // generate the interface name from the meta object
- int idx = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTERFACE);
- if (idx >= mo->classInfoOffset()) {
- interface = QLatin1String(mo->classInfo(idx).value());
- } else {
- interface = QLatin1String(mo->className());
- interface.replace(QLatin1String("::"), QLatin1String("."));
-
- if (interface.startsWith(QLatin1String("QDBus"))) {
- interface.prepend(QLatin1String("org.qtproject.QtDBus."));
- } else if (interface.startsWith(QLatin1Char('Q')) &&
- interface.length() >= 2 && interface.at(1).isUpper()) {
- // assume it's Qt
- interface.prepend(QLatin1String("org.qtproject.Qt."));
- } else if (!QCoreApplication::instance()||
- QCoreApplication::instance()->applicationName().isEmpty()) {
- interface.prepend(QLatin1String("local."));
- } else {
- interface.prepend(QLatin1Char('.')).prepend(QCoreApplication::instance()->applicationName());
- QStringList domainName =
- QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'),
- Qt::SkipEmptyParts);
- if (domainName.isEmpty())
- interface.prepend(QLatin1String("local."));
- else
- for (int i = 0; i < domainName.count(); ++i)
- interface.prepend(QLatin1Char('.')).prepend(domainName.at(i));
- }
- }
- }
-
- QString xml;
- int idx = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTROSPECTION);
- if (idx >= mo->classInfoOffset())
- return QString::fromUtf8(mo->classInfo(idx).value());
- else
- xml = generateInterfaceXml(mo, flags, base->methodCount(), base->propertyCount());
-
- if (xml.isEmpty())
- return QString(); // don't add an empty interface
- return QString::fromLatin1(" <interface name=\"%1\">\n%2 </interface>\n")
+ return " <interface name=\"%1\">\n%2 </interface>\n"_L1
.arg(interface, xml);
}
-#endif
-
QT_END_NAMESPACE
#endif // QT_NO_DBUS
diff --git a/src/dbus/qdbusxmlparser.cpp b/src/dbus/qdbusxmlparser.cpp
index 94223e1574..c2e8df8be7 100644
--- a/src/dbus/qdbusxmlparser.cpp
+++ b/src/dbus/qdbusxmlparser.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 "qdbusxmlparser_p.h"
#include "qdbusutil_p.h"
@@ -43,178 +7,206 @@
#include <QtCore/qmap.h>
#include <QtCore/qvariant.h>
#include <QtCore/qtextstream.h>
-#include <QtCore/qxmlstream.h>
#include <QtCore/qdebug.h>
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
-Q_LOGGING_CATEGORY(dbusParser, "dbus.parser", QtWarningMsg)
+using namespace Qt::StringLiterals;
-#define qDBusParserError(...) qCDebug(dbusParser, ##__VA_ARGS__)
+Q_LOGGING_CATEGORY(dbusParser, "dbus.parser", QtWarningMsg)
-static bool parseArg(const QXmlStreamAttributes &attributes, QDBusIntrospection::Argument &argData,
- QDBusIntrospection::Interface *ifaceData)
+#define qDBusParserWarning(format, ...) \
+ do { \
+ if (m_reporter) \
+ m_reporter->warning(m_currentLocation, format "\n", ##__VA_ARGS__); \
+ else \
+ qCDebug(dbusParser, "Warning: " format, ##__VA_ARGS__); \
+ } while (0)
+
+#define qDBusParserError(format, ...) \
+ do { \
+ if (m_reporter) \
+ m_reporter->error(m_currentLocation, format "\n", ##__VA_ARGS__); \
+ else \
+ qCDebug(dbusParser, "Error: " format, ##__VA_ARGS__); \
+ } while (0)
+
+bool QDBusXmlParser::parseArg(const QXmlStreamAttributes &attributes,
+ QDBusIntrospection::Argument &argData)
{
- const QString argType = attributes.value(QLatin1String("type")).toString();
+ Q_ASSERT(m_currentInterface);
+
+ const QString argType = attributes.value("type"_L1).toString();
bool ok = QDBusUtil::isValidSingleSignature(argType);
if (!ok) {
- qDBusParserError("Invalid D-BUS type signature '%s' found while parsing introspection",
- qPrintable(argType));
+ qDBusParserError("Invalid D-Bus type signature '%s' found while parsing introspection",
+ qPrintable(argType));
}
- argData.name = attributes.value(QLatin1String("name")).toString();
+ argData.name = attributes.value("name"_L1).toString();
argData.type = argType;
- ifaceData->introspection += QLatin1String(" <arg");
- if (attributes.hasAttribute(QLatin1String("direction"))) {
- const QString direction = attributes.value(QLatin1String("direction")).toString();
- ifaceData->introspection += QLatin1String(" direction=\"") + direction + QLatin1String("\"");
+ m_currentInterface->introspection += " <arg"_L1;
+ if (attributes.hasAttribute("direction"_L1)) {
+ const QString direction = attributes.value("direction"_L1).toString();
+ m_currentInterface->introspection += " direction=\""_L1 + direction + u'"';
}
- ifaceData->introspection += QLatin1String(" type=\"") + argData.type + QLatin1String("\"");
+ m_currentInterface->introspection += " type=\""_L1 + argData.type + u'"';
if (!argData.name.isEmpty())
- ifaceData->introspection += QLatin1String(" name=\"") + argData.name + QLatin1String("\"");
- ifaceData->introspection += QLatin1String("/>\n");
+ m_currentInterface->introspection += " name=\""_L1 + argData.name + u'"';
+ m_currentInterface->introspection += "/>\n"_L1;
return ok;
}
-static bool parseAnnotation(const QXmlStreamReader &xml, QDBusIntrospection::Annotations &annotations,
- QDBusIntrospection::Interface *ifaceData, bool interfaceAnnotation = false)
+bool QDBusXmlParser::parseAnnotation(QDBusIntrospection::Annotations &annotations,
+ bool interfaceAnnotation)
{
- Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("annotation"));
+ Q_ASSERT(m_currentInterface);
+ Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "annotation"_L1);
+
+ QDBusIntrospection::Annotation annotation;
+ annotation.location = m_currentLocation;
- const QXmlStreamAttributes attributes = xml.attributes();
- const QString name = attributes.value(QLatin1String("name")).toString();
+ const QXmlStreamAttributes attributes = m_xml.attributes();
+ annotation.name = attributes.value("name"_L1).toString();
- if (!QDBusUtil::isValidInterfaceName(name)) {
- qDBusParserError("Invalid D-BUS annotation '%s' found while parsing introspection",
- qPrintable(name));
+ if (!QDBusUtil::isValidInterfaceName(annotation.name)) {
+ qDBusParserError("Invalid D-Bus annotation '%s' found while parsing introspection",
+ qPrintable(annotation.name));
return false;
}
- const QString value = attributes.value(QLatin1String("value")).toString();
- annotations.insert(name, value);
+ annotation.value = attributes.value("value"_L1).toString();
+ annotations.insert(annotation.name, annotation);
if (!interfaceAnnotation)
- ifaceData->introspection += QLatin1String(" ");
- ifaceData->introspection += QLatin1String(" <annotation value=\"") + value.toHtmlEscaped() + QLatin1String("\" name=\"") + name + QLatin1String("\"/>\n");
+ m_currentInterface->introspection += " "_L1;
+ m_currentInterface->introspection += " <annotation value=\""_L1
+ + annotation.value.toHtmlEscaped() + "\" name=\""_L1 + annotation.name + "\"/>\n"_L1;
return true;
}
-static bool parseProperty(QXmlStreamReader &xml, QDBusIntrospection::Property &propertyData,
- QDBusIntrospection::Interface *ifaceData)
+bool QDBusXmlParser::parseProperty(QDBusIntrospection::Property &propertyData)
{
- Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("property"));
+ Q_ASSERT(m_currentInterface);
+ Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "property"_L1);
- QXmlStreamAttributes attributes = xml.attributes();
- const QString propertyName = attributes.value(QLatin1String("name")).toString();
+ QXmlStreamAttributes attributes = m_xml.attributes();
+ const QString propertyName = attributes.value("name"_L1).toString();
if (!QDBusUtil::isValidMemberName(propertyName)) {
- qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
- qPrintable(propertyName), qPrintable(ifaceData->name));
- xml.skipCurrentElement();
+ qDBusParserWarning("Invalid D-Bus member name '%s' found in interface '%s' while parsing "
+ "introspection",
+ qPrintable(propertyName), qPrintable(m_currentInterface->name));
+ m_xml.skipCurrentElement();
return false;
}
// parse data
propertyData.name = propertyName;
- propertyData.type = attributes.value(QLatin1String("type")).toString();
+ propertyData.type = attributes.value("type"_L1).toString();
if (!QDBusUtil::isValidSingleSignature(propertyData.type)) {
// cannot be!
- qDBusParserError("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection",
- qPrintable(propertyData.type), qPrintable(ifaceData->name),
- qPrintable(propertyName));
+ qDBusParserError("Invalid D-Bus type signature '%s' found in property '%s.%s' while "
+ "parsing introspection",
+ qPrintable(propertyData.type), qPrintable(m_currentInterface->name),
+ qPrintable(propertyName));
}
- const QString access = attributes.value(QLatin1String("access")).toString();
- if (access == QLatin1String("read"))
+ const QString access = attributes.value("access"_L1).toString();
+ if (access == "read"_L1)
propertyData.access = QDBusIntrospection::Property::Read;
- else if (access == QLatin1String("write"))
+ else if (access == "write"_L1)
propertyData.access = QDBusIntrospection::Property::Write;
- else if (access == QLatin1String("readwrite"))
+ else if (access == "readwrite"_L1)
propertyData.access = QDBusIntrospection::Property::ReadWrite;
else {
- qDBusParserError("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection",
- qPrintable(access), qPrintable(ifaceData->name),
- qPrintable(propertyName));
+ qDBusParserError("Invalid D-Bus property access '%s' found in property '%s.%s' while "
+ "parsing introspection",
+ qPrintable(access), qPrintable(m_currentInterface->name),
+ qPrintable(propertyName));
return false; // invalid one!
}
- ifaceData->introspection += QLatin1String(" <property access=\"") + access + QLatin1String("\" type=\"") + propertyData.type + QLatin1String("\" name=\"") + propertyName + QLatin1String("\"");
+ m_currentInterface->introspection += " <property access=\""_L1 + access + "\" type=\""_L1 + propertyData.type + "\" name=\""_L1 + propertyName + u'"';
- if (!xml.readNextStartElement()) {
- ifaceData->introspection += QLatin1String("/>\n");
+ if (!readNextStartElement()) {
+ m_currentInterface->introspection += "/>\n"_L1;
} else {
- ifaceData->introspection += QLatin1String(">\n");
+ m_currentInterface->introspection += ">\n"_L1;
do {
- if (xml.name() == QLatin1String("annotation")) {
- parseAnnotation(xml, propertyData.annotations, ifaceData);
- } else if (xml.prefix().isEmpty()) {
- qDBusParserError() << "Unknown element" << xml.name() << "while checking for annotations";
+ if (m_xml.name() == "annotation"_L1) {
+ parseAnnotation(propertyData.annotations);
+ } else if (m_xml.prefix().isEmpty()) {
+ qDBusParserWarning("Unknown element '%s' while checking for annotations",
+ qPrintable(m_xml.name().toString()));
}
- xml.skipCurrentElement();
- } while (xml.readNextStartElement());
+ m_xml.skipCurrentElement();
+ } while (readNextStartElement());
- ifaceData->introspection += QLatin1String(" </property>\n");
+ m_currentInterface->introspection += " </property>\n"_L1;
}
- if (!xml.isEndElement() || xml.name() != QLatin1String("property")) {
- qDBusParserError() << "Invalid property specification" << xml.tokenString() << xml.name();
+ if (!m_xml.isEndElement() || m_xml.name() != "property"_L1) {
+ qDBusParserError("Invalid property specification: '%s'", qPrintable(m_xml.tokenString()));
return false;
}
return true;
}
-static bool parseMethod(QXmlStreamReader &xml, QDBusIntrospection::Method &methodData,
- QDBusIntrospection::Interface *ifaceData)
+bool QDBusXmlParser::parseMethod(QDBusIntrospection::Method &methodData)
{
- Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("method"));
+ Q_ASSERT(m_currentInterface);
+ Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "method"_L1);
- const QXmlStreamAttributes attributes = xml.attributes();
- const QString methodName = attributes.value(QLatin1String("name")).toString();
+ const QXmlStreamAttributes attributes = m_xml.attributes();
+ const QString methodName = attributes.value("name"_L1).toString();
if (!QDBusUtil::isValidMemberName(methodName)) {
- qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
- qPrintable(methodName), qPrintable(ifaceData->name));
+ qDBusParserError("Invalid D-Bus member name '%s' found in interface '%s' while parsing "
+ "introspection",
+ qPrintable(methodName), qPrintable(m_currentInterface->name));
return false;
}
methodData.name = methodName;
- ifaceData->introspection += QLatin1String(" <method name=\"") + methodName + QLatin1String("\"");
+ m_currentInterface->introspection += " <method name=\""_L1 + methodName + u'"';
QDBusIntrospection::Arguments outArguments;
QDBusIntrospection::Arguments inArguments;
QDBusIntrospection::Annotations annotations;
- if (!xml.readNextStartElement()) {
- ifaceData->introspection += QLatin1String("/>\n");
+ if (!readNextStartElement()) {
+ m_currentInterface->introspection += "/>\n"_L1;
} else {
- ifaceData->introspection += QLatin1String(">\n");
+ m_currentInterface->introspection += ">\n"_L1;
do {
- if (xml.name() == QLatin1String("annotation")) {
- parseAnnotation(xml, annotations, ifaceData);
- } else if (xml.name() == QLatin1String("arg")) {
- const QXmlStreamAttributes attributes = xml.attributes();
- const QString direction = attributes.value(QLatin1String("direction")).toString();
+ if (m_xml.name() == "annotation"_L1) {
+ parseAnnotation(annotations);
+ } else if (m_xml.name() == "arg"_L1) {
+ const QXmlStreamAttributes attributes = m_xml.attributes();
+ const QString direction = attributes.value("direction"_L1).toString();
QDBusIntrospection::Argument argument;
- if (!attributes.hasAttribute(QLatin1String("direction"))
- || direction == QLatin1String("in")) {
- parseArg(attributes, argument, ifaceData);
+ argument.location = m_currentLocation;
+ if (!attributes.hasAttribute("direction"_L1) || direction == "in"_L1) {
+ parseArg(attributes, argument);
inArguments << argument;
- } else if (direction == QLatin1String("out")) {
- parseArg(attributes, argument, ifaceData);
+ } else if (direction == "out"_L1) {
+ parseArg(attributes, argument);
outArguments << argument;
}
- } else if (xml.prefix().isEmpty()) {
- qDBusParserError() << "Unknown element" << xml.name() << "while checking for method arguments";
+ } else if (m_xml.prefix().isEmpty()) {
+ qDBusParserWarning("Unknown element '%s' while checking for method arguments",
+ qPrintable(m_xml.name().toString()));
}
- xml.skipCurrentElement();
- } while (xml.readNextStartElement());
+ m_xml.skipCurrentElement();
+ } while (readNextStartElement());
- ifaceData->introspection += QLatin1String(" </method>\n");
+ m_currentInterface->introspection += " </method>\n"_L1;
}
methodData.inputArgs = inArguments;
@@ -224,50 +216,52 @@ static bool parseMethod(QXmlStreamReader &xml, QDBusIntrospection::Method &metho
return true;
}
-
-static bool parseSignal(QXmlStreamReader &xml, QDBusIntrospection::Signal &signalData,
- QDBusIntrospection::Interface *ifaceData)
+bool QDBusXmlParser::parseSignal(QDBusIntrospection::Signal &signalData)
{
- Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("signal"));
+ Q_ASSERT(m_currentInterface);
+ Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "signal"_L1);
- const QXmlStreamAttributes attributes = xml.attributes();
- const QString signalName = attributes.value(QLatin1String("name")).toString();
+ const QXmlStreamAttributes attributes = m_xml.attributes();
+ const QString signalName = attributes.value("name"_L1).toString();
if (!QDBusUtil::isValidMemberName(signalName)) {
- qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
- qPrintable(signalName), qPrintable(ifaceData->name));
+ qDBusParserError("Invalid D-Bus member name '%s' found in interface '%s' while parsing "
+ "introspection",
+ qPrintable(signalName), qPrintable(m_currentInterface->name));
return false;
}
signalData.name = signalName;
- ifaceData->introspection += QLatin1String(" <signal name=\"") + signalName + QLatin1String("\"");
+ m_currentInterface->introspection += " <signal name=\""_L1 + signalName + u'"';
QDBusIntrospection::Arguments arguments;
QDBusIntrospection::Annotations annotations;
- if (!xml.readNextStartElement()) {
- ifaceData->introspection += QLatin1String("/>\n");
+ if (!readNextStartElement()) {
+ m_currentInterface->introspection += "/>\n"_L1;
} else {
- ifaceData->introspection += QLatin1String(">\n");
+ m_currentInterface->introspection += ">\n"_L1;
do {
- if (xml.name() == QLatin1String("annotation")) {
- parseAnnotation(xml, annotations, ifaceData);
- } else if (xml.name() == QLatin1String("arg")) {
- const QXmlStreamAttributes attributes = xml.attributes();
+ if (m_xml.name() == "annotation"_L1) {
+ parseAnnotation(annotations);
+ } else if (m_xml.name() == "arg"_L1) {
+ const QXmlStreamAttributes attributes = m_xml.attributes();
QDBusIntrospection::Argument argument;
- if (!attributes.hasAttribute(QLatin1String("direction")) ||
- attributes.value(QLatin1String("direction")) == QLatin1String("out")) {
- parseArg(attributes, argument, ifaceData);
+ argument.location = m_currentLocation;
+ if (!attributes.hasAttribute("direction"_L1) ||
+ attributes.value("direction"_L1) == "out"_L1) {
+ parseArg(attributes, argument);
arguments << argument;
}
} else {
- qDBusParserError() << "Unknown element" << xml.name() << "while checking for signal arguments";
+ qDBusParserWarning("Unknown element '%s' while checking for signal arguments",
+ qPrintable(m_xml.name().toString()));
}
- xml.skipCurrentElement();
- } while (xml.readNextStartElement());
+ m_xml.skipCurrentElement();
+ } while (readNextStartElement());
- ifaceData->introspection += QLatin1String(" </signal>\n");
+ m_currentInterface->introspection += " </signal>\n"_L1;
}
signalData.outputArgs = arguments;
@@ -276,105 +270,142 @@ static bool parseSignal(QXmlStreamReader &xml, QDBusIntrospection::Signal &signa
return true;
}
-static void readInterface(QXmlStreamReader &xml, QDBusIntrospection::Object *objData,
- QDBusIntrospection::Interfaces *interfaces)
+void QDBusXmlParser::readInterface()
{
- const QString ifaceName = xml.attributes().value(QLatin1String("name")).toString();
+ Q_ASSERT(!m_currentInterface);
+
+ const QString ifaceName = m_xml.attributes().value("name"_L1).toString();
if (!QDBusUtil::isValidInterfaceName(ifaceName)) {
- qDBusParserError("Invalid D-BUS interface name '%s' found while parsing introspection",
- qPrintable(ifaceName));
+ qDBusParserError("Invalid D-Bus interface name '%s' found while parsing introspection",
+ qPrintable(ifaceName));
return;
}
- objData->interfaces.append(ifaceName);
+ m_object->interfaces.append(ifaceName);
- QDBusIntrospection::Interface *ifaceData = new QDBusIntrospection::Interface;
- ifaceData->name = ifaceName;
- ifaceData->introspection += QLatin1String(" <interface name=\"") + ifaceName + QLatin1String("\">\n");
+ m_currentInterface = std::make_unique<QDBusIntrospection::Interface>();
+ m_currentInterface->location = m_currentLocation;
+ m_currentInterface->name = ifaceName;
+ m_currentInterface->introspection += " <interface name=\""_L1 + ifaceName + "\">\n"_L1;
- while (xml.readNextStartElement()) {
- if (xml.name() == QLatin1String("method")) {
+ while (readNextStartElement()) {
+ if (m_xml.name() == "method"_L1) {
QDBusIntrospection::Method methodData;
- if (parseMethod(xml, methodData, ifaceData))
- ifaceData->methods.insert(methodData.name, methodData);
- } else if (xml.name() == QLatin1String("signal")) {
+ methodData.location = m_currentLocation;
+ if (parseMethod(methodData))
+ m_currentInterface->methods.insert(methodData.name, methodData);
+ } else if (m_xml.name() == "signal"_L1) {
QDBusIntrospection::Signal signalData;
- if (parseSignal(xml, signalData, ifaceData))
- ifaceData->signals_.insert(signalData.name, signalData);
- } else if (xml.name() == QLatin1String("property")) {
+ signalData.location = m_currentLocation;
+ if (parseSignal(signalData))
+ m_currentInterface->signals_.insert(signalData.name, signalData);
+ } else if (m_xml.name() == "property"_L1) {
QDBusIntrospection::Property propertyData;
- if (parseProperty(xml, propertyData, ifaceData))
- ifaceData->properties.insert(propertyData.name, propertyData);
- } else if (xml.name() == QLatin1String("annotation")) {
- parseAnnotation(xml, ifaceData->annotations, ifaceData, true);
- xml.skipCurrentElement(); // skip over annotation object
+ propertyData.location = m_currentLocation;
+ if (parseProperty(propertyData))
+ m_currentInterface->properties.insert(propertyData.name, propertyData);
+ } else if (m_xml.name() == "annotation"_L1) {
+ parseAnnotation(m_currentInterface->annotations, true);
+ m_xml.skipCurrentElement(); // skip over annotation object
} else {
- if (xml.prefix().isEmpty()) {
- qDBusParserError() << "Unknown element while parsing interface" << xml.name();
+ if (m_xml.prefix().isEmpty()) {
+ qDBusParserWarning("Unknown element '%s' while parsing interface",
+ qPrintable(m_xml.name().toString()));
}
- xml.skipCurrentElement();
+ m_xml.skipCurrentElement();
}
}
- ifaceData->introspection += QLatin1String(" </interface>");
+ m_currentInterface->introspection += " </interface>"_L1;
- interfaces->insert(ifaceName, QSharedDataPointer<QDBusIntrospection::Interface>(ifaceData));
+ m_interfaces.insert(
+ ifaceName,
+ QSharedDataPointer<QDBusIntrospection::Interface>(m_currentInterface.release()));
- if (!xml.isEndElement() || xml.name() != QLatin1String("interface")) {
- qDBusParserError() << "Invalid Interface specification";
+ if (!m_xml.isEndElement() || m_xml.name() != "interface"_L1) {
+ qDBusParserError("Invalid Interface specification");
}
}
-static void readNode(const QXmlStreamReader &xml, QDBusIntrospection::Object *objData, int nodeLevel)
+void QDBusXmlParser::readNode(int nodeLevel)
{
- const QString objName = xml.attributes().value(QLatin1String("name")).toString();
- const QString fullName = objData->path.endsWith(QLatin1Char('/'))
- ? (objData->path + objName)
- : QString(objData->path + QLatin1Char('/') + objName);
+ const QString objName = m_xml.attributes().value("name"_L1).toString();
+ QString fullName = m_object->path;
+ if (!(fullName.endsWith(u'/') || (nodeLevel == 0 && objName.startsWith(u'/'))))
+ fullName.append(u'/');
+ fullName += objName;
+
if (!QDBusUtil::isValidObjectPath(fullName)) {
- qDBusParserError("Invalid D-BUS object path '%s' found while parsing introspection",
- qPrintable(fullName));
+ qDBusParserError("Invalid D-Bus object path '%s' found while parsing introspection",
+ qPrintable(fullName));
return;
}
if (nodeLevel > 0)
- objData->childObjects.append(objName);
+ m_object->childObjects.append(objName);
+ else
+ m_object->location = m_currentLocation;
}
-QDBusXmlParser::QDBusXmlParser(const QString& service, const QString& path,
- const QString& xmlData)
- : m_service(service), m_path(path), m_object(new QDBusIntrospection::Object)
+void QDBusXmlParser::updateCurrentLocation()
{
-// qDBusParserError() << "parsing" << xmlData;
+ m_currentLocation =
+ QDBusIntrospection::SourceLocation{ m_xml.lineNumber(), m_xml.columnNumber() };
+}
+// Similar to m_xml.readNextElement() but sets current location to point
+// to the start element.
+bool QDBusXmlParser::readNextStartElement()
+{
+ updateCurrentLocation();
+
+ while (m_xml.readNext() != QXmlStreamReader::Invalid) {
+ if (m_xml.isEndElement())
+ return false;
+ else if (m_xml.isStartElement())
+ return true;
+ updateCurrentLocation();
+ }
+ return false;
+}
+
+QDBusXmlParser::QDBusXmlParser(const QString &service, const QString &path, const QString &xmlData,
+ QDBusIntrospection::DiagnosticsReporter *reporter)
+ : m_service(service),
+ m_path(path),
+ m_object(new QDBusIntrospection::Object),
+ m_xml(xmlData),
+ m_reporter(reporter)
+{
m_object->service = m_service;
m_object->path = m_path;
- QXmlStreamReader xml(xmlData);
-
int nodeLevel = -1;
- while (!xml.atEnd()) {
- xml.readNext();
+ while (!m_xml.atEnd()) {
+ updateCurrentLocation();
+ m_xml.readNext();
- switch (xml.tokenType()) {
+ switch (m_xml.tokenType()) {
case QXmlStreamReader::StartElement:
- if (xml.name() == QLatin1String("node")) {
- readNode(xml, m_object, ++nodeLevel);
- } else if (xml.name() == QLatin1String("interface")) {
- readInterface(xml, m_object, &m_interfaces);
+ if (m_xml.name() == "node"_L1) {
+ readNode(++nodeLevel);
+ } else if (m_xml.name() == "interface"_L1) {
+ readInterface();
} else {
- if (xml.prefix().isEmpty()) {
- qDBusParserError() << "skipping unknown element" << xml.name();
+ if (m_xml.prefix().isEmpty()) {
+ qDBusParserWarning("Skipping unknown element '%s'",
+ qPrintable(m_xml.name().toString()));
}
- xml.skipCurrentElement();
+ m_xml.skipCurrentElement();
}
break;
case QXmlStreamReader::EndElement:
- if (xml.name() == QLatin1String("node")) {
+ if (m_xml.name() == "node"_L1) {
--nodeLevel;
} else {
- qDBusParserError() << "Invalid Node declaration" << xml.name();
+ qDBusParserError("Invalid node declaration '%s'",
+ qPrintable(m_xml.name().toString()));
}
break;
case QXmlStreamReader::StartDocument:
@@ -387,18 +418,17 @@ QDBusXmlParser::QDBusXmlParser(const QString& service, const QString& path,
break;
case QXmlStreamReader::Characters:
// ignore whitespace
- if (xml.isWhitespace())
+ if (m_xml.isWhitespace())
break;
Q_FALLTHROUGH();
default:
- qDBusParserError() << "unknown token" << xml.name() << xml.tokenString();
+ qDBusParserError("Unknown token: '%s'", qPrintable(m_xml.tokenString()));
break;
}
}
- if (xml.hasError()) {
- qDBusParserError() << "xml error" << xml.errorString() << "doc" << xmlData;
- }
+ if (m_xml.hasError())
+ qDBusParserError("XML error: %s", qPrintable(m_xml.errorString()));
}
QT_END_NAMESPACE
diff --git a/src/dbus/qdbusxmlparser_p.h b/src/dbus/qdbusxmlparser_p.h
index d089bae163..0476ba3628 100644
--- a/src/dbus/qdbusxmlparser_p.h
+++ b/src/dbus/qdbusxmlparser_p.h
@@ -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
#ifndef QDBUSXMLPARSER_P_H
#define QDBUSXMLPARSER_P_H
@@ -54,6 +18,7 @@
#include <QtDBus/private/qtdbusglobal_p.h>
#include <QtCore/qloggingcategory.h>
#include <QtCore/qmap.h>
+#include <QtCore/qxmlstream.h>
#include "qdbusintrospection_p.h"
#ifndef QT_NO_DBUS
@@ -70,14 +35,30 @@ class QDBusXmlParser
QString m_service;
QString m_path;
QSharedDataPointer<QDBusIntrospection::Object> m_object;
+ std::unique_ptr<QDBusIntrospection::Interface> m_currentInterface;
QDBusIntrospection::Interfaces m_interfaces;
+ QXmlStreamReader m_xml;
+ QDBusIntrospection::SourceLocation m_currentLocation;
+ QDBusIntrospection::DiagnosticsReporter *m_reporter;
public:
- QDBusXmlParser(const QString& service, const QString& path,
- const QString& xmlData);
+ QDBusXmlParser(const QString &service, const QString &path, const QString &xmlData,
+ QDBusIntrospection::DiagnosticsReporter *reporter = nullptr);
inline QDBusIntrospection::Interfaces interfaces() const { return m_interfaces; }
inline QSharedDataPointer<QDBusIntrospection::Object> object() const { return m_object; }
+
+private:
+ void readNode(int nodeLevel);
+ void readInterface();
+ bool parseSignal(QDBusIntrospection::Signal &signalData);
+ bool parseMethod(QDBusIntrospection::Method &methodData);
+ bool parseProperty(QDBusIntrospection::Property &propertyData);
+ bool parseAnnotation(QDBusIntrospection::Annotations &annotations,
+ bool interfaceAnnotation = false);
+ bool parseArg(const QXmlStreamAttributes &attributes, QDBusIntrospection::Argument &argData);
+ bool readNextStartElement();
+ void updateCurrentLocation();
};
QT_END_NAMESPACE
diff --git a/src/dbus/qt_attribution.json b/src/dbus/qt_attribution.json
index 6cfe6ab2af..a4c4446862 100644
--- a/src/dbus/qt_attribution.json
+++ b/src/dbus/qt_attribution.json
@@ -11,8 +11,8 @@
"LicenseId": "AFL-2.1 OR GPL-2.0-or-later",
"License": "Academic Free License v2.1, or GNU General Public License v2.0 or later",
"LicenseFile": "LIBDBUS-1-LICENSE.txt",
- "Files": "Fragments from various upstream files, see comments in ...",
+ "Comment": "Fragments from various upstream files, see comments in ...",
"Files": "dbus_minimal_p.h",
- "Copyright": "Copyright (C) 2002, 2003 CodeFactory AB
-Copyright (C) 2004, 2005 Red Hat, Inc."
+ "Copyright": ["Copyright (C) 2002, 2003 CodeFactory AB",
+ "Copyright (C) 2004, 2005 Red Hat, Inc."]
}
diff --git a/src/dbus/qtdbusglobal.h b/src/dbus/qtdbusglobal.h
index 69c1afb085..9724c066f6 100644
--- a/src/dbus/qtdbusglobal.h
+++ b/src/dbus/qtdbusglobal.h
@@ -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
#ifndef QTDBUSGLOBAL_H
#define QTDBUSGLOBAL_H
diff --git a/src/dbus/qtdbusglobal_p.h b/src/dbus/qtdbusglobal_p.h
index c2788f5c23..9d315de75c 100644
--- a/src/dbus/qtdbusglobal_p.h
+++ b/src/dbus/qtdbusglobal_p.h
@@ -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
#ifndef QTDBUSGLOBAL_P_H
#define QTDBUSGLOBAL_P_H