internet: Add common InternetService::ConfigRequired() method.
This will allow some common handling of unconfigured services.
This commit is contained in:
parent
7cb5f5c804
commit
a5e84bbe98
|
@ -83,7 +83,7 @@ QStandardItem* CloudFileService::CreateRootItem() {
|
||||||
void CloudFileService::LazyPopulate(QStandardItem* item) {
|
void CloudFileService::LazyPopulate(QStandardItem* item) {
|
||||||
switch (item->data(InternetModel::Role_Type).toInt()) {
|
switch (item->data(InternetModel::Role_Type).toInt()) {
|
||||||
case InternetModel::Type_Service:
|
case InternetModel::Type_Service:
|
||||||
if (!has_credentials()) {
|
if (ConfigRequired()) {
|
||||||
ShowConfig();
|
ShowConfig();
|
||||||
} else {
|
} else {
|
||||||
Connect();
|
Connect();
|
||||||
|
|
|
@ -49,6 +49,7 @@ class CloudFileService : public InternetService {
|
||||||
virtual bool has_credentials() const = 0;
|
virtual bool has_credentials() const = 0;
|
||||||
bool is_indexing() const { return indexing_task_id_ != -1; }
|
bool is_indexing() const { return indexing_task_id_ != -1; }
|
||||||
|
|
||||||
|
bool ConfigRequired() override { return !has_credentials(); }
|
||||||
signals:
|
signals:
|
||||||
void AllIndexingTasksFinished();
|
void AllIndexingTasksFinished();
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,8 @@ class InternetService : public QObject {
|
||||||
|
|
||||||
virtual QString Icon() { return QString(); }
|
virtual QString Icon() { return QString(); }
|
||||||
|
|
||||||
|
virtual bool ConfigRequired() { return false; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void StreamError(const QString& message);
|
void StreamError(const QString& message);
|
||||||
void StreamMetadataFound(const QUrl& original_url, const Song& song);
|
void StreamMetadataFound(const QUrl& original_url, const Song& song);
|
||||||
|
|
|
@ -126,7 +126,7 @@ void DigitallyImportedServiceBase::RefreshStreamsFinished(QNetworkReply* reply,
|
||||||
void DigitallyImportedServiceBase::PopulateStreams() {
|
void DigitallyImportedServiceBase::PopulateStreams() {
|
||||||
if (root_->hasChildren()) root_->removeRows(0, root_->rowCount());
|
if (root_->hasChildren()) root_->removeRows(0, root_->rowCount());
|
||||||
|
|
||||||
if (!is_premium_account()) {
|
if (ConfigRequired()) {
|
||||||
ShowConfig();
|
ShowConfig();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,8 @@ class DigitallyImportedServiceBase : public InternetService {
|
||||||
void SongFromChannel(const DigitallyImportedClient::Channel& channel,
|
void SongFromChannel(const DigitallyImportedClient::Channel& channel,
|
||||||
Song* song) const;
|
Song* song) const;
|
||||||
|
|
||||||
|
bool ConfigRequired() override { return !is_premium_account(); }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void ShowConfig() override;
|
void ShowConfig() override;
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,8 @@ class SpotifyService : public InternetService {
|
||||||
LoginState login_state() const { return login_state_; }
|
LoginState login_state() const { return login_state_; }
|
||||||
bool IsLoggedIn() const { return login_state_ == LoginState_LoggedIn; }
|
bool IsLoggedIn() const { return login_state_ == LoginState_LoggedIn; }
|
||||||
|
|
||||||
|
bool ConfigRequired() override { return !IsLoggedIn(); }
|
||||||
|
|
||||||
static void SongFromProtobuf(const cpb::spotify::Track& track, Song* song);
|
static void SongFromProtobuf(const cpb::spotify::Track& track, Song* song);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -168,7 +168,7 @@ void SubsonicService::LazyPopulate(QStandardItem* item) {
|
||||||
switch (item->data(InternetModel::Role_Type).toInt()) {
|
switch (item->data(InternetModel::Role_Type).toInt()) {
|
||||||
case InternetModel::Type_Service:
|
case InternetModel::Type_Service:
|
||||||
library_model_->Init();
|
library_model_->Init();
|
||||||
if (login_state() != LoginState_Loggedin) {
|
if (ConfigRequired()) {
|
||||||
ShowConfig();
|
ShowConfig();
|
||||||
} else if (total_song_count_ == 0 && !load_database_task_id_) {
|
} else if (total_song_count_ == 0 && !load_database_task_id_) {
|
||||||
ReloadDatabase();
|
ReloadDatabase();
|
||||||
|
|
|
@ -103,6 +103,10 @@ class SubsonicService : public InternetService {
|
||||||
|
|
||||||
LoginState login_state() const { return login_state_; }
|
LoginState login_state() const { return login_state_; }
|
||||||
|
|
||||||
|
bool ConfigRequired() override {
|
||||||
|
return login_state() != LoginState_Loggedin;
|
||||||
|
}
|
||||||
|
|
||||||
// Subsonic API methods
|
// Subsonic API methods
|
||||||
void Ping();
|
void Ping();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue