testexecmgmt/ucc/Source/TestExecuteUCCPlugin/CUCCTestStep.cpp
changeset 0 3da2a79470a7
equal deleted inserted replaced
-1:000000000000 0:3da2a79470a7
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file CUCCTestStep.cpp
       
    22 */
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 #include "assert.h"
       
    27 #include "CUCCTestStep.h"
       
    28 #include "CUCCSDeviceProtocol.h"
       
    29 
       
    30 _LIT( delim, "|" );
       
    31 
       
    32 CUCCTestStep::CUCCTestStep() 
       
    33 	{
       
    34 	}
       
    35 
       
    36 CUCCTestStep::~CUCCTestStep()
       
    37 	{
       
    38 	}
       
    39 
       
    40 CUCCSDeviceControl *CUCCTestStep::CreateApplicationControlInstance( int *aUID, TBool aUIDRequired )
       
    41 	{
       
    42 	int r = 0;
       
    43 	TBool rv;
       
    44 	TBuf<50> initialisation_string;
       
    45 	TPtrC temp_string;
       
    46 	CUCCSDeviceControl *app_instance = NULL;
       
    47 
       
    48 	// check params
       
    49 	assert( aUID != NULL );
       
    50 	*aUID = -1;
       
    51 
       
    52 	// Note: I've changed the tags of the ini files, but am keeping support for the old tags 
       
    53 	TDPTransport transType = TDP_NONE;
       
    54 	
       
    55 	// Get the com port from the ini file and add it to the initialisation string
       
    56 	if( GetStringFromConfig( _L("UCCControl"), _L("CommPortIndex"), temp_string ) )
       
    57 		{
       
    58 		initialisation_string.Append( temp_string );
       
    59 		initialisation_string.Append( delim );
       
    60 		initialisation_string.Append( _L("115200") );
       
    61 		initialisation_string.Append( delim );
       
    62 		transType = TDP_SERIAL;
       
    63 		}
       
    64 	else if( GetStringFromConfig( _L("UCCControl"), _L("RemoteHost"), temp_string ) )
       
    65 		{
       
    66 		initialisation_string.Append( temp_string );
       
    67 		initialisation_string.Append( delim );
       
    68 		if( GetIntFromConfig( _L("UCCControl"), _L("IAP"), r) )
       
    69 			{
       
    70 			initialisation_string.Append( _L("IAP:") );
       
    71 			initialisation_string.AppendNum(r);
       
    72 			initialisation_string.Append( delim );
       
    73 			}
       
    74 		if( r == 0 && GetIntFromConfig( _L("UCCControl"), _L("SNAP"), r) )
       
    75 			{
       
    76 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
    77 			initialisation_string.Append( _L("SNAP:") );
       
    78 			initialisation_string.AppendNum(r);
       
    79 			initialisation_string.Append( delim );
       
    80 #else
       
    81 			r = 0;
       
    82 			INFO_PRINTF1(_L("Access Point selection is not supported.."));
       
    83 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
    84 			}
       
    85 		transType = TDP_TCP;
       
    86 		}
       
    87 	else
       
    88 		{
       
    89 		return NULL;
       
    90 		}
       
    91 
       
    92 	// Get the test id (use case number) from the ini file
       
    93 	// Only if it is required.
       
    94 	if( aUIDRequired )
       
    95 		{
       
    96 		rv = GetIntFromConfig( _L("UCCControl"), _L("UseCaseID"), (*aUID) );
       
    97 		if( rv == 0 )
       
    98 			{
       
    99 			rv = GetIntFromConfig( _L("Test_Common"), _L("testID"), (*aUID) );
       
   100 			if( rv == 0 )
       
   101 				{
       
   102 				return NULL;
       
   103 				}
       
   104 			}
       
   105 		}
       
   106 
       
   107 	// create the application control object
       
   108 	app_instance = CUCCSDeviceControl::New();	
       
   109 	assert (app_instance != NULL);
       
   110 
       
   111 	// connect to the uccs
       
   112 	r = app_instance->connectL( (TDesC16*)&initialisation_string, transType );
       
   113 	if( r != 0)
       
   114 		{
       
   115 		delete app_instance;
       
   116 		return NULL;
       
   117 		}
       
   118 
       
   119 	// done return the info
       
   120 	return app_instance;
       
   121 	}