QTfrontend/newnetclient.cpp
changeset 1878 b3b277d2b891
parent 1875 189370d394db
child 1879 bb114339eb4e
equal deleted inserted replaced
1877:1edafdb4c7a2 1878:b3b277d2b891
    18  */
    18  */
    19 
    19 
    20 #include <QDebug>
    20 #include <QDebug>
    21 #include <QInputDialog>
    21 #include <QInputDialog>
    22 
    22 
    23 #include <QtCrypto>
       
    24 
       
    25 #include "hwconsts.h"
    23 #include "hwconsts.h"
    26 #include "newnetclient.h"
    24 #include "newnetclient.h"
    27 #include "proto.h"
    25 #include "proto.h"
    28 #include "gameuiconfig.h"
    26 #include "gameuiconfig.h"
    29 #include "game.h"
    27 #include "game.h"
    30 #include "gamecfgwidget.h"
    28 #include "gamecfgwidget.h"
    31 #include "teamselect.h"
    29 #include "teamselect.h"
       
    30 #include "misc.h"
    32 
    31 
    33 char delimeter='\n';
    32 char delimeter='\n';
    34 
    33 
    35 HWNewNet::HWNewNet(GameUIConfig * config, GameCFGWidget* pGameCFGWidget, TeamSelWidget* pTeamSelWidget) :
    34 HWNewNet::HWNewNet(GameUIConfig * config, GameCFGWidget* pGameCFGWidget, TeamSelWidget* pTeamSelWidget) :
    36   config(config),
    35   config(config),
   433 	}
   432 	}
   434 
   433 
   435 	if (lst[0] == "ASKPASSWORD") {
   434 	if (lst[0] == "ASKPASSWORD") {
   436 		QString password = QInputDialog::getText(0, tr("Password"), tr("Enter your password:"), QLineEdit::Password);
   435 		QString password = QInputDialog::getText(0, tr("Password"), tr("Enter your password:"), QLineEdit::Password);
   437 
   436 
   438 		QCA::Initializer qcaInit;
   437 		QString hash = Hash::md5(password.toLatin1());
   439 		QCA::Hash shaHash("md5");
   438 
   440 		shaHash.update(password.toLatin1());
   439 		RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(hash));
   441 		QByteArray hashResult = shaHash.final().toByteArray();
       
   442 		
       
   443 		RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(QCA::arrayToHex(hashResult)));
       
   444 		return;
   440 		return;
   445 	}
   441 	}
   446 
   442 
   447 	if (lst[0] == "TEAM_ACCEPTED") {
   443 	if (lst[0] == "TEAM_ACCEPTED") {
   448 		if (lst.size() != 2)
   444 		if (lst.size() != 2)