mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Compile with Qt5
This commit is contained in:
parent
2ff4ebc72f
commit
878ae56a71
1 changed files with 20 additions and 12 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QSslSocket>
|
||||
#include <QNetworkCookieJar>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -83,10 +84,10 @@ void Account::save()
|
|||
}
|
||||
// ### TODO port away from ConfigFile
|
||||
MirallConfigFile cfg;
|
||||
qDebug() << "Saving " << approvedCerts().count() << " unknown certs.";
|
||||
qDebug() << "Saving " << approvedErrors().count() << " unknown errors.";
|
||||
QByteArray certs;
|
||||
Q_FOREACH( const QSslCertificate& cert, approvedCerts() ) {
|
||||
certs += cert.toPem() + '\n';
|
||||
Q_FOREACH( const QSslError& error, approvedErrors() ) {
|
||||
certs += error.certificate().toPem() + '\n';
|
||||
}
|
||||
if (!certs.isEmpty()) {
|
||||
cfg.setCaCerts( certs );
|
||||
|
@ -99,7 +100,11 @@ Account* Account::restore()
|
|||
if (!settings->childKeys().isEmpty()) {
|
||||
Account *acc = new Account;
|
||||
MirallConfigFile cfg;
|
||||
acc->setApprovedCerts(QSslCertificate::fromData(cfg.caCerts()));
|
||||
Q_FOREACH(QSslCertificate cert, QSslCertificate::fromData(cfg.caCerts())) {
|
||||
// ### TODO: We actually want to handle arbitrary errors, but would need to store
|
||||
// errors along with their certs (or vice versa) in the configuration file
|
||||
acc->addApprovedError(QSslError(QSslError::SelfSignedCertificate, cert));
|
||||
}
|
||||
acc->setUrl(settings->value(QLatin1String(urlC)).toUrl());
|
||||
acc->setCredentials(CredentialsFactory::create(settings->value(QLatin1String(authTypeC)).toString()));
|
||||
Q_FOREACH(QString key, settings->childKeys()) {
|
||||
|
@ -199,14 +204,19 @@ void Account::setCertificateChain(const QList<QSslCertificate> &certs)
|
|||
_certificateChain = certs;
|
||||
}
|
||||
|
||||
void Account::setApprovedCerts(const QList<QSslCertificate> certs)
|
||||
void Account::setApprovedErrors(const QList<QSslError> &errors)
|
||||
{
|
||||
_approvedCerts = certs;
|
||||
_approvedErrors = errors;
|
||||
}
|
||||
|
||||
void Account::addApprovedCerts(const QList<QSslCertificate> certs)
|
||||
void Account::addApprovedErrors(const QList<QSslError> &errors)
|
||||
{
|
||||
_approvedCerts += certs;
|
||||
_approvedErrors += errors;
|
||||
}
|
||||
|
||||
void Account::addApprovedError(const QSslError &error)
|
||||
{
|
||||
_approvedErrors += error;
|
||||
}
|
||||
|
||||
void Account::setSslErrorHandler(AbstractSslErrorHandler *handler)
|
||||
|
@ -287,13 +297,11 @@ void Account::slotHandleErrors(QNetworkReply *reply , QList<QSslError> errors)
|
|||
return;
|
||||
}
|
||||
|
||||
QList<QSslCertificate> approvedCerts;
|
||||
if (_sslErrorHandler.isNull() ) {
|
||||
qDebug() << Q_FUNC_INFO << "called without valid SSL error handler for account" << url();
|
||||
} else {
|
||||
if (_sslErrorHandler->handleErrors(errors, &approvedCerts, this)) {
|
||||
QSslSocket::addDefaultCaCertificates(approvedCerts);
|
||||
addApprovedCerts(approvedCerts);
|
||||
if (_sslErrorHandler->handleErrors(errors, this)) {
|
||||
addApprovedErrors(errors);
|
||||
// all ssl certs are known and accepted. We can ignore the problems right away.
|
||||
qDebug() << "Certs are already known and trusted, Warnings are not valid.";
|
||||
reply->ignoreSslErrors();
|
||||
|
|
Loading…
Reference in a new issue