Skip to content

Commit

Permalink
Fixup build with qt > 5.14
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Aug 18, 2024
1 parent 43ec16f commit 1987e91
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 86 deletions.
4 changes: 2 additions & 2 deletions common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ LIBDBUSQEVENTLOOP = $${PWD}/libdbus-qeventloop
LIBRESOURCEQT = $${PWD}/libresourceqt
LIBMEDIAOVERRIDESQT = $${PWD}/libmediaoverridesqt

RESOURCEQTLIB = -L$${LIBRESOURCEQT}/build -lresourceqt5
DBUSQEVENTLOOPLIB = -L$${LIBDBUSQEVENTLOOP}/build -ldbus-qeventloop-qt5
RESOURCEQTLIB = -L$${LIBRESOURCEQT}/build -lresourceqt$${QT_MAJOR_VERSION}
DBUSQEVENTLOOPLIB = -L$${LIBDBUSQEVENTLOOP}/build -ldbus-qeventloop-qt$${QT_MAJOR_VERSION}

PUBLIC_INCLUDE = $${LIBRESOURCEQT}/include/

2 changes: 1 addition & 1 deletion libdbus-qeventloop/dbusconnectioneventloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ dbus_bool_t DBUSConnectionEventLoop::addWatch(DBusWatch *watch, void *data)
loop->connect(watcher.write, SIGNAL(activated(int)), SLOT(writeSocket(int)));
}

loop->watchers.insertMulti(fd, watcher);
loop->watchers.insert(fd, watcher);

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions libdbus-qeventloop/libdbus-qeventloop.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##############################################################################

include(../common.pri)
TARGET = dbus-qeventloop-qt5
TARGET = dbus-qeventloop-qt$${QT_MAJOR_VERSION}
TEMPLATE = lib
DESTDIR = build
MOC_DIR = .moc
Expand All @@ -42,14 +42,14 @@ INSTALLBASE = $$[QT_INSTALL_PREFIX]
target.path = $$[QT_INSTALL_LIBS]
headers.path = $$INSTALLBASE/include

QMAKE_PKGCONFIG_NAME = libdbus-qeventloop5
QMAKE_PKGCONFIG_NAME = libdbus-qeventloop$${QT_MAJOR_VERSION}
QMAKE_PKGCONFIG_DESCRIPTION = D-Bus - QEventloop binding
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $$headers.path
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_REQUIRES = dbus-1
QMAKE_PKGCONFIG_VERSION = $$VERSION
QMAKE_PKGCONFIG_FILE = libdbus-qeventloop5
QMAKE_PKGCONFIG_FILE = libdbus-qeventloop$${QT_MAJOR_VERSION}

INSTALLS = target headers

12 changes: 6 additions & 6 deletions libmediaoverridesqt/libmediaoverridesqt.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include(../common.pri)
TEMPLATE = lib
TARGET = mediaoverridesqt5
TARGET = mediaoverridesqt$${QT_MAJOR_VERSION}
DESTDIR = build
DEPENDPATH += .
INCLUDEPATH += .
Expand Down Expand Up @@ -28,16 +28,16 @@ QMAKE_DISTCLEAN += -r moc build
headers.files = $${PUBLIC_HEADERS}
INSTALLBASE = $$[QT_INSTALL_PREFIX]
target.path = $$[QT_INSTALL_LIBS]
headers.path = $${INSTALLBASE}/include/resource/qt5/policy
headers.path = $${INSTALLBASE}/include/resource/qt$${QT_MAJOR_VERSION}/policy

QMAKE_PKGCONFIG_NAME = libmediaoverridesqt5
QMAKE_PKGCONFIG_NAME = libmediaoverridesqt$${QT_MAJOR_VERSION}
QMAKE_PKGCONFIG_DESCRIPTION = Maemo playback manager Qt API
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $${INSTALLBASE}/include/resource/qt5
QMAKE_PKGCONFIG_INCDIR = $${INSTALLBASE}/include/resource/qt$${QT_MAJOR_VERSION}
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_REQUIRES = Qt5DBus
QMAKE_PKGCONFIG_REQUIRES = Qt$${QT_MAJOR_VERSION}DBus
QMAKE_PKGCONFIG_VERSION = $$VERSION
QMAKE_PKGCONFIG_FILE = libmediaoverridesqt5
QMAKE_PKGCONFIG_FILE = libmediaoverridesqt$${QT_MAJOR_VERSION}

INSTALLS = target headers

8 changes: 8 additions & 0 deletions libresourceqt/include/policy/resource-set.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ USA.
#include <stdarg.h>
#include <stdio.h>

#if (QT_VERSION > QT_VERSION_CHECK(6,0,0))
#include <QRecursiveMutex>
#endif

class ResourceSetPrivate;


Expand Down Expand Up @@ -414,7 +418,11 @@ class ResourceSet: public QObject
bool haveAudioProperties;
bool inAcquireMode;
QList<requestType> requestQ;
#if (QT_VERSION > QT_VERSION_CHECK(6,0,0))
QRecursiveMutex reqMutex;
#else
QMutex reqMutex;
#endif
bool ignoreQ;
ResourceSetPrivate* d;
bool initialize();
Expand Down
16 changes: 8 additions & 8 deletions libresourceqt/libresourceqt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

include(../common.pri)
TEMPLATE = lib
TARGET = resourceqt5
TARGET = resourceqt$${QT_MAJOR_VERSION}
DESTDIR = build
DEPENDPATH += $${POLICY} src
INCLUDEPATH += $${PUBLIC_INCLUDE} $${LIBDBUSQEVENTLOOP} src
Expand Down Expand Up @@ -55,23 +55,23 @@ PKGCONFIG += dbus-1 libresource
headers.files = $${PUBLIC_HEADERS}
INSTALLBASE = $$[QT_INSTALL_PREFIX]
target.path = $$[QT_INSTALL_LIBS]
headers.path = $${INSTALLBASE}/include/resource/qt5/policy
headers.path = $${INSTALLBASE}/include/resource/qt$${QT_MAJOR_VERSION}/policy

man.files = docs/man
man.path = $${INSTALLBASE}/share
htmldoc.files = docs/html
htmldoc.path = $${INSTALLBASE}/share/doc/libresourceqt5
htmldoc.path = $${INSTALLBASE}/share/doc/libresourceqt$${QT_MAJOR_VERSION}
xmldoc.files = docs/xml
xmldoc.path = $${INSTALLBASE}/share/doc/libresourceqt5
xmldoc.path = $${INSTALLBASE}/share/doc/libresourceqt$${QT_MAJOR_VERSION}

QMAKE_PKGCONFIG_NAME = libresourceqt5
QMAKE_PKGCONFIG_NAME = libresourceqt$${QT_MAJOR_VERSION}
QMAKE_PKGCONFIG_DESCRIPTION = Maemo resource management Qt API
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $${INSTALLBASE}/include/resource/qt5
QMAKE_PKGCONFIG_INCDIR = $${INSTALLBASE}/include/resource/qt$${QT_MAJOR_VERSION}
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_REQUIRES = dbus-1 libdbus-qeventloop5 libresource Qt5Core
QMAKE_PKGCONFIG_REQUIRES = dbus-1 libdbus-qeventloop$${QT_MAJOR_VERSION} libresource Qt$${QT_MAJOR_VERSION}Core
QMAKE_PKGCONFIG_VERSION = $$VERSION
QMAKE_PKGCONFIG_FILE = libresourceqt5
QMAKE_PKGCONFIG_FILE = libresourceqt$${QT_MAJOR_VERSION}

INSTALLS = target headers man htmldoc xmldoc

65 changes: 65 additions & 0 deletions libresourceqt/src/resource-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ USA.
#include <dbus/dbus.h>
#include <res-msg.h>

