TInt CTestDriveSsFax::DriveETelApiL()
//
// This function contains the real meat of the Client-side test code
//
	{
	_LIT(KFaxLineName,"Fax");
	_LIT(KMmPhoneName,"GsmPhone1");

	RMobilePhone mmPhone;
	INFO_PRINTF1(_L("Opening Multimode Phone\n"));
	TESTL(mmPhone.Open(iServer,KMmPhoneName)==KErrNone);

	RLine faxLine;
	INFO_PRINTF1(_L("Opening Fax Line\n"));
	TESTL(faxLine.Open(iPhone,KFaxLineName)==KErrNone);
 	RCall faxCall;
	INFO_PRINTF1(_L("Opening New fax Call\n"));
	TESTL(faxCall.OpenNewCall(faxLine)==KErrNone);

	TRequestStatus stat1,stat2,reqStatus;
	RMobilePhone::TMMTableSettings tableSettings;
	tableSettings.iLocId=KInternetAccessPoint;
	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
	iPhone.InitialiseMM(reqStatus , tableSettingsPckg); 	
	User::WaitForRequest(reqStatus);
	TESTL(reqStatus == KErrNone);

	// Now wait for an incoming fax call...
	INFO_PRINTF1(_L("Answering a Fax Call\n"));
	RCall::TFaxSessionSettings faxSessionSettings;
	faxSessionSettings.iMode=RCall::EReceive;
	faxSessionSettings.iFaxRetrieveType=RCall::EFaxOnDemand;
	faxSessionSettings.iFaxClass=EClassAuto;
	faxSessionSettings.iFaxId.Zero();
	faxSessionSettings.iMaxSpeed=14400;
	faxSessionSettings.iMinSpeed=12000;
	faxSessionSettings.iRxResolution=EFaxNormal;
	faxSessionSettings.iRxCompression=EModifiedHuffman;
	faxCall.SetFaxSettings(faxSessionSettings);
	faxCall.AnswerIncomingCall(stat2);
	User::After(2000000L);					// Wait for a 2secs to make sure the port is "access denied"

	INFO_PRINTF1(_L("Get Signal Strength\n"));
	TInt32 signalStrength;
	TInt8 bar=0;
	mmPhone.GetSignalStrength(stat1,signalStrength,bar);
	User::WaitForRequest(stat1);
	TESTL(stat1==KErrAccessDenied);			// The port is "access denied" by this time

	User::WaitForRequest(stat2);
	User::After(300000L);
	TESTL(faxCall.HangUp()==KErrNone);
	
	mmPhone.Close();
	faxLine.Close();
	faxCall.Close();
	return KErrNone;
	}
/**
This function opens a RMobileSmartCardEap sub-session from RMobilePhone
that will refer to the application referenced by aAID.  It will be
assumed that the application exists and contains a DF_EAP for the
aEapType specified.  The client must call
RMobileSmartCardEap::InitialiseEapMethod() to ensure correct
functionality of this sub-session.

@param aPhone The RMobilePhone sub-session relative to which this
              sub-session will open.
@param aAId The UICC Application ID, which should be of one that has
            EAP support.
@param aEapType The EAP method type that this sub-session will use
                under the aAID application.

@return KErrNone if successful, otherwise a system-wide error code.
@see RMobileSmartCardEap::InitialiseEapMethod()

@capability None

@publishedPartner
@released
*/
EXPORT_C TInt RMobileSmartCardEap::Open(RMobilePhone& aPhone, const RMobilePhone::TAID& aAID, const TEapType& aEapType)
	{
	RSessionBase* session = &aPhone.SessionHandle();
	__ASSERT_ALWAYS(session != NULL, PanicClient(EEtelPanicNullHandle));
	TInt subSessionHandle = aPhone.SubSessionHandle();
	__ASSERT_ALWAYS(subSessionHandle != NULL, PanicClient(EEtelPanicNullHandle));

	TRAPD(ret, ConstructL());
	if (ret != KErrNone)
		{
		Destruct();
		return ret;
		}

	// Appending the application ID and Eap Type to the name of the
	// subsession; plus two one-byte delimeters indicating lengths.
	// See var appIdbuf for why KAIDSize is multiplied by 2.
	TBufC<SCEAP_SSN_LENGTH + RMobilePhone::KAIDSize*2 +
	      KEapTypeSize + 2> nameBuf(KETelSmartCardEapSession); // 2 for delimeters
	TPtr name(nameBuf.Des());

	// the length of the AID as a Sept ASCII character
	TChar lengthAIDChar = SeptChar(aAID.Length());

	// the value of the AID
	// converted to a 16-bit string representation.  Multiply by 2,
	// since each AID byte is represented as two sem-octects.
	TBufC<2*RMobilePhone::KAIDSize> appIdbuf;
	TPtr appIdPtr(appIdbuf.Des());
	ConvertBinToText(aAID, appIdPtr);

	// the length of the EapType
	TInt lengthEapType = aEapType.Length();
	TChar charEapType = SeptChar(lengthEapType);

	// the value of the EapType (converted to 16-bit)
	TBufC<KEapTypeSize> eapTypeBuf;
	TPtr eapTypePtr(eapTypeBuf.Des());
	eapTypePtr.Copy(aEapType);

	// appending...
	name.Append(lengthAIDChar);
	name.Append(appIdPtr);
	name.Append(charEapType);
	name.Append(eapTypePtr);

	TIpcArgs args(&name, TIpcArgs::ENothing, subSessionHandle);
	SetSessionHandle(*session);
	ret = CreateSubSession(*session, EEtelOpenFromSubSession, args);

	if (ret != KErrNone)
		{
		Destruct();
		}

	return ret;
	}
/**
* Notify reset for RMobilePhone::NotifyCallBarringStatusChange
*/	
void TSupplementalTsyTestHelper::WaitForMobilePhoneNotifyCallBarringStatusChange( 
				RMobilePhone& aMobilePhone,
				TEtelRequestBase& aRequestStatus,
				RMobilePhone::TMobilePhoneCBCondition& aCondition, 
				RMobilePhone::TMobilePhoneCBCondition aExpectedCondition,
				TInt aWantedStatus )

	{
	// Wait for the request to complete	
	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeLong);	
	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyCallBarringStatusChange did not complete"))
	
	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
							&& aCondition != aExpectedCondition )
		{
		// Request has completed with incorrect result. Consume any outstanding
		// Repost notification until timeout or we get the right result.
		
		aMobilePhone.NotifyCallBarringStatusChange(aRequestStatus, aCondition);
		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
		}
		
	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyCallBarringStatusChange Wrong completion status"))	
	ASSERT_EQUALS(aCondition, aExpectedCondition, 
				_L("RMobilePhone::NotifyCallBarringStatusChange Wrong result"))	
	
	// Cancel request if it is still pending	
	if (aRequestStatus.Int() == KRequestPending)	
		{
		aRequestStatus.Cancel();
		}
	}
/**
* Notify reset for RMobilePhone::NotifyCallServiceCapsChange
*/	
void TSupplementalTsyTestHelper::WaitForMobilePhoneNotifyCallServiceCapsChange( 
				RMobilePhone& aMobilePhone,
				TEtelRequestBase& aRequestStatus,
				TUint32& aCaps, 
				TUint32 aWantedCaps,
				TUint32 aUnwantedCaps,
				TInt aWantedStatus )

	{
	// Wait for the request to complete	
	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyCallServiceCapsChange did not complete"))
	
	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  
							&& ( ((aCaps & aWantedCaps) != aWantedCaps)
								 || ((aCaps & aUnwantedCaps) != 0) ) )
		{
		// Request has completed with incorrect result. Consume any outstanding
		// Repost notification until timeout or we get the right result.	
		aMobilePhone.NotifyCallServiceCapsChange(aRequestStatus, aCaps);
		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
		}
		
	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, 
				_L("RMobilePhone::NotifyCallServiceCapsChange Wrong completion status"))	
	ASSERT_BITS_SET(aCaps, aWantedCaps, aUnwantedCaps, 
				_L("RMobilePhone::NotifyCallServiceCapsChange Wrong caps"))
	
	// Cancel request if it is still pending	
	if (aRequestStatus.Int() == KRequestPending)	
		{
		aRequestStatus.Cancel();
		}
	}
/**
* Notify reset for RMobilePhone::NotifyIdentityServiceStatus
*/	
void TSupplementalTsyTestHelper::WaitForMobilePhoneNotifyIdentityServiceStatus( 
				RMobilePhone& aMobilePhone,
				TEtelRequestBase& aRequestStatus,
				RMobilePhone::TMobilePhoneIdService& aService, 
				RMobilePhone::TMobilePhoneIdService aExpectedService,
				RMobilePhone::TMobilePhoneIdServiceStatus &aStatus,
				TInt aWantedStatus )

	{
	// Wait for the request to complete	
	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyIdentityServiceStatus did not complete"))
	
	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
							&& aService != aExpectedService )
		{
		// Request has completed with incorrect result. Consume any outstanding
		// Repost notification until timeout or we get the right result.
		
		aMobilePhone.NotifyIdentityServiceStatus(aRequestStatus, aService, aStatus);
		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
		}
		
	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyIdentityServiceStatus Wrong completion status"))	
	ASSERT_EQUALS(aService, aExpectedService, 
				_L("RMobilePhone::NotifyIdentityServiceStatus Wrong result"))	
	
	// Cancel request if it is still pending	
	if (aRequestStatus.Int() == KRequestPending)	
		{
		aRequestStatus.Cancel();
		}
	}
/**
* Notify reset for RMobilePhone::NotifyCCBSRecall
*/	
void TSupplementalTsyTestHelper::WaitForMobilePhoneNotifyCCBSRecall( 
				RMobilePhone& aMobilePhone,
				TEtelRequestBase& aRequestStatus,
				TCmpBase<RMobilePhone::TMobilePhoneCCBSEntryV2> &aMobilePhoneCCBSEntryV2,
				TInt aWantedStatus )

	{
	// Wait for the request to complete	
	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyCCBSRecall did not complete"))
	
	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
							&& !aMobilePhoneCCBSEntryV2.IsEqual(ENoLogError) )
		{
		// Request has completed with incorrect result. Consume any outstanding
		// Repost notification until timeout or we get the right result.		
		RMobilePhone::TMobilePhoneCCBSEntryV2Pckg pkgParam( aMobilePhoneCCBSEntryV2.GetValue() );
		aMobilePhone.NotifyCCBSRecall(aRequestStatus, pkgParam);
		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
		}

	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyCCBSRecall Wrong completion status"))	
	ASSERT_TRUE(aMobilePhoneCCBSEntryV2.IsEqual(ELogError), 
				_L("RMobilePhone::NotifyCCBSRecall Wrong result"))	
	
	// Cancel request if it is still pending	
	if (aRequestStatus.Int() == KRequestPending)	
		{
		aRequestStatus.Cancel();
		}
	}
const CBBSensorEvent& CLogBatteryImpl::get_value()
{
	CALLSTACKITEM_N(_CL("CLogBatteryImpl"), _CL("get_value"));

#ifndef __WINS__
#  ifndef __S60V2__
	RPhoneType::TBatteryInfo	info;
	TInt err=Phone().GetBatteryInfo(info);
#  else
 	TRequestStatus s;
	RMobilePhone::TMobilePhoneBatteryInfoV1 info;
	iPhone.GetBatteryInfo(s, info);
	User::WaitForRequest(s);
	TInt err=s.Int();
#  endif

	if (err==KErrNone) {
		iValue.iLevel=info.iChargeLevel;
		iValue.iState=info.iStatus;
	} else {
		TBuf<100> msg=_L("failed to get battery status: ");
		msg.AppendNum(err);
		post_error(msg, err);
	}
#else
	iValue.iLevel=100;
	iValue.iState=1;
#endif
	return iEvent;
}
void CEtelMMLbsTestStepBase::OOMTest_DialEmergencyCall()
 {
 	const TInt KMaxTests = 1000;	
 	RMobilePhone mmPhone;
	TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
	TEST(ret==KErrNone);
	RMobileLine mmLine;
	ret=mmLine.Open(mmPhone,DMMTSY_LINE_VOICE_NAME);
    TEST(ret==KErrNone);
	RMobileCall mmCall;
	TName callName;
	ret=mmCall.OpenNewCall(mmLine,callName);
    TEST(ret==KErrNone);
	TRequestStatus reqStatus;
	TBuf<RMobileENStore::KEmergencyNumberSize> aNumber(DMMTSY_EN_STORE_AMBULANCE_NUM);

	TBool oomAvailable = EFalse; 
	TInt failure=1;
	while (!oomAvailable  && failure < KMaxTests)
		{
	  	iTelServer.__DbgFailNext(failure);
     	mmCall.DialEmergencyCall(reqStatus, aNumber);
   		User::WaitForRequest(reqStatus);
		INFO_PRINTF2(_L("mmCall.DialEmergencyCall(reqStatus, aNumber);%d "),reqStatus.Int());
		TEST(reqStatus==KErrNone); 
		if(reqStatus!=KErrNone)	
			{
			INFO_PRINTF2(_L("Failing after %d Allocs"),failure); 
			} 
		else 
			{ 
			INFO_PRINTF2(_L("Passing after %d Allocs"),failure); 
			} 

		iTelServer.__DbgFailNextAvailable(oomAvailable); 
		failure++; 
		}
		
	// KMaxTests is used to stop the above while statement looping
	// indefinitely. If KMaxTests is reached then we can guess that something
	// has gone wrong and the test should be failed.
	TESTCHECKCONDITION(failure < KMaxTests);
	
	mmCall.Close();
	mmLine.Close();
	mmPhone.Close();
 }
// ----------------------------------------------------------------------------
// Construct USB serial number. Some of the personalities may need this.
// ----------------------------------------------------------------------------
//
void CUsbActivePersonalityHandler::ConstructUsbSerialNumberL()
    {
    LOG_FUNC

    RTelServer telServer;
    RMobilePhone phone;

    LEAVEIFERROR( telServer.Connect() );
    CleanupClosePushL( telServer );

    LEAVEIFERROR( telServer.LoadPhoneModule( KMmTsyModuleName ) );

    LEAVEIFERROR( phone.Open( telServer, KMmTsyPhoneName ) );
    CleanupClosePushL( phone );

    // to store the serial number to be published as the USB device's serial
    // number, fetch it from telephony server.
    TRequestStatus status;
    phone.GetPhoneId( status, iPhoneInfo );
    User::WaitForRequest( status );

    // make sure that the serial number fulfills USB requirements and then
    // convert the serial number so that it can be printed to log
    TLex lex( iPhoneInfo.iSerialNumber );
    TInt length = iPhoneInfo.iSerialNumber.Length();

    if( length < KSerialNumberLength )
        {
        // In GSM, the complete IMEI can be used as USB serial
        // number. But in CDMA, the ESN is too short for a valid Mass
        // Storage serial number (Mass-Storage and Bulk Only Transport
        // specs both require minimum 12 byte number), so it is
        // extended with trailing zeroes. When doing this, make sure
        // not to write anything over descriptor's max length
        if( iPhoneInfo.iSerialNumber.MaxLength() < KSerialNumberLength )
            {
            iPhoneInfo.iSerialNumber.SetLength( KSerialNumberLength );
            }
        while( length < KSerialNumberLength )
            {
            iPhoneInfo.iSerialNumber.Append( '0' );
            ++length;
            }
        }

    CleanupStack::PopAndDestroy( 2, &telServer );
    }
// -----------------------------------------------------------------------------
// CWimSimFileHandler::OpenCustomApiL
// Open CustomAPI for communication
// -----------------------------------------------------------------------------
//  
void CWimSimFileHandler::OpenCustomApiL()
    {
    _WIMTRACE(_L("WIM | WIMServer | CWimSimFileHandler::OpenCustomApiL | Begin"));
    iEtelServer = new( ELeave ) RTelServer();
    
    RMobilePhone phone;

    // Connect to the Etel server.
    TInt ret = iEtelServer->Connect();
    
    if ( ret != KErrNone )
        {
        _WIMTRACE2(_L("WIM | WIMServer | CWimSimFileHandler::OpenCustomApiL | Connection to etel server failed: %d"), ret);
        User::Leave( ret );
        }

    // Load phone module.
    ret = iEtelServer->LoadPhoneModule( KMmTsyModuleName );
    
    if ( ret != KErrNone )
        {
        _WIMTRACE2(_L("WIM | WIMServer | CWimSimFileHandler::OpenCustomApiL | loading phone module failed: %d"), ret);
        User::Leave( ret );
        }
    
    // Open phone
    ret = phone.Open( *iEtelServer, KMmTsyPhoneName );
         
    if ( ret != KErrNone )
        {
        _WIMTRACE2(_L("WIM | WIMServer | CWimSimFileHandler::OpenCustomApiL | phone.Open failed: %d"), ret);
        User::Leave( ret );
        }
    
    // Open new CustomAPI session for phone
    ret = iCustomApi->Open( phone );

    phone.Close(); // Close phone

    if ( ret != KErrNone )
        {
        _WIMTRACE2(_L("WIM | WIMServer | CWimSimFileHandler::OpenCustomApiL | iCustomApi->Open failed: %d"), ret);
        User::Leave( ret );
        }
    }
