Merge
authorWuzzy <Wuzzy2@mail.ru>
Thu, 25 Apr 2019 23:01:30 +0200
changeset 14861 b02581c5b0c5
parent 14860 e239378a9400 (current diff)
parent 14859 bdb47255d7e4 (diff)
child 14862 111c4d750c6d
Merge
--- a/QTfrontend/hwform.cpp	Thu Apr 25 23:01:05 2019 +0200
+++ b/QTfrontend/hwform.cpp	Thu Apr 25 23:01:30 2019 +0200
@@ -1366,6 +1366,7 @@
     GoToPage(ID_PAGE_CONNECTING);
 
     connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame()), Qt::QueuedConnection);
+    connect(hwnet, SIGNAL(redirected(quint16)), this, SLOT(NetRedirected(quint16)), Qt::QueuedConnection);
     connect(hwnet, SIGNAL(connected()), this, SLOT(NetConnected()), Qt::QueuedConnection);
     connect(hwnet, SIGNAL(Error(const QString&)), this, SLOT(NetError(const QString&)), Qt::QueuedConnection);
     connect(hwnet, SIGNAL(Warning(const QString&)), this, SLOT(NetWarning(const QString&)), Qt::QueuedConnection);
@@ -1715,6 +1716,23 @@
     }
 }
 
+void HWForm::NetRedirected(quint16 port)
+{
+    QMessageBox questionMsg(this);
+    questionMsg.setIcon(QMessageBox::Question);
+    questionMsg.setWindowTitle(QMessageBox::tr("Server redirection"));
+    questionMsg.setText(QMessageBox::tr("This server supports secure connections on port %1.\nWould you like to reconnect securely?").arg(port));
+    questionMsg.setTextFormat(Qt::PlainText);
+    questionMsg.setWindowModality(Qt::WindowModal);
+    questionMsg.addButton(QMessageBox::Yes);
+    questionMsg.addButton(QMessageBox::No);
+
+    if (questionMsg.exec() == QMessageBox::Yes)
+    {
+
+    }
+}
+
 void HWForm::NetConnected()
 {
     GoToPage(ID_PAGE_ROOMSLIST);
--- a/QTfrontend/hwform.h	Thu Apr 25 23:01:05 2019 +0200
+++ b/QTfrontend/hwform.h	Thu Apr 25 23:01:30 2019 +0200
@@ -103,6 +103,7 @@
         void NetConnectServer(const QString & host, quint16 port);
         void NetConnectOfficialServer();
         void NetStartServer();
+        void NetRedirected(quint16 port);
         void NetDisconnect();
         void NetConnected();
         void NetError(const QString & errmsg);
--- a/QTfrontend/net/newnetclient.cpp	Thu Apr 25 23:01:05 2019 +0200
+++ b/QTfrontend/net/newnetclient.cpp	Thu Apr 25 23:01:30 2019 +0200
@@ -296,6 +296,26 @@
         return;
     }
 
+    if (lst[0] == "REDIRECT")
+    {        
+        if (lst.size() < 2 || lst[1].toInt() == 0)
+        {
+            qWarning("Net: Malformed REDIRECT message");
+            return;            
+        }
+
+        quint16 port = lst[1].toInt();
+        if (port == 0) 
+        {
+            qWarning() << "Invalid redirection port";            
+        }
+        else 
+        {
+            emit redirected(port);
+        }
+        return;
+    }
+
     if (lst[0] == "CONNECTED")
     {
         if(lst.size() < 3 || lst[2].toInt() < cMinServerVersion)
--- a/QTfrontend/net/newnetclient.h	Thu Apr 25 23:01:05 2019 +0200
+++ b/QTfrontend/net/newnetclient.h	Thu Apr 25 23:01:30 2019 +0200
@@ -98,6 +98,7 @@
         void AskForRunGame();
         void connected();
         void disconnected(const QString & reason);
+        void redirected(quint16 port);
         void Error(const QString & errmsg);
         void Warning(const QString & wrnmsg);
         void NickRegistered(const QString & nick);