Skip to content

Commit

Permalink
FIX(server): Fix build with Qt 6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
botanegg committed Nov 5, 2024
1 parent 7787e5b commit 145fa19
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
11 changes: 8 additions & 3 deletions src/murmur/Messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
#include "Version.h"
#include "crypto/CryptState.h"

#include <QtCore/QStack>
#include <QtCore/QtEndian>

#include <cassert>
#include <unordered_map>

#include <QtCore/QStack>
#include <QtCore/QTimeZone>
#include <QtCore/QtEndian>

#include <tracy/Tracy.hpp>

#define RATELIMIT(user) \
Expand Down Expand Up @@ -687,7 +688,11 @@ void Server::msgBanList(ServerUser *uSource, MumbleProto::BanList &msg) {
b.qsReason = u8(be.reason());
if (be.has_start()) {
b.qdtStart = QDateTime::fromString(u8(be.start()), Qt::ISODate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
b.qdtStart.setTimeZone(QTimeZone::UTC);
#else
b.qdtStart.setTimeSpec(Qt::UTC);
#endif
} else {
b.qdtStart = QDateTime::currentDateTime().toUTC();
}
Expand Down
30 changes: 24 additions & 6 deletions src/murmur/ServerDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include <QtCore/QtGlobal>
#include "ServerDB.h"

#ifdef Q_OS_WIN
# include "win.h"
#endif

#include "ServerDB.h"

#include "ACL.h"
#include "Channel.h"
#include "Connection.h"
Expand All @@ -22,12 +20,14 @@
#include "ServerUser.h"
#include "User.h"

#include <cstdint>

#include <QtCore/QCoreApplication>
#include <QtCore/QTimeZone>
#include <QtCore/QtGlobal>
#include <QtSql/QSqlError>
#include <QtSql/QSqlQuery>

#include <cstdint>

#ifdef Q_OS_WIN
# include <winsock2.h>
#else
Expand Down Expand Up @@ -1210,7 +1210,11 @@ QList< UserInfo > Server::getRegisteredUsersEx() {
userinfo.name = query.value(1).toString();
userinfo.last_channel = query.value(2).toInt();
userinfo.last_active = QDateTime::fromString(query.value(3).toString(), Qt::ISODate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
userinfo.last_active.setTimeZone(QTimeZone::UTC);
#else
userinfo.last_active.setTimeSpec(Qt::UTC);
#endif

users << userinfo;
}
Expand Down Expand Up @@ -2220,14 +2224,22 @@ int Server::readLastChannel(int id) {
}

QDateTime last_active = QDateTime::fromString(query.value(1).toString(), Qt::ISODate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
last_active.setTimeZone(QTimeZone::UTC);
#else
last_active.setTimeSpec(Qt::UTC);
#endif
QDateTime last_disconnect;

// NULL column for last_disconnect will yield an empty invalid QDateTime object.
// Using that object with QDateTime::secsTo() will return 0 as per Qt specification.
if (!query.value(2).isNull()) {
last_disconnect = QDateTime::fromString(query.value(2).toString(), Qt::ISODate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
last_disconnect.setTimeZone(QTimeZone::UTC);
#else
last_disconnect.setTimeSpec(Qt::UTC);
#endif
}

if (last_active.secsTo(last_disconnect) <= 0) {
Expand Down Expand Up @@ -2291,7 +2303,9 @@ void Server::dumpChannel(const Channel *c) {
}
qWarning(" ");

foreach (c, c->qlChannels) { dumpChannel(c); }
foreach (c, c->qlChannels) {
dumpChannel(c);
}
}

void Server::getBans() {
Expand All @@ -2312,7 +2326,11 @@ void Server::getBans() {
ban.qsHash = query.value(3).toString();
ban.qsReason = query.value(4).toString();
ban.qdtStart = query.value(5).toDateTime();
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
ban.qdtStart.setTimeZone(QTimeZone::UTC);
#else
ban.qdtStart.setTimeSpec(Qt::UTC);
#endif
ban.iDuration = query.value(6).toUInt();

if (ban.isValid())
Expand Down

0 comments on commit 145fa19

Please sign in to comment.