preliminary avatar support
This commit is contained in:
parent
b1d8c7bda0
commit
8d6a4f4f90
19 changed files with 344 additions and 143 deletions
|
@ -1,3 +1,4 @@
|
|||
#include <QLabel>
|
||||
#include <QTreeView>
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
|
@ -338,12 +339,65 @@ void UserList::userClicked(QTreeWidgetItem *item, int /*column*/)
|
|||
emit openMessageDialog(item->data(2, Qt::UserRole).toString(), true);
|
||||
}
|
||||
|
||||
UserInfoBox::UserInfoBox(AbstractClient *_client, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
avatarLabel = new QLabel;
|
||||
nameLabel = new QLabel;
|
||||
QFont nameFont = nameLabel->font();
|
||||
nameFont.setBold(true);
|
||||
nameFont.setPointSize(nameFont.pointSize() * 1.5);
|
||||
nameLabel->setFont(nameFont);
|
||||
countryLabel1 = new QLabel;
|
||||
countryLabel2 = new QLabel;
|
||||
userLevelLabel1 = new QLabel;
|
||||
userLevelLabel2 = new QLabel;
|
||||
|
||||
QGridLayout *mainLayout = new QGridLayout;
|
||||
mainLayout->addWidget(avatarLabel, 0, 0, 3, 1);
|
||||
mainLayout->addWidget(nameLabel, 0, 1, 1, 2);
|
||||
mainLayout->addWidget(countryLabel1, 1, 1, 1, 1);
|
||||
mainLayout->addWidget(countryLabel2, 1, 2, 1, 1);
|
||||
mainLayout->addWidget(userLevelLabel1, 2, 1, 1, 1);
|
||||
mainLayout->addWidget(userLevelLabel2, 2, 2, 1, 1);
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
Command_GetUserInfo *cmd = new Command_GetUserInfo;
|
||||
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(processResponse(ProtocolResponse *)));
|
||||
_client->sendCommand(cmd);
|
||||
}
|
||||
|
||||
void UserInfoBox::retranslateUi()
|
||||
{
|
||||
countryLabel1->setText(tr("Location:"));
|
||||
userLevelLabel1->setText(tr("User level:"));
|
||||
}
|
||||
|
||||
void UserInfoBox::processResponse(ProtocolResponse *response)
|
||||
{
|
||||
Response_GetUserInfo *resp = qobject_cast<Response_GetUserInfo *>(response);
|
||||
if (!resp)
|
||||
return;
|
||||
ServerInfo_User *user = resp->getUserInfo();
|
||||
|
||||
QPixmap avatarPixmap;
|
||||
if (!avatarPixmap.loadFromData(user->getAvatarBmp()))
|
||||
avatarPixmap = UserLevelPixmapGenerator::generatePixmap(64, user->getUserLevel());
|
||||
avatarLabel->setPixmap(avatarPixmap);
|
||||
|
||||
nameLabel->setText(user->getName());
|
||||
countryLabel2->setPixmap(CountryPixmapGenerator::generatePixmap(15, user->getCountry()));
|
||||
userLevelLabel2->setPixmap(UserLevelPixmapGenerator::generatePixmap(15, user->getUserLevel()));
|
||||
}
|
||||
|
||||
TabServer::TabServer(AbstractClient *_client, QWidget *parent)
|
||||
: Tab(parent), client(_client)
|
||||
{
|
||||
gameSelector = new GameSelector(client);
|
||||
chatChannelSelector = new ChatChannelSelector(client);
|
||||
serverMessageLog = new ServerMessageLog(client);
|
||||
userInfoBox = new UserInfoBox(client);
|
||||
userList = new UserList(client);
|
||||
|
||||
connect(gameSelector, SIGNAL(gameJoined(int)), this, SIGNAL(gameJoined(int)));
|
||||
|
@ -359,9 +413,13 @@ TabServer::TabServer(AbstractClient *_client, QWidget *parent)
|
|||
vbox->addWidget(gameSelector);
|
||||
vbox->addLayout(hbox);
|
||||
|
||||
QVBoxLayout *vbox2 = new QVBoxLayout;
|
||||
vbox2->addWidget(userInfoBox);
|
||||
vbox2->addWidget(userList);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->addLayout(vbox, 3);
|
||||
mainLayout->addWidget(userList, 1);
|
||||
mainLayout->addLayout(vbox2, 1);
|
||||
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
@ -371,5 +429,6 @@ void TabServer::retranslateUi()
|
|||
gameSelector->retranslateUi();
|
||||
chatChannelSelector->retranslateUi();
|
||||
serverMessageLog->retranslateUi();
|
||||
userInfoBox->retranslateUi();
|
||||
userList->retranslateUi();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ class QTreeWidgetItem;
|
|||
class QPushButton;
|
||||
class QCheckBox;
|
||||
class QTextEdit;
|
||||
class QLabel;
|
||||
|
||||
class GamesModel;
|
||||
class GamesProxyModel;
|
||||
|
@ -101,6 +102,17 @@ public:
|
|||
void retranslateUi();
|
||||
};
|
||||
|
||||
class UserInfoBox : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
QLabel *avatarLabel, *nameLabel, *countryLabel1, *countryLabel2, *userLevelLabel1, *userLevelLabel2;
|
||||
private slots:
|
||||
void processResponse(ProtocolResponse *response);
|
||||
public:
|
||||
UserInfoBox(AbstractClient *_client, QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
};
|
||||
|
||||
class TabServer : public Tab {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
|
@ -114,6 +126,7 @@ private:
|
|||
ChatChannelSelector *chatChannelSelector;
|
||||
ServerMessageLog *serverMessageLog;
|
||||
UserList *userList;
|
||||
UserInfoBox *userInfoBox;
|
||||
public:
|
||||
TabServer(AbstractClient *_client, QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
|
|
|
@ -402,27 +402,27 @@
|
|||
<context>
|
||||
<name>ChatChannelSelector</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="151"/>
|
||||
<location filename="../src/tab_server.cpp" line="152"/>
|
||||
<source>Chat channels</source>
|
||||
<translation>Chaträume</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="152"/>
|
||||
<location filename="../src/tab_server.cpp" line="153"/>
|
||||
<source>Joi&n</source>
|
||||
<translation>Teil&nehmen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="155"/>
|
||||
<location filename="../src/tab_server.cpp" line="156"/>
|
||||
<source>Channel</source>
|
||||
<translation>Raum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="156"/>
|
||||
<location filename="../src/tab_server.cpp" line="157"/>
|
||||
<source>Description</source>
|
||||
<translation>Beschreibung</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="157"/>
|
||||
<location filename="../src/tab_server.cpp" line="158"/>
|
||||
<source>Players</source>
|
||||
<translation>Spieler</translation>
|
||||
</message>
|
||||
|
@ -1183,20 +1183,20 @@
|
|||
<context>
|
||||
<name>GameSelector</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="115"/>
|
||||
<location filename="../src/tab_server.cpp" line="116"/>
|
||||
<source>C&reate</source>
|
||||
<translation>Spiel e&rstellen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="116"/>
|
||||
<location filename="../src/tab_server.cpp" line="117"/>
|
||||
<source>&Join</source>
|
||||
<translation>&Teilnehmen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="78"/>
|
||||
<location filename="../src/tab_server.cpp" line="79"/>
|
||||
<location filename="../src/tab_server.cpp" line="80"/>
|
||||
<location filename="../src/tab_server.cpp" line="81"/>
|
||||
<location filename="../src/tab_server.cpp" line="82"/>
|
||||
<source>Error</source>
|
||||
<translation>Fehler</translation>
|
||||
</message>
|
||||
|
@ -1205,47 +1205,47 @@
|
|||
<translation type="obsolete">XXX</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="78"/>
|
||||
<location filename="../src/tab_server.cpp" line="79"/>
|
||||
<source>Wrong password.</source>
|
||||
<translation>Falsches Passwort.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="79"/>
|
||||
<location filename="../src/tab_server.cpp" line="80"/>
|
||||
<source>Spectators are not allowed in this game.</source>
|
||||
<translation>In diesem Spiel sind keine Zuschauer zugelassen.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="80"/>
|
||||
<location filename="../src/tab_server.cpp" line="81"/>
|
||||
<source>The game is already full.</source>
|
||||
<translation>Das Spiel ist bereits voll.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="81"/>
|
||||
<location filename="../src/tab_server.cpp" line="82"/>
|
||||
<source>The game does not exist any more.</source>
|
||||
<translation>Dieses Spiel gibt es nicht mehr.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="97"/>
|
||||
<location filename="../src/tab_server.cpp" line="98"/>
|
||||
<source>Join game</source>
|
||||
<translation>Spiel beitreten</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="97"/>
|
||||
<location filename="../src/tab_server.cpp" line="98"/>
|
||||
<source>Password:</source>
|
||||
<translation>Passwort:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="113"/>
|
||||
<location filename="../src/tab_server.cpp" line="114"/>
|
||||
<source>Games</source>
|
||||
<translation>Spiele</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="114"/>
|
||||
<location filename="../src/tab_server.cpp" line="115"/>
|
||||
<source>&Show full games</source>
|
||||
<translation>&Volle Spiele anzeigen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="117"/>
|
||||
<location filename="../src/tab_server.cpp" line="118"/>
|
||||
<source>J&oin as spectator</source>
|
||||
<translation>&Zuschauen</translation>
|
||||
</message>
|
||||
|
@ -2815,7 +2815,7 @@
|
|||
<context>
|
||||
<name>ServerMessageLog</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="231"/>
|
||||
<location filename="../src/tab_server.cpp" line="232"/>
|
||||
<source>Server messages</source>
|
||||
<translation>Servernachrichten</translation>
|
||||
</message>
|
||||
|
@ -3066,7 +3066,7 @@ Bitte geben Sie einen Namen ein:</translation>
|
|||
<context>
|
||||
<name>TabServer</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.h" line="120"/>
|
||||
<location filename="../src/tab_server.h" line="133"/>
|
||||
<source>Server</source>
|
||||
<translation>Server</translation>
|
||||
</message>
|
||||
|
@ -3086,6 +3086,19 @@ Bitte geben Sie einen Namen ein:</translation>
|
|||
<translation type="obsolete">Spiel %1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>UserInfoBox</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="373"/>
|
||||
<source>Location:</source>
|
||||
<translation>Ort:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="374"/>
|
||||
<source>User level:</source>
|
||||
<translation>Nutzerstatus:</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>UserInterfaceSettingsPage</name>
|
||||
<message>
|
||||
|
@ -3112,7 +3125,7 @@ Bitte geben Sie einen Namen ein:</translation>
|
|||
<context>
|
||||
<name>UserList</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="281"/>
|
||||
<location filename="../src/tab_server.cpp" line="282"/>
|
||||
<source>Users online: %1</source>
|
||||
<translation>Benutzer online: %1</translation>
|
||||
</message>
|
||||
|
|
|
@ -352,27 +352,27 @@
|
|||
<context>
|
||||
<name>ChatChannelSelector</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="151"/>
|
||||
<location filename="../src/tab_server.cpp" line="152"/>
|
||||
<source>Chat channels</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="152"/>
|
||||
<location filename="../src/tab_server.cpp" line="153"/>
|
||||
<source>Joi&n</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="155"/>
|
||||
<location filename="../src/tab_server.cpp" line="156"/>
|
||||
<source>Channel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="156"/>
|
||||
<location filename="../src/tab_server.cpp" line="157"/>
|
||||
<source>Description</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="157"/>
|
||||
<location filename="../src/tab_server.cpp" line="158"/>
|
||||
<source>Players</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -790,65 +790,65 @@
|
|||
<context>
|
||||
<name>GameSelector</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="115"/>
|
||||
<location filename="../src/tab_server.cpp" line="116"/>
|
||||
<source>C&reate</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="116"/>
|
||||
<location filename="../src/tab_server.cpp" line="117"/>
|
||||
<source>&Join</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="78"/>
|
||||
<location filename="../src/tab_server.cpp" line="79"/>
|
||||
<location filename="../src/tab_server.cpp" line="80"/>
|
||||
<location filename="../src/tab_server.cpp" line="81"/>
|
||||
<location filename="../src/tab_server.cpp" line="82"/>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="78"/>
|
||||
<location filename="../src/tab_server.cpp" line="79"/>
|
||||
<source>Wrong password.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="79"/>
|
||||
<location filename="../src/tab_server.cpp" line="80"/>
|
||||
<source>Spectators are not allowed in this game.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="80"/>
|
||||
<location filename="../src/tab_server.cpp" line="81"/>
|
||||
<source>The game is already full.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="81"/>
|
||||
<location filename="../src/tab_server.cpp" line="82"/>
|
||||
<source>The game does not exist any more.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="97"/>
|
||||
<location filename="../src/tab_server.cpp" line="98"/>
|
||||
<source>Join game</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="97"/>
|
||||
<location filename="../src/tab_server.cpp" line="98"/>
|
||||
<source>Password:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="113"/>
|
||||
<location filename="../src/tab_server.cpp" line="114"/>
|
||||
<source>Games</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="114"/>
|
||||
<location filename="../src/tab_server.cpp" line="115"/>
|
||||
<source>&Show full games</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="117"/>
|
||||
<location filename="../src/tab_server.cpp" line="118"/>
|
||||
<source>J&oin as spectator</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -1922,7 +1922,7 @@
|
|||
<context>
|
||||
<name>ServerMessageLog</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="231"/>
|
||||
<location filename="../src/tab_server.cpp" line="232"/>
|
||||
<source>Server messages</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -2144,11 +2144,24 @@ Please enter a name:</source>
|
|||
<context>
|
||||
<name>TabServer</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.h" line="120"/>
|
||||
<location filename="../src/tab_server.h" line="133"/>
|
||||
<source>Server</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>UserInfoBox</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="373"/>
|
||||
<source>Location:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="374"/>
|
||||
<source>User level:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>UserInterfaceSettingsPage</name>
|
||||
<message>
|
||||
|
@ -2175,7 +2188,7 @@ Please enter a name:</source>
|
|||
<context>
|
||||
<name>UserList</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="281"/>
|
||||
<location filename="../src/tab_server.cpp" line="282"/>
|
||||
<source>Users online: %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -356,27 +356,27 @@
|
|||
<context>
|
||||
<name>ChatChannelSelector</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="151"/>
|
||||
<location filename="../src/tab_server.cpp" line="152"/>
|
||||
<source>Chat channels</source>
|
||||
<translation>Canales de Chat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="152"/>
|
||||
<location filename="../src/tab_server.cpp" line="153"/>
|
||||
<source>Joi&n</source>
|
||||
<translation>E&ntrar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="155"/>
|
||||
<location filename="../src/tab_server.cpp" line="156"/>
|
||||
<source>Channel</source>
|
||||
<translation>Canal</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="156"/>
|
||||
<location filename="../src/tab_server.cpp" line="157"/>
|
||||
<source>Description</source>
|
||||
<translation>Descripción</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="157"/>
|
||||
<location filename="../src/tab_server.cpp" line="158"/>
|
||||
<source>Players</source>
|
||||
<translation>Jugadores</translation>
|
||||
</message>
|
||||
|
@ -806,65 +806,65 @@
|
|||
<context>
|
||||
<name>GameSelector</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="115"/>
|
||||
<location filename="../src/tab_server.cpp" line="116"/>
|
||||
<source>C&reate</source>
|
||||
<translation>C&rear</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="116"/>
|
||||
<location filename="../src/tab_server.cpp" line="117"/>
|
||||
<source>&Join</source>
|
||||
<translation>E&ntrar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="78"/>
|
||||
<location filename="../src/tab_server.cpp" line="79"/>
|
||||
<location filename="../src/tab_server.cpp" line="80"/>
|
||||
<location filename="../src/tab_server.cpp" line="81"/>
|
||||
<location filename="../src/tab_server.cpp" line="82"/>
|
||||
<source>Error</source>
|
||||
<translation>Error</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="78"/>
|
||||
<location filename="../src/tab_server.cpp" line="79"/>
|
||||
<source>Wrong password.</source>
|
||||
<translation>Contraseña incorrecta.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="79"/>
|
||||
<location filename="../src/tab_server.cpp" line="80"/>
|
||||
<source>Spectators are not allowed in this game.</source>
|
||||
<translation>No se permiten espectadores en esta partida.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="80"/>
|
||||
<location filename="../src/tab_server.cpp" line="81"/>
|
||||
<source>The game is already full.</source>
|
||||
<translation>La partida no tiene plazas libres.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="81"/>
|
||||
<location filename="../src/tab_server.cpp" line="82"/>
|
||||
<source>The game does not exist any more.</source>
|
||||
<translation>La partida ya no existe.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="97"/>
|
||||
<location filename="../src/tab_server.cpp" line="98"/>
|
||||
<source>Join game</source>
|
||||
<translation>Entrar en la partida</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="97"/>
|
||||
<location filename="../src/tab_server.cpp" line="98"/>
|
||||
<source>Password:</source>
|
||||
<translation>Contraseña:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="113"/>
|
||||
<location filename="../src/tab_server.cpp" line="114"/>
|
||||
<source>Games</source>
|
||||
<translation>Partidas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="114"/>
|
||||
<location filename="../src/tab_server.cpp" line="115"/>
|
||||
<source>&Show full games</source>
|
||||
<translation>&Ver partidas sin plazas libres</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="117"/>
|
||||
<location filename="../src/tab_server.cpp" line="118"/>
|
||||
<source>J&oin as spectator</source>
|
||||
<translation>Entrar como e&spectador</translation>
|
||||
</message>
|
||||
|
@ -1950,7 +1950,7 @@
|
|||
<context>
|
||||
<name>ServerMessageLog</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="231"/>
|
||||
<location filename="../src/tab_server.cpp" line="232"/>
|
||||
<source>Server messages</source>
|
||||
<translation>Mensajes del servidor</translation>
|
||||
</message>
|
||||
|
@ -2173,11 +2173,24 @@ Por favor, introduzca un nombre:</translation>
|
|||
<context>
|
||||
<name>TabServer</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.h" line="120"/>
|
||||
<location filename="../src/tab_server.h" line="133"/>
|
||||
<source>Server</source>
|
||||
<translation>Servidor</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>UserInfoBox</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="373"/>
|
||||
<source>Location:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="374"/>
|
||||
<source>User level:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>UserInterfaceSettingsPage</name>
|
||||
<message>
|
||||
|
@ -2204,7 +2217,7 @@ Por favor, introduzca un nombre:</translation>
|
|||
<context>
|
||||
<name>UserList</name>
|
||||
<message>
|
||||
<location filename="../src/tab_server.cpp" line="281"/>
|
||||
<location filename="../src/tab_server.cpp" line="282"/>
|
||||
<source>Users online: %1</source>
|
||||
<translation>Usuarios online: %1</translation>
|
||||
</message>
|
||||
|
|
|
@ -38,6 +38,7 @@ void ProtocolItem::initializeHash()
|
|||
registerSerializableItem("resp", ProtocolResponse::newItem);
|
||||
ProtocolResponse::initializeHash();
|
||||
registerSerializableItem("resplist_users", Response_ListUsers::newItem);
|
||||
registerSerializableItem("respget_user_info", Response_GetUserInfo::newItem);
|
||||
registerSerializableItem("respdeck_list", Response_DeckList::newItem);
|
||||
registerSerializableItem("respdeck_download", Response_DeckDownload::newItem);
|
||||
registerSerializableItem("respdeck_upload", Response_DeckUpload::newItem);
|
||||
|
@ -232,6 +233,14 @@ Response_DeckList::Response_DeckList(int _cmdId, ResponseCode _responseCode, Dec
|
|||
insertItem(_root);
|
||||
}
|
||||
|
||||
Response_GetUserInfo::Response_GetUserInfo(int _cmdId, ResponseCode _responseCode, ServerInfo_User *_user)
|
||||
: ProtocolResponse(_cmdId, _responseCode, "get_user_info")
|
||||
{
|
||||
if (!_user)
|
||||
_user = new ServerInfo_User;
|
||||
insertItem(_user);
|
||||
}
|
||||
|
||||
Response_DeckDownload::Response_DeckDownload(int _cmdId, ResponseCode _responseCode, DeckList *_deck)
|
||||
: ProtocolResponse(_cmdId, _responseCode, "deck_download")
|
||||
{
|
||||
|
|
|
@ -38,10 +38,11 @@ enum ItemId {
|
|||
ItemId_Event_Join = ItemId_Other + 210,
|
||||
ItemId_Event_Ping = ItemId_Other + 211,
|
||||
ItemId_Response_ListUsers = ItemId_Other + 300,
|
||||
ItemId_Response_DeckList = ItemId_Other + 301,
|
||||
ItemId_Response_DeckDownload = ItemId_Other + 302,
|
||||
ItemId_Response_DeckUpload = ItemId_Other + 303,
|
||||
ItemId_Response_DumpZone = ItemId_Other + 304,
|
||||
ItemId_Response_GetUserInfo = ItemId_Other + 301,
|
||||
ItemId_Response_DeckList = ItemId_Other + 302,
|
||||
ItemId_Response_DeckDownload = ItemId_Other + 303,
|
||||
ItemId_Response_DeckUpload = ItemId_Other + 304,
|
||||
ItemId_Response_DumpZone = ItemId_Other + 305,
|
||||
ItemId_Invalid = ItemId_Other + 1000
|
||||
};
|
||||
|
||||
|
@ -210,6 +211,15 @@ public:
|
|||
QList<ServerInfo_User *> getUserList() const { return typecastItemList<ServerInfo_User *>(); }
|
||||
};
|
||||
|
||||
class Response_GetUserInfo : public ProtocolResponse {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Response_GetUserInfo(int _cmdId = -1, ResponseCode _responseCode = RespOk, ServerInfo_User *_userInfo = 0);
|
||||
int getItemId() const { return ItemId_Response_GetUserInfo; }
|
||||
static SerializableItem *newItem() { return new Response_GetUserInfo; }
|
||||
ServerInfo_User *getUserInfo() const { return static_cast<ServerInfo_User *>(itemMap.value("user")); }
|
||||
};
|
||||
|
||||
class Response_DeckList : public ProtocolResponse {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -12,12 +12,13 @@ ServerInfo_ChatChannel::ServerInfo_ChatChannel(const QString &_name, const QStri
|
|||
insertItem(new SerializableItem_Bool("auto_join", _autoJoin));
|
||||
}
|
||||
|
||||
ServerInfo_User::ServerInfo_User(const QString &_name, int _userLevel, const QString &_country)
|
||||
ServerInfo_User::ServerInfo_User(const QString &_name, int _userLevel, const QString &_country, const QByteArray &_avatarBmp)
|
||||
: SerializableItem_Map("user")
|
||||
{
|
||||
insertItem(new SerializableItem_String("name", _name));
|
||||
insertItem(new SerializableItem_Int("userlevel", _userLevel));
|
||||
insertItem(new SerializableItem_String("country", _country));
|
||||
insertItem(new SerializableItem_ByteArray("avatar_bmp", _avatarBmp));
|
||||
}
|
||||
|
||||
ServerInfo_User::ServerInfo_User(const ServerInfo_User *other)
|
||||
|
@ -26,6 +27,7 @@ ServerInfo_User::ServerInfo_User(const ServerInfo_User *other)
|
|||
insertItem(new SerializableItem_String("name", other->getName()));
|
||||
insertItem(new SerializableItem_Int("userlevel", other->getUserLevel()));
|
||||
insertItem(new SerializableItem_String("country", other->getCountry()));
|
||||
insertItem(new SerializableItem_ByteArray("avatar_bmp", other->getAvatarBmp()));
|
||||
}
|
||||
|
||||
ServerInfo_Game::ServerInfo_Game(int _gameId, const QString &_description, bool _hasPassword, int _playerCount, int _maxPlayers, ServerInfo_User *_creatorInfo, bool _spectatorsAllowed, bool _spectatorsNeedPassword, int _spectatorCount)
|
||||
|
|
|
@ -39,13 +39,14 @@ public:
|
|||
IsJudge = 0x04,
|
||||
IsAdmin = 0x08
|
||||
};
|
||||
ServerInfo_User(const QString &_name = QString(), int _userLevel = IsNothing, const QString &_country = QString());
|
||||
ServerInfo_User(const QString &_name = QString(), int _userLevel = IsNothing, const QString &_country = QString(), const QByteArray &_avatarBmp = QByteArray());
|
||||
ServerInfo_User(const ServerInfo_User *other);
|
||||
static SerializableItem *newItem() { return new ServerInfo_User; }
|
||||
QString getName() const { return static_cast<SerializableItem_String *>(itemMap.value("name"))->getData(); }
|
||||
int getUserLevel() const { return static_cast<SerializableItem_Int *>(itemMap.value("userlevel"))->getData(); }
|
||||
void setUserLevel(int _userLevel) { static_cast<SerializableItem_Int *>(itemMap.value("userlevel"))->setData(_userLevel); }
|
||||
QString getCountry() const { return static_cast<SerializableItem_String *>(itemMap.value("country"))->getData(); }
|
||||
QByteArray getAvatarBmp() const { return static_cast<SerializableItem_ByteArray *>(itemMap.value("avatar_bmp"))->getData(); }
|
||||
};
|
||||
|
||||
class ServerInfo_Game : public SerializableItem_Map {
|
||||
|
|
|
@ -2,71 +2,72 @@ enum AutoItemId {
|
|||
ItemId_Command_Ping = 1001,
|
||||
ItemId_Command_Login = 1002,
|
||||
ItemId_Command_Message = 1003,
|
||||
ItemId_Command_DeckList = 1004,
|
||||
ItemId_Command_DeckNewDir = 1005,
|
||||
ItemId_Command_DeckDelDir = 1006,
|
||||
ItemId_Command_DeckDel = 1007,
|
||||
ItemId_Command_DeckDownload = 1008,
|
||||
ItemId_Command_ListChatChannels = 1009,
|
||||
ItemId_Command_ChatJoinChannel = 1010,
|
||||
ItemId_Command_ChatLeaveChannel = 1011,
|
||||
ItemId_Command_ChatSay = 1012,
|
||||
ItemId_Command_ListGames = 1013,
|
||||
ItemId_Command_ListUsers = 1014,
|
||||
ItemId_Command_CreateGame = 1015,
|
||||
ItemId_Command_JoinGame = 1016,
|
||||
ItemId_Command_LeaveGame = 1017,
|
||||
ItemId_Command_Say = 1018,
|
||||
ItemId_Command_Shuffle = 1019,
|
||||
ItemId_Command_Mulligan = 1020,
|
||||
ItemId_Command_RollDie = 1021,
|
||||
ItemId_Command_DrawCards = 1022,
|
||||
ItemId_Command_MoveCard = 1023,
|
||||
ItemId_Command_FlipCard = 1024,
|
||||
ItemId_Command_AttachCard = 1025,
|
||||
ItemId_Command_CreateToken = 1026,
|
||||
ItemId_Command_CreateArrow = 1027,
|
||||
ItemId_Command_DeleteArrow = 1028,
|
||||
ItemId_Command_SetCardAttr = 1029,
|
||||
ItemId_Command_SetCardCounter = 1030,
|
||||
ItemId_Command_IncCardCounter = 1031,
|
||||
ItemId_Command_ReadyStart = 1032,
|
||||
ItemId_Command_Concede = 1033,
|
||||
ItemId_Command_IncCounter = 1034,
|
||||
ItemId_Command_CreateCounter = 1035,
|
||||
ItemId_Command_SetCounter = 1036,
|
||||
ItemId_Command_DelCounter = 1037,
|
||||
ItemId_Command_NextTurn = 1038,
|
||||
ItemId_Command_SetActivePhase = 1039,
|
||||
ItemId_Command_DumpZone = 1040,
|
||||
ItemId_Command_StopDumpZone = 1041,
|
||||
ItemId_Event_Say = 1042,
|
||||
ItemId_Event_Leave = 1043,
|
||||
ItemId_Event_GameClosed = 1044,
|
||||
ItemId_Event_Shuffle = 1045,
|
||||
ItemId_Event_RollDie = 1046,
|
||||
ItemId_Event_MoveCard = 1047,
|
||||
ItemId_Event_FlipCard = 1048,
|
||||
ItemId_Event_DestroyCard = 1049,
|
||||
ItemId_Event_AttachCard = 1050,
|
||||
ItemId_Event_CreateToken = 1051,
|
||||
ItemId_Event_DeleteArrow = 1052,
|
||||
ItemId_Event_SetCardAttr = 1053,
|
||||
ItemId_Event_SetCardCounter = 1054,
|
||||
ItemId_Event_SetCounter = 1055,
|
||||
ItemId_Event_DelCounter = 1056,
|
||||
ItemId_Event_SetActivePlayer = 1057,
|
||||
ItemId_Event_SetActivePhase = 1058,
|
||||
ItemId_Event_DumpZone = 1059,
|
||||
ItemId_Event_StopDumpZone = 1060,
|
||||
ItemId_Event_ServerMessage = 1061,
|
||||
ItemId_Event_Message = 1062,
|
||||
ItemId_Event_GameJoined = 1063,
|
||||
ItemId_Event_UserLeft = 1064,
|
||||
ItemId_Event_ChatLeaveChannel = 1065,
|
||||
ItemId_Event_ChatSay = 1066,
|
||||
ItemId_Context_ReadyStart = 1067,
|
||||
ItemId_Context_Concede = 1068,
|
||||
ItemId_Context_DeckSelect = 1069,
|
||||
ItemId_Other = 1070
|
||||
ItemId_Command_GetUserInfo = 1004,
|
||||
ItemId_Command_DeckList = 1005,
|
||||
ItemId_Command_DeckNewDir = 1006,
|
||||
ItemId_Command_DeckDelDir = 1007,
|
||||
ItemId_Command_DeckDel = 1008,
|
||||
ItemId_Command_DeckDownload = 1009,
|
||||
ItemId_Command_ListChatChannels = 1010,
|
||||
ItemId_Command_ChatJoinChannel = 1011,
|
||||
ItemId_Command_ChatLeaveChannel = 1012,
|
||||
ItemId_Command_ChatSay = 1013,
|
||||
ItemId_Command_ListGames = 1014,
|
||||
ItemId_Command_ListUsers = 1015,
|
||||
ItemId_Command_CreateGame = 1016,
|
||||
ItemId_Command_JoinGame = 1017,
|
||||
ItemId_Command_LeaveGame = 1018,
|
||||
ItemId_Command_Say = 1019,
|
||||
ItemId_Command_Shuffle = 1020,
|
||||
ItemId_Command_Mulligan = 1021,
|
||||
ItemId_Command_RollDie = 1022,
|
||||
ItemId_Command_DrawCards = 1023,
|
||||
ItemId_Command_MoveCard = 1024,
|
||||
ItemId_Command_FlipCard = 1025,
|
||||
ItemId_Command_AttachCard = 1026,
|
||||
ItemId_Command_CreateToken = 1027,
|
||||
ItemId_Command_CreateArrow = 1028,
|
||||
ItemId_Command_DeleteArrow = 1029,
|
||||
ItemId_Command_SetCardAttr = 1030,
|
||||
ItemId_Command_SetCardCounter = 1031,
|
||||
ItemId_Command_IncCardCounter = 1032,
|
||||
ItemId_Command_ReadyStart = 1033,
|
||||
ItemId_Command_Concede = 1034,
|
||||
ItemId_Command_IncCounter = 1035,
|
||||
ItemId_Command_CreateCounter = 1036,
|
||||
ItemId_Command_SetCounter = 1037,
|
||||
ItemId_Command_DelCounter = 1038,
|
||||
ItemId_Command_NextTurn = 1039,
|
||||
ItemId_Command_SetActivePhase = 1040,
|
||||
ItemId_Command_DumpZone = 1041,
|
||||
ItemId_Command_StopDumpZone = 1042,
|
||||
ItemId_Event_Say = 1043,
|
||||
ItemId_Event_Leave = 1044,
|
||||
ItemId_Event_GameClosed = 1045,
|
||||
ItemId_Event_Shuffle = 1046,
|
||||
ItemId_Event_RollDie = 1047,
|
||||
ItemId_Event_MoveCard = 1048,
|
||||
ItemId_Event_FlipCard = 1049,
|
||||
ItemId_Event_DestroyCard = 1050,
|
||||
ItemId_Event_AttachCard = 1051,
|
||||
ItemId_Event_CreateToken = 1052,
|
||||
ItemId_Event_DeleteArrow = 1053,
|
||||
ItemId_Event_SetCardAttr = 1054,
|
||||
ItemId_Event_SetCardCounter = 1055,
|
||||
ItemId_Event_SetCounter = 1056,
|
||||
ItemId_Event_DelCounter = 1057,
|
||||
ItemId_Event_SetActivePlayer = 1058,
|
||||
ItemId_Event_SetActivePhase = 1059,
|
||||
ItemId_Event_DumpZone = 1060,
|
||||
ItemId_Event_StopDumpZone = 1061,
|
||||
ItemId_Event_ServerMessage = 1062,
|
||||
ItemId_Event_Message = 1063,
|
||||
ItemId_Event_GameJoined = 1064,
|
||||
ItemId_Event_UserLeft = 1065,
|
||||
ItemId_Event_ChatLeaveChannel = 1066,
|
||||
ItemId_Event_ChatSay = 1067,
|
||||
ItemId_Context_ReadyStart = 1068,
|
||||
ItemId_Context_Concede = 1069,
|
||||
ItemId_Context_DeckSelect = 1070,
|
||||
ItemId_Other = 1071
|
||||
};
|
||||
|
|
|
@ -17,6 +17,11 @@ Command_Message::Command_Message(const QString &_userName, const QString &_text)
|
|||
insertItem(new SerializableItem_String("user_name", _userName));
|
||||
insertItem(new SerializableItem_String("text", _text));
|
||||
}
|
||||
Command_GetUserInfo::Command_GetUserInfo(const QString &_userName)
|
||||
: Command("get_user_info")
|
||||
{
|
||||
insertItem(new SerializableItem_String("user_name", _userName));
|
||||
}
|
||||
Command_DeckList::Command_DeckList()
|
||||
: Command("deck_list")
|
||||
{
|
||||
|
@ -432,6 +437,7 @@ void ProtocolItem::initializeHashAuto()
|
|||
itemNameHash.insert("cmdping", Command_Ping::newItem);
|
||||
itemNameHash.insert("cmdlogin", Command_Login::newItem);
|
||||
itemNameHash.insert("cmdmessage", Command_Message::newItem);
|
||||
itemNameHash.insert("cmdget_user_info", Command_GetUserInfo::newItem);
|
||||
itemNameHash.insert("cmddeck_list", Command_DeckList::newItem);
|
||||
itemNameHash.insert("cmddeck_new_dir", Command_DeckNewDir::newItem);
|
||||
itemNameHash.insert("cmddeck_del_dir", Command_DeckDelDir::newItem);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
0:ping
|
||||
0:login:s,username:s,password
|
||||
0:message:s,user_name:s,text
|
||||
0:get_user_info:s,user_name
|
||||
0:deck_list
|
||||
0:deck_new_dir:s,path:s,dir_name
|
||||
0:deck_del_dir:s,path
|
||||
|
|
|
@ -28,6 +28,14 @@ public:
|
|||
static SerializableItem *newItem() { return new Command_Message; }
|
||||
int getItemId() const { return ItemId_Command_Message; }
|
||||
};
|
||||
class Command_GetUserInfo : public Command {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Command_GetUserInfo(const QString &_userName = QString());
|
||||
QString getUserName() const { return static_cast<SerializableItem_String *>(itemMap.value("user_name"))->getData(); };
|
||||
static SerializableItem *newItem() { return new Command_GetUserInfo; }
|
||||
int getItemId() const { return ItemId_Command_GetUserInfo; }
|
||||
};
|
||||
class Command_DeckList : public Command {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -145,3 +145,16 @@ void SerializableItem_DateTime::writeElement(QXmlStreamWriter *xml)
|
|||
{
|
||||
xml->writeCharacters(QString::number(data.toTime_t()));
|
||||
}
|
||||
|
||||
bool SerializableItem_ByteArray::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isCharacters() && !xml->isWhitespace())
|
||||
data = qUncompress(QByteArray::fromBase64(xml->text().toString().toAscii()));
|
||||
|
||||
return SerializableItem::readElement(xml);
|
||||
}
|
||||
|
||||
void SerializableItem_ByteArray::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeCharacters(QString(qCompress(data).toBase64()));
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
const Color &getData() { return data; }
|
||||
void setData(const Color &_data) { data = _data; }
|
||||
};
|
||||
|
||||
|
||||
class SerializableItem_DateTime : public SerializableItem {
|
||||
private:
|
||||
QDateTime data;
|
||||
|
@ -135,4 +135,17 @@ public:
|
|||
void setData(const QDateTime &_data) { data = _data; }
|
||||
};
|
||||
|
||||
class SerializableItem_ByteArray : public SerializableItem {
|
||||
private:
|
||||
QByteArray data;
|
||||
protected:
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
public:
|
||||
SerializableItem_ByteArray(const QString &_itemType, const QByteArray &_data)
|
||||
: SerializableItem(_itemType), data(_data) { }
|
||||
const QByteArray &getData() { return data; }
|
||||
void setData(const QByteArray &_data) { data = _data; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -56,8 +56,6 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
}
|
||||
|
||||
ServerInfo_User *data = getUserData(name);
|
||||
if (authState == PasswordRight)
|
||||
data->setUserLevel(data->getUserLevel() | ServerInfo_User::IsRegistered);
|
||||
session->setUserInfo(data);
|
||||
|
||||
users.insert(name, session);
|
||||
|
|
|
@ -123,6 +123,7 @@ ResponseCode Server_ProtocolHandler::processCommandHelper(Command *command, Comm
|
|||
case ItemId_Command_DeckDel: return cmdDeckDel(qobject_cast<Command_DeckDel *>(command), cont);
|
||||
case ItemId_Command_DeckUpload: return cmdDeckUpload(qobject_cast<Command_DeckUpload *>(command), cont);
|
||||
case ItemId_Command_DeckDownload: return cmdDeckDownload(qobject_cast<Command_DeckDownload *>(command), cont);
|
||||
case ItemId_Command_GetUserInfo: return cmdGetUserInfo(qobject_cast<Command_GetUserInfo *>(command), cont);
|
||||
case ItemId_Command_ListChatChannels: return cmdListChatChannels(qobject_cast<Command_ListChatChannels *>(command), cont);
|
||||
case ItemId_Command_ChatJoinChannel: return cmdChatJoinChannel(qobject_cast<Command_ChatJoinChannel *>(command), cont);
|
||||
case ItemId_Command_ListUsers: return cmdListUsers(qobject_cast<Command_ListUsers *>(command), cont);
|
||||
|
@ -246,6 +247,25 @@ ResponseCode Server_ProtocolHandler::cmdMessage(Command_Message *cmd, CommandCon
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdGetUserInfo(Command_GetUserInfo *cmd, CommandContainer *cont)
|
||||
{
|
||||
if (authState == PasswordWrong)
|
||||
return RespLoginNeeded;
|
||||
|
||||
ServerInfo_User *result;
|
||||
if (cmd->getUserName().isEmpty())
|
||||
result = new ServerInfo_User(userInfo);
|
||||
else {
|
||||
Server_ProtocolHandler *handler = server->getUsers().value(cmd->getUserName());
|
||||
if (!handler)
|
||||
return RespNameNotFound;
|
||||
result = handler->getUserInfo();
|
||||
}
|
||||
|
||||
cont->setResponse(new Response_GetUserInfo(cont->getCmdId(), RespOk, result));
|
||||
return RespNothing;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdListChatChannels(Command_ListChatChannels * /*cmd*/, CommandContainer *cont)
|
||||
{
|
||||
if (authState == PasswordWrong)
|
||||
|
|
|
@ -44,6 +44,7 @@ private:
|
|||
virtual ResponseCode cmdDeckDel(Command_DeckDel *cmd, CommandContainer *cont) = 0;
|
||||
virtual ResponseCode cmdDeckUpload(Command_DeckUpload *cmd, CommandContainer *cont) = 0;
|
||||
virtual ResponseCode cmdDeckDownload(Command_DeckDownload *cmd, CommandContainer *cont) = 0;
|
||||
ResponseCode cmdGetUserInfo(Command_GetUserInfo *cmd, CommandContainer *cont);
|
||||
ResponseCode cmdListChatChannels(Command_ListChatChannels *cmd, CommandContainer *cont);
|
||||
ResponseCode cmdChatJoinChannel(Command_ChatJoinChannel *cmd, CommandContainer *cont);
|
||||
ResponseCode cmdChatLeaveChannel(Command_ChatLeaveChannel *cmd, CommandContainer *cont, Server_ChatChannel *channel);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <QtSql>
|
||||
#include <QSettings>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include "servatrice.h"
|
||||
#include "server_chatchannel.h"
|
||||
#include "serversocketinterface.h"
|
||||
|
@ -79,8 +80,12 @@ bool Servatrice::openDatabase()
|
|||
sqldb.setPassword(settings->value("password").toString());
|
||||
settings->endGroup();
|
||||
|
||||
if (!sqldb.open())
|
||||
std::cerr << "Opening database...";
|
||||
if (!sqldb.open()) {
|
||||
std::cerr << "error" << std::endl;
|
||||
return false;
|
||||
}
|
||||
std::cerr << "OK" << std::endl;
|
||||
|
||||
if (!nextGameId) {
|
||||
QSqlQuery query;
|
||||
|
@ -124,7 +129,7 @@ AuthenticationResult Servatrice::checkUserPassword(const QString &user, const QS
|
|||
checkSql();
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("select password from users where name = :name");
|
||||
query.prepare("select password from users where name = :name and active = 1");
|
||||
query.bindValue(":name", user);
|
||||
if (!execSqlQuery(query))
|
||||
return PasswordWrong;
|
||||
|
@ -147,7 +152,7 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
|
|||
checkSql();
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("select admin, country from users where name = :name");
|
||||
query.prepare("select admin, country, avatar_bmp from users where name = :name and active = 1");
|
||||
query.bindValue(":name", name);
|
||||
if (!execSqlQuery(query))
|
||||
return new ServerInfo_User(name);
|
||||
|
@ -155,15 +160,17 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
|
|||
if (query.next()) {
|
||||
bool is_admin = query.value(0).toInt();
|
||||
QString country = query.value(1).toString();
|
||||
QByteArray avatarBmp = query.value(2).toByteArray();
|
||||
|
||||
int userLevel = ServerInfo_User::IsUser;
|
||||
int userLevel = ServerInfo_User::IsUser | ServerInfo_User::IsRegistered;
|
||||
if (is_admin)
|
||||
userLevel |= ServerInfo_User::IsAdmin;
|
||||
|
||||
return new ServerInfo_User(
|
||||
name,
|
||||
userLevel,
|
||||
country
|
||||
country,
|
||||
avatarBmp
|
||||
);
|
||||
} else
|
||||
return new ServerInfo_User(name);
|
||||
|
@ -171,4 +178,4 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
|
|||
return new ServerInfo_User(name);
|
||||
}
|
||||
|
||||
const QString Servatrice::versionString = "Servatrice 0.20100918";
|
||||
const QString Servatrice::versionString = "Servatrice 0.20101009";
|
||||
|
|
Loading…
Reference in a new issue