MythTV  master
channel.h
Go to the documentation of this file.
1 // Program Name: channel.h
3 // Created : Apr. 8, 2011
4 //
5 // Copyright (c) 2011 Robert McNamara <rmcnamara@mythtv.org>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //
25 
26 #ifndef CHANNEL_H
27 #define CHANNEL_H
28 
29 #include "libmythbase/mythconfig.h"
30 #if CONFIG_QTSCRIPT
31 #include <QScriptEngine>
32 #endif
33 
35 
36 class Channel : public ChannelServices
37 {
38  Q_OBJECT
39 
40  public:
41 
42  Q_INVOKABLE explicit Channel( QObject */*parent*/ = nullptr ) {}
43 
44  public:
45 
46  /* Channel Methods */
47 
49  uint ChannelGroupID,
50  uint StartIndex,
51  uint Count,
52  bool OnlyVisible,
53  bool Details,
54  bool OrderByName,
55  bool GroupByCallsign,
56  bool OnlyTunable ) override; // ChannelServices
57 
58  DTC::ChannelInfo* GetChannelInfo ( uint ChanID ) override; // ChannelServices
59 
60  bool UpdateDBChannel ( uint MplexID,
61  uint SourceID,
63  const QString &CallSign,
64  const QString &ChannelName,
65  const QString &ChannelNumber,
67  uint ATSCMajorChannel,
68  uint ATSCMinorChannel,
69  bool UseEIT,
70  bool Visible,
71  const QString &ExtendedVisible,
72  const QString &FrequencyID,
73  const QString &Icon,
74  const QString &Format,
75  const QString &XMLTVID,
76  const QString &DefaultAuthority,
77  uint ServiceType ) override; // ChannelServices
78 
79  bool AddDBChannel ( uint MplexID,
80  uint SourceID,
82  const QString &CallSign,
83  const QString &ChannelName,
84  const QString &ChannelNumber,
86  uint ATSCMajorChannel,
87  uint ATSCMinorChannel,
88  bool UseEIT,
89  bool Visible,
90  const QString &ExtendedVisible,
91  const QString &FrequencyID,
92  const QString &Icon,
93  const QString &Format,
94  const QString &XMLTVID,
95  const QString &DefaultAuthority,
96  uint ServiceType ) override; // ChannelServices
97 
98  bool RemoveDBChannel ( uint ChannelID ) override; // ChannelServices
99 
100  /* Video Source Methods */
101 
102  DTC::VideoSourceList* GetVideoSourceList ( void ) override; // ChannelServices
103 
104  DTC::VideoSource* GetVideoSource ( uint SourceID ) override; // ChannelServices
105 
107  const QString &SourceName,
108  const QString &Grabber,
109  const QString &UserId,
110  const QString &FreqTable,
111  const QString &LineupId,
112  const QString &Password,
113  bool UseEIT,
114  const QString &ConfigPath,
115  int NITId,
116  uint BouquetId,
117  uint RegionId,
119  uint LCNOffset ) override; // ChannelServices
120 
121  int AddVideoSource ( const QString &SourceName,
122  const QString &Grabber,
123  const QString &UserId,
124  const QString &FreqTable,
125  const QString &LineupId,
126  const QString &Password,
127  bool UseEIT,
128  const QString &ConfigPath,
129  int NITId,
130  uint BouquetId,
131  uint RegionId,
133  uint LCNOffset ) override; // ChannelServices
134 
135  bool RemoveVideoSource ( uint SourceID ) override; // ChannelServices
136 
137  DTC::LineupList* GetDDLineupList ( const QString &/*Source*/,
138  const QString &/*UserId*/,
139  const QString &/*Password*/ ) override; // ChannelServices
140 
141  int FetchChannelsFromSource( uint SourceId,
142  uint CardId,
143  bool WaitForFinish ) override; // ChannelServices
144 
145  /* Multiplex Methods */
146 
148  uint StartIndex,
149  uint Count ) override; // ChannelServices
150 
151  DTC::VideoMultiplex* GetVideoMultiplex ( uint MplexID ) override; // ChannelServices
152 
153  QStringList GetXMLTVIdList ( uint SourceID ) override; // ChannelServices
154 
155 };
156 
157 // --------------------------------------------------------------------------
158 // The following class wrapper is due to a limitation in Qt Script Engine. It
159 // requires all methods that return pointers to user classes that are derived from
160 // QObject actually return QObject* (not the user class *). If the user class pointer
161 // is returned, the script engine treats it as a QVariant and doesn't create a
162 // javascript prototype wrapper for it.
163 //
164 // This class allows us to keep the rich return types in the main API class while
165 // offering the script engine a class it can work with.
166 //
167 // Only API Classes that return custom classes needs to implement these wrappers.
168 //
169 // We should continue to look for a cleaning solution to this problem.
170 // --------------------------------------------------------------------------
171 
172 #if CONFIG_QTSCRIPT
173 class ScriptableChannel : public QObject
174 {
175  Q_OBJECT
176 
177  private:
178 
179  Channel m_obj;
180  QScriptEngine *m_pEngine;
181 
182  public:
183 
184  Q_INVOKABLE explicit ScriptableChannel( QScriptEngine *pEngine, QObject *parent = nullptr ) : QObject( parent )
185  {
186  m_pEngine = pEngine;
187  }
188 
189  public slots:
190 
191  QObject* GetChannelInfoList ( int SourceID = 0,
192  int ChannelGroupID = 0,
193  int StartIndex = 0,
194  int Count = 0,
195  bool OnlyVisible = false,
196  bool Details = false,
197  bool OrderByName = false,
198  bool GroupByCallsign = false,
199  bool OnlyTunable = false
200  )
201  {
202  SCRIPT_CATCH_EXCEPTION( nullptr,
203  return m_obj.GetChannelInfoList( SourceID, ChannelGroupID, StartIndex, Count, OnlyVisible, Details, OrderByName, GroupByCallsign, OnlyTunable );
204  )
205  }
206 
207  QObject* GetChannelInfo ( int ChanID )
208  {
209  SCRIPT_CATCH_EXCEPTION( nullptr,
210  return m_obj.GetChannelInfo( ChanID );
211  )
212  }
213 
214  bool UpdateDBChannel ( uint MplexID,
215  uint SourceID,
216  uint ChannelID,
217  const QString &CallSign,
218  const QString &ChannelName,
219  const QString &ChannelNumber,
220  uint ServiceID,
221  uint ATSCMajorChannel,
222  uint ATSCMinorChannel,
223  bool UseEIT,
224  bool Visible,
225  const QString &ExtendedVisible,
226  const QString &FrequencyID,
227  const QString &Icon,
228  const QString &Format,
229  const QString &XMLTVID,
230  const QString &DefaultAuthority,
231  uint ServiceType )
232  {
233  SCRIPT_CATCH_EXCEPTION( false,
234  return m_obj.UpdateDBChannel(MplexID, SourceID, ChannelID,
235  CallSign, ChannelName, ChannelNumber,
236  ServiceID, ATSCMajorChannel, ATSCMinorChannel,
237  UseEIT, Visible, ExtendedVisible, FrequencyID, Icon, Format,
238  XMLTVID, DefaultAuthority, ServiceType);
239  )
240  }
241 
242  bool AddDBChannel ( uint MplexID,
243  uint SourceID,
244  uint ChannelID,
245  const QString &CallSign,
246  const QString &ChannelName,
247  const QString &ChannelNumber,
248  uint ServiceID,
249  uint ATSCMajorChannel,
250  uint ATSCMinorChannel,
251  bool UseEIT,
252  bool Visible,
253  const QString &ExtendedVisible,
254  const QString &FrequencyID,
255  const QString &Icon,
256  const QString &Format,
257  const QString &XMLTVID,
258  const QString &DefaultAuthority,
259  uint ServiceType )
260  {
261  SCRIPT_CATCH_EXCEPTION( false,
262  return m_obj.AddDBChannel(MplexID, SourceID, ChannelID,
263  CallSign, ChannelName, ChannelNumber,
264  ServiceID, ATSCMajorChannel, ATSCMinorChannel,
265  UseEIT, Visible, ExtendedVisible, FrequencyID, Icon, Format,
266  XMLTVID, DefaultAuthority, ServiceType);
267  )
268  }
269 
270  bool RemoveDBChannel ( uint ChannelID )
271  {
272  SCRIPT_CATCH_EXCEPTION( false,
273  return m_obj.RemoveDBChannel(ChannelID);
274  )
275  }
276 
277  QObject* GetVideoSourceList ( void )
278  {
279  SCRIPT_CATCH_EXCEPTION( nullptr,
280  return m_obj.GetVideoSourceList();
281  )
282  }
283 
284  QObject* GetVideoSource ( uint SourceID )
285  {
286  SCRIPT_CATCH_EXCEPTION( nullptr,
287  return m_obj.GetVideoSource( SourceID );
288  )
289  }
290 
291  bool UpdateVideoSource ( uint SourceID,
292  const QString &SourceName,
293  const QString &Grabber,
294  const QString &UserId,
295  const QString &FreqTable,
296  const QString &LineupId,
297  const QString &Password,
298  bool UseEIT,
299  const QString &ConfigPath,
300  int NITId,
301  uint BouquetId,
302  uint RegionId,
304  uint LCNOffset )
305  {
306  SCRIPT_CATCH_EXCEPTION( false,
307  return m_obj.UpdateVideoSource( SourceID, SourceName, Grabber,
308  UserId, FreqTable, LineupId, Password,
309  UseEIT, ConfigPath, NITId, BouquetId, RegionId,
311  )
312  }
313 
314  bool AddVideoSource ( const QString &SourceName,
315  const QString &Grabber,
316  const QString &UserId,
317  const QString &FreqTable,
318  const QString &LineupId,
319  const QString &Password,
320  bool UseEIT,
321  const QString &ConfigPath,
322  int NITId,
323  uint BouquetId,
324  uint RegionId,
326  uint LCNOffset )
327  {
328  SCRIPT_CATCH_EXCEPTION( false,
329  return m_obj.AddVideoSource( SourceName, Grabber, UserId,
330  FreqTable, LineupId, Password,
331  UseEIT, ConfigPath, NITId, BouquetId, RegionId,
333  )
334  }
335 
336  bool RemoveVideoSource ( uint SourceID )
337  {
338  SCRIPT_CATCH_EXCEPTION( false,
339  return m_obj.RemoveVideoSource( SourceID );
340  )
341  }
342 
343  QObject* GetVideoMultiplexList ( int SourceID,
344  int StartIndex,
345  int Count )
346  {
347  SCRIPT_CATCH_EXCEPTION( nullptr,
348  return m_obj.GetVideoMultiplexList( SourceID, StartIndex, Count );
349  )
350  }
351 
352  QObject* GetVideoMultiplex ( int MplexID )
353  {
354  SCRIPT_CATCH_EXCEPTION( nullptr,
355  return m_obj.GetVideoMultiplex( MplexID );
356  )
357  }
358 
359  QStringList GetXMLTVIdList ( int SourceID )
360  {
361  SCRIPT_CATCH_EXCEPTION( QStringList(),
362  return m_obj.GetXMLTVIdList(SourceID);
363  )
364  }
365 };
366 
367 
368 // NOLINTNEXTLINE(modernize-use-auto)
369 Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV( ScriptableChannel, QObject*);
370 #endif
371 
372 #endif
Password
static StandardSetting * Password(bool enabled)
Setting for changing password.
Definition: galleryconfig.cpp:245
Channel::FetchChannelsFromSource
int FetchChannelsFromSource(uint SourceId, uint CardId, bool WaitForFinish) override
Definition: channel.cpp:572
DTC::VideoSourceList
Definition: videoSourceList.h:15
Channel
Definition: channel.h:36
Channel::RemoveDBChannel
bool RemoveDBChannel(uint ChannelID) override
Definition: channel.cpp:284
UseEIT
Definition: videosource.cpp:599
Channel::GetVideoMultiplexList
DTC::VideoMultiplexList * GetVideoMultiplexList(uint SourceID, uint StartIndex, uint Count) override
Definition: channel.cpp:601
ChannelServices
Definition: channelServices.h:41
DTC::VideoMultiplex
Definition: videoMultiplex.h:15
Channel::GetXMLTVIdList
QStringList GetXMLTVIdList(uint SourceID) override
Definition: channel.cpp:761
MythDate::Format
Format
Definition: mythdate.h:15
Channel::GetVideoMultiplex
DTC::VideoMultiplex * GetVideoMultiplex(uint MplexID) override
Definition: channel.cpp:699
SourceID
Definition: videosource.cpp:2873
Channel::GetDDLineupList
DTC::LineupList * GetDDLineupList(const QString &, const QString &, const QString &) override
Definition: channel.cpp:560
DTC::ChannelInfoList
Definition: channelInfoList.h:14
Visible
Definition: channelsettings.cpp:392
Channel::Channel
Q_INVOKABLE Channel(QObject *=nullptr)
Definition: channel.h:42
Channel::GetVideoSourceList
DTC::VideoSourceList * GetVideoSourceList(void) override
Definition: channel.cpp:295
Channel::UpdateDBChannel
bool UpdateDBChannel(uint MplexID, uint SourceID, uint ChannelID, const QString &CallSign, const QString &ChannelName, const QString &ChannelNumber, uint ServiceID, uint ATSCMajorChannel, uint ATSCMinorChannel, bool UseEIT, bool Visible, const QString &ExtendedVisible, const QString &FrequencyID, const QString &Icon, const QString &Format, const QString &XMLTVID, const QString &DefaultAuthority, uint ServiceType) override
Definition: channel.cpp:147
ChannelID
Definition: channelsettings.h:20
Channel::GetChannelInfoList
DTC::ChannelInfoList * GetChannelInfoList(uint SourceID, uint ChannelGroupID, uint StartIndex, uint Count, bool OnlyVisible, bool Details, bool OrderByName, bool GroupByCallsign, bool OnlyTunable) override
Definition: channel.cpp:52
ServiceID
Definition: channelsettings.cpp:313
LCNOffset
Definition: videosource.cpp:489
DTC::VideoSource
Definition: videoSource.h:14
DTC::LineupList
Definition: lineup.h:66
FreqTable
static GlobalComboBoxSetting * FreqTable()
Definition: backendsettings.cpp:251
ScanFrequency
Definition: channelscanmiscsettings.h:279
Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV
#define Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV(T, _Arg1)
Definition: service.h:113
Channel::GetVideoSource
DTC::VideoSource * GetVideoSource(uint SourceID) override
Definition: channel.cpp:354
uint
unsigned int uint
Definition: compat.h:79
SCRIPT_CATCH_EXCEPTION
#define SCRIPT_CATCH_EXCEPTION(default, code)
Definition: service.h:85
channelServices.h
Channel::UpdateVideoSource
bool UpdateVideoSource(uint SourceID, const QString &SourceName, const QString &Grabber, const QString &UserId, const QString &FreqTable, const QString &LineupId, const QString &Password, bool UseEIT, const QString &ConfigPath, int NITId, uint BouquetId, uint RegionId, uint ScanFrequency, uint LCNOffset) override
Definition: channel.cpp:408
Channel::RemoveVideoSource
bool RemoveVideoSource(uint SourceID) override
Definition: channel.cpp:549
Icon
Definition: channelsettings.cpp:209
DTC::VideoMultiplexList
Definition: videoMultiplexList.h:15
DTC::ChannelInfo
Definition: programAndChannel.h:30
Channel::AddVideoSource
int AddVideoSource(const QString &SourceName, const QString &Grabber, const QString &UserId, const QString &FreqTable, const QString &LineupId, const QString &Password, bool UseEIT, const QString &ConfigPath, int NITId, uint BouquetId, uint RegionId, uint ScanFrequency, uint LCNOffset) override
Definition: channel.cpp:523
Channel::AddDBChannel
bool AddDBChannel(uint MplexID, uint SourceID, uint ChannelID, const QString &CallSign, const QString &ChannelName, const QString &ChannelNumber, uint ServiceID, uint ATSCMajorChannel, uint ATSCMinorChannel, bool UseEIT, bool Visible, const QString &ExtendedVisible, const QString &FrequencyID, const QString &Icon, const QString &Format, const QString &XMLTVID, const QString &DefaultAuthority, uint ServiceType) override
Definition: channel.cpp:242
Channel::GetChannelInfo
DTC::ChannelInfo * GetChannelInfo(uint ChanID) override
Definition: channel.cpp:130