Пример #1
0
/** Create the module information depending on module id(i'e either agps_manager or network location manager) 
    Fills a module info class/structure with values depending on the module id. 

    @param  aModuleId       module id within the ini file
    @param  aModInfo		The modified module info structure.
*/
EXPORT_C void T_LbsUtils::Create_ModuleInfoL(TPositionModuleId aModuleId, TPositionModuleInfo& aModInfo)

	{  
	   TPositionQuality posQuality;
	
	// Use these values if the module is a-gps manager 
		if (aModuleId == (TUid::Uid(APGS_MODINFO_MODULE_ID)))
		 {
		 aModInfo.SetModuleId(TUid::Uid(APGS_MODINFO_MODULE_ID));
	     aModInfo.SetIsAvailable(AGPS_MODINFO_IS_AVAILABLE);
	     aModInfo.SetModuleName(AGPS_MODINFO_MOD_NAME);
	     aModInfo.SetTechnologyType(AGPS_MODINFO_TECHNOLOGY_TYPE);
	     aModInfo.SetDeviceLocation(AGPS_MODINFO_DEVICE_LOCATION);
	     aModInfo.SetCapabilities(AGPS_MODINFO_CAPABILITIES);
	      
	     // Classes Supported - this is a binary bitmap, but support for each class 
    	// has to be set individually.
		
	 	TInt supportedClasses = AGPS_MODINFO_CLASSES_SUPPORTED_POSITION_FAMILY; 
    	TPositionClassFamily currentClass = EPositionInfoFamily;
    	while(currentClass <= EPositionUpdateOptionsFamily)
        	{
        	aModInfo.SetClassesSupported(currentClass, supportedClasses & 1); 
        	supportedClasses >>= 1;
        	currentClass = static_cast<TPositionClassFamily>(static_cast<TInt>(currentClass) + 1);   		
        	}
	     	     
	     aModInfo.SetVersion(AGPS_MODINFO_VERSION);
    	 posQuality.SetTimeToFirstFix(AGPS_MODINFO_TIME_TO_FIRST_FIX);
	     posQuality.SetTimeToNextFix(AGPS_MODINFO_TIME_TO_NEXT_FIX);
    	 posQuality.SetHorizontalAccuracy(AGPS_MODINFO_HORIZONTAL_ACCURACY);
	     posQuality.SetVerticalAccuracy(AGPS_MODINFO_VERTICAL_ACCURACY);
    	 posQuality.SetCostIndicator(AGPS_MODINFO_COST_INDICATOR);
	     posQuality.SetPowerConsumption(AGPS_MODINFO_POWER_CONSUMPTION);
       	 aModInfo.SetPositionQuality(posQuality);
      	 }
/* Read in ModuleInfo from an .ini file
*/
void CTe_LbsIniFileReader::ReadModuleInfoL(TPositionModuleInfo& aModuleInfo)
{
    TInt    intValue;
    TBool    success;

    // Technology-type - this is a binary bitmap.
    FindVar(KTechnologyTypeStr, intValue);
    TPositionModuleInfo::TTechnologyType technologyType = DecimalToBitmask(intValue);
    aModuleInfo.SetTechnologyType(technologyType);

    // Classes Supported - this is a binary bitmap, but support for each class
    // has to be set individually.
    FindVar(KClassesSupportedStr, intValue);
    TInt supportedClasses = DecimalToBitmask(intValue);

    TPositionClassFamily currentClass = EPositionInfoFamily;
    while(currentClass <= EPositionUpdateOptionsFamily)
    {
        aModuleInfo.SetClassesSupported(currentClass, supportedClasses & 1);
        supportedClasses >>= 1;
        currentClass = static_cast<TPositionClassFamily>(static_cast<TInt>(currentClass) + 1);
    }

    // Capabilities - this is a binary bitmap.
    FindVar(KCapabilitiesStr, intValue);
    TPositionModuleInfo::TCapabilities capabilities = DecimalToBitmask(intValue);
    aModuleInfo.SetCapabilities(capabilities);

    // Module Name
    TUint16* buffer = new (ELeave) TUint16[KPositionModuleMaxNameLength];
    CleanupStack::PushL(buffer);

    TPtrC16 modulePtr(reinterpret_cast<const TUint16*>(buffer),KPositionModuleMaxNameLength);
    success = FindVar(KModuleNameStr, modulePtr);

    TBuf<KPositionModuleMaxNameLength> moduleName;
    if(success)
    {
        moduleName.Copy(modulePtr);
    }
    else
    {
        moduleName.Copy(KNullDesC);
    }
    // Get rid of any delimiting " characters.
    TInt length = moduleName.Length();
    if(length > 0)
    {
        TInt lastPos = length - 1;
        TChar quote('\"');
        if(moduleName[lastPos] == quote)
        {
            moduleName.Delete(lastPos, 1);
        }
        if(modulePtr[0] == quote)
        {
            moduleName.Delete(0, 1);
        }
    }
    aModuleInfo.SetModuleName(moduleName);
    CleanupStack::PopAndDestroy(buffer);

    // Module Id
    TUid moduleUid = TUid::Uid(0);
    FindVar(KModuleIdStr,intValue);
    if(intValue>0)
    {
        moduleUid = (TUid::Uid(intValue));
    }
    aModuleInfo.SetModuleId(moduleUid);

    // Module Version
    TVersion version(0,0,0);
    FindVar(KVersionStr,version);
    aModuleInfo.SetVersion(version);

    // Device Location
    TPositionModuleInfo::TDeviceLocation deviceLocation;
    FindVar(KDeviceLocationStr,intValue);
    switch(intValue)
    {
    case 1:
        deviceLocation = TPositionModuleInfo::EDeviceInternal;
        break;
    case 2:
        deviceLocation = TPositionModuleInfo::EDeviceExternal;
        break;
    default:
        deviceLocation = TPositionModuleInfo::EDeviceUnknown;
        break;
    }
    aModuleInfo.SetDeviceLocation(deviceLocation);

    // IsAvailable - to be read from .ini file but for now ...
    aModuleInfo.SetIsAvailable(ETrue);

}
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();
	}