Skip to content

Commit 6285bd2

Browse files
committed
qt6 support
1 parent 6a9b7a2 commit 6285bd2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+229
-200
lines changed

Diff for: 3rdparty/stringprep/CMakeLists.txt

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ set(CMAKE_AUTOMOC ON)
88
set(CMAKE_AUTORCC ON)
99
set(CMAKE_AUTOUIC ON)
1010

11-
find_package(Qt5 COMPONENTS Core REQUIRED)
11+
if(QT_DEFAULT_MAJOR_VERSION LESS 6)
12+
find_package(Qt5 5.10 REQUIRED COMPONENTS Core)
13+
else()
14+
find_package(Qt6 REQUIRED COMPONENTS Core)
15+
endif()
1216

1317
add_library(stringprep STATIC
1418
stringprep.cpp
1519
profiles.cpp
1620
rfc3454.cpp
21+
qstringprep.h
1722
)
1823

1924
target_compile_definitions(stringprep PRIVATE QSTRINGPREP_BUILDING)
@@ -22,5 +27,9 @@ if(MSVC)
2227
target_compile_definitions(stringprep PRIVATE _CRT_SECURE_NO_WARNINGS _GENERATED_STDINT_H)
2328
endif()
2429

25-
target_link_libraries(stringprep PUBLIC Qt5::Core)
30+
if(QT_DEFAULT_MAJOR_VERSION LESS 6)
31+
target_link_libraries(stringprep PUBLIC Qt5::Core)
32+
else()
33+
target_link_libraries(stringprep PUBLIC Qt6::Core)
34+
endif()
2635
target_include_directories(stringprep PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

Diff for: CMakeLists.txt

+8-6
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,16 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR ("${CMAKE_BUILD_TYPE}" STREQUAL "Re
7474
include(debug-definitions)
7575
endif()
7676

77-
find_package(Qt5 COMPONENTS Core Gui Xml Network REQUIRED)
77+
if(QT_DEFAULT_MAJOR_VERSION STREQUAL "")
78+
set(QT_DEFAULT_MAJOR_VERSION 5)
79+
endif()
7880

79-
if(Qt5Core_FOUND)
80-
message(STATUS "Qt5 found, version ${Qt5Core_VERSION}")
81-
if(IRIS_BUNDLED_QCA AND ("${Qt5Core_VERSION}" VERSION_LESS "5.6"))
82-
message(FATAL_ERROR "Minimal Qt version for bundled Qca is 5.6. Please disable IRIS_BUNDLED_QCA option")
83-
endif()
81+
if(QT_DEFAULT_MAJOR_VERSION LESS 6)
82+
find_package(Qt5 5.10 REQUIRED COMPONENTS Core Gui Xml Network)
83+
else()
84+
find_package(Qt6 REQUIRED COMPONENTS Core Gui Xml Network)
8485
endif()
86+
message(STATUS "Qt${QT_DEFAULT_MAJOR_VERSION} found, version ${Qt6Core_VERSION}")
8587

8688
# Find QCA package or use bundled if enabled
8789
include(IrisQCA)

Diff for: cmake/modules/IrisQCA.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ if(IRIS_BUNDLED_QCA)
4040
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
4141
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
4242
-DOSX_FRAMEWORK=OFF)
43+
if(QT_DEFAULT_MAJOR_VERSION LESS 6)
44+
list(APPEND QCA_BUILD_OPTIONS -DBUILD_WITH_QT6=OFF)
45+
else()
46+
list(APPEND QCA_BUILD_OPTIONS -DBUILD_WITH_QT6=ON)
47+
endif()
4348
if (EXISTS ${QCA_SOURCE_DIR})
4449
message(STATUS "QCA: found bundled sources")
4550
ExternalProject_Add(QcaProject

Diff for: cmake/modules/policyRules.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ if(NOT POLICY_SET)
99
cmake_policy(SET CMP0074 NEW)
1010
message(STATUS "CMP0074 policy set to NEW")
1111
endif()
12-
set(POLICY_SET ON PARENT_SCOPE)
12+
set(POLICY_SET ON)
1313
endif()
1414

Diff for: src/irisnet/CMakeLists.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,15 @@ endif()
127127

128128
target_link_libraries(irisnet PUBLIC
129129
${Qca_LIBRARY} ${USRSCTP_LIBRARY}
130-
Qt5::Core Qt5::Network Qt5::Xml
131-
${EXTRA_LDFLAGS}
132130
)
133131

132+
if(QT_DEFAULT_MAJOR_VERSION LESS 6)
133+
target_link_libraries(irisnet PUBLIC Qt5::Core Qt5::Network Qt5::Xml)
134+
else()
135+
target_link_libraries(irisnet PUBLIC Qt6::Core Qt6::Network Qt6::Xml)
136+
endif()
137+
target_link_libraries(irisnet PUBLIC ${EXTRA_LDFLAGS})
138+
134139
if(IRIS_ENABLE_INSTALL)
135140
install(FILES ${IRISNET_CORELIB_HEADERS}
136141
DESTINATION ${IRIS_INSTALL_INCLUDEDIR}/irisnet/corelib

Diff for: src/irisnet/corelib/netinterface_qtname.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class IrisQtName : public NameProvider {
4040

4141
~IrisQtName()
4242
{
43-
for (auto const &l : qAsConst(lookups)) {
43+
for (auto const &l : std::as_const(lookups)) {
4444
if (!l.isHostInfo) {
4545
delete reinterpret_cast<QDnsLookup *>(l.handle);
4646
}

Diff for: src/irisnet/corelib/netinterface_unix.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static QHostAddress linux_ipv6_to_qaddr(const QString &in)
7474
quint8 raw[16];
7575
for (int n = 0; n < 16; ++n) {
7676
bool ok;
77-
int x = in.midRef(n * 2, 2).toInt(&ok, 16);
77+
int x = QStringView{in}.mid(n * 2, 2).toInt(&ok, 16);
7878
if (!ok)
7979
return out;
8080
raw[n] = (quint8)x;
@@ -92,7 +92,7 @@ static QHostAddress linux_ipv4_to_qaddr(const QString &in)
9292
unsigned char *rawp = (unsigned char *)&raw;
9393
for (int n = 0; n < 4; ++n) {
9494
bool ok;
95-
int x = in.midRef(n * 2, 2).toInt(&ok, 16);
95+
int x = QStringView{in}.mid(n * 2, 2).toInt(&ok, 16);
9696
if (!ok)
9797
return out;
9898
rawp[n] = (unsigned char)x;

Diff for: src/irisnet/corelib/netnames.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ XMPP::NameRecord WeightedNameRecordList::takeNext()
491491

492492
/* Find the new total weight of this priority group */
493493
int totalWeight = 0;
494-
for (const auto &record : qAsConst(currentPriorityGroup->second)) {
494+
for (const auto &record : std::as_const(currentPriorityGroup->second)) {
495495
totalWeight += record.weight();
496496
}
497497

@@ -740,7 +740,7 @@ class NameManager : public QObject {
740740
sub_instances_to_remove += it.key();
741741
}
742742

743-
for (int res_sub_id : qAsConst(sub_instances_to_remove)) {
743+
for (int res_sub_id : std::as_const(sub_instances_to_remove)) {
744744
res_sub_instances.remove(res_sub_id);
745745
p_local->resolve_stop(res_sub_id);
746746
}
@@ -1094,7 +1094,7 @@ void ServiceResolver::clear_resolvers()
10941094
#endif
10951095

10961096
/* cleanup all resolvers */
1097-
for (XMPP::NameResolver *resolver : qAsConst(d->resolverList)) {
1097+
for (XMPP::NameResolver *resolver : std::as_const(d->resolverList)) {
10981098
cleanup_resolver(resolver);
10991099
}
11001100
}

Diff for: src/irisnet/corelib/objectsession.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ObjectSessionPrivate : public QObject {
8484
return false;
8585
}
8686

87-
arg.data = QMetaType::create(arg.type, arg_data[n]);
87+
arg.data = QMetaType(arg.type).create(arg_data[n]);
8888
args += arg;
8989
}
9090

Diff for: src/irisnet/noncore/cutestuff/httpconnect.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static bool extractMainHeader(const QString &line, QString *proto, int *code, QS
8080
if (n2 == -1)
8181
return false;
8282
if (code)
83-
*code = line.midRef(n, n2 - n).toInt();
83+
*code = QStringView{line}.mid(n, n2 - n).toInt();
8484
n = n2 + 1;
8585
if (msg)
8686
*msg = line.mid(n);
@@ -269,7 +269,7 @@ void HttpConnect::sock_readyRead()
269269
#ifdef PROX_DEBUG
270270
fprintf(stderr, "HttpConnect: header proto=[%s] code=[%d] msg=[%s]\n", qPrintable(proto), code,
271271
qPrintable(msg));
272-
for (const auto &it : qAsConst(d->headerLines))
272+
for (const auto &it : std::as_const(d->headerLines))
273273
fprintf(stderr, "HttpConnect: * [%s]\n", qPrintable(it));
274274
#endif
275275
}

Diff for: src/irisnet/noncore/cutestuff/httppoll.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static bool extractMainHeader(const QString &line, QString *proto, int *code, QS
408408
if (n2 == -1)
409409
return false;
410410
if (code)
411-
*code = line.midRef(n, n2 - n).toInt();
411+
*code = QStringView{line}.mid(n, n2 - n).toInt();
412412
n = n2 + 1;
413413
if (msg)
414414
*msg = line.mid(n);
@@ -503,7 +503,7 @@ QByteArray HttpProxyPost::body() const { return d->body; }
503503

504504
QString HttpProxyPost::getHeader(const QString &var) const
505505
{
506-
for (const QString &s : qAsConst(d->headerLines)) {
506+
for (const QString &s : std::as_const(d->headerLines)) {
507507
int n = s.indexOf(": ");
508508
if (n == -1)
509509
continue;
@@ -776,7 +776,7 @@ void HttpProxyGetStream::stop() { resetConnection(); }
776776

777777
QString HttpProxyGetStream::getHeader(const QString &var) const
778778
{
779-
for (const QString &s : qAsConst(d->headerLines)) {
779+
for (const QString &s : std::as_const(d->headerLines)) {
780780
int n = s.indexOf(": ");
781781
if (n == -1)
782782
continue;

Diff for: src/irisnet/noncore/dtls.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool Dtls::FingerPrint::parse(const QDomElement &el)
6262
qPrintable(ns()));
6363
}
6464
auto ht = el.attribute(QLatin1String("hash"));
65-
hash = QStringRef(&ht);
65+
hash = QStringView{ht};
6666
hash.setData(QByteArray::fromHex(el.text().toLatin1()));
6767
auto setupIt = std::find(fpRoles.begin(), fpRoles.end(), el.attribute(QLatin1String("setup")).toLatin1());
6868
setup = Setup(setupIt == fpRoles.end() ? NotSet : std::distance(fpRoles.begin(), setupIt) + 1);

Diff for: src/irisnet/noncore/ice176.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ class Ice176::Private : public QObject {
675675
continue;
676676
}
677677

678-
for (const IceComponent::CandidateInfo::Ptr &rc : qAsConst(remoteCandidates)) {
678+
for (const IceComponent::CandidateInfo::Ptr &rc : std::as_const(remoteCandidates)) {
679679
auto pair = makeCandidatesPair(lc, rc);
680680
if (!pair.isNull())
681681
pairs += pair;
@@ -1087,7 +1087,7 @@ class Ice176::Private : public QObject {
10871087
void dumpCandidatesAndStart()
10881088
{
10891089
QList<Ice176::Candidate> list;
1090-
for (auto const &cc : qAsConst(localCandidates)) {
1090+
for (auto const &cc : std::as_const(localCandidates)) {
10911091
Ice176::Candidate c;
10921092
toOutCandidate(cc, c);
10931093
list += c;
@@ -1368,7 +1368,7 @@ private slots:
13681368
}
13691369

13701370
bool iceTransportInUse = false;
1371-
for (const IceComponent::Candidate &lc : qAsConst(localCandidates)) {
1371+
for (const IceComponent::Candidate &lc : std::as_const(localCandidates)) {
13721372
if (lc.iceTransport == cc.iceTransport) {
13731373
iceTransportInUse = true;
13741374
break;
@@ -1781,7 +1781,7 @@ QList<QHostAddress> Ice176::availableNetworkAddresses()
17811781
continue;
17821782

17831783
QList<QNetworkAddressEntry> entries = ni.addressEntries();
1784-
for (const QNetworkAddressEntry &na : qAsConst(entries)) {
1784+
for (const QNetworkAddressEntry &na : std::as_const(entries)) {
17851785
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
17861786
if (na.preferredLifetime().hasExpired() || na.netmask().isNull())
17871787
#else

Diff for: src/irisnet/noncore/iceagent.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ static QChar randomPrintableChar()
3232

3333
uchar c = static_cast<uchar>(QCA::Random::randomChar() % 62);
3434
if (c <= 25)
35-
return 'a' + c;
35+
return QChar::fromLatin1('a' + c);
3636
else if (c <= 51)
37-
return 'A' + (c - 26);
37+
return QChar::fromLatin1('A' + (c - 26));
3838
else
39-
return '0' + (c - 52);
39+
return QChar::fromLatin1('0' + (c - 52));
4040
}
4141

4242
struct IceAgent::Private {

Diff for: src/irisnet/noncore/icelocaltransport.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ private slots:
502502
ObjectSessionWatcher watch(&sess);
503503

504504
if (!dwrites.isEmpty()) {
505-
for (const Written &wr : qAsConst(dwrites)) {
505+
for (const Written &wr : std::as_const(dwrites)) {
506506
emit q->datagramsWritten(Direct, wr.count, wr.addr);
507507
if (!watch.isValid())
508508
return;

Diff for: src/irisnet/noncore/stunallocate.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ class StunAllocate::Private : public QObject {
751751
newList += StunAllocate::Channel(channels[n]->addr);
752752
}
753753

754-
if (newList == channelsOut)
754+
if (std::as_const(newList) == std::as_const(channelsOut))
755755
return false;
756756

757757
channelsOut = newList;

Diff for: src/irisnet/noncore/stunallocate.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class StunAllocate : public QObject {
4444

4545
Channel(const TransportAddress &_address) : address(_address) { }
4646

47-
inline bool operator==(const Channel &other) { return address == other.address; }
48-
inline bool operator!=(const Channel &other) { return !operator==(other); }
47+
inline bool operator==(const Channel &other) const { return address == other.address; }
48+
inline bool operator!=(const Channel &other) const { return !operator==(other); }
4949
};
5050

5151
StunAllocate(XMPP::StunTransactionPool *pool);

Diff for: src/irisnet/noncore/stuntransaction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ void StunTransactionPool::continueAfterParams(const TransportAddress &addr)
634634
d->needLongTermAuth = false;
635635
d->triedLongTermAuth.insert(addr);
636636

637-
for (StunTransaction *trans : qAsConst(d->transactions)) {
637+
for (StunTransaction *trans : std::as_const(d->transactions)) {
638638
// the only reason an inactive transaction would be in the
639639
// list is if it is waiting for an auth retry
640640
if (!trans->d->active && !trans->d->cancelling) {

Diff for: src/irisnet/noncore/stuntypes.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ namespace StunTypes {
477477
if (parseUnknownAttributes(val, &typeList)) {
478478
if (!typeList.isEmpty()) {
479479
QStringList strList;
480-
for (quint16 i : qAsConst(typeList))
480+
for (quint16 i : std::as_const(typeList))
481481
strList += QString::asprintf("0x%04x", i);
482482
return strList.join(", ");
483483
} else

Diff for: src/irisnet/noncore/udpportreserver.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class UdpPortReserver::Private : public QObject {
7777
if (lendingAny)
7878
abort();
7979

80-
for (const Item &i : qAsConst(items)) {
80+
for (const Item &i : std::as_const(items)) {
8181
for (QUdpSocket *sock : i.sockList)
8282
sock->deleteLater();
8383
}
@@ -96,7 +96,7 @@ class UdpPortReserver::Private : public QObject {
9696
QList<int> added;
9797
for (int x : newPorts) {
9898
bool found = false;
99-
for (const Item &i : qAsConst(items)) {
99+
for (const Item &i : std::as_const(items)) {
100100
if (i.port == x) {
101101
found = true;
102102
break;
@@ -112,7 +112,7 @@ class UdpPortReserver::Private : public QObject {
112112
// keep ports in sorted order
113113
std::sort(ports.begin(), ports.end());
114114

115-
for (int x : qAsConst(added)) {
115+
for (int x : std::as_const(added)) {
116116
int insert_before = items.count();
117117
for (int n = 0; n < items.count(); ++n) {
118118
if (x < items[n].port) {
@@ -240,12 +240,12 @@ private slots:
240240
continue;
241241

242242
QList<QHostAddress> neededAddrs;
243-
for (const QHostAddress &a : qAsConst(addrs)) {
243+
for (const QHostAddress &a : std::as_const(addrs)) {
244244
if (!i.haveAddress(a))
245245
neededAddrs += a;
246246
}
247247

248-
for (const QHostAddress &a : qAsConst(neededAddrs)) {
248+
for (const QHostAddress &a : std::as_const(neededAddrs)) {
249249
QUdpSocket *sock = new QUdpSocket(q);
250250

251251
if (!sock->bind(a, quint16(i.port))) {
@@ -267,7 +267,7 @@ private slots:
267267

268268
// don't care about this port anymore?
269269
if (!i.lent && !ports.contains(i.port)) {
270-
for (QUdpSocket *sock : qAsConst(i.sockList))
270+
for (QUdpSocket *sock : std::as_const(i.sockList))
271271
sock->deleteLater();
272272

273273
items.removeAt(n);
@@ -338,7 +338,7 @@ private slots:
338338
QList<QUdpSocket *> out;
339339

340340
i->lent = true;
341-
for (QUdpSocket *sock : qAsConst(i->sockList)) {
341+
for (QUdpSocket *sock : std::as_const(i->sockList)) {
342342
i->lentAddrs += sock->localAddress();
343343
sock->disconnect(this);
344344
sock->setParent(parent);

Diff for: src/xmpp/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ target_link_libraries(iris
207207
ZLIB::ZLIB
208208
PUBLIC
209209
${Qca_LIBRARY}
210-
Qt5::Core Qt5::Gui Qt5::Network Qt5::Xml
210+
Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Xml
211211
)
212212

213213
if(IRIS_BUNDLED_QCA)
@@ -237,6 +237,7 @@ else()
237237
target_include_directories(iris
238238
PRIVATE
239239
${iris_SOURCE_DIR}/include
240+
${iris_SOURCE_DIR}/include/iris
240241
${iris_SOURCE_DIR}/src
241242
${Qca_INCLUDE_DIR}
242243
)

0 commit comments

Comments
 (0)