equal
deleted
inserted
replaced
27 // CONSTANTS |
27 // CONSTANTS |
28 #ifdef _DEBUG |
28 #ifdef _DEBUG |
29 _LIT(KTraceFileName, "EPos_CPosLocMonitorReqHandlerHub.cpp"); |
29 _LIT(KTraceFileName, "EPos_CPosLocMonitorReqHandlerHub.cpp"); |
30 #endif |
30 #endif |
31 |
31 |
|
32 const TInt KLocationServerSID=0x101f97b2; |
|
33 |
32 |
34 |
33 // ============================== MEMBER FUNCTIONS =================================================== |
35 // ============================== MEMBER FUNCTIONS =================================================== |
34 /** |
36 /** |
35 * NewL of the Two-phased constructor. |
37 * NewL of the Two-phased constructor. |
36 * |
38 * |
66 User::LeaveIfError(iLocMonSession.Connect()); |
68 User::LeaveIfError(iLocMonSession.Connect()); |
67 |
69 |
68 // Establish the subsession with the location monitor - As SetPositionInfoL() |
70 // Establish the subsession with the location monitor - As SetPositionInfoL() |
69 // is likely to be called whenever we have an update from the PSYs, the subsession |
71 // is likely to be called whenever we have an update from the PSYs, the subsession |
70 // with the location monitor is created as a member variable instead of a local variable. |
72 // with the location monitor is created as a member variable instead of a local variable. |
71 iLocMonSubSession.OpenL(iLocMonSession); |
73 iLocMonSubSession.OpenL(iLocMonSession); |
|
74 |
|
75 // Attach to the Last Known Location P&S property |
|
76 iLastKnownPosProperty.Attach( |
|
77 KPosLastKnownLocationCategory, |
|
78 KPosLastKnownLocation); |
|
79 |
|
80 // Get the last known position from loc monitor and publish it. |
|
81 TRequestStatus status; |
|
82 TPositionInfo posInfo; |
|
83 iLocMonSubSession.GetLastKnownPosition(posInfo, status); |
|
84 User::WaitForRequest(status); |
|
85 |
|
86 if (status.Int()==KErrNone) |
|
87 { |
|
88 PublishPosition(posInfo); |
|
89 } |
72 } |
90 } |
73 |
91 |
74 |
92 |
75 /** |
93 /** |
76 * Destructor |
94 * Destructor |
104 * @param aPositionInfo The last known position. |
122 * @param aPositionInfo The last known position. |
105 */ |
123 */ |
106 void CPosLocMonitorReqHandlerHub::SetPositionInfo( const TPositionInfo& aPositionInfo ) |
124 void CPosLocMonitorReqHandlerHub::SetPositionInfo( const TPositionInfo& aPositionInfo ) |
107 { |
125 { |
108 DEBUG_TRACE("CPosLocMonitorReqHandlerHub::SetPositionInfoL", __LINE__) |
126 DEBUG_TRACE("CPosLocMonitorReqHandlerHub::SetPositionInfoL", __LINE__) |
109 |
127 |
110 TInt errSetPos = iLocMonSubSession.SetLastKnownPosition(aPositionInfo); |
128 // check the latest position is newer than the last published position |
|
129 TPosition newPos; |
|
130 aPositionInfo.GetPosition(newPos); |
|
131 |
|
132 // publish the position |
|
133 PublishPosition(aPositionInfo); |
|
134 // pass the position to the loc monitor. |
|
135 TInt errSetPos = iLocMonSubSession.SetLastKnownPosition(aPositionInfo); |
111 } |
136 } |
112 |
137 |
113 /** |
138 /** |
114 * Get Last Known Position Request |
139 * Get Last Known Position Request |
115 * >> Called by the subsession to request the last known position. |
140 * >> Called by the subsession to request the last known position. |
314 } |
339 } |
315 |
340 |
316 } |
341 } |
317 |
342 |
318 |
343 |
319 |
344 /** |
|
345 * PublishPosition |
|
346 * >> Publishes the position to the Last Known Position P&S Property |
|
347 * |
|
348 */ |
|
349 void CPosLocMonitorReqHandlerHub::PublishPosition(const TPositionInfo& aPositionInfo) |
|
350 { |
|
351 TPckg<TPositionInfo> positionDes( aPositionInfo ); |
|
352 TInt err = iLastKnownPosProperty.Set(positionDes); |
|
353 if(err == KErrNotFound) |
|
354 { |
|
355 __ASSERT_DEBUG(EFalse, DebugPanic(EPosServerPanicLastKnownPosPnsNotDefined)); |
|
356 // The key is not defined. This should not happen in normal case. |
|
357 // However, if this happens, we define the key again |
|
358 _LIT_SECURITY_POLICY_C1(readPolicy, ECapabilityReadDeviceData); |
|
359 _LIT_SECURITY_POLICY_S0(writePolicy, KLocationServerSID); |
|
360 //Error code ignored |
|
361 iLastKnownPosProperty.Define( |
|
362 KPosLastKnownLocationCategory, |
|
363 KPosLastKnownLocation, |
|
364 RProperty::EText, |
|
365 readPolicy, |
|
366 writePolicy); |
|
367 } |
|
368 } |
|
369 |