diff options
Diffstat (limited to 'src/plugins/resourcepolicy')
-rw-r--r-- | src/plugins/resourcepolicy/resourcepolicy.json | 4 | ||||
-rw-r--r-- | src/plugins/resourcepolicy/resourcepolicy.pro | 22 | ||||
-rw-r--r-- | src/plugins/resourcepolicy/resourcepolicyimpl.cpp | 100 | ||||
-rw-r--r-- | src/plugins/resourcepolicy/resourcepolicyimpl.h | 67 | ||||
-rw-r--r-- | src/plugins/resourcepolicy/resourcepolicyint.cpp | 405 | ||||
-rw-r--r-- | src/plugins/resourcepolicy/resourcepolicyint.h | 106 | ||||
-rw-r--r-- | src/plugins/resourcepolicy/resourcepolicyplugin.cpp | 62 | ||||
-rw-r--r-- | src/plugins/resourcepolicy/resourcepolicyplugin.h | 59 |
8 files changed, 0 insertions, 825 deletions
diff --git a/src/plugins/resourcepolicy/resourcepolicy.json b/src/plugins/resourcepolicy/resourcepolicy.json deleted file mode 100644 index d751b849c..000000000 --- a/src/plugins/resourcepolicy/resourcepolicy.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Keys": ["resourcepolicy"], - "Services": ["org.qt-project.qt.mediaplayerresourcesetfactory", "default"] -} diff --git a/src/plugins/resourcepolicy/resourcepolicy.pro b/src/plugins/resourcepolicy/resourcepolicy.pro deleted file mode 100644 index 89e75be1b..000000000 --- a/src/plugins/resourcepolicy/resourcepolicy.pro +++ /dev/null @@ -1,22 +0,0 @@ -TARGET = resourceqt - -QT += multimedia-private - -QMAKE_USE += libresourceqt5 - -INCLUDEPATH += $$PWD \ - $${SOURCE_DIR}/src/multimedia - -HEADERS += \ - $$PWD/resourcepolicyplugin.h \ - $$PWD/resourcepolicyimpl.h \ - $$PWD/resourcepolicyint.h - -SOURCES += \ - $$PWD/resourcepolicyplugin.cpp \ - $$PWD/resourcepolicyimpl.cpp \ - $$PWD/resourcepolicyint.cpp - -PLUGIN_TYPE = resourcepolicy -PLUGIN_CLASS_NAME = ResourceQtPolicyPlugin -load(qt_plugin) diff --git a/src/plugins/resourcepolicy/resourcepolicyimpl.cpp b/src/plugins/resourcepolicy/resourcepolicyimpl.cpp deleted file mode 100644 index 0ce02e9b4..000000000 --- a/src/plugins/resourcepolicy/resourcepolicyimpl.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <robin.burchell@jollamobile.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QGlobalStatic> - -#include <policy/resource.h> -#include <policy/resources.h> -#include <policy/resource-set.h> - -#include "resourcepolicyimpl.h" -#include "resourcepolicyint.h" - -Q_GLOBAL_STATIC(ResourcePolicyInt, globalResourcePolicyInt); - -ResourcePolicyImpl::ResourcePolicyImpl(QObject *parent) - : QMediaPlayerResourceSetInterface(parent) -{ - ResourcePolicyInt *set = globalResourcePolicyInt; - set->addClient(this); -} - -ResourcePolicyImpl::~ResourcePolicyImpl() -{ - ResourcePolicyInt *set = globalResourcePolicyInt; - if (!globalResourcePolicyInt.isDestroyed()) - set->removeClient(this); -} - -bool ResourcePolicyImpl::isVideoEnabled() const -{ - ResourcePolicyInt *set = globalResourcePolicyInt; - return set->isVideoEnabled(this); -} - -void ResourcePolicyImpl::setVideoEnabled(bool videoEnabled) -{ - ResourcePolicyInt *set = globalResourcePolicyInt; - set->setVideoEnabled(this, videoEnabled); -} - -void ResourcePolicyImpl::acquire() -{ - ResourcePolicyInt *set = globalResourcePolicyInt; - set->acquire(this); -} - -void ResourcePolicyImpl::release() -{ - ResourcePolicyInt *set = globalResourcePolicyInt; - set->release(this); -} - -bool ResourcePolicyImpl::isGranted() const -{ - ResourcePolicyInt *set = globalResourcePolicyInt; - return set->isGranted(this); -} - -bool ResourcePolicyImpl::isAvailable() const -{ - ResourcePolicyInt *set = globalResourcePolicyInt; - return set->isAvailable(); -} diff --git a/src/plugins/resourcepolicy/resourcepolicyimpl.h b/src/plugins/resourcepolicy/resourcepolicyimpl.h deleted file mode 100644 index 27eb32dc8..000000000 --- a/src/plugins/resourcepolicy/resourcepolicyimpl.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <robin.burchell@jollamobile.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef RESOURCEPOLICYIMPL_H -#define RESOURCEPOLICYIMPL_H - -#include <QObject> - -#include <private/qmediaresourceset_p.h> - -namespace ResourcePolicy { - class ResourceSet; -}; - -class ResourcePolicyImpl : public QMediaPlayerResourceSetInterface -{ - Q_OBJECT -public: - ResourcePolicyImpl(QObject *parent = 0); - ~ResourcePolicyImpl(); - - bool isVideoEnabled() const; - void setVideoEnabled(bool videoEnabled); - void acquire(); - void release(); - bool isGranted() const; - bool isAvailable() const; -}; - -#endif // RESOURCEPOLICYIMPL_H diff --git a/src/plugins/resourcepolicy/resourcepolicyint.cpp b/src/plugins/resourcepolicy/resourcepolicyint.cpp deleted file mode 100644 index fc6a3d874..000000000 --- a/src/plugins/resourcepolicy/resourcepolicyint.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <robin.burchell@jollamobile.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include <policy/resource.h> -#include <policy/resources.h> -#include <policy/resource-set.h> - -#include "resourcepolicyint.h" -#include "resourcepolicyimpl.h" - -#include <QMap> -#include <QByteArray> -#include <QString> - -static int clientid = 0; - -ResourcePolicyInt::ResourcePolicyInt(QObject *parent) - : QObject(parent) - , m_acquired(0) - , m_status(Initial) - , m_video(0) - , m_available(false) - , m_resourceSet(0) -{ - const char *resourceClass = "player"; - - QByteArray envVar = qgetenv("NEMO_RESOURCE_CLASS_OVERRIDE"); - if (!envVar.isEmpty()) { - QString data(envVar); - // Only allow few resource classes - if (data == "navigator" || - data == "call" || - data == "camera" || - data == "game" || - data == "player" || - data == "event") - resourceClass = envVar.constData(); - } - -#ifdef RESOURCE_DEBUG - qDebug() << "##### Using resource class " << resourceClass; -#endif - - m_resourceSet = new ResourcePolicy::ResourceSet(resourceClass, this); - m_resourceSet->setAlwaysReply(); - - connect(m_resourceSet, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), - this, SLOT(handleResourcesGranted())); - connect(m_resourceSet, SIGNAL(resourcesDenied()), - this, SLOT(handleResourcesDenied())); - connect(m_resourceSet, SIGNAL(resourcesReleased()), - this, SLOT(handleResourcesReleased())); - connect(m_resourceSet, SIGNAL(lostResources()), - this, SLOT(handleResourcesLost())); - connect(m_resourceSet, SIGNAL(resourcesReleasedByManager()), - this, SLOT(handleResourcesReleasedByManager())); - - connect(m_resourceSet, SIGNAL(resourcesBecameAvailable(const QList<ResourcePolicy::ResourceType>)), - this, SLOT(handleResourcesBecameAvailable(const QList<ResourcePolicy::ResourceType>))); - - ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource(resourceClass); - - audioResource->setProcessID(QCoreApplication::applicationPid()); - audioResource->setStreamTag("media.name", "*"); - m_resourceSet->addResourceObject(audioResource); - m_resourceSet->update(); -} - -ResourcePolicyInt::~ResourcePolicyInt() -{ - delete m_resourceSet; - m_resourceSet = 0; -#ifdef RESOURCE_DEBUG - qDebug() << "##### Tearing down singleton."; -#endif -} - -void ResourcePolicyInt::addClient(ResourcePolicyImpl *client) -{ - clientEntry entry; - entry.id = clientid++; - entry.client = client; - entry.status = Initial; - entry.videoEnabled = false; - m_clients.insert(entry.client, entry); -#ifdef RESOURCE_DEBUG - qDebug() << "##### Add client " << client << " : " << entry.id; -#endif -} - -void ResourcePolicyInt::removeClient(ResourcePolicyImpl *client) -{ - QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.find(client); - if (i != m_clients.end()) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### Remove client " << client << " : " << i.value().id; -#endif - if (i.value().status == GrantedResource) - --m_acquired; - m_clients.erase(i); - } - - if (m_acquired == 0 && m_status != Initial) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### Remove client, acquired = 0, release"; -#endif - m_resourceSet->release(); - m_status = Initial; - } -} - -bool ResourcePolicyInt::isVideoEnabled(const ResourcePolicyImpl *client) const -{ - QMap<const ResourcePolicyImpl*, clientEntry>::const_iterator i = m_clients.find(client); - if (i != m_clients.constEnd()) - return i.value().videoEnabled; - - return false; -} - -void ResourcePolicyInt::setVideoEnabled(const ResourcePolicyImpl *client, bool videoEnabled) -{ - bool update = false; - - QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.find(client); - if (i != m_clients.end()) { - if (videoEnabled == i.value().videoEnabled) - return; - - if (videoEnabled) { - if (m_video > 0) { - i.value().videoEnabled = true; - } else { - m_resourceSet->addResource(ResourcePolicy::VideoPlaybackType); - update = true; - } - ++m_video; - } else { - --m_video; - i.value().videoEnabled = false; - if (m_video == 0) { - m_resourceSet->deleteResource(ResourcePolicy::VideoPlaybackType); - update = true; - } - } - } - - if (update) - m_resourceSet->update(); -} - -void ResourcePolicyInt::acquire(const ResourcePolicyImpl *client) -{ - QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.find(client); - if (i != m_clients.end()) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": ACQUIRE"; -#endif - if (i.value().status == Initial) { - - if (m_status == RequestedResource) { - i.value().status = RequestedResource; -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": Already requesting, set client as RequestResource and return"; -#endif - return; - } - - if (m_status == GrantedResource) { - ++m_acquired; -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": Already granted, set as GrantedResource and return"; -#endif - i.value().status = GrantedResource; - emit i.value().client->resourcesGranted(); - return; - } - } else if (i.value().status == RequestedResource) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": Already requesting, return"; -#endif - return; - } else { -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": Already granted, return "; -#endif - return; - } - i.value().status = RequestedResource; - m_status = RequestedResource; - -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": ACQUIRE call resourceSet->acquire()"; -#endif - // If m_status was Initial this is the first time resources are requested, - // so let's actually do the acquiring - m_resourceSet->acquire(); - } -} - -void ResourcePolicyInt::release(const ResourcePolicyImpl *client) -{ - QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.find(client); - if (i != m_clients.end()) { - if (i.value().status == GrantedResource) { - i.value().status = Initial; - --m_acquired; -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": RELEASE, acquired (" << m_acquired << ")"; -#endif - emit i.value().client->resourcesReleased(); - } - } - - if (m_acquired == 0 && m_status != Initial) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": RELEASE call resourceSet->release()"; -#endif - m_resourceSet->release(); - m_status = Initial; - } -} - -bool ResourcePolicyInt::isGranted(const ResourcePolicyImpl *client) const -{ - QMap<const ResourcePolicyImpl*, clientEntry>::const_iterator i = m_clients.find(client); - if (i != m_clients.constEnd()) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": IS GRANTED, status: " << i.value().status; -#endif - return i.value().status == GrantedResource; - } - - return false; -} - -bool ResourcePolicyInt::isAvailable() const -{ -#ifdef RESOURCE_DEBUG - qDebug() << "##### isAvailable " << m_available; -#endif - return m_available; -} - -void ResourcePolicyInt::handleResourcesGranted() -{ - m_status = GrantedResource; - QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.begin(); - while (i != m_clients.end()) { - if (i.value().status == RequestedResource) { - ++m_acquired; -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": HANDLE GRANTED, acquired (" << m_acquired << ") emitting resourcesGranted()"; -#endif - i.value().status = GrantedResource; - emit i.value().client->resourcesGranted(); - } - ++i; - } -} - -void ResourcePolicyInt::handleResourcesDenied() -{ - m_status = Initial; - m_acquired = 0; - QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.begin(); - while (i != m_clients.end()) { - if (i.value().status == RequestedResource) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": HANDLE DENIED, acquired (" << m_acquired << ") emitting resourcesDenied()"; -#endif - i.value().status = Initial; - emit i.value().client->resourcesDenied(); - } - // Do we need to act for clients that are in granted state? - ++i; - } -} - -void ResourcePolicyInt::handleResourcesReleased() -{ - m_status = Initial; - m_acquired = 0; - QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.begin(); - while (i != m_clients.end()) { - if (i.value().status != Initial) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": HANDLE RELEASED, acquired (" << m_acquired << ") emitting resourcesReleased()"; -#endif - i.value().status = Initial; - emit i.value().client->resourcesReleased(); - } - ++i; - } -} - -void ResourcePolicyInt::handleResourcesLost() -{ - // If resources were granted switch to acquiring state, - // so that if the resources are freed elsewhere we - // will acquire them again properly. - if (m_status == GrantedResource) - m_status = RequestedResource; - - m_acquired = 0; - - QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.begin(); - while (i != m_clients.end()) { - if (i.value().status == GrantedResource) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": HANDLE LOST, acquired (" << m_acquired << ") emitting resourcesLost()"; -#endif - i.value().status = RequestedResource; - emit i.value().client->resourcesLost(); - } - ++i; - } -} - -void ResourcePolicyInt::handleResourcesReleasedByManager() -{ - if (m_status != Initial) - m_status = Initial; - - m_acquired = 0; - - QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.begin(); - while (i != m_clients.end()) { - if (i.value().status != Initial) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": HANDLE RELEASEDBYMANAGER, acquired (" << m_acquired << ") emitting resourcesLost()"; -#endif - i.value().status = Initial; - emit i.value().client->resourcesLost(); - } - ++i; - } -} - -void ResourcePolicyInt::handleResourcesBecameAvailable(const QList<ResourcePolicy::ResourceType> &resources) -{ - bool available = false; - - for (int i = 0; i < resources.size(); ++i) { - if (resources.at(i) == ResourcePolicy::AudioPlaybackType) - available = true; - } - - availabilityChanged(available); -} - -void ResourcePolicyInt::availabilityChanged(bool available) -{ - if (available == m_available) - return; - - m_available = available; - - QMap<const ResourcePolicyImpl*, clientEntry>::const_iterator i = m_clients.constBegin(); - while (i != m_clients.constEnd()) { -#ifdef RESOURCE_DEBUG - qDebug() << "##### " << i.value().id << ": emitting availabilityChanged(" << m_available << ")"; -#endif - emit i.value().client->availabilityChanged(m_available); - ++i; - } -} diff --git a/src/plugins/resourcepolicy/resourcepolicyint.h b/src/plugins/resourcepolicy/resourcepolicyint.h deleted file mode 100644 index 9ba79c1bc..000000000 --- a/src/plugins/resourcepolicy/resourcepolicyint.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <robin.burchell@jollamobile.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef RESOURCEPOLICYINT_H -#define RESOURCEPOLICYINT_H - -#include <QObject> -#include <QMap> - -#include <policy/resource-set.h> -#include <policy/resource.h> -#include <private/qmediaresourceset_p.h> -#include "resourcepolicyimpl.h" - -namespace ResourcePolicy { - class ResourceSet; -}; - -enum ResourceStatus { - Initial = 0, - RequestedResource, - GrantedResource -}; - -struct clientEntry { - int id; - ResourcePolicyImpl *client; - ResourceStatus status; - bool videoEnabled; -}; - -class ResourcePolicyInt : public QObject -{ - Q_OBJECT -public: - ResourcePolicyInt(QObject *parent = 0); - ~ResourcePolicyInt(); - - bool isVideoEnabled(const ResourcePolicyImpl *client) const; - void setVideoEnabled(const ResourcePolicyImpl *client, bool videoEnabled); - void acquire(const ResourcePolicyImpl *client); - void release(const ResourcePolicyImpl *client); - bool isGranted(const ResourcePolicyImpl *client) const; - bool isAvailable() const; - - void addClient(ResourcePolicyImpl *client); - void removeClient(ResourcePolicyImpl *client); - -private slots: - void handleResourcesGranted(); - void handleResourcesDenied(); - void handleResourcesReleased(); - void handleResourcesLost(); - void handleResourcesReleasedByManager(); - void handleResourcesBecameAvailable(const QList<ResourcePolicy::ResourceType> &resources); - -private: - void availabilityChanged(bool available); - - QMap<const ResourcePolicyImpl*, clientEntry> m_clients; - - int m_acquired; - ResourceStatus m_status; - int m_video; - bool m_available; - ResourcePolicy::ResourceSet *m_resourceSet; -}; - -#endif // RESOURCEPOLICYINT_H diff --git a/src/plugins/resourcepolicy/resourcepolicyplugin.cpp b/src/plugins/resourcepolicy/resourcepolicyplugin.cpp deleted file mode 100644 index bc78d6fbe..000000000 --- a/src/plugins/resourcepolicy/resourcepolicyplugin.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <robin.burchell@jollamobile.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QDebug> - -#include "resourcepolicyplugin.h" -#include "resourcepolicyimpl.h" - -ResourcePolicyPlugin::ResourcePolicyPlugin(QObject *parent) - : QMediaResourcePolicyPlugin(parent) -{ -} - -QObject *ResourcePolicyPlugin::create(const QString &interfaceId) -{ - // TODO: what is interfaceId for? - return new ResourcePolicyImpl(this); -} - -void ResourcePolicyPlugin::destroy(QObject *resourceSet) -{ - // TODO: do we need to do anything more elaborate here? - delete resourceSet; -} - diff --git a/src/plugins/resourcepolicy/resourcepolicyplugin.h b/src/plugins/resourcepolicy/resourcepolicyplugin.h deleted file mode 100644 index 6661c73de..000000000 --- a/src/plugins/resourcepolicy/resourcepolicyplugin.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <robin.burchell@jollamobile.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef RESOURCEPOLICYPLUGIN_H -#define RESOURCEPOLICYPLUGIN_H - -#include <private/qmediaresourcepolicyplugin_p.h> -#include <QObject> - -class ResourcePolicyPlugin : public QMediaResourcePolicyPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaresourcesetfactory/5.0" FILE "resourcepolicy.json") - Q_INTERFACES(QMediaResourceSetFactoryInterface) -public: - ResourcePolicyPlugin(QObject *parent = 0); - - QObject *create(const QString &interfaceId); - void destroy(QObject *resourceSet); -}; - -#endif // RESOURCEPOLICYPLUGIN_H |