diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 4c4f249fb..aef310736 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -74,7 +74,7 @@ endif() if (BLUETOOTH_ENABLED) target_compile_definitions(kdeconnectcore PRIVATE -DKDECONNECT_BLUETOOTH) - target_link_libraries(kdeconnectcore PRIVATE Qt5::Bluetooth) + target_link_libraries(kdeconnectcore PRIVATE Qt${QT_MAJOR_VERSION}::Bluetooth) endif() if (LOOPBACK_ENABLED) @@ -83,7 +83,7 @@ endif() if (MDNS_ENABLED) target_compile_definitions(kdeconnectcore PRIVATE -DKDECONNECT_MDNS) - target_link_libraries(kdeconnectcore PRIVATE KF5::DNSSD) + target_link_libraries(kdeconnectcore PRIVATE KF${QT_MAJOR_VERSION}::DNSSD) endif() set_target_properties(kdeconnectcore PROPERTIES diff --git a/core/backends/bluetooth/bluetoothlinkprovider.cpp b/core/backends/bluetooth/bluetoothlinkprovider.cpp index 56ad5c9e7..8497919c6 100644 --- a/core/backends/bluetooth/bluetoothlinkprovider.cpp +++ b/core/backends/bluetooth/bluetoothlinkprovider.cpp @@ -38,7 +38,7 @@ void BluetoothLinkProvider::onStart() } mBluetoothServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this); - mBluetoothServer->setSecurityFlags(QBluetooth::Encryption | QBluetooth::Secure); + mBluetoothServer->setSecurityFlags(QBluetooth::Security::Encryption | QBluetooth::Security::Secure); connect(mBluetoothServer, SIGNAL(newConnection()), this, SLOT(serverNewConnection())); mServiceDiscoveryAgent->start(); @@ -111,7 +111,7 @@ void BluetoothLinkProvider::serviceDiscovered(const QBluetoothServiceInfo &old_i qCDebug(KDECONNECT_CORE()) << "Connecting to" << info.device().address(); - if (socket->error() != QBluetoothSocket::NoSocketError) { + if (socket->error() != QBluetoothSocket::SocketError::NoSocketError) { qCWarning(KDECONNECT_CORE) << "Socket connection error:" << socket->errorString(); } } diff --git a/core/backends/bluetooth/connectionmultiplexer.cpp b/core/backends/bluetooth/connectionmultiplexer.cpp index d7820668f..4f7ccedb9 100644 --- a/core/backends/bluetooth/connectionmultiplexer.cpp +++ b/core/backends/bluetooth/connectionmultiplexer.cpp @@ -125,10 +125,16 @@ bool ConnectionMultiplexer::tryParseMessage() */ char message_type = header[0]; uint16_t message_length = qFromBigEndian(&header.data()[1]); +#if QT_VERSION_MAJOR == 5 quint128 message_uuid_raw; - for (int i = 0; i < 16; ++i) + for (int i = 0; i < 16; ++i) { message_uuid_raw.data[i] = header[3 + i]; + } QBluetoothUuid message_uuid = QBluetoothUuid(message_uuid_raw); +#else + const QByteArray uuisByteArray = header.sliced(3, 16); // Faster than mid, see https://doc.qt.io/qt-6/qbytearray.html#mid + QBluetoothUuid message_uuid = QBluetoothUuid::fromBytes(uuisByteArray.constData()); +#endif // Check if we have the full message including its data QByteArray data = mSocket->read(message_length); @@ -229,8 +235,13 @@ QBluetoothUuid ConnectionMultiplexer::newChannel() message[0] = MESSAGE_OPEN_CHANNEL; qToBigEndian(0, &message.data()[1]); - quint128 new_id_raw = new_id.toUInt128(); - message.append((const char *)new_id_raw.data, 16); +#if QT_VERSION_MAJOR == 5 + quint128 id_raw = new_id.toUInt128(); + message.append((const char *)id_raw.data, 16); +#else + const auto channelBytes = new_id.toByteArray(); + message.append(channelBytes.constData(), 16); +#endif to_write_bytes.append(message); // Add the channel ourselves @@ -337,8 +348,13 @@ void ConnectionMultiplexer::channelCanRead(QBluetoothUuid channelId) QByteArray message(3, (char)0); message[0] = MESSAGE_READ; qToBigEndian(2, &message.data()[1]); +#if QT_VERSION_MAJOR == 5 quint128 id_raw = channelId.toUInt128(); message.append((const char *)id_raw.data, 16); +#else + const auto channelBytes = channelId.toByteArray(); + message.append(channelBytes.constData(), 16); +#endif message.append(2, 0); qToBigEndian(read_amount, &message.data()[19]); to_write_bytes.append(message); @@ -367,8 +383,14 @@ void ConnectionMultiplexer::channelCanWrite(QBluetoothUuid channelId) message[0] = MESSAGE_WRITE; qToBigEndian(amount, &message.data()[1]); +#if QT_VERSION_MAJOR == 5 quint128 id_raw = channelId.toUInt128(); message.append((const char *)id_raw.data, 16); +#else + const auto channelBytes = channelId.toByteArray(); + message.append(channelBytes.constData(), 16); +#endif + message.append(data); to_write_bytes.append(message); // Try to send it immediately @@ -405,8 +427,13 @@ void ConnectionMultiplexer::closeChannel(QBluetoothUuid channelId) message[0] = MESSAGE_CLOSE_CHANNEL; qToBigEndian(0, &message.data()[1]); +#if QT_VERSION_MAJOR == 5 quint128 id_raw = channelId.toUInt128(); message.append((const char *)id_raw.data, 16); +#else + const auto channelBytes = channelId.toByteArray(); + message.append(channelBytes.constData(), 16); +#endif to_write_bytes.append(message); // Try to send it immediately bytesWritten();