Remember password
authornemo
Sun, 31 May 2009 19:42:49 +0000
changeset 2138 b246ad6484f5
parent 2137 4bb9ff2069ec
child 2139 5a083e71a71d
Remember password
QTfrontend/newnetclient.cpp
--- a/QTfrontend/newnetclient.cpp	Sun May 31 19:32:54 2009 +0000
+++ b/QTfrontend/newnetclient.cpp	Sun May 31 19:42:49 2009 +0000
@@ -452,9 +452,15 @@
 	}
 
 	if (lst[0] == "ASKPASSWORD") {
-		QString password = QInputDialog::getText(0, tr("Password"), tr("Enter your password:"), QLineEdit::Password);
+        int passLength = config->value("net/passwordlength", 0).toInt();
+        QString hash = config->value("net/passwordhash", "").toString();       
+		QString password = QInputDialog::getText(0, tr("Password"), tr("Enter your password:"), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'));
 
-		QString hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex();
+        if (!passLength || password!=QString(passLength, '\0')) {
+            hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex();
+            config->setValue("net/passwordhash", hash);
+            config->setValue("net/passwordlength", password.size());
+        }
 
 		RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(hash));
 		return;