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