cbsref/telephonyrefplugins/atltsy/integrationtest/src/testltsyshareddata.cpp
changeset 44 8b72faa1200f
equal deleted inserted replaced
39:2473f5e227f9 44:8b72faa1200f
       
     1 // @file TestTelephonySharedData.cpp
       
     2 //
       
     3 // Copyright (c) 2004-2007 Symbian Software Ltd. All rights reserved.
       
     4 //
       
     5 // This contains implementation of Shared Data
       
     6 
       
     7 // User include
       
     8 #include "TestLtsySharedData.h"
       
     9 
       
    10 // Epoc include
       
    11 #include <etelmm.h>
       
    12 
       
    13 /*@{*/
       
    14 /// Literal constants
       
    15 _LIT(KSimTsyName,		"SIM");
       
    16 _LIT(KPhoneName,		"SimulatorPhone");
       
    17 _LIT(KDummyTsyName,		"DMM");
       
    18 _LIT(KDMobile,			"DMobile");
       
    19 /*@}*/
       
    20 
       
    21 CTestLtsySharedData* CTestLtsySharedData::NewL()
       
    22 	{
       
    23 	CTestLtsySharedData*	self=new(ELeave) CTestLtsySharedData();
       
    24 	CleanupStack::PushL(self);
       
    25 	self->ConstructL();
       
    26 	CleanupStack::Pop();
       
    27 	return self;
       
    28 	}
       
    29 
       
    30 CTestLtsySharedData::CTestLtsySharedData()
       
    31 :	CBase()
       
    32 ,	iCallId(CTelephony::EISVCall1)
       
    33 ,	iCallId1(CTelephony::EISVCall2)
       
    34 ,	iTelServerConnected(EFalse)
       
    35 ,	iPhoneModuleLoaded(EFalse)
       
    36 ,	iPhoneOpened(EFalse)
       
    37 ,	iPhoneInitialised(EFalse)
       
    38 ,	iLineOpened(EFalse)
       
    39 ,	iCallOpened(EFalse)
       
    40 ,	iTelephony(NULL)
       
    41 ,	iActiveScheduler(NULL)
       
    42 /*
       
    43 Constructor
       
    44 */
       
    45 	{
       
    46 	}
       
    47 
       
    48 CTestLtsySharedData::~CTestLtsySharedData()
       
    49 /*
       
    50 Destructor
       
    51 */
       
    52 	{
       
    53 	ClosePhone();
       
    54 	}
       
    55 
       
    56 void CTestLtsySharedData::ConstructL()
       
    57 	{
       
    58 	}
       
    59 
       
    60 TInt CTestLtsySharedData::OpenPhone(const TName& aTsyName, CTestStep& aTestStep)
       
    61 /*
       
    62 This function will load TSY depending on the comms db
       
    63 settings and opens the phone for making a call.
       
    64 
       
    65 @param - TSY to be loaded
       
    66 @param - CTestStep instance
       
    67 @leave - system wide error codes
       
    68 */
       
    69 	{
       
    70 	ClosePhone();
       
    71 
       
    72 	// Load the phone module depending on the comms DB settings
       
    73 	TInt	ret=KErrNone;
       
    74 	if(aTsyName.Compare(KSimTsyName) == 0 )
       
    75 		{
       
    76 		iTSYName = aTsyName;
       
    77 		}
       
    78 	else if (aTsyName.Compare(KDummyTsyName) == 0 )
       
    79 		{
       
    80 		iTSYName = aTsyName;
       
    81 		}
       
    82 	else
       
    83 		{
       
    84 		ret=KErrArgument;
       
    85 		}
       
    86 
       
    87 	if ( ret==KErrNone )
       
    88 		{
       
    89 		ret = ReopenPhone();
       
    90 		}
       
    91 
       
    92 	if ( ret!=KErrNone )
       
    93 		{
       
    94 		aTestStep.ERR_PRINTF2(_L("Failed to open phone. Error code = %d"), ret);
       
    95 		aTestStep.SetTestStepResult(EFail);
       
    96 		}
       
    97 
       
    98 	return ret;
       
    99 	}
       
   100 
       
   101 TInt CTestLtsySharedData::ReopenPhone()
       
   102 /*
       
   103 This function will load TSY depending on the comms db
       
   104 settings and opens the phone for making a call.
       
   105 
       
   106 @param - CTestStep instance
       
   107 @leave - system wide error codes
       
   108 */
       
   109 	{
       
   110 	TRAPD(ret, iActiveScheduler=new (ELeave) CActiveScheduler());
       
   111 
       
   112 	if ( ret==KErrNone )
       
   113 		{
       
   114 		CActiveScheduler::Install(iActiveScheduler);
       
   115 		ret=iServer.Connect();
       
   116 		}
       
   117 
       
   118 	if ( ret==KErrNone )
       
   119 		{
       
   120 		iTelServerConnected = ETrue;
       
   121 		ret=iServer.LoadPhoneModule(iTSYName);
       
   122 		}
       
   123 
       
   124 	if ( ret==KErrNone )
       
   125 		{
       
   126 		iPhoneModuleLoaded = ETrue;
       
   127 		TRAP(ret, iTelephony=CTelephony::NewL());
       
   128 		}
       
   129 
       
   130 	if ( ret==KErrNone )
       
   131 		{
       
   132 		// Open the phone
       
   133 		if ( iTSYName.Compare(KDummyTsyName) == 0 )
       
   134 			{
       
   135 			// Open the phone with the Dummy mobile phone name
       
   136 			ret = iMobilePhone.Open(iServer, KDMobile);
       
   137 			}
       
   138 		else
       
   139 			{
       
   140 			// open the phone with the simuplator phone
       
   141 			ret = iMobilePhone.Open(iServer, KPhoneName);
       
   142 			}
       
   143 		iPhoneOpened = ret==KErrNone;
       
   144 		}
       
   145 
       
   146 	return ret;
       
   147 	}
       
   148 
       
   149 void CTestLtsySharedData::ClosePhone()
       
   150 /*
       
   151 Closes the RTelServer, RmobilePhone,RMobileCall and RMobileLine opened sessions.
       
   152 */
       
   153 	{
       
   154 	if ( iCallOpened )
       
   155 		{
       
   156 		iMobileCall.Close();
       
   157 		iCallOpened=EFalse;
       
   158 		}
       
   159 
       
   160 	if ( iLineOpened )
       
   161 		{
       
   162 		iMobileLine.Close();
       
   163 		iLineOpened=EFalse;
       
   164 		}
       
   165 
       
   166 	if ( iPhoneOpened )
       
   167 		{
       
   168 		iMobilePhone.Close();
       
   169 		iPhoneOpened = EFalse;
       
   170 		}
       
   171 
       
   172 	if ( iTelephony!= NULL )
       
   173 		{
       
   174 		delete iTelephony;
       
   175 		iTelephony=NULL;
       
   176 		}
       
   177 
       
   178 	if ( iPhoneModuleLoaded )
       
   179 		{
       
   180 		iServer.UnloadPhoneModule(iTSYName);
       
   181 		iPhoneModuleLoaded = EFalse;
       
   182 		}
       
   183 
       
   184 	if ( iTelServerConnected )
       
   185 		{
       
   186 		iServer.Close();
       
   187 		iTelServerConnected = EFalse;
       
   188 		}
       
   189 
       
   190 	CActiveScheduler::Install(NULL);
       
   191 	delete iActiveScheduler;
       
   192 	iActiveScheduler=NULL;
       
   193 	}