From: APTX Date: Thu, 10 Feb 2011 20:14:08 +0000 (+0100) Subject: Make Client StateMachine debug messages conditional. X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=34a2b92b2da19c5e8eab053fc8ddd057481f8869;p=anidbudpclient.git Make Client StateMachine debug messages conditional. --- diff --git a/client.cpp b/client.cpp index c3b9a1f..bd9bcec 100644 --- a/client.cpp +++ b/client.cpp @@ -216,20 +216,26 @@ void Client::setIdlePolicy(IdlePolicy policy) void Client::enterErrorState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering Error State"; +#endif disconnect(); } void Client::enterDisconnectedState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering Disconnected State"; +#endif if (socket->state() == QAbstractSocket::BoundState) socket->disconnectFromHost(); } void Client::enterConnectingState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering Connecting State"; +#endif if (!m_hostAddress.isNull()) { @@ -268,13 +274,17 @@ qDebug() << "Host lookup finished"; void Client::enterConnectedState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering Connected State"; +#endif emit connected(); } void Client::enterAuthenticatingState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering Authenticating State"; +#endif if (authenticatingStarted) return; @@ -294,11 +304,15 @@ qDebug() << "Entering Authenticating State"; void Client::doAuthenticate(bool success) { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "doAuthenticate init"; +#endif authenticatingStarted = false; if (success) { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "success!"; +#endif m_sessionId = authReply->sessionId().toUtf8(); emit authenticated(); return; @@ -312,7 +326,9 @@ qDebug() << "success!"; void Client::enterSendState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering Send State"; +#endif // Do not send commands if wait time didn't end // Happens if sendState is entered from recv* states. @@ -349,7 +365,9 @@ qDebug() << "Sending Control Command"; void Client::enterWaitState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering Wait State"; +#endif // Do not restart timer if it is active if (!commandTimer->isActive()) @@ -358,8 +376,10 @@ qDebug() << "Entering Wait State"; void Client::enterIdleState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering Idle State"; qDebug() << m_idlePolicy; +#endif // If not loogged in, nothing has to be done in idle state. if (m_sessionId.isEmpty()) @@ -383,13 +403,17 @@ qDebug() << m_idlePolicy; void Client::exitIdleState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Exiting Idle State"; +#endif idleTimer->stop(); } void Client::enterIdleTiemoutState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering IdleTiemout State"; +#endif switch (m_idlePolicy) { case DoNothingIdlePolicy: @@ -404,7 +428,9 @@ qDebug() << "Entering IdleTiemout State"; void Client::enterRecieveState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering Recieve State"; +#endif while (socket->hasPendingDatagrams()) { char data[UDP_DATAGRAM_MAXIMUM_SIZE]; @@ -619,7 +645,9 @@ endLoop: void Client::enterRecieveFailState() { +#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG qDebug() << "Entering RecieveFail State"; +#endif } // -------------------------------------------------------------------------------------