Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display a message to upgrade client if minimumSupportedDesktopVersion is thrown #6405

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/accountsettings.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/accountsettings.cpp

File src/gui/accountsettings.cpp does not conform to Custom style guidelines. (lines 1279, 1280)
* Copyright (C) by Daniel Molkentin <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -1105,10 +1105,10 @@
_ui->connectLabel->setStyleSheet({});
} else {
errors.prepend(message);
auto msg = errors.join(QLatin1String("\n"));
qCDebug(lcAccountSettings) << msg;
Theme::replaceLinkColorString(msg, QColor("#c1c8e6"));
_ui->connectLabel->setText(msg);
auto userFriendlyMsg = errors.join(QLatin1String("<br>"));
qCDebug(lcAccountSettings) << userFriendlyMsg;
Theme::replaceLinkColorString(userFriendlyMsg, QColor("#c1c8e6"));
_ui->connectLabel->setText(userFriendlyMsg);
_ui->connectLabel->setToolTip({});
_ui->connectLabel->setStyleSheet(errStyle);
}
Expand Down Expand Up @@ -1276,9 +1276,9 @@
break;
}
case AccountState::NetworkError:
showConnectionLabel(tr("No connection to %1 at %2.")
.arg(Utility::escape(Theme::instance()->appNameGUI()), server),
_accountState->connectionErrors());
showConnectionLabel(tr("Unable to connect to %1.")
.arg(Utility::escape(Theme::instance()->appNameGUI())),
_accountState->connectionErrors());
break;
case AccountState::ConfigurationError:
showConnectionLabel(tr("Server configuration error: %1 at %2.")
Expand Down
9 changes: 9 additions & 0 deletions src/gui/connectionvalidator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/connectionvalidator.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/connectionvalidator.cpp

File src/gui/connectionvalidator.cpp does not conform to Custom style guidelines. (lines 338, 339)
* Copyright (C) by Klaas Freitag <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -27,6 +27,7 @@
#include "networkjobs.h"
#include "clientproxy.h"
#include <creds/abstractcredentials.h>
#include "systray.h"

namespace OCC {

Expand Down Expand Up @@ -328,7 +329,15 @@
void ConnectionValidator::reportResult(Status status)
{
emit connectionResult(status, _errors);
showSystrayErrorMessage();
deleteLater();
}

void ConnectionValidator::showSystrayErrorMessage()
{
Systray::instance()->showMessage(tr("Network Error"),
_errors.join("<br>"),
QSystemTrayIcon::Warning);
}

} // namespace OCC
2 changes: 2 additions & 0 deletions src/gui/connectionvalidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ protected slots:
AccountStatePtr _accountState;
AccountPtr _account;
bool _isCheckingServerAndAuth = false;

void showSystrayErrorMessage();
};
}

Expand Down
24 changes: 15 additions & 9 deletions src/libsync/abstractnetworkjob.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/abstractnetworkjob.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/abstractnetworkjob.cpp

File src/libsync/abstractnetworkjob.cpp does not conform to Custom style guidelines. (lines 472, 473, 474)
* Copyright (C) by Klaas Freitag <[email protected]>
* Copyright (C) by Daniel Molkentin <[email protected]>
*
Expand Down Expand Up @@ -323,20 +323,20 @@

QString AbstractNetworkJob::errorStringParsingBody(QByteArray *body)
{
QString base = errorString();
const auto base = errorString();
if (base.isEmpty() || !reply()) {
return QString();
}

QByteArray replyBody = reply()->readAll();
const auto replyBody = reply()->readAll();
if (body) {
*body = replyBody;
}

QString extra = extractErrorMessage(replyBody);
const auto extra = extractErrorMessage(replyBody);
// Don't append the XML error message to a OC-ErrorString message.
if (!extra.isEmpty() && !reply()->hasRawHeader("OC-ErrorString")) {
return QString::fromLatin1("%1 (%2)").arg(base, extra);
return extra;
}

return base;
Expand Down Expand Up @@ -416,7 +416,7 @@
while (!reader.atEnd() && !reader.hasError()) {
reader.readNextStartElement();
if (reader.name() == QLatin1String("message")) {
QString message = reader.readElementText();
const auto message = reader.readElementText();
if (!message.isEmpty()) {
return message;
}
Expand Down Expand Up @@ -457,16 +457,22 @@

QString networkReplyErrorString(const QNetworkReply &reply)
{
QString base = reply.errorString();
int httpStatus = reply.attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
QString httpReason = reply.attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
const auto base = reply.errorString();
const auto httpStatus = reply.attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
const auto httpReason = reply.attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();

// Only adjust HTTP error messages of the expected format.
if (httpReason.isEmpty() || httpStatus == 0 || !base.contains(httpReason)) {
return base;
}

return AbstractNetworkJob::tr(R"(Server replied "%1 %2" to "%3 %4")").arg(QString::number(httpStatus), httpReason, HttpLogger::requestVerb(reply), reply.request().url().toDisplayString());
const auto displayString = reply.request().url().toDisplayString();
const auto requestVerb = HttpLogger::requestVerb(reply);

return AbstractNetworkJob::tr(R"(Server replied "%1 %2" to "%3 %4")").arg(QString::number(httpStatus),
httpReason,
requestVerb,
displayString);
}

void AbstractNetworkJob::retry()
Expand Down
Loading