2013-05-04 18:01:45 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2013-05-04 18:01:45 +04:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2017-05-09 15:24:11 +03:00
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonObject>
|
2017-08-24 13:38:00 +03:00
|
|
|
#include <QJsonArray>
|
2017-05-09 15:24:11 +03:00
|
|
|
#include <QLoggingCategory>
|
2013-10-21 23:42:52 +04:00
|
|
|
#include <QNetworkReply>
|
2015-03-24 23:30:42 +03:00
|
|
|
#include <QNetworkProxyFactory>
|
2017-11-10 11:57:42 +03:00
|
|
|
#include <QXmlStreamReader>
|
2013-05-04 18:01:45 +04:00
|
|
|
|
2014-07-11 02:31:24 +04:00
|
|
|
#include "connectionvalidator.h"
|
|
|
|
#include "account.h"
|
2020-02-14 04:10:01 +03:00
|
|
|
#include "accountstate.h"
|
|
|
|
#include "userinfo.h"
|
2014-07-11 02:31:24 +04:00
|
|
|
#include "networkjobs.h"
|
2015-03-24 23:30:42 +03:00
|
|
|
#include "clientproxy.h"
|
2014-03-03 20:55:15 +04:00
|
|
|
#include <creds/abstractcredentials.h>
|
2024-02-02 14:46:31 +03:00
|
|
|
#include "systray.h"
|
2013-05-04 18:01:45 +04:00
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2013-05-04 18:01:45 +04:00
|
|
|
|
2017-12-28 22:33:10 +03:00
|
|
|
Q_LOGGING_CATEGORY(lcConnectionValidator, "nextcloud.sync.connectionvalidator", QtInfoMsg)
|
2017-05-09 15:24:11 +03:00
|
|
|
|
2015-11-23 23:47:30 +03:00
|
|
|
// Make sure the timeout for this job is less than how often we get called
|
|
|
|
// This makes sure we get tried often enough without "ConnectionValidator already running"
|
2016-02-10 14:35:26 +03:00
|
|
|
static qint64 timeoutToUseMsec = qMax(1000, ConnectionValidator::DefaultCallingIntervalMsec - 5 * 1000);
|
2015-11-23 23:47:30 +03:00
|
|
|
|
2024-03-13 17:52:06 +03:00
|
|
|
ConnectionValidator::ConnectionValidator(AccountStatePtr accountState, const QStringList &previousErrors, QObject *parent)
|
2013-07-30 16:37:46 +04:00
|
|
|
: QObject(parent)
|
2024-03-13 17:52:06 +03:00
|
|
|
, _previousErrors(previousErrors)
|
2020-02-14 04:10:01 +03:00
|
|
|
, _accountState(accountState)
|
|
|
|
, _account(accountState->account())
|
2013-05-04 18:01:45 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-17 16:09:57 +03:00
|
|
|
void ConnectionValidator::checkServerAndAuth()
|
2013-05-04 18:01:45 +04:00
|
|
|
{
|
2014-12-03 15:10:49 +03:00
|
|
|
if (!_account) {
|
2020-01-30 20:40:08 +03:00
|
|
|
_errors << tr("No Nextcloud account configured");
|
2014-12-11 15:55:59 +03:00
|
|
|
reportResult(NotConfigured);
|
2014-12-03 15:10:49 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-05-09 15:24:11 +03:00
|
|
|
qCDebug(lcConnectionValidator) << "Checking server and authentication";
|
2015-03-27 13:53:58 +03:00
|
|
|
|
2015-02-05 17:18:38 +03:00
|
|
|
_isCheckingServerAndAuth = true;
|
2014-12-03 15:10:49 +03:00
|
|
|
|
2015-03-24 23:30:42 +03:00
|
|
|
// Lookup system proxy in a thread https://github.com/owncloud/client/issues/2993
|
2024-06-28 14:43:07 +03:00
|
|
|
if ((ClientProxy::isUsingSystemDefault() && _account->networkProxySetting() == Account::AccountNetworkProxySetting::GlobalProxy)
|
|
|
|
|| _account->proxyType() == QNetworkProxy::DefaultProxy) {
|
2017-05-09 15:24:11 +03:00
|
|
|
qCDebug(lcConnectionValidator) << "Trying to look up system proxy";
|
2024-06-28 14:43:07 +03:00
|
|
|
ClientProxy::lookupSystemProxyAsync(_account->url(), this, SLOT(systemProxyLookupDone(QNetworkProxy)));
|
2015-03-24 23:30:42 +03:00
|
|
|
} else {
|
2015-03-25 14:25:18 +03:00
|
|
|
// We want to reset the QNAM proxy so that the global proxy settings are used (via ClientProxy settings)
|
|
|
|
_account->networkAccessManager()->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
|
2015-03-24 23:30:42 +03:00
|
|
|
// use a queued invocation so we're as asynchronous as with the other code path
|
2023-06-28 20:18:39 +03:00
|
|
|
QMetaObject::invokeMethod(this, "slotCheckRedirectCostFreeUrl", Qt::QueuedConnection);
|
2015-03-24 23:30:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionValidator::systemProxyLookupDone(const QNetworkProxy &proxy)
|
|
|
|
{
|
|
|
|
if (!_account) {
|
2017-03-30 14:46:20 +03:00
|
|
|
qCWarning(lcConnectionValidator) << "Bailing out, Account had been deleted";
|
2015-03-24 23:30:42 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-17 13:02:15 +03:00
|
|
|
if (proxy.type() != QNetworkProxy::NoProxy) {
|
2020-06-18 22:05:11 +03:00
|
|
|
qCInfo(lcConnectionValidator) << "Setting QNAM proxy to be system proxy" << ClientProxy::printQNetworkProxy(proxy);
|
2015-11-17 13:02:15 +03:00
|
|
|
} else {
|
2017-03-30 14:46:20 +03:00
|
|
|
qCInfo(lcConnectionValidator) << "No system proxy set by OS";
|
2015-11-17 13:02:15 +03:00
|
|
|
}
|
2015-03-27 13:53:58 +03:00
|
|
|
_account->networkAccessManager()->setProxy(proxy);
|
2015-03-24 23:30:42 +03:00
|
|
|
|
2023-06-28 20:18:39 +03:00
|
|
|
slotCheckRedirectCostFreeUrl();
|
2015-03-24 23:30:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// The actual check
|
2023-06-28 20:18:39 +03:00
|
|
|
|
|
|
|
void ConnectionValidator::slotCheckRedirectCostFreeUrl()
|
|
|
|
{
|
|
|
|
const auto checkJob = new CheckRedirectCostFreeUrlJob(_account, this);
|
|
|
|
checkJob->setTimeout(timeoutToUseMsec);
|
|
|
|
checkJob->setIgnoreCredentialFailure(true);
|
|
|
|
connect(checkJob, &CheckRedirectCostFreeUrlJob::timeout, this, &ConnectionValidator::slotJobTimeout);
|
|
|
|
connect(checkJob, &CheckRedirectCostFreeUrlJob::jobFinished, this, &ConnectionValidator::slotCheckRedirectCostFreeUrlFinished);
|
|
|
|
checkJob->start();
|
|
|
|
}
|
|
|
|
|
2015-03-24 23:30:42 +03:00
|
|
|
void ConnectionValidator::slotCheckServerAndAuth()
|
|
|
|
{
|
2020-05-18 21:54:23 +03:00
|
|
|
auto *checkJob = new CheckServerJob(_account, this);
|
2015-11-23 23:47:30 +03:00
|
|
|
checkJob->setTimeout(timeoutToUseMsec);
|
2014-12-17 16:09:57 +03:00
|
|
|
checkJob->setIgnoreCredentialFailure(true);
|
2017-09-20 11:14:48 +03:00
|
|
|
connect(checkJob, &CheckServerJob::instanceFound, this, &ConnectionValidator::slotStatusFound);
|
|
|
|
connect(checkJob, &CheckServerJob::instanceNotFound, this, &ConnectionValidator::slotNoStatusFound);
|
|
|
|
connect(checkJob, &CheckServerJob::timeout, this, &ConnectionValidator::slotJobTimeout);
|
2014-12-17 16:09:57 +03:00
|
|
|
checkJob->start();
|
2013-05-04 18:01:45 +04:00
|
|
|
}
|
|
|
|
|
2023-06-28 20:18:39 +03:00
|
|
|
void ConnectionValidator::slotCheckRedirectCostFreeUrlFinished(int statusCode)
|
|
|
|
{
|
|
|
|
if (statusCode >= 301 && statusCode <= 307) {
|
|
|
|
reportResult(StatusRedirect);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
slotCheckServerAndAuth();
|
|
|
|
}
|
|
|
|
|
2017-04-26 13:15:33 +03:00
|
|
|
void ConnectionValidator::slotStatusFound(const QUrl &url, const QJsonObject &info)
|
2013-05-04 18:01:45 +04:00
|
|
|
{
|
2017-04-19 12:02:03 +03:00
|
|
|
// Newer servers don't disclose any version in status.php anymore
|
|
|
|
// https://github.com/owncloud/core/pull/27473/files
|
|
|
|
// so this string can be empty.
|
|
|
|
QString serverVersion = CheckServerJob::version(info);
|
|
|
|
|
2013-05-04 18:01:45 +04:00
|
|
|
// status.php was found.
|
2017-03-30 14:46:20 +03:00
|
|
|
qCInfo(lcConnectionValidator) << "** Application: ownCloud found: "
|
2013-10-28 23:01:59 +04:00
|
|
|
<< url << " with version "
|
2013-10-23 16:48:44 +04:00
|
|
|
<< CheckServerJob::versionString(info)
|
2017-04-19 12:02:03 +03:00
|
|
|
<< "(" << serverVersion << ")";
|
2015-02-12 14:59:00 +03:00
|
|
|
|
2017-09-08 12:59:45 +03:00
|
|
|
// Update server url in case of redirection
|
|
|
|
if (_account->url() != url) {
|
|
|
|
qCInfo(lcConnectionValidator()) << "status.php was redirected to" << url.toString();
|
|
|
|
_account->setUrl(url);
|
2022-12-19 17:11:18 +03:00
|
|
|
emit _account->wantsAccountSaved(_account.data());
|
2017-09-08 12:59:45 +03:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:02:03 +03:00
|
|
|
if (!serverVersion.isEmpty() && !setAndCheckServerVersion(serverVersion)) {
|
2013-05-04 18:01:45 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-06 11:45:15 +03:00
|
|
|
// Check for maintenance mode: Servers send "true", so go through QVariant
|
|
|
|
// to parse it correctly.
|
|
|
|
if (info["maintenance"].toVariant().toBool()) {
|
2017-05-08 13:39:08 +03:00
|
|
|
reportResult(MaintenanceMode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-03 15:10:49 +03:00
|
|
|
// now check the authentication
|
2017-09-20 11:14:48 +03:00
|
|
|
QTimer::singleShot(0, this, &ConnectionValidator::checkAuthentication);
|
2013-05-04 18:01:45 +04:00
|
|
|
}
|
|
|
|
|
2015-02-11 11:23:04 +03:00
|
|
|
// status.php could not be loaded (network or server issue!).
|
2013-10-28 23:01:59 +04:00
|
|
|
void ConnectionValidator::slotNoStatusFound(QNetworkReply *reply)
|
2013-05-04 18:01:45 +04:00
|
|
|
{
|
2017-03-23 17:53:22 +03:00
|
|
|
auto job = qobject_cast<CheckServerJob *>(sender());
|
2021-12-16 19:23:03 +03:00
|
|
|
qCWarning(lcConnectionValidator) << reply->error() << reply->errorString() << job->errorString() << reply->peek(1024);
|
2017-04-27 14:58:26 +03:00
|
|
|
if (reply->error() == QNetworkReply::SslHandshakeFailedError) {
|
|
|
|
reportResult(SslError);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_account->credentials()->stillValid(reply)) {
|
|
|
|
// Note: Why would this happen on a status.php request?
|
2015-03-10 14:14:14 +03:00
|
|
|
_errors.append(tr("Authentication error: Either username or password are wrong."));
|
2017-03-23 17:53:22 +03:00
|
|
|
} else {
|
2015-09-13 03:57:49 +03:00
|
|
|
//_errors.append(tr("Unable to connect to %1").arg(_account->url().toString()));
|
2017-03-23 17:53:22 +03:00
|
|
|
_errors.append(job->errorString());
|
2015-03-10 14:14:14 +03:00
|
|
|
}
|
2014-12-11 15:55:59 +03:00
|
|
|
reportResult(StatusNotFound);
|
2014-09-12 19:58:01 +04:00
|
|
|
}
|
|
|
|
|
2014-12-11 15:55:59 +03:00
|
|
|
void ConnectionValidator::slotJobTimeout(const QUrl &url)
|
2014-09-12 19:58:01 +04:00
|
|
|
{
|
2015-09-16 04:08:27 +03:00
|
|
|
Q_UNUSED(url);
|
2015-09-13 03:57:49 +03:00
|
|
|
//_errors.append(tr("Unable to connect to %1").arg(url.toString()));
|
2021-04-26 20:27:26 +03:00
|
|
|
_errors.append(tr("Timeout"));
|
2014-12-11 17:43:48 +03:00
|
|
|
reportResult(Timeout);
|
2013-05-04 18:01:45 +04:00
|
|
|
}
|
|
|
|
|
2014-09-12 19:58:01 +04:00
|
|
|
|
2014-12-17 16:09:57 +03:00
|
|
|
void ConnectionValidator::checkAuthentication()
|
2013-05-04 18:01:45 +04:00
|
|
|
{
|
2014-03-03 20:55:15 +04:00
|
|
|
AbstractCredentials *creds = _account->credentials();
|
2014-12-03 15:10:49 +03:00
|
|
|
|
2017-04-27 14:58:26 +03:00
|
|
|
if (!creds->ready()) {
|
|
|
|
reportResult(CredentialsNotReady);
|
|
|
|
return;
|
2015-01-21 17:30:25 +03:00
|
|
|
}
|
|
|
|
|
2013-05-04 18:01:45 +04:00
|
|
|
// simply GET the webdav root, will fail if credentials are wrong.
|
|
|
|
// continue in slotAuthCheck here :-)
|
2017-05-09 15:24:11 +03:00
|
|
|
qCDebug(lcConnectionValidator) << "# Check whether authenticated propfind works.";
|
2020-05-18 21:54:23 +03:00
|
|
|
auto *job = new PropfindJob(_account, "/", this);
|
2015-11-23 23:47:30 +03:00
|
|
|
job->setTimeout(timeoutToUseMsec);
|
2013-11-22 17:01:11 +04:00
|
|
|
job->setProperties(QList<QByteArray>() << "getlastmodified");
|
2017-09-20 11:14:48 +03:00
|
|
|
connect(job, &PropfindJob::result, this, &ConnectionValidator::slotAuthSuccess);
|
|
|
|
connect(job, &PropfindJob::finishedWithError, this, &ConnectionValidator::slotAuthFailed);
|
2013-11-22 17:01:11 +04:00
|
|
|
job->start();
|
2013-05-04 18:01:45 +04:00
|
|
|
}
|
|
|
|
|
2013-10-28 23:01:59 +04:00
|
|
|
void ConnectionValidator::slotAuthFailed(QNetworkReply *reply)
|
2013-05-04 18:01:45 +04:00
|
|
|
{
|
2017-03-23 17:53:22 +03:00
|
|
|
auto job = qobject_cast<PropfindJob *>(sender());
|
2014-12-11 17:43:48 +03:00
|
|
|
Status stat = Timeout;
|
2013-05-04 18:01:45 +04:00
|
|
|
|
2017-04-27 14:58:26 +03:00
|
|
|
if (reply->error() == QNetworkReply::SslHandshakeFailedError) {
|
|
|
|
_errors << job->errorStringParsingBody();
|
|
|
|
stat = SslError;
|
|
|
|
|
|
|
|
} else if (reply->error() == QNetworkReply::AuthenticationRequiredError
|
|
|
|
|| !_account->credentials()->stillValid(reply)) {
|
2017-03-30 14:46:20 +03:00
|
|
|
qCWarning(lcConnectionValidator) << "******** Password is wrong!" << reply->error() << job->errorString();
|
2013-09-11 12:24:31 +04:00
|
|
|
_errors << tr("The provided credentials are not correct");
|
2017-04-27 14:58:26 +03:00
|
|
|
stat = CredentialsWrong;
|
2013-11-25 18:33:35 +04:00
|
|
|
|
2013-10-28 23:01:59 +04:00
|
|
|
} else if (reply->error() != QNetworkReply::NoError) {
|
2017-03-23 17:53:22 +03:00
|
|
|
_errors << job->errorStringParsingBody();
|
2015-02-25 11:49:39 +03:00
|
|
|
|
|
|
|
const int httpStatus =
|
|
|
|
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
|
|
|
if (httpStatus == 503) {
|
2015-04-24 12:32:47 +03:00
|
|
|
_errors.clear();
|
|
|
|
stat = ServiceUnavailable;
|
2015-02-25 11:49:39 +03:00
|
|
|
}
|
2013-05-04 18:01:45 +04:00
|
|
|
}
|
|
|
|
|
2014-12-11 15:55:59 +03:00
|
|
|
reportResult(stat);
|
2013-05-04 18:01:45 +04:00
|
|
|
}
|
|
|
|
|
2013-10-23 16:48:44 +04:00
|
|
|
void ConnectionValidator::slotAuthSuccess()
|
|
|
|
{
|
2014-12-11 15:55:59 +03:00
|
|
|
_errors.clear();
|
2015-02-05 17:18:38 +03:00
|
|
|
if (!_isCheckingServerAndAuth) {
|
|
|
|
reportResult(Connected);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
checkServerCapabilities();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionValidator::checkServerCapabilities()
|
|
|
|
{
|
2017-11-10 11:57:42 +03:00
|
|
|
// The main flow now needs the capabilities
|
2020-05-18 21:54:23 +03:00
|
|
|
auto *job = new JsonApiJob(_account, QLatin1String("ocs/v1.php/cloud/capabilities"), this);
|
2016-04-27 13:19:49 +03:00
|
|
|
job->setTimeout(timeoutToUseMsec);
|
2017-09-20 11:14:48 +03:00
|
|
|
QObject::connect(job, &JsonApiJob::jsonReceived, this, &ConnectionValidator::slotCapabilitiesRecieved);
|
2015-02-05 17:18:38 +03:00
|
|
|
job->start();
|
|
|
|
}
|
|
|
|
|
2017-04-26 13:15:33 +03:00
|
|
|
void ConnectionValidator::slotCapabilitiesRecieved(const QJsonDocument &json)
|
2015-02-05 17:18:38 +03:00
|
|
|
{
|
2017-04-26 13:15:33 +03:00
|
|
|
auto caps = json.object().value("ocs").toObject().value("data").toObject().value("capabilities").toObject();
|
2017-03-30 14:46:20 +03:00
|
|
|
qCInfo(lcConnectionValidator) << "Server capabilities" << caps;
|
2017-04-26 13:15:33 +03:00
|
|
|
_account->setCapabilities(caps.toVariantMap());
|
2017-04-19 12:02:03 +03:00
|
|
|
|
|
|
|
// New servers also report the version in the capabilities
|
2017-04-26 13:15:33 +03:00
|
|
|
QString serverVersion = caps["core"].toObject()["status"].toObject()["version"].toString();
|
2017-04-19 12:02:03 +03:00
|
|
|
if (!serverVersion.isEmpty() && !setAndCheckServerVersion(serverVersion)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-18 17:07:51 +03:00
|
|
|
// Check for the directEditing capability
|
|
|
|
QUrl directEditingURL = QUrl(caps["files"].toObject()["directEditing"].toObject()["url"].toString());
|
|
|
|
QString directEditingETag = caps["files"].toObject()["directEditing"].toObject()["etag"].toString();
|
|
|
|
_account->fetchDirectEditors(directEditingURL, directEditingETag);
|
|
|
|
|
2016-09-16 16:49:43 +03:00
|
|
|
fetchUser();
|
2014-12-11 15:55:59 +03:00
|
|
|
}
|
|
|
|
|
2016-09-16 16:49:43 +03:00
|
|
|
void ConnectionValidator::fetchUser()
|
|
|
|
{
|
2020-05-18 21:54:23 +03:00
|
|
|
auto *userInfo = new UserInfo(_accountState.data(), true, true, this);
|
2020-02-14 04:10:01 +03:00
|
|
|
QObject::connect(userInfo, &UserInfo::fetchedLastInfo, this, &ConnectionValidator::slotUserFetched);
|
|
|
|
userInfo->setActive(true);
|
2016-09-16 16:49:43 +03:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:02:03 +03:00
|
|
|
bool ConnectionValidator::setAndCheckServerVersion(const QString &version)
|
|
|
|
{
|
2017-05-09 15:24:11 +03:00
|
|
|
qCInfo(lcConnectionValidator) << _account->url() << "has server version" << version;
|
2017-04-19 12:02:03 +03:00
|
|
|
_account->setServerVersion(version);
|
|
|
|
|
2018-03-01 11:15:17 +03:00
|
|
|
// We cannot deal with servers < 7.0.0
|
2017-04-19 12:02:03 +03:00
|
|
|
if (_account->serverVersionInt()
|
2018-03-01 11:15:17 +03:00
|
|
|
&& _account->serverVersionInt() < Account::makeServerVersion(7, 0, 0)) {
|
2017-04-19 12:02:03 +03:00
|
|
|
_errors.append(tr("The configured server for this client is too old"));
|
|
|
|
_errors.append(tr("Please update to the latest server and restart the client."));
|
|
|
|
reportResult(ServerVersionMismatch);
|
|
|
|
return false;
|
|
|
|
}
|
2018-03-01 11:15:17 +03:00
|
|
|
// We attempt to work with servers >= 7.0.0 but warn users.
|
2017-04-19 12:02:03 +03:00
|
|
|
// Check usages of Account::serverVersionUnsupported() for details.
|
|
|
|
|
2017-05-22 15:41:06 +03:00
|
|
|
// Record that the server supports HTTP/2
|
2018-02-09 18:06:38 +03:00
|
|
|
// Actual decision if we should use HTTP/2 is done in AccessManager::createRequest
|
2017-05-22 15:41:06 +03:00
|
|
|
if (auto job = qobject_cast<AbstractNetworkJob *>(sender())) {
|
|
|
|
if (auto reply = job->reply()) {
|
|
|
|
_account->setHttp2Supported(
|
2022-08-04 19:17:34 +03:00
|
|
|
reply->attribute(QNetworkRequest::Http2WasUsedAttribute).toBool());
|
2017-05-22 15:41:06 +03:00
|
|
|
}
|
|
|
|
}
|
2017-04-19 12:02:03 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-14 04:10:01 +03:00
|
|
|
void ConnectionValidator::slotUserFetched(UserInfo *userInfo)
|
2016-09-16 16:49:43 +03:00
|
|
|
{
|
2020-02-14 04:10:01 +03:00
|
|
|
if(userInfo) {
|
|
|
|
userInfo->setActive(false);
|
|
|
|
userInfo->deleteLater();
|
2017-10-05 22:08:38 +03:00
|
|
|
}
|
2020-02-14 04:10:01 +03:00
|
|
|
|
2017-11-23 12:11:39 +03:00
|
|
|
#ifndef TOKEN_AUTH_ONLY
|
2020-02-14 04:10:01 +03:00
|
|
|
connect(_account->e2e(), &ClientSideEncryption::initializationFinished, this, &ConnectionValidator::reportConnected);
|
2021-01-19 17:09:38 +03:00
|
|
|
_account->e2e()->initialize(_account);
|
2017-11-23 12:11:39 +03:00
|
|
|
#else
|
|
|
|
reportResult(Connected);
|
|
|
|
#endif
|
2017-01-22 15:55:08 +03:00
|
|
|
}
|
|
|
|
|
2017-11-23 12:11:39 +03:00
|
|
|
#ifndef TOKEN_AUTH_ONLY
|
2017-09-11 17:52:57 +03:00
|
|
|
void ConnectionValidator::reportConnected() {
|
2016-09-16 16:49:43 +03:00
|
|
|
reportResult(Connected);
|
|
|
|
}
|
2017-11-23 12:11:39 +03:00
|
|
|
#endif
|
2015-02-05 17:18:38 +03:00
|
|
|
|
2014-12-11 15:55:59 +03:00
|
|
|
void ConnectionValidator::reportResult(Status status)
|
|
|
|
{
|
|
|
|
emit connectionResult(status, _errors);
|
2024-02-07 21:43:35 +03:00
|
|
|
|
|
|
|
// notify user of errors
|
2024-03-13 17:52:06 +03:00
|
|
|
if (!_errors.isEmpty() && _previousErrors != _errors) {
|
2024-02-07 21:43:35 +03:00
|
|
|
showSystrayErrorMessage();
|
|
|
|
}
|
|
|
|
|
2014-12-11 15:55:59 +03:00
|
|
|
deleteLater();
|
2013-05-04 18:01:45 +04:00
|
|
|
}
|
2013-10-23 16:48:44 +04:00
|
|
|
|
2024-02-02 14:46:31 +03:00
|
|
|
void ConnectionValidator::showSystrayErrorMessage()
|
|
|
|
{
|
2024-03-06 20:07:56 +03:00
|
|
|
Systray::instance()->showMessage(tr("Connection issue"),
|
2024-02-02 14:46:31 +03:00
|
|
|
_errors.join("<br>"),
|
|
|
|
QSystemTrayIcon::Warning);
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
} // namespace OCC
|