|
|
|
@ -56,7 +56,28 @@ bool ReplayStream::loadRoute(const QString &route, const QString &data_dir, uint |
|
|
|
|
QObject::connect(replay.get(), &Replay::seeking, this, &AbstractStream::seeking); |
|
|
|
|
QObject::connect(replay.get(), &Replay::seekedTo, this, &AbstractStream::seekedTo); |
|
|
|
|
QObject::connect(replay.get(), &Replay::segmentsMerged, this, &ReplayStream::mergeSegments); |
|
|
|
|
return replay->load(); |
|
|
|
|
bool success = replay->load(); |
|
|
|
|
if (!success) { |
|
|
|
|
if (replay->lastRouteError() == RouteLoadError::AccessDenied) { |
|
|
|
|
auto auth_content = util::read_file(util::getenv("HOME") + "/.comma/auth.json"); |
|
|
|
|
QString message; |
|
|
|
|
if (auth_content.empty()) { |
|
|
|
|
message = "Authentication Required. Please run the following command to authenticate:\n\n" |
|
|
|
|
"python tools/lib/auth.py\n\n" |
|
|
|
|
"This will grant access to routes from your comma account."; |
|
|
|
|
} else { |
|
|
|
|
message = tr("Access Denied. You do not have permission to access route:\n\n%1\n\n" |
|
|
|
|
"This is likely a private route.").arg(route); |
|
|
|
|
} |
|
|
|
|
QMessageBox::warning(nullptr, tr("Access Denied"), message); |
|
|
|
|
} else if (replay->lastRouteError() == RouteLoadError::NetworkError) { |
|
|
|
|
QMessageBox::warning(nullptr, tr("Network Error"), |
|
|
|
|
tr("Unable to load the route:\n\n %1.\n\nPlease check your network connection and try again.").arg(route)); |
|
|
|
|
} else { |
|
|
|
|
QMessageBox::warning(nullptr, tr("Route Load Failed"), tr("Failed to load route: '%1'").arg(route)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return success; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ReplayStream::start() { |
|
|
|
@ -144,7 +165,7 @@ OpenReplayWidget::OpenReplayWidget(AbstractStream **stream) : AbstractOpenStream |
|
|
|
|
bool OpenReplayWidget::open() { |
|
|
|
|
QString route = route_edit->text(); |
|
|
|
|
QString data_dir; |
|
|
|
|
if (int idx = route.lastIndexOf('/'); idx != -1) { |
|
|
|
|
if (int idx = route.lastIndexOf('/'); idx != -1 && util::file_exists(route.toStdString())) { |
|
|
|
|
data_dir = route.mid(0, idx + 1); |
|
|
|
|
route = route.mid(idx + 1); |
|
|
|
|
} |
|
|
|
@ -161,8 +182,6 @@ bool OpenReplayWidget::open() { |
|
|
|
|
|
|
|
|
|
if (replay_stream->loadRoute(route, data_dir, flags)) { |
|
|
|
|
*stream = replay_stream.release(); |
|
|
|
|
} else { |
|
|
|
|
QMessageBox::warning(nullptr, tr("Warning"), tr("Failed to load route: '%1'").arg(route)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return *stream != nullptr; |
|
|
|
|