diff options
author | Arne Morten Kvarving <spiff@kodi.tv> | 2022-09-20 22:02:53 +0200 |
---|---|---|
committer | Arne Morten Kvarving <spiff@kodi.tv> | 2022-09-27 21:01:55 +0200 |
commit | eefb3c9697a6c890eb482b83a3c71d8b3742da8c (patch) | |
tree | 45035c9edc740c7bf2a62f22d0e8b0f255afa09c | |
parent | 4fbf1568607020d9e28b56bea1f6fd44dcf317a0 (diff) |
ApplicationActionListeners: move to ApplicationComponents
-rw-r--r-- | xbmc/application/Application.cpp | 21 | ||||
-rw-r--r-- | xbmc/application/Application.h | 2 | ||||
-rw-r--r-- | xbmc/application/ApplicationActionListeners.h | 7 | ||||
-rw-r--r-- | xbmc/network/AirTunesServer.cpp | 9 | ||||
-rw-r--r-- | xbmc/pvr/guilib/PVRGUIActionListener.cpp | 10 |
5 files changed, 35 insertions, 14 deletions
diff --git a/xbmc/application/Application.cpp b/xbmc/application/Application.cpp index efd04d613f..b1f01d01b2 100644 --- a/xbmc/application/Application.cpp +++ b/xbmc/application/Application.cpp @@ -19,6 +19,8 @@ #include "addons/VFSEntry.h" #include "application/AppInboundProtocol.h" #include "application/AppParams.h" +#include "application/ApplicationActionListeners.h" +#include "application/ApplicationComponents.h" #include "cores/AudioEngine/Engines/ActiveAE/ActiveAE.h" #include "cores/IPlayer.h" #include "cores/playercorefactory/PlayerCoreFactory.h" @@ -222,8 +224,7 @@ using namespace std::chrono_literals; #define MAX_FFWD_SPEED 5 CApplication::CApplication(void) - : CApplicationActionListeners(m_critSection), - CApplicationPlayerCallback(m_appPlayer, m_stackHelper), + : CApplicationPlayerCallback(m_appPlayer, m_stackHelper), CApplicationPowerHandling(m_appPlayer), CApplicationSettingsHandling(m_appPlayer, *this, *this, *this), CApplicationSkinHandling(m_appPlayer), @@ -241,10 +242,14 @@ CApplication::CApplication(void) #ifdef HAVE_X11 XInitThreads(); #endif + + // register application components + RegisterComponent(std::make_shared<CApplicationActionListeners>(m_critSection)); } CApplication::~CApplication(void) { + DeregisterComponent(typeid(CApplicationActionListeners)); } bool CApplication::OnEvent(XBMC_Event& newEvent) @@ -805,8 +810,9 @@ bool CApplication::Initialize() m_slowTimer.StartZero(); // register action listeners - RegisterActionListener(&m_appPlayer.GetSeekHandler()); - RegisterActionListener(&CPlayerController::GetInstance()); + const auto appListener = GetComponent<CApplicationActionListeners>(); + appListener->RegisterActionListener(&m_appPlayer.GetSeekHandler()); + appListener->RegisterActionListener(&CPlayerController::GetInstance()); CServiceBroker::GetRepositoryUpdater().Start(); if (!profileManager->UsingLoginScreen()) @@ -974,7 +980,7 @@ bool CApplication::OnAction(const CAction &action) // handle extra global presses // notify action listeners - if (NotifyActionListeners(action)) + if (GetComponent<CApplicationActionListeners>()->NotifyActionListeners(action)) return true; // screenshot : take a screenshot :) @@ -2111,8 +2117,9 @@ bool CApplication::Stop(int exitCode) CScriptInvocationManager::GetInstance().StopRunningScripts(); // unregister action listeners - UnregisterActionListener(&m_appPlayer.GetSeekHandler()); - UnregisterActionListener(&CPlayerController::GetInstance()); + const auto appListener = GetComponent<CApplicationActionListeners>(); + appListener->UnregisterActionListener(&m_appPlayer.GetSeekHandler()); + appListener->UnregisterActionListener(&CPlayerController::GetInstance()); CGUIComponent *gui = CServiceBroker::GetGUI(); if (gui) diff --git a/xbmc/application/Application.h b/xbmc/application/Application.h index 131716180c..710ea9923b 100644 --- a/xbmc/application/Application.h +++ b/xbmc/application/Application.h @@ -9,7 +9,6 @@ #pragma once #include "ServiceManager.h" -#include "application/ApplicationActionListeners.h" #include "application/ApplicationComponents.h" #include "application/ApplicationEnums.h" #include "application/ApplicationPlayer.h" @@ -90,7 +89,6 @@ class CApplication : public IWindowManagerCallback, public IMsgTargetCallback, public KODI::MESSAGING::IMessageTarget, public CApplicationComponents, - public CApplicationActionListeners, public CApplicationPlayerCallback, public CApplicationPowerHandling, public CApplicationSettingsHandling, diff --git a/xbmc/application/ApplicationActionListeners.h b/xbmc/application/ApplicationActionListeners.h index 4611ad4cec..8f72dd4fd0 100644 --- a/xbmc/application/ApplicationActionListeners.h +++ b/xbmc/application/ApplicationActionListeners.h @@ -8,9 +8,12 @@ #pragma once +#include "application/IApplicationComponent.h" + #include <vector> class CAction; +class CApplication; class CCriticalSection; class IActionListener; @@ -18,8 +21,10 @@ class IActionListener; * \brief Class handling application support for action listeners. */ -class CApplicationActionListeners +class CApplicationActionListeners : public IApplicationComponent { + friend class CApplication; + public: CApplicationActionListeners(CCriticalSection& sect); diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp index 4e34d96961..d63b38d45e 100644 --- a/xbmc/network/AirTunesServer.cpp +++ b/xbmc/network/AirTunesServer.cpp @@ -17,6 +17,8 @@ #include "ServiceBroker.h" #include "URL.h" #include "application/Application.h" +#include "application/ApplicationActionListeners.h" +#include "application/ApplicationComponents.h" #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxBXA.h" #include "filesystem/File.h" #include "filesystem/PipeFile.h" @@ -670,16 +672,19 @@ CAirTunesServer::~CAirTunesServer() void CAirTunesServer::RegisterActionListener(bool doRegister) { + auto& components = CServiceBroker::GetAppComponents(); + const auto appListener = components.GetComponent<CApplicationActionListeners>(); + if (doRegister) { CServiceBroker::GetAnnouncementManager()->AddAnnouncer(this); - g_application.RegisterActionListener(this); + appListener->RegisterActionListener(this); ServerInstance->Create(); } else { CServiceBroker::GetAnnouncementManager()->RemoveAnnouncer(this); - g_application.UnregisterActionListener(this); + appListener->UnregisterActionListener(this); ServerInstance->StopThread(true); } } diff --git a/xbmc/pvr/guilib/PVRGUIActionListener.cpp b/xbmc/pvr/guilib/PVRGUIActionListener.cpp index fec4e08e0e..38dfbddc63 100644 --- a/xbmc/pvr/guilib/PVRGUIActionListener.cpp +++ b/xbmc/pvr/guilib/PVRGUIActionListener.cpp @@ -10,6 +10,8 @@ #include "ServiceBroker.h" #include "application/Application.h" +#include "application/ApplicationActionListeners.h" +#include "application/ApplicationComponents.h" #include "dialogs/GUIDialogNumeric.h" #include "guilib/GUIComponent.h" #include "guilib/GUIWindowManager.h" @@ -37,7 +39,9 @@ namespace PVR CPVRGUIActionListener::CPVRGUIActionListener() { - g_application.RegisterActionListener(this); + auto& components = CServiceBroker::GetAppComponents(); + const auto appListener = components.GetComponent<CApplicationActionListeners>(); + appListener->RegisterActionListener(this); CServiceBroker::GetSettingsComponent()->GetSettings()->RegisterCallback( this, {CSettings::SETTING_PVRPARENTAL_ENABLED, CSettings::SETTING_PVRMANAGER_RESETDB, @@ -51,7 +55,9 @@ CPVRGUIActionListener::CPVRGUIActionListener() CPVRGUIActionListener::~CPVRGUIActionListener() { CServiceBroker::GetSettingsComponent()->GetSettings()->UnregisterCallback(this); - g_application.UnregisterActionListener(this); + auto& components = CServiceBroker::GetAppComponents(); + const auto appListener = components.GetComponent<CApplicationActionListeners>(); + appListener->UnregisterActionListener(this); } void CPVRGUIActionListener::Init(CPVRManager& mgr) |