From 0334e01186cbb1d2a4d5f5d5ad2dabb173d87dc6 Mon Sep 17 00:00:00 2001 From: Wolf Bergenheim Date: Thu, 25 Feb 2010 13:56:08 +0200 Subject: Fixed ResourceSet signals QList to list namespace, so the users don't have to use namecpace ResourcePolicy --- libresourceqt.pro | 3 +- libresourceqt/include/qt4/policy/resource-set.h | 4 +- libresourceqt/src/resource-engine.h | 4 +- resourceqt-client/client.cpp | 2 + resourceqt-client/client.h | 14 ++-- .../test-resource-engine/test-resource-engine.cpp | 96 +++++++++++++++++++++- tests/test-resource-engine/test-resource-engine.h | 22 +++-- tests/test-resource-set/test-resource-set.cpp | 59 +++++++++++++ tests/test-resource-set/test-resource-set.h | 43 ++++++---- 9 files changed, 205 insertions(+), 42 deletions(-) diff --git a/libresourceqt.pro b/libresourceqt.pro index c5814e4..d032d2e 100644 --- a/libresourceqt.pro +++ b/libresourceqt.pro @@ -2,11 +2,10 @@ # Main projectfile ##################################################################### -CONFIG += ordered +CONFIG += ordered TEMPLATE = subdirs SUBDIRS = libdbus-qeventloop \ libresourceqt \ resourceqt-client \ tests - diff --git a/libresourceqt/include/qt4/policy/resource-set.h b/libresourceqt/include/qt4/policy/resource-set.h index bc81b89..e190cd0 100644 --- a/libresourceqt/include/qt4/policy/resource-set.h +++ b/libresourceqt/include/qt4/policy/resource-set.h @@ -195,13 +195,13 @@ signals: * \param availableResources A list of available resources. The list of * available resources contains only available resource which we have in the set. */ - void resourcesBecameAvailable(const QList &availableResources); + void resourcesBecameAvailable(const QList &availableResources); /** * This signal is emited as a response to the acquire() request. * \param grantedOptionalResources The list of granted optional resources. * All the mandatory resources have also been aquired. */ - void resourcesGranted(const QList &grantedOptionalResources); + void resourcesGranted(const QList &grantedOptionalResources); /** * This signal is emited as a response to the acquire() request, in the * case where one or more of the mandatroy resources were not availalble. diff --git a/libresourceqt/src/resource-engine.h b/libresourceqt/src/resource-engine.h index 6caaef7..897c27e 100644 --- a/libresourceqt/src/resource-engine.h +++ b/libresourceqt/src/resource-engine.h @@ -17,8 +17,8 @@ class ResourceEngine: public QObject { Q_OBJECT Q_DISABLE_COPY( ResourceEngine ) -#ifndef QT_NO_DEBUG - friend class TestResourceEngine; +#ifdef TEST_RESOURCE_ENGINE_H + friend class ::TestResourceEngine; #endif public: diff --git a/resourceqt-client/client.cpp b/resourceqt-client/client.cpp index 1c4ce34..27583fe 100644 --- a/resourceqt-client/client.cpp +++ b/resourceqt-client/client.cpp @@ -7,6 +7,8 @@ #include "client.h" +using namespace ResourcePolicy; + Client::Client(QString appClass) : QObject() { applicationClass = appClass; diff --git a/resourceqt-client/client.h b/resourceqt-client/client.h index 81461c5..ed32538 100644 --- a/resourceqt-client/client.h +++ b/resourceqt-client/client.h @@ -6,8 +6,6 @@ #include -using namespace ResourcePolicy; - #define RES_AUDIO_PLAYBACK (1<<0) #define RES_VIDEO_PLAYBACK (1<<1) #define RES_AUDIO_RECORDING (1<<2) @@ -33,7 +31,7 @@ public: static uint32_t parseResourceList(QString resourceListStr); private slots: - void resourceAcquiredHandler(const QList& grantedResList); + void resourceAcquiredHandler(const QList& grantedResList); void resourceDeniedHandler(); void resourceLostHandler(); void resourceReleasedHandler(); @@ -49,14 +47,14 @@ private: uint32_t resourcesOptional; QString applicationClass; - ResourceSet* resourceSet; + ResourcePolicy::ResourceSet* resourceSet; - Resource* allocateResource(ResourceType resource, bool optional); - ResourceType getResourceType(uint32_t resource); + ResourcePolicy::Resource* allocateResource(ResourcePolicy::ResourceType resource, bool optional); + ResourcePolicy::ResourceType getResourceType(uint32_t resource); void showPrompt(); - void showResources(const QList resList); - void showResources(const QList resList); + void showResources(const QList resList); + void showResources(const QList resList); void updateSet(uint32_t list, uint32_t optional, bool remove); }; diff --git a/tests/test-resource-engine/test-resource-engine.cpp b/tests/test-resource-engine/test-resource-engine.cpp index 804ef16..8b7fe72 100644 --- a/tests/test-resource-engine/test-resource-engine.cpp +++ b/tests/test-resource-engine/test-resource-engine.cpp @@ -1,10 +1,12 @@ #include "test-resource-engine.h" #include +#include using namespace ResourcePolicy; quint32 theID = 0; void statusCallbackHandler(resset_t *libresourceSet, resmsg_t *message); +static bool strverify(const char *a, const char *b); static void verify_resproto_init(resproto_role_t role, resproto_transport_t transport, @@ -197,6 +199,65 @@ void TestResourceEngine::testRelease() QVERIFY(releaseRequestSucceeded == !requestShouldFail); } +void TestResourceEngine::testRegisterAudioProperties_data() +{ + QTest::addColumn("audioGroup"); + QTest::addColumn("pid"); + QTest::addColumn("streamName"); + QTest::addColumn("streamValue"); + + QTest::newRow("'player':12345:'media.role':'music'") << "player" << 12345 << "media.role" << "music"; + QTest::newRow("'':12345:'media.role':'music'") << "" << 12345 << "media.role" << "music"; + QTest::newRow(":12345:'media.role':'music'") << QString() << 12345 << "media.role" << "music"; + QTest::newRow("'player':0:'media.role':'music'") << "player" << 0 << "media.role" << "music"; + QTest::newRow("'player':12345:'':'music'") << "player" << 12345 << "" << "music"; + QTest::newRow("'player':12345::'music'") << "player" << 12345 << QString() << "music"; + QTest::newRow("'player':12345:'':''") << "player" << 12345 << "" << ""; + QTest::newRow("'player':12345::") << "player" << 12345 << QString() << QString(); + QTest::newRow("'player':12345:'media.role':''") << "player" << 12345 << "media.role" << ""; + QTest::newRow("'player':12345:'media.role':") << "player" << 12345 << "media.role" << QString(); + QTest::newRow("'':0:'':''") << "" << 0 << "" << ""; + QTest::newRow(":0::") << QString() << 0 << QString() << QString(); +} + +char *expectedGroup, *expectedStreamName, *expectedStreamValue; + +void TestResourceEngine::testRegisterAudioProperties() +{ + QFETCH(QString, audioGroup); + QFETCH(quint32, pid); + QFETCH(QString, streamName); + QFETCH(QString, streamValue); + + if(audioGroup.isEmpty() || audioGroup.isNull()) { + expectedGroup = NULL; + } + else { + QByteArray ba = audioGroup.toLatin1(); + expectedGroup = strdup(ba.data()); + } + + if(streamName.isEmpty() || streamName.isNull()) { + expectedStreamName = NULL; + } + else { + QByteArray ba = streamName.toLatin1(); + expectedStreamName = strdup(ba.data()); + } + if(streamValue.isEmpty() || streamValue.isNull()) { + expectedStreamValue = NULL; + } + else { + QByteArray ba = streamValue.toLatin1(); + expectedStreamValue = strdup(ba.data()); + } + + resourceEngine->connectToManager(); + + bool audioPropertiesSetSucceeded = resourceEngine->registerAudioProperties(audioGroup, pid, streamName, streamValue); + QVERIFY(audioPropertiesSetSucceeded); +} + QTEST_MAIN(TestResourceEngine) //////////////////////////////////////////////////////////////// @@ -348,6 +409,14 @@ int resproto_send_message(resset_t *resourceSet, resmsg_t *message, grantMessage.record.reqno = message->record.reqno; grantCallback(&grantMessage, resSet, resSet->userdata); break; + case RESMSG_AUDIO: + statusMessage.type = RESMSG_STATUS; + statusMessage.status.errcod = 0; + statusMessage.status.errmsg = ""; + statusMessage.record.id = 11; + statusMessage.record.reqno = 77; + callbackFunction(resSet, &statusMessage); + break; default: qDebug("Unknown message requested..."); return 0; @@ -369,16 +438,41 @@ static void verify_resproto_send_message(resset_t *resourceSet, resmsg_t *messag QVERIFY(message->possess.id == theID); QVERIFY(callbackFunction != NULL); break; + case RESMSG_AUDIO: + QVERIFY(resourceSet == resSet); + QVERIFY(message->possess.id == theID); + QVERIFY(callbackFunction != NULL); + QVERIFY(strverify(expectedGroup, message->audio.group)); + QVERIFY(strverify(expectedStreamName, message->audio.property.name)); + QVERIFY(strverify(expectedStreamValue, message->audio.property.match.pattern)); default: bool expectedMessageType = false; QVERIFY(expectedMessageType); } } +static bool strverify(const char *a, const char *b) +{ + if (a == b) { + return true; + } + else if ((a == NULL) || (b == NULL)) { + return false; + } + else { + int i = strcmp(a, b); + if (i == 0) + return true; + else + return false; + } + +} + char *resmsg_dump_message(resmsg_t *resmsg, int indent, char *buf, int len) { - return "message"; + char * ret = strdup("message"); } \ No newline at end of file diff --git a/tests/test-resource-engine/test-resource-engine.h b/tests/test-resource-engine/test-resource-engine.h index dbdd755..5398a72 100644 --- a/tests/test-resource-engine/test-resource-engine.h +++ b/tests/test-resource-engine/test-resource-engine.h @@ -3,26 +3,27 @@ #include #include + +class TestResourceEngine; + #include "resource-engine.h" Q_DECLARE_METATYPE(ResourcePolicy::ResourceType) -namespace ResourcePolicy -{ class TestResourceEngine: public QObject { Q_OBJECT private: - ResourceEngine *resourceEngine; - AudioResource *audioPlayback; - VideoResource *videoPlayback; - AudioRecorderResource *audioRecorder; - VideoRecorderResource *videoRecorder; + ResourcePolicy::ResourceEngine *resourceEngine; + ResourcePolicy::AudioResource *audioPlayback; + ResourcePolicy::VideoResource *videoPlayback; + ResourcePolicy::AudioRecorderResource *audioRecorder; + ResourcePolicy::VideoRecorderResource *videoRecorder; bool libresourceInitialized; bool acquireOrDenyWasCalled; public: - ResourceSet *resourceSet; + ResourcePolicy::ResourceSet *resourceSet; TestResourceEngine(); ~TestResourceEngine(); @@ -44,7 +45,10 @@ private slots: void testRelease_data(); void testRelease(); + + void testRegisterAudioProperties_data(); + void testRegisterAudioProperties(); }; -} + #endif diff --git a/tests/test-resource-set/test-resource-set.cpp b/tests/test-resource-set/test-resource-set.cpp index d9cbbce..61ea71c 100644 --- a/tests/test-resource-set/test-resource-set.cpp +++ b/tests/test-resource-set/test-resource-set.cpp @@ -1,5 +1,7 @@ #include "test-resource-set.h" +using namespace ResourcePolicy; + Resource * TestResourceSet::resourceFromType(ResourceType type) { switch (type) { @@ -125,5 +127,62 @@ void TestResourceSet::testContainsSet() QVERIFY(containsAll); QVERIFY(containsSubset); } + +void TestResourceSet::testConnectToSignals() +{ + bool signalConnectionSucceeded=false; + signalConnectionSucceeded = QObject::connect(resourceSet, + SIGNAL(resourcesBecameAvailable(const QList &)), + this, SLOT(handleResourcesBecameAvailable(const QList &))); + + QVERIFY(signalConnectionSucceeded); + + signalConnectionSucceeded = QObject::connect(resourceSet, + SIGNAL(resourcesGranted(const QList &)), + this, SLOT(handleResourcesGranted(const QList &))); + + QVERIFY(signalConnectionSucceeded); + + signalConnectionSucceeded = QObject::connect(resourceSet, + SIGNAL(resourcesDenied()), + this, SLOT(handleResourcesDenied())); + + QVERIFY(signalConnectionSucceeded); + + signalConnectionSucceeded = QObject::connect(resourceSet, + SIGNAL(resourcesReleased()), + this, SLOT(handleResourcesReleased())); + + QVERIFY(signalConnectionSucceeded); + + signalConnectionSucceeded = QObject::connect(resourceSet, + SIGNAL(lostResources()), + this, SLOT(handleLostResources())); + + QVERIFY(signalConnectionSucceeded); + +} + +void TestResourceSet::handleResourcesBecameAvailable(const QList &availableResources) +{ + +} +void TestResourceSet::handleResourcesGranted(const QList &grantedOptionalResources) +{ +} + +void TestResourceSet::handleResourcesDenied() +{ +} + +void TestResourceSet::handleResourcesReleased() +{ +} + +void TestResourceSet::handleLostResources() +{ +} + + QTEST_MAIN(TestResourceSet) diff --git a/tests/test-resource-set/test-resource-set.h b/tests/test-resource-set/test-resource-set.h index abab859..c112b6c 100644 --- a/tests/test-resource-set/test-resource-set.h +++ b/tests/test-resource-set/test-resource-set.h @@ -4,32 +4,37 @@ #include #include -using namespace ResourcePolicy; - class TestResourceSet: public QObject { Q_OBJECT private: - ResourceSet *resourceSet; - - AudioResource *audioResource; - AudioRecorderResource *audioRecorderResource; - Resource *videoResource; - Resource *videoRecorderResource; - Resource *vibraResource; - Resource *ledsResource; - Resource *backlightResource; - Resource *systemButtonResource; - Resource *lockButtonResource; - Resource *scaleButtonResource; - Resource *snapButtonResource; - Resource *lensCoverResource; - - Resource * resourceFromType(ResourceType type); + ResourcePolicy::ResourceSet *resourceSet; + + ResourcePolicy::AudioResource *audioResource; + ResourcePolicy::AudioRecorderResource *audioRecorderResource; + ResourcePolicy::Resource *videoResource; + ResourcePolicy::Resource *videoRecorderResource; + ResourcePolicy::Resource *vibraResource; + ResourcePolicy::Resource *ledsResource; + ResourcePolicy::Resource *backlightResource; + ResourcePolicy::Resource *systemButtonResource; + ResourcePolicy::Resource *lockButtonResource; + ResourcePolicy::Resource *scaleButtonResource; + ResourcePolicy::Resource *snapButtonResource; + ResourcePolicy::Resource *lensCoverResource; + + ResourcePolicy::Resource * resourceFromType(ResourcePolicy::ResourceType type); public: TestResourceSet(); ~TestResourceSet(); +public slots: + + void handleResourcesBecameAvailable(const QList &availableResources); + void handleResourcesGranted(const QList &grantedOptionalResources); + void handleResourcesDenied(); + void handleResourcesReleased(); + void handleLostResources(); private slots: @@ -43,6 +48,8 @@ private slots: void testDelResource(); void testContainsSet(); + + void testConnectToSignals(); }; #endif -- cgit v1.2.3 From c32ba573805a7d2cfe5e64c78dc508385fa34d27 Mon Sep 17 00:00:00 2001 From: Wolf Bergenheim Date: Fri, 26 Feb 2010 09:09:40 +0200 Subject: fixed audio tests --- .../test-resource-engine/test-resource-engine.cpp | 58 +++++++++++----------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/tests/test-resource-engine/test-resource-engine.cpp b/tests/test-resource-engine/test-resource-engine.cpp index 8b7fe72..42f1a0e 100644 --- a/tests/test-resource-engine/test-resource-engine.cpp +++ b/tests/test-resource-engine/test-resource-engine.cpp @@ -131,28 +131,28 @@ void TestResourceEngine::testAcquire() void TestResourceEngine::handleAcquire(quint32 bitmaskOfGrantedResources) { - qDebug("Acquired resources: 0x%04x", bitmaskOfGrantedResources); + //qDebug("Acquired resources: 0x%04x", bitmaskOfGrantedResources); QVERIFY(messageOperationShoulSucceed); bool hasOptionalResource = false; QList resourceList = resourceSet->resources(); for (int i=0; i < resourceList.size(); i++) { quint32 bitmask = resourceTypeToLibresourceType(resourceList.at(i)->type()); - qDebug("Checking if resource %x(%x) is in the list", resourceList.at(i)->type(), bitmask); + //qDebug("Checking if resource %x(%x) is in the list", resourceList.at(i)->type(), bitmask); if ((bitmask & bitmaskOfGrantedResources) == bitmask) { - qDebug("Yes :)"); + //qDebug("Yes :)"); if (resourceList.at(i)->type() == optionalType) { - qDebug("Resource is the one we are looking for. :D"); + //qDebug("Resource is the one we are looking for. :D"); hasOptionalResource = true; break; } } else { - qDebug("No :("); + //qDebug("No :("); } } if ((optionalType == NumberOfTypes) && (bitmaskOfGrantedResources > 0)) { - qDebug("Expected to get no optional resources"); + //qDebug("Expected to get no optional resources"); hasOptionalResource = true; } QVERIFY(hasOptionalResource); @@ -206,18 +206,18 @@ void TestResourceEngine::testRegisterAudioProperties_data() QTest::addColumn("streamName"); QTest::addColumn("streamValue"); - QTest::newRow("'player':12345:'media.role':'music'") << "player" << 12345 << "media.role" << "music"; - QTest::newRow("'':12345:'media.role':'music'") << "" << 12345 << "media.role" << "music"; - QTest::newRow(":12345:'media.role':'music'") << QString() << 12345 << "media.role" << "music"; - QTest::newRow("'player':0:'media.role':'music'") << "player" << 0 << "media.role" << "music"; - QTest::newRow("'player':12345:'':'music'") << "player" << 12345 << "" << "music"; - QTest::newRow("'player':12345::'music'") << "player" << 12345 << QString() << "music"; - QTest::newRow("'player':12345:'':''") << "player" << 12345 << "" << ""; - QTest::newRow("'player':12345::") << "player" << 12345 << QString() << QString(); - QTest::newRow("'player':12345:'media.role':''") << "player" << 12345 << "media.role" << ""; - QTest::newRow("'player':12345:'media.role':") << "player" << 12345 << "media.role" << QString(); - QTest::newRow("'':0:'':''") << "" << 0 << "" << ""; - QTest::newRow(":0::") << QString() << 0 << QString() << QString(); + QTest::newRow("'player':12345:'media.role':'music'") << "player" << 12345u << "media.role" << "music"; + QTest::newRow("'':12345:'media.role':'music'") << "" << 12345u << "media.role" << "music"; + QTest::newRow(":12345:'media.role':'music'") << QString() << 12345u << "media.role" << "music"; + QTest::newRow("'player':0:'media.role':'music'") << "player" << 0u << "media.role" << "music"; + QTest::newRow("'player':12345:'':'music'") << "player" << 12345u << "" << "music"; + QTest::newRow("'player':12345::'music'") << "player" << 12345u << QString() << "music"; + QTest::newRow("'player':12345:'':''") << "player" << 12345u << "" << ""; + QTest::newRow("'player':12345::") << "player" << 12345u << QString() << QString(); + QTest::newRow("'player':12345:'media.role':''") << "player" << 12345u << "media.role" << ""; + QTest::newRow("'player':12345:'media.role':") << "player" << 12345u << "media.role" << QString(); + QTest::newRow("'':0:'':''") << "" << 0u << "" << ""; + QTest::newRow(":0::") << QString() << 0u << QString() << QString(); } char *expectedGroup, *expectedStreamName, *expectedStreamValue; @@ -229,6 +229,8 @@ void TestResourceEngine::testRegisterAudioProperties() QFETCH(QString, streamName); QFETCH(QString, streamValue); + requestShouldFail = false; + if(audioGroup.isEmpty() || audioGroup.isNull()) { expectedGroup = NULL; } @@ -237,20 +239,18 @@ void TestResourceEngine::testRegisterAudioProperties() expectedGroup = strdup(ba.data()); } - if(streamName.isEmpty() || streamName.isNull()) { + if(streamName.isEmpty() || streamName.isNull() || streamValue.isEmpty() || streamValue.isNull()) { expectedStreamName = NULL; + expectedStreamValue = NULL; } else { QByteArray ba = streamName.toLatin1(); expectedStreamName = strdup(ba.data()); - } - if(streamValue.isEmpty() || streamValue.isNull()) { - expectedStreamValue = NULL; - } - else { - QByteArray ba = streamValue.toLatin1(); + ba = streamValue.toLatin1(); expectedStreamValue = strdup(ba.data()); } + //qDebug() << "streamValue = " << streamValue; + //qDebug("expectedStreamValue = %s", expectedStreamValue); resourceEngine->connectToManager(); @@ -358,7 +358,7 @@ int resconn_disconnect(resset_t *resSet, resmsg_t *message, static void verify_resconn_disconnect(resset_t *resourceSet, resmsg_t *message, resproto_status_t callbackFunction) { - qDebug("resourceSet = %p resSet = %p", resourceSet, resSet); + //qDebug("resourceSet = %p resSet = %p", resourceSet, resSet); QVERIFY(resourceSet == resSet); QVERIFY(message->record.type == RESMSG_UNREGISTER); QVERIFY(message->record.id == theID); @@ -370,7 +370,7 @@ int resproto_send_message(resset_t *resourceSet, resmsg_t *message, resproto_status_t callbackFunction) { resmsg_t grantMessage, statusMessage; - qDebug("%s(): id:%u req#: %u", __FUNCTION__, message->record.id, message->record.reqno); + //qDebug("%s(): id:%u req#: %u", __FUNCTION__, message->record.id, message->record.reqno); verify_resproto_send_message(resourceSet, message, callbackFunction); @@ -418,7 +418,7 @@ int resproto_send_message(resset_t *resourceSet, resmsg_t *message, callbackFunction(resSet, &statusMessage); break; default: - qDebug("Unknown message requested..."); + //qDebug("Unknown message requested..."); return 0; } @@ -445,6 +445,7 @@ static void verify_resproto_send_message(resset_t *resourceSet, resmsg_t *messag QVERIFY(strverify(expectedGroup, message->audio.group)); QVERIFY(strverify(expectedStreamName, message->audio.property.name)); QVERIFY(strverify(expectedStreamValue, message->audio.property.match.pattern)); + break; default: bool expectedMessageType = false; QVERIFY(expectedMessageType); @@ -453,6 +454,7 @@ static void verify_resproto_send_message(resset_t *resourceSet, resmsg_t *messag static bool strverify(const char *a, const char *b) { + //qDebug("a='%s' b='%s'", a, b); if (a == b) { return true; } -- cgit v1.2.3 From 73d8ff411fa93877cd6d10231909bd013fcb2144 Mon Sep 17 00:00:00 2001 From: Wolf Bergenheim Date: Fri, 26 Feb 2010 09:29:06 +0200 Subject: version bump --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 6d623f5..799ae77 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libresourceqt (1.1) unstable; urgency=low + + * Bugfix release + +-- Wolf Bergenheim Fri, 26 Feb 2010 09:21:57 +0200 + libresourceqt (1.0) unstable; urgency=low * First release -- cgit v1.2.3 From 7cd15b89a5da8cb7885f6dcb4be2acf562fbb7e7 Mon Sep 17 00:00:00 2001 From: Wolf Bergenheim Date: Fri, 26 Feb 2010 10:06:57 +0200 Subject: fixed changelog --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 799ae77..74b7496 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,7 @@ libresourceqt (1.1) unstable; urgency=low * Bugfix release --- Wolf Bergenheim Fri, 26 Feb 2010 09:21:57 +0200 + -- Wolf Bergenheim Fri, 26 Feb 2010 09:21:57 +0200 libresourceqt (1.0) unstable; urgency=low -- cgit v1.2.3 From 53060a6e6e0b1920fb18f9be1e67eec21f62f9fa Mon Sep 17 00:00:00 2001 From: Wolf Bergenheim Date: Mon, 8 Mar 2010 13:28:32 +0200 Subject: Fixed namespace of resourcesGranted signal parameter --- resourceqt-client/client.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resourceqt-client/client.cpp b/resourceqt-client/client.cpp index 27583fe..968810e 100644 --- a/resourceqt-client/client.cpp +++ b/resourceqt-client/client.cpp @@ -159,7 +159,9 @@ bool Client::initialize(uint32_t all, uint32_t optional, bool alwaysReply, bool updateSet(all, optional, false); - if (!connect(resourceSet, SIGNAL(resourcesGranted(QList)), this, SLOT(resourceAcquiredHandler(QList)))) { + if (!connect(resourceSet, SIGNAL(resourcesGranted(QList)), + this, SLOT(resourceAcquiredHandler(QList)))) + { return false; } -- cgit v1.2.3 From ff1e1a228971c2412ad21693e558bbdcaaeaba77 Mon Sep 17 00:00:00 2001 From: Wolf Bergenheim Date: Wed, 10 Mar 2010 14:32:07 +0200 Subject: Updated documentation --- libresourceqt/Doxyfile | 15 +++++---- libresourceqt/include/qt4/policy/audio-resource.h | 12 ++++++++ libresourceqt/include/qt4/policy/resource-set.h | 37 ++++++++++++++--------- libresourceqt/include/qt4/policy/resource.h | 34 ++++++++++++--------- 4 files changed, 61 insertions(+), 37 deletions(-) diff --git a/libresourceqt/Doxyfile b/libresourceqt/Doxyfile index d41c553..f2c2e14 100644 --- a/libresourceqt/Doxyfile +++ b/libresourceqt/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = ResourcePolicy # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 0.1 +PROJECT_NUMBER = 1.1 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -573,8 +573,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = include/resource.h \ - include/resource-set.h +INPUT = include/qt4 # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -627,7 +626,7 @@ FILE_PATTERNS = *.c \ # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. -RECURSIVE = NO +RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a @@ -923,13 +922,13 @@ GENERATE_QHP = YES # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. -QCH_FILE = ../libresourceqt.qch +QCH_FILE = ../com.nokia.policy.libresourceqt.qch # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace -QHP_NAMESPACE = libresourceqt +QHP_NAMESPACE = ResourcePolicy # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see @@ -1349,7 +1348,7 @@ PERL_PATH = /usr/bin/perl # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. -CLASS_DIAGRAMS = YES +CLASS_DIAGRAMS = NO # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see @@ -1371,7 +1370,7 @@ HIDE_UNDOC_RELATIONS = YES # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) -HAVE_DOT = NO +HAVE_DOT = YES # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This diff --git a/libresourceqt/include/qt4/policy/audio-resource.h b/libresourceqt/include/qt4/policy/audio-resource.h index 99c2c7f..bb0783f 100644 --- a/libresourceqt/include/qt4/policy/audio-resource.h +++ b/libresourceqt/include/qt4/policy/audio-resource.h @@ -18,14 +18,26 @@ public: QString audioGroup() const; bool audioGroupIsSet() const; + /** + * Set the audio group (classification) + * \param newGroup The new audio group to set. + */ void setAudioGroup(const QString & newGroup); quint32 processID() const; + /** + * Set the PID of the process which will render the audio. Use this if the + * audio renderer is in a separate process. + */ void setProcessID(quint32 newPID); QString streamTagName() const; QString streamTagValue() const; bool streamTagIsSet() const; + /** + * Set the tream tag to help policy to correctly identify the audio stream + * beloning to you + */ void setStreamTag(const QString &name, const QString &value); virtual ResourceType type() const; diff --git a/libresourceqt/include/qt4/policy/resource-set.h b/libresourceqt/include/qt4/policy/resource-set.h index e190cd0..ab0e597 100644 --- a/libresourceqt/include/qt4/policy/resource-set.h +++ b/libresourceqt/include/qt4/policy/resource-set.h @@ -24,23 +24,23 @@ * \code * ResourcePolicy::ResourceSet *resources = new ResourcePolicy::ResourceSet("player"); * \endcode - * Then to add resources to the set use the \ref addResource() method to add - * resources to the \ref ResourceSet. Like this: + * Then to add resources to the set use the ResourceSet::addResource() method to add + * resources to the ResourcePolicy::ResourceSet. Like this: * \code * resources->addResource(AudioPlaybackType); * resources->addResource(VideoPlaybackType); * \endcode * If you want to pre-populate the AudioResource with the audio group (it is a good idea) - * and other oudio parameters you can create an audio object your self and then - * give that to the \ref ResourceSet. Note that you should NOT free this object. - * The \ref ResourceSet takes ownership of this pointer. + * and other oudio parameters you can create an audio object yourself and then + * give that to the ResourcePolicy::ResourceSet. Note that you should NOT free this object. + * The ResourcePolicy::ResourceSet takes ownership of this pointer. * \code - * ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource("fmradio"); + * ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource("player"); * resources->addResourceObject(audioResource); * \endcode * Calling the ResourcePolicy::ResourceSet::deleteResource() method will remove - * and delete the object. Then when you want to acquire the \ref ResourcePolicy::ResourceSet - * you simply use the \ref acquire() method, like this: + * and delete the object. Then when you want to acquire the ResourcePolicy::ResourceSet + * you simply use the ResourcePolicy::ResourceSet::acquire() method, like this: * \code * QObject::connect(resources, SIGNAL(resourcesAcquired()), * this, SLOT(acquireOkHandler(QList))); @@ -55,7 +55,7 @@ * This signal tells you when you should stop using the resources you have asked for. * So it is important that you connect to it. * - * To modify the properties of the resources you can use the \ref resource() method. + * To modify the properties of the resources you can use the ResourcePolicy::ResourceSet::resource() method. */ /** @@ -101,8 +101,8 @@ public: * This method adds a resource to the set. A set contains only a single * instance of a given resource. If the ResourceSet already contains a * resource of the given type it will be overridden. - * \param resource The resource to add to the set. The \ref ResourseSet takes - * ownership of the pointer. Do NOT free! + * \param resource The resource to add to the set. + * The ResourcePolicy::ResourseSet takes ownership of the pointer. Do NOT free! */ void addResourceObject(Resource *resource); @@ -119,7 +119,7 @@ public: QList resources() const; /** * This method returns a const pointer to a resource of a specific type. - * \type The type of resource we are interested in. + * \param type The type of resource we are interested in. * \return a pointer to the Resource if it is defined NULL otherwise. */ Resource * resource(ResourceType type) const; @@ -159,17 +159,17 @@ public: */ bool release(); /** - * Commit changes to the \ref ResourceSet. Remember to call update() + * Commit changes to the \ref ResourcePolicy::ResourceSet. Remember to call update() * after adding and/or removing resources. */ bool update(); /** - * Stes the auto-release. When loosing the resources doue to another + * Sets the auto-release. When loosing the resources due to another * application with a higher priority the default is that we automatically * re-gain our resources without having to re-request them. However if * the AutoRelease is set we release the resources and need to re-acquire - * them, when the pre-emting application releases it s resources. + * them, when the pre-emting application releases its resources. * * This feature is by default disabled. * @@ -177,6 +177,10 @@ public: * and cannot be unset. */ bool setAutoRelease(); + /** + * Check whether we have setAutoRelease(). + * \return true if auto-release is ennabled. + */ bool willAutoRelease(); /** * Sets that the resourcesGranted() signal is emited even if we already @@ -186,6 +190,9 @@ public: * and cannot be unset. */ bool setAlwaysReply(); + /** + * Check whether the always-get-reply flag has been set. + * \return true if we will always get a reply (even if there is no change). bool alwaysGetReply(); signals: diff --git a/libresourceqt/include/qt4/policy/resource.h b/libresourceqt/include/qt4/policy/resource.h index 434f3dd..4c18408 100644 --- a/libresourceqt/include/qt4/policy/resource.h +++ b/libresourceqt/include/qt4/policy/resource.h @@ -5,24 +5,27 @@ namespace ResourcePolicy { +/** + * This enumeration represents the resources which can be reserved. + * \see ResourcePolicy::ResourceSet::AddResource() for info on how to reserve + * resources. + */ enum ResourceType { - AudioPlaybackType = 0, - VideoPlaybackType, - AudioRecorderType, - VideoRecorderType, - VibraType, - LedsType, - BacklightType, - SystemButtonType, - LockButtonType, - ScaleButtonType, - SnapButtonType, + AudioPlaybackType = 0, ///< For audio playback + VideoPlaybackType, ///< For video playback + AudioRecorderType, ///< For audio recording (using of the microphone) + VideoRecorderType, ///< For video recording (using the camera) + VibraType, ///< For Vibra + LedsType, ///< For LEDs + BacklightType, ///< For the backlight (of the display) + SystemButtonType, ///< For the system (power) button + LockButtonType, ///< For the lock button + ScaleButtonType, ///< The scale (zoom) button + SnapButtonType, ///< Use this if you are a camera application LensCoverType, NumberOfTypes }; -class ResourceSet; - /** * This class is the super class for all resources. It represents a generic * \ref Resource. The type specific resource classes should be used. @@ -30,7 +33,6 @@ class ResourceSet; class Resource { public: - friend class ResourceSet; /** * Whether or not this resource is optional, in that it doesn't need to * be available for the set to be acquired. @@ -51,6 +53,10 @@ public: */ bool isGranted() const; + /** + * Use this method to check for the type of Resource + * \return The ResourceType associated to this resource + */ virtual ResourceType type() const = 0; virtual ~Resource(); protected: -- cgit v1.2.3 From 50dbb5b9aad308fe9c23db4e6db3f4b1a07dab17 Mon Sep 17 00:00:00 2001 From: Wolf Bergenheim Date: Thu, 11 Mar 2010 10:47:19 +0200 Subject: Fixed bugs caused by documenting --- libresourceqt/include/qt4/policy/resource-set.h | 1 + libresourceqt/include/qt4/policy/resource.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/libresourceqt/include/qt4/policy/resource-set.h b/libresourceqt/include/qt4/policy/resource-set.h index ab0e597..0d72cb7 100644 --- a/libresourceqt/include/qt4/policy/resource-set.h +++ b/libresourceqt/include/qt4/policy/resource-set.h @@ -193,6 +193,7 @@ public: /** * Check whether the always-get-reply flag has been set. * \return true if we will always get a reply (even if there is no change). + */ bool alwaysGetReply(); signals: diff --git a/libresourceqt/include/qt4/policy/resource.h b/libresourceqt/include/qt4/policy/resource.h index 4c18408..4f9b02e 100644 --- a/libresourceqt/include/qt4/policy/resource.h +++ b/libresourceqt/include/qt4/policy/resource.h @@ -26,12 +26,15 @@ enum ResourceType { NumberOfTypes }; +class ResourceSet; + /** * This class is the super class for all resources. It represents a generic * \ref Resource. The type specific resource classes should be used. */ class Resource { + friend class ResourceSet; public: /** * Whether or not this resource is optional, in that it doesn't need to -- cgit v1.2.3