2 * Copyright (C) 2016-2022 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.
11 #include "pvr/IPVRComponent.h"
12 #include "pvr/settings/PVRSettings.h"
21 class CPVRTimerInfoTag
;
23 class CPVRGUIActionsTimers
: public IPVRComponent
26 CPVRGUIActionsTimers();
27 ~CPVRGUIActionsTimers() override
= default;
30 * @brief Open the timer settings dialog to create a new tv or radio timer.
31 * @param bRadio indicates whether a radio or tv timer shall be created.
32 * @return true on success, false otherwise.
34 bool AddTimer(bool bRadio
) const;
37 * @brief Create a new timer, either interactive or non-interactive.
38 * @param item containing epg data to create a timer for. item must be an epg tag or a channel.
39 * @param bShowTimerSettings is used to control whether a settings dialog will be opened prior
41 * @return true, if the timer was created successfully, false otherwise.
43 bool AddTimer(const CFileItem
& item
, bool bShowTimerSettings
) const;
46 * @brief Add a timer to the client. Doesn't add the timer to the container. The backend will
48 * @return True if it was sent correctly, false if not.
50 bool AddTimer(const std::shared_ptr
<CPVRTimerInfoTag
>& item
) const;
53 * @brief Create a new timer rule, either interactive or non-interactive.
54 * @param item containing epg data to create a timer rule for. item must be an epg tag or a
56 * @param bShowTimerSettings is used to control whether a settings dialog will be opened prior
57 * creating the timer rule.
58 * @param bFallbackToOneShotTimer if no timer rule can be created, try to create a one-shot
60 * @return true, if the timer rule was created successfully, false otherwise.
62 bool AddTimerRule(const CFileItem
& item
,
63 bool bShowTimerSettings
,
64 bool bFallbackToOneShotTimer
) const;
67 * @brief Creates or deletes a timer for the given epg tag.
68 * @param item containing an epg tag.
69 * @return true on success, false otherwise.
71 bool ToggleTimer(const CFileItem
& item
) const;
74 * @brief Toggles a given timer's enabled/disabled state.
75 * @param item containing a timer.
76 * @return true on success, false otherwise.
78 bool ToggleTimerState(const CFileItem
& item
) const;
81 * @brief Open the timer settings dialog to edit an existing timer.
82 * @param item containing an epg tag or a timer.
83 * @return true on success, false otherwise.
85 bool EditTimer(const CFileItem
& item
) const;
88 * @brief Open the timer settings dialog to edit an existing timer rule.
89 * @param item containing an epg tag or a timer.
90 * @return true on success, false otherwise.
92 bool EditTimerRule(const CFileItem
& item
) const;
95 * @brief Get the timer rule for a given timer
96 * @param item containing an item to query the timer rule for. item must be a timer or an epg tag.
97 * @return The timer rule item, or nullptr if none was found.
99 std::shared_ptr
<CFileItem
> GetTimerRule(const CFileItem
& item
) const;
102 * @brief Delete a timer, always showing a confirmation dialog.
103 * @param item containing a timer to delete. item must be a timer, an epg tag or a channel.
104 * @return true, if the timer was deleted successfully, false otherwise.
106 bool DeleteTimer(const CFileItem
& item
) const;
109 * @brief Delete a timer rule, always showing a confirmation dialog.
110 * @param item containing a timer rule to delete. item must be a timer, an epg tag or a channel.
111 * @return true, if the timer rule was deleted successfully, false otherwise.
113 bool DeleteTimerRule(const CFileItem
& item
) const;
116 * @brief Toggle recording on the currently playing channel, if any.
117 * @return True if the recording was started or stopped successfully, false otherwise.
119 bool ToggleRecordingOnPlayingChannel();
122 * @brief Start or stop recording on a given channel.
123 * @param channel the channel to start/stop recording.
124 * @param bOnOff True to start recording, false to stop.
125 * @return True if the recording was started or stopped successfully, false otherwise.
127 bool SetRecordingOnChannel(const std::shared_ptr
<CPVRChannel
>& channel
, bool bOnOff
);
130 * @brief Stop a currently active recording, always showing a confirmation dialog.
131 * @param item containing a recording to stop. item must be a timer, an epg tag or a channel.
132 * @return true, if the recording was stopped successfully, false otherwise.
134 bool StopRecording(const CFileItem
& item
) const;
137 * @brief Create a new reminder timer, non-interactive.
138 * @param item containing epg data to create a reminder timer for. item must be an epg tag.
139 * @return true, if the timer was created successfully, false otherwise.
141 bool AddReminder(const CFileItem
& item
) const;
144 * @brief Announce due reminders, if any.
146 void AnnounceReminders() const;
149 CPVRGUIActionsTimers(const CPVRGUIActionsTimers
&) = delete;
150 CPVRGUIActionsTimers
const& operator=(CPVRGUIActionsTimers
const&) = delete;
153 * @brief Open the timer settings dialog.
154 * @param timer containing the timer the settings shall be displayed for.
155 * @return true, if the dialog was ended successfully, false otherwise.
157 bool ShowTimerSettings(const std::shared_ptr
<CPVRTimerInfoTag
>& timer
) const;
160 * @brief Add a timer or timer rule, either interactive or non-interactive.
161 * @param item containing epg data to create a timer or timer rule for. item must be an epg tag
163 * @param bCreateteRule denotes whether to create a one-shot timer or a timer rule.
164 * @param bShowTimerSettings is used to control whether a settings dialog will be opened prior
165 * creating the timer or timer rule.
166 * @param bFallbackToOneShotTimer if bCreateteRule is true and no timer rule can be created, try
167 * to create a one-shot timer instead.
168 * @return true, if the timer or timer rule was created successfully, false otherwise.
170 bool AddTimer(const CFileItem
& item
,
172 bool bShowTimerSettings
,
173 bool bFallbackToOneShotTimer
) const;
176 * @brief Delete a timer or timer rule, always showing a confirmation dialog.
177 * @param item containing a timer or timer rule to delete. item must be a timer, an epg tag or
179 * @param bIsRecording denotes whether the timer is currently recording (controls correct
180 * confirmation dialog).
181 * @param bDeleteRule denotes to delete a timer rule. For convenience, one can pass a timer
183 * @return true, if the timer or timer rule was deleted successfully, false otherwise.
185 bool DeleteTimer(const CFileItem
& item
, bool bIsRecording
, bool bDeleteRule
) const;
188 * @brief Delete a timer or timer rule, showing a confirmation dialog in case a timer currently
189 * recording shall be deleted.
190 * @param timer containing a timer or timer rule to delete.
191 * @param bIsRecording denotes whether the timer is currently recording (controls correct
192 * confirmation dialog).
193 * @param bDeleteRule denotes to delete a timer rule. For convenience, one can pass a timer
195 * @return true, if the timer or timer rule was deleted successfully, false otherwise.
197 bool DeleteTimer(const std::shared_ptr
<CPVRTimerInfoTag
>& timer
,
199 bool bDeleteRule
) const;
202 * @brief Open a dialog to confirm timer delete.
203 * @param timer the timer to delete.
204 * @param bDeleteRule in: ignored. out, for one shot timer scheduled by a timer rule: true to
205 * also delete the timer rule that has scheduled this timer, false to only delete the one shot
206 * timer. out, for one shot timer not scheduled by a timer rule: ignored
207 * @return true, to proceed with delete, false otherwise.
209 bool ConfirmDeleteTimer(const std::shared_ptr
<const CPVRTimerInfoTag
>& timer
,
210 bool& bDeleteRule
) const;
213 * @brief Open a dialog to confirm stop recording.
214 * @param timer the recording to stop (actually the timer to delete).
215 * @return true, to proceed with delete, false otherwise.
217 bool ConfirmStopRecording(const std::shared_ptr
<const CPVRTimerInfoTag
>& timer
) const;
220 * @brief Announce and process a reminder timer.
221 * @param timer The reminder timer.
223 void AnnounceReminder(const std::shared_ptr
<CPVRTimerInfoTag
>& timer
) const;
225 CPVRSettings m_settings
;
226 mutable bool m_bReminderAnnouncementRunning
{false};
231 // pretty scope and name
232 using Timers
= CPVRGUIActionsTimers
;