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