diff --git a/cockatrice/src/abstractclient.cpp b/cockatrice/src/abstractclient.cpp index 5fb9b433..7edb7a2e 100644 --- a/cockatrice/src/abstractclient.cpp +++ b/cockatrice/src/abstractclient.cpp @@ -32,15 +32,16 @@ void AbstractClient::processProtocolItem(ProtocolItem *item) GenericEvent *genericEvent = qobject_cast(item); if (genericEvent) { switch (genericEvent->getItemId()) { - case ItemId_Event_ConnectionClosed: emit connectionClosedEventReceived(qobject_cast(item)); break; - case ItemId_Event_AddToList: emit addToListEventReceived(qobject_cast(item)); break; - case ItemId_Event_RemoveFromList: emit removeFromListEventReceived(qobject_cast(item)); break; - case ItemId_Event_UserJoined: emit userJoinedEventReceived(qobject_cast(item)); break; - case ItemId_Event_UserLeft: emit userLeftEventReceived(qobject_cast(item)); break; - case ItemId_Event_ServerMessage: emit serverMessageEventReceived(qobject_cast(item)); break; - case ItemId_Event_ListRooms: emit listRoomsEventReceived(qobject_cast(item)); break; - case ItemId_Event_GameJoined: emit gameJoinedEventReceived(qobject_cast(item)); break; - case ItemId_Event_Message: emit messageEventReceived(qobject_cast(item)); break; + case ItemId_Event_ConnectionClosed: emit connectionClosedEventReceived(static_cast(item)); break; + case ItemId_Event_ServerShutdown: emit serverShutdownEventReceived(static_cast(item)); break; + case ItemId_Event_AddToList: emit addToListEventReceived(static_cast(item)); break; + case ItemId_Event_RemoveFromList: emit removeFromListEventReceived(static_cast(item)); break; + case ItemId_Event_UserJoined: emit userJoinedEventReceived(static_cast(item)); break; + case ItemId_Event_UserLeft: emit userLeftEventReceived(static_cast(item)); break; + case ItemId_Event_ServerMessage: emit serverMessageEventReceived(static_cast(item)); break; + case ItemId_Event_ListRooms: emit listRoomsEventReceived(static_cast(item)); break; + case ItemId_Event_GameJoined: emit gameJoinedEventReceived(static_cast(item)); break; + case ItemId_Event_Message: emit messageEventReceived(static_cast(item)); break; } if (genericEvent->getReceiverMayDelete()) delete genericEvent; diff --git a/cockatrice/src/abstractclient.h b/cockatrice/src/abstractclient.h index f43131b5..d896a89d 100644 --- a/cockatrice/src/abstractclient.h +++ b/cockatrice/src/abstractclient.h @@ -21,6 +21,7 @@ class Event_ListRooms; class Event_GameJoined; class Event_Message; class Event_ConnectionClosed; +class Event_ServerShutdown; enum ClientStatus { StatusDisconnected, @@ -43,6 +44,7 @@ signals: void gameEventContainerReceived(GameEventContainer *event); // Generic events void connectionClosedEventReceived(Event_ConnectionClosed *event); + void serverShutdownEventReceived(Event_ServerShutdown *event); void addToListEventReceived(Event_AddToList *event); void removeFromListEventReceived(Event_RemoveFromList *event); void userJoinedEventReceived(Event_UserJoined *event); diff --git a/cockatrice/src/localserverinterface.h b/cockatrice/src/localserverinterface.h index fc23b1b5..26194147 100644 --- a/cockatrice/src/localserverinterface.h +++ b/cockatrice/src/localserverinterface.h @@ -18,8 +18,9 @@ private: ResponseCode cmdDeckDel(Command_DeckDel * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; } ResponseCode cmdDeckUpload(Command_DeckUpload * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; } ResponseCode cmdDeckDownload(Command_DeckDownload * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; } - ResponseCode cmdUpdateServerMessage(Command_UpdateServerMessage * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; } ResponseCode cmdBanFromServer(Command_BanFromServer * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; } + ResponseCode cmdShutdownServer(Command_ShutdownServer * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; } + ResponseCode cmdUpdateServerMessage(Command_UpdateServerMessage * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; } public: LocalServerInterface(LocalServer *_server); ~LocalServerInterface(); diff --git a/cockatrice/src/tab_admin.cpp b/cockatrice/src/tab_admin.cpp index 4ea3a652..08232138 100644 --- a/cockatrice/src/tab_admin.cpp +++ b/cockatrice/src/tab_admin.cpp @@ -1,19 +1,72 @@ +#include #include +#include #include #include #include +#include +#include +#include #include "tab_admin.h" #include "abstractclient.h" #include "protocol_items.h" -TabAdmin::TabAdmin(TabSupervisor *_tabSupervisor, AbstractClient *_client, QWidget *parent) - : Tab(_tabSupervisor, parent), locked(true), client(_client) +ShutdownDialog::ShutdownDialog(QWidget *parent) + : QDialog(parent) +{ + QLabel *reasonLabel = new QLabel(tr("&Reason for shutdown:")); + reasonEdit = new QLineEdit; + reasonLabel->setBuddy(reasonEdit); + QLabel *minutesLabel = new QLabel(tr("&Time until shutdown (minutes):")); + minutesEdit = new QSpinBox; + minutesLabel->setBuddy(minutesEdit); + minutesEdit->setMinimum(0); + minutesEdit->setValue(5); + + QPushButton *okButton = new QPushButton(tr("&OK")); + okButton->setAutoDefault(true); + okButton->setDefault(true); + connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); + QPushButton *cancelButton = new QPushButton(tr("&Cancel")); + connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); + + QHBoxLayout *buttonLayout = new QHBoxLayout; + buttonLayout->addStretch(); + buttonLayout->addWidget(okButton); + buttonLayout->addWidget(cancelButton); + + QGridLayout *mainLayout = new QGridLayout; + mainLayout->addWidget(reasonLabel, 0, 0); + mainLayout->addWidget(reasonEdit, 0, 1); + mainLayout->addWidget(minutesLabel, 1, 0); + mainLayout->addWidget(minutesEdit, 1, 1); + mainLayout->addLayout(buttonLayout, 2, 0, 1, 2); + + setLayout(mainLayout); + setWindowTitle(tr("Shut down server")); +} + +QString ShutdownDialog::getReason() const +{ + return reasonEdit->text(); +} + +int ShutdownDialog::getMinutes() const +{ + return minutesEdit->value(); +} + +TabAdmin::TabAdmin(TabSupervisor *_tabSupervisor, AbstractClient *_client, bool _fullAdmin, QWidget *parent) + : Tab(_tabSupervisor, parent), locked(true), client(_client), fullAdmin(_fullAdmin) { updateServerMessageButton = new QPushButton; connect(updateServerMessageButton, SIGNAL(clicked()), this, SLOT(actUpdateServerMessage())); + shutdownServerButton = new QPushButton; + connect(shutdownServerButton, SIGNAL(clicked()), this, SLOT(actShutdownServer())); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(updateServerMessageButton); + vbox->addWidget(shutdownServerButton); vbox->addStretch(); adminGroupBox = new QGroupBox; @@ -38,6 +91,7 @@ TabAdmin::TabAdmin(TabSupervisor *_tabSupervisor, AbstractClient *_client, QWidg void TabAdmin::retranslateUi() { updateServerMessageButton->setText(tr("Update server &message")); + shutdownServerButton->setText(tr("&Shut down server")); adminGroupBox->setTitle(tr("Server administration functions")); unlockButton->setText(tr("&Unlock functions")); @@ -49,10 +103,18 @@ void TabAdmin::actUpdateServerMessage() client->sendCommand(new Command_UpdateServerMessage()); } +void TabAdmin::actShutdownServer() +{ + ShutdownDialog dlg; + if (dlg.exec()) + client->sendCommand(new Command_ShutdownServer(dlg.getReason(), dlg.getMinutes())); +} + void TabAdmin::actUnlock() { if (QMessageBox::question(this, tr("Unlock administration functions"), tr("Do you really want to unlock the administration functions?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - adminGroupBox->setEnabled(true); + if (fullAdmin) + adminGroupBox->setEnabled(true); lockButton->setEnabled(true); unlockButton->setEnabled(false); locked = false; @@ -61,7 +123,8 @@ void TabAdmin::actUnlock() void TabAdmin::actLock() { - adminGroupBox->setEnabled(false); + if (fullAdmin) + adminGroupBox->setEnabled(false); lockButton->setEnabled(false); unlockButton->setEnabled(true); locked = true; diff --git a/cockatrice/src/tab_admin.h b/cockatrice/src/tab_admin.h index 8450d473..a4982bba 100644 --- a/cockatrice/src/tab_admin.h +++ b/cockatrice/src/tab_admin.h @@ -2,27 +2,43 @@ #define TAB_ADMIN_H #include "tab.h" +#include class AbstractClient; class QGroupBox; class QPushButton; +class QSpinBox; +class QLineEdit; + +class ShutdownDialog : public QDialog { + Q_OBJECT +private: + QLineEdit *reasonEdit; + QSpinBox *minutesEdit; +public: + ShutdownDialog(QWidget *parent = 0); + QString getReason() const; + int getMinutes() const; +}; class TabAdmin : public Tab { Q_OBJECT private: bool locked; AbstractClient *client; - QPushButton *updateServerMessageButton; + bool fullAdmin; + QPushButton *updateServerMessageButton, *shutdownServerButton; QGroupBox *adminGroupBox; QPushButton *unlockButton, *lockButton; private slots: void actUpdateServerMessage(); + void actShutdownServer(); void actUnlock(); void actLock(); public: - TabAdmin(TabSupervisor *_tabSupervisor, AbstractClient *_client, QWidget *parent = 0); + TabAdmin(TabSupervisor *_tabSupervisor, AbstractClient *_client, bool _fullAdmin, QWidget *parent = 0); void retranslateUi(); QString getTabText() const { return tr("Administration"); } bool getLocked() const { return locked; } diff --git a/cockatrice/src/tab_supervisor.cpp b/cockatrice/src/tab_supervisor.cpp index be7751a0..1dfe7d44 100644 --- a/cockatrice/src/tab_supervisor.cpp +++ b/cockatrice/src/tab_supervisor.cpp @@ -135,8 +135,8 @@ void TabSupervisor::start(AbstractClient *_client, ServerInfo_User *userInfo) } else tabDeckStorage = 0; - if (userInfo->getUserLevel() & ServerInfo_User::IsAdmin) { - tabAdmin = new TabAdmin(this, client); + if (userInfo->getUserLevel() & ServerInfo_User::IsModerator) { + tabAdmin = new TabAdmin(this, client, (userInfo->getUserLevel() & ServerInfo_User::IsAdmin)); myAddTab(tabAdmin); } else tabAdmin = 0; diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index 595e8b8e..7acbe551 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -56,11 +56,18 @@ void MainWindow::processConnectionClosedEvent(Event_ConnectionClosed *event) reasonStr = tr("There are too many concurrent connections from your address."); else if (reason == "banned") reasonStr = tr("Banned by moderator."); + else if (reason == "server_shutdown") + reasonStr = tr("Scheduled server shutdown."); else reasonStr = tr("Unknown reason."); QMessageBox::critical(this, tr("Connection closed"), tr("The server has terminated your connection.\nReason: %1").arg(reasonStr)); } +void MainWindow::processServerShutdownEvent(Event_ServerShutdown *event) +{ + QMessageBox::information(this, tr("Scheduled server shutdown"), tr("The server is going to be restarted in %n minute(s).\nAll running games will be lost.\nReason for shutdown: %1", "", event->getMinutes()).arg(event->getReason())); +} + void MainWindow::statusChanged(ClientStatus _status) { setClientStatusTitle(); @@ -290,6 +297,7 @@ MainWindow::MainWindow(QWidget *parent) client = new RemoteClient(this); connect(client, SIGNAL(connectionClosedEventReceived(Event_ConnectionClosed *)), this, SLOT(processConnectionClosedEvent(Event_ConnectionClosed *))); + connect(client, SIGNAL(serverShutdownEventReceived(Event_ServerShutdown *)), this, SLOT(processServerShutdownEvent(Event_ServerShutdown *))); connect(client, SIGNAL(serverError(ResponseCode)), this, SLOT(serverError(ResponseCode))); connect(client, SIGNAL(socketError(const QString &)), this, SLOT(socketError(const QString &))); connect(client, SIGNAL(serverTimeout()), this, SLOT(serverTimeout())); diff --git a/cockatrice/src/window_main.h b/cockatrice/src/window_main.h index 9ca62ba8..4d8b45d6 100644 --- a/cockatrice/src/window_main.h +++ b/cockatrice/src/window_main.h @@ -36,6 +36,7 @@ private slots: void updateTabMenu(QMenu *menu); void statusChanged(ClientStatus _status); void processConnectionClosedEvent(Event_ConnectionClosed *event); + void processServerShutdownEvent(Event_ServerShutdown *event); void serverTimeout(); void serverError(ResponseCode r); void socketError(const QString &errorStr); diff --git a/cockatrice/translations/cockatrice_cs.ts b/cockatrice/translations/cockatrice_cs.ts index 1ce8de4b..bea2660e 100644 --- a/cockatrice/translations/cockatrice_cs.ts +++ b/cockatrice/translations/cockatrice_cs.ts @@ -1390,216 +1390,237 @@ + Scheduled server shutdown. + + + + Unknown reason. - + Connection closed - + The server has terminated your connection. Reason: %1 - + + Scheduled server shutdown + + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + + + + + + + Number of players - + Please enter the number of players. - - + + Player %1 - + About Cockatrice - + Version %1 - + Authors: - + Translators: - + Spanish: - + Portugese (Portugal): - + Portugese (Brazil): - + French: - + Japanese: - + Russian: - + Czech: - + Slovak: - - + - - + + + Error - + Server timeout - + Invalid login data. - + There is already an active session using this user name. Please close that session first and re-login. - + Socket error: %1 - + 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. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. - + Connecting to %1... - + Disconnected - + Logged in at %1 - + &Connect... - + &Disconnect - + Start &local game... - + &Deck editor - + &Full screen - + Ctrl+F - + &Settings... - + &Exit - + &Cockatrice - + &About Cockatrice - + &Help - + Are you sure? - + There are still open games. Are you sure you want to quit? @@ -2705,40 +2726,73 @@ Local version is %1, remote version is %2. + + ShutdownDialog + + + &Reason for shutdown: + + + + + &Time until shutdown (minutes): + + + + + &OK + + + + + &Cancel + + + + + Shut down server + + + TabAdmin - + Update server &message - + + &Shut down server + + + + Server administration functions - + &Unlock functions - + &Lock functions - + Unlock administration functions - + Do you really want to unlock the administration functions? - + Administration diff --git a/cockatrice/translations/cockatrice_de.ts b/cockatrice/translations/cockatrice_de.ts index 85e2d47b..33c22939 100644 --- a/cockatrice/translations/cockatrice_de.ts +++ b/cockatrice/translations/cockatrice_de.ts @@ -2140,138 +2140,162 @@ + Scheduled server shutdown. + Planmäßige Serverabschaltung. + + + Unknown reason. Unbekannter Grund. - + Connection closed Verbindung geschlossen - + The server has terminated your connection. Reason: %1 Der Server hat Ihre Verbindung beendet. Grund: %1 - + + Scheduled server shutdown + Planmäßige Serverabschaltung + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + Der Server wird in %n Minute neu gestartet. +Alle laufenden Spiele werden beendet. +Grund für die Abschaltung: %1 + Der Server wird in %n Minuten neu gestartet. +Alle laufenden Spiele werden beendet. +Grund für die Abschaltung: %1 + + + + Number of players Spieleranzahl - + Please enter the number of players. Bitte die Spieleranzahl eingeben: - - + + Player %1 Spieler %1 - + About Cockatrice Über Cockatrice - + Version %1 Version %1 - + Authors: Autoren: - + Translators: Übersetzer: - + Spanish: Spanisch: - + Portugese (Portugal): Portugiesisch (Portugal): - + Portugese (Brazil): Portugiesisch (Brasilien): - + French: Französisch: - + Japanese: Japanisch: - + Russian: Russisch: - + Czech: Tschechisch: - + Slovak: Slowakisch: - - + - - + + + Error Fehler - + Server timeout Server Zeitüberschreitung - + Invalid login data. Ungültige Anmeldedaten. - + There is already an active session using this user name. Please close that session first and re-login. Es gibt bereits eine aktive Verbindung mit diesem Benutzernamen. Bitte schließen Sie diese Verbindung zuerst und versuchen Sie es dann erneut. - + Socket error: %1 Netzwerkfehler: %1 - + 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. 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. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. Ihr Cockatrice-Client ist veraltet. Bitte laden Sie sich die neueste Version herunter. @@ -2282,52 +2306,52 @@ Lokale Version ist %1, Serverversion ist %2. Protokollversionen stimmen nicht überein. Lokale Version: %1, Serverversion: %2. - + Connecting to %1... Verbinde zu %1... - + Disconnected nicht verbunden - + Logged in at %1 Angemeldet bei %1 - + &Connect... &Verbinden... - + &Disconnect Verbindung &trennen - + Start &local game... &Lokales Spiel starten... - + &About Cockatrice &Über Cockatrice - + &Help &Hilfe - + Are you sure? Sind Sie sicher? - + There are still open games. Are you sure you want to quit? Es gibt noch offene Spiele. Wollen Sie das Programm wirklich beenden? @@ -2344,27 +2368,27 @@ Lokale Version ist %1, Serverversion ist %2. Spiel ver&lassen - + &Deck editor &Deck-Editor - + &Full screen &Vollbild - + Ctrl+F Ctrl+F - + &Settings... &Einstellungen... - + &Exit &Beenden @@ -2377,7 +2401,7 @@ Lokale Version ist %1, Serverversion ist %2. Esc - + &Cockatrice &Cockatrice @@ -4021,40 +4045,77 @@ Lokale Version ist %1, Serverversion ist %2. Langer Name + + ShutdownDialog + + + &Reason for shutdown: + G&rund für die Abschaltung: + + + + &Time until shutdown (minutes): + &Zeit bis zur Abschaltung (Minuten): + + + + &OK + &OK + + + + &Cancel + &Abbrechen + + + + Shut down server + Server abschalten + + TabAdmin - + Update server &message Server&nachricht aktualisieren - + Shut down server + Server abschalten + + + + &Shut down server + &Server abschalten + + + Server administration functions Funktionen zur Serverwartung - + &Unlock functions &Sperre aufheben - + &Lock functions Funktionen s&perren - + Unlock administration functions Wartungsfunktionen entsperren - + Do you really want to unlock the administration functions? Möchten Sie wirklich die Sperre der Wartungsfunktionen aufheben? - + Administration Wartung diff --git a/cockatrice/translations/cockatrice_en.ts b/cockatrice/translations/cockatrice_en.ts index 415aa3fd..a0cd85a4 100644 --- a/cockatrice/translations/cockatrice_en.ts +++ b/cockatrice/translations/cockatrice_en.ts @@ -1390,216 +1390,236 @@ + Scheduled server shutdown. + + + + Unknown reason. - + Connection closed - + The server has terminated your connection. Reason: %1 - + + Scheduled server shutdown + + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + + + + + + Number of players - + Please enter the number of players. - - + + Player %1 - + About Cockatrice - + Version %1 - + Authors: - + Translators: - + Spanish: - + Portugese (Portugal): - + Portugese (Brazil): - + French: - + Japanese: - + Russian: - + Czech: - + Slovak: - - + - - + + + Error - + Server timeout - + Invalid login data. - + There is already an active session using this user name. Please close that session first and re-login. - + Socket error: %1 - + 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. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. - + Connecting to %1... - + Disconnected - + Logged in at %1 - + &Connect... - + &Disconnect - + Start &local game... - + &Deck editor - + &Full screen - + Ctrl+F - + &Settings... - + &Exit - + &Cockatrice - + &About Cockatrice - + &Help - + Are you sure? - + There are still open games. Are you sure you want to quit? @@ -2712,40 +2732,73 @@ Local version is %1, remote version is %2. + + ShutdownDialog + + + &Reason for shutdown: + + + + + &Time until shutdown (minutes): + + + + + &OK + + + + + &Cancel + + + + + Shut down server + + + TabAdmin - + Update server &message - + + &Shut down server + + + + Server administration functions - + &Unlock functions - + &Lock functions - + Unlock administration functions - + Do you really want to unlock the administration functions? - + Administration diff --git a/cockatrice/translations/cockatrice_es.ts b/cockatrice/translations/cockatrice_es.ts index 116265d5..60757984 100644 --- a/cockatrice/translations/cockatrice_es.ts +++ b/cockatrice/translations/cockatrice_es.ts @@ -1755,138 +1755,158 @@ + Scheduled server shutdown. + + + + Unknown reason. Motivo desconocido. - + Connection closed Conexión cerrada - + The server has terminated your connection. Reason: %1 El servidor ha finalizado tu conexión. Motivo: %1 - + + Scheduled server shutdown + + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + + + + + + Number of players Número de jugadores - + Please enter the number of players. Por favor, introduzca el número de jugadores. - - + + Player %1 Jugador %1 - + About Cockatrice Acerca de Cockatrice - + Version %1 Versión %1 - + Authors: Autores: - + Translators: Traductores: - + Spanish: Español: - + Portugese (Portugal): Portugués (Portugal): - + Portugese (Brazil): Portugués (Brasil): - + French: Francés: - + Japanese: Japonés: - + Russian: Ruso: - + Czech: - + Slovak: - - + - - + + + Error Error - + Server timeout Tiempo de espera del servidor agotado - + Invalid login data. Datos de conexión invalidos. - + There is already an active session using this user name. Please close that session first and re-login. Ya existe una sesión activa usando ese nombre de usuario. Por favor, cierra esa sesión primero y reintentalo. - + Socket error: %1 Error del Socket: %1 - + 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. Estás intentando conectar a un servidor obsoleto. Por favor, usa una versión anterior de Cockatrice o conecta a un servidor apropiado. La versión local es %1, la versión remota es %2. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. Tu cliente de Cockatrice esta obsoleto. Por favor, actualiza tu versión de Cockatrice. @@ -1897,82 +1917,82 @@ La versión local es %1, la versión remota es %2. La versión del protocolo es diferente. Version local: %1, version remota: %2. - + Connecting to %1... Conectando a %1... - + Disconnected Desconectado - + Logged in at %1 Conectado en %1 - + &Connect... &Conectar... - + &Disconnect &Desconectar - + Start &local game... Empezar partida &local... - + &Deck editor Editor de &mazos - + &Full screen &Pantalla completa - + Ctrl+F CTRL+F - + &Settings... &Preferencias... - + &Exit &Salir - + &Cockatrice &Cockatrice - + &About Cockatrice &Acerca de Cockatrice - + &Help A&yuda - + Are you sure? ¿Estás seguro? - + There are still open games. Are you sure you want to quit? Todavía hay partidas abiertas. ¿Estás seguro que quieres salir? @@ -3140,40 +3160,73 @@ La versión local es %1, la versión remota es %2. Nombre largo + + ShutdownDialog + + + &Reason for shutdown: + + + + + &Time until shutdown (minutes): + + + + + &OK + &Aceptar + + + + &Cancel + &Cancelar + + + + Shut down server + + + TabAdmin - + Update server &message Actualizar &mensaje del servidor - + + &Shut down server + + + + Server administration functions Funciones de administración del servidor - + &Unlock functions &Desbloquear funciones - + &Lock functions &Bloquear funciones - + Unlock administration functions Desbloquear funciones de administración - + Do you really want to unlock the administration functions? ¿Realmente quieres desbloquear las funciones de administración? - + Administration Administración diff --git a/cockatrice/translations/cockatrice_fr.ts b/cockatrice/translations/cockatrice_fr.ts index de17833e..3573db24 100644 --- a/cockatrice/translations/cockatrice_fr.ts +++ b/cockatrice/translations/cockatrice_fr.ts @@ -1595,23 +1595,23 @@ MainWindow - + Number of players Nombre de joueurs - + Please enter the number of players. Entrez s'il vous plait le nombre de joueurs. - - + + Player %1 Joueur %1 - + About Cockatrice à propos de Cockatrice @@ -1620,67 +1620,67 @@ <font size="8"><b>Cockatrice</b></font><br>Version %1<br><br><br><b>Auteurs:</b><br>Max-Wilhelm Bruker<br>Marcus Schütz<br>Marius van Zundert<br><br><b>Tranducteurs:</b><br>Espagnol: Gocho<br>Portugais: Milton Gonçalves<br>Portugais: Milton Gonçalves<br>Français: Yannick HAMMER<br> - + Version %1 Version %1 - + Authors: Auteurs: - + Translators: Traducteurs: - + Spanish: Espagnol: - + Portugese (Portugal): Portugais (Portugal): - + Portugese (Brazil): Portugais (Brésil): - + French: Français: - + Japanese: Japonais: - - + - - + + + Error Erreur - + Server timeout Délai de la demande dépassé - + Invalid login data. Information de connexion érronée. - + Socket error: %1 Erreur de socket: %1 @@ -1700,136 +1700,156 @@ + Scheduled server shutdown. + + + + Unknown reason. Raison inconnue. - + Connection closed Connection fermée - + The server has terminated your connection. Reason: %1 Le serveur a coupé votre connexion. Raison: %1 - + + Scheduled server shutdown + + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + + + + + + Russian: putted "France" instead of "Russe" -> meant that I must put the translation laguage country, isn't it? France: - + Czech: - + Slovak: - + There is already an active session using this user name. Please close that session first and re-login. Il y a déjà une session ouvert avec le même pseudo. Fermez cette session puis re-connectez-vous. - + 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. Vous tentez de vous connecter à un serveur obsolète. Chargez la nouvelle version de Cockatrice ou connectez-vous à un serveur approprié. La version la plus récente est %1, l'ancienne version est %2. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. Votre client Cockatrice est obsolète. Veuillez charger la nouvelle version. La version la plus récente est %1, l'ancienne version est %2. - + Connecting to %1... Connexion à %1... - + Disconnected Déconnecté - + Logged in at %1 Connecté à %1 - + &Connect... à verifier &Connecter... - + &Disconnect &Déconnecter - + Start &local game... Démarrer une partie &locale... - + &Deck editor Éditeur de &deck - + &Full screen &Plein écran - + Ctrl+F Ctrl+F - + &Settings... &Paramètres... - + &Exit &Quitter - + &Cockatrice &Cockatrice - + &About Cockatrice À propos de Cock&atrice - + &Help A&ide - + Are you sure? Êtes-vous sûr? - + There are still open games. Are you sure you want to quit? Il y a encore des parties en cours. Êtes-vous sûr de vouloir quitter? @@ -2999,40 +3019,73 @@ La version la plus récente est %1, l'ancienne version est %2.Nom complet + + ShutdownDialog + + + &Reason for shutdown: + + + + + &Time until shutdown (minutes): + + + + + &OK + &OK + + + + &Cancel + &Annuler + + + + Shut down server + + + TabAdmin - + Update server &message Mettre à jour le &message du serveur - + + &Shut down server + + + + Server administration functions Fonctions d'administration du serveur - + &Unlock functions &Débloquer fonctions - + &Lock functions &Bloquer fonctions - + Unlock administration functions Débloquer fonctions d'administration - + Do you really want to unlock the administration functions? Êtes-vous sûr de vouloir débloquer les fonctions d'administration? - + Administration Administration diff --git a/cockatrice/translations/cockatrice_ja.ts b/cockatrice/translations/cockatrice_ja.ts index 4ae3575c..73682c83 100644 --- a/cockatrice/translations/cockatrice_ja.ts +++ b/cockatrice/translations/cockatrice_ja.ts @@ -1443,220 +1443,239 @@ + Scheduled server shutdown. + + + + Unknown reason. 不明な理由. - + Connection closed 通信切断 - + The server has terminated your connection. Reason: %1 サーバーはあなたの接続を切断しました. 理由: %1 - + + Scheduled server shutdown + + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + + + + + Number of players プレイヤー人数 - + Please enter the number of players. プレイヤーの人数を入れてください. - - + + Player %1 プレイヤー %1 - + About Cockatrice Cockatriceについて - + Version %1 - + Authors: 著者: - + Translators: 翻訳者: - + Spanish: スペイン語: - + Portugese (Portugal): ポルトガル語(ポルトガル): - + Portugese (Brazil): ポルトガル語(ブラジル): - + French: フランス語: - + Japanese: 日本語: - + Russian: ロシア語: - + Czech: - + Slovak: - - + - - + + + Error エラー - + Server timeout サーバータイムアウト - + Invalid login data. 無効なログインデータです. - + There is already an active session using this user name. Please close that session first and re-login. これはすでにこのユーザー名で使われているアクティブなセッションです. まずこのセッションを閉じてログインしなおしてください. - + Socket error: %1 ソケットエラー: %1 - + 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. あなたは古いVerのサーバーに接続しようとしています.CockatriceのVerをダウングレードするか適正なサーバーに接続してください. ローカルVer %1,リモートVer %2. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. あなたのCockatriceのVerが古いです.Cockatriceをアップデートしてください. ローカルVer %1,リモートVer %2. - + Connecting to %1... %1へ接続しています... - + Disconnected 切断されました - + Logged in at %1 %1にログイン中 - + &Connect... 接続... - + &Disconnect 切断 - + Start &local game... ローカルゲームを開始... - + &Deck editor デッキエディター - + &Full screen フルスクリーン - + Ctrl+F - + &Settings... 設定... - + &Exit 終了 - + &Cockatrice - + &About Cockatrice - + &Help ヘルプ - + Are you sure? よろしいですか? - + There are still open games. Are you sure you want to quit? ゲームがまだ開いています.本当に退出しますか? @@ -2779,40 +2798,73 @@ Local version is %1, remote version is %2. 正式名称 + + ShutdownDialog + + + &Reason for shutdown: + + + + + &Time until shutdown (minutes): + + + + + &OK + + + + + &Cancel + + + + + Shut down server + + + TabAdmin - + Update server &message サーバー更新&メッセージ - + + &Shut down server + + + + Server administration functions サーバー管理機能 - + &Unlock functions 機能をアンロックする - + &Lock functions 機能をロックする - + Unlock administration functions 管理機能をアンロックする - + Do you really want to unlock the administration functions? 本当に管理機能をアンロックしますか? - + Administration 管理者 diff --git a/cockatrice/translations/cockatrice_pl.ts b/cockatrice/translations/cockatrice_pl.ts index bdaa8263..093c6668 100644 --- a/cockatrice/translations/cockatrice_pl.ts +++ b/cockatrice/translations/cockatrice_pl.ts @@ -1390,216 +1390,237 @@ + Scheduled server shutdown. + + + + Unknown reason. - + Connection closed - + The server has terminated your connection. Reason: %1 - + + Scheduled server shutdown + + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + + + + + + + Number of players - + Please enter the number of players. - - + + Player %1 - + About Cockatrice - + Version %1 - + Authors: - + Translators: - + Spanish: - + Portugese (Portugal): - + Portugese (Brazil): - + French: - + Japanese: - + Russian: - + Czech: - + Slovak: - - + - - + + + Error - + Server timeout - + Invalid login data. - + There is already an active session using this user name. Please close that session first and re-login. - + Socket error: %1 - + 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. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. - + Connecting to %1... - + Disconnected - + Logged in at %1 - + &Connect... - + &Disconnect - + Start &local game... - + &Deck editor - + &Full screen - + Ctrl+F - + &Settings... - + &Exit - + &Cockatrice - + &About Cockatrice - + &Help - + Are you sure? - + There are still open games. Are you sure you want to quit? @@ -2705,40 +2726,73 @@ Local version is %1, remote version is %2. + + ShutdownDialog + + + &Reason for shutdown: + + + + + &Time until shutdown (minutes): + + + + + &OK + + + + + &Cancel + + + + + Shut down server + + + TabAdmin - + Update server &message - + + &Shut down server + + + + Server administration functions - + &Unlock functions - + &Lock functions - + Unlock administration functions - + Do you really want to unlock the administration functions? - + Administration diff --git a/cockatrice/translations/cockatrice_pt-br.ts b/cockatrice/translations/cockatrice_pt-br.ts index c0549f8d..8dd17c58 100644 --- a/cockatrice/translations/cockatrice_pt-br.ts +++ b/cockatrice/translations/cockatrice_pt-br.ts @@ -1598,23 +1598,23 @@ MainWindow - + Number of players Número de jogadores - + Please enter the number of players. Por favor, entre o número de jogadores. - - + + Player %1 Jogador %1 - + About Cockatrice Sobre o Cockatrice @@ -1623,72 +1623,72 @@ <font size="8"><b>Cockatrice</b></font><br>Version %1<br><br><br><b>Authors:</b><br>Max-Wilhelm Bruker<br>Marcus Schütz<br>Marius van Zundert<br><br><b>Translators:</b><br>Spanish: Gocho<br>Portugese: Milton Gonçalves<br>Brazilian Portuguese: Thiago Queiroz<br> - + Version %1 Versão %1 - + Authors: Autores: - + Translators: Tradutores: - + Spanish: Espanhol: - + Portugese (Portugal): Português (Portugal): - + Portugese (Brazil): Português (Brasil): - + French: Francês: - + Japanese: Japonês: - + Russian: Russo: - - + - - + + + Error Erro - + Server timeout Tempo esgotado do servidor - + Invalid login data. Informações de login inválidas. - + Socket error: %1 Erro de ligação:%1 @@ -1708,129 +1708,149 @@ + Scheduled server shutdown. + + + + Unknown reason. Razão desconhecida. - + Connection closed Conexão fechada - + The server has terminated your connection. Reason: %1 O servidor terminou sua conexão. Razão: %1 - + + Scheduled server shutdown + + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + + + + + + Czech: - + Slovak: - + There is already an active session using this user name. Please close that session first and re-login. Já existe uma sessão ativa usando este nome de usuário. Por favor, feche a sessão primeiro e logue novamente. - + 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. Você está tentando conectar a um servidor obsoleto. Por favor, faça um downgrade na versão do seu Cockatrice ou conecte-se ao servidor correto. A versão local é %1 e a versão remota é %2. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. A versão do seu Cockatrice é obsoleta. Por favor, atualize a sua versão. A versão local é %1 e a versão remota é %2. - + Connecting to %1... Conectando a %1... - + Disconnected Desconectado - + Logged in at %1 Logado em %1 - + &Connect... &Conectar... - + &Disconnect &Desconectar - + Start &local game... Iniciar jogo &local... - + &Deck editor Editor de &decks - + &Full screen Tela &cheia - + Ctrl+F Ctrl+F - + &Settings... &Configurações... - + &Exit &Sair - + &Cockatrice &Cockatrice - + &About Cockatrice So&bre o Cockatrice - + &Help &Ajuda - + Are you sure? Você tem certeza? - + There are still open games. Are you sure you want to quit? Ainda existem jogos abertos. Você tem certeza que deseja sair? @@ -2982,40 +3002,73 @@ A versão local é %1 e a versão remota é %2. Nome longo + + ShutdownDialog + + + &Reason for shutdown: + + + + + &Time until shutdown (minutes): + + + + + &OK + &OK + + + + &Cancel + &Cancelar + + + + Shut down server + + + TabAdmin - + Update server &message &Atualizar mensagem do servidor - + + &Shut down server + + + + Server administration functions Funções do administrador do servidor - + &Unlock functions &Desbloquear funções - + &Lock functions &Bloquear funções - + Unlock administration functions Desbloquear funções do administrador - + Do you really want to unlock the administration functions? Você quer mesmo desbloquear as funções do administrador? - + Administration Administração diff --git a/cockatrice/translations/cockatrice_pt.ts b/cockatrice/translations/cockatrice_pt.ts index 9b7dac82..7ed23d1b 100644 --- a/cockatrice/translations/cockatrice_pt.ts +++ b/cockatrice/translations/cockatrice_pt.ts @@ -1598,23 +1598,23 @@ MainWindow - + Number of players Número de jogadores - + Please enter the number of players. Por favor introduza o número de jogadores. - - + + Player %1 Jogador %1 - + About Cockatrice Sobre o Cockatrice @@ -1623,22 +1623,22 @@ <font size="8"><b>Cockatrice</b></font><br>Versão %1<br><br><br><b>Autores:</b><br>Max-Wilhelm Bruker<br>Marcus Schütz<br>Marius van Zundert<br><br><b>Tradutores:</b><br>Espanhol: Gocho<br>Português: Milton Gonçalves<br> - + Version %1 Versão %1 - + Authors: Autores: - + Translators: Tradutores: - + Spanish: Espanhol: @@ -1647,52 +1647,52 @@ Português: - + Portugese (Portugal): Português (Portugal): - + Portugese (Brazil): Português (Brasil): - + French: Francês: - + Japanese: Japonês: - + Russian: Russo: - - + - - + + + Error Erro - + Server timeout Tempo do servidor esgotado - + Invalid login data. Informação de login incorrecta. - + Socket error: %1 Erro de ligação:%1 @@ -1712,129 +1712,149 @@ + Scheduled server shutdown. + + + + Unknown reason. Razão desconhecida. - + Connection closed Ligação terminada - + The server has terminated your connection. Reason: %1 O servidor terminou a sua ligação. Motivo: %1 - + + Scheduled server shutdown + + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + + + + + + Czech: - + Slovak: - + There is already an active session using this user name. Please close that session first and re-login. Já existe uma sessão activa com este nome de utilizador. Por favor termine essa sessão e volte a ligar-se. - + 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. Está a tentar ligar-se a um servidor obsoleto. Por favor faça downgrade à sua versão do Cockatrice ou ligue-se a servidor adequado. Versão local é %1, versão remota é %2. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. A sua versão do Cockatrice é obsoleta. Por favor actualize-a. Versão local é %1, versão remota é %2. - + Connecting to %1... Ligando a %1... - + Disconnected Desligado - + Logged in at %1 Logado em %1 - + &Connect... &Ligar... - + &Disconnect &Desligar - + Start &local game... Começar &jogo local... - + &Deck editor &Editor de decks - + &Full screen Ecrã &inteiro - + Ctrl+F Ctrl+F - + &Settings... &Configurações... - + &Exit &Sair - + &Cockatrice &Cockatrice - + &About Cockatrice S&obre o Cockatrice - + &Help &Ajuda - + Are you sure? Tens a certeza? - + There are still open games. Are you sure you want to quit? Ainda há jogos abertos. Tem a certeza que deseja sair? @@ -2986,40 +3006,73 @@ Versão local é %1, versão remota é %2. Nome longo + + ShutdownDialog + + + &Reason for shutdown: + + + + + &Time until shutdown (minutes): + + + + + &OK + + + + + &Cancel + &Cancelar + + + + Shut down server + + + TabAdmin - + Update server &message &Actualizar mensagem do servidor - + + &Shut down server + + + + Server administration functions Funções do administrador do servidor - + &Unlock functions &Desbloquear funções - + &Lock functions &Bloquear funções - + Unlock administration functions Desbloquear funções de administração - + Do you really want to unlock the administration functions? Quer mesmo desbloquear as funçõesde administração? - + Administration Administração diff --git a/cockatrice/translations/cockatrice_ru.ts b/cockatrice/translations/cockatrice_ru.ts index 1f5e95e5..9d7920e1 100644 --- a/cockatrice/translations/cockatrice_ru.ts +++ b/cockatrice/translations/cockatrice_ru.ts @@ -1544,220 +1544,241 @@ + Scheduled server shutdown. + + + + Unknown reason. Неизвестная причина. - + Connection closed Соединение прервано - + The server has terminated your connection. Reason: %1 Ваше подключение было прервано сервером. Причина: %1 - + + Scheduled server shutdown + + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + + + + + + + Number of players Количество игроков - + Please enter the number of players. Введите количество игроков. - - + + Player %1 Игрок %1 - + About Cockatrice О программе - + Version %1 Версия %1 - + Authors: Разработчики: - + Translators: Переводчики: - + Spanish: Испанский: - + Portugese (Portugal): Португальский: - + Portugese (Brazil): Португальский (Brazil): - + French: Французский: - + Japanese: Японский: - + Russian: Русский: - + Czech: - + Slovak: - - + - - + + + Error Ошибка - + Server timeout Временная ошибка - + Invalid login data. Неверный логин/пароль. - + There is already an active session using this user name. Please close that session first and re-login. Пользователь с таким именем уже подключен. Пожалуйста, закройте это подключение и войдите заново. - + Socket error: %1 Ошибка сокета: %1 - + 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. Вы пытаетесь подключиться к несуществующему серверу. Пожалуйста, обновите Cockatrice или выберите другой сервер. Локальная версия %1, удаленная версия %2. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. Ваш клиент Cockatrice устарел. Пожалуйста, обновите Cockatrice. Локальная версия %1, удаленная версия %2. - + Connecting to %1... Подключение к %1... - + Disconnected Подключение прервано - + Logged in at %1 Подключено к %1 - + &Connect... &Подключение... - + &Disconnect П&рервать подключение - + Start &local game... &Начать локальную игру... - + &Deck editor Редактор &колод - + &Full screen П&олный экран - + Ctrl+F - + &Settings... Н&астройки - + &Exit &Выход - + &Cockatrice - + &About Cockatrice О про&грамме - + &Help &Справка - + Are you sure? Вы уверены? - + There are still open games. Are you sure you want to quit? Вы подключены к игре. Выйти? @@ -2903,40 +2924,73 @@ Local version is %1, remote version is %2. Полное название + + ShutdownDialog + + + &Reason for shutdown: + + + + + &Time until shutdown (minutes): + + + + + &OK + &Ок + + + + &Cancel + &Отмена + + + + Shut down server + + + TabAdmin - + Update server &message Обновить сооб&щения сервера - + + &Shut down server + + + + Server administration functions Функции администрирования сервера - + &Unlock functions &Разблокировать функции - + &Lock functions &Заблокировать функции - + Unlock administration functions Разблокировать административные права - + Do you really want to unlock the administration functions? Вы действительно хотите разблокировать административные права? - + Administration Администрирование diff --git a/cockatrice/translations/cockatrice_sk.ts b/cockatrice/translations/cockatrice_sk.ts index 30324e93..835301f8 100644 --- a/cockatrice/translations/cockatrice_sk.ts +++ b/cockatrice/translations/cockatrice_sk.ts @@ -1390,216 +1390,237 @@ + Scheduled server shutdown. + + + + Unknown reason. - + Connection closed - + The server has terminated your connection. Reason: %1 - + + Scheduled server shutdown + + + + + The server is going to be restarted in %n minute(s). +All running games will be lost. +Reason for shutdown: %1 + + + + + + + + Number of players - + Please enter the number of players. - - + + Player %1 - + About Cockatrice - + Version %1 - + Authors: - + Translators: - + Spanish: - + Portugese (Portugal): - + Portugese (Brazil): - + French: - + Japanese: - + Russian: - + Czech: - + Slovak: - - + - - + + + Error - + Server timeout - + Invalid login data. - + There is already an active session using this user name. Please close that session first and re-login. - + Socket error: %1 - + 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. - + Your Cockatrice client is obsolete. Please update your Cockatrice version. Local version is %1, remote version is %2. - + Connecting to %1... - + Disconnected - + Logged in at %1 - + &Connect... - + &Disconnect - + Start &local game... - + &Deck editor - + &Full screen - + Ctrl+F - + &Settings... - + &Exit - + &Cockatrice - + &About Cockatrice - + &Help - + Are you sure? - + There are still open games. Are you sure you want to quit? @@ -2705,40 +2726,73 @@ Local version is %1, remote version is %2. + + ShutdownDialog + + + &Reason for shutdown: + + + + + &Time until shutdown (minutes): + + + + + &OK + + + + + &Cancel + + + + + Shut down server + + + TabAdmin - + Update server &message - + + &Shut down server + + + + Server administration functions - + &Unlock functions - + &Lock functions - + Unlock administration functions - + Do you really want to unlock the administration functions? - + Administration diff --git a/common/protocol.h b/common/protocol.h index b72deb10..0cb067ee 100644 --- a/common/protocol.h +++ b/common/protocol.h @@ -167,6 +167,15 @@ public: void setGameId(int _gameId) { static_cast(itemMap.value("game_id"))->setData(_gameId); } }; +class ModeratorCommand : public Command { + Q_OBJECT +public: + ModeratorCommand(const QString &_cmdName) + : Command(_cmdName) + { + } +}; + class AdminCommand : public Command { Q_OBJECT public: diff --git a/common/protocol_item_ids.h b/common/protocol_item_ids.h index 2d89e883..b00687cf 100644 --- a/common/protocol_item_ids.h +++ b/common/protocol_item_ids.h @@ -65,19 +65,21 @@ ItemId_Event_DumpZone = 1063, ItemId_Event_StopDumpZone = 1064, ItemId_Event_RemoveFromList = 1065, ItemId_Event_ServerMessage = 1066, -ItemId_Event_ConnectionClosed = 1067, -ItemId_Event_Message = 1068, -ItemId_Event_GameJoined = 1069, -ItemId_Event_UserLeft = 1070, -ItemId_Event_LeaveRoom = 1071, -ItemId_Event_RoomSay = 1072, -ItemId_Context_ReadyStart = 1073, -ItemId_Context_Concede = 1074, -ItemId_Context_DeckSelect = 1075, -ItemId_Context_UndoDraw = 1076, -ItemId_Context_MoveCard = 1077, -ItemId_Context_Mulligan = 1078, -ItemId_Command_UpdateServerMessage = 1079, -ItemId_Command_BanFromServer = 1080, -ItemId_Other = 1081 +ItemId_Event_ServerShutdown = 1067, +ItemId_Event_ConnectionClosed = 1068, +ItemId_Event_Message = 1069, +ItemId_Event_GameJoined = 1070, +ItemId_Event_UserLeft = 1071, +ItemId_Event_LeaveRoom = 1072, +ItemId_Event_RoomSay = 1073, +ItemId_Context_ReadyStart = 1074, +ItemId_Context_Concede = 1075, +ItemId_Context_DeckSelect = 1076, +ItemId_Context_UndoDraw = 1077, +ItemId_Context_MoveCard = 1078, +ItemId_Context_Mulligan = 1079, +ItemId_Command_UpdateServerMessage = 1080, +ItemId_Command_ShutdownServer = 1081, +ItemId_Command_BanFromServer = 1082, +ItemId_Other = 1083 }; diff --git a/common/protocol_items.cpp b/common/protocol_items.cpp index 17aea383..69de7319 100644 --- a/common/protocol_items.cpp +++ b/common/protocol_items.cpp @@ -398,6 +398,12 @@ Event_ServerMessage::Event_ServerMessage(const QString &_message) { insertItem(new SerializableItem_String("message", _message)); } +Event_ServerShutdown::Event_ServerShutdown(const QString &_reason, int _minutes) + : GenericEvent("server_shutdown") +{ + insertItem(new SerializableItem_String("reason", _reason)); + insertItem(new SerializableItem_Int("minutes", _minutes)); +} Event_ConnectionClosed::Event_ConnectionClosed(const QString &_reason) : GenericEvent("connection_closed") { @@ -467,8 +473,14 @@ Command_UpdateServerMessage::Command_UpdateServerMessage() : AdminCommand("update_server_message") { } +Command_ShutdownServer::Command_ShutdownServer(const QString &_reason, int _minutes) + : AdminCommand("shutdown_server") +{ + insertItem(new SerializableItem_String("reason", _reason)); + insertItem(new SerializableItem_Int("minutes", _minutes)); +} Command_BanFromServer::Command_BanFromServer(const QString &_userName, int _minutes) - : AdminCommand("ban_from_server") + : ModeratorCommand("ban_from_server") { insertItem(new SerializableItem_String("user_name", _userName)); insertItem(new SerializableItem_Int("minutes", _minutes)); @@ -541,6 +553,7 @@ void ProtocolItem::initializeHashAuto() itemNameHash.insert("game_eventstop_dump_zone", Event_StopDumpZone::newItem); itemNameHash.insert("generic_eventremove_from_list", Event_RemoveFromList::newItem); itemNameHash.insert("generic_eventserver_message", Event_ServerMessage::newItem); + itemNameHash.insert("generic_eventserver_shutdown", Event_ServerShutdown::newItem); itemNameHash.insert("generic_eventconnection_closed", Event_ConnectionClosed::newItem); itemNameHash.insert("generic_eventmessage", Event_Message::newItem); itemNameHash.insert("generic_eventgame_joined", Event_GameJoined::newItem); @@ -554,5 +567,6 @@ void ProtocolItem::initializeHashAuto() itemNameHash.insert("game_event_contextmove_card", Context_MoveCard::newItem); itemNameHash.insert("game_event_contextmulligan", Context_Mulligan::newItem); itemNameHash.insert("cmdupdate_server_message", Command_UpdateServerMessage::newItem); + itemNameHash.insert("cmdshutdown_server", Command_ShutdownServer::newItem); itemNameHash.insert("cmdban_from_server", Command_BanFromServer::newItem); } diff --git a/common/protocol_items.dat b/common/protocol_items.dat index 73369c6b..14e486c9 100644 --- a/common/protocol_items.dat +++ b/common/protocol_items.dat @@ -64,6 +64,7 @@ 3:stop_dump_zone:i,zone_owner_id:s,zone 4:remove_from_list:s,list:s,user_name 4:server_message:s,message +4:server_shutdown:s,reason:i,minutes 4:connection_closed:s,reason 4:message:s,sender_name:s,receiver_name:s,text 4:game_joined:i,game_id:s,game_description:i,player_id:b,spectator:b,spectators_can_talk:b,spectators_see_everything:b,resuming @@ -77,4 +78,5 @@ 6:move_card 6:mulligan:i,number 7:update_server_message -7:ban_from_server:s,user_name:i,minutes \ No newline at end of file +7:shutdown_server:s,reason:i,minutes +8:ban_from_server:s,user_name:i,minutes \ No newline at end of file diff --git a/common/protocol_items.h b/common/protocol_items.h index d58d3dec..d03a7825 100644 --- a/common/protocol_items.h +++ b/common/protocol_items.h @@ -598,6 +598,15 @@ public: static SerializableItem *newItem() { return new Event_ServerMessage; } int getItemId() const { return ItemId_Event_ServerMessage; } }; +class Event_ServerShutdown : public GenericEvent { + Q_OBJECT +public: + Event_ServerShutdown(const QString &_reason = QString(), int _minutes = -1); + QString getReason() const { return static_cast(itemMap.value("reason"))->getData(); }; + int getMinutes() const { return static_cast(itemMap.value("minutes"))->getData(); }; + static SerializableItem *newItem() { return new Event_ServerShutdown; } + int getItemId() const { return ItemId_Event_ServerShutdown; } +}; class Event_ConnectionClosed : public GenericEvent { Q_OBJECT public: @@ -706,7 +715,16 @@ public: static SerializableItem *newItem() { return new Command_UpdateServerMessage; } int getItemId() const { return ItemId_Command_UpdateServerMessage; } }; -class Command_BanFromServer : public AdminCommand { +class Command_ShutdownServer : public AdminCommand { + Q_OBJECT +public: + Command_ShutdownServer(const QString &_reason = QString(), int _minutes = -1); + QString getReason() const { return static_cast(itemMap.value("reason"))->getData(); }; + int getMinutes() const { return static_cast(itemMap.value("minutes"))->getData(); }; + static SerializableItem *newItem() { return new Command_ShutdownServer; } + int getItemId() const { return ItemId_Command_ShutdownServer; } +}; +class Command_BanFromServer : public ModeratorCommand { Q_OBJECT public: Command_BanFromServer(const QString &_userName = QString(), int _minutes = -1); diff --git a/common/protocol_mc.pl b/common/protocol_mc.pl index 31e85b1f..2b1c96b7 100755 --- a/common/protocol_mc.pl +++ b/common/protocol_mc.pl @@ -80,6 +80,13 @@ while () { $parentConstructorCall = "$baseClass(\"$name1\")"; $constructorParamsH = ""; $constructorParamsCpp = ""; + } elsif ($type == 8) { + $type = 'cmd'; + $namePrefix = 'Command'; + $baseClass = 'ModeratorCommand'; + $parentConstructorCall = "$baseClass(\"$name1\")"; + $constructorParamsH = ""; + $constructorParamsCpp = ""; } $className = $namePrefix . '_' . $name2; $itemEnum .= "ItemId_$className = " . ++$itemId . ",\n"; diff --git a/common/server.cpp b/common/server.cpp index a7e4c683..e4c68ff9 100644 --- a/common/server.cpp +++ b/common/server.cpp @@ -23,6 +23,7 @@ #include "server_room.h" #include "server_protocolhandler.h" #include "protocol_datastructures.h" +#include #include Server::Server(QObject *parent) diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index a3ced63a..10729b8b 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -142,6 +142,17 @@ ResponseCode Server_ProtocolHandler::processCommandHelper(Command *command, Comm default: return RespInvalidCommand; } } + ModeratorCommand *moderatorCommand = qobject_cast(command); + if (moderatorCommand) { + qDebug() << "received ModeratorCommand"; + if (!(userInfo->getUserLevel() & ServerInfo_User::IsModerator)) + return RespLoginNeeded; + + switch (command->getItemId()) { + case ItemId_Command_BanFromServer: return cmdBanFromServer(static_cast(command), cont); + default: return RespInvalidCommand; + } + } AdminCommand *adminCommand = qobject_cast(command); if (adminCommand) { qDebug() << "received AdminCommand"; @@ -149,8 +160,8 @@ ResponseCode Server_ProtocolHandler::processCommandHelper(Command *command, Comm return RespLoginNeeded; switch (command->getItemId()) { + case ItemId_Command_ShutdownServer: return cmdShutdownServer(static_cast(command), cont); case ItemId_Command_UpdateServerMessage: return cmdUpdateServerMessage(static_cast(command), cont); - case ItemId_Command_BanFromServer: return cmdBanFromServer(static_cast(command), cont); default: return RespInvalidCommand; } } diff --git a/common/server_protocolhandler.h b/common/server_protocolhandler.h index c65d8d02..5817da22 100644 --- a/common/server_protocolhandler.h +++ b/common/server_protocolhandler.h @@ -87,8 +87,9 @@ private: ResponseCode cmdDumpZone(Command_DumpZone *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player); ResponseCode cmdStopDumpZone(Command_StopDumpZone *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player); ResponseCode cmdRevealCards(Command_RevealCards *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player); - virtual ResponseCode cmdUpdateServerMessage(Command_UpdateServerMessage *cmd, CommandContainer *cont) = 0; virtual ResponseCode cmdBanFromServer(Command_BanFromServer *cmd, CommandContainer *cont) = 0; + virtual ResponseCode cmdShutdownServer(Command_ShutdownServer *cmd, CommandContainer *cont) = 0; + virtual ResponseCode cmdUpdateServerMessage(Command_UpdateServerMessage *cmd, CommandContainer *cont) = 0; ResponseCode processCommandHelper(Command *command, CommandContainer *cont); private slots: diff --git a/servatrice/src/main.cpp b/servatrice/src/main.cpp index a36e3332..6c16c965 100644 --- a/servatrice/src/main.cpp +++ b/servatrice/src/main.cpp @@ -130,12 +130,16 @@ int main(int argc, char *argv[]) testRNG(); Servatrice server(settings); + QObject::connect(&server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection); std::cerr << "-------------------------" << std::endl; std::cerr << "Server initialized." << std::endl; int retval = app.exec(); + std::cerr << "Server quit." << std::endl; + std::cerr << "-------------------------" << std::endl; + delete rng; delete settings; diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index eaca1de6..0cc2dd96 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -44,7 +44,7 @@ void Servatrice_TcpServer::incomingConnection(int socketDescriptor) } Servatrice::Servatrice(QSettings *_settings, QObject *parent) - : Server(parent), dbMutex(QMutex::Recursive), settings(_settings), uptime(0) + : Server(parent), dbMutex(QMutex::Recursive), settings(_settings), uptime(0), shutdownTimer(0) { pingClock = new QTimer(this); connect(pingClock, SIGNAL(timeout()), this, SIGNAL(pingClockTimeout())); @@ -119,6 +119,7 @@ Servatrice::Servatrice(QSettings *_settings, QObject *parent) Servatrice::~Servatrice() { prepareDestroy(); + QSqlDatabase::database().close(); } bool Servatrice::openDatabase() @@ -233,7 +234,7 @@ ServerInfo_User *Servatrice::evalUserQueryResult(const QSqlQuery &query, bool co int userLevel = ServerInfo_User::IsUser | ServerInfo_User::IsRegistered; if (is_admin == 1) - userLevel |= ServerInfo_User::IsAdmin; + userLevel |= ServerInfo_User::IsAdmin | ServerInfo_User::IsModerator; else if (is_admin == 2) userLevel |= ServerInfo_User::IsModerator; @@ -388,4 +389,38 @@ void Servatrice::statusUpdate() execSqlQuery(query); } +void Servatrice::scheduleShutdown(const QString &reason, int minutes) +{ + QMutexLocker locker(&serverMutex); + + shutdownReason = reason; + shutdownMinutes = minutes + 1; + if (minutes > 0) { + shutdownTimer = new QTimer; + connect(shutdownTimer, SIGNAL(timeout()), this, SLOT(shutdownTimeout())); + shutdownTimer->start(60000); + } + shutdownTimeout(); +} + +void Servatrice::shutdownTimeout() +{ + QMutexLocker locker(&serverMutex); + + --shutdownMinutes; + + GenericEvent *event; + if (shutdownMinutes) + event = new Event_ServerShutdown(shutdownReason, shutdownMinutes); + else + event = new Event_ConnectionClosed("server_shutdown"); + + for (int i = 0; i < clients.size(); ++i) + clients[i]->sendProtocolItem(event, false); + delete event; + + if (!shutdownMinutes) + deleteLater(); +} + const QString Servatrice::versionString = "Servatrice 0.20110527"; diff --git a/servatrice/src/servatrice.h b/servatrice/src/servatrice.h index f1174c91..1a3d1d09 100644 --- a/servatrice/src/servatrice.h +++ b/servatrice/src/servatrice.h @@ -50,6 +50,7 @@ class Servatrice : public Server private slots: void statusUpdate(); void updateBanTimer(); + void shutdownTimeout(); public: QMutex dbMutex; static const QString versionString; @@ -76,6 +77,7 @@ public: bool getUserBanned(Server_ProtocolHandler *client, const QString &userName) const; void addAddressBan(const QHostAddress &address, int minutes) { addressBanList.append(QPair(address, minutes)); } void addNameBan(const QString &name, int minutes) { nameBanList.append(QPair(name, minutes)); } + void scheduleShutdown(const QString &reason, int minutes); protected: bool userExists(const QString &user); AuthenticationResult checkUserPassword(const QString &user, const QString &password); @@ -92,6 +94,10 @@ private: int maxGameInactivityTime, maxPlayerInactivityTime; int maxUsersPerAddress, messageCountingInterval, maxMessageCountPerInterval, maxMessageSizePerInterval, maxGamesPerUser; ServerInfo_User *evalUserQueryResult(const QSqlQuery &query, bool complete); + + QString shutdownReason; + int shutdownMinutes; + QTimer *shutdownTimer; }; #endif diff --git a/servatrice/src/serversocketinterface.cpp b/servatrice/src/serversocketinterface.cpp index f02747ca..14628a42 100644 --- a/servatrice/src/serversocketinterface.cpp +++ b/servatrice/src/serversocketinterface.cpp @@ -454,8 +454,8 @@ ResponseCode ServerSocketInterface::cmdDeckDownload(Command_DeckDownload *cmd, C return RespNothing; } -// ADMIN FUNCTIONS. -// Permission is checked by the calling function. +// MODERATOR FUNCTIONS. +// May be called by admins and moderators. Permission is checked by the calling function. ResponseCode ServerSocketInterface::cmdUpdateServerMessage(Command_UpdateServerMessage * /*cmd*/, CommandContainer * /*cont*/) { @@ -463,6 +463,15 @@ ResponseCode ServerSocketInterface::cmdUpdateServerMessage(Command_UpdateServerM return RespOk; } +// ADMIN FUNCTIONS. +// Permission is checked by the calling function. + +ResponseCode ServerSocketInterface::cmdShutdownServer(Command_ShutdownServer *cmd, CommandContainer * /*cont*/) +{ + servatrice->scheduleShutdown(cmd->getReason(), cmd->getMinutes()); + return RespOk; +} + ResponseCode ServerSocketInterface::cmdBanFromServer(Command_BanFromServer *cmd, CommandContainer * /*cont*/) { QString userName = cmd->getUserName(); diff --git a/servatrice/src/serversocketinterface.h b/servatrice/src/serversocketinterface.h index 8f7b937e..a155b421 100644 --- a/servatrice/src/serversocketinterface.h +++ b/servatrice/src/serversocketinterface.h @@ -66,8 +66,9 @@ private: ResponseCode cmdDeckUpload(Command_DeckUpload *cmd, CommandContainer *cont); DeckList *getDeckFromDatabase(int deckId); ResponseCode cmdDeckDownload(Command_DeckDownload *cmd, CommandContainer *cont); - ResponseCode cmdUpdateServerMessage(Command_UpdateServerMessage *cmd, CommandContainer *cont); ResponseCode cmdBanFromServer(Command_BanFromServer *cmd, CommandContainer *cont); + ResponseCode cmdShutdownServer(Command_ShutdownServer *cmd, CommandContainer *cont); + ResponseCode cmdUpdateServerMessage(Command_UpdateServerMessage *cmd, CommandContainer *cont); public: ServerSocketInterface(Servatrice *_server, QTcpSocket *_socket, QObject *parent = 0); ~ServerSocketInterface();