Skip to content

Commit

Permalink
protobuf: Fix namespace conflict
Browse files Browse the repository at this point in the history
Protobuf 3.15 adds a namespace alias for "pb" that conflicts with
Clementine's. Modify Clementine to use "cpb".

Patch provided by @ahesford

Reference: https://github.com/protocolbuffers/protobuf/blob/5c028d6cf42e426d47f5baa6ea3f0f5c86b97beb/src/google/protobuf/port.h#L44
  • Loading branch information
jbroadus committed Feb 21, 2021
1 parent d93bd9c commit cc9e7cd
Show file tree
Hide file tree
Showing 34 changed files with 548 additions and 544 deletions.
128 changes: 64 additions & 64 deletions ext/clementine-spotifyblob/spotifyclient.cpp

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions ext/clementine-spotifyblob/spotifyclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class QTimer;
class MediaPipeline;
class ResponseMessage;

class SpotifyClient : public AbstractMessageHandler<pb::spotify::Message> {
class SpotifyClient : public AbstractMessageHandler<cpb::spotify::Message> {
Q_OBJECT

public:
Expand All @@ -48,15 +48,15 @@ class SpotifyClient : public AbstractMessageHandler<pb::spotify::Message> {
void Init(quint16 port);

protected:
void MessageArrived(const pb::spotify::Message& message);
void MessageArrived(const cpb::spotify::Message& message);
void DeviceClosed();

private slots:
void ProcessEvents();

private:
void SendLoginCompleted(bool success, const QString& error,
pb::spotify::LoginResponse_Error error_code);
cpb::spotify::LoginResponse_Error error_code);
void SendPlaybackError(const QString& error);
void SendSearchResponse(sp_search* result);

Expand Down Expand Up @@ -118,40 +118,40 @@ class SpotifyClient : public AbstractMessageHandler<pb::spotify::Message> {
ToplistBrowseComplete(sp_toplistbrowse* result, void* userdata);

// Request handlers.
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 AddTracksToPlaylist(const pb::spotify::AddTracksToPlaylistRequest& req);
void Login(const cpb::spotify::LoginRequest& req);
void Search(const cpb::spotify::SearchRequest& req);
void LoadPlaylist(const cpb::spotify::LoadPlaylistRequest& req);
void SyncPlaylist(const cpb::spotify::SyncPlaylistRequest& req);
void AddTracksToPlaylist(const cpb::spotify::AddTracksToPlaylistRequest& req);
void RemoveTracksFromPlaylist(
const pb::spotify::RemoveTracksFromPlaylistRequest& req);
void StartPlayback(const pb::spotify::PlaybackRequest& req);
const cpb::spotify::RemoveTracksFromPlaylistRequest& req);
void StartPlayback(const cpb::spotify::PlaybackRequest& req);
void Seek(qint64 offset_nsec);
void LoadImage(const QString& id_b64);
void BrowseAlbum(const QString& uri);
void BrowseToplist(const pb::spotify::BrowseToplistRequest& req);
void SetPlaybackSettings(const pb::spotify::PlaybackSettings& req);
void SetPaused(const pb::spotify::PauseRequest& req);
void BrowseToplist(const cpb::spotify::BrowseToplistRequest& req);
void SetPlaybackSettings(const cpb::spotify::PlaybackSettings& req);
void SetPaused(const cpb::spotify::PauseRequest& req);

void SendPlaylistList();

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);
void ConvertTrack(sp_track* track, cpb::spotify::Track* pb);
void ConvertAlbum(sp_album* album, cpb::spotify::Track* pb);
void ConvertAlbumBrowse(sp_albumbrowse* browse, cpb::spotify::Track* pb);

// Gets the appropriate sp_playlist* but does not load it.
sp_playlist* GetPlaylist(pb::spotify::PlaylistType type, int user_index);
sp_playlist* GetPlaylist(cpb::spotify::PlaylistType type, int user_index);

private:
struct PendingLoadPlaylist {
pb::spotify::LoadPlaylistRequest request_;
cpb::spotify::LoadPlaylistRequest request_;
sp_playlist* playlist_;
QList<sp_track*> tracks_;
bool offline_sync;
};

struct PendingPlaybackRequest {
pb::spotify::PlaybackRequest request_;
cpb::spotify::PlaybackRequest request_;
sp_link* link_;
sp_track* track_;

Expand All @@ -170,7 +170,7 @@ class SpotifyClient : public AbstractMessageHandler<pb::spotify::Message> {
void TryPlaybackAgain(const PendingPlaybackRequest& req);
void TryImageAgain(sp_image* image);
int GetDownloadProgress(sp_playlist* playlist);
void SendDownloadProgress(pb::spotify::PlaylistType type, int index,
void SendDownloadProgress(cpb::spotify::PlaylistType type, int index,
int download_progress);

QByteArray api_key_;
Expand All @@ -190,9 +190,9 @@ class SpotifyClient : public AbstractMessageHandler<pb::spotify::Message> {
QList<PendingPlaybackRequest> pending_playback_requests_;
QList<PendingImageRequest> pending_image_requests_;
QMap<sp_image*, int> image_callbacks_registered_;
QMap<sp_search*, pb::spotify::SearchRequest> pending_searches_;
QMap<sp_search*, cpb::spotify::SearchRequest> pending_searches_;
QMap<sp_albumbrowse*, QString> pending_album_browses_;
QMap<sp_toplistbrowse*, pb::spotify::BrowseToplistRequest>
QMap<sp_toplistbrowse*, cpb::spotify::BrowseToplistRequest>
pending_toplist_browses_;

QMap<sp_search*, QList<sp_albumbrowse*>> pending_search_album_browses_;
Expand Down
10 changes: 5 additions & 5 deletions ext/clementine-tagreader/tagreaderworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#include <QUrl>

TagReaderWorker::TagReaderWorker(QIODevice* socket, QObject* parent)
: AbstractMessageHandler<pb::tagreader::Message>(socket, parent) {}
: AbstractMessageHandler<cpb::tagreader::Message>(socket, parent) {}

void TagReaderWorker::MessageArrived(const pb::tagreader::Message& message) {
pb::tagreader::Message reply;
void TagReaderWorker::MessageArrived(const cpb::tagreader::Message& message) {
cpb::tagreader::Message reply;

#if 0
// Crash every few requests
Expand Down Expand Up @@ -68,7 +68,7 @@ void TagReaderWorker::MessageArrived(const pb::tagreader::Message& message) {
data.size());
} else if (message.has_read_cloud_file_request()) {
#ifdef HAVE_GOOGLE_DRIVE
const pb::tagreader::ReadCloudFileRequest& req =
const cpb::tagreader::ReadCloudFileRequest& req =
message.read_cloud_file_request();
if (!tag_reader_.ReadCloudFile(
QUrl::fromEncoded(QByteArray(req.download_url().data(),
Expand All @@ -86,7 +86,7 @@ void TagReaderWorker::MessageArrived(const pb::tagreader::Message& message) {
}

void TagReaderWorker::DeviceClosed() {
AbstractMessageHandler<pb::tagreader::Message>::DeviceClosed();
AbstractMessageHandler<cpb::tagreader::Message>::DeviceClosed();

qApp->exit();
}
4 changes: 2 additions & 2 deletions ext/clementine-tagreader/tagreaderworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
#include "tagreadermessages.pb.h"
#include "core/messagehandler.h"

class TagReaderWorker : public AbstractMessageHandler<pb::tagreader::Message> {
class TagReaderWorker : public AbstractMessageHandler<cpb::tagreader::Message> {
public:
TagReaderWorker(QIODevice* socket, QObject* parent = NULL);

protected:
void MessageArrived(const pb::tagreader::Message& message);
void MessageArrived(const cpb::tagreader::Message& message);
void DeviceClosed();

private:
Expand Down
2 changes: 1 addition & 1 deletion ext/libclementine-remote/remotecontrolmessages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

syntax = "proto2";

package pb.remote;
package cpb.remote;

// The supported message types
enum MsgType {
Expand Down
2 changes: 1 addition & 1 deletion ext/libclementine-spotifyblob/spotifymessages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

syntax = "proto2";

package pb.spotify;
package cpb.spotify;

message LoginRequest {
required string username = 1;
Expand Down
10 changes: 5 additions & 5 deletions ext/libclementine-tagreader/gmereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ bool GME::IsSupportedFormat(const QFileInfo& file_info) {
}

void GME::ReadFile(const QFileInfo& file_info,
pb::tagreader::SongMetadata* song_info) {
cpb::tagreader::SongMetadata* song_info) {
if (file_info.completeSuffix().endsWith("spc"))
SPC::Read(file_info, song_info);
if (file_info.completeSuffix().endsWith("vgm"))
VGM::Read(file_info, song_info);
}

void GME::SPC::Read(const QFileInfo& file_info,
pb::tagreader::SongMetadata* song_info) {
cpb::tagreader::SongMetadata* song_info) {
QFile file(file_info.filePath());
if (!file.open(QIODevice::ReadOnly)) return;

Expand Down Expand Up @@ -137,7 +137,7 @@ void GME::SPC::Read(const QFileInfo& file_info,
}

song_info->set_valid(true);
song_info->set_type(pb::tagreader::SongMetadata_Type_SPC);
song_info->set_type(cpb::tagreader::SongMetadata_Type_SPC);
}

qint16 GME::SPC::GetNextMemAddressAlign32bit(qint16 input) {
Expand All @@ -157,7 +157,7 @@ quint64 GME::SPC::ConvertSPCStringToNum(const QByteArray& arr) {
}

void GME::VGM::Read(const QFileInfo& file_info,
pb::tagreader::SongMetadata* song_info) {
cpb::tagreader::SongMetadata* song_info) {
QFile file(file_info.filePath());
if (!file.open(QIODevice::ReadOnly)) return;

Expand Down Expand Up @@ -206,7 +206,7 @@ void GME::VGM::Read(const QFileInfo& file_info,
song_info->set_year(strings[8].left(4).toInt());
song_info->set_length_nanosec(length * kNsecPerMsec);
song_info->set_valid(true);
song_info->set_type(pb::tagreader::SongMetadata_Type_VGM);
song_info->set_type(cpb::tagreader::SongMetadata_Type_VGM);
}

bool GME::VGM::GetPlaybackLength(const QByteArray& sample_count_bytes,
Expand Down
6 changes: 3 additions & 3 deletions ext/libclementine-tagreader/gmereader.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class QByteArray;
namespace GME {
bool IsSupportedFormat(const QFileInfo& file_info);
void ReadFile(const QFileInfo& file_info,
pb::tagreader::SongMetadata* song_info);
cpb::tagreader::SongMetadata* song_info);

namespace SPC {
/* SPC SPEC:
Expand Down Expand Up @@ -42,7 +42,7 @@ enum xID6_ID { SongName = 0x01, GameName = 0x02, ArtistName = 0x03 };

enum xID6_TYPE { Length = 0x0, String = 0x1, Integer = 0x4 };

void Read(const QFileInfo& file_info, pb::tagreader::SongMetadata* song_info);
void Read(const QFileInfo& file_info, cpb::tagreader::SongMetadata* song_info);
qint16 GetNextMemAddressAlign32bit(qint16 input);
quint64 ConvertSPCStringToNum(const QByteArray& arr);
} // namespace SPC
Expand All @@ -58,7 +58,7 @@ const int LOOP_SAMPLE_COUNT = 0x20;
const int SAMPLE_TIMEBASE = 44100;
const int GST_GME_LOOP_TIME_MS = 8000;

void Read(const QFileInfo& file_info, pb::tagreader::SongMetadata* song_info);
void Read(const QFileInfo& file_info, cpb::tagreader::SongMetadata* song_info);
/* Takes in two QByteArrays, expected to be 4 bytes long. Desired length
* is returned via output parameter out_length. Returns false on error. */
bool GetPlaybackLength(const QByteArray& sample_count_bytes,
Expand Down

0 comments on commit cc9e7cd

Please sign in to comment.