Use QStringLiteral

This commit is contained in:
Jonas Kvinge
2024-04-09 23:20:26 +02:00
parent 3cfffa5fbb
commit 58944993b8
233 changed files with 3885 additions and 3885 deletions

View File

@@ -77,7 +77,7 @@ constexpr char QobuzService::kAlbumsSongsFtsTable[] = "qobuz_albums_songs_fts";
constexpr char QobuzService::kSongsFtsTable[] = "qobuz_songs_fts";
QobuzService::QobuzService(Application *app, QObject *parent)
: InternetService(Song::Source::Qobuz, "Qobuz", "qobuz", QobuzSettingsPage::kSettingsGroup, SettingsDialog::Page::Qobuz, app, parent),
: InternetService(Song::Source::Qobuz, QStringLiteral("Qobuz"), QStringLiteral("qobuz"), QobuzSettingsPage::kSettingsGroup, SettingsDialog::Page::Qobuz, app, parent),
app_(app),
network_(app->network()),
url_handler_(new QobuzUrlHandler(app, this)),
@@ -338,7 +338,7 @@ void QobuzService::HandleAuthReply(QNetworkReply *reply) {
if (reply->error() != QNetworkReply::NoError || reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
if (reply->error() != QNetworkReply::NoError && reply->error() < 200) {
// This is a network error, there is nothing more to do.
LoginError(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
LoginError(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
return;
}
else {
@@ -348,18 +348,18 @@ void QobuzService::HandleAuthReply(QNetworkReply *reply) {
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
if (json_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
QJsonObject json_obj = json_doc.object();
if (!json_obj.isEmpty() && json_obj.contains("status") && json_obj.contains("code") && json_obj.contains("message")) {
int code = json_obj["code"].toInt();
QString message = json_obj["message"].toString();
login_errors_ << QString("%1 (%2)").arg(message).arg(code);
if (!json_obj.isEmpty() && json_obj.contains(QStringLiteral("status")) && json_obj.contains(QStringLiteral("code")) && json_obj.contains(QStringLiteral("message"))) {
int code = json_obj[QStringLiteral("code")].toInt();
QString message = json_obj[QStringLiteral("message")].toString();
login_errors_ << QStringLiteral("%1 (%2)").arg(message).arg(code);
}
}
if (login_errors_.isEmpty()) {
if (reply->error() != QNetworkReply::NoError) {
login_errors_ << QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
login_errors_ << QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error());
}
else {
login_errors_ << QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
login_errors_ << QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
}
}
LoginError();
@@ -374,82 +374,82 @@ void QobuzService::HandleAuthReply(QNetworkReply *reply) {
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
if (json_error.error != QJsonParseError::NoError) {
LoginError("Authentication reply from server missing Json data.");
LoginError(QStringLiteral("Authentication reply from server missing Json data."));
return;
}
if (json_doc.isEmpty()) {
LoginError("Authentication reply from server has empty Json document.");
LoginError(QStringLiteral("Authentication reply from server has empty Json document."));
return;
}
if (!json_doc.isObject()) {
LoginError("Authentication reply from server has Json document that is not an object.", json_doc);
LoginError(QStringLiteral("Authentication reply from server has Json document that is not an object."), json_doc);
return;
}
QJsonObject json_obj = json_doc.object();
if (json_obj.isEmpty()) {
LoginError("Authentication reply from server has empty Json object.", json_doc);
LoginError(QStringLiteral("Authentication reply from server has empty Json object."), json_doc);
return;
}
if (!json_obj.contains("user_auth_token")) {
LoginError("Authentication reply from server is missing user_auth_token", json_obj);
if (!json_obj.contains(QStringLiteral("user_auth_token"))) {
LoginError(QStringLiteral("Authentication reply from server is missing user_auth_token"), json_obj);
return;
}
user_auth_token_ = json_obj["user_auth_token"].toString();
user_auth_token_ = json_obj[QStringLiteral("user_auth_token")].toString();
if (!json_obj.contains("user")) {
LoginError("Authentication reply from server is missing user", json_obj);
if (!json_obj.contains(QStringLiteral("user"))) {
LoginError(QStringLiteral("Authentication reply from server is missing user"), json_obj);
return;
}
QJsonValue value_user = json_obj["user"];
QJsonValue value_user = json_obj[QStringLiteral("user")];
if (!value_user.isObject()) {
LoginError("Authentication reply user is not a object", json_obj);
LoginError(QStringLiteral("Authentication reply user is not a object"), json_obj);
return;
}
QJsonObject obj_user = value_user.toObject();
if (!obj_user.contains("id")) {
LoginError("Authentication reply from server is missing user id", obj_user);
if (!obj_user.contains(QStringLiteral("id"))) {
LoginError(QStringLiteral("Authentication reply from server is missing user id"), obj_user);
return;
}
user_id_ = obj_user["id"].toInt();
user_id_ = obj_user[QStringLiteral("id")].toInt();
if (!obj_user.contains("device")) {
LoginError("Authentication reply from server is missing user device", obj_user);
if (!obj_user.contains(QStringLiteral("device"))) {
LoginError(QStringLiteral("Authentication reply from server is missing user device"), obj_user);
return;
}
QJsonValue value_device = obj_user["device"];
QJsonValue value_device = obj_user[QStringLiteral("device")];
if (!value_device.isObject()) {
LoginError("Authentication reply from server user device is not a object", value_device);
LoginError(QStringLiteral("Authentication reply from server user device is not a object"), value_device);
return;
}
QJsonObject obj_device = value_device.toObject();
if (!obj_device.contains("device_manufacturer_id")) {
LoginError("Authentication reply from server device is missing device_manufacturer_id", obj_device);
if (!obj_device.contains(QStringLiteral("device_manufacturer_id"))) {
LoginError(QStringLiteral("Authentication reply from server device is missing device_manufacturer_id"), obj_device);
return;
}
device_id_ = obj_device["device_manufacturer_id"].toString();
device_id_ = obj_device[QStringLiteral("device_manufacturer_id")].toString();
if (!obj_user.contains("credential")) {
LoginError("Authentication reply from server is missing user credential", obj_user);
if (!obj_user.contains(QStringLiteral("credential"))) {
LoginError(QStringLiteral("Authentication reply from server is missing user credential"), obj_user);
return;
}
QJsonValue value_credential = obj_user["credential"];
QJsonValue value_credential = obj_user[QStringLiteral("credential")];
if (!value_credential.isObject()) {
LoginError("Authentication reply from serve userr credential is not a object", value_device);
LoginError(QStringLiteral("Authentication reply from serve userr credential is not a object"), value_device);
return;
}
QJsonObject obj_credential = value_credential.toObject();
if (!obj_credential.contains("id")) {
LoginError("Authentication reply user credential from server is missing user credential id", obj_credential);
if (!obj_credential.contains(QStringLiteral("id"))) {
LoginError(QStringLiteral("Authentication reply user credential from server is missing user credential id"), obj_credential);
return;
}
credential_id_ = obj_credential["id"].toInt();
credential_id_ = obj_credential[QStringLiteral("id")].toInt();
QSettings s;
s.beginGroup(QobuzSettingsPage::kSettingsGroup);