Updated ClientID Functionality
ClientID is now generated on startup and stored in settings cache. Then upon connect there is a new SrvClientID generated from the ClientID + servername being connected to
This commit is contained in:
parent
3c58003a3d
commit
ee849f6379
3 changed files with 13 additions and 5 deletions
|
@ -81,7 +81,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(settingsCache->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);
|
||||||
|
@ -111,7 +111,7 @@ void RemoteClient::doLogin() {
|
||||||
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(settingsCache->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;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
@ -612,4 +613,12 @@ void SettingsCache::setNotifyAboutUpdate(int _notifyaboutupdate)
|
||||||
{
|
{
|
||||||
notifyAboutUpdates = _notifyaboutupdate;
|
notifyAboutUpdates = _notifyaboutupdate;
|
||||||
settings->setValue("personal/updatenotification", notifyAboutUpdates);
|
settings->setValue("personal/updatenotification", notifyAboutUpdates);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SettingsCache::getSrvClientID(const QString _hostname)
|
||||||
|
{
|
||||||
|
QString srvClientID = getClientID();
|
||||||
|
srvClientID += _hostname;
|
||||||
|
QString uniqueServerClientID = QCryptographicHash::hash(srvClientID.toUtf8(), QCryptographicHash::Sha1).toHex().right(15);
|
||||||
|
return uniqueServerClientID;
|
||||||
}
|
}
|
|
@ -176,7 +176,8 @@ public:
|
||||||
bool getRememberGameSettings() const { return rememberGameSettings; }
|
bool getRememberGameSettings() const { return rememberGameSettings; }
|
||||||
int getKeepAlive() const { return keepalive; }
|
int getKeepAlive() const { return keepalive; }
|
||||||
void setClientID(QString clientID);
|
void setClientID(QString clientID);
|
||||||
QString getClientID() { return clientID; }
|
QString getClientID() { return clientID; }
|
||||||
|
QString getSrvClientID(const QString _hostname);
|
||||||
ShortcutsSettings& shortcuts() const { return *shortcutsSettings; }
|
ShortcutsSettings& shortcuts() const { return *shortcutsSettings; }
|
||||||
CardDatabaseSettings& cardDatabase() const { return *cardDatabaseSettings; }
|
CardDatabaseSettings& cardDatabase() const { return *cardDatabaseSettings; }
|
||||||
ServersSettings& servers() const { return *serversSettings; }
|
ServersSettings& servers() const { return *serversSettings; }
|
||||||
|
|
Loading…
Reference in a new issue