Ejemplo n.º 1
0
// ---------------------------------------------------------------------------
// CMmLineList::RemoveObject
// Marks a line object in array as not used
// ---------------------------------------------------------------------------
//
TInt CMmLineList::RemoveLine ( 
    const TName& aLineName )
    {
    TInt ret ( KErrGeneral );

    if ( iObjectContainer )
        {
        ret = KErrNone;
        if ( 0 == aLineName.CompareF( KMmTsyVoice1LineName ) )
            {
            iIsLineInUse[ ELine0Voice1 ] = EFalse;
            }
        else if ( 0 == aLineName.CompareF( KMmTsyVoice2LineName ) )
            {
            iIsLineInUse[ ELine1Voice2 ] = EFalse;
            }
        else if ( 0 == aLineName.CompareF( KMmTsyDataLineName ) )
            {
            iIsLineInUse[ ELine2Data ] = EFalse;
            }
        else if ( 0 == aLineName.CompareF( KMmTsyFaxLineName ) )
            {
            iIsLineInUse[ ELine3Fax ] = EFalse;
            }
        else
            {
            ret = KErrNotFound;
            }
        }
    return ret;
    }
Ejemplo n.º 2
0
// ---------------------------------------------------------------------------
// CMmLineList::AddLineObject
// Adds a TSY to the Line list
// ---------------------------------------------------------------------------
//
TInt CMmLineList::AddLineObject ( 
    CTelObject* aTsyObject, const TName& aLineName )
    {
    TInt ret ( KErrGeneral );
    
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMLINELIST_ADDLINEOBJECT_1, "TSY: CMmLineList::AddLineObject");
    if ( iObjectContainer )
        {
OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMLINELIST_ADDLINEOBJECT_2, "TSY: CMmLineList::AddLineObject:iObjectContainer->Count()=%d", iObjectContainer->Count());

        
        TInt trapError( KErrNone );    

        if ( 0 == aLineName.CompareF( KMmTsyVoice1LineName ) )
            {
            iIsLineInUse[ ELine0Voice1 ] = ETrue;
            iObjectContainer->Delete( ELine0Voice1 );
            iObjectContainer->Compress();
            TRAP( trapError, iObjectContainer->InsertL( ELine0Voice1, 
                                                        aTsyObject ) );
            }
        else if ( 0 == aLineName.CompareF( KMmTsyVoice2LineName ) )
            {
            iIsLineInUse[ ELine1Voice2 ] = ETrue;
            iObjectContainer->Delete( ELine1Voice2 );
            iObjectContainer->Compress();
            TRAP( trapError, iObjectContainer->InsertL( ELine1Voice2, 
                                                        aTsyObject ) );
            }
        else if ( 0 == aLineName.CompareF( KMmTsyDataLineName ) )
            {
            iIsLineInUse[ ELine2Data ] = ETrue;
            iObjectContainer->Delete( ELine2Data );
            iObjectContainer->Compress();
            TRAP( trapError, iObjectContainer->InsertL( ELine2Data,
                                                        aTsyObject ) );
            }
        else if ( 0 == aLineName.CompareF( KMmTsyFaxLineName ) )
            {
            iIsLineInUse[ ELine3Fax ] = ETrue;
            iObjectContainer->Delete( ELine3Fax );
            iObjectContainer->Compress();
            TRAP( trapError, iObjectContainer->InsertL( ELine3Fax,
                                                        aTsyObject ) );
            }
        //Check the trap error
        if ( KErrNone != trapError )
            {
            //change return value to indicate out of memory error
            ret = KErrNoMemory;
            }
        else
            {
            //success return value
            ret = KErrNone;
            iInitialised = ETrue;
            }
        }
    return ret;
    }
Ejemplo n.º 3
0
void TestRename()
	{
	TName name;

	test.Start(_L("Renaming the current process with User::RenameProcess"));
	name = RProcess().Name();
	name.SetLength(KTestProcessName().Length());
	test(name.CompareF(KTestProcessName)!=0);
	User::RenameProcess(KTestProcessName);
	name = RProcess().Name();
	name.SetLength(KTestProcessName().Length());
	test(name.CompareF(KTestProcessName)==0);


	test.End();
	}
void CSmsStackTestServer::LoadTsyL(RTelServer& aServer, RPhone& aPhone, const TDesC& aTsyName)
    {
    INFO_PRINTF2(_L("Using TSY \"%S\"Loading RTelServer..."), &aTsyName);

    TInt ret = aServer.LoadPhoneModule(aTsyName);
    if (ret!=KErrNone)
        {
        ERR_PRINTF2(_L("Loading Phone Module returned %d"), ret);
        User::Leave(ret);
        }
    
    // Find the phone corresponding to this TSY and open a number of handles on it
    TInt numPhones;
    ret = aServer.EnumeratePhones(numPhones);
    if (ret!=KErrNone)
        {
        ERR_PRINTF2(_L("Enumerate Phones  returned %d"), ret);
        User::Leave(ret);
        }
    
    TBool found=EFalse;

    while (numPhones--)
        {
        TName phoneTsy;
        ret = aServer.GetTsyName(numPhones,phoneTsy);
        if (ret!=KErrNone)
            {
            ERR_PRINTF2(_L("GetTsyName returned %d"), ret);
            User::Leave(ret);
            }
        
        if (phoneTsy.CompareF(aTsyName)==KErrNone)
            {
            INFO_PRINTF1(_L("Found RPhone..."));
            found = ETrue;
            RTelServer::TPhoneInfo info;
            ret = aServer.GetPhoneInfo(numPhones,info);
            if (ret!=KErrNone)
                {
                ERR_PRINTF2(_L("GetPhoneInfo returned %d"), ret);
                User::Leave(ret);
                }
            ret = aPhone.Open(aServer,info.iName);
            if (ret!=KErrNone)
                {
                ERR_PRINTF2(_L("Opening phone returned %d"), ret);
                User::Leave(ret);
                }
 
            INFO_PRINTF1(_L("Initializing..."));
            ret = aPhone.Initialise();
            TTimeIntervalMicroSeconds32 InitPause=9000000;  //Required Pause to Allow SMSStack to Complete its Async Init
            User::After(InitPause);                         //call to the TSY and finish its StartUp.
            if (ret!=KErrNone)
                {
                ERR_PRINTF2(_L("Completed Initialize returned %d"), ret);
                User::Leave(ret);
                }
            break;
            }
        }
    
    if(!found)
        {
        ERR_PRINTF2(_L("Couldn't find the phone for TSY %S"), &aTsyName);
        }
    }
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"));
	}
/** Finds and opens the phones to be used to monitor current network
info and cell info (timing advance).

This method also checks if the TSY can provide the different
bits of information needed by SUPL from ETEL: current and home network
information, cell ID information (for Timing Advance).
	
@leave	Leaves if underlying ETEL.DLL returns error,
or if we can't find a suitable Phone or can't open it.
*/
void CSuplNetworkInfoHandler::InitialisePhonesL()
	{
	SUPLLOG(ELogP1, "CSuplNetworkInfoHandler::InitialisePhonesL() Begin\n");
	TInt err(KErrNone);
		
	// Read the name of the .tsy to load from CommDB
	TBuf<KCommsDbSvrMaxFieldLength> tsyName;
	GetCommDbTSYnameL(tsyName);

	// Load .tsy into ETel
	User::LeaveIfError(iTelServer.LoadPhoneModule(tsyName));

	// Find available phones; check that the one we requested 
	// to be loaded is there.
	TInt phoneIndex(0);
	User::LeaveIfError(iTelServer.EnumeratePhones(phoneIndex));
	while(phoneIndex-->0)
		{
		TName searchTsyName;
		// Check whether this phone belongs to loaded TSY
		if ((iTelServer.GetTsyName(phoneIndex, searchTsyName) == KErrNone) 
			&& (searchTsyName.CompareF(tsyName) == KErrNone)) 
			break;
		}
		
	// Open a phone to be used for monitoring the network.
	RTelServer::TPhoneInfo phoneInfo;
	User::LeaveIfError(iTelServer.GetPhoneInfo(phoneIndex, phoneInfo));	
	User::LeaveIfError(iNetPhone.Open(iTelServer, phoneInfo.iName));
	
	// Check that the phone is ready to be used.	
	RPhone::TStatus status;
	User::LeaveIfError(iNetPhone.GetStatus(status));
	if(status.iModemDetected != RPhone::EDetectedPresent)
		{		
		err = iNetPhone.Initialise();
		if(err != KErrNone)
			{
			iNetPhone.Close();
			User::Leave(err);
			}
		}	

	// Check that network info can be accessed
	TUint32 networkCaps;
	User::LeaveIfError(iNetPhone.GetNetworkCaps(networkCaps));
	if (!(networkCaps & RMobilePhone::KCapsGetCurrentNetwork
		  && networkCaps & RMobilePhone::KCapsNotifyCurrentNetwork))
		{
		// No point in continuing
		err = KErrNotSupported;
		}
	else
		{
		if(networkCaps & RMobilePhone::KCapsGetHomeNetwork)
			{
			iHomeNetworkInfoSupport = ETrue;
			}
		
		// Network info can be accessed.

		// Check if Timing Advance is supported by the TSY
		// (If it isn't, that is NOT a critical error, so donnot
		// change the returned error code)
		iTimingAdvSupport = EFalse;
		iTelServer.IsSupportedByModule(tsyName, KEtelFuncCellInfo, iTimingAdvSupport);
		if (iTimingAdvSupport)
			{
			// Open a new phone for Get/NotifyCellInfo() requests			
			if (KErrNone ==	iCellPhone.Open(iTelServer, phoneInfo.iName))
				{
				// Check that iCellPhone is ready to be used	
				if(KErrNone == iCellPhone.GetStatus(status))
					{
					if(status.iModemDetected != RPhone::EDetectedPresent)
						{
						if(KErrNone != iCellPhone.Initialise())
							{
							// Unable to initialise phone
							iCellPhone.Close();
							iTimingAdvSupport = EFalse;
							}
						}
					}
				else
					{
					// Unable to get phone status
					iCellPhone.Close();
					iTimingAdvSupport = EFalse;					
					}
				}
			else
				{
				// Unable to open phone
				iTimingAdvSupport = EFalse;	
				}
			}
		}
	User::LeaveIfError(err);
	
	iMsisdnSupport = EFalse;
	if(iTelServer.IsSupportedByModule(tsyName, KETelFuncMobileOwnNumberStore, iMsisdnSupport)==KErrNone && 
			iMsisdnSupport)
		{
		if(iOnStore.Open(iNetPhone)!=KErrNone)
			{
			iMsisdnSupport=EFalse;
			}
		}
	
	SUPLLOG(ELogP1, "CSuplNetworkInfoHandler::InitialisePhonesL() End\n");
	}
Ejemplo n.º 7
0
TInt CPhoneWatcher::ConnectToPhone()
	{
	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_1, "PhoneWatcher : ConnectToPhone()");
	TInt error;

	RTelServer::TPhoneInfo phoneInfo;

	// Get the number of phones
	TInt phoneCount = 0;
	error = ETel().EnumeratePhones(phoneCount);
	if	(error < KErrNone)
		{
		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_2, "PhoneWatcher : Failed to enumerate phones (%d)", error);
		return error;
		}

	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_3, "PhoneWatcher : Counted %d 'phones'", phoneCount);

	// Iterate through all the phones
	for(TInt i=0; i<phoneCount; i++)
		{
		// Get the TSY name for the phone
		TName matchTsyName;
		
		error = ETel().GetTsyName(i, matchTsyName);
		if	(error < KErrNone)
			{
			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_4, "PhoneWatcher : Getting TSY name failed (%d)", error);
			return error;
			}

		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_5, "PhoneWatcher : TSY for phone %d is '%S'", i, matchTsyName);


		// See if the phone belongs to the TSY
		if	(matchTsyName.CompareF(iTSYName) == 0)
			{
			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_6, "PhoneWatcher : %S is a match for CommDb TSY: %S", matchTsyName, iTSYName);

			error = ETel().GetPhoneInfo(i, phoneInfo);
			if	(error < KErrNone)
				{
				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_7, "PhoneWatcher : Getting phone info failed (%d)", error);
				return error;
				}
			break;
			}
		}

	// Connect to the specified phone
	error = Phone().Open(ETel(), phoneInfo.iName);
	if	(error < KErrNone)
		{
		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_8, "PhoneWatcher : Open phone %S failed (%d)", phoneInfo.iName, error);
		return error;
		}
	OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_9, "PhoneWatcher : Opened 'phone' %S", phoneInfo.iName);


	// Indicate we're connected and to move to next state.
	return error;
	}