PlayerResourcePolicy::PlayerResourcePolicy(QObject *parent) : QObject(parent), m_videoEnabled(true), m_resourceSet(0), m_status(PlayerResourcePolicy::Initial) { #ifdef HAVE_RESOURCE_POLICY m_resourceSet = new ResourcePolicy::ResourceSet("player", this); m_resourceSet->setAlwaysReply(); ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource("player"); audioResource->setProcessID(QCoreApplication::applicationPid()); audioResource->setStreamTag("media.name", "*"); m_resourceSet->addResourceObject(audioResource); m_resourceSet->addResource(ResourcePolicy::VideoPlaybackType); m_resourceSet->update(); connect(m_resourceSet, SIGNAL(resourcesGranted(const QList<ResourcePolicy::ResourceType>)), this, SLOT(handleResourcesGranted())); connect(m_resourceSet, SIGNAL(resourcesDenied()), this, SLOT(handleResourcesDenied())); connect(m_resourceSet, SIGNAL(lostResources()), this, SLOT(handleResourcesLost())); connect(m_resourceSet, SIGNAL(resourcesReleasedByManager()), this, SLOT(handleResourcesLost())); #endif }
ResourceManager::ResourceManager() : QObject(), m_resources(0), m_result(false), m_waiting(false) { qRegisterMetaType<ResourcePolicy::ResourceSet*>("ResourcePolicy::ResourceSet*"); qRegisterMetaType<ResourcePolicy::ResourceType>("ResourcePolicy::ResourceType"); qRegisterMetaType<QList<ResourcePolicy::ResourceType> >("QList<ResourcePolicy::ResourceType>"); m_resources = new ResourcePolicy::ResourceSet(QString::fromAscii("camera"), this); m_resources->setAlwaysReply(); m_resources->addResource(ResourcePolicy::VideoPlaybackType); m_resources->addResource(ResourcePolicy::VideoRecorderType); QObject::connect(m_resources, SIGNAL(resourcesDenied()), this, SLOT(denied())); QObject::connect(m_resources, SIGNAL(lostResources()), this, SLOT(lost())); QObject::connect(m_resources, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), this, SLOT(granted())); }
AlertTonePreview::~AlertTonePreview () { SYS_DEBUG ("Stopping the playback."); if (m_gstVolume) { gst_object_unref (m_gstVolume); m_gstVolume = NULL; } GstBus *bus = gst_element_get_bus (m_gstPipeline); gst_bus_remove_signal_watch (bus); gst_object_unref (bus); gst_element_set_state (m_gstPipeline, GST_STATE_NULL); gst_object_unref (m_gstPipeline); m_gstPipeline = NULL; #ifdef HAVE_LIBRESOURCEQT disconnect (resources, SIGNAL (resourcesGranted (QList<ResourcePolicy::ResourceType>)), this, SLOT (audioResourceAcquired ())); disconnect (resources, SIGNAL (lostResources ()), this, SLOT (audioResourceLost())); resources->release (); #endif }
VolumeControl::VolumeControl(QObject *parent) : QObject(parent), window(0), pulseAudioControl(new PulseAudioControl(this)), hwKeyResource(new ResourcePolicy::ResourceSet("event")), hwKeysAcquired(false), volume_(0), maximumVolume_(0), audioWarning(new MGConfItem("/desktop/nemo/audiowarning", this)), safeVolume_(0), callActive_(false) { hwKeyResource->setAlwaysReply(); hwKeyResource->addResourceObject(new ResourcePolicy::ScaleButtonResource); connect(hwKeyResource, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), this, SLOT(hwKeyResourceAcquired())); connect(hwKeyResource, SIGNAL(lostResources()), this, SLOT(hwKeyResourceLost())); // Set up key repeat: initial delay and per-repeat delay keyRepeatDelayTimer.setSingleShot(true); keyRepeatDelayTimer.setInterval(600); keyRepeatTimer.setInterval(75); connect(&keyRepeatDelayTimer, SIGNAL(timeout()), &keyRepeatTimer, SLOT(start())); connect(&keyRepeatTimer, SIGNAL(timeout()), this, SLOT(changeVolume())); connect(pulseAudioControl, SIGNAL(volumeChanged(int,int)), this, SLOT(setVolume(int,int))); connect(pulseAudioControl, SIGNAL(highVolume(int)), SLOT(handleHighVolume(int))); connect(pulseAudioControl, SIGNAL(longListeningTime(int)), SLOT(handleLongListeningTime(int))); connect(pulseAudioControl, SIGNAL(callActiveChanged(bool)), SLOT(handleCallActive(bool))); pulseAudioControl->update(); qApp->installEventFilter(this); acquireKeys(); }
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(); }
void AlertTonePreview::getResources() { /* * Create these objects only once during the run... */ if (! resources) { resources = new ResourcePolicy::ResourceSet ("player"); resources->setAutoRelease (); resources->setAlwaysReply (); } if (! audioResource) { /* * This is for the libresource to be able to identify our pulseaudio stream, * so this is very important that the same key-value pair should be set * for the pulsesink. The value should be uniqe. */ audioResource = new ResourcePolicy::AudioResource ("player"); audioResource->setProcessID (QApplication::applicationPid ()); audioResource->setStreamTag("media.name", "*"); resources->addResourceObject (audioResource); resources->initAndConnect (); } connect (resources, SIGNAL (resourcesGranted (QList<ResourcePolicy::ResourceType>)), SLOT (audioResourceAcquired ())); connect (resources, SIGNAL (lostResources ()), SLOT (audioResourceLost ())); connect (resources, SIGNAL (resourcesReleasedByManager ()), SLOT (audioResourceLost ())); resources->acquire (); }
VolumeBarLogic::VolumeBarLogic(QObject *parent) : QObject(parent), volumeBarWindow(NULL), currentvolume (0), currentmax (0), hwkeys(new keySniffer()), mHideTimer(new QTimer()) { mHideTimer->setSingleShot(TRUE); openConnection(); #if (HAVE_LIBRESOURCEQT) hwkeyResource = new ResourcePolicy::ResourceSet("event"); hwkeyResource->setAlwaysReply(); ResourcePolicy::ScaleButtonResource *volumeKeys = new ResourcePolicy::ScaleButtonResource; hwkeyResource->addResourceObject(volumeKeys); connect(hwkeyResource, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), this, SLOT(hwKeyResourceAcquired())); connect(hwkeyResource, SIGNAL(lostResources()), this, SLOT(hwKeyResourceLost())); hwkeyResource->acquire(); #endif }
VolumeBarLogic::VolumeBarLogic(QObject *parent) : QObject(parent), volumeBarWindow(NULL), dbus_conn (NULL), currentvolume (0), currentmax (0) #if (HAVE_LIBRESOURCEQT && HAVE_QMSYSTEM) ,hwkeys(new MeeGo::QmKeys(this)) #endif { openConnection (true); #if (HAVE_LIBRESOURCEQT && HAVE_QMSYSTEM) hwkeyResource = new ResourcePolicy::ResourceSet("event"); hwkeyResource->setAlwaysReply(); ResourcePolicy::ScaleButtonResource *volumeKeys = new ResourcePolicy::ScaleButtonResource; hwkeyResource->addResourceObject(volumeKeys); connect(hwkeyResource, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), this, SLOT(hwKeyResourceAcquired())); connect(hwkeyResource, SIGNAL(lostResources()), this, SLOT(hwKeyResourceLost())); hwkeyResource->acquire(); #endif }