Skip to content

Commit

Permalink
FEAT: Add Qt 6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebeatrici committed Jul 20, 2024
1 parent b75fe54 commit 1edb151
Show file tree
Hide file tree
Showing 63 changed files with 339 additions and 197 deletions.
2 changes: 1 addition & 1 deletion src/Ban.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ QString Ban::toString() const {
iDuration == 0 ? QLatin1String("(permanent)") : QLatin1String("(temporary)"));
}

quint32 qHash(const Ban &b) {
std::size_t qHash(const Ban &b) {
return qHash(b.qsHash) ^ qHash(b.haAddress) ^ qHash(b.qsUsername) ^ qHash(b.iMask);
}
2 changes: 1 addition & 1 deletion src/Ban.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ struct Ban {
QString toString() const;
};

quint32 qHash(const Ban &);
std::size_t qHash(const Ban &);

#endif
5 changes: 2 additions & 3 deletions src/FFDHE.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
#ifndef MUMBLE_FFDHE_H_
#define MUMBLE_FFDHE_H_

class QByteArray;
class QString;
class QStringList;
#include <QByteArray>
#include <QStringList>

/// FFDHE provides access to the Diffie-Hellman parameters from RFC 7919.
class FFDHE {
Expand Down
6 changes: 4 additions & 2 deletions src/HostAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "ByteSwap.h"

#include <QRegularExpression>

#ifdef Q_OS_WIN
# include "win.h"
# include <winsock2.h>
Expand Down Expand Up @@ -180,7 +182,7 @@ void HostAddress::setByte(std::size_t idx, std::uint8_t value) {
m_byteRepresentation[idx] = value;
}

quint32 qHash(const HostAddress &ha) {
std::size_t qHash(const HostAddress &ha) {
return qHashRange(ha.m_byteRepresentation.begin(), ha.m_byteRepresentation.end());
}

Expand All @@ -202,7 +204,7 @@ QString HostAddress::toString(bool bracketEnclosed) const {
ntohs(shortArray[4]), ntohs(shortArray[5]), ntohs(shortArray[6]),
ntohs(shortArray[7]), squareBracketClose);

return str.replace(QRegExp(QLatin1String("(:0)+")), QLatin1String(":"));
return str.replace(QRegularExpression(QLatin1String("(:0)+")), QLatin1String(":"));
} else {
return bracketEnclosed ? QLatin1String("[::]") : QLatin1String("::");
}
Expand Down
2 changes: 1 addition & 1 deletion src/HostAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct HostAddress {

void setByte(std::size_t idx, std::uint8_t value);

friend quint32 qHash(const HostAddress &);
friend std::size_t qHash(const HostAddress &);

private:
// Binary representation of an IPv6 address
Expand Down
2 changes: 1 addition & 1 deletion src/PacketDataStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class PacketDataStream {
return *this; \
}


INTMAPOPERATOR(qsizetype);
INTMAPOPERATOR(int);
INTMAPOPERATOR(unsigned int);
INTMAPOPERATOR(short);
Expand Down
2 changes: 1 addition & 1 deletion src/QtUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

#include <QCryptographicHash>
#include <QString>
#include <QStringList>

#include <memory>

class QObject;
class QStringList;

namespace Mumble {
namespace QtUtils {
Expand Down
8 changes: 2 additions & 6 deletions src/SSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,12 @@ void MumbleSSL::addSystemCA() {

QString MumbleSSL::protocolToString(QSsl::SslProtocol protocol) {
switch (protocol) {
case QSsl::SslV3:
return QLatin1String("SSL 3");
case QSsl::SslV2:
return QLatin1String("SSL 2");
#if QT_VERSION < 0x060300
case QSsl::TlsV1_0:
return QLatin1String("TLS 1.0");
case QSsl::TlsV1_1:
return QLatin1String("TLS 1.1");
#endif
case QSsl::TlsV1_2:
return QLatin1String("TLS 1.2");
#if QT_VERSION >= 0x050C00
Expand All @@ -171,8 +169,6 @@ QString MumbleSSL::protocolToString(QSsl::SslProtocol protocol) {
#endif
case QSsl::AnyProtocol:
return QLatin1String("AnyProtocol");
case QSsl::TlsV1SslV3:
return QLatin1String("TlsV1SslV3");
case QSsl::SecureProtocols:
return QLatin1String("SecureProtocols");
default:
Expand Down
4 changes: 2 additions & 2 deletions src/ServerAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ bool operator<(const ServerAddress &lhs, const ServerAddress &rhs) {
return false;
}

uint qHash(const ServerAddress &key) {
return qHash(key.host) ^ uint(key.port);
std::size_t qHash(const ServerAddress &key) {
return qHash(key.host) ^ static_cast< std::size_t >(key.port);
}
2 changes: 1 addition & 1 deletion src/ServerAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ bool operator<(const ServerAddress &lhs, const ServerAddress &rhs);

/// Implementation of qHash for ServerAddress, such that ServerAddress
/// can be used as a key in QHash, QMap, etc.
uint qHash(const ServerAddress &key);
std::size_t qHash(const ServerAddress &key);

#endif
4 changes: 2 additions & 2 deletions src/UnresolvedServerAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ bool operator<(const UnresolvedServerAddress &lhs, const UnresolvedServerAddress
return false;
}

uint qHash(const UnresolvedServerAddress &key) {
return qHash(key.hostname) ^ uint(key.port);
std::size_t qHash(const UnresolvedServerAddress &key) {
return qHash(key.hostname) ^ static_cast< std::size_t >(key.port);
}
2 changes: 1 addition & 1 deletion src/UnresolvedServerAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ bool operator<(const UnresolvedServerAddress &lhs, const UnresolvedServerAddress

/// Implementation of qHash for UnresolvedServerAddress, such that
/// UnresolvedServerAddress can be used as a key in QHash, QMap, etc.
uint qHash(const UnresolvedServerAddress &key);
std::size_t qHash(const UnresolvedServerAddress &key);

#endif
16 changes: 9 additions & 7 deletions src/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "Version.h"

#include <QObject>
#include <QRegExp>
#include <QRegularExpression>

namespace Version {

Expand Down Expand Up @@ -69,12 +69,14 @@ QString toConfigString(Version::full_t v) {

bool getComponents(Version::component_t &major, Version::component_t &minor, Version::component_t &patch,
const QString &version) {
QRegExp rx(QLatin1String("(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?"));

if (rx.exactMatch(version)) {
major = static_cast< Version::component_t >(rx.cap(1).toInt());
minor = static_cast< Version::component_t >(rx.cap(2).toInt());
patch = static_cast< Version::component_t >(rx.cap(3).toInt());
constexpr QLatin1StringView pattern("(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?");
const QRegularExpression rx(QRegularExpression::anchoredPattern(pattern));
const QRegularExpressionMatch match = rx.matchView(version);

if (match.hasMatch()) {
major = static_cast< Version::component_t >(match.captured(1).toInt());
minor = static_cast< Version::component_t >(match.captured(2).toInt());
patch = static_cast< Version::component_t >(match.captured(3).toInt());

return true;
}
Expand Down
9 changes: 7 additions & 2 deletions src/mumble/API_v_1_x_x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,8 +1213,13 @@ QVariant getMumbleSettingHelper(mumble_settings_key_t key) {

// IS_TYPE actually only checks if the QVariant can be converted to the needed type since that's all that we really care
// about at the end of the day.
#define IS_TYPE(var, varType) static_cast< QMetaType::Type >(var.type()) == varType
#define IS_NOT_TYPE(var, varType) static_cast< QMetaType::Type >(var.type()) != varType
#if QT_VERSION >= 0x060000
# define IS_TYPE(var, varType) static_cast< QMetaType::Type >(var.typeId()) == varType
# define IS_NOT_TYPE(var, varType) static_cast< QMetaType::Type >(var.typeId()) != varType
#else
# define IS_TYPE(var, varType) static_cast< QMetaType::Type >(var.type()) == varType
# define IS_NOT_TYPE(var, varType) static_cast< QMetaType::Type >(var.type()) != varType
#endif

void MumbleAPI::getMumbleSetting_bool_v_1_0_x(mumble_plugin_id_t callerID, mumble_settings_key_t key, bool *outValue,
std::shared_ptr< api_promise_t > promise) {
Expand Down
5 changes: 4 additions & 1 deletion src/mumble/Accessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
#include <QAccessible>
#include <QAccessibleEvent>
#include <QObject>
#include <QRegularExpression>
#include <QWidget>

#include <queue>

namespace Mumble {
namespace Accessibility {

QString removeHTMLTags(QString value) { return value.remove(QRegExp("<[^>]*>")); }
QString removeHTMLTags(QString value) {
return value.remove(QRegularExpression("<[^>]*>"));
}

void setDescriptionFromLabel(QWidget *widget, const QLabel *label) {
widget->setAccessibleDescription(removeHTMLTags(label->text()));
Expand Down
6 changes: 4 additions & 2 deletions src/mumble/Cert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Utils.h"
#include "Global.h"

#include <QRegularExpression>
#include <QTimer>
#include <QtCore/QUrl>
#include <QtGui/QDesktopServices>
Expand Down Expand Up @@ -228,8 +229,9 @@ void CertWizard::initializePage(int id) {

bool CertWizard::validateCurrentPage() {
if (currentPage() == qwpNew) {
QRegExp ereg(QLatin1String("(^$)|((.+)@(.+))"), Qt::CaseInsensitive, QRegExp::RegExp2);
if (!ereg.exactMatch(qleEmail->text())) {
const QRegularExpression ereg(QRegularExpression::anchoredPattern(QLatin1String("(^$)|((.+)@(.+))")),
QRegularExpression::CaseInsensitiveOption);
if (!ereg.match(qleEmail->text()).hasMatch()) {
qlError->setText(tr("Unable to validate email.<br />Enter a valid (or blank) email to continue."));
qwpNew->setComplete(false);
return false;
Expand Down
1 change: 0 additions & 1 deletion src/mumble/ConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <QScrollArea>
#include <QtCore/QMutexLocker>
#include <QtGui/QScreen>
#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QPushButton>

Expand Down
20 changes: 13 additions & 7 deletions src/mumble/ConnectDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include "Global.h"

#include <QSettings>
#include <QShortcut>
#include <QtCore/QMimeData>
#include <QtCore/QRegularExpression>
#include <QtCore/QUrlQuery>
#include <QtCore/QtEndian>
#include <QtGui/QClipboard>
Expand All @@ -28,7 +30,6 @@
#include <QtWidgets/QInputDialog>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QShortcut>
#include <QtXml/QDomDocument>

#include <boost/accumulators/statistics/extended_p_square.hpp>
Expand Down Expand Up @@ -129,7 +130,11 @@ ServerView::~ServerView() {
delete siPublic;
}

#if QT_VERSION >= 0x060000
QMimeData *ServerView::mimeData(const QList< QTreeWidgetItem * > &mimeitems) const {
#else
QMimeData *ServerView::mimeData(const QList< QTreeWidgetItem * > mimeitems) const {
#endif
if (mimeitems.isEmpty())
return nullptr;

Expand All @@ -154,11 +159,12 @@ void ServerView::fixupName(ServerItem *si) {

int tag = 1;

QRegExp tmatch(QLatin1String("(.+)\\((\\d+)\\)"));
tmatch.setMinimal(true);
if (tmatch.exactMatch(name)) {
name = tmatch.capturedTexts().at(1).trimmed();
tag = tmatch.capturedTexts().at(2).toInt();
const QRegularExpression regex(QRegularExpression::anchoredPattern(QLatin1String("(.+)\\((\\d+)\\)")),
QRegularExpression::InvertedGreedinessOption);
const QRegularExpressionMatch match = regex.match(name);
if (match.hasMatch()) {
name = match.capturedTexts().at(1).trimmed();
tag = match.capturedTexts().at(2).toInt();
}

bool found;
Expand Down Expand Up @@ -734,7 +740,7 @@ bool ServerItem::operator<(const QTreeWidgetItem &o) const {
QString a = qsName.toLower();
QString b = other.qsName.toLower();

QRegExp re(QLatin1String("[^0-9a-z]"));
QRegularExpression re(QLatin1String("[^0-9a-z]"));
a.remove(re);
b.remove(re);
return a < b;
Expand Down
4 changes: 4 additions & 0 deletions src/mumble/ConnectDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ class ServerView : public QTreeWidget {
void fixupName(ServerItem *si);

protected:
#if QT_VERSION >= 0x060000
QMimeData *mimeData(const QList< QTreeWidgetItem * > &) const Q_DECL_OVERRIDE;
#else
QMimeData *mimeData(const QList< QTreeWidgetItem * >) const Q_DECL_OVERRIDE;
#endif
QStringList mimeTypes() const Q_DECL_OVERRIDE;
Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE;
bool dropMimeData(QTreeWidgetItem *, int, const QMimeData *, Qt::DropAction) Q_DECL_OVERRIDE;
Expand Down
4 changes: 2 additions & 2 deletions src/mumble/CrashReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void CrashReporter::run() {
QString app = QLatin1String("dxdiag.exe");
QString systemRoot = EnvUtils::getenv(QLatin1String("SystemRoot"));

if (systemRoot.count() > 0) {
if (!systemRoot.isEmpty()) {
app = QDir::fromNativeSeparators(systemRoot + QLatin1String("/System32/dxdiag.exe"));
}

Expand Down Expand Up @@ -204,7 +204,7 @@ void CrashReporter::run() {
connect(qpdProgress, SIGNAL(canceled()), qelLoop, SLOT(quit()));

QString boundary =
QString::fromLatin1("---------------------------%1").arg(QDateTime::currentDateTime().toTime_t());
QString::fromLatin1("---------------------------%1").arg(QDateTime::currentDateTime().toSecsSinceEpoch());

QString os = QString::fromLatin1("--%1\r\nContent-Disposition: form-data; "
"name=\"os\"\r\nContent-Transfer-Encoding: 8bit\r\n\r\n%2 %3\r\n")
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool Database::findOrCreateDatabase() {
QStringList datapaths;

datapaths << Global::get().qdBasePath.absolutePath();
datapaths << QStandardPaths::writableLocation(QStandardPaths::DataLocation);
datapaths << QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
datapaths << QDir::homePath() + QLatin1String("/.config/Mumble");
#endif
Expand Down
6 changes: 5 additions & 1 deletion src/mumble/GKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ GKeyLibrary::GKeyLibrary() {
if (RegOpenKeyEx(GKEY_LOGITECH_DLL_REG_HKEY, GKEY_LOGITECH_DLL_REG_PATH, 0, KEY_READ, &key) == ERROR_SUCCESS) {
LONG err = RegQueryValueEx(key, L"", nullptr, &type, reinterpret_cast< LPBYTE >(wcLocation), &len);
if (err == ERROR_SUCCESS && type == REG_SZ) {
QString qsLocation = QString::fromUtf16(reinterpret_cast< ushort * >(wcLocation), len / 2);
#if QT_VERSION >= 0x060000
const auto qsLocation = QString::fromUtf16(reinterpret_cast< char16_t * >(wcLocation), len / 2);
#else
const auto qsLocation = QString::fromUtf16(reinterpret_cast< ushort * >(wcLocation), len / 2);
#endif
qWarning("GKeyLibrary: Found ServerBinary with libLocation = \"%s\", len = %lu", qPrintable(qsLocation),
static_cast< unsigned long >(len));
alternatives << qsLocation;
Expand Down
Loading

0 comments on commit 1edb151

Please sign in to comment.