コード例 #1
0
// ---------------------------------------------------------
// 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);
        }
    }
コード例 #2
0
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);
	 }

	}
コード例 #3
0
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
    }
コード例 #4
0
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);
	}
コード例 #5
0
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
}