aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-18 21:26:43 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-18 21:26:43 +0200
commit6b355d1aa87072143e09ea5269e8cf465318a64f (patch)
tree5de8b227d319e8c677ef4ea3d7931233a808bd5a
parent2dd85770cbfd6d9c7506757f25765c05ef74987d (diff)
downloadlibquotient-6b355d1aa87072143e09ea5269e8cf465318a64f.tar.gz
libquotient-6b355d1aa87072143e09ea5269e8cf465318a64f.zip
Drop pre-Qt 5.15 code
-rw-r--r--lib/connection.cpp16
-rw-r--r--lib/converters.h10
-rw-r--r--lib/eventitem.h2
-rw-r--r--lib/jobs/basejob.cpp8
-rw-r--r--lib/logging.h7
-rw-r--r--lib/mxcreply.cpp8
-rw-r--r--lib/networkaccessmanager.cpp15
-rw-r--r--lib/quotient_common.h15
-rw-r--r--lib/room.cpp7
-rw-r--r--lib/syncdata.cpp7
10 files changed, 10 insertions, 85 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index c390cc05..2319a38a 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -49,10 +49,6 @@
# include <qt5keychain/keychain.h>
#endif
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
-# include <QtCore/QCborValue>
-#endif
-
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
#include <QtCore/QElapsedTimer>
@@ -1826,16 +1822,10 @@ void Connection::saveRoomState(Room* r) const
QFile outRoomFile { stateCacheDir().filePath(
SyncData::fileNameForRoom(r->id())) };
if (outRoomFile.open(QFile::WriteOnly)) {
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
const auto data =
d->cacheToBinary
? QCborValue::fromJsonValue(r->toJson()).toCbor()
: QJsonDocument(r->toJson()).toJson(QJsonDocument::Compact);
-#else
- QJsonDocument json { r->toJson() };
- const auto data = d->cacheToBinary ? json.toBinaryData()
- : json.toJson(QJsonDocument::Compact);
-#endif
outRoomFile.write(data.data(), data.size());
qCDebug(MAIN) << "Room state cache saved to" << outRoomFile.fileName();
} else {
@@ -1905,15 +1895,9 @@ void Connection::saveState() const
}
#endif
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
const auto data =
d->cacheToBinary ? QCborValue::fromJsonValue(rootObj).toCbor()
: QJsonDocument(rootObj).toJson(QJsonDocument::Compact);
-#else
- QJsonDocument json { rootObj };
- const auto data = d->cacheToBinary ? json.toBinaryData()
- : json.toJson(QJsonDocument::Compact);
-#endif
qCDebug(PROFILER) << "Cache for" << userId() << "generated in" << et;
outFile.write(data.data(), data.size());
diff --git a/lib/converters.h b/lib/converters.h
index da30cae6..c985fd60 100644
--- a/lib/converters.h
+++ b/lib/converters.h
@@ -188,15 +188,7 @@ inline QDateTime fromJson(const QJsonValue& jv)
return QDateTime::fromMSecsSinceEpoch(fromJson<qint64>(jv), Qt::UTC);
}
-inline QJsonValue toJson(const QDate& val) {
- return toJson(
-#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
- QDateTime(val)
-#else
- val.startOfDay()
-#endif
- );
-}
+inline QJsonValue toJson(const QDate& val) { return toJson(val.startOfDay()); }
template <>
inline QDate fromJson(const QJsonValue& jv)
{
diff --git a/lib/eventitem.h b/lib/eventitem.h
index 5e001d88..e476c66c 100644
--- a/lib/eventitem.h
+++ b/lib/eventitem.h
@@ -14,7 +14,7 @@
namespace Quotient {
namespace EventStatus {
- QUO_NAMESPACE
+ Q_NAMESPACE_EXPORT(QUOTIENT_API)
/** Special marks an event can assume
*
diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp
index b6858b5a..fe70911e 100644
--- a/lib/jobs/basejob.cpp
+++ b/lib/jobs/basejob.cpp
@@ -301,16 +301,10 @@ void BaseJob::Private::sendRequest()
QNetworkRequest::NoLessSafeRedirectPolicy);
req.setMaximumRedirectsAllowed(10);
req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- req.setAttribute(
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
- QNetworkRequest::Http2AllowedAttribute
-#else
- QNetworkRequest::HTTP2AllowedAttribute
-#endif
// Qt doesn't combine HTTP2 with SSL quite right, occasionally crashing at
// what seems like an attempt to write to a closed channel. If/when that
// changes, false should be turned to true below.
- , false);
+ req.setAttribute(QNetworkRequest::Http2AllowedAttribute, false);
Q_ASSERT(req.url().isValid());
for (auto it = requestHeaders.cbegin(); it != requestHeaders.cend(); ++it)
req.setRawHeader(it.key(), it.value());
diff --git a/lib/logging.h b/lib/logging.h
index fc0a4c99..c8d17210 100644
--- a/lib/logging.h
+++ b/lib/logging.h
@@ -44,12 +44,7 @@ inline QDebug formatJson(QDebug debug_object)
//! Suppress full qualification of enums/QFlags when logging
inline QDebug terse(QDebug dbg)
{
- return
-#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
- dbg.setVerbosity(0), dbg;
-#else
- dbg.verbosity(QDebug::MinimumVerbosity);
-#endif
+ return dbg.verbosity(QDebug::MinimumVerbosity);
}
inline qint64 profilerMinNsecs()
diff --git a/lib/mxcreply.cpp b/lib/mxcreply.cpp
index 4174cfd8..c7547be8 100644
--- a/lib/mxcreply.cpp
+++ b/lib/mxcreply.cpp
@@ -71,12 +71,6 @@ MxcReply::MxcReply(QNetworkReply* reply, Room* room, const QString &eventId)
#endif
}
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
-#define ERROR_SIGNAL errorOccurred
-#else
-#define ERROR_SIGNAL error
-#endif
-
MxcReply::MxcReply()
: d(ZeroImpl<Private>())
{
@@ -88,7 +82,7 @@ MxcReply::MxcReply()
setError(QNetworkReply::ProtocolInvalidOperationError,
BadRequestPhrase);
setFinished(true);
- emit ERROR_SIGNAL(QNetworkReply::ProtocolInvalidOperationError);
+ emit errorOccurred(QNetworkReply::ProtocolInvalidOperationError);
emit finished();
}, Qt::QueuedConnection);
}
diff --git a/lib/networkaccessmanager.cpp b/lib/networkaccessmanager.cpp
index f4e7b1af..38ab07cc 100644
--- a/lib/networkaccessmanager.cpp
+++ b/lib/networkaccessmanager.cpp
@@ -68,24 +68,11 @@ void NetworkAccessManager::clearIgnoredSslErrors()
d->ignoredSslErrors.clear();
}
-static NetworkAccessManager* createNam()
-{
- auto nam = new NetworkAccessManager();
-#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
- // See #109; in newer Qt, bearer management is deprecated altogether
- NetworkAccessManager::connect(nam,
- &QNetworkAccessManager::networkAccessibleChanged, [nam] {
- nam->setNetworkAccessible(QNetworkAccessManager::Accessible);
- });
-#endif
- return nam;
-}
-
NetworkAccessManager* NetworkAccessManager::instance()
{
static QThreadStorage<NetworkAccessManager*> storage;
if(!storage.hasLocalData()) {
- storage.setLocalData(createNam());
+ storage.setLocalData(new NetworkAccessManager());
}
return storage.localData();
}
diff --git a/lib/quotient_common.h b/lib/quotient_common.h
index 2b785a39..8bcd5ca6 100644
--- a/lib/quotient_common.h
+++ b/lib/quotient_common.h
@@ -51,21 +51,8 @@
#define DECL_DEPRECATED_ENUMERATOR(Deprecated, Recommended) \
Deprecated Q_DECL_ENUMERATOR_DEPRECATED_X("Use " #Recommended) = Recommended
-#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
-// The first line forward-declares the namespace static metaobject with
-// QUOTIENT_API so that dynamically linked clients could serialise flag/enum
-// values from the namespace; Qt before 5.14 doesn't help with that. The second
-// line is needed for moc to do its job on the namespace.
-#define QUO_NAMESPACE \
- extern QUOTIENT_API const QMetaObject staticMetaObject; \
- Q_NAMESPACE
-#else
-// Since Qt 5.14.0, it's all packed in a single macro
-#define QUO_NAMESPACE Q_NAMESPACE_EXPORT(QUOTIENT_API)
-#endif
-
namespace Quotient {
-QUO_NAMESPACE
+Q_NAMESPACE_EXPORT(QUOTIENT_API)
// std::array {} needs explicit template parameters on macOS because
// Apple stdlib doesn't have deduction guides for std::array. C++20 has
diff --git a/lib/room.cpp b/lib/room.cpp
index f692c354..e07de123 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -1974,11 +1974,8 @@ void Room::Private::postprocessChanges(Changes changes, bool saveState)
if (changes & Change::Highlights)
emit q->highlightCountChanged();
- qCDebug(MAIN) << terse << changes << "= hex" <<
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- Qt::
-#endif
- hex << uint(changes) << "in" << q->objectName();
+ qCDebug(MAIN) << terse << changes << "= hex" << Qt::hex << uint(changes)
+ << "in" << q->objectName();
emit q->changed(changes);
if (saveState)
connection->saveRoomState(q);
diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp
index 95d3c7e4..ff3dc0c2 100644
--- a/lib/syncdata.cpp
+++ b/lib/syncdata.cpp
@@ -179,12 +179,7 @@ QJsonObject SyncData::loadJson(const QString& fileName)
const auto json = data.startsWith('{')
? QJsonDocument::fromJson(data).object()
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
- : QCborValue::fromCbor(data).toJsonValue().toObject()
-#else
- : QJsonDocument::fromBinaryData(data).object()
-#endif
- ;
+ : QCborValue::fromCbor(data).toJsonValue().toObject();
if (json.isEmpty()) {
qCWarning(MAIN) << "State cache in" << fileName
<< "is broken or empty, discarding";