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
3b70ad8c
Commit
3b70ad8c
authored
Mar 25, 2012
by
Max-Wilhelm Bruker
Browse files
minor fixes wrt commit
4e4a7563
parent
4e4a7563
Changes
7
Hide whitespace changes
Inline
Side-by-side
cockatrice/CMakeLists.txt
View file @
3b70ad8c
...
...
@@ -193,7 +193,7 @@ QT4_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES})
INCLUDE
(
${
QT_USE_FILE
}
)
INCLUDE_DIRECTORIES
(
../common
)
INCLUDE_DIRECTORIES
(
${
PROTOBUF_INCLUDE_DIR
}
)
INCLUDE_DIRECTORIES
(
${
CMAKE_
CURRENT_
BINARY_DIR
}
/
../
common
)
INCLUDE_DIRECTORIES
(
${
CMAKE_BINARY_DIR
}
/common
)
INCLUDE_DIRECTORIES
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
INCLUDE_DIRECTORIES
(
${
QT_MOBILITY_INCLUDE_DIR
}
)
INCLUDE_DIRECTORIES
(
${
QT_MOBILITY_MULTIMEDIAKIT_INCLUDE_DIR
}
)
...
...
cockatrice/src/abstractclient.cpp
View file @
3b70ad8c
...
...
@@ -22,8 +22,10 @@
AbstractClient
::
AbstractClient
(
QObject
*
parent
)
:
QObject
(
parent
),
nextCmdId
(
0
),
status
(
StatusDisconnected
)
{
qRegisterMetaType
<
QVariant
>
(
"QVariant"
);
qRegisterMetaType
<
CommandContainer
>
(
"CommandContainer"
);
qRegisterMetaType
<
Response
>
(
"Response"
);
qRegisterMetaType
<
Response
::
ResponseCode
>
(
"Response::ResponseCode"
);
qRegisterMetaType
<
ClientStatus
>
(
"ClientStatus"
);
qRegisterMetaType
<
RoomEvent
>
(
"RoomEvent"
);
qRegisterMetaType
<
GameEventContainer
>
(
"GameEventContainer"
);
...
...
cockatrice/src/remoteclient.cpp
View file @
3b70ad8c
...
...
@@ -24,18 +24,20 @@ RemoteClient::RemoteClient(QObject *parent)
connect
(
socket
,
SIGNAL
(
error
(
QAbstractSocket
::
SocketError
)),
this
,
SLOT
(
slotSocketError
(
QAbstractSocket
::
SocketError
)));
connect
(
this
,
SIGNAL
(
serverIdentificationEventReceived
(
const
Event_ServerIdentification
&
)),
this
,
SLOT
(
processServerIdentificationEvent
(
const
Event_ServerIdentification
&
)));
connect
(
this
,
SIGNAL
(
sigConnectToServer
(
QString
,
unsigned
int
,
QString
,
QString
)),
this
,
SLOT
(
doConnectToServer
(
QString
,
unsigned
int
,
QString
,
QString
)));
connect
(
this
,
SIGNAL
(
sigDisconnectFromServer
()),
this
,
SLOT
(
doDisconnectFromServer
()));
}
RemoteClient
::~
RemoteClient
()
{
disconnectFromServer
();
d
oD
isconnectFromServer
();
thread
()
->
quit
();
}
void
RemoteClient
::
slotSocketError
(
QAbstractSocket
::
SocketError
/*error*/
)
{
QString
errorString
=
socket
->
errorString
();
disconnectFromServer
();
d
oD
isconnectFromServer
();
emit
socketError
(
errorString
);
}
...
...
@@ -118,7 +120,7 @@ void RemoteClient::readData()
}
while
(
!
inputBuffer
.
isEmpty
());
if
(
status
==
StatusDisconnecting
)
disconnectFromServer
();
d
oD
isconnectFromServer
();
}
void
RemoteClient
::
sendCommandContainer
(
const
CommandContainer
&
cont
)
...
...
@@ -135,9 +137,9 @@ void RemoteClient::sendCommandContainer(const CommandContainer &cont)
socket
->
write
(
buf
);
}
void
RemoteClient
::
c
onnectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
)
void
RemoteClient
::
doC
onnectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
)
{
disconnectFromServer
();
d
oD
isconnectFromServer
();
userName
=
_userName
;
password
=
_password
;
...
...
@@ -145,7 +147,7 @@ void RemoteClient::connectToServer(const QString &hostname, unsigned int port, c
setStatus
(
StatusConnecting
);
}
void
RemoteClient
::
disconnectFromServer
()
void
RemoteClient
::
d
oD
isconnectFromServer
()
{
timer
->
stop
();
...
...
@@ -163,14 +165,15 @@ void RemoteClient::disconnectFromServer()
void
RemoteClient
::
ping
()
{
/*
QMutableMapIterator<int, PendingCommand *> i(pendingCommands);
while (i.hasNext())
if (i.next().value()->tick() > maxTimeout) {
CommandContainer *cont = i.value();
QMutableMapIterator
<
int
,
PendingCommand
*>
i
(
pendingCommands
);
while
(
i
.
hasNext
())
{
PendingCommand
*
pend
=
i
.
next
().
value
();
if
(
pend
->
tick
()
>
maxTimeout
)
{
i
.
remove
();
cont
->deleteLater();
pend
->
deleteLater
();
}
*/
}
int
maxTime
=
timeRunning
-
lastDataReceived
;
emit
maxPingTime
(
maxTime
,
maxTimeout
);
if
(
maxTime
>=
maxTimeout
)
{
...
...
@@ -181,3 +184,13 @@ void RemoteClient::ping()
++
timeRunning
;
}
}
void
RemoteClient
::
connectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
)
{
emit
sigConnectToServer
(
hostname
,
port
,
_userName
,
_password
);
}
void
RemoteClient
::
disconnectFromServer
()
{
emit
sigDisconnectFromServer
();
}
cockatrice/src/remoteclient.h
View file @
3b70ad8c
...
...
@@ -14,6 +14,8 @@ signals:
void
socketError
(
const
QString
&
errorString
);
void
protocolVersionMismatch
(
int
clientVersion
,
int
serverVersion
);
void
protocolError
();
void
sigConnectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
);
void
sigDisconnectFromServer
();
private
slots
:
void
slotConnected
();
void
readData
();
...
...
@@ -21,6 +23,8 @@ private slots:
void
ping
();
void
processServerIdentificationEvent
(
const
Event_ServerIdentification
&
event
);
void
loginResponse
(
const
Response
&
response
);
void
doConnectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
);
void
doDisconnectFromServer
();
private:
static
const
int
maxTimeout
=
10
;
int
timeRunning
,
lastDataReceived
;
...
...
@@ -31,13 +35,12 @@ private:
QTimer
*
timer
;
QTcpSocket
*
socket
;
protected
slots
:
void
sendCommandContainer
(
const
CommandContainer
&
cont
);
public:
RemoteClient
(
QObject
*
parent
=
0
);
~
RemoteClient
();
QString
peerName
()
const
{
return
socket
->
peerName
();
}
void
connectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
);
void
disconnectFromServer
();
};
...
...
cockatrice/src/tab_supervisor.cpp
View file @
3b70ad8c
...
...
@@ -72,13 +72,19 @@ void CloseButton::paintEvent(QPaintEvent * /*event*/)
style
()
->
drawPrimitive
(
QStyle
::
PE_IndicatorTabClose
,
&
opt
,
&
p
,
this
);
}
TabSupervisor
::
TabSupervisor
(
QWidget
*
parent
)
:
QTabWidget
(
parent
),
client
(
0
),
tabServer
(
0
),
tabDeckStorage
(
0
),
tabAdmin
(
0
)
TabSupervisor
::
TabSupervisor
(
AbstractClient
*
_client
,
QWidget
*
parent
)
:
QTabWidget
(
parent
),
client
(
_client
),
tabServer
(
0
),
tabDeckStorage
(
0
),
tabAdmin
(
0
)
{
tabChangedIcon
=
new
QIcon
(
":/resources/icon_tab_changed.svg"
);
setElideMode
(
Qt
::
ElideRight
);
setIconSize
(
QSize
(
15
,
15
));
connect
(
this
,
SIGNAL
(
currentChanged
(
int
)),
this
,
SLOT
(
updateCurrent
(
int
)));
connect
(
client
,
SIGNAL
(
roomEventReceived
(
const
RoomEvent
&
)),
this
,
SLOT
(
processRoomEvent
(
const
RoomEvent
&
)));
connect
(
client
,
SIGNAL
(
gameEventContainerReceived
(
const
GameEventContainer
&
)),
this
,
SLOT
(
processGameEventContainer
(
const
GameEventContainer
&
)));
connect
(
client
,
SIGNAL
(
gameJoinedEventReceived
(
const
Event_GameJoined
&
)),
this
,
SLOT
(
gameJoined
(
const
Event_GameJoined
&
)));
connect
(
client
,
SIGNAL
(
userMessageEventReceived
(
const
Event_UserMessage
&
)),
this
,
SLOT
(
processUserMessageEvent
(
const
Event_UserMessage
&
)));
connect
(
client
,
SIGNAL
(
maxPingTime
(
int
,
int
)),
this
,
SLOT
(
updatePingTime
(
int
,
int
)));
}
TabSupervisor
::~
TabSupervisor
()
...
...
@@ -113,17 +119,10 @@ int TabSupervisor::myAddTab(Tab *tab)
return
addTab
(
tab
,
tab
->
getTabText
());
}
void
TabSupervisor
::
start
(
AbstractClient
*
_client
,
const
ServerInfo_User
&
_userInfo
)
void
TabSupervisor
::
start
(
const
ServerInfo_User
&
_userInfo
)
{
client
=
_client
;
userInfo
=
new
ServerInfo_User
(
_userInfo
);
connect
(
client
,
SIGNAL
(
roomEventReceived
(
const
RoomEvent
&
)),
this
,
SLOT
(
processRoomEvent
(
const
RoomEvent
&
)));
connect
(
client
,
SIGNAL
(
gameEventContainerReceived
(
const
GameEventContainer
&
)),
this
,
SLOT
(
processGameEventContainer
(
const
GameEventContainer
&
)));
connect
(
client
,
SIGNAL
(
gameJoinedEventReceived
(
const
Event_GameJoined
&
)),
this
,
SLOT
(
gameJoined
(
const
Event_GameJoined
&
)));
connect
(
client
,
SIGNAL
(
userMessageEventReceived
(
const
Event_UserMessage
&
)),
this
,
SLOT
(
processUserMessageEvent
(
const
Event_UserMessage
&
)));
connect
(
client
,
SIGNAL
(
maxPingTime
(
int
,
int
)),
this
,
SLOT
(
updatePingTime
(
int
,
int
)));
tabServer
=
new
TabServer
(
this
,
client
);
connect
(
tabServer
,
SIGNAL
(
roomJoined
(
const
ServerInfo_Room
&
,
bool
)),
this
,
SLOT
(
addRoomTab
(
const
ServerInfo_Room
&
,
bool
)));
myAddTab
(
tabServer
);
...
...
@@ -176,11 +175,6 @@ void TabSupervisor::stop()
if
((
!
client
)
&&
localClients
.
isEmpty
())
return
;
if
(
client
)
{
disconnect
(
client
,
0
,
this
,
0
);
client
=
0
;
}
if
(
!
localClients
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
localClients
.
size
();
++
i
)
localClients
[
i
]
->
deleteLater
();
...
...
cockatrice/src/tab_supervisor.h
View file @
3b70ad8c
...
...
@@ -55,10 +55,10 @@ private:
int
myAddTab
(
Tab
*
tab
);
void
addCloseButtonToTab
(
Tab
*
tab
,
int
tabIndex
);
public:
TabSupervisor
(
QWidget
*
parent
=
0
);
TabSupervisor
(
AbstractClient
*
_client
,
QWidget
*
parent
=
0
);
~
TabSupervisor
();
void
retranslateUi
();
void
start
(
AbstractClient
*
_client
,
const
ServerInfo_User
&
userInfo
);
void
start
(
const
ServerInfo_User
&
userInfo
);
void
startLocal
(
const
QList
<
AbstractClient
*>
&
_clients
);
void
stop
();
int
getGameCount
()
const
{
return
gameTabs
.
size
();
}
...
...
cockatrice/src/window_main.cpp
View file @
3b70ad8c
...
...
@@ -108,7 +108,7 @@ void MainWindow::statusChanged(ClientStatus _status)
void
MainWindow
::
userInfoReceived
(
const
ServerInfo_User
&
info
)
{
tabSupervisor
->
start
(
client
,
info
);
tabSupervisor
->
start
(
info
);
}
// Actions
...
...
@@ -352,7 +352,7 @@ MainWindow::MainWindow(QWidget *parent)
client
->
moveToThread
(
clientThread
);
clientThread
->
start
();
tabSupervisor
=
new
TabSupervisor
;
tabSupervisor
=
new
TabSupervisor
(
client
)
;
connect
(
tabSupervisor
,
SIGNAL
(
setMenu
(
QMenu
*
)),
this
,
SLOT
(
updateTabMenu
(
QMenu
*
)));
connect
(
tabSupervisor
,
SIGNAL
(
localGameEnded
()),
this
,
SLOT
(
localGameEnded
()));
...
...
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