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"
44 #include "recorders/channelbase.h"
47 
48 #define LOC QString("ChScanGUI: ")
49 
50 static const int kCodeRejected = 0;
51 static 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;
78  if (m_sigmonScanner)
79  {
82  }
83 
84  bool success = (m_iptvScanner != nullptr);
85 #ifdef USING_VBOX
86  success |= (m_vboxScanner != nullptr);
87 #endif
88 #if !defined( USING_MINGW ) && !defined( _MSC_VER )
89  success |= (m_externRecScanner != nullptr);
90 #endif
91 #ifdef USING_HDHOMERUN
92  success |= (m_hdhrScanner != nullptr);
93 #endif
94 
95  Teardown();
96 
97  if (scanEvent->type() == ScannerEvent::kScanErrored)
98  {
99  QString error = scanEvent->strValue();
100  InformUser(error);
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)
123  m_scanStage->SetStatusTitleText(scanEvent->strValue());
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 
160 void 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))
172  m_scanStage->AppendLine(msg);
173  mainStack->AddScreen(m_scanStage);
174  }
175  else
176  {
177  delete m_scanStage;
178  m_scanStage = nullptr;
179  }
180 }
ChannelScannerGUI::m_messageList
QStringList m_messageList
Definition: channelscanner_gui.h:77
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:318
error
static void error(const char *str,...)
Definition: vbi.cpp:36
ChannelScanner::m_hdhrScanner
HDHRChannelFetcher * m_hdhrScanner
Definition: channelscanner.h:147
ChannelScannerGUI::InformUser
void InformUser(const QString &error) override
Definition: channelscanner_gui.cpp:145
channelimporter.h
ChannelScannerGUI::HandleEvent
void HandleEvent(const ScannerEvent *scanEvent) override
Definition: channelscanner_gui.cpp:62
channelscan_sm.h
mythdialogbox.h
MythScreenStack
Definition: mythscreenstack.h:16
ScannerEvent::kAppendTextToLog
static const Type kAppendTextToLog
Definition: scanmonitor.h:109
ChannelScannerGUI::m_scanStage
ChannelScannerGUIScanPane * m_scanStage
Definition: channelscanner_gui.h:76
ChannelScannerGUIScanPane::AppendLine
void AppendLine(const QString &text)
Definition: channelscanner_gui_scan_pane.cpp:155
channelbase.h
ChannelScanner::m_removeDuplicates
bool m_removeDuplicates
Remove duplicate transports and channels?
Definition: channelscanner.h:163
ChannelImporter::Process
void Process(const ScanDTVTransportList &_transports, int sourceid=-1)
Definition: channelimporter.cpp:76
ChannelScanSM::StopScanner
void StopScanner(void)
Stops the ChannelScanSM event loop and the signal monitor, blocking until both exit.
Definition: channelscan_sm.cpp:2273
ScannerEvent::kSetStatusText
static const Type kSetStatusText
Definition: scanmonitor.h:110
ScannerEvent::kScanShutdown
static const Type kScanShutdown
Definition: scanmonitor.h:107
kCodeAccepted
static const int kCodeAccepted
Definition: channelscanner_gui.cpp:51
ChannelScannerGUIScanPane::SetStatusSignalStrength
void SetStatusSignalStrength(int value)
Definition: channelscanner_gui_scan_pane.cpp:128
ScannerEvent::kScanComplete
static const Type kScanComplete
Definition: scanmonitor.h:106
ChannelScannerGUI::Process
virtual void Process(const ScanDTVTransportList &_transports, bool success=false)
Definition: channelscanner_gui.cpp:136
ChannelScanner::m_freeToAirOnly
bool m_freeToAirOnly
Only fta channels desired post scan?
Definition: channelscanner.h:151
ChannelScannerGUI::quitScanning
void quitScanning(void)
Definition: channelscanner_gui.cpp:150
ChannelScannerGUIScanPane::SetStatusText
void SetStatusText(const QString &value)
Definition: channelscanner_gui_scan_pane.cpp:143
ChannelScannerGUIScanPane::SetStatusSignalToNoise
void SetStatusSignalToNoise(int value)
Definition: channelscanner_gui_scan_pane.cpp:119
dvbsignalmonitor.h
ChannelScanner::m_sigmonScanner
ChannelScanSM * m_sigmonScanner
Definition: channelscanner.h:131
ChannelScannerGUIScanPane::SetScanProgress
void SetScanProgress(double value)
Definition: channelscanner_gui_scan_pane.cpp:164
ChannelScanner::m_sourceid
int m_sourceid
Definition: channelscanner.h:168
ScannerEvent::intValue
int intValue() const
Definition: scanmonitor.h:97
ScannerEvent::kSetStatusRotorPosition
static const Type kSetStatusRotorPosition
Definition: scanmonitor.h:113
ScannerEvent::kSetStatusSignalToNoise
static const Type kSetStatusSignalToNoise
Definition: scanmonitor.h:114
ChannelScanner::m_fullSearch
bool m_fullSearch
Extended search for old channels post scan?
Definition: channelscanner.h:160
ChannelScanner::Teardown
virtual void Teardown(void)
Definition: channelscanner.cpp:63
ChannelScannerGUI::MonitorProgress
void MonitorProgress(bool lock, bool strength, bool snr, bool rotor) override
Definition: channelscanner_gui.cpp:160
ScannerEvent::kSetStatusSignalLock
static const Type kSetStatusSignalLock
Definition: scanmonitor.h:116
kCodeRejected
static const int kCodeRejected
Definition: channelscanner_gui.cpp:50
ScanDTVTransportList
std::vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:143
ScannerEvent::kSetStatusSignalStrength
static const Type kSetStatusSignalStrength
Definition: scanmonitor.h:115
ChannelScannerGUIScanPane::SetStatusRotorPosition
void SetStatusRotorPosition(int value)
Definition: channelscanner_gui_scan_pane.cpp:110
ChannelScanner::m_channelNumbersOnly
bool m_channelNumbersOnly
Only channels with logical channel numbers desired post scan?
Definition: channelscanner.h:154
ChannelScanner::m_iptvScanner
IPTVChannelFetcher * m_iptvScanner
Definition: channelscanner.h:132
ScannerEvent
Definition: scanmonitor.h:86
mpegstreamdata.h
ChannelScanner::m_addFullTS
bool m_addFullTS
Add MPTS "full transport stream" channels.
Definition: channelscanner.h:166
ChannelScanner::m_serviceRequirements
ServiceRequirements m_serviceRequirements
Services desired post scan.
Definition: channelscanner.h:171
ScannerEvent::strValue
QString strValue() const
Definition: scanmonitor.h:94
ChannelScanner::m_scanMonitor
ScanMonitor * m_scanMonitor
Definition: channelscanner.h:127
ChannelScannerGUIScanPane::SetStatusTitleText
void SetStatusTitleText(const QString &value)
Definition: channelscanner_gui_scan_pane.cpp:149
ScannerEvent::kSetStatusTitleText
static const Type kSetStatusTitleText
Definition: scanmonitor.h:111
ChannelScannerGUIScanPane::Create
bool Create() override
Definition: channelscanner_gui_scan_pane.cpp:38
ChannelImporter
Definition: channelimporter.h:71
ScannerEvent::kSetPercentComplete
static const Type kSetPercentComplete
Definition: scanmonitor.h:112
ScannerEvent::kScanErrored
static const Type kScanErrored
Definition: scanmonitor.h:108
ChannelScannerGUIScanPane
Definition: channelscanner_gui_scan_pane.h:40
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:104
channelscanner_gui.h
ChannelScannerGUI::~ChannelScannerGUI
~ChannelScannerGUI() override
Definition: channelscanner_gui.cpp:53
MythScreenType::Exiting
void Exiting()
ChannelScanSM::GetChannelList
chan_info_map_t GetChannelList(transport_scan_items_it_t trans_info, ScannedChannelInfo *scan_info) const
Definition: channelscan_sm.cpp:1359
ChannelScannerGUIScanPane::SetStatusLock
void SetStatusLock(int value)
Definition: channelscanner_gui_scan_pane.cpp:137
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:52
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:562
post_event
void post_event(QObject *dest, QEvent::Type type, int val)
Percentage to set to after the first tune.
Definition: scanmonitor.cpp:68
dtvsignalmonitor.h
ChannelScanner::m_completeOnly
bool m_completeOnly
Only complete channels desired post scan?
Definition: channelscanner.h:157
channelscanner_gui_scan_pane.h