mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 23:17:13 +03:00
Add dialog to connection wizard
When connecting to a https:// URL fails, present the user with three choices: * Try again with a http:// URL * Configure client-side TLS certificates * Go back and enter a different URL This allows users connecting with an ownCloud server secured with client-side TLS certificates to start the certificate import wizard manually instead of relying on a custom server error message.
This commit is contained in:
parent
6c3e19e531
commit
227b7ccabd
6 changed files with 176 additions and 11 deletions
|
@ -27,6 +27,7 @@ set(client_UI
|
|||
owncloudsetuppage.ui
|
||||
addcertificatedialog.ui
|
||||
wizard/owncloudadvancedsetuppage.ui
|
||||
wizard/owncloudconnectionmethoddialog.ui
|
||||
wizard/owncloudhttpcredspage.ui
|
||||
wizard/owncloudsetupnocredspage.ui
|
||||
wizard/owncloudwizardresultpage.ui
|
||||
|
@ -64,6 +65,7 @@ set(client_SRCS
|
|||
addcertificatedialog.cpp
|
||||
wizard/abstractcredswizardpage.cpp
|
||||
wizard/owncloudadvancedsetuppage.cpp
|
||||
wizard/owncloudconnectionmethoddialog.cpp
|
||||
wizard/owncloudhttpcredspage.cpp
|
||||
wizard/owncloudsetuppage.cpp
|
||||
wizard/owncloudshibbolethcredspage.cpp
|
||||
|
|
32
src/gui/wizard/owncloudconnectionmethoddialog.cpp
Normal file
32
src/gui/wizard/owncloudconnectionmethoddialog.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include "wizard/owncloudconnectionmethoddialog.h"
|
||||
|
||||
OwncloudConnectionMethodDialog::OwncloudConnectionMethodDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::OwncloudConnectionMethodDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->btnNoTLS, SIGNAL(clicked(bool)), this, SLOT(returnNoTLS()));
|
||||
connect(ui->btnClientSideTLS, SIGNAL(clicked(bool)), this, SLOT(returnClientSideTLS()));
|
||||
connect(ui->btnBack, SIGNAL(clicked(bool)), this, SLOT(returnBack()));
|
||||
}
|
||||
|
||||
void OwncloudConnectionMethodDialog::returnNoTLS()
|
||||
{
|
||||
done(No_TLS);
|
||||
}
|
||||
|
||||
void OwncloudConnectionMethodDialog::returnClientSideTLS()
|
||||
{
|
||||
done(Client_Side_TLS);
|
||||
}
|
||||
|
||||
void OwncloudConnectionMethodDialog::returnBack()
|
||||
{
|
||||
done(Back);
|
||||
}
|
||||
|
||||
OwncloudConnectionMethodDialog::~OwncloudConnectionMethodDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
34
src/gui/wizard/owncloudconnectionmethoddialog.h
Normal file
34
src/gui/wizard/owncloudconnectionmethoddialog.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef OWNCLOUDCONNECTIONMETHODDIALOG_H
|
||||
#define OWNCLOUDCONNECTIONMETHODDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ui_owncloudconnectionmethoddialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class OwncloudConnectionMethodDialog;
|
||||
}
|
||||
|
||||
class OwncloudConnectionMethodDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OwncloudConnectionMethodDialog(QWidget *parent = 0);
|
||||
~OwncloudConnectionMethodDialog();
|
||||
enum {
|
||||
No_TLS,
|
||||
Client_Side_TLS,
|
||||
Back
|
||||
};
|
||||
|
||||
public slots:
|
||||
void returnNoTLS();
|
||||
void returnClientSideTLS();
|
||||
void returnBack();
|
||||
|
||||
private:
|
||||
Ui::OwncloudConnectionMethodDialog *ui;
|
||||
};
|
||||
|
||||
#endif // OWNCLOUDCONNECTIONMETHODDIALOG_H
|
81
src/gui/wizard/owncloudconnectionmethoddialog.ui
Normal file
81
src/gui/wizard/owncloudconnectionmethoddialog.ui
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OwncloudConnectionMethodDialog</class>
|
||||
<widget class="QDialog" name="OwncloudConnectionMethodDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>401</width>
|
||||
<height>205</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Connection failed</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Failed to connect to the secure server address specified. How do you wish to proceed?</p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnNoTLS">
|
||||
<property name="text">
|
||||
<string>Try without TLS (not very secure)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnClientSideTLS">
|
||||
<property name="text">
|
||||
<string>Configure client-side TLS certificate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnBack">
|
||||
<property name="text">
|
||||
<string>Use a different URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "wizard/owncloudwizardcommon.h"
|
||||
#include "wizard/owncloudsetuppage.h"
|
||||
#include "wizard/owncloudconnectionmethoddialog.h"
|
||||
#include "../3rdparty/certificates/p12topem.h"
|
||||
#include "theme.h"
|
||||
#include "account.h"
|
||||
|
@ -236,18 +237,32 @@ void OwncloudSetupPage::setErrorString( const QString& err, bool retryHTTPonly )
|
|||
_ui.errorLabel->setVisible(false);
|
||||
} else {
|
||||
if (retryHTTPonly) {
|
||||
if (err.contains("SSL handshake failed", Qt::CaseInsensitive)) {
|
||||
slotAskSSLClientCertificate();
|
||||
} else {
|
||||
QString msg = tr("<p>Could not connect securely:</p><p>%1</p><p>Do you want to connect unencrypted instead (not recommended)?</p>").arg(err);
|
||||
QString title = tr("Connection failed");
|
||||
if (QMessageBox::question(this, title, msg, QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||
QUrl url(_ui.leUrl->text());
|
||||
if (url.scheme() == "https") {
|
||||
// Ask the user how to proceed when connecting to a https:// URL fails.
|
||||
// It is possible that the server is secured with client-side TLS certificates,
|
||||
// but that it has no way of informing the owncloud client that this is the case.
|
||||
|
||||
OwncloudConnectionMethodDialog dialog;
|
||||
int retVal = dialog.exec();
|
||||
|
||||
switch (retVal) {
|
||||
case OwncloudConnectionMethodDialog::No_TLS:
|
||||
{
|
||||
url.setScheme("http");
|
||||
_ui.leUrl->setText(url.toString());
|
||||
// skip ahead to next page, since the user would expect us to retry automatically
|
||||
wizard()->next();
|
||||
}
|
||||
break;
|
||||
case OwncloudConnectionMethodDialog::Client_Side_TLS:
|
||||
slotAskSSLClientCertificate();
|
||||
break;
|
||||
case OwncloudConnectionMethodDialog::Back:
|
||||
default:
|
||||
// No-op.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "wizard/owncloudwizard.h"
|
||||
|
||||
#include "../addcertificatedialog.h"
|
||||
#include "wizard/owncloudconnectionmethoddialog.h"
|
||||
|
||||
#include "ui_owncloudsetupnocredspage.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue