]> Some of my projects - anidbudpclient.git/commitdiff
Make Client StateMachine debug messages conditional.
authorAPTX <marek321@gmail.com>
Thu, 10 Feb 2011 20:14:08 +0000 (21:14 +0100)
committerAPTX <marek321@gmail.com>
Thu, 10 Feb 2011 20:14:08 +0000 (21:14 +0100)
client.cpp

index c3b9a1fe18d192ec6ef32b37743d8b26624e4124..bd9bcec994700ef1ca8e1cb1bc33c4026e3840dc 100644 (file)
@@ -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
 }
 
 // -------------------------------------------------------------------------------------