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
0afdbc72
Commit
0afdbc72
authored
Mar 01, 2011
by
Max-Wilhelm Bruker
Browse files
more work on buddy&ignore
parent
4149f780
Changes
9
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/localserver.h
View file @
0afdbc72
...
@@ -21,8 +21,8 @@ public:
...
@@ -21,8 +21,8 @@ public:
protected:
protected:
bool
userExists
(
const
QString
&
/*name*/
)
{
return
false
;
}
bool
userExists
(
const
QString
&
/*name*/
)
{
return
false
;
}
ServerInfo_User
*
getUserData
(
const
QString
&
name
);
ServerInfo_User
*
getUserData
(
const
QString
&
name
);
Q
List
<
ServerInfo_User
*>
getBuddyList
(
const
QString
&
/*name*/
)
{
return
Q
List
<
ServerInfo_User
*>
();
}
Q
Map
<
QString
,
ServerInfo_User
*>
getBuddyList
(
const
QString
&
/*name*/
)
{
return
Q
Map
<
QString
,
ServerInfo_User
*>
();
}
Q
List
<
ServerInfo_User
*>
getIgnoreList
(
const
QString
&
/*name*/
)
{
return
Q
List
<
ServerInfo_User
*>
();
}
Q
Map
<
QString
,
ServerInfo_User
*>
getIgnoreList
(
const
QString
&
/*name*/
)
{
return
Q
Map
<
QString
,
ServerInfo_User
*>
();
}
};
};
#endif
#endif
\ No newline at end of file
cockatrice/src/tab_room.cpp
View file @
0afdbc72
...
@@ -80,6 +80,7 @@ void GameSelector::checkResponse(ResponseCode response)
...
@@ -80,6 +80,7 @@ void GameSelector::checkResponse(ResponseCode response)
case
RespNameNotFound
:
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"The game does not exist any more."
));
break
;
case
RespNameNotFound
:
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"The game does not exist any more."
));
break
;
case
RespUserLevelTooLow
:
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"This game is only open to registered users."
));
break
;
case
RespUserLevelTooLow
:
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"This game is only open to registered users."
));
break
;
case
RespOnlyBuddies
:
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"This game is only open to its creator's buddies."
));
break
;
case
RespOnlyBuddies
:
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"This game is only open to its creator's buddies."
));
break
;
case
RespOnIgnoreList
:
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"You are being ignored by the creator of this game."
));
break
;
default:
;
default:
;
}
}
}
}
...
...
common/protocol.cpp
View file @
0afdbc72
...
@@ -266,6 +266,7 @@ void ProtocolResponse::initializeHash()
...
@@ -266,6 +266,7 @@ void ProtocolResponse::initializeHash()
responseHash
.
insert
(
"spectators_not_allowed"
,
RespSpectatorsNotAllowed
);
responseHash
.
insert
(
"spectators_not_allowed"
,
RespSpectatorsNotAllowed
);
responseHash
.
insert
(
"only_buddies"
,
RespOnlyBuddies
);
responseHash
.
insert
(
"only_buddies"
,
RespOnlyBuddies
);
responseHash
.
insert
(
"user_level_too_low"
,
RespUserLevelTooLow
);
responseHash
.
insert
(
"user_level_too_low"
,
RespUserLevelTooLow
);
responseHash
.
insert
(
"on_ignore_list"
,
RespOnIgnoreList
);
}
}
Response_JoinRoom
::
Response_JoinRoom
(
int
_cmdId
,
ResponseCode
_responseCode
,
ServerInfo_Room
*
_roomInfo
)
Response_JoinRoom
::
Response_JoinRoom
(
int
_cmdId
,
ResponseCode
_responseCode
,
ServerInfo_Room
*
_roomInfo
)
...
...
common/protocol_datastructures.h
View file @
0afdbc72
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
class
DeckList
;
class
DeckList
;
enum
ResponseCode
{
RespNothing
,
RespOk
,
RespInternalError
,
RespInvalidCommand
,
RespInvalidData
,
RespNameNotFound
,
RespLoginNeeded
,
RespFunctionNotAllowed
,
RespGameNotStarted
,
RespGameFull
,
RespContextError
,
RespWrongPassword
,
RespSpectatorsNotAllowed
,
RespOnlyBuddies
,
RespUserLevelTooLow
};
enum
ResponseCode
{
RespNothing
,
RespOk
,
RespInternalError
,
RespInvalidCommand
,
RespInvalidData
,
RespNameNotFound
,
RespLoginNeeded
,
RespFunctionNotAllowed
,
RespGameNotStarted
,
RespGameFull
,
RespContextError
,
RespWrongPassword
,
RespSpectatorsNotAllowed
,
RespOnlyBuddies
,
RespUserLevelTooLow
,
RespOnIgnoreList
};
// PrivateZone: Contents of the zone are always visible to the owner,
// PrivateZone: Contents of the zone are always visible to the owner,
// but not to anyone else.
// but not to anyone else.
...
...
common/server.h
View file @
0afdbc72
...
@@ -39,8 +39,8 @@ public:
...
@@ -39,8 +39,8 @@ public:
virtual
int
getMaxGameInactivityTime
()
const
=
0
;
virtual
int
getMaxGameInactivityTime
()
const
=
0
;
virtual
int
getMaxPlayerInactivityTime
()
const
=
0
;
virtual
int
getMaxPlayerInactivityTime
()
const
=
0
;
virtual
Q
List
<
ServerInfo_User
*>
getBuddyList
(
const
QString
&
name
)
=
0
;
virtual
Q
Map
<
QString
,
ServerInfo_User
*>
getBuddyList
(
const
QString
&
name
)
=
0
;
virtual
Q
List
<
ServerInfo_User
*>
getIgnoreList
(
const
QString
&
name
)
=
0
;
virtual
Q
Map
<
QString
,
ServerInfo_User
*>
getIgnoreList
(
const
QString
&
name
)
=
0
;
protected:
protected:
QMap
<
int
,
Server_Game
*>
games
;
QMap
<
int
,
Server_Game
*>
games
;
QList
<
Server_ProtocolHandler
*>
clients
;
QList
<
Server_ProtocolHandler
*>
clients
;
...
...
common/server_game.cpp
View file @
0afdbc72
...
@@ -179,6 +179,11 @@ ResponseCode Server_Game::checkJoin(ServerInfo_User *user, const QString &_passw
...
@@ -179,6 +179,11 @@ ResponseCode Server_Game::checkJoin(ServerInfo_User *user, const QString &_passw
return
RespWrongPassword
;
return
RespWrongPassword
;
if
(
!
(
user
->
getUserLevel
()
&
ServerInfo_User
::
IsRegistered
)
&&
onlyRegistered
)
if
(
!
(
user
->
getUserLevel
()
&
ServerInfo_User
::
IsRegistered
)
&&
onlyRegistered
)
return
RespUserLevelTooLow
;
return
RespUserLevelTooLow
;
if
(
onlyBuddies
)
if
(
!
static_cast
<
Server_Room
*>
(
parent
())
->
getServer
()
->
getBuddyList
(
creatorInfo
->
getName
()).
contains
(
user
->
getName
()))
return
RespOnlyBuddies
;
if
(
static_cast
<
Server_Room
*>
(
parent
())
->
getServer
()
->
getIgnoreList
(
creatorInfo
->
getName
()).
contains
(
user
->
getName
()))
return
RespOnIgnoreList
;
if
(
spectator
)
{
if
(
spectator
)
{
if
(
!
spectatorsAllowed
)
if
(
!
spectatorsAllowed
)
return
RespSpectatorsNotAllowed
;
return
RespSpectatorsNotAllowed
;
...
...
common/server_protocolhandler.cpp
View file @
0afdbc72
...
@@ -241,12 +241,8 @@ ResponseCode Server_ProtocolHandler::cmdLogin(Command_Login *cmd, CommandContain
...
@@ -241,12 +241,8 @@ ResponseCode Server_ProtocolHandler::cmdLogin(Command_Login *cmd, CommandContain
enqueueProtocolItem
(
new
Event_ServerMessage
(
server
->
getLoginMessage
()));
enqueueProtocolItem
(
new
Event_ServerMessage
(
server
->
getLoginMessage
()));
if
(
authState
==
PasswordRight
)
{
if
(
authState
==
PasswordRight
)
{
QList
<
ServerInfo_User
*>
_buddyList
=
server
->
getBuddyList
(
userInfo
->
getName
());
buddyList
=
server
->
getBuddyList
(
userInfo
->
getName
());
for
(
int
i
=
0
;
i
<
_buddyList
.
size
();
++
i
)
ignoreList
=
server
->
getIgnoreList
(
userInfo
->
getName
());
buddyList
.
insert
(
_buddyList
[
i
]
->
getName
(),
_buddyList
[
i
]);
QList
<
ServerInfo_User
*>
_ignoreList
=
server
->
getIgnoreList
(
userInfo
->
getName
());
for
(
int
i
=
0
;
i
<
_ignoreList
.
size
();
++
i
)
ignoreList
.
insert
(
_ignoreList
[
i
]
->
getName
(),
_ignoreList
[
i
]);
// This might not scale very well. Use an extra QMap if it becomes a problem.
// This might not scale very well. Use an extra QMap if it becomes a problem.
const
QList
<
Server_Game
*>
&
serverGames
=
server
->
getGames
();
const
QList
<
Server_Game
*>
&
serverGames
=
server
->
getGames
();
...
...
servatrice/src/servatrice.cpp
View file @
0afdbc72
...
@@ -228,9 +228,9 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
...
@@ -228,9 +228,9 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
return
new
ServerInfo_User
(
name
,
ServerInfo_User
::
IsUser
);
return
new
ServerInfo_User
(
name
,
ServerInfo_User
::
IsUser
);
}
}
Q
List
<
ServerInfo_User
*>
Servatrice
::
getBuddyList
(
const
QString
&
name
)
Q
Map
<
QString
,
ServerInfo_User
*>
Servatrice
::
getBuddyList
(
const
QString
&
name
)
{
{
Q
List
<
ServerInfo_User
*>
result
;
Q
Map
<
QString
,
ServerInfo_User
*>
result
;
const
QString
method
=
settings
->
value
(
"authentication/method"
).
toString
();
const
QString
method
=
settings
->
value
(
"authentication/method"
).
toString
();
if
(
method
==
"sql"
)
{
if
(
method
==
"sql"
)
{
...
@@ -242,15 +242,17 @@ QList<ServerInfo_User *> Servatrice::getBuddyList(const QString &name)
...
@@ -242,15 +242,17 @@ QList<ServerInfo_User *> Servatrice::getBuddyList(const QString &name)
if
(
!
execSqlQuery
(
query
))
if
(
!
execSqlQuery
(
query
))
return
result
;
return
result
;
while
(
query
.
next
())
while
(
query
.
next
())
{
result
.
append
(
evalUserQueryResult
(
query
,
false
));
ServerInfo_User
*
temp
=
evalUserQueryResult
(
query
,
false
);
result
.
insert
(
temp
->
getName
(),
temp
);
}
}
}
return
result
;
return
result
;
}
}
Q
List
<
ServerInfo_User
*>
Servatrice
::
getIgnoreList
(
const
QString
&
name
)
Q
Map
<
QString
,
ServerInfo_User
*>
Servatrice
::
getIgnoreList
(
const
QString
&
name
)
{
{
Q
List
<
ServerInfo_User
*>
result
;
Q
Map
<
QString
,
ServerInfo_User
*>
result
;
const
QString
method
=
settings
->
value
(
"authentication/method"
).
toString
();
const
QString
method
=
settings
->
value
(
"authentication/method"
).
toString
();
if
(
method
==
"sql"
)
{
if
(
method
==
"sql"
)
{
...
@@ -262,8 +264,10 @@ QList<ServerInfo_User *> Servatrice::getIgnoreList(const QString &name)
...
@@ -262,8 +264,10 @@ QList<ServerInfo_User *> Servatrice::getIgnoreList(const QString &name)
if
(
!
execSqlQuery
(
query
))
if
(
!
execSqlQuery
(
query
))
return
result
;
return
result
;
while
(
query
.
next
())
while
(
query
.
next
())
{
result
.
append
(
evalUserQueryResult
(
query
,
false
));
ServerInfo_User
*
temp
=
evalUserQueryResult
(
query
,
false
);
result
.
insert
(
temp
->
getName
(),
temp
);
}
}
}
return
result
;
return
result
;
}
}
...
...
servatrice/src/servatrice.h
View file @
0afdbc72
...
@@ -51,8 +51,8 @@ public:
...
@@ -51,8 +51,8 @@ public:
protected:
protected:
bool
userExists
(
const
QString
&
user
);
bool
userExists
(
const
QString
&
user
);
AuthenticationResult
checkUserPassword
(
const
QString
&
user
,
const
QString
&
password
);
AuthenticationResult
checkUserPassword
(
const
QString
&
user
,
const
QString
&
password
);
Q
List
<
ServerInfo_User
*>
getBuddyList
(
const
QString
&
name
);
Q
Map
<
QString
,
ServerInfo_User
*>
getBuddyList
(
const
QString
&
name
);
Q
List
<
ServerInfo_User
*>
getIgnoreList
(
const
QString
&
name
);
Q
Map
<
QString
,
ServerInfo_User
*>
getIgnoreList
(
const
QString
&
name
);
private:
private:
QTimer
*
pingClock
,
*
statusUpdateClock
;
QTimer
*
pingClock
,
*
statusUpdateClock
;
QTcpServer
*
tcpServer
;
QTcpServer
*
tcpServer
;
...
...
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