onedrive: Fix json response parsing
Discontinue use of incorrect and obsolete QJsonDocument::fromBinaryData method. Utilize common InternetService::ParseJsonReply instead.
This commit is contained in:
parent
e479206c45
commit
565110e223
@ -110,8 +110,11 @@ void SkydriveService::AddAuthorizationHeader(QNetworkRequest* request) {
|
|||||||
|
|
||||||
void SkydriveService::FetchUserInfoFinished(QNetworkReply* reply) {
|
void SkydriveService::FetchUserInfoFinished(QNetworkReply* reply) {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
QJsonObject json_response =
|
|
||||||
QJsonDocument::fromBinaryData(reply->readAll()).object();
|
QJsonDocument document = ParseJsonReply(reply);
|
||||||
|
if (document.isNull()) return;
|
||||||
|
|
||||||
|
QJsonObject json_response = document.object();
|
||||||
|
|
||||||
QString name = json_response["name"].toString();
|
QString name = json_response["name"].toString();
|
||||||
if (!name.isEmpty()) {
|
if (!name.isEmpty()) {
|
||||||
@ -137,8 +140,11 @@ void SkydriveService::ListFiles(const QString& folder) {
|
|||||||
|
|
||||||
void SkydriveService::ListFilesFinished(QNetworkReply* reply) {
|
void SkydriveService::ListFilesFinished(QNetworkReply* reply) {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
QJsonObject json_response =
|
|
||||||
QJsonDocument::fromBinaryData(reply->readAll()).object();
|
QJsonDocument document = ParseJsonReply(reply);
|
||||||
|
if (document.isNull()) return;
|
||||||
|
|
||||||
|
QJsonObject json_response = document.object();
|
||||||
|
|
||||||
QJsonArray files = json_response["data"].toArray();
|
QJsonArray files = json_response["data"].toArray();
|
||||||
for (const QJsonValue& f : files) {
|
for (const QJsonValue& f : files) {
|
||||||
@ -179,8 +185,11 @@ QUrl SkydriveService::GetStreamingUrlFromSongId(const QString& file_id) {
|
|||||||
std::unique_ptr<QNetworkReply> reply(network_->get(request));
|
std::unique_ptr<QNetworkReply> reply(network_->get(request));
|
||||||
WaitForSignal(reply.get(), SIGNAL(finished()));
|
WaitForSignal(reply.get(), SIGNAL(finished()));
|
||||||
|
|
||||||
QJsonObject json_response =
|
QJsonDocument document = ParseJsonReply(reply.get());
|
||||||
QJsonDocument::fromBinaryData(reply.get()->readAll()).object();
|
if (document.isNull()) return QUrl();
|
||||||
|
|
||||||
|
QJsonObject json_response = document.object();
|
||||||
|
|
||||||
return QUrl(json_response["source"].toString());
|
return QUrl(json_response["source"].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user