summaryrefslogtreecommitdiff
path: root/libresourceqt
diff options
context:
space:
mode:
Diffstat (limited to 'libresourceqt')
-rw-r--r--libresourceqt/include/qt4/policy/resource-set.h312
-rw-r--r--libresourceqt/include/qt4/policy/resource.h115
-rw-r--r--libresourceqt/include/qt4/policy/resources.h319
-rw-r--r--libresourceqt/src/resource-engine.cpp108
-rw-r--r--libresourceqt/src/resource-set.cpp27
-rw-r--r--libresourceqt/src/resource.cpp4
-rw-r--r--libresourceqt/src/resources.cpp48
7 files changed, 468 insertions, 465 deletions
diff --git a/libresourceqt/include/qt4/policy/resource-set.h b/libresourceqt/include/qt4/policy/resource-set.h
index 0e18e5b..3e9bc24 100644
--- a/libresourceqt/include/qt4/policy/resource-set.h
+++ b/libresourceqt/include/qt4/policy/resource-set.h
@@ -9,15 +9,15 @@
/**
* \mainpage Resource Policy Library
- *
+ *
* \section intro_section Introduction
- *
+ *
* This library is used to request resources from the Polict Resource Manager.
* To use this library two classes are provided: \ref ResourcePolicy::Resource and
* \ref ResourcePolicy::ResourceSet.
- *
+ *
* \section library_use_section Library Usage
- *
+ *
* To use the Resource Policy Library, you first need to create a number of
* \ref Resource objects like this (given as an example of what a media player
* might want/need):
@@ -50,168 +50,168 @@
*/
namespace ResourcePolicy
{
+/**
+ * The resourceSet repesents a set of attributes. Each set can only contain
+ * a single Resource of a given type. That is one AudioPlaybackResource, etc.
+ *
+ * Internally the set is stored as a QVector of \ref Resource objects.
+ */
+class ResourceSet: public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(ResourceSet)
+public:
+ /**
+ * The constructor.
+ * \param applicationClass This parameter defines the application class.
+ * The application class is used to determine the priority order of the
+ * application.
+ * \param parent The optional parent of of this class.
+ */
+ ResourceSet(const QString &applicationClass, QObject *parent = NULL);
+ /**
+ * The destructor
+ */
+ ~ResourceSet();
/**
- * The resourceSet repesents a set of attributes. Each set can only contain
- * a single Resource of a given type. That is one AudioPlaybackResource, etc.
- *
- * Internally the set is stored as a QVector of \ref Resource objects.
- */
- class ResourceSet: public QObject
- {
- Q_OBJECT
- Q_DISABLE_COPY( ResourceSet )
- public:
- /**
- * The constructor.
- * \param applicationClass This parameter defines the application class.
- * The application class is used to determine the priority order of the
- * application.
- * \param parent The optional parent of of this class.
- */
- ResourceSet(const QString &applicationClass, QObject *parent=NULL);
- /**
- * The destructor
- */
- ~ResourceSet();
- /**
- * Finalizes the ResourceSet. This method should be called after all
- * resources have been added to the set.
- * \return true if the finalization was successful.
- */
- bool finalize();
+ * Finalizes the ResourceSet. This method should be called after all
+ * resources have been added to the set.
+ * \return true if the finalization was successful.
+ */
+ bool finalize();
- /**
- * 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. A copy of this object
- * is stored in the Set.
- */
- void addResource(const Resource *resource);
- /**
- * This method adds all resources in the list 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 resources The list of resources to add to the set. These will
- * be copied.
- */
- void addResources(const QList<Resource *>resources);
- /**
- * This method removes the resource of the given type
- * \param type The type of the resource to remove from the set.
- */
- void delResource(ResourceType type);
+ /**
+ * 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. A copy of this object
+ * is stored in the Set.
+ */
+ void addResource(const Resource *resource);
+ /**
+ * This method adds all resources in the list 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 resources The list of resources to add to the set. These will
+ * be copied.
+ */
+ void addResources(const QList<Resource *>resources);
+ /**
+ * This method removes the resource of the given type
+ * \param type The type of the resource to remove from the set.
+ */
+ void delResource(ResourceType type);
- /**
- * This method returns a list of all resource in the set.
- * \return a QList of all resources in the set.
- */
- QList<Resource *> resources() const;
- /**
- * This method returns a const pointer to a resource of a specific type.
- * \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;
- /**
- * Checks if the \ref ResourceSet contains the given \ref Resource
- * \param type The Resource to look for
- * \return true if the \ref Resource is defined in this \ref ResourceSet
- */
- bool contains(ResourceType type) const;
+ /**
+ * This method returns a list of all resource in the set.
+ * \return a QList of all resources in the set.
+ */
+ QList<Resource *> resources() const;
+ /**
+ * This method returns a const pointer to a resource of a specific type.
+ * \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;
+ /**
+ * Checks if the \ref ResourceSet contains the given \ref Resource
+ * \param type The Resource to look for
+ * \return true if the \ref Resource is defined in this \ref ResourceSet
+ */
+ bool contains(ResourceType type) const;
- /**
- * Checks if the \ref ResourceSet contains all given resources.
- * \param types A list of resources to check for
- * \return true if \b all given resources are defined in the ResourceSet.
- */
- bool contains(const QList<ResourceType> &types) const;
+ /**
+ * Checks if the \ref ResourceSet contains all given resources.
+ * \param types A list of resources to check for
+ * \return true if \b all given resources are defined in the ResourceSet.
+ */
+ bool contains(const QList<ResourceType> &types) const;
- /**
- * Returns the unique identifier for this ResourceSet.
- * @return the unique identifier for this ResourceSet.
- */
- quint32 id() const;
+ /**
+ * Returns the unique identifier for this ResourceSet.
+ * @return the unique identifier for this ResourceSet.
+ */
+ quint32 id() const;
- /**
- * Returns the registered application class (given in the constructor).
- */
- QString applicationClass();
+ /**
+ * Returns the registered application class (given in the constructor).
+ */
+ QString applicationClass();
- /**
- * Try to acquire the \ref ResourceSet. The resourcesGranted() or
- * resourcesDenied() signal will be emited depending on whether the
- * requested resources could be acquired or not.
- */
- bool acquire();
- /**
- * Release the acquired resources.
- */
- bool release();
- /**
- * Commit changes to the \ref ResourceSet. Remember to call update()
- * after adding and/or removing resources.
- */
- bool update();
+ /**
+ * Try to acquire the \ref ResourceSet. The resourcesGranted() or
+ * resourcesDenied() signal will be emited depending on whether the
+ * requested resources could be acquired or not.
+ */
+ bool acquire();
+ /**
+ * Release the acquired resources.
+ */
+ bool release();
+ /**
+ * Commit changes to the \ref ResourceSet. Remember to call update()
+ * after adding and/or removing resources.
+ */
+ bool update();
- /**
- * Stes the auto-release. When loosing the resources doue 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.
- * This feature is by default disabled.
- * Remember to call update() when changing this.
- */
- void setAutoRelease();
- /**
- * see \ref setAutoRelease().
- */
- void unsetAutoRelease();
- /**
- * Sets that the resourcesGranted() signal is emited even if we already
- * have the requested resources granted. By default this feature is off.
- */
- void setAlwaysReply();
- /**
- * Unsets the always reply flag (see \ref setAlwaysReply())
- */
- void unsetAlwaysReply();
+ /**
+ * Stes the auto-release. When loosing the resources doue 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.
+ * This feature is by default disabled.
+ * Remember to call update() when changing this.
+ */
+ void setAutoRelease();
+ /**
+ * see \ref setAutoRelease().
+ */
+ void unsetAutoRelease();
+ /**
+ * Sets that the resourcesGranted() signal is emited even if we already
+ * have the requested resources granted. By default this feature is off.
+ */
+ void setAlwaysReply();
+ /**
+ * Unsets the always reply flag (see \ref setAlwaysReply())
+ */
+ void unsetAlwaysReply();
- signals:
- /**
- * This signal is emited when the Resource Policy Manager notifies that
- * the given resources have become available.
- * \param availableResources A list of available resources. The list of
- * available resources contains only available resource which we have in the set.
- */
- void resourcesBecameAvailable(QList<ResourceType> 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(QList<ResourceType> 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.
- */
- void resourcesDenied();
- /**
- * This signal is emited when some other program with a higher priority
- * superseeds us, and as a result we loose our resources.
- */
- void lostResources();
+signals:
+ /**
+ * This signal is emited when the Resource Policy Manager notifies that
+ * the given resources have become available.
+ * \param availableResources A list of available resources. The list of
+ * available resources contains only available resource which we have in the set.
+ */
+ void resourcesBecameAvailable(QList<ResourceType> 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(QList<ResourceType> 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.
+ */
+ void resourcesDenied();
+ /**
+ * This signal is emited when some other program with a higher priority
+ * superseeds us, and as a result we loose our resources.
+ */
+ void lostResources();
- private:
- quint32 identifier;
- const QString resourceClass;
- Resource* resourceSet[NumberOfTypes];
- bool connected;
- bool autoRelease;
- bool alwaysReply;
- };
+private:
+ quint32 identifier;
+ const QString resourceClass;
+ Resource* resourceSet[NumberOfTypes];
+ bool connected;
+ bool autoRelease;
+ bool alwaysReply;
+};
}
#endif
diff --git a/libresourceqt/include/qt4/policy/resource.h b/libresourceqt/include/qt4/policy/resource.h
index 74b3e9b..dd31a78 100644
--- a/libresourceqt/include/qt4/policy/resource.h
+++ b/libresourceqt/include/qt4/policy/resource.h
@@ -3,69 +3,70 @@
#include <QtCore>
-namespace ResourcePolicy {
- enum ResourceType {
- AudioPlaybackType = 0,
- VideoPlaybackType,
- AudioRecorderType,
- VideoRecorderType,
- VibraType,
- LedsType,
- BacklightType,
- SystemButtonType,
- LockButtonType,
- ScaleButtonType,
- SnapButtonType,
- LensCoverType,
- NumberOfTypes
- };
+namespace ResourcePolicy
+{
+enum ResourceType {
+ AudioPlaybackType = 0,
+ VideoPlaybackType,
+ AudioRecorderType,
+ VideoRecorderType,
+ VibraType,
+ LedsType,
+ BacklightType,
+ SystemButtonType,
+ LockButtonType,
+ ScaleButtonType,
+ SnapButtonType,
+ LensCoverType,
+ NumberOfTypes
+};
- class ResourceSet;
+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
+{
+public:
+ friend 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
- {
- 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.
- * \return true when this resource is optional.
- */
- bool isOptional() const;
- /**
- * Set the resource to be optional or mandatory.
- * \param resourceIsOptional This optional parameter defaults to true.
- * The default, true, results in the resource becoming optional. When it
- * is set to false the resource becomes mandatory.
- */
- void setOptional(bool resourceIsOptional=true);
- /**
- * Whether or not the resource to be shared. If it is shared then other
- * programs are allowed to share this resource.
- * \return true when this resource is shared.
- */
- bool isGranted() const;
+ * Whether or not this resource is optional, in that it doesn't need to
+ * be available for the set to be acquired.
+ * \return true when this resource is optional.
+ */
+ bool isOptional() const;
+ /**
+ * Set the resource to be optional or mandatory.
+ * \param resourceIsOptional This optional parameter defaults to true.
+ * The default, true, results in the resource becoming optional. When it
+ * is set to false the resource becomes mandatory.
+ */
+ void setOptional(bool resourceIsOptional = true);
+ /**
+ * Whether or not the resource to be shared. If it is shared then other
+ * programs are allowed to share this resource.
+ * \return true when this resource is shared.
+ */
+ bool isGranted() const;
- virtual ResourceType type() const = 0;
- virtual Resource * clone() const = 0;
- virtual ~Resource();
- protected:
- Resource();
- Resource(const Resource &other);
+ virtual ResourceType type() const = 0;
+ virtual Resource * clone() const = 0;
+ virtual ~Resource();
+protected:
+ Resource();
+ Resource(const Resource &other);
- ResourceType resourceType;
- bool optional;
- quint32 identifier;
- private:
- void setGranted();
- void unsetGranted();
- bool granted;
+ ResourceType resourceType;
+ bool optional;
+ quint32 identifier;
+private:
+ void setGranted();
+ void unsetGranted();
+ bool granted;
- };
+};
}
#endif
diff --git a/libresourceqt/include/qt4/policy/resources.h b/libresourceqt/include/qt4/policy/resources.h
index 47002d7..f00cc2e 100644
--- a/libresourceqt/include/qt4/policy/resources.h
+++ b/libresourceqt/include/qt4/policy/resources.h
@@ -5,165 +5,166 @@
#include <QObject>
#include <QString>
-namespace ResourcePolicy {
-
- class AudioResource: public Resource
- {
- public:
- AudioResource(const QString &audioGroup=QString());
- AudioResource(const AudioResource &other);
- virtual ~AudioResource();
-
- QString audioGroup() const;
- void setAudioGroup(const QString & newGroup);
-
- quint32 processID() const;
- void setProcessID(quint32 newPID);
-
- QString streamTag() const;
- void setStreamTag(const QString & newStreamTag);
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- private:
- QString group;
- quint32 pid;
- QString stream;
- };
-
- class AudioRecorderResource: public Resource
- {
- public:
- AudioRecorderResource(const QString & audioGroup=QString());
- AudioRecorderResource(const AudioRecorderResource &other);
- virtual ~AudioRecorderResource();
-
- QString audioGroup() const;
- void setAudioGroup(const QString & newGroup);
-
- quint32 processID() const;
- void setProcessID(quint32 newPID);
-
- QString streamTag() const;
- void setStreamTag(const QString & newStreamTag);
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- private:
- QString group;
- quint32 pid;
- QString stream;
- };
-
- class BacklightResource: public Resource
- {
- public:
- BacklightResource();
- BacklightResource(const BacklightResource &other);
- virtual ~BacklightResource();
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- };
-
- class LedsResource: public Resource
- {
- public:
- LedsResource();
- LedsResource(const LedsResource &other);
- virtual ~LedsResource();
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- };
-
- class VibraResource: public Resource
- {
- public:
- VibraResource();
- VibraResource(const VibraResource &other);
- virtual ~VibraResource();
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- };
-
- class VideoRecorderResource: public Resource
- {
- public:
- VideoRecorderResource();
- VideoRecorderResource(const VideoRecorderResource &other);
- virtual ~VideoRecorderResource();
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- };
-
- class VideoResource: public Resource
- {
- public:
- VideoResource();
- VideoResource(const VideoResource &other);
- virtual ~VideoResource();
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- };
-
- class SystemButtonResource: public Resource
- {
- public:
- SystemButtonResource();
- SystemButtonResource(const SystemButtonResource &other);
- virtual ~SystemButtonResource();
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- };
-
- class LockButtonResource: public Resource
- {
- public:
- LockButtonResource();
- LockButtonResource(const LockButtonResource &other);
- virtual ~LockButtonResource();
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- };
-
- class ScaleButtonResource: public Resource
- {
- public:
- ScaleButtonResource();
- ScaleButtonResource(const ScaleButtonResource &other);
- virtual ~ScaleButtonResource();
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- };
-
- class SnapButtonResource: public Resource
- {
- public:
- SnapButtonResource();
- SnapButtonResource(const SnapButtonResource &other);
- virtual ~SnapButtonResource();
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- };
-
- class LensCoverResource: public Resource
- {
- public:
- LensCoverResource();
- LensCoverResource(const LensCoverResource &other);
- virtual ~LensCoverResource();
-
- virtual ResourceType type() const;
- virtual Resource * clone() const;
- };
+namespace ResourcePolicy
+{
+
+class AudioResource: public Resource
+{
+public:
+ AudioResource(const QString &audioGroup = QString());
+ AudioResource(const AudioResource &other);
+ virtual ~AudioResource();
+
+ QString audioGroup() const;
+ void setAudioGroup(const QString & newGroup);
+
+ quint32 processID() const;
+ void setProcessID(quint32 newPID);
+
+ QString streamTag() const;
+ void setStreamTag(const QString & newStreamTag);
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+private:
+ QString group;
+ quint32 pid;
+ QString stream;
+};
+
+class AudioRecorderResource: public Resource
+{
+public:
+ AudioRecorderResource(const QString & audioGroup = QString());
+ AudioRecorderResource(const AudioRecorderResource &other);
+ virtual ~AudioRecorderResource();
+
+ QString audioGroup() const;
+ void setAudioGroup(const QString & newGroup);
+
+ quint32 processID() const;
+ void setProcessID(quint32 newPID);
+
+ QString streamTag() const;
+ void setStreamTag(const QString & newStreamTag);
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+private:
+ QString group;
+ quint32 pid;
+ QString stream;
+};
+
+class BacklightResource: public Resource
+{
+public:
+ BacklightResource();
+ BacklightResource(const BacklightResource &other);
+ virtual ~BacklightResource();
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+};
+
+class LedsResource: public Resource
+{
+public:
+ LedsResource();
+ LedsResource(const LedsResource &other);
+ virtual ~LedsResource();
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+};
+
+class VibraResource: public Resource
+{
+public:
+ VibraResource();
+ VibraResource(const VibraResource &other);
+ virtual ~VibraResource();
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+};
+
+class VideoRecorderResource: public Resource
+{
+public:
+ VideoRecorderResource();
+ VideoRecorderResource(const VideoRecorderResource &other);
+ virtual ~VideoRecorderResource();
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+};
+
+class VideoResource: public Resource
+{
+public:
+ VideoResource();
+ VideoResource(const VideoResource &other);
+ virtual ~VideoResource();
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+};
+
+class SystemButtonResource: public Resource
+{
+public:
+ SystemButtonResource();
+ SystemButtonResource(const SystemButtonResource &other);
+ virtual ~SystemButtonResource();
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+};
+
+class LockButtonResource: public Resource
+{
+public:
+ LockButtonResource();
+ LockButtonResource(const LockButtonResource &other);
+ virtual ~LockButtonResource();
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+};
+
+class ScaleButtonResource: public Resource
+{
+public:
+ ScaleButtonResource();
+ ScaleButtonResource(const ScaleButtonResource &other);
+ virtual ~ScaleButtonResource();
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+};
+
+class SnapButtonResource: public Resource
+{
+public:
+ SnapButtonResource();
+ SnapButtonResource(const SnapButtonResource &other);
+ virtual ~SnapButtonResource();
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+};
+
+class LensCoverResource: public Resource
+{
+public:
+ LensCoverResource();
+ LensCoverResource(const LensCoverResource &other);
+ virtual ~LensCoverResource();
+
+ virtual ResourceType type() const;
+ virtual Resource * clone() const;
+};
}
#endif
diff --git a/libresourceqt/src/resource-engine.cpp b/libresourceqt/src/resource-engine.cpp
index e2d6113..0bc8fcd 100644
--- a/libresourceqt/src/resource-engine.cpp
+++ b/libresourceqt/src/resource-engine.cpp
@@ -14,9 +14,9 @@ static void handleGrantMessage(resmsg_t *msg, resset_t *rs, void *data);
static void handleAdviceMessage(resmsg_t *msg, resset_t *rs, void *data);
ResourceEngine::ResourceEngine(ResourceSet *resourceSet)
- : QObject(resourceSet), connected(false), resourceSet(resourceSet),
- libresourceConnection(NULL), libresourceSet(NULL), requestId(0),
- messageMap(), mode(0)
+ : QObject(resourceSet), connected(false), resourceSet(resourceSet),
+ libresourceConnection(NULL), libresourceSet(NULL), requestId(0),
+ messageMap(), mode(0)
{
}
@@ -31,15 +31,15 @@ bool ResourceEngine::initialize()
dbus_error_init(&dbusError);
dbusConnection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbusError);
- if(dbus_error_is_set(&dbusError)) {
+ if (dbus_error_is_set(&dbusError)) {
qDebug("Error getting the system bus: %s", dbusError.message);
dbus_error_free(&dbusError);
return false;
}
dbus_error_free(&dbusError);
libresourceConnection = resproto_init(RESPROTO_ROLE_CLIENT, RESPROTO_TRANSPORT_DBUS,
- connectionIsUp, dbusConnection);
- if(libresourceConnection == NULL) {
+ connectionIsUp, dbusConnection);
+ if (libresourceConnection == NULL) {
return NULL;
}
@@ -148,7 +148,7 @@ bool ResourceEngine::disconnect()
int r = resconn_disconnect(libresourceSet, &resourceMessage,
statusCallbackHandler);
connected = false;
- if(r)
+ if (r)
return true;
else
return false;
@@ -157,8 +157,8 @@ bool ResourceEngine::disconnect()
static inline quint32 allResourcesToBitmask(const ResourceSet *resourceSet)
{
QList<Resource *> resourceList = resourceSet->resources();
- quint32 bitmask=0;
- for(int i=0; i < resourceList.size(); i++) {
+ quint32 bitmask = 0;
+ for (int i = 0; i < resourceList.size(); i++) {
bitmask += resourceTypeToLibresourceType(resourceList[i]->type());
}
return bitmask;
@@ -166,46 +166,46 @@ static inline quint32 allResourcesToBitmask(const ResourceSet *resourceSet)
static inline quint32 resourceTypeToLibresourceType(ResourceType type)
{
- quint32 bitmask=0;
- switch(type) {
- case AudioPlaybackType:
- bitmask += RESMSG_AUDIO_PLAYBACK;
- break;
- case VideoPlaybackType:
- bitmask += RESMSG_VIDEO_PLAYBACK;
- break;
- case AudioRecorderType:
- bitmask += RESMSG_AUDIO_RECORDING;
- break;
- case VideoRecorderType:
- bitmask += RESMSG_VIDEO_RECORDING;
- break;
- case VibraType:
- bitmask += RESMSG_VIBRA;
- break;
- case LedsType:
- bitmask += RESMSG_LEDS;
- break;
- case BacklightType:
- bitmask += RESMSG_BACKLIGHT;
- break;
- case SystemButtonType:
- bitmask += RESMSG_SYSTEM_BUTTON;
- break;
- case LockButtonType:
- bitmask += RESMSG_LOCK_BUTTON;
- break;
- case ScaleButtonType:
- bitmask += RESMSG_SCALE_BUTTON;
- break;
- case SnapButtonType:
- bitmask += RESMSG_SNAP_BUTTON;
- break;
- case LensCoverType:
- bitmask += RESMSG_LENS_COVER;
- break;
- default:
- break;
+ quint32 bitmask = 0;
+ switch (type) {
+ case AudioPlaybackType:
+ bitmask += RESMSG_AUDIO_PLAYBACK;
+ break;
+ case VideoPlaybackType:
+ bitmask += RESMSG_VIDEO_PLAYBACK;
+ break;
+ case AudioRecorderType:
+ bitmask += RESMSG_AUDIO_RECORDING;
+ break;
+ case VideoRecorderType:
+ bitmask += RESMSG_VIDEO_RECORDING;
+ break;
+ case VibraType:
+ bitmask += RESMSG_VIBRA;
+ break;
+ case LedsType:
+ bitmask += RESMSG_LEDS;
+ break;
+ case BacklightType:
+ bitmask += RESMSG_BACKLIGHT;
+ break;
+ case SystemButtonType:
+ bitmask += RESMSG_SYSTEM_BUTTON;
+ break;
+ case LockButtonType:
+ bitmask += RESMSG_LOCK_BUTTON;
+ break;
+ case ScaleButtonType:
+ bitmask += RESMSG_SCALE_BUTTON;
+ break;
+ case SnapButtonType:
+ bitmask += RESMSG_SNAP_BUTTON;
+ break;
+ case LensCoverType:
+ bitmask += RESMSG_LENS_COVER;
+ break;
+ default:
+ break;
}
return bitmask;
}
@@ -213,9 +213,9 @@ static inline quint32 resourceTypeToLibresourceType(ResourceType type)
static inline quint32 optionalResourcesToBitmask(const ResourceSet *resourceSet)
{
QList<Resource *> resourceList = resourceSet->resources();
- quint32 bitmask=0;
- for(int i=0; i < resourceList.size(); i++) {
- if(resourceList[i]->isOptional()) {
+ quint32 bitmask = 0;
+ for (int i = 0; i < resourceList.size(); i++) {
+ if (resourceList[i]->isOptional()) {
bitmask += resourceTypeToLibresourceType(resourceList[i]->type());
}
}
@@ -232,12 +232,12 @@ static void statusCallbackHandler(resset_t *libresourceSet, resmsg_t *message)
void ResourceEngine::handleStatusMessage(quint32 requestNo)
{
resmsg_type_t messageType = messageMap.take(requestNo);
- if(messageType == RESMSG_REGISTER) {
+ if (messageType == RESMSG_REGISTER) {
qDebug("connected!");
connected = true;
emit connectedToManager();
}
- else if(messageType == RESMSG_UNREGISTER) {
+ else if (messageType == RESMSG_UNREGISTER) {
qDebug("disconnected!");
connected = false;
emit disconnectedFromManager();
diff --git a/libresourceqt/src/resource-set.cpp b/libresourceqt/src/resource-set.cpp
index f8f3826..93af954 100644
--- a/libresourceqt/src/resource-set.cpp
+++ b/libresourceqt/src/resource-set.cpp
@@ -3,8 +3,8 @@ using namespace ResourcePolicy;
ResourceSet::ResourceSet(const QString &applicationClass, QObject * parent)
- : QObject(parent), resourceClass(applicationClass), autoRelease(false),
- alwaysReply(false)
+ : QObject(parent), resourceClass(applicationClass), autoRelease(false),
+ alwaysReply(false)
{
identifier = (quint32)this;
@@ -13,7 +13,7 @@ ResourceSet::ResourceSet(const QString &applicationClass, QObject * parent)
ResourceSet::~ResourceSet()
{
- for(int i=0;i<NumberOfTypes;i++) {
+ for (int i = 0;i < NumberOfTypes;i++) {
delete resourceSet[i];
}
}
@@ -25,7 +25,7 @@ bool ResourceSet::finalize()
void ResourceSet::addResource(const Resource *resource)
{
- if((resource->type() == AudioPlaybackType) || (resource->type() == AudioRecorderType)) {
+ if ((resource->type() == AudioPlaybackType) || (resource->type() == AudioRecorderType)) {
qDebug("audioResource...");
}
resourceSet[resource->type()] = resource->clone();
@@ -33,14 +33,14 @@ void ResourceSet::addResource(const Resource *resource)
void ResourceSet::addResources(const QList<Resource *>resources)
{
- for(int i=0; i < resources.size(); i++) {
+ for (int i = 0; i < resources.size(); i++) {
addResource(resources.at(i));
}
}
void ResourceSet::delResource(ResourceType type)
{
- if(contains(type)) {
+ if (contains(type)) {
delete resourceSet[type];
resourceSet[type] = NULL;
}
@@ -48,7 +48,7 @@ void ResourceSet::delResource(ResourceType type)
bool ResourceSet::contains(ResourceType type) const
{
- if((type < NumberOfTypes) && (resourceSet[type] != NULL))
+ if ((type < NumberOfTypes) && (resourceSet[type] != NULL))
return true;
else
return false;
@@ -56,12 +56,13 @@ bool ResourceSet::contains(ResourceType type) const
bool ResourceSet::contains(const QList<ResourceType> &types) const
{
- bool containsAll=true;
- int i=0;
+ bool containsAll = true;
+ int i = 0;
do {
containsAll = contains(types.at(i));
i++;
- } while((i < types.size()) && containsAll);
+ }
+ while ((i < types.size()) && containsAll);
return containsAll;
}
@@ -73,8 +74,8 @@ quint32 ResourceSet::id() const
QList<Resource *> ResourceSet::resources() const
{
QList<Resource *> listOfResources;
- for(int i=0; i < NumberOfTypes; i++) {
- if(resourceSet[i] != NULL) {
+ for (int i = 0; i < NumberOfTypes; i++) {
+ if (resourceSet[i] != NULL) {
Resource *clone = resourceSet[i]->clone();
listOfResources.append(clone);
}
@@ -84,7 +85,7 @@ QList<Resource *> ResourceSet::resources() const
Resource * ResourceSet::resource(ResourceType type) const
{
- if(contains(type))
+ if (contains(type))
return resourceSet[type]->clone();
else
return NULL;
diff --git a/libresourceqt/src/resource.cpp b/libresourceqt/src/resource.cpp
index c9bd79e..d288ae6 100644
--- a/libresourceqt/src/resource.cpp
+++ b/libresourceqt/src/resource.cpp
@@ -3,14 +3,14 @@
using namespace ResourcePolicy;
Resource::Resource()
- : optional(false),
+ : optional(false),
identifier(0), granted(false)
{
identifier = (quint32)this;
}
Resource::Resource(const Resource &other)
- : optional(other.optional),
+ : optional(other.optional),
identifier(other.identifier), granted(other.granted)
{
}
diff --git a/libresourceqt/src/resources.cpp b/libresourceqt/src/resources.cpp
index c763ebc..12d9492 100644
--- a/libresourceqt/src/resources.cpp
+++ b/libresourceqt/src/resources.cpp
@@ -3,12 +3,12 @@
using namespace ResourcePolicy;
AudioResource::AudioResource(const QString &audioGroup)
- : Resource(), group(audioGroup), pid(0), stream(QString())
+ : Resource(), group(audioGroup), pid(0), stream(QString())
{
}
AudioResource::AudioResource(const AudioResource &other)
- : Resource(other), group(other.group), pid(other.pid), stream(other.stream)
+ : Resource(other), group(other.group), pid(other.pid), stream(other.stream)
{
}
@@ -57,12 +57,12 @@ ResourceType AudioResource::type() const
}
AudioRecorderResource::AudioRecorderResource(const QString & audioGroup)
- : Resource(), group(audioGroup), pid(0), stream(QString())
+ : Resource(), group(audioGroup), pid(0), stream(QString())
{
}
AudioRecorderResource::AudioRecorderResource(const AudioRecorderResource &other)
- : Resource(other), group(other.group), pid(other.pid), stream(other.stream)
+ : Resource(other), group(other.group), pid(other.pid), stream(other.stream)
{
}
@@ -106,12 +106,12 @@ ResourceType AudioRecorderResource::type() const
}
VideoResource::VideoResource()
- : Resource()
+ : Resource()
{
}
VideoResource::VideoResource(const VideoResource &other)
- : Resource(other)
+ : Resource(other)
{
}
@@ -130,12 +130,12 @@ ResourceType VideoResource::type() const
}
VideoRecorderResource::VideoRecorderResource()
- : Resource()
+ : Resource()
{
}
VideoRecorderResource::VideoRecorderResource(const VideoRecorderResource &other)
- : Resource(other)
+ : Resource(other)
{
}
@@ -154,12 +154,12 @@ ResourceType VideoRecorderResource::type() const
}
VibraResource::VibraResource()
- : Resource()
+ : Resource()
{
}
VibraResource::VibraResource(const VibraResource &other)
- : Resource(other)
+ : Resource(other)
{
}
@@ -178,12 +178,12 @@ ResourceType VibraResource::type() const
}
LedsResource::LedsResource()
- : Resource()
+ : Resource()
{
}
LedsResource::LedsResource(const LedsResource &other)
- : Resource(other)
+ : Resource(other)
{
}
@@ -202,12 +202,12 @@ ResourceType LedsResource::type() const
}
BacklightResource::BacklightResource()
- : Resource()
+ : Resource()
{
}
BacklightResource::BacklightResource(const BacklightResource &other)
- : Resource(other)
+ : Resource(other)
{
}
@@ -226,12 +226,12 @@ ResourceType BacklightResource::type() const
}
SystemButtonResource::SystemButtonResource()
- : Resource()
+ : Resource()
{
}
SystemButtonResource::SystemButtonResource(const SystemButtonResource &other)
- : Resource(other)
+ : Resource(other)
{
}
@@ -250,12 +250,12 @@ ResourceType SystemButtonResource::type() const
}
LockButtonResource::LockButtonResource()
- : Resource()
+ : Resource()
{
}
LockButtonResource::LockButtonResource(const LockButtonResource &other)
- : Resource(other)
+ : Resource(other)
{
}
@@ -274,12 +274,12 @@ ResourceType LockButtonResource::type() const
}
ScaleButtonResource::ScaleButtonResource()
- : Resource()
+ : Resource()
{
}
ScaleButtonResource::ScaleButtonResource(const ScaleButtonResource &other)
- : Resource(other)
+ : Resource(other)
{
}
@@ -298,12 +298,12 @@ ResourceType ScaleButtonResource::type() const
}
SnapButtonResource::SnapButtonResource()
- : Resource()
+ : Resource()
{
}
SnapButtonResource::SnapButtonResource(const SnapButtonResource &other)
- : Resource(other)
+ : Resource(other)
{
}
@@ -322,12 +322,12 @@ ResourceType SnapButtonResource::type() const
}
LensCoverResource::LensCoverResource()
- : Resource()
+ : Resource()
{
}
LensCoverResource::LensCoverResource(const LensCoverResource &other)
- : Resource(other)
+ : Resource(other)
{
}