[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / application / ApplicationActionListeners.cpp
blob83c798ec61b7b5961565dca919ec1a7296e50532
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "ApplicationActionListeners.h"
11 #include "interfaces/IActionListener.h"
12 #include "threads/CriticalSection.h"
14 #include <algorithm>
15 #include <mutex>
17 CApplicationActionListeners::CApplicationActionListeners(CCriticalSection& section)
18 : m_critSection(section)
22 void CApplicationActionListeners::RegisterActionListener(IActionListener* listener)
24 std::unique_lock<CCriticalSection> lock(m_critSection);
25 const auto it = std::find(m_actionListeners.begin(), m_actionListeners.end(), listener);
26 if (it == m_actionListeners.end())
27 m_actionListeners.push_back(listener);
30 void CApplicationActionListeners::UnregisterActionListener(IActionListener* listener)
32 std::unique_lock<CCriticalSection> lock(m_critSection);
33 auto it = std::find(m_actionListeners.begin(), m_actionListeners.end(), listener);
34 if (it != m_actionListeners.end())
35 m_actionListeners.erase(it);
38 bool CApplicationActionListeners::NotifyActionListeners(const CAction& action) const
40 std::unique_lock<CCriticalSection> lock(m_critSection);
41 for (const auto& listener : m_actionListeners)
43 if (listener->OnAction(action))
44 return true;
47 return false;