/** * From CSession2 * * This function services all requests from clients. */ void CPosSession::ServiceL(const RMessage2& aMessage) { switch (aMessage.Function()) { case ELbsPositionerOpenModuleId: OpenFromModuleIdL(aMessage); break; case ELbsPositionerOpen: OpenDefaultPositionerL(aMessage); break; case ELbsPositionerOpenCriteria: OpenPositionerFromCriteriaL(aMessage); break; case ELbsPositionerClose: ClosePositioner(aMessage); break; case ELbsGetDefaultModuleId: GetDefaultModuleIdL(aMessage); break; case ELbsGetNumModules: GetNumModulesL(aMessage); break; case ELbsGetModuleInfoByIndex: GetModuleInfoByIndexL(aMessage); break; case ELbsGetModuleInfoById: GetModuleInfoByIdL(aMessage); break; case ELbsGetModuleStatus: GetModuleStatusL(aMessage); break; case ELbsNotifyModuleStatusEvent: NotifyModuleStatusEventL(aMessage); break; case ELbsEmptyLastKnownPositionStore: EmptyLastKnownPositionStore(aMessage); break; case ELbsServerCancelAsyncRequest: LBS_RDEBUG("Client", "LBS", "CancelAsyncRequest"); HandleCancelAsyncRequestL(aMessage); break; default: ForwardToSubSessionL(aMessage); break; } }
// --------------------------------------------------------- // CT_LbsClientPosTp178::TestCancel // // (other items were commented in a header). // --------------------------------------------------------- // void CT_LbsClientPosTp178::TestCancelL() { _LIT(KSTART, "TestCancel()"); _LIT(KEND, "TestCancel() passed"); // Setup verification stuff INFO_PRINTF1(KSTART); _LIT(KService, "SAAA"); ConnectL(); SetupPsyL(iUidTestPsy3); OpenPositionerByName(iUidTestPsy3); PerformRequestL(KService, CRequestor::ERequestorService, CRequestor::EFormatApplication); StartSchedulerForAWhile178L(2000000); iPositioner.CancelRequest(EPositionerNotifyPositionUpdate); CheckRequestResultL(KErrCancel); ClosePositioner(); Disconnect(); INFO_PRINTF1(KEND); }
// --------------------------------------------------------- // CT_LbsClientPosTp2::StartL // // (other items were commented in a header). // --------------------------------------------------------- // void CT_LbsClientPosTp2::StartL() { SetupPsyL(iUidMultiPsy); //synchronous request ConnectL(); User::LeaveIfError(OpenPositionerByName(iUidMultiPsy)); TPositionInfo info = TPositionInfo(); RequestL(info); CheckPositionInfoL(info); TPositionCourseInfo courseInfo; RequestL(courseInfo); CheckPositionCourseInfoL(courseInfo); TPositionSatelliteInfo satelliteInfo; RequestL(satelliteInfo); CheckPositionSatelliteInfoL(satelliteInfo); HPositionGenericInfo* genericInfo = HPositionGenericInfo::NewLC(); RequestL(*genericInfo); CheckGenericInfoL(*genericInfo); CleanupStack::PopAndDestroy(); //genericInfo ClosePositioner(); Disconnect(); }
// --------------------------------------------------------- // 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(); }
// --------------------------------------------------------- // CT_LbsClientPosTp1::CloseTest // // (other items were commented in a header). // --------------------------------------------------------- // void CT_LbsClientPosTp1::CloseTest() { ClosePositioner(); Disconnect(); }
// Destructor CPosPSYRequester::~CPosPSYRequester() { ClosePositioner(); }
// --------------------------------------------------------- // CT_LbsClientPosTp178::TestTimeout // // (other items were commented in a header). // --------------------------------------------------------- // void CT_LbsClientPosTp178::TestTimeoutL() { _LIT(KSTART, "TestTimeout()"); _LIT(KEND, "TestTimeout() passed"); _LIT(KTIME, "Request took %d us"); // Setup verification stuff INFO_PRINTF1(KSTART); //TPrivDlgDiagnostics tmpdiag; TTime requestStartTime; TTime requestStopTime; TTimeIntervalMicroSeconds durationMicro; TBuf<100> buf; _LIT(KService, "SAAA"); TPositionUpdateOptions updateOptions; TTimeIntervalMicroSeconds longInterval(7000000); ConnectL(); SetupPsyL(iUidTestPsy3); OpenPositionerByName(iUidTestPsy3); updateOptions.SetUpdateTimeOut(longInterval); // Access protected member (iPositioner) here iPositioner.SetUpdateOptions(updateOptions); _LIT(KONE, "Perform first request, should NOT time out"); INFO_PRINTF1(KONE); requestStartTime.UniversalTime(); //Make one request to verify psy PerformRequestL(KService, CRequestor::ERequestorService, CRequestor::EFormatApplication); CheckRequestResultL(KErrNone); requestStopTime.UniversalTime(); durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); TInt duration = durationMicro.Int64(); buf.Format(KTIME, duration); INFO_PRINTF1(buf); ClosePositioner(); OpenPositionerByName(iUidTestPsy3); // ECancelButton means that the Automatised class should wait for a cancel call // before returning result updateOptions.SetUpdateTimeOut(longInterval); // Access protected (iPositioner) member here iPositioner.SetUpdateOptions(updateOptions); _LIT(KTWO, "Perform second request, should not time out"); INFO_PRINTF1(KTWO); //Make one request to verify psy TPositionInfo info = TPositionInfo(); requestStartTime.UniversalTime(); TInt err = PerformSyncRequest(KService, &info); requestStopTime.UniversalTime(); if (err != KErrNone) { _LIT(KError, "Wrong result from iStatus, should be KErrNone, was %d"); TBuf<100> buf; buf.Format(KError, err); LogErrorAndLeaveL(buf); } durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); duration = durationMicro.Int64(); buf.Format(KTIME, duration); INFO_PRINTF1(buf); ClosePositioner(); Disconnect(); INFO_PRINTF1(KEND); }
// --------------------------------------------------------- // CT_LbsClientPosTp261::StartL // // (other items were commented in a header). // --------------------------------------------------------- // void CT_LbsClientPosTp261::StartL() { _LIT(KService1, "Service1"); _LIT(KService2, "Service2"); _LIT(KService3, "Service3"); _LIT(KContact1, "Contact1"); _LIT(KContact2, "Contact2"); _LIT(KContact3, "Contact3"); CRequestor* serviceId1 = CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication, KService1); CRequestor* serviceId2 = CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication, KService2); CRequestor* serviceId3 = CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication, KService3); CRequestor* contactId1 = CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatTelephone, KContact1); CRequestor* contactId2 = CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatUrl, KContact2); CRequestor* contactId3 = CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatMail, KContact3); RRequestorStack stack = RRequestorStack(); CleanupStack::PushL(TCleanupItem(CleanOp ,&stack)); CleanupStack::PushL(serviceId1); CleanupStack::PushL(serviceId2); CleanupStack::PushL(serviceId3); CleanupStack::PushL(contactId1); CleanupStack::PushL(contactId2); CleanupStack::PushL(contactId3); ConnectL(); OpenPositioner(); stack.Append(serviceId1); stack.Append(contactId1); stack.Append(contactId2); stack.Append(serviceId2); stack.Append(contactId3); stack.Append(serviceId3); CleanupStack::Pop(contactId3); CleanupStack::Pop(contactId2); CleanupStack::Pop(contactId1); CleanupStack::Pop(serviceId3); CleanupStack::Pop(serviceId2); CleanupStack::Pop(serviceId1); TInt err = iPositioner.SetRequestor(stack); if (err != KErrNone) { _LIT(KErrorAndLeave, "Problems setting requestorstack"); LogErrorAndLeaveL(KErrorAndLeave); } const TInt KPosBufFlatExpandSize = 100; //ExternalizeL CBufFlat* bufFlat = CBufFlat::NewL(KPosBufFlatExpandSize); CleanupStack::PushL(bufFlat); RBufWriteStream stream(*bufFlat); CleanupClosePushL(stream); stack.ExternalizeL(stream); TPtr8 dataPtr((TUint8*)NULL, 0); dataPtr.Set(bufFlat->Ptr(0)); CleanupStack::PopAndDestroy(&stream); HBufC8* tempBuf = HBufC8::NewLC(bufFlat->Size()); TPtr8 ptr = tempBuf->Des(); ptr = dataPtr; //Internalize bufFlat->InsertL(0, ptr); RBufReadStream rstream(*bufFlat); CleanupClosePushL(rstream); RRequestorStack stack2 = RRequestorStack(); CleanupStack::PushL(TCleanupItem(CleanOp ,&stack2)); stack2.InternalizeL(rstream); // Verify the requestor stack VerifyRequestorStackL(stack2); _LIT(KResult, "The RequestorStack is correct after Externalize/Internalize"); INFO_PRINTF1(KResult); CleanupStack::PopAndDestroy(1); // CleanupOp stack2 CleanupStack::PopAndDestroy(&rstream); CleanupStack::PopAndDestroy(tempBuf); CleanupStack::PopAndDestroy(bufFlat); CleanupStack::PopAndDestroy(1); // CleanupOp stack1 ClosePositioner(); Disconnect(); }