Validate configuration better
This commit is contained in:
@@ -319,6 +319,16 @@ void SubsonicService::ResetSongsRequest() {
|
||||
|
||||
void SubsonicService::GetSongs() {
|
||||
|
||||
if (!server_url().isValid()) {
|
||||
emit SongsResults(SongList(), tr("Server URL is invalid."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (username().isEmpty() || password().isEmpty()) {
|
||||
emit SongsResults(SongList(), tr("Missing username or password."));
|
||||
return;
|
||||
}
|
||||
|
||||
ResetSongsRequest();
|
||||
songs_request_.reset(new SubsonicRequest(this, url_handler_, network_, this));
|
||||
connect(songs_request_.get(), SIGNAL(Results(const SongList&, const QString&)), SLOT(SongsResultsReceived(const SongList&, const QString&)));
|
||||
|
||||
@@ -31,6 +31,14 @@ SubsonicUrlHandler::SubsonicUrlHandler(Application *app, SubsonicService *servic
|
||||
|
||||
UrlHandler::LoadResult SubsonicUrlHandler::StartLoading(const QUrl &url) {
|
||||
|
||||
if (!server_url().isValid()) {
|
||||
return LoadResult(url, LoadResult::Error, url, Song::FileType_Stream, -1, tr("Subsonic server URL is invalid."));
|
||||
}
|
||||
|
||||
if (username().isEmpty() || password().isEmpty()) {
|
||||
return LoadResult(url, LoadResult::Error, url, Song::FileType_Stream, -1, tr("Missing Subsonic username or password."));
|
||||
}
|
||||
|
||||
ParamList params = ParamList() << Param("c", service_->client_name())
|
||||
<< Param("v", service_->api_version())
|
||||
<< Param("f", "json")
|
||||
|
||||
@@ -42,6 +42,9 @@ class SubsonicUrlHandler : public UrlHandler {
|
||||
|
||||
QString scheme() const { return service_->url_scheme(); }
|
||||
QUrl server_url() const { return service_->server_url(); }
|
||||
QString username() const { return service_->username(); }
|
||||
QString password() const { return service_->password(); }
|
||||
|
||||
LoadResult StartLoading(const QUrl &url);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user