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 <QScriptEngine>
30 
32 
33 class Channel : public ChannelServices
34 {
35  Q_OBJECT
36 
37  public:
38 
39  Q_INVOKABLE explicit Channel( QObject */*parent*/ = nullptr ) {}
40 
41  public:
42 
43  /* Channel Methods */
44 
46  uint ChannelGroupID,
47  uint StartIndex,
48  uint Count,
49  bool OnlyVisible,
50  bool Details,
51  bool OrderByName,
52  bool GroupByCallsign,
53  bool OnlyTunable ) override; // ChannelServices
54 
55  DTC::ChannelInfo* GetChannelInfo ( uint ChanID ) override; // ChannelServices
56 
57  bool UpdateDBChannel ( uint MplexID,
58  uint SourceID,
60  const QString &CallSign,
61  const QString &ChannelName,
62  const QString &ChannelNumber,
64  uint ATSCMajorChannel,
65  uint ATSCMinorChannel,
66  bool UseEIT,
67  bool Visible,
68  const QString &ExtendedVisible,
69  const QString &FrequencyID,
70  const QString &Icon,
71  const QString &Format,
72  const QString &XMLTVID,
73  const QString &DefaultAuthority,
74  uint ServiceType ) override; // ChannelServices
75 
76  bool AddDBChannel ( uint MplexID,
77  uint SourceID,
79  const QString &CallSign,
80  const QString &ChannelName,
81  const QString &ChannelNumber,
83  uint ATSCMajorChannel,
84  uint ATSCMinorChannel,
85  bool UseEIT,
86  bool Visible,
87  const QString &ExtendedVisible,
88  const QString &FrequencyID,
89  const QString &Icon,
90  const QString &Format,
91  const QString &XMLTVID,
92  const QString &DefaultAuthority,
93  uint ServiceType ) override; // ChannelServices
94 
95  bool RemoveDBChannel ( uint ChannelID ) override; // ChannelServices
96 
97  /* Video Source Methods */
98 
99  DTC::VideoSourceList* GetVideoSourceList ( void ) override; // ChannelServices
100 
101  DTC::VideoSource* GetVideoSource ( uint SourceID ) override; // ChannelServices
102 
104  const QString &SourceName,
105  const QString &Grabber,
106  const QString &UserId,
107  const QString &FreqTable,
108  const QString &LineupId,
109  const QString &Password,
110  bool UseEIT,
111  const QString &ConfigPath,
112  int NITId,
113  uint BouquetId,
114  uint RegionId,
115  uint ScanFrequency ) override; // ChannelServices
116 
117  int AddVideoSource ( const QString &SourceName,
118  const QString &Grabber,
119  const QString &UserId,
120  const QString &FreqTable,
121  const QString &LineupId,
122  const QString &Password,
123  bool UseEIT,
124  const QString &ConfigPath,
125  int NITId,
126  uint BouquetId,
127  uint RegionId,
128  uint ScanFrequency ) override; // ChannelServices
129 
130  bool RemoveVideoSource ( uint SourceID ) override; // ChannelServices
131 
132  DTC::LineupList* GetDDLineupList ( const QString &/*Source*/,
133  const QString &/*UserId*/,
134  const QString &/*Password*/ ) override; // ChannelServices
135 
136  int FetchChannelsFromSource( uint SourceId,
137  uint CardId,
138  bool WaitForFinish ) override; // ChannelServices
139 
140  /* Multiplex Methods */
141 
143  uint StartIndex,
144  uint Count ) override; // ChannelServices
145 
146  DTC::VideoMultiplex* GetVideoMultiplex ( uint MplexID ) override; // ChannelServices
147 
148  QStringList GetXMLTVIdList ( uint SourceID ) override; // ChannelServices
149 
150 };
151 
152 // --------------------------------------------------------------------------
153 // The following class wrapper is due to a limitation in Qt Script Engine. It
154 // requires all methods that return pointers to user classes that are derived from
155 // QObject actually return QObject* (not the user class *). If the user class pointer
156 // is returned, the script engine treats it as a QVariant and doesn't create a
157 // javascript prototype wrapper for it.
158 //
159 // This class allows us to keep the rich return types in the main API class while
160 // offering the script engine a class it can work with.
161 //
162 // Only API Classes that return custom classes needs to implement these wrappers.
163 //
164 // We should continue to look for a cleaning solution to this problem.
165 // --------------------------------------------------------------------------
166 
167 class ScriptableChannel : public QObject
168 {
169  Q_OBJECT
170 
171  private:
172 
174  QScriptEngine *m_pEngine;
175 
176  public:
177 
178  Q_INVOKABLE explicit ScriptableChannel( QScriptEngine *pEngine, QObject *parent = nullptr ) : QObject( parent )
179  {
180  m_pEngine = pEngine;
181  }
182 
183  public slots:
184 
185  QObject* GetChannelInfoList ( int SourceID = 0,
186  int ChannelGroupID = 0,
187  int StartIndex = 0,
188  int Count = 0,
189  bool OnlyVisible = false,
190  bool Details = false,
191  bool OrderByName = false,
192  bool GroupByCallsign = false,
193  bool OnlyTunable = false
194  )
195  {
196  SCRIPT_CATCH_EXCEPTION( nullptr,
197  return m_obj.GetChannelInfoList( SourceID, ChannelGroupID, StartIndex, Count, OnlyVisible, Details, OrderByName, GroupByCallsign, OnlyTunable );
198  )
199  }
200 
201  QObject* GetChannelInfo ( int ChanID )
202  {
203  SCRIPT_CATCH_EXCEPTION( nullptr,
204  return m_obj.GetChannelInfo( ChanID );
205  )
206  }
207 
208  bool UpdateDBChannel ( uint MplexID,
209  uint SourceID,
210  uint ChannelID,
211  const QString &CallSign,
212  const QString &ChannelName,
213  const QString &ChannelNumber,
214  uint ServiceID,
215  uint ATSCMajorChannel,
216  uint ATSCMinorChannel,
217  bool UseEIT,
218  bool Visible,
219  const QString &ExtendedVisible,
220  const QString &FrequencyID,
221  const QString &Icon,
222  const QString &Format,
223  const QString &XMLTVID,
224  const QString &DefaultAuthority,
225  uint ServiceType )
226  {
227  SCRIPT_CATCH_EXCEPTION( false,
228  return m_obj.UpdateDBChannel(MplexID, SourceID, ChannelID,
229  CallSign, ChannelName, ChannelNumber,
230  ServiceID, ATSCMajorChannel, ATSCMinorChannel,
231  UseEIT, Visible, ExtendedVisible, FrequencyID, Icon, Format,
232  XMLTVID, DefaultAuthority, ServiceType);
233  )
234  }
235 
236  bool AddDBChannel ( uint MplexID,
237  uint SourceID,
238  uint ChannelID,
239  const QString &CallSign,
240  const QString &ChannelName,
241  const QString &ChannelNumber,
242  uint ServiceID,
243  uint ATSCMajorChannel,
244  uint ATSCMinorChannel,
245  bool UseEIT,
246  bool Visible,
247  const QString &ExtendedVisible,
248  const QString &FrequencyID,
249  const QString &Icon,
250  const QString &Format,
251  const QString &XMLTVID,
252  const QString &DefaultAuthority,
253  uint ServiceType )
254  {
255  SCRIPT_CATCH_EXCEPTION( false,
256  return m_obj.AddDBChannel(MplexID, SourceID, ChannelID,
257  CallSign, ChannelName, ChannelNumber,
258  ServiceID, ATSCMajorChannel, ATSCMinorChannel,
259  UseEIT, Visible, ExtendedVisible, FrequencyID, Icon, Format,
260  XMLTVID, DefaultAuthority, ServiceType);
261  )
262  }
263 
265  {
266  SCRIPT_CATCH_EXCEPTION( false,
268  )
269  }
270 
271  QObject* GetVideoSourceList ( void )
272  {
273  SCRIPT_CATCH_EXCEPTION( nullptr,
274  return m_obj.GetVideoSourceList();
275  )
276  }
277 
279  {
280  SCRIPT_CATCH_EXCEPTION( nullptr,
281  return m_obj.GetVideoSource( SourceID );
282  )
283  }
284 
286  const QString &SourceName,
287  const QString &Grabber,
288  const QString &UserId,
289  const QString &FreqTable,
290  const QString &LineupId,
291  const QString &Password,
292  bool UseEIT,
293  const QString &ConfigPath,
294  int NITId,
295  uint BouquetId,
296  uint RegionId,
298  {
299  SCRIPT_CATCH_EXCEPTION( false,
300  return m_obj.UpdateVideoSource( SourceID, SourceName, Grabber,
301  UserId, FreqTable, LineupId, Password,
302  UseEIT, ConfigPath, NITId, BouquetId, RegionId,
303  ScanFrequency );
304  )
305  }
306 
307  bool AddVideoSource ( const QString &SourceName,
308  const QString &Grabber,
309  const QString &UserId,
310  const QString &FreqTable,
311  const QString &LineupId,
312  const QString &Password,
313  bool UseEIT,
314  const QString &ConfigPath,
315  int NITId,
316  uint BouquetId,
317  uint RegionId,
319  {
320  SCRIPT_CATCH_EXCEPTION( false,
321  return m_obj.AddVideoSource( SourceName, Grabber, UserId,
322  FreqTable, LineupId, Password,
323  UseEIT, ConfigPath, NITId, BouquetId, RegionId,
324  ScanFrequency );
325  )
326  }
327 
329  {
330  SCRIPT_CATCH_EXCEPTION( false,
331  return m_obj.RemoveVideoSource( SourceID );
332  )
333  }
334 
336  int StartIndex,
337  int Count )
338  {
339  SCRIPT_CATCH_EXCEPTION( nullptr,
340  return m_obj.GetVideoMultiplexList( SourceID, StartIndex, Count );
341  )
342  }
343 
344  QObject* GetVideoMultiplex ( int MplexID )
345  {
346  SCRIPT_CATCH_EXCEPTION( nullptr,
347  return m_obj.GetVideoMultiplex( MplexID );
348  )
349  }
350 
351  QStringList GetXMLTVIdList ( int SourceID )
352  {
353  SCRIPT_CATCH_EXCEPTION( QStringList(),
354  return m_obj.GetXMLTVIdList(SourceID);
355  )
356  }
357 };
358 
359 
360 // NOLINTNEXTLINE(modernize-use-auto)
362 
363 #endif
Password
static StandardSetting * Password(bool enabled)
Setting for changing password.
Definition: galleryconfig.cpp:217
Channel::FetchChannelsFromSource
int FetchChannelsFromSource(uint SourceId, uint CardId, bool WaitForFinish) override
Definition: channel.cpp:545
DTC::VideoSourceList
Definition: videoSourceList.h:15
Channel
Definition: channel.h:33
Channel::RemoveDBChannel
bool RemoveDBChannel(uint ChannelID) override
Definition: channel.cpp:267
ScriptableChannel::GetVideoMultiplexList
QObject * GetVideoMultiplexList(int SourceID, int StartIndex, int Count)
Definition: channel.h:335
UseEIT
Definition: videosource.cpp:558
ScriptableChannel
Definition: channel.h:167
ScriptableChannel::GetVideoSourceList
QObject * GetVideoSourceList(void)
Definition: channel.h:271
ScriptableChannel::GetChannelInfo
QObject * GetChannelInfo(int ChanID)
Definition: channel.h:201
Channel::GetVideoMultiplexList
DTC::VideoMultiplexList * GetVideoMultiplexList(uint SourceID, uint StartIndex, uint Count) override
Definition: channel.cpp:574
ChannelServices
Definition: channelServices.h:41
DTC::VideoMultiplex
Definition: videoMultiplex.h:15
Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV
Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV(ScriptableChannel, QObject *)
Channel::GetXMLTVIdList
QStringList GetXMLTVIdList(uint SourceID) override
Definition: channel.cpp:734
ScriptableChannel::GetVideoSource
QObject * GetVideoSource(uint SourceID)
Definition: channel.h:278
slots
unsigned int slots[4]
Definition: element.cpp:38
MythDate::Format
Format
Definition: mythdate.h:12
Channel::GetVideoMultiplex
DTC::VideoMultiplex * GetVideoMultiplex(uint MplexID) override
Definition: channel.cpp:672
SourceID
Definition: videosource.cpp:2788
ScriptableChannel::GetXMLTVIdList
QStringList GetXMLTVIdList(int SourceID)
Definition: channel.h:351
Channel::GetDDLineupList
DTC::LineupList * GetDDLineupList(const QString &, const QString &, const QString &) override
Definition: channel.cpp:533
ScriptableChannel::RemoveVideoSource
bool RemoveVideoSource(uint SourceID)
Definition: channel.h:328
DTC::ChannelInfoList
Definition: channelInfoList.h:14
Visible
Definition: channelsettings.cpp:391
Channel::Channel
Q_INVOKABLE Channel(QObject *=nullptr)
Definition: channel.h:39
Channel::GetVideoSourceList
DTC::VideoSourceList * GetVideoSourceList(void) override
Definition: channel.cpp:278
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:144
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:49
ServiceID
Definition: channelsettings.cpp:312
ScriptableChannel::ScriptableChannel
Q_INVOKABLE ScriptableChannel(QScriptEngine *pEngine, QObject *parent=nullptr)
Definition: channel.h:178
ScriptableChannel::GetChannelInfoList
QObject * GetChannelInfoList(int SourceID=0, int ChannelGroupID=0, int StartIndex=0, int Count=0, bool OnlyVisible=false, bool Details=false, bool OrderByName=false, bool GroupByCallsign=false, bool OnlyTunable=false)
Definition: channel.h:185
DTC::VideoSource
Definition: videoSource.h:14
DTC::LineupList
Definition: lineup.h:66
ScriptableChannel::GetVideoMultiplex
QObject * GetVideoMultiplex(int MplexID)
Definition: channel.h:344
FreqTable
static GlobalComboBoxSetting * FreqTable()
Definition: backendsettings.cpp:240
ScanFrequency
Definition: channelscanmiscsettings.h:231
Channel::GetVideoSource
DTC::VideoSource * GetVideoSource(uint SourceID) override
Definition: channel.cpp:335
ScriptableChannel::RemoveDBChannel
bool RemoveDBChannel(uint ChannelID)
Definition: channel.h:264
uint
unsigned int uint
Definition: compat.h:140
SCRIPT_CATCH_EXCEPTION
#define SCRIPT_CATCH_EXCEPTION(default, code)
Definition: service.h:83
channelServices.h
ScriptableChannel::m_pEngine
QScriptEngine * m_pEngine
Definition: channel.h:174
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) override
Definition: channel.cpp:387
ScriptableChannel::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)
Definition: channel.h:285
ScriptableChannel::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)
Definition: channel.h:208
Channel::RemoveVideoSource
bool RemoveVideoSource(uint SourceID) override
Definition: channel.cpp:522
ScriptableChannel::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)
Definition: channel.h:236
Icon
Definition: channelsettings.cpp:208
ScriptableChannel::AddVideoSource
bool 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)
Definition: channel.h:307
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) override
Definition: channel.cpp:498
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:232
Channel::GetChannelInfo
DTC::ChannelInfo * GetChannelInfo(uint ChanID) override
Definition: channel.cpp:127
ScriptableChannel::m_obj
Channel m_obj
Definition: channel.h:173