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::ScanComplete)
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::ScanShutdown ||
75  scanEvent->type() == ScannerEvent::ScanErrored)
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 
92  Teardown();
93 
94  if (scanEvent->type() == ScannerEvent::ScanErrored)
95  {
96  QString error = scanEvent->strValue();
98  return;
99  }
100 
101  int ret = scanEvent->intValue();
102  if (!transports.empty() || (kCodeRejected != ret))
103  {
104  Process(transports, success);
105  }
106  }
107  else if (scanEvent->type() == ScannerEvent::AppendTextToLog)
108  {
109  if (m_scanStage)
110  m_scanStage->AppendLine(scanEvent->strValue());
111  m_messageList += scanEvent->strValue();
112  }
113 
114  if (!m_scanStage)
115  return;
116 
117  if (scanEvent->type() == ScannerEvent::SetStatusText)
118  m_scanStage->SetStatusText(scanEvent->strValue());
119  else if (scanEvent->type() == ScannerEvent::SetStatusTitleText)
120  m_scanStage->SetStatusTitleText(scanEvent->strValue());
121  else if (scanEvent->type() == ScannerEvent::SetPercentComplete)
122  m_scanStage->SetScanProgress(scanEvent->intValue() * 0.01);
123  else if (scanEvent->type() == ScannerEvent::SetStatusRotorPosition)
125  else if (scanEvent->type() == ScannerEvent::SetStatusSignalLock)
126  m_scanStage->SetStatusLock(scanEvent->intValue());
127  else if (scanEvent->type() == ScannerEvent::SetStatusSignalToNoise)
129  else if (scanEvent->type() == ScannerEvent::SetStatusSignalStrength)
131 }
132 
134  bool success)
135 {
136  ChannelImporter ci(true, true, true, true, true,
139  ci.Process(_transports, m_sourceid);
140 }
141 
143 {
145 }
146 
148 {
149  m_scanStage = nullptr;
150 
151  if (m_scanMonitor)
152  {
154  }
155 }
156 
157 void ChannelScannerGUI::MonitorProgress(bool lock, bool strength,
158  bool snr, bool rotor)
159 {
161 
162  m_scanStage = new ChannelScannerGUIScanPane(lock, strength, snr, rotor, mainStack);
163 
164  if (m_scanStage->Create())
165  {
167 
168  for (const QString& msg : qAsConst(m_messageList))
169  m_scanStage->AppendLine(msg);
170  mainStack->AddScreen(m_scanStage);
171  }
172  else
173  {
174  delete m_scanStage;
175  m_scanStage = nullptr;
176  }
177 }
ChannelScannerGUI::m_messageList
QStringList m_messageList
Definition: channelscanner_gui.h:77
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:315
ScannerEvent::SetPercentComplete
static Type SetPercentComplete
Definition: scanmonitor.h:112
error
static void error(const char *str,...)
Definition: vbi.cpp:36
ChannelScannerGUI::InformUser
void InformUser(const QString &error) override
Definition: channelscanner_gui.cpp:142
channelimporter.h
ScannerEvent::ScanComplete
static Type ScanComplete
Definition: scanmonitor.h:106
ScannerEvent::ScanShutdown
static Type ScanShutdown
Definition: scanmonitor.h:107
ChannelScannerGUI::HandleEvent
void HandleEvent(const ScannerEvent *scanEvent) override
Definition: channelscanner_gui.cpp:62
channelscan_sm.h
mythdialogbox.h
MythScreenStack
Definition: mythscreenstack.h:16
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
ScannerEvent::SetStatusText
static Type SetStatusText
Definition: scanmonitor.h:110
ChannelScanner::m_removeDuplicates
bool m_removeDuplicates
Remove duplicate transports and channels?
Definition: channelscanner.h:153
ChannelImporter::Process
void Process(const ScanDTVTransportList &_transports, int sourceid=-1)
Definition: channelimporter.cpp:54
ChannelScanSM::StopScanner
void StopScanner(void)
Stops the ChannelScanSM event loop and the signal monitor, blocking until both exit.
Definition: channelscan_sm.cpp:2277
kCodeAccepted
static const int kCodeAccepted
Definition: channelscanner_gui.cpp:51
ChannelScannerGUIScanPane::SetStatusSignalStrength
void SetStatusSignalStrength(int value)
Definition: channelscanner_gui_scan_pane.cpp:128
ChannelScannerGUI::Process
virtual void Process(const ScanDTVTransportList &_transports, bool success=false)
Definition: channelscanner_gui.cpp:133
ChannelScanner::m_freeToAirOnly
bool m_freeToAirOnly
Only fta channels desired post scan?
Definition: channelscanner.h:141
ChannelScannerGUI::quitScanning
void quitScanning(void)
Definition: channelscanner_gui.cpp:147
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:125
ChannelScannerGUIScanPane::SetScanProgress
void SetScanProgress(double value)
Definition: channelscanner_gui_scan_pane.cpp:164
ScannerEvent::AppendTextToLog
static Type AppendTextToLog
Definition: scanmonitor.h:109
ChannelScanner::m_sourceid
int m_sourceid
Definition: channelscanner.h:158
ScannerEvent::SetStatusSignalToNoise
static Type SetStatusSignalToNoise
Definition: scanmonitor.h:114
ScannerEvent::intValue
int intValue() const
Definition: scanmonitor.h:97
ChannelScanner::m_fullSearch
bool m_fullSearch
Extended search for old channels post scan?
Definition: channelscanner.h:150
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:157
kCodeRejected
static const int kCodeRejected
Definition: channelscanner_gui.cpp:50
ScannerEvent::SetStatusSignalLock
static Type SetStatusSignalLock
Definition: scanmonitor.h:116
ScanDTVTransportList
std::vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:143
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:144
ChannelScanner::m_iptvScanner
IPTVChannelFetcher * m_iptvScanner
Definition: channelscanner.h:126
ScannerEvent
Definition: scanmonitor.h:86
mpegstreamdata.h
ChannelScanner::m_addFullTS
bool m_addFullTS
Add MPTS "full transport stream" channels.
Definition: channelscanner.h:156
ChannelScanner::m_serviceRequirements
ServiceRequirements m_serviceRequirements
Services desired post scan.
Definition: channelscanner.h:161
ScannerEvent::strValue
QString strValue() const
Definition: scanmonitor.h:94
ChannelScanner::m_scanMonitor
ScanMonitor * m_scanMonitor
Definition: channelscanner.h:121
ChannelScannerGUIScanPane::SetStatusTitleText
void SetStatusTitleText(const QString &value)
Definition: channelscanner_gui_scan_pane.cpp:149
ScannerEvent::SetStatusRotorPosition
static Type SetStatusRotorPosition
Definition: scanmonitor.h:113
ChannelScannerGUIScanPane::Create
bool Create() override
Definition: channelscanner_gui_scan_pane.cpp:38
ChannelImporter
Definition: channelimporter.h:70
ScannerEvent::ScanErrored
static Type ScanErrored
Definition: scanmonitor.h:108
ChannelScannerGUIScanPane
Definition: channelscanner_gui_scan_pane.h:40
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:102
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:1363
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:50
ScannerEvent::SetStatusSignalStrength
static Type SetStatusSignalStrength
Definition: scanmonitor.h:115
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
ScannerEvent::SetStatusTitleText
static Type SetStatusTitleText
Definition: scanmonitor.h:111
ChannelScanner::m_completeOnly
bool m_completeOnly
Only complete channels desired post scan?
Definition: channelscanner.h:147
channelscanner_gui_scan_pane.h