diff --git a/src/internet/groovesharkservice.cpp b/src/internet/groovesharkservice.cpp index 5c297d00b..16224e6ee 100644 --- a/src/internet/groovesharkservice.cpp +++ b/src/internet/groovesharkservice.cpp @@ -431,6 +431,7 @@ void GroovesharkService::EnsureItemsCreated() { search_->setData(InternetModel::PlayBehaviour_DoubleClickAction, InternetModel::Role_PlayBehaviour); root_->appendRow(search_); + RetrieveUserFavorites(); RetrieveUserPlaylists(); } } @@ -506,6 +507,39 @@ void GroovesharkService::PlaylistSongsRetrieved() { root_->appendRow(item); } +void GroovesharkService::RetrieveUserFavorites() { + QNetworkReply* reply = CreateRequest("getUserFavoriteSongs", QList(), true); + + connect(reply, SIGNAL(finished()), SLOT(UserFavoritesRetrieved())); +} + +void GroovesharkService::UserFavoritesRetrieved() { + QNetworkReply* reply = qobject_cast(sender()); + if (!reply) + return; + + reply->deleteLater(); + + // Create item + QStandardItem* item = new QStandardItem(QIcon(":/star-on.png"), tr("Favorites")); + item->setData(InternetModel::Type_UserPlaylist, InternetModel::Role_Type); + item->setData(true, InternetModel::Role_CanLazyLoad); + item->setData(InternetModel::PlayBehaviour_SingleItem, InternetModel::Role_PlayBehaviour); + + QVariantMap result = ExtractResult(reply); + SongList songs = ExtractSongs(result); + foreach (const Song& song, songs) { + QStandardItem* child = new QStandardItem(song.PrettyTitleWithArtist()); + child->setData(Type_Track, InternetModel::Role_Type); + child->setData(QVariant::fromValue(song), InternetModel::Role_SongMetadata); + child->setData(InternetModel::PlayBehaviour_SingleItem, InternetModel::Role_PlayBehaviour); + child->setData(song.url(), InternetModel::Role_Url); + + item->appendRow(child); + } + root_->appendRow(item); +} + void GroovesharkService::MarkStreamKeyOver30Secs(const QString& stream_key, const QString& server_id) { QList parameters; diff --git a/src/internet/groovesharkservice.h b/src/internet/groovesharkservice.h index 0389daccd..48089dbd6 100644 --- a/src/internet/groovesharkservice.h +++ b/src/internet/groovesharkservice.h @@ -63,6 +63,7 @@ class GroovesharkService : public InternetService { void Logout(); bool IsLoggedIn() const { return !session_id_.isEmpty(); } void RetrieveUserPlaylists(); + void RetrieveUserFavorites(); void MarkStreamKeyOver30Secs(const QString& stream_key, const QString& server_id); void MarkSongComplete(const QString& song_id, const QString& stream_key, const QString& server_id); @@ -119,6 +120,7 @@ class GroovesharkService : public InternetService { void GetAlbumSongsFinished(QNetworkReply* reply, int id); void Authenticated(); void UserPlaylistsRetrieved(); + void UserFavoritesRetrieved(); void PlaylistSongsRetrieved(); void StreamMarked(); void SongMarkedAsComplete();