Skip to content

Commit

Permalink
Show the user an error if downloading an IPTV playlist failed
Browse files Browse the repository at this point in the history
Any error would have silently discarded, only showing up in the log. So add a way to propagate the error and show a popup (to keep in the style of mythtv-setup)
  • Loading branch information
jyavenard committed Jul 19, 2013
1 parent dd919dc commit 90c9aa7
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/channelscan/channelimporter.h
Expand Up @@ -83,8 +83,8 @@ class MTV_PUBLIC ChannelImporter
use_gui(gui), is_interactive(interactive),
do_delete(_delete),
do_insert(insert), do_save(save), m_fta_only(fta_only),
m_service_requirements(service_requirements),
m_success(success) { }
m_success(success),
m_service_requirements(service_requirements) { }

void Process(const ScanDTVTransportList&);

Expand Down
10 changes: 8 additions & 2 deletions mythtv/libs/libmythtv/channelscan/channelscanner_cli.cpp
Expand Up @@ -50,7 +50,8 @@ ChannelScannerCLI::~ChannelScannerCLI()
void ChannelScannerCLI::HandleEvent(const ScannerEvent *scanEvent)
{
if ((scanEvent->type() == ScannerEvent::ScanComplete) ||
(scanEvent->type() == ScannerEvent::ScanShutdown))
(scanEvent->type() == ScannerEvent::ScanShutdown) ||
(scanEvent->type() == ScannerEvent::ScanErrored))
{
cout<<endl;

Expand All @@ -68,7 +69,12 @@ void ChannelScannerCLI::HandleEvent(const ScannerEvent *scanEvent)

Teardown();

if (sigmonScanner && !transports.empty())
if (scanEvent->type() == ScannerEvent::ScanErrored)
{
QString error = scanEvent->strValue();
InformUser(error);
}
else if (sigmonScanner && !transports.empty())
Process(transports);

done = true;
Expand Down
18 changes: 14 additions & 4 deletions mythtv/libs/libmythtv/channelscan/channelscanner_gui.cpp
Expand Up @@ -97,7 +97,8 @@ void ChannelScannerGUI::HandleEvent(const ScannerEvent *scanEvent)
post_event(scanMonitor, ScannerEvent::ScanShutdown,
kDialogCodeAccepted);
}
else if (scanEvent->type() == ScannerEvent::ScanShutdown)
else if (scanEvent->type() == ScannerEvent::ScanShutdown ||
scanEvent->type() == ScannerEvent::ScanErrored)
{
if (scanEvent->ConfigurableValue())
{
Expand All @@ -115,10 +116,19 @@ void ChannelScannerGUI::HandleEvent(const ScannerEvent *scanEvent)
bool wasIPTV = iptvScanner != NULL;
Teardown();

int ret = scanEvent->intValue();
if (!transports.empty() || (MythDialog::Rejected != ret))
if (scanEvent->type() == ScannerEvent::ScanErrored)
{
Process(transports, wasIPTV);
QString error = scanEvent->strValue();
InformUser(error);
return;
}
else
{
int ret = scanEvent->intValue();
if (!transports.empty() || (MythDialog::Rejected != ret))
{
Process(transports, wasIPTV);
}
}
}
else if (scanEvent->type() == ScannerEvent::AppendTextToLog)
Expand Down
8 changes: 7 additions & 1 deletion mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp
Expand Up @@ -105,6 +105,12 @@ void IPTVChannelFetcher::run(void)

if (_stop_now || playlist.isEmpty())
{
if (playlist.isNull() && _scan_monitor)
{
_scan_monitor->ScanAppendTextToLog(QObject::tr("Error"));
_scan_monitor->ScanPercentComplete(100);
_scan_monitor->ScanErrored(QObject::tr("Downloading Playlist Failed"));
}
_thread_running = false;
_stop_now = true;
return;
Expand Down Expand Up @@ -240,7 +246,7 @@ QString IPTVChannelFetcher::DownloadPlaylist(const QString &url,
else
tmp = QString(data);

return QString::fromUtf8(tmp.toLatin1().constData());
return tmp.isNull() ? tmp : QString::fromUtf8(tmp.toLatin1().constData());
}

static uint estimate_number_of_channels(const QString &rawdata)
Expand Down
7 changes: 7 additions & 0 deletions mythtv/libs/libmythtv/channelscan/scanmonitor.cpp
Expand Up @@ -39,6 +39,8 @@ QEvent::Type ScannerEvent::ScanComplete =
(QEvent::Type) QEvent::registerEventType();
QEvent::Type ScannerEvent::ScanShutdown =
(QEvent::Type) QEvent::registerEventType();
QEvent::Type ScannerEvent::ScanErrored =
(QEvent::Type) QEvent::registerEventType();
QEvent::Type ScannerEvent::AppendTextToLog =
(QEvent::Type) QEvent::registerEventType();
QEvent::Type ScannerEvent::SetStatusText =
Expand Down Expand Up @@ -124,6 +126,11 @@ void ScanMonitor::ScanUpdateStatusTitleText(const QString &str)
post_event(this, ScannerEvent::SetStatusTitleText, str);
}

void ScanMonitor::ScanErrored(const QString &error)
{
post_event(this, ScannerEvent::ScanErrored, error);
}

void ScanMonitor::StatusRotorPosition(const SignalMonitorValue &val)
{
post_event(this, ScannerEvent::SetStatusRotorPosition,
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/channelscan/scanmonitor.h
Expand Up @@ -61,6 +61,7 @@ class ScanMonitor :
void ScanUpdateStatusTitleText(const QString &status);
void ScanAppendTextToLog(const QString &status);
void ScanComplete(void);
void ScanErrored(const QString &error);

// SignalMonitorListener
virtual void AllGood(void) { }
Expand Down Expand Up @@ -103,6 +104,7 @@ class ScannerEvent : public QEvent

static Type ScanComplete;
static Type ScanShutdown;
static Type ScanErrored;
static Type AppendTextToLog;
static Type SetStatusText;
static Type SetStatusTitleText;
Expand Down

0 comments on commit 90c9aa7

Please sign in to comment.