testexecmgmt/ucc/Source/facontroller/CSFacontroller.cpp
author Johnson Ma <johnson.ma@nokia.com>
Mon, 08 Mar 2010 15:04:18 +0800
changeset 0 3da2a79470a7
permissions -rw-r--r--
Initial EPL Contribution
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     1
/*
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     8
*
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    11
*
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    12
* Contributors:
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    13
*
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    14
* Description:    
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    15
* This file was autogenerated by rpcgen, but should be modified by the developer.
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    16
* Make sure you don't use the -component_mod flag in future or this file will be overwritten.
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    17
* Mon Oct 06 12:02:04 2003
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    18
* System Includes
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    19
*
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    20
*/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    21
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    22
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    23
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    24
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    25
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    26
#include <stdio.h>
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    27
#include <signal.h>
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    28
#ifndef WIN32
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    29
#include <unistd.h>
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    30
#include <net/if.h>
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    31
#endif
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    32
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    33
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    34
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    35
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    36
 * Local Includes
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    37
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    38
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    39
#include "CSvcFacontroller.h"
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    40
#include "CSFacontroller.h"
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    41
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    42
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    43
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    44
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    45
 * Definition
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    46
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    47
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    48
#define TEMPLATE_CONFIG_FILE			"dynfad.template.conf"
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    49
#define MOBILE_AGENT_COMMAND_LINE		"./dynfad --fg --debug --config "
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    50
#define MAXCOMMANDLINELENGTH			(31 + 256 + 1)
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    51
#define MAXTUNNELS                      32
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    52
#define MAXINTERFACECONFIGENTRY			(IFNAMSIZ + 128)
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    53
#define CONFIGCOUNT						16
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    54
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    55
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    56
/*******************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    57
 *
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    58
 * Macro Functions
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    59
 *
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    60
 ******************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    61
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    62
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    63
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    64
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    65
 * Implementation
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    66
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    67
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    68
CSFacontroller::CSFacontroller()
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    69
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    70
	iDynamicsCallTimeout = -1;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    71
	iAgentProcess = NULL;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    72
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    73
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    74
CSFacontroller::~CSFacontroller()
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    75
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    76
	assert( iAgentProcess == NULL );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    77
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    78
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    79
int CSFacontroller::GetKey()
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    80
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    81
	return iKey;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    82
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    83
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    84
void CSFacontroller::SetKey( int aKey )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    85
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    86
	iKey = aKey;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    87
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    88
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    89
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    90
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    91
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    92
 * PUBLIC FUNCTION: cstr_createagent
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    93
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    94
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    95
TResult CSFacontroller::cstr_createagent( void )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    96
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    97
	TResult rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    98
	TDCFError terr, terr_a[CONFIGCOUNT];
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    99
	TInterfaceAliasError ierr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   100
	TStartupInfo startup_info;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   101
	CIntegerAllocator *ialloc;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   102
	char dynamics_config[MAXINTERFACECONFIGENTRY];
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   103
	string interface_name, interface_address;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   104
	int errcode, i;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   105
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   106
	// initialise the result
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   107
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   108
	rv.iSubComponentResult = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   109
	rv.iData0 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   110
	rv.iData1 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   111
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   112
	// get an address for the new interface alias
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   113
	ialloc = CSvcFacontroller::GetIntegerAllocator();
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   114
	assert( ialloc != NULL );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   115
	iInterfaceHostAddress = ialloc->AllocateInteger();
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   116
	if( iInterfaceHostAddress == -1 ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   117
	  rv.iServiceResult = ERR_NO_MORE_INTERFACES;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   118
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   119
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   120
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   121
	// create a local copy of the configuration file
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   122
	terr = iDynamicsConfigFile.SetReferenceFile( TEMPLATE_CONFIG_FILE );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   123
	if( terr != DCE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   124
	  ialloc->FreeInteger( iInterfaceHostAddress );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   125
	  rv.iServiceResult = ERR_CONFIG_FILE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   126
	  rv.iSubComponentResult = (int)terr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   127
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   128
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   129
	terr = iDynamicsConfigFile.CreateLocalCopy( &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   130
	if( terr != DCE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   131
	  ialloc->FreeInteger( iInterfaceHostAddress );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   132
	  rv.iServiceResult = ERR_CONFIG_FILE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   133
	  rv.iSubComponentResult = (int)terr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   134
	  rv.iData0 = errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   135
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   136
	}	  
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   137
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   138
	// create an alias interface to use
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   139
	startup_info = CSvcFacontroller::GetStartupInfo();
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   140
	ierr = iAgentInterface.CreateNewInterfaceAlias( startup_info.iBaseInterfaceIndex, startup_info.iNetworkMask, iInterfaceHostAddress, &iInterfaceIndex, &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   141
	if( ierr != IE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   142
	  rv.iServiceResult = ERR_CREATE_INTERFACE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   143
	  rv.iSubComponentResult = ierr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   144
	  rv.iData0 = errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   145
	  ialloc->FreeInteger( iInterfaceHostAddress );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   146
	  iDynamicsConfigFile.RemoveLocalCopy( &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   147
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   148
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   149
	ierr = iAgentInterface.GetInterfaceAddress( &interface_address );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   150
	assert( ierr == IE_NONE );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   151
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   152
	// set the interface name in the config file
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   153
	ierr = iAgentInterface.GetInterfaceName( &interface_name );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   154
	snprintf( dynamics_config, MAXINTERFACECONFIGENTRY, "%s 2 -1 10", interface_name.c_str() ); 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   155
	terr_a[0] = iDynamicsConfigFile.AddListOption( "INTERFACES_BEGIN", "INTERFACES_END", dynamics_config, &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   156
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   157
	// set the tunnel name prefix to a unique value for this agent
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   158
	//	snprintf( dynamics_config, MAXINTERFACECONFIGENTRY, "TunnelDevice \"TUNL-%s-\"", interface_name.c_str() );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   159
	snprintf( dynamics_config, MAXINTERFACECONFIGENTRY, "TunnelDevice \"TUNL\"" );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   160
	terr_a[1] = iDynamicsConfigFile.SetSingleOption( "TunnelDevice", dynamics_config, &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   161
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   162
	// set the FA addresses to the alias interface address
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   163
	snprintf( dynamics_config, MAXINTERFACECONFIGENTRY, "HighestFAIPAddress %s", interface_address.c_str() );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   164
	terr_a[2] = iDynamicsConfigFile.SetSingleOption( "HighestFAIPAddress", dynamics_config, &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   165
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   166
	// set the FA addresses to the alias interface address
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   167
	snprintf( dynamics_config, MAXINTERFACECONFIGENTRY, "UpperFAIPAddress %s", interface_address.c_str() );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   168
	terr_a[3] = iDynamicsConfigFile.SetSingleOption( "UpperFAIPAddress", dynamics_config, &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   169
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   170
	// see if any errors occured setting the config info
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   171
	for( i = 0; i < 3; i++ ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   172
		if( terr_a[i] != DCE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   173
			rv.iServiceResult = ERR_CONFIG_FILE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   174
			rv.iSubComponentResult = (int)terr_a[i];
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   175
			iAgentInterface.DestroyInterfaceAlias( &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   176
			ialloc->FreeInteger( iInterfaceHostAddress );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   177
			iDynamicsConfigFile.RemoveLocalCopy( &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   178
			return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   179
		}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   180
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   181
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   182
	// done - success
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   183
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   184
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   185
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   186
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   187
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   188
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   189
 * PUBLIC FUNCTION: dstr_removeagent
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   190
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   191
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   192
int CSFacontroller::dstr_removeagent( int aArgs, int *aDeleteInstance )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   193
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   194
	int rv = ERR_NONE, errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   195
	TDCFError terr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   196
	TInterfaceAliasError ierr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   197
	CIntegerAllocator *ialloc;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   198
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   199
	// make sure that the proces isn't running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   200
	if( iAgentProcess != NULL ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   201
	  *aDeleteInstance = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   202
	  rv = ERR_INVALIDSTATE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   203
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   204
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   205
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   206
	// free the interface index
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   207
	ialloc = CSvcFacontroller::GetIntegerAllocator();
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   208
	assert( ialloc != NULL );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   209
	ialloc->FreeInteger( iInterfaceHostAddress );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   210
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   211
	// clean up the config file
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   212
	terr = iDynamicsConfigFile.RemoveLocalCopy( &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   213
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   214
	// destroy the interface alias
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   215
	ierr = iAgentInterface.DestroyInterfaceAlias( &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   216
	  
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   217
	// check for errors from the config file - delete the instance in any case
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   218
	if( terr != DCE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   219
	  rv = ERR_CONFIG_FILE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   220
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   221
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   222
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   223
	// check for errors from the interface alias - delete the instance
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   224
	if( ierr != IE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   225
	  rv = ERR_DESTROY_INTERFACE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   226
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   227
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   228
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   229
	// done - success
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   230
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   231
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   232
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   233
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   234
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   235
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   236
 * PUBLIC FUNCTION: startmobileagent
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   237
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   238
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   239
TResult CSFacontroller::startmobileagent( TStartAgentRequest aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   240
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   241
	TResult rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   242
	int errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   243
	TCAProcessError perr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   244
	char command_line_str[MAXCOMMANDLINELENGTH];
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   245
	TDCFError terr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   246
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   247
	// initialise the result
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   248
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   249
	rv.iSubComponentResult = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   250
	rv.iData0 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   251
	rv.iData1 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   252
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   253
	// check that there is currently no process
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   254
	if( iAgentProcess != NULL ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   255
		rv.iServiceResult = ERR_INVALIDSTATE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   256
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   257
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   258
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   259
	// do some semantic checking of the params
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   260
	if( (aArgs.iSolicitationMode < -1) || (aArgs.iSolicitationMode > 1) ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   261
		rv.iServiceResult = ERR_INVALIDARG;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   262
		rv.iData0 = 3;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   263
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   264
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   265
	if( (aArgs.iSolicitationMode == 1) && (aArgs.iSolicitationInterval < 1) ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   266
		rv.iServiceResult = ERR_INVALIDARG;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   267
		rv.iData0 = 4;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   268
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   269
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   270
	if( aArgs.iSolicitationMode != 1 ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   271
	  aArgs.iSolicitationInterval = 1;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   272
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   273
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   274
	// add the interface name to the config file
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   275
	snprintf( command_line_str, MAXCOMMANDLINELENGTH, "%s 3 %d %d", aArgs.iLowerInterface, aArgs.iSolicitationMode, aArgs.iSolicitationInterval );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   276
	terr = iDynamicsConfigFile.AddListOption( "INTERFACES_BEGIN", "INTERFACES_END", command_line_str, &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   277
	if( terr != DCE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   278
		rv.iServiceResult = ERR_CONFIG_FILE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   279
		rv.iSubComponentResult = (int)terr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   280
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   281
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   282
	
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   283
	// create the new process object
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   284
	iAgentProcess = new CAProcess();
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   285
	assert( iAgentProcess != NULL );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   286
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   287
	// construct the command line
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   288
	snprintf( command_line_str, MAXCOMMANDLINELENGTH, "%s%s", MOBILE_AGENT_COMMAND_LINE, iDynamicsConfigFile.GetLocalFilename() );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   289
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   290
	// start the actual process
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   291
	perr = iAgentProcess->StartProcess( command_line_str, &errcode, false, false, false ); 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   292
	if( perr != CAE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   293
		rv.iServiceResult = ERR_START_PROCESS_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   294
		rv.iSubComponentResult = (int)perr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   295
		delete iAgentProcess;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   296
		iAgentProcess = NULL;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   297
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   298
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   299
	iLowerInterface = aArgs.iLowerInterface;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   300
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   301
	// done - success
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   302
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   303
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   304
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   305
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   306
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   307
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   308
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   309
 * PUBLIC FUNCTION: stopmobileagent
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   310
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   311
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   312
TResult CSFacontroller::stopmobileagent( int aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   313
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   314
	TResult rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   315
	TCAProcessError perr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   316
	TProcessStatus pstatus;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   317
	TDCFError terr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   318
	int errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   319
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   320
	// initialise the result
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   321
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   322
	rv.iSubComponentResult = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   323
	rv.iData0 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   324
	rv.iData1 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   325
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   326
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   327
	// if the process isn't started then invalid state
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   328
	if( iAgentProcess == NULL ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   329
	  rv.iServiceResult = ERR_INVALIDSTATE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   330
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   331
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   332
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   333
	// remove the interface line added in startup
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   334
	terr = iDynamicsConfigFile.RemoveListOption( "INTERFACES_BEGIN", "INTERFACES_END", iLowerInterface.c_str(), &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   335
	if( terr != DCE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   336
		rv.iServiceResult = ERR_CONFIG_FILE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   337
		rv.iSubComponentResult = (int)terr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   338
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   339
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   340
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   341
	// if the process isn't running then it has died outside the scope of this controller, clean up the state, return an error since
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   342
	// this is noteworthy and should be either expected or not happen.
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   343
	perr = iAgentProcess->GetProcessStatus( &pstatus );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   344
	assert( perr == CAE_NONE );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   345
	if( pstatus != PS_STARTED ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   346
	  assert( (pstatus == PS_STOPPED) || (pstatus == PS_ABANDONNED) );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   347
	  delete iAgentProcess;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   348
	  iAgentProcess = NULL;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   349
	  rv.iServiceResult = ERR_PROCESS_TERMINATED_OUTSIDE_SCOPE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   350
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   351
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   352
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   353
	// request the process to stop
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   354
	perr = iAgentProcess->RequestStop( SIGTERM );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   355
	if( perr != CAE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   356
	  rv.iServiceResult = ERR_STOP_PROCESS_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   357
	  rv.iSubComponentResult = (int)perr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   358
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   359
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   360
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   361
	// wait for the process to stop
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   362
	perr = iAgentProcess->WaitForProcessToTerminate( -1 );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   363
	if( perr != CAE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   364
	  rv.iServiceResult = ERR_WAIT_PROCESS_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   365
	  rv.iSubComponentResult = (int)perr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   366
	  return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   367
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   368
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   369
	// remove the process
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   370
	delete iAgentProcess;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   371
	iAgentProcess = NULL;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   372
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   373
	// done - success
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   374
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   375
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   376
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   377
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   378
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   379
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   380
 * PUBLIC FUNCTION: getmobileagentstatus
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   381
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   382
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   383
TResult CSFacontroller::getmobileagentstatus( int aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   384
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   385
	TResult rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   386
	TCAProcessError perr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   387
	TProcessStatus pstatus;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   388
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   389
	// initialise the result
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   390
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   391
	rv.iSubComponentResult = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   392
	rv.iData0 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   393
	rv.iData1 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   394
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   395
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   396
	// if the process doesn't exist then we return PS_INVALID
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   397
	if( iAgentProcess == NULL ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   398
		rv.iData0 = PS_INVALID;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   399
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   400
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   401
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   402
	// otherwise just return whatever iAgentProcess->GetProcessStatus() returns
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   403
	perr = iAgentProcess->GetProcessStatus( &pstatus );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   404
	assert( perr == CAE_NONE );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   405
	rv.iData0 = (int)pstatus;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   406
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   407
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   408
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   409
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   410
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   411
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   412
 * PUBLIC FUNCTION: setsingleoption
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   413
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   414
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   415
TResult CSFacontroller::setsingleoption( TOptionDesc aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   416
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   417
	TResult rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   418
	int errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   419
	TDCFError cerr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   420
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   421
	// initialise the result
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   422
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   423
	rv.iSubComponentResult = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   424
	rv.iData0 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   425
	rv.iData1 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   426
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   427
	// make sure that the process isn't running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   428
	if( iAgentProcess != NULL ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   429
		rv.iServiceResult = ERR_INVALIDSTATE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   430
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   431
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   432
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   433
	// modify the config file
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   434
	cerr = iDynamicsConfigFile.SetSingleOption( aArgs.iOptionToken, aArgs.iOptionValue, &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   435
	if( cerr != DCE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   436
		rv.iServiceResult = ERR_CONFIG_FILE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   437
		rv.iSubComponentResult = (int)cerr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   438
		rv.iData0 = errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   439
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   440
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   441
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   442
	// return success
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   443
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   444
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   445
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   446
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   447
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   448
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   449
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   450
 * PUBLIC FUNCTION: removesingleoption
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   451
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   452
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   453
TResult CSFacontroller::removesingleoption( TOptionDesc aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   454
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   455
	TResult rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   456
	int errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   457
	TDCFError cerr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   458
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   459
	// initialise the result
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   460
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   461
	rv.iSubComponentResult = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   462
	rv.iData0 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   463
	rv.iData1 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   464
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   465
	// make sure that the process isn't running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   466
	if( iAgentProcess != NULL ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   467
		rv.iServiceResult = ERR_INVALIDSTATE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   468
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   469
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   470
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   471
	// modify the config file
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   472
	cerr = iDynamicsConfigFile.RemoveSingleOption( aArgs.iOptionToken, &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   473
	if( cerr != DCE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   474
		rv.iServiceResult = ERR_CONFIG_FILE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   475
		rv.iSubComponentResult = (int)cerr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   476
		rv.iData0 = errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   477
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   478
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   479
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   480
	// return success
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   481
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   482
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   483
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   484
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   485
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   486
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   487
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   488
 * PUBLIC FUNCTION: addlistoption
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   489
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   490
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   491
TResult CSFacontroller::addlistoption( TOptionDesc aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   492
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   493
	TResult rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   494
	int errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   495
	TDCFError cerr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   496
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   497
	// initialise the result
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   498
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   499
	rv.iSubComponentResult = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   500
	rv.iData0 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   501
	rv.iData1 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   502
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   503
	// make sure that the process isn't running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   504
	if( iAgentProcess != NULL ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   505
		rv.iServiceResult = ERR_INVALIDSTATE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   506
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   507
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   508
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   509
	// modify the config file
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   510
	cerr = iDynamicsConfigFile.AddListOption( aArgs.iOptionBlockStart, aArgs.iOptionBlockEnd, aArgs.iOptionValue, &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   511
	if( cerr != DCE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   512
		rv.iServiceResult = ERR_CONFIG_FILE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   513
		rv.iSubComponentResult = (int)cerr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   514
		rv.iData0 = errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   515
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   516
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   517
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   518
	// return success
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   519
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   520
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   521
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   522
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   523
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   524
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   525
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   526
 * PUBLIC FUNCTION: removelistoption
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   527
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   528
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   529
TResult CSFacontroller::removelistoption( TOptionDesc aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   530
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   531
	TResult rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   532
	int errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   533
	TDCFError cerr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   534
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   535
	// initialise the result
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   536
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   537
	rv.iSubComponentResult = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   538
	rv.iData0 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   539
	rv.iData1 = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   540
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   541
	// make sure that the process isn't running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   542
	if( iAgentProcess != NULL ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   543
		rv.iServiceResult = ERR_INVALIDSTATE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   544
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   545
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   546
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   547
	// modify the config file
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   548
	cerr = iDynamicsConfigFile.RemoveListOption( aArgs.iOptionBlockStart, aArgs.iOptionBlockEnd, aArgs.iOptionToken, &errcode );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   549
	if( cerr != DCE_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   550
		rv.iServiceResult = ERR_CONFIG_FILE_ERROR;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   551
		rv.iSubComponentResult = (int)cerr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   552
		rv.iData0 = errcode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   553
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   554
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   555
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   556
	// return success
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   557
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   558
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   559
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   560
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   561
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   562
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   563
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   564
 * PUBLIC FUNCTION: getstatus
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   565
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   566
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   567
TFaStatusInfo CSFacontroller::getstatus( int aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   568
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   569
	TFaStatusInfo rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   570
	TDynamicsCallInfo cres;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   571
	TForeignAgentStatusInfo foreign_agent_info;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   572
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   573
	// init the return value
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   574
	memset( &rv, 0, sizeof(rv) );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   575
	rv.iCallResult.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   576
	
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   577
	// check that the agent is running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   578
	rv.iCallResult = is_agent_running();
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   579
	if( rv.iCallResult.iServiceResult != ERR_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   580
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   581
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   582
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   583
	// make the call to dynamics
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   584
	cres = iDynamicsCommand.ForeignAgentGetStatus( &foreign_agent_info );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   585
	if( cres.iResult != DC_SUCCESS ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   586
		set_dynamics_error( &(rv.iCallResult), &cres );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   587
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   588
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   589
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   590
	// set the result
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   591
	rv.iAdvertisementsSent = foreign_agent_info.iAdvertisementsSent;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   592
	rv.iDiscardedMalformed = foreign_agent_info.iDiscardedMalformed;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   593
	rv.iDiscardedUnknownExtension = foreign_agent_info.iDiscardedUnknownExtension;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   594
	rv.iDiscardedVendor = foreign_agent_info.iDiscardedVendor;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   595
	rv.iPendingRegistrationRequests = foreign_agent_info.iPendingRegistrationRequests;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   596
	rv.iReplysAccepted = foreign_agent_info.iReplysAccepted;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   597
	rv.iReplysRejected = foreign_agent_info.iReplysRejected;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   598
	rv.iRequestsAccepted = foreign_agent_info.iRequestsAccepted;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   599
	rv.iRequestsRejected = foreign_agent_info.iRequestsRejected;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   600
	rv.iTunnelCount = foreign_agent_info.iTunnelCount;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   601
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   602
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   603
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   604
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   605
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   606
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   607
 * PUBLIC FUNCTION: destroytunnelid
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   608
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   609
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   610
TResult CSFacontroller::destroytunnelid( TFaTunnelID aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   611
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   612
	TResult rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   613
	TDynamicsCallInfo cres;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   614
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   615
	// init the return value
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   616
	memset( &rv, 0, sizeof(rv) );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   617
	rv.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   618
	
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   619
	// check that the agent is running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   620
	rv = is_agent_running();
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   621
	if( rv.iServiceResult != ERR_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   622
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   623
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   624
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   625
	// make the call to dynamics
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   626
	cres = iDynamicsCommand.ForeignAgentDestroyTunnel( aArgs.iMobileNodeAddress );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   627
	if( cres.iResult != DC_SUCCESS ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   628
		set_dynamics_error( &rv, &cres );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   629
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   630
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   631
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   632
	// done 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   633
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   634
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   635
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   636
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   637
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   638
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   639
 * PUBLIC FUNCTION: listtunnels
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   640
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   641
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   642
TFaTunnelList CSFacontroller::listtunnels( int aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   643
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   644
	TResult res;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   645
	TFaTunnelList rv = { 0, NULL };
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   646
	TDynamicsCallInfo cres;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   647
	TTunnelID tunnel_list[MAXTUNNELS];
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   648
	int tunnel_count = MAXTUNNELS, i;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   649
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   650
	// check that the agent is running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   651
	res = is_agent_running();
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   652
	if( res.iServiceResult != ERR_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   653
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   654
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   655
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   656
	// make the call to dynamics
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   657
	cres = iDynamicsCommand.ForeignAgentGetTunnels( &tunnel_count, tunnel_list );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   658
	if( cres.iResult != DC_SUCCESS ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   659
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   660
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   661
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   662
	// allocate memory for the list
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   663
	rv.TFaTunnelList_len = tunnel_count;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   664
	rv.TFaTunnelList_val = (TFaTunnelID*)calloc( tunnel_count, sizeof(TFaTunnelID) );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   665
	assert( rv.TFaTunnelList_val != NULL );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   666
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   667
	// now return the information
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   668
	for( i = 0; i < tunnel_count; i++ ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   669
		(rv.TFaTunnelList_val)[i].iAgentID = 0;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   670
		(rv.TFaTunnelList_val)[i].iID = (tunnel_list[i]).iTunnelID;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   671
		(rv.TFaTunnelList_val)[i].iHomeAgentAddress = (tunnel_list[i]).iHomeAgentAddress;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   672
		(rv.TFaTunnelList_val)[i].iMobileNodeAddress = (tunnel_list[i]).iMobileNodeAddress;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   673
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   674
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   675
	// done - success
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   676
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   677
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   678
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   679
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   680
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   681
 * PUBLIC FUNCTION: gettunnelinfo
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   682
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   683
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   684
TFaTunnelInfo CSFacontroller::gettunnelinfo( TGetTunnelRequest aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   685
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   686
	TFaTunnelInfo rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   687
	TDynamicsCallInfo cres;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   688
	TForeignAgentTunnelInfo fati;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   689
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   690
	// init the result
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   691
	memset( &rv, 0, sizeof(rv) );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   692
	rv.iCallResult.iServiceResult = ERR_NONE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   693
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   694
	// check that the agent is running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   695
	rv.iCallResult = is_agent_running();
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   696
	if( rv.iCallResult.iServiceResult != ERR_NONE ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   697
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   698
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   699
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   700
	// make the call to dynamics
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   701
	cres = iDynamicsCommand.ForeignAgentGetTunnelInfo( aArgs.iMobileNodeAddress, &fati );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   702
	if( cres.iResult != DC_SUCCESS ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   703
		set_dynamics_error( &(rv.iCallResult), &cres );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   704
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   705
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   706
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   707
	// set the info
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   708
	rv.iCareofAddress = fati.iCareofAddress;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   709
	rv.iCreationTime = fati.iCreationTime;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   710
	rv.iExpirationTime = fati.iExpirationTime;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   711
	rv.iHomeAgentAddress = fati.iHomeAgentAddress;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   712
	rv.iLastTimestamp = fati.iLastTimestamp;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   713
	rv.iMobileNodeAddress = fati.iMobileNodeAddress;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   714
	rv.iPrivateHomeAgentID = fati.iPrivateHomeAgentID;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   715
	rv.iRefreshTime = fati.iRefreshTime;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   716
	rv.iSPI = fati.iSPI;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   717
	rv.iTimeout = fati.iTimeout;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   718
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   719
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   720
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   721
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   722
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   723
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   724
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   725
 * PUBLIC FUNCTION: settimeout
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   726
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   727
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   728
void CSFacontroller::settimeout( TTimeoutRequest aArgs )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   729
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   730
	iDynamicsCallTimeout = aArgs.iTimeout;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   731
	iDynamicsCommand.SetTimeout( aArgs.iTimeout );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   732
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   733
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   734
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   735
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   736
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   737
 * PRIVATE FUNCTION: is_agent_running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   738
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   739
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   740
TResult CSFacontroller::is_agent_running()
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   741
{	
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   742
	TResult rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   743
	TCAProcessError perr;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   744
	TProcessStatus pstatus;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   745
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   746
	// clear the rv
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   747
	memset( &rv, 0, sizeof(rv) );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   748
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   749
	// check that the agent was running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   750
	if( iAgentProcess == NULL ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   751
		rv.iServiceResult = ERR_INVALIDSTATE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   752
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   753
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   754
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   755
	// check that the agent is still runnning
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   756
	perr = iAgentProcess->GetProcessStatus( &pstatus );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   757
	assert( perr == CAE_NONE );
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   758
	if( pstatus != PS_STARTED ) {
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   759
		rv.iServiceResult = ERR_INVALIDSTATE;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   760
		return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   761
	}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   762
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   763
	// done - success
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   764
	return rv;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   765
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   766
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   767
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   768
/****************************************************************************************
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   769
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   770
 * PRIVATE FUNCTION: is_agent_running
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   771
 * 
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   772
 ***************************************************************************************/
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   773
void CSFacontroller::set_dynamics_error( TResult *result, TDynamicsCallInfo *cres )
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   774
{
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   775
	result->iServiceResult = ERR_DYNAMICS_CALL_FAILED;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   776
	result->iSubComponentResult = cres->iResult;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   777
	result->iData0 = cres->iErrorCode;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   778
	result->iData1 = cres->iErrorDetail;
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   779
}
3da2a79470a7 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   780