Merge pull request #1894 from woogerboy21/clientid_update
Updated ClientID Functionality
This commit is contained in:
commit
830a4c2f56
3 changed files with 13 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QCryptographicHash>
|
||||||
#include "remoteclient.h"
|
#include "remoteclient.h"
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include "pending_command.h"
|
#include "pending_command.h"
|
||||||
|
@ -81,7 +82,7 @@ void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentifica
|
||||||
cmdRegister.set_gender((ServerInfo_User_Gender) gender);
|
cmdRegister.set_gender((ServerInfo_User_Gender) gender);
|
||||||
cmdRegister.set_country(country.toStdString());
|
cmdRegister.set_country(country.toStdString());
|
||||||
cmdRegister.set_real_name(realName.toStdString());
|
cmdRegister.set_real_name(realName.toStdString());
|
||||||
cmdRegister.set_clientid(settingsCache->getClientID().toStdString());
|
cmdRegister.set_clientid(getSrvClientID(lastHostname).toStdString());
|
||||||
PendingCommand *pend = prepareSessionCommand(cmdRegister);
|
PendingCommand *pend = prepareSessionCommand(cmdRegister);
|
||||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(registerResponse(Response)));
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(registerResponse(Response)));
|
||||||
sendCommand(pend);
|
sendCommand(pend);
|
||||||
|
@ -107,11 +108,10 @@ void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentifica
|
||||||
|
|
||||||
void RemoteClient::doLogin() {
|
void RemoteClient::doLogin() {
|
||||||
setStatus(StatusLoggingIn);
|
setStatus(StatusLoggingIn);
|
||||||
|
|
||||||
Command_Login cmdLogin;
|
Command_Login cmdLogin;
|
||||||
cmdLogin.set_user_name(userName.toStdString());
|
cmdLogin.set_user_name(userName.toStdString());
|
||||||
cmdLogin.set_password(password.toStdString());
|
cmdLogin.set_password(password.toStdString());
|
||||||
cmdLogin.set_clientid(settingsCache->getClientID().toStdString());
|
cmdLogin.set_clientid(getSrvClientID(lastHostname).toStdString());
|
||||||
cmdLogin.set_clientver(VERSION_STRING);
|
cmdLogin.set_clientver(VERSION_STRING);
|
||||||
|
|
||||||
if (!clientFeatures.isEmpty()) {
|
if (!clientFeatures.isEmpty()) {
|
||||||
|
@ -119,7 +119,6 @@ void RemoteClient::doLogin() {
|
||||||
for (i = clientFeatures.begin(); i != clientFeatures.end(); ++i)
|
for (i = clientFeatures.begin(); i != clientFeatures.end(); ++i)
|
||||||
cmdLogin.add_clientfeatures(i.key().toStdString().c_str());
|
cmdLogin.add_clientfeatures(i.key().toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingCommand *pend = prepareSessionCommand(cmdLogin);
|
PendingCommand *pend = prepareSessionCommand(cmdLogin);
|
||||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(loginResponse(Response)));
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(loginResponse(Response)));
|
||||||
sendCommand(pend);
|
sendCommand(pend);
|
||||||
|
@ -263,7 +262,6 @@ void RemoteClient::doConnectToServer(const QString &hostname, unsigned int port,
|
||||||
|
|
||||||
userName = _userName;
|
userName = _userName;
|
||||||
password = _password;
|
password = _password;
|
||||||
QString clientid = settingsCache->getClientID();
|
|
||||||
lastHostname = hostname;
|
lastHostname = hostname;
|
||||||
lastPort = port;
|
lastPort = port;
|
||||||
|
|
||||||
|
@ -363,3 +361,11 @@ void RemoteClient::disconnectFromServer()
|
||||||
{
|
{
|
||||||
emit sigDisconnectFromServer();
|
emit sigDisconnectFromServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RemoteClient::getSrvClientID(const QString _hostname)
|
||||||
|
{
|
||||||
|
QString srvClientID = settingsCache->getClientID();
|
||||||
|
srvClientID += _hostname;
|
||||||
|
QString uniqueServerClientID = QCryptographicHash::hash(srvClientID.toUtf8(), QCryptographicHash::Sha1).toHex().right(15);
|
||||||
|
return uniqueServerClientID;
|
||||||
|
}
|
|
@ -51,6 +51,7 @@ private:
|
||||||
QTcpSocket *socket;
|
QTcpSocket *socket;
|
||||||
QString lastHostname;
|
QString lastHostname;
|
||||||
int lastPort;
|
int lastPort;
|
||||||
|
QString getSrvClientID(const QString _hostname);
|
||||||
protected slots:
|
protected slots:
|
||||||
void sendCommandContainer(const CommandContainer &cont);
|
void sendCommandContainer(const CommandContainer &cont);
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue