From 09dd48f24094165eb317563f69e56410d0bb86f3 Mon Sep 17 00:00:00 2001 From: Sergei Ilinykh Date: Mon, 18 Mar 2024 02:15:43 +0300 Subject: [PATCH] Fixed deprecation warnings --- 3rdparty/stringprep/stringprep.cpp | 8 +++++--- src/irisnet/corelib/objectsession.cpp | 12 ++++++++++++ src/irisnet/noncore/cutestuff/httppoll.cpp | 2 +- src/irisnet/noncore/ice176.cpp | 6 +++--- src/irisnet/noncore/stunbinding.cpp | 20 ++++++++++---------- src/irisnet/noncore/stuntypes.cpp | 2 +- src/irisnet/noncore/tcpportreserver.h | 2 +- src/xmpp/jid/jid.cpp | 4 ++-- src/xmpp/jid/jid.h | 5 ++--- src/xmpp/xmpp-im/jingle-application.h | 6 +++--- src/xmpp/xmpp-im/jingle-ft.h | 2 +- src/xmpp/xmpp-im/jingle-ibb.h | 4 ++-- src/xmpp/xmpp-im/jingle-ice.cpp | 11 ++++------- src/xmpp/xmpp-im/jingle-ice.h | 4 ++-- src/xmpp/xmpp-im/jingle-s5b.h | 4 ++-- src/xmpp/xmpp-im/jingle-sctp.h | 3 +-- src/xmpp/xmpp-im/jingle-session.cpp | 8 ++++---- src/xmpp/xmpp-im/jingle-session.h | 2 +- src/xmpp/xmpp-im/jingle.cpp | 6 +++--- src/xmpp/xmpp-im/jingle.h | 2 +- src/xmpp/xmpp-im/s5b.cpp | 2 +- src/xmpp/xmpp-im/s5b.h | 2 +- src/xmpp/xmpp-im/xmpp_hash.cpp | 2 +- src/xmpp/xmpp-im/xmpp_xmlcommon.cpp | 4 ++++ 24 files changed, 68 insertions(+), 55 deletions(-) diff --git a/3rdparty/stringprep/stringprep.cpp b/3rdparty/stringprep/stringprep.cpp index f5793f69..d7f581ba 100644 --- a/3rdparty/stringprep/stringprep.cpp +++ b/3rdparty/stringprep/stringprep.cpp @@ -101,7 +101,7 @@ static int stringprep_apply_table_to_string(QVector &ucs4, const Stringpre { std::ptrdiff_t pos; size_t i, maplen; - uint32_t * src = ucs4.data(); /* points to unprocessed data */ + uint32_t *src = ucs4.data(); /* points to unprocessed data */ size_t srclen = ucs4.size(); /* length of unprocessed data */ while ((pos = stringprep_find_string_in_table(src, srclen, &i, table, table_size)) != -1) { @@ -177,7 +177,8 @@ int stringprep_4i(QString &input, Stringprep_profile_flags flags, const Stringpr /* Profile requires NFKC, but callee asked for no NFKC. */ return STRINGPREP_FLAG_ERROR; - ucs4vector = QString::fromUcs4(ucs4vector.data(), ucs4vector.length()) + static_assert(sizeof(char32_t) == sizeof(uint)); + ucs4vector = QString::fromUcs4(reinterpret_cast(ucs4vector.data()), ucs4vector.length()) .normalized(QString::NormalizationForm_KC) .toUcs4(); break; @@ -264,7 +265,8 @@ int stringprep_4i(QString &input, Stringprep_profile_flags flags, const Stringpr } } - input = QString::fromUcs4(ucs4vector.data(), ucs4vector.size()); + static_assert(sizeof(char32_t) == sizeof(uint)); + input = QString::fromUcs4(reinterpret_cast(ucs4vector.data()), ucs4vector.size()); return STRINGPREP_OK; } diff --git a/src/irisnet/corelib/objectsession.cpp b/src/irisnet/corelib/objectsession.cpp index b3ee2d30..ade6f717 100644 --- a/src/irisnet/corelib/objectsession.cpp +++ b/src/irisnet/corelib/objectsession.cpp @@ -55,7 +55,11 @@ class ObjectSessionPrivate : public QObject { void clearArgs() { for (int n = 0; n < args.count(); ++n) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QMetaType::destroy(args[n].type, args[n].data); +#else + QMetaType(args[n].type).destroy(args[n].data); +#endif args.clear(); } @@ -78,7 +82,11 @@ class ObjectSessionPrivate : public QObject { break; Argument arg; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) arg.type = QMetaType::type(arg_name[n]); +#else + arg.type = QMetaType::fromName(arg_name[n]).id(); +#endif if (!arg.type) { clearArgs(); return false; @@ -149,7 +157,11 @@ private slots: QGenericArgument arg[10]; for (int n = 0; n < call->args.count(); ++n) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) arg[n] = QGenericArgument(QMetaType::typeName(call->args[n].type), call->args[n].data); +#else + arg[n] = QGenericArgument(QMetaType(call->args[n].type).name(), call->args[n].data); +#endif bool ok; ok = QMetaObject::invokeMethod(call->obj, call->method.data(), Qt::DirectConnection, arg[0], arg[1], arg[2], diff --git a/src/irisnet/noncore/cutestuff/httppoll.cpp b/src/irisnet/noncore/cutestuff/httppoll.cpp index 54ecffff..1abdbccc 100644 --- a/src/irisnet/noncore/cutestuff/httppoll.cpp +++ b/src/irisnet/noncore/cutestuff/httppoll.cpp @@ -848,7 +848,7 @@ void HttpProxyGetStream::sock_readyRead() void HttpProxyGetStream::processData(const QByteArray &block) { - printf("processData: %d bytes\n", block.size()); + printf("processData: %lld bytes\n", block.size()); if (!d->inHeader) { emit dataReady(block); return; diff --git a/src/irisnet/noncore/ice176.cpp b/src/irisnet/noncore/ice176.cpp index 387aa3b1..62d7b387 100644 --- a/src/irisnet/noncore/ice176.cpp +++ b/src/irisnet/noncore/ice176.cpp @@ -453,7 +453,7 @@ class Ice176::Private : public QObject { } this->remoteCandidates += remoteCandidates; - iceDebug("adding %d remote candidates. total=%d", remoteCandidates.count(), this->remoteCandidates.count()); + iceDebug("adding %lld remote candidates. total=%lld", remoteCandidates.count(), this->remoteCandidates.count()); doPairing(localCandidates, remoteCandidates); } @@ -508,7 +508,7 @@ class Ice176::Private : public QObject { void addChecklistPairs(const QList> &pairs) { #ifdef ICE_DEBUG - iceDebug("%d new pairs", pairs.count()); + iceDebug("%lld new pairs", pairs.count()); for (auto &p : pairs) p->logNew = true; #endif @@ -549,7 +549,7 @@ class Ice176::Private : public QObject { while (checkList.pairs.count() > max_pairs) checkList.pairs.removeLast(); #ifdef ICE_DEBUG - iceDebug("%d after pruning (just new below):", checkList.pairs.count()); + iceDebug("%lld after pruning (just new below):", checkList.pairs.count()); for (auto &p : checkList.pairs) { if (p->logNew) iceDebug("C%d, %s", p->local->componentId, qPrintable(*p)); diff --git a/src/irisnet/noncore/stunbinding.cpp b/src/irisnet/noncore/stunbinding.cpp index 15bda2ea..b40de926 100644 --- a/src/irisnet/noncore/stunbinding.cpp +++ b/src/irisnet/noncore/stunbinding.cpp @@ -28,12 +28,12 @@ class StunBinding::Private : public QObject { Q_OBJECT public: - StunBinding *q; - StunTransactionPool::Ptr pool; - QScopedPointer trans; - TransportAddress stunAddr; - TransportAddress addr; - QString errorString; + StunBinding *q; + StunTransactionPool::Ptr pool; + std::unique_ptr trans; + TransportAddress stunAddr; + TransportAddress addr; + QString errorString; bool use_extPriority = false, use_extIceControlling = false, use_extIceControlled = false; quint32 extPriority = 0; bool extUseCandidate = false; @@ -52,9 +52,9 @@ class StunBinding::Private : public QObject { stunAddr = _addr; trans.reset(new StunTransaction()); - connect(trans.data(), &StunTransaction::createMessage, this, &Private::trans_createMessage); - connect(trans.data(), &StunTransaction::finished, this, &Private::trans_finished); - connect(trans.data(), &StunTransaction::error, this, &Private::trans_error); + connect(trans.get(), &StunTransaction::createMessage, this, &Private::trans_createMessage); + connect(trans.get(), &StunTransaction::finished, this, &Private::trans_finished); + connect(trans.get(), &StunTransaction::error, this, &Private::trans_error); if (!stuser.isEmpty()) { trans->setShortTermUsername(stuser); @@ -70,7 +70,7 @@ class StunBinding::Private : public QObject { { if (!trans) return; - auto t = trans.take(); + auto t = trans.release(); t->disconnect(this); t->cancel(); // will self-delete the transaction either on incoming or timeout // just in case those too diff --git a/src/irisnet/noncore/stuntypes.cpp b/src/irisnet/noncore/stuntypes.cpp index fe0cbb39..1982f778 100644 --- a/src/irisnet/noncore/stuntypes.cpp +++ b/src/irisnet/noncore/stuntypes.cpp @@ -624,7 +624,7 @@ namespace StunTypes { if (!val.isEmpty()) out += QString(" = %1").arg(val); } else - out += QString::asprintf(" Unknown attribute (0x%04x) of %d bytes", a.type, a.value.size()); + out += QString::asprintf(" Unknown attribute (0x%04x) of %lld bytes", a.type, a.value.size()); } } else out += "\n (None)"; diff --git a/src/irisnet/noncore/tcpportreserver.h b/src/irisnet/noncore/tcpportreserver.h index 16275203..bece3be4 100644 --- a/src/irisnet/noncore/tcpportreserver.h +++ b/src/irisnet/noncore/tcpportreserver.h @@ -123,7 +123,7 @@ class TcpPortScope : public QObject { private: struct Private; - QScopedPointer d; + std::unique_ptr d; }; /** diff --git a/src/xmpp/jid/jid.cpp b/src/xmpp/jid/jid.cpp index 12e455c7..5295e58b 100644 --- a/src/xmpp/jid/jid.cpp +++ b/src/xmpp/jid/jid.cpp @@ -31,7 +31,7 @@ using namespace XMPP; //---------------------------------------------------------------------------- // StringPrepCache //---------------------------------------------------------------------------- -QScopedPointer StringPrepCache::_instance; +std::unique_ptr StringPrepCache::_instance; bool StringPrepCache::nameprep(const QString &in, int maxbytes, QString &out) { @@ -155,7 +155,7 @@ StringPrepCache *StringPrepCache::instance() irisNetAddPostRoutine(cleanup); // REVIEW probably not necessary since heap will be deallocated with destructors #endif } - return _instance.data(); + return _instance.get(); } StringPrepCache::StringPrepCache() { } diff --git a/src/xmpp/jid/jid.h b/src/xmpp/jid/jid.h index e7c1a3a8..f31dfd4c 100644 --- a/src/xmpp/jid/jid.h +++ b/src/xmpp/jid/jid.h @@ -22,7 +22,6 @@ #include #include -#include #include namespace XMPP { @@ -41,8 +40,8 @@ class StringPrepCache { QHash resourceprep_table; QHash saslprep_table; - static QScopedPointer _instance; - static StringPrepCache *instance(); + static std::unique_ptr _instance; + static StringPrepCache *instance(); StringPrepCache(); }; diff --git a/src/xmpp/xmpp-im/jingle-application.h b/src/xmpp/xmpp-im/jingle-application.h index cd3b06cb..3b0edbbc 100644 --- a/src/xmpp/xmpp-im/jingle-application.h +++ b/src/xmpp/xmpp-im/jingle-application.h @@ -79,7 +79,7 @@ namespace XMPP { namespace Jingle { inline Origin senders() const { return _senders; } inline QString contentName() const { return _contentName; } inline QSharedPointer transport() const { return _transport; } - inline TransportSelector *transportSelector() const { return _transportSelector.data(); } + inline TransportSelector *transportSelector() const { return _transportSelector.get(); } bool isRemote() const; inline bool isLocal() const { return !isRemote(); } inline ApplicationFlags flags() const { return _flags; } @@ -185,8 +185,8 @@ namespace XMPP { namespace Jingle { Origin _senders; // current transport. either local or remote. has info about origin and state - QSharedPointer _transport; - QScopedPointer _transportSelector; + QSharedPointer _transport; + std::unique_ptr _transportSelector; // if transport-replace is in progress. will be set to true when accepted by both sides. PendingTransportReplace _pendingTransportReplace = PendingTransportReplace::None; diff --git a/src/xmpp/xmpp-im/jingle-ft.h b/src/xmpp/xmpp-im/jingle-ft.h index bc9ab6f0..589622cb 100644 --- a/src/xmpp/xmpp-im/jingle-ft.h +++ b/src/xmpp/xmpp-im/jingle-ft.h @@ -133,7 +133,7 @@ namespace XMPP { namespace Jingle { namespace FileTransfer { private: class Private; - QScopedPointer d; + std::unique_ptr d; }; class Manager : public XMPP::Jingle::ApplicationManager { diff --git a/src/xmpp/xmpp-im/jingle-ibb.h b/src/xmpp/xmpp-im/jingle-ibb.h index 7020a519..6dbdba13 100644 --- a/src/xmpp/xmpp-im/jingle-ibb.h +++ b/src/xmpp/xmpp-im/jingle-ibb.h @@ -50,7 +50,7 @@ namespace Jingle { namespace IBB { friend class Manager; struct Private; - QScopedPointer d; + std::unique_ptr d; }; class Manager; @@ -91,7 +91,7 @@ namespace Jingle { namespace IBB { private: struct Private; - QScopedPointer d; + std::unique_ptr d; }; } // namespace IBB } // namespace Jingle diff --git a/src/xmpp/xmpp-im/jingle-ice.cpp b/src/xmpp/xmpp-im/jingle-ice.cpp index fc63726a..96386e91 100644 --- a/src/xmpp/xmpp-im/jingle-ice.cpp +++ b/src/xmpp/xmpp-im/jingle-ice.cpp @@ -33,10 +33,7 @@ #include "xmpp_client.h" #include "xmpp_externalservicediscovery.h" #include "xmpp_serverinfomanager.h" -#include "xmpp_xmlcommon.h" -#include -#include #include #include @@ -452,7 +449,7 @@ namespace XMPP { namespace Jingle { namespace ICE { int proxiesInDiscoCount = 0; QVector components; QList pendingLocalCandidates; // cid to candidate mapping - QScopedPointer remoteState; + std::unique_ptr remoteState; // QString sid; // Transport::Mode mode = Transport::Tcp; @@ -638,7 +635,7 @@ namespace XMPP { namespace Jingle { namespace ICE { return; } - auto manager = dynamic_cast(q->pad()->manager())->d.data(); + auto manager = dynamic_cast(q->pad()->manager())->d.get(); stunBindPort = manager->stunBindPort; stunRelayUdpPort = manager->stunRelayUdpPort; stunRelayTcpPort = manager->stunRelayTcpPort; @@ -659,7 +656,7 @@ namespace XMPP { namespace Jingle { namespace ICE { void startIce() { - auto manager = dynamic_cast(q->_pad->manager())->d.data(); + auto manager = dynamic_cast(q->_pad->manager())->d.get(); if (!stunBindAddr.isNull() && stunBindPort > 0) qDebug("STUN service: %s;%d", qPrintable(stunBindAddr.toString()), stunBindPort); @@ -707,7 +704,7 @@ namespace XMPP { namespace Jingle { namespace ICE { [this](const QList &candidates) { pendingActions |= NewCandidate; pendingLocalCandidates += candidates; - qDebug("discovered %d local candidates", candidates.size()); + qDebug("discovered %lld local candidates", candidates.size()); for (auto const &c : candidates) { qDebug(" - %s:%d", qPrintable(c.ip.toString()), c.port); } diff --git a/src/xmpp/xmpp-im/jingle-ice.h b/src/xmpp/xmpp-im/jingle-ice.h index 58f858a4..990d8b08 100644 --- a/src/xmpp/xmpp-im/jingle-ice.h +++ b/src/xmpp/xmpp-im/jingle-ice.h @@ -60,7 +60,7 @@ namespace Jingle { namespace ICE { friend class Manager; class Private; - QScopedPointer d; + std::unique_ptr d; }; class Pad : public TransportManagerPad { @@ -129,7 +129,7 @@ namespace Jingle { namespace ICE { private: friend class Transport; class Private; - QScopedPointer d; + std::unique_ptr d; }; } // namespace Ice } // namespace Jingle diff --git a/src/xmpp/xmpp-im/jingle-s5b.h b/src/xmpp/xmpp-im/jingle-s5b.h index 91376179..00dddaa3 100644 --- a/src/xmpp/xmpp-im/jingle-s5b.h +++ b/src/xmpp/xmpp-im/jingle-s5b.h @@ -152,7 +152,7 @@ namespace Jingle { namespace S5B { friend class Manager; class Private; - QScopedPointer d; + std::unique_ptr d; }; class Pad : public TransportManagerPad { @@ -212,7 +212,7 @@ namespace Jingle { namespace S5B { private: class Private; - QScopedPointer d; + std::unique_ptr d; }; } // namespace S5B } // namespace Jingle diff --git a/src/xmpp/xmpp-im/jingle-sctp.h b/src/xmpp/xmpp-im/jingle-sctp.h index 92dab3dc..0ac2d1ee 100644 --- a/src/xmpp/xmpp-im/jingle-sctp.h +++ b/src/xmpp/xmpp-im/jingle-sctp.h @@ -25,7 +25,6 @@ #include #include #include -#include #include @@ -95,7 +94,7 @@ namespace XMPP { namespace Jingle { namespace SCTP { void newIncomingChannel(); private: - QScopedPointer d; + std::unique_ptr d; }; }}} diff --git a/src/xmpp/xmpp-im/jingle-session.cpp b/src/xmpp/xmpp-im/jingle-session.cpp index f0323406..ab2233c2 100644 --- a/src/xmpp/xmpp-im/jingle-session.cpp +++ b/src/xmpp/xmpp-im/jingle-session.cpp @@ -306,7 +306,7 @@ namespace XMPP { namespace Jingle { } QMultiMap updates; - qDebug("jingle-doStep: %d applications have updates", signalingContent.size()); + qDebug("jingle-doStep: %lld applications have updates", signalingContent.size()); for (auto app : std::as_const(signalingContent)) { auto updateType = app->evaluateOutgoingUpdate(); if (updateType.action != Action::NoAction) { @@ -510,7 +510,7 @@ namespace XMPP { namespace Jingle { return result { Unsupported, trReason == Reason::NoReason ? Reason::UnsupportedApplications : trReason, nullptr }; } - QScopedPointer app(appPad->manager()->startApplication(appPad, c.name, c.creator, c.senders)); + std::unique_ptr app(appPad->manager()->startApplication(appPad, c.name, c.creator, c.senders)); if (!app) return result { Unparsed, Reason::Success, nullptr }; @@ -522,10 +522,10 @@ namespace XMPP { namespace Jingle { } if (app->setTransport(std::get<2>(trpr))) { - return result { Ok, Reason::Success, app.take() }; + return result { Ok, Reason::Success, app.release() }; } // TODO We can do transport-replace in all cases where std::get<1>(trpr) != NoReason - return result { Unsupported, Reason::IncompatibleParameters, app.take() }; + return result { Unsupported, Reason::IncompatibleParameters, app.release() }; } typedef std::tuple, QList> diff --git a/src/xmpp/xmpp-im/jingle-session.h b/src/xmpp/xmpp-im/jingle-session.h index 07425323..8f60683e 100644 --- a/src/xmpp/xmpp-im/jingle-session.h +++ b/src/xmpp/xmpp-im/jingle-session.h @@ -95,7 +95,7 @@ namespace XMPP { namespace Jingle { bool updateFromXml(Action action, const QDomElement &jingleEl); class Private; - QScopedPointer d; + std::unique_ptr d; }; }} diff --git a/src/xmpp/xmpp-im/jingle.cpp b/src/xmpp/xmpp-im/jingle.cpp index 4819c866..20ae9c15 100644 --- a/src/xmpp/xmpp-im/jingle.cpp +++ b/src/xmpp/xmpp-im/jingle.cpp @@ -533,9 +533,9 @@ namespace XMPP { namespace Jingle { //---------------------------------------------------------------------------- class Manager::Private { public: - XMPP::Client *client; - Manager *manager; - QScopedPointer pushTask; + XMPP::Client *client; + Manager *manager; + std::unique_ptr pushTask; // ns -> application std::map> applicationManagers; // ns -> parser function diff --git a/src/xmpp/xmpp-im/jingle.h b/src/xmpp/xmpp-im/jingle.h index 9763926d..845977b8 100644 --- a/src/xmpp/xmpp-im/jingle.h +++ b/src/xmpp/xmpp-im/jingle.h @@ -377,7 +377,7 @@ namespace Jingle { Session *incomingSessionInitiate(const Jid &from, const Jingle &jingle, const QDomElement &jingleEl); class Private; - QScopedPointer d; + std::unique_ptr d; }; Origin negateOrigin(Origin o); diff --git a/src/xmpp/xmpp-im/s5b.cpp b/src/xmpp/xmpp-im/s5b.cpp index c0b9b18a..0398ac63 100644 --- a/src/xmpp/xmpp-im/s5b.cpp +++ b/src/xmpp/xmpp-im/s5b.cpp @@ -2229,7 +2229,7 @@ S5BServer::S5BServer(QTcpServer *serverSocket) : TcpPortServer(serverSocket), d( S5BServer::~S5BServer() { - // basically to make QScopedPointer happy + // basically to make std::unique_ptr happy } void S5BServer::writeUDP(const QHostAddress &addr, quint16 port, const QByteArray &data) diff --git a/src/xmpp/xmpp-im/s5b.h b/src/xmpp/xmpp-im/s5b.h index 5343d3e7..5fff63b4 100644 --- a/src/xmpp/xmpp-im/s5b.h +++ b/src/xmpp/xmpp-im/s5b.h @@ -254,7 +254,7 @@ class S5BServer : public TcpPortServer { private: struct Private; - QScopedPointer d; + std::unique_ptr d; }; class JT_S5B : public Task { diff --git a/src/xmpp/xmpp-im/xmpp_hash.cpp b/src/xmpp/xmpp-im/xmpp_hash.cpp index 558e0bcf..9db6af47 100644 --- a/src/xmpp/xmpp-im/xmpp_hash.cpp +++ b/src/xmpp/xmpp-im/xmpp_hash.cpp @@ -172,7 +172,7 @@ bool Hash::compute(const QByteArray &ba) if (!v_data.isEmpty()) return true; - qDebug("failed to compute %s hash for %d bytes", qPrintable(stringType()), ba.size()); + qDebug("failed to compute %s hash for %lld bytes", qPrintable(stringType()), ba.size()); return false; } diff --git a/src/xmpp/xmpp-im/xmpp_xmlcommon.cpp b/src/xmpp/xmpp-im/xmpp_xmlcommon.cpp index 590080f8..e0f29c8e 100644 --- a/src/xmpp/xmpp-im/xmpp_xmlcommon.cpp +++ b/src/xmpp/xmpp-im/xmpp_xmlcommon.cpp @@ -445,8 +445,12 @@ void readColorEntry(const QDomElement &e, const QString &name, QColor *v) QDomElement tag = e.firstChildElement(name); if (tag.isNull()) return; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QColor c; c.setNamedColor(tagContent(tag)); +#else + auto c = QColor::fromString(tagContent(tag)); +#endif if (c.isValid()) *v = c; }