//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / TESTING
//
//File: client.cpp
//
//Version: $Revision: 1.3 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/12/16 14:12:44 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Timo Pärnänen
//
//Description:
//
//Copyright:
//
//
//Licence:
//
//
//History: 
//

#include <typeinfo>
#include <iostream.h>
#include <string.h>
#include "pf/system.h"
#include "pf/debug.h"
#include "pf/naming.h"
#include "mgmt/toveswitch_impl.h"
#include "mgmt/mgmtcommand.h"

void printUsage(char *name_)
{
    cerr << endl;
    cerr << "Usage: " << name_ << " <pointCode> ";
    cerr << " -ORBnaming `cat /work/Naming/Naming.ior`" << endl;
    cerr << endl;
    exit(0);
}

//
// main function
//

int main(int argc, char *argv[])
{
    debugOutputCout();

    if (argc != 4 || *argv[1] == 'h')
    {
        printUsage(argv[0]);
    }

    pfSystem::init(argc, argv);

    // Construct name for naming component
    string tmpName = argv[1];
    tmpName += "/ss7test";

    CosNaming_Name name = pfNaming::parseName(tmpName);
    
    CORBA_Object_ptr tmp = 0;
    toveSwitch_switchInterface_ptr server;
    
    try
    {
        tmp = pfNaming::instance()->resolve(name);
        server = toveSwitch_switchInterface::_narrow(tmp);
    }
    catch (...)
    {
        debugUser("resolve in NS failed");
        exit(1);
    }

    string calledGT("9876");
    string callingGT("1234");

    mgmtCommand command("start");
    command.addParameter("calledGT", calledGT);
    command.addParameter("callingGT", callingGT);
    
    try
    {
	toveSwitch_ParameterList parameterList = command.getList();
        server->execute(command.getCommandName().c_str(), parameterList);
    }
    catch (...)
    {
        debugUser("ss7test starting not completed");
        exit(0);
    }    
    return 0;
}

