show ban duration in client
This commit is contained in:
parent
78d188c462
commit
13b992cf12
15 changed files with 159 additions and 91 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
||||||
tags
|
tags
|
||||||
|
build
|
||||||
*.qm
|
*.qm
|
||||||
|
.directory
|
||||||
|
|
|
@ -38,7 +38,6 @@ class AbstractClient : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
signals:
|
signals:
|
||||||
void statusChanged(ClientStatus _status);
|
void statusChanged(ClientStatus _status);
|
||||||
void serverError(Response::ResponseCode resp, QString reasonStr);
|
|
||||||
|
|
||||||
// Room events
|
// Room events
|
||||||
void roomEventReceived(const RoomEvent &event);
|
void roomEventReceived(const RoomEvent &event);
|
||||||
|
|
|
@ -24,6 +24,7 @@ RemoteClient::RemoteClient(QObject *parent)
|
||||||
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError)));
|
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError)));
|
||||||
|
|
||||||
connect(this, SIGNAL(serverIdentificationEventReceived(const Event_ServerIdentification &)), this, SLOT(processServerIdentificationEvent(const Event_ServerIdentification &)));
|
connect(this, SIGNAL(serverIdentificationEventReceived(const Event_ServerIdentification &)), this, SLOT(processServerIdentificationEvent(const Event_ServerIdentification &)));
|
||||||
|
connect(this, SIGNAL(connectionClosedEventReceived(Event_ConnectionClosed)), this, SLOT(processConnectionClosedEvent(Event_ConnectionClosed)));
|
||||||
connect(this, SIGNAL(sigConnectToServer(QString, unsigned int, QString, QString)), this, SLOT(doConnectToServer(QString, unsigned int, QString, QString)));
|
connect(this, SIGNAL(sigConnectToServer(QString, unsigned int, QString, QString)), this, SLOT(doConnectToServer(QString, unsigned int, QString, QString)));
|
||||||
connect(this, SIGNAL(sigDisconnectFromServer()), this, SLOT(doDisconnectFromServer()));
|
connect(this, SIGNAL(sigDisconnectFromServer()), this, SLOT(doDisconnectFromServer()));
|
||||||
}
|
}
|
||||||
|
@ -66,6 +67,11 @@ void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentifica
|
||||||
sendCommand(pend);
|
sendCommand(pend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoteClient::processConnectionClosedEvent(const Event_ConnectionClosed & /*event*/)
|
||||||
|
{
|
||||||
|
doDisconnectFromServer();
|
||||||
|
}
|
||||||
|
|
||||||
void RemoteClient::loginResponse(const Response &response)
|
void RemoteClient::loginResponse(const Response &response)
|
||||||
{
|
{
|
||||||
const Response_Login &resp = response.GetExtension(Response_Login::ext);
|
const Response_Login &resp = response.GetExtension(Response_Login::ext);
|
||||||
|
@ -83,7 +89,7 @@ void RemoteClient::loginResponse(const Response &response)
|
||||||
ignoreList.append(resp.ignore_list(i));
|
ignoreList.append(resp.ignore_list(i));
|
||||||
emit ignoreListReceived(ignoreList);
|
emit ignoreListReceived(ignoreList);
|
||||||
} else {
|
} else {
|
||||||
emit serverError(response.response_code(), QString::fromStdString(resp.denied_reason_str()));
|
emit loginError(response.response_code(), QString::fromStdString(resp.denied_reason_str()), resp.denied_end_time());
|
||||||
setStatus(StatusDisconnecting);
|
setStatus(StatusDisconnecting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ class RemoteClient : public AbstractClient {
|
||||||
signals:
|
signals:
|
||||||
void maxPingTime(int seconds, int maxSeconds);
|
void maxPingTime(int seconds, int maxSeconds);
|
||||||
void serverTimeout();
|
void serverTimeout();
|
||||||
|
void loginError(Response::ResponseCode resp, QString reasonStr, quint32 endTime);
|
||||||
void socketError(const QString &errorString);
|
void socketError(const QString &errorString);
|
||||||
void protocolVersionMismatch(int clientVersion, int serverVersion);
|
void protocolVersionMismatch(int clientVersion, int serverVersion);
|
||||||
void protocolError();
|
void protocolError();
|
||||||
|
@ -22,6 +23,7 @@ private slots:
|
||||||
void slotSocketError(QAbstractSocket::SocketError error);
|
void slotSocketError(QAbstractSocket::SocketError error);
|
||||||
void ping();
|
void ping();
|
||||||
void processServerIdentificationEvent(const Event_ServerIdentification &event);
|
void processServerIdentificationEvent(const Event_ServerIdentification &event);
|
||||||
|
void processConnectionClosedEvent(const Event_ConnectionClosed &event);
|
||||||
void loginResponse(const Response &response);
|
void loginResponse(const Response &response);
|
||||||
void doConnectToServer(const QString &hostname, unsigned int port, const QString &_userName, const QString &_password);
|
void doConnectToServer(const QString &hostname, unsigned int port, const QString &_userName, const QString &_password);
|
||||||
void doDisconnectFromServer();
|
void doDisconnectFromServer();
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "window_main.h"
|
#include "window_main.h"
|
||||||
|
@ -67,6 +68,10 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even
|
||||||
case Event_ConnectionClosed::TOO_MANY_CONNECTIONS: reasonStr = tr("There are too many concurrent connections from your address."); break;
|
case Event_ConnectionClosed::TOO_MANY_CONNECTIONS: reasonStr = tr("There are too many concurrent connections from your address."); break;
|
||||||
case Event_ConnectionClosed::BANNED: {
|
case Event_ConnectionClosed::BANNED: {
|
||||||
reasonStr = tr("Banned by moderator");
|
reasonStr = tr("Banned by moderator");
|
||||||
|
if (event.has_end_time())
|
||||||
|
reasonStr.append("\n" + tr("Expected end time: %1").arg(QDateTime::fromTime_t(event.end_time()).toString()));
|
||||||
|
else
|
||||||
|
reasonStr.append("\n" + tr("This ban lasts indefinitely."));
|
||||||
if (event.has_reason_str())
|
if (event.has_reason_str())
|
||||||
reasonStr.append("\n\n" + QString::fromStdString(event.reason_str()));
|
reasonStr.append("\n\n" + QString::fromStdString(event.reason_str()));
|
||||||
break;
|
break;
|
||||||
|
@ -234,13 +239,29 @@ void MainWindow::serverTimeout()
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Server timeout"));
|
QMessageBox::critical(this, tr("Error"), tr("Server timeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::serverError(Response::ResponseCode r, QString reasonStr)
|
void MainWindow::loginError(Response::ResponseCode r, QString reasonStr, quint32 endTime)
|
||||||
{
|
{
|
||||||
switch (r) {
|
switch (r) {
|
||||||
case Response::RespWrongPassword: QMessageBox::critical(this, tr("Error"), tr("Invalid login data.")); break;
|
case Response::RespWrongPassword:
|
||||||
case Response::RespWouldOverwriteOldSession: QMessageBox::critical(this, tr("Error"), tr("There is already an active session using this user name.\nPlease close that session first and re-login.")); break;
|
QMessageBox::critical(this, tr("Error"), tr("Invalid login data."));
|
||||||
case Response::RespUserIsBanned: QMessageBox::critical(this, tr("Error"), tr("You are banned.\n%1").arg(reasonStr)); break;
|
break;
|
||||||
default: QMessageBox::critical(this, tr("Error"), tr("Unknown server error: %1").arg(static_cast<int>(r)));
|
case Response::RespWouldOverwriteOldSession:
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("There is already an active session using this user name.\nPlease close that session first and re-login."));
|
||||||
|
break;
|
||||||
|
case Response::RespUserIsBanned: {
|
||||||
|
QString bannedStr;
|
||||||
|
if (endTime)
|
||||||
|
bannedStr = tr("You are banned until %1.").arg(QDateTime::fromTime_t(endTime).toString());
|
||||||
|
else
|
||||||
|
bannedStr = tr("You are banned indefinitely.");
|
||||||
|
if (!reasonStr.isEmpty())
|
||||||
|
bannedStr.append("\n\n" + reasonStr);
|
||||||
|
|
||||||
|
QMessageBox::critical(this, tr("Error"), bannedStr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Unknown login error: %1").arg(static_cast<int>(r)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +364,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
client = new RemoteClient;
|
client = new RemoteClient;
|
||||||
connect(client, SIGNAL(connectionClosedEventReceived(const Event_ConnectionClosed &)), this, SLOT(processConnectionClosedEvent(const Event_ConnectionClosed &)));
|
connect(client, SIGNAL(connectionClosedEventReceived(const Event_ConnectionClosed &)), this, SLOT(processConnectionClosedEvent(const Event_ConnectionClosed &)));
|
||||||
connect(client, SIGNAL(serverShutdownEventReceived(const Event_ServerShutdown &)), this, SLOT(processServerShutdownEvent(const Event_ServerShutdown &)));
|
connect(client, SIGNAL(serverShutdownEventReceived(const Event_ServerShutdown &)), this, SLOT(processServerShutdownEvent(const Event_ServerShutdown &)));
|
||||||
connect(client, SIGNAL(serverError(Response::ResponseCode, QString)), this, SLOT(serverError(Response::ResponseCode, QString)));
|
connect(client, SIGNAL(loginError(Response::ResponseCode, QString, quint32)), this, SLOT(loginError(Response::ResponseCode, QString, quint32)));
|
||||||
connect(client, SIGNAL(socketError(const QString &)), this, SLOT(socketError(const QString &)));
|
connect(client, SIGNAL(socketError(const QString &)), this, SLOT(socketError(const QString &)));
|
||||||
connect(client, SIGNAL(serverTimeout()), this, SLOT(serverTimeout()));
|
connect(client, SIGNAL(serverTimeout()), this, SLOT(serverTimeout()));
|
||||||
connect(client, SIGNAL(statusChanged(ClientStatus)), this, SLOT(statusChanged(ClientStatus)));
|
connect(client, SIGNAL(statusChanged(ClientStatus)), this, SLOT(statusChanged(ClientStatus)));
|
||||||
|
|
|
@ -39,7 +39,7 @@ private slots:
|
||||||
void processConnectionClosedEvent(const Event_ConnectionClosed &event);
|
void processConnectionClosedEvent(const Event_ConnectionClosed &event);
|
||||||
void processServerShutdownEvent(const Event_ServerShutdown &event);
|
void processServerShutdownEvent(const Event_ServerShutdown &event);
|
||||||
void serverTimeout();
|
void serverTimeout();
|
||||||
void serverError(Response::ResponseCode r, QString reasonStr);
|
void loginError(Response::ResponseCode r, QString reasonStr, quint32 endTime);
|
||||||
void socketError(const QString &errorStr);
|
void socketError(const QString &errorStr);
|
||||||
void protocolVersionMismatch(int localVersion, int remoteVersion);
|
void protocolVersionMismatch(int localVersion, int remoteVersion);
|
||||||
void userInfoReceived(const ServerInfo_User &userInfo);
|
void userInfoReceived(const ServerInfo_User &userInfo);
|
||||||
|
|
|
@ -2293,7 +2293,7 @@ Dies wird nur für Moderatoren gespeichert und kann von der gebannten Person nic
|
||||||
<context>
|
<context>
|
||||||
<name>MainWindow</name>
|
<name>MainWindow</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="67"/>
|
<location filename="../src/window_main.cpp" line="68"/>
|
||||||
<source>There are too many concurrent connections from your address.</source>
|
<source>There are too many concurrent connections from your address.</source>
|
||||||
<translation>Es gibt zu viele gleichzeitige Verbindungen von Ihrer Adresse.</translation>
|
<translation>Es gibt zu viele gleichzeitige Verbindungen von Ihrer Adresse.</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -2302,7 +2302,7 @@ Dies wird nur für Moderatoren gespeichert und kann von der gebannten Person nic
|
||||||
<translation type="obsolete">Gebannt von einem Moderator.</translation>
|
<translation type="obsolete">Gebannt von einem Moderator.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="74"/>
|
<location filename="../src/window_main.cpp" line="79"/>
|
||||||
<source>Scheduled server shutdown.</source>
|
<source>Scheduled server shutdown.</source>
|
||||||
<translation>Planmäßige Serverabschaltung.</translation>
|
<translation>Planmäßige Serverabschaltung.</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -2311,29 +2311,39 @@ Dies wird nur für Moderatoren gespeichert und kann von der gebannten Person nic
|
||||||
<translation type="obsolete">Unbekannter Grund.</translation>
|
<translation type="obsolete">Unbekannter Grund.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="69"/>
|
<location filename="../src/window_main.cpp" line="70"/>
|
||||||
<source>Banned by moderator</source>
|
<source>Banned by moderator</source>
|
||||||
<translation>Gebannt von einem Moderator</translation>
|
<translation>Gebannt von einem Moderator</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="77"/>
|
<location filename="../src/window_main.cpp" line="72"/>
|
||||||
|
<source>Expected end time: %1</source>
|
||||||
|
<translation>Voraussichtliches Ende: %1</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/window_main.cpp" line="74"/>
|
||||||
|
<source>This ban lasts indefinitely.</source>
|
||||||
|
<translation>Dieser Bann ist unbefristet.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/window_main.cpp" line="82"/>
|
||||||
<source>Connection closed</source>
|
<source>Connection closed</source>
|
||||||
<translation>Verbindung geschlossen</translation>
|
<translation>Verbindung geschlossen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="77"/>
|
<location filename="../src/window_main.cpp" line="82"/>
|
||||||
<source>The server has terminated your connection.
|
<source>The server has terminated your connection.
|
||||||
Reason: %1</source>
|
Reason: %1</source>
|
||||||
<translation>Der Server hat Ihre Verbindung beendet.
|
<translation>Der Server hat Ihre Verbindung beendet.
|
||||||
Grund: %1</translation>
|
Grund: %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="82"/>
|
<location filename="../src/window_main.cpp" line="87"/>
|
||||||
<source>Scheduled server shutdown</source>
|
<source>Scheduled server shutdown</source>
|
||||||
<translation>Planmäßige Serverabschaltung</translation>
|
<translation>Planmäßige Serverabschaltung</translation>
|
||||||
</message>
|
</message>
|
||||||
<message numerus="yes">
|
<message numerus="yes">
|
||||||
<location filename="../src/window_main.cpp" line="82"/>
|
<location filename="../src/window_main.cpp" line="87"/>
|
||||||
<source>The server is going to be restarted in %n minute(s).
|
<source>The server is going to be restarted in %n minute(s).
|
||||||
All running games will be lost.
|
All running games will be lost.
|
||||||
Reason for shutdown: %1</source>
|
Reason for shutdown: %1</source>
|
||||||
|
@ -2347,150 +2357,163 @@ Grund für die Abschaltung: %1</numerusform>
|
||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="131"/>
|
<location filename="../src/window_main.cpp" line="136"/>
|
||||||
<source>Number of players</source>
|
<source>Number of players</source>
|
||||||
<translation>Spieleranzahl</translation>
|
<translation>Spieleranzahl</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="131"/>
|
<location filename="../src/window_main.cpp" line="136"/>
|
||||||
<source>Please enter the number of players.</source>
|
<source>Please enter the number of players.</source>
|
||||||
<translation>Bitte die Spieleranzahl eingeben:</translation>
|
<translation>Bitte die Spieleranzahl eingeben:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="140"/>
|
<location filename="../src/window_main.cpp" line="145"/>
|
||||||
<location filename="../src/window_main.cpp" line="146"/>
|
<location filename="../src/window_main.cpp" line="151"/>
|
||||||
<source>Player %1</source>
|
<source>Player %1</source>
|
||||||
<translation>Spieler %1</translation>
|
<translation>Spieler %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="158"/>
|
<location filename="../src/window_main.cpp" line="163"/>
|
||||||
<source>Load replay</source>
|
<source>Load replay</source>
|
||||||
<translation>Aufgezeichnetes Spiel laden</translation>
|
<translation>Aufgezeichnetes Spiel laden</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="214"/>
|
<location filename="../src/window_main.cpp" line="219"/>
|
||||||
<source>About Cockatrice</source>
|
<source>About Cockatrice</source>
|
||||||
<translation>Über Cockatrice</translation>
|
<translation>Über Cockatrice</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="216"/>
|
<location filename="../src/window_main.cpp" line="221"/>
|
||||||
<source>Version %1</source>
|
<source>Version %1</source>
|
||||||
<translation>Version %1</translation>
|
<translation>Version %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="217"/>
|
<location filename="../src/window_main.cpp" line="222"/>
|
||||||
<source>Authors:</source>
|
<source>Authors:</source>
|
||||||
<translation>Autoren:</translation>
|
<translation>Autoren:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="218"/>
|
<location filename="../src/window_main.cpp" line="223"/>
|
||||||
<source>Translators:</source>
|
<source>Translators:</source>
|
||||||
<translation>Übersetzer:</translation>
|
<translation>Übersetzer:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="219"/>
|
<location filename="../src/window_main.cpp" line="224"/>
|
||||||
<source>Spanish:</source>
|
<source>Spanish:</source>
|
||||||
<translation>Spanisch:</translation>
|
<translation>Spanisch:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="220"/>
|
<location filename="../src/window_main.cpp" line="225"/>
|
||||||
<source>Portugese (Portugal):</source>
|
<source>Portugese (Portugal):</source>
|
||||||
<translation>Portugiesisch (Portugal):</translation>
|
<translation>Portugiesisch (Portugal):</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="221"/>
|
<location filename="../src/window_main.cpp" line="226"/>
|
||||||
<source>Portugese (Brazil):</source>
|
<source>Portugese (Brazil):</source>
|
||||||
<translation>Portugiesisch (Brasilien):</translation>
|
<translation>Portugiesisch (Brasilien):</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="222"/>
|
<location filename="../src/window_main.cpp" line="227"/>
|
||||||
<source>French:</source>
|
<source>French:</source>
|
||||||
<translation>Französisch:</translation>
|
<translation>Französisch:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="223"/>
|
<location filename="../src/window_main.cpp" line="228"/>
|
||||||
<source>Japanese:</source>
|
<source>Japanese:</source>
|
||||||
<translation>Japanisch:</translation>
|
<translation>Japanisch:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="224"/>
|
<location filename="../src/window_main.cpp" line="229"/>
|
||||||
<source>Russian:</source>
|
<source>Russian:</source>
|
||||||
<translation>Russisch:</translation>
|
<translation>Russisch:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="225"/>
|
<location filename="../src/window_main.cpp" line="230"/>
|
||||||
<source>Czech:</source>
|
<source>Czech:</source>
|
||||||
<translation>Tschechisch:</translation>
|
<translation>Tschechisch:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="227"/>
|
<location filename="../src/window_main.cpp" line="232"/>
|
||||||
<source>Italian:</source>
|
<source>Italian:</source>
|
||||||
<translation>Italienisch:</translation>
|
<translation>Italienisch:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="228"/>
|
<location filename="../src/window_main.cpp" line="233"/>
|
||||||
<source>Swedish:</source>
|
<source>Swedish:</source>
|
||||||
<translation>Schwedisch:</translation>
|
<translation>Schwedisch:</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/window_main.cpp" line="254"/>
|
||||||
|
<source>You are banned until %1.</source>
|
||||||
|
<translation>Sie sind gebannt bis: %1.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/window_main.cpp" line="256"/>
|
||||||
|
<source>You are banned indefinitely.</source>
|
||||||
|
<translation>Sie sind auf unbestimmte Zeit gebannt.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/window_main.cpp" line="264"/>
|
||||||
|
<source>Unknown login error: %1</source>
|
||||||
|
<translation>Unbekannter Login-Fehler: %1</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Slovak:</source>
|
<source>Slovak:</source>
|
||||||
<translation type="obsolete">Slowakisch:</translation>
|
<translation type="obsolete">Slowakisch:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="234"/>
|
<location filename="../src/window_main.cpp" line="239"/>
|
||||||
<location filename="../src/window_main.cpp" line="240"/>
|
<location filename="../src/window_main.cpp" line="246"/>
|
||||||
<location filename="../src/window_main.cpp" line="241"/>
|
|
||||||
<location filename="../src/window_main.cpp" line="242"/>
|
|
||||||
<location filename="../src/window_main.cpp" line="243"/>
|
|
||||||
<location filename="../src/window_main.cpp" line="249"/>
|
<location filename="../src/window_main.cpp" line="249"/>
|
||||||
<location filename="../src/window_main.cpp" line="255"/>
|
<location filename="../src/window_main.cpp" line="260"/>
|
||||||
<location filename="../src/window_main.cpp" line="257"/>
|
<location filename="../src/window_main.cpp" line="264"/>
|
||||||
|
<location filename="../src/window_main.cpp" line="270"/>
|
||||||
|
<location filename="../src/window_main.cpp" line="276"/>
|
||||||
|
<location filename="../src/window_main.cpp" line="278"/>
|
||||||
<source>Error</source>
|
<source>Error</source>
|
||||||
<translation>Fehler</translation>
|
<translation>Fehler</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="234"/>
|
<location filename="../src/window_main.cpp" line="239"/>
|
||||||
<source>Server timeout</source>
|
<source>Server timeout</source>
|
||||||
<translation>Server Zeitüberschreitung</translation>
|
<translation>Server Zeitüberschreitung</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="240"/>
|
<location filename="../src/window_main.cpp" line="246"/>
|
||||||
<source>Invalid login data.</source>
|
<source>Invalid login data.</source>
|
||||||
<translation>Ungültige Anmeldedaten.</translation>
|
<translation>Ungültige Anmeldedaten.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="241"/>
|
<location filename="../src/window_main.cpp" line="249"/>
|
||||||
<source>There is already an active session using this user name.
|
<source>There is already an active session using this user name.
|
||||||
Please close that session first and re-login.</source>
|
Please close that session first and re-login.</source>
|
||||||
<translation>Es gibt bereits eine aktive Verbindung mit diesem Benutzernamen.
|
<translation>Es gibt bereits eine aktive Verbindung mit diesem Benutzernamen.
|
||||||
Bitte schließen Sie diese Verbindung zuerst und versuchen Sie es dann erneut.</translation>
|
Bitte schließen Sie diese Verbindung zuerst und versuchen Sie es dann erneut.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="242"/>
|
|
||||||
<source>You are banned.
|
<source>You are banned.
|
||||||
%1</source>
|
%1</source>
|
||||||
<translation>Sie sind gebannt.
|
<translation type="obsolete">Sie sind gebannt.
|
||||||
%1</translation>
|
%1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="243"/>
|
|
||||||
<source>Unknown server error: %1</source>
|
<source>Unknown server error: %1</source>
|
||||||
<translation>Unbekannter Serverfehler: %1</translation>
|
<translation type="obsolete">Unbekannter Serverfehler: %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="249"/>
|
<location filename="../src/window_main.cpp" line="270"/>
|
||||||
<source>Socket error: %1</source>
|
<source>Socket error: %1</source>
|
||||||
<translation>Netzwerkfehler: %1</translation>
|
<translation>Netzwerkfehler: %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="255"/>
|
<location filename="../src/window_main.cpp" line="276"/>
|
||||||
<source>You are trying to connect to an obsolete server. Please downgrade your Cockatrice version or connect to a suitable server.
|
<source>You are trying to connect to an obsolete server. Please downgrade your Cockatrice version or connect to a suitable server.
|
||||||
Local version is %1, remote version is %2.</source>
|
Local version is %1, remote version is %2.</source>
|
||||||
<translation>Sie versuchen sich an einem veralteten Server anzumelden. Bitte verwenden Sie eine ältere Cockatrice-Version oder melden Sie sich an einem aktuellen Server an.
|
<translation>Sie versuchen sich an einem veralteten Server anzumelden. Bitte verwenden Sie eine ältere Cockatrice-Version oder melden Sie sich an einem aktuellen Server an.
|
||||||
Lokale Version ist %1, Serverversion ist %2.</translation>
|
Lokale Version ist %1, Serverversion ist %2.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="257"/>
|
<location filename="../src/window_main.cpp" line="278"/>
|
||||||
<source>Your Cockatrice client is obsolete. Please update your Cockatrice version.
|
<source>Your Cockatrice client is obsolete. Please update your Cockatrice version.
|
||||||
Local version is %1, remote version is %2.</source>
|
Local version is %1, remote version is %2.</source>
|
||||||
<translation>Ihr Cockatrice-Client ist veraltet. Bitte laden Sie sich die neueste Version herunter.
|
<translation>Ihr Cockatrice-Client ist veraltet. Bitte laden Sie sich die neueste Version herunter.
|
||||||
|
@ -2501,62 +2524,62 @@ Lokale Version ist %1, Serverversion ist %2.</translation>
|
||||||
<translation type="obsolete">Protokollversionen stimmen nicht überein. Lokale Version: %1, Serverversion: %2.</translation>
|
<translation type="obsolete">Protokollversionen stimmen nicht überein. Lokale Version: %1, Serverversion: %2.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="263"/>
|
<location filename="../src/window_main.cpp" line="284"/>
|
||||||
<source>Connecting to %1...</source>
|
<source>Connecting to %1...</source>
|
||||||
<translation>Verbinde zu %1...</translation>
|
<translation>Verbinde zu %1...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="264"/>
|
<location filename="../src/window_main.cpp" line="285"/>
|
||||||
<source>Disconnected</source>
|
<source>Disconnected</source>
|
||||||
<translation>nicht verbunden</translation>
|
<translation>nicht verbunden</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="265"/>
|
<location filename="../src/window_main.cpp" line="286"/>
|
||||||
<source>Connected, logging in at %1</source>
|
<source>Connected, logging in at %1</source>
|
||||||
<translation>Verbunden, Anmeldung bei %1</translation>
|
<translation>Verbunden, Anmeldung bei %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="266"/>
|
<location filename="../src/window_main.cpp" line="287"/>
|
||||||
<source>Logged in at %1</source>
|
<source>Logged in at %1</source>
|
||||||
<translation>Angemeldet bei %1</translation>
|
<translation>Angemeldet bei %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="275"/>
|
<location filename="../src/window_main.cpp" line="296"/>
|
||||||
<source>&Connect...</source>
|
<source>&Connect...</source>
|
||||||
<translation>&Verbinden...</translation>
|
<translation>&Verbinden...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="276"/>
|
<location filename="../src/window_main.cpp" line="297"/>
|
||||||
<source>&Disconnect</source>
|
<source>&Disconnect</source>
|
||||||
<translation>Verbindung &trennen</translation>
|
<translation>Verbindung &trennen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="277"/>
|
<location filename="../src/window_main.cpp" line="298"/>
|
||||||
<source>Start &local game...</source>
|
<source>Start &local game...</source>
|
||||||
<translation>&Lokales Spiel starten...</translation>
|
<translation>&Lokales Spiel starten...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="278"/>
|
<location filename="../src/window_main.cpp" line="299"/>
|
||||||
<source>&Watch replay...</source>
|
<source>&Watch replay...</source>
|
||||||
<translation>&Aufgezeichnetes Spiel abspielen...</translation>
|
<translation>&Aufgezeichnetes Spiel abspielen...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="287"/>
|
<location filename="../src/window_main.cpp" line="308"/>
|
||||||
<source>&About Cockatrice</source>
|
<source>&About Cockatrice</source>
|
||||||
<translation>&Über Cockatrice</translation>
|
<translation>&Über Cockatrice</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="288"/>
|
<location filename="../src/window_main.cpp" line="309"/>
|
||||||
<source>&Help</source>
|
<source>&Help</source>
|
||||||
<translation>&Hilfe</translation>
|
<translation>&Hilfe</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="380"/>
|
<location filename="../src/window_main.cpp" line="401"/>
|
||||||
<source>Are you sure?</source>
|
<source>Are you sure?</source>
|
||||||
<translation>Sind Sie sicher?</translation>
|
<translation>Sind Sie sicher?</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="380"/>
|
<location filename="../src/window_main.cpp" line="401"/>
|
||||||
<source>There are still open games. Are you sure you want to quit?</source>
|
<source>There are still open games. Are you sure you want to quit?</source>
|
||||||
<translation>Es gibt noch offene Spiele. Wollen Sie das Programm wirklich beenden?</translation>
|
<translation>Es gibt noch offene Spiele. Wollen Sie das Programm wirklich beenden?</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -2573,27 +2596,27 @@ Lokale Version ist %1, Serverversion ist %2.</translation>
|
||||||
<translation type="obsolete">Spiel ver&lassen</translation>
|
<translation type="obsolete">Spiel ver&lassen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="279"/>
|
<location filename="../src/window_main.cpp" line="300"/>
|
||||||
<source>&Deck editor</source>
|
<source>&Deck editor</source>
|
||||||
<translation>&Deck-Editor</translation>
|
<translation>&Deck-Editor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="280"/>
|
<location filename="../src/window_main.cpp" line="301"/>
|
||||||
<source>&Full screen</source>
|
<source>&Full screen</source>
|
||||||
<translation>&Vollbild</translation>
|
<translation>&Vollbild</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="281"/>
|
<location filename="../src/window_main.cpp" line="302"/>
|
||||||
<source>Ctrl+F</source>
|
<source>Ctrl+F</source>
|
||||||
<translation>Ctrl+F</translation>
|
<translation>Ctrl+F</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="282"/>
|
<location filename="../src/window_main.cpp" line="303"/>
|
||||||
<source>&Settings...</source>
|
<source>&Settings...</source>
|
||||||
<translation>&Einstellungen...</translation>
|
<translation>&Einstellungen...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="283"/>
|
<location filename="../src/window_main.cpp" line="304"/>
|
||||||
<source>&Exit</source>
|
<source>&Exit</source>
|
||||||
<translation>&Beenden</translation>
|
<translation>&Beenden</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -2606,7 +2629,7 @@ Lokale Version ist %1, Serverversion ist %2.</translation>
|
||||||
<translation type="obsolete">Esc</translation>
|
<translation type="obsolete">Esc</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="285"/>
|
<location filename="../src/window_main.cpp" line="306"/>
|
||||||
<source>&Cockatrice</source>
|
<source>&Cockatrice</source>
|
||||||
<translation>&Cockatrice</translation>
|
<translation>&Cockatrice</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -5171,7 +5194,7 @@ Lokale Version ist %1, Serverversion ist %2.</translation>
|
||||||
<translation type="obsolete">Alle Dateien (*.*)</translation>
|
<translation type="obsolete">Alle Dateien (*.*)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/window_main.cpp" line="160"/>
|
<location filename="../src/window_main.cpp" line="165"/>
|
||||||
<source>Cockatrice replays (*.cor)</source>
|
<source>Cockatrice replays (*.cor)</source>
|
||||||
<translation>Aufgezeichnete Cockatrice-Spiele (*.cor)</translation>
|
<translation>Aufgezeichnete Cockatrice-Spiele (*.cor)</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -5197,32 +5220,32 @@ Lokale Version ist %1, Serverversion ist %2.</translation>
|
||||||
<context>
|
<context>
|
||||||
<name>RemoteReplayList_TreeModel</name>
|
<name>RemoteReplayList_TreeModel</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/remotereplaylist_treewidget.cpp" line="125"/>
|
<location filename="../src/remotereplaylist_treewidget.cpp" line="137"/>
|
||||||
<source>ID</source>
|
<source>ID</source>
|
||||||
<translation>ID</translation>
|
<translation>ID</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/remotereplaylist_treewidget.cpp" line="126"/>
|
<location filename="../src/remotereplaylist_treewidget.cpp" line="138"/>
|
||||||
<source>Name</source>
|
<source>Name</source>
|
||||||
<translation>Name</translation>
|
<translation>Name</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/remotereplaylist_treewidget.cpp" line="127"/>
|
<location filename="../src/remotereplaylist_treewidget.cpp" line="139"/>
|
||||||
<source>Players</source>
|
<source>Players</source>
|
||||||
<translation>Spieler</translation>
|
<translation>Spieler</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/remotereplaylist_treewidget.cpp" line="128"/>
|
<location filename="../src/remotereplaylist_treewidget.cpp" line="140"/>
|
||||||
<source>Keep</source>
|
<source>Keep</source>
|
||||||
<translation>Behalten</translation>
|
<translation>Behalten</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/remotereplaylist_treewidget.cpp" line="129"/>
|
<location filename="../src/remotereplaylist_treewidget.cpp" line="141"/>
|
||||||
<source>Time started</source>
|
<source>Time started</source>
|
||||||
<translation>Startzeit</translation>
|
<translation>Startzeit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/remotereplaylist_treewidget.cpp" line="130"/>
|
<location filename="../src/remotereplaylist_treewidget.cpp" line="142"/>
|
||||||
<source>Duration (sec)</source>
|
<source>Duration (sec)</source>
|
||||||
<translation>Länge (Sekunden)</translation>
|
<translation>Länge (Sekunden)</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -12,4 +12,5 @@ message Event_ConnectionClosed {
|
||||||
}
|
}
|
||||||
optional CloseReason reason = 1;
|
optional CloseReason reason = 1;
|
||||||
optional string reason_str = 2;
|
optional string reason_str = 2;
|
||||||
|
optional uint32 end_time = 3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,4 +9,5 @@ message Response_Login {
|
||||||
repeated ServerInfo_User buddy_list = 2;
|
repeated ServerInfo_User buddy_list = 2;
|
||||||
repeated ServerInfo_User ignore_list = 3;
|
repeated ServerInfo_User ignore_list = 3;
|
||||||
optional string denied_reason_str = 4;
|
optional string denied_reason_str = 4;
|
||||||
|
optional uint64 denied_end_time = 5;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,14 +66,14 @@ void Server::prepareDestroy()
|
||||||
roomsLock.unlock();
|
roomsLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString &name, const QString &password, QString &reasonStr)
|
AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString &name, const QString &password, QString &reasonStr, int &secondsLeft)
|
||||||
{
|
{
|
||||||
if (name.size() > 35)
|
if (name.size() > 35)
|
||||||
name = name.left(35);
|
name = name.left(35);
|
||||||
|
|
||||||
QWriteLocker locker(&clientsLock);
|
QWriteLocker locker(&clientsLock);
|
||||||
|
|
||||||
AuthenticationResult authState = checkUserPassword(session, name, password, reasonStr);
|
AuthenticationResult authState = checkUserPassword(session, name, password, reasonStr, secondsLeft);
|
||||||
if ((authState == NotLoggedIn) || (authState == UserIsBanned))
|
if ((authState == NotLoggedIn) || (authState == UserIsBanned))
|
||||||
return authState;
|
return authState;
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
mutable QReadWriteLock clientsLock, roomsLock; // locking order: roomsLock before clientsLock
|
mutable QReadWriteLock clientsLock, roomsLock; // locking order: roomsLock before clientsLock
|
||||||
Server(QObject *parent = 0);
|
Server(QObject *parent = 0);
|
||||||
~Server();
|
~Server();
|
||||||
AuthenticationResult loginUser(Server_ProtocolHandler *session, QString &name, const QString &password, QString &reason);
|
AuthenticationResult loginUser(Server_ProtocolHandler *session, QString &name, const QString &password, QString &reason, int &secondsLeft);
|
||||||
const QMap<int, Server_Room *> &getRooms() { return rooms; }
|
const QMap<int, Server_Room *> &getRooms() { return rooms; }
|
||||||
virtual int getNextGameId() { return nextGameId++; }
|
virtual int getNextGameId() { return nextGameId++; }
|
||||||
virtual int getNextReplayId() { return nextReplayId++; }
|
virtual int getNextReplayId() { return nextReplayId++; }
|
||||||
|
@ -111,7 +111,7 @@ protected:
|
||||||
virtual qint64 startSession(const QString &userName, const QString &address) { return 0; }
|
virtual qint64 startSession(const QString &userName, const QString &address) { return 0; }
|
||||||
virtual void endSession(qint64 sessionId) { }
|
virtual void endSession(qint64 sessionId) { }
|
||||||
virtual bool userExists(const QString &user) { return false; }
|
virtual bool userExists(const QString &user) { return false; }
|
||||||
virtual AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reason) { return UnknownUser; }
|
virtual AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reason, int &secondsLeft) { return UnknownUser; }
|
||||||
virtual ServerInfo_User getUserData(const QString &name, bool withId = false) = 0;
|
virtual ServerInfo_User getUserData(const QString &name, bool withId = false) = 0;
|
||||||
int getUsersCount() const;
|
int getUsersCount() const;
|
||||||
int getGamesCount() const;
|
int getGamesCount() const;
|
||||||
|
|
|
@ -337,11 +337,14 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
||||||
if (userName.isEmpty() || (userInfo != 0))
|
if (userName.isEmpty() || (userInfo != 0))
|
||||||
return Response::RespContextError;
|
return Response::RespContextError;
|
||||||
QString reasonStr;
|
QString reasonStr;
|
||||||
AuthenticationResult res = server->loginUser(this, userName, QString::fromStdString(cmd.password()), reasonStr);
|
int banSecondsLeft = 0;
|
||||||
|
AuthenticationResult res = server->loginUser(this, userName, QString::fromStdString(cmd.password()), reasonStr, banSecondsLeft);
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case UserIsBanned: {
|
case UserIsBanned: {
|
||||||
Response_Login *re = new Response_Login;
|
Response_Login *re = new Response_Login;
|
||||||
re->set_denied_reason_str(reasonStr.toStdString());
|
re->set_denied_reason_str(reasonStr.toStdString());
|
||||||
|
if (banSecondsLeft != 0)
|
||||||
|
re->set_denied_end_time(QDateTime::currentDateTime().addSecs(banSecondsLeft).toTime_t());
|
||||||
rc.setResponseExtension(re);
|
rc.setResponseExtension(re);
|
||||||
return Response::RespUserIsBanned;
|
return Response::RespUserIsBanned;
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,7 +297,7 @@ QList<ServerProperties> Servatrice::getServerList() const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticationResult Servatrice::checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr)
|
AuthenticationResult Servatrice::checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr, int &banSecondsLeft)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&dbMutex);
|
QMutexLocker locker(&dbMutex);
|
||||||
const QString method = settings->value("authentication/method").toString();
|
const QString method = settings->value("authentication/method").toString();
|
||||||
|
@ -308,7 +308,7 @@ AuthenticationResult Servatrice::checkUserPassword(Server_ProtocolHandler *handl
|
||||||
return UnknownUser;
|
return UnknownUser;
|
||||||
|
|
||||||
QSqlQuery ipBanQuery;
|
QSqlQuery ipBanQuery;
|
||||||
ipBanQuery.prepare("select time_to_sec(timediff(now(), date_add(b.time_from, interval b.minutes minute))) < 0, b.minutes <=> 0, b.visible_reason from " + dbPrefix + "_bans b where b.time_from = (select max(c.time_from) from " + dbPrefix + "_bans c where c.ip_address = :address) and b.ip_address = :address2");
|
ipBanQuery.prepare("select time_to_sec(timediff(now(), date_add(b.time_from, interval b.minutes minute))), b.minutes <=> 0, b.visible_reason from " + dbPrefix + "_bans b where b.time_from = (select max(c.time_from) from " + dbPrefix + "_bans c where c.ip_address = :address) and b.ip_address = :address2");
|
||||||
ipBanQuery.bindValue(":address", static_cast<ServerSocketInterface *>(handler)->getPeerAddress().toString());
|
ipBanQuery.bindValue(":address", static_cast<ServerSocketInterface *>(handler)->getPeerAddress().toString());
|
||||||
ipBanQuery.bindValue(":address2", static_cast<ServerSocketInterface *>(handler)->getPeerAddress().toString());
|
ipBanQuery.bindValue(":address2", static_cast<ServerSocketInterface *>(handler)->getPeerAddress().toString());
|
||||||
if (!execSqlQuery(ipBanQuery)) {
|
if (!execSqlQuery(ipBanQuery)) {
|
||||||
|
@ -316,15 +316,19 @@ AuthenticationResult Servatrice::checkUserPassword(Server_ProtocolHandler *handl
|
||||||
return NotLoggedIn;
|
return NotLoggedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ipBanQuery.next())
|
if (ipBanQuery.next()) {
|
||||||
if (ipBanQuery.value(0).toInt() || ipBanQuery.value(1).toInt()) {
|
const int secondsLeft = -ipBanQuery.value(0).toInt();
|
||||||
|
const bool permanentBan = ipBanQuery.value(1).toInt();
|
||||||
|
if ((secondsLeft > 0) || permanentBan) {
|
||||||
reasonStr = ipBanQuery.value(2).toString();
|
reasonStr = ipBanQuery.value(2).toString();
|
||||||
|
banSecondsLeft = permanentBan ? 0 : secondsLeft;
|
||||||
qDebug("Login denied: banned by address");
|
qDebug("Login denied: banned by address");
|
||||||
return UserIsBanned;
|
return UserIsBanned;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QSqlQuery nameBanQuery;
|
QSqlQuery nameBanQuery;
|
||||||
nameBanQuery.prepare("select time_to_sec(timediff(now(), date_add(b.time_from, interval b.minutes minute))) < 0, b.minutes <=> 0, b.visible_reason from " + dbPrefix + "_bans b where b.time_from = (select max(c.time_from) from " + dbPrefix + "_bans c where c.user_name = :name2) and b.user_name = :name1");
|
nameBanQuery.prepare("select time_to_sec(timediff(now(), date_add(b.time_from, interval b.minutes minute))), b.minutes <=> 0, b.visible_reason from " + dbPrefix + "_bans b where b.time_from = (select max(c.time_from) from " + dbPrefix + "_bans c where c.user_name = :name2) and b.user_name = :name1");
|
||||||
nameBanQuery.bindValue(":name1", user);
|
nameBanQuery.bindValue(":name1", user);
|
||||||
nameBanQuery.bindValue(":name2", user);
|
nameBanQuery.bindValue(":name2", user);
|
||||||
if (!execSqlQuery(nameBanQuery)) {
|
if (!execSqlQuery(nameBanQuery)) {
|
||||||
|
@ -332,12 +336,16 @@ AuthenticationResult Servatrice::checkUserPassword(Server_ProtocolHandler *handl
|
||||||
return NotLoggedIn;
|
return NotLoggedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nameBanQuery.next())
|
if (nameBanQuery.next()) {
|
||||||
if (nameBanQuery.value(0).toInt() || nameBanQuery.value(1).toInt()) {
|
const int secondsLeft = -nameBanQuery.value(0).toInt();
|
||||||
|
const bool permanentBan = nameBanQuery.value(1).toInt();
|
||||||
|
if ((secondsLeft > 0) || permanentBan) {
|
||||||
reasonStr = nameBanQuery.value(2).toString();
|
reasonStr = nameBanQuery.value(2).toString();
|
||||||
|
banSecondsLeft = permanentBan ? 0 : secondsLeft;
|
||||||
qDebug("Login denied: banned by name");
|
qDebug("Login denied: banned by name");
|
||||||
return UserIsBanned;
|
return UserIsBanned;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QSqlQuery passwordQuery;
|
QSqlQuery passwordQuery;
|
||||||
passwordQuery.prepare("select password_sha512 from " + dbPrefix + "_users where name = :name and active = 1");
|
passwordQuery.prepare("select password_sha512 from " + dbPrefix + "_users where name = :name and active = 1");
|
||||||
|
|
|
@ -130,7 +130,7 @@ protected:
|
||||||
qint64 startSession(const QString &userName, const QString &address);
|
qint64 startSession(const QString &userName, const QString &address);
|
||||||
void endSession(qint64 sessionId);
|
void endSession(qint64 sessionId);
|
||||||
bool userExists(const QString &user);
|
bool userExists(const QString &user);
|
||||||
AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr);
|
AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr, int &secondsLeft);
|
||||||
|
|
||||||
void clearSessionTables();
|
void clearSessionTables();
|
||||||
void lockSessionTables();
|
void lockSessionTables();
|
||||||
|
|
|
@ -587,8 +587,8 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
|
||||||
query.bindValue(":ip_address", address);
|
query.bindValue(":ip_address", address);
|
||||||
query.bindValue(":id_admin", userInfo->id());
|
query.bindValue(":id_admin", userInfo->id());
|
||||||
query.bindValue(":minutes", minutes);
|
query.bindValue(":minutes", minutes);
|
||||||
query.bindValue(":reason", QString::fromStdString(cmd.reason()) + "\n");
|
query.bindValue(":reason", QString::fromStdString(cmd.reason()));
|
||||||
query.bindValue(":visible_reason", QString::fromStdString(cmd.visible_reason()) + "\n");
|
query.bindValue(":visible_reason", QString::fromStdString(cmd.visible_reason()));
|
||||||
servatrice->execSqlQuery(query);
|
servatrice->execSqlQuery(query);
|
||||||
servatrice->dbMutex.unlock();
|
servatrice->dbMutex.unlock();
|
||||||
|
|
||||||
|
@ -601,6 +601,8 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
|
||||||
event.set_reason(Event_ConnectionClosed::BANNED);
|
event.set_reason(Event_ConnectionClosed::BANNED);
|
||||||
if (cmd.has_visible_reason())
|
if (cmd.has_visible_reason())
|
||||||
event.set_reason_str(cmd.visible_reason());
|
event.set_reason_str(cmd.visible_reason());
|
||||||
|
if (minutes)
|
||||||
|
event.set_end_time(QDateTime::currentDateTime().addSecs(60 * minutes).toTime_t());
|
||||||
for (int i = 0; i < userList.size(); ++i) {
|
for (int i = 0; i < userList.size(); ++i) {
|
||||||
SessionEvent *se = userList[i]->prepareSessionEvent(event);
|
SessionEvent *se = userList[i]->prepareSessionEvent(event);
|
||||||
userList[i]->sendProtocolItem(*se);
|
userList[i]->sendProtocolItem(*se);
|
||||||
|
|
Loading…
Reference in a new issue