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
59da62d2
Commit
59da62d2
authored
Sep 13, 2015
by
Zach
Browse files
Merge pull request #1502 from woogerboy21/fix_ban_crash
Fix server crash on banning
parents
d5afd97f
46f78fce
Changes
4
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/user_context_menu.cpp
View file @
59da62d2
...
@@ -210,7 +210,7 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
...
@@ -210,7 +210,7 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
}
}
}
}
bool
anotherUser
=
userName
!=
QString
::
fromStdString
(
tabSupervisor
->
getUserInfo
()
->
name
());
bool
anotherUser
=
userName
!=
QString
::
fromStdString
(
tabSupervisor
->
getUserInfo
()
->
name
());
aDetails
->
setEnabled
(
onlin
e
);
aDetails
->
setEnabled
(
tru
e
);
aChat
->
setEnabled
(
anotherUser
&&
online
);
aChat
->
setEnabled
(
anotherUser
&&
online
);
aShowGames
->
setEnabled
(
anotherUser
);
aShowGames
->
setEnabled
(
anotherUser
);
aAddToBuddyList
->
setEnabled
(
anotherUser
);
aAddToBuddyList
->
setEnabled
(
anotherUser
);
...
...
cockatrice/src/userlist.cpp
View file @
59da62d2
...
@@ -124,19 +124,19 @@ void BanDialog::okClicked()
...
@@ -124,19 +124,19 @@ void BanDialog::okClicked()
}
}
if
(
nameBanCheckBox
->
isChecked
())
if
(
nameBanCheckBox
->
isChecked
())
if
(
nameBanEdit
->
text
()
==
""
){
if
(
nameBanEdit
->
text
()
.
simplified
()
==
""
){
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"You must have a value in the name ban when selecting the name ban checkbox."
));
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"You must have a value in the name ban when selecting the name ban checkbox."
));
return
;
return
;
}
}
if
(
ipBanCheckBox
->
isChecked
())
if
(
ipBanCheckBox
->
isChecked
())
if
(
ipBanEdit
->
text
()
==
""
){
if
(
ipBanEdit
->
text
()
.
simplified
()
==
""
){
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"You must have a value in the ip ban when selecting the ip ban checkbox."
));
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"You must have a value in the ip ban when selecting the ip ban checkbox."
));
return
;
return
;
}
}
if
(
idBanCheckBox
->
isChecked
())
if
(
idBanCheckBox
->
isChecked
())
if
(
idBan
CheckBox
->
text
()
==
""
){
if
(
idBan
Edit
->
text
().
simplified
()
==
""
){
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"You must have a value in the clientid ban when selecting the clientid ban checkbox."
));
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"You must have a value in the clientid ban when selecting the clientid ban checkbox."
));
return
;
return
;
}
}
...
...
common/server_protocolhandler.cpp
View file @
59da62d2
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include
"pb/event_user_message.pb.h"
#include
"pb/event_user_message.pb.h"
#include
"pb/event_game_joined.pb.h"
#include
"pb/event_game_joined.pb.h"
#include
"pb/event_room_say.pb.h"
#include
"pb/event_room_say.pb.h"
#include
"pb/serverinfo_user.pb.h"
#include
<google/protobuf/descriptor.h>
#include
<google/protobuf/descriptor.h>
#include
"featureset.h"
#include
"featureset.h"
...
@@ -536,12 +537,14 @@ Response::ResponseCode Server_ProtocolHandler::cmdGetUserInfo(const Command_GetU
...
@@ -536,12 +537,14 @@ Response::ResponseCode Server_ProtocolHandler::cmdGetUserInfo(const Command_GetU
QReadLocker
locker
(
&
server
->
clientsLock
);
QReadLocker
locker
(
&
server
->
clientsLock
);
ServerInfo_User_Container
*
infoSource
=
server
->
findUser
(
userName
);
ServerInfo_User_Container
*
infoSource
=
server
->
findUser
(
userName
);
if
(
!
infoSource
)
if
(
!
infoSource
)
{
return
Response
::
RespNameNotFound
;
re
->
mutable_user_info
()
->
CopyFrom
(
databaseInterface
->
getUserData
(
userName
,
true
));
}
else
{
re
->
mutable_user_info
()
->
CopyFrom
(
infoSource
->
copyUserInfo
(
true
,
false
,
userInfo
->
user_level
()
&
ServerInfo_User
::
IsModerator
));
re
->
mutable_user_info
()
->
CopyFrom
(
infoSource
->
copyUserInfo
(
true
,
false
,
userInfo
->
user_level
()
&
ServerInfo_User
::
IsModerator
));
}
}
}
rc
.
setResponseExtension
(
re
);
rc
.
setResponseExtension
(
re
);
return
Response
::
RespOk
;
return
Response
::
RespOk
;
}
}
...
...
servatrice/src/serversocketinterface.cpp
View file @
59da62d2
...
@@ -768,8 +768,13 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
...
@@ -768,8 +768,13 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
if
(
!
sqlInterface
->
checkSql
())
if
(
!
sqlInterface
->
checkSql
())
return
Response
::
RespInternalError
;
return
Response
::
RespInternalError
;
QString
userName
=
QString
::
fromStdString
(
cmd
.
user_name
());
QString
userName
=
QString
::
fromStdString
(
cmd
.
user_name
()).
simplified
();
QString
address
=
QString
::
fromStdString
(
cmd
.
address
());
QString
address
=
QString
::
fromStdString
(
cmd
.
address
()).
simplified
();
QString
clientID
=
QString
::
fromStdString
(
cmd
.
clientid
()).
simplified
();
if
(
userName
.
isEmpty
()
&&
address
.
isEmpty
()
&&
clientID
.
isEmpty
())
return
Response
::
RespOk
;
QString
trustedSources
=
settingsCache
->
value
(
"server/trusted_sources"
,
"127.0.0.1,::1"
).
toString
();
QString
trustedSources
=
settingsCache
->
value
(
"server/trusted_sources"
,
"127.0.0.1,::1"
).
toString
();
int
minutes
=
cmd
.
minutes
();
int
minutes
=
cmd
.
minutes
();
if
(
trustedSources
.
contains
(
address
,
Qt
::
CaseInsensitive
))
if
(
trustedSources
.
contains
(
address
,
Qt
::
CaseInsensitive
))
...
@@ -790,10 +795,11 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
...
@@ -790,10 +795,11 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
if
(
!
userName
.
isEmpty
())
{
if
(
!
userName
.
isEmpty
())
{
ServerSocketInterface
*
user
=
static_cast
<
ServerSocketInterface
*>
(
server
->
getUsers
().
value
(
userName
));
ServerSocketInterface
*
user
=
static_cast
<
ServerSocketInterface
*>
(
server
->
getUsers
().
value
(
userName
));
userList
.
append
(
user
);
if
(
user
)
userList
.
append
(
user
);
}
}
if
(
userName
.
isEmpty
()
&&
address
.
isEmpty
()
&&
(
!
QString
::
fromStdString
(
cmd
.
client
id
())
.
isEmpty
()))
{
if
(
userName
.
isEmpty
()
&&
address
.
isEmpty
()
&&
(
!
client
ID
.
isEmpty
()))
{
QSqlQuery
*
query
=
sqlInterface
->
prepareQuery
(
"select name from {prefix}_users where clientid = :client_id"
);
QSqlQuery
*
query
=
sqlInterface
->
prepareQuery
(
"select name from {prefix}_users where clientid = :client_id"
);
query
->
bindValue
(
":client_id"
,
QString
::
fromStdString
(
cmd
.
clientid
()));
query
->
bindValue
(
":client_id"
,
QString
::
fromStdString
(
cmd
.
clientid
()));
sqlInterface
->
execSqlQuery
(
query
);
sqlInterface
->
execSqlQuery
(
query
);
...
...
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