Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
8d6a4f4f
Commit
8d6a4f4f
authored
Oct 10, 2010
by
Max-Wilhelm Bruker
Browse files
preliminary avatar support
parent
b1d8c7bd
Changes
19
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/tab_server.cpp
View file @
8d6a4f4f
#include
<QLabel>
#include
<QTreeView>
#include
<QTreeView>
#include
<QCheckBox>
#include
<QCheckBox>
#include
<QPushButton>
#include
<QPushButton>
...
@@ -338,12 +339,65 @@ void UserList::userClicked(QTreeWidgetItem *item, int /*column*/)
...
@@ -338,12 +339,65 @@ void UserList::userClicked(QTreeWidgetItem *item, int /*column*/)
emit
openMessageDialog
(
item
->
data
(
2
,
Qt
::
UserRole
).
toString
(),
true
);
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
)
TabServer
::
TabServer
(
AbstractClient
*
_client
,
QWidget
*
parent
)
:
Tab
(
parent
),
client
(
_client
)
:
Tab
(
parent
),
client
(
_client
)
{
{
gameSelector
=
new
GameSelector
(
client
);
gameSelector
=
new
GameSelector
(
client
);
chatChannelSelector
=
new
ChatChannelSelector
(
client
);
chatChannelSelector
=
new
ChatChannelSelector
(
client
);
serverMessageLog
=
new
ServerMessageLog
(
client
);
serverMessageLog
=
new
ServerMessageLog
(
client
);
userInfoBox
=
new
UserInfoBox
(
client
);
userList
=
new
UserList
(
client
);
userList
=
new
UserList
(
client
);
connect
(
gameSelector
,
SIGNAL
(
gameJoined
(
int
)),
this
,
SIGNAL
(
gameJoined
(
int
)));
connect
(
gameSelector
,
SIGNAL
(
gameJoined
(
int
)),
this
,
SIGNAL
(
gameJoined
(
int
)));
...
@@ -359,9 +413,13 @@ TabServer::TabServer(AbstractClient *_client, QWidget *parent)
...
@@ -359,9 +413,13 @@ TabServer::TabServer(AbstractClient *_client, QWidget *parent)
vbox
->
addWidget
(
gameSelector
);
vbox
->
addWidget
(
gameSelector
);
vbox
->
addLayout
(
hbox
);
vbox
->
addLayout
(
hbox
);
QVBoxLayout
*
vbox2
=
new
QVBoxLayout
;
vbox2
->
addWidget
(
userInfoBox
);
vbox2
->
addWidget
(
userList
);
QHBoxLayout
*
mainLayout
=
new
QHBoxLayout
;
QHBoxLayout
*
mainLayout
=
new
QHBoxLayout
;
mainLayout
->
addLayout
(
vbox
,
3
);
mainLayout
->
addLayout
(
vbox
,
3
);
mainLayout
->
add
Widget
(
userList
,
1
);
mainLayout
->
add
Layout
(
vbox2
,
1
);
setLayout
(
mainLayout
);
setLayout
(
mainLayout
);
}
}
...
@@ -371,5 +429,6 @@ void TabServer::retranslateUi()
...
@@ -371,5 +429,6 @@ void TabServer::retranslateUi()
gameSelector
->
retranslateUi
();
gameSelector
->
retranslateUi
();
chatChannelSelector
->
retranslateUi
();
chatChannelSelector
->
retranslateUi
();
serverMessageLog
->
retranslateUi
();
serverMessageLog
->
retranslateUi
();
userInfoBox
->
retranslateUi
();
userList
->
retranslateUi
();
userList
->
retranslateUi
();
}
}
cockatrice/src/tab_server.h
View file @
8d6a4f4f
...
@@ -13,6 +13,7 @@ class QTreeWidgetItem;
...
@@ -13,6 +13,7 @@ class QTreeWidgetItem;
class
QPushButton
;
class
QPushButton
;
class
QCheckBox
;
class
QCheckBox
;
class
QTextEdit
;
class
QTextEdit
;
class
QLabel
;
class
GamesModel
;
class
GamesModel
;
class
GamesProxyModel
;
class
GamesProxyModel
;
...
@@ -101,6 +102,17 @@ public:
...
@@ -101,6 +102,17 @@ public:
void
retranslateUi
();
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
{
class
TabServer
:
public
Tab
{
Q_OBJECT
Q_OBJECT
signals:
signals:
...
@@ -114,6 +126,7 @@ private:
...
@@ -114,6 +126,7 @@ private:
ChatChannelSelector
*
chatChannelSelector
;
ChatChannelSelector
*
chatChannelSelector
;
ServerMessageLog
*
serverMessageLog
;
ServerMessageLog
*
serverMessageLog
;
UserList
*
userList
;
UserList
*
userList
;
UserInfoBox
*
userInfoBox
;
public:
public:
TabServer
(
AbstractClient
*
_client
,
QWidget
*
parent
=
0
);
TabServer
(
AbstractClient
*
_client
,
QWidget
*
parent
=
0
);
void
retranslateUi
();
void
retranslateUi
();
...
...
cockatrice/translations/cockatrice_de.ts
View file @
8d6a4f4f
...
@@ -402,27 +402,27 @@
...
@@ -402,27 +402,27 @@
<
context
>
<
context
>
<
name
>
ChatChannelSelector
<
/name
>
<
name
>
ChatChannelSelector
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
2
"
/>
<
source
>
Chat
channels
<
/source
>
<
source
>
Chat
channels
<
/source
>
<
translation
>
Chaträume
<
/translation
>
<
translation
>
Chaträume
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
2
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
3
"
/>
<
source
>
Joi
&
amp
;
n
<
/source
>
<
source
>
Joi
&
amp
;
n
<
/source
>
<
translation
>
Teil
&
amp
;
nehmen
<
/translation
>
<
translation
>
Teil
&
amp
;
nehmen
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
5
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
6
"
/>
<
source
>
Channel
<
/source
>
<
source
>
Channel
<
/source
>
<
translation
>
Raum
<
/translation
>
<
translation
>
Raum
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
6
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
7
"
/>
<
source
>
Description
<
/source
>
<
source
>
Description
<
/source
>
<
translation
>
Beschreibung
<
/translation
>
<
translation
>
Beschreibung
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
8
"
/>
<
source
>
Players
<
/source
>
<
source
>
Players
<
/source
>
<
translation
>
Spieler
<
/translation
>
<
translation
>
Spieler
<
/translation
>
<
/message
>
<
/message
>
...
@@ -1183,20 +1183,20 @@
...
@@ -1183,20 +1183,20 @@
<
context
>
<
context
>
<
name
>
GameSelector
<
/name
>
<
name
>
GameSelector
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
5
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
6
"
/>
<
source
>
C
&
amp
;
reate
<
/source
>
<
source
>
C
&
amp
;
reate
<
/source
>
<
translation
>
Spiel
e
&
amp
;
rstellen
<
/translation
>
<
translation
>
Spiel
e
&
amp
;
rstellen
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
6
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
7
"
/>
<
source
>&
amp
;
Join
<
/source
>
<
source
>&
amp
;
Join
<
/source
>
<
translation
>&
amp
;
Teilnehmen
<
/translation
>
<
translation
>&
amp
;
Teilnehmen
<
/translation
>
<
/message
>
<
/message
>
<
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
=
"
79
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
80
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
80
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
81
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
81
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
82
"
/>
<
source
>
Error
<
/source
>
<
source
>
Error
<
/source
>
<
translation
>
Fehler
<
/translation
>
<
translation
>
Fehler
<
/translation
>
<
/message
>
<
/message
>
...
@@ -1205,47 +1205,47 @@
...
@@ -1205,47 +1205,47 @@
<
translation
type
=
"
obsolete
"
>
XXX
<
/translation
>
<
translation
type
=
"
obsolete
"
>
XXX
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
7
8
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
7
9
"
/>
<
source
>
Wrong
password
.
<
/source
>
<
source
>
Wrong
password
.
<
/source
>
<
translation
>
Falsches
Passwort
.
<
/translation
>
<
translation
>
Falsches
Passwort
.
<
/translation
>
<
/message
>
<
/message
>
<
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
>
<
source
>
Spectators
are
not
allowed
in
this
game
.
<
/source
>
<
translation
>
In
diesem
Spiel
sind
keine
Zuschauer
zugelassen
.
<
/translation
>
<
translation
>
In
diesem
Spiel
sind
keine
Zuschauer
zugelassen
.
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
0
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
1
"
/>
<
source
>
The
game
is
already
full
.
<
/source
>
<
source
>
The
game
is
already
full
.
<
/source
>
<
translation
>
Das
Spiel
ist
bereits
voll
.
<
/translation
>
<
translation
>
Das
Spiel
ist
bereits
voll
.
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
2
"
/>
<
source
>
The
game
does
not
exist
any
more
.
<
/source
>
<
source
>
The
game
does
not
exist
any
more
.
<
/source
>
<
translation
>
Dieses
Spiel
gibt
es
nicht
mehr
.
<
/translation
>
<
translation
>
Dieses
Spiel
gibt
es
nicht
mehr
.
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
8
"
/>
<
source
>
Join
game
<
/source
>
<
source
>
Join
game
<
/source
>
<
translation
>
Spiel
beitreten
<
/translation
>
<
translation
>
Spiel
beitreten
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
8
"
/>
<
source
>
Password
:
<
/source
>
<
source
>
Password
:
<
/source
>
<
translation
>
Passwort
:
<
/translation
>
<
translation
>
Passwort
:
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
3
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
4
"
/>
<
source
>
Games
<
/source
>
<
source
>
Games
<
/source
>
<
translation
>
Spiele
<
/translation
>
<
translation
>
Spiele
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
4
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
5
"
/>
<
source
>&
amp
;
Show
full
games
<
/source
>
<
source
>&
amp
;
Show
full
games
<
/source
>
<
translation
>&
amp
;
Volle
Spiele
anzeigen
<
/translation
>
<
translation
>&
amp
;
Volle
Spiele
anzeigen
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
8
"
/>
<
source
>
J
&
amp
;
oin
as
spectator
<
/source
>
<
source
>
J
&
amp
;
oin
as
spectator
<
/source
>
<
translation
>&
amp
;
Zuschauen
<
/translation
>
<
translation
>&
amp
;
Zuschauen
<
/translation
>
<
/message
>
<
/message
>
...
@@ -2815,7 +2815,7 @@
...
@@ -2815,7 +2815,7 @@
<
context
>
<
context
>
<
name
>
ServerMessageLog
<
/name
>
<
name
>
ServerMessageLog
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
23
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
23
2
"
/>
<
source
>
Server
messages
<
/source
>
<
source
>
Server
messages
<
/source
>
<
translation
>
Servernachrichten
<
/translation
>
<
translation
>
Servernachrichten
<
/translation
>
<
/message
>
<
/message
>
...
@@ -3066,7 +3066,7 @@ Bitte geben Sie einen Namen ein:</translation>
...
@@ -3066,7 +3066,7 @@ Bitte geben Sie einen Namen ein:</translation>
<
context
>
<
context
>
<
name
>
TabServer
<
/name
>
<
name
>
TabServer
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.h
"
line
=
"
1
20
"
/>
<
location
filename
=
"
../src/tab_server.h
"
line
=
"
1
33
"
/>
<
source
>
Server
<
/source
>
<
source
>
Server
<
/source
>
<
translation
>
Server
<
/translation
>
<
translation
>
Server
<
/translation
>
<
/message
>
<
/message
>
...
@@ -3086,6 +3086,19 @@ Bitte geben Sie einen Namen ein:</translation>
...
@@ -3086,6 +3086,19 @@ Bitte geben Sie einen Namen ein:</translation>
<
translation
type
=
"
obsolete
"
>
Spiel
%
1
<
/translation
>
<
translation
type
=
"
obsolete
"
>
Spiel
%
1
<
/translation
>
<
/message
>
<
/message
>
<
/context
>
<
/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
>
<
context
>
<
name
>
UserInterfaceSettingsPage
<
/name
>
<
name
>
UserInterfaceSettingsPage
<
/name
>
<
message
>
<
message
>
...
@@ -3112,7 +3125,7 @@ Bitte geben Sie einen Namen ein:</translation>
...
@@ -3112,7 +3125,7 @@ Bitte geben Sie einen Namen ein:</translation>
<
context
>
<
context
>
<
name
>
UserList
<
/name
>
<
name
>
UserList
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
28
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
28
2
"
/>
<
source
>
Users
online
:
%
1
<
/source
>
<
source
>
Users
online
:
%
1
<
/source
>
<
translation
>
Benutzer
online
:
%
1
<
/translation
>
<
translation
>
Benutzer
online
:
%
1
<
/translation
>
<
/message
>
<
/message
>
...
...
cockatrice/translations/cockatrice_en.ts
View file @
8d6a4f4f
...
@@ -352,27 +352,27 @@
...
@@ -352,27 +352,27 @@
<
context
>
<
context
>
<
name
>
ChatChannelSelector
<
/name
>
<
name
>
ChatChannelSelector
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
2
"
/>
<
source
>
Chat
channels
<
/source
>
<
source
>
Chat
channels
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
2
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
3
"
/>
<
source
>
Joi
&
amp
;
n
<
/source
>
<
source
>
Joi
&
amp
;
n
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
5
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
6
"
/>
<
source
>
Channel
<
/source
>
<
source
>
Channel
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
6
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
7
"
/>
<
source
>
Description
<
/source
>
<
source
>
Description
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
8
"
/>
<
source
>
Players
<
/source
>
<
source
>
Players
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
...
@@ -790,65 +790,65 @@
...
@@ -790,65 +790,65 @@
<
context
>
<
context
>
<
name
>
GameSelector
<
/name
>
<
name
>
GameSelector
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
5
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
6
"
/>
<
source
>
C
&
amp
;
reate
<
/source
>
<
source
>
C
&
amp
;
reate
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
6
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
7
"
/>
<
source
>&
amp
;
Join
<
/source
>
<
source
>&
amp
;
Join
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
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
=
"
79
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
80
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
80
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
81
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
81
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
82
"
/>
<
source
>
Error
<
/source
>
<
source
>
Error
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
7
8
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
7
9
"
/>
<
source
>
Wrong
password
.
<
/source
>
<
source
>
Wrong
password
.
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
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
>
<
source
>
Spectators
are
not
allowed
in
this
game
.
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
0
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
1
"
/>
<
source
>
The
game
is
already
full
.
<
/source
>
<
source
>
The
game
is
already
full
.
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
2
"
/>
<
source
>
The
game
does
not
exist
any
more
.
<
/source
>
<
source
>
The
game
does
not
exist
any
more
.
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
8
"
/>
<
source
>
Join
game
<
/source
>
<
source
>
Join
game
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
8
"
/>
<
source
>
Password
:
<
/source
>
<
source
>
Password
:
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
3
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
4
"
/>
<
source
>
Games
<
/source
>
<
source
>
Games
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
4
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
5
"
/>
<
source
>&
amp
;
Show
full
games
<
/source
>
<
source
>&
amp
;
Show
full
games
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
8
"
/>
<
source
>
J
&
amp
;
oin
as
spectator
<
/source
>
<
source
>
J
&
amp
;
oin
as
spectator
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
...
@@ -1922,7 +1922,7 @@
...
@@ -1922,7 +1922,7 @@
<
context
>
<
context
>
<
name
>
ServerMessageLog
<
/name
>
<
name
>
ServerMessageLog
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
23
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
23
2
"
/>
<
source
>
Server
messages
<
/source
>
<
source
>
Server
messages
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
...
@@ -2144,11 +2144,24 @@ Please enter a name:</source>
...
@@ -2144,11 +2144,24 @@ Please enter a name:</source>
<
context
>
<
context
>
<
name
>
TabServer
<
/name
>
<
name
>
TabServer
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.h
"
line
=
"
1
20
"
/>
<
location
filename
=
"
../src/tab_server.h
"
line
=
"
1
33
"
/>
<
source
>
Server
<
/source
>
<
source
>
Server
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
<
/context
>
<
/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
>
<
context
>
<
name
>
UserInterfaceSettingsPage
<
/name
>
<
name
>
UserInterfaceSettingsPage
<
/name
>
<
message
>
<
message
>
...
@@ -2175,7 +2188,7 @@ Please enter a name:</source>
...
@@ -2175,7 +2188,7 @@ Please enter a name:</source>
<
context
>
<
context
>
<
name
>
UserList
<
/name
>
<
name
>
UserList
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
28
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
28
2
"
/>
<
source
>
Users
online
:
%
1
<
/source
>
<
source
>
Users
online
:
%
1
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
/message
>
...
...
cockatrice/translations/cockatrice_es.ts
View file @
8d6a4f4f
...
@@ -356,27 +356,27 @@
...
@@ -356,27 +356,27 @@
<
context
>
<
context
>
<
name
>
ChatChannelSelector
<
/name
>
<
name
>
ChatChannelSelector
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
2
"
/>
<
source
>
Chat
channels
<
/source
>
<
source
>
Chat
channels
<
/source
>
<
translation
>
Canales
de
Chat
<
/translation
>
<
translation
>
Canales
de
Chat
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
2
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
3
"
/>
<
source
>
Joi
&
amp
;
n
<
/source
>
<
source
>
Joi
&
amp
;
n
<
/source
>
<
translation
>
E
&
amp
;
ntrar
<
/translation
>
<
translation
>
E
&
amp
;
ntrar
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
5
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
6
"
/>
<
source
>
Channel
<
/source
>
<
source
>
Channel
<
/source
>
<
translation
>
Canal
<
/translation
>
<
translation
>
Canal
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
6
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
7
"
/>
<
source
>
Description
<
/source
>
<
source
>
Description
<
/source
>
<
translation
>
Descripción
<
/translation
>
<
translation
>
Descripción
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
15
8
"
/>
<
source
>
Players
<
/source
>
<
source
>
Players
<
/source
>
<
translation
>
Jugadores
<
/translation
>
<
translation
>
Jugadores
<
/translation
>
<
/message
>
<
/message
>
...
@@ -806,65 +806,65 @@
...
@@ -806,65 +806,65 @@
<
context
>
<
context
>
<
name
>
GameSelector
<
/name
>
<
name
>
GameSelector
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
5
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
6
"
/>
<
source
>
C
&
amp
;
reate
<
/source
>
<
source
>
C
&
amp
;
reate
<
/source
>
<
translation
>
C
&
amp
;
rear
<
/translation
>
<
translation
>
C
&
amp
;
rear
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
6
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
7
"
/>
<
source
>&
amp
;
Join
<
/source
>
<
source
>&
amp
;
Join
<
/source
>
<
translation
>
E
&
amp
;
ntrar
<
/translation
>
<
translation
>
E
&
amp
;
ntrar
<
/translation
>
<
/message
>
<
/message
>
<
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
=
"
79
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
80
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
80
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
81
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
81
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
82
"
/>
<
source
>
Error
<
/source
>
<
source
>
Error
<
/source
>
<
translation
>
Error
<
/translation
>
<
translation
>
Error
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
7
8
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
7
9
"
/>
<
source
>
Wrong
password
.
<
/source
>
<
source
>
Wrong
password
.
<
/source
>
<
translation
>
Contraseña
incorrecta
.
<
/translation
>
<
translation
>
Contraseña
incorrecta
.
<
/translation
>
<
/message
>
<
/message
>
<
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
>
<
source
>
Spectators
are
not
allowed
in
this
game
.
<
/source
>
<
translation
>
No
se
permiten
espectadores
en
esta
partida
.
<
/translation
>
<
translation
>
No
se
permiten
espectadores
en
esta
partida
.
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
0
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
1
"
/>
<
source
>
The
game
is
already
full
.
<
/source
>
<
source
>
The
game
is
already
full
.
<
/source
>
<
translation
>
La
partida
no
tiene
plazas
libres
.
<
/translation
>
<
translation
>
La
partida
no
tiene
plazas
libres
.
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
8
2
"
/>
<
source
>
The
game
does
not
exist
any
more
.
<
/source
>
<
source
>
The
game
does
not
exist
any
more
.
<
/source
>
<
translation
>
La
partida
ya
no
existe
.
<
/translation
>
<
translation
>
La
partida
ya
no
existe
.
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
8
"
/>
<
source
>
Join
game
<
/source
>
<
source
>
Join
game
<
/source
>
<
translation
>
Entrar
en
la
partida
<
/translation
>
<
translation
>
Entrar
en
la
partida
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
9
8
"
/>
<
source
>
Password
:
<
/source
>
<
source
>
Password
:
<
/source
>
<
translation
>
Contraseña
:
<
/translation
>
<
translation
>
Contraseña
:
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
3
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
4
"
/>
<
source
>
Games
<
/source
>
<
source
>
Games
<
/source
>
<
translation
>
Partidas
<
/translation
>
<
translation
>
Partidas
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
4
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
5
"
/>
<
source
>&
amp
;
Show
full
games
<
/source
>
<
source
>&
amp
;
Show
full
games
<
/source
>
<
translation
>&
amp
;
Ver
partidas
sin
plazas
libres
<
/translation
>
<
translation
>&
amp
;
Ver
partidas
sin
plazas
libres
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
7
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
11
8
"
/>
<
source
>
J
&
amp
;
oin
as
spectator
<
/source
>
<
source
>
J
&
amp
;
oin
as
spectator
<
/source
>
<
translation
>
Entrar
como
e
&
amp
;
spectador
<
/translation
>
<
translation
>
Entrar
como
e
&
amp
;
spectador
<
/translation
>
<
/message
>
<
/message
>
...
@@ -1950,7 +1950,7 @@
...
@@ -1950,7 +1950,7 @@
<
context
>
<
context
>
<
name
>
ServerMessageLog
<
/name
>
<
name
>
ServerMessageLog
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
23
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
23
2
"
/>
<
source
>
Server
messages
<
/source
>
<
source
>
Server
messages
<
/source
>
<
translation
>
Mensajes
del
servidor
<
/translation
>
<
translation
>
Mensajes
del
servidor
<
/translation
>
<
/message
>
<
/message
>
...
@@ -2173,11 +2173,24 @@ Por favor, introduzca un nombre:</translation>
...
@@ -2173,11 +2173,24 @@ Por favor, introduzca un nombre:</translation>
<
context
>
<
context
>
<
name
>
TabServer
<
/name
>
<
name
>
TabServer
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.h
"
line
=
"
1
20
"
/>
<
location
filename
=
"
../src/tab_server.h
"
line
=
"
1
33
"
/>
<
source
>
Server
<
/source
>
<
source
>
Server
<
/source
>
<
translation
>
Servidor
<
/translation
>
<
translation
>
Servidor
<
/translation
>
<
/message
>
<
/message
>
<
/context
>
<
/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
>
<
context
>
<
name
>
UserInterfaceSettingsPage
<
/name
>
<
name
>
UserInterfaceSettingsPage
<
/name
>
<
message
>
<
message
>
...
@@ -2204,7 +2217,7 @@ Por favor, introduzca un nombre:</translation>
...
@@ -2204,7 +2217,7 @@ Por favor, introduzca un nombre:</translation>
<
context
>
<
context
>
<
name
>
UserList
<
/name
>
<
name
>
UserList
<
/name
>
<
message
>
<
message
>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
28
1
"
/>
<
location
filename
=
"
../src/tab_server.cpp
"
line
=
"
28
2
"
/>
<
source
>
Users
online
:
%
1
<
/source
>
<
source
>
Users
online
:
%
1
<
/source
>
<
translation
>
Usuarios
online
:
%
1
<
/translation
>
<
translation
>
Usuarios
online
:
%
1
<
/translation
>
<
/message
>
<
/message
>
...
...
common/protocol.cpp
View file @
8d6a4f4f
...
@@ -38,6 +38,7 @@ void ProtocolItem::initializeHash()
...
@@ -38,6 +38,7 @@ void ProtocolItem::initializeHash()
registerSerializableItem
(
"resp"
,
ProtocolResponse
::
newItem
);
registerSerializableItem
(
"resp"
,
ProtocolResponse
::
newItem
);
ProtocolResponse
::
initializeHash
();
ProtocolResponse
::
initializeHash
();
registerSerializableItem
(
"resplist_users"
,
Response_ListUsers
::
newItem
);
registerSerializableItem
(
"resplist_users"
,
Response_ListUsers
::
newItem
);
registerSerializableItem
(
"respget_user_info"
,
Response_GetUserInfo
::
newItem
);
registerSerializableItem
(
"respdeck_list"
,
Response_DeckList
::
newItem
);
registerSerializableItem
(
"respdeck_list"
,
Response_DeckList
::
newItem
);
registerSerializableItem
(
"respdeck_download"
,
Response_DeckDownload
::
newItem
);
registerSerializableItem
(
"respdeck_download"
,
Response_DeckDownload
::
newItem
);
registerSerializableItem
(
"respdeck_upload"
,
Response_DeckUpload
::
newItem
);
registerSerializableItem
(
"respdeck_upload"
,
Response_DeckUpload
::
newItem
);
...
@@ -232,6 +233,14 @@ Response_DeckList::Response_DeckList(int _cmdId, ResponseCode _responseCode, Dec
...
@@ -232,6 +233,14 @@ Response_DeckList::Response_DeckList(int _cmdId, ResponseCode _responseCode, Dec
insertItem
(
_root
);
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
)
Response_DeckDownload
::
Response_DeckDownload
(
int
_cmdId
,
ResponseCode
_responseCode
,
DeckList
*
_deck
)
:
ProtocolResponse
(
_cmdId
,
_responseCode
,
"deck_download"
)
:
ProtocolResponse
(
_cmdId
,
_responseCode
,
"deck_download"
)
{
{
...
...
common/protocol.h
View file @
8d6a4f4f
...
@@ -38,10 +38,11 @@ enum ItemId {
...
@@ -38,10 +38,11 @@ enum ItemId {
ItemId_Event_Join
=
ItemId_Other
+
210
,
ItemId_Event_Join
=
ItemId_Other
+
210
,
ItemId_Event_Ping
=
ItemId_Other
+
211
,
ItemId_Event_Ping
=
ItemId_Other
+
211
,
ItemId_Response_ListUsers
=
ItemId_Other
+
300
,
ItemId_Response_ListUsers
=
ItemId_Other
+
300
,
ItemId_Response_DeckList
=
ItemId_Other
+
301
,
ItemId_Response_GetUserInfo
=
ItemId_Other
+
301
,
ItemId_Response_DeckDownload
=
ItemId_Other
+
302
,
ItemId_Response_DeckList
=
ItemId_Other
+
302
,
ItemId_Response_DeckUpload
=
ItemId_Other
+
303
,
ItemId_Response_DeckDownload
=
ItemId_Other
+
303
,
ItemId_Response_DumpZone
=
ItemId_Other
+
304
,
ItemId_Response_DeckUpload
=
ItemId_Other
+
304
,
ItemId_Response_DumpZone
=
ItemId_Other
+
305
,
ItemId_Invalid
=
ItemId_Other
+
1000
ItemId_Invalid
=
ItemId_Other
+
1000
};
};
...
@@ -210,6 +211,15 @@ public:
...
@@ -210,6 +211,15 @@ public:
QList
<
ServerInfo_User
*>
getUserList
()
const
{
return
typecastItemList
<
ServerInfo_User
*>
();
}
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
{
class
Response_DeckList
:
public
ProtocolResponse
{
Q_OBJECT
Q_OBJECT
public:
public:
...
...
common/protocol_datastructures.cpp
View file @
8d6a4f4f
...
@@ -12,12 +12,13 @@ ServerInfo_ChatChannel::ServerInfo_ChatChannel(const QString &_name, const QStri
...
@@ -12,12 +12,13 @@ ServerInfo_ChatChannel::ServerInfo_ChatChannel(const QString &_name, const QStri
insertItem
(
new
SerializableItem_Bool
(
"auto_join"
,
_autoJoin
));
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"
)
:
SerializableItem_Map
(
"user"
)
{
{
insertItem
(
new
SerializableItem_String
(
"name"
,
_name
));
insertItem
(
new
SerializableItem_String
(
"name"
,
_name
));
insertItem
(
new
SerializableItem_Int
(
"userlevel"
,
_userLevel
));
insertItem
(
new
SerializableItem_Int
(
"userlevel"
,
_userLevel
));
insertItem
(
new
SerializableItem_String
(
"country"
,
_country
));
insertItem
(
new
SerializableItem_String
(
"country"
,
_country
));
insertItem
(
new
SerializableItem_ByteArray
(
"avatar_bmp"
,
_avatarBmp
));
}
}
ServerInfo_User
::
ServerInfo_User
(
const
ServerInfo_User
*
other
)
ServerInfo_User
::
ServerInfo_User
(
const
ServerInfo_User
*
other
)
...
@@ -26,6 +27,7 @@ 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_String
(
"name"
,
other
->
getName
()));
insertItem
(
new
SerializableItem_Int
(
"userlevel"
,
other
->
getUserLevel
()));
insertItem
(
new
SerializableItem_Int
(
"userlevel"
,
other
->
getUserLevel
()));
insertItem
(
new
SerializableItem_String
(
"country"
,
other
->
getCountry
()));
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
)
ServerInfo_Game
::
ServerInfo_Game
(
int
_gameId
,
const
QString
&
_description
,
bool
_hasPassword
,
int
_playerCount
,
int
_maxPlayers
,
ServerInfo_User
*
_creatorInfo
,
bool
_spectatorsAllowed
,
bool
_spectatorsNeedPassword
,
int
_spectatorCount
)
...
...
common/protocol_datastructures.h
View file @
8d6a4f4f
...
@@ -39,13 +39,14 @@ public:
...
@@ -39,13 +39,14 @@ public:
IsJudge
=
0x04
,
IsJudge
=
0x04
,
IsAdmin
=
0x08
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
);
ServerInfo_User
(
const
ServerInfo_User
*
other
);
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_User
;
}
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_User
;
}
QString
getName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"name"
))
->
getData
();
}
QString
getName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"name"
))
->
getData
();
}
int
getUserLevel
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"userlevel"
))
->
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
);
}
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
();
}
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
{
class
ServerInfo_Game
:
public
SerializableItem_Map
{
...
...
common/protocol_item_ids.h
View file @
8d6a4f4f
...
@@ -2,71 +2,72 @@ enum AutoItemId {
...
@@ -2,71 +2,72 @@ enum AutoItemId {
ItemId_Command_Ping
=
1001
,
ItemId_Command_Ping
=
1001
,
ItemId_Command_Login
=
1002
,
ItemId_Command_Login
=
1002
,
ItemId_Command_Message
=
1003
,
ItemId_Command_Message
=
1003
,
ItemId_Command_DeckList
=
1004
,
ItemId_Command_GetUserInfo
=
1004
,
ItemId_Command_DeckNewDir
=
1005
,
ItemId_Command_DeckList
=
1005
,
ItemId_Command_DeckDelDir
=
1006
,
ItemId_Command_DeckNewDir
=
1006
,
ItemId_Command_DeckDel
=
1007
,
ItemId_Command_DeckDelDir
=
1007
,
ItemId_Command_DeckDownload
=
1008
,
ItemId_Command_DeckDel
=
1008
,
ItemId_Command_ListChatChannels
=
1009
,
ItemId_Command_DeckDownload
=
1009
,
ItemId_Command_ChatJoinChannel
=
1010
,
ItemId_Command_ListChatChannels
=
1010
,
ItemId_Command_ChatLeaveChannel
=
1011
,
ItemId_Command_ChatJoinChannel
=
1011
,
ItemId_Command_ChatSay
=
1012
,
ItemId_Command_ChatLeaveChannel
=
1012
,
ItemId_Command_ListGames
=
1013
,
ItemId_Command_ChatSay
=
1013
,
ItemId_Command_ListUsers
=
1014
,
ItemId_Command_ListGames
=
1014
,
ItemId_Command_CreateGame
=
1015
,
ItemId_Command_ListUsers
=
1015
,
ItemId_Command_JoinGame
=
1016
,
ItemId_Command_CreateGame
=
1016
,
ItemId_Command_LeaveGame
=
1017
,
ItemId_Command_JoinGame
=
1017
,
ItemId_Command_Say
=
1018
,
ItemId_Command_LeaveGame
=
1018
,
ItemId_Command_Shuffle
=
1019
,
ItemId_Command_Say
=
1019
,
ItemId_Command_Mulligan
=
1020
,
ItemId_Command_Shuffle
=
1020
,
ItemId_Command_RollDie
=
1021
,
ItemId_Command_Mulligan
=
1021
,
ItemId_Command_DrawCards
=
1022
,
ItemId_Command_RollDie
=
1022
,
ItemId_Command_MoveCard
=
1023
,
ItemId_Command_DrawCards
=
1023
,
ItemId_Command_FlipCard
=
1024
,
ItemId_Command_MoveCard
=
1024
,
ItemId_Command_AttachCard
=
1025
,
ItemId_Command_FlipCard
=
1025
,
ItemId_Command_CreateToken
=
1026
,
ItemId_Command_AttachCard
=
1026
,
ItemId_Command_CreateArrow
=
1027
,
ItemId_Command_CreateToken
=
1027
,
ItemId_Command_DeleteArrow
=
1028
,
ItemId_Command_CreateArrow
=
1028
,
ItemId_Command_SetCardAttr
=
1029
,
ItemId_Command_DeleteArrow
=
1029
,
ItemId_Command_SetCardCounter
=
1030
,
ItemId_Command_SetCardAttr
=
1030
,
ItemId_Command_IncCardCounter
=
1031
,
ItemId_Command_SetCardCounter
=
1031
,
ItemId_Command_ReadyStart
=
1032
,
ItemId_Command_IncCardCounter
=
1032
,
ItemId_Command_Concede
=
1033
,
ItemId_Command_ReadyStart
=
1033
,
ItemId_Command_IncCounter
=
1034
,
ItemId_Command_Concede
=
1034
,
ItemId_Command_CreateCounter
=
1035
,
ItemId_Command_IncCounter
=
1035
,
ItemId_Command_SetCounter
=
1036
,
ItemId_Command_CreateCounter
=
1036
,
ItemId_Command_DelCounter
=
1037
,
ItemId_Command_SetCounter
=
1037
,
ItemId_Command_NextTurn
=
1038
,
ItemId_Command_DelCounter
=
1038
,
ItemId_Command_SetActivePhase
=
1039
,
ItemId_Command_NextTurn
=
1039
,
ItemId_Command_DumpZone
=
1040
,
ItemId_Command_SetActivePhase
=
1040
,
ItemId_Command_StopDumpZone
=
1041
,
ItemId_Command_DumpZone
=
1041
,
ItemId_Event_Say
=
1042
,
ItemId_Command_StopDumpZone
=
1042
,
ItemId_Event_Leave
=
1043
,
ItemId_Event_Say
=
1043
,
ItemId_Event_GameClosed
=
1044
,
ItemId_Event_Leave
=
1044
,
ItemId_Event_Shuffle
=
1045
,
ItemId_Event_GameClosed
=
1045
,
ItemId_Event_RollDie
=
1046
,
ItemId_Event_Shuffle
=
1046
,
ItemId_Event_MoveCard
=
1047
,
ItemId_Event_RollDie
=
1047
,
ItemId_Event_FlipCard
=
1048
,
ItemId_Event_MoveCard
=
1048
,
ItemId_Event_DestroyCard
=
1049
,
ItemId_Event_FlipCard
=
1049
,
ItemId_Event_AttachCard
=
1050
,
ItemId_Event_DestroyCard
=
1050
,
ItemId_Event_CreateToken
=
1051
,
ItemId_Event_AttachCard
=
1051
,
ItemId_Event_DeleteArrow
=
1052
,
ItemId_Event_CreateToken
=
1052
,
ItemId_Event_SetCardAttr
=
1053
,
ItemId_Event_DeleteArrow
=
1053
,
ItemId_Event_SetCardCounter
=
1054
,
ItemId_Event_SetCardAttr
=
1054
,
ItemId_Event_SetCounter
=
1055
,
ItemId_Event_SetCardCounter
=
1055
,
ItemId_Event_DelCounter
=
1056
,
ItemId_Event_SetCounter
=
1056
,
ItemId_Event_SetActivePlayer
=
1057
,
ItemId_Event_DelCounter
=
1057
,
ItemId_Event_SetActivePhase
=
1058
,
ItemId_Event_SetActivePlayer
=
1058
,
ItemId_Event_DumpZone
=
1059
,
ItemId_Event_SetActivePhase
=
1059
,
ItemId_Event_StopDumpZone
=
1060
,
ItemId_Event_DumpZone
=
1060
,
ItemId_Event_ServerMessage
=
1061
,
ItemId_Event_StopDumpZone
=
1061
,
ItemId_Event_Message
=
1062
,
ItemId_Event_ServerMessage
=
1062
,
ItemId_Event_GameJoined
=
1063
,
ItemId_Event_Message
=
1063
,
ItemId_Event_UserLeft
=
1064
,
ItemId_Event_GameJoined
=
1064
,
ItemId_Event_ChatLeaveChannel
=
1065
,
ItemId_Event_UserLeft
=
1065
,
ItemId_Event_ChatSay
=
1066
,
ItemId_Event_ChatLeaveChannel
=
1066
,
ItemId_Context_ReadyStart
=
1067
,
ItemId_Event_ChatSay
=
1067
,
ItemId_Context_Concede
=
1068
,
ItemId_Context_ReadyStart
=
1068
,
ItemId_Context_DeckSelect
=
1069
,
ItemId_Context_Concede
=
1069
,
ItemId_Other
=
1070
ItemId_Context_DeckSelect
=
1070
,
ItemId_Other
=
1071
};
};
common/protocol_items.cpp
View file @
8d6a4f4f
...
@@ -17,6 +17,11 @@ Command_Message::Command_Message(const QString &_userName, const QString &_text)
...
@@ -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
(
"user_name"
,
_userName
));
insertItem
(
new
SerializableItem_String
(
"text"
,
_text
));
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_DeckList
::
Command_DeckList
()
:
Command
(
"deck_list"
)
:
Command
(
"deck_list"
)
{
{
...
@@ -432,6 +437,7 @@ void ProtocolItem::initializeHashAuto()
...
@@ -432,6 +437,7 @@ void ProtocolItem::initializeHashAuto()
itemNameHash
.
insert
(
"cmdping"
,
Command_Ping
::
newItem
);
itemNameHash
.
insert
(
"cmdping"
,
Command_Ping
::
newItem
);
itemNameHash
.
insert
(
"cmdlogin"
,
Command_Login
::
newItem
);
itemNameHash
.
insert
(
"cmdlogin"
,
Command_Login
::
newItem
);
itemNameHash
.
insert
(
"cmdmessage"
,
Command_Message
::
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_list"
,
Command_DeckList
::
newItem
);
itemNameHash
.
insert
(
"cmddeck_new_dir"
,
Command_DeckNewDir
::
newItem
);
itemNameHash
.
insert
(
"cmddeck_new_dir"
,
Command_DeckNewDir
::
newItem
);
itemNameHash
.
insert
(
"cmddeck_del_dir"
,
Command_DeckDelDir
::
newItem
);
itemNameHash
.
insert
(
"cmddeck_del_dir"
,
Command_DeckDelDir
::
newItem
);
...
...
common/protocol_items.dat
View file @
8d6a4f4f
0:ping
0:ping
0:login:s,username:s,password
0:login:s,username:s,password
0:message:s,user_name:s,text
0:message:s,user_name:s,text
0:get_user_info:s,user_name
0:deck_list
0:deck_list
0:deck_new_dir:s,path:s,dir_name
0:deck_new_dir:s,path:s,dir_name
0:deck_del_dir:s,path
0:deck_del_dir:s,path
...
...
common/protocol_items.h
View file @
8d6a4f4f
...
@@ -28,6 +28,14 @@ public:
...
@@ -28,6 +28,14 @@ public:
static
SerializableItem
*
newItem
()
{
return
new
Command_Message
;
}
static
SerializableItem
*
newItem
()
{
return
new
Command_Message
;
}
int
getItemId
()
const
{
return
ItemId_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
{
class
Command_DeckList
:
public
Command
{
Q_OBJECT
Q_OBJECT
public:
public:
...
...
common/serializable_item.cpp
View file @
8d6a4f4f
...
@@ -145,3 +145,16 @@ void SerializableItem_DateTime::writeElement(QXmlStreamWriter *xml)
...
@@ -145,3 +145,16 @@ void SerializableItem_DateTime::writeElement(QXmlStreamWriter *xml)
{
{
xml
->
writeCharacters
(
QString
::
number
(
data
.
toTime_t
()));
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
()));
}
common/serializable_item.h
View file @
8d6a4f4f
...
@@ -121,7 +121,7 @@ public:
...
@@ -121,7 +121,7 @@ public:
const
Color
&
getData
()
{
return
data
;
}
const
Color
&
getData
()
{
return
data
;
}
void
setData
(
const
Color
&
_data
)
{
data
=
_data
;
}
void
setData
(
const
Color
&
_data
)
{
data
=
_data
;
}
};
};
class
SerializableItem_DateTime
:
public
SerializableItem
{
class
SerializableItem_DateTime
:
public
SerializableItem
{
private:
private:
QDateTime
data
;
QDateTime
data
;
...
@@ -135,4 +135,17 @@ public:
...
@@ -135,4 +135,17 @@ public:
void
setData
(
const
QDateTime
&
_data
)
{
data
=
_data
;
}
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
#endif
common/server.cpp
View file @
8d6a4f4f
...
@@ -56,8 +56,6 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
...
@@ -56,8 +56,6 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
}
}
ServerInfo_User
*
data
=
getUserData
(
name
);
ServerInfo_User
*
data
=
getUserData
(
name
);
if
(
authState
==
PasswordRight
)
data
->
setUserLevel
(
data
->
getUserLevel
()
|
ServerInfo_User
::
IsRegistered
);
session
->
setUserInfo
(
data
);
session
->
setUserInfo
(
data
);
users
.
insert
(
name
,
session
);
users
.
insert
(
name
,
session
);
...
...
common/server_protocolhandler.cpp
View file @
8d6a4f4f
...
@@ -123,6 +123,7 @@ ResponseCode Server_ProtocolHandler::processCommandHelper(Command *command, Comm
...
@@ -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_DeckDel
:
return
cmdDeckDel
(
qobject_cast
<
Command_DeckDel
*>
(
command
),
cont
);
case
ItemId_Command_DeckUpload
:
return
cmdDeckUpload
(
qobject_cast
<
Command_DeckUpload
*>
(
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_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_ListChatChannels
:
return
cmdListChatChannels
(
qobject_cast
<
Command_ListChatChannels
*>
(
command
),
cont
);
case
ItemId_Command_ChatJoinChannel
:
return
cmdChatJoinChannel
(
qobject_cast
<
Command_ChatJoinChannel
*>
(
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
);
case
ItemId_Command_ListUsers
:
return
cmdListUsers
(
qobject_cast
<
Command_ListUsers
*>
(
command
),
cont
);
...
@@ -246,6 +247,25 @@ ResponseCode Server_ProtocolHandler::cmdMessage(Command_Message *cmd, CommandCon
...
@@ -246,6 +247,25 @@ ResponseCode Server_ProtocolHandler::cmdMessage(Command_Message *cmd, CommandCon
return
RespOk
;
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
)
ResponseCode
Server_ProtocolHandler
::
cmdListChatChannels
(
Command_ListChatChannels
*
/*cmd*/
,
CommandContainer
*
cont
)
{
{
if
(
authState
==
PasswordWrong
)
if
(
authState
==
PasswordWrong
)
...
...
common/server_protocolhandler.h
View file @
8d6a4f4f
...
@@ -44,6 +44,7 @@ private:
...
@@ -44,6 +44,7 @@ private:
virtual
ResponseCode
cmdDeckDel
(
Command_DeckDel
*
cmd
,
CommandContainer
*
cont
)
=
0
;
virtual
ResponseCode
cmdDeckDel
(
Command_DeckDel
*
cmd
,
CommandContainer
*
cont
)
=
0
;
virtual
ResponseCode
cmdDeckUpload
(
Command_DeckUpload
*
cmd
,
CommandContainer
*
cont
)
=
0
;
virtual
ResponseCode
cmdDeckUpload
(
Command_DeckUpload
*
cmd
,
CommandContainer
*
cont
)
=
0
;
virtual
ResponseCode
cmdDeckDownload
(
Command_DeckDownload
*
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
cmdListChatChannels
(
Command_ListChatChannels
*
cmd
,
CommandContainer
*
cont
);
ResponseCode
cmdChatJoinChannel
(
Command_ChatJoinChannel
*
cmd
,
CommandContainer
*
cont
);
ResponseCode
cmdChatJoinChannel
(
Command_ChatJoinChannel
*
cmd
,
CommandContainer
*
cont
);
ResponseCode
cmdChatLeaveChannel
(
Command_ChatLeaveChannel
*
cmd
,
CommandContainer
*
cont
,
Server_ChatChannel
*
channel
);
ResponseCode
cmdChatLeaveChannel
(
Command_ChatLeaveChannel
*
cmd
,
CommandContainer
*
cont
,
Server_ChatChannel
*
channel
);
...
...
servatrice/src/servatrice.cpp
View file @
8d6a4f4f
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include
<QtSql>
#include
<QtSql>
#include
<QSettings>
#include
<QSettings>
#include
<QDebug>
#include
<QDebug>
#include
<iostream>
#include
"servatrice.h"
#include
"servatrice.h"
#include
"server_chatchannel.h"
#include
"server_chatchannel.h"
#include
"serversocketinterface.h"
#include
"serversocketinterface.h"
...
@@ -79,8 +80,12 @@ bool Servatrice::openDatabase()
...
@@ -79,8 +80,12 @@ bool Servatrice::openDatabase()
sqldb
.
setPassword
(
settings
->
value
(
"password"
).
toString
());
sqldb
.
setPassword
(
settings
->
value
(
"password"
).
toString
());
settings
->
endGroup
();
settings
->
endGroup
();
if
(
!
sqldb
.
open
())
std
::
cerr
<<
"Opening database..."
;
if
(
!
sqldb
.
open
())
{
std
::
cerr
<<
"error"
<<
std
::
endl
;
return
false
;
return
false
;
}
std
::
cerr
<<
"OK"
<<
std
::
endl
;
if
(
!
nextGameId
)
{
if
(
!
nextGameId
)
{
QSqlQuery
query
;
QSqlQuery
query
;
...
@@ -124,7 +129,7 @@ AuthenticationResult Servatrice::checkUserPassword(const QString &user, const QS
...
@@ -124,7 +129,7 @@ AuthenticationResult Servatrice::checkUserPassword(const QString &user, const QS
checkSql
();
checkSql
();
QSqlQuery
query
;
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
);
query
.
bindValue
(
":name"
,
user
);
if
(
!
execSqlQuery
(
query
))
if
(
!
execSqlQuery
(
query
))
return
PasswordWrong
;
return
PasswordWrong
;
...
@@ -147,7 +152,7 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
...
@@ -147,7 +152,7 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
checkSql
();
checkSql
();
QSqlQuery
query
;
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
);
query
.
bindValue
(
":name"
,
name
);
if
(
!
execSqlQuery
(
query
))
if
(
!
execSqlQuery
(
query
))
return
new
ServerInfo_User
(
name
);
return
new
ServerInfo_User
(
name
);
...
@@ -155,15 +160,17 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
...
@@ -155,15 +160,17 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
if
(
query
.
next
())
{
if
(
query
.
next
())
{
bool
is_admin
=
query
.
value
(
0
).
toInt
();
bool
is_admin
=
query
.
value
(
0
).
toInt
();
QString
country
=
query
.
value
(
1
).
toString
();
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
)
if
(
is_admin
)
userLevel
|=
ServerInfo_User
::
IsAdmin
;
userLevel
|=
ServerInfo_User
::
IsAdmin
;
return
new
ServerInfo_User
(
return
new
ServerInfo_User
(
name
,
name
,
userLevel
,
userLevel
,
country
country
,
avatarBmp
);
);
}
else
}
else
return
new
ServerInfo_User
(
name
);
return
new
ServerInfo_User
(
name
);
...
@@ -171,4 +178,4 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
...
@@ -171,4 +178,4 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
return
new
ServerInfo_User
(
name
);
return
new
ServerInfo_User
(
name
);
}
}
const
QString
Servatrice
::
versionString
=
"Servatrice 0.201009
18
"
;
const
QString
Servatrice
::
versionString
=
"Servatrice 0.2010
10
09"
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment