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