MythTV  master
channel.cpp
Go to the documentation of this file.
1 // Program Name: channel.cpp
3 // Created : Apr. 8, 2011
4 //
5 // Copyright (c) 2011 Robert McNamara <rmcnamara@mythtv.org>
6 // Copyright (c) 2013 MythTV Developers
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 //
26 
27 #include <QList>
28 
29 #include <cmath>
30 
31 #include "channel.h"
32 
33 #include "compat.h"
34 #include "mythdbcon.h"
35 #include "mythdirs.h"
36 #include "mythversion.h"
37 #include "mythcorecontext.h"
38 #include "channelutil.h"
39 #include "sourceutil.h"
40 #include "cardutil.h"
41 #include "mythdate.h"
42 
43 #include "serviceUtil.h"
44 
46 //
48 
50  uint nChannelGroupID,
51  uint nStartIndex,
52  uint nCount,
53  bool bOnlyVisible,
54  bool bDetails,
55  bool bOrderByName,
56  bool bGroupByCallsign,
57  bool bOnlyTunable )
58 {
59  ChannelInfoList chanList;
60 
61  uint nTotalAvailable = 0;
62 
63  chanList = ChannelUtil::LoadChannels( 0, 0, nTotalAvailable, bOnlyVisible,
66  nSourceID, nChannelGroupID, false, "",
67  "", bOnlyTunable);
68 
69  // ----------------------------------------------------------------------
70  // Build Response
71  // ----------------------------------------------------------------------
72 
73  auto *pChannelInfos = new DTC::ChannelInfoList();
74 
75  nStartIndex = (nStartIndex > 0) ? min( nStartIndex, nTotalAvailable ) : 0;
76  nCount = (nCount > 0) ? min(nCount, (nTotalAvailable - nStartIndex)) :
77  (nTotalAvailable - nStartIndex);
78 
79  ChannelInfoList::iterator chanIt;
80  auto chanItBegin = chanList.begin() + nStartIndex;
81  auto chanItEnd = chanItBegin + nCount;
82 
83  for( chanIt = chanItBegin; chanIt < chanItEnd; ++chanIt )
84  {
85  DTC::ChannelInfo *pChannelInfo = pChannelInfos->AddNewChannelInfo();
86 
87  ChannelInfo channelInfo = (*chanIt);
88 
89  if (!FillChannelInfo(pChannelInfo, channelInfo, bDetails))
90  {
91  delete pChannelInfo;
92  delete pChannelInfos;
93  throw( QString("Channel ID appears invalid."));
94  }
95  }
96 
97  int nCurPage = 0;
98  int nTotalPages = 0;
99  if (nCount == 0)
100  nTotalPages = 1;
101  else
102  nTotalPages = (int)ceil((float)nTotalAvailable / nCount);
103 
104  if (nTotalPages == 1)
105  nCurPage = 1;
106  else
107  {
108  nCurPage = (int)ceil((float)nStartIndex / nCount) + 1;
109  }
110 
111  pChannelInfos->setStartIndex ( nStartIndex );
112  pChannelInfos->setCount ( nCount );
113  pChannelInfos->setCurrentPage ( nCurPage );
114  pChannelInfos->setTotalPages ( nTotalPages );
115  pChannelInfos->setTotalAvailable( nTotalAvailable );
116  pChannelInfos->setAsOf ( MythDate::current() );
117  pChannelInfos->setVersion ( MYTH_BINARY_VERSION );
118  pChannelInfos->setProtoVer ( MYTH_PROTO_VERSION );
119 
120  return pChannelInfos;
121 }
122 
124 //
126 
128 {
129  if (nChanID == 0)
130  throw( QString("Channel ID appears invalid."));
131 
132  auto *pChannelInfo = new DTC::ChannelInfo();
133 
134  if (!FillChannelInfo(pChannelInfo, nChanID, true))
135  {
136  // throw causes a crash on linux and we can't know in advance
137  // that a channel id from an old recording rule is invalid
138  //throw( QString("Channel ID appears invalid."));
139  }
140 
141  return pChannelInfo;
142 }
143 
145  uint SourceID,
146  uint ChannelID,
147  const QString &CallSign,
148  const QString &ChannelName,
149  const QString &ChannelNumber,
150  uint ServiceID,
151  uint ATSCMajorChannel,
152  uint ATSCMinorChannel,
153  bool UseEIT,
154  bool visible,
155  const QString &FrequencyID,
156  const QString &Icon,
157  const QString &Format,
158  const QString &XMLTVID,
159  const QString &DefaultAuthority,
160  uint ServiceType )
161 {
162  bool bResult = ChannelUtil::UpdateChannel( MplexID, SourceID, ChannelID,
163  CallSign, ChannelName, ChannelNumber,
164  ServiceID, ATSCMajorChannel, ATSCMinorChannel,
165  UseEIT, !visible, false, FrequencyID,
166  Icon, Format, XMLTVID, DefaultAuthority,
167  ServiceType );
168 
169  return bResult;
170 }
171 
173  uint SourceID,
174  uint ChannelID,
175  const QString &CallSign,
176  const QString &ChannelName,
177  const QString &ChannelNumber,
178  uint ServiceID,
179  uint ATSCMajorChannel,
180  uint ATSCMinorChannel,
181  bool UseEIT,
182  bool visible,
183  const QString &FrequencyID,
184  const QString &Icon,
185  const QString &Format,
186  const QString &XMLTVID,
187  const QString &DefaultAuthority,
188  uint ServiceType )
189 {
190  bool bResult = ChannelUtil::CreateChannel( MplexID, SourceID, ChannelID,
191  CallSign, ChannelName, ChannelNumber,
192  ServiceID, ATSCMajorChannel, ATSCMinorChannel,
193  UseEIT, !visible, false, FrequencyID,
194  Icon, Format, XMLTVID, DefaultAuthority,
195  ServiceType );
196 
197  return bResult;
198 }
199 
200 bool Channel::RemoveDBChannel( uint nChannelID )
201 {
202  bool bResult = ChannelUtil::DeleteChannel( nChannelID );
203 
204  return bResult;
205 }
206 
208 //
210 
212 {
213  MSqlQuery query(MSqlQuery::InitCon());
214 
215  if (!query.isConnected())
216  throw( QString("Database not open while trying to list "
217  "Video Sources."));
218 
219  query.prepare("SELECT sourceid, name, xmltvgrabber, userid, "
220  "freqtable, lineupid, password, useeit, configpath, "
221  "dvb_nit_id, bouquet_id, region_id, scanfrequency FROM videosource "
222  "ORDER BY sourceid" );
223 
224  if (!query.exec())
225  {
226  MythDB::DBError("MythAPI::GetVideoSourceList()", query);
227 
228  throw( QString( "Database Error executing query." ));
229  }
230 
231  // ----------------------------------------------------------------------
232  // return the results of the query
233  // ----------------------------------------------------------------------
234 
235  auto* pList = new DTC::VideoSourceList();
236 
237  while (query.next())
238  {
239 
240  DTC::VideoSource *pVideoSource = pList->AddNewVideoSource();
241 
242  pVideoSource->setId ( query.value(0).toInt() );
243  pVideoSource->setSourceName ( query.value(1).toString() );
244  pVideoSource->setGrabber ( query.value(2).toString() );
245  pVideoSource->setUserId ( query.value(3).toString() );
246  pVideoSource->setFreqTable ( query.value(4).toString() );
247  pVideoSource->setLineupId ( query.value(5).toString() );
248  pVideoSource->setPassword ( query.value(6).toString() );
249  pVideoSource->setUseEIT ( query.value(7).toBool() );
250  pVideoSource->setConfigPath ( query.value(8).toString() );
251  pVideoSource->setNITId ( query.value(9).toInt() );
252  pVideoSource->setBouquetId ( query.value(10).toUInt() );
253  pVideoSource->setRegionId ( query.value(11).toUInt() );
254  pVideoSource->setScanFrequency ( query.value(12).toUInt() );
255  }
256 
257  pList->setAsOf ( MythDate::current() );
258  pList->setVersion ( MYTH_BINARY_VERSION );
259  pList->setProtoVer ( MYTH_PROTO_VERSION );
260 
261  return pList;
262 }
263 
265 //
267 
269 {
270  MSqlQuery query(MSqlQuery::InitCon());
271 
272  if (!query.isConnected())
273  throw( QString("Database not open while trying to list "
274  "Video Sources."));
275 
276  query.prepare("SELECT name, xmltvgrabber, userid, "
277  "freqtable, lineupid, password, useeit, configpath, "
278  "dvb_nit_id, bouquet_id, region_id, scanfrequency "
279  "FROM videosource WHERE sourceid = :SOURCEID "
280  "ORDER BY sourceid" );
281  query.bindValue(":SOURCEID", nSourceID);
282 
283  if (!query.exec())
284  {
285  MythDB::DBError("MythAPI::GetVideoSource()", query);
286 
287  throw( QString( "Database Error executing query." ));
288  }
289 
290  // ----------------------------------------------------------------------
291  // return the results of the query
292  // ----------------------------------------------------------------------
293 
294  auto *pVideoSource = new DTC::VideoSource();
295 
296  if (query.next())
297  {
298  pVideoSource->setId ( nSourceID );
299  pVideoSource->setSourceName ( query.value(0).toString() );
300  pVideoSource->setGrabber ( query.value(1).toString() );
301  pVideoSource->setUserId ( query.value(2).toString() );
302  pVideoSource->setFreqTable ( query.value(3).toString() );
303  pVideoSource->setLineupId ( query.value(4).toString() );
304  pVideoSource->setPassword ( query.value(5).toString() );
305  pVideoSource->setUseEIT ( query.value(6).toBool() );
306  pVideoSource->setConfigPath ( query.value(7).toString() );
307  pVideoSource->setNITId ( query.value(8).toInt() );
308  pVideoSource->setBouquetId ( query.value(9).toUInt() );
309  pVideoSource->setRegionId ( query.value(10).toUInt() );
310  pVideoSource->setScanFrequency ( query.value(11).toUInt() );
311  }
312 
313  return pVideoSource;
314 }
315 
317 //
319 
321  const QString &sSourceName,
322  const QString &sGrabber,
323  const QString &sUserId,
324  const QString &sFreqTable,
325  const QString &sLineupId,
326  const QString &sPassword,
327  bool bUseEIT,
328  const QString &sConfigPath,
329  int nNITId,
330  uint nBouquetId,
331  uint nRegionId,
332  uint nScanFrequency )
333 {
334 
335  if (!HAS_PARAM("sourceid"))
336  {
337  LOG(VB_GENERAL, LOG_ERR, "SourceId is required");
338  return false;
339  }
340 
341  if (!SourceUtil::IsSourceIDValid(nSourceId))
342  {
343  LOG(VB_GENERAL, LOG_ERR, QString("SourceId %1 doesn't exist")
344  .arg(nSourceId));
345  return false;
346  }
347 
348  if (m_parsedParams.size() < 2 )
349  {
350  LOG(VB_GENERAL, LOG_ERR, QString("SourceId=%1 was the only parameter")
351  .arg(nSourceId));
352  return false;
353  }
354 
355  MSqlBindings bindings;
356  MSqlBindings::const_iterator it;
357  QString settings;
358 
359  if ( HAS_PARAM("sourcename") )
360  ADD_SQL(settings, bindings, "name", "SourceName", sSourceName)
361 
362  if ( HAS_PARAM("grabber") )
363  ADD_SQL(settings, bindings, "xmltvgrabber", "Grabber", sGrabber)
364 
365  if ( HAS_PARAM("userid") )
366  ADD_SQL(settings, bindings, "userid", "UserId", sUserId)
367 
368  if ( HAS_PARAM("freqtable") )
369  ADD_SQL(settings, bindings, "freqtable", "FreqTable", sFreqTable)
370 
371  if ( HAS_PARAM("lineupid") )
372  ADD_SQL(settings, bindings, "lineupid", "LineupId", sLineupId)
373 
374  if ( HAS_PARAM("password") )
375  ADD_SQL(settings, bindings, "password", "Password", sPassword)
376 
377  if ( HAS_PARAM("useeit") )
378  ADD_SQL(settings, bindings, "useeit", "UseEIT", bUseEIT)
379 
380  if (HAS_PARAM("configpath"))
381  {
382  if (sConfigPath.isEmpty())
383  settings += "configpath=NULL, "; // mythfilldatabase grabber requirement
384  else
385  ADD_SQL(settings, bindings, "configpath", "ConfigPath", sConfigPath)
386  }
387 
388  if ( HAS_PARAM("nitid") )
389  ADD_SQL(settings, bindings, "dvb_nit_id", "NITId", nNITId)
390 
391  if ( HAS_PARAM("bouquetid") )
392  ADD_SQL(settings, bindings, "bouquet_id", "BouquetId", nBouquetId)
393 
394  if ( HAS_PARAM("regionid") )
395  ADD_SQL(settings, bindings, "region_id", "RegionId", nRegionId)
396 
397  if ( HAS_PARAM("scanfrequency") )
398  ADD_SQL(settings, bindings, "scanfrequency", "ScanFrequency", nScanFrequency)
399 
400  if ( settings.isEmpty() )
401  {
402  LOG(VB_GENERAL, LOG_ERR, "No valid parameters were passed");
403  return false;
404  }
405 
406  settings.chop(2);
407 
408  MSqlQuery query(MSqlQuery::InitCon());
409 
410  query.prepare(QString("UPDATE videosource SET %1 WHERE sourceid=:SOURCEID")
411  .arg(settings));
412  bindings[":SOURCEID"] = nSourceId;
413 
414  for (it = bindings.begin(); it != bindings.end(); ++it)
415  query.bindValue(it.key(), it.value());
416 
417  if (!query.exec())
418  {
419  MythDB::DBError("MythAPI::UpdateVideoSource()", query);
420 
421  throw( QString( "Database Error executing query." ));
422  }
423 
424  return true;
425 }
426 
428 //
430 
431 int Channel::AddVideoSource( const QString &sSourceName,
432  const QString &sGrabber,
433  const QString &sUserId,
434  const QString &sFreqTable,
435  const QString &sLineupId,
436  const QString &sPassword,
437  bool bUseEIT,
438  const QString &sConfigPath,
439  int nNITId,
440  uint nBouquetId,
441  uint nRegionId,
442  uint nScanFrequency )
443 {
444  int nResult = SourceUtil::CreateSource(sSourceName, sGrabber, sUserId, sFreqTable,
445  sLineupId, sPassword, bUseEIT, sConfigPath,
446  nNITId, nBouquetId, nRegionId, nScanFrequency);
447 
448  return nResult;
449 }
450 
452 //
454 
456 {
457  bool bResult = SourceUtil::DeleteSource( nSourceID );
458 
459  return bResult;
460 }
461 
463 //
465 
466 DTC::LineupList* Channel::GetDDLineupList( const QString &/*sSource*/,
467  const QString &/*sUserId*/,
468  const QString &/*sPassword*/ )
469 {
470  auto *pLineups = new DTC::LineupList();
471  return pLineups;
472 }
473 
475 //
477 
479  const uint nCardId,
480  bool bWaitForFinish )
481 {
482  if ( nSourceId < 1 || nCardId < 1)
483  throw( QString("A source ID and card ID are both required."));
484 
485  int nResult = 0;
486 
487  QString cardtype = CardUtil::GetRawInputType(nCardId);
488 
489  if (!CardUtil::IsUnscanable(cardtype) &&
490  !CardUtil::IsEncoder(cardtype))
491  {
492  throw( QString("This device is incompatible with channel fetching.") );
493  }
494 
495  SourceUtil::UpdateChannelsFromListings(nSourceId, cardtype, bWaitForFinish);
496 
497  if (bWaitForFinish)
498  nResult = SourceUtil::GetChannelCount(nSourceId);
499 
500  return nResult;
501 }
502 
504 //
506 
508  uint nStartIndex,
509  uint nCount )
510 {
511  MSqlQuery query(MSqlQuery::InitCon());
512 
513  if (!query.isConnected())
514  throw( QString("Database not open while trying to list "
515  "Video Sources."));
516 
517  query.prepare("SELECT mplexid, sourceid, transportid, networkid, "
518  "frequency, inversion, symbolrate, fec, polarity, "
519  "modulation, bandwidth, lp_code_rate, transmission_mode, "
520  "guard_interval, visible, constellation, hierarchy, hp_code_rate, "
521  "mod_sys, rolloff, sistandard, serviceversion, updatetimestamp, "
522  "default_authority FROM dtv_multiplex WHERE sourceid = :SOURCEID "
523  "ORDER BY mplexid" );
524  query.bindValue(":SOURCEID", nSourceID);
525 
526  if (!query.exec())
527  {
528  MythDB::DBError("MythAPI::GetVideoMultiplexList()", query);
529 
530  throw( QString( "Database Error executing query." ));
531  }
532 
533  uint muxCount = (uint)query.size();
534 
535  // ----------------------------------------------------------------------
536  // Build Response
537  // ----------------------------------------------------------------------
538 
539  auto *pVideoMultiplexes = new DTC::VideoMultiplexList();
540 
541  nStartIndex = (nStartIndex > 0) ? min( nStartIndex, muxCount ) : 0;
542  nCount = (nCount > 0) ? min( nCount, muxCount ) : muxCount;
543  int nEndIndex = min((nStartIndex + nCount), muxCount );
544 
545  for( int n = nStartIndex; n < nEndIndex; n++)
546  {
547  if (query.seek(n))
548  {
549  DTC::VideoMultiplex *pVideoMultiplex = pVideoMultiplexes->AddNewVideoMultiplex();
550 
551  pVideoMultiplex->setMplexId( query.value(0).toInt() );
552  pVideoMultiplex->setSourceId( query.value(1).toInt() );
553  pVideoMultiplex->setTransportId( query.value(2).toInt() );
554  pVideoMultiplex->setNetworkId( query.value(3).toInt() );
555  pVideoMultiplex->setFrequency( query.value(4).toLongLong() );
556  pVideoMultiplex->setInversion( query.value(5).toString() );
557  pVideoMultiplex->setSymbolRate( query.value(6).toLongLong() );
558  pVideoMultiplex->setFEC( query.value(7).toString() );
559  pVideoMultiplex->setPolarity( query.value(8).toString() );
560  pVideoMultiplex->setModulation( query.value(9).toString() );
561  pVideoMultiplex->setBandwidth( query.value(10).toString() );
562  pVideoMultiplex->setLPCodeRate( query.value(11).toString() );
563  pVideoMultiplex->setTransmissionMode( query.value(12).toString() );
564  pVideoMultiplex->setGuardInterval( query.value(13).toString() );
565  pVideoMultiplex->setVisible( query.value(14).toBool() );
566  pVideoMultiplex->setConstellation( query.value(15).toString() );
567  pVideoMultiplex->setHierarchy( query.value(16).toString() );
568  pVideoMultiplex->setHPCodeRate( query.value(17).toString() );
569  pVideoMultiplex->setModulationSystem( query.value(18).toString() );
570  pVideoMultiplex->setRollOff( query.value(19).toString() );
571  pVideoMultiplex->setSIStandard( query.value(20).toString() );
572  pVideoMultiplex->setServiceVersion( query.value(21).toInt() );
573  pVideoMultiplex->setUpdateTimeStamp(
574  MythDate::as_utc(query.value(22).toDateTime()));
575  pVideoMultiplex->setDefaultAuthority( query.value(23).toString() );
576  }
577  }
578 
579  int curPage = 0;
580  int totalPages = 0;
581  if (nCount == 0)
582  totalPages = 1;
583  else
584  totalPages = (int)ceil((float)muxCount / nCount);
585 
586  if (totalPages == 1)
587  curPage = 1;
588  else
589  {
590  curPage = (int)ceil((float)nStartIndex / nCount) + 1;
591  }
592 
593  pVideoMultiplexes->setStartIndex ( nStartIndex );
594  pVideoMultiplexes->setCount ( nCount );
595  pVideoMultiplexes->setCurrentPage ( curPage );
596  pVideoMultiplexes->setTotalPages ( totalPages );
597  pVideoMultiplexes->setTotalAvailable( muxCount );
598  pVideoMultiplexes->setAsOf ( MythDate::current() );
599  pVideoMultiplexes->setVersion ( MYTH_BINARY_VERSION );
600  pVideoMultiplexes->setProtoVer ( MYTH_PROTO_VERSION );
601 
602  return pVideoMultiplexes;
603 }
604 
606 {
607  MSqlQuery query(MSqlQuery::InitCon());
608 
609  if (!query.isConnected())
610  throw( QString("Database not open while trying to list "
611  "Video Multiplex."));
612 
613  query.prepare("SELECT sourceid, transportid, networkid, "
614  "frequency, inversion, symbolrate, fec, polarity, "
615  "modulation, bandwidth, lp_code_rate, transmission_mode, "
616  "guard_interval, visible, constellation, hierarchy, hp_code_rate, "
617  "mod_sys, rolloff, sistandard, serviceversion, updatetimestamp, "
618  "default_authority FROM dtv_multiplex WHERE mplexid = :MPLEXID "
619  "ORDER BY mplexid" );
620  query.bindValue(":MPLEXID", nMplexID);
621 
622  if (!query.exec())
623  {
624  MythDB::DBError("MythAPI::GetVideoMultiplex()", query);
625 
626  throw( QString( "Database Error executing query." ));
627  }
628 
629  auto *pVideoMultiplex = new DTC::VideoMultiplex();
630 
631  if (query.next())
632  {
633  pVideoMultiplex->setMplexId( nMplexID );
634  pVideoMultiplex->setSourceId( query.value(0).toInt() );
635  pVideoMultiplex->setTransportId( query.value(1).toInt() );
636  pVideoMultiplex->setNetworkId( query.value(2).toInt() );
637  pVideoMultiplex->setFrequency( query.value(3).toLongLong() );
638  pVideoMultiplex->setInversion( query.value(4).toString() );
639  pVideoMultiplex->setSymbolRate( query.value(5).toLongLong() );
640  pVideoMultiplex->setFEC( query.value(6).toString() );
641  pVideoMultiplex->setPolarity( query.value(7).toString() );
642  pVideoMultiplex->setModulation( query.value(8).toString() );
643  pVideoMultiplex->setBandwidth( query.value(9).toString() );
644  pVideoMultiplex->setLPCodeRate( query.value(10).toString() );
645  pVideoMultiplex->setTransmissionMode( query.value(11).toString() );
646  pVideoMultiplex->setGuardInterval( query.value(12).toString() );
647  pVideoMultiplex->setVisible( query.value(13).toBool() );
648  pVideoMultiplex->setConstellation( query.value(14).toString() );
649  pVideoMultiplex->setHierarchy( query.value(15).toString() );
650  pVideoMultiplex->setHPCodeRate( query.value(16).toString() );
651  pVideoMultiplex->setModulationSystem( query.value(17).toString() );
652  pVideoMultiplex->setRollOff( query.value(18).toString() );
653  pVideoMultiplex->setSIStandard( query.value(19).toString() );
654  pVideoMultiplex->setServiceVersion( query.value(20).toInt() );
655  pVideoMultiplex->setUpdateTimeStamp(
656  MythDate::as_utc(query.value(21).toDateTime()));
657  pVideoMultiplex->setDefaultAuthority( query.value(22).toString() );
658  }
659 
660  return pVideoMultiplex;
661 }
662 
664 //
666 
668 {
669  MSqlQuery query(MSqlQuery::InitCon());
670 
671  if (!query.isConnected())
672  throw( QString("Database not open while trying to get source name."));
673 
674  query.prepare("SELECT name FROM videosource WHERE sourceid = :SOURCEID ");
675  query.bindValue(":SOURCEID", SourceID);
676 
677  if (!query.exec())
678  {
679  MythDB::DBError("MythAPI::GetXMLTVIdList()", query);
680 
681  throw( QString( "Database Error executing query." ));
682  }
683 
684  QStringList idList;
685 
686  if (query.next())
687  {
688  QString sourceName = query.value(0).toString();
689 
690  QString xmltvFile = GetConfDir() + '/' + sourceName + ".xmltv";
691 
692  if (QFile::exists(xmltvFile))
693  {
694  QFile file(xmltvFile);
695  if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
696  return idList;
697 
698  while (!file.atEnd())
699  {
700  QByteArray line = file.readLine();
701 
702  if (line.startsWith("channel="))
703  {
704  QString id = line.mid(8, -1).trimmed();
705  idList.append(id);
706  }
707  }
708 
709  idList.sort();
710  }
711  }
712  else
713  throw(QString("SourceID (%1) not found").arg(SourceID));
714 
715  return idList;
716 }
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:782
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:172
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:863
static ChannelInfoList LoadChannels(uint startIndex, uint count, uint &totalAvailable, bool ignoreHidden=true, OrderBy orderBy=kChanOrderByChanNum, GroupBy groupBy=kChanGroupByChanid, uint sourceID=0, uint channelGroupID=0, bool liveTVOnly=false, const QString &callsign="", const QString &channum="", bool ignoreUntunable=true)
Load channels from database into a list of ChannelInfo objects.
static uint GetChannelCount(uint sourceid)
Definition: sourceutil.cpp:111
static bool DeleteSource(uint sourceid)
Definition: sourceutil.cpp:511
static bool CreateChannel(uint db_mplexid, uint db_sourceid, uint new_channel_id, const QString &callsign, const QString &service_name, const QString &chan_num, uint service_id, uint atsc_major_channel, uint atsc_minor_channel, bool use_on_air_guide, bool hidden, bool hidden_in_guide, const QString &freqid, const QString &icon=QString(), QString format="Default", const QString &xmltvid=QString(), const QString &default_authority=QString(), uint service_type=0)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
DTC::VideoSourceList * GetVideoSourceList(void) override
Definition: channel.cpp:211
int size(void) const
Definition: mythdbcon.h:203
bool isConnected(void)
Only updated once during object creation.
Definition: mythdbcon.h:135
static bool IsUnscanable(const QString &rawtype)
Definition: cardutil.h:144
QList< QString > m_parsedParams
Definition: service.h:67
bool RemoveDBChannel(uint ChannelID) override
Definition: channel.cpp:200
QDateTime as_utc(const QDateTime &old_dt)
Returns copy of QDateTime with TimeSpec set to UTC.
Definition: mythdate.cpp:23
static bool IsEncoder(const QString &rawtype)
Definition: cardutil.h:121
QString GetConfDir(void)
Definition: mythdirs.cpp:224
QVariant value(int i) const
Definition: mythdbcon.h:198
bool FillChannelInfo(DTC::ChannelInfo *pChannel, uint nChanID, bool bDetails)
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.
Definition: mythdbcon.h:98
bool RemoveVideoSource(uint SourceID) override
Definition: channel.cpp:455
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:431
DTC::VideoMultiplex * GetVideoMultiplex(uint MplexID) override
Definition: channel.cpp:605
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
static bool IsSourceIDValid(uint sourceid)
Definition: sourceutil.cpp:367
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
static bool UpdateChannelsFromListings(uint sourceid, const QString &inputtype=QString(), bool wait=false)
Definition: sourceutil.cpp:383
#define HAS_PARAM(p)
Definition: serviceUtil.h:54
int FetchChannelsFromSource(uint SourceId, uint CardId, bool WaitForFinish) override
Definition: channel.cpp:478
#define MYTH_PROTO_VERSION
Increment this whenever the MythTV network protocol changes.
Definition: mythversion.h:48
unsigned int uint
Definition: compat.h:140
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:807
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
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:144
DTC::LineupList * GetDDLineupList(const QString &, const QString &, const QString &) override
Definition: channel.cpp:466
static int CreateSource(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: sourceutil.cpp:462
bool seek(int, bool relative=false)
Wrap QSqlQuery::seek(int,bool)
Definition: mythdbcon.cpp:802
#define MYTH_BINARY_VERSION
Update this whenever the plug-in ABI changes.
Definition: mythversion.h:16
static QString GetRawInputType(uint inputid)
Definition: cardutil.h:271
#define ADD_SQL(settings_var, bindvar, col, api_param, val)
Definition: serviceUtil.h:49
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
DTC::VideoSource * GetVideoSource(uint SourceID) override
Definition: channel.cpp:268
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:179
QStringList GetXMLTVIdList(uint SourceID) override
Definition: channel.cpp:667
DTC::VideoMultiplexList * GetVideoMultiplexList(uint SourceID, uint StartIndex, uint Count) override
Definition: channel.cpp:507
vector< ChannelInfo > ChannelInfoList
Definition: channelinfo.h:121
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:320
DTC::ChannelInfo * GetChannelInfo(uint ChanID) override
Definition: channel.cpp:127
static bool DeleteChannel(uint channel_id)
static bool UpdateChannel(uint db_mplexid, uint source_id, uint channel_id, const QString &callsign, const QString &service_name, const QString &chan_num, uint service_id, uint atsc_major_channel, uint atsc_minor_channel, bool use_on_air_guide, bool hidden, bool hidden_in_guide, const QString &freqid=QString(), const QString &icon=QString(), QString format=QString(), const QString &xmltvid=QString(), const QString &default_authority=QString(), uint service_type=0)