#if (QT_VERSION > QT_VERSION_CHECK(6,0,0))
#include <QRecursiveMutex>
#endif

Q_LOGGING_CATEGORY(lcResourceQt, "resourceQt", QtWarningMsg)

using namespace ResourcePolicy;
Expand All @@ -32,7 +36,11 @@ static QMultiMap<resconn_t *, ResourceEngine *> engineMap;
resconn_t *ResourceEngine::libresourceConnection = NULL;
quint32 ResourceEngine::libresourceUsers = 0;

#if (QT_VERSION > QT_VERSION_CHECK(6,0,0))
static QRecursiveMutex mutex;
#else
static QMutex mutex(QMutex::Recursive);
#endif

static inline quint32 allResourcesToBitmask(const ResourceSet *resourceSet);
static inline quint32 optionalResourcesToBitmask(const ResourceSet *resourceSet);
Expand Down Expand Up @@ -62,6 +70,7 @@ ResourceEngine::~ResourceEngine()
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
QMutexLocker locker(&mutex);

qCDebug(lcResourceQt, "ResourceEngine::~ResourceEngine(%d) - starting destruction", identifier);
libresourceUsers--;

Expand All @@ -83,7 +92,11 @@ ResourceEngine::~ResourceEngine()
bool ResourceEngine::initialize()
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
DBusError dbusError;
DBusConnection *dbusConnection;

