mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-29 01:53:54 -07:00
Connect/disconnect and join game/room intents.
Took 3 hours 14 minutes
This commit is contained in:
parent
ea6d9366a3
commit
d174a2941f
26 changed files with 512 additions and 3 deletions
|
|
@ -289,3 +289,46 @@ bool ServersSettings::updateExistingServer(QString saveName,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int ServersSettings::findServerIndex(const QString &host, const QString &port) const
|
||||
{
|
||||
int size = getValue("totalServers", "server", "server_details").toInt();
|
||||
|
||||
for (int i = 0; i <= size; ++i) {
|
||||
QString storedHost = getValue(QString("server%1").arg(i), "server", "server_details").toString();
|
||||
QString storedPort = getValue(QString("port%1").arg(i), "server", "server_details").toString();
|
||||
|
||||
if (storedHost == host && storedPort == port) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool ServersSettings::hasUsername(const QString &host, const QString &port) const
|
||||
{
|
||||
int index = findServerIndex(host, port);
|
||||
if (index < 0)
|
||||
return false;
|
||||
|
||||
QString user = getValue(QString("username%1").arg(index), "server", "server_details").toString();
|
||||
return !user.isEmpty();
|
||||
}
|
||||
|
||||
bool ServersSettings::hasCredentials(const QString &host, const QString &port) const
|
||||
{
|
||||
int index = findServerIndex(host, port);
|
||||
if (index < 0)
|
||||
return false;
|
||||
|
||||
bool save = getValue(QString("savePassword%1").arg(index), "server", "server_details").toBool();
|
||||
QString password = getValue(QString("password%1").arg(index), "server", "server_details").toString();
|
||||
|
||||
return save && !password.isEmpty();
|
||||
}
|
||||
|
||||
bool ServersSettings::hasLoginData(const QString &host, const QString &port) const
|
||||
{
|
||||
return hasUsername(host, port) && hasCredentials(host, port);
|
||||
}
|
||||
|
|
@ -61,6 +61,10 @@ public:
|
|||
QString password,
|
||||
bool savePassword,
|
||||
QString site = QString());
|
||||
int findServerIndex(const QString &host, const QString &port) const;
|
||||
bool hasUsername(const QString &host, const QString &port) const;
|
||||
bool hasCredentials(const QString &host, const QString &port) const;
|
||||
bool hasLoginData(const QString &host, const QString &port) const;
|
||||
|
||||
bool updateExistingServerWithoutLoss(QString saveName,
|
||||
QString serv = QString(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue