//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / SIG
//
//File: sigstate_null.cpp
//
//Version: $Revision: 1.2 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/11/12 08:23:01 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Sami Raatikainen
//
//Description:
//      See corresponding header file.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 

#include "sigstate_null.h"

#include "sigprotocol.h"
#include "sigstrings.h"

sigNull *sigNull :: _only = 0;

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

sigNull :: sigNull(void)
    : sigState()
{
    return;
}

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

void sigNull :: sigSETUPreqAct(sigSETUPreq *primitive_,
                               pfProtocol *protocol_)
{
    sigProtocol *protocol = protocolCast(protocol_);
    
    // Choose mode: if Connection Identifier is present, this
    // must act like a network party. 
    // ++TODO++ (feature added by Jari, check if it's ok)
    if (primitive_->isAvailable(sigConnectionIdentifierStr) != 0)
    {
        protocol->setNetworkMode();
    }
    else
    {
        protocol->setUserMode();
    }
    
    // ++TODO++ may this come to network from user?
    if (primitive_->isVariableDefined(sigEndpointReferenceStr) != 0)
    {
        // Multipoint Setup
        protocol->setMultipointConnection();
    }
    
    protocol->startAwaitCONNECTtimer();
    protocol->sendSETUPreqToDown(primitive_);
    protocol->changeToCallInitiatedState();
    return;
};

void sigNull :: sigSETUPindAct(sigSETUPind *primitive_,
                               pfProtocol *protocol_)
{
    sigProtocol *protocol = protocolCast(protocol_);

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

    protocol->createConduits(primitive_);
    protocol->sendSETUPindToCC(primitive_);
    protocol->changeToCallPresentState();
    return;
}

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

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

void sigNull :: sigPROCEEDINGindAct(sigPROCEEDINGind *,
                                    pfProtocol *)
{
    return;
}

void sigNull :: sigSETUPconfAct(sigSETUPconf *,
                                pfProtocol *)
{
    return;
}

void sigNull :: sigSETUP_COMPLETEindAct(sigSETUP_COMPLETEind *,
                                        pfProtocol *)
{
    return;
}

void sigNull :: sigRELEASEindAct(sigRELEASEind *,
                                 pfProtocol *)
{
    return;
}

void sigNull :: sigRELEASEconfAct(sigRELEASEconf *,
                                  pfProtocol *)
{
    return;
}