Expand Down Expand Up @@ -124,7 +137,11 @@ bool ResourceEngine::initialize()
static void handleUnregisterMessage(resmsg_t *message, resset_t *libresourceSet, void *)
{
qCDebug(lcResourceQt, "**************** %s() - locking....", __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
if (NULL == libresourceSet->userdata) {
qCDebug(lcResourceQt) << QString("IGNORING unregister, no context");
return;
Expand All @@ -151,7 +168,11 @@ void ResourceEngine::disconnected()
static void handleGrantMessage(resmsg_t *message, resset_t *libresourceSet, void *)
{
qCDebug(lcResourceQt, "**************** %s() - locking....", __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
if (NULL == libresourceSet->userdata) {
qCDebug(lcResourceQt, "IGNORING grant, no context: type=0x%04x, id=0x%04x, reqno=0x%04x, resc=0x%04x",
message->notify.type, message->notify.id, message->notify.reqno, message->notify.resrc);
Expand Down Expand Up @@ -224,7 +245,11 @@ void ResourceEngine::receivedGrant(resmsg_notify_t *notifyMessage)
static void handleReleaseMessage(resmsg_t *message, resset_t *rs, void *)
{
qCDebug(lcResourceQt, "**************** %s() - locking....", __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
if (NULL == rs->userdata) {
qCDebug(lcResourceQt) << QString("IGNORING release, no context");
return;
Expand Down Expand Up @@ -253,7 +278,11 @@ void ResourceEngine::receivedRelease(resmsg_notify_t *message)
static void handleAdviceMessage(resmsg_t *message, resset_t *libresourceSet, void *)
{
qCDebug(lcResourceQt, "**************** %s() - locking....", __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
if (NULL == libresourceSet->userdata) {
qCDebug(lcResourceQt) << QString("IGNORING advice, no context");
return;
Expand Down Expand Up @@ -282,7 +311,11 @@ void ResourceEngine::receivedAdvice(resmsg_notify_t *message)
bool ResourceEngine::connectToManager()
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
if (isConnecting) {
qCDebug(lcResourceQt, "ResourceEngine::%s().... allready connecting, ignoring request", __FUNCTION__);
return true;
Expand Down Expand Up @@ -327,7 +360,11 @@ bool ResourceEngine::connectToManager()
bool ResourceEngine::disconnectFromManager()
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
resmsg_t resourceMessage;
memset(&resourceMessage, 0, sizeof(resmsg_t));

Expand Down Expand Up @@ -419,7 +456,11 @@ static inline quint32 optionalResourcesToBitmask(const ResourceSet *resourceSet)
static void statusCallbackHandler(resset_t *libresourceSet, resmsg_t *message)
{
qCDebug(lcResourceQt, "**************** %s().... %d", __FUNCTION__, __LINE__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
if (NULL == libresourceSet->userdata) {
qCDebug(lcResourceQt, "IGNORING status message, no context: type=0x%04x, id=0x%04x, reqno=0x%04x, errcod=%d",
message->status.type, message->status.id, message->status.reqno, message->status.errcod);
Expand Down Expand Up @@ -519,7 +560,11 @@ bool ResourceEngine::isConnectingToManager()
bool ResourceEngine::acquireResources()
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
resmsg_t message;
memset(&message, 0, sizeof(resmsg_t));

Expand All @@ -538,7 +583,11 @@ bool ResourceEngine::acquireResources()
bool ResourceEngine::releaseResources()
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
resmsg_t message;
memset(&message, 0, sizeof(resmsg_t));

Expand All @@ -556,7 +605,11 @@ bool ResourceEngine::releaseResources()
bool ResourceEngine::updateResources()
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
resmsg_t message;
memset(&message, 0, sizeof(resmsg_t));
message.record.type = RESMSG_UPDATE;
Expand Down Expand Up @@ -591,7 +644,11 @@ bool ResourceEngine::registerAudioProperties(const QString &audioGroup, quint32
const QString &name, const QString &value)
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
resmsg_t message;
memset(&message, 0, sizeof(resmsg_t));
QByteArray groupBa, nameBa, valueBa;
Expand Down Expand Up @@ -633,7 +690,11 @@ bool ResourceEngine::registerAudioProperties(const QString &audioGroup, quint32
bool ResourceEngine::registerVideoProperties(quint32 pid)
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
resmsg_t message;
memset(&message, 0, sizeof(resmsg_t));

Expand All @@ -660,7 +721,11 @@ bool ResourceEngine::registerVideoProperties(quint32 pid)
static void connectionIsUp(resconn_t *connection)
{
qCDebug(lcResourceQt, "**************** %s() - locking....", __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif

qCDebug(lcResourceQt) << QString("connection is up");

Expand Down
13 changes: 11 additions & 2 deletions libresourceqt/src/resource-set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ USA.
*************************************************************************/
#include <policy/resource-set.h>
#include "resource-engine.h"

using namespace ResourcePolicy;

static quint32 resourceSetId=1;
Expand All @@ -35,7 +36,11 @@ ResourceSet::ResourceSet(const QString &applicationClass, QObject * parent,
audioResource(NULL), autoRelease(initialAutoRelease),
alwaysReply(initialAlwaysReply), initialized(false), pendingAcquire(false),
pendingUpdate(false), pendingAudioProperties(false), pendingVideoProperties(false),
inAcquireMode(false), reqMutex(QMutex::Recursive), ignoreQ(false)
inAcquireMode(false),
#if (QT_VERSION < QT_VERSION_CHECK(5,14,0))
reqMutex(QMutex::Recursive),
#endif
ignoreQ(false)
{
identifier = resourceSetId++;
memset(resourceSet, 0, sizeof(Resource *)*NumberOfTypes);
Expand All @@ -46,7 +51,11 @@ ResourceSet::ResourceSet(const QString &applicationClass, QObject * parent)
audioResource(NULL), autoRelease(false),
alwaysReply(false), initialized(false), pendingAcquire(false),
pendingUpdate(false), pendingAudioProperties(false), pendingVideoProperties(false),
inAcquireMode(false), reqMutex(QMutex::Recursive), ignoreQ(false)
inAcquireMode(false),
#if (QT_VERSION < QT_VERSION_CHECK(5,14,0))
reqMutex(QMutex::Recursive),
#endif
ignoreQ(false)
{
identifier = resourceSetId++;
memset(resourceSet, 0, sizeof(Resource *)*NumberOfTypes);
Expand Down
Loading

0 comments on commit 1987e91

Please sign in to comment.