Support OGG, FLAC & AAC file types for Ubuntu One.
This commit is contained in:
parent
629f1abb6c
commit
e14334075c
@ -121,8 +121,33 @@ void UbuntuOneService::FileListRequestFinished(QNetworkReply* reply) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
QString GuessMimeTypeForFile(const QString& filename) {
|
||||||
|
if (filename.endsWith(".mp3")) {
|
||||||
|
return "audio/mpeg";
|
||||||
|
} else if (filename.endsWith(".m4a")) {
|
||||||
|
return "audio/mpeg";
|
||||||
|
} else if (filename.endsWith(".ogg")) {
|
||||||
|
return "application/ogg";
|
||||||
|
} else if (filename.endsWith(".flac")) {
|
||||||
|
return "application/x-flac";
|
||||||
|
}
|
||||||
|
return QString::null;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void UbuntuOneService::MaybeAddFileToDatabase(const QVariantMap& file) {
|
void UbuntuOneService::MaybeAddFileToDatabase(const QVariantMap& file) {
|
||||||
QString content_path = file["content_path"].toString();
|
const QString content_path = file["content_path"].toString();
|
||||||
|
const QString filename = file["path"].toString().mid(1);
|
||||||
|
const QString mime_type = GuessMimeTypeForFile(filename);
|
||||||
|
if (mime_type.isNull()) {
|
||||||
|
// Unknown file type.
|
||||||
|
// Potentially, we could do a HEAD request to see what Ubuntu One thinks
|
||||||
|
// the Content-Type is, probably not worth it though.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QUrl service_url;
|
QUrl service_url;
|
||||||
service_url.setScheme("ubuntuonefile");
|
service_url.setScheme("ubuntuonefile");
|
||||||
@ -137,9 +162,9 @@ void UbuntuOneService::MaybeAddFileToDatabase(const QVariantMap& file) {
|
|||||||
|
|
||||||
TagReaderClient::ReplyType* reply = app_->tag_reader_client()->ReadCloudFile(
|
TagReaderClient::ReplyType* reply = app_->tag_reader_client()->ReadCloudFile(
|
||||||
content_url,
|
content_url,
|
||||||
file["path"].toString().mid(1),
|
filename,
|
||||||
file["size"].toInt(),
|
file["size"].toInt(),
|
||||||
"audio/mpeg",
|
mime_type,
|
||||||
GenerateAuthorisationHeader());
|
GenerateAuthorisationHeader());
|
||||||
NewClosure(
|
NewClosure(
|
||||||
reply, SIGNAL(Finished(bool)),
|
reply, SIGNAL(Finished(bool)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user