Replace qDebug() by report_info() in core/cloudstorage.cpp

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-26 15:49:55 +01:00 committed by bstoeger
parent 47254d91e0
commit 991b72d4ff

View file

@ -74,31 +74,30 @@ QNetworkReply* CloudStorageAuthenticate::deleteAccount(const QString& email, con
void CloudStorageAuthenticate::deleteFinished() void CloudStorageAuthenticate::deleteFinished()
{ {
QString cloudAuthReply(reply->readAll()); std::string cloudAuthReply = reply->readAll().toStdString();
qDebug() << "Completed connection with cloud storage backend, response" << cloudAuthReply; report_info("Completed connection with cloud storage backend, response %s", cloudAuthReply.c_str());
emit finishedDelete(); emit finishedDelete();
} }
void CloudStorageAuthenticate::uploadFinished() void CloudStorageAuthenticate::uploadFinished()
{ {
static QString myLastError; static std::string myLastError;
QString cloudAuthReply(reply->readAll()); std::string cloudAuthReply = reply->readAll().toStdString();
qDebug() << "Completed connection with cloud storage backend, response" << cloudAuthReply; report_info("Completed connection with cloud storage backend, response %s", cloudAuthReply.c_str());
if (cloudAuthReply == QLatin1String("[VERIFIED]") || cloudAuthReply == QLatin1String("[OK]")) { if (cloudAuthReply == "[VERIFIED]" || cloudAuthReply == "[OK]") {
qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_VERIFIED); qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_VERIFIED);
/* TODO: Move this to a correct place /* TODO: Move this to a correct place
NotificationWidget *nw = MainWindow::instance()->getNotificationWidget(); NotificationWidget *nw = MainWindow::instance()->getNotificationWidget();
if (nw->getNotificationText() == myLastError) if (nw->getNotificationText().toStdString() == myLastError)
nw->hideNotification(); nw->hideNotification();
*/ */
myLastError.clear(); myLastError.clear();
} else if (cloudAuthReply == QLatin1String("[VERIFY]") || } else if (cloudAuthReply == "[VERIFY]" || cloudAuthReply == "Invalid PIN") {
cloudAuthReply == QLatin1String("Invalid PIN")) {
qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_NEED_TO_VERIFY); qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_NEED_TO_VERIFY);
report_error("%s", qPrintable(tr("Cloud account verification required, enter PIN in preferences"))); report_error("%s", qPrintable(tr("Cloud account verification required, enter PIN in preferences")));
} else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) { } else if (cloudAuthReply == "[PASSWDCHANGED]") {
qPrefCloudStorage::set_cloud_storage_password(cloudNewPassword); qPrefCloudStorage::set_cloud_storage_password(cloudNewPassword);
cloudNewPassword.clear(); cloudNewPassword.clear();
emit passwordChangeSuccessful(); emit passwordChangeSuccessful();
@ -106,28 +105,28 @@ void CloudStorageAuthenticate::uploadFinished()
} else { } else {
qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_INCORRECT_USER_PASSWD); qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_INCORRECT_USER_PASSWD);
myLastError = cloudAuthReply; myLastError = cloudAuthReply;
report_error("%s", qPrintable(cloudAuthReply)); report_error("%s", cloudAuthReply.c_str());
} }
emit finishedAuthenticate(); emit finishedAuthenticate();
} }
void CloudStorageAuthenticate::uploadError(QNetworkReply::NetworkError) void CloudStorageAuthenticate::uploadError(QNetworkReply::NetworkError)
{ {
qDebug() << "Received error response from cloud storage backend:" << reply->errorString(); report_info("Received error response from cloud storage backend: %s", qPrintable(reply->errorString()));
} }
void CloudStorageAuthenticate::sslErrors(const QList<QSslError> &errorList) void CloudStorageAuthenticate::sslErrors(const QList<QSslError> &errorList)
{ {
if (verbose) { if (verbose) {
qDebug() << "Received error response trying to set up https connection with cloud storage backend:"; report_info("Received error response trying to set up https connection with cloud storage backend:");
for (QSslError err: errorList) { for (QSslError err: errorList) {
qDebug() << err.errorString(); report_info("%s", qPrintable(err.errorString()));
} }
} }
QSslConfiguration conf = reply->sslConfiguration(); QSslConfiguration conf = reply->sslConfiguration();
QSslCertificate cert = conf.peerCertificate(); QSslCertificate cert = conf.peerCertificate();
QByteArray hexDigest = cert.digest().toHex(); QByteArray hexDigest = cert.digest().toHex();
qDebug() << "got invalid SSL certificate with hex digest" << hexDigest; report_info("got invalid SSL certificate with hex digest %s", qPrintable(hexDigest));
} }
QNetworkAccessManager *manager() QNetworkAccessManager *manager()