1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
/*
* Copyright (C) 2016-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "pvr/IPVRComponent.h"
#include "pvr/PVRChannelNumberInputHandler.h"
#include "pvr/guilib/PVRGUIChannelNavigator.h"
#include "pvr/settings/PVRSettings.h"
#include "threads/CriticalSection.h"
#include <memory>
#include <string>
#include <vector>
class CFileItem;
namespace PVR
{
class CPVRChannel;
class CPVRChannelGroupMember;
class CPVRChannelSwitchingInputHandler : public CPVRChannelNumberInputHandler
{
public:
// CPVRChannelNumberInputHandler implementation
void GetChannelNumbers(std::vector<std::string>& channelNumbers) override;
void AppendChannelNumberCharacter(char cCharacter) override;
void OnInputDone() override;
private:
/*!
* @brief Switch to the channel with the given number.
* @param channelNumber the channel number
*/
void SwitchToChannel(const CPVRChannelNumber& channelNumber);
/*!
* @brief Switch to the previously played channel.
*/
void SwitchToPreviousChannel();
};
class CPVRGUIActionsChannels : public IPVRComponent
{
public:
CPVRGUIActionsChannels();
~CPVRGUIActionsChannels() override;
/*!
* @brief Get the events available for CEventStream.
* @return The events.
*/
CEventStream<PVRChannelNumberInputChangedEvent>& Events() { return m_events; }
/*!
* @brief Register a handler for channel number input.
* @param handler The handler to register.
*/
void RegisterChannelNumberInputHandler(CPVRChannelNumberInputHandler* handler);
/*!
* @brief Deregister a handler for channel number input.
* @param handler The handler to deregister.
*/
void DeregisterChannelNumberInputHandler(CPVRChannelNumberInputHandler* handler);
/*!
* @brief CEventStream callback for channel number input changes.
* @param event The event.
*/
void Notify(const PVRChannelNumberInputChangedEvent& event);
/*!
* @brief Hide a channel, always showing a confirmation dialog.
* @param item containing a channel or an epg tag.
* @return true on success, false otherwise.
*/
bool HideChannel(const CFileItem& item) const;
/*!
* @brief Open a selection dialog and start a channel scan on the selected client.
* @return true on success, false otherwise.
*/
bool StartChannelScan();
/*!
* @brief Start a channel scan on the specified client or open a dialog to select a client
* @param clientId the id of client to scan or PVR_INVALID_CLIENT_ID if a dialog will be opened
* @return true on success, false otherwise.
*/
bool StartChannelScan(int clientId);
/*!
* @return True when a channel scan is currently running, false otherwise.
*/
bool IsRunningChannelScan() const { return m_bChannelScanRunning; }
/*!
* @brief Get a channel group member for the given channel, either from the currently active
* group or if not found there, from the 'all channels' group.
* @param channel the channel.
* @return the group member or nullptr if not found.
*/
std::shared_ptr<CPVRChannelGroupMember> GetChannelGroupMember(
const std::shared_ptr<CPVRChannel>& channel) const;
/*!
* @brief Get a channel group member for the given item, either from the currently active group
* or if not found there, from the 'all channels' group.
* @param item the item containing a channel, channel group, recording, timer or epg tag.
* @return the group member or nullptr if not found.
*/
std::shared_ptr<CPVRChannelGroupMember> GetChannelGroupMember(const CFileItem& item) const;
/*!
* @brief Get the currently active channel number input handler.
* @return the handler.
*/
CPVRChannelNumberInputHandler& GetChannelNumberInputHandler();
/*!
* @brief Get the channel navigator.
* @return the navigator.
*/
CPVRGUIChannelNavigator& GetChannelNavigator();
/*!
* @brief Inform GUI actions that playback of an item just started.
* @param item The item that started to play.
*/
void OnPlaybackStarted(const CFileItem& item);
/*!
* @brief Inform GUI actions that playback of an item was stopped due to user interaction.
* @param item The item that stopped to play.
*/
void OnPlaybackStopped(const CFileItem& item);
/*!
* @brief Get the currently selected channel item path; used across several windows/dialogs to
* share item selection.
* @param bRadio True to query the selected path for PVR radio, false for Live TV.
* @return the path.
*/
std::string GetSelectedChannelPath(bool bRadio) const;
/*!
* @brief Set the currently selected channel item path; used across several windows/dialogs to
* share item selection.
* @param bRadio True to set the selected path for PVR radio, false for Live TV.
* @param path The new path to set.
*/
void SetSelectedChannelPath(bool bRadio, const std::string& path);
private:
CPVRGUIActionsChannels(const CPVRGUIActionsChannels&) = delete;
CPVRGUIActionsChannels const& operator=(CPVRGUIActionsChannels const&) = delete;
CPVRChannelSwitchingInputHandler m_channelNumberInputHandler;
bool m_bChannelScanRunning{false};
CPVRGUIChannelNavigator m_channelNavigator;
CEventSource<PVRChannelNumberInputChangedEvent> m_events;
mutable CCriticalSection m_critSection;
CPVRSettings m_settings;
std::string m_selectedChannelPathTV;
std::string m_selectedChannelPathRadio;
};
namespace GUI
{
// pretty scope and name
using Channels = CPVRGUIActionsChannels;
} // namespace GUI
} // namespace PVR
|