1 /*
2  *  Copyright (C) 2012-2018 Team Kodi
3  *  This file is part of Kodi - https://kodi.tv
4  *
5  *  SPDX-License-Identifier: GPL-2.0-or-later
6  *  See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <functional>
12 #include <memory>
13 #include <string>
14 #include <vector>
15 
16 struct PVR_MENUHOOK;
17 
18 namespace PVR
19 {
20   class CPVRClientMenuHook
21   {
22   public:
23     CPVRClientMenuHook() = delete;
24     virtual ~CPVRClientMenuHook() = default;
25 
26     CPVRClientMenuHook(const std::string& addonId, const PVR_MENUHOOK& hook);
27 
28     bool operator ==(const CPVRClientMenuHook& right) const;
29 
30     bool IsAllHook() const;
31     bool IsChannelHook() const;
32     bool IsTimerHook() const;
33     bool IsEpgHook() const;
34     bool IsRecordingHook() const;
35     bool IsDeletedRecordingHook() const;
36     bool IsSettingsHook() const;
37 
38     std::string GetAddonId() const;
39     unsigned int GetId() const;
40     unsigned int GetLabelId() const;
41     std::string GetLabel() const;
42 
43   private:
44     std::string m_addonId;
45     std::shared_ptr<PVR_MENUHOOK> m_hook;
46   };
47 
48   class CPVRClientMenuHooks
49   {
50   public:
51     CPVRClientMenuHooks() = default;
52     virtual ~CPVRClientMenuHooks() = default;
53 
CPVRClientMenuHooks(const std::string & addonId)54     explicit CPVRClientMenuHooks(const std::string& addonId) : m_addonId(addonId) {}
55 
56     void AddHook(const PVR_MENUHOOK& addonHook);
57     void Clear();
58 
59     std::vector<CPVRClientMenuHook> GetChannelHooks() const;
60     std::vector<CPVRClientMenuHook> GetTimerHooks() const;
61     std::vector<CPVRClientMenuHook> GetEpgHooks() const;
62     std::vector<CPVRClientMenuHook> GetRecordingHooks() const;
63     std::vector<CPVRClientMenuHook> GetDeletedRecordingHooks() const;
64     std::vector<CPVRClientMenuHook> GetSettingsHooks() const;
65 
66   private:
67     std::vector<CPVRClientMenuHook> GetHooks(
68         const std::function<bool(const CPVRClientMenuHook& hook)>& function) const;
69 
70     std::string m_addonId;
71     std::unique_ptr<std::vector<CPVRClientMenuHook>> m_hooks;
72   };
73 }
74