Author: mir3x
Date: Thu Nov  5 21:05:21 2015
New Revision: 30430

URL: http://svn.gna.org/viewcvs/freeciv?rev=30430&view=rev
Log:
Enabled connection to servers with authentication in qt-client.

See patch #6513


Modified:
    trunk/client/gui-qt/connectdlg.cpp
    trunk/client/gui-qt/fc_client.cpp
    trunk/client/gui-qt/fc_client.h
    trunk/client/gui-qt/pages.cpp

Modified: trunk/client/gui-qt/connectdlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/connectdlg.cpp?rev=30430&r1=30429&r2=30430&view=diff
==============================================================================
--- trunk/client/gui-qt/connectdlg.cpp  (original)
+++ trunk/client/gui-qt/connectdlg.cpp  Thu Nov  5 21:05:21 2015
@@ -60,32 +60,7 @@
 void handle_authentication_req(enum authentication_type type,
                                const char *message)
 {
-  switch (type) {
-  case AUTH_NEWUSER_FIRST:
-     /* PORTME: switch configs if need be */
-    return;
-  case AUTH_NEWUSER_RETRY:
-     /* PORTME: switch configs if need be */
-    return;
-  case AUTH_LOGIN_FIRST:
-    /* if we magically have a password already present in 'password'
-     * then, use that and skip the password entry dialog */
-    if (password[0] != '\0') {
-      struct packet_authentication_reply reply;
-
-      sz_strlcpy(reply.password, password);
-      send_packet_authentication_reply(&client.conn, &reply);
-      return;
-    } else {
-     /* PORTME: switch configs if need be */
-    }
-    return;
-  case AUTH_LOGIN_RETRY:
-     /* PORTME: switch configs if need be */
-    return;
-  }
-
-  log_error("Unsupported authentication type %d: %s.", type, message);
+  gui()->handle_authentication_req(type, message);
 }
 
 /**************************************************************************

Modified: trunk/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.cpp?rev=30430&r1=30429&r2=30430&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.cpp   (original)
+++ trunk/client/gui-qt/fc_client.cpp   Thu Nov  5 21:05:21 2015
@@ -306,10 +306,13 @@
     break;
   case PAGE_NETWORK:
     update_network_lists();
+    set_connection_state(LOGIN_TYPE);
     connect_host_edit->setText(server_host);
     fc_snprintf(buf, sizeof(buf), "%d", server_port);
     connect_port_edit->setText(buf);
     connect_login_edit->setText(user_name);
+    connect_password_edit->setDisabled(true);
+    connect_confirm_password_edit->setDisabled(true);
     break;
   default:
     if (client.conn.used) {

Modified: trunk/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.h?rev=30430&r1=30429&r2=30430&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.h     (original)
+++ trunk/client/gui-qt/fc_client.h     Thu Nov  5 21:05:21 2015
@@ -194,6 +194,8 @@
   void popdown_tile_info();
   void set_diplo_dialog(choice_dialog *widget);
   void update_completer();
+  void handle_authentication_req(enum authentication_type type,
+                                 const char *message);
   choice_dialog *get_diplo_dialog();
 
   QCompleter *chat_completer;
@@ -269,8 +271,6 @@
   void create_cursors(void);
   void update_scenarios_page(void);
   void set_connection_state(enum connection_state state);
-  void handle_authentication_req(
-    enum authentication_type type, const char *message);
   void update_obs_button();
   void init();
 

Modified: trunk/client/gui-qt/pages.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/pages.cpp?rev=30430&r1=30429&r2=30430&view=diff
==============================================================================
--- trunk/client/gui-qt/pages.cpp       (original)
+++ trunk/client/gui-qt/pages.cpp       Thu Nov  5 21:05:21 2015
@@ -214,27 +214,28 @@
   case LOGIN_TYPE:
     set_status_bar("");
     connect_password_edit->setText("");
+    connect_password_edit->setDisabled(true);
     connect_confirm_password_edit->setText("");
-    connect_confirm_password_edit->setReadOnly(true);
+    connect_confirm_password_edit->setDisabled(true);
     break;
   case NEW_PASSWORD_TYPE:
     connect_password_edit->setText("");
     connect_confirm_password_edit->setText("");
-    connect_confirm_password_edit->setReadOnly(false);
+    connect_password_edit->setDisabled(false);
+    connect_confirm_password_edit->setDisabled(false);
     connect_password_edit->setFocus(Qt::OtherFocusReason);
     break;
   case ENTER_PASSWORD_TYPE:
     connect_password_edit->setText("");
     connect_confirm_password_edit->setText("");
-    connect_confirm_password_edit->setReadOnly(true);
+    connect_password_edit->setDisabled(false);
+    connect_confirm_password_edit->setDisabled(true);
     connect_password_edit->setFocus(Qt::OtherFocusReason);
 
 
     break;
   case WAITING_TYPE:
     set_status_bar("");
-    connect_confirm_password_edit->setReadOnly(true);
-
     break;
   }
 
@@ -267,7 +268,6 @@
 
   connect_password_edit->setDisabled(true);
   connect_confirm_password_edit->setDisabled(true);
-  connect_confirm_password_edit->setReadOnly (true);
   connect_tab_widget = new QTabWidget;
   connect_lan = new QWidget;
   connect_metaserver = new QWidget;
@@ -355,6 +355,10 @@
   network_button = new QPushButton(_("Connect"));
   page_network_grid_layout->addWidget(network_button, 5, 5, 1, 1);
   connect(network_button, SIGNAL(clicked()), this, SLOT(slot_connect()));
+  connect(connect_password_edit, SIGNAL(returnPressed()),
+          network_button, SIGNAL(clicked()));
+  connect(connect_confirm_password_edit, SIGNAL(returnPressed()),
+          network_button, SIGNAL(clicked()));
 
   connect_lan->setLayout(page_network_lan_layout);
   connect_metaserver->setLayout(page_network_wan_layout);
@@ -1120,7 +1124,6 @@
     set_connection_state(NEW_PASSWORD_TYPE);
     return;
   case AUTH_LOGIN_FIRST:
-
     /* if we magically have a password already present in 'password'
      * then, use that and skip the password entry dialog */
     if (password[0] != '\0') {
@@ -1154,8 +1157,6 @@
 
   switch (connection_status) {
   case LOGIN_TYPE:
-    connect_password_edit->setDisabled(true);
-    connect_confirm_password_edit->setDisabled(true);
     sz_strlcpy(user_name, connect_login_edit->text().toLocal8Bit().data());
     sz_strlcpy(server_host, connect_host_edit->text().toLocal8Bit().data());
     server_port = connect_port_edit->text().toInt();
@@ -1169,8 +1170,6 @@
 
     return;
   case NEW_PASSWORD_TYPE:
-    connect_password_edit->setDisabled(false);
-    connect_confirm_password_edit->setDisabled(false);
     sz_strlcpy(password, connect_password_edit->text().toLatin1().data());
     sz_strlcpy(reply.password,
                connect_confirm_password_edit->text().toLatin1().data());
@@ -1186,8 +1185,6 @@
 
     return;
   case ENTER_PASSWORD_TYPE:
-    connect_password_edit->setDisabled(false);
-    connect_confirm_password_edit->setDisabled(false);
     sz_strlcpy(reply.password,
                connect_password_edit->text().toLatin1().data());
     send_packet_authentication_reply(&client.conn, &reply);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to