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 using namespace std;
36 
37 // MythTV headers
38 #include <mythdialogs.h>
39 #include "mythdialogbox.h"
40 #include "channelscanner_gui.h"
42 #include "channelimporter.h"
43 #include "channelscan_sm.h"
44 
45 #include "channelbase.h"
46 #include "dtvsignalmonitor.h"
47 #include "dvbsignalmonitor.h"
48 #include "mpegstreamdata.h"
49 
50 #define LOC QString("ChScanGUI: ")
51 
53  : m_scanStage(nullptr)
54 {
55 }
56 
58 {
59  Teardown();
60  if (scanMonitor)
61  {
64  }
65 }
66 
68 {
69  if (scanEvent->type() == ScannerEvent::ScanComplete)
70  {
71  if (m_scanStage)
73 
74  InformUser(tr("Scan complete"));
75 
76  // HACK: make channel insertion work after [21644]
79  }
80  else if (scanEvent->type() == ScannerEvent::ScanShutdown ||
81  scanEvent->type() == ScannerEvent::ScanErrored)
82  {
83  ScanDTVTransportList transports;
84  if (sigmonScanner)
85  {
87  transports = sigmonScanner->GetChannelList(addFullTS);
88  }
89 
90  bool success = (iptvScanner != nullptr);
91 #ifdef USING_VBOX
92  success |= (vboxScanner != nullptr);
93 #endif
94 #if !defined( USING_MINGW ) && !defined( _MSC_VER )
95  success |= (m_ExternRecScanner != nullptr);
96 #endif
97 
98  Teardown();
99 
100  if (scanEvent->type() == ScannerEvent::ScanErrored)
101  {
102  QString error = scanEvent->strValue();
103  InformUser(error);
104  return;
105  }
106  else
107  {
108  int ret = scanEvent->intValue();
109  if (!transports.empty() || (MythDialog::Rejected != ret))
110  {
111  Process(transports, success);
112  }
113  }
114  }
115  else if (scanEvent->type() == ScannerEvent::AppendTextToLog)
116  {
117  if (m_scanStage)
118  m_scanStage->AppendLine(scanEvent->strValue());
119  m_messageList += scanEvent->strValue();
120  }
121 
122  if (!m_scanStage)
123  return;
124 
125  if (scanEvent->type() == ScannerEvent::SetStatusText)
126  m_scanStage->SetStatusText(scanEvent->strValue());
127  else if (scanEvent->type() == ScannerEvent::SetStatusTitleText)
128  m_scanStage->SetStatusTitleText(scanEvent->strValue());
129  else if (scanEvent->type() == ScannerEvent::SetPercentComplete)
130  m_scanStage->SetScanProgress(scanEvent->intValue() * 0.01);
131  else if (scanEvent->type() == ScannerEvent::SetStatusRotorPosition)
133  else if (scanEvent->type() == ScannerEvent::SetStatusSignalLock)
134  m_scanStage->SetStatusLock(scanEvent->intValue());
135  else if (scanEvent->type() == ScannerEvent::SetStatusSignalToNoise)
137  else if (scanEvent->type() == ScannerEvent::SetStatusSignalStrength)
139 }
140 
142  bool success)
143 {
144  ChannelImporter ci(true, true, true, true, true,
146  ci.Process(_transports, m_sourceid);
147 }
148 
150 {
152 }
153 
155 {
156  m_scanStage = nullptr;
157 
158  if (scanMonitor)
159  {
162  }
163 }
164 
165 void ChannelScannerGUI::MonitorProgress(bool lock, bool strength,
166  bool snr, bool rotor)
167 {
169 
170  m_scanStage = new ChannelScannerGUIScanPane(lock, strength, snr, rotor, mainStack);
171 
172  if (m_scanStage->Create())
173  {
174  connect(m_scanStage, SIGNAL(Exiting()), SLOT(quitScanning()));
175 
176  for (uint i = 0; i < (uint) m_messageList.size(); ++i)
178  mainStack->AddScreen(m_scanStage);
179  }
180  else
181  {
182  delete m_scanStage;
183  m_scanStage = nullptr;
184  }
185 }
static Type SetStatusText
Definition: scanmonitor.h:109
void SetStatusText(const QString &value)
static Type SetStatusSignalStrength
Definition: scanmonitor.h:114
void HandleEvent(const ScannerEvent *scanEvent) override
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
static void error(const char *str,...)
Definition: vbi.c:41
virtual void Teardown(void)
static Type SetStatusTitleText
Definition: scanmonitor.h:110
vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:132
void SetStatusTitleText(const QString &value)
ScanMonitor * scanMonitor
static Type AppendTextToLog
Definition: scanmonitor.h:108
static Type SetPercentComplete
Definition: scanmonitor.h:111
unsigned int uint
Definition: compat.h:140
MythScreenStack * GetMainStack()
ChannelScannerGUIScanPane * m_scanStage
static Type ScanComplete
Definition: scanmonitor.h:105
static Type ScanShutdown
Definition: scanmonitor.h:106
chan_info_map_t GetChannelList(transport_scan_items_it_t trans_info, ScannedChannelInfo *scan_info) const
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
QString strValue() const
Definition: scanmonitor.h:95
ChannelScanSM * sigmonScanner
static Type SetStatusRotorPosition
Definition: scanmonitor.h:112
bool freeToAirOnly
Only fta channels desired post scan?
static Type ScanErrored
Definition: scanmonitor.h:107
MythMainWindow * GetMythMainWindow(void)
static Type SetStatusSignalToNoise
Definition: scanmonitor.h:113
int intValue() const
Definition: scanmonitor.h:98
void MonitorProgress(bool lock, bool strength, bool snr, bool rotor) override
bool addFullTS
Add MPTS "full transport stream" channels.
IPTVChannelFetcher * iptvScanner
static Type SetStatusSignalLock
Definition: scanmonitor.h:115
void StopScanner(void)
Stops the ChannelScanSM event loop and the signal monitor, blocking until both exit.
virtual void Process(const ScanDTVTransportList &, bool success=false)
QStringList m_messageList
void post_event(QObject *dest, QEvent::Type type, int val)
Definition: scanmonitor.cpp:68
ServiceRequirements serviceRequirements
Services desired post scan.
void InformUser(const QString &error) override
void Process(const ScanDTVTransportList &, int sourceid=-1)
static const DialogCode Rejected
Definition: mythdialogs.h:59