81 #include "gamecfgwidget.h" |
81 #include "gamecfgwidget.h" |
82 #include "netserverslist.h" |
82 #include "netserverslist.h" |
83 #include "netudpserver.h" |
83 #include "netudpserver.h" |
84 #include "chatwidget.h" |
84 #include "chatwidget.h" |
85 #include "input_ip.h" |
85 #include "input_ip.h" |
|
86 #include "input_password.h" |
86 #include "ammoSchemeModel.h" |
87 #include "ammoSchemeModel.h" |
87 #include "bgwidget.h" |
88 #include "bgwidget.h" |
88 #include "xfire.h" |
89 #include "xfire.h" |
89 #include "drawmapwidget.h" |
90 #include "drawmapwidget.h" |
90 #include "mouseoverfilter.h" |
91 #include "mouseoverfilter.h" |
933 NetConnectServer("netserver.hedgewars.org", 46631); |
934 NetConnectServer("netserver.hedgewars.org", 46631); |
934 } |
935 } |
935 |
936 |
936 void HWForm::NetPassword(const QString & nick) |
937 void HWForm::NetPassword(const QString & nick) |
937 { |
938 { |
938 bool ok = false; |
|
939 int passLength = config->value("net/passwordlength", 0).toInt(); |
939 int passLength = config->value("net/passwordlength", 0).toInt(); |
940 QString hash = config->value("net/passwordhash", "").toString(); |
940 QString hash = config->value("net/passwordhash", "").toString(); |
941 |
941 |
942 // If the password is blank, ask the user to enter one in |
942 // If the password is blank, ask the user to enter one in |
943 if (passLength == 0) |
943 if (passLength == 0) |
944 { |
944 { |
945 QString password = QInputDialog::getText(this, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(nick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok); |
945 HWPasswordDialog * hpd = new HWPasswordDialog(this, tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(nick)); |
946 |
946 hpd->cbSave->setChecked(config->value("net/savepassword", true).toBool()); |
947 if (!ok) |
947 if (hpd->exec() != QDialog::Accepted) |
948 { |
948 { |
949 ForcedDisconnect(tr("No password supplied.")); |
949 ForcedDisconnect(tr("No password supplied.")); |
|
950 delete hpd; |
950 return; |
951 return; |
951 } |
952 } |
952 |
953 |
|
954 QString password = hpd->lePassword->text(); |
953 hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); |
955 hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); |
954 config->setValue("net/passwordhash", hash); |
956 |
955 config->setValue("net/passwordlength", password.size()); |
957 bool save = hpd->cbSave->isChecked(); |
956 config->setNetPasswordLength(password.size()); |
958 config->setValue("net/savepassword", save); |
|
959 if (save) // user wants to save password |
|
960 { |
|
961 config->setValue("net/passwordhash", hash); |
|
962 config->setValue("net/passwordlength", password.size()); |
|
963 config->setNetPasswordLength(password.size()); |
|
964 } |
|
965 |
|
966 delete hpd; |
957 } |
967 } |
958 |
968 |
959 hwnet->SendPasswordHash(hash); |
969 hwnet->SendPasswordHash(hash); |
960 } |
970 } |
961 |
971 |