Permalink
Browse files

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)
  • Loading branch information...
jyavenard committed Jul 19, 2013
1 parent dd919dc commit 90c9aa79ed3d19acce88f0f5fdedf9ee19d585ea
@@ -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&);
@@ -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;
@@ -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;
@@ -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)
@@ -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)
@@ -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,
@@ -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;

0 comments on commit 90c9aa7

Please sign in to comment.