void SpotifyService::EnsureServerCreated(const QString& username, const QString& password) { if (server_ && blob_process_) { return; } delete server_; server_ = new SpotifyServer(this); connect( server_, SIGNAL(LoginCompleted(bool, QString, pb::spotify::LoginResponse_Error)), SLOT(LoginCompleted(bool, QString, pb::spotify::LoginResponse_Error))); connect(server_, SIGNAL(PlaylistsUpdated(pb::spotify::Playlists)), SLOT(PlaylistsUpdated(pb::spotify::Playlists))); connect(server_, SIGNAL(InboxLoaded(pb::spotify::LoadPlaylistResponse)), SLOT(InboxLoaded(pb::spotify::LoadPlaylistResponse))); connect(server_, SIGNAL(StarredLoaded(pb::spotify::LoadPlaylistResponse)), SLOT(StarredLoaded(pb::spotify::LoadPlaylistResponse))); connect(server_, SIGNAL(UserPlaylistLoaded(pb::spotify::LoadPlaylistResponse)), SLOT(UserPlaylistLoaded(pb::spotify::LoadPlaylistResponse))); connect(server_, SIGNAL(PlaybackError(QString)), SIGNAL(StreamError(QString))); connect(server_, SIGNAL(SearchResults(pb::spotify::SearchResponse)), SLOT(SearchResults(pb::spotify::SearchResponse))); connect(server_, SIGNAL(ImageLoaded(QString, QImage)), SIGNAL(ImageLoaded(QString, QImage))); connect(server_, SIGNAL(SyncPlaylistProgress(pb::spotify::SyncPlaylistProgress)), SLOT(SyncPlaylistProgress(pb::spotify::SyncPlaylistProgress))); connect(server_, SIGNAL(ToplistBrowseResults(pb::spotify::BrowseToplistResponse)), SLOT(ToplistLoaded(pb::spotify::BrowseToplistResponse))); server_->Init(); login_task_id_ = app_->task_manager()->StartTask(tr("Connecting to Spotify")); QString login_username = username; QString login_password = password; if (username.isEmpty()) { QSettings s; s.beginGroup(kSettingsGroup); login_username = s.value("username").toString(); login_password = QString(); } server_->Login(login_username, login_password, bitrate_, volume_normalisation_); StartBlobProcess(); }
void SpotifyService::EnsureServerCreated(const QString& username, const QString& password) { if (server_ && blob_process_) { return; } delete server_; server_ = new SpotifyServer(this); connect(server_, SIGNAL(LoginCompleted(bool,QString,spotify_pb::LoginResponse_Error)), SLOT(LoginCompleted(bool,QString,spotify_pb::LoginResponse_Error))); connect(server_, SIGNAL(PlaylistsUpdated(spotify_pb::Playlists)), SLOT(PlaylistsUpdated(spotify_pb::Playlists))); connect(server_, SIGNAL(InboxLoaded(spotify_pb::LoadPlaylistResponse)), SLOT(InboxLoaded(spotify_pb::LoadPlaylistResponse))); connect(server_, SIGNAL(StarredLoaded(spotify_pb::LoadPlaylistResponse)), SLOT(StarredLoaded(spotify_pb::LoadPlaylistResponse))); connect(server_, SIGNAL(UserPlaylistLoaded(spotify_pb::LoadPlaylistResponse)), SLOT(UserPlaylistLoaded(spotify_pb::LoadPlaylistResponse))); connect(server_, SIGNAL(PlaybackError(QString)), SIGNAL(StreamError(QString))); connect(server_, SIGNAL(SearchResults(spotify_pb::SearchResponse)), SLOT(SearchResults(spotify_pb::SearchResponse))); connect(server_, SIGNAL(ImageLoaded(QString,QImage)), SLOT(ImageLoaded(QString,QImage))); connect(server_, SIGNAL(SyncPlaylistProgress(spotify_pb::SyncPlaylistProgress)), SLOT(SyncPlaylistProgress(spotify_pb::SyncPlaylistProgress))); server_->Init(); login_task_id_ = model()->task_manager()->StartTask(tr("Connecting to Spotify")); if (username.isEmpty()) { QSettings s; s.beginGroup(kSettingsGroup); server_->Login(s.value("username").toString(), s.value("password").toString()); } else { server_->Login(username, password); } StartBlobProcess(); }