aboutsummaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/direct_connect_dialog.cpp15
-rw-r--r--src/widgets/server_editor_dialog.cpp3
-rw-r--r--src/widgets/server_editor_dialog.h2
3 files changed, 13 insertions, 7 deletions
diff --git a/src/widgets/direct_connect_dialog.cpp b/src/widgets/direct_connect_dialog.cpp
index f8c77b85..9859889d 100644
--- a/src/widgets/direct_connect_dialog.cpp
+++ b/src/widgets/direct_connect_dialog.cpp
@@ -51,7 +51,7 @@ void DirectConnectDialog::onConnectPressed()
QString l_hostname = ui_direct_hostname_edit->text();
if (!SCHEME_PATTERN.match(l_hostname).hasMatch())
{
- l_hostname = "ws://" % l_hostname;
+ l_hostname = "wss://" % l_hostname;
}
QUrl l_url(l_hostname);
@@ -61,20 +61,21 @@ void DirectConnectDialog::onConnectPressed()
return;
}
- if (l_url.scheme() != "ws")
+ if (l_url.scheme() != "ws" && l_url.scheme() != "wss")
{
- call_error(tr("Invalid URL scheme. Only ws:// is supported."));
+ call_error(tr("Invalid URL scheme. Only ws: and wss: are supported."));
return;
}
- if (l_url.port() == -1)
+ int port = l_url.port();
+ if (port == -1)
{
- call_error(tr("Invalid server port."));
- return;
+ port = (l_url.scheme() == "wss") ? 443 : 80;
}
ServerInfo l_server;
l_server.address = l_url.host();
- l_server.port = l_url.port();
+ l_server.port = port;
+ l_server.scheme = l_url.scheme();
l_server.name = "Direct Connection";
net_manager->connect_to_server(l_server);
diff --git a/src/widgets/server_editor_dialog.cpp b/src/widgets/server_editor_dialog.cpp
index 03c8d6c6..8f987f6a 100644
--- a/src/widgets/server_editor_dialog.cpp
+++ b/src/widgets/server_editor_dialog.cpp
@@ -31,6 +31,7 @@ ServerEditorDialog::ServerEditorDialog(QWidget *parent)
FROM_UI(QLineEdit, name);
FROM_UI(QLineEdit, hostname);
FROM_UI(QSpinBox, port);
+ FROM_UI(QCheckBox, secure_cb);
FROM_UI(QPlainTextEdit, description);
FROM_UI(QDialogButtonBox, button_box);
@@ -49,6 +50,7 @@ ServerEditorDialog::ServerEditorDialog(const ServerInfo &server, QWidget *parent
ui_name->setText(server.name);
ui_hostname->setText(server.address);
ui_port->setValue(server.port);
+ ui_secure_cb->setChecked(server.scheme == "wss");
ui_description->setPlainText(server.description);
}
@@ -58,6 +60,7 @@ ServerInfo ServerEditorDialog::currentServerInfo() const
server.name = ui_name->text();
server.address = ui_hostname->text();
server.port = ui_port->value();
+ server.scheme = ui_secure_cb->isChecked() ? "wss" : "ws";
server.description = ui_description->toPlainText();
return server;
}
diff --git a/src/widgets/server_editor_dialog.h b/src/widgets/server_editor_dialog.h
index a8844d4b..7b0bb651 100644
--- a/src/widgets/server_editor_dialog.h
+++ b/src/widgets/server_editor_dialog.h
@@ -2,6 +2,7 @@
#include "network/serverinfo.h"
+#include <QCheckBox>
#include <QComboBox>
#include <QDialog>
#include <QDialogButtonBox>
@@ -29,6 +30,7 @@ private:
QLineEdit *ui_name;
QLineEdit *ui_hostname;
QSpinBox *ui_port;
+ QCheckBox *ui_secure_cb;
QPlainTextEdit *ui_description;
QDialogButtonBox *ui_button_box;