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// MythTV headers
38
39#include "channelscanner_gui.h"
41#include "channelimporter.h"
42#include "channelscan_sm.h"
43#include "mpeg/mpegstreamdata.h"
47
48#define LOC QString("ChScanGUI: ")
49
50static const int kCodeRejected = 0;
51static const int kCodeAccepted = 1;
52
54{
55 Teardown();
56 if (m_scanMonitor)
57 {
59 }
60}
61
63{
64 if (scanEvent->type() == ScannerEvent::kScanComplete)
65 {
66 if (m_scanStage)
68
69 InformUser(tr("Scan complete"));
70
71 // HACK: make channel insertion work after [21644]
73 }
74 else if (scanEvent->type() == ScannerEvent::kScanShutdown ||
75 scanEvent->type() == ScannerEvent::kScanErrored)
76 {
77 ScanDTVTransportList transports;
79 {
82 }
83
84 bool success = (m_iptvScanner != nullptr);
85#if CONFIG_VBOX
86 success |= (m_vboxScanner != nullptr);
87#endif
88#if !defined( _WIN32 )
89 success |= (m_externRecScanner != nullptr);
90#endif
91#if CONFIG_HDHOMERUN
92 success |= (m_hdhrScanner != nullptr);
93#endif
94
95 Teardown();
96
97 if (scanEvent->type() == ScannerEvent::kScanErrored)
98 {
99 QString error = scanEvent->strValue();
101 return;
102 }
103
104 int ret = scanEvent->intValue();
105 if (!transports.empty() || (kCodeRejected != ret))
106 {
107 Process(transports, success);
108 }
109 }
110 else if (scanEvent->type() == ScannerEvent::kAppendTextToLog)
111 {
112 if (m_scanStage)
113 m_scanStage->AppendLine(scanEvent->strValue());
114 m_messageList += scanEvent->strValue();
115 }
116
117 if (!m_scanStage)
118 return;
119
120 if (scanEvent->type() == ScannerEvent::kSetStatusText)
121 m_scanStage->SetStatusText(scanEvent->strValue());
122 else if (scanEvent->type() == ScannerEvent::kSetStatusTitleText)
124 else if (scanEvent->type() == ScannerEvent::kSetPercentComplete)
125 m_scanStage->SetScanProgress(scanEvent->intValue() * 0.01);
126 else if (scanEvent->type() == ScannerEvent::kSetStatusRotorPosition)
128 else if (scanEvent->type() == ScannerEvent::kSetStatusSignalLock)
129 m_scanStage->SetStatusLock(scanEvent->intValue());
130 else if (scanEvent->type() == ScannerEvent::kSetStatusSignalToNoise)
132 else if (scanEvent->type() == ScannerEvent::kSetStatusSignalStrength)
134}
135
137 bool success)
138{
139 ChannelImporter ci(true, true, true, true, true,
142 ci.Process(_transports, m_sourceid);
143}
144
146{
148}
149
151{
152 m_scanStage = nullptr;
153
154 if (m_scanMonitor)
155 {
157 }
158}
159
160void ChannelScannerGUI::MonitorProgress(bool lock, bool strength,
161 bool snr, bool rotor)
162{
164
165 m_scanStage = new ChannelScannerGUIScanPane(lock, strength, snr, rotor, mainStack);
166
167 if (m_scanStage->Create())
168 {
170
171 for (const QString& msg : std::as_const(m_messageList))
173 mainStack->AddScreen(m_scanStage);
174 }
175 else
176 {
177 delete m_scanStage;
178 m_scanStage = nullptr;
179 }
180}
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