Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
Servatrice_DatabaseInterface Class Reference

#include <servatrice_database_interface.h>

Inheritance diagram for Servatrice_DatabaseInterface:
[legend]
Collaboration diagram for Servatrice_DatabaseInterface:
[legend]

Public Slots

void initDatabase (const QSqlDatabase &_sqlDatabase)

Public Member Functions

 Servatrice_DatabaseInterface (int _instanceId, Servatrice *_server)
 ~Servatrice_DatabaseInterface () override
bool initDatabase (const QString &type, const QString &hostName, const QString &databaseName, const QString &userName, const QString &password)
bool openDatabase ()
bool checkSql ()
QSqlQuery * prepareQuery (const QString &queryText)
bool execSqlQuery (QSqlQuery *query)
const QSqlDatabase & getDatabase ()
bool activeUserExists (const QString &user) override
bool userExists (const QString &user) override
QString getUserSalt (const QString &user) override
int getUserIdInDB (const QString &name)
QMap< QString, ServerInfo_User > getBuddyList (const QString &name) override
QMap< QString, ServerInfo_User > getIgnoreList (const QString &name) override
bool isInBuddyList (const QString &whoseList, const QString &who) override
bool isInIgnoreList (const QString &whoseList, const QString &who) override
ServerInfo_User getUserData (const QString &name, bool withId=false) override
void storeGameInformation (const QString &roomName, const QStringList &roomGameTypes, const ServerInfo_Game &gameInfo, const QSet< QString > &allPlayersEver, const QSet< QString > &allSpectatorsEver, const QList< GameReplay * > &replayList) override
DeckListgetDeckFromDatabase (int deckId, int userId) override
int getNextGameId () override
int getNextReplayId () override
int getActiveUserCount (QString connectionType=QString()) override
qint64 startSession (const QString &userName, const QString &address, const QString &clientId, const QString &connectionType) override
void endSession (qint64 sessionId) override
void clearSessionTables () override
void lockSessionTables () override
void unlockSessionTables () override
bool userSessionExists (const QString &userName) override
bool usernameIsValid (const QString &user, QString &error) override
bool checkUserIsBanned (const QString &ipAddress, const QString &userName, const QString &clientId, QString &banReason, int &banSecondsRemaining) override
int checkNumberOfUserAccounts (const QString &email) override
bool registerUser (const QString &userName, const QString &realName, const QString &password, bool passwordNeedsHash, const QString &emailAddress, const QString &country, bool active=false) override
bool activateUser (const QString &userName, const QString &token) override
void updateUsersClientID (const QString &userName, const QString &userClientID) override
void updateUsersLastLoginData (const QString &userName, const QString &clientVersion) override
void logMessage (const int senderId, const QString &senderName, const QString &senderIp, const QString &logMessage, LogMessage_TargetType targetType, const int targetId, const QString &targetName) override
bool changeUserPassword (const QString &user, const QString &password, bool passwordNeedsHash) override
bool changeUserPassword (const QString &user, const QString &oldPassword, bool oldPasswordNeedsHash, const QString &newPassword, bool newPasswordNeedsHash) override
QList< ServerInfo_Ban > getUserBanHistory (const QString userName)
bool addWarning (const QString userName, const QString adminName, const QString warningReason, const QString clientID)
QList< ServerInfo_Warning > getUserWarnHistory (const QString userName)
QList< ServerInfo_ChatMessage > getMessageLogHistory (const QString &user, const QString &ipaddress, const QString &gamename, const QString &gameid, const QString &message, bool &chat, bool &game, bool &room, int &range, int &maxresults)
bool addForgotPassword (const QString &user)
bool removeForgotPassword (const QString &user) override
bool doesForgotPasswordExist (const QString &user)
bool updateUserToken (const QString &token, const QString &user)
bool validateTableColumnStringData (const QString &table, const QString &column, const QString &_user, const QString &_datatocheck)
void addAuditRecord (const QString &user, const QString &ipaddress, const QString &clientid, const QString &action, const QString &details, const bool &results)
Public Member Functions inherited from Server_DatabaseInterface
 Server_DatabaseInterface (QObject *parent=nullptr)
virtual bool getRequireRegistration ()
virtual bool checkUserIsBanned (Server_ProtocolHandler *, QString &, int &)

Protected Member Functions

AuthenticationResult checkUserPassword (Server_ProtocolHandler *handler, const QString &user, const QString &password, const QString &clientId, QString &reasonStr, int &banSecondsLeft, bool passwordNeedsHash) override

Private Member Functions

ServerInfo_User evalUserQueryResult (const QSqlQuery *query, bool complete, bool withId=false)
bool checkUserIsIdBanned (const QString &clientId, QString &banReason, int &banSecondsRemaining)
bool checkUserIsIpBanned (const QString &ipAddress, QString &banReason, int &banSecondsRemaining)
bool checkUserIsNameBanned (QString const &userName, QString &banReason, int &banSecondsRemaining)

Private Attributes

int instanceId
QSqlDatabase sqlDatabase
QHash< QString, QSqlQuery * > preparedStatements
Servatriceserver

Additional Inherited Members

Public Types inherited from Server_DatabaseInterface
enum  LogMessage_TargetType { MessageTargetRoom , MessageTargetGame , MessageTargetChat , MessageTargetIslRoom }

Constructor & Destructor Documentation

◆ Servatrice_DatabaseInterface()

Servatrice_DatabaseInterface::Servatrice_DatabaseInterface ( int _instanceId,
Servatrice * _server )
explicit

◆ ~Servatrice_DatabaseInterface()

Servatrice_DatabaseInterface::~Servatrice_DatabaseInterface ( )
override

Member Function Documentation

◆ activateUser()

bool Servatrice_DatabaseInterface::activateUser ( const QString & userName,
const QString & token )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ activeUserExists()

bool Servatrice_DatabaseInterface::activeUserExists ( const QString & user)
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ addAuditRecord()

void Servatrice_DatabaseInterface::addAuditRecord ( const QString & user,
const QString & ipaddress,
const QString & clientid,
const QString & action,
const QString & details,
const bool & results = false )
Here is the call graph for this function:

◆ addForgotPassword()

bool Servatrice_DatabaseInterface::addForgotPassword ( const QString & user)
Here is the call graph for this function:

◆ addWarning()

bool Servatrice_DatabaseInterface::addWarning ( const QString userName,
const QString adminName,
const QString warningReason,
const QString clientID )
Here is the call graph for this function:

◆ changeUserPassword() [1/2]

bool Servatrice_DatabaseInterface::changeUserPassword ( const QString & user,
const QString & oldPassword,
bool oldPasswordNeedsHash,
const QString & newPassword,
bool newPasswordNeedsHash )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ changeUserPassword() [2/2]

bool Servatrice_DatabaseInterface::changeUserPassword ( const QString & user,
const QString & password,
bool passwordNeedsHash )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkNumberOfUserAccounts()

int Servatrice_DatabaseInterface::checkNumberOfUserAccounts ( const QString & email)
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ checkSql()

bool Servatrice_DatabaseInterface::checkSql ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkUserIsBanned()

bool Servatrice_DatabaseInterface::checkUserIsBanned ( const QString & ipAddress,
const QString & userName,
const QString & clientId,
QString & banReason,
int & banSecondsRemaining )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkUserIsIdBanned()

bool Servatrice_DatabaseInterface::checkUserIsIdBanned ( const QString & clientId,
QString & banReason,
int & banSecondsRemaining )
private

Must be called after checkSql and server is known to be in auth mode.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkUserIsIpBanned()

bool Servatrice_DatabaseInterface::checkUserIsIpBanned ( const QString & ipAddress,
QString & banReason,
int & banSecondsRemaining )
private

Must be called after checkSql and server is known to be in auth mode.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkUserIsNameBanned()

bool Servatrice_DatabaseInterface::checkUserIsNameBanned ( QString const & userName,
QString & banReason,
int & banSecondsRemaining )
private

Must be called after checkSql and server is known to be in auth mode.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkUserPassword()

AuthenticationResult Servatrice_DatabaseInterface::checkUserPassword ( Server_ProtocolHandler * handler,
const QString & user,
const QString & password,
const QString & clientId,
QString & reasonStr,
int & banSecondsLeft,
bool passwordNeedsHash )
overrideprotectedvirtual

Implements Server_DatabaseInterface.

Here is the call graph for this function:

◆ clearSessionTables()

void Servatrice_DatabaseInterface::clearSessionTables ( )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ doesForgotPasswordExist()

bool Servatrice_DatabaseInterface::doesForgotPasswordExist ( const QString & user)
Here is the call graph for this function:

◆ endSession()

void Servatrice_DatabaseInterface::endSession ( qint64 sessionId)
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ evalUserQueryResult()

ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult ( const QSqlQuery * query,
bool complete,
bool withId = false )
private
Here is the caller graph for this function:

◆ execSqlQuery()

bool Servatrice_DatabaseInterface::execSqlQuery ( QSqlQuery * query)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getActiveUserCount()

int Servatrice_DatabaseInterface::getActiveUserCount ( QString connectionType = QString())
overridevirtual

Implements Server_DatabaseInterface.

Here is the call graph for this function:

◆ getBuddyList()

QMap< QString, ServerInfo_User > Servatrice_DatabaseInterface::getBuddyList ( const QString & name)
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ getDatabase()

const QSqlDatabase & Servatrice_DatabaseInterface::getDatabase ( )
inline

◆ getDeckFromDatabase()

DeckList * Servatrice_DatabaseInterface::getDeckFromDatabase ( int deckId,
int userId )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ getIgnoreList()

QMap< QString, ServerInfo_User > Servatrice_DatabaseInterface::getIgnoreList ( const QString & name)
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ getMessageLogHistory()

QList< ServerInfo_ChatMessage > Servatrice_DatabaseInterface::getMessageLogHistory ( const QString & user,
const QString & ipaddress,
const QString & gamename,
const QString & gameid,
const QString & message,
bool & chat,
bool & game,
bool & room,
int & range,
int & maxresults )
Here is the call graph for this function:

◆ getNextGameId()

int Servatrice_DatabaseInterface::getNextGameId ( )
overridevirtual

Implements Server_DatabaseInterface.

Here is the call graph for this function:

◆ getNextReplayId()

int Servatrice_DatabaseInterface::getNextReplayId ( )
overridevirtual

Implements Server_DatabaseInterface.

Here is the call graph for this function:

◆ getUserBanHistory()

QList< ServerInfo_Ban > Servatrice_DatabaseInterface::getUserBanHistory ( const QString userName)
Here is the call graph for this function:

◆ getUserData()

ServerInfo_User Servatrice_DatabaseInterface::getUserData ( const QString & name,
bool withId = false )
overridevirtual

Implements Server_DatabaseInterface.

Here is the call graph for this function:

◆ getUserIdInDB()

int Servatrice_DatabaseInterface::getUserIdInDB ( const QString & name)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUserSalt()

QString Servatrice_DatabaseInterface::getUserSalt ( const QString & user)
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ getUserWarnHistory()

QList< ServerInfo_Warning > Servatrice_DatabaseInterface::getUserWarnHistory ( const QString userName)
Here is the call graph for this function:

◆ initDatabase [1/2]

void Servatrice_DatabaseInterface::initDatabase ( const QSqlDatabase & _sqlDatabase)
slot
Here is the call graph for this function:

◆ initDatabase() [2/2]

bool Servatrice_DatabaseInterface::initDatabase ( const QString & type,
const QString & hostName,
const QString & databaseName,
const QString & userName,
const QString & password )
Here is the call graph for this function:

◆ isInBuddyList()

bool Servatrice_DatabaseInterface::isInBuddyList ( const QString & whoseList,
const QString & who )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ isInIgnoreList()

bool Servatrice_DatabaseInterface::isInIgnoreList ( const QString & whoseList,
const QString & who )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ lockSessionTables()

void Servatrice_DatabaseInterface::lockSessionTables ( )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logMessage()

void Servatrice_DatabaseInterface::logMessage ( const int senderId,
const QString & senderName,
const QString & senderIp,
const QString & logMessage,
LogMessage_TargetType targetType,
const int targetId,
const QString & targetName )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openDatabase()

bool Servatrice_DatabaseInterface::openDatabase ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepareQuery()

QSqlQuery * Servatrice_DatabaseInterface::prepareQuery ( const QString & queryText)
Here is the caller graph for this function:

◆ registerUser()

bool Servatrice_DatabaseInterface::registerUser ( const QString & userName,
const QString & realName,
const QString & password,
bool passwordNeedsHash,
const QString & emailAddress,
const QString & country,
bool active = false )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ removeForgotPassword()

bool Servatrice_DatabaseInterface::removeForgotPassword ( const QString & user)
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ startSession()

qint64 Servatrice_DatabaseInterface::startSession ( const QString & userName,
const QString & address,
const QString & clientId,
const QString & connectionType )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ storeGameInformation()

void Servatrice_DatabaseInterface::storeGameInformation ( const QString & roomName,
const QStringList & roomGameTypes,
const ServerInfo_Game & gameInfo,
const QSet< QString > & allPlayersEver,
const QSet< QString > & allSpectatorsEver,
const QList< GameReplay * > & replayList )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ unlockSessionTables()

void Servatrice_DatabaseInterface::unlockSessionTables ( )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateUsersClientID()

void Servatrice_DatabaseInterface::updateUsersClientID ( const QString & userName,
const QString & userClientID )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ updateUsersLastLoginData()

void Servatrice_DatabaseInterface::updateUsersLastLoginData ( const QString & userName,
const QString & clientVersion )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ updateUserToken()

bool Servatrice_DatabaseInterface::updateUserToken ( const QString & token,
const QString & user )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ userExists()

bool Servatrice_DatabaseInterface::userExists ( const QString & user)
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ usernameIsValid()

bool Servatrice_DatabaseInterface::usernameIsValid ( const QString & user,
QString & error )
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the caller graph for this function:

◆ userSessionExists()

bool Servatrice_DatabaseInterface::userSessionExists ( const QString & userName)
overridevirtual

Reimplemented from Server_DatabaseInterface.

Here is the call graph for this function:

◆ validateTableColumnStringData()

bool Servatrice_DatabaseInterface::validateTableColumnStringData ( const QString & table,
const QString & column,
const QString & _user,
const QString & _datatocheck )
Here is the call graph for this function:

Member Data Documentation

◆ instanceId

int Servatrice_DatabaseInterface::instanceId
private

◆ preparedStatements

QHash<QString, QSqlQuery *> Servatrice_DatabaseInterface::preparedStatements
private

◆ server

Servatrice* Servatrice_DatabaseInterface::server
private

◆ sqlDatabase

QSqlDatabase Servatrice_DatabaseInterface::sqlDatabase
private

The documentation for this class was generated from the following files: