Commit 506ad91b authored by woogerboy21's avatar woogerboy21
Browse files

Privatized Function

Moved the updated hashing function out of the settingscache and into the
remoteclient and privatized the function for proper use.
parent ee849f63
#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 ...@@ -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->getSrvClientID(lastHostname).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 ...@@ -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->getSrvClientID(lastHostname).toStdString()); cmdLogin.set_clientid(getSrvClientID(lastHostname).toStdString());
cmdLogin.set_clientver(VERSION_STRING); cmdLogin.set_clientver(VERSION_STRING);
if (!clientFeatures.isEmpty()) { if (!clientFeatures.isEmpty()) {
...@@ -361,3 +361,11 @@ void RemoteClient::disconnectFromServer() ...@@ -361,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;
}
\ No newline at end of file
...@@ -51,6 +51,7 @@ private: ...@@ -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:
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#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>
...@@ -613,12 +612,4 @@ void SettingsCache::setNotifyAboutUpdate(int _notifyaboutupdate) ...@@ -613,12 +612,4 @@ 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;
} }
\ No newline at end of file
...@@ -176,8 +176,7 @@ public: ...@@ -176,8 +176,7 @@ 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; }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment