451 emit AskForRunGame(); |
451 emit AskForRunGame(); |
452 return; |
452 return; |
453 } |
453 } |
454 |
454 |
455 if (lst[0] == "ASKPASSWORD") { |
455 if (lst[0] == "ASKPASSWORD") { |
|
456 bool ok = false; |
456 int passLength = config->value("net/passwordlength", 0).toInt(); |
457 int passLength = config->value("net/passwordlength", 0).toInt(); |
457 QString hash = config->value("net/passwordhash", "").toString(); |
458 QString hash = config->value("net/passwordhash", "").toString(); |
458 QString password = QInputDialog::getText(0, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password\nor pick another nickname:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0')); |
459 QString password = QInputDialog::getText(0, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password\nor pick another nickname:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok); |
459 |
460 |
|
461 if (!ok) { |
|
462 Disconnect(); |
|
463 emit Disconnected(); |
|
464 return; |
|
465 } |
|
466 |
460 if (!passLength || password!=QString(passLength, '\0')) { |
467 if (!passLength || password!=QString(passLength, '\0')) { |
461 hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); |
468 hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); |
462 config->setValue("net/passwordhash", hash); |
469 config->setValue("net/passwordhash", hash); |
463 config->setValue("net/passwordlength", password.size()); |
470 config->setValue("net/passwordlength", password.size()); |
464 } |
471 } |