summaryrefslogtreecommitdiffstats
path: root/xbmc/pvr/guilib/PVRGUIActionsTimers.h
blob: f6ae8fe005fabf702f12c1c61da09ad71006e574 (plain)
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
 *  Copyright (C) 2016-2022 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/settings/PVRSettings.h"

#include <memory>

class CFileItem;

namespace PVR
{
class CPVRChannel;
class CPVRTimerInfoTag;

class CPVRGUIActionsTimers : public IPVRComponent
{
public:
  CPVRGUIActionsTimers();
  ~CPVRGUIActionsTimers() override = default;

  /*!
   * @brief Open the timer settings dialog to create a new tv or radio timer.
   * @param bRadio indicates whether a radio or tv timer shall be created.
   * @return true on success, false otherwise.
   */
  bool AddTimer(bool bRadio) const;

  /*!
   * @brief Create a new timer, either interactive or non-interactive.
   * @param item containing epg data to create a timer for. item must be an epg tag or a channel.
   * @param bShowTimerSettings is used to control whether a settings dialog will be opened prior
   * creating the timer.
   * @return true, if the timer was created successfully, false otherwise.
   */
  bool AddTimer(const CFileItem& item, bool bShowTimerSettings) const;

  /*!
   * @brief Add a timer to the client. Doesn't add the timer to the container. The backend will
   * do this.
   * @return True if it was sent correctly, false if not.
   */
  bool AddTimer(const std::shared_ptr<CPVRTimerInfoTag>& item) const;

  /*!
   * @brief Create a new timer rule, either interactive or non-interactive.
   * @param item containing epg data to create a timer rule for. item must be an epg tag or a
   * channel.
   * @param bShowTimerSettings is used to control whether a settings dialog will be opened prior
   * creating the timer rule.
   * @param bFallbackToOneShotTimer if no timer rule can be created, try to create a one-shot
   * timer instead.
   * @return true, if the timer rule was created successfully, false otherwise.
   */
  bool AddTimerRule(const CFileItem& item,
                    bool bShowTimerSettings,
                    bool bFallbackToOneShotTimer) const;

  /*!
   * @brief Creates or deletes a timer for the given epg tag.
   * @param item containing an epg tag.
   * @return true on success, false otherwise.
   */
  bool ToggleTimer(const CFileItem& item) const;

  /*!
   * @brief Toggles a given timer's enabled/disabled state.
   * @param item containing a timer.
   * @return true on success, false otherwise.
   */
  bool ToggleTimerState(const CFileItem& item) const;

  /*!
   * @brief Open the timer settings dialog to edit an existing timer.
   * @param item containing an epg tag or a timer.
   * @return true on success, false otherwise.
   */
  bool EditTimer(const CFileItem& item) const;

  /*!
   * @brief Open the timer settings dialog to edit an existing timer rule.
   * @param item containing an epg tag or a timer.
   * @return true on success, false otherwise.
   */
  bool EditTimerRule(const CFileItem& item) const;

  /*!
   * @brief Get the timer rule for a given timer
   * @param item containing an item to query the timer rule for. item must be a timer or an epg tag.
   * @return The timer rule item, or nullptr if none was found.
   */
  std::shared_ptr<CFileItem> GetTimerRule(const CFileItem& item) const;

  /*!
   * @brief Delete a timer, always showing a confirmation dialog.
   * @param item containing a timer to delete. item must be a timer, an epg tag or a channel.
   * @return true, if the timer was deleted successfully, false otherwise.
   */
  bool DeleteTimer(const CFileItem& item) const;

  /*!
   * @brief Delete a timer rule, always showing a confirmation dialog.
   * @param item containing a timer rule to delete. item must be a timer, an epg tag or a channel.
   * @return true, if the timer rule was deleted successfully, false otherwise.
   */
  bool DeleteTimerRule(const CFileItem& item) const;

  /*!
   * @brief Toggle recording on the currently playing channel, if any.
   * @return True if the recording was started or stopped successfully, false otherwise.
   */
  bool ToggleRecordingOnPlayingChannel();

  /*!
   * @brief Start or stop recording on a given channel.
   * @param channel the channel to start/stop recording.
   * @param bOnOff True to start recording, false to stop.
   * @return True if the recording was started or stopped successfully, false otherwise.
   */
  bool SetRecordingOnChannel(const std::shared_ptr<CPVRChannel>& channel, bool bOnOff);

  /*!
   * @brief Stop a currently active recording, always showing a confirmation dialog.
   * @param item containing a recording to stop. item must be a timer, an epg tag or a channel.
   * @return true, if the recording was stopped successfully, false otherwise.
   */
  bool StopRecording(const CFileItem& item) const;

  /*!
   * @brief Create a new reminder timer, non-interactive.
   * @param item containing epg data to create a reminder timer for. item must be an epg tag.
   * @return true, if the timer was created successfully, false otherwise.
   */
  bool AddReminder(const CFileItem& item) const;

  /*!
   * @brief Announce due reminders, if any.
   */
  void AnnounceReminders() const;

private:
  CPVRGUIActionsTimers(const CPVRGUIActionsTimers&) = delete;
  CPVRGUIActionsTimers const& operator=(CPVRGUIActionsTimers const&) = delete;

  /*!
   * @brief Open the timer settings dialog.
   * @param timer containing the timer the settings shall be displayed for.
   * @return true, if the dialog was ended successfully, false otherwise.
   */
  bool ShowTimerSettings(const std::shared_ptr<CPVRTimerInfoTag>& timer) const;

  /*!
   * @brief Add a timer or timer rule, either interactive or non-interactive.
   * @param item containing epg data to create a timer or timer rule for. item must be an epg tag
   * or a channel.
   * @param bCreateteRule denotes whether to create a one-shot timer or a timer rule.
   * @param bShowTimerSettings is used to control whether a settings dialog will be opened prior
   * creating the timer or timer rule.
   * @param bFallbackToOneShotTimer if bCreateteRule is true and no timer rule can be created, try
   * to create a one-shot timer instead.
   * @return true, if the timer or timer rule was created successfully, false otherwise.
   */
  bool AddTimer(const CFileItem& item,
                bool bCreateRule,
                bool bShowTimerSettings,
                bool bFallbackToOneShotTimer) const;

  /*!
   * @brief Delete a timer or timer rule, always showing a confirmation dialog.
   * @param item containing a timer or timer rule to delete. item must be a timer, an epg tag or
   * a channel.
   * @param bIsRecording denotes whether the timer is currently recording (controls correct
   * confirmation dialog).
   * @param bDeleteRule denotes to delete a timer rule. For convenience, one can pass a timer
   * created by a rule.
   * @return true, if the timer or timer rule was deleted successfully, false otherwise.
  */
  bool DeleteTimer(const CFileItem& item, bool bIsRecording, bool bDeleteRule) const;

  /*!
   * @brief Delete a timer or timer rule, showing a confirmation dialog in case a timer currently
   * recording shall be deleted.
   * @param timer containing a timer or timer rule to delete.
   * @param bIsRecording denotes whether the timer is currently recording (controls correct
   * confirmation dialog).
   * @param bDeleteRule denotes to delete a timer rule. For convenience, one can pass a timer
   * created by a rule.
   * @return true, if the timer or timer rule was deleted successfully, false otherwise.
   */
  bool DeleteTimer(const std::shared_ptr<CPVRTimerInfoTag>& timer,
                   bool bIsRecording,
                   bool bDeleteRule) const;

  /*!
   * @brief Open a dialog to confirm timer delete.
   * @param timer the timer to delete.
   * @param bDeleteRule in: ignored. out, for one shot timer scheduled by a timer rule: true to
   * also delete the timer rule that has scheduled this timer, false to only delete the one shot
   * timer. out, for one shot timer not scheduled by a timer rule: ignored
   * @return true, to proceed with delete, false otherwise.
   */
  bool ConfirmDeleteTimer(const std::shared_ptr<CPVRTimerInfoTag>& timer, bool& bDeleteRule) const;

  /*!
   * @brief Open a dialog to confirm stop recording.
   * @param timer the recording to stop (actually the timer to delete).
   * @return true, to proceed with delete, false otherwise.
   */
  bool ConfirmStopRecording(const std::shared_ptr<CPVRTimerInfoTag>& timer) const;

  /*!
   * @brief Announce and process a reminder timer.
   * @param timer The reminder timer.
   */
  void AnnounceReminder(const std::shared_ptr<CPVRTimerInfoTag>& timer) const;

  CPVRSettings m_settings;
  mutable bool m_bReminderAnnouncementRunning{false};
};

namespace GUI
{
// pretty scope and name
using Timers = CPVRGUIActionsTimers;
} // namespace GUI

} // namespace PVR