MythTV  master
v2channel.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 // C++
28 #include <algorithm>
29 #include <cmath>
30 
31 // Qt
32 #include <QList>
33 #include <QTemporaryFile>
34 
35 // MythTV
37 #include "libmythbase/compat.h"
38 #include "libmythbase/mythdb.h"
39 #include "libmythbase/mythdbcon.h"
40 #include "libmythbase/mythdirs.h"
42 #include "libmythbase/mythversion.h"
45 #include "libmythtv/channelutil.h"
50 #include "libmythtv/sourceutil.h"
51 #include "libmythtv/cardutil.h"
52 #include "libmythbase/mythdate.h"
53 #include "libmythtv/frequencies.h"
55 #include "libmythtv/restoredata.h"
57 
58 // MythBackend
59 #include "v2artworkInfoList.h"
60 #include "v2castMemberList.h"
61 #include "v2channel.h"
62 #include "v2programAndChannel.h"
63 #include "v2recording.h"
64 #include "v2serviceUtil.h"
65 #include "v2grabber.h"
66 #include "v2freqtable.h"
67 
69 //
71 
73 (CHANNEL_HANDLE, V2Channel::staticMetaObject, &V2Channel::RegisterCustomTypes))
74 
76 {
77  qRegisterMetaType<V2ChannelInfoList*>("V2ChannelInfoList");
78  qRegisterMetaType<V2ChannelInfo*>("V2ChannelInfo");
79  qRegisterMetaType<V2VideoSourceList*>("V2VideoSourceList");
80  qRegisterMetaType<V2VideoSource*>("V2VideoSource");
81  qRegisterMetaType<V2LineupList*>("V2LineupList");
82  qRegisterMetaType<V2Lineup*>("V2Lineup");
83  qRegisterMetaType<V2VideoMultiplexList*>("V2VideoMultiplexList");
84  qRegisterMetaType<V2VideoMultiplex*>("V2VideoMultiplex");
85  qRegisterMetaType<V2Program*>("V2Program");
86  qRegisterMetaType<V2RecordingInfo*>("V2RecordingInfo");
87  qRegisterMetaType<V2ArtworkInfoList*>("V2ArtworkInfoList");
88  qRegisterMetaType<V2ArtworkInfo*>("V2ArtworkInfo");
89  qRegisterMetaType<V2CastMemberList*>("V2CastMemberList");
90  qRegisterMetaType<V2CastMember*>("V2CastMember");
91  qRegisterMetaType<V2Grabber*>("V2Grabber");
92  qRegisterMetaType<V2GrabberList*>("V2GrabberList");
93  qRegisterMetaType<V2FreqTableList*>("V2FreqTableList");
94  qRegisterMetaType<V2CommMethodList*>("V2CommMethodList");
95  qRegisterMetaType<V2CommMethod*>("V2CommMethod");
96  qRegisterMetaType<V2ScanStatus*>("V2ScanStatus");
97  qRegisterMetaType<V2Scan*>("V2Scan");
98  qRegisterMetaType<V2ScanList*>("V2ScanList");
99  qRegisterMetaType<V2ChannelRestore*>("V2ChannelRestore");
100 }
101 
103 {
104 }
105 
106 
107 
109  uint nChannelGroupID,
110  uint nStartIndex,
111  uint nCount,
112  bool bOnlyVisible,
113  bool bDetails,
114  bool bOrderByName,
115  bool bGroupByCallsign,
116  bool bOnlyTunable )
117 {
118  ChannelInfoList chanList;
119 
120  uint nTotalAvailable = 0;
121 
122  chanList = ChannelUtil::LoadChannels( 0, 0, nTotalAvailable, bOnlyVisible,
125  nSourceID, nChannelGroupID, false, "",
126  "", bOnlyTunable);
127 
128  // ----------------------------------------------------------------------
129  // Build Response
130  // ----------------------------------------------------------------------
131 
132  auto *pChannelInfos = new V2ChannelInfoList();
133 
134  nStartIndex = (nStartIndex > 0) ? std::min( nStartIndex, nTotalAvailable ) : 0;
135  nCount = (nCount > 0) ? std::min(nCount, (nTotalAvailable - nStartIndex)) :
136  (nTotalAvailable - nStartIndex);
137 
138  ChannelInfoList::iterator chanIt;
139  auto chanItBegin = chanList.begin() + nStartIndex;
140  auto chanItEnd = chanItBegin + nCount;
141 
142  for( chanIt = chanItBegin; chanIt < chanItEnd; ++chanIt )
143  {
144  V2ChannelInfo *pChannelInfo = pChannelInfos->AddNewChannelInfo();
145 
146  const ChannelInfo& channelInfo = (*chanIt);
147 
148  if (!V2FillChannelInfo(pChannelInfo, channelInfo, bDetails))
149  {
150  delete pChannelInfo;
151  delete pChannelInfos;
152  throw( QString("V2Channel ID appears invalid."));
153  }
154  }
155 
156  int nCurPage = 0;
157  int nTotalPages = 0;
158  if (nCount == 0)
159  nTotalPages = 1;
160  else
161  nTotalPages = (int)std::ceil((float)nTotalAvailable / nCount);
162 
163  if (nTotalPages == 1)
164  nCurPage = 1;
165  else
166  {
167  nCurPage = (int)std::ceil((float)nStartIndex / nCount) + 1;
168  }
169 
170  pChannelInfos->setStartIndex ( nStartIndex );
171  pChannelInfos->setCount ( nCount );
172  pChannelInfos->setCurrentPage ( nCurPage );
173  pChannelInfos->setTotalPages ( nTotalPages );
174  pChannelInfos->setTotalAvailable( nTotalAvailable );
175  pChannelInfos->setAsOf ( MythDate::current() );
176  pChannelInfos->setVersion ( MYTH_BINARY_VERSION );
177  pChannelInfos->setProtoVer ( MYTH_PROTO_VERSION );
178 
179  return pChannelInfos;
180 }
181 
183 //
185 
187 {
188  if (nChanID == 0)
189  throw( QString("V2Channel ID appears invalid."));
190 
191  auto *pChannelInfo = new V2ChannelInfo();
192 
193  if (!V2FillChannelInfo(pChannelInfo, nChanID, true))
194  {
195  // throw causes a crash on linux and we can't know in advance
196  // that a channel id from an old recording rule is invalid
197  //throw( QString("V2Channel ID appears invalid."));
198  }
199 
200  return pChannelInfo;
201 }
202 
204  uint SourceID,
205  uint ChannelID,
206  const QString &CallSign,
207  const QString &ChannelName,
208  const QString &ChannelNumber,
209  uint ServiceID,
210  uint ATSCMajorChannel,
211  uint ATSCMinorChannel,
212  bool UseEIT,
213  bool Visible,
214  const QString &ExtendedVisible,
215  const QString &FrequencyID,
216  const QString &Icon,
217  const QString &Format,
218  const QString &XMLTVID,
219  const QString &DefaultAuthority,
220  uint ServiceType,
221  int RecPriority,
222  int TimeOffset,
223  int CommMethod )
224 {
225  if (!HAS_PARAMv2("ChannelID"))
226  throw QString("ChannelId is required");
227 
228  if (m_request->m_queries.size() < 2 )
229  throw QString("Nothing to update");
230 
231  ChannelInfo channel;
232  if (!channel.Load(ChannelID))
233  throw QString("ChannelId %1 doesn't exist");
234 
235  if (HAS_PARAMv2("MplexID"))
236  channel.m_mplexId = MplexID;
237  if (HAS_PARAMv2("SourceID"))
238  channel.m_sourceId = SourceID;
239  if (HAS_PARAMv2("CallSign"))
240  channel.m_callSign = CallSign;
241  if (HAS_PARAMv2("ChannelName"))
242  channel.m_name = ChannelName;
243  if (HAS_PARAMv2("ChannelNumber"))
244  channel.m_chanNum = ChannelNumber;
245  if (HAS_PARAMv2("ServiceID"))
246  channel.m_serviceId = ServiceID;
247  if (HAS_PARAMv2("ATSCMajorChannel"))
248  channel.m_atscMajorChan = ATSCMajorChannel;
249  if (HAS_PARAMv2("ATSCMinorChannel"))
250  channel.m_atscMinorChan = ATSCMinorChannel;
251  if (HAS_PARAMv2("UseEIT"))
252  channel.m_useOnAirGuide = UseEIT;
253  if (HAS_PARAMv2("ExtendedVisible"))
254  channel.m_visible = channelVisibleTypeFromString(ExtendedVisible);
255  else if (HAS_PARAMv2("Visible"))
256  {
257  if (channel.m_visible == kChannelVisible ||
258  channel.m_visible == kChannelNotVisible)
259  {
260  channel.m_visible =
262  }
263  else if ((channel.m_visible == kChannelAlwaysVisible && !Visible) ||
264  (channel.m_visible == kChannelNeverVisible && Visible))
265  {
266  throw QString("Can't override Always/NeverVisible");
267  }
268  }
269  if (HAS_PARAMv2("FrequencyID"))
270  channel.m_freqId = FrequencyID;
271  if (HAS_PARAMv2("Icon"))
272  channel.m_icon = Icon;
273  if (HAS_PARAMv2("Format"))
274  channel.m_tvFormat = Format;
275  if (HAS_PARAMv2("XMLTVID"))
276  channel.m_xmltvId = XMLTVID;
277  if (HAS_PARAMv2("DefaultAuthority"))
278  channel.m_defaultAuthority = DefaultAuthority;
279  if (HAS_PARAMv2("servicetype"))
280  channel.m_serviceType = ServiceType;
281  if (HAS_PARAMv2("RecPriority"))
282  channel.m_recPriority = RecPriority;
283  if (HAS_PARAMv2("TimeOffset"))
284  channel.m_tmOffset = TimeOffset;
285  if (HAS_PARAMv2("CommMethod"))
286  channel.m_commMethod = CommMethod;
287  bool bResult = ChannelUtil::UpdateChannel(
288  channel.m_mplexId, channel.m_sourceId, channel.m_chanId,
289  channel.m_callSign, channel.m_name, channel.m_chanNum,
290  channel.m_serviceId, channel.m_atscMajorChan,
291  channel.m_atscMinorChan, channel.m_useOnAirGuide,
292  channel.m_visible, channel.m_freqId,
293  channel.m_icon, channel.m_tvFormat, channel.m_xmltvId,
294  channel.m_defaultAuthority, channel.m_serviceType,
295  channel.m_recPriority, channel.m_tmOffset, channel.m_commMethod );
296 
297  if (bResult)
299  QDateTime(), "UpdateDBChannel");
300  return bResult;
301 }
302 
303 
305  uint chanId = 0;
306 
307  MSqlQuery query(MSqlQuery::InitCon());
308  query.prepare("SELECT MAX(chanid) FROM channel");
309  if (!query.exec())
310  {
311  MythDB::DBError("V2Channel::AddDBChannel", query);
312  throw( QString( "Database Error executing query." ));
313  }
314  if (query.next())
315  chanId = query.value(0).toUInt() + 1;
316  chanId = std::max<uint>(chanId, 1000);
317  return chanId;
318 }
319 
321  uint SourceID,
322  uint ChannelID,
323  const QString &CallSign,
324  const QString &ChannelName,
325  const QString &ChannelNumber,
326  uint ServiceID,
327  uint ATSCMajorChannel,
328  uint ATSCMinorChannel,
329  bool UseEIT,
330  bool Visible,
331  const QString &ExtendedVisible,
332  const QString &FrequencyID,
333  const QString &Icon,
334  const QString &Format,
335  const QString &XMLTVID,
336  const QString &DefaultAuthority,
337  uint ServiceType,
338  int RecPriority,
339  int TimeOffset,
340  int CommMethod )
341 {
342  ChannelVisibleType chan_visible = kChannelVisible;
343  if (HAS_PARAMv2("ExtendedVisible"))
344  chan_visible = channelVisibleTypeFromString(ExtendedVisible);
345  else if (HAS_PARAMv2("Visible"))
346  chan_visible = (Visible ? kChannelVisible : kChannelNotVisible);
347 
348  bool bResult = ChannelUtil::CreateChannel( MplexID, SourceID, ChannelID,
349  CallSign, ChannelName, ChannelNumber,
350  ServiceID, ATSCMajorChannel, ATSCMinorChannel,
351  UseEIT, chan_visible, FrequencyID,
352  Icon, Format, XMLTVID, DefaultAuthority,
353  ServiceType, RecPriority, TimeOffset, CommMethod );
354 
355  return bResult;
356 }
357 
359 {
360  bool bResult = ChannelUtil::DeleteChannel( nChannelID );
361 
362  return bResult;
363 }
364 
365 
367 {
368  auto* pList = new V2CommMethodList();
369 
370  std::deque<int> tmp = GetPreferredSkipTypeCombinations();
371  tmp.push_front(COMM_DETECT_UNINIT);
372  tmp.push_back(COMM_DETECT_COMMFREE);
373 
374  for (int pref : tmp)
375  {
376  V2CommMethod* pCommMethod = pList->AddNewCommMethod();
377  pCommMethod->setCommMethod(pref);
378  pCommMethod->setLocalizedName(SkipTypeToString(pref));
379  }
380  return pList;
381 }
382 
383 
385 //
387 
389 {
390  MSqlQuery query(MSqlQuery::InitCon());
391 
392  if (!query.isConnected())
393  throw( QString("Database not open while trying to list "
394  "Video Sources."));
395 
396  query.prepare("SELECT sourceid, name, xmltvgrabber, userid, "
397  "freqtable, lineupid, password, useeit, configpath, "
398  "dvb_nit_id, bouquet_id, region_id, scanfrequency, "
399  "lcnoffset FROM videosource "
400  "ORDER BY sourceid" );
401 
402  if (!query.exec())
403  {
404  MythDB::DBError("MythAPI::GetVideoSourceList()", query);
405 
406  throw( QString( "Database Error executing query." ));
407  }
408 
409  // ----------------------------------------------------------------------
410  // return the results of the query
411  // ----------------------------------------------------------------------
412 
413  auto* pList = new V2VideoSourceList();
414 
415  while (query.next())
416  {
417 
418  V2VideoSource *pVideoSource = pList->AddNewVideoSource();
419 
420  pVideoSource->setId ( query.value(0).toInt() );
421  pVideoSource->setSourceName ( query.value(1).toString() );
422  pVideoSource->setGrabber ( query.value(2).toString() );
423  pVideoSource->setUserId ( query.value(3).toString() );
424  pVideoSource->setFreqTable ( query.value(4).toString() );
425  pVideoSource->setLineupId ( query.value(5).toString() );
426  pVideoSource->setPassword ( query.value(6).toString() );
427  pVideoSource->setUseEIT ( query.value(7).toBool() );
428  pVideoSource->setConfigPath ( query.value(8).toString() );
429  pVideoSource->setNITId ( query.value(9).toInt() );
430  pVideoSource->setBouquetId ( query.value(10).toUInt() );
431  pVideoSource->setRegionId ( query.value(11).toUInt() );
432  pVideoSource->setScanFrequency ( query.value(12).toUInt() );
433  pVideoSource->setLCNOffset ( query.value(13).toUInt() );
434  }
435 
436  pList->setAsOf ( MythDate::current() );
437  pList->setVersion ( MYTH_BINARY_VERSION );
438  pList->setProtoVer ( MYTH_PROTO_VERSION );
439 
440  return pList;
441 }
442 
444 //
446 
448 {
449  MSqlQuery query(MSqlQuery::InitCon());
450 
451  if (!query.isConnected())
452  throw( QString("Database not open while trying to list "
453  "Video Sources."));
454 
455  query.prepare("SELECT name, xmltvgrabber, userid, "
456  "freqtable, lineupid, password, useeit, configpath, "
457  "dvb_nit_id, bouquet_id, region_id, scanfrequency, "
458  "lcnoffset "
459  "FROM videosource WHERE sourceid = :SOURCEID "
460  "ORDER BY sourceid" );
461  query.bindValue(":SOURCEID", nSourceID);
462 
463  if (!query.exec())
464  {
465  MythDB::DBError("MythAPI::GetVideoSource()", query);
466 
467  throw( QString( "Database Error executing query." ));
468  }
469 
470  // ----------------------------------------------------------------------
471  // return the results of the query
472  // ----------------------------------------------------------------------
473 
474  auto *pVideoSource = new V2VideoSource();
475 
476  if (query.next())
477  {
478  pVideoSource->setId ( nSourceID );
479  pVideoSource->setSourceName ( query.value(0).toString() );
480  pVideoSource->setGrabber ( query.value(1).toString() );
481  pVideoSource->setUserId ( query.value(2).toString() );
482  pVideoSource->setFreqTable ( query.value(3).toString() );
483  pVideoSource->setLineupId ( query.value(4).toString() );
484  pVideoSource->setPassword ( query.value(5).toString() );
485  pVideoSource->setUseEIT ( query.value(6).toBool() );
486  pVideoSource->setConfigPath ( query.value(7).toString() );
487  pVideoSource->setNITId ( query.value(8).toInt() );
488  pVideoSource->setBouquetId ( query.value(9).toUInt() );
489  pVideoSource->setRegionId ( query.value(10).toUInt() );
490  pVideoSource->setScanFrequency ( query.value(11).toUInt() );
491  pVideoSource->setLCNOffset ( query.value(12).toUInt() );
492  }
493 
494  return pVideoSource;
495 }
496 
498 //
500 
502  const QString &sSourceName,
503  const QString &sGrabber,
504  const QString &sUserId,
505  const QString &sFreqTable,
506  const QString &sLineupId,
507  const QString &sPassword,
508  bool bUseEIT,
509  const QString &sConfigPath,
510  int nNITId,
511  uint nBouquetId,
512  uint nRegionId,
513  uint nScanFrequency,
514  uint nLCNOffset )
515 {
516 
517  if (!HAS_PARAMv2("SourceID"))
518  {
519  LOG(VB_GENERAL, LOG_ERR, "SourceId is required");
520  return false;
521  }
522 
523  if (!SourceUtil::IsSourceIDValid(nSourceId))
524  {
525  LOG(VB_GENERAL, LOG_ERR, QString("SourceId %1 doesn't exist")
526  .arg(nSourceId));
527  return false;
528  }
529 
530  if (m_request->m_queries.size() < 2 )
531  {
532  LOG(VB_GENERAL, LOG_ERR, QString("SourceId=%1 was the only parameter")
533  .arg(nSourceId));
534  return false;
535  }
536 
537  MSqlBindings bindings;
538  MSqlBindings::const_iterator it;
539  QString settings;
540 
541  if ( HAS_PARAMv2("SourceName") )
542  ADD_SQLv2(settings, bindings, "name", "SourceName", sSourceName);
543 
544  if ( HAS_PARAMv2("Grabber") )
545  ADD_SQLv2(settings, bindings, "xmltvgrabber", "Grabber", sGrabber);
546 
547  if ( HAS_PARAMv2("UserId") )
548  ADD_SQLv2(settings, bindings, "userid", "UserId", sUserId);
549 
550  if ( HAS_PARAMv2("FreqTable") )
551  ADD_SQLv2(settings, bindings, "freqtable", "FreqTable", sFreqTable);
552 
553  if ( HAS_PARAMv2("LineupId") )
554  ADD_SQLv2(settings, bindings, "lineupid", "LineupId", sLineupId);
555 
556  if ( HAS_PARAMv2("Password") )
557  ADD_SQLv2(settings, bindings, "password", "Password", sPassword);
558 
559  if ( HAS_PARAMv2("UseEIT") )
560  ADD_SQLv2(settings, bindings, "useeit", "UseEIT", bUseEIT);
561 
562  if (HAS_PARAMv2("ConfigPath"))
563  {
564  if (sConfigPath.isEmpty())
565  settings += "configpath=NULL, "; // mythfilldatabase grabber requirement
566  else
567  ADD_SQLv2(settings, bindings, "configpath", "ConfigPath", sConfigPath);
568  }
569 
570  if ( HAS_PARAMv2("NITId") )
571  ADD_SQLv2(settings, bindings, "dvb_nit_id", "NITId", nNITId);
572 
573  if ( HAS_PARAMv2("BouquetId") )
574  ADD_SQLv2(settings, bindings, "bouquet_id", "BouquetId", nBouquetId);
575 
576  if ( HAS_PARAMv2("RegionId") )
577  ADD_SQLv2(settings, bindings, "region_id", "RegionId", nRegionId);
578 
579  if ( HAS_PARAMv2("ScanFrequency") )
580  ADD_SQLv2(settings, bindings, "scanfrequency", "ScanFrequency", nScanFrequency);
581 
582  if ( HAS_PARAMv2("LCNOffset") )
583  ADD_SQLv2(settings, bindings, "lcnoffset", "LCNOffset", nLCNOffset);
584 
585  if ( settings.isEmpty() )
586  {
587  LOG(VB_GENERAL, LOG_ERR, "No valid parameters were passed");
588  return false;
589  }
590 
591  settings.chop(2);
592 
593  MSqlQuery query(MSqlQuery::InitCon());
594 
595  query.prepare(QString("UPDATE videosource SET %1 WHERE sourceid=:SOURCEID")
596  .arg(settings));
597  bindings[":SOURCEID"] = nSourceId;
598 
599  for (it = bindings.cbegin(); it != bindings.cend(); ++it)
600  query.bindValue(it.key(), it.value());
601 
602  if (!query.exec())
603  {
604  MythDB::DBError("MythAPI::UpdateVideoSource()", query);
605 
606  throw( QString( "Database Error executing query." ));
607  }
608 
609  return true;
610 }
611 
613 //
615 
616 int V2Channel::AddVideoSource( const QString &sSourceName,
617  const QString &sGrabber,
618  const QString &sUserId,
619  const QString &sFreqTable,
620  const QString &sLineupId,
621  const QString &sPassword,
622  bool bUseEIT,
623  const QString &sConfigPath,
624  int nNITId,
625  uint nBouquetId,
626  uint nRegionId,
627  uint nScanFrequency,
628  uint nLCNOffset )
629 {
630  int nResult = SourceUtil::CreateSource(sSourceName, sGrabber, sUserId, sFreqTable,
631  sLineupId, sPassword, bUseEIT, sConfigPath,
632  nNITId, nBouquetId, nRegionId, nScanFrequency,
633  nLCNOffset);
634 
635  return nResult;
636 }
637 
639 //
641 
643 {
644  bool bResult = SourceUtil::DeleteAllSources();
645 
646  return bResult;
647 }
648 
650 {
651  bool bResult = SourceUtil::DeleteSource( nSourceID );
652 
653  return bResult;
654 }
655 
657 //
659 
660 V2LineupList* V2Channel::GetDDLineupList( const QString &/*sSource*/,
661  const QString &/*sUserId*/,
662  const QString &/*sPassword*/ )
663 {
664  auto *pLineups = new V2LineupList();
665  return pLineups;
666 }
667 
669 //
671 
673  const uint nCardId,
674  bool bWaitForFinish )
675 {
676  if ( nSourceId < 1 || nCardId < 1)
677  throw( QString("A source ID and card ID are both required."));
678 
679  int nResult = 0;
680 
681  QString cardtype = CardUtil::GetRawInputType(nCardId);
682 
683  // These tests commented because they prevent fetching channels for CETON
684  // cable card device, which is compatible with fetching and requires fetching.
685  // if (!CardUtil::IsUnscanable(cardtype) &&
686  // !CardUtil::IsEncoder(cardtype))
687  // {
688  // throw( QString("This device is incompatible with channel fetching.") );
689  // }
690 
691  SourceUtil::UpdateChannelsFromListings(nSourceId, cardtype, bWaitForFinish);
692 
693  if (bWaitForFinish)
694  nResult = SourceUtil::GetChannelCount(nSourceId);
695 
696  return nResult;
697 }
698 
700 //
702 
704  uint nStartIndex,
705  uint nCount )
706 {
707  MSqlQuery query(MSqlQuery::InitCon());
708 
709  if (!query.isConnected())
710  throw( QString("Database not open while trying to list "
711  "Video Sources."));
712  QString where;
713  if (nSourceID > 0)
714  where = "WHERE sourceid = :SOURCEID";
715  QString sql = QString("SELECT mplexid, sourceid, transportid, networkid, "
716  "frequency, inversion, symbolrate, fec, polarity, "
717  "modulation, bandwidth, lp_code_rate, transmission_mode, "
718  "guard_interval, visible, constellation, hierarchy, hp_code_rate, "
719  "mod_sys, rolloff, sistandard, serviceversion, updatetimestamp, "
720  "default_authority FROM dtv_multiplex %1 "
721  "ORDER BY mplexid").arg(where);
722 
723  query.prepare(sql);
724  if (nSourceID > 0)
725  query.bindValue(":SOURCEID", nSourceID);
726 
727  if (!query.exec())
728  {
729  MythDB::DBError("MythAPI::GetVideoMultiplexList()", query);
730 
731  throw( QString( "Database Error executing query." ));
732  }
733 
734  uint muxCount = (uint)query.size();
735 
736  // ----------------------------------------------------------------------
737  // Build Response
738  // ----------------------------------------------------------------------
739 
740  auto *pVideoMultiplexes = new V2VideoMultiplexList();
741 
742  nStartIndex = (nStartIndex > 0) ? std::min( nStartIndex, muxCount ) : 0;
743  nCount = (nCount > 0) ? std::min( nCount, muxCount ) : muxCount;
744  int nEndIndex = std::min((nStartIndex + nCount), muxCount );
745 
746  for( int n = nStartIndex; n < nEndIndex; n++)
747  {
748  if (query.seek(n))
749  {
750  V2VideoMultiplex *pVideoMultiplex = pVideoMultiplexes->AddNewVideoMultiplex();
751 
752  pVideoMultiplex->setMplexId( query.value(0).toInt() );
753  pVideoMultiplex->setSourceId( query.value(1).toInt() );
754  pVideoMultiplex->setTransportId( query.value(2).toInt() );
755  pVideoMultiplex->setNetworkId( query.value(3).toInt() );
756  pVideoMultiplex->setFrequency( query.value(4).toLongLong() );
757  pVideoMultiplex->setInversion( query.value(5).toString() );
758  pVideoMultiplex->setSymbolRate( query.value(6).toLongLong() );
759  pVideoMultiplex->setFEC( query.value(7).toString() );
760  pVideoMultiplex->setPolarity( query.value(8).toString() );
761  pVideoMultiplex->setModulation( query.value(9).toString() );
762  pVideoMultiplex->setBandwidth( query.value(10).toString() );
763  pVideoMultiplex->setLPCodeRate( query.value(11).toString() );
764  pVideoMultiplex->setTransmissionMode( query.value(12).toString() );
765  pVideoMultiplex->setGuardInterval( query.value(13).toString() );
766  pVideoMultiplex->setVisible( query.value(14).toBool() );
767  pVideoMultiplex->setConstellation( query.value(15).toString() );
768  pVideoMultiplex->setHierarchy( query.value(16).toString() );
769  pVideoMultiplex->setHPCodeRate( query.value(17).toString() );
770  pVideoMultiplex->setModulationSystem( query.value(18).toString() );
771  pVideoMultiplex->setRollOff( query.value(19).toString() );
772  pVideoMultiplex->setSIStandard( query.value(20).toString() );
773  pVideoMultiplex->setServiceVersion( query.value(21).toInt() );
774  pVideoMultiplex->setUpdateTimeStamp(
775  MythDate::as_utc(query.value(22).toDateTime()));
776  pVideoMultiplex->setDefaultAuthority( query.value(23).toString() );
777 
778  // Code from libs/libmythtv/channelscan/multiplexsetting.cpp:53
779  QString DisplayText;
780  if (query.value(9).toString() == "8vsb") //modulation
781  {
782  QString ChannelNumber =
783  // value(4) = frequency
784  QString("Freq %1").arg(query.value(4).toInt());
785  int findFrequency = (query.value(4).toInt() / 1000) - 1750;
786  for (const auto & list : gChanLists[0].list)
787  {
788  if ((list.freq <= findFrequency + 200) &&
789  (list.freq >= findFrequency - 200))
790  {
791  ChannelNumber = QString("%1").arg(list.name);
792  }
793  }
794  //: %1 is the channel number
795  DisplayText = tr("ATSC Channel %1").arg(ChannelNumber);
796  }
797  else
798  {
799  DisplayText = QString("%1 Hz (%2) (%3) (%4)")
800  .arg(query.value(4).toString(), // frequency
801  query.value(6).toString(), // symbolrate
802  query.value(3).toString(), // networkid
803  query.value(2).toString()); // transportid
804  }
805  pVideoMultiplex->setDescription(DisplayText);
806  }
807  }
808 
809  int curPage = 0;
810  int totalPages = 0;
811  if (nCount == 0)
812  totalPages = 1;
813  else
814  totalPages = (int)std::ceil((float)muxCount / nCount);
815 
816  if (totalPages == 1)
817  curPage = 1;
818  else
819  {
820  curPage = (int)std::ceil((float)nStartIndex / nCount) + 1;
821  }
822 
823  pVideoMultiplexes->setStartIndex ( nStartIndex );
824  pVideoMultiplexes->setCount ( nCount );
825  pVideoMultiplexes->setCurrentPage ( curPage );
826  pVideoMultiplexes->setTotalPages ( totalPages );
827  pVideoMultiplexes->setTotalAvailable( muxCount );
828  pVideoMultiplexes->setAsOf ( MythDate::current() );
829  pVideoMultiplexes->setVersion ( MYTH_BINARY_VERSION );
830  pVideoMultiplexes->setProtoVer ( MYTH_PROTO_VERSION );
831 
832  return pVideoMultiplexes;
833 }
834 
836 {
837  MSqlQuery query(MSqlQuery::InitCon());
838 
839  if (!query.isConnected())
840  throw( QString("Database not open while trying to list "
841  "Video Multiplex."));
842 
843  query.prepare("SELECT sourceid, transportid, networkid, "
844  "frequency, inversion, symbolrate, fec, polarity, "
845  "modulation, bandwidth, lp_code_rate, transmission_mode, "
846  "guard_interval, visible, constellation, hierarchy, hp_code_rate, "
847  "mod_sys, rolloff, sistandard, serviceversion, updatetimestamp, "
848  "default_authority FROM dtv_multiplex WHERE mplexid = :MPLEXID "
849  "ORDER BY mplexid" );
850  query.bindValue(":MPLEXID", nMplexID);
851 
852  if (!query.exec())
853  {
854  MythDB::DBError("MythAPI::GetVideoMultiplex()", query);
855 
856  throw( QString( "Database Error executing query." ));
857  }
858 
859  auto *pVideoMultiplex = new V2VideoMultiplex();
860 
861  if (query.next())
862  {
863  pVideoMultiplex->setMplexId( nMplexID );
864  pVideoMultiplex->setSourceId( query.value(0).toInt() );
865  pVideoMultiplex->setTransportId( query.value(1).toInt() );
866  pVideoMultiplex->setNetworkId( query.value(2).toInt() );
867  pVideoMultiplex->setFrequency( query.value(3).toLongLong() );
868  pVideoMultiplex->setInversion( query.value(4).toString() );
869  pVideoMultiplex->setSymbolRate( query.value(5).toLongLong() );
870  pVideoMultiplex->setFEC( query.value(6).toString() );
871  pVideoMultiplex->setPolarity( query.value(7).toString() );
872  pVideoMultiplex->setModulation( query.value(8).toString() );
873  pVideoMultiplex->setBandwidth( query.value(9).toString() );
874  pVideoMultiplex->setLPCodeRate( query.value(10).toString() );
875  pVideoMultiplex->setTransmissionMode( query.value(11).toString() );
876  pVideoMultiplex->setGuardInterval( query.value(12).toString() );
877  pVideoMultiplex->setVisible( query.value(13).toBool() );
878  pVideoMultiplex->setConstellation( query.value(14).toString() );
879  pVideoMultiplex->setHierarchy( query.value(15).toString() );
880  pVideoMultiplex->setHPCodeRate( query.value(16).toString() );
881  pVideoMultiplex->setModulationSystem( query.value(17).toString() );
882  pVideoMultiplex->setRollOff( query.value(18).toString() );
883  pVideoMultiplex->setSIStandard( query.value(19).toString() );
884  pVideoMultiplex->setServiceVersion( query.value(20).toInt() );
885  pVideoMultiplex->setUpdateTimeStamp(
886  MythDate::as_utc(query.value(21).toDateTime()));
887  pVideoMultiplex->setDefaultAuthority( query.value(22).toString() );
888  }
889 
890  return pVideoMultiplex;
891 }
892 
894 //
896 
898 {
899  MSqlQuery query(MSqlQuery::InitCon());
900 
901  if (!query.isConnected())
902  throw( QString("Database not open while trying to get source name."));
903 
904  query.prepare("SELECT name FROM videosource WHERE sourceid = :SOURCEID ");
905  query.bindValue(":SOURCEID", SourceID);
906 
907  if (!query.exec())
908  {
909  MythDB::DBError("MythAPI::GetXMLTVIdList()", query);
910 
911  throw( QString( "Database Error executing query." ));
912  }
913 
914  QStringList idList;
915 
916  if (query.next())
917  {
918  QString sourceName = query.value(0).toString();
919 
920  QString xmltvFile = GetConfDir() + '/' + sourceName + ".xmltv";
921 
922  if (QFile::exists(xmltvFile))
923  {
924  QFile file(xmltvFile);
925  if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
926  return idList;
927 
928  while (!file.atEnd())
929  {
930  QByteArray line = file.readLine();
931 
932  if (line.startsWith("channel="))
933  {
934  QString id = line.mid(8, -1).trimmed();
935  idList.append(id);
936  }
937  }
938 
939  idList.sort();
940  }
941  }
942  else
943  {
944  throw(QString("SourceID (%1) not found").arg(SourceID));
945  }
946 
947  return idList;
948 }
949 
950 // Prevent concurrent access to tv_find_grabbers
951 static QMutex lockGrabber;
952 
954 {
955  // ----------------------------------------------------------------------
956  // Build Response
957  // ----------------------------------------------------------------------
958 
959  QMutexLocker lock(&lockGrabber);
960 
961  auto *pGrabberList = new V2GrabberList();
962 
963  // Add default grabbers
964  V2Grabber *pGrabber = pGrabberList->AddNewGrabber();
965  pGrabber->setProgram("eitonly");
966  pGrabber->setDisplayName(QObject::tr("Transmitted guide only (EIT)"));
967  pGrabber = pGrabberList->AddNewGrabber();
968  pGrabber->setProgram("/bin/true");
969  pGrabber->setDisplayName(QObject::tr("No grabber"));
970 
971  QStringList args;
972  args += "baseline";
973 
974  MythSystemLegacy find_grabber_proc("tv_find_grabbers", args,
976  find_grabber_proc.Run(25s);
977  LOG(VB_GENERAL, LOG_INFO,
978  "Running 'tv_find_grabbers " + args.join(" ") + "'.");
979  uint status = find_grabber_proc.Wait();
980 
981  if (status == GENERIC_EXIT_OK)
982  {
983  QTextStream ostream(find_grabber_proc.ReadAll());
984  while (!ostream.atEnd())
985  {
986  QString grabber_list(ostream.readLine());
987  QStringList grabber_split =
988  grabber_list.split("|", Qt::SkipEmptyParts);
989  const QString& grabber_name = grabber_split[1];
990  QFileInfo grabber_file(grabber_split[0]);
991  QString program = grabber_file.fileName();
992 
993  if (!pGrabberList->containsProgram(program))
994  {
995  pGrabber = pGrabberList->AddNewGrabber();
996  pGrabber->setProgram(program);
997  pGrabber->setDisplayName(grabber_name);
998  }
999  LOG(VB_GENERAL, LOG_DEBUG, "Found " + grabber_split[0]);
1000  }
1001  LOG(VB_GENERAL, LOG_INFO, "Finished running tv_find_grabbers");
1002  }
1003  else
1004  {
1005  LOG(VB_GENERAL, LOG_ERR, "Failed to run tv_find_grabbers");
1006  }
1007 
1008  return pGrabberList;
1009 }
1010 
1012 {
1013  // Channel Frequency Table
1014  QStringList freqList;
1015  freqList.append("default");
1016  for (const auto & freqEntry : gChanLists)
1017  {
1018  freqList.append(freqEntry.name);
1019  }
1020  return freqList;
1021 
1022 }
1023 
1025  const QString &DesiredServices,
1026  bool FreeToAirOnly,
1027  bool ChannelNumbersOnly,
1028  bool CompleteChannelsOnly,
1029  bool FullChannelSearch,
1030  bool RemoveDuplicates,
1031  bool AddFullTS,
1032  bool TestDecryptable,
1033  const QString &ScanType,
1034  const QString &FreqTable,
1035  const QString &Modulation,
1036  const QString &FirstChan,
1037  const QString &LastChan,
1038  uint ScanId,
1039  bool IgnoreSignalTimeout,
1040  bool FollowNITSetting,
1041  uint MplexId,
1042  const QString &Frequency,
1043  const QString &Bandwidth,
1044  const QString &Polarity,
1045  const QString &SymbolRate,
1046  const QString &Inversion,
1047  const QString &Constellation,
1048  const QString &ModSys,
1049  const QString &CodeRateLP,
1050  const QString &CodeRateHP,
1051  const QString &FEC,
1052  const QString &TransmissionMode,
1053  const QString &GuardInterval,
1054  const QString &Hierarchy,
1055  const QString &RollOff)
1056 {
1058  if (pScanner->m_status == "RUNNING")
1059  return false;
1060 
1061  return pScanner->StartScan (CardId,
1063  FreeToAirOnly,
1068  AddFullTS,
1069  TestDecryptable,
1070  ScanType,
1071  FreqTable,
1072  Modulation,
1073  FirstChan,
1074  LastChan,
1075  ScanId,
1078  MplexId,
1079  Frequency,
1080  Bandwidth,
1081  Polarity,
1082  SymbolRate,
1083  Inversion,
1084  Constellation,
1085  ModSys,
1086  CodeRateLP,
1087  CodeRateHP,
1088  FEC,
1089  TransmissionMode,
1090  GuardInterval,
1091  Hierarchy,
1092  RollOff);
1093 }
1094 
1095 
1097 {
1098  auto *pStatus = new V2ScanStatus();
1100  pStatus->setCardId(pScanner->m_cardid);
1101  pStatus->setStatus(pScanner->m_status);
1102  pStatus->setSignalLock(pScanner->m_statusLock);
1103  pStatus->setProgress(pScanner->m_statusProgress);
1104  pStatus->setSignalNoise(pScanner->m_statusSnr);
1105  pStatus->setSignalStrength(pScanner->m_statusSignalStrength);
1106  pStatus->setStatusLog(pScanner->m_statusLog);
1107  pStatus->setStatusText(pScanner->m_statusText);
1108  pStatus->setStatusTitle(pScanner->m_statusTitleText);
1109  pStatus->setDialogMsg(pScanner->m_dlgMsg);
1110  pStatus->setDialogButtons(pScanner->m_dlgButtons);
1111  pStatus->setDialogInputReq(pScanner->m_dlgInputReq);
1112 
1113  return pStatus;
1114 }
1115 
1116 
1117 bool V2Channel::StopScan ( uint Cardid )
1118 {
1120  if (pScanner->m_status != "RUNNING" || pScanner->m_cardid != Cardid)
1121  return false;
1122  pScanner->stopScan();
1123  return true;
1124 }
1125 
1127 {
1128  auto scanList = LoadScanList(SourceId);
1129  auto * pResult = new V2ScanList();
1130  for (const ScanInfo &scan : scanList)
1131  {
1132  auto *pItem = pResult->AddNewScan();
1133  pItem->setScanId (scan.m_scanid);
1134  pItem->setCardId (scan.m_cardid);
1135  pItem->setSourceId (scan.m_sourceid);
1136  pItem->setProcessed (scan.m_processed);
1137  pItem->setScanDate (scan.m_scandate);
1138  }
1139  return pResult;
1140 }
1141 
1143  const QString &DialogString,
1144  int DialogButton )
1145 {
1147  if (pScanner->m_cardid == Cardid)
1148  {
1149  pScanner->m_dlgString = DialogString;
1150  pScanner->m_dlgButton = DialogButton;
1151  pScanner->m_dlgButtons.clear();
1152  pScanner->m_dlgInputReq = false;
1153  pScanner->m_dlgMsg = "";
1154  pScanner->m_waitCondition.wakeOne();
1155  return true;
1156  }
1157  return false;
1158 }
1159 
1161  bool XmltvId,
1162  bool Icon,
1163  bool Visible)
1164 {
1165  auto * pResult = new V2ChannelRestore();
1166  RestoreData* rd = RestoreData::getInstance(SourceId);
1167  QString result = rd->doRestore(XmltvId, Icon, Visible);
1168  if (result.isEmpty())
1169  throw( QString("GetRestoreData failed."));
1170  pResult->setNumChannels(rd->m_num_channels);
1171  pResult->setNumXLMTVID(rd->m_num_xmltvid);
1172  pResult->setNumIcon(rd->m_num_icon);
1173  pResult->setNumVisible(rd->m_num_visible);
1174  return pResult;
1175 }
1176 
1178 {
1179  RestoreData* rd = RestoreData::getInstance(SourceId);
1180  bool result = rd->doSave();
1182  return result;
1183 }
1184 
1185 
1186 bool V2Channel::CopyIconToBackend(const QString& Url, const QString& ChanId)
1187 {
1188  QString filename = Url.section('/', -1);
1189 
1190  QString dirpath = GetConfDir();
1191  QDir configDir(dirpath);
1192  if (!configDir.exists() && !configDir.mkdir(dirpath))
1193  {
1194  LOG(VB_GENERAL, LOG_ERR, QString("Could not create %1").arg(dirpath));
1195  }
1196 
1197  QString channelDir = QString("%1/%2").arg(configDir.absolutePath(),
1198  "/channels");
1199  QDir strChannelDir(channelDir);
1200  if (!strChannelDir.exists() && !strChannelDir.mkdir(channelDir))
1201  {
1202  LOG(VB_GENERAL, LOG_ERR,
1203  QString("Could not create %1").arg(channelDir));
1204  }
1205  channelDir += "/";
1206 
1207  QString filePath = channelDir + filename;
1208 
1209  // If we get to this point we've already checked whether the icon already
1210  // exist locally, we want to download anyway to fix a broken image or
1211  // get the latest version of the icon
1212 
1213  QTemporaryFile tmpFile(filePath);
1214  if (!tmpFile.open())
1215  {
1216  LOG(VB_GENERAL, LOG_INFO, "Icon Download: Couldn't create temporary file");
1217  return false;
1218  }
1219 
1220  bool fRet = GetMythDownloadManager()->download(Url, tmpFile.fileName());
1221 
1222  if (!fRet)
1223  {
1224  LOG(VB_GENERAL, LOG_INFO,
1225  QString("Download for icon %1 failed").arg(filename));
1226  return false;
1227  }
1228 
1229  QImage icon(tmpFile.fileName());
1230  if (icon.isNull())
1231  {
1232  LOG(VB_GENERAL, LOG_INFO,
1233  QString("Downloaded icon for %1 isn't a valid image").arg(filename));
1234  return false;
1235  }
1236 
1237  // Remove any existing icon
1238  QFile file(filePath);
1239  file.remove();
1240 
1241  // Rename temporary file & prevent it being cleaned up
1242  tmpFile.rename(filePath);
1243  tmpFile.setAutoRemove(false);
1244 
1245  MSqlQuery query(MSqlQuery::InitCon());
1246  QString qstr = "UPDATE channel SET icon = :ICON "
1247  "WHERE chanid = :CHANID";
1248 
1249  query.prepare(qstr);
1250  query.bindValue(":ICON", filename);
1251  query.bindValue(":CHANID", ChanId);
1252 
1253  if (!query.exec())
1254  {
1255  MythDB::DBError("Error inserting channel icon", query);
1256  return false;
1257  }
1258 
1259  return fRet;
1260 }
ChannelInfo
Definition: channelinfo.h:31
MythHTTPService::HAS_PARAMv2
bool HAS_PARAMv2(const QString &p)
Definition: mythhttpservice.h:36
RestoreData::doSave
bool doSave(void)
Definition: restoredata.cpp:424
V2Channel::RemoveDBChannel
static bool RemoveDBChannel(uint ChannelID)
Definition: v2channel.cpp:358
RestoreData::m_num_visible
int m_num_visible
Definition: restoredata.h:114
V2CommMethodList
Definition: v2commMethod.h:45
MSqlBindings
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.
Definition: mythdbcon.h:100
CommMethod
Definition: channelsettings.cpp:425
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:812
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:127
build_compdb.args
args
Definition: build_compdb.py:11
ChannelScannerWeb::m_dlgInputReq
bool m_dlgInputReq
Definition: channelscanner_web.h:125
ChannelInfo::m_serviceType
uint m_serviceType
Definition: channelinfo.h:112
ChannelUtil::kChanGroupByCallsign
@ kChanGroupByCallsign
Definition: channelutil.h:215
MSqlQuery::size
int size(void) const
Definition: mythdbcon.h:214
SourceUtil::DeleteSource
static bool DeleteSource(uint sourceid)
Definition: sourceutil.cpp:530
RemoveDuplicates
Definition: channelscanmiscsettings.h:174
kChannelNeverVisible
@ kChannelNeverVisible
Definition: channelinfo.h:25
ChannelScannerWeb::m_statusProgress
uint m_statusProgress
Definition: channelscanner_web.h:116
RestoreData::m_num_icon
int m_num_icon
Definition: restoredata.h:113
RestoreData
Definition: restoredata.h:82
LoadScanList
std::vector< ScanInfo > LoadScanList(void)
Definition: scaninfo.cpp:268
CompleteChannelsOnly
Definition: channelscanmiscsettings.h:139
mythdb.h
MythSystemLegacy
Definition: mythsystemlegacy.h:67
ChannelInfo::m_chanId
uint m_chanId
Definition: channelinfo.h:85
V2Channel::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, int RecPriority, int TimeOffset, int CommMethod)
Definition: v2channel.cpp:203
MythDate::as_utc
QDateTime as_utc(const QDateTime &old_dt)
Returns copy of QDateTime with TimeSpec set to UTC.
Definition: mythdate.cpp:28
RestoreData::m_num_xmltvid
int m_num_xmltvid
Definition: restoredata.h:112
ChannelUtil::LoadChannels
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.
Definition: channelutil.cpp:2470
SourceUtil::GetChannelCount
static uint GetChannelCount(uint sourceid)
Definition: sourceutil.cpp:136
channelimporter.h
V2Channel::CopyIconToBackend
static bool CopyIconToBackend(const QString &Url, const QString &ChanId)
Definition: v2channel.cpp:1186
UseEIT
Definition: videosource.cpp:594
ADD_SQLv2
static void ADD_SQLv2(QString &settings_var, MSqlBindings &bindvar, const QString &col, const QString &api_param, const T &val)
Definition: v2serviceUtil.h:29
ChannelUtil::DeleteChannel
static bool DeleteChannel(uint channel_id)
Definition: channelutil.cpp:1811
ChannelScannerWeb::StartScan
bool StartScan(uint CardId, const QString &DesiredServices, bool FreeToAirOnly, bool ChannelNumbersOnly, bool CompleteChannelsOnly, bool FullChannelSearch, bool RemoveDuplicates, bool AddFullTS, bool TestDecryptable, const QString &ScanType, const QString &FreqTable, QString Modulation, const QString &FirstChan, const QString &LastChan, uint ScanId, bool IgnoreSignalTimeout, bool FollowNITSetting, uint MplexId, const QString &Frequency, const QString &Bandwidth, const QString &Polarity, const QString &SymbolRate, const QString &Inversion, const QString &Constellation, const QString &ModSys, const QString &CodeRate_LP, const QString &CodeRate_HP, const QString &FEC, const QString &Trans_Mode, const QString &Guard_Interval, const QString &Hierarchy, const QString &RollOff)
Definition: channelscanner_web.cpp:56
ChannelInfo::m_freqId
QString m_freqId
Definition: channelinfo.h:87
v2programAndChannel.h
V2Channel::RemoveVideoSource
static bool RemoveVideoSource(uint SourceID)
Definition: v2channel.cpp:649
V2Channel::StopScan
static bool StopScan(uint Cardid)
Definition: v2channel.cpp:1117
frequencies.h
ChannelScannerWeb::m_waitCondition
QWaitCondition m_waitCondition
Definition: channelscanner_web.h:110
xbmcvfs.exists
bool exists(str path)
Definition: xbmcvfs.py:51
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:204
mythdbcon.h
V2VideoSourceList
Definition: v2videoSourceList.h:12
V2Channel::GetScanList
static V2ScanList * GetScanList(uint SourceId)
Definition: v2channel.cpp:1126
v2recording.h
scanwizardconfig.h
mythhttpmetaservice.h
ChannelInfo::m_atscMajorChan
uint m_atscMajorChan
Definition: channelinfo.h:113
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:618
ChannelInfo::m_name
QString m_name
Definition: channelinfo.h:92
SkipTypeToString
QString SkipTypeToString(int flags)
Definition: programtypes.cpp:91
MythDate::Format
Format
Definition: mythdate.h:15
channelscanner_web.h
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
SourceID
Definition: videosource.cpp:2874
MythSystemLegacy::ReadAll
QByteArray & ReadAll()
Definition: mythsystemlegacy.cpp:402
ChannelScannerWeb::m_cardid
uint m_cardid
Definition: channelscanner_web.h:111
build_compdb.file
file
Definition: build_compdb.py:55
SourceUtil::CreateSource
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, uint lcnoffset)
Definition: sourceutil.cpp:477
mythdirs.h
V2Channel::StartScan
static bool StartScan(uint CardId, const QString &DesiredServices, bool FreeToAirOnly, bool ChannelNumbersOnly, bool CompleteChannelsOnly, bool FullChannelSearch, bool RemoveDuplicates, bool AddFullTS, bool TestDecryptable, const QString &ScanType, const QString &FreqTable, const QString &Modulation, const QString &FirstChan, const QString &LastChan, uint ScanId, bool IgnoreSignalTimeout, bool FollowNITSetting, uint MplexId, const QString &Frequency, const QString &Bandwidth, const QString &Polarity, const QString &SymbolRate, const QString &Inversion, const QString &Constellation, const QString &ModSys, const QString &CodeRateLP, const QString &CodeRateHP, const QString &FEC, const QString &TransmissionMode, const QString &GuardInterval, const QString &Hierarchy, const QString &RollOff)
Definition: v2channel.cpp:1024
V2Channel::RegisterCustomTypes
static void RegisterCustomTypes()
ChannelScannerWeb::m_dlgString
QString m_dlgString
Definition: channelscanner_web.h:127
ChannelVisibleType
ChannelVisibleType
Definition: channelinfo.h:20
Visible
Definition: channelsettings.cpp:448
ChannelInfo::m_icon
QString m_icon
Definition: channelinfo.h:93
V2Channel::GetChannelInfoList
static V2ChannelInfoList * GetChannelInfoList(uint SourceID, uint ChannelGroupID, uint StartIndex, uint Count, bool OnlyVisible, bool Details, bool OrderByName, bool GroupByCallsign, bool OnlyTunable)
Definition: v2channel.cpp:108
hardwareprofile.scan.scan
def scan(profile, smoonURL, gate)
Definition: scan.py:54
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:15
V2Grabber
Definition: v2grabber.h:20
V2Channel::GetScanStatus
static V2ScanStatus * GetScanStatus()
Definition: v2channel.cpp:1096
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
IgnoreSignalTimeout
Definition: channelscanmiscsettings.h:52
V2Channel::GetGrabberList
static V2GrabberList * GetGrabberList()
Definition: v2channel.cpp:953
mythsystemlegacy.h
programtypes.h
ChannelID
Definition: channelsettings.h:19
SourceUtil::IsSourceIDValid
static bool IsSourceIDValid(uint sourceid)
Definition: sourceutil.cpp:380
ChannelInfo::m_commMethod
int m_commMethod
Definition: channelinfo.h:119
RestoreData::doRestore
QString doRestore(bool do_xmltvid, bool do_icon, bool do_visible)
Definition: restoredata.cpp:172
ChannelInfo::m_useOnAirGuide
bool m_useOnAirGuide
Definition: channelinfo.h:108
v2channel.h
V2CommMethod
Definition: v2commMethod.h:17
mythdate.h
sourceutil.h
kChannelVisible
@ kChannelVisible
Definition: channelinfo.h:23
SourceUtil::UpdateChannelsFromListings
static bool UpdateChannelsFromListings(uint sourceid, const QString &inputtype=QString(), bool wait=false)
Definition: sourceutil.cpp:396
V2ChannelInfoList
Definition: v2channelInfoList.h:10
ServiceID
Definition: channelsettings.cpp:369
mythlogging.h
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:263
v2serviceUtil.h
channelVisibleTypeFromString
ChannelVisibleType channelVisibleTypeFromString(const QString &type)
Definition: channelinfo.cpp:541
V2Channel::GetVideoMultiplex
static V2VideoMultiplex * GetVideoMultiplex(uint MplexID)
Definition: v2channel.cpp:835
V2Channel::GetXMLTVIdList
static QStringList GetXMLTVIdList(uint SourceID)
Definition: v2channel.cpp:897
ChannelInfo::m_atscMinorChan
uint m_atscMinorChan
Definition: channelinfo.h:114
GENERIC_EXIT_OK
@ GENERIC_EXIT_OK
Exited with no error.
Definition: exitcodes.h:13
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:550
ChannelUtil::UpdateChannel
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, ChannelVisibleType visible, const QString &freqid=QString(), const QString &icon=QString(), QString format=QString(), const QString &xmltvid=QString(), const QString &default_authority=QString(), uint service_type=0, int recpriority=INT_MIN, int tmOffset=INT_MIN, int commMethod=INT_MIN)
Definition: channelutil.cpp:1597
compat.h
ChannelScannerWeb::m_dlgButton
int m_dlgButton
Definition: channelscanner_web.h:126
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:226
restoredata.h
V2Channel::AddVideoSource
static 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)
Definition: v2channel.cpp:616
v2freqtable.h
ChannelInfo::m_chanNum
QString m_chanNum
Definition: channelinfo.h:86
V2Channel::GetAvailableChanid
static uint GetAvailableChanid(void)
Definition: v2channel.cpp:304
ChannelScannerWeb::m_statusSnr
int m_statusSnr
Definition: channelscanner_web.h:117
FreqTable
static GlobalComboBoxSetting * FreqTable()
Definition: backendsettings.cpp:251
MythSystemLegacy::Wait
uint Wait(std::chrono::seconds timeout=0s)
Definition: mythsystemlegacy.cpp:243
ChannelScannerWeb::m_statusLock
bool m_statusLock
Definition: channelscanner_web.h:115
scaninfo.h
MythDownloadManager::download
bool download(const QString &url, const QString &dest, bool reload=false)
Downloads a URL to a file in blocking mode.
Definition: mythdownloadmanager.cpp:431
COMM_DETECT_COMMFREE
@ COMM_DETECT_COMMFREE
Definition: programtypes.h:128
V2Channel::V2Channel
V2Channel()
Definition: v2channel.cpp:102
CHANNEL_HANDLE
#define CHANNEL_HANDLE
Definition: v2channel.h:40
scheduledrecording.h
V2Channel::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)
Definition: v2channel.cpp:501
V2Channel::GetChannelInfo
static V2ChannelInfo * GetChannelInfo(uint ChanID)
Definition: v2channel.cpp:186
MSqlQuery::seek
bool seek(int where, bool relative=false)
Wrap QSqlQuery::seek(int,bool)
Definition: mythdbcon.cpp:832
V2FillChannelInfo
bool V2FillChannelInfo(V2ChannelInfo *pChannel, uint nChanID, bool bDetails)
Definition: v2serviceUtil.cpp:170
ChannelInfo::m_tmOffset
int m_tmOffset
Definition: channelinfo.h:120
V2Channel::GetVideoSource
static V2VideoSource * GetVideoSource(uint SourceID)
Definition: v2channel.cpp:447
ChannelUtil::kChanOrderByName
@ kChanOrderByName
Definition: channelutil.h:209
V2Channel::SendScanDialogResponse
static bool SendScanDialogResponse(uint Cardid, const QString &DialogString, int DialogButton)
Definition: v2channel.cpp:1142
MSqlQuery::isConnected
bool isConnected(void) const
Only updated once during object creation.
Definition: mythdbcon.h:137
RestoreData::m_num_channels
int m_num_channels
Definition: restoredata.h:111
FullChannelSearch
Definition: channelscanmiscsettings.h:157
ChannelScannerWeb::m_dlgMsg
QString m_dlgMsg
Definition: channelscanner_web.h:123
MythHTTPService
Definition: mythhttpservice.h:19
V2Channel::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, int RecPriority, int TimeOffset, int CommMethod)
Definition: v2channel.cpp:320
kMSRunShell
@ kMSRunShell
run process through shell
Definition: mythsystem.h:43
ChannelUtil::CreateChannel
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, ChannelVisibleType visible, const QString &freqid, const QString &icon=QString(), QString format="Default", const QString &xmltvid=QString(), const QString &default_authority=QString(), uint service_type=0, int recpriority=0, int tmOffset=0, int commMethod=-1)
Definition: channelutil.cpp:1509
lockGrabber
static QMutex lockGrabber
Definition: v2channel.cpp:951
channelutil.h
ChannelScannerWeb
Definition: channelscanner_web.h:46
FollowNITSetting
Definition: channelscanmiscsettings.h:65
ChannelScannerWeb::m_statusText
QString m_statusText
Definition: channelscanner_web.h:118
V2Channel::RemoveAllVideoSources
static bool RemoveAllVideoSources(void)
Definition: v2channel.cpp:642
TimeOffset
Definition: channelsettings.cpp:231
v2artworkInfoList.h
gChanLists
const CHANLISTS_vec gChanLists
Definition: frequencies.cpp:2215
ChannelScannerWeb::m_status
QString m_status
Definition: channelscanner_web.h:114
CardUtil::GetRawInputType
static QString GetRawInputType(uint inputid)
Definition: cardutil.h:292
ChannelInfo::m_serviceId
uint m_serviceId
Definition: channelinfo.h:111
V2ScanList
Definition: v2channelScan.h:62
ChannelNumbersOnly
Definition: channelscanmiscsettings.h:123
V2Channel::GetRestoreData
static V2ChannelRestore * GetRestoreData(uint SourceId, bool XmltvId, bool Icon, bool Visible)
Definition: v2channel.cpp:1160
Frequency
Definition: transporteditor.cpp:466
V2Channel::GetDDLineupList
static V2LineupList * GetDDLineupList(const QString &Source, const QString &UserId, const QString &Password)
Definition: v2channel.cpp:660
cardutil.h
V2VideoMultiplexList
Definition: v2videoMultiplexList.h:11
Modulation
Definition: transporteditor.cpp:541
DesiredServices
Definition: channelscanmiscsettings.h:79
ChannelInfo::Load
bool Load(uint lchanid=-1)
Definition: channelinfo.cpp:131
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:888
Q_GLOBAL_STATIC_WITH_ARGS
Q_GLOBAL_STATIC_WITH_ARGS(MythHTTPMetaService, s_service,(CHANNEL_HANDLE, V2Channel::staticMetaObject, &V2Channel::RegisterCustomTypes)) void V2Channel
Definition: v2channel.cpp:72
V2Channel::FetchChannelsFromSource
static int FetchChannelsFromSource(uint SourceId, uint CardId, bool WaitForFinish)
Definition: v2channel.cpp:672
V2LineupList
Definition: v2lineup.h:56
ChannelInfo::m_sourceId
uint m_sourceId
Definition: channelinfo.h:89
kChannelAlwaysVisible
@ kChannelAlwaysVisible
Definition: channelinfo.h:22
V2GrabberList
Definition: v2grabber.h:48
ChannelInfo::m_tvFormat
QString m_tvFormat
Definition: channelinfo.h:105
ChannelUtil::kChanGroupByChanid
@ kChanGroupByChanid
Definition: channelutil.h:217
ChannelScannerWeb::m_statusLog
QString m_statusLog
Definition: channelscanner_web.h:119
ChannelScannerWeb::m_statusTitleText
QString m_statusTitleText
Definition: channelscanner_web.h:120
ChannelInfo::m_recPriority
int m_recPriority
Definition: channelinfo.h:98
V2Channel::GetVideoSourceList
static V2VideoSourceList * GetVideoSourceList(void)
Definition: v2channel.cpp:388
V2Channel::GetFreqTableList
static QStringList GetFreqTableList()
Definition: v2channel.cpp:1011
SourceUtil::DeleteAllSources
static bool DeleteAllSources(void)
Definition: sourceutil.cpp:586
ChannelUtil::kChanOrderByChanNum
@ kChanOrderByChanNum
Definition: channelutil.h:208
V2VideoMultiplex
Definition: v2videoMultiplex.h:12
ChannelScannerWeb::getInstance
static ChannelScannerWeb * getInstance()
Definition: channelscanner_web.cpp:47
ChannelInfo::m_xmltvId
QString m_xmltvId
Definition: channelinfo.h:97
Icon
Definition: channelsettings.cpp:265
RestoreData::getInstance
static RestoreData * getInstance(uint sourceid)
Definition: restoredata.cpp:104
FreeToAirOnly
Definition: channelscanmiscsettings.h:109
MythHTTPService::m_request
HTTPRequest2 m_request
Definition: mythhttpservice.h:35
MythSystemLegacy::Run
void Run(std::chrono::seconds timeout=0s)
Runs a command inside the /bin/sh shell. Returns immediately.
Definition: mythsystemlegacy.cpp:213
ChannelScannerWeb::stopScan
void stopScan()
Definition: channelscanner_web.cpp:428
V2Channel::GetVideoMultiplexList
static V2VideoMultiplexList * GetVideoMultiplexList(uint SourceID, uint StartIndex, uint Count)
Definition: v2channel.cpp:703
RollOff
Definition: transporteditor.cpp:834
RestoreData::freeInstance
static void freeInstance()
Definition: restoredata.cpp:119
V2ScanStatus
Definition: v2channelScan.h:6
mythdownloadmanager.h
COMM_DETECT_UNINIT
@ COMM_DETECT_UNINIT
Definition: programtypes.h:129
GetPreferredSkipTypeCombinations
std::deque< int > GetPreferredSkipTypeCombinations(void)
Definition: programtypes.cpp:129
build_compdb.filename
filename
Definition: build_compdb.py:21
ChannelInfo::m_mplexId
uint m_mplexId
Definition: channelinfo.h:110
V2ChannelRestore
Definition: v2channelRestore.h:19
v2castMemberList.h
ScheduledRecording::RescheduleMatch
static void RescheduleMatch(uint recordid, uint sourceid, uint mplexid, const QDateTime &maxstarttime, const QString &why)
Definition: scheduledrecording.h:17
ChannelInfo::m_visible
ChannelVisibleType m_visible
Definition: channelinfo.h:106
kMSStdOut
@ kMSStdOut
allow access to stdout
Definition: mythsystem.h:41
v2grabber.h
V2VideoSource
Definition: v2videoSource.h:10
ChannelScannerWeb::m_statusSignalStrength
int m_statusSignalStrength
Definition: channelscanner_web.h:122
MythHTTPMetaService
Definition: mythhttpmetaservice.h:10
ScanInfo
Definition: scaninfo.h:17
V2Channel::SaveRestoreData
static bool SaveRestoreData(uint SourceId)
Definition: v2channel.cpp:1177
ChannelInfo::m_defaultAuthority
QString m_defaultAuthority
Definition: channelinfo.h:118
ChannelInfo::m_callSign
QString m_callSign
Definition: channelinfo.h:91
ChannelScannerWeb::m_dlgButtons
QStringList m_dlgButtons
Definition: channelscanner_web.h:124
V2ChannelInfo
Definition: v2programAndChannel.h:27
kChannelNotVisible
@ kChannelNotVisible
Definition: channelinfo.h:24
uint
unsigned int uint
Definition: freesurround.h:24
V2Channel::GetCommMethodList
static V2CommMethodList * GetCommMethodList(void)
Definition: v2channel.cpp:366
GetMythDownloadManager
MythDownloadManager * GetMythDownloadManager(void)
Gets the pointer to the MythDownloadManager singleton.
Definition: mythdownloadmanager.cpp:146
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:837
AddFullTS
Definition: channelscanmiscsettings.h:190
ChannelInfoList
std::vector< ChannelInfo > ChannelInfoList
Definition: channelinfo.h:131