8 #include <QNetworkInterface>
9 #include "../../shared/settings.h"
10 #include "../../shared/util.h"
11 #include "../net/serverconnection.h"
12 #include "../clientapp/clientapp.h"
14 #include "ui_connectwindow.h"
16 #include <QCloseEvent>
18 #define UDPBUFSIZ 9000
31 _ui =
new Ui::ConnectWindow;
41 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Tool);
44 _ui->stackedWidget->setCurrentIndex(0);
59 _ui->box_manual->setVisible(
false);
80 _ui->btn_connection->setEnabled(
true);
81 _ui->btn_connection->setText(tr(
"&Disconnect"));
83 _ui->lineEditName->setEnabled(
false);
84 _ui->stackedWidget->setCurrentIndex(1);
89 _ui->btn_connection->setText(tr(
"&Stop"));
91 _ui->btn_connection->setText(tr(
"&Connect"));
95 _ui->lblStatus->setText(tr(
"Ready to connect."));
101 _ui->lblStatus->setText(tr(
"Found session, connecting..."));
104 _ui->lblStatus->setText(tr(
"Waiting for server challenge..."));
107 _ui->lblStatus->setText(tr(
"Replied to challenge, sent own..."));
110 _ui->lblStatus->setText(tr(
"Logging in..."));
115 _ui->lblStatus->setText(tr(
"Invalid certificate."));
121 _ui->lblStatus->setText(tr(
"Unknown state :-("));
140 _ui->stackedWidget->setCurrentIndex(0);
143 killTimer(event->timerId());
159 _ui->stackedWidget->setCurrentIndex(0);
160 _ui->comboBox_rooms->setCurrentIndex(0);
175 _ui->lineEditName->setFocus();
204 qDebug() <<
"DoConnect()";
207 int index =
_ui->comboBox_rooms->currentIndex();
208 QString selectedMgrIP =
_ui->comboBox_rooms->itemData(index).toString();
210 if (selectedMgrIP ==
"manual_connection") {
211 qDebug() <<
"connect to sessionName by manual connection";
212 QByteArray sessionName =
_ui->lineEditName->text().toUtf8();
215 qDebug() <<
"connect to mgrIP (through room selection) " << selectedMgrIP;
222 qDebug() <<
"DoDisconnect()";
240 _ui->stackedWidget->setCurrentIndex(0);
259 _ui->comboBox_rooms->clear();
260 foreach (
Room r, m) {
264 _ui->comboBox_rooms->addItem(tr(
"Session Name..."),
"manual_connection");
279 QString sessionName =
_ui->comboBox_rooms->itemData(index).toString();
280 if (sessionName ==
"manual_connection") {
281 qDebug() <<
"switch to manual connection";
282 _ui->box_manual->setVisible(
true);
284 this->resize(300, 200);
286 _ui->box_manual->setVisible(
false);
287 this->resize(300, 140);
Class for handling the client connection.
void onConnectionClosed(QObject *connection)
If connection is closed set _pendingConnection = nullptr.
void DoDisconnect()
actually disconnects the connection
void updateUserInterface()
Handle changes in state and update window.
QByteArray _currentSession
ConnectWindow(QWidget *parent=nullptr)
Initialize Connection Window.
void onBtnConnection()
Handle click on Connect/Disconnect button.
void stateChange(ConnectWindow::ConnectionState state)
void onServerDetected(const QString &host, quint16 port, const QByteArray &sessionName, const QByteArray &certHash, bool autoConnect)
ConnectWindow::onServerDetected.
void onRoomSelection(int index)
check if "manual_connection" is selected, then switch to manual connection page
void start(const QByteArray &sessionName, const QString &mgrIP)
start
ServerDiscovery _serverDiscovery
void disconnected(ServerConnection *connection)
~ConnectWindow() override
ConnectWindow::~ConnectWindow.
ServerConnection * _pendingConnection
void setAvailableRooms(const QList< Room > &m)
set the available rooms.
void DoConnect()
actually connects the connection
void onBtnHide()
Handle click on Cancel/Hide Button.
void closeEvent(QCloseEvent *e) override
Handle incoming closeEvent and hide window.
void connectToSession(const QByteArray &sessionName, const QString &mgrIP)
Public function connect to session.
void onConnectionDisconnected(ServerConnection *connection)
ConnectWindow::onConnectionDisconnected.
void connected(ServerConnection *connection)
void timerEvent(QTimerEvent *event) override
Called when a Qt timer fires; used for server discovery and auto-hiding the connect dialog...
void serverDetected(const QString &host, const quint16 port, const QByteArray &sessionName, const QByteArray &certHash, bool autoConnect)
void onConnectionStateChange(ConnectWindow::ConnectionState state)
Handle connection state changes and update member variables describing state.
void showEvent(QShowEvent *event) override
Gives the keyboard input focus to the input line.