void CTTGPSLoggerPositionRequester::StartL()
	{
	Stop();
	//RDebug::Print(_L("%d\n"), __LINE__);

#ifdef POSMETH
	TPositionModuleInfo info;
	if ( (iPositioningMethod>0) &&
				((iPositionServer.GetModuleInfoByIndex(iPositioningMethod-1,info) == KErrNone) && (info.IsAvailable())) )
			{
			User::LeaveIfError(iPositioner.Open(iPositionServer, info.ModuleId()));
			}
	else
#endif
		User::LeaveIfError(iPositioner.Open(iPositionServer));
	
	//RDebug::Print(_L("%d\n"), __LINE__);
	User::LeaveIfError(iPositioner.SetRequestor(CRequestor::ERequestorService, CRequestor::EFormatApplication, KRequestor));
	//RDebug::Print(_L("%d\n"), __LINE__);
	const TTimeIntervalMicroSeconds KUpdateInterval(1000000);
	const TTimeIntervalMicroSeconds KTimeOut(2000000);
	const TTimeIntervalMicroSeconds KMaxUpdateAge(0);
	TPositionUpdateOptions options;
	options.SetUpdateInterval(KUpdateInterval);
	options.SetUpdateTimeOut(KTimeOut);
	options.SetMaxUpdateAge(KMaxUpdateAge);
	options.SetAcceptPartialUpdates(ETrue);
	//RDebug::Print(_L("%d\n"), __LINE__);
	User::LeaveIfError(iPositioner.SetUpdateOptions(options));
	//RDebug::Print(_L("%d\n"), __LINE__);
	iPositioner.NotifyPositionUpdate(*iPositionInfo, iStatus);
	//RDebug::Print(_L("%d\n"), __LINE__);
	SetActive();
	}
void CPosSession::GetDefaultModuleIdL(const RMessage2& aMessage)
    {
    DEBUG_TRACE("EPositionServerGetDefaultModuleId", __LINE__)

    CPosModuleIdList* moduleList = iModuleSettings.ModuleIdListL();
    CleanupStack::PushL( moduleList );
    TInt nrOfModules = moduleList->Count();
    TInt res = KErrNotFound;

    for (TInt i = 0; (i < nrOfModules) && (res == KErrNotFound); i++)
        {
        TPositionModuleInfo candidate;
        iModuleSettings.GetModuleInfoL((*moduleList)[i], candidate);

        if (candidate.IsAvailable())
            {
            TPckg<TPositionModuleId> moduleId(candidate.ModuleId());
            User::LeaveIfError(Global::Write(aMessage, KParamModuleIdGetDefault, moduleId));
            res = KErrNone;
            }
        }

    CleanupStack::PopAndDestroy(moduleList);
    RequestComplete(aMessage, res);
    }   
// ---------------------------------------------------------
// CT_LbsClientPosTp76::CheckModuleInfoL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp76::CheckModuleInfoL(const TPositionModuleInfo& dbInfo,
                                const TPositionModuleInfo& clientInfo)
    {
    _LIT(KNotSame, "Module Info from settings is not the same as when read by GetModuleInfoById");
    if (dbInfo.IsAvailable() != clientInfo.IsAvailable() ||
        dbInfo.ModuleId() != clientInfo.ModuleId() ||
        dbInfo.DeviceLocation() != clientInfo.DeviceLocation() ||
        dbInfo.Capabilities() != clientInfo.Capabilities() ||
        dbInfo.TechnologyType() != clientInfo.TechnologyType() ||
        dbInfo.Version().iBuild != clientInfo.Version().iBuild ||
        dbInfo.Version().iMajor != clientInfo.Version().iMajor ||
        dbInfo.Version().iMinor != clientInfo.Version().iMinor ||
        dbInfo.Version().Name() != clientInfo.Version().Name() ||
        dbInfo.ClassesSupported(EPositionInfoFamily) != clientInfo.ClassesSupported(EPositionInfoFamily))
        {
        LogErrorAndLeaveL(KNotSame);
        }
    TPositionQuality dbQuality;
    TPositionQuality clientQuality;
    dbInfo.GetPositionQuality(dbQuality);
    clientInfo.GetPositionQuality(clientQuality);
    if (dbQuality.TimeToFirstFix() != clientQuality.TimeToFirstFix() ||
        dbQuality.TimeToNextFix() != clientQuality.TimeToNextFix() ||
        dbQuality.HorizontalAccuracy() != clientQuality.HorizontalAccuracy() ||
        dbQuality.VerticalAccuracy() != clientQuality.VerticalAccuracy() ||
        dbQuality.CostIndicator() != clientQuality.CostIndicator() || 
        dbQuality.PowerConsumption() != clientQuality.PowerConsumption() )
        {
        LogErrorAndLeaveL(KNotSame);
        }


    TBuf<30> name1;
    TBuf<30> name2;
    dbInfo.GetModuleName(name1);
    clientInfo.GetModuleName(name2);
    if (name1 != name2)
        {
        LogErrorAndLeaveL(KNotSame);
        }
    }
void CAzqInternalGPSReader::ConstructL()
	{
	CActiveScheduler::Add( this); // Add to scheduler

	User::LeaveIfError(iPositionServer.Connect());


	//leave if internal gps not present

	TUint numModules=0;
	TPositionModuleInfo modInfo;
	TPositionModuleStatus modStatus;

	TBool foundModule = EFalse;

	// 2. Get the number of modules installed
	User::LeaveIfError(iPositionServer.GetNumModules(numModules));

	// 3. Iterate over the modules to get information about each module
	// 4. Get the availability of a module
	// 5. Get information about the module technology, quality etc.

	for (TUint I=0 ; I < numModules ; I++)
	 {
		 User::LeaveIfError(iPositionServer.GetModuleInfoByIndex(I, modInfo));

		 /* Check module technology type and availability
		    In this example - does the module support assisted capability
		    and is the module available? */

		 if ( modInfo.IsAvailable() && (modInfo.TechnologyType() == ( TPositionModuleInfo::ETechnologyAssisted) ) )
		 {
			  foundModule = ETrue;
			  iPositionModuleId = modInfo.ModuleId();
			  break;
		 }
	 }


	if (foundModule)
	 {

	 	User::LeaveIfError(iPositioner.Open(iPositionServer,iPositionModuleId));

	 }
	else
	 {
	    User::Leave(KErrNotFound);
	 }

	}
void CTe_locsrvSuiteStepBase::StandardPrepareL()
{
    // Setup modules:
    // LcfDummyPsy1,3 and LcfPsy6 should be enabled, other - disabled
    CPosModules* modules = CPosModules::OpenL();
    CleanupStack::PushL(modules);
    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();

    CPosModuleIdList* idList = modules->ModuleIdListLC();
    for (TInt i = 0; i < idList->Count(); i++)
        {
        TPositionModuleInfo info;
        modules->GetModuleInfoL((*idList)[i], info);
        switch (info.ModuleId().iUid)
            {
            case KLcfPsy1UidValue:
            case KLcfPsy3UidValue:
            case KLcfPsy6UidValue:
                if (!info.IsAvailable())
                    {
                    moduleUpdate->SetUpdateAvailability(ETrue);
                    modules->UpdateModuleL(info.ModuleId(), *moduleUpdate);
                    }
                break;
            default:        
                if (info.IsAvailable())
                    {
                    moduleUpdate->SetUpdateAvailability(EFalse);
                    modules->UpdateModuleL(info.ModuleId(), *moduleUpdate);
                    }
                break;
            }
        }
    CleanupStack::PopAndDestroy(3, modules);
    User::After(KSecondsToMicro);
}
// ---------------------------------------------------------
// CT_LbsClientPosTp76::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp76::StartL()
    {
	// Open connection to Epos    
	RPositionServer posServer;
	CleanupClosePushL(posServer);
	TInt err = posServer.Connect();    
	_LIT(KConnectError, "TP76. Unable to open connection to Epos, return code %d");
	AssertTrueSecL(err == KErrNone, KConnectError, err);

	// Set priority for those psys that will be used in this tp.
	// The order will be testpsy1(externalgps),testpsy2,testpsy3
	TUid uidPsy1 = iUidTestPsy1;
	TUid uidPsy2 = iUidTestPsy2;
	TUid uidPsy3 = iUidTestPsy3;

    SetupPsyL(uidPsy1); // will disable all except uidPsy1

    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db);

    // Enable the PSY test psys 
    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
    moduleUpdate -> SetUpdateAvailability(ETrue);
    db->SetModulePriorityL(uidPsy1, 0);
    db->SetModulePriorityL(uidPsy2, 1);
    db->SetModulePriorityL(uidPsy3, 1);
    db->UpdateModuleL(uidPsy1, *moduleUpdate);
    db->UpdateModuleL(uidPsy2, *moduleUpdate);
    db->UpdateModuleL(uidPsy3, *moduleUpdate);
    CleanupStack::PopAndDestroy(moduleUpdate);

    // Setup the PSY:s in the correct order
    CPosModuleIdList* prioList = db->ModuleIdListLC();
    TInt numModules = prioList->Count();
    TPositionModuleInfo modInfoPsy2; //used to comapre that the same result is returned.
    db -> GetModuleInfoL(uidPsy2, modInfoPsy2);
    CleanupStack::PopAndDestroy(2); // db, prioList
	
	// Get default positioning module info. (testpsy1 or externalgps)
	TPositionModuleInfo modInfo;
    TPositionModuleId defaultId;
    err = posServer.GetDefaultModuleId(defaultId);
    _LIT(KDefaultModuleId, "Not possible to get default module id");
    AssertTrueSecL(err == KErrNone, KDefaultModuleId, err);
    // Check that the correct id was returned.
    if (defaultId != uidPsy1)
        {
        _LIT(KErrorWrongModule, "Default module was not returned in GetDefaultModuleId()");
        LogErrorAndLeaveL(KErrorWrongModule);
        }

    // Get default module info by using the id returned.
    err = posServer.GetModuleInfoById(defaultId, modInfo);
	_LIT(KGetDefPosModInfoError,
            "TP76. Error occured at GetModuleInfoById, return code %d");
	AssertTrueSecL(err == KErrNone, KGetDefPosModInfoError, err);
	// Check if the received psy is the right one
	_LIT(KIncorrectPsyError,
           "TP76. Incorrect PSY returned from Epos.");
	AssertTrueL(uidPsy1 == modInfo.ModuleId(), KIncorrectPsyError);
    //END TEST DEFAULT//

	//
    // TestGetModuleInfoById //
	//

    // Get info from specific psy (testpsy2)
	_LIT(KGetPosModInfoError, "Wrong data received from Epos");
    err = posServer.GetModuleInfoById(uidPsy2, modInfo);
	AssertTrueSecL(err == 0, KGetPosModInfoError, err);
	AssertTrueL(modInfo.ModuleId() == uidPsy2, KGetPosModInfoError);
    CheckModuleInfoL(modInfoPsy2, modInfo);
    //END TEST GetModuleInfoById//

	//
    // Test GetModuleInfoByIndex //
	//

	// Get info from the testpsys (testpsy1, testpsy2, testpsy3)
    TPositionModuleId id1;
    TPositionModuleId id2;
    TPositionModuleId id3;
    TUint count;
	err = posServer.GetNumModules(count);
	_LIT(KNumPosModInfoError,
            "TP76. Error occured at GetNumModules error code returned, return code %d");
	AssertTrueSecL(err == 0,KNumPosModInfoError,err);
	_LIT(KIncorrectNoOfModules,
           "TP76. Incorrect number of modules.");
    TUint no = (TUint) numModules; //Bad API implementation
	AssertTrueL(count == no, KIncorrectNoOfModules);

    err = posServer.GetModuleInfoByIndex(0, modInfo);
    AssertTrueSecL(err == KErrNone, KGetDefPosModInfoError, err);
    id1 = modInfo.ModuleId();
    if (!(id1 == uidPsy1 ||
        id1 == uidPsy2 ||
        id1 == uidPsy3))
        {
        LogErrorAndLeaveL(KGetPosModInfoError);
        }

    err = posServer.GetModuleInfoByIndex(1, modInfo);
    AssertTrueSecL(err == 0, KGetDefPosModInfoError, err);
    id2 = modInfo.ModuleId();
    if (!(id2 == uidPsy1 ||
        id2 == uidPsy2 ||
        id2 == uidPsy3))
        {
        LogErrorAndLeaveL(KGetPosModInfoError);
        }

    err = posServer.GetModuleInfoByIndex(2, modInfo);
    AssertTrueSecL(err == 0, KGetDefPosModInfoError, err);
    id3 = modInfo.ModuleId();
    if (!(id3 == uidPsy1 ||
        id3 == uidPsy2 ||
        id3 == uidPsy3))
        {
        LogErrorAndLeaveL(KGetPosModInfoError);
        }
    
    // Assuming that only 3 PSYs are installed
    err = posServer.GetModuleInfoByIndex(3, modInfo);
    AssertTrueSecL(err == 0, KGetDefPosModInfoError, err);

    // END TEST GetModuleInfoByIndex //

	CleanupStack::PopAndDestroy(); //posServer
	}
Exemple #7
0
// ---------------------------------------------------------
// CT_LbsClientPosTp1::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp1::StartL()
    {
    ConnectL();
    
    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db); 

    SetupPsyL(iUidMultiPsy);

    _LIT(KSetupPSY, "TP1: Has Setup Multi PSY");
    INFO_PRINTF1(KSetupPSY);
    
    //setting priority
	TPositionModuleInfo moduleInfoHp;//Hp - high prio;
	TPositionModuleInfo moduleInfoLp;//Lp - low prio;

    CPosModuleIdList* prioList = db->ModuleIdListLC();	
    db->GetModuleInfoL(prioList->At(0), moduleInfoHp);

    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
    moduleUpdate->SetUpdateAvailability(ETrue);

    if (iUidMultiPsy.iUid == moduleInfoHp.ModuleId().iUid)
		{
		// Case when Multi PSY has highest prio: 
		// Ensuring it is enabled
	    _LIT(KMultiHighest, "TP1: Case when Multi PSY has highest prio");
	    INFO_PRINTF1(KMultiHighest);	    
		db->UpdateModuleL((*prioList)[0], *moduleUpdate);
		}
	else
		{
		// Case when Multi PSY has not highest prio: 
		// 
	    _LIT(KMultiNotHighest, "TP1: Case when Multi PSY has NOT highest prio");	    
	    INFO_PRINTF1(KMultiNotHighest);	    
        db->GetModuleInfoL(iUidMultiPsy, moduleInfoLp);
		// Ensuring it is enabled
		db->UpdateModuleL(iUidMultiPsy, *moduleUpdate);

		TUint hp = db->PriorityL(moduleInfoHp.ModuleId());
		TUint lp = db->PriorityL(moduleInfoLp.ModuleId());

		// Changing prio of highest prio PSY and Multi PSY.
		// Setting Multi PSY to highest prio
		db->SetModulePriorityL(iUidMultiPsy, hp);
        db->SetModulePriorityL((*prioList)[0], lp); 
		}

	_LIT(KTestPSY1On, "TP1: Enabling Test PSY 1");
    INFO_PRINTF1(KTestPSY1On);	    
	db -> UpdateModuleL(iUidTestPsy1, *moduleUpdate);
	_LIT(KTestPSY2On, "TP1: Enabling Test PSY 2");
    INFO_PRINTF1(KTestPSY2On);
	db -> UpdateModuleL(iUidTestPsy2, *moduleUpdate);
    
	CleanupStack::PopAndDestroy(moduleUpdate);
	CleanupStack::PopAndDestroy(2, db); // db, prioList

    User::LeaveIfError(OpenPositioner());

    // Request data from default psy should be Multi psy
    _LIT(KService, "service");
    TPositionInfo posInfo = TPositionInfo();
    TInt err = PerformSyncRequest(KService, &posInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest, err);
        }
	
    if (iUidMultiPsy.iUid != posInfo.ModuleId().iUid)
		{
		_LIT(KIncorrectPsyError, "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
		}

	HPositionGenericInfo* genericInfo = HPositionGenericInfo::NewLC();
	err = PerformSyncRequest(KService, &(*genericInfo));
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest);
        }

	 if (iUidMultiPsy.iUid != (genericInfo -> ModuleId()).iUid)
		{
		_LIT(KIncorrectPsyError,
           "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
		}

	TPositionCourseInfo courseInfo = TPositionCourseInfo();
	err = PerformSyncRequest(KService, &courseInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "Course info supported by default, but request failed");
        LogErrorAndLeaveL(KErrorRequest);
        }

	TPositionSatelliteInfo satelliteInfo = TPositionSatelliteInfo();
	err = PerformSyncRequest(KService, &satelliteInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "Satellite info supported by default, but request failed");
        LogErrorAndLeaveL(KErrorRequest);
        }	

    //Changing the priority and verifiy that it still possilbe
    //to request updated from a psy if basic position information
    //is used and that it is not possilbe to request sat or cource
    //any more.
    SetupPsyL(iUidTestPsy2);
    User::After(3000000);

    // Request data from default psy should be test psy 2 now
    err = PerformSyncRequest(KService, &posInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest);
        }
	
    if (iUidTestPsy2.iUid != posInfo.ModuleId().iUid)
		{
		_LIT(KIncorrectPsyError,
           "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
		}

	err = PerformSyncRequest(KService, &(*genericInfo));
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest);
        }

	 if (iUidTestPsy2.iUid != (genericInfo -> ModuleId()).iUid)
		{
		_LIT(KIncorrectPsyError,
           "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
        }

    err = PerformSyncRequest(KService, &courseInfo);
    if (err != KErrArgument)
        {
        _LIT(KErrorRequest, "Course info not supported by default, KErrArgument not returned");
        LogErrorAndLeaveL(KErrorRequest);
        }


	err = PerformSyncRequest(KService, &satelliteInfo);
    if (err != KErrArgument)
        {
        _LIT(KErrorRequest, "Satellite info not supported by default, KErrArgument not returned");
        LogErrorAndLeaveL(KErrorRequest);
        }

    //check that it is possilbe to change the different
    //type of class info during periodic request and
    //that the periodic update will fail if the class
    //type is incorrect.
    TTimeIntervalMicroSeconds interval = TTimeIntervalMicroSeconds(1000000);
    TPositionUpdateOptions posOption;
	posOption.SetUpdateInterval(interval);
	_LIT(KUpdateErr, "Error when setting update interval,  %d");
	err = iPositioner.SetUpdateOptions(posOption);
    AssertTrueL(err == KErrNone, KUpdateErr, err);

    _LIT(KErrPeriodic, "The periodic request did not return KErrNone, %d");
    err = PerformSyncRequest(KService, &posInfo);
    AssertTrueL(err == KErrNone , KErrPeriodic, err);
    
    _LIT(KErrPeriodicArr, "The periodic request did not return KErrArgument, %d");
    err = PerformSyncRequest(KService, &satelliteInfo);
    AssertTrueL(err == KErrArgument , KErrPeriodicArr, err);
    SetupPsyL(iUidMultiPsy);
    User::After(3000000);
    err = PerformSyncRequest(KService, &satelliteInfo);
    AssertTrueL(err == KErrNone , KErrPeriodic, err);

    CleanupStack::PopAndDestroy(genericInfo);
    ClosePositioner();
    Disconnect();
    }
EXPORT_C TBool T_LbsUtils::Compare_ModuleInfo(TPositionModuleInfo& aModInfoSideA, TPositionModuleInfo& aModInfoSideB)
	{
	// Compare all module information items and quality.
	
	// Compare module id.
	if (aModInfoSideA.ModuleId() != aModInfoSideB.ModuleId())
		{
		return EFalse;
		}	

	//	Compare is available flag.
	if (aModInfoSideA.IsAvailable() != aModInfoSideB.IsAvailable())
		{
		return EFalse;
		}	

	// Compare technology type.
	if (aModInfoSideA.TechnologyType() != aModInfoSideB.TechnologyType())
		{
		return EFalse;
		}	

	//	Compare device location.
	if (aModInfoSideA.DeviceLocation() != aModInfoSideB.DeviceLocation())
		{
		return EFalse;
		}	

	//	Compare capabilities.
	if (aModInfoSideA.Capabilities() != aModInfoSideB.Capabilities())
		{
		return EFalse;
		}	

	// Compare each of the family classes. Use min and max enum values.
	for (TInt i = EPositionInfoFamily; i <= EPositionUpdateOptionsFamily; i++)
		{
		if (aModInfoSideA.ClassesSupported(static_cast<TPositionClassFamily>(i)) != aModInfoSideB.ClassesSupported(static_cast<TPositionClassFamily>(i)))
			{
			return EFalse;
			}	
		}
		
	// Compare version.
	if ((aModInfoSideA.Version().iMajor != aModInfoSideB.Version().iMajor) ||
		(aModInfoSideA.Version().iMinor != aModInfoSideB.Version().iMinor) ||
		(aModInfoSideA.Version().iBuild != aModInfoSideB.Version().iBuild))
		{
		return EFalse;
		}	

	// Compare module name.
	TBuf<KPositionMaxModuleName> modNameSideA;
	TBuf<KPositionMaxModuleName> modNameSideB;

	aModInfoSideA.GetModuleName(modNameSideA);
	aModInfoSideB.GetModuleName(modNameSideB);
	if (0 != modNameSideA.Compare(modNameSideB))
	{
		return EFalse;
	}

	// Compare module quality.
	TPositionQuality qualitySideA;
	TPositionQuality qualitySideB;	
	
	aModInfoSideA.GetPositionQuality(qualitySideA);
	aModInfoSideB.GetPositionQuality(qualitySideB);
	
	return Compare_PositionQuality(qualitySideA, qualitySideB);
	}
void CTTGPSLoggerPositioningMethod::EditItemL(TBool aCalledFromMenu) // edit text
    {
	CDesC16ArrayFlat *itemArray = new (ELeave) CDesC16ArrayFlat(20);
	CDesC16ArrayFlat *itemArrayDetails = new (ELeave) CDesC16ArrayFlat(20);
	CleanupStack::PushL(itemArray); // in case the appends leave
	CleanupStack::PushL(itemArrayDetails); // in case the appends leave
	RPositionServer iPositionServer;
	RPositioner iPositioner;
	User::LeaveIfError(iPositionServer.Connect());
	User::LeaveIfError(iPositioner.Open(iPositionServer));
	itemArray->AppendL(_L("(Info on all modules)"));
	itemArray->AppendL(_L("(Default)"));
	TUint aModules = 0;
	TInt defaultModule=-1;

	// Get the available numbers of modules
	User::LeaveIfError(iPositionServer.GetNumModules(aModules));
    TPositionModuleInfo info;
	TPositionModuleId aModuleId;
	iPositionServer.GetDefaultModuleId(aModuleId);

	// Prepare itemArray and itemArrayDetails
    for(TUint i = 0; i < aModules; i++)
    	{
    	if ((iPositionServer.GetModuleInfoByIndex(i,info) == KErrNone) && (info.IsAvailable()))
    		{
    		TBuf<200> smallBuffer;
    		smallBuffer.Zero();
    		info.GetModuleName(smallBuffer);
    		itemArray->AppendL(smallBuffer);

			TBuf<200> buffer;
			buffer.Zero();
			info.GetModuleName(buffer);
			buffer.Append(_L(" ("));
			if (info.DeviceLocation() & TPositionModuleInfo::EDeviceExternal)
				buffer.Append(_L("External "));
			if (info.DeviceLocation() & TPositionModuleInfo::EDeviceInternal)
				buffer.Append(_L("Internal "));
			if (info.DeviceLocation() & TPositionModuleInfo::EDeviceUnknown)
				buffer.Append(_L("Unknown "));
			if (info.TechnologyType()& TPositionModuleInfo::ETechnologyAssisted)
				buffer.Append(_L("Assisted "));
			if (info.TechnologyType()& TPositionModuleInfo::ETechnologyTerminal)
				buffer.Append(_L("GPS, "));
			if (info.TechnologyType()& TPositionModuleInfo::ETechnologyNetwork)
				buffer.Append(_L("Network, "));
			if (info.TechnologyType()& TPositionModuleInfo::ETechnologyUnknown)
				buffer.Append(_L("Unknown tech, "));
			if (buffer.Mid(buffer.Length()-2, 2).Compare( _L(", ")) == KErrNone)
				buffer.Replace(buffer.Length()-2, 2, _L(")"));
			if (buffer.Mid(buffer.Length()-1, 1).Compare( _L(" "))  == KErrNone)
				buffer.Replace(buffer.Length()-1, 1, _L(")"));
			if ( info.ModuleId() == aModuleId)
				{
				buffer.Append(_L(" [Default]"));
				defaultModule=i;
				}
    		itemArrayDetails->AppendL(buffer);    		
    		}
    	}	
	iPositioner.Close();
	iPositionServer.Close();

	// Present list of positioning methods
	TInt selectIndex;
    selectIndex=iPosMethod+1;
    HBufC* title = NULL;
	title = CEikonEnv::Static()->AllocReadResourceLC(R_TTGP_TBUF32_DIALOG_POSITIONING_TITLE); // Select positioning method:
    CAknListQueryDialog* dialog = new (ELeave) CAknListQueryDialog(&selectIndex);
    dialog->PrepareLC(R_TTGP_DIALOG_LISTQUERY);
    dialog->QueryHeading()->SetTextL(*title);
    dialog->SetItemTextArray(itemArray);
    dialog->SetOwnershipType(ELbmDoesNotOwnItemArray);
    TInt answer = dialog->RunLD();
    CleanupStack::PopAndDestroy(); // title
    // Check answer
    if (answer)
    	{
        if (selectIndex==0) // (Info on all modules)
    		{
    		TBuf<1000> aText;
    		aText.Zero();
    		for (TInt i=0;i<itemArrayDetails->Count();i++)
    			{
    			aText.AppendFormat(_L("%d. "), i+1);
    			aText.Append(itemArrayDetails->MdcaPoint(i));
    			if (i<itemArrayDetails->Count()-1)
    				aText.Append(_L("\n"));
    			}
    		HBufC* title = CEikonEnv::Static()->AllocReadResourceLC(R_TTGP_TBUF32_AVAILABLEPOSITIONING_TITLE); // Available modules:
    		CAknMessageQueryDialog* dialog = new (ELeave) CAknMessageQueryDialog();
    		CleanupStack::PushL(dialog);
    		dialog->PrepareLC(R_TTGP_DIALOG_MESSAGEQUERY_OK);
    		dialog->QueryHeading()->SetTextL(*title);
    		dialog->SetMessageTextL(aText);
    		CleanupStack::Pop(); // dialog
    		dialog->RunLD();
    		CleanupStack::PopAndDestroy(); // title
    		}
        else
        if (selectIndex==1) // Default module
        	{
        	if (defaultModule>-1)
        		{
        		// Present default module name
        		HBufC* title = CEikonEnv::Static()->AllocReadResourceLC(R_TTGP_TBUF32_SELECTEDPOSITIONING_TITLE); // Selected module:
        		CAknMessageQueryDialog* dialog = new (ELeave) CAknMessageQueryDialog();
        		CleanupStack::PushL(dialog);
        		dialog->PrepareLC(R_TTGP_DIALOG_MESSAGEQUERY_OK);
        		dialog->QueryHeading()->SetTextL(*title);
        		dialog->SetMessageTextL(itemArrayDetails->MdcaPoint(defaultModule));
        		CleanupStack::Pop(); // dialog
        		dialog->RunLD();
        		CleanupStack::PopAndDestroy(); // title
        		}
    		iPosMethod=0; // default module selected
    		C_APPUI->Engine()->Requester()->SetPositioningMethod(iPosMethod);
    		C_APPUI->Engine()->Requester()->StartL();
        	}
        else
        if (selectIndex>1) // Custom selection of the module
        	{
    		HBufC* title = CEikonEnv::Static()->AllocReadResourceLC(R_TTGP_TBUF32_SELECTEDPOSITIONING_TITLE); // Selected module:
    		CAknMessageQueryDialog* dialog = new (ELeave) CAknMessageQueryDialog();
    		CleanupStack::PushL(dialog);
    		dialog->PrepareLC(R_TTGP_DIALOG_MESSAGEQUERY_OK);
    		dialog->QueryHeading()->SetTextL(*title);
    		dialog->SetMessageTextL(itemArrayDetails->MdcaPoint(selectIndex-2));
    		CleanupStack::Pop(); // dialog
    		dialog->RunLD();
    		CleanupStack::PopAndDestroy(); // title
    		iPosMethod=selectIndex-1;
    		C_APPUI->Engine()->Requester()->SetPositioningMethod(iPosMethod);
    		C_APPUI->Engine()->Requester()->StartL();
    		}
    	UpdateListBoxTextL();
    	}
    CleanupStack::PopAndDestroy(); // itemArrayDetails
    CleanupStack::PopAndDestroy(); // itemArray
    }
TVerdict ClbsinternalapiTest1Step::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Our implementation only gets called if the base class doTestStepPreambleL() did
 * not leave. That being the case, the current test result value will be EPass.
 */
	{
	  if (TestStepResult()==EPass)
		{
		//Let's do some tests...
		
		TPositionModuleInfoExtended moduleInfo1;
		TPositionModuleInfoExtended moduleInfo2;
		
		const TUid KModuleUid1 = {0x0ABC0987};
		const TUid KModuleUid2 = {0x01230987};
		
		TPositionModuleInfo* posModInfo;
		posModInfo = 	(TPositionModuleInfo*)(&moduleInfo1.iPositionModuleInfoBytes[0]);
		posModInfo->SetModuleId(TPositionModuleId(KModuleUid1));
		moduleInfo1.iModuleId = KModuleUid1;
		
		posModInfo = 	(TPositionModuleInfo*)(&moduleInfo2.iPositionModuleInfoBytes[0]);
		posModInfo->SetModuleId(TPositionModuleId(KModuleUid2));
		moduleInfo2.iModuleId = KModuleUid2;
		
		const TPositionModuleInfoExtended* KModuleInfoArray[] =
			{
			&moduleInfo1,
			&moduleInfo2
			};
		
		LbsModuleInfo::InitializeL(KModuleInfoArray, 2);
		
		TUint numModules = 0;
		
		User::LeaveIfError(LbsModuleInfo::GetNumModules(numModules));
		
		if(numModules!=2)
			{
			User::Leave(KErrGeneral);
			}
		
		TPositionModuleInfo retrievingModuleInfo;
		
		//Check we can retrieve the two objects by index
		User::LeaveIfError(LbsModuleInfo::GetModuleInfoByIndex(0, &retrievingModuleInfo, sizeof(TPositionModuleInfo)));
		
		if(retrievingModuleInfo.ModuleId()!=KModuleUid1)
			User::Leave(KErrGeneral);
		
		User::LeaveIfError(LbsModuleInfo::GetModuleInfoByIndex(1, &retrievingModuleInfo, sizeof(TPositionModuleInfo)));
		
		if(retrievingModuleInfo.ModuleId()!=KModuleUid2)
			User::Leave(KErrGeneral);
		
		//Check we can retrieve the two objects by id
		User::LeaveIfError(LbsModuleInfo::GetModuleInfoById(KModuleUid1, &retrievingModuleInfo, sizeof(TPositionModuleInfo)));
		
		if(retrievingModuleInfo.ModuleId()!=KModuleUid1)
			User::Leave(KErrGeneral);
		
		User::LeaveIfError(LbsModuleInfo::GetModuleInfoById(KModuleUid2, &retrievingModuleInfo, sizeof(TPositionModuleInfo)));
		
		if(retrievingModuleInfo.ModuleId()!=KModuleUid2)
			User::Leave(KErrGeneral);
		
		SetTestStepResult(EPass);
		}
	  return TestStepResult();
	}
void CGpsDataHandler::ResolveAndConnectL() {
	TInt aResult;

#ifndef __SERIES60_3X__

	if((aResult = iSocketServ.Connect()) == KErrNone) {
		if(iGpsDeviceResolved) {
			if((aResult = iSocket.Open(iSocketServ, KBTAddrFamily, KSockStream, KRFCOMM)) == KErrNone) {
				iEngineStatus = EGpsConnecting;

				iSocket.Connect(iBTAddr, iStatus);
				SetActive();
			}
		}
		else {
			_LIT(KLinkMan, "BTLinkManager");
			//_LIT(KLinkMan, "RFCOMM");
			TProtocolName aProtocolName(KLinkMan);

			if((aResult = iSocketServ.FindProtocol(aProtocolName, iProtocolDesc)) == KErrNone) {
				if((aResult = iResolver.Open(iSocketServ, iProtocolDesc.iAddrFamily, iProtocolDesc.iProtocol)) == KErrNone) {
					TInquirySockAddr aInquiry;
					aInquiry.SetIAC(KGIAC);
					//aInquiry.SetMajorServiceClass(EMajorServicePositioning);
					aInquiry.SetAction(KHostResName | KHostResInquiry | KHostResIgnoreCache);
					iResolver.GetByAddress(aInquiry, iNameEntry, iStatus);

					iEngineStatus = EGpsResolving;
					SetActive();
				}
			}
		}
	}

	if(aResult != KErrNone) {
		iEngineStatus = EGpsDisconnected;
		iSocketServ.Close();
		iObserver->GpsError(EGpsConnectionFailed);
	}
#else
	TBool aDeviceFound = false;

	if((aResult = iPositionServ.Connect()) == KErrNone) {
		iEngineStatus = EGpsConnecting;
		TUint aNumOfModules;

		if((aResult = iPositionServ.GetNumModules(aNumOfModules)) == KErrNone) {
			TPositionModuleInfo aModuleInfo;
			TUid aModuleId;
			
			for(TUint i = 0; i < aNumOfModules && aResult == KErrNone && !aDeviceFound; i++) {
				if((aResult = iPositionServ.GetModuleInfoByIndex(i, aModuleInfo)) == KErrNone) {
					aModuleId = aModuleInfo.ModuleId();
					
					if(aModuleInfo.IsAvailable() && aModuleInfo.TechnologyType() != TPositionModuleInfo::ETechnologyNetwork) {
						aDeviceFound = true;
					}
				}
			}

			if(aResult == KErrNone && aDeviceFound) {
				if((aResult = iPositioner.Open(iPositionServ, aModuleId)) == KErrNone) {
					iEngineStatus = EGpsConnected;

					if((aResult = iPositioner.SetRequestor(CRequestor::ERequestorService, CRequestor::EFormatApplication, _L("Buddycloud"))) == KErrNone) {
						iEngineStatus = EGpsReading;
						
						TPositionUpdateOptions aOptions;
						aOptions.SetAcceptPartialUpdates(true);				
						iPositioner.SetUpdateOptions(aOptions);	
						
						iPositioner.NotifyPositionUpdate(iPositionInfo, iStatus);
						SetActive();
					}

					if(aResult != KErrNone) {
						iPositioner.Close();
					}
				}
			}
		}
	}

	if(aResult != KErrNone || !aDeviceFound) {
		iEngineStatus = EGpsDisconnected;
		iPositionServ.Close();
		iObserver->GpsError(EGpsConnectionFailed);
	}
#endif
}