void CLogBatteryImpl::ConstructL()
{
	CALLSTACKITEM_N(_CL("CLogBatteryImpl"), _CL("ConstructL"));

	Mlog_base_impl::ConstructL();
	iEvent.iData()=&iValue; iEvent.iData.SetOwnsValue(EFalse);

#ifndef __WINS__
	CActiveScheduler::Add(this);

#ifndef __S60V2__
	Phone().BatteryInfoNotification(iStatus, iBatteryInfo);
#else
	RTelServer::TPhoneInfo info;
	User::LeaveIfError( TelServer().GetPhoneInfo( 0, info ) );
	User::LeaveIfError( iPhone.Open( TelServer(), info.iName ) );
	iPhone.NotifyBatteryInfoChange(iStatus, iBatteryInfo);
#endif
#endif
	SetActive();
}
void CLogBatteryImpl::DoCancel()
{
	CALLSTACKITEM_N(_CL("CLogBatteryImpl"), _CL("DoCancel"));

#ifndef __S60V2__
	Phone().BatteryInfoNotificationCancel();
#else
	iPhone.Close();
	if (iStatus.Int()==KRequestPending) {
		TRequestStatus *s=&iStatus;
		User::RequestComplete(s, KErrCancel);
	}
#endif
}
enum TVerdict CEtelMMTestAuthenticate::doTestStepL( void )
/**
 * Test step Authenticate
 *
 */
{
   __UHEAP_MARK;
	TInt ret;
	RMobilePhone phone;
	ret=phone.Open(iTelServer,DMMTSY_PHONE_NAMEAUTH1);
	TEST(ret==KErrNone);
	// start sanity test for
	// 2.4	REQ3877 Enable retrieval of the IMS authentication parameters

  	TRequestStatus reqStatus;
  	RMobilePhone::TImsAuthenticateDataV5 authenticateData;
  	authenticateData.iAUTN=DMMTSY_PHONE_AUTN_IN;
	authenticateData.iRAND=DMMTSY_PHONE_RAND_IN;
	authenticateData.iRES=DMMTSY_PHONE_RES_IN;
	authenticateData.iIK=DMMTSY_PHONE_IK_IN;
	authenticateData.iCK=DMMTSY_PHONE_CK_IN;
	authenticateData.iAUTS=DMMTSY_PHONE_AUTS_IN;


  	RMobilePhone::TImsAuthenticateDataV5Pckg authenticateDataPckgd(authenticateData);
  	phone.ImsAuthenticate (reqStatus,authenticateDataPckgd);
  	User::WaitForRequest(reqStatus);
  	TEST(reqStatus==KErrNone);
  	TEST(authenticateData.iAUTN==DMMTSY_PHONE_AUTN_OUT);
	TEST(authenticateData.iRAND==DMMTSY_PHONE_RAND_OUT);	
	TEST(authenticateData.iRES==DMMTSY_PHONE_RES_OUT);
	TEST(authenticateData.iIK==DMMTSY_PHONE_IK_OUT);		
	TEST(authenticateData.iCK==DMMTSY_PHONE_CK_OUT);
	TEST(authenticateData.iAUTS==DMMTSY_PHONE_AUTS_OUT);	
	
	
	authenticateData.iAUTN=DMMTSY_PHONE_AUTN_IN;
	authenticateData.iRAND=DMMTSY_PHONE_RAND_IN;
	
	phone.ImsAuthenticate(reqStatus,authenticateDataPckgd);
	phone.CancelAsyncRequest(EMobilePhoneIMSAuthenticate);
  	User::WaitForRequest(reqStatus);
  	TEST(reqStatus==KErrCancel);
	
			
  	phone.Close();
	// end sanity test for
	// 2.4	REQ3877 Enable retrieval of the IMS authentication parameters
	__UHEAP_MARKEND;

	return TestStepResult();
}
void CLogBatteryImpl::CheckedRunL()
{
	CALLSTACKITEM_N(_CL("CLogBatteryImpl"), _CL("CheckedRunL"));

	if (iStatus.Int()==KErrNone) {
		iValue.iLevel=iBatteryInfo.iChargeLevel;
		iValue.iState=iBatteryInfo.iStatus;
	} else {
		iErrorCount++;
		if (iErrorCount>5) User::Leave(iStatus.Int());
		get_value();
	}
	iEvent.iStamp()=GetTime();
	post_new_value(iEvent);

#ifndef __S60V2__
	Phone().BatteryInfoNotification(iStatus, iBatteryInfo);
#else
	iPhone.NotifyBatteryInfoChange(iStatus, iBatteryInfo);
#endif
	SetActive();
}
TInt CTestDriveDataCallRemoteTerm::DriveETelApiL()
/**
 * This method contains the real meat of the Client-side the "Data Call set-up, data 
 * transfer and remote termination" test code.  This method sets up to make a data-call
 * and then transfer data.  After the data transfer, the call is terminated by the remote end.
 *
 * @return KErrNone.
 */
	{
	_LIT(KMmPhoneName,"GsmPhone1");
	_LIT(KDataLineName,"Data");

	INFO_PRINTF1(_L("Opening Mobile Phone\n"));
	RMobilePhone mmPhone;
	TESTL(mmPhone.Open(iServer,KMmPhoneName)==KErrNone);

	RLine line;
	INFO_PRINTF1(_L("Opening Data Line\n"));
	TESTL(line.Open(iPhone,KDataLineName)==KErrNone);

	INFO_PRINTF1(_L("Opening New Data Call\n"));
	RCall call;
	TESTL(call.OpenNewCall(line)==KErrNone);

	TRequestStatus reqStatus;
	RMobilePhone::TMMTableSettings tableSettings;
	tableSettings.iLocId=KInternetAccessPoint;
	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
	iPhone.InitialiseMM(reqStatus , tableSettingsPckg); 	
	User::WaitForRequest(reqStatus);
	TESTL(reqStatus == KErrNone);

	// dial
	_LIT(KDialString,"+1234");
	TESTL(call.Dial(KDialString)==KErrNone);

	INFO_PRINTF1(_L("Loan Data Call Port to Comm Server\n"));
	RCall::TCommPort commPort;
	TESTL(call.LoanDataPort(commPort)==KErrNone);

	RCommServ cs;
	TESTL(cs.Connect()==KErrNone);

	RComm port;
	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);

	// Transfer data
	TRequestStatus stat;
	port.Write(stat,KWriteTestRemoteData);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);

    //-- a small delay between successive writes to the COM port
    //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem
    User::After(500000);		

	port.Write(stat,KWriteTestRemoteData);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);

	// Remote termination of call should have occurred in scripts, 
	// close port and comm server
	port.Close();
	cs.Close();
	INFO_PRINTF1(_L("Reclaim Data Call Port from Comm Server\n"));
	TESTL(call.RecoverDataPort()==KErrNone);

	TInt32 ss;
	TInt8 bar=0;
	mmPhone.GetSignalStrength(stat,ss,bar);
	User::WaitForRequest(stat);
	TESTL(stat==KErrNone);

	// close iPhone, line and call
	mmPhone.Close();
	line.Close();
	call.Close();
	return KErrNone;
	}
enum TVerdict CTestDialCallControlCorrectSIDCorrectCap::doTestStepL()
/**
@SYMTestCaseID TEL-ETEL-NA-2038
@SYMComponent  telephony_etel
@SYMTestCaseDesc To check client has the required SID and Capability to successfully call the RMobileCall::DialCallControl API.
@SYMTestPriority High
@SYMTestActions  Call the RMobileCall::DialCallControl API with required SID and required Capability and check the return value of the API
@SYMTestExpectedResults KErrNone when SID and capabilities are both correct.
@SYMTestType CT
*/
{
    TInt iTestCount = 1;

    RMobilePhone mmPhone;
    TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
    TEST(ret==KErrNone);

    RMobileLine mmLine;
    ret=mmLine.Open(mmPhone,DMMTSY_LINE_VOICE_NAME);
    TEST(ret==KErrNone);

    RMobileCall mmCall;
    TName callName;
    ret=mmCall.OpenNewCall(mmLine,callName);
    TEST(ret==KErrNone);

    RMobileCall::TMobileCallParamsV7 mmCallParamsV7;
    TEST(mmCallParamsV7.ExtensionId() == RMobileCall::KETelMobileCallParamsV7);

    mmCallParamsV7.iInterval = DMMTSY_CALL_INTERVAL;
    mmCallParamsV7.iIdRestrict = DMMTSY_CALL_CLI_RESTRICT_SETTING1;
    mmCallParamsV7.iCug.iExplicitInvoke = DMMTSY_CALL_CUG_INVOKE;
    mmCallParamsV7.iCug.iCugIndex = DMMTSY_CALL_CUG_INDEX;
    mmCallParamsV7.iCug.iSuppressOA = DMMTSY_CALL_CUG_OA;
    mmCallParamsV7.iCug.iSuppressPrefCug = DMMTSY_CALL_CUG_PREF;
    mmCallParamsV7.iAutoRedial = DMMTSY_CALL_AUTO_REDIAL_FLAG;
    mmCallParamsV7.iBearerMode = DMMTSY_CALL_NEW_BEARER;
    mmCallParamsV7.iCallParamOrigin = DMMTSY_CALL_PARAM_ORIGIN;
    mmCallParamsV7.iSubAddress = DMMTSY_CALL_SUBADDRESS;
    mmCallParamsV7.iBearerCap1 = DMMTSY_CALL_BEARER_CAP1;
    mmCallParamsV7.iBearerCap2 = DMMTSY_CALL_BEARER_CAP2;
    mmCallParamsV7.iBCRepeatIndicator = DMMTSY_CALL_BC_REPEAT_INDICATOR;
    mmCallParamsV7.iIconId.iQualifier = DMMTSY_CALL_ICON_ID_QUALIFIER;
    mmCallParamsV7.iIconId.iIdentifier = DMMTSY_CALL_ICON_ID_IDENTIFIER;
    mmCallParamsV7.iAlphaId = DMMTSY_CALL_ALPHA_ID;

    RMobileCall::TMobileCallParamsV7Pckg mmCallParamsV7Pckg(mmCallParamsV7);

    TBuf<RMobilePhone::KMaxMobileTelNumberSize> telNumber(DMMTSY_PHONE_TEL_NUMBER);

    TRequestStatus reqStatus;
    mmCall.DialCallControl(reqStatus, mmCallParamsV7Pckg, telNumber);
    User::WaitForRequest(reqStatus);

    TEST(reqStatus.Int()==KErrNone);
    INFO_PRINTF2(_L("Test %d - RMobileCall::DialCallControl correct SID correct caps passed"), iTestCount++);

    mmCall.Close();
    mmLine.Close();
    mmPhone.Close();

    return TestStepResult();
}
Beispiel #17
0
enum TVerdict CTestLine::doTestStepL()
//
// Test Line Functions
//
    {
	iTestCount=1;
	INFO_PRINTF1(_L(""));
	INFO_PRINTF1(_L("Test Mobile Line Functionality"));
//	LOGTEXT(_L8("Test Mobile Line Functionality"));
	
	RMobilePhone mmPhone;
	TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
	TEST(ret==KErrNone);

	RMobileLine mmLine;
	ret=mmLine.Open(mmPhone,DMMTSY_LINE_VOICE_NAME);
    TEST(ret==KErrNone);

	// Test for Primary or Auxillary voice line

	// line caps are part of Etel core api but as we have extended them 
	// in etelmm so we test the extension here 
	RLine::TCaps lineCaps = {DMMTSY_MOBILE_LINE_AUX_VOICE};
	lineCaps.iFlags ^= DMMTSY_MOBILE_LINE_AUX_VOICE; // make sure AUX voice bit is clear						

	// Get Caps will set the AUX voice bit 
	TEST(KErrNone==mmLine.GetCaps(lineCaps));

	if(lineCaps.iFlags & DMMTSY_MOBILE_LINE_AUX_VOICE)
		{
		INFO_PRINTF2(_L("Test %d - Line is an auxiliary voice line"), iTestCount) ;
		INFO_PRINTF2(_L("Test %d - Test for Primary or Auxillary voice line - passed"), iTestCount++);
		}
	else
		{
		INFO_PRINTF2(_L("Test %d - Line is a primary voice line"), iTestCount) ;
		INFO_PRINTF2(_L("Test %d - Test for Primary or Auxillary voice line - FAILED"), iTestCount++);
		}

	// Get Line Status
	TRequestStatus reqStatus;

	RMobileCall::TMobileCallStatus lineStatus;
	TEST(KErrNone==mmLine.GetMobileLineStatus(lineStatus));
	TEST(lineStatus==DMMTSY_CALL_STATUS1);
	INFO_PRINTF2(_L("Test %d - RMobileLine::GetMobileLineStatus (sync) passed"), iTestCount++);

	// Notify Change of Line Status
	// asynchronous

	mmLine.NotifyMobileLineStatusChange(reqStatus,lineStatus);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone);
	TEST(lineStatus==DMMTSY_CALL_STATUS2);

	// asynchronous & cancel

	mmLine.NotifyMobileLineStatusChange(reqStatus,lineStatus);
	mmLine.CancelAsyncRequest(EMobileLineNotifyMobileLineStatusChange);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
	if (reqStatus.Int()==KErrCancel)
		INFO_PRINTF2(_L("Test %d - RMobileLine::NotifyMobileLineStatusChange (async & cancel (Cancelled Request)) passed"), iTestCount++);
	else
		{
		TEST(lineStatus==DMMTSY_CALL_STATUS2);
		INFO_PRINTF2(_L("Test %d - RMobileLine::NotifyMobileLineStatusChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
		}

	mmLine.Close();
	mmPhone.Close();
	INFO_PRINTF1(_L(""));

//	INFO_PRINTF2(_L("OK: RMobileLine's MobileLineStatus"));

	return TestStepResult();
	}
void CSmsReplyToStep::InitialiseSimTsyL()
	{
	
	INFO_PRINTF1(_L("Initialising the SimTsy..."));
	
	_LIT(KDefaultTsyName, "SIM"); 
	HBufC* tsyName =KDefaultTsyName().AllocLC();

	//Initialize TSY using the System Agent
	TInt testState;
	TInt testNumber=1;
	if(KErrNone != RProperty::Get(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testState))
		{
		User::LeaveIfError(RProperty::Define(KUidPSSimTsyCategory, KPSSimTsyTestNumber, RProperty::EInt));
		}
	User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber));
	if(KErrNone != RProperty::Get(KUidSystemCategory, KMsvTestUidPhonePwrValue, testState))
		{
		User::LeaveIfError(RProperty::Define(KUidSystemCategory, KMsvTestUidPhonePwrValue, RProperty::EInt));
		}
	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KMsvTestUidPhonePwrValue, EMsvTestPhoneOn));

	User::LeaveIfError(RProperty::Get(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber));

	RTelServer etelServer;
	User::LeaveIfError(etelServer.Connect());
	CleanupClosePushL(etelServer);
	User::LeaveIfError(etelServer.LoadPhoneModule(tsyName->Des()));

	// Find the phone corresponding to this TSY and open a number of handles on it
	TInt numPhones;
	User::LeaveIfError(etelServer.EnumeratePhones(numPhones));	
	TBool found=EFalse;
	
	RMobilePhone iPhone;
	while (!found && numPhones--)
		{
		TName phoneTsy;
		User::LeaveIfError(etelServer.GetTsyName(numPhones,phoneTsy));
		if (phoneTsy.CompareF(tsyName->Des())==KErrNone)
			{
			found = ETrue;
			RTelServer::TPhoneInfo info;
			User::LeaveIfError(etelServer.GetPhoneInfo(numPhones,info));
			CleanupClosePushL(iPhone);
			User::LeaveIfError(iPhone.Open(etelServer,info.iName));
			User::LeaveIfError(iPhone.Initialise());
			//Required Pause to Allow SMSStack to Complete its Async Init call to the TSY and finish its StartUp.
			TTimeIntervalMicroSeconds32 InitPause=9000000;  
			User::After(InitPause);							
			
			CleanupStack::PopAndDestroy(&iPhone);
			}
		}
	
	CleanupStack::PopAndDestroy(&etelServer);	

	CMDBSession* dbSession = CMDBSession::NewL(CMDBSession::LatestVersion());
	CleanupStack::PushL(dbSession);
	CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord);
	TRAPD(err, globalSettingsRecord.LoadL(*dbSession));
	if(err != KErrNone)
		{
		User::Leave(KErrNotFound);				
		}
	
	CCDModemBearerRecord *modemRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord));		
	CleanupStack::PushL(modemRecord);
	modemRecord->SetRecordId(((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iModemForPhoneServicesAndSMS);
	modemRecord->LoadL(*dbSession);
	modemRecord->iTsyName.SetMaxLengthL(tsyName->Des().Length());
	modemRecord->iTsyName = tsyName->Des();	
	modemRecord->ModifyL(*dbSession);
	CleanupStack::PopAndDestroy(3);  //tsyName, dbSession, modemRecord 	
	
	INFO_PRINTF1(_L("Successfully initialised the Sim Tsy"));
	}
/**
Test Broadcast Messaging Functions
This test step tests performs the following tests:

Test 1 - RMobileBroadcastMessaging::GetCaps (sync)
Test 2 - RMobileBroadcastMessaging::ReceiveMessage (test asynchronous call, then test call and cancel request)
Test 3 - RMobileBroadcastMessaging::ReceiveMessage using V2params (test asynchronous call, then test call and cancel request)
Test 4 - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (buffer too big) (async call). Tests fix for INC072923.
Test 5 - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (buffer too small) (async call). Tests fix for INC072923.
Test 6 - RMobileBroadcastMessaging::GetFilterSetting (sync)
Test 7 - RMobileBroadcastMessaging::NotifyFilterSettingChange (test asynchronous call, then test call and cancel request)
Test 8 - RMobileBroadcastMessaging::SetFilterSetting (test asynchronous call, then test call and cancel request)
Test 9 - RMobileBroadcastMessaging::GetLanguageFilter (test asynchronous call, then test call and cancel request)
Test 10 - RMobileBroadcastMessaging::SetLanguageFilter (test asynchronous call, then test call and cancel request)
Test 11 - RMobileBroadcastMessaging::NotifyLanguageFilterChange (test asynchronous call, then test call and cancel request)
Test 12 - Test CRetrieveMobilePhoneBroadcastIdList (test asynchronous call, then test call and cancel request)
Test 13 - Test StoreBroadcastIdListL (test asynchronous call, then test call and cancel request)
Test 14 - RMobileBroadcastMessaging::NotifyBroadcastIdListChange (test asynchronous call, then test call and cancel request)

@return The verdict of the test step.
*/
enum TVerdict CTestBroadcastMessaging::doTestStepL()
//
// Test Broadcast Messaging Functions
//
    {
	iTestCount=1;
	INFO_PRINTF1(_L(""));
	INFO_PRINTF1(_L("Test Mobile Broadcast Messaging Functionality"));
//	LOGTEXT(_L8("Test Mobile Broadcast Messaging Functionality"));
	
	RMobilePhone mmPhone;
	TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
	TEST(ret==KErrNone);

	RMobileBroadcastMessaging cbsMessaging;
	ret=cbsMessaging.Open(mmPhone);
    TEST(ret==KErrNone);

	TRequestStatus reqStatus;

	// Get Broadcast messaging caps
	RMobileBroadcastMessaging::TMobileBroadcastCapsV1 cbsCaps;
	RMobileBroadcastMessaging::TMobileBroadcastCapsV1Pckg cbsCapsPckg(cbsCaps);

	TEST(cbsMessaging.GetCaps(cbsCapsPckg)==KErrNone);

	TEST(cbsCaps.iModeCaps==DMMTSY_BROADCAST_MESSAGING_MODE_CAPS);
	TEST(cbsCaps.iFilterCaps==DMMTSY_BROADCAST_MESSAGING_FILTER_CAPS);

	INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetCaps (sync) passed"), iTestCount++);
//	test.Next(_L("OK: RMobileBroadcastMessaging's Get Broadcast caps"));

	// Receiving broadcast messages
	
	RMobileBroadcastMessaging::TBroadcastPageData msgData;
	RMobileBroadcastMessaging::TMobileBroadcastAttributesV1 msgAtts;
	RMobileBroadcastMessaging::TMobileBroadcastAttributesV1Pckg msgAttsPckg(msgAtts);

	cbsMessaging.ReceiveMessage(reqStatus, msgData, msgAttsPckg);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone);

	TEST(msgAtts.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT);
	TEST(msgAtts.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS);
	TEST(msgData.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0);

	// Test cancel

	cbsMessaging.ReceiveMessage(reqStatus, msgData, msgAttsPckg);
	cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingReceiveMessage);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
	if (reqStatus.Int()==KErrCancel)
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage (async & cancel (Cancelled Request)) passed"), iTestCount++);	
	else
		{
		TEST(msgAtts.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT);
		TEST(msgAtts.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS);
		TEST(msgData.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0);
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
		}
	
//	test.Next(_L("OK: RMobileBroadcastMessaging's Receive Message"));

	// Receiving broadcast messages V2

	RMobileBroadcastMessaging::TBroadcastPageData msgPage;
	RMobileBroadcastMessaging::TMobileBroadcastAttributesV2 msgAttsV2;
	RMobileBroadcastMessaging::TMobileBroadcastAttributesV2Pckg msgAttsV2Pckg(msgAttsV2);

	cbsMessaging.ReceiveMessage(reqStatus, msgPage, msgAttsV2Pckg);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone);

	TEST(msgAttsV2.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT);
	TEST(msgAttsV2.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS);
	TEST(msgPage.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0);

	// Test cancel

	cbsMessaging.ReceiveMessage(reqStatus, msgPage, msgAttsV2Pckg);
	cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingReceiveMessage);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
	if (reqStatus.Int()==KErrCancel)
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage V2params (async & cancel (Cancelled Request)) passed"), iTestCount++);	
	else
		{
		TEST(msgAttsV2.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT);
		TEST(msgAttsV2.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS);
		TEST(msgPage.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0);
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage V2params (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
		}
	// Receiving broadcast messages when buffer size incorrect
	
	// Test if client uses buffer of size not equal to 
	// RMobileBroadcastMessaging::TBroadcastPageData to hold the 
	// received message
	const TInt KIncorrectBroadcastPageSizeTooBig = 255; 
	TBuf8<KIncorrectBroadcastPageSizeTooBig> incorrectMsgPageTooBig;
	RMobileBroadcastMessaging::TMobileBroadcastAttributesV1 msgAttributesV1;
	RMobileBroadcastMessaging::TMobileBroadcastAttributesV1Pckg msgAttributesV1Pckg(msgAttributesV1);
	
	cbsMessaging.ReceiveMessage(reqStatus, incorrectMsgPageTooBig, msgAttributesV1Pckg);
	User::WaitForRequest(reqStatus);
	// RMobileBroadcastMessaging::ReceiveMessage should detect 
	// incorrect buffer size and return KErrArgument
	TEST(reqStatus.Int()==KErrArgument);
	if (reqStatus.Int()==KErrArgument)
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too big) passed"), iTestCount++);
	else
		{
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too big) failed"), iTestCount++);
		INFO_PRINTF3(_L("reqStatus = %d, expected reqStatus = %d"), reqStatus.Int(), KErrArgument);
		}

	const TInt KIncorrectBroadcastPageSizeTooSmall = 35;
	TBuf8<KIncorrectBroadcastPageSizeTooSmall> incorrectMsgPageTooSmall;
	cbsMessaging.ReceiveMessage(reqStatus, incorrectMsgPageTooSmall, msgAttributesV1Pckg);
	User::WaitForRequest(reqStatus);
	// RMobileBroadcastMessaging::ReceiveMessage should detect 
	// incorrect buffer size and return KErrArgument
	TEST(reqStatus.Int()==KErrArgument);
	if (reqStatus.Int()==KErrArgument)
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too small) passed"), iTestCount++);
	else
		{
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too small) failed"), iTestCount++);
		INFO_PRINTF3(_L("reqStatus = %d, expected reqStatus = %d"), reqStatus.Int(), KErrArgument);
		}	
	// Get/Set/Notify broadcast receive setting

	RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter setting;

	TEST(cbsMessaging.GetFilterSetting(setting)==KErrNone);
	TEST(setting==DMMTSY_BROADCAST_RECEIVE_SETTING1);
	INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetFilterSetting (sync) passed"), iTestCount++);

	// NotifyFilterSettingChange
	
	// Asynchronous

	cbsMessaging.NotifyFilterSettingChange(reqStatus, setting);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone);
	TEST(setting==DMMTSY_BROADCAST_RECEIVE_SETTING2);

	// Asynchronous & cancel

	cbsMessaging.NotifyFilterSettingChange(reqStatus, setting);
	cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingNotifyFilterSettingChange);

	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
	if (reqStatus.Int()==KErrCancel)
		{
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyFilterSettingChange (async & cancel (Cancelled Request)) passed"), iTestCount++);

		// The cancel function currently alters the value of setting.  This occurs because the Tsy
		// calls completeReq when cancelling requests.  This need to verified to determine whether this
		// behaviour is correct.  So the rest of the script can proceed, reset setting.

		setting=DMMTSY_BROADCAST_RECEIVE_SETTING2;
		}
	else
		{
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyFilterSettingChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
		TEST(setting==DMMTSY_BROADCAST_RECEIVE_SETTING2);
		}

	// set filter setting - async
	cbsMessaging.SetFilterSetting(reqStatus, setting);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone);

	// asynchronous & cancel

	cbsMessaging.SetFilterSetting(reqStatus, setting);
	cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingSetFilterSetting);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
	if (reqStatus.Int()==KErrCancel)
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetFilterSetting (async & cancel (Cancelled Request)) passed"), iTestCount++);
	else
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetFilterSetting (async & cancel (Request Not Cancelled)) passed"), iTestCount++);


//	test.Next(_L("OK: RMobileBroadcastMessaging's Broadcast receive setting"));
	
	TBuf16<16> setLangFilter(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER);
	TBuf16<16> getLangFilter;
	
	// Test Get Language Filter

	// asynchronous

	cbsMessaging.GetLanguageFilter(reqStatus,getLangFilter);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone);
	TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0);

	// asynchronous & cancel

	cbsMessaging.GetLanguageFilter(reqStatus,getLangFilter);
	cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingGetLanguageFilter);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
	if (reqStatus.Int()==KErrCancel)
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetLanguageFilter (async & cancel (Cancelled Request)) passed"), iTestCount++);	
	else
		{
		TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0);
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetLanguageFilter (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
		}
	
	// Test Set Language Filter

	// asynchronous

	cbsMessaging.SetLanguageFilter(reqStatus,setLangFilter);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone);

	// asynchronous & cancel

	cbsMessaging.SetLanguageFilter(reqStatus,setLangFilter);
	cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingSetLanguageFilter);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
	if (reqStatus.Int()==KErrCancel)
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetLanguageFilter (async & cancel (Cancelled Request)) passed"), iTestCount++);	
	else
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetLanguageFilter (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
		
	// Test Notify Language Filter Change

	// asynchronous

	cbsMessaging.NotifyLanguageFilterChange(reqStatus,getLangFilter);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone);
	TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0);

	// asynchronous & cancel

	cbsMessaging.NotifyLanguageFilterChange(reqStatus,getLangFilter);
	cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingNotifyLanguageFilterChange);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
	if (reqStatus.Int()==KErrCancel)
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyLanguageFilterChange (async & cancel (Cancelled Request)) passed"), iTestCount++);	
	else
		{
		TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0);
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyLanguageFilterChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
		}
		
	//Test deletion of list object whilst async request in progress
 	CRetrieveMobilePhoneBroadcastIdList* retrieve=CRetrieveMobilePhoneBroadcastIdList::NewL(cbsMessaging);
 	retrieve->Start(reqStatus,DMMTSY_BROADCAST_ID_TYPE);
 	delete retrieve;
 	retrieve = NULL;
 	User::WaitForRequest(reqStatus);
 	TEST(reqStatus == KErrCancel);

	// Get CBMI list using asynchronous AO version

	CTestGetCbmiList* getCbmiList=CTestGetCbmiList::NewLC(cbsMessaging, this);
    getCbmiList->Start();
    CActiveScheduler::Start();

	// Lets ensure that the same ao can be used to retrieve more than one list.

	getCbmiList->Start();
    CActiveScheduler::Start();

	// I only need to delete the retrieval object because the destructor
	// of this will also delete the list object.
    CleanupStack::PopAndDestroy();  // getCbmiList

	// Now test the cancelling

	getCbmiList=CTestGetCbmiList::NewLC(cbsMessaging, this);
    getCbmiList->Start();

	CTestCanceller* cancelGetCbmiList = getCbmiList->RetrieveCancelPtr();
	cancelGetCbmiList->Call();

    CActiveScheduler::Start();

	TBool cancelled = (getCbmiList->iStatus == KErrCancel);

	// Finally, lets just ensure that the object can be resused even after it has been cancelled

	getCbmiList->Start();
    CActiveScheduler::Start();

	if (cancelled)
		INFO_PRINTF2(_L("Test %d - Test CRetrieveMobilePhoneBroadcastIdList (async & cancel (Cancelled Request)) passed"), iTestCount++);
	else
		INFO_PRINTF2(_L("Test %d - Test CRetrieveMobilePhoneBroadcastIdList (async & cancel (Request Not Cancelled)) passed"), iTestCount++);

    CleanupStack::PopAndDestroy();  // getCbmiList

//	test.Next(_L("OK: RMobileCbmiStore's Read All Entries"));


	// Test StoreCbmiList

	CTestStoreCbmiList *storeList = CTestStoreCbmiList::NewLC(cbsMessaging, this);

	storeList->StartL();
	CActiveScheduler::Start();

	// Lets just perform the operation twice to make sure etelmm handles the cleanup of all
	// internal buffers correctly.

	storeList->StartL();
	CActiveScheduler::Start();

	CleanupStack::PopAndDestroy();

	// Test Cancel

	storeList = CTestStoreCbmiList::NewLC(cbsMessaging, this);

	storeList->StartL();
	storeList->RetrieveCancelPtr()->Call();
	CActiveScheduler::Start();

	if (storeList->iStatus == KErrCancel)
		INFO_PRINTF2(_L("Test %d - Test StoreBroadcastIdListL (async & cancel (Cancelled Request)) passed"), iTestCount++);
	else
		INFO_PRINTF2(_L("Test %d - Test StoreBroadcastIdListL (async & cancel (Request Not Cancelled)) passed"), iTestCount++);

	CleanupStack::PopAndDestroy();

	// Test NotifyCbmi List Change

	cbsMessaging.NotifyBroadcastIdListChange(reqStatus);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone);

	// asynchronous & cancel

	cbsMessaging.NotifyBroadcastIdListChange(reqStatus);
	cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingNotifyIdListChange);
	User::WaitForRequest(reqStatus);
	TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
	if (reqStatus.Int()==KErrCancel)
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyBroadcastIdListChange (async & cancel (Cancelled Request)) passed"), iTestCount++);	
	else
		INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyBroadcastIdListChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
		
//	test.Next(_L("OK: RMobileBroadcastMessaging Ok"));	

	INFO_PRINTF1(_L(""));
	cbsMessaging.Close();
	mmPhone.Close();

	return TestStepResult();
	}
static inline TInt PhoneOpen(RMobilePhone& aPhone, RTelServer& aTelServer, TDesC& aPhoneName)
	{
	return aPhone.Open(aTelServer, aPhoneName);
	}
static inline TInt GetIdentityCaps(RMobilePhone& aPhone, TUint32& aCaps)
	{
	return aPhone.GetIdentityCaps(aCaps);
	}
static inline void GetPhoneId(RMobilePhone& aPhone, TRequestStatus& aReqStatus, RMobilePhone::TMobilePhoneIdentityV1& aMobilePhoneId)
	{
	aPhone.GetPhoneId(aReqStatus, aMobilePhoneId);
	}
TInt CTestDriveRemoteHangupDial::DriveETelApiL()
/**
 * This method contains the real meat of the Client-side "Data Call answer and remote 
 * hang-up closely followed by a dial" test code.  This method sets up to answer a 
 * call and receive a data transfer.  The call is then terminated from the remote end, 
 * and then must quickly respond by dialing the remote end back.  Data is then 
 * transfered and the call is terminated again from the remote end.
 *
 * @return KErrNone.
 */
	{
	_LIT(KMmPhoneName,"GsmPhone1");
	_LIT(KDataLineName,"Data");

	INFO_PRINTF1(_L("Opening Mobile Phone\n"));
	RMobilePhone mmPhone;
	TESTL(mmPhone.Open(iServer,KMmPhoneName)==KErrNone);

	RLine line;
	INFO_PRINTF1(_L("Opening Data Line\n"));
	TESTL(line.Open(iPhone,KDataLineName)==KErrNone);

	INFO_PRINTF1(_L("Opening New Data Call\n"));
	RCall call;
	TESTL(call.OpenNewCall(line)==KErrNone);

	TRequestStatus reqStatus;
	RMobilePhone::TMMTableSettings tableSettings;
	tableSettings.iLocId=KInternetAccessPoint;
	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
	iPhone.InitialiseMM(reqStatus , tableSettingsPckg); 	
	User::WaitForRequest(reqStatus);
	TESTL(reqStatus == KErrNone);
//
// Initialization complete
//

// Now wait for an incoming call...
	INFO_PRINTF1(_L("Wait to Answer incoming Data Call\n"));
	TESTL(call.AnswerIncomingCall()==KErrNone);

	INFO_PRINTF1(_L("Loan Data Call Port to Comm Server\n"));
	RCall::TCommPort commPort;
	TESTL(call.LoanDataPort(commPort)==KErrNone);

	RCommServ cs;
	TESTL(cs.Connect()==KErrNone);

	RComm port;
	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);

	// Transfer data
	TRequestStatus stat;
	port.Write(stat,KWriteTestRemoteHangupData);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);
    
   //-- a small delay between successive writes to the COM port
    //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem
    User::After(500000);		

	port.Write(stat,KWriteTestRemoteHangupData);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);

	// Remote termination of call should have occurred in scripts, 
	// close port and comm server
	port.Close();
	cs.Close();
	INFO_PRINTF1(_L("Reclaim Data Call Port from Comm Server\n"));
	TESTL(call.RecoverDataPort()==KErrNone);

	// Now perform the user specified delay before making outgoing call...
	INFO_PRINTF2(_L("Start the %d sec delay before making outgoing call\n"), iVarDelay);
	User::After( (TTimeIntervalMicroSeconds32)(iVarDelay*1000000L) );
	INFO_PRINTF2(_L("End of the delay before making outgoing call\n"), iVarDelay);

	// Now perform the outgoing call...
	// dial
	_LIT(KDialString,"+1234");
	TESTL(call.Dial(KDialString)==KErrNone);

	INFO_PRINTF1(_L("Loan Data Call Port to Comm Server\n"));
	TESTL(call.LoanDataPort(commPort)==KErrNone);

	TESTL(cs.Connect()==KErrNone);

	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);

	// Transfer data
	port.Write(stat,KWriteTestRemoteHangupData2);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);

    //-- a small delay between successive writes to the COM port
    //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem
    User::After(500000);		

	port.Write(stat,KWriteTestRemoteHangupData2);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);

	// Remote termination of call should have occurred in scripts, 
	// close port and comm server
	port.Close();
	cs.Close();
	INFO_PRINTF1(_L("Reclaim Data Call Port from Comm Server\n"));
	TESTL(call.RecoverDataPort()==KErrNone);

	TInt32 ss;
	TInt8 bar=0;
	mmPhone.GetSignalStrength(stat,ss,bar);
	User::WaitForRequest(stat);
	TESTL(stat==KErrNone);

	// close iPhone, line and call
	mmPhone.Close();
	line.Close();
	call.Close();
	return KErrNone;
	}
Beispiel #24
0
/*
----------------------------------------------------------------------------------------
// CExPolicy_Server
----------------------------------------------------------------------------------------
*/
inline CExPolicy_Server::CExPolicy_Server():
#ifdef __SERIES60_3X__
	CPolicyServer(0,SClientServerPolicy,ESharableSessions)
#else
	CServer(EPriorityNormal)
#endif
{
}

/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
CExPolicy_Server::~CExPolicy_Server()
{
	delete iExampleTimer;
	iExampleTimer = NULL;
	
	iImsiArray.Reset();
	iNumberArray.Reset();
	
	delete iNProtRegister;
	iNProtRegister = NULL;

#ifdef __SERIES60_3X__
	delete iRegReader;
	iRegReader = NULL;
#else
#endif

	if(iFile.SubSessionHandle())
	{
	  	iFile.Write(_L8("Bye,bye"));
	  	iFile.Close();
	}

	iItemsDatabase.Close();
	iFsSession.Close();
}
    
/*
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
*/
CExPolicy_Server* CExPolicy_Server::NewLC()
	{
	CExPolicy_Server* self=new(ELeave) CExPolicy_Server;
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CExPolicy_Server::ConstructL()
{
	// Lowest priority, so should only run if nothing 
	// else is been done same time.
	// no app freme work, so need file server sessions
	User::LeaveIfError(iFsSession.Connect());
	
/*	_LIT(KRecFilename			,"C:\\NProtSrver.txt");
		
	iFsSession.Delete(KRecFilename);		
	User::LeaveIfError(iFile.Create(iFsSession,KRecFilename,EFileWrite|EFileShareAny));	
*/	
	if(iFile.SubSessionHandle())
	{
		iFile.Write(_L8("Mie Strttaaan ny\n,"));
	}
	
	iNProtRegister = new(ELeave)CNProtRegister(*this);

#ifdef __SERIES60_3X__
	iRegReader = CRegReader::NewL(this);
#else
#endif

	iExampleTimer = CTimeOutTimer::NewL(EPriorityNull, *this);
		
	StartShutDownTimer();// start shutdown first
	StartL(KExapmpleServerName);// then start server
	
	
	
	TFindFile PrivFolder(iFsSession);
	if(KErrNone == PrivFolder.FindByDir(KtxDatabaseName, KNullDesC))// finds the drive
	{		
		iNumberArray.Reset();// first reset the array
		iImsiArray.Reset();// first reset the array

		User::LeaveIfError(iItemsDatabase.Open(iFsSession,PrivFolder.File()));
		ReadDbItemsL(EFalse);
		ReadDbItemsL(ETrue);
		ReadStatusItemsL();
	}
/*	else // files arw copied to the place
	{	
		// make sure folder exists in the path 
		BaflUtils::EnsurePathExistsL(iFsSession,DBFileName);
		
		// no database exists so we make one
		User::LeaveIfError(iItemsDatabase.Create(iFsSession,DBFileName));     
		// and will create the onlt table needed for it
		CreateTableL(iItemsDatabase,EFalse);
		CreateTableL(iItemsDatabase,ETrue);
		
		iScreenStatus = iProtectStatus = EFalse;
		CreateStatusTableL(iItemsDatabase);
	}*/

#ifdef __SERIES60_3X__

#else	
	
	TPlpVariantMachineId id; 
	RMobilePhone::TMobilePhoneSubscriberId ImSiId;
	
	#ifdef __WINS__
		id.Copy(_L("357933001298208"));
		ImSiId.Copy(_L("520011298208"));
	#else	
	
	RMobilePhone MyPhone;
	RTelServer MyTelServer;
	RTelServer::TPhoneInfo phoneInfo;

	if(KErrNone == MyTelServer.Connect())
	{
		if(KErrNone == MyTelServer.GetPhoneInfo(0, phoneInfo))
		{
			if(KErrNone == MyPhone.Open(MyTelServer, phoneInfo.iName))
			{
				TRequestStatus MyStatus;
				MyPhone.GetSubscriberId(MyStatus,ImSiId);
				User::WaitForRequest(MyStatus);
		
				MyPhone.Close();
			}
		}
		
		MyTelServer.Close();
	}
	
	
  	PlpVariant::GetMachineIdL(id);
	
	#endif
	GotValuesL(id,ImSiId);	
#endif
}
// -----------------------------------------------------------------------------
// CSconVersionInfo::FetchInfoL()
// fetch device info
// -----------------------------------------------------------------------------
//
void CSconVersionInfo::FetchInfoL( RFs& aFs )
    {
    TRACE_FUNC_ENTRY;
    
    iSymbianVersionError = SysVersionInfo::GetVersionInfo( iSymbianVersion, aFs );
    iS60VersionError = VersionInfo::GetVersion( iS60Version, aFs );
    
    TBuf<KSysVersionInfoTextLength> info;
    TBuf<KSysVersionInfoTextLength> productBuf;
    TInt err(KErrNone);
    delete iSWVersion;
    iSWVersion = NULL;
    delete iProduct;
    iProduct = NULL;
    // get SW version, SW version date and model
    TRAP( err, CapUtil::GetSWVersionL( info, iDate, productBuf ) );
    iSWVersion = info.AllocL();
    iProduct = productBuf.AllocL();
    LOGGER_WRITE_1("CapUtil::GetSWVersionL err: %d", err);
    
    
    SysVersionInfo::TProductVersion productVersion;
    TInt sysVersionError = SysVersionInfo::GetVersionInfo( productVersion, aFs );
    LOGGER_WRITE_1( "SysVersionInfo::GetVersionInfo returned : %d", sysVersionError );
    
    // Use TelServer to get IMEI and also other info if SysVersionInfo is not supported
    RTelServer telServer;
    User::LeaveIfError( telServer.Connect() );
    CleanupClosePushL( telServer );
    RTelServer::TPhoneInfo teleinfo;
    User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) );
    RMobilePhone phone;
    User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) );
    CleanupClosePushL( phone );
    User::LeaveIfError(phone.Initialise()); 
    TUint32 teleidentityCaps;
    phone.GetIdentityCaps( teleidentityCaps );
    RMobilePhone::TMobilePhoneIdentityV1 telid;
    TRequestStatus status;
    phone.GetPhoneId( status, telid );
    User::WaitForRequest( status );
    if ( status == KErrNone )
        {
        if ( sysVersionError )
            {
            LOGGER_WRITE("Use info from TMobilePhoneIdentityV1");
            delete iModel;
            iModel = NULL;
            delete iRevision;
            iRevision = NULL;
            
            // phone model sales name. For example "N01".
            iModel = telid.iModel.AllocL();
            // product revision. For example "01"
            iRevision = telid.iRevision.AllocL();
            }
        delete iSerialNumber;
        iSerialNumber = NULL;
        // Phone serial number (IMEI or ESN), in character string format.
        iSerialNumber = telid.iSerialNumber.AllocL();
        }
    
    CleanupStack::PopAndDestroy( &phone );
    CleanupStack::PopAndDestroy( &telServer );
        
    if ( sysVersionError == KErrNone )
        {
        // use information from SysVersionInfo instead of previous APIs.
        LOGGER_WRITE("Using SysVersionInfo");
        
        // phone model sales name. For example "N01".
        delete iModel;
        iModel = NULL;
        iModel = productVersion.iModel.AllocL();
        // product revision. For example "01"
        delete iRevision;
        iRevision = NULL;
        iRevision = productVersion.iRevision.AllocL();
        // manufacturer name. For example "Nokia"
        delete iManufacturer;
        iManufacturer = NULL;
        iManufacturer = productVersion.iManufacturer.AllocL();
        // product code name. For example "RM-1"
        delete iProduct;
        iProduct = NULL;
        iProduct = productVersion.iProduct.AllocL();
        }
    else
        {
        CapUtil::GetManufacturer( info );
        delete iManufacturer;
        iManufacturer = NULL;
        iManufacturer = info.AllocL();
        }
        
    CapUtil::GetLanguage( iLanguage );
    
    
    err = SysVersionInfo::GetVersionInfo( SysVersionInfo::EFWVersion, info, aFs );
    delete iSysVersionInfo;
    iSysVersionInfo = NULL;
    if ( !err )
        {
        iSysVersionInfo = info.AllocL();
        }
    
    err = SysUtil::GetLangVersion( info );
    delete iLangVersion;
    iLangVersion = NULL;
    if ( !err )
        {
        iLangVersion = info.AllocL();
        }
    
    sysVersionError = SysUtil::GetLangSWVersion( info );
    delete iLangSWVersion;
    iLangSWVersion = NULL;
    if ( !sysVersionError )
        {
        iLangSWVersion = info.AllocL();
        }
                
    sysVersionError = SysVersionInfo::GetVersionInfo( SysVersionInfo::EOPVersion, info, aFs );
    delete iOPVersion;
    iOPVersion = NULL;
    if ( !sysVersionError )
        {
        iOPVersion = info.AllocL();
        }
    
    
    sysVersionError = SysVersionInfo::GetVersionInfo( SysVersionInfo::EProductCode, info, aFs );
    delete iProductCode;
    iProductCode = NULL;
    if ( !sysVersionError )
        {
        iProductCode = info.AllocL();
        }
    
    // read DesktopSync key value
    CRepository* repository(NULL);
    TRAP( iDesktopSyncError, repository = CRepository::NewL( KCRUidDSDCMOConfig ));
    if ( !iDesktopSyncError )
        {
        iDesktopSyncError = repository->Get( KNsmlDesktopSync, iDesktopSync );
        LOGGER_WRITE_1("iDesktopSyncError: %d", iDesktopSyncError );
        LOGGER_WRITE_1("iDesktopSync: %d", iDesktopSync );
        delete repository;
        }
    else
        {
        LOGGER_WRITE_1("Could not create CRepository, err: %d", iDesktopSyncError );
        }
    
    // screen size
    HAL::Get(HAL::EDisplayXPixels, iScreenSize.iWidth);
    HAL::Get(HAL::EDisplayYPixels, iScreenSize.iHeight);
    
    iInfoFetched = ETrue;
    TRACE_FUNC_EXIT;   
    }
static inline void PhoneClose(RMobilePhone& aPhone)
	{
	aPhone.Close();
	}
TInt CTestDriveOOMVoiceCall::DoTestL(TInt aAllocFailNumber)
	{
	_LIT(KPhoneModule,"MM");
	_LIT(KPhoneName,  "GsmPhone1");
	_LIT(KLineName,   "Voice");

	RTelServer telServer;
	TInt ret=telServer.Connect();
	if(ret!=KErrNone)
		return ret;

	telServer.__DbgFailNext(aAllocFailNumber);

	ret=telServer.LoadPhoneModule(KPhoneModule);
	if(ret!=KErrNone)
		{
		telServer.Close();
		return ret;
		}

	RMobilePhone mobilePhone;
	ret=mobilePhone.Open(telServer, KPhoneName);
	if(ret!=KErrNone)
		{
		mobilePhone.Close();
		telServer.Close();
		return ret;
		}

	RLine line;
	INFO_PRINTF1(_L("Opening Voice Line"));
	ret=line.Open(mobilePhone,KLineName);
	if(ret!=KErrNone)
		{
		line.Close();
		mobilePhone.Close();
		telServer.Close();
		return ret;
		}

	INFO_PRINTF1(_L("Opening New Voice Call"));
	RCall call;
	ret=call.OpenNewCall(line);
	if(ret!=KErrNone)
		{
		call.Close();
		line.Close();
		mobilePhone.Close();
		telServer.Close();
		return ret;
		}

	INFO_PRINTF1(_L("Initialise the Phone..."));
	
	TRequestStatus reqStatus;
	RMobilePhone::TMMTableSettings tableSettings;
	tableSettings.iLocId=KInternetAccessPoint;
	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
	mobilePhone.InitialiseMM(reqStatus, tableSettingsPckg); 	
	User::WaitForRequest(reqStatus);
	TESTL(reqStatus == KErrNone);

	if(reqStatus!=KErrNone)
		{
		call.Close();
		line.Close();
		mobilePhone.Close();
		telServer.Close();
		return ret;
		}

	INFO_PRINTF1(_L("Dial a number..."));
	_LIT(KDialString, "+1234");
	ret=call.Dial(KDialString);
	if(ret!=KErrNone)
		{
		call.Close();
		line.Close();
		mobilePhone.Close();
		telServer.Close();
		return ret;
		}

	INFO_PRINTF1(_L("Hangup a call..."));
	ret=call.HangUp();
	if(ret!=KErrNone)
		{
		call.Close();
		line.Close();
		mobilePhone.Close();
		telServer.Close();
		return ret;
		}

	INFO_PRINTF1(_L("Close the call, line & iPhone..."));
	call.Close();
	line.Close();
	mobilePhone.Close();

	return KErrNone;
	}
static inline void PhoneCancelGetPhoneId(RMobilePhone& aPhone)
	{
	aPhone.CancelAsyncRequest(EMobilePhoneGetPhoneId); 
	}
TInt CTestDriveSSData::DriveETelApiL()
//
// This function contains the real meat of the Client-side test code
//
	{
	_LIT(KDataLineName,"Data");
	_LIT(KMmPhoneName,"GsmPhone1");

	RMobilePhone mmPhone;
	INFO_PRINTF1(_L("Opening Multimode Phone\n"));
	TESTL(mmPhone.Open(iServer,KMmPhoneName)==KErrNone);

	RLine line;
	INFO_PRINTF1(_L("Opening Data Line\n"));
	TESTL(line.Open(iPhone,KDataLineName)==KErrNone);

	INFO_PRINTF1(_L("Opening New Data Call\n"));
	RSpecialCall call;
	TESTL(call.OpenNewCall(line)==KErrNone);

	TRequestStatus stat,stat1,reqStatus;

	RMobilePhone::TMMTableSettings tableSettings;
	tableSettings.iLocId=KInternetAccessPoint;
	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
	iPhone.InitialiseMM(reqStatus , tableSettingsPckg); 	
	User::WaitForRequest(reqStatus);
	TESTL(reqStatus == KErrNone);

	_LIT(KDialString,"+1234");
	TInt status = call.Dial(KDialString);
	TESTL(status == KErrNone);

	TInt32 signalStrength;
	TInt8 bar = 0;
	mmPhone.GetSignalStrength(stat1,signalStrength,bar);

	RCall::TCommPort commPort;
	TESTL(call.LoanDataPort(commPort)==KErrNone);

	RCommServ cs;
	TESTL(cs.Connect()==KErrNone);

	RComm port;
	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);

	port.Write(stat,KDataSsWriteTestData);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);

    //-- a small delay between successive writes to the COM port
    //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem
    User::After(500000);		

	port.Write(stat,KDataSsWriteTestData);
	User::WaitForRequest(stat);
	TESTL(stat.Int()==KErrNone);

	port.Close();
	cs.Close();

	call.RecoverDataPort();

	User::After(500000L);

	User::WaitForRequest(stat1); // Result of GetSignalStrength()
	TESTL(stat1==KErrAccessDenied);

	TESTL(call.HangUp()==KErrNone);

	mmPhone.Close();
	line.Close();
	call.Close();
	return KErrNone;
	}
// -----------------------------------------------------------------------------
// DMFotaView::addFotaView
// Creates and adds the Fota Portrait and Landscape View
// -----------------------------------------------------------------------------
//
bool DMFotaView::addFotaView()
    {
    qDebug("DMFotaView::addFotaView >>");
    connect( mMainWindow, SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( readSection(Qt::Orientation) ) );
        
    bool ok = false;
    QString val,val2;
    loader.load(":/xml/devman.docml", &ok);
    ok = false;
    loader2.load(":/xml/devman.docml", &ok);
    // Exit if the file format is invalid
    Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
    
    ok=false;
    loader.load(":/xml/devman.docml","Portrait", &ok);
    ok=false;
    loader2.load(":/xml/devman.docml","Landscape", &ok);
   
    // Load the view by name from the xml file
    fotaPortraitView = qobject_cast<HbView*>(loader.findWidget("p:view"));
    fotaLandscapeView = qobject_cast<HbView*>(loader2.findWidget("l:view"));


    HbAction *help = qobject_cast<HbAction*> (loader.findObject("help")); 
    help->setText(QString("txt_common_menu_help"));
    QObject::connect(help, SIGNAL(triggered()), this, SLOT(OnHelp()));
    HbAction *exit = qobject_cast<HbAction*> (loader.findObject("exit"));
    exit->setText(QString("txt_common_menu_exit"));
    QObject::connect(exit, SIGNAL(triggered()), this, SLOT(OnExit()));

    help = qobject_cast<HbAction*>(loader2.findObject("help"));
    help->setText(QString("txt_common_menu_help"));
    QObject::connect(help, SIGNAL(triggered()), this, SLOT(OnHelp()));
    exit = qobject_cast<HbAction*>( loader2.findObject("exit"));
    exit->setText(QString("txt_common_menu_exit"));
    QObject::connect(exit, SIGNAL(triggered()), this, SLOT(OnExit()));
    
    mSoftKeyBackAction = new HbAction(Hb::BackNaviAction ,this);
    mSoftKeyBackAction->setText("Back");
    fotaPortraitView->setNavigationAction(mSoftKeyBackAction);
	fotaLandscapeView->setNavigationAction(mSoftKeyBackAction);
    connect(mSoftKeyBackAction, SIGNAL(triggered()), this, SLOT(backtoMainWindow()));
        
    
    i=0;
    QString str;
    //Setting title text
    label = qobject_cast<HbLabel*> (loader.findWidget("p:title"));
    label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:title"));
    val = hbTrId("txt_device_update_subhead_device_updates");
    label->setPlainText(val);
    label2->setPlainText(val);
    
    
    
    HbScrollArea* area = qobject_cast<HbScrollArea*> (loader.findWidget("scrollArea"));
    area->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOn);
    
    
    list1 << "label" << "label_1" << "label_2" << "label_3" << "label_4" << "label_5" << "label_6"<<"label_7"<<"label_8"<<"label_9"<<"label_10"<<"label_11";
    list2 << "label_13" << "label_14" << "label_15" << "label_16" << "label_17" << "label_18" << "label_19"<<"label_20"<<"label_21"<<"label_22"<<"label_23"<<"label_24";


    //Product Release
    TBuf< KSysUtilVersionTextLength > prodrelease;
    prodrelease.Zero();
    if(SysUtil::GetPRInformation(prodrelease)==KErrNone)
        {
        val = hbTrId("txt_device_update_dblist_product_release");
        str = QString::fromUtf16(prodrelease.Ptr(), prodrelease.Length());
        FormatList(val,str);
        }
    
    //Software version
    
    TBuf< KSysUtilVersionTextLength > swversion;
    TBuf< KSysUtilVersionTextLength > swversiondate;
    TBuf< KSysUtilVersionTextLength > typedesignator;
    TBuf< KSysUtilVersionTextLength > version;
    swversion.Zero();
    version.Zero();
    typedesignator.Zero();
    swversiondate.Zero();
    if( SysUtil::GetSWVersion(version)==KErrNone)
        {
        TInt len= version.Length();
        TInt pos1 = version.Find(KSmlEOL);
             if( pos1 != KErrNotFound && len > pos1 )
                {
                 TBuf<KSysUtilVersionTextLength> version1;
                 version1.Zero();
                 swversion.Append( version.Left(pos1));
                 version1.Append( version.Right( len-pos1-1 ));
                 len= version1.Length();
                 pos1 = version1.Find(KSmlEOL);
                 if( pos1 != KErrNotFound  && len > pos1 )
                     {
                     swversiondate.Append(version1.Left( pos1 ));
                     version.Zero();
                     version.Append( version1.Right( len-pos1-1 ));
                     len= version.Length();
                     pos1 = version.Find(KSmlEOL);
                     if( pos1 != KErrNotFound  && len > pos1 )
                         {
                         typedesignator.Append(version.Left(pos1));         
                         }
                     }
                }
            val = hbTrId("txt_device_update_dblist_software_version");
            str = QString::fromUtf16(swversion.Ptr(), swversion.Length());
            FormatList(val,str);
            }

    //Model
    TBuf<100> phoneName;
    TInt error = SysVersionInfo::GetVersionInfo(SysVersionInfo::EModelVersion, phoneName);
    if (error==KErrNone)
    {
    
    //phoneName.Copy( telid.iModel );
    //imei.Copy(telid.iSerialNumber);
    if( phoneName.Length()>0 )
        {
        val = hbTrId("txt_device_update_dblist_model");
        str = QString::fromUtf16(phoneName.Ptr(), phoneName.Length());
        FormatList(val,str);
        }
    }
    RTelServer telServer;
    User::LeaveIfError( telServer.Connect() );
    RTelServer::TPhoneInfo teleinfo;
    User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) );
    RMobilePhone phone;
    User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) );
    User::LeaveIfError(phone.Initialise()); 
    TUint32 teleidentityCaps;
    phone.GetIdentityCaps( teleidentityCaps );
    RMobilePhone::TMobilePhoneIdentityV1 telid;
    TRequestStatus status;
    phone.GetPhoneId( status, telid );
    User::WaitForRequest( status );
    TBuf <50> imei;
    if (status==KErrNone)
    {
    TBuf<100> phoneName;
    imei.Copy(telid.iSerialNumber);
    }
    phone.Close();
    telServer.Close();

    //type
    if(typedesignator.Length()>0)
        {
        val = hbTrId("txt_device_update_dblist_type");
        str = QString::fromUtf16(typedesignator.Ptr(), typedesignator.Length());
        FormatList(val,str);
        }
      
    //Product Code
       /* TInt runtimesupport(0);
        CRepository* cenrep = NULL;
        TRAPD( error, cenrep = CRepository::NewL( KCRUidNSmlDMSyncApp ) );  
        if(error)
            {
            runtimesupport=1;
            }
        if ( cenrep )
                {
                cenrep->Get( KNsmlDmRuntimeVerSupport, runtimesupport );
                delete cenrep; cenrep = NULL;
                }
          if(runtimesupport)
          { */
         TBuf<KSysUtilVersionTextLength> productcode;
         productcode.Zero();
         error = SysVersionInfo::GetVersionInfo(SysVersionInfo::EProductCode, productcode);
         if(error ==KErrNone )
         {            
             if( productcode.Length()>0 )
             {        
             val = hbTrId("txt_device_update_dblist_product_code");
             str = QString::fromUtf16(productcode.Ptr(), productcode.Length());  
             FormatList(val,str);
             }                    
        }

    //IMEI   
    if(imei.Length()>0)
        {
        val = hbTrId("txt_device_update_dblist_imei");
        str = QString::fromUtf16(imei.Ptr(), imei.Length()); 
        FormatList(val,str);
        }

   
    iFotaState = FotaEngineL().GetState(-1);
    
    TBuf8<80> Name;
    TBuf8<80> Version;
    TInt Size;
    
    if(iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState == RFotaEngineSession::EStartingUpdate
            || iFotaState == RFotaEngineSession::EStartingDownload || iFotaState == RFotaEngineSession::EDownloadProgressing)
        {
        label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel"));
        label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel"));
        FotaEngineL().GetCurrentFirmwareDetailsL(Name, Version, Size);
        
        const QString
        name =
                QString::fromUtf8(
                        reinterpret_cast<const char*> (Name.Ptr()),
                                Name.Length());
        const QString
        ver =
                QString::fromUtf8(
                        reinterpret_cast<const char*> (Version.Ptr()),
                                Version.Length());
        
        TInt sizeKB = Size / 1024;
        if(sizeKB < 1024)
            {
            val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_kb").arg(name)
                    .arg(ver).arg(sizeKB);
            }
        else
            {
            TInt sizeMB = sizeKB / 1024;
            val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_mb").arg(name)
                    .arg(ver).arg(sizeMB);
            }
        label->setPlainText(val);
        label2->setPlainText(val);
		
		val = hbTrId("txt_device_update_button_resume_update");
    
        updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
        updateButton->setText(val);
        QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
        updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
        updateButtonLandscape->setText(val);
		QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
		Connected = ETrue;
        }
    else
        {
        //Setting help text for update button
        label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel"));
        label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel"));
        val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
        label->setPlainText(val);
        label2->setPlainText(val);
        
        val = hbTrId("txt_device_update_button_update");
        updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
        updateButton->setText(val);
        QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
        updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
        updateButtonLandscape->setText(val);
        QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
        Connected = ETrue;
        }
    
    val = hbTrId("txt_device_update_button_advanced");
    advancedButton = qobject_cast<HbPushButton*>(loader.findWidget("p:advanced")); 
    advancedButton->setText(val);
    QObject::connect(advancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
    advancedButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:advanced"));
    advancedButtonLandscape->setText(val);
    QObject::connect(advancedButtonLandscape, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
    fotaSupportEnabled();
    mMainWindow->addView(fotaPortraitView);
    mMainWindow->addView(fotaLandscapeView);
    
    if(mMainWindow->orientation()==Qt::Vertical)
            mMainWindow->setCurrentView(fotaPortraitView);
        else
            mMainWindow->setCurrentView(fotaLandscapeView);
    
    iMoniter = CDeviceUpdateMoniter::NewL(this);
    //iMoniter->StartMoniter();
    emit applicationReady();
    qDebug("DMFotaView::addFotaView <<");
    return ETrue;
    }