mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
[Server] Move the database lifecycle calls onto the interface (#7859)
This commit is contained in:
parent
526d528e96
commit
0caacb27c1
4 changed files with 24 additions and 6 deletions
|
|
@ -816,6 +816,24 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
/** @brief Opens the server's main database connection; false when it cannot be opened. */
|
||||
virtual bool openDatabase(const QString & /* type */,
|
||||
const QString & /* hostName */,
|
||||
const QString & /* databaseName */,
|
||||
const QString & /* userName */,
|
||||
const QString & /* password */)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/** @brief Drops expired deck shares; a no-op when persistence is unavailable. */
|
||||
virtual void cleanupExpiredDeckShares()
|
||||
{
|
||||
}
|
||||
/** @brief Purges expired legacy password backups; a no-op when persistence is unavailable. */
|
||||
virtual void purgeExpiredLegacyBackups()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void clearSessionTables()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ bool Servatrice::initServer()
|
|||
|
||||
if (databaseType != DatabaseNone) {
|
||||
dbPrefix = getDBPrefixString();
|
||||
bool dbOpened = servatriceDatabaseInterface->initDatabase(
|
||||
bool dbOpened = servatriceDatabaseInterface->openDatabase(
|
||||
"QMYSQL", getDBHostNameString(), getDBDatabaseNameString(), getDBUserNameString(), getDBPasswordString());
|
||||
if (!dbOpened) {
|
||||
qCCritical(ServatriceLog) << "Failed to open the database; refusing to start.";
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ void Servatrice_DatabaseInterface::initDatabase(const QSqlDatabase &_sqlDatabase
|
|||
}
|
||||
}
|
||||
|
||||
bool Servatrice_DatabaseInterface::initDatabase(const QString &type,
|
||||
bool Servatrice_DatabaseInterface::openDatabase(const QString &type,
|
||||
const QString &hostName,
|
||||
const QString &databaseName,
|
||||
const QString &userName,
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@ public slots:
|
|||
public:
|
||||
explicit Servatrice_DatabaseInterface(int _instanceId, Servatrice *_server);
|
||||
~Servatrice_DatabaseInterface() override;
|
||||
bool initDatabase(const QString &type,
|
||||
bool openDatabase(const QString &type,
|
||||
const QString &hostName,
|
||||
const QString &databaseName,
|
||||
const QString &userName,
|
||||
const QString &password);
|
||||
const QString &password) override;
|
||||
bool openDatabase();
|
||||
bool checkSql() override;
|
||||
QSqlQuery *prepareQuery(const QString &queryText);
|
||||
|
|
@ -94,7 +94,7 @@ public:
|
|||
/** @brief Drop the account's legacy password backup. */
|
||||
void clearLegacyBackup(const QString &user);
|
||||
/** @brief Drop every legacy password backup that has not been used within the TTL. */
|
||||
void purgeExpiredLegacyBackups();
|
||||
void purgeExpiredLegacyBackups() override;
|
||||
int getUserIdInDB(const QString &name);
|
||||
int getUserId(const QString &name) override;
|
||||
bool addToBuddyList(int userId, int targetId) override;
|
||||
|
|
@ -172,7 +172,7 @@ public:
|
|||
ReplayAccessResult getLatestReplayForGame(int gameId, int &replayId, QByteArray &data) override;
|
||||
ReplayWriteResult grantReplayAccessByName(int gameId, const QString &userName) override;
|
||||
/** @brief Deletes all expired share bundles (cascades to their items). */
|
||||
void cleanupExpiredDeckShares();
|
||||
void cleanupExpiredDeckShares() override;
|
||||
|
||||
int getNextGameId() override;
|
||||
int getNextReplayId() override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue