//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / UNI
//
//File: unistate_u0.cpp
//
//Version: $Revision: 1.14 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/12/14 13:27:09 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Jari Katajavuori
//
//Description:
//
//
//Copyright:
//
//
//Licence:
//
//
//History: 

#include "unistate_u0.h"

#include "unistrings.h"
#include "uniprotocol.h"

uniUserNull *uniUserNull :: _only = 0;

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

uniUserNull :: uniUserNull(void)
    : uniState()
{
    return;
}

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

void uniUserNull :: sigSETUPreqAct(sigSETUPreq *message_,
                                   pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);

#if 0
    // Choose mode: if Connection Identifier is present, this
    // must act like a network party.
    if (message_->isAvailable(uniConnectionIdentifierStr) != 0)
    {
        protocol->setNetworkMode();
    }
    else
    {
        protocol->setUserMode();
    }
#endif
    
    if (message_->isVariableDefined(uniEndpointReferenceStr) != 0)
    {
        // Multipoint Setup
        protocol->setBooleanTrue(uniMultipointConnectionFlagStr);
    }
    
    protocol->sendSETUPpduToCoOrd(message_);
    protocol->setInteger(uniT303TimeoutsStr, 0);
    protocol->startTimer(uniT303Str);
    protocol->changeToCallInitiatedState();
    
    return;
};

void uniUserNull :: uniSETUPpduAct(uniSETUPpdu *message_,
                               pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);

#if 0
    // Choose mode: if Connection Identifier is present, the
    // other party is network, this acts like user.
    if (message_->isAvailable(uniConnectionIdentifierStr) != 0)
    {
        protocol->setUserMode();
    }
    else
    {
        protocol->setNetworkMode();
    }
#endif

    protocol->sendSETUPindToCC(message_);
    protocol->changeToCallPresentState();
    return;
}
    

// waiting for response from cc to do the final clearing
void uniUserNull :: sigRELEASErespAct(sigRELEASEresp *,
                                      pfProtocol *protocol_)
{
    // When RELEASEresp is received, cc is ready for exit.
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);
    protocol->finalClearing();
    return;
}


// Following methods resets some inputs. This is because there is several
// inputs which are allowed anywhere except N0.

void uniUserNull :: sigRELEASEreqAct(sigRELEASEreq *,
                                        pfProtocol *)
{
    return;
}

void uniUserNull :: uniCALL_PROCEEDINGpduAct(uniCALL_PROCEEDINGpdu *,
                                                pfProtocol *)
{
    return;
}

void uniUserNull :: uniCONNECTpduAct(uniCONNECTpdu *,
                                        pfProtocol *)
{
    return;
}

void uniUserNull :: uniCONNECT_ACKpduAct(uniCONNECT_ACKpdu *,
                                            pfProtocol *)
{
    return;
}

void uniUserNull :: uniRELEASEpduAct(uniRELEASEpdu *,
                                        pfProtocol *)
{
    return;
}

void uniUserNull :: uniRELEASE_COMPLETEpduAct(uniRELEASE_COMPLETEpdu *,
                                                 pfProtocol *)
{
    return;
}

void uniUserNull :: uniSTATUSpduAct(uniSTATUSpdu *message_,
                                       pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);
    pfUlong cs =
        message_->getStorage(uniCallStateStr).getInteger(uniCallState_StateStr);
    if (cs != uniState_Null)
    {
        protocol->sendRELEASE_COMPLETEpduToCoOrd(
            uniCauseValue_MessageNotCompatibleWithCallState);
    }    return;
}

void uniUserNull :: uniADD_PARTYpduAct(uniADD_PARTYpdu *,
                                          pfProtocol *)
{
    return;
}

void uniUserNull :: uniADD_PARTY_ACKpduAct(uniADD_PARTY_ACKpdu *,
                                              pfProtocol *)
{
    return;
}

void uniUserNull :: uniADD_PARTY_REJECTpduAct(uniADD_PARTY_REJECTpdu *,
                                                 pfProtocol *)
{
    return;
}

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

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

void uniUserNull :: uniT322timeoutAct(pfProtocol *)
{
    return;
}

void uniUserNull :: uniTREMOVEDtimeoutAct(pfProtocol *)
{
    return;
}

