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