From 71efca99daff2fdc3d4b405a2fc191264872dffd Mon Sep 17 00:00:00 2001 From: Holden <68555040+HTRamsey@users.noreply.github.com> Date: Mon, 13 May 2024 17:23:22 -0700 Subject: [PATCH] QtAndroidSerialPort: Rebase on Latest QSerialPortInfo (#11525) --- libs/qtandroidserialport/CMakeLists.txt | 3 + libs/qtandroidserialport/qserialportglobal.h | 12 ++ libs/qtandroidserialport/qserialportinfo.cpp | 121 ++++------- libs/qtandroidserialport/qserialportinfo.h | 49 +---- .../qserialportinfo_android.cpp | 201 ++++++++---------- libs/qtandroidserialport/qserialportinfo_p.h | 59 +---- .../qtandroidserialport.pri | 5 +- .../qtandroidserialport/qtserialportexports.h | 50 +++++ .../qtandroidserialport/qtserialportversion.h | 9 + 9 files changed, 225 insertions(+), 284 deletions(-) create mode 100644 libs/qtandroidserialport/qserialportglobal.h create mode 100644 libs/qtandroidserialport/qtserialportexports.h create mode 100644 libs/qtandroidserialport/qtserialportversion.h diff --git a/libs/qtandroidserialport/CMakeLists.txt b/libs/qtandroidserialport/CMakeLists.txt index a985b6c1ca2..7730017cc31 100644 --- a/libs/qtandroidserialport/CMakeLists.txt +++ b/libs/qtandroidserialport/CMakeLists.txt @@ -10,10 +10,13 @@ qt_add_library(qtandroidserialport STATIC qserialport_p.h qserialport_android.cpp qserialport_android_p.h + qserialportglobal.h qserialportinfo.cpp qserialportinfo.h qserialportinfo_p.h qserialportinfo_android.cpp + qtserialportexports.h + qtserialportversion.h ) target_link_libraries(qtandroidserialport diff --git a/libs/qtandroidserialport/qserialportglobal.h b/libs/qtandroidserialport/qserialportglobal.h new file mode 100644 index 00000000000..6ed2cbdc1c6 --- /dev/null +++ b/libs/qtandroidserialport/qserialportglobal.h @@ -0,0 +1,12 @@ +// Copyright (C) 2012 Denis Shienkov +// Copyright (C) 2012 Laszlo Papp +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSERIALPORTGLOBAL_H +#define QSERIALPORTGLOBAL_H + +#include +#include +#include "qtserialportexports.h" + +#endif // QSERIALPORTGLOBAL_H diff --git a/libs/qtandroidserialport/qserialportinfo.cpp b/libs/qtandroidserialport/qserialportinfo.cpp index be3eed17c55..24f88ae4664 100644 --- a/libs/qtandroidserialport/qserialportinfo.cpp +++ b/libs/qtandroidserialport/qserialportinfo.cpp @@ -1,44 +1,21 @@ -/**************************************************************************** -** -** Copyright (C) 2011-2012 Denis Shienkov -** Copyright (C) 2011 Sergey Belyashov -** Copyright (C) 2012 Laszlo Papp -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSerialPort module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2011-2012 Denis Shienkov +// Copyright (C) 2011 Sergey Belyashov +// Copyright (C) 2012 Laszlo Papp +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qserialportinfo.h" #include "qserialportinfo_p.h" #include "qserialport.h" +#include "qserialport_android_p.h" QT_BEGIN_NAMESPACE +// We changed from QScopedPointer to std::unique_ptr, make sure it's +// binary compatible. The QScopedPointer had a non-default deleter, but +// the deleter just provides a static function to use for deletion so we don't +// include it in this template definition (the deleter-class was deleted). +static_assert(sizeof(std::unique_ptr) + == sizeof(QScopedPointer)); /*! \class QSerialPortInfo @@ -49,12 +26,20 @@ QT_BEGIN_NAMESPACE \inmodule QtSerialPort \since 5.1 - Use the static functions to generate a list of QSerialPortInfo - objects. Each QSerialPortInfo object in the list represents a single - serial port and can be queried for the port name, system location, - description, and manufacturer. The QSerialPortInfo class can also be - used as an input parameter for the setPort() method of the QSerialPort - class. + Use the static \l availablePorts() function to generate a list of + QSerialPortInfo objects. Each QSerialPortInfo object in the list represents + a single serial port and can be queried for the \l {portName}{port name}, + \l {systemLocation}{system location}, \l description, \l manufacturer, and + some other hardware parameters. The QSerialPortInfo class can also be + used as an input parameter for the \l {QSerialPort::}{setPort()} method of + the QSerialPort class. + + \section1 Example Usage + + The example code enumerates all available serial ports and prints their + parameters to console: + + \snippet doc_src_serialport.cpp enumerate_ports \sa QSerialPort */ @@ -72,7 +57,7 @@ QSerialPortInfo::QSerialPortInfo() Constructs a copy of \a other. */ QSerialPortInfo::QSerialPortInfo(const QSerialPortInfo &other) - : d_ptr(other.d_ptr ? new QSerialPortInfoPrivate(*other.d_ptr) : Q_NULLPTR) + : d_ptr(other.d_ptr ? new QSerialPortInfoPrivate(*other.d_ptr) : nullptr) { } @@ -80,13 +65,8 @@ QSerialPortInfo::QSerialPortInfo(const QSerialPortInfo &other) Constructs a QSerialPortInfo object from serial \a port. */ QSerialPortInfo::QSerialPortInfo(const QSerialPort &port) + : QSerialPortInfo(port.portName()) { - foreach (const QSerialPortInfo &serialPortInfo, availablePorts()) { - if (port.portName() == serialPortInfo.portName()) { - *this = serialPortInfo; - break; - } - } } /*! @@ -98,9 +78,10 @@ QSerialPortInfo::QSerialPortInfo(const QSerialPort &port) */ QSerialPortInfo::QSerialPortInfo(const QString &name) { - foreach (const QSerialPortInfo &serialPortInfo, availablePorts()) { - if (name == serialPortInfo.portName()) { - *this = serialPortInfo; + const auto infos = QSerialPortInfo::availablePorts(); + for (const QSerialPortInfo &info : infos) { + if (name == info.portName()) { + *this = info; break; } } @@ -119,8 +100,7 @@ QSerialPortInfo::~QSerialPortInfo() { } -/*! \fn void QSerialPortInfo::swap(QSerialPortInfo &other) - +/*! Swaps QSerialPortInfo \a other with this QSerialPortInfo. This operation is very fast and never fails. */ @@ -225,8 +205,8 @@ quint16 QSerialPortInfo::productIdentifier() const } /*! - Returns true if there is a valid 16-bit vendor number present; otherwise - returns false. + Returns \c true if there is a valid \c 16-bit vendor number present; otherwise + returns \c false. \sa vendorIdentifier(), productIdentifier(), hasProductIdentifier() */ @@ -237,8 +217,8 @@ bool QSerialPortInfo::hasVendorIdentifier() const } /*! - Returns true if there is a valid 16-bit product number present; otherwise - returns false. + Returns \c true if there is a valid \c 16-bit product number present; otherwise + returns \c false. \sa productIdentifier(), vendorIdentifier(), hasVendorIdentifier() */ @@ -253,35 +233,18 @@ bool QSerialPortInfo::hasProductIdentifier() const Returns whether this QSerialPortInfo object holds a serial port definition. - - \sa isBusy() -*/ - -/*! - \fn bool QSerialPortInfo::isBusy() const - - Returns true if serial port is busy; - otherwise returns false. - - \sa isNull() -*/ - -/*! - \fn bool QSerialPortInfo::isValid() const - \obsolete - - Returns true if serial port is present on system; - otherwise returns false. - - \sa isNull(), isBusy() */ /*! \fn QList QSerialPortInfo::standardBaudRates() - Returns a list of available standard baud rates supported by - the current serial port. + Returns a list of available standard baud rates supported + by the target platform. */ +QList QSerialPortInfo::standardBaudRates() +{ + return QSerialPortPrivate::standardBaudRates(); +} /*! \fn QList QSerialPortInfo::availablePorts() diff --git a/libs/qtandroidserialport/qserialportinfo.h b/libs/qtandroidserialport/qserialportinfo.h index dde6909e749..8b5b6543f2a 100644 --- a/libs/qtandroidserialport/qserialportinfo.h +++ b/libs/qtandroidserialport/qserialportinfo.h @@ -1,36 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Denis Shienkov -** Copyright (C) 2012 Laszlo Papp -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSerialPort module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2012 Denis Shienkov +// Copyright (C) 2012 Laszlo Papp +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QSERIALPORTINFO_H #define QSERIALPORTINFO_H @@ -38,12 +8,14 @@ #include #include +#include "qserialportglobal.h" + QT_BEGIN_NAMESPACE class QSerialPort; class QSerialPortInfoPrivate; -class QSerialPortInfo +class Q_SERIALPORT_EXPORT QSerialPortInfo { Q_DECLARE_PRIVATE(QSerialPortInfo) public: @@ -69,21 +41,16 @@ class QSerialPortInfo bool hasProductIdentifier() const; bool isNull() const; - bool isBusy() const; -#if QT_DEPRECATED_SINCE(5, 2) - QT_DEPRECATED bool isValid() const; -#endif static QList standardBaudRates(); static QList availablePorts(); - std::unique_ptr d_ptr; - private: QSerialPortInfo(const QSerialPortInfoPrivate &dd); friend QList availablePortsByUdev(bool &ok); friend QList availablePortsBySysfs(bool &ok); - friend QList availablePortsByFiltersOfDevices(); + friend QList availablePortsByFiltersOfDevices(bool &ok); + std::unique_ptr d_ptr; }; inline bool QSerialPortInfo::isNull() const diff --git a/libs/qtandroidserialport/qserialportinfo_android.cpp b/libs/qtandroidserialport/qserialportinfo_android.cpp index 75a0f0306d8..344e66fed98 100644 --- a/libs/qtandroidserialport/qserialportinfo_android.cpp +++ b/libs/qtandroidserialport/qserialportinfo_android.cpp @@ -1,158 +1,133 @@ -/**************************************************************************** -** -** Copyright (C) 2011-2012 Denis Shienkov -** Copyright (C) 2011 Sergey Belyashov -** Copyright (C) 2012 Laszlo Papp -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSerialPort module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2011-2012 Denis Shienkov +// Copyright (C) 2011 Sergey Belyashov +// Copyright (C) 2012 Laszlo Papp +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qserialportinfo.h" #include "qserialportinfo_p.h" -#include "qserialport_android_p.h" +#include "qserialport_p.h" -#include -#include +#include #include #include -#include +#include -QT_BEGIN_NAMESPACE -static const char V_jniClassName[] {"org/mavlink/qgroundcontrol/QGCActivity"}; -static const char V_TAG[] {"QGC_QSerialPortInfo"}; +QGC_LOGGING_CATEGORY(QSerialPortInfo_AndroidLog, "qgc.libs.qtandroidserialport.qserialportinfo_android") + +static constexpr const char* jniClassName = "org/mavlink/qgroundcontrol/QGCActivity"; -extern void cleanJavaException(); +QT_BEGIN_NAMESPACE -QList availablePortsByFiltersOfDevices() +QList availablePortsByFiltersOfDevices(bool &ok) { - QList serialPortInfoList; + QJniEnvironment env; + if (!env.isValid()) { + qCWarning(QSerialPortInfo_AndroidLog) << "Invalid QJniEnvironment"; + return QList(); + } - QJniObject resultL = QJniObject::callStaticObjectMethod( - V_jniClassName, - "availableDevicesInfo", - "()[Ljava/lang/String;"); - - if (!resultL.isValid()) { - // No devices found - return serialPortInfoList; + if (!QJniObject::isClassAvailable(jniClassName)) { + qCWarning(QSerialPortInfo_AndroidLog) << "Class Not Available"; + return QList(); + } + + jclass javaClass = env.findClass(jniClassName); + if (!javaClass) { + ok = false; + qCWarning(QSerialPortInfo_AndroidLog) << "Class Not Found"; + return QList(); } - QJniEnvironment envL; - jobjectArray objArrayL = resultL.object(); - int countL = envL->GetArrayLength(objArrayL); + jmethodID methodId = env.findStaticMethod(javaClass, "availableDevicesInfo"); + if (!methodId) { + ok = false; + qCWarning(QSerialPortInfo_AndroidLog) << "Method Not Found"; + return QList(); + } + + const QJniObject result = QJniObject::callStaticMethod(javaClass, methodId); + if (!result.isValid()) { + ok = false; + qCWarning(QSerialPortInfo_AndroidLog) << "Method Call Failed"; + return QList(); + } + + QList serialPortInfoList; + + const jobjectArray objArray = result.object(); + const jsize count = env->GetArrayLength(objArray); + + for (jsize i = 0; i < count; i++) { + jobject obj = env->GetObjectArrayElement(objArray, i); + jstring string = static_cast(obj); + const char *rawString = env->GetStringUTFChars(string, 0); + qCDebug(QSerialPortInfo_AndroidLog) << "Adding device" << rawString; + + const QStringList strList = QString::fromUtf8(rawString).split(QStringLiteral(":")); + env->ReleaseStringUTFChars(string, rawString); + env->DeleteLocalRef(string); + + if (strList.size() < 4) { + qCWarning(QSerialPortInfo_AndroidLog) << "Invalid device info"; + continue; + } - for (int iL = 0; iL < countL; iL++) - { QSerialPortInfoPrivate priv; - jstring stringL = (jstring)(envL->GetObjectArrayElement(objArrayL, iL)); - const char *rawStringL = envL->GetStringUTFChars(stringL, 0); - __android_log_print(ANDROID_LOG_INFO, V_TAG, "Adding device: %s", rawStringL); - QStringList strListL = QString::fromUtf8(rawStringL).split(QStringLiteral(":")); - envL->ReleaseStringUTFChars(stringL, rawStringL); - envL->DeleteLocalRef(stringL); - - priv.portName = strListL[0]; - priv.device = strListL[0]; - priv.manufacturer = strListL[1]; - priv.productIdentifier = strListL[2].toInt(); - priv.hasProductIdentifier = (priv.productIdentifier != 0) ? true: false; - priv.vendorIdentifier = strListL[3].toInt(); - priv.hasVendorIdentifier = (priv.vendorIdentifier != 0) ? true: false; + + priv.portName = strList.at(0); + priv.device = strList.at(0); + // priv.description = strList.at(); + priv.manufacturer = strList.at(1); + // priv.serialNumber = strList.at(); + priv.productIdentifier = strList.at(2).toInt(); + priv.hasProductIdentifier = (priv.productIdentifier != 0); + priv.vendorIdentifier = strList.at(3).toInt(); + priv.hasVendorIdentifier = (priv.vendorIdentifier != 0); serialPortInfoList.append(priv); } + ok = true; return serialPortInfoList; } -QList availablePortsBySysfs() +QList availablePortsBySysfs(bool &ok) { - return availablePortsByFiltersOfDevices(); + ok = false; + return QList(); } -QList availablePortsByUdev() +QList availablePortsByUdev(bool &ok) { - return availablePortsByFiltersOfDevices(); + ok = false; + return QList(); } QList QSerialPortInfo::availablePorts() { - return availablePortsByFiltersOfDevices(); -} - -QList QSerialPortInfo::standardBaudRates() -{ - return QSerialPortPrivate::standardBaudRates(); -} - -bool QSerialPortInfo::isBusy() const -{ - QJniObject jstrL = QJniObject::fromString(d_ptr->portName); - cleanJavaException(); - jboolean resultL = QJniObject::callStaticMethod( - V_jniClassName, - "isDeviceNameOpen", - "(Ljava/lang/String;)Z", - jstrL.object()); - cleanJavaException(); - return resultL; -} + bool ok = false; + const QList serialPortInfoList = availablePortsByFiltersOfDevices(ok); -#if QT_DEPRECATED_SINCE(5, 2) -bool QSerialPortInfo::isValid() const -{ - QJniObject jstrL = QJniObject::fromString(d_ptr->portName); - cleanJavaException(); - jboolean resultL = QJniObject::callStaticMethod( - V_jniClassName, - "isDeviceNameValid", - "(Ljava/lang/String;)Z", - jstrL.object()); - cleanJavaException(); - return resultL; + if (ok) { + return serialPortInfoList; + } else { + return QList(); + } } -#endif QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source) { return (source.startsWith(QLatin1Char('/')) - || source.startsWith(QStringLiteral("./")) - || source.startsWith(QStringLiteral("../"))) - ? source : (QStringLiteral("/dev/") + source); + || source.startsWith(QLatin1String("./")) + || source.startsWith(QLatin1String("../"))) + ? source : (QLatin1String("/dev/") + source); } QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source) { - return source.startsWith(QStringLiteral("/dev/")) + return source.startsWith(QLatin1String("/dev/")) ? source.mid(5) : source; } QT_END_NAMESPACE - diff --git a/libs/qtandroidserialport/qserialportinfo_p.h b/libs/qtandroidserialport/qserialportinfo_p.h index 4ca97f96f25..1a949f08e57 100644 --- a/libs/qtandroidserialport/qserialportinfo_p.h +++ b/libs/qtandroidserialport/qserialportinfo_p.h @@ -1,37 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2011-2012 Denis Shienkov -** Copyright (C) 2011 Sergey Belyashov -** Copyright (C) 2012 Laszlo Papp -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSerialPort module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2011-2012 Denis Shienkov +// Copyright (C) 2017 Sergey Belyashov +// Copyright (C) 2013 Laszlo Papp +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QSERIALPORTINFO_P_H #define QSERIALPORTINFO_P_H @@ -48,24 +18,13 @@ // #include +#include QT_BEGIN_NAMESPACE class Q_AUTOTEST_EXPORT QSerialPortInfoPrivate { public: - QSerialPortInfoPrivate() - : vendorIdentifier(0) - , productIdentifier(0) - , hasVendorIdentifier(false) - , hasProductIdentifier(false) - { - } - - ~QSerialPortInfoPrivate() - { - } - static QString portNameToSystemLocation(const QString &source); static QString portNameFromSystemLocation(const QString &source); @@ -75,11 +34,11 @@ class Q_AUTOTEST_EXPORT QSerialPortInfoPrivate QString manufacturer; QString serialNumber; - quint16 vendorIdentifier; - quint16 productIdentifier; + quint16 vendorIdentifier = 0; + quint16 productIdentifier = 0; - bool hasVendorIdentifier; - bool hasProductIdentifier; + bool hasVendorIdentifier = false; + bool hasProductIdentifier = false; }; QT_END_NAMESPACE diff --git a/libs/qtandroidserialport/qtandroidserialport.pri b/libs/qtandroidserialport/qtandroidserialport.pri index e4d8248c25a..8c8effc4ca4 100644 --- a/libs/qtandroidserialport/qtandroidserialport.pri +++ b/libs/qtandroidserialport/qtandroidserialport.pri @@ -6,7 +6,10 @@ android { PUBLIC_HEADERS += \ $$PWD/qserialport.h \ - $$PWD/qserialportinfo.h + $$PWD/qserialportinfo.h \ + $$PWD/qserialportglobal.h \ + $$PWD/qtserialportexports.h \ + $$PWD/qtserialportversion.h PRIVATE_HEADERS += \ $$PWD/qserialport_p.h \ diff --git a/libs/qtandroidserialport/qtserialportexports.h b/libs/qtandroidserialport/qtserialportexports.h new file mode 100644 index 00000000000..1d995f2999c --- /dev/null +++ b/libs/qtandroidserialport/qtserialportexports.h @@ -0,0 +1,50 @@ +// Copyright (C) 2022 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 QTSERIALPORTEXPORTS_H +#define QTSERIALPORTEXPORTS_H + +#include +#include // Q_SERIALPORT_EXPORT +#include // QT_IF_DEPRECATED_SINCE + +#if defined(QT_SHARED) || !defined(QT_STATIC) +# if defined(QT_BUILD_SERIALPORT_LIB) +# define Q_SERIALPORT_EXPORT Q_DECL_EXPORT +# else +# define Q_SERIALPORT_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_SERIALPORT_EXPORT +#endif + +#if !defined(QT_BUILD_SERIALPORT_LIB) && !defined(QT_STATIC) +/* outside library -> inline decl + defi */ +/* static builds treat everything as part of the library, so they never inline */ +# define QT_SERIALPORT_INLINE_SINCE(major, minor) inline +# define QT_SERIALPORT_INLINE_IMPL_SINCE(major, minor) 1 +#elif defined(QT_SERIALPORT_BUILD_REMOVED_API) +/* inside library, inside removed_api.cpp: + * keep deprecated API -> non-inline decl; + * remove deprecated API -> inline decl; + * definition is always available */ +# define QT_SERIALPORT_INLINE_SINCE(major, minor) \ + QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */) +# define QT_SERIALPORT_INLINE_IMPL_SINCE(major, minor) 1 +#else +/* inside library, outside removed_api.cpp: + * keep deprecated API -> non-inline decl, no defi; + * remove deprecated API -> inline decl, defi */ +# define QT_SERIALPORT_INLINE_SINCE(major, minor) \ + QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */) +# define QT_SERIALPORT_INLINE_IMPL_SINCE(major, minor) \ + QT_IF_DEPRECATED_SINCE(major, minor, 1, 0) +#endif + +#ifdef QT_SERIALPORT_BUILD_REMOVED_API +# define QT_SERIALPORT_REMOVED_SINCE(major, minor) QT_DEPRECATED_SINCE(major, minor) +#else +# define QT_SERIALPORT_REMOVED_SINCE(major, minor) 0 +#endif + +#endif // QTSERIALPORTEXPORTS_H diff --git a/libs/qtandroidserialport/qtserialportversion.h b/libs/qtandroidserialport/qtserialportversion.h new file mode 100644 index 00000000000..e5984dd54e6 --- /dev/null +++ b/libs/qtandroidserialport/qtserialportversion.h @@ -0,0 +1,9 @@ +/* This file was generated by syncqt. */ +#ifndef QT_QTSERIALPORT_VERSION_H +#define QT_QTSERIALPORT_VERSION_H + +#define QTSERIALPORT_VERSION_STR "6.6.3" + +#define QTSERIALPORT_VERSION 0x060603 + +#endif // QT_QTSERIALPORT_VERSION_H