19 #include <e32base.h> |
19 #include <e32base.h> |
20 #include <lbspositioninfo.h> |
20 #include <lbspositioninfo.h> |
21 #include <lbs/epos_cpositioner.h> |
21 #include <lbs/epos_cpositioner.h> |
22 #include <lbs/epos_cposmodules.h> |
22 #include <lbs/epos_cposmodules.h> |
23 #include <lbs/epos_mposmodulesobserver.h> |
23 #include <lbs/epos_mposmodulesobserver.h> |
|
24 #include <centralrepository.h> |
24 #include "lbsdevloggermacros.h" |
25 #include "lbsdevloggermacros.h" |
25 #include "EPos_ServerPanic.h" |
26 #include "EPos_ServerPanic.h" |
26 #include "EPos_Global.h" |
27 #include "EPos_Global.h" |
27 #include "EPos_CPosCallbackTimer.h" |
28 #include "EPos_CPosCallbackTimer.h" |
28 #include "EPos_CPositionRequest.h" |
29 #include "EPos_CPositionRequest.h" |
29 #include "epos_cposmodulessettings.h" |
30 #include "epos_cposmodulessettings.h" |
30 |
31 |
|
32 |
31 //TODO Verify |
33 //TODO Verify |
32 #include "EPos_CPosLocMonitorReqHandlerHub.h" |
34 #include "EPos_CPosLocMonitorReqHandlerHub.h" |
33 #include "OstTraceDefinitions.h" |
35 #include "OstTraceDefinitions.h" |
34 #ifdef OST_TRACE_COMPILER_IN_USE |
36 #ifdef OST_TRACE_COMPILER_IN_USE |
35 #include "EPos_CPositionRequestTraces.h" |
37 #include "EPos_CPositionRequestTraces.h" |
36 #endif |
38 #endif |
|
39 #include "lbsrootcenrepdefs.h" |
|
40 #include "lbspositioningstatusprops.h" |
|
41 |
37 |
42 |
38 |
43 |
39 |
44 |
40 // CONSTANTS |
45 // CONSTANTS |
41 #ifdef _DEBUG |
46 #ifdef _DEBUG |
42 _LIT(KTraceFileName, "EPos_CPositionRequest.cpp"); |
47 _LIT(KTraceFileName, "EPos_CPositionRequest.cpp"); |
43 #endif |
48 #endif |
44 |
49 |
45 const TInt KParamPositionInfo = 0; |
50 const TInt KParamPositionInfo = 0; |
|
51 const TTimeIntervalMicroSeconds KIndFlickerTresholdTracking = 30000000; |
46 |
52 |
47 // ================= LOCAL FUNCTIONS ======================== |
53 // ================= LOCAL FUNCTIONS ======================== |
48 |
54 |
49 void CancelTimerCleanup(TAny* aTimer) |
55 void CancelTimerCleanup(TAny* aTimer) |
50 { |
56 { |
76 CActive(EPriorityStandard), |
82 CActive(EPriorityStandard), |
77 iRequestPhase(EPosReqInactive), |
83 iRequestPhase(EPosReqInactive), |
78 iPositionerParams(aPositionerParams), |
84 iPositionerParams(aPositionerParams), |
79 iHasProxyPositioner(aIsProxy), |
85 iHasProxyPositioner(aIsProxy), |
80 iLocMonitorReqHandler(aLocMonitorReqHandlerHub), |
86 iLocMonitorReqHandler(aLocMonitorReqHandlerHub), |
81 iModuleSettings(aModuleSettings) |
87 iModuleSettings(aModuleSettings), |
|
88 iPositioningActive( EFalse ) |
82 { |
89 { |
83 CActiveScheduler::Add(this); |
90 CActiveScheduler::Add(this); |
84 } |
91 } |
85 |
92 |
86 // EPOC default constructor can leave. |
93 // EPOC default constructor can leave. |
99 if (!iModuleInfo.IsAvailable()) |
106 if (!iModuleInfo.IsAvailable()) |
100 { |
107 { |
101 User::Leave(KErrNotFound); |
108 User::Leave(KErrNotFound); |
102 } |
109 } |
103 |
110 |
|
111 // Get the CategoryUid from the cenrep file owned by LbsRoot. |
|
112 CRepository* rep = CRepository::NewLC(KLbsCenRepUid); |
|
113 TInt posStatusCategory; |
|
114 TInt err = rep->Get(KMoPositioningStatusAPIKey, posStatusCategory); |
|
115 User::LeaveIfError(err); |
|
116 CleanupStack::PopAndDestroy(rep); |
|
117 iPosStatusCategory = TUid::Uid(posStatusCategory); |
|
118 |
104 LoadPositionerL(); |
119 LoadPositionerL(); |
105 } |
120 } |
106 |
121 |
107 /** |
122 /** |
108 * Two-phased constructor. |
123 * Two-phased constructor. |
148 } |
163 } |
149 delete iTrackingTimer; |
164 delete iTrackingTimer; |
150 delete iPositionBuffer; |
165 delete iPositionBuffer; |
151 delete iTimeoutTimer; |
166 delete iTimeoutTimer; |
152 delete iPositioner; |
167 delete iPositioner; |
|
168 |
|
169 // Deactivate the positioning status when the object dies. |
|
170 DeActivatePositioningStatusIfNeeded(); |
153 } |
171 } |
154 |
172 |
155 /** |
173 /** |
156 * Starts a position request cycle. Should only be called when PSY is |
174 * Starts a position request cycle. Should only be called when PSY is |
157 * enabled. |
175 * enabled. |
159 */ |
177 */ |
160 void CPositionRequest::MakeRequestL(const RMessage2& aMessage) |
178 void CPositionRequest::MakeRequestL(const RMessage2& aMessage) |
161 { |
179 { |
162 if (!iModuleInfo.IsAvailable()) |
180 if (!iModuleInfo.IsAvailable()) |
163 { |
181 { |
|
182 // Deactivate positioning status if there are PSY's not found. |
|
183 DeActivatePositioningStatusIfNeeded(); |
164 User::Leave(KErrNotFound); |
184 User::Leave(KErrNotFound); |
165 } |
185 } |
166 |
186 |
167 __ASSERT_DEBUG(iPositioner, DebugPanic(EPosServerPanicPositionerNotInitialized)); |
187 __ASSERT_DEBUG(iPositioner, DebugPanic(EPosServerPanicPositionerNotInitialized)); |
168 |
188 |
|
189 |
|
190 |
169 iMessage = aMessage; // Store parameter here in case of leave. |
191 iMessage = aMessage; // Store parameter here in case of leave. |
170 |
192 |
171 // Clear previous position data |
193 // Clear previous position data |
172 delete iPositionBuffer; |
194 delete iPositionBuffer; |
173 iPositionBuffer = NULL; |
195 iPositionBuffer = NULL; |
186 !(classType & EPositionInfoClass)) |
208 !(classType & EPositionInfoClass)) |
187 { |
209 { |
188 User::Leave(KErrArgument); |
210 User::Leave(KErrArgument); |
189 } |
211 } |
190 |
212 |
|
213 |
|
214 |
191 // Set ModuleId to KNullId to be able to verify that Id is set by PSY. |
215 // Set ModuleId to KNullId to be able to verify that Id is set by PSY. |
192 infoBase.SetModuleId(KNullUid); |
216 infoBase.SetModuleId(KNullUid); |
193 |
217 |
194 CleanupStack::PushL(TCleanupItem(CancelTimerCleanup, iTimeoutTimer)); |
218 CleanupStack::PushL(TCleanupItem(CancelTimerCleanup, iTimeoutTimer)); |
|
219 |
|
220 ActivatePositioningStatusIfNeeded(); |
195 |
221 |
196 // Start timer if necessary |
222 // Start timer if necessary |
197 if (iTimeOut.Int64() > 0) |
223 if (iTimeOut.Int64() > 0) |
198 { |
224 { |
199 LBS_RDEBUG_INFO("CPositionRequest::MakeRequestL() Start Timeout Timer"); |
225 LBS_RDEBUG_INFO("CPositionRequest::MakeRequestL() Start Timeout Timer"); |
322 { |
348 { |
323 if (aEvent.iModuleId != iModuleInfo.ModuleId()) |
349 if (aEvent.iModuleId != iModuleInfo.ModuleId()) |
324 { |
350 { |
325 return; |
351 return; |
326 } |
352 } |
327 |
353 |
328 switch (aEvent.iType) |
354 switch (aEvent.iType) |
329 { |
355 { |
330 case EPosModulesEventAvailabilityChanged: |
356 case EPosModulesEventAvailabilityChanged: |
331 case EPosModulesEventModuleInstalled: |
357 case EPosModulesEventModuleInstalled: |
332 iModuleSettings.PosModules().GetModuleInfoL( |
358 iModuleSettings.PosModules().GetModuleInfoL( |
465 |
493 |
466 default: |
494 default: |
467 DEBUG_TRACE("CPositionRequest::DoCancel() panicing", __LINE__) |
495 DEBUG_TRACE("CPositionRequest::DoCancel() panicing", __LINE__) |
468 DebugPanic(EPosServerPanicRequestInconsistency); |
496 DebugPanic(EPosServerPanicRequestInconsistency); |
469 } |
497 } |
|
498 |
|
499 // Deactive positioning status after cancellation. |
|
500 DeActivatePositioningStatusIfNeeded(); |
470 |
501 |
471 TInt err; |
502 TInt err; |
472 if (iRequestTimedOut) |
503 if (iRequestTimedOut) |
473 { |
504 { |
474 iRequestTimedOut = EFalse; |
505 iRequestTimedOut = EFalse; |
523 } |
555 } |
524 } |
556 } |
525 else |
557 else |
526 { |
558 { |
527 CompleteClient(aReason); |
559 CompleteClient(aReason); |
|
560 } |
|
561 |
|
562 // If the request is not tracking mode, deactivate the indicator |
|
563 // Tracking mode check and the last check for the error scenarios other than |
|
564 // KErrNone and KPositionPartialUpdate. |
|
565 if( ( ( iTrackingState == EPosFirstTrackingRequest || iTrackingState == EPosTracking ) && |
|
566 iTrackingUpdateInterval > KIndFlickerTresholdTracking ) || |
|
567 iTrackingUpdateInterval == TTimeIntervalMicroSeconds ( 0 ) || |
|
568 !( aReason == KErrNone || aReason == KPositionPartialUpdate ) ) |
|
569 { |
|
570 DeActivatePositioningStatusIfNeeded(); |
528 } |
571 } |
529 } |
572 } |
530 |
573 |
531 void CPositionRequest::StartPositionDataRequestPhase() |
574 void CPositionRequest::StartPositionDataRequestPhase() |
532 { |
575 { |
731 { |
774 { |
732 LBS_RDEBUG_INFO("CPositionRequest::ExtendUpdateTimeOut()"); |
775 LBS_RDEBUG_INFO("CPositionRequest::ExtendUpdateTimeOut()"); |
733 iTimeoutTimer->ExtendTimeout(aAdditionalTime); |
776 iTimeoutTimer->ExtendTimeout(aAdditionalTime); |
734 } |
777 } |
735 |
778 |
|
779 void CPositionRequest::ActivatePositioningStatusIfNeeded() |
|
780 { |
|
781 // Check for the positioning status, If it has been activated from this object, |
|
782 // there is no need to increment the count again. |
|
783 if( !iPositioningActive ) |
|
784 { |
|
785 TInt count, err; |
|
786 err = RProperty::Get(iPosStatusCategory, KLbsMoPositioningStatusKey, count); |
|
787 |
|
788 if(err == KErrNone) |
|
789 { |
|
790 err = RProperty::Set(iPosStatusCategory, KLbsMoPositioningStatusKey, count+1); |
|
791 if(err == KErrNone) |
|
792 { |
|
793 iPositioningActive = ETrue; |
|
794 } |
|
795 else |
|
796 { |
|
797 DEBUG_TRACE("CPositionRequest::ActivatePositioningStatusIfNeeded() - Error in setting Positioning Status", __LINE__) |
|
798 } |
|
799 } |
|
800 else |
|
801 { |
|
802 DEBUG_TRACE("CPositionRequest::ActivatePositioningStatusIfNeeded() - Error in getting Positioning Status", __LINE__) |
|
803 |
|
804 } |
|
805 } |
|
806 } |
|
807 |
|
808 void CPositionRequest::DeActivatePositioningStatusIfNeeded() |
|
809 { |
|
810 // If the positioning status is activated by this object, deactivate it |
|
811 if( iPositioningActive ) |
|
812 { |
|
813 TInt count, err; |
|
814 err = RProperty::Get(iPosStatusCategory, KLbsMoPositioningStatusKey, count); |
|
815 |
|
816 if(err == KErrNone) |
|
817 { |
|
818 __ASSERT_DEBUG(count > 0, DebugPanic(EPosServerPanicIndDeactivationFailed)); |
|
819 |
|
820 err = RProperty::Set(iPosStatusCategory, KLbsMoPositioningStatusKey, count-1); |
|
821 if(err == KErrNone) |
|
822 { |
|
823 iPositioningActive = EFalse; |
|
824 } |
|
825 else |
|
826 { |
|
827 DEBUG_TRACE("CPositionRequest::DeActivatePositioningStatusIfNeeded() - error in setting Positioning Status", __LINE__) |
|
828 } |
|
829 } |
|
830 else |
|
831 { |
|
832 DEBUG_TRACE("CPositionRequest::DeActivatePositioningStatusIfNeeded() - error in getting Positioning Status", __LINE__) |
|
833 } |
|
834 } |
|
835 } |
736 // End of File |
836 // End of File |