summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-01-11 13:07:22 +0200
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-01-11 13:07:22 +0200
commit16e168be787858303c33756c3895b3ec4a9ad2de (patch)
treef4b015e4afa70ba7718cd21b895e16c871eb7337
parent60e514250464d6b563ab92b19bf717e57d7b6a52 (diff)
API documentation
-rw-r--r--include/resource-factory.h15
-rw-r--r--include/resource-types.h5
-rw-r--r--include/resource.h127
-rw-r--r--src/libplayback-wrapper.cpp12
-rw-r--r--src/resource.cpp68
-rw-r--r--tests/test-libplayback.make303
-rw-r--r--tests/test-resource.cpp22
-rw-r--r--tests/test-resource.h5
8 files changed, 237 insertions, 320 deletions
diff --git a/include/resource-factory.h b/include/resource-factory.h
index b49a6e8..22de00a 100644
--- a/include/resource-factory.h
+++ b/include/resource-factory.h
@@ -7,15 +7,30 @@
class Resource;
+/** This class is a helper class which should be used to create Resources. Note
+ * that it will own all resources, and so should not be deleted before all
+ * resources are ready to be released. The best way to acchieve this is by
+ * makeing the ResourceHandler class own the factory.
+ */
class ResourceFactory: public QObject
{
Q_OBJECT
Q_DISABLE_COPY( ResourceFactory );
private:
+ //! \internal
QDBusConnection sessionBusConnection;
public:
ResourceFactory(QObject *parent = 0);
~ResourceFactory();
+ /** This method creates a new \ref Resource object.
+ * @param applicationClass The application class to tell the Resource Policy.
+ * @param requestedResources A bit mask of the resources tha this application
+ * wats as a set. If more than one resource is set in this bit mask, then
+ * that set is treated as a whole, and cannot be separated. If the application
+ * needs at times say only audio and at times audio and video, then several
+ * \ref Resource objects need to be created.
+ * @return Returns a pointer to a new Resource, or NULL if there is an error.
+ */
Resource * createResource(enum ResourceTypes::ResourceClass applicationClass,
quint16 requestedResources=ResourceTypes::AudioResource);
};
diff --git a/include/resource-types.h b/include/resource-types.h
index 57c6bfc..18f0d4d 100644
--- a/include/resource-types.h
+++ b/include/resource-types.h
@@ -1,8 +1,10 @@
#ifndef RESOURCE_TYPES_H
#define RESOURCE_TYPES_H
+//! This namespace contains the enumerations used by the Resource library.
namespace ResourceTypes {
+ //! This enum represents the class of the application which uses the resource.
enum ResourceClass {
InvalidClass = 0,
VoIPClass,
@@ -19,6 +21,8 @@ namespace ResourceTypes {
InputClass
};
+ //! This enum defines the different resources that an application can request.
+ //! \note These are bits and can be combined to a bit mask.
enum ResourceType {
AudioResource = 0x01,
VideoResource = 0x02,
@@ -26,6 +30,7 @@ namespace ResourceTypes {
VideoRecorderResource = 0x08
};
+ //! The current state of a resource.
enum ResourceState {
UnknownState,
NotOwnedState,
diff --git a/include/resource.h b/include/resource.h
index 0be0b3a..3399b7c 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -8,6 +8,53 @@
using namespace ResourceTypes;
+/**
+ * This class represents a (set of) requested resource(s). It is created through
+ * the ResourceFactory which knows how to connect it to the underying ResourceLibrary.
+ * This class is responsible for managing the requested resource and is the way
+ * for the application to communicate with the Resource Policy.
+ *
+ * If a program wants to use different sets of resources, e.g. a media player
+ * wanting to play either music or video (audio + video resources), it would then
+ * create multiple resource objects from the ResourceFactory.
+ *
+ * Here is an example of how a media player might use this class. First off you
+ * are going to need a \ref ResourceFactory which you use to create a \ref Resource.
+ * The Resource has a number of signals, most are not strictly mandatory to connect
+ * to, but in order to have it work correctly you should at least connect to the
+ * connectedToServer() and stateChanged() signals, see this example.
+ * \code
+ * resourceFactory = new ResourceFactory(this);
+ * QVERIFY(resourceFactory != NULL);
+ * Resource *resource = resourceFactory->createResource(MediaClass, AudioResource|VideoResource);
+ * if(resource == NULL) doError();
+ * QObject::connect(resource, SIGNAL(connectedToServer()),
+ * &myResourceHandler, SLOT(connectedToServer()));
+ * QObject::connect(resource, SIGNAL(stateChanged(enum ResourceState)),
+ * &myResourceHandler, SLOT(stateChanged(enum ResourceState)));
+ * resource->connectToServer();
+ * \endcode
+ * Then the resource handler would have methods like these to handle the signals:
+ * \code
+ * void MediaPlayerResourceHandler::connectedToServer()
+ * {
+ * //We are now connected to the Policy Server, we can start requesting.
+ * this->reserve();
+ * }
+ *
+ * void MediaPlayerResourceHandler::stateChanged(enum ResourceState)
+ * {
+ * if(resourceState == ResourceTypes::NotOwnedState) {
+ * this->mediaStream->stopMedia();
+ * }
+ * else if(resourceState == ResourceTypes::NotOwnedState) {
+ * //We now own the audio and video devices, so we can
+ * // freely start playing.
+ * this->mediaStream->startMedia();
+ * }
+ * }
+ * \endcode
+ */
class Resource: public QObject
{
Q_OBJECT
@@ -15,49 +62,111 @@ class Resource: public QObject
friend class ResourceFactory;
friend class TestResource;
private:
+ //! \internal The Class that the application belongs to.
enum ResourceClass resourceClass;
+ //! \internal A bit mask of ResourceTypes::ResourceType types which determine the
+ //! the resources which we are interested in.
quint16 resourceType;
+ //! \internal The ResourceLibrary low-level protocol library wrapper.
ResourceLibrary *resourceLibrary;
+ //! The current state of the resource, whether we have exclusive access or not.
enum ResourceState resourceState;
+ //! \internal Private Constructor to prevent accidental mis-use
Resource(enum ResourceClass requestedClass, quint16 requestedResources, QObject *parent=0);
+ //! \internal Initializes the resource library and the low-level protocol library.
bool initialize(ResourceLibrary *library);
public:
virtual ~Resource();
- bool hasExclusiveAccess() const;
+ //! Returns true if we have exclusive access to our resources (as a whole)
+ bool isReserved() const;
+ //! Method used to query whether we have a given resource type in our set.
bool hasResource(enum ResourceType resourceType) const;
+ //! The application class that was registered to this resource.
enum ResourceClass applicationClass() const;
+ //! Returns the \ref ResourceTypes::ResourceType bit mask of resources.
quint16 resources() const;
+ //! Connects and registeres with the Resource Policy Server. The connectedToServer()
+ //! signal is emited when the connection is successful.
bool connectToServer();
+ //! Disconnects from the Resource Policy server.
+ void disconnectFromServer();
+
+ //! \internal Stores the new state and emits a stateChanged() signal.
void handleStateChange(enum ResourceState newState);
+ //! \internal Emits the exclusiveAccessIsAvailable() signal.
+ void emitReservable();
+
+ //! Reserve exclusive access to our resources.
+ //! \return true when the message was successfully sent to the server.
+ virtual bool reserve();
+ //! Ask server to relinquish exclusive access to our resources.
+ //! \return true when the message was successfully sent to the server.
+ virtual bool release();
+ //! Query the server of our current state. The stateChanged() signal will
+ //! be emited when the server responds.
+ virtual bool requestState();
- virtual bool requestExclusiveAccess();
- virtual bool releaseExclusiveAccess();
- virtual bool getExclusiveAccessState();
-/*
+ //! Set the global Mute state.
virtual bool setMute();
+ //! unset the global mute state.
virtual bool unsetMute();
+ //! Query the server for the global mute state. The reply will come
+ //! via the muteState() signal.
virtual bool requestMute();
-
+
+ //! Set the global privacy override, i.e. pipe all audio to the public
+ //! audio device (IHF speakers).
virtual bool setPrivacyOverride();
+ //! Unset the global privacy override, i.e. pipe audio to the private
+ //! headset or eaprpiece if policy dictates so.
virtual bool unsetPrivacyOverride();
+ //! Query the server for the global provacy override state. The reply
+ //! comes via the privacyOverride() signal.
virtual bool requestPrivacyOverride();
+ //! Set the global bluetooth override, i.e. Do not route audio to the
+ //! bluetooth device even if it is connected.
virtual bool setBluetoothOverride();
+ //! Unset the global bluetooth override, i.e. audio is routed to a
+ //! connected bluetooth headset if policy dictates so.
virtual bool unsetBluetoothOverride();
+ //! Query the server for the global bluetooth override flag. The reply
+ //! comes via the bluetoothOverrideState() signal.
virtual bool requestBluetoothOverride();
- virtual bool setPID(pid_t pid);
+ //! Let the Policy Server know the process ID (PID) of the process which
+ //! will do the actual media playing, in case it differs from the PID
+ //! of the owner of this object.
+ virtual bool setPid(quint32 pid);
+ //! Tell policy the stream name of the media stream that this program uses,
+ //! for the same reasons as above.
virtual bool setStreamName(const QString & name);
-*/
- // completed and discarded from libplayback? what are those?
+
signals:
+ //! Emited when we are connected to the server.
void connectedToServer();
+ //! Emited when the server notifies us that another process has precedence
+ //! over us. When receiving this signal with the ResourceTypes::NotOwnedState
+ //! the program should immediately stop using the resources it had reserved
+ //! (if it is in use). When receiving this signal with the
+ //! ResourceTypes::OwnedState, it means that we have received access to the
+ //! resources we asked for and are free to start to use them.
void stateChanged(enum ResourceState newState);
+ //! This is a hint by the Policy Server that our resources are free to use.
+ //! It means we can expect a reserve() to result in a
+ //! stateChanged(ResourceTypes::OwnedState) signal.
+ void reservable();
+ //! This signal shows the global mute state.
+ void muteStateChanged(bool oldMuteState, bool newMuteState);
+ //! This signal shows the global privacy override state.
+ void privacyOverrideChanged(bool PrivacyState, bool newPrivacyState);
+ //! This signal shows the global bluetooth override state.
+ void bluetoothOverrideChanged(bool oldBluetoothState, bool newBluetoothState);
};
#endif
diff --git a/src/libplayback-wrapper.cpp b/src/libplayback-wrapper.cpp
index a869b63..940945d 100644
--- a/src/libplayback-wrapper.cpp
+++ b/src/libplayback-wrapper.cpp
@@ -6,6 +6,7 @@ static inline quint16 resourceFlagsToLibPlaybackFlags(quint16 resourceFlags);
static inline enum ResourceState libPlaybackStateToResourceState(enum pb_state_e libPlaybackState);
static void libPlaybackStateHandler(pb_playback_t *libPlaybackHandler, enum pb_state_e newState,
pb_req_t* playbackRequest, void *data);
+static void libPlaybackStateHintHandler(pb_playback_t *libPlaybackHandler, const int allowedStates[], void *data);
LibPlaybackWrapper::LibPlaybackWrapper(Resource *res)
: QObject(res), dbusConnection(NULL), libPlaybackHandle(NULL)
@@ -108,12 +109,10 @@ void libPlaybackStateHandler(pb_playback_t *libPlaybackHandler, enum pb_state_e
{
LibPlaybackWrapper *libPlaybackWrapper = static_cast<LibPlaybackWrapper*>(data);
- libPlaybackWrapper->stateChanged(newState);
-
pb_playback_req_completed(libPlaybackHandler, playbackRequest);
+ libPlaybackWrapper->stateChanged(newState);
}
-
void LibPlaybackWrapper::stateChanged(enum pb_state_e newState)
{
enum ResourceState resourceState;
@@ -133,3 +132,10 @@ inline enum ResourceState libPlaybackStateToResourceState(enum pb_state_e libPla
return UnknownState;
}
}
+
+static void libPlaybackStateHintHandler(pb_playback_t *libPlaybackHandler, const int allowedStates[], void *data)
+{
+ LibPlaybackWrapper *libPlaybackWrapper = static_cast<LibPlaybackWrapper*>(data);
+
+// libPlaybackWrapper->hintReceived(newStates);
+}
diff --git a/src/resource.cpp b/src/resource.cpp
index 1765c04..3b461da 100644
--- a/src/resource.cpp
+++ b/src/resource.cpp
@@ -40,7 +40,7 @@ bool Resource::hasResource(enum ResourceType resourceType) const
return false;
}
-bool Resource::hasExclusiveAccess() const
+bool Resource::isReserved() const
{
if(resourceState == OwnedState)
return true;
@@ -60,17 +60,77 @@ void Resource::handleStateChange(enum ResourceState newState)
}
}
-bool Resource::requestExclusiveAccess()
+void Resource::emitReservable()
+{
+ return;
+}
+
+bool Resource::reserve()
{
return false;
}
-bool Resource::releaseExclusiveAccess()
+bool Resource::release()
+{
+ return false;
+}
+
+bool Resource::requestState()
+{
+ return false;
+}
+
+bool Resource::setMute()
+{
+ return false;
+}
+
+bool Resource::unsetMute()
+{
+ return false;
+}
+
+bool Resource::requestMute()
+{
+ return false;
+}
+
+bool Resource::setPrivacyOverride()
+{
+ return false;
+}
+
+bool Resource::unsetPrivacyOverride()
+{
+ return false;
+}
+
+bool Resource::requestPrivacyOverride()
+{
+ return false;
+}
+
+bool Resource::setBluetoothOverride()
+{
+ return false;
+}
+
+bool Resource::unsetBluetoothOverride()
+{
+ return false;
+}
+
+bool Resource::requestBluetoothOverride()
+{
+ return false;
+}
+
+bool Resource::setPid(quint32 pid)
{
return false;
}
-bool Resource::getExclusiveAccessState()
+bool Resource::setStreamName(const QString & name)
{
return false;
}
diff --git a/tests/test-libplayback.make b/tests/test-libplayback.make
deleted file mode 100644
index 8946476..0000000
--- a/tests/test-libplayback.make
+++ /dev/null
@@ -1,303 +0,0 @@
-#############################################################################
-# Makefile for building: build/test-libplayback
-# Generated by qmake (2.01a) (Qt 4.6.0) on: Tue Jan 5 10:34:26 2010
-# Project: test-libplayback.pro
-# Template: app
-# Command: /usr/bin/qmake -unix -o test-libplayback.make test-libplayback.pro
-#############################################################################
-
-####### Compiler, tools and options
-
-CC = gcc
-CXX = g++
-DEFINES = -DQT_DBUS_LIB -DQT_CORE_LIB -DQT_SHARED
-CFLAGS = -pipe -g -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/libplayback-1 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -Wall -W -D_REENTRANT $(DEFINES)
-CXXFLAGS = -pipe -g -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/libplayback-1 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -Wall -W -D_REENTRANT $(DEFINES)
-INCPATH = -I/targets/maemo6-armv7/usr/share/qt4/mkspecs/linux-g++-gles2 -I. -I/targets/maemo6-armv7/usr/include/qt4/QtCore -I/targets/maemo6-armv7/usr/include/qt4/QtDBus -I/targets/maemo6-armv7/usr/include/qt4 -I/targets/maemo6-armv7/usr/include/qt4/QtTest -I../src -I../include -Ibuild
-LINK = g++
-LFLAGS = -Wl,-rpath-link=/lib -Wl,-rpath-link=/usr/lib -Wl,-rpath-link=/usr/local/lib -Wl,-rpath-link=/usr/X11R6/lib
-LIBS = $(SUBLIBS) -L/usr/lib -lplayback-1 -ldbus-1 -lrt -lQtTest -lQtDBus -lQtCore -lpthread
-AR = ar cqs
-RANLIB =
-QMAKE = /usr/bin/qmake
-TAR = tar -cf
-COMPRESS = gzip -9f
-COPY = cp -f
-SED = sed
-COPY_FILE = $(COPY)
-COPY_DIR = $(COPY) -r
-STRIP = strip
-INSTALL_FILE = install -m 644 -p
-INSTALL_DIR = $(COPY_DIR)
-INSTALL_PROGRAM = install -m 755 -p
-DEL_FILE = rm -f
-SYMLINK = ln -sf
-DEL_DIR = rmdir
-MOVE = mv -f
-CHK_DIR_EXISTS= test -d
-MKDIR = mkdir -p
-
-####### Output directory
-
-OBJECTS_DIR = build/
-
-####### Files
-
-SOURCES = test-libplayback.cpp \
- ../src/libplayback-wrapper.cpp \
- ../src/resource.cpp \
- ../src/resource-factory.cpp build/moc_test-libplayback.cpp \
- build/moc_resource.cpp \
- build/moc_resource-factory.cpp \
- build/moc_libplayback-wrapper.cpp
-OBJECTS = build/test-libplayback.o \
- build/libplayback-wrapper.o \
- build/resource.o \
- build/resource-factory.o \
- build/moc_test-libplayback.o \
- build/moc_resource.o \
- build/moc_resource-factory.o \
- build/moc_libplayback-wrapper.o
-DIST = /targets/maemo6-armv7/usr/share/qt4/mkspecs/common/g++.conf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/common/unix.conf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/common/linux.conf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/qconfig.pri \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qt_functions.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qt_config.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/default_pre.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/debug.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/default_post.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/link_pkgconfig.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/warn_on.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qtestlib.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qt.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/moc.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/dbusinterfaces.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/dbusadaptors.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/unix/thread.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/resources.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/uic.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/yacc.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/lex.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/include_source_dir.prf \
- test-libplayback.pro
-QMAKE_TARGET = test-libplayback
-DESTDIR = build/
-TARGET = build/test-libplayback
-
-first: all
-####### Implicit rules
-
-.SUFFIXES: .o .c .cpp .cc .cxx .C
-
-.cpp.o:
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.cc.o:
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.cxx.o:
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.C.o:
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.c.o:
- $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
-
-####### Build rules
-
-all: test-libplayback.make $(TARGET)
-
-$(TARGET): $(OBJECTS)
- @$(CHK_DIR_EXISTS) build/ || $(MKDIR) build/
- $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
-
-test-libplayback.make: test-libplayback.pro /targets/maemo6-armv7/usr/share/qt4/mkspecs/linux-g++-gles2/qmake.conf /targets/maemo6-armv7/usr/share/qt4/mkspecs/common/g++.conf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/common/unix.conf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/common/linux.conf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/qconfig.pri \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qt_functions.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qt_config.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/default_pre.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/debug.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/default_post.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/link_pkgconfig.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/warn_on.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qtestlib.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qt.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/moc.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/dbusinterfaces.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/dbusadaptors.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/unix/thread.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/resources.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/uic.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/yacc.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/lex.prf \
- /targets/maemo6-armv7/usr/share/qt4/mkspecs/features/include_source_dir.prf \
- /usr/lib/libQtTest.prl \
- /usr/lib/libQtDBus.prl \
- /usr/lib/libQtCore.prl
- $(QMAKE) -unix -o test-libplayback.make test-libplayback.pro
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/common/g++.conf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/common/unix.conf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/common/linux.conf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/qconfig.pri:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qt_functions.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qt_config.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/default_pre.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/debug.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/default_post.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/link_pkgconfig.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/warn_on.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qtestlib.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/qt.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/moc.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/dbusinterfaces.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/dbusadaptors.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/unix/thread.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/resources.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/uic.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/yacc.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/lex.prf:
-/targets/maemo6-armv7/usr/share/qt4/mkspecs/features/include_source_dir.prf:
-/usr/lib/libQtTest.prl:
-/usr/lib/libQtDBus.prl:
-/usr/lib/libQtCore.prl:
-qmake: FORCE
- @$(QMAKE) -unix -o test-libplayback.make test-libplayback.pro
-
-dist:
- @$(CHK_DIR_EXISTS) build/test-libplayback1.0.0 || $(MKDIR) build/test-libplayback1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) build/test-libplayback1.0.0/ && $(COPY_FILE) --parents test-libplayback.h ../include/resource.h ../include/resource-factory.h ../include/resource-types.h ../src/libplayback-wrapper.h ../src/resource-library.h build/test-libplayback1.0.0/ && $(COPY_FILE) --parents test-libplayback.cpp ../src/libplayback-wrapper.cpp ../src/resource.cpp ../src/resource-factory.cpp build/test-libplayback1.0.0/ && (cd `dirname build/test-libplayback1.0.0` && $(TAR) test-libplayback1.0.0.tar test-libplayback1.0.0 && $(COMPRESS) test-libplayback1.0.0.tar) && $(MOVE) `dirname build/test-libplayback1.0.0`/test-libplayback1.0.0.tar.gz . && $(DEL_FILE) -r build/test-libplayback1.0.0
-
-
-clean:compiler_clean
- -$(DEL_FILE) $(OBJECTS)
- -$(DEL_FILE) *~ core *.core
-
-
-####### Sub-libraries
-
-distclean: clean
- -$(DEL_FILE) $(TARGET)
- -$(DEL_FILE) test-libplayback.make
-
-
-mocclean: compiler_moc_header_clean compiler_moc_source_clean
-
-mocables: compiler_moc_header_make_all compiler_moc_source_make_all
-
-compiler_moc_header_make_all: build/moc_test-libplayback.cpp build/moc_resource.cpp build/moc_resource-factory.cpp build/moc_libplayback-wrapper.cpp
-compiler_moc_header_clean:
- -$(DEL_FILE) build/moc_test-libplayback.cpp build/moc_resource.cpp build/moc_resource-factory.cpp build/moc_libplayback-wrapper.cpp
-build/moc_test-libplayback.cpp: ../include/resource-factory.h \
- ../include/resource-types.h \
- ../include/resource.h \
- ../src/resource-library.h \
- test-libplayback.h
- /usr/bin/moc $(DEFINES) $(INCPATH) test-libplayback.h -o build/moc_test-libplayback.cpp
-
-build/moc_resource.cpp: ../src/resource-library.h \
- ../include/resource-types.h \
- ../include/resource.h
- /usr/bin/moc $(DEFINES) $(INCPATH) ../include/resource.h -o build/moc_resource.cpp
-
-build/moc_resource-factory.cpp: ../include/resource-types.h \
- ../include/resource-factory.h
- /usr/bin/moc $(DEFINES) $(INCPATH) ../include/resource-factory.h -o build/moc_resource-factory.cpp
-
-build/moc_libplayback-wrapper.cpp: ../src/resource-library.h \
- ../include/resource.h \
- ../include/resource-types.h \
- ../src/libplayback-wrapper.h
- /usr/bin/moc $(DEFINES) $(INCPATH) ../src/libplayback-wrapper.h -o build/moc_libplayback-wrapper.cpp
-
-compiler_dbus_interface_source_make_all:
-compiler_dbus_interface_source_clean:
-compiler_dbus_adaptor_source_make_all:
-compiler_dbus_adaptor_source_clean:
-compiler_rcc_make_all:
-compiler_rcc_clean:
-compiler_image_collection_make_all: qmake_image_collection.cpp
-compiler_image_collection_clean:
- -$(DEL_FILE) qmake_image_collection.cpp
-compiler_moc_source_make_all:
-compiler_moc_source_clean:
-compiler_dbus_interface_header_make_all:
-compiler_dbus_interface_header_clean:
-compiler_dbus_interface_moc_make_all:
-compiler_dbus_interface_moc_clean:
-compiler_dbus_adaptor_header_make_all:
-compiler_dbus_adaptor_header_clean:
-compiler_dbus_adaptor_moc_make_all:
-compiler_dbus_adaptor_moc_clean:
-compiler_uic_make_all:
-compiler_uic_clean:
-compiler_yacc_decl_make_all:
-compiler_yacc_decl_clean:
-compiler_yacc_impl_make_all:
-compiler_yacc_impl_clean:
-compiler_lex_make_all:
-compiler_lex_clean:
-compiler_clean: compiler_moc_header_clean
-
-####### Compile
-
-build/test-libplayback.o: test-libplayback.cpp test-libplayback.h \
- ../include/resource-factory.h \
- ../include/resource-types.h \
- ../include/resource.h \
- ../src/resource-library.h
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/test-libplayback.o test-libplayback.cpp
-
-build/libplayback-wrapper.o: ../src/libplayback-wrapper.cpp ../src/libplayback-wrapper.h \
- ../src/resource-library.h \
- ../include/resource.h \
- ../include/resource-types.h
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/libplayback-wrapper.o ../src/libplayback-wrapper.cpp
-
-build/resource.o: ../src/resource.cpp ../include/resource.h \
- ../src/resource-library.h \
- ../include/resource-types.h
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/resource.o ../src/resource.cpp
-
-build/resource-factory.o: ../src/resource-factory.cpp ../include/resource-factory.h \
- ../include/resource-types.h \
- ../src/libplayback-wrapper.h \
- ../src/resource-library.h \
- ../include/resource.h
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/resource-factory.o ../src/resource-factory.cpp
-
-build/moc_test-libplayback.o: build/moc_test-libplayback.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_test-libplayback.o build/moc_test-libplayback.cpp
-
-build/moc_resource.o: build/moc_resource.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_resource.o build/moc_resource.cpp
-
-build/moc_resource-factory.o: build/moc_resource-factory.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_resource-factory.o build/moc_resource-factory.cpp
-
-build/moc_libplayback-wrapper.o: build/moc_libplayback-wrapper.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_libplayback-wrapper.o build/moc_libplayback-wrapper.cpp
-
-####### Install
-
-install_target: first FORCE
- @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/share/libresourceqt/tests/ || $(MKDIR) $(INSTALL_ROOT)/usr/share/libresourceqt/tests/
- -$(INSTALL_PROGRAM) "build/$(QMAKE_TARGET)" "$(INSTALL_ROOT)/usr/share/libresourceqt/tests/$(QMAKE_TARGET)"
-
-uninstall_target: FORCE
- -$(DEL_FILE) "$(INSTALL_ROOT)/usr/share/libresourceqt/tests/$(QMAKE_TARGET)"
- -$(DEL_DIR) $(INSTALL_ROOT)/usr/share/libresourceqt/tests/
-
-
-install: install_target FORCE
-
-uninstall: uninstall_target FORCE
-
-FORCE:
-
diff --git a/tests/test-resource.cpp b/tests/test-resource.cpp
index 8f2e52e..49c43b0 100644
--- a/tests/test-resource.cpp
+++ b/tests/test-resource.cpp
@@ -3,6 +3,7 @@
using namespace ResourceTypes;
TestResource::TestResource()
+ : isReservable(false)
{
}
@@ -17,7 +18,7 @@ void TestResource::init()
QVERIFY(resource != NULL);
QVERIFY(resource->applicationClass() == MediaClass);
QVERIFY(resource->resources() == (AudioResource|VideoResource));
- QVERIFY(resource->hasExclusiveAccess() == false);
+ QVERIFY(resource->isReserved() == false);
QVERIFY(resource->hasResource(AudioResource));
QVERIFY(resource->hasResource(VideoResource));
}
@@ -90,4 +91,23 @@ void TestResource::testConnectToServerFails()
QVERIFY(connectToServerSucceeded);
}
+// testStateChanged
+
+void TestResource::testReservable()
+{
+ resource->initialize(resourceLibrary);
+ resource->connectToServer();
+
+ QObject::connect(resource, SIGNAL(reservable()), this, SLOT(handleReservable()));
+
+ resource->emitReservable();
+
+ QVERIFY(isReservable);
+}
+
+void TestResource::handleReservable()
+{
+ isReservable = true;
+}
+
QTEST_MAIN(TestResource)
diff --git a/tests/test-resource.h b/tests/test-resource.h
index 6a39ad4..9028ccd 100644
--- a/tests/test-resource.h
+++ b/tests/test-resource.h
@@ -11,6 +11,8 @@ class TestResource: public QObject
private:
ResourceLibrary *resourceLibrary;
Resource *resource;
+
+ bool isReservable;
public:
TestResource();
~TestResource();
@@ -25,6 +27,9 @@ private slots:
void testApplicationClass();
void testResources();
+
+ void testReservable();
+ void handleReservable();
};
#endif