From 90c9aa79ed3d19acce88f0f5fdedf9ee19d585ea Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Sat, 20 Jul 2013 01:21:19 +1000 Subject: [PATCH] Show the user an error if downloading an IPTV playlist failed 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) --- .../libmythtv/channelscan/channelimporter.h | 4 ++-- .../channelscan/channelscanner_cli.cpp | 10 ++++++++-- .../channelscan/channelscanner_gui.cpp | 18 ++++++++++++++---- .../channelscan/iptvchannelfetcher.cpp | 8 +++++++- .../libs/libmythtv/channelscan/scanmonitor.cpp | 7 +++++++ .../libs/libmythtv/channelscan/scanmonitor.h | 2 ++ 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/mythtv/libs/libmythtv/channelscan/channelimporter.h b/mythtv/libs/libmythtv/channelscan/channelimporter.h index c9d77d79fe1..49fda8bffb2 100644 --- a/mythtv/libs/libmythtv/channelscan/channelimporter.h +++ b/mythtv/libs/libmythtv/channelscan/channelimporter.h @@ -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&); diff --git a/mythtv/libs/libmythtv/channelscan/channelscanner_cli.cpp b/mythtv/libs/libmythtv/channelscan/channelscanner_cli.cpp index c4210dc74d3..fef06c5fd0e 100644 --- a/mythtv/libs/libmythtv/channelscan/channelscanner_cli.cpp +++ b/mythtv/libs/libmythtv/channelscan/channelscanner_cli.cpp @@ -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<type() == ScannerEvent::ScanErrored) + { + QString error = scanEvent->strValue(); + InformUser(error); + } + else if (sigmonScanner && !transports.empty()) Process(transports); done = true; diff --git a/mythtv/libs/libmythtv/channelscan/channelscanner_gui.cpp b/mythtv/libs/libmythtv/channelscan/channelscanner_gui.cpp index 750f160aec4..3465cbfcd01 100644 --- a/mythtv/libs/libmythtv/channelscan/channelscanner_gui.cpp +++ b/mythtv/libs/libmythtv/channelscan/channelscanner_gui.cpp @@ -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()) { @@ -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) diff --git a/mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp b/mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp index c29ba6b94a0..3480b40f4d9 100644 --- a/mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp +++ b/mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp @@ -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; @@ -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) diff --git a/mythtv/libs/libmythtv/channelscan/scanmonitor.cpp b/mythtv/libs/libmythtv/channelscan/scanmonitor.cpp index a15b74486cd..c50d56c7c80 100644 --- a/mythtv/libs/libmythtv/channelscan/scanmonitor.cpp +++ b/mythtv/libs/libmythtv/channelscan/scanmonitor.cpp @@ -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 = @@ -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, diff --git a/mythtv/libs/libmythtv/channelscan/scanmonitor.h b/mythtv/libs/libmythtv/channelscan/scanmonitor.h index 076658a413e..b4a535be76f 100644 --- a/mythtv/libs/libmythtv/channelscan/scanmonitor.h +++ b/mythtv/libs/libmythtv/channelscan/scanmonitor.h @@ -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) { } @@ -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;