Ask before opening url, fix some typos
This commit is contained in:
@@ -13,7 +13,7 @@ Unreleased:
|
|||||||
* Fixed key up causing playback to reset
|
* Fixed key up causing playback to reset
|
||||||
* New improved last.fm and musicbrainz album cover providers
|
* New improved last.fm and musicbrainz album cover providers
|
||||||
* Removed liblastfm dependency
|
* Removed liblastfm dependency
|
||||||
* Replace sha2 with QCryptographicHash
|
* Replaced sha2 with QCryptographicHash
|
||||||
|
|
||||||
Version 0.4.2:
|
Version 0.4.2:
|
||||||
|
|
||||||
|
|||||||
@@ -144,10 +144,9 @@ void ListenBrainzScrobbler::Authenticate() {
|
|||||||
|
|
||||||
bool result = QDesktopServices::openUrl(url);
|
bool result = QDesktopServices::openUrl(url);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
QMessageBox box(QMessageBox::NoIcon, "Scrobbler Authentication", QString("Please open this URL in your browser: <a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
|
QMessageBox messagebox(QMessageBox::Information, "ListenBrainz Authentication", QString("Please open this URL in your browser:<br /><a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
|
||||||
box.setTextFormat(Qt::RichText);
|
messagebox.setTextFormat(Qt::RichText);
|
||||||
qLog(Debug) << "Scrobbler authentication URL: " << url.toString();
|
messagebox.exec();
|
||||||
box.exec();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -241,7 +240,7 @@ void ListenBrainzScrobbler::AuthenticateReplyFinished(QNetworkReply *reply) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!json_obj.contains("access_token") || !json_obj.contains("expires_in") || !json_obj.contains("token_type") || !json_obj.contains("refresh_token")) {
|
if (!json_obj.contains("access_token") || !json_obj.contains("expires_in") || !json_obj.contains("token_type") || !json_obj.contains("refresh_token")) {
|
||||||
AuthError("Json session object is missing values.");
|
AuthError("Json access_token, expires_in or token_type is missing.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +288,7 @@ QByteArray ListenBrainzScrobbler::GetReplyData(QNetworkReply *reply) {
|
|||||||
Error(error_reason);
|
Error(error_reason);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// See if there is Json data containing "error" and "error_description" - then use that instead.
|
// See if there is Json data containing "code" and "error" - then use that instead.
|
||||||
data = reply->readAll();
|
data = reply->readAll();
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &error);
|
QJsonDocument json_doc = QJsonDocument::fromJson(data, &error);
|
||||||
@@ -299,8 +298,8 @@ QByteArray ListenBrainzScrobbler::GetReplyData(QNetworkReply *reply) {
|
|||||||
QJsonObject json_obj = json_doc.object();
|
QJsonObject json_obj = json_doc.object();
|
||||||
if (json_obj.contains("code") && json_obj.contains("error")) {
|
if (json_obj.contains("code") && json_obj.contains("error")) {
|
||||||
error_code = json_obj["code"].toInt();
|
error_code = json_obj["code"].toInt();
|
||||||
QString message = json_obj["error"].toString();
|
QString error_message = json_obj["error"].toString();
|
||||||
error_reason = QString("%1 (%2)").arg(message).arg(error_code);
|
error_reason = QString("%1 (%2)").arg(error_message).arg(error_code);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
error_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||||
@@ -460,7 +459,7 @@ void ListenBrainzScrobbler::ScrobbleRequestFinished(QNetworkReply *reply, QList<
|
|||||||
|
|
||||||
if (json_obj.contains("status")) {
|
if (json_obj.contains("status")) {
|
||||||
QString status = json_obj["status"].toString();
|
QString status = json_obj["status"].toString();
|
||||||
qLog(Debug) << "MusicBrainz: Received scrobble status:" << status;
|
qLog(Debug) << "ListenBrainz: Received scrobble status:" << status;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_->Flush(list);
|
cache_->Flush(list);
|
||||||
|
|||||||
@@ -22,7 +22,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QApplication>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -131,12 +133,27 @@ void ScrobblingAPI20::Authenticate() {
|
|||||||
url_query.addQueryItem("cb", redirect_url.toString());
|
url_query.addQueryItem("cb", redirect_url.toString());
|
||||||
url.setQuery(url_query);
|
url.setQuery(url_query);
|
||||||
|
|
||||||
bool result = QDesktopServices::openUrl(url);
|
QMessageBox messagebox(QMessageBox::Information, QString("%1 Scrobbler Authentication").arg(name_), QString("Open URL in web browser?<br /><a href=\"%1\">%1</a><br />Press \"Save\" to copy the URL to clipboard and manually open it in a web browser.").arg(url.toString()), QMessageBox::Open|QMessageBox::Save|QMessageBox::Cancel);
|
||||||
if (!result) {
|
messagebox.setTextFormat(Qt::RichText);
|
||||||
QMessageBox box(QMessageBox::NoIcon, "Scrobbler Authentication", QString("Please open this URL in your browser: <a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
|
int result = messagebox.exec();
|
||||||
box.setTextFormat(Qt::RichText);
|
switch (result) {
|
||||||
qLog(Debug) << "Scrobbler authentication URL: " << url.toString();
|
case QMessageBox::Open:{
|
||||||
box.exec();
|
bool openurl_result = QDesktopServices::openUrl(url);
|
||||||
|
if (openurl_result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
QMessageBox messagebox_error(QMessageBox::Warning, "Scrobbler Authentication", QString("Could not open URL. Please open this URL in your browser: <a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
|
||||||
|
messagebox_error.setTextFormat(Qt::RichText);
|
||||||
|
messagebox_error.exec();
|
||||||
|
}
|
||||||
|
case QMessageBox::Save:
|
||||||
|
QApplication::clipboard()->setText(url.toString());
|
||||||
|
break;
|
||||||
|
case QMessageBox::Cancel:
|
||||||
|
AuthError("Authentication was cancelled.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -466,7 +483,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, QList<quint6
|
|||||||
int error = json_obj["error"].toInt();
|
int error = json_obj["error"].toInt();
|
||||||
Error(QString("Error: %1: %2").arg(QString::number(error)).arg(error));
|
Error(QString("Error: %1: %2").arg(QString::number(error)).arg(error));
|
||||||
}
|
}
|
||||||
Error("Json reply from server is missing session.");
|
Error("Json reply from server is missing scrobbles.");
|
||||||
cache()->ClearSent(list);
|
cache()->ClearSent(list);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -612,7 +629,7 @@ void ScrobblingAPI20::SingleScrobbleRequestFinished(QNetworkReply *reply, quint6
|
|||||||
int error = json_obj["error"].toInt();
|
int error = json_obj["error"].toInt();
|
||||||
Error(QString("Error: %1: %2").arg(QString::number(error)).arg(error));
|
Error(QString("Error: %1: %2").arg(QString::number(error)).arg(error));
|
||||||
}
|
}
|
||||||
Error("Json reply from server is missing session.");
|
Error("Json reply from server is missing scrobbles.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user