//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / UNI
//
//File: unistate_n12.cpp
//
//Version: $Revision: 1.17 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/12/14 06:56:33 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Jari Katajavuori
//
//Description:
//      State Release Indication (N12)
//
//Copyright:
//
//
//Licence:
//
//
//History: 

#include "unistate_n12.h"

#include "unidefs.h"
#include "unistrings.h"
#include "uniprotocol.h"
#include "unipdu.h"

uniNetworkReleaseIndication *
uniNetworkReleaseIndication :: _only = 0;

uniNetworkReleaseIndication *
uniNetworkReleaseIndication :: instance(void)
{
    if (_only == 0)
    {
        _only = new uniNetworkReleaseIndication;
    }
    return _only;
}

uniNetworkReleaseIndication :: uniNetworkReleaseIndication(void)
    : uniNetworkState()
{
    return;
}

uniNetworkReleaseIndication :: ~uniNetworkReleaseIndication(void)
{
    return;
}

void uniNetworkReleaseIndication :: uniRELEASE_COMPLETEpduAct(
    uniRELEASE_COMPLETEpdu *message_,
    pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);
    protocol->verifyMessage(message_, uniState_Null);
    protocol->stopTimer(uniT308Str);
    protocol->sendRELEASEconfToCC(message_);
    protocol->changeToNullState();
    return;
}

void uniNetworkReleaseIndication :: uniRELEASEpduAct(
    uniRELEASEpdu *message_,
    pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);
    protocol->verifyMessage(message_, uniState_Null);
    protocol->stopTimer(uniT308Str);
    protocol->clearPMPs(message_);
    protocol->sendRELEASEconfToCC(message_);
    protocol->changeToNullState();
    return;
}

void uniNetworkReleaseIndication :: uniSTATUSpduAct(uniSTATUSpdu *message_,
                                                    pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);
    protocol->clearCallIfNullState(message_);
    return;
}

void uniNetworkReleaseIndication :: uniLINK_ESTABLISHindAct(
    uniLINK_ESTABLISHind *,
    pfProtocol *)
{
    return;
}

void uniNetworkReleaseIndication :: uniDROP_PARTYrespAct(
    uniDROP_PARTYresp *message_,
    pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);
    if (protocol->isMultipointConnection() != 0)
    {
        protocol->sendDROP_PARTY_ACKpduToCoOrd(message_);
        protocol->removePMP(message_);
    }
    return;
}

void uniNetworkReleaseIndication :: uniDROP_PARTYpduAct(
    uniDROP_PARTYpdu *,
    pfProtocol *)
{
    return;
}

void uniNetworkReleaseIndication :: uniDROP_PARTY_ACKpduAct(
    uniDROP_PARTY_ACKpdu *,
    pfProtocol *)
{
    return;
}

void uniNetworkReleaseIndication :: uniT308timeoutAct(
    pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);
    if (protocol->getInteger(uniT308TimeoutsStr) == 0)
    {
        pfUlong causeR = protocol->getInteger(uniCauseRStr);
        protocol->sendRELEASEpduToCoOrd(causeR,
                                        uniCauseValue_RecoveryOnTimerExpiry);
        protocol->startTimer(uniT308Str);
        protocol->setInteger(uniT308TimeoutsStr, 1);
    }
    else
    {        
        protocol->clearCall(uniCauseValue_NormalUnspecified);
    }
    return;
}

void uniNetworkReleaseIndication :: uniTREMOVEDtimeoutAct(
    pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);
    protocol->setBooleanTrue(uniAllowFinalClearingStr);
    return;
}

