diff --git a/common.pri b/common.pri index 6d32973..6e0c174 100644 --- a/common.pri +++ b/common.pri @@ -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/ diff --git a/libdbus-qeventloop/dbusconnectioneventloop.cpp b/libdbus-qeventloop/dbusconnectioneventloop.cpp index a060f78..c138d00 100644 --- a/libdbus-qeventloop/dbusconnectioneventloop.cpp +++ b/libdbus-qeventloop/dbusconnectioneventloop.cpp @@ -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; } diff --git a/libdbus-qeventloop/libdbus-qeventloop.pro b/libdbus-qeventloop/libdbus-qeventloop.pro index 4ec0494..f9453bf 100644 --- a/libdbus-qeventloop/libdbus-qeventloop.pro +++ b/libdbus-qeventloop/libdbus-qeventloop.pro @@ -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 @@ -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 diff --git a/libmediaoverridesqt/libmediaoverridesqt.pro b/libmediaoverridesqt/libmediaoverridesqt.pro index e379858..6f2c161 100644 --- a/libmediaoverridesqt/libmediaoverridesqt.pro +++ b/libmediaoverridesqt/libmediaoverridesqt.pro @@ -1,6 +1,6 @@ include(../common.pri) TEMPLATE = lib -TARGET = mediaoverridesqt5 +TARGET = mediaoverridesqt$${QT_MAJOR_VERSION} DESTDIR = build DEPENDPATH += . INCLUDEPATH += . @@ -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 diff --git a/libresourceqt/include/policy/resource-set.h b/libresourceqt/include/policy/resource-set.h index 8ee0008..1abfa6b 100644 --- a/libresourceqt/include/policy/resource-set.h +++ b/libresourceqt/include/policy/resource-set.h @@ -59,6 +59,10 @@ USA. #include #include +#if (QT_VERSION > QT_VERSION_CHECK(6,0,0)) +#include +#endif + class ResourceSetPrivate; @@ -414,7 +418,11 @@ class ResourceSet: public QObject bool haveAudioProperties; bool inAcquireMode; QList requestQ; +#if (QT_VERSION > QT_VERSION_CHECK(6,0,0)) + QRecursiveMutex reqMutex; +#else QMutex reqMutex; +#endif bool ignoreQ; ResourceSetPrivate* d; bool initialize(); diff --git a/libresourceqt/libresourceqt.pro b/libresourceqt/libresourceqt.pro index d8325de..1af8af8 100644 --- a/libresourceqt/libresourceqt.pro +++ b/libresourceqt/libresourceqt.pro @@ -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 @@ -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 diff --git a/libresourceqt/src/resource-engine.cpp b/libresourceqt/src/resource-engine.cpp index 1c71c3f..97754fa 100644 --- a/libresourceqt/src/resource-engine.cpp +++ b/libresourceqt/src/resource-engine.cpp @@ -23,6 +23,10 @@ USA. #include #include +#if (QT_VERSION > QT_VERSION_CHECK(6,0,0)) +#include +#endif + Q_LOGGING_CATEGORY(lcResourceQt, "resourceQt", QtWarningMsg) using namespace ResourcePolicy; @@ -32,7 +36,11 @@ static QMultiMap 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); @@ -61,7 +69,11 @@ ResourceEngine::ResourceEngine(ResourceSet *resourceSet) ResourceEngine::~ResourceEngine() { qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__); +#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) QMutexLocker locker(&mutex); +#else + mutex.unlock(); +#endif qCDebug(lcResourceQt, "ResourceEngine::~ResourceEngine(%d) - starting destruction", identifier); libresourceUsers--; @@ -83,7 +95,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; @@ -124,7 +140,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; @@ -151,7 +171,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); @@ -224,7 +248,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; @@ -253,7 +281,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; @@ -282,7 +314,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; @@ -327,7 +363,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)); @@ -419,7 +459,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); @@ -519,7 +563,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)); @@ -538,7 +586,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)); @@ -556,7 +608,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; @@ -591,7 +647,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; @@ -633,7 +693,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)); @@ -660,7 +724,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"); diff --git a/libresourceqt/src/resource-set.cpp b/libresourceqt/src/resource-set.cpp index 4b57cb2..7021101 100644 --- a/libresourceqt/src/resource-set.cpp +++ b/libresourceqt/src/resource-set.cpp @@ -20,6 +20,7 @@ USA. *************************************************************************/ #include #include "resource-engine.h" + using namespace ResourcePolicy; static quint32 resourceSetId=1; @@ -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), +#if (QT_VERSION > QT_VERSION_CHECK(6,0,0)) + inAcquireMode(false), reqMutex(QRecursiveMutex()), ignoreQ(false) +#else inAcquireMode(false), reqMutex(QMutex::Recursive), ignoreQ(false) +#endif { identifier = resourceSetId++; memset(resourceSet, 0, sizeof(Resource *)*NumberOfTypes); @@ -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), +#if (QT_VERSION > QT_VERSION_CHECK(6,0,0)) + inAcquireMode(false), reqMutex(QRecursiveMutex()), ignoreQ(false) +#else inAcquireMode(false), reqMutex(QMutex::Recursive), ignoreQ(false) +#endif { identifier = resourceSetId++; memset(resourceSet, 0, sizeof(Resource *)*NumberOfTypes); diff --git a/resourceqt-client/client.cpp b/resourceqt-client/client.cpp index 2add6e0..9d42cf4 100644 --- a/resourceqt-client/client.cpp +++ b/resourceqt-client/client.cpp @@ -29,6 +29,12 @@ USA. #include "client.h" +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) +#define ENDL endl +#else +#define ENDL Qt::endl +#endif + #define OUTPUT output << prefix #define outputln output << "\n" << prefix @@ -75,7 +81,11 @@ Client::~Client() void Client::showPrompt() { +#if (QT_VERSION > QT_VERSION_CHECK(5,14,0)) + OUTPUT << "resource-Qt> " << Qt::flush; +#else OUTPUT << "resource-Qt> " << flush; +#endif } bool Client::initialize(const CommandLineParser &parser) @@ -86,11 +96,11 @@ bool Client::initialize(const CommandLineParser &parser) prefix = parser.getPrefix(); if (parser.shouldAlwaysReply()) { - OUTPUT << "client: AlwaysReply" << endl; + OUTPUT << "client: AlwaysReply" << ENDL; } if (parser.shouldAutoRelease()) { - OUTPUT << "client: AutoRelease" << endl; + OUTPUT << "client: AutoRelease" << ENDL; } showTimings = parser.showTimings(); @@ -146,7 +156,7 @@ bool Client::initialize(const CommandLineParser &parser) startTimer(); resourceSet->initAndConnect(); - OUTPUT << "accepting input" << endl; + OUTPUT << "accepting input" << ENDL; showPrompt(); return true; } @@ -264,7 +274,7 @@ void Client::showResources(const QList &resList) { outputln << "Resource Set:\n"; foreach(ResourceType resource, resList) { - output << "\t" << resourceTypeToString(resource) << endl; + output << "\t" << resourceTypeToString(resource) << ENDL; } } @@ -277,7 +287,7 @@ void Client::showResources(const QList &resList) output << " (optional)"; if (resource->isGranted()) output << " (granted)"; - output << endl; + output << ENDL; } } @@ -301,7 +311,7 @@ void Client::resourceAcquiredHandler(const QList&) grantedResources << resource->type(); } } - OUTPUT << "granted:" << grantedResources << endl; + OUTPUT << "granted:" << grantedResources << ENDL; } showPrompt(); } @@ -310,7 +320,7 @@ void Client::resourceDeniedHandler() { stopTimer(); QList allResources = resourceSet->resources(); - OUTPUT << "denied:" << allResources << endl; + OUTPUT << "denied:" << allResources << ENDL; showPrompt(); } @@ -319,7 +329,7 @@ void Client::resourceLostHandler() stopTimer(); QList allResources = resourceSet->resources(); - outputln << "lost:" << allResources << endl; + outputln << "lost:" << allResources << ENDL; showPrompt(); } @@ -328,7 +338,7 @@ void Client::resourceReleasedHandler() stopTimer(); QList allResources = resourceSet->resources(); - outputln << "released:"<< allResources << endl; + outputln << "released:"<< allResources << ENDL; showPrompt(); } @@ -337,7 +347,7 @@ void Client::resourceReleasedByManagerHandler() stopTimer(); QList allResources = resourceSet->resources(); - outputln << "mgr-released:"<< allResources << endl; + outputln << "mgr-released:"<< allResources << ENDL; showPrompt(); } @@ -347,7 +357,7 @@ void Client::resourcesBecameAvailableHandler(const QList::const_iterator i = commandList.constBegin(); while (i != commandList.constEnd()) { - OUTPUT << qSetFieldWidth(10) << right << i.key() + OUTPUT << qSetFieldWidth(10) << Qt::right << i.key() << qSetFieldWidth(1) << " " - << qSetFieldWidth(55) << left << i.value().args - << qSetFieldWidth(0) << i.value().help << endl; + << qSetFieldWidth(55) << Qt::left << i.value().args + << qSetFieldWidth(0) << i.value().help << ENDL; ++i; } } @@ -390,7 +400,7 @@ void Client::readLine(int) QList list = resourceSet->resources(); if (!list.count()) { OUTPUT << "Resource set is empty, use add command to add some." - << endl; + << ENDL; } else { showResources(list); @@ -438,14 +448,14 @@ void Client::readLine(int) input >> what; if (what.isEmpty() || what.isNull()) { - OUTPUT << "Not enough parameters! See help" << endl; + OUTPUT << "Not enough parameters! See help" << ENDL; } else { Resource *resource = resourceSet->resource(AudioPlaybackType); AudioResource *audioResource = static_cast(resource); qDebug("resource = %p audioResource = %p", resource, audioResource); if (audioResource == NULL) { - OUTPUT << "No AudioResource available in set!" << endl; + OUTPUT << "No AudioResource available in set!" << ENDL; } else { if (what == "group") { @@ -459,7 +469,7 @@ void Client::readLine(int) audioResource->setProcessID(pid); } else { - OUTPUT << "Bad pid parameter!" << endl; + OUTPUT << "Bad pid parameter!" << ENDL; } } else if (what == "tag") { @@ -467,7 +477,7 @@ void Client::readLine(int) if (tagName.isEmpty() || tagName.isNull() || tagValue.isEmpty() || tagValue.isNull()) { OUTPUT << "tag requires 2 parameters name and value. See help" - << endl; + << ENDL; } else { audioResource->setStreamTag(tagValue, tagName); @@ -485,12 +495,12 @@ void Client::readLine(int) input >> group >> pid >> tagName >> tagValue; if (group.isEmpty() || (pid == 0) || tagName.isEmpty() || tagValue.isEmpty()) { - OUTPUT << "Invalid parameters! See help!" << endl; + OUTPUT << "Invalid parameters! See help!" << ENDL; } else { AudioResource *audioResource = new AudioResource(group); if (audioResource == NULL) { - OUTPUT << "Failed to create an AudioResource object!" << endl; + OUTPUT << "Failed to create an AudioResource object!" << ENDL; } else { audioResource->setProcessID(pid); @@ -507,7 +517,7 @@ void Client::readLine(int) input >> what; if (what.isEmpty() || what.isNull()) { - OUTPUT << "Not enough parameters! See help" << endl; + OUTPUT << "Not enough parameters! See help" << ENDL; } else { Resource *resource = resourceSet->resource(VideoPlaybackType); @@ -515,7 +525,7 @@ void Client::readLine(int) qDebug("resource = %p videoResource = %p", resource, videoResource); if (videoResource == NULL) { - OUTPUT << "No VideoResource available in set!" << endl; + OUTPUT << "No VideoResource available in set!" << ENDL; } else { if (what == "pid") { @@ -525,7 +535,7 @@ void Client::readLine(int) videoResource->setProcessID(pid); } else { - OUTPUT << "Bad pid parameter!" << endl; + OUTPUT << "Bad pid parameter!" << ENDL; } } else { @@ -539,13 +549,13 @@ void Client::readLine(int) input >> pid ; if ( pid == 0 ) { - OUTPUT << "Invalid process ID! See help!" << endl; + OUTPUT << "Invalid process ID! See help!" << ENDL; } else { VideoResource *videoResource = new VideoResource(); if (videoResource == NULL) { - OUTPUT << "Failed to create an VideoResource object!" << endl; + OUTPUT << "Failed to create an VideoResource object!" << ENDL; } else { videoResource->setProcessID(pid); @@ -560,7 +570,7 @@ void Client::readLine(int) resourceSet = new ResourceSet(applicationClass); } else { - OUTPUT << "unknown command '" << command << "'" << endl; + OUTPUT << "unknown command '" << command << "'" << ENDL; } showPrompt(); @@ -600,7 +610,7 @@ void Client::stopTimer() if (showTimings) { long int ms = stop_timer(); if (ms > 0) { - outputln << "Operation took " << ms << " ms" << endl; + outputln << "Operation took " << ms << " ms" << ENDL; } } } diff --git a/resourceqt-client/commandlineparser.cpp b/resourceqt-client/commandlineparser.cpp index 50c8243..553a14a 100644 --- a/resourceqt-client/commandlineparser.cpp +++ b/resourceqt-client/commandlineparser.cpp @@ -22,6 +22,14 @@ USA. #include #include "commandlineparser.h" +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) +#define ENDL endl +#define SKIPEP QString::SkipEmptyParts +#else +#define ENDL Qt::endl +#define SKIPEP Qt::SkipEmptyParts +#endif + extern bool verbose; QHash CommandLineParser::resourceValues; @@ -76,7 +84,7 @@ bool CommandLineParser::parseArguments() break; case 'o': if (!parseResourceList(*(++ci), optResources)) { - output << "Failed to parse resources: " << *ci << endl; + output << "Failed to parse resources: " << *ci << ENDL; return false; } break; @@ -113,13 +121,13 @@ bool CommandLineParser::parseArguments() ++ci; if (ci != args.constEnd()) { if (!parseResourceList(*ci, allResources)) { - output << "Error while parsing resource list" << endl; + output << "Error while parsing resource list" << ENDL; } } } if (!allResources.contains(optResources)) { - output << "optional resources are not subset of all resources" << endl; + output << "optional resources are not subset of all resources" << ENDL; return false; } return true; @@ -163,7 +171,7 @@ bool CommandLineParser::parseResourceList(const QString &resourceListStr, return false; } else { - QStringList resList = resourceListStr.split(",", QString::SkipEmptyParts); + QStringList resList = resourceListStr.split(",", SKIPEP); foreach(QString res, resList) { if (resourceValues.contains(res)) { @@ -181,7 +189,7 @@ bool CommandLineParser::parseModeValues(const QString &modeListStr) return false; } - QStringList modeList = modeListStr.split(",", QString::SkipEmptyParts); + QStringList modeList = modeListStr.split(",", SKIPEP); foreach(QString mode, modeList) { if (mode == "AutoRelease") { @@ -191,7 +199,7 @@ bool CommandLineParser::parseModeValues(const QString &modeListStr) alwaysReply = true; } else { - output << "Ignoring unknown mode '" << mode << "'!" << endl; + output << "Ignoring unknown mode '" << mode << "'!" << ENDL; } } return true; @@ -201,40 +209,40 @@ void CommandLineParser::usage() { output << "usage: resourceqt-client [-h] [-f mode-values]" << "[-o optional-resources] [-i] [-v] [-p prefix] " << - "class all-resources" << endl; - output << "\toptions:" << endl; - output << "\t h\tprint this help message and exit" << endl; - output << "\t i\tshow timings of requests" << endl; - output << "\t v\tshow debug of libresourceqt" << endl; - output << "\t p\tPrefix all output with the given prefix" << endl; + "class all-resources" << ENDL; + output << "\toptions:" << ENDL; + output << "\t h\tprint this help message and exit" << ENDL; + output << "\t i\tshow timings of requests" << ENDL; + output << "\t v\tshow debug of libresourceqt" << ENDL; + output << "\t p\tPrefix all output with the given prefix" << ENDL; output << "\t f\tmode values. See 'modes' below for the " - "\n\t\tsyntax of " << endl; + "\n\t\tsyntax of " << ENDL; output << "\t o\toptional resources. See 'resources' below for the " - "syntax of\n\t\t" << endl; - output << "\tclass:" << endl; - output << "\t\tcall\t - for native or 3rd party telephony" << endl; - output << "\t\tcamera\t - for photo applications" << endl; - output << "\t\tringtone - for ringtones" << endl; - output << "\t\talarm\t - for alarm clock" << endl; - output << "\t\tnavigator - for mapping applications" << endl; - output << "\t\tgame\t - for gaming" << endl; - output << "\t\tplayer\t - for media playback/recording" << endl; - output << "\t\tevent\t - for messaging and other event notifications" << endl; - output << "\t\tbackground - for thumbnailing etc" << endl; - output << "\t\tvideoeditor\t - for video editing/MMS" << endl; - output << "\tresources:" << endl; - output << "\t comma separated list of the following resources" << endl; + "syntax of\n\t\t" << ENDL; + output << "\tclass:" << ENDL; + output << "\t\tcall\t - for native or 3rd party telephony" << ENDL; + output << "\t\tcamera\t - for photo applications" << ENDL; + output << "\t\tringtone - for ringtones" << ENDL; + output << "\t\talarm\t - for alarm clock" << ENDL; + output << "\t\tnavigator - for mapping applications" << ENDL; + output << "\t\tgame\t - for gaming" << ENDL; + output << "\t\tplayer\t - for media playback/recording" << ENDL; + output << "\t\tevent\t - for messaging and other event notifications" << ENDL; + output << "\t\tbackground - for thumbnailing etc" << ENDL; + output << "\t\tvideoeditor\t - for video editing/MMS" << ENDL; + output << "\tresources:" << ENDL; + output << "\t comma separated list of the following resources" << ENDL; QHash::const_iterator ci = resourceValues.constBegin(); while (ci != resourceValues.constEnd()) { - output << "\t\t" << ci.key() << endl; + output << "\t\t" << ci.key() << ENDL; ++ci; } - output << "\t no whitespace allowed in the resource list." << endl; - output << "\tmodes:" << endl; - output << "\t comma separated list of the following modes" << endl; - output << "\t\tAutoRelease" << endl; - output << "\t\tAlwaysReply" << endl; + output << "\t no whitespace allowed in the resource list." << ENDL; + output << "\tmodes:" << ENDL; + output << "\t comma separated list of the following modes" << ENDL; + output << "\t\tAutoRelease" << ENDL; + output << "\t\tAlwaysReply" << ENDL; } const QSet& CommandLineParser::resources() const diff --git a/resourceqt-client/resourceqt-client.pro b/resourceqt-client/resourceqt-client.pro index 55cf295..6a1d408 100644 --- a/resourceqt-client/resourceqt-client.pro +++ b/resourceqt-client/resourceqt-client.pro @@ -22,7 +22,7 @@ include(../common.pri) TEMPLATE = app -TARGET = resourceqt5-client +TARGET = resourceqt$${QT_MAJOR_VERSION}-client MOC_DIR = .moc OBJECTS_DIR = .obj DEPENDPATH += . diff --git a/tests/test_common.pri b/tests/test_common.pri index ebcf854..a30cdbf 100644 --- a/tests/test_common.pri +++ b/tests/test_common.pri @@ -5,4 +5,4 @@ LIBS += $$DBUSQEVENTLOOPLIB INCLUDEPATH += $$PUBLIC_INCLUDE -TESTSTARGETDIR = libresourceqt-qt5-tests +TESTSTARGETDIR = libresourceqt-qt$${QT_MAJOR_VERSION}-tests diff --git a/tests/tests.pro b/tests/tests.pro index e81d442..a84985e 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -37,7 +37,7 @@ SUBDIRS = test-audio-resource \ # Install options include(test_common.pri) unix{ - testsxml.path = /usr/share/libresourceqt-qt5-tests/ + testsxml.path = /usr/share/libresourceqt-qt$${QT_MAJOR_VERSION}-tests/ testsxml.files = tests.xml testsxml.target = tests.xml testsxml.CONFIG = no_check_exist