MythTV master
channelscanner_gui.cpp
Go to the documentation of this file.
1/* -*- Mode: c++ -*-
2 * vim: set expandtab tabstop=4 shiftwidth=4:
3 *
4 * Original Project
5 * MythTV http://www.mythtv.org
6 *
7 * Copyright (c) 2004, 2005 John Pullan <john@pullan.org>
8 * Copyright (c) 2005 - 2007 Daniel Kristjansson
9 *
10 * Description:
11 * Collection of classes to provide channel scanning functionallity
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27 *
28 */
29
30// System headers
31#include <unistd.h>
32
33// Std C++
34#include <algorithm>
35
36#include <QtGlobal>
37#if QT_VERSION >= QT_VERSION_CHECK(6,5,0)
38#include <QtSystemDetection>
39#endif
40
41// MythTV headers
42#include "libmythbase/mythconfig.h"
44
45#include "channelscanner_gui.h"
47#include "channelimporter.h"
48#include "channelscan_sm.h"
49#include "mpeg/mpegstreamdata.h"
53
54#define LOC QString("ChScanGUI: ")
55
56static const int kCodeRejected = 0;
57static const int kCodeAccepted = 1;
58
60{
61 Teardown();
62 if (m_scanMonitor)
63 {
65 }
66}
67
69{
70 if (scanEvent->type() == ScannerEvent::kScanComplete)
71 {
72 if (m_scanStage)
74
75 InformUser(tr("Scan complete"));
76
77 // HACK: make channel insertion work after [21644]
79 }
80 else if (scanEvent->type() == ScannerEvent::kScanShutdown ||
81 scanEvent->type() == ScannerEvent::kScanErrored)
82 {
83 ScanDTVTransportList transports;
85 {
88 }
89
90 bool success = (m_iptvScanner != nullptr);
91#if CONFIG_VBOX
92 success |= (m_vboxScanner != nullptr);
93#endif
94#ifndef Q_OS_WINDOWS
95 success |= (m_externRecScanner != nullptr);
96#endif
97#if CONFIG_HDHOMERUN
98 success |= (m_hdhrScanner != nullptr);
99#endif
100
101 Teardown();
102
103 if (scanEvent->type() == ScannerEvent::kScanErrored)
104 {
105 QString error = scanEvent->strValue();
107 return;
108 }
109
110 int ret = scanEvent->intValue();
111 if (!transports.empty() || (kCodeRejected != ret))
112 {
113 Process(transports, success);
114 }
115 }
116 else if (scanEvent->type() == ScannerEvent::kAppendTextToLog)
117 {
118 if (m_scanStage)
119 m_scanStage->AppendLine(scanEvent->strValue());
120 m_messageList += scanEvent->strValue();
121 }
122
123 if (!m_scanStage)
124 return;
125
126 if (scanEvent->type() == ScannerEvent::kSetStatusText)
127 m_scanStage->SetStatusText(scanEvent->strValue());
128 else if (scanEvent->type() == ScannerEvent::kSetStatusTitleText)
130 else if (scanEvent->type() == ScannerEvent::kSetPercentComplete)
131 m_scanStage->SetScanProgress(scanEvent->intValue() * 0.01);
132 else if (scanEvent->type() == ScannerEvent::kSetStatusRotorPosition)
134 else if (scanEvent->type() == ScannerEvent::kSetStatusSignalLock)
135 m_scanStage->SetStatusLock(scanEvent->intValue());
136 else if (scanEvent->type() == ScannerEvent::kSetStatusSignalToNoise)
138 else if (scanEvent->type() == ScannerEvent::kSetStatusSignalStrength)
140}
141
143 bool success)
144{
145 ChannelImporter ci(true, true, true, true, true,
148 ci.Process(_transports, m_sourceid);
149}
150
152{
154}
155
157{
158 m_scanStage = nullptr;
159
160 if (m_scanMonitor)
161 {
163 }
164}
165
166void ChannelScannerGUI::MonitorProgress(bool lock, bool strength,
167 bool snr, bool rotor)
168{
170
171 m_scanStage = new ChannelScannerGUIScanPane(lock, strength, snr, rotor, mainStack);
172
173 if (m_scanStage->Create())
174 {
176
177 for (const QString& msg : std::as_const(m_messageList))
179 mainStack->AddScreen(m_scanStage);
180 }
181 else
182 {
183 delete m_scanStage;
184 m_scanStage = nullptr;
185 }
186}
static const int kCodeAccepted
static const int kCodeRejected
void Process(const ScanDTVTransportList &_transports, int sourceid=-1)
chan_info_map_t GetChannelList(transport_scan_items_it_t trans_info, ScannedChannelInfo *scan_info) const
void StopScanner(void)
Stops the ChannelScanSM event loop and the signal monitor, blocking until both exit.
void SetStatusText(const QString &value)
void SetStatusTitleText(const QString &value)
virtual void Process(const ScanDTVTransportList &_transports, bool success=false)
void InformUser(const QString &error) override
void MonitorProgress(bool lock, bool strength, bool snr, bool rotor) override
QStringList m_messageList
void HandleEvent(const ScannerEvent *scanEvent) override
ChannelScannerGUIScanPane * m_scanStage
bool m_completeOnly
Only complete channels desired post scan?
IPTVChannelFetcher * m_iptvScanner
ChannelScanSM * m_sigmonScanner
virtual void Teardown(void)
bool m_fullSearch
Extended search for old channels post scan?
bool m_channelNumbersOnly
Only channels with logical channel numbers desired post scan?
bool m_freeToAirOnly
Only fta channels desired post scan?
bool m_removeDuplicates
Remove duplicate transports and channels?
ScanMonitor * m_scanMonitor
bool m_addFullTS
Add MPTS "full transport stream" channels.
ServiceRequirements m_serviceRequirements
Services desired post scan.
MythScreenStack * GetMainStack()
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
static const Type kSetStatusSignalLock
Definition: scanmonitor.h:116
QString strValue() const
Definition: scanmonitor.h:94
static const Type kScanShutdown
Definition: scanmonitor.h:107
static const Type kSetStatusTitleText
Definition: scanmonitor.h:111
static const Type kSetStatusSignalToNoise
Definition: scanmonitor.h:114
static const Type kSetStatusText
Definition: scanmonitor.h:110
static const Type kAppendTextToLog
Definition: scanmonitor.h:109
static const Type kSetStatusRotorPosition
Definition: scanmonitor.h:113
static const Type kScanComplete
Definition: scanmonitor.h:106
static const Type kSetPercentComplete
Definition: scanmonitor.h:112
static const Type kSetStatusSignalStrength
Definition: scanmonitor.h:115
int intValue() const
Definition: scanmonitor.h:97
static const Type kScanErrored
Definition: scanmonitor.h:108
std::vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:143
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
MythMainWindow * GetMythMainWindow(void)
def error(message)
Definition: smolt.py:409
void post_event(QObject *dest, QEvent::Type type, int val)
Percentage to set to after the first tune.
Definition: scanmonitor.cpp:68