Fix merge & relative path for portable build
This commit is contained in:
commit
4125d690fa
33 changed files with 1556 additions and 581 deletions
|
@ -7,6 +7,7 @@ RUN apt-get update && apt-get install -y\
|
|||
cmake\
|
||||
git\
|
||||
libprotobuf-dev\
|
||||
libqt5sql5-mysql\
|
||||
libqt5svg5-dev\
|
||||
libqt5webkit5-dev\
|
||||
libsqlite3-dev\
|
||||
|
@ -37,4 +38,4 @@ WORKDIR /home/servatrice
|
|||
|
||||
EXPOSE 4747
|
||||
|
||||
CMD servatrice
|
||||
ENTRYPOINT [ "servatrice" ]
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "pb/event_server_shutdown.pb.h"
|
||||
#include "pb/event_connection_closed.pb.h"
|
||||
#include "pb/event_user_message.pb.h"
|
||||
#include "pb/event_notify_user.pb.h"
|
||||
#include "pb/event_list_rooms.pb.h"
|
||||
#include "pb/event_add_to_list.pb.h"
|
||||
#include "pb/event_remove_from_list.pb.h"
|
||||
|
@ -40,6 +41,7 @@ AbstractClient::AbstractClient(QObject *parent)
|
|||
qRegisterMetaType<Event_ListRooms>("Event_ListRooms");
|
||||
qRegisterMetaType<Event_GameJoined>("Event_GameJoined");
|
||||
qRegisterMetaType<Event_UserMessage>("Event_UserMessage");
|
||||
qRegisterMetaType<Event_NotifyUser>("Event_NotifyUser");
|
||||
qRegisterMetaType<ServerInfo_User>("ServerInfo_User");
|
||||
qRegisterMetaType<QList<ServerInfo_User> >("QList<ServerInfo_User>");
|
||||
qRegisterMetaType<Event_ReplayAdded>("Event_ReplayAdded");
|
||||
|
@ -75,6 +77,7 @@ void AbstractClient::processProtocolItem(const ServerMessage &item)
|
|||
case SessionEvent::SERVER_SHUTDOWN: emit serverShutdownEventReceived(event.GetExtension(Event_ServerShutdown::ext)); break;
|
||||
case SessionEvent::CONNECTION_CLOSED: emit connectionClosedEventReceived(event.GetExtension(Event_ConnectionClosed::ext)); break;
|
||||
case SessionEvent::USER_MESSAGE: emit userMessageEventReceived(event.GetExtension(Event_UserMessage::ext)); break;
|
||||
case SessionEvent::NOTIFY_USER: emit notifyUserEventReceived(event.GetExtension(Event_NotifyUser::ext)); break;
|
||||
case SessionEvent::LIST_ROOMS: emit listRoomsEventReceived(event.GetExtension(Event_ListRooms::ext)); break;
|
||||
case SessionEvent::ADD_TO_LIST: emit addToListEventReceived(event.GetExtension(Event_AddToList::ext)); break;
|
||||
case SessionEvent::REMOVE_FROM_LIST: emit removeFromListEventReceived(event.GetExtension(Event_RemoveFromList::ext)); break;
|
||||
|
|
|
@ -21,6 +21,7 @@ class Event_ServerMessage;
|
|||
class Event_ListRooms;
|
||||
class Event_GameJoined;
|
||||
class Event_UserMessage;
|
||||
class Event_NotifyUser;
|
||||
class Event_ConnectionClosed;
|
||||
class Event_ServerShutdown;
|
||||
class Event_ReplayAdded;
|
||||
|
@ -56,6 +57,7 @@ signals:
|
|||
void listRoomsEventReceived(const Event_ListRooms &event);
|
||||
void gameJoinedEventReceived(const Event_GameJoined &event);
|
||||
void userMessageEventReceived(const Event_UserMessage &event);
|
||||
void notifyUserEventReceived(const Event_NotifyUser &event);
|
||||
void userInfoChanged(const ServerInfo_User &userInfo);
|
||||
void buddyListReceived(const QList<ServerInfo_User> &buddyList);
|
||||
void ignoreListReceived(const QList<ServerInfo_User> &ignoreList);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
void DlgCreateGame::sharedCtor()
|
||||
{
|
||||
rememberGameSettings = new QCheckBox(tr("Re&member settings"));
|
||||
descriptionLabel = new QLabel(tr("&Description:"));
|
||||
descriptionEdit = new QLineEdit;
|
||||
descriptionLabel->setBuddy(descriptionEdit);
|
||||
|
@ -38,6 +39,7 @@ void DlgCreateGame::sharedCtor()
|
|||
generalGrid->addWidget(descriptionEdit, 0, 1);
|
||||
generalGrid->addWidget(maxPlayersLabel, 1, 0);
|
||||
generalGrid->addWidget(maxPlayersEdit, 1, 1);
|
||||
generalGrid->addWidget(rememberGameSettings, 2, 0);
|
||||
|
||||
QVBoxLayout *gameTypeLayout = new QVBoxLayout;
|
||||
QMapIterator<int, QString> gameTypeIterator(gameTypes);
|
||||
|
@ -111,15 +113,26 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType
|
|||
{
|
||||
sharedCtor();
|
||||
|
||||
rememberGameSettings->setChecked(settingsCache->getRememberGameSettings());
|
||||
descriptionEdit->setText(settingsCache->getGameDescription());
|
||||
maxPlayersEdit->setValue(settingsCache->getMaxPlayers());
|
||||
onlyBuddiesCheckBox->setChecked(settingsCache->getOnlyBuddies());
|
||||
onlyRegisteredCheckBox->setChecked(settingsCache->getOnlyRegistered());
|
||||
if (room && room->getUserInfo()->user_level() & ServerInfo_User::IsRegistered)
|
||||
{
|
||||
onlyRegisteredCheckBox->setChecked(settingsCache->getOnlyRegistered());
|
||||
} else {
|
||||
onlyBuddiesCheckBox->setEnabled(false);
|
||||
onlyRegisteredCheckBox->setEnabled(false);
|
||||
}
|
||||
spectatorsAllowedCheckBox->setChecked(settingsCache->getSpectatorsAllowed());
|
||||
spectatorsNeedPasswordCheckBox->setChecked(settingsCache->getSpectatorsNeedPassword());
|
||||
spectatorsCanTalkCheckBox->setChecked(settingsCache->getSpectatorsCanTalk());
|
||||
spectatorsSeeEverythingCheckBox->setChecked(settingsCache->getSpectatorsCanSeeEverything());
|
||||
|
||||
if (!rememberGameSettings->isChecked()){
|
||||
actReset();
|
||||
}
|
||||
|
||||
clearButton = new QPushButton(tr("&Clear"));
|
||||
buttonBox->addButton(QDialogButtonBox::Cancel);
|
||||
buttonBox->addButton(clearButton, QDialogButtonBox::ActionRole);
|
||||
|
@ -134,6 +147,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
|
|||
{
|
||||
sharedCtor();
|
||||
|
||||
rememberGameSettings->setEnabled(false);
|
||||
descriptionEdit->setEnabled(false);
|
||||
maxPlayersEdit->setEnabled(false);
|
||||
passwordEdit->setEnabled(false);
|
||||
|
@ -197,15 +211,6 @@ descriptionEdit->setFocus();
|
|||
|
||||
void DlgCreateGame::actOK()
|
||||
{
|
||||
settingsCache->setGameDescription(descriptionEdit->text());
|
||||
settingsCache->setMaxPlayers(maxPlayersEdit->value());
|
||||
settingsCache->setOnlyBuddies(onlyBuddiesCheckBox->isChecked());
|
||||
settingsCache->setOnlyRegistered(onlyRegisteredCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsAllowed(spectatorsAllowedCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsNeedPassword(spectatorsNeedPasswordCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsCanTalk(spectatorsCanTalkCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsCanSeeEverything(spectatorsSeeEverythingCheckBox->isChecked());
|
||||
|
||||
Command_CreateGame cmd;
|
||||
cmd.set_description(descriptionEdit->text().simplified().toStdString());
|
||||
cmd.set_password(passwordEdit->text().toStdString());
|
||||
|
@ -227,7 +232,18 @@ void DlgCreateGame::actOK()
|
|||
}
|
||||
}
|
||||
|
||||
settingsCache->setGameTypes(gameTypes);
|
||||
settingsCache->setRememberGameSettings(rememberGameSettings->isChecked());
|
||||
if (rememberGameSettings->isChecked()){
|
||||
settingsCache->setGameDescription(descriptionEdit->text());
|
||||
settingsCache->setMaxPlayers(maxPlayersEdit->value());
|
||||
settingsCache->setOnlyBuddies(onlyBuddiesCheckBox->isChecked());
|
||||
settingsCache->setOnlyRegistered(onlyRegisteredCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsAllowed(spectatorsAllowedCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsNeedPassword(spectatorsNeedPasswordCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsCanTalk(spectatorsCanTalkCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsCanSeeEverything(spectatorsSeeEverythingCheckBox->isChecked());
|
||||
settingsCache->setGameTypes(gameTypes);
|
||||
}
|
||||
PendingCommand *pend = room->prepareRoomCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(checkResponse(Response)));
|
||||
room->sendRoomCommand(pend);
|
||||
|
|
|
@ -39,6 +39,7 @@ private:
|
|||
QCheckBox *spectatorsAllowedCheckBox, *spectatorsNeedPasswordCheckBox, *spectatorsCanTalkCheckBox, *spectatorsSeeEverythingCheckBox;
|
||||
QDialogButtonBox *buttonBox;
|
||||
QPushButton *clearButton;
|
||||
QCheckBox *rememberGameSettings;
|
||||
|
||||
void sharedCtor();
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ DlgEditUser::DlgEditUser(QWidget *parent, QString email, int gender, QString cou
|
|||
foreach(QString c, countries)
|
||||
{
|
||||
countryEdit->addItem(QPixmap(":/resources/countries/" + c + ".svg"), c);
|
||||
if(c == country)
|
||||
if (c == country)
|
||||
countryEdit->setCurrentIndex(i);
|
||||
|
||||
++i;
|
||||
|
|
|
@ -58,9 +58,7 @@ DlgRegister::DlgRegister(QWidget *parent)
|
|||
countryEdit->setCurrentIndex(0);
|
||||
QStringList countries = settingsCache->getCountries();
|
||||
foreach(QString c, countries)
|
||||
{
|
||||
countryEdit->addItem(QPixmap(":/resources/countries/" + c + ".svg"), c);
|
||||
}
|
||||
|
||||
realnameLabel = new QLabel(tr("Real name:"));
|
||||
realnameEdit = new QLineEdit();
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
QString getPassword() const { return passwordEdit->text(); }
|
||||
QString getEmail() const { return emailEdit->text(); }
|
||||
int getGender() const { return genderEdit->currentIndex() - 1; }
|
||||
QString getCountry() const { return genderEdit->currentIndex() == 0 ? "" : countryEdit->currentText(); }
|
||||
QString getCountry() const { return countryEdit->currentIndex() == 0 ? "" : countryEdit->currentText(); }
|
||||
QString getRealName() const { return realnameEdit->text(); }
|
||||
private slots:
|
||||
void actOk();
|
||||
|
|
|
@ -119,7 +119,7 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr
|
|||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
QSvgRenderer svg(QString(":/resources/countries/" + countryCode + ".svg"));
|
||||
QSvgRenderer svg(QString(":/resources/countries/" + countryCode.toLower() + ".svg"));
|
||||
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
||||
QPixmap pixmap(width, height);
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "pb/event_server_identification.pb.h"
|
||||
#include "settingscache.h"
|
||||
#include "main.h"
|
||||
#include "version_string.h"
|
||||
|
||||
static const unsigned int protocolVersion = 14;
|
||||
|
||||
|
@ -112,6 +113,7 @@ void RemoteClient::doLogin()
|
|||
cmdLogin.set_user_name(userName.toStdString());
|
||||
cmdLogin.set_password(password.toStdString());
|
||||
cmdLogin.set_clientid(settingsCache->getClientID().toStdString());
|
||||
cmdLogin.set_clientver(VERSION_STRING);
|
||||
PendingCommand *pend = prepareSessionCommand(cmdLogin);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(loginResponse(Response)));
|
||||
sendCommand(pend);
|
||||
|
|
|
@ -220,6 +220,7 @@ SettingsCache::SettingsCache()
|
|||
spectatorsNeedPassword = settings->value("game/spectatorsneedpassword", false).toBool();
|
||||
spectatorsCanTalk = settings->value("game/spectatorscantalk", false).toBool();
|
||||
spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool();
|
||||
rememberGameSettings = settings->value("game/remembergamesettings", true).toBool();
|
||||
clientID = settings->value("personal/clientid", "notset").toString();
|
||||
}
|
||||
|
||||
|
@ -646,3 +647,9 @@ void SettingsCache::setSpectatorsCanSeeEverything(const bool _spectatorsCanSeeEv
|
|||
spectatorsCanSeeEverything = _spectatorsCanSeeEverything;
|
||||
settings->setValue("game/spectatorscanseeeverything", spectatorsCanSeeEverything);
|
||||
}
|
||||
|
||||
void SettingsCache::setRememberGameSettings(const bool _rememberGameSettings)
|
||||
{
|
||||
rememberGameSettings = _rememberGameSettings;
|
||||
settings->setValue("game/remembergamesettings", rememberGameSettings);
|
||||
}
|
|
@ -115,6 +115,8 @@ private:
|
|||
bool spectatorsCanSeeEverything;
|
||||
int keepalive;
|
||||
void translateLegacySettings();
|
||||
bool rememberGameSettings;
|
||||
|
||||
public:
|
||||
SettingsCache();
|
||||
QString getSettingsPath();
|
||||
|
@ -187,6 +189,7 @@ public:
|
|||
bool getSpectatorsNeedPassword() const { return spectatorsNeedPassword; }
|
||||
bool getSpectatorsCanTalk() const { return spectatorsCanTalk; }
|
||||
bool getSpectatorsCanSeeEverything() const { return spectatorsCanSeeEverything; }
|
||||
bool getRememberGameSettings() const { return rememberGameSettings; }
|
||||
int getKeepAlive() const { return keepalive; }
|
||||
void setClientID(QString clientID);
|
||||
QString getClientID() { return clientID; }
|
||||
|
@ -260,6 +263,7 @@ public slots:
|
|||
void setSpectatorsNeedPassword(const bool _spectatorsNeedPassword);
|
||||
void setSpectatorsCanTalk(const bool _spectatorsCanTalk);
|
||||
void setSpectatorsCanSeeEverything(const bool _spectatorsCanSeeEverything);
|
||||
void setRememberGameSettings(const bool _rememberGameSettings);
|
||||
};
|
||||
|
||||
extern SettingsCache *settingsCache;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#include "tab_supervisor.h"
|
||||
#include "abstractclient.h"
|
||||
|
@ -13,14 +16,12 @@
|
|||
#include "pixmapgenerator.h"
|
||||
#include "userlist.h"
|
||||
#include "settingscache.h"
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "pb/room_commands.pb.h"
|
||||
#include "pb/room_event.pb.h"
|
||||
#include "pb/game_event_container.pb.h"
|
||||
#include "pb/event_user_message.pb.h"
|
||||
#include "pb/event_notify_user.pb.h"
|
||||
#include "pb/event_game_joined.pb.h"
|
||||
#include "pb/serverinfo_user.pb.h"
|
||||
#include "pb/serverinfo_room.pb.h"
|
||||
|
@ -90,6 +91,7 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent)
|
|||
connect(client, SIGNAL(gameJoinedEventReceived(const Event_GameJoined &)), this, SLOT(gameJoined(const Event_GameJoined &)));
|
||||
connect(client, SIGNAL(userMessageEventReceived(const Event_UserMessage &)), this, SLOT(processUserMessageEvent(const Event_UserMessage &)));
|
||||
connect(client, SIGNAL(maxPingTime(int, int)), this, SLOT(updatePingTime(int, int)));
|
||||
connect(client, SIGNAL(notifyUserEventReceived(const Event_NotifyUser &)), this, SLOT(processNotifyUserEvent(const Event_NotifyUser &)));
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
@ -559,3 +561,13 @@ bool TabSupervisor::getAdminLocked() const
|
|||
return true;
|
||||
return tabAdmin->getLocked();
|
||||
}
|
||||
|
||||
void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
|
||||
{
|
||||
switch ((Event_NotifyUser::NotificationType) event.type()) {
|
||||
case Event_NotifyUser::PROMOTED: QMessageBox::information(this, tr("Promotion"), tr("You have been promoted to moderator. Please log out and back in for changes to take effect.")); break;
|
||||
default: ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ class RoomEvent;
|
|||
class GameEventContainer;
|
||||
class Event_GameJoined;
|
||||
class Event_UserMessage;
|
||||
class Event_NotifyUser;
|
||||
class ServerInfo_Room;
|
||||
class ServerInfo_User;
|
||||
class GameReplay;
|
||||
|
@ -105,6 +106,7 @@ private slots:
|
|||
void processRoomEvent(const RoomEvent &event);
|
||||
void processGameEventContainer(const GameEventContainer &cont);
|
||||
void processUserMessageEvent(const Event_UserMessage &event);
|
||||
void processNotifyUserEvent(const Event_NotifyUser &event);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -1,5 +1,6 @@
|
|||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include "user_context_menu.h"
|
||||
#include "tab_supervisor.h"
|
||||
#include "tab_userlists.h"
|
||||
|
@ -31,6 +32,8 @@ UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *p
|
|||
aRemoveFromIgnoreList = new QAction(QString(), this);
|
||||
aKick = new QAction(QString(), this);
|
||||
aBan = new QAction(QString(), this);
|
||||
aPromoteToMod = new QAction(QString(), this);
|
||||
aDemoteFromMod = new QAction(QString(), this);
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
@ -46,6 +49,8 @@ void UserContextMenu::retranslateUi()
|
|||
aRemoveFromIgnoreList->setText(tr("Remove from &ignore list"));
|
||||
aKick->setText(tr("Kick from &game"));
|
||||
aBan->setText(tr("Ban from &server"));
|
||||
aPromoteToMod->setText(tr("&Promote user to moderator"));
|
||||
aDemoteFromMod->setText(tr("Dem&ote user from moderator"));
|
||||
}
|
||||
|
||||
void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer)
|
||||
|
@ -89,6 +94,27 @@ void UserContextMenu::banUser_processUserInfoResponse(const Response &r)
|
|||
dlg->show();
|
||||
}
|
||||
|
||||
void UserContextMenu::adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer)
|
||||
{
|
||||
|
||||
const Command_AdjustMod &cmd = commandContainer.admin_command(0).GetExtension(Command_AdjustMod::ext);
|
||||
|
||||
if (resp.response_code() == Response::RespOk) {
|
||||
if (cmd.should_be_mod()) {
|
||||
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Success"), tr("Successfully promoted user."));
|
||||
} else {
|
||||
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Success"), tr("Successfully demoted user."));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (cmd.should_be_mod()) {
|
||||
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Failed"), tr("Failed to promote user."));
|
||||
} else {
|
||||
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Failed"), tr("Failed to demote user."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UserContextMenu::banUser_dialogFinished()
|
||||
{
|
||||
BanDialog *dlg = static_cast<BanDialog *>(sender());
|
||||
|
@ -132,6 +158,14 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
if (!tabSupervisor->getAdminLocked()) {
|
||||
menu->addSeparator();
|
||||
menu->addAction(aBan);
|
||||
|
||||
menu->addSeparator();
|
||||
if (userLevel.testFlag(ServerInfo_User::IsModerator) && (tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin)) {
|
||||
menu->addAction(aDemoteFromMod);
|
||||
|
||||
} else if (userLevel.testFlag(ServerInfo_User::IsRegistered) && (tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin)) {
|
||||
menu->addAction(aPromoteToMod);
|
||||
}
|
||||
}
|
||||
bool anotherUser = userName != QString::fromStdString(tabSupervisor->getUserInfo()->name());
|
||||
aDetails->setEnabled(online);
|
||||
|
@ -143,6 +177,8 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
aRemoveFromIgnoreList->setEnabled(anotherUser);
|
||||
aKick->setEnabled(anotherUser);
|
||||
aBan->setEnabled(anotherUser);
|
||||
aPromoteToMod->setEnabled(anotherUser);
|
||||
aDemoteFromMod->setEnabled(anotherUser);
|
||||
|
||||
QAction *actionClicked = menu->exec(pos);
|
||||
if (actionClicked == aDetails) {
|
||||
|
@ -186,6 +222,7 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
} else if (actionClicked == aKick) {
|
||||
Command_KickFromGame cmd;
|
||||
cmd.set_player_id(playerId);
|
||||
|
||||
game->sendGameCommand(cmd);
|
||||
} else if (actionClicked == aBan) {
|
||||
Command_GetUserInfo cmd;
|
||||
|
@ -193,7 +230,14 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response)));
|
||||
client->sendCommand(pend);
|
||||
} else if (actionClicked == aPromoteToMod || actionClicked == aDemoteFromMod) {
|
||||
Command_AdjustMod cmd;
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
cmd.set_should_be_mod(actionClicked == aPromoteToMod);
|
||||
|
||||
PendingCommand *pend = client->prepareAdminCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(adjustMod_processUserResponse(Response, CommandContainer)));
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,12 @@ private:
|
|||
QAction *aAddToIgnoreList, *aRemoveFromIgnoreList;
|
||||
QAction *aKick;
|
||||
QAction *aBan;
|
||||
QAction *aPromoteToMod, *aDemoteFromMod;
|
||||
signals:
|
||||
void openMessageDialog(const QString &userName, bool focus);
|
||||
private slots:
|
||||
void banUser_processUserInfoResponse(const Response &resp);
|
||||
void adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer);
|
||||
void banUser_dialogFinished();
|
||||
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
|
||||
public:
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
#include <QSystemTrayIcon>
|
||||
#include <QApplication>
|
||||
#if QT_VERSION < 0x050000
|
||||
// for Qt::escape()
|
||||
#include <QtGui/qtextdocument.h>
|
||||
#include <QtGui/qtextdocument.h> // for Qt::escape()
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
|
@ -47,7 +46,6 @@
|
|||
#include "localclient.h"
|
||||
#include "settingscache.h"
|
||||
#include "tab_game.h"
|
||||
|
||||
#include "version_string.h"
|
||||
|
||||
#include "pb/game_replay.pb.h"
|
||||
|
@ -55,6 +53,14 @@
|
|||
#include "pb/event_connection_closed.pb.h"
|
||||
#include "pb/event_server_shutdown.pb.h"
|
||||
|
||||
#define GITHUB_CONTRIBUTORS_URL "https://github.com/Cockatrice/Cockatrice/graphs/contributors?type=c"
|
||||
#define GITHUB_CONTRIBUTE_URL "https://github.com/Cockatrice/Cockatrice#cockatrice"
|
||||
#define GITHUB_TRANSLATOR_RECOGNIZE_URL "https://github.com/Cockatrice/Cockatrice/wiki/Translators"
|
||||
#define GITHUB_TRANSLATOR_FAQ_URL "https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ"
|
||||
#define GITHUB_ISSUES_URL "https://github.com/Cockatrice/Cockatrice/issues"
|
||||
#define GITHUB_TROUBLESHOOTING_URL "https://github.com/Cockatrice/Cockatrice/wiki/Troubleshooting"
|
||||
#define GITHUB_FAQ_URL "https://github.com/Cockatrice/Cockatrice/wiki/Frequently-Asked-Questions"
|
||||
|
||||
const QString MainWindow::appName = "Cockatrice";
|
||||
|
||||
void MainWindow::updateTabMenu(const QList<QMenu *> &newMenuList)
|
||||
|
@ -71,7 +77,7 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even
|
|||
client->disconnectFromServer();
|
||||
QString reasonStr;
|
||||
switch (event.reason()) {
|
||||
case Event_ConnectionClosed::USER_LIMIT_REACHED: reasonStr = tr("The server has reached its maximum user capacity, please check back later."); break;
|
||||
case Event_ConnectionClosed::USER_LIMIT_REACHED: reasonStr = tr("The server has reached its maximum user capacity, please check back later."); break;
|
||||
case Event_ConnectionClosed::TOO_MANY_CONNECTIONS: reasonStr = tr("There are too many concurrent connections from your address."); break;
|
||||
case Event_ConnectionClosed::BANNED: {
|
||||
reasonStr = tr("Banned by moderator");
|
||||
|
@ -85,6 +91,7 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even
|
|||
}
|
||||
case Event_ConnectionClosed::SERVER_SHUTDOWN: reasonStr = tr("Scheduled server shutdown."); break;
|
||||
case Event_ConnectionClosed::USERNAMEINVALID: reasonStr = tr("Invalid username."); break;
|
||||
case Event_ConnectionClosed::LOGGEDINELSEWERE: reasonStr = tr("You have been logged out due to logging in at another location."); break;
|
||||
default: reasonStr = QString::fromStdString(event.reason_str());
|
||||
}
|
||||
QMessageBox::critical(this, tr("Connection closed"), tr("The server has terminated your connection.\nReason: %1").arg(reasonStr));
|
||||
|
@ -268,15 +275,15 @@ void MainWindow::actAbout()
|
|||
+ "<br><br><b>" + tr("Project Manager:") + "</b><br>Gavin Bisesi<br><br>"
|
||||
+ "<b>" + tr("Past Project Managers:") + "</b><br>Max-Wilhelm Bruker<br>Marcus Schütz<br><br>"
|
||||
+ "<b>" + tr("Developers:") + "</b><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/graphs/contributors?type=c'>" + tr("Our Developers") + "</a><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice#cockatrice'>" + tr("Help Develop!") + "</a><br><br>"
|
||||
+ "<a href='" + GITHUB_CONTRIBUTORS_URL + "'>" + tr("Our Developers") + "</a><br>"
|
||||
+ "<a href='" + GITHUB_CONTRIBUTE_URL + "'>" + tr("Help Develop!") + "</a><br><br>"
|
||||
+ "<b>" + tr("Translators:") + "</b><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/wiki/Translators'>" + tr("Recognition Page") + "</a><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ'>" + tr("Help Translate!") + "</a><br><br>"
|
||||
+ "<a href='" + GITHUB_TRANSLATOR_RECOGNIZE_URL + "'>" + tr("Recognition Page") + "</a><br>"
|
||||
+ "<a href='" + GITHUB_TRANSLATOR_FAQ_URL + "'>" + tr("Help Translate!") + "</a><br><br>"
|
||||
+ "<b>" + tr("Support:") + "</b><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/issues'>" + tr("Report an Issue") + "</a><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/wiki/Troubleshooting'>" + tr("Troubleshooting") + "</a><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/wiki/Frequently-Asked-Questions'>" + tr("F.A.Q.") + "</a><br>"
|
||||
+ "<a href='" + GITHUB_ISSUES_URL + "'>" + tr("Report an Issue") + "</a><br>"
|
||||
+ "<a href='" + GITHUB_TROUBLESHOOTING_URL + "'>" + tr("Troubleshooting") + "</a><br>"
|
||||
+ "<a href='" + GITHUB_FAQ_URL + "'>" + tr("F.A.Q.") + "</a><br>"
|
||||
));
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -106,6 +106,7 @@ SET(PROTO_FILES
|
|||
event_user_joined.proto
|
||||
event_user_left.proto
|
||||
event_user_message.proto
|
||||
event_notify_user.proto
|
||||
game_commands.proto
|
||||
game_event_container.proto
|
||||
game_event_context.proto
|
||||
|
@ -127,6 +128,7 @@ SET(PROTO_FILES
|
|||
response_register.proto
|
||||
response_replay_download.proto
|
||||
response_replay_list.proto
|
||||
response_adjust_mod.proto
|
||||
response.proto
|
||||
room_commands.proto
|
||||
room_event.proto
|
||||
|
|
|
@ -3,6 +3,7 @@ message AdminCommand {
|
|||
UPDATE_SERVER_MESSAGE = 1000;
|
||||
SHUTDOWN_SERVER = 1001;
|
||||
RELOAD_CONFIG = 1002;
|
||||
ADJUST_MOD = 1003;
|
||||
}
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
@ -26,3 +27,12 @@ message Command_ReloadConfig {
|
|||
optional Command_ReloadConfig ext = 1002;
|
||||
}
|
||||
}
|
||||
|
||||
message Command_AdjustMod {
|
||||
extend AdminCommand {
|
||||
optional Command_AdjustMod ext = 1003;
|
||||
}
|
||||
required string user_name = 1;
|
||||
required bool should_be_mod = 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ message Event_ConnectionClosed {
|
|||
BANNED = 4;
|
||||
USERNAMEINVALID = 5;
|
||||
USER_LIMIT_REACHED = 6;
|
||||
DEMOTED = 7;
|
||||
LOGGEDINELSEWERE = 8;
|
||||
}
|
||||
optional CloseReason reason = 1;
|
||||
optional string reason_str = 2;
|
||||
|
|
14
common/pb/event_notify_user.proto
Normal file
14
common/pb/event_notify_user.proto
Normal file
|
@ -0,0 +1,14 @@
|
|||
import "session_event.proto";
|
||||
|
||||
message Event_NotifyUser {
|
||||
|
||||
enum NotificationType {
|
||||
PROMOTED = 1;
|
||||
}
|
||||
|
||||
extend SessionEvent {
|
||||
optional Event_NotifyUser ext = 1010;
|
||||
}
|
||||
optional NotificationType type = 1;
|
||||
|
||||
}
|
|
@ -49,6 +49,7 @@ message Response {
|
|||
DECK_UPLOAD = 1008;
|
||||
REGISTER = 1009;
|
||||
ACTIVATE = 1010;
|
||||
ADJUST_MOD = 1011;
|
||||
REPLAY_LIST = 1100;
|
||||
REPLAY_DOWNLOAD = 1101;
|
||||
}
|
||||
|
|
7
common/pb/response_adjust_mod.proto
Normal file
7
common/pb/response_adjust_mod.proto
Normal file
|
@ -0,0 +1,7 @@
|
|||
import "response.proto";
|
||||
|
||||
message Response_AdjustMod{
|
||||
extend Response {
|
||||
optional Response_AdjustMod ext = 1011;
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ message Command_Login {
|
|||
optional string user_name = 1;
|
||||
optional string password = 2;
|
||||
optional string clientid = 3;
|
||||
optional string clientver = 4;
|
||||
}
|
||||
|
||||
message Command_Message {
|
||||
|
|
|
@ -12,6 +12,7 @@ message SessionEvent {
|
|||
USER_JOINED = 1007;
|
||||
USER_LEFT = 1008;
|
||||
GAME_JOINED = 1009;
|
||||
NOTIFY_USER = 1010;
|
||||
REPLAY_ADDED = 1100;
|
||||
}
|
||||
extensions 100 to max;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "pb/event_user_left.pb.h"
|
||||
#include "pb/event_list_rooms.pb.h"
|
||||
#include "pb/session_event.pb.h"
|
||||
#include "pb/event_connection_closed.pb.h"
|
||||
#include "pb/isl_message.pb.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QThread>
|
||||
|
@ -126,9 +127,17 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
|
||||
// verify that new session would not cause problems with older existing session
|
||||
if (users.contains(name) || databaseInterface->userSessionExists(name)) {
|
||||
qDebug("Login denied: would overwrite old session");
|
||||
databaseInterface->unlockSessionTables();
|
||||
return WouldOverwriteOldSession;
|
||||
qDebug("Session already logged in, logging old session out");
|
||||
|
||||
Event_ConnectionClosed event;
|
||||
event.set_reason(Event_ConnectionClosed::LOGGEDINELSEWERE);
|
||||
event.set_reason_str("You have been logged out due to logging in at another location.");
|
||||
event.set_end_time(QDateTime::currentDateTime().toTime_t());
|
||||
|
||||
SessionEvent *se = users.value(name)->prepareSessionEvent(event);
|
||||
users.value(name)->sendProtocolItem(*se);
|
||||
delete se;
|
||||
|
||||
}
|
||||
} else if (authState == UnknownUser) {
|
||||
// Change user name so that no two users have the same names,
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
void removeClient(Server_ProtocolHandler *player);
|
||||
virtual QString getLoginMessage() const { return QString(); }
|
||||
|
||||
virtual bool permitUnregisteredUsers() const { return true; }
|
||||
virtual bool getGameShouldPing() const { return false; }
|
||||
virtual bool getClientIdRequired() const { return false; }
|
||||
virtual bool getRegOnlyServer() const { return false; }
|
||||
|
|
|
@ -652,7 +652,9 @@ Response::ResponseCode Server_ProtocolHandler::cmdCreateGame(const Command_Creat
|
|||
if (description.size() > 60)
|
||||
description = description.left(60);
|
||||
|
||||
Server_Game *game = new Server_Game(copyUserInfo(false), gameId, description, QString::fromStdString(cmd.password()), cmd.max_players(), gameTypes, cmd.only_buddies(), cmd.only_registered(), cmd.spectators_allowed(), cmd.spectators_need_password(), cmd.spectators_can_talk(), cmd.spectators_see_everything(), room);
|
||||
// When server doesn't permit registered users to exist, do not honor only-reg setting
|
||||
bool onlyRegisteredUsers = cmd.only_registered() && (server->permitUnregisteredUsers());
|
||||
Server_Game *game = new Server_Game(copyUserInfo(false), gameId, description, QString::fromStdString(cmd.password()), cmd.max_players(), gameTypes, cmd.only_buddies(), onlyRegisteredUsers, cmd.spectators_allowed(), cmd.spectators_need_password(), cmd.spectators_can_talk(), cmd.spectators_see_everything(), room);
|
||||
game->addPlayer(this, rc, false, false);
|
||||
room->addGame(game);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ OracleWizard::OracleWizard(QWidget *parent)
|
|||
QStandardPaths::standardLocations(QStandardPaths::DataLocation).first();
|
||||
#endif
|
||||
#else
|
||||
dataDir.append("../cockatrice/data");
|
||||
dataDir.append("data");
|
||||
#endif
|
||||
|
||||
importer = new OracleImporter(dataDir, this);
|
||||
|
@ -517,13 +517,13 @@ bool SaveSetsPage::validatePage()
|
|||
dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first();
|
||||
#endif
|
||||
#else
|
||||
dataDir = "../cockatrice/data";
|
||||
dataDir = "data";
|
||||
#endif
|
||||
|
||||
#ifdef PORTABLE_BUILD
|
||||
QSettings* settings = new QSettings("../cockatrice/settings/global.ini",QSettings::IniFormat,this);
|
||||
QString defaultPath = "../cockatrice/data/cards.xml";
|
||||
settings->setValue("paths/carddatabase", "data/cards.xml");
|
||||
QSettings* settings = new QSettings("settings/global.ini",QSettings::IniFormat,this);
|
||||
QString defaultPath = "data/cards.xml";
|
||||
settings->setValue("paths/carddatabase", defaultPath);
|
||||
#else
|
||||
QSettings* settings = new QSettings(settingsCache->getSettingsPath()+"global.ini",QSettings::IniFormat,this);
|
||||
QString defaultPath = settings->value("paths/carddatabase").toString();
|
||||
|
@ -732,13 +732,13 @@ bool SaveTokensPage::validatePage()
|
|||
dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first();
|
||||
#endif
|
||||
#else
|
||||
dataDir = "../cockatrice/data";
|
||||
dataDir = "data";
|
||||
#endif
|
||||
|
||||
#ifdef PORTABLE_BUILD
|
||||
QSettings* settings = new QSettings("../cockatrice/settings/global.ini",QSettings::IniFormat,this);
|
||||
QString defaultPath = "../cockatrice/data/tokens.xml";
|
||||
settings->setValue("paths/tokendatabase", "data/tokens.xml");
|
||||
QSettings* settings = new QSettings("settings/global.ini",QSettings::IniFormat,this);
|
||||
QString defaultPath = "data/tokens.xml";
|
||||
settings->setValue("paths/tokendatabase", defaultPath);
|
||||
#else
|
||||
QSettings* settings = new QSettings(settingsCache->getSettingsPath()+"global.ini",QSettings::IniFormat,this);
|
||||
QString defaultPath = settings->value("paths/tokendatabase").toString();
|
||||
|
|
|
@ -136,6 +136,7 @@ public:
|
|||
bool initServer();
|
||||
QString getServerName() const { return serverName; }
|
||||
QString getLoginMessage() const { QMutexLocker locker(&loginMessageMutex); return loginMessage; }
|
||||
bool permitUnregisteredUsers() const { return authenticationMethod != AuthenticationNone; }
|
||||
bool getGameShouldPing() const { return true; }
|
||||
bool getClientIdRequired() const { return clientIdRequired; }
|
||||
bool getRegOnlyServer() const { return regServerOnly; }
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include <QSqlError>
|
||||
#include <QSqlQuery>
|
||||
#include <QHostAddress>
|
||||
#include <QDebug>
|
||||
|
@ -49,6 +50,7 @@
|
|||
#include "pb/event_server_identification.pb.h"
|
||||
#include "pb/event_add_to_list.pb.h"
|
||||
#include "pb/event_remove_from_list.pb.h"
|
||||
#include "pb/event_notify_user.pb.h"
|
||||
#include "pb/response_deck_list.pb.h"
|
||||
#include "pb/response_deck_download.pb.h"
|
||||
#include "pb/response_deck_upload.pb.h"
|
||||
|
@ -309,6 +311,7 @@ Response::ResponseCode ServerSocketInterface::processExtendedAdminCommand(int cm
|
|||
case AdminCommand::SHUTDOWN_SERVER: return cmdShutdownServer(cmd.GetExtension(Command_ShutdownServer::ext), rc);
|
||||
case AdminCommand::UPDATE_SERVER_MESSAGE: return cmdUpdateServerMessage(cmd.GetExtension(Command_UpdateServerMessage::ext), rc);
|
||||
case AdminCommand::RELOAD_CONFIG: return cmdReloadConfig(cmd.GetExtension(Command_ReloadConfig::ext), rc);
|
||||
case AdminCommand::ADJUST_MOD: return cmdAdjustMod(cmd.GetExtension(Command_AdjustMod::ext), rc);
|
||||
default: return Response::RespFunctionNotAllowed;
|
||||
}
|
||||
}
|
||||
|
@ -1000,3 +1003,52 @@ Response::ResponseCode ServerSocketInterface::cmdReloadConfig(const Command_Relo
|
|||
settingsCache->sync();
|
||||
return Response::RespOk;
|
||||
}
|
||||
|
||||
Response::ResponseCode ServerSocketInterface::cmdAdjustMod(const Command_AdjustMod &cmd, ResponseContainer & /*rc*/) {
|
||||
|
||||
QString userName = QString::fromStdString(cmd.user_name());
|
||||
|
||||
if (cmd.should_be_mod()) {
|
||||
QSqlQuery *query = sqlInterface->prepareQuery(
|
||||
"update {prefix}_users set admin = :adminlevel where name = :username");
|
||||
query->bindValue(":adminlevel", 2);
|
||||
query->bindValue(":username", userName);
|
||||
if (!sqlInterface->execSqlQuery(query)){
|
||||
logger->logMessage(QString::fromStdString("Failed to promote user %1: %2").arg(userName).arg(query->lastError().text()));
|
||||
return Response::RespInternalError;
|
||||
}
|
||||
|
||||
ServerSocketInterface *user = static_cast<ServerSocketInterface *>(server->getUsers().value(userName));
|
||||
if (user) {
|
||||
Event_NotifyUser event;
|
||||
event.set_type(Event_NotifyUser::PROMOTED);
|
||||
SessionEvent *se = user->prepareSessionEvent(event);
|
||||
user->sendProtocolItem(*se);
|
||||
delete se;
|
||||
}
|
||||
} else {
|
||||
QSqlQuery *query = sqlInterface->prepareQuery("update {prefix}_users set admin = :adminlevel where name = :username");
|
||||
query->bindValue(":adminlevel", 0);
|
||||
query->bindValue(":username", userName);
|
||||
if (!sqlInterface->execSqlQuery(query)){
|
||||
logger->logMessage(QString::fromStdString("Failed to demote user %1: %2").arg(userName).arg(query->lastError().text()));
|
||||
return Response::RespInternalError;
|
||||
}
|
||||
|
||||
ServerSocketInterface *user = static_cast<ServerSocketInterface *>(server->getUsers().value(userName));
|
||||
if (user) {
|
||||
Event_ConnectionClosed event;
|
||||
event.set_reason(Event_ConnectionClosed::DEMOTED);
|
||||
event.set_reason_str("Your moderator status has been revoked.");
|
||||
event.set_end_time(QDateTime::currentDateTime().toTime_t());
|
||||
|
||||
SessionEvent *se = user->prepareSessionEvent(event);
|
||||
user->sendProtocolItem(*se);
|
||||
delete se;
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(user, "prepareDestroy", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
return Response::RespOk;
|
||||
}
|
|
@ -100,6 +100,7 @@ private:
|
|||
Response::ResponseCode cmdRegisterAccount(const Command_Register &cmd, ResponseContainer &rc);
|
||||
Response::ResponseCode cmdActivateAccount(const Command_Activate &cmd, ResponseContainer & /* rc */);
|
||||
Response::ResponseCode cmdReloadConfig(const Command_ReloadConfig &/* cmd */, ResponseContainer & /*rc*/);
|
||||
Response::ResponseCode cmdAdjustMod(const Command_AdjustMod &cmd, ResponseContainer & /*rc*/);
|
||||
|
||||
Response::ResponseCode processExtendedSessionCommand(int cmdType, const SessionCommand &cmd, ResponseContainer &rc);
|
||||
Response::ResponseCode processExtendedModeratorCommand(int cmdType, const ModeratorCommand &cmd, ResponseContainer &rc);
|
||||
|
|
Loading…
Reference in a new issue