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