Rename google drive tagging methods to more appropriate generic names.

This commit is contained in:
John Maguire 2012-11-28 16:34:10 +01:00
parent 210f978188
commit 9c7a3ab105
7 changed files with 39 additions and 39 deletions

View File

@ -129,19 +129,19 @@ void TagReaderWorker::MessageArrived(const pb::tagreader::Message& message) {
QStringFromStdString(message.load_embedded_art_request().filename()));
reply.mutable_load_embedded_art_response()->set_data(
data.constData(), data.size());
} else if (message.has_read_google_drive_request()) {
} else if (message.has_read_cloud_file_request()) {
#ifdef HAVE_GOOGLE_DRIVE
const pb::tagreader::ReadGoogleDriveRequest& req =
message.read_google_drive_request();
if (!ReadGoogleDrive(
const pb::tagreader::ReadCloudFileRequest& req =
message.read_cloud_file_request();
if (!ReadCloudFile(
QUrl::fromEncoded(QByteArray(req.download_url().data(),
req.download_url().size())),
QStringFromStdString(req.title()),
req.size(),
QStringFromStdString(req.mime_type()),
QStringFromStdString(req.authorisation_header()),
reply.mutable_read_google_drive_response()->mutable_metadata())) {
reply.mutable_read_google_drive_response()->clear_metadata();
reply.mutable_read_cloud_file_response()->mutable_metadata())) {
reply.mutable_read_cloud_file_response()->clear_metadata();
}
#endif
}
@ -611,12 +611,12 @@ void TagReaderWorker::DeviceClosed() {
}
#ifdef HAVE_GOOGLE_DRIVE
bool TagReaderWorker::ReadGoogleDrive(const QUrl& download_url,
const QString& title,
int size,
const QString& mime_type,
const QString& authorisation_header,
pb::tagreader::SongMetadata* song) const {
bool TagReaderWorker::ReadCloudFile(const QUrl& download_url,
const QString& title,
int size,
const QString& mime_type,
const QString& authorisation_header,
pb::tagreader::SongMetadata* song) const {
qLog(Debug) << "Loading tags from" << title;
CloudStream* stream = new CloudStream(

View File

@ -55,12 +55,12 @@ private:
QByteArray LoadEmbeddedArt(const QString& filename) const;
#ifdef HAVE_GOOGLE_DRIVE
bool ReadGoogleDrive(const QUrl& download_url,
const QString& title,
int size,
const QString& mime_type,
const QString& access_token,
pb::tagreader::SongMetadata* song) const;
bool ReadCloudFile(const QUrl& download_url,
const QString& title,
int size,
const QString& mime_type,
const QString& access_token,
pb::tagreader::SongMetadata* song) const;
#endif // HAVE_GOOGLE_DRIVE
static void Decode(const TagLib::String& tag, const QTextCodec* codec,

View File

@ -82,7 +82,7 @@ message LoadEmbeddedArtResponse {
optional bytes data = 1;
}
message ReadGoogleDriveRequest {
message ReadCloudFileRequest {
optional string download_url = 1;
optional string title = 2;
optional int32 size = 3;
@ -90,7 +90,7 @@ message ReadGoogleDriveRequest {
optional string mime_type = 5;
}
message ReadGoogleDriveResponse {
message ReadCloudFileResponse {
optional SongMetadata metadata = 1;
}
@ -109,6 +109,6 @@ message Message {
optional LoadEmbeddedArtRequest load_embedded_art_request = 8;
optional LoadEmbeddedArtResponse load_embedded_art_response = 9;
optional ReadGoogleDriveRequest read_google_drive_request = 10;
optional ReadGoogleDriveResponse read_google_drive_response = 11;
optional ReadCloudFileRequest read_cloud_file_request = 10;
optional ReadCloudFileResponse read_cloud_file_response = 11;
}

View File

@ -84,14 +84,14 @@ TagReaderReply* TagReaderClient::LoadEmbeddedArt(const QString& filename) {
return worker_pool_->SendMessageWithReply(&message);
}
TagReaderReply* TagReaderClient::ReadGoogleDrive(const QUrl& download_url,
const QString& title,
int size,
const QString& mime_type,
const QString& authorisation_header) {
TagReaderReply* TagReaderClient::ReadCloudFile(const QUrl& download_url,
const QString& title,
int size,
const QString& mime_type,
const QString& authorisation_header) {
pb::tagreader::Message message;
pb::tagreader::ReadGoogleDriveRequest* req =
message.mutable_read_google_drive_request();
pb::tagreader::ReadCloudFileRequest* req =
message.mutable_read_cloud_file_request();
const QString url_string = download_url.toEncoded();
req->set_download_url(DataCommaSizeFromQString(url_string));

View File

@ -45,11 +45,11 @@ public:
ReplyType* SaveFile(const QString& filename, const Song& metadata);
ReplyType* IsMediaFile(const QString& filename);
ReplyType* LoadEmbeddedArt(const QString& filename);
ReplyType* ReadGoogleDrive(const QUrl& download_url,
const QString& title,
int size,
const QString& mime_type,
const QString& authorisation_header);
ReplyType* ReadCloudFile(const QUrl& download_url,
const QString& title,
int size,
const QString& mime_type,
const QString& authorisation_header);
// Convenience functions that call the above functions and wait for a
// response. These block the calling thread with a semaphore, and must NOT

View File

@ -139,7 +139,7 @@ void GoogleDriveService::MaybeAddFileToDatabase(const google_drive::File& file)
// Song not in index; tag and add.
QString authorisation_header = QString("Bearer %1").arg(client_->access_token());
TagReaderClient::ReplyType* reply = app_->tag_reader_client()->ReadGoogleDrive(
TagReaderClient::ReplyType* reply = app_->tag_reader_client()->ReadCloudFile(
file.download_url(),
file.title(),
file.size(),
@ -159,8 +159,8 @@ void GoogleDriveService::ReadTagsFinished(TagReaderClient::ReplyType* reply,
TaskManager::ScopedTask(task_id, task_manager_);
const pb::tagreader::ReadGoogleDriveResponse& msg =
reply->message().read_google_drive_response();
const pb::tagreader::ReadCloudFileResponse& msg =
reply->message().read_cloud_file_response();
if (!msg.has_metadata() || !msg.metadata().filesize()) {
qLog(Debug) << "Failed to tag:" << metadata.title();
return;

View File

@ -135,7 +135,7 @@ void UbuntuOneService::MaybeAddFileToDatabase(const QVariantMap& file) {
QUrl content_url(kContentRoot);
content_url.setPath(content_path);
TagReaderClient::ReplyType* reply = app_->tag_reader_client()->ReadGoogleDrive(
TagReaderClient::ReplyType* reply = app_->tag_reader_client()->ReadCloudFile(
content_url,
file["path"].toString().mid(1),
file["size"].toInt(),
@ -151,7 +151,7 @@ void UbuntuOneService::ReadTagsFinished(
TagReaderClient::ReplyType* reply, const QVariantMap& file, const QUrl& url) {
qLog(Debug) << reply->message().DebugString().c_str();
Song song;
song.InitFromProtobuf(reply->message().read_google_drive_response().metadata());
song.InitFromProtobuf(reply->message().read_cloud_file_response().metadata());
song.set_directory_id(0);
song.set_etag(file["hash"].toString());
song.set_mtime(