Use pb::spotify instead of spotify_pb for the protobuf namespace

This commit is contained in:
David Sansome 2012-01-07 23:26:27 +00:00
parent ccb3a0aa3a
commit 68a379ef26
14 changed files with 207 additions and 204 deletions

View File

@ -91,8 +91,8 @@ SpotifyClient::SpotifyClient(QObject* parent)
events_timer_->setSingleShot(true);
connect(events_timer_, SIGNAL(timeout()), SLOT(ProcessEvents()));
connect(handler_, SIGNAL(MessageArrived(spotify_pb::SpotifyMessage)),
SLOT(HandleMessage(spotify_pb::SpotifyMessage)));
connect(handler_, SIGNAL(MessageArrived(pb::spotify::SpotifyMessage)),
SLOT(HandleMessage(pb::spotify::SpotifyMessage)));
connect(protocol_socket_, SIGNAL(disconnected()),
QCoreApplication::instance(), SLOT(quit()));
}
@ -115,7 +115,7 @@ void SpotifyClient::Init(quint16 port) {
void SpotifyClient::LoggedInCallback(sp_session* session, sp_error error) {
SpotifyClient* me = reinterpret_cast<SpotifyClient*>(sp_session_userdata(session));
const bool success = error == SP_ERROR_OK;
spotify_pb::LoginResponse_Error error_code = spotify_pb::LoginResponse_Error_Other;
pb::spotify::LoginResponse_Error error_code = pb::spotify::LoginResponse_Error_Other;
if (!success) {
qLog(Warning) << "Failed to login" << sp_error_message(error);
@ -123,16 +123,16 @@ void SpotifyClient::LoggedInCallback(sp_session* session, sp_error error) {
switch (error) {
case SP_ERROR_BAD_USERNAME_OR_PASSWORD:
error_code = spotify_pb::LoginResponse_Error_BadUsernameOrPassword;
error_code = pb::spotify::LoginResponse_Error_BadUsernameOrPassword;
break;
case SP_ERROR_USER_BANNED:
error_code = spotify_pb::LoginResponse_Error_UserBanned;
error_code = pb::spotify::LoginResponse_Error_UserBanned;
break;
case SP_ERROR_USER_NEEDS_PREMIUM :
error_code = spotify_pb::LoginResponse_Error_UserNeedsPremium;
error_code = pb::spotify::LoginResponse_Error_UserNeedsPremium;
break;
default:
error_code = spotify_pb::LoginResponse_Error_Other;
error_code = pb::spotify::LoginResponse_Error_Other;
break;
}
@ -160,7 +160,7 @@ void SpotifyClient::LogMessageCallback(sp_session* session, const char* data) {
qLog(Debug) << "libspotify:" << QString::fromUtf8(data).trimmed();
}
void SpotifyClient::Search(const spotify_pb::SearchRequest& req) {
void SpotifyClient::Search(const pb::spotify::SearchRequest& req) {
sp_search* search = sp_search_create(
session_, req.query().c_str(),
0, req.limit(),
@ -214,11 +214,11 @@ void SpotifyClient::SearchAlbumBrowseComplete(sp_albumbrowse* result, void* user
void SpotifyClient::SendSearchResponse(sp_search* result) {
// Take the request out of the queue
spotify_pb::SearchRequest req = pending_searches_.take(result);
pb::spotify::SearchRequest req = pending_searches_.take(result);
// Prepare the response
spotify_pb::SpotifyMessage message;
spotify_pb::SearchResponse* response = message.mutable_search_response();
pb::spotify::SpotifyMessage message;
pb::spotify::SearchResponse* response = message.mutable_search_response();
*response->mutable_request() = req;
@ -243,7 +243,7 @@ void SpotifyClient::SendSearchResponse(sp_search* result) {
QList<sp_albumbrowse*> browses = pending_search_album_browses_.take(result);
foreach (sp_albumbrowse* browse, browses) {
sp_album* album = sp_albumbrowse_album(browse);
spotify_pb::Album* msg = response->add_album();
pb::spotify::Album* msg = response->add_album();
ConvertAlbum(album, msg->mutable_metadata());
ConvertAlbumBrowse(browse, msg->mutable_metadata());
@ -265,7 +265,7 @@ void SpotifyClient::SendSearchResponse(sp_search* result) {
sp_search_release(result);
}
void SpotifyClient::HandleMessage(const spotify_pb::SpotifyMessage& message) {
void SpotifyClient::HandleMessage(const pb::spotify::SpotifyMessage& message) {
if (message.has_login_request()) {
Login(message.login_request());
} else if (message.has_load_playlist_request()) {
@ -287,12 +287,12 @@ void SpotifyClient::HandleMessage(const spotify_pb::SpotifyMessage& message) {
}
}
void SpotifyClient::SetPlaybackSettings(const spotify_pb::PlaybackSettings& req) {
void SpotifyClient::SetPlaybackSettings(const pb::spotify::PlaybackSettings& req) {
sp_bitrate bitrate = SP_BITRATE_320k;
switch (req.bitrate()) {
case spotify_pb::Bitrate96k: bitrate = SP_BITRATE_96k; break;
case spotify_pb::Bitrate160k: bitrate = SP_BITRATE_160k; break;
case spotify_pb::Bitrate320k: bitrate = SP_BITRATE_320k; break;
case pb::spotify::Bitrate96k: bitrate = SP_BITRATE_96k; break;
case pb::spotify::Bitrate160k: bitrate = SP_BITRATE_160k; break;
case pb::spotify::Bitrate320k: bitrate = SP_BITRATE_320k; break;
}
qLog(Debug) << "Setting playback settings: bitrate"
@ -303,11 +303,11 @@ void SpotifyClient::SetPlaybackSettings(const spotify_pb::PlaybackSettings& req)
sp_session_set_volume_normalization(session_, req.volume_normalisation());
}
void SpotifyClient::Login(const spotify_pb::LoginRequest& req) {
void SpotifyClient::Login(const pb::spotify::LoginRequest& req) {
sp_error error = sp_session_create(&spotify_config_, &session_);
if (error != SP_ERROR_OK) {
qLog(Warning) << "Failed to create session" << sp_error_message(error);
SendLoginCompleted(false, sp_error_message(error), spotify_pb::LoginResponse_Error_Other);
SendLoginCompleted(false, sp_error_message(error), pb::spotify::LoginResponse_Error_Other);
return;
}
@ -318,7 +318,7 @@ void SpotifyClient::Login(const spotify_pb::LoginRequest& req) {
if (error != SP_ERROR_OK) {
qLog(Warning) << "Tried to relogin but no stored credentials";
SendLoginCompleted(false, sp_error_message(error),
spotify_pb::LoginResponse_Error_ReloginFailed);
pb::spotify::LoginResponse_Error_ReloginFailed);
}
} else {
sp_session_login(session_,
@ -329,10 +329,10 @@ void SpotifyClient::Login(const spotify_pb::LoginRequest& req) {
}
void SpotifyClient::SendLoginCompleted(bool success, const QString& error,
spotify_pb::LoginResponse_Error error_code) {
spotify_pb::SpotifyMessage message;
pb::spotify::LoginResponse_Error error_code) {
pb::spotify::SpotifyMessage message;
spotify_pb::LoginResponse* response = message.mutable_login_response();
pb::spotify::LoginResponse* response = message.mutable_login_response();
response->set_success(success);
response->set_error(DataCommaSizeFromQString(error));
@ -380,8 +380,8 @@ void SpotifyClient::PlaylistRemovedCallback(sp_playlistcontainer* pc, sp_playlis
}
void SpotifyClient::SendPlaylistList() {
spotify_pb::SpotifyMessage message;
spotify_pb::Playlists* response = message.mutable_playlists_updated();
pb::spotify::SpotifyMessage message;
pb::spotify::Playlists* response = message.mutable_playlists_updated();
sp_playlistcontainer* container = sp_session_playlistcontainer(session_);
if (!container) {
@ -408,7 +408,7 @@ void SpotifyClient::SendPlaylistList() {
continue;
}
spotify_pb::Playlists::Playlist* msg = response->add_playlist();
pb::spotify::Playlists::Playlist* msg = response->add_playlist();
msg->set_index(i);
msg->set_name(sp_playlist_name(playlist));
@ -427,18 +427,18 @@ void SpotifyClient::SendPlaylistList() {
handler_->SendMessage(message);
}
sp_playlist* SpotifyClient::GetPlaylist(spotify_pb::PlaylistType type, int user_index) {
sp_playlist* SpotifyClient::GetPlaylist(pb::spotify::PlaylistType type, int user_index) {
sp_playlist* playlist = NULL;
switch (type) {
case spotify_pb::Inbox:
case pb::spotify::Inbox:
playlist = sp_session_inbox_create(session_);
break;
case spotify_pb::Starred:
case pb::spotify::Starred:
playlist = sp_session_starred_create(session_);
break;
case spotify_pb::UserPlaylist: {
case pb::spotify::UserPlaylist: {
sp_playlistcontainer* pc = sp_session_playlistcontainer(session_);
if (pc && user_index <= sp_playlistcontainer_num_playlists(pc)) {
@ -454,7 +454,7 @@ sp_playlist* SpotifyClient::GetPlaylist(spotify_pb::PlaylistType type, int user_
return playlist;
}
void SpotifyClient::LoadPlaylist(const spotify_pb::LoadPlaylistRequest& req) {
void SpotifyClient::LoadPlaylist(const pb::spotify::LoadPlaylistRequest& req) {
PendingLoadPlaylist pending_load;
pending_load.request_ = req;
pending_load.playlist_ = GetPlaylist(req.type(), req.user_playlist_index());
@ -464,8 +464,8 @@ void SpotifyClient::LoadPlaylist(const spotify_pb::LoadPlaylistRequest& req) {
if (!pending_load.playlist_) {
qLog(Warning) << "Invalid playlist requested or not logged in";
spotify_pb::SpotifyMessage message;
spotify_pb::LoadPlaylistResponse* response = message.mutable_load_playlist_response();
pb::spotify::SpotifyMessage message;
pb::spotify::LoadPlaylistResponse* response = message.mutable_load_playlist_response();
*response->mutable_request() = req;
handler_->SendMessage(message);
return;
@ -477,7 +477,7 @@ void SpotifyClient::LoadPlaylist(const spotify_pb::LoadPlaylistRequest& req) {
PlaylistStateChangedForLoadPlaylist(pending_load.playlist_, this);
}
void SpotifyClient::SyncPlaylist(const spotify_pb::SyncPlaylistRequest& req) {
void SpotifyClient::SyncPlaylist(const pb::spotify::SyncPlaylistRequest& req) {
sp_playlist* playlist = GetPlaylist(req.request().type(), req.request().user_playlist_index());
// The playlist should already be loaded.
@ -528,12 +528,12 @@ void SpotifyClient::PlaylistStateChangedForLoadPlaylist(sp_playlist* pl, void* u
}
// Everything is loaded so send the response protobuf and unref everything.
spotify_pb::SpotifyMessage message;
spotify_pb::LoadPlaylistResponse* response = message.mutable_load_playlist_response();
pb::spotify::SpotifyMessage message;
pb::spotify::LoadPlaylistResponse* response = message.mutable_load_playlist_response();
// For some reason, we receive the starred tracks in reverse order but not
// other playlists.
if (pending_load->request_.type() == spotify_pb::Starred) {
if (pending_load->request_.type() == pb::spotify::Starred) {
std::reverse(pending_load->tracks_.begin(),
pending_load->tracks_.end());
}
@ -559,7 +559,7 @@ void SpotifyClient::PlaylistStateChangedForGetPlaylists(sp_playlist* pl, void* u
me->SendPlaylistList();
}
void SpotifyClient::ConvertTrack(sp_track* track, spotify_pb::Track* pb) {
void SpotifyClient::ConvertTrack(sp_track* track, pb::spotify::Track* pb) {
sp_album* album = sp_track_album(track);
pb->set_starred(sp_track_is_starred(session_, track));
@ -592,7 +592,7 @@ void SpotifyClient::ConvertTrack(sp_track* track, spotify_pb::Track* pb) {
pb->set_uri(uri);
}
void SpotifyClient::ConvertAlbum(sp_album* album, spotify_pb::Track* pb) {
void SpotifyClient::ConvertAlbum(sp_album* album, pb::spotify::Track* pb) {
pb->set_album(sp_album_name(album));
pb->set_year(sp_album_year(album));
pb->add_artist(sp_artist_name(sp_album_artist(album)));
@ -622,7 +622,7 @@ void SpotifyClient::ConvertAlbum(sp_album* album, spotify_pb::Track* pb) {
pb->set_uri(uri);
}
void SpotifyClient::ConvertAlbumBrowse(sp_albumbrowse* browse, spotify_pb::Track* pb) {
void SpotifyClient::ConvertAlbumBrowse(sp_albumbrowse* browse, pb::spotify::Track* pb) {
pb->set_track(sp_albumbrowse_num_tracks(browse));
}
@ -722,7 +722,7 @@ void SpotifyClient::OfflineStatusUpdatedCallback(sp_session* session) {
int download_progress = me->GetDownloadProgress(playlist);
if (download_progress != -1) {
me->SendDownloadProgress(spotify_pb::UserPlaylist, i, download_progress);
me->SendDownloadProgress(pb::spotify::UserPlaylist, i, download_progress);
}
}
@ -731,7 +731,7 @@ void SpotifyClient::OfflineStatusUpdatedCallback(sp_session* session) {
sp_playlist_release(inbox);
if (download_progress != -1) {
me->SendDownloadProgress(spotify_pb::Inbox, -1, download_progress);
me->SendDownloadProgress(pb::spotify::Inbox, -1, download_progress);
}
sp_playlist* starred = sp_session_starred_create(session);
@ -739,14 +739,14 @@ void SpotifyClient::OfflineStatusUpdatedCallback(sp_session* session) {
sp_playlist_release(starred);
if (download_progress != -1) {
me->SendDownloadProgress(spotify_pb::Starred, -1, download_progress);
me->SendDownloadProgress(pb::spotify::Starred, -1, download_progress);
}
}
void SpotifyClient::SendDownloadProgress(
spotify_pb::PlaylistType type, int index, int download_progress) {
spotify_pb::SpotifyMessage message;
spotify_pb::SyncPlaylistProgress* progress = message.mutable_sync_playlist_progress();
pb::spotify::PlaylistType type, int index, int download_progress) {
pb::spotify::SpotifyMessage message;
pb::spotify::SyncPlaylistProgress* progress = message.mutable_sync_playlist_progress();
progress->mutable_request()->set_type(type);
if (index != -1) {
progress->mutable_request()->set_user_playlist_index(index);
@ -771,7 +771,7 @@ int SpotifyClient::GetDownloadProgress(sp_playlist* playlist) {
return -1;
}
void SpotifyClient::StartPlayback(const spotify_pb::PlaybackRequest& req) {
void SpotifyClient::StartPlayback(const pb::spotify::PlaybackRequest& req) {
// Get a link object from the URI
sp_link* link = sp_link_create_from_string(req.track_uri().c_str());
if (!link) {
@ -835,8 +835,8 @@ void SpotifyClient::TryPlaybackAgain(const PendingPlaybackRequest& req) {
}
void SpotifyClient::SendPlaybackError(const QString& error) {
spotify_pb::SpotifyMessage message;
spotify_pb::PlaybackError* msg = message.mutable_playback_error();
pb::spotify::SpotifyMessage message;
pb::spotify::PlaybackError* msg = message.mutable_playback_error();
msg->set_error(DataCommaSizeFromQString(error));
handler_->SendMessage(message);
@ -849,8 +849,8 @@ void SpotifyClient::LoadImage(const QString& id_b64) {
<< kSpotifyImageIDSize << "bytes):" << id_b64;
// Send an error response straight away
spotify_pb::SpotifyMessage message;
spotify_pb::ImageResponse* msg = message.mutable_image_response();
pb::spotify::SpotifyMessage message;
pb::spotify::ImageResponse* msg = message.mutable_image_response();
msg->set_id(DataCommaSizeFromQString(id_b64));
handler_->SendMessage(message);
return;
@ -898,8 +898,8 @@ void SpotifyClient::TryImageAgain(sp_image* image) {
const void* data = sp_image_data(image, &size);
// Send the response
spotify_pb::SpotifyMessage message;
spotify_pb::ImageResponse* msg = message.mutable_image_response();
pb::spotify::SpotifyMessage message;
pb::spotify::ImageResponse* msg = message.mutable_image_response();
msg->set_id(DataCommaSizeFromQString(req->id_b64_));
if (data && size) {
msg->set_data(data, size);
@ -951,8 +951,8 @@ void SpotifyClient::AlbumBrowseComplete(sp_albumbrowse* result, void* userdata)
QString uri = me->pending_album_browses_.take(result);
spotify_pb::SpotifyMessage message;
spotify_pb::BrowseAlbumResponse* msg = message.mutable_browse_album_response();
pb::spotify::SpotifyMessage message;
pb::spotify::BrowseAlbumResponse* msg = message.mutable_browse_album_response();
msg->set_uri(DataCommaSizeFromQString(uri));

View File

@ -49,12 +49,12 @@ public:
void Init(quint16 port);
private slots:
void HandleMessage(const spotify_pb::SpotifyMessage& message);
void HandleMessage(const pb::spotify::SpotifyMessage& message);
void ProcessEvents();
private:
void SendLoginCompleted(bool success, const QString& error,
spotify_pb::LoginResponse_Error error_code);
pb::spotify::LoginResponse_Error error_code);
void SendPlaybackError(const QString& error);
void SendSearchResponse(sp_search* result);
@ -103,35 +103,35 @@ private:
static void SP_CALLCONV AlbumBrowseComplete(sp_albumbrowse* result, void* userdata);
// Request handlers.
void Login(const spotify_pb::LoginRequest& req);
void Search(const spotify_pb::SearchRequest& req);
void LoadPlaylist(const spotify_pb::LoadPlaylistRequest& req);
void SyncPlaylist(const spotify_pb::SyncPlaylistRequest& req);
void StartPlayback(const spotify_pb::PlaybackRequest& req);
void Login(const pb::spotify::LoginRequest& req);
void Search(const pb::spotify::SearchRequest& req);
void LoadPlaylist(const pb::spotify::LoadPlaylistRequest& req);
void SyncPlaylist(const pb::spotify::SyncPlaylistRequest& req);
void StartPlayback(const pb::spotify::PlaybackRequest& req);
void Seek(qint64 offset_bytes);
void LoadImage(const QString& id_b64);
void BrowseAlbum(const QString& uri);
void SetPlaybackSettings(const spotify_pb::PlaybackSettings& req);
void SetPlaybackSettings(const pb::spotify::PlaybackSettings& req);
void SendPlaylistList();
void ConvertTrack(sp_track* track, spotify_pb::Track* pb);
void ConvertAlbum(sp_album* album, spotify_pb::Track* pb);
void ConvertAlbumBrowse(sp_albumbrowse* browse, spotify_pb::Track* pb);
void ConvertTrack(sp_track* track, pb::spotify::Track* pb);
void ConvertAlbum(sp_album* album, pb::spotify::Track* pb);
void ConvertAlbumBrowse(sp_albumbrowse* browse, pb::spotify::Track* pb);
// Gets the appropriate sp_playlist* but does not load it.
sp_playlist* GetPlaylist(spotify_pb::PlaylistType type, int user_index);
sp_playlist* GetPlaylist(pb::spotify::PlaylistType type, int user_index);
private:
struct PendingLoadPlaylist {
spotify_pb::LoadPlaylistRequest request_;
pb::spotify::LoadPlaylistRequest request_;
sp_playlist* playlist_;
QList<sp_track*> tracks_;
bool offline_sync;
};
struct PendingPlaybackRequest {
spotify_pb::PlaybackRequest request_;
pb::spotify::PlaybackRequest request_;
sp_link* link_;
sp_track* track_;
@ -150,7 +150,7 @@ private:
void TryPlaybackAgain(const PendingPlaybackRequest& req);
void TryImageAgain(sp_image* image);
int GetDownloadProgress(sp_playlist* playlist);
void SendDownloadProgress(spotify_pb::PlaylistType type, int index, int download_progress);
void SendDownloadProgress(pb::spotify::PlaylistType type, int index, int download_progress);
QByteArray api_key_;
@ -170,7 +170,7 @@ private:
QList<PendingPlaybackRequest> pending_playback_requests_;
QList<PendingImageRequest> pending_image_requests_;
QMap<sp_image*, int> image_callbacks_registered_;
QMap<sp_search*, spotify_pb::SearchRequest> pending_searches_;
QMap<sp_search*, pb::spotify::SearchRequest> pending_searches_;
QMap<sp_albumbrowse*, QString> pending_album_browses_;
QMap<sp_search*, QList<sp_albumbrowse*> > pending_search_album_browses_;

View File

@ -34,6 +34,7 @@ endif(PROTOBUF_LITE_LIBRARY AND USE_PROTOBUF_LITE)
target_link_libraries(libclementine-common
${protobuf}
${TAGLIB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
chardet
)

View File

@ -52,7 +52,7 @@ void SpotifyMessageHandler::DeviceReadyRead() {
// Did we get everything?
if (buffer_.size() == expected_length_) {
// Parse the message
spotify_pb::SpotifyMessage message;
pb::spotify::SpotifyMessage message;
if (!message.ParseFromArray(buffer_.data().constData(), buffer_.size())) {
qLog(Error) << "Malformed protobuf message";
device_->close();
@ -70,12 +70,12 @@ void SpotifyMessageHandler::DeviceReadyRead() {
}
}
void SpotifyMessageHandler::SendMessage(const spotify_pb::SpotifyMessage& message) {
void SpotifyMessageHandler::SendMessage(const pb::spotify::SpotifyMessage& message) {
std::string data = message.SerializeAsString();
WriteMessage(QByteArray(data.data(), data.size()));
}
void SpotifyMessageHandler::SendMessageAsync(const spotify_pb::SpotifyMessage& message) {
void SpotifyMessageHandler::SendMessageAsync(const pb::spotify::SpotifyMessage& message) {
std::string data = message.SerializeAsString();
metaObject()->invokeMethod(this, "WriteMessage", Qt::QueuedConnection,
Q_ARG(QByteArray, QByteArray(data.data(), data.size())));

View File

@ -27,8 +27,10 @@
class QAbstractSocket;
namespace spotify_pb {
class SpotifyMessage;
namespace pb {
namespace spotify {
class SpotifyMessage;
}
}
@ -44,11 +46,11 @@ class SpotifyMessageHandler : public QObject {
public:
SpotifyMessageHandler(QAbstractSocket* device, QObject* parent);
void SendMessage(const spotify_pb::SpotifyMessage& message);
void SendMessageAsync(const spotify_pb::SpotifyMessage& message);
void SendMessage(const pb::spotify::SpotifyMessage& message);
void SendMessageAsync(const pb::spotify::SpotifyMessage& message);
signals:
void MessageArrived(const spotify_pb::SpotifyMessage& message);
void MessageArrived(const pb::spotify::SpotifyMessage& message);
private slots:
void WriteMessage(const QByteArray& data);

View File

@ -19,7 +19,7 @@
// compatible.
package spotify_pb;
package pb.spotify;
option optimize_for = LITE_RUNTIME;

View File

@ -35,7 +35,7 @@ public:
TagReaderClient(QObject* parent = 0);
typedef AbstractMessageHandler<pb::tagreader::Message> HandlerType;
typedef typename HandlerType::ReplyType ReplyType;
typedef HandlerType::ReplyType ReplyType;
static const char* kWorkerExecutableName;

View File

@ -44,12 +44,12 @@ SpotifyServer* SpotifySearchProvider::server() {
return NULL;
server_ = service_->server();
connect(server_, SIGNAL(SearchResults(spotify_pb::SearchResponse)),
SLOT(SearchFinishedSlot(spotify_pb::SearchResponse)));
connect(server_, SIGNAL(SearchResults(pb::spotify::SearchResponse)),
SLOT(SearchFinishedSlot(pb::spotify::SearchResponse)));
connect(server_, SIGNAL(ImageLoaded(QString,QImage)),
SLOT(ArtLoadedSlot(QString,QImage)));
connect(server_, SIGNAL(AlbumBrowseResults(spotify_pb::BrowseAlbumResponse)),
SLOT(AlbumBrowseResponse(spotify_pb::BrowseAlbumResponse)));
connect(server_, SIGNAL(AlbumBrowseResults(pb::spotify::BrowseAlbumResponse)),
SLOT(AlbumBrowseResponse(pb::spotify::BrowseAlbumResponse)));
connect(server_, SIGNAL(destroyed()), SLOT(ServerDestroyed()));
return server_;
@ -75,7 +75,7 @@ void SpotifySearchProvider::SearchAsync(int id, const QString& query) {
queries_[query_string] = state;
}
void SpotifySearchProvider::SearchFinishedSlot(const spotify_pb::SearchResponse& response) {
void SpotifySearchProvider::SearchFinishedSlot(const pb::spotify::SearchResponse& response) {
QString query_string = QString::fromUtf8(response.request().query().c_str());
QMap<QString, PendingState>::iterator it = queries_.find(query_string);
if (it == queries_.end())
@ -86,7 +86,7 @@ void SpotifySearchProvider::SearchFinishedSlot(const spotify_pb::SearchResponse&
ResultList ret;
for (int i=0; i < response.result_size() ; ++i) {
const spotify_pb::Track& track = response.result(i);
const pb::spotify::Track& track = response.result(i);
Result result(this);
result.type_ = globalsearch::Type_Track;
@ -97,7 +97,7 @@ void SpotifySearchProvider::SearchFinishedSlot(const spotify_pb::SearchResponse&
}
for (int i=0 ; i<response.album_size() ; ++i) {
const spotify_pb::Album& album = response.album(i);
const pb::spotify::Album& album = response.album(i);
Result result(this);
result.type_ = globalsearch::Type_Album;
@ -174,7 +174,7 @@ void SpotifySearchProvider::LoadTracksAsync(int id, const Result& result) {
}
}
void SpotifySearchProvider::AlbumBrowseResponse(const spotify_pb::BrowseAlbumResponse& response) {
void SpotifySearchProvider::AlbumBrowseResponse(const pb::spotify::BrowseAlbumResponse& response) {
QString uri = QStringFromStdString(response.uri());
QMap<QString, int>::iterator it = pending_tracks_.find(uri);
if (it == pending_tracks_.end())

View File

@ -19,7 +19,7 @@
#define SPOTIFYSEARCHPROVIDER_H
#include "searchprovider.h"
#include "spotifyblob/common/spotifymessages.pb.h"
#include "spotifymessages.pb.h"
class SpotifyServer;
class SpotifyService;
@ -40,10 +40,10 @@ public:
private slots:
void ServerDestroyed();
void SearchFinishedSlot(const spotify_pb::SearchResponse& response);
void SearchFinishedSlot(const pb::spotify::SearchResponse& response);
void ArtLoadedSlot(const QString& id, const QImage& image);
void AlbumBrowseResponse(const spotify_pb::BrowseAlbumResponse& response);
void AlbumBrowseResponse(const pb::spotify::BrowseAlbumResponse& response);
private:
SpotifyServer* server();

View File

@ -52,22 +52,22 @@ void SpotifyServer::NewConnection() {
protocol_socket_ = server_->nextPendingConnection();
handler_ = new SpotifyMessageHandler(protocol_socket_, this);
connect(handler_, SIGNAL(MessageArrived(spotify_pb::SpotifyMessage)),
SLOT(HandleMessage(spotify_pb::SpotifyMessage)));
connect(handler_, SIGNAL(MessageArrived(pb::spotify::SpotifyMessage)),
SLOT(HandleMessage(pb::spotify::SpotifyMessage)));
qLog(Info) << "Connection from port" << protocol_socket_->peerPort();
// Send any login messages that were queued before the client connected
foreach (const spotify_pb::SpotifyMessage& message, queued_login_messages_) {
foreach (const pb::spotify::SpotifyMessage& message, queued_login_messages_) {
SendMessage(message);
}
queued_login_messages_.clear();
}
void SpotifyServer::SendMessage(const spotify_pb::SpotifyMessage& message) {
void SpotifyServer::SendMessage(const pb::spotify::SpotifyMessage& message) {
const bool is_login_message = message.has_login_request();
QList<spotify_pb::SpotifyMessage>* queue =
QList<pb::spotify::SpotifyMessage>* queue =
is_login_message ? &queued_login_messages_ : &queued_messages_;
if (!protocol_socket_ || (!is_login_message && !logged_in_)) {
@ -78,10 +78,10 @@ void SpotifyServer::SendMessage(const spotify_pb::SpotifyMessage& message) {
}
void SpotifyServer::Login(const QString& username, const QString& password,
spotify_pb::Bitrate bitrate, bool volume_normalisation) {
spotify_pb::SpotifyMessage message;
pb::spotify::Bitrate bitrate, bool volume_normalisation) {
pb::spotify::SpotifyMessage message;
spotify_pb::LoginRequest* request = message.mutable_login_request();
pb::spotify::LoginRequest* request = message.mutable_login_request();
request->set_username(DataCommaSizeFromQString(username));
if (!password.isEmpty()) {
request->set_password(DataCommaSizeFromQString(password));
@ -92,24 +92,24 @@ void SpotifyServer::Login(const QString& username, const QString& password,
SendMessage(message);
}
void SpotifyServer::SetPlaybackSettings(spotify_pb::Bitrate bitrate, bool volume_normalisation) {
spotify_pb::SpotifyMessage message;
void SpotifyServer::SetPlaybackSettings(pb::spotify::Bitrate bitrate, bool volume_normalisation) {
pb::spotify::SpotifyMessage message;
spotify_pb::PlaybackSettings* request = message.mutable_set_playback_settings_request();
pb::spotify::PlaybackSettings* request = message.mutable_set_playback_settings_request();
request->set_bitrate(bitrate);
request->set_volume_normalisation(volume_normalisation);
SendMessage(message);
}
void SpotifyServer::HandleMessage(const spotify_pb::SpotifyMessage& message) {
void SpotifyServer::HandleMessage(const pb::spotify::SpotifyMessage& message) {
if (message.has_login_response()) {
const spotify_pb::LoginResponse& response = message.login_response();
const pb::spotify::LoginResponse& response = message.login_response();
logged_in_ = response.success();
if (response.success()) {
// Send any messages that were queued before the client logged in
foreach (const spotify_pb::SpotifyMessage& message, queued_messages_) {
foreach (const pb::spotify::SpotifyMessage& message, queued_messages_) {
SendMessage(message);
}
queued_messages_.clear();
@ -120,18 +120,18 @@ void SpotifyServer::HandleMessage(const spotify_pb::SpotifyMessage& message) {
} else if (message.has_playlists_updated()) {
emit PlaylistsUpdated(message.playlists_updated());
} else if (message.has_load_playlist_response()) {
const spotify_pb::LoadPlaylistResponse& response = message.load_playlist_response();
const pb::spotify::LoadPlaylistResponse& response = message.load_playlist_response();
switch (response.request().type()) {
case spotify_pb::Inbox:
case pb::spotify::Inbox:
emit InboxLoaded(response);
break;
case spotify_pb::Starred:
case pb::spotify::Starred:
emit StarredLoaded(response);
break;
case spotify_pb::UserPlaylist:
case pb::spotify::UserPlaylist:
emit UserPlaylistLoaded(response);
break;
}
@ -140,7 +140,7 @@ void SpotifyServer::HandleMessage(const spotify_pb::SpotifyMessage& message) {
} else if (message.has_search_response()) {
emit SearchResults(message.search_response());
} else if (message.has_image_response()) {
const spotify_pb::ImageResponse& response = message.image_response();
const pb::spotify::ImageResponse& response = message.image_response();
const QString id = QStringFromStdString(response.id());
if (response.has_data()) {
@ -156,9 +156,9 @@ void SpotifyServer::HandleMessage(const spotify_pb::SpotifyMessage& message) {
}
}
void SpotifyServer::LoadPlaylist(spotify_pb::PlaylistType type, int index) {
spotify_pb::SpotifyMessage message;
spotify_pb::LoadPlaylistRequest* req = message.mutable_load_playlist_request();
void SpotifyServer::LoadPlaylist(pb::spotify::PlaylistType type, int index) {
pb::spotify::SpotifyMessage message;
pb::spotify::LoadPlaylistRequest* req = message.mutable_load_playlist_request();
req->set_type(type);
if (index != -1) {
@ -169,9 +169,9 @@ void SpotifyServer::LoadPlaylist(spotify_pb::PlaylistType type, int index) {
}
void SpotifyServer::SyncPlaylist(
spotify_pb::PlaylistType type, int index, bool offline) {
spotify_pb::SpotifyMessage message;
spotify_pb::SyncPlaylistRequest* req = message.mutable_sync_playlist_request();
pb::spotify::PlaylistType type, int index, bool offline) {
pb::spotify::SpotifyMessage message;
pb::spotify::SyncPlaylistRequest* req = message.mutable_sync_playlist_request();
req->mutable_request()->set_type(type);
if (index != -1) {
req->mutable_request()->set_user_playlist_index(index);
@ -182,29 +182,29 @@ void SpotifyServer::SyncPlaylist(
}
void SpotifyServer::SyncInbox() {
SyncPlaylist(spotify_pb::Inbox, -1, true);
SyncPlaylist(pb::spotify::Inbox, -1, true);
}
void SpotifyServer::SyncStarred() {
SyncPlaylist(spotify_pb::Starred, -1, true);
SyncPlaylist(pb::spotify::Starred, -1, true);
}
void SpotifyServer::SyncUserPlaylist(int index) {
Q_ASSERT(index >= 0);
SyncPlaylist(spotify_pb::UserPlaylist, index, true);
SyncPlaylist(pb::spotify::UserPlaylist, index, true);
}
void SpotifyServer::LoadInbox() {
LoadPlaylist(spotify_pb::Inbox);
LoadPlaylist(pb::spotify::Inbox);
}
void SpotifyServer::LoadStarred() {
LoadPlaylist(spotify_pb::Starred);
LoadPlaylist(pb::spotify::Starred);
}
void SpotifyServer::LoadUserPlaylist(int index) {
Q_ASSERT(index >= 0);
LoadPlaylist(spotify_pb::UserPlaylist, index);
LoadPlaylist(pb::spotify::UserPlaylist, index);
}
void SpotifyServer::StartPlaybackLater(const QString& uri, quint16 port) {
@ -218,8 +218,8 @@ void SpotifyServer::StartPlaybackLater(const QString& uri, quint16 port) {
}
void SpotifyServer::StartPlayback(const QString& uri, quint16 port) {
spotify_pb::SpotifyMessage message;
spotify_pb::PlaybackRequest* req = message.mutable_playback_request();
pb::spotify::SpotifyMessage message;
pb::spotify::PlaybackRequest* req = message.mutable_playback_request();
req->set_track_uri(DataCommaSizeFromQString(uri));
req->set_media_port(port);
@ -227,16 +227,16 @@ void SpotifyServer::StartPlayback(const QString& uri, quint16 port) {
}
void SpotifyServer::Seek(qint64 offset_bytes) {
spotify_pb::SpotifyMessage message;
spotify_pb::SeekRequest* req = message.mutable_seek_request();
pb::spotify::SpotifyMessage message;
pb::spotify::SeekRequest* req = message.mutable_seek_request();
req->set_offset_bytes(offset_bytes);
SendMessage(message);
}
void SpotifyServer::Search(const QString& text, int limit, int limit_album) {
spotify_pb::SpotifyMessage message;
spotify_pb::SearchRequest* req = message.mutable_search_request();
pb::spotify::SpotifyMessage message;
pb::spotify::SearchRequest* req = message.mutable_search_request();
req->set_query(DataCommaSizeFromQString(text));
req->set_limit(limit);
@ -245,16 +245,16 @@ void SpotifyServer::Search(const QString& text, int limit, int limit_album) {
}
void SpotifyServer::LoadImage(const QString& id) {
spotify_pb::SpotifyMessage message;
spotify_pb::ImageRequest* req = message.mutable_image_request();
pb::spotify::SpotifyMessage message;
pb::spotify::ImageRequest* req = message.mutable_image_request();
req->set_id(DataCommaSizeFromQString(id));
SendMessage(message);
}
void SpotifyServer::AlbumBrowse(const QString& uri) {
spotify_pb::SpotifyMessage message;
spotify_pb::BrowseAlbumRequest* req = message.mutable_browse_album_request();
pb::spotify::SpotifyMessage message;
pb::spotify::BrowseAlbumRequest* req = message.mutable_browse_album_request();
req->set_uri(DataCommaSizeFromQString(uri));
SendMessage(message);

View File

@ -18,7 +18,7 @@
#ifndef SPOTIFYSERVER_H
#define SPOTIFYSERVER_H
#include "spotifyblob/common/spotifymessages.pb.h"
#include "spotifymessages.pb.h"
#include <QImage>
#include <QObject>
@ -36,7 +36,7 @@ public:
void Init();
void Login(const QString& username, const QString& password,
spotify_pb::Bitrate bitrate, bool volume_normalisation);
pb::spotify::Bitrate bitrate, bool volume_normalisation);
void LoadStarred();
void SyncStarred();
@ -48,7 +48,7 @@ public:
void Search(const QString& text, int limit, int limit_album = 0);
void LoadImage(const QString& id);
void AlbumBrowse(const QString& uri);
void SetPlaybackSettings(spotify_pb::Bitrate bitrate, bool volume_normalisation);
void SetPlaybackSettings(pb::spotify::Bitrate bitrate, bool volume_normalisation);
int server_port() const;
@ -58,34 +58,34 @@ public slots:
signals:
void LoginCompleted(bool success, const QString& error,
spotify_pb::LoginResponse_Error error_code);
void PlaylistsUpdated(const spotify_pb::Playlists& playlists);
pb::spotify::LoginResponse_Error error_code);
void PlaylistsUpdated(const pb::spotify::Playlists& playlists);
void StarredLoaded(const spotify_pb::LoadPlaylistResponse& response);
void InboxLoaded(const spotify_pb::LoadPlaylistResponse& response);
void UserPlaylistLoaded(const spotify_pb::LoadPlaylistResponse& response);
void StarredLoaded(const pb::spotify::LoadPlaylistResponse& response);
void InboxLoaded(const pb::spotify::LoadPlaylistResponse& response);
void UserPlaylistLoaded(const pb::spotify::LoadPlaylistResponse& response);
void PlaybackError(const QString& message);
void SearchResults(const spotify_pb::SearchResponse& response);
void SearchResults(const pb::spotify::SearchResponse& response);
void ImageLoaded(const QString& id, const QImage& image);
void SyncPlaylistProgress(const spotify_pb::SyncPlaylistProgress& progress);
void AlbumBrowseResults(const spotify_pb::BrowseAlbumResponse& response);
void SyncPlaylistProgress(const pb::spotify::SyncPlaylistProgress& progress);
void AlbumBrowseResults(const pb::spotify::BrowseAlbumResponse& response);
private slots:
void NewConnection();
void HandleMessage(const spotify_pb::SpotifyMessage& message);
void HandleMessage(const pb::spotify::SpotifyMessage& message);
private:
void LoadPlaylist(spotify_pb::PlaylistType type, int index = -1);
void SyncPlaylist(spotify_pb::PlaylistType type, int index, bool offline);
void SendMessage(const spotify_pb::SpotifyMessage& message);
void LoadPlaylist(pb::spotify::PlaylistType type, int index = -1);
void SyncPlaylist(pb::spotify::PlaylistType type, int index, bool offline);
void SendMessage(const pb::spotify::SpotifyMessage& message);
QTcpServer* server_;
QTcpSocket* protocol_socket_;
SpotifyMessageHandler* handler_;
bool logged_in_;
QList<spotify_pb::SpotifyMessage> queued_login_messages_;
QList<spotify_pb::SpotifyMessage> queued_messages_;
QList<pb::spotify::SpotifyMessage> queued_login_messages_;
QList<pb::spotify::SpotifyMessage> queued_messages_;
};
#endif // SPOTIFYSERVER_H

View File

@ -50,7 +50,7 @@ SpotifyService::SpotifyService(InternetModel* parent)
context_menu_(NULL),
search_delay_(new QTimer(this)),
login_state_(LoginState_OtherError),
bitrate_(spotify_pb::Bitrate320k),
bitrate_(pb::spotify::Bitrate320k),
volume_normalisation_(false)
{
// Build the search path for the binary blob.
@ -136,7 +136,7 @@ void SpotifyService::Login(const QString& username, const QString& password) {
}
void SpotifyService::LoginCompleted(bool success, const QString& error,
spotify_pb::LoginResponse_Error error_code) {
pb::spotify::LoginResponse_Error error_code) {
if (login_task_id_) {
model()->task_manager()->SetTaskFinished(login_task_id_);
login_task_id_ = 0;
@ -147,19 +147,19 @@ void SpotifyService::LoginCompleted(bool success, const QString& error,
QString error_copy(error);
switch (error_code) {
case spotify_pb::LoginResponse_Error_BadUsernameOrPassword:
case pb::spotify::LoginResponse_Error_BadUsernameOrPassword:
login_state_ = LoginState_BadCredentials;
break;
case spotify_pb::LoginResponse_Error_UserBanned:
case pb::spotify::LoginResponse_Error_UserBanned:
login_state_ = LoginState_Banned;
break;
case spotify_pb::LoginResponse_Error_UserNeedsPremium:
case pb::spotify::LoginResponse_Error_UserNeedsPremium:
login_state_ = LoginState_NoPremium;
break;
case spotify_pb::LoginResponse_Error_ReloginFailed:
case pb::spotify::LoginResponse_Error_ReloginFailed:
if (login_state_ == LoginState_LoggedIn) {
// This is the first time the relogin has failed - show a message this
// time only.
@ -205,8 +205,8 @@ void SpotifyService::ReloadSettings() {
s.beginGroup(kSettingsGroup);
login_state_ = LoginState(s.value("login_state", LoginState_OtherError).toInt());
bitrate_ = static_cast<spotify_pb::Bitrate>(
s.value("bitrate", spotify_pb::Bitrate320k).toInt());
bitrate_ = static_cast<pb::spotify::Bitrate>(
s.value("bitrate", pb::spotify::Bitrate320k).toInt());
volume_normalisation_ = s.value("volume_normalisation", false).toBool();
if (server_ && blob_process_) {
@ -223,24 +223,24 @@ void SpotifyService::EnsureServerCreated(const QString& username,
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(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(spotify_pb::SearchResponse)),
SLOT(SearchResults(spotify_pb::SearchResponse)));
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(spotify_pb::SyncPlaylistProgress)),
SLOT(SyncPlaylistProgress(spotify_pb::SyncPlaylistProgress)));
connect(server_, SIGNAL(SyncPlaylistProgress(pb::spotify::SyncPlaylistProgress)),
SLOT(SyncPlaylistProgress(pb::spotify::SyncPlaylistProgress)));
server_->Init();
@ -327,7 +327,7 @@ void SpotifyService::BlobDownloadFinished() {
EnsureServerCreated();
}
void SpotifyService::PlaylistsUpdated(const spotify_pb::Playlists& response) {
void SpotifyService::PlaylistsUpdated(const pb::spotify::Playlists& response) {
if (login_task_id_) {
model()->task_manager()->SetTaskFinished(login_task_id_);
login_task_id_ = 0;
@ -367,7 +367,7 @@ void SpotifyService::PlaylistsUpdated(const spotify_pb::Playlists& response) {
playlists_.clear();
for (int i=0 ; i<response.playlist_size() ; ++i) {
const spotify_pb::Playlists::Playlist& msg = response.playlist(i);
const pb::spotify::Playlists::Playlist& msg = response.playlist(i);
QStandardItem* item = new QStandardItem(QStringFromStdString(msg.name()));
item->setData(InternetModel::Type_UserPlaylist, InternetModel::Role_Type);
@ -383,13 +383,13 @@ void SpotifyService::PlaylistsUpdated(const spotify_pb::Playlists& response) {
}
}
bool SpotifyService::DoPlaylistsDiffer(const spotify_pb::Playlists& response) const {
bool SpotifyService::DoPlaylistsDiffer(const pb::spotify::Playlists& response) const {
if (playlists_.count() != response.playlist_size()) {
return true;
}
for (int i=0 ; i<response.playlist_size() ; ++i) {
const spotify_pb::Playlists::Playlist& msg = response.playlist(i);
const pb::spotify::Playlists::Playlist& msg = response.playlist(i);
const QStandardItem* item = PlaylistBySpotifyIndex(msg.index());
if (!item) {
@ -404,11 +404,11 @@ bool SpotifyService::DoPlaylistsDiffer(const spotify_pb::Playlists& response) co
return false;
}
void SpotifyService::InboxLoaded(const spotify_pb::LoadPlaylistResponse& response) {
void SpotifyService::InboxLoaded(const pb::spotify::LoadPlaylistResponse& response) {
FillPlaylist(inbox_, response);
}
void SpotifyService::StarredLoaded(const spotify_pb::LoadPlaylistResponse& response) {
void SpotifyService::StarredLoaded(const pb::spotify::LoadPlaylistResponse& response) {
FillPlaylist(starred_, response);
}
@ -421,7 +421,7 @@ QStandardItem* SpotifyService::PlaylistBySpotifyIndex(int index) const {
return NULL;
}
void SpotifyService::UserPlaylistLoaded(const spotify_pb::LoadPlaylistResponse& response) {
void SpotifyService::UserPlaylistLoaded(const pb::spotify::LoadPlaylistResponse& response) {
// Find a playlist with this index
QStandardItem* item = PlaylistBySpotifyIndex(response.request().user_playlist_index());
if (item) {
@ -429,7 +429,7 @@ void SpotifyService::UserPlaylistLoaded(const spotify_pb::LoadPlaylistResponse&
}
}
void SpotifyService::FillPlaylist(QStandardItem* item, const spotify_pb::LoadPlaylistResponse& response) {
void SpotifyService::FillPlaylist(QStandardItem* item, const pb::spotify::LoadPlaylistResponse& response) {
qLog(Debug) << "Filling playlist:" << item->text();
if (item->hasChildren())
item->removeRows(0, item->rowCount());
@ -448,7 +448,7 @@ void SpotifyService::FillPlaylist(QStandardItem* item, const spotify_pb::LoadPla
}
}
void SpotifyService::SongFromProtobuf(const spotify_pb::Track& track, Song* song) {
void SpotifyService::SongFromProtobuf(const pb::spotify::Track& track, Song* song) {
song->set_rating(track.starred() ? 1.0 : 0.0);
song->set_title(QStringFromStdString(track.title()));
song->set_album(QStringFromStdString(track.album()));
@ -544,7 +544,7 @@ void SpotifyService::DoSearch() {
}
}
void SpotifyService::SearchResults(const spotify_pb::SearchResponse& response) {
void SpotifyService::SearchResults(const pb::spotify::SearchResponse& response) {
if (QStringFromStdString(response.request().query()) != pending_search_) {
qLog(Debug) << "Old search result for"
<< QStringFromStdString(response.request().query())
@ -622,17 +622,17 @@ void SpotifyService::LoadImage(const QString& id) {
}
void SpotifyService::SyncPlaylistProgress(
const spotify_pb::SyncPlaylistProgress& progress) {
const pb::spotify::SyncPlaylistProgress& progress) {
qLog(Debug) << "Sync progress:" << progress.sync_progress();
int task_id = -1;
switch (progress.request().type()) {
case spotify_pb::Inbox:
case pb::spotify::Inbox:
task_id = inbox_sync_id_;
break;
case spotify_pb::Starred:
case pb::spotify::Starred:
task_id = starred_sync_id_;
break;
case spotify_pb::UserPlaylist: {
case pb::spotify::UserPlaylist: {
QMap<int, int>::const_iterator it = playlist_sync_ids_.constFind(
progress.request().user_playlist_index());
if (it != playlist_sync_ids_.constEnd()) {
@ -650,7 +650,7 @@ void SpotifyService::SyncPlaylistProgress(
model()->task_manager()->SetTaskProgress(task_id, progress.sync_progress(), 100);
if (progress.sync_progress() == 100) {
model()->task_manager()->SetTaskFinished(task_id);
if (progress.request().type() == spotify_pb::UserPlaylist) {
if (progress.request().type() == pb::spotify::UserPlaylist) {
playlist_sync_ids_.remove(task_id);
}
}

View File

@ -3,7 +3,7 @@
#include "internetmodel.h"
#include "internetservice.h"
#include "spotifyblob/common/spotifymessages.pb.h"
#include "spotifymessages.pb.h"
#include <QProcess>
#include <QTimer>
@ -71,7 +71,7 @@ public:
LoginState login_state() const { return login_state_; }
bool IsLoggedIn() const { return login_state_ == LoginState_LoggedIn; }
static void SongFromProtobuf(const spotify_pb::Track& track, Song* song);
static void SongFromProtobuf(const pb::spotify::Track& track, Song* song);
signals:
void BlobStateChanged();
@ -86,24 +86,24 @@ protected:
private:
void StartBlobProcess();
void FillPlaylist(QStandardItem* item, const spotify_pb::LoadPlaylistResponse& response);
void FillPlaylist(QStandardItem* item, const pb::spotify::LoadPlaylistResponse& response);
void EnsureMenuCreated();
QStandardItem* PlaylistBySpotifyIndex(int index) const;
bool DoPlaylistsDiffer(const spotify_pb::Playlists& response) const;
bool DoPlaylistsDiffer(const pb::spotify::Playlists& response) const;
private slots:
void EnsureServerCreated(const QString& username = QString(),
const QString& password = QString());
void BlobProcessError(QProcess::ProcessError error);
void LoginCompleted(bool success, const QString& error,
spotify_pb::LoginResponse_Error error_code);
void PlaylistsUpdated(const spotify_pb::Playlists& response);
void InboxLoaded(const spotify_pb::LoadPlaylistResponse& response);
void StarredLoaded(const spotify_pb::LoadPlaylistResponse& response);
void UserPlaylistLoaded(const spotify_pb::LoadPlaylistResponse& response);
void SearchResults(const spotify_pb::SearchResponse& response);
void SyncPlaylistProgress(const spotify_pb::SyncPlaylistProgress& progress);
pb::spotify::LoginResponse_Error error_code);
void PlaylistsUpdated(const pb::spotify::Playlists& response);
void InboxLoaded(const pb::spotify::LoadPlaylistResponse& response);
void StarredLoaded(const pb::spotify::LoadPlaylistResponse& response);
void UserPlaylistLoaded(const pb::spotify::LoadPlaylistResponse& response);
void SearchResults(const pb::spotify::SearchResponse& response);
void SyncPlaylistProgress(const pb::spotify::SyncPlaylistProgress& progress);
void OpenSearchTab();
void DoSearch();
@ -141,7 +141,7 @@ private:
QMap<int, int> playlist_sync_ids_;
LoginState login_state_;
spotify_pb::Bitrate bitrate_;
pb::spotify::Bitrate bitrate_;
bool volume_normalisation_;
};

View File

@ -17,11 +17,11 @@
#include "spotifysettingspage.h"
#include "spotifymessages.pb.h"
#include "spotifyservice.h"
#include "internetmodel.h"
#include "ui_spotifysettingspage.h"
#include "core/network.h"
#include "spotifyblob/common/spotifymessages.pb.h"
#include "ui/iconloader.h"
#include <QMessageBox>
@ -56,9 +56,9 @@ SpotifySettingsPage::SpotifySettingsPage(SettingsDialog* dialog)
ui_->login_state->AddCredentialField(ui_->password);
ui_->login_state->AddCredentialGroup(ui_->account_group);
ui_->bitrate->addItem("96 " + tr("kbps"), spotify_pb::Bitrate96k);
ui_->bitrate->addItem("160 " + tr("kbps"), spotify_pb::Bitrate160k);
ui_->bitrate->addItem("320 " + tr("kbps"), spotify_pb::Bitrate320k);
ui_->bitrate->addItem("96 " + tr("kbps"), pb::spotify::Bitrate96k);
ui_->bitrate->addItem("160 " + tr("kbps"), pb::spotify::Bitrate160k);
ui_->bitrate->addItem("320 " + tr("kbps"), pb::spotify::Bitrate320k);
BlobStateChanged();
}
@ -109,7 +109,7 @@ void SpotifySettingsPage::Load() {
validated_ = false;
ui_->bitrate->setCurrentIndex(ui_->bitrate->findData(
s.value("bitrate", spotify_pb::Bitrate320k).toInt()));
s.value("bitrate", pb::spotify::Bitrate320k).toInt()));
ui_->volume_normalisation->setChecked(
s.value("volume_normalisation", false).toBool());