From: APTX Date: Wed, 23 Sep 2009 13:14:43 +0000 (+0200) Subject: - Port to the State machine classes from 4.6.0. X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=dd9fd362cece3d0ee5ae006a7fb98cf18ff14cbb;p=anidbudpclient.git - Port to the State machine classes from 4.6.0. - Remove qtstatemachine-solution lib. --- diff --git a/anidbudpclient.pro b/anidbudpclient.pro index 9575960..9f2968b 100644 --- a/anidbudpclient.pro +++ b/anidbudpclient.pro @@ -57,5 +57,3 @@ CONV_HEADERS += include/AniDBUdpClient/Client \ include/AniDBUdpClient/UptimeCommand \ include/AniDBUdpClient/Hash \ include/AniDBUdpClient/UptimeCommand \ - -include(../../lib/qtstatemachine/src/qtstatemachine.pri) diff --git a/client.cpp b/client.cpp index 151d856..4acb117 100644 --- a/client.cpp +++ b/client.cpp @@ -1,9 +1,8 @@ #include "client.h" -#include -#include -#include -#include +#include +#include +#include #include #include @@ -52,20 +51,20 @@ qDebug() << "Api instance init!"; setFloodInterval(5); - stateMachine = new QtStateMachine(this); - - errorState = new QtState; - disconnectedState = new QtState; - connectingState = new QtState; - connectedState = new QtState; - authenticatingState = new QtState(connectedState); - idleState = new QtState(connectedState); - idleTimeoutState = new QtState(connectedState); - sendState = new QtState(connectedState); - waitState = new QtState(connectedState); - recieveState = new QtState; - recieveFailState = new QtState; - connectedHistoryState = connectedState->addHistoryState(); + stateMachine = new QStateMachine(this); + + errorState = new QState; + disconnectedState = new QState; + connectingState = new QState; + connectedState = new QState; + authenticatingState = new QState(connectedState); + idleState = new QState(connectedState); + idleTimeoutState = new QState(connectedState); + sendState = new QState(connectedState); + waitState = new QState(connectedState); + recieveState = new QState; + recieveFailState = new QState; + connectedHistoryState = new QHistoryState(connectedState); stateMachine->addState(errorState); stateMachine->addState(disconnectedState); @@ -111,19 +110,19 @@ qDebug() << "Api instance init!"; // ------------ END Transitions ------------------- // ------------- Methods --------------------- - errorState->invokeMethodOnEntry(this, "enterErrorState"); - disconnectedState->invokeMethodOnEntry(this, "enterDisconnectedState"); - connectingState->invokeMethodOnEntry(this, "enterConnectingState"); - connectedState->invokeMethodOnEntry(this, "enterConnectedState"); - authenticatingState->invokeMethodOnEntry(this, "enterAuthenticatingState"); - sendState->invokeMethodOnEntry(this, "enterSendState"); - waitState->invokeMethodOnEntry(this, "enterWaitState"); - idleState->invokeMethodOnEntry(this, "enterIdleState"); - idleState->invokeMethodOnExit(this, "exitIdleState"); - idleTimeoutState->invokeMethodOnEntry(this, "enterIdleTiemoutState"); - - recieveState->invokeMethodOnEntry(this, "enterRecieveState"); - recieveFailState->invokeMethodOnEntry(this, "enterRecieveFailState"); + QObject::connect(errorState, SIGNAL(entered()), this, SLOT(enterErrorState())); + QObject::connect(disconnectedState, SIGNAL(entered()), this, SLOT(enterDisconnectedState())); + QObject::connect(connectingState, SIGNAL(entered()), this, SLOT(enterConnectingState())); + QObject::connect(connectedState, SIGNAL(entered()), this, SLOT(enterConnectedState())); + QObject::connect(authenticatingState, SIGNAL(entered()), this, SLOT(enterAuthenticatingState())); + QObject::connect(sendState, SIGNAL(entered()), this, SLOT(enterSendState())); + QObject::connect(waitState, SIGNAL(entered()), this, SLOT(enterWaitState())); + QObject::connect(idleState, SIGNAL(entered()), this, SLOT(enterIdleState())); + QObject::connect(idleState, SIGNAL(exited()), this, SLOT(exitIdleState())); + QObject::connect(idleTimeoutState, SIGNAL(entered()), this, SLOT(enterIdleTiemoutState())); + + QObject::connect(recieveState, SIGNAL(entered()), this, SLOT(enterRecieveState())); + QObject::connect(recieveFailState, SIGNAL(entered()), this, SLOT(enterRecieveFailState())); // ------------ END Methods ------------------- stateMachine->start(); diff --git a/client.h b/client.h index 728ba49..6f5b854 100644 --- a/client.h +++ b/client.h @@ -12,9 +12,9 @@ #include "anidbudpclient_global.h" #include "authcommand.h" -class QtStateMachine; -class QtState; -class QtHistoryState; +class QStateMachine; +class QState; +class QHistoryState; class QUdpSocket; class QTimer; @@ -208,22 +208,22 @@ private: static const int UDP_API_COMMAND_TIMEOUT = 10; - QtStateMachine *stateMachine; - QtState *errorState; - QtState *disconnectedState; - QtState *connectingState; - QtState *connectedState; - QtState *authenticatingState; + QStateMachine *stateMachine; + QState *errorState; + QState *disconnectedState; + QState *connectingState; + QState *connectedState; + QState *authenticatingState; - QtState *idleState; - QtState *idleTimeoutState; - QtState *sendState; - QtState *waitState; + QState *idleState; + QState *idleTimeoutState; + QState *sendState; + QState *waitState; - QtState *recieveState; - QtState *recieveFailState; + QState *recieveState; + QState *recieveFailState; - QtHistoryState *connectedHistoryState; + QHistoryState *connectedHistoryState; }; class CommandData : QObject