133 void CLocationManagerServer::ConstructL() |
132 void CLocationManagerServer::ConstructL() |
134 { |
133 { |
135 LOG ("CLocationManagerServer::ConstructL() begin"); |
134 LOG ("CLocationManagerServer::ConstructL() begin"); |
136 |
135 |
137 StartL( KLocServerName ); |
136 StartL( KLocServerName ); |
138 |
137 |
|
138 // initialize etel |
|
139 InitialisePhoneL(); |
|
140 |
|
141 #ifdef LOC_REVERSEGEOCODE |
|
142 iEcomSession = &(REComSession::OpenL()); |
|
143 #endif //LOC_REVERSEGEOCODE |
|
144 |
|
145 iASW = new (ELeave) CActiveSchedulerWait(); |
|
146 |
|
147 iNwRegistrationStatusHandler = CNwRegistrationStatusHandler::NewL(iPhone); |
|
148 |
|
149 iLocationRecord = CLocationRecord::NewL(*this, iPhone); |
|
150 iTrackLog = CTrackLog::NewL(); |
|
151 iMdeSession = CMdESession::NewL( *this ); |
|
152 |
|
153 iLocationRecord->SetObserver( this ); |
|
154 |
|
155 iLocationRecord->SetAddObserver( iTrackLog ); |
|
156 |
|
157 iTrackLog->AddGpxObserver( this ); |
|
158 |
|
159 CRepository* repository = CRepository::NewLC( KRepositoryUid ); |
|
160 TInt err = repository->Get( KLocationTrailShutdownTimer, iLocManStopDelay ); |
|
161 |
|
162 LOG1("iLocManStopDelay:%d", iLocManStopDelay); |
|
163 |
|
164 if ( err != KErrNone ) |
|
165 { |
|
166 LOG1("iLocManStopDelay err:%d", err); |
|
167 iLocManStopDelay = KLocationTrailShutdownDelay; |
|
168 } |
|
169 |
|
170 err = repository->Get( KLocationTrailRemapShutdownTimer, iLocManStopRemapDelay ); |
|
171 CleanupStack::PopAndDestroy( repository ); |
|
172 |
|
173 LOG1("iLocManStopRemapDelay:%d", iLocManStopRemapDelay); |
|
174 |
|
175 if ( err != KErrNone ) |
|
176 { |
|
177 LOG1("iLocManStopRemapDelay err:%d", err); |
|
178 iLocManStopRemapDelay = KLocationTrailRemapShutdownDelay; |
|
179 } |
|
180 |
|
181 if( !iSessionReady ) |
|
182 { |
|
183 iASW->Start(); |
|
184 } |
|
185 |
|
186 delete iASW; |
|
187 iASW = NULL; |
|
188 |
|
189 if( iSessionReady ) |
|
190 { |
|
191 LOG("Session is ready to give service"); |
|
192 //Create the instance of the geotagging timer object |
|
193 // Create timer, if n/w or reverse geo code based feature flag is enabled |
|
194 #if defined(LOC_REVERSEGEOCODE) || defined(LOC_GEOTAGGING_CELLID) |
|
195 iGeoTagTimer = CLocationGeoTagTimerAO::NewL(*iMdeSession, *this); |
|
196 //Schedule a task for geotagging every day at 3.00 AM |
|
197 iGeoTagTimer->StartTimer(); |
|
198 #endif |
|
199 } |
|
200 else |
|
201 { |
|
202 LOG("Unable to open MDE session. Closing.."); |
|
203 User::Leave( KErrCouldNotConnect ); |
|
204 } |
|
205 |
139 RProcess process; |
206 RProcess process; |
140 process.SetPriority( EPriorityBackground ); |
207 process.SetPriority( EPriorityBackground ); |
141 process.Close(); |
208 process.Close(); |
142 |
209 |
143 // initialize etel |
210 LOG ("CLocationManagerServer::ConstructL() end"); |
144 InitialisePhoneL(); |
211 } |
145 |
212 |
|
213 // -------------------------------------------------------------------------- |
|
214 // CLocationManagerServer::~CLocationManagerServer() |
|
215 // C++ destructor. |
|
216 // -------------------------------------------------------------------------- |
|
217 // |
|
218 CLocationManagerServer::~CLocationManagerServer() |
|
219 { |
|
220 LOG("CLocationManagerServer::~CLocationManagerServer ,begin"); |
|
221 #if defined(LOC_REVERSEGEOCODE) || defined(LOC_GEOTAGGING_CELLID) |
|
222 delete iGeoTagTimer; |
|
223 iGeoTagTimer = NULL; |
|
224 #endif |
146 #ifdef LOC_REVERSEGEOCODE |
225 #ifdef LOC_REVERSEGEOCODE |
147 iEcomSession = &(REComSession::OpenL()); |
226 delete iGeoTaggingPendingReqObj; |
|
227 iGeoTaggingPendingReqObj = NULL; |
148 #endif //LOC_REVERSEGEOCODE |
228 #endif //LOC_REVERSEGEOCODE |
149 |
229 |
150 iASW = new (ELeave) CActiveSchedulerWait(); |
230 delete iLocationRecord; |
151 |
231 iLocationRecord = NULL; |
152 iNwRegistrationStatusHandler = CNwRegistrationStatusHandler::NewL(iPhone); |
232 delete iTrackLog; |
153 |
233 iTrackLog = NULL; |
154 iMdeSession = CMdESession::NewL( *this ); |
234 delete iTimer; |
155 iLocationRecord = CLocationRecord::NewL(*this, iPhone); |
235 iTimer = NULL; |
156 iTrackLog = CTrackLog::NewL(); |
236 delete iRelationQuery; |
157 |
237 iRelationQuery = NULL; |
158 iASW->Start(); |
|
159 delete iASW; |
238 delete iASW; |
160 iASW = NULL; |
239 iASW = NULL; |
161 if(iSessionReady) |
|
162 { |
|
163 LOG("Session is ready to give service"); |
|
164 |
|
165 iLocationRecord->SetObserver( this ); |
|
166 |
|
167 iLocationRecord->SetAddObserver( iTrackLog ); |
|
168 |
|
169 iTrackLog->AddGpxObserver( this ); |
|
170 |
|
171 CRepository* repository = CRepository::NewLC( KRepositoryUid ); |
|
172 TInt err = repository->Get( KLocationTrailShutdownTimer, iLocManStopDelay ); |
|
173 |
|
174 LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay:%d", iLocManStopDelay); |
|
175 |
|
176 if ( err != KErrNone ) |
|
177 { |
|
178 LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay err:%d", err); |
|
179 iLocManStopDelay = KLocationTrailShutdownDelay; |
|
180 } |
|
181 |
|
182 err = repository->Get( KLocationTrailRemapShutdownTimer, iLocManStopRemapDelay ); |
|
183 CleanupStack::PopAndDestroy( repository ); |
|
184 |
|
185 LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay:%d", iLocManStopRemapDelay); |
|
186 |
|
187 if ( err != KErrNone ) |
|
188 { |
|
189 LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay err:%d", err); |
|
190 iLocManStopRemapDelay = KLocationTrailRemapShutdownDelay; |
|
191 } |
|
192 |
|
193 #ifdef LOC_REVERSEGEOCODE |
|
194 //Create the instance of the geotagging timer object |
|
195 iGeoTagTimer = CLocationGeoTagTimerAO::NewL(*iMdeSession, *this); |
|
196 //Schedule a task for geotagging every day at 3.00 AM |
|
197 iGeoTagTimer->StartTimer(); |
|
198 #endif //LOC_REVERSEGEOCODE |
|
199 } |
|
200 else |
|
201 { |
|
202 LOG("Unable to open MDE session. Closing.."); |
|
203 User::Leave(KErrCouldNotConnect); |
|
204 } |
|
205 LOG ("CLocationManagerServer::ConstructL() end"); |
|
206 } |
|
207 |
|
208 // -------------------------------------------------------------------------- |
|
209 // CLocationManagerServer::~CLocationManagerServer() |
|
210 // C++ destructor. |
|
211 // -------------------------------------------------------------------------- |
|
212 // |
|
213 CLocationManagerServer::~CLocationManagerServer() |
|
214 { |
|
215 LOG("CLocationManagerServer::~CLocationManagerServer ,begin"); |
|
216 |
|
217 #ifdef LOC_REVERSEGEOCODE |
|
218 delete iGeoTagTimer; |
|
219 delete iGeoTaggingPendingReqObj; |
|
220 #endif //LOC_REVERSEGEOCODE |
|
221 |
|
222 delete iLocationRecord; |
|
223 delete iTrackLog; |
|
224 delete iTimer; |
|
225 delete iASW; |
|
226 delete iMdeSession; |
240 delete iMdeSession; |
|
241 iMdeSession = NULL; |
227 delete iNwRegistrationStatusHandler; |
242 delete iNwRegistrationStatusHandler; |
|
243 iNwRegistrationStatusHandler = NULL; |
228 iTargetObjectIds.Close(); |
244 iTargetObjectIds.Close(); |
229 CancelRequests(iNotifReqs); |
245 CancelRequests(iNotifReqs); |
230 iNotifReqs.Close(); |
246 iNotifReqs.Close(); |
231 CancelRequests(iLocationReqs); |
247 CancelRequests(iLocationReqs); |
232 iLocationReqs.Close(); |
248 iLocationReqs.Close(); |
1655 LOG("Completing the request"); |
1668 LOG("Completing the request"); |
1656 iGeoTaggingMessage.Complete(aError); |
1669 iGeoTaggingMessage.Complete(aError); |
1657 iGeoTaggingMessage = RMessage2 (); |
1670 iGeoTaggingMessage = RMessage2 (); |
1658 } |
1671 } |
1659 #endif //LOC_REVERSEGEOCODE |
1672 #endif //LOC_REVERSEGEOCODE |
|
1673 StopServer(); |
|
1674 LOG("CLocationManagerServer::GeoTaggingCompleted ,end"); |
|
1675 } |
|
1676 |
|
1677 |
|
1678 // -------------------------------------------------------------------------- |
|
1679 // CLocationManagerServer::StopServer |
|
1680 // -------------------------------------------------------------------------- |
|
1681 // |
|
1682 |
|
1683 void CLocationManagerServer::StopServer() |
|
1684 { |
|
1685 LOG("CLocationManagerServer::StopServer ,begin"); |
1660 // once geo tagging completed, check whether, we can terminate the server |
1686 // once geo tagging completed, check whether, we can terminate the server |
|
1687 // dont't stop this process if |
|
1688 // 1. when client are connected. |
|
1689 // 2. 3AM timer is going on. |
|
1690 // 3. Tagging is in progress. |
1661 if ( !iSessionCount |
1691 if ( !iSessionCount |
|
1692 #if defined(LOC_REVERSEGEOCODE) || defined(LOC_GEOTAGGING_CELLID) |
|
1693 && iGeoTagTimer == NULL |
|
1694 #endif |
1662 && iLocationRecord |
1695 && iLocationRecord |
1663 && !iLocationRecord->TaggingInProgress()) |
1696 && !iLocationRecord->TaggingInProgress()) |
1664 { |
1697 { |
1665 // Nothing in progress. shutdown the server |
1698 // Nothing in progress. shutdown the server |
|
1699 LOG("Stop the schedular"); |
1666 CActiveScheduler::Stop(); |
1700 CActiveScheduler::Stop(); |
1667 } |
1701 } |
1668 LOG("CLocationManagerServer::GeoTaggingCompleted ,end"); |
1702 LOG("CLocationManagerServer::StopServer ,end"); |
1669 } |
1703 } |
1670 |
|
1671 |
1704 |
1672 // -------------------------------------------------------------------------- |
1705 // -------------------------------------------------------------------------- |
1673 // CLocationManagerServer::PendingGeoTagReqComplete |
1706 // CLocationManagerServer::PendingGeoTagReqComplete |
1674 // -------------------------------------------------------------------------- |
1707 // -------------------------------------------------------------------------- |
1675 // |
1708 // |