//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project/CC
//
//File: cctstate_null.cpp
//
//Version: $Revision: 1.12 $
//
//State: $State: Exp $
//
//Date: $Date: 1999/03/05 16:31:13 $
//
//Organisation:
//      University of Technology
// 
//Author:
//      Pasi Nummisalo
//
//Description:
//      See header.  
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//      
//Licence:
//     
//
//History:
//

#include "ccprotocol.h"
#include "cctstate_authattempt.h"
#include "cctstate_null.h"

//#include "switch/tovemanager.h"

ccTstateNull *ccTstateNull :: _only = 0;

ccTstateNull :: ccTstateNull(void)
    : ccTstate()
{
    return;
}

ccTstateNull :: ~ccTstateNull(void)
{
    _only = 0;
    return;
}

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

//
//Function: proceed
//
//Description:
//    Entry event: Disconnect and clearing of a prevous call, or
//    default handling of exceptions by SSF/CCF completed.
//

void ccTstateNull :: proceed(ccProtocol *protocol_)
{
#if CC_DEBUG
traceState(ccCCT,"Null");
#endif

    releaseAction(protocol_);    
    return;
}

//
//Function: ccSETUPpduAct
//
//Description:
//    Exit event: Indication of incoming call received from
//    originating half BCSM.
//

void ccTstateNull :: ccSETUPpduAct(ccSETUPpdu *messenger_,
                                   ccProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccCC,ccCCT,"Null","SETUP");
#endif
    
   // Save setup messenger content (storage)
   protocol_->saveData("setup", messenger_);

   // toveManager::instance()->callEstablished((long) protocol_->getId());
   
   // To DP Termination Attempt
   exitAction(protocol_, ccTstateAuthorizeAttempt::instance()); 

   return;
}


//
//Function: sigRELEASEconfAct
//
//Description:
//    Event: answer to RELEASEreq.
//

void ccTstateNull :: sigRELEASEconfAct(sigRELEASEconf *,
                                       pfProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccDSS2T,ccCCT,"null","RELEASEconf");
#endif

   // Down          CC           CC
   // ..............................
   //             (null)
   // RELEASEconf--->
   //             (null)
   // [<--RELEASEresp]
   //           (destroyed)
 
    ccProtocol *ccprotocol = entryAction(protocol_);
    sendReadyForDeletionMessage(ccprotocol);
    return;

/* DEPRECATED
    ccProtocol *ccprotocol = entryAction(protocol_);
    // Starting uninstalling process    
    // by sending close request (asynchronous) to down.
    pfCloseRequestTransporter *closeReq =
        pfCloseRequestTransporter::createCloseRequestTransporter();
    ccprotocol->toA(closeReq);
*/    
    return;
}

//
//Function: ccRELEASE_ACTIVEpduAct
//
//Description: 
//    Unexpected RELEASE_ACTIVE message form O side: ignore
//

void ccTstateNull :: ccRELEASE_ACTIVEpduAct(ccRELEASE_ACTIVEpdu *release_,
                                            ccProtocol *protocol_)
{
#if CC_DEBUG    
traceInput(ccCC,ccCCT,"Null","RELEASE_ACTIVE");
#endif
    // Do nothing, we are just starting or allready released.
    return;
}
