changeset 39 | 3efc7a0e8755 |
parent 0 | 667063e416a2 |
child 45 | 6b6920c56e2f |
37:e175e2ba2fb0 | 39:3efc7a0e8755 |
---|---|
73 #include <LbsPositionInfo.h> |
73 #include <LbsPositionInfo.h> |
74 #include <lbs.h> |
74 #include <lbs.h> |
75 //#include <epossimulationpsy.hrh> |
75 //#include <epossimulationpsy.hrh> |
76 #include "firingofstartuptriggerandlisttrigger.h" |
76 #include "firingofstartuptriggerandlisttrigger.h" |
77 #include "t_triggerfireobserver.h" |
77 #include "t_triggerfireobserver.h" |
78 #include <e32property.h> |
78 |
79 |
|
80 #include <EPos_MPosModulesObserver.h> |
|
81 #include <EPos_CPosModuleIdList.h> |
|
82 #include <EPos_CPosModules.h> |
|
83 #include <EPos_CPosModuleUpdate.h> |
|
84 #include <MProEngEngine.h> |
|
85 #include <Profile.hrh> |
|
86 #include <ProEngFactory.h> |
|
79 |
87 |
80 // EXTERNAL DATA STRUCTURES |
88 // EXTERNAL DATA STRUCTURES |
81 //extern ?external_data; |
89 //extern ?external_data; |
82 |
90 |
83 // EXTERNAL FUNCTION PROTOTYPES |
91 // EXTERNAL FUNCTION PROTOTYPES |
137 void CFiringofStartupTriggerAndListTrigger::Delete() |
145 void CFiringofStartupTriggerAndListTrigger::Delete() |
138 { |
146 { |
139 |
147 |
140 } |
148 } |
141 |
149 |
150 void CFiringofStartupTriggerAndListTrigger::EnableSimPSYL() |
|
151 { |
|
152 CPosModules* db = CPosModules::OpenL(); |
|
153 CleanupStack::PushL( db ); |
|
154 |
|
155 // List entries |
|
156 CPosModuleIdList* idList = db->ModuleIdListLC(); |
|
157 CPosModuleUpdate* updateParams = CPosModuleUpdate::NewLC(); |
|
158 |
|
159 // Get the display name and status of each installed positioning plug-in |
|
160 for (TInt i = 0; i < idList->Count(); i++) |
|
161 { |
|
162 // get PSY info |
|
163 TPositionModuleInfo moduleInfo; |
|
164 db->GetModuleInfoL( (*idList)[i], moduleInfo ); |
|
165 |
|
166 if ( moduleInfo.IsAvailable() ) |
|
167 { |
|
168 // read PSY’s name |
|
169 TBuf<KPositionMaxModuleName> moduleName; |
|
170 moduleInfo.GetModuleName( moduleName ); |
|
171 TPositionModuleId id = moduleInfo.ModuleId(); |
|
172 |
|
173 updateParams->SetUpdateAvailability( EFalse ); |
|
174 db->UpdateModuleL( id, *updateParams ); |
|
175 } |
|
176 } |
|
177 TPositionModuleId id2 = {0x101F7A81}; |
|
178 updateParams->SetUpdateAvailability( ETrue ); |
|
179 db->UpdateModuleL( id2, *updateParams ); |
|
180 |
|
181 CleanupStack::PopAndDestroy( updateParams ); |
|
182 CleanupStack::PopAndDestroy( idList ); |
|
183 CleanupStack::PopAndDestroy( db ); |
|
184 } |
|
185 |
|
186 void CFiringofStartupTriggerAndListTrigger::SetProfileToOfflineL() |
|
187 { |
|
188 if( !iProEngine ) |
|
189 iProEngine= ProEngFactory::NewEngineL(); |
|
190 // Store current profile id. |
|
191 iCurrentProfile = iProEngine->ActiveProfileId(); |
|
192 // Change the active profile to Off-line |
|
193 iProEngine->SetActiveProfileL( EProfileOffLineId ); |
|
194 } |
|
195 |
|
196 void CFiringofStartupTriggerAndListTrigger::RestoreProfileL() |
|
197 { |
|
198 if( !iProEngine ) |
|
199 iProEngine = ProEngFactory::NewEngineL(); |
|
200 iProEngine->SetActiveProfileL( iCurrentProfile ); |
|
201 } |
|
202 |
|
203 //------------------------------------------------------------------------------ |
|
204 //CFiringofStartupTriggerAndListTrigger::GetCurrentCoordinateL |
|
205 //------------------------------------------------------------------------------ |
|
206 void CFiringofStartupTriggerAndListTrigger::GetCurrentCoordinateL( TCoordinate& aCoordinate ) |
|
207 { |
|
208 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL(); |
|
209 CleanupStack::PushL( notifier ); |
|
210 CActiveSchedulerWait* wait = new ( ELeave ) CActiveSchedulerWait; |
|
211 CleanupStack::PushL( wait ); |
|
212 |
|
213 TPositionInfo positionInfo; |
|
214 // Ownership of wait is taken by notifier |
|
215 notifier->CurrentPositionL( positionInfo,wait ); |
|
216 CleanupStack::Pop( wait ); |
|
217 wait->Start(); |
|
218 TPosition position; |
|
219 positionInfo.GetPosition( position ); |
|
220 aCoordinate.SetCoordinate( position.Latitude(),position.Longitude(),position.Altitude() ); |
|
221 CleanupStack::PopAndDestroy( notifier ); |
|
222 } |
|
223 |
|
224 |
|
225 |
|
142 // ----------------------------------------------------------------------------- |
226 // ----------------------------------------------------------------------------- |
143 // CFiringofStartupTriggerAndListTrigger::RunMethodL |
227 // CFiringofStartupTriggerAndListTrigger::RunMethodL |
144 // Run specified method. Contains also table of test mothods and their names. |
228 // Run specified method. Contains also table of test mothods and their names. |
145 // ----------------------------------------------------------------------------- |
229 // ----------------------------------------------------------------------------- |
146 // |
230 // |
153 // Copy this line for every implemented function. |
237 // Copy this line for every implemented function. |
154 // First string is the function name used in TestScripter script file. |
238 // First string is the function name used in TestScripter script file. |
155 // Second is the actual implementation member function. |
239 // Second is the actual implementation member function. |
156 |
240 |
157 ENTRY( "test01", CFiringofStartupTriggerAndListTrigger::TCLBTFW001_testL ), |
241 ENTRY( "test01", CFiringofStartupTriggerAndListTrigger::TCLBTFW001_testL ), |
158 ENTRY( "test02", CFiringofStartupTriggerAndListTrigger::TCLBTFW002_testL ), |
242 ENTRY( "test02", CFiringofStartupTriggerAndListTrigger::TCLBTFW002_testL ), |
159 ENTRY( "test03", CFiringofStartupTriggerAndListTrigger::TCLBTFW003_testL ), |
243 ENTRY( "test03", CFiringofStartupTriggerAndListTrigger::TCLBTFW003_testL ), |
160 ENTRY( "test04", CFiringofStartupTriggerAndListTrigger::TCLBTFW004_testL ), |
244 ENTRY( "test04", CFiringofStartupTriggerAndListTrigger::TCLBTFW004_testL ), |
161 ENTRY( "test05", CFiringofStartupTriggerAndListTrigger::TCLBTFW005_testL ), |
245 ENTRY( "test05", CFiringofStartupTriggerAndListTrigger::TCLBTFW005_testL ), |
162 ENTRY( "test06", CFiringofStartupTriggerAndListTrigger::TCLBTFW006_testL ), |
246 ENTRY( "test06", CFiringofStartupTriggerAndListTrigger::TCLBTFW006_testL ), |
163 ENTRY( "test07", CFiringofStartupTriggerAndListTrigger::TCLBTFW007_testL ), |
247 ENTRY( "test07", CFiringofStartupTriggerAndListTrigger::TCLBTFW007_testL ), |
164 ENTRY( "test08", CFiringofStartupTriggerAndListTrigger::TCLBTFW008_testL ), |
248 ENTRY( "test08", CFiringofStartupTriggerAndListTrigger::TCLBTFW008_testL ), |
165 ENTRY( "test09", CFiringofStartupTriggerAndListTrigger::TCLBTFW009_testL ), |
249 ENTRY( "test09", CFiringofStartupTriggerAndListTrigger::TCLBTFW009_testL ), |
166 ENTRY( "test10", CFiringofStartupTriggerAndListTrigger::TCLBTFW010_testL ), |
250 ENTRY( "test10", CFiringofStartupTriggerAndListTrigger::TCLBTFW010_testL ), |
167 ENTRY( "test11", CFiringofStartupTriggerAndListTrigger::TCLBTFW011_testL ), |
251 ENTRY( "test11", CFiringofStartupTriggerAndListTrigger::TCLBTFW011_testL ), |
168 ENTRY( "test12", CFiringofStartupTriggerAndListTrigger::TCLBTFW012_testL ), |
252 ENTRY( "test12", CFiringofStartupTriggerAndListTrigger::TCLBTFW012_testL ), |
169 ENTRY( "test13", CFiringofStartupTriggerAndListTrigger::TCLBTFW013_testL ), |
253 ENTRY( "test13", CFiringofStartupTriggerAndListTrigger::TCLBTFW013_testL ), |
170 ENTRY( "test14", CFiringofStartupTriggerAndListTrigger::TCLBTFW014_testL ), |
254 ENTRY( "test14", CFiringofStartupTriggerAndListTrigger::TCLBTFW014_testL ), |
171 ENTRY( "test15", CFiringofStartupTriggerAndListTrigger::TCLBTFW015_testL ), |
255 ENTRY( "test15", CFiringofStartupTriggerAndListTrigger::TCLBTFW015_testL ), |
172 ENTRY( "test16", CFiringofStartupTriggerAndListTrigger::TCLBTFW016_testL ), |
256 |
173 ENTRY( "test17", CFiringofStartupTriggerAndListTrigger::TCLBTFW017_testL ), |
257 ENTRY( "test70", CFiringofStartupTriggerAndListTrigger::TCLBTFW070_testL ), |
174 ENTRY( "test18", CFiringofStartupTriggerAndListTrigger::TCLBTFW018_testL ), |
258 ENTRY( "test71", CFiringofStartupTriggerAndListTrigger::TCLBTFW071_testL ), |
175 |
259 ENTRY( "test72", CFiringofStartupTriggerAndListTrigger::TCLBTFW072_testL ), |
176 ENTRY( "test70", CFiringofStartupTriggerAndListTrigger::TCLBTFW070_testL ), |
260 ENTRY( "test73", CFiringofStartupTriggerAndListTrigger::TCLBTFW073_testL ), |
177 ENTRY( "test71", CFiringofStartupTriggerAndListTrigger::TCLBTFW071_testL ), |
261 ENTRY( "test74", CFiringofStartupTriggerAndListTrigger::TCLBTFW074_testL ), |
178 ENTRY( "test72", CFiringofStartupTriggerAndListTrigger::TCLBTFW072_testL ), |
262 ENTRY( "test75", CFiringofStartupTriggerAndListTrigger::TCLBTFW075_testL ), |
179 ENTRY( "test73", CFiringofStartupTriggerAndListTrigger::TCLBTFW073_testL ), |
263 ENTRY( "test76", CFiringofStartupTriggerAndListTrigger::TCLBTFW076_testL ), |
180 ENTRY( "test74", CFiringofStartupTriggerAndListTrigger::TCLBTFW074_testL ), |
264 ENTRY( "test77", CFiringofStartupTriggerAndListTrigger::TCLBTFW077_testL ), |
181 ENTRY( "test75", CFiringofStartupTriggerAndListTrigger::TCLBTFW075_testL ), |
265 ENTRY( "test78", CFiringofStartupTriggerAndListTrigger::TCLBTFW078_testL ), |
182 ENTRY( "test76", CFiringofStartupTriggerAndListTrigger::TCLBTFW076_testL ), |
266 ENTRY( "test79", CFiringofStartupTriggerAndListTrigger::TCLBTFW079_testL ), |
183 ENTRY( "test77", CFiringofStartupTriggerAndListTrigger::TCLBTFW077_testL ), |
267 ENTRY( "test80", CFiringofStartupTriggerAndListTrigger::TCLBTFW080_testL ), |
184 ENTRY( "test78", CFiringofStartupTriggerAndListTrigger::TCLBTFW078_testL ), |
268 ENTRY( "test81", CFiringofStartupTriggerAndListTrigger::TCLBTFW081_testL ), |
185 ENTRY( "test79", CFiringofStartupTriggerAndListTrigger::TCLBTFW079_testL ), |
269 ENTRY( "test82", CFiringofStartupTriggerAndListTrigger::TCLBTFW082_testL ), |
186 ENTRY( "test80", CFiringofStartupTriggerAndListTrigger::TCLBTFW080_testL ), |
270 ENTRY( "test83", CFiringofStartupTriggerAndListTrigger::TCLBTFW083_testL ), |
187 ENTRY( "test81", CFiringofStartupTriggerAndListTrigger::TCLBTFW081_testL ), |
271 ENTRY( "test84", CFiringofStartupTriggerAndListTrigger::TCLBTFW084_testL ), |
188 ENTRY( "test82", CFiringofStartupTriggerAndListTrigger::TCLBTFW082_testL ), |
272 ENTRY( "test85", CFiringofStartupTriggerAndListTrigger::TCLBTFW085_testL ), |
189 ENTRY( "test83", CFiringofStartupTriggerAndListTrigger::TCLBTFW083_testL ), |
273 ENTRY( "test86", CFiringofStartupTriggerAndListTrigger::TCLBTFW086_testL ), |
190 ENTRY( "test84", CFiringofStartupTriggerAndListTrigger::TCLBTFW084_testL ), |
274 ENTRY( "test87", CFiringofStartupTriggerAndListTrigger::TCLBTFW087_testL ), |
191 ENTRY( "test85", CFiringofStartupTriggerAndListTrigger::TCLBTFW085_testL ), |
275 ENTRY( "test88", CFiringofStartupTriggerAndListTrigger::TCLBTFW088_testL ), |
192 ENTRY( "test86", CFiringofStartupTriggerAndListTrigger::TCLBTFW086_testL ), |
276 ENTRY( "test89", CFiringofStartupTriggerAndListTrigger::TCLBTFW089_testL ), |
193 ENTRY( "test87", CFiringofStartupTriggerAndListTrigger::TCLBTFW087_testL ), |
277 ENTRY( "test90", CFiringofStartupTriggerAndListTrigger::TCLBTFW090_testL ), |
194 ENTRY( "test88", CFiringofStartupTriggerAndListTrigger::TCLBTFW088_testL ), |
278 ENTRY( "test91", CFiringofStartupTriggerAndListTrigger::TCLBTFW091_testL ), |
195 ENTRY( "test89", CFiringofStartupTriggerAndListTrigger::TCLBTFW089_testL ), |
279 ENTRY( "test92", CFiringofStartupTriggerAndListTrigger::TCLBTFW092_testL ), |
196 ENTRY( "test90", CFiringofStartupTriggerAndListTrigger::TCLBTFW090_testL ), |
280 ENTRY( "test93", CFiringofStartupTriggerAndListTrigger::TCLBTFW093_testL ), |
197 ENTRY( "test91", CFiringofStartupTriggerAndListTrigger::TCLBTFW091_testL ), |
281 ENTRY( "test94", CFiringofStartupTriggerAndListTrigger::TCLBTFW094_testL ), |
198 ENTRY( "test92", CFiringofStartupTriggerAndListTrigger::TCLBTFW092_testL ), |
282 ENTRY( "test95", CFiringofStartupTriggerAndListTrigger::TCLBTFW095_testL ), |
199 ENTRY( "test93", CFiringofStartupTriggerAndListTrigger::TCLBTFW093_testL ), |
|
200 ENTRY( "test94", CFiringofStartupTriggerAndListTrigger::TCLBTFW094_testL ), |
|
201 ENTRY( "test95", CFiringofStartupTriggerAndListTrigger::TCLBTFW095_testL ), |
|
202 |
|
203 |
|
204 |
|
205 }; |
283 }; |
206 |
284 |
207 const TInt count = sizeof( KFunctions ) / |
285 const TInt count = sizeof( KFunctions ) / |
208 sizeof( TStifFunctionInfo ); |
286 sizeof( TStifFunctionInfo ); |
209 |
287 |
222 |
300 |
223 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW001_testL( CStifItemParser& /* aItem */ ) |
301 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW001_testL( CStifItemParser& /* aItem */ ) |
224 { |
302 { |
225 |
303 |
226 iLog->Log(_L("Entering Test1")); |
304 iLog->Log(_L("Entering Test1")); |
227 _LIT( KSimulationFile,"c:\\system\\data\\simu_move1.sps" ); |
305 _LIT( KSimulationFile,"c:\\system\\data\\simu_move1.sps" ); |
228 // _LIT( KSimulationFile0,"c:\\system\\data\\simu_move2.sps" ); |
306 |
229 RPositionServer iLocationServer; |
307 // Set profile to offline mode.This is required to avoid movement detection blocking the |
230 RPositioner iPositioner; |
308 // trigger firing. |
231 |
309 SetProfileToOfflineL(); |
232 // Connect to the location server |
310 // Enable simulation psy |
233 User::LeaveIfError(iLocationServer.Connect()); |
311 EnableSimPSYL(); |
234 |
312 RLbtServer lbtserver; |
235 // Open the positioner |
|
236 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
|
237 |
|
238 RLbtServer lbtserver; |
|
239 RLbt lbt; |
313 RLbt lbt; |
240 iLog->Log(_L("Before connecting")); |
314 iLog->Log(_L("Before connecting")); |
241 User::LeaveIfError( lbtserver.Connect() ); |
315 User::LeaveIfError( lbtserver.Connect() ); |
242 CleanupClosePushL( lbtserver ); |
316 CleanupClosePushL( lbtserver ); |
243 iLog->Log(_L("Connection to RLbtServer Passed ")); |
317 iLog->Log(_L("Connection to RLbtServer Passed ")); |
276 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
350 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
277 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
351 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
278 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
352 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
279 // set condition |
353 // set condition |
280 |
354 |
281 TCoordinate coordinate(62.5285,23.9385); |
355 TCoordinate coordinate; |
282 // TCoordinate coordinate(62.4438,23.9385); |
356 GetCurrentCoordinateL( coordinate ); |
283 |
357 |
284 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
358 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
285 CleanupStack::PushL( circle ); |
359 CleanupStack::PushL( circle ); |
286 |
360 |
287 |
361 |
314 FireInfo = notifier->GetFiredTrigger(); |
388 FireInfo = notifier->GetFiredTrigger(); |
315 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
389 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
316 firePosition.Distance(coordinate,trigDistance); |
390 firePosition.Distance(coordinate,trigDistance); |
317 //close sim psy |
391 //close sim psy |
318 |
392 |
319 iPositioner.Close(); |
393 RestoreProfileL(); |
320 iLocationServer.Close(); |
|
321 if( trigDistance<=1000 && FireInfo.iTriggerId==trigId ) |
394 if( trigDistance<=1000 && FireInfo.iTriggerId==trigId ) |
322 { |
395 { |
323 lbt.DeleteTriggerL(trigId); |
396 lbt.DeleteTriggerL(trigId); |
324 CleanupStack::PopAndDestroy( notifier ); |
397 CleanupStack::PopAndDestroy( notifier ); |
325 CleanupStack::PopAndDestroy( trig ); |
398 CleanupStack::PopAndDestroy( trig ); |
353 |
426 |
354 RLbtServer lbtserver; |
427 RLbtServer lbtserver; |
355 RLbt lbt; |
428 RLbt lbt; |
356 RPositionServer iLocationServer; |
429 RPositionServer iLocationServer; |
357 RPositioner iPositioner; |
430 RPositioner iPositioner; |
358 |
431 |
432 // Set profile to offline mode.This is required to avoid movement detection blocking the |
|
433 // trigger firing. |
|
434 SetProfileToOfflineL(); |
|
435 // Enable simulation psy |
|
436 EnableSimPSYL(); |
|
437 |
|
359 // Connect to the location server |
438 // Connect to the location server |
360 User::LeaveIfError(iLocationServer.Connect()); |
439 User::LeaveIfError(iLocationServer.Connect()); |
361 |
440 |
362 // Open the positioner |
441 // Open the positioner |
363 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
442 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
394 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
473 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
395 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
474 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
396 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
475 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
397 // set condition |
476 // set condition |
398 |
477 |
399 TCoordinate coordinate(62.5285,23.9385); |
478 TCoordinate coordinate; |
400 |
479 GetCurrentCoordinateL( coordinate ); |
401 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
480 |
481 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,200); |
|
402 CleanupStack::PushL( circle ); |
482 CleanupStack::PushL( circle ); |
403 |
483 |
404 |
484 |
405 // ownership of circle object transferred to the condition object |
485 // ownership of circle object transferred to the condition object |
406 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
486 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
422 notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); |
502 notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); |
423 wait->Start( ); |
503 wait->Start( ); |
424 |
504 |
425 notifier->StartNotification( wait ); |
505 notifier->StartNotification( wait ); |
426 wait->Start( ); |
506 wait->Start( ); |
507 iLog->Log(_L("Trigger fired")); |
|
427 TLbtTriggerFireInfo FireInfo; |
508 TLbtTriggerFireInfo FireInfo; |
428 TReal32 trigDistance; |
509 TReal32 trigDistance; |
429 TPosition firePosition; |
510 TPosition firePosition; |
430 FireInfo = notifier->GetFiredTrigger(); |
511 FireInfo = notifier->GetFiredTrigger(); |
512 iLog->Log(_L("Trigger fired")); |
|
431 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
513 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
432 firePosition.Distance(coordinate,trigDistance); |
514 firePosition.Distance(coordinate,trigDistance); |
433 |
515 |
434 //close sim psy |
516 //close sim psy |
435 |
517 |
436 iPositioner.Close(); |
518 iPositioner.Close(); |
437 iLocationServer.Close(); |
519 iLocationServer.Close(); |
438 if( trigDistance>=1000 && FireInfo.iTriggerId==trigId ) |
520 RestoreProfileL(); |
521 if( FireInfo.iTriggerId==trigId ) |
|
439 { |
522 { |
440 lbt.DeleteTriggerL(trigId); |
523 lbt.DeleteTriggerL(trigId); |
441 CleanupStack::PopAndDestroy( notifier ); |
524 CleanupStack::PopAndDestroy( notifier ); |
442 CleanupStack::PopAndDestroy( trig ); |
525 CleanupStack::PopAndDestroy( trig ); |
443 CleanupStack::Pop( &lbt ); |
526 CleanupStack::Pop( &lbt ); |
451 CleanupStack::PopAndDestroy( notifier ); |
534 CleanupStack::PopAndDestroy( notifier ); |
452 CleanupStack::PopAndDestroy( trig ); |
535 CleanupStack::PopAndDestroy( trig ); |
453 CleanupStack::Pop( &lbt ); |
536 CleanupStack::Pop( &lbt ); |
454 CleanupStack::PopAndDestroy( &lbtserver ); |
537 CleanupStack::PopAndDestroy( &lbtserver ); |
455 delete wait; |
538 delete wait; |
456 |
539 iLog->Log(_L("Test case passed ")); |
457 return -99; |
540 return -99; |
458 } |
541 } |
459 |
542 |
460 } |
543 } |
461 |
544 |
469 RLbtServer lbtserver; |
552 RLbtServer lbtserver; |
470 RLbt lbt; |
553 RLbt lbt; |
471 RPositionServer iLocationServer; |
554 RPositionServer iLocationServer; |
472 RPositioner iPositioner; |
555 RPositioner iPositioner; |
473 |
556 |
474 // Connect to the location server |
557 // Set profile to offline mode.This is required to avoid movement detection blocking the |
475 User::LeaveIfError(iLocationServer.Connect()); |
558 // trigger firing. |
476 |
559 SetProfileToOfflineL(); |
477 // Open the positioner |
560 // Enable simulation psy |
478 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
561 EnableSimPSYL(); |
479 |
562 |
480 |
|
481 User::LeaveIfError( lbtserver.Connect() ); |
563 User::LeaveIfError( lbtserver.Connect() ); |
482 CleanupClosePushL( lbtserver ); |
564 CleanupClosePushL( lbtserver ); |
483 User::LeaveIfError( lbt.Open( lbtserver ) ); |
565 User::LeaveIfError( lbt.Open( lbtserver ) ); |
484 CleanupClosePushL( lbt ); |
566 CleanupClosePushL( lbt ); |
485 |
567 |
510 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
592 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
511 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
593 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
512 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
594 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
513 // set condition |
595 // set condition |
514 |
596 |
515 TCoordinate coordinate(62.5285,23.9385); |
597 TCoordinate coordinate; |
516 |
598 GetCurrentCoordinateL( coordinate ); |
517 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
599 |
600 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,200); |
|
518 CleanupStack::PushL( circle ); |
601 CleanupStack::PushL( circle ); |
519 |
602 |
520 |
603 |
521 // ownership of circle object transferred to the condition object |
604 // ownership of circle object transferred to the condition object |
522 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
605 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
536 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
619 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
537 |
620 |
538 notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); |
621 notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); |
539 wait->Start( ); |
622 wait->Start( ); |
540 |
623 |
541 /* notifier->StartNotification( wait ); |
624 RestoreProfileL(); |
542 wait->Start( );*/ |
|
543 |
625 |
544 CleanupStack::PopAndDestroy( notifier ); |
626 CleanupStack::PopAndDestroy( notifier ); |
545 CleanupStack::PopAndDestroy( trig ); |
627 CleanupStack::PopAndDestroy( trig ); |
546 CleanupStack::Pop( &lbt ); |
628 CleanupStack::Pop( &lbt ); |
547 CleanupStack::PopAndDestroy( &lbtserver ); |
629 CleanupStack::PopAndDestroy( &lbtserver ); |
548 delete wait; |
630 delete wait; |
549 User::Exit(0); |
|
550 return KErrNone; |
631 return KErrNone; |
551 |
632 |
552 } |
633 } |
553 |
634 |
554 |
635 |
564 RLbt lbt; |
645 RLbt lbt; |
565 |
646 |
566 RPositionServer iLocationServer; |
647 RPositionServer iLocationServer; |
567 RPositioner iPositioner; |
648 RPositioner iPositioner; |
568 |
649 |
650 // Set profile to offline mode.This is required to avoid movement detection blocking the |
|
651 // trigger firing. |
|
652 SetProfileToOfflineL(); |
|
653 // Enable simulation psy |
|
654 EnableSimPSYL(); |
|
655 |
|
569 // Connect to the location server |
656 // Connect to the location server |
570 User::LeaveIfError(iLocationServer.Connect()); |
657 User::LeaveIfError(iLocationServer.Connect()); |
571 |
658 |
572 // Open the positioner |
659 // Open the positioner |
573 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
660 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
603 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
690 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
604 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
691 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
605 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
692 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
606 // set condition |
693 // set condition |
607 |
694 |
608 TCoordinate coordinate(62.5285,23.9385); |
695 TCoordinate coordinate; |
696 GetCurrentCoordinateL( coordinate ); |
|
609 |
697 |
610 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
698 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
611 CleanupStack::PushL( circle ); |
699 CleanupStack::PushL( circle ); |
612 |
700 |
613 |
701 |
643 |
731 |
644 //close sim psy |
732 //close sim psy |
645 |
733 |
646 iPositioner.Close(); |
734 iPositioner.Close(); |
647 iLocationServer.Close(); |
735 iLocationServer.Close(); |
648 if( trigDistance<=1000 && FireInfo.iTriggerId==trigId ) |
736 RestoreProfileL(); |
737 if( FireInfo.iTriggerId==trigId ) |
|
649 { |
738 { |
650 lbt.DeleteTriggerL(trigId); |
739 lbt.DeleteTriggerL(trigId); |
651 CleanupStack::PopAndDestroy( notifier ); |
740 CleanupStack::PopAndDestroy( notifier ); |
652 CleanupStack::PopAndDestroy( trig ); |
741 CleanupStack::PopAndDestroy( trig ); |
653 CleanupStack::Pop( &lbt ); |
742 CleanupStack::Pop( &lbt ); |
687 User::LeaveIfError(iLocationServer.Connect()); |
776 User::LeaveIfError(iLocationServer.Connect()); |
688 |
777 |
689 // Open the positioner |
778 // Open the positioner |
690 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
779 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
691 |
780 |
781 // Set profile to offline mode.This is required to avoid movement detection blocking the |
|
782 // trigger firing. |
|
783 SetProfileToOfflineL(); |
|
784 // Enable simulation psy |
|
785 EnableSimPSYL(); |
|
692 |
786 |
693 User::LeaveIfError( lbtserver.Connect() ); |
787 User::LeaveIfError( lbtserver.Connect() ); |
694 CleanupClosePushL( lbtserver ); |
788 CleanupClosePushL( lbtserver ); |
695 User::LeaveIfError( lbt.Open( lbtserver ) ); |
789 User::LeaveIfError( lbt.Open( lbtserver ) ); |
696 CleanupClosePushL( lbt ); |
790 CleanupClosePushL( lbt ); |
725 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
819 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
726 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
820 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
727 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
821 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
728 // set condition |
822 // set condition |
729 |
823 |
730 TCoordinate coordinate(62.5285,23.9385); |
824 TCoordinate coordinate; |
825 GetCurrentCoordinateL( coordinate ); |
|
731 |
826 |
732 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
827 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
733 CleanupStack::PushL( circle ); |
828 CleanupStack::PushL( circle ); |
734 |
829 |
735 |
830 |
761 notifier->After(1500000); |
856 notifier->After(1500000); |
762 wait->Start( ); |
857 wait->Start( ); |
763 // User::After(60000000); |
858 // User::After(60000000); |
764 iPositioner.Close(); |
859 iPositioner.Close(); |
765 iLocationServer.Close(); |
860 iLocationServer.Close(); |
861 RestoreProfileL(); |
|
766 if(notifier->iTriggerFireCount> 0) |
862 if(notifier->iTriggerFireCount> 0) |
767 { |
863 { |
768 CleanupStack::PopAndDestroy( notifier ); |
864 CleanupStack::PopAndDestroy( notifier ); |
769 CleanupStack::PopAndDestroy( trig ); |
865 CleanupStack::PopAndDestroy( trig ); |
770 CleanupStack::PopAndDestroy( &lbt ); |
866 CleanupStack::PopAndDestroy( &lbt ); |
802 User::LeaveIfError(iLocationServer.Connect()); |
898 User::LeaveIfError(iLocationServer.Connect()); |
803 |
899 |
804 // Open the positioner |
900 // Open the positioner |
805 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
901 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
806 |
902 |
903 // Set profile to offline mode.This is required to avoid movement detection blocking the |
|
904 // trigger firing. |
|
905 SetProfileToOfflineL(); |
|
906 // Enable simulation psy |
|
907 EnableSimPSYL(); |
|
807 |
908 |
808 User::LeaveIfError( lbtserver.Connect() ); |
909 User::LeaveIfError( lbtserver.Connect() ); |
809 CleanupClosePushL( lbtserver ); |
910 CleanupClosePushL( lbtserver ); |
810 iLog->Log(_L("Connection to RLbtServer Passed ")); |
911 iLog->Log(_L("Connection to RLbtServer Passed ")); |
811 User::LeaveIfError( lbt.Open( lbtserver ) ); |
912 User::LeaveIfError( lbt.Open( lbtserver ) ); |
840 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
941 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
841 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
942 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
842 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
943 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
843 // set condition |
944 // set condition |
844 |
945 |
845 TCoordinate coordinate(62.5285,23.9385); |
946 TCoordinate coordinate; |
846 // TCoordinate coordinate(62.4438,23.9385); |
947 GetCurrentCoordinateL( coordinate ); |
847 |
948 |
848 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
949 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
849 CleanupStack::PushL( circle ); |
950 CleanupStack::PushL( circle ); |
850 |
951 |
851 |
952 |
878 FireInfo = notifier->GetFiredTrigger(); |
979 FireInfo = notifier->GetFiredTrigger(); |
879 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
980 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
880 firePosition.Distance(coordinate,trigDistance); |
981 firePosition.Distance(coordinate,trigDistance); |
881 iPositioner.Close(); |
982 iPositioner.Close(); |
882 iLocationServer.Close(); |
983 iLocationServer.Close(); |
984 RestoreProfileL(); |
|
883 if(trigDistance<=1000 && FireInfo.iTriggerId==trigId ) |
985 if(trigDistance<=1000 && FireInfo.iTriggerId==trigId ) |
884 { |
986 { |
885 |
987 |
886 CleanupStack::PopAndDestroy( notifier ); |
988 CleanupStack::PopAndDestroy( notifier ); |
887 CleanupStack::PopAndDestroy( trig ); |
989 CleanupStack::PopAndDestroy( trig ); |
892 |
994 |
893 return KErrNone; |
995 return KErrNone; |
894 } |
996 } |
895 else |
997 else |
896 { |
998 { |
897 CleanupStack::PopAndDestroy( notifier ); |
999 CleanupStack::PopAndDestroy( notifier ); |
898 CleanupStack::PopAndDestroy( trig ); |
1000 CleanupStack::PopAndDestroy( trig ); |
899 CleanupStack::Pop( &lbt ); |
1001 CleanupStack::Pop( &lbt ); |
900 CleanupStack::PopAndDestroy( &lbtserver ); |
1002 CleanupStack::PopAndDestroy( &lbtserver ); |
901 delete wait; |
1003 delete wait; |
902 |
1004 |
927 |
1029 |
928 User::LeaveIfError( lbtserver.Connect() ); |
1030 User::LeaveIfError( lbtserver.Connect() ); |
929 CleanupClosePushL( lbtserver ); |
1031 CleanupClosePushL( lbtserver ); |
930 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1032 User::LeaveIfError( lbt.Open( lbtserver ) ); |
931 CleanupClosePushL( lbt ); |
1033 CleanupClosePushL( lbt ); |
1034 |
|
1035 // Set profile to offline mode.This is required to avoid movement detection blocking the |
|
1036 // trigger firing. |
|
1037 SetProfileToOfflineL(); |
|
1038 // Enable simulation psy |
|
1039 EnableSimPSYL(); |
|
932 |
1040 |
933 //Delete all the existing trggers |
1041 //Delete all the existing trggers |
934 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1042 TRAP_IGNORE(lbt.DeleteTriggersL()); |
935 |
1043 |
936 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1044 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
955 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1063 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
956 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1064 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
957 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1065 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
958 // set condition |
1066 // set condition |
959 |
1067 |
960 TCoordinate coordinate(62.5285,23.9385); |
1068 TCoordinate coordinate; |
1069 GetCurrentCoordinateL( coordinate ); |
|
961 |
1070 |
962 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1071 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
963 CleanupStack::PushL( circle ); |
1072 CleanupStack::PushL( circle ); |
964 |
1073 |
965 |
1074 |
992 FireInfo = notifier->GetFiredTrigger(); |
1101 FireInfo = notifier->GetFiredTrigger(); |
993 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
1102 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
994 firePosition.Distance(coordinate,trigDistance); |
1103 firePosition.Distance(coordinate,trigDistance); |
995 iPositioner.Close(); |
1104 iPositioner.Close(); |
996 iLocationServer.Close(); |
1105 iLocationServer.Close(); |
1106 RestoreProfileL(); |
|
997 if(trigDistance==0 && FireInfo.iTriggerId==trigId ) |
1107 if(trigDistance==0 && FireInfo.iTriggerId==trigId ) |
998 { |
1108 { |
999 |
1109 |
1000 CleanupStack::PopAndDestroy( notifier ); |
1110 CleanupStack::PopAndDestroy( notifier ); |
1001 CleanupStack::PopAndDestroy( trig ); |
1111 CleanupStack::PopAndDestroy( trig ); |
1041 User::LeaveIfError( lbtserver.Connect() ); |
1151 User::LeaveIfError( lbtserver.Connect() ); |
1042 CleanupClosePushL( lbtserver ); |
1152 CleanupClosePushL( lbtserver ); |
1043 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1153 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1044 CleanupClosePushL( lbt ); |
1154 CleanupClosePushL( lbt ); |
1045 |
1155 |
1156 // Set profile to offline mode.This is required to avoid movement detection blocking the |
|
1157 // trigger firing. |
|
1158 SetProfileToOfflineL(); |
|
1159 // Enable simulation psy |
|
1160 EnableSimPSYL(); |
|
1161 |
|
1046 //Delete all the existing trggers |
1162 //Delete all the existing trggers |
1047 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1163 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1048 |
1164 |
1049 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1165 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1050 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
1166 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
1067 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1183 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1068 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1184 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1069 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1185 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1070 // set condition |
1186 // set condition |
1071 |
1187 |
1072 TCoordinate coordinate(62.5285,23.9385); |
1188 TCoordinate coordinate; |
1189 GetCurrentCoordinateL( coordinate ); |
|
1073 coordinate.Move(90,2000); |
1190 coordinate.Move(90,2000); |
1074 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1191 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1075 CleanupStack::PushL( circle ); |
1192 CleanupStack::PushL( circle ); |
1076 |
1193 |
1077 |
1194 |
1104 FireInfo = notifier->GetFiredTrigger(); |
1221 FireInfo = notifier->GetFiredTrigger(); |
1105 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
1222 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
1106 firePosition.Distance(coordinate,trigDistance); |
1223 firePosition.Distance(coordinate,trigDistance); |
1107 iPositioner.Close(); |
1224 iPositioner.Close(); |
1108 iLocationServer.Close(); |
1225 iLocationServer.Close(); |
1226 RestoreProfileL(); |
|
1109 if( trigDistance>=1000 && FireInfo.iTriggerId==trigId ) |
1227 if( trigDistance>=1000 && FireInfo.iTriggerId==trigId ) |
1110 { |
1228 { |
1111 |
1229 |
1112 CleanupStack::PopAndDestroy( notifier ); |
1230 CleanupStack::PopAndDestroy( notifier ); |
1113 CleanupStack::PopAndDestroy( trig ); |
1231 CleanupStack::PopAndDestroy( trig ); |
1149 |
1267 |
1150 User::LeaveIfError( lbtserver.Connect() ); |
1268 User::LeaveIfError( lbtserver.Connect() ); |
1151 CleanupClosePushL( lbtserver ); |
1269 CleanupClosePushL( lbtserver ); |
1152 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1270 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1153 CleanupClosePushL( lbt ); |
1271 CleanupClosePushL( lbt ); |
1272 |
|
1273 // Set profile to offline mode.This is required to avoid movement detection blocking the |
|
1274 // trigger firing. |
|
1275 SetProfileToOfflineL(); |
|
1276 // Enable simulation psy |
|
1277 EnableSimPSYL(); |
|
1154 |
1278 |
1155 //Delete all the existing trggers |
1279 //Delete all the existing trggers |
1156 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1280 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1157 |
1281 |
1158 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1282 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1176 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1300 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1177 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1301 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1178 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1302 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1179 // set condition |
1303 // set condition |
1180 |
1304 |
1181 TCoordinate coordinate(62.5285,23.9385); |
1305 TCoordinate coordinate; |
1306 GetCurrentCoordinateL( coordinate ); |
|
1182 |
1307 |
1183 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1308 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1184 CleanupStack::PushL( circle ); |
1309 CleanupStack::PushL( circle ); |
1185 |
1310 |
1186 |
1311 |
1211 notifier->StartNotification( wait ); |
1336 notifier->StartNotification( wait ); |
1212 notifier->After(5000000); |
1337 notifier->After(5000000); |
1213 wait->Start( ); |
1338 wait->Start( ); |
1214 iPositioner.Close(); |
1339 iPositioner.Close(); |
1215 iLocationServer.Close(); |
1340 iLocationServer.Close(); |
1341 RestoreProfileL(); |
|
1216 if(notifier->iTriggerFireCount== 0) |
1342 if(notifier->iTriggerFireCount== 0) |
1217 { |
1343 { |
1218 CleanupStack::PopAndDestroy( notifier ); |
1344 CleanupStack::PopAndDestroy( notifier ); |
1219 CleanupStack::PopAndDestroy( trig ); |
1345 CleanupStack::PopAndDestroy( trig ); |
1220 CleanupStack::PopAndDestroy( &lbt ); |
1346 CleanupStack::PopAndDestroy( &lbt ); |
1260 User::LeaveIfError( lbtserver.Connect() ); |
1386 User::LeaveIfError( lbtserver.Connect() ); |
1261 CleanupClosePushL( lbtserver ); |
1387 CleanupClosePushL( lbtserver ); |
1262 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1388 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1263 CleanupClosePushL( lbt ); |
1389 CleanupClosePushL( lbt ); |
1264 |
1390 |
1391 // Set profile to offline mode.This is required to avoid movement detection blocking the |
|
1392 // trigger firing. |
|
1393 SetProfileToOfflineL(); |
|
1394 // Enable simulation psy |
|
1395 EnableSimPSYL(); |
|
1265 //Delete all the existing trggers |
1396 //Delete all the existing trggers |
1266 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1397 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1267 |
1398 |
1268 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1399 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1269 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
1400 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
1286 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1417 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1287 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1418 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1288 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1419 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1289 // set condition |
1420 // set condition |
1290 |
1421 |
1291 TCoordinate coordinate(62.5285,23.9385); |
1422 TCoordinate coordinate; |
1423 GetCurrentCoordinateL( coordinate ); |
|
1292 coordinate.Move(90,1100); |
1424 coordinate.Move(90,1100); |
1293 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1425 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1294 CleanupStack::PushL( circle ); |
1426 CleanupStack::PushL( circle ); |
1295 |
1427 |
1296 |
1428 |
1319 notifier->StartNotification( wait ); |
1451 notifier->StartNotification( wait ); |
1320 notifier->After(5000000); |
1452 notifier->After(5000000); |
1321 wait->Start( ); |
1453 wait->Start( ); |
1322 iPositioner.Close(); |
1454 iPositioner.Close(); |
1323 iLocationServer.Close(); |
1455 iLocationServer.Close(); |
1456 RestoreProfileL(); |
|
1324 if(notifier->iTriggerFireCount== 0) |
1457 if(notifier->iTriggerFireCount== 0) |
1325 { |
1458 { |
1326 CleanupStack::PopAndDestroy( notifier ); |
1459 CleanupStack::PopAndDestroy( notifier ); |
1327 CleanupStack::PopAndDestroy( trig ); |
1460 CleanupStack::PopAndDestroy( trig ); |
1328 CleanupStack::PopAndDestroy( &lbt ); |
1461 CleanupStack::PopAndDestroy( &lbt ); |
1354 RLbt lbt; |
1487 RLbt lbt; |
1355 |
1488 |
1356 User::LeaveIfError( lbtserver.Connect() ); |
1489 User::LeaveIfError( lbtserver.Connect() ); |
1357 CleanupClosePushL( lbtserver ); |
1490 CleanupClosePushL( lbtserver ); |
1358 |
1491 |
1359 TCoordinate coordinate(62.4438,23.9385); |
1492 TCoordinate coordinate; |
1493 GetCurrentCoordinateL( coordinate ); |
|
1360 TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 2); |
1494 TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 2); |
1361 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate ); |
1495 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate ); |
1362 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
1496 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
1363 |
1497 |
1364 notifier->StartNotification( wait ); |
1498 notifier->StartNotification( wait ); |
1420 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1554 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1421 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1555 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1422 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1556 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1423 // set condition |
1557 // set condition |
1424 |
1558 |
1425 TCoordinate coordinate(62.5285,23.9385); |
1559 TCoordinate coordinate; |
1560 GetCurrentCoordinateL( coordinate ); |
|
1426 |
1561 |
1427 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1562 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1428 CleanupStack::PushL( circle ); |
1563 CleanupStack::PushL( circle ); |
1429 |
1564 |
1430 |
1565 |
1484 User::LeaveIfError( lbtserver.Connect() ); |
1619 User::LeaveIfError( lbtserver.Connect() ); |
1485 CleanupClosePushL( lbtserver ); |
1620 CleanupClosePushL( lbtserver ); |
1486 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1621 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1487 CleanupClosePushL( lbt ); |
1622 CleanupClosePushL( lbt ); |
1488 |
1623 |
1624 // Set profile to offline mode.This is required to avoid movement detection blocking the |
|
1625 // trigger firing. |
|
1626 SetProfileToOfflineL(); |
|
1627 // Enable simulation psy |
|
1628 EnableSimPSYL(); |
|
1489 //Delete all the existing trggers |
1629 //Delete all the existing trggers |
1490 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1630 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1491 |
1631 |
1492 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1632 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1493 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
1633 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
1511 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1651 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
1512 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1652 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
1513 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1653 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
1514 // set condition |
1654 // set condition |
1515 |
1655 |
1516 TCoordinate coordinate(62.5285,23.9385); |
1656 TCoordinate coordinate; |
1657 GetCurrentCoordinateL( coordinate ); |
|
1517 |
1658 |
1518 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,10000); |
1659 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,10000); |
1519 CleanupStack::PushL( circle ); |
1660 CleanupStack::PushL( circle ); |
1520 |
1661 |
1521 |
1662 |
1562 lbt.SetTriggerStateL(trigId,CLbtTriggerEntry::EStateEnabled,ELbtTrue); |
1703 lbt.SetTriggerStateL(trigId,CLbtTriggerEntry::EStateEnabled,ELbtTrue); |
1563 notifier->StartNotification( wait ); |
1704 notifier->StartNotification( wait ); |
1564 wait->Start( ); |
1705 wait->Start( ); |
1565 iPositioner.Close(); |
1706 iPositioner.Close(); |
1566 iLocationServer.Close(); |
1707 iLocationServer.Close(); |
1708 RestoreProfileL(); |
|
1567 if(notifier->iTriggerFireCount > 0) |
1709 if(notifier->iTriggerFireCount > 0) |
1568 { |
1710 { |
1569 lbt.DeleteTriggerL(trigId); |
1711 lbt.DeleteTriggerL(trigId); |
1570 CleanupStack::PopAndDestroy( notifier ); |
1712 CleanupStack::PopAndDestroy( notifier ); |
1571 CleanupStack::PopAndDestroy( trig ); |
1713 CleanupStack::PopAndDestroy( trig ); |
1588 return KErrGeneral; |
1730 return KErrGeneral; |
1589 } |
1731 } |
1590 |
1732 |
1591 } |
1733 } |
1592 |
1734 |
1593 // Testing the hysteresis condition for entry type of trigger |
1735 |
1594 |
1736 |
1595 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW014_testL( CStifItemParser& /* aItem */ ) |
1737 //Firing of startup trigger when trigger handling process not found in the system |
1596 { |
1738 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW014_testL( CStifItemParser& /* aItem */ ) |
1597 |
1739 { |
1598 _LIT( KSimulationFile,"c:\\system\\data\\test1.nme" ); |
1740 |
1741 _LIT( KSimulationFile,"c:\\system\\data\\simu_move1.sps" ); |
|
1599 |
1742 |
1600 RLbtServer lbtserver; |
1743 RLbtServer lbtserver; |
1601 RLbt lbt; |
1744 RLbt lbt; |
1745 |
|
1602 RPositionServer iLocationServer; |
1746 RPositionServer iLocationServer; |
1603 RPositioner iPositioner; |
1747 RPositioner iPositioner; |
1604 |
1748 |
1605 // Connect to the location server |
1749 // Connect to the location server |
1606 User::LeaveIfError(iLocationServer.Connect()); |
1750 User::LeaveIfError(iLocationServer.Connect()); |
1607 |
1751 |
1608 // Open the positioner |
1752 // Open the positioner |
1609 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
1753 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
1610 |
|
1611 |
1754 |
1612 User::LeaveIfError( lbtserver.Connect() ); |
1755 User::LeaveIfError( lbtserver.Connect() ); |
1613 CleanupClosePushL( lbtserver ); |
1756 CleanupClosePushL( lbtserver ); |
1614 iLog->Log(_L("Connection to RLbtServer Passed ")); |
1757 iLog->Log(_L("Connection to RLbtServer Passed ")); |
1615 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1758 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1616 iLog->Log(_L("Subsession opened ")); |
1759 iLog->Log(_L("Subsession opened ")); |
1617 CleanupClosePushL( lbt ); |
1760 CleanupClosePushL( lbt ); |
1618 |
1761 |
1619 //Delete all the existing trggers |
1762 // Set profile to offline mode.This is required to avoid movement detection blocking the |
1620 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1763 // trigger firing. |
1621 |
1764 SetProfileToOfflineL(); |
1622 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1765 // Enable simulation psy |
1623 iLog->Log(_L("Simulation PSY Repository object created")); |
1766 EnableSimPSYL(); |
1624 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
|
1625 iLog->Log(_L("Simulation input file set ")); |
|
1626 CleanupStack::PopAndDestroy(repository); |
|
1627 |
|
1628 //Construct a session trigger |
|
1629 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
|
1630 |
|
1631 //Push to cleanup stack |
|
1632 CleanupStack::PushL( trig ); |
|
1633 iLog->Log(_L("Startup Trigger Entry Created ")); |
|
1634 |
|
1635 // Set Name |
|
1636 trig->SetNameL(_L("Trigger1")); |
|
1637 // _LIT( KMyTriggerHandlingProcessName, "About.exe"); |
|
1638 _LIT( KMyTriggerHandlingProcessName, "ConsoleUI.exe"); |
|
1639 |
|
1640 TSecureId secureid; |
|
1641 trig->SetProcessId(KMyTriggerHandlingProcessName,secureid); |
|
1642 //Set Requestor |
|
1643 CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; |
|
1644 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
|
1645 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
|
1646 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
|
1647 // set condition |
|
1648 |
|
1649 TCoordinate coordinate(65.5285,23.9385); |
|
1650 // TCoordinate coordinate(62.4438,23.9385); |
|
1651 |
|
1652 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
|
1653 CleanupStack::PushL( circle ); |
|
1654 |
|
1655 |
|
1656 // ownership of circle object transferred to the condition object |
|
1657 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
|
1658 circle, |
|
1659 CLbtTriggerConditionArea::EFireOnEnter); |
|
1660 |
|
1661 CleanupStack::Pop( circle ); |
|
1662 |
|
1663 trig->SetCondition(condition); // ownership transferred to object |
|
1664 |
|
1665 TLbtTriggerId trigId; |
|
1666 |
|
1667 |
|
1668 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate); |
|
1669 CleanupStack::PushL( notifier ); |
|
1670 |
|
1671 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
|
1672 |
|
1673 notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); |
|
1674 wait->Start( ); |
|
1675 iLog->Log(_L("Trigger Created")); |
|
1676 notifier->StartNotification( wait ); |
|
1677 wait->Start( ); |
|
1678 // time_t time1,time2; |
|
1679 // Time(); |
|
1680 // notifier->StartNotification( wait ); |
|
1681 // wait->Start( ); |
|
1682 |
|
1683 // notifier->StartNotification( wait ); |
|
1684 wait->Start( ); |
|
1685 notifier->iWaitStatus = KRequestPending; |
|
1686 |
|
1687 // notifier->StartNotification( wait ); |
|
1688 notifier->After(1000000); |
|
1689 wait->Start( ); |
|
1690 |
|
1691 iLog->Log(_L("Trigger Fired")); |
|
1692 TLbtTriggerFireInfo FireInfo; |
|
1693 TReal32 trigDistance; |
|
1694 TPosition firePosition; |
|
1695 FireInfo = notifier->GetFiredTrigger(); |
|
1696 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
|
1697 firePosition.Distance(coordinate,trigDistance); |
|
1698 iPositioner.Close(); |
|
1699 iLocationServer.Close(); |
|
1700 lbt.DeleteTriggerL(trigId); |
|
1701 if(notifier->iTriggerFireCount ==2) |
|
1702 { |
|
1703 CleanupStack::PopAndDestroy( notifier ); |
|
1704 CleanupStack::PopAndDestroy( trig ); |
|
1705 CleanupStack::Pop( &lbt ); |
|
1706 CleanupStack::PopAndDestroy( &lbtserver ); |
|
1707 delete wait; |
|
1708 |
|
1709 return KErrNone; |
|
1710 } |
|
1711 else |
|
1712 { |
|
1713 CleanupStack::PopAndDestroy( notifier ); |
|
1714 CleanupStack::PopAndDestroy( trig ); |
|
1715 CleanupStack::Pop( &lbt ); |
|
1716 CleanupStack::PopAndDestroy( &lbtserver ); |
|
1717 delete wait; |
|
1718 |
|
1719 return -99; |
|
1720 } |
|
1721 } |
|
1722 |
|
1723 //Testing the hysteresis condition for exit type of trigger |
|
1724 |
|
1725 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW015_testL( CStifItemParser& /* aItem */ ) |
|
1726 { |
|
1727 |
|
1728 _LIT( KSimulationFile,"c:\\system\\data\\test2.nme" ); |
|
1729 |
|
1730 RLbtServer lbtserver; |
|
1731 RLbt lbt; |
|
1732 RPositionServer iLocationServer; |
|
1733 RPositioner iPositioner; |
|
1734 |
|
1735 // Connect to the location server |
|
1736 User::LeaveIfError(iLocationServer.Connect()); |
|
1737 |
|
1738 // Open the positioner |
|
1739 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
|
1740 |
|
1741 |
|
1742 User::LeaveIfError( lbtserver.Connect() ); |
|
1743 CleanupClosePushL( lbtserver ); |
|
1744 iLog->Log(_L("Connection to RLbtServer Passed ")); |
|
1745 User::LeaveIfError( lbt.Open( lbtserver ) ); |
|
1746 iLog->Log(_L("Subsession opened ")); |
|
1747 CleanupClosePushL( lbt ); |
|
1748 |
|
1749 //Delete all the existing trggers |
|
1750 TRAP_IGNORE(lbt.DeleteTriggersL()); |
|
1751 |
|
1752 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
|
1753 iLog->Log(_L("Simulation PSY Repository object created")); |
|
1754 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
|
1755 iLog->Log(_L("Simulation input file set ")); |
|
1756 CleanupStack::PopAndDestroy(repository); |
|
1757 |
|
1758 //Construct a session trigger |
|
1759 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
|
1760 |
|
1761 //Push to cleanup stack |
|
1762 CleanupStack::PushL( trig ); |
|
1763 iLog->Log(_L("Startup Trigger Entry Created ")); |
|
1764 |
|
1765 // Set Name |
|
1766 trig->SetNameL(_L("Trigger1")); |
|
1767 // _LIT( KMyTriggerHandlingProcessName, "About.exe"); |
|
1768 _LIT( KMyTriggerHandlingProcessName, "ConsoleUI.exe"); |
|
1769 |
|
1770 TSecureId secureid; |
|
1771 trig->SetProcessId(KMyTriggerHandlingProcessName,secureid); |
|
1772 //Set Requestor |
|
1773 CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; |
|
1774 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
|
1775 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
|
1776 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
|
1777 // set condition |
|
1778 |
|
1779 TCoordinate coordinate(65.5285,23.9385); |
|
1780 // TCoordinate coordinate(62.4438,23.9385); |
|
1781 |
|
1782 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
|
1783 CleanupStack::PushL( circle ); |
|
1784 |
|
1785 |
|
1786 // ownership of circle object transferred to the condition object |
|
1787 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
|
1788 circle, |
|
1789 CLbtTriggerConditionArea::EFireOnExit); |
|
1790 |
|
1791 CleanupStack::Pop( circle ); |
|
1792 |
|
1793 trig->SetCondition(condition); // ownership transferred to object |
|
1794 |
|
1795 TLbtTriggerId trigId; |
|
1796 |
|
1797 |
|
1798 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate); |
|
1799 CleanupStack::PushL( notifier ); |
|
1800 |
|
1801 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
|
1802 |
|
1803 notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); |
|
1804 wait->Start( ); |
|
1805 iLog->Log(_L("Trigger Created")); |
|
1806 notifier->StartNotification( wait ); |
|
1807 wait->Start( ); |
|
1808 // notifier->StartNotification( wait ); |
|
1809 wait->Start( ); |
|
1810 // notifier->StartNotification( wait ); |
|
1811 // wait->Start( ); |
|
1812 notifier->iWaitStatus = KRequestPending; |
|
1813 |
|
1814 // notifier->StartNotification( wait ); |
|
1815 notifier->After(15000000); |
|
1816 wait->Start( ); |
|
1817 iLog->Log(_L("Trigger Fired")); |
|
1818 TLbtTriggerFireInfo FireInfo; |
|
1819 TReal32 trigDistance; |
|
1820 TPosition firePosition; |
|
1821 FireInfo = notifier->GetFiredTrigger(); |
|
1822 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
|
1823 firePosition.Distance(coordinate,trigDistance); |
|
1824 iPositioner.Close(); |
|
1825 iLocationServer.Close(); |
|
1826 lbt.DeleteTriggerL(trigId); |
|
1827 if( notifier->iTriggerFireCount ==2) |
|
1828 { |
|
1829 CleanupStack::PopAndDestroy( notifier ); |
|
1830 CleanupStack::PopAndDestroy( trig ); |
|
1831 CleanupStack::Pop( &lbt ); |
|
1832 CleanupStack::PopAndDestroy( &lbtserver ); |
|
1833 delete wait; |
|
1834 |
|
1835 return KErrNone; |
|
1836 } |
|
1837 else |
|
1838 { |
|
1839 CleanupStack::PopAndDestroy( notifier ); |
|
1840 CleanupStack::PopAndDestroy( trig ); |
|
1841 CleanupStack::Pop( &lbt ); |
|
1842 CleanupStack::PopAndDestroy( &lbtserver ); |
|
1843 delete wait; |
|
1844 |
|
1845 return -99; |
|
1846 } |
|
1847 } |
|
1848 |
|
1849 |
|
1850 //Registering for trigger fire notification after trigger fires multiple times |
|
1851 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW016_testL( CStifItemParser& /* aItem */ ) |
|
1852 { |
|
1853 |
|
1854 _LIT( KSimulationFile,"c:\\system\\data\\test3.nme" ); |
|
1855 |
|
1856 RLbtServer lbtserver; |
|
1857 RLbt lbt; |
|
1858 RPositionServer iLocationServer; |
|
1859 RPositioner iPositioner; |
|
1860 |
|
1861 // Connect to the location server |
|
1862 User::LeaveIfError(iLocationServer.Connect()); |
|
1863 |
|
1864 // Open the positioner |
|
1865 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
|
1866 |
|
1867 |
|
1868 User::LeaveIfError( lbtserver.Connect() ); |
|
1869 CleanupClosePushL( lbtserver ); |
|
1870 iLog->Log(_L("Connection to RLbtServer Passed ")); |
|
1871 User::LeaveIfError( lbt.Open( lbtserver ) ); |
|
1872 iLog->Log(_L("Subsession opened ")); |
|
1873 CleanupClosePushL( lbt ); |
|
1874 |
|
1875 //Delete all the existing trggers |
|
1876 TRAP_IGNORE(lbt.DeleteTriggersL()); |
|
1877 |
|
1878 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
|
1879 iLog->Log(_L("Simulation PSY Repository object created")); |
|
1880 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
|
1881 iLog->Log(_L("Simulation input file set ")); |
|
1882 CleanupStack::PopAndDestroy(repository); |
|
1883 |
|
1884 //Construct a session trigger |
|
1885 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
|
1886 |
|
1887 //Push to cleanup stack |
|
1888 CleanupStack::PushL( trig ); |
|
1889 iLog->Log(_L("Startup Trigger Entry Created ")); |
|
1890 |
|
1891 // Set Name |
|
1892 trig->SetNameL(_L("Trigger1")); |
|
1893 // _LIT( KMyTriggerHandlingProcessName, "About.exe"); |
|
1894 _LIT( KMyTriggerHandlingProcessName, "ConsoleUI.exe"); |
|
1895 |
|
1896 TSecureId secureid; |
|
1897 trig->SetProcessId(KMyTriggerHandlingProcessName,secureid); |
|
1898 //Set Requestor |
|
1899 CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; |
|
1900 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
|
1901 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
|
1902 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
|
1903 // set condition |
|
1904 |
|
1905 TCoordinate coordinate(62.5285,23.9385); |
|
1906 // TCoordinate coordinate(62.4438,23.9385); |
|
1907 |
|
1908 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
|
1909 CleanupStack::PushL( circle ); |
|
1910 |
|
1911 |
|
1912 // ownership of circle object transferred to the condition object |
|
1913 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
|
1914 circle, |
|
1915 CLbtTriggerConditionArea::EFireOnEnter); |
|
1916 |
|
1917 CleanupStack::Pop( circle ); |
|
1918 |
|
1919 trig->SetCondition(condition); // ownership transferred to object |
|
1920 |
|
1921 TLbtTriggerId trigId; |
|
1922 |
|
1923 |
|
1924 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate); |
|
1925 CleanupStack::PushL( notifier ); |
|
1926 |
|
1927 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
|
1928 |
|
1929 notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); |
|
1930 wait->Start( ); |
|
1931 iLog->Log(_L("Trigger Created")); |
|
1932 notifier->After(50000000); |
|
1933 notifier->StartNotification(wait); |
|
1934 wait->Start( ); |
|
1935 iLog->Log(_L("Trigger Fired")); |
|
1936 TLbtTriggerFireInfo FireInfo; |
|
1937 TReal32 trigDistance; |
|
1938 TPosition firePosition; |
|
1939 FireInfo = notifier->GetFiredTrigger(); |
|
1940 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
|
1941 firePosition.Distance(coordinate,trigDistance); |
|
1942 iPositioner.Close(); |
|
1943 iLocationServer.Close(); |
|
1944 |
|
1945 CleanupStack::PopAndDestroy( notifier ); |
|
1946 CleanupStack::PopAndDestroy( trig ); |
|
1947 CleanupStack::Pop( &lbt ); |
|
1948 CleanupStack::PopAndDestroy( &lbtserver ); |
|
1949 delete wait; |
|
1950 |
|
1951 return KErrNone; |
|
1952 |
|
1953 } |
|
1954 |
|
1955 |
|
1956 //Firing of startup trigger when trigger handling process not found in the system |
|
1957 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW017_testL( CStifItemParser& /* aItem */ ) |
|
1958 { |
|
1959 |
|
1960 _LIT( KSimulationFile,"c:\\system\\data\\simu_move1.sps" ); |
|
1961 |
|
1962 RLbtServer lbtserver; |
|
1963 RLbt lbt; |
|
1964 |
|
1965 RPositionServer iLocationServer; |
|
1966 RPositioner iPositioner; |
|
1967 |
|
1968 // Connect to the location server |
|
1969 User::LeaveIfError(iLocationServer.Connect()); |
|
1970 |
|
1971 // Open the positioner |
|
1972 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
|
1973 |
|
1974 User::LeaveIfError( lbtserver.Connect() ); |
|
1975 CleanupClosePushL( lbtserver ); |
|
1976 iLog->Log(_L("Connection to RLbtServer Passed ")); |
|
1977 User::LeaveIfError( lbt.Open( lbtserver ) ); |
|
1978 iLog->Log(_L("Subsession opened ")); |
|
1979 CleanupClosePushL( lbt ); |
|
1980 |
1767 |
1981 //Delete all the existing trggers |
1768 //Delete all the existing trggers |
1982 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1769 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1983 |
1770 |
1984 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1771 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
2006 TSecureId secureid; |
1793 TSecureId secureid; |
2007 trig->SetProcessId(KMyTriggerHandlingProcessName,secureid); |
1794 trig->SetProcessId(KMyTriggerHandlingProcessName,secureid); |
2008 |
1795 |
2009 // set condition |
1796 // set condition |
2010 |
1797 |
2011 TCoordinate coordinate(62.5285,23.9385); |
1798 TCoordinate coordinate; |
2012 // TCoordinate coordinate(62.4438,23.9385); |
1799 GetCurrentCoordinateL( coordinate ); |
2013 |
1800 |
2014 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1801 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
2015 CleanupStack::PushL( circle ); |
1802 CleanupStack::PushL( circle ); |
2016 |
1803 |
2017 |
1804 |
2044 FireInfo = notifier->GetFiredTrigger(); |
1831 FireInfo = notifier->GetFiredTrigger(); |
2045 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
1832 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
2046 firePosition.Distance(coordinate,trigDistance); |
1833 firePosition.Distance(coordinate,trigDistance); |
2047 iPositioner.Close(); |
1834 iPositioner.Close(); |
2048 iLocationServer.Close(); |
1835 iLocationServer.Close(); |
2049 |
1836 RestoreProfileL(); |
2050 CleanupStack::PopAndDestroy( notifier ); |
1837 CleanupStack::PopAndDestroy( notifier ); |
2051 CleanupStack::PopAndDestroy( trig ); |
1838 CleanupStack::PopAndDestroy( trig ); |
2052 CleanupStack::Pop( &lbt ); |
1839 CleanupStack::Pop( &lbt ); |
2053 CleanupStack::PopAndDestroy( &lbtserver ); |
1840 CleanupStack::PopAndDestroy( &lbtserver ); |
2054 delete wait; |
1841 delete wait; |
2058 } |
1845 } |
2059 |
1846 |
2060 |
1847 |
2061 //Firing of multiple Entry type startup triggers |
1848 //Firing of multiple Entry type startup triggers |
2062 |
1849 |
2063 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW018_testL( CStifItemParser& /* aItem */ ) |
1850 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW015_testL( CStifItemParser& /* aItem */ ) |
2064 { |
1851 { |
2065 |
1852 |
2066 _LIT( KSimulationFile,"c:\\system\\data\\simu_move1.sps" ); |
1853 _LIT( KSimulationFile,"c:\\system\\data\\simu_move1.sps" ); |
2067 |
1854 |
2068 RLbtServer lbtserver; |
1855 RLbtServer lbtserver; |
2072 CleanupClosePushL( lbtserver ); |
1859 CleanupClosePushL( lbtserver ); |
2073 iLog->Log(_L("Connection to RLbtServer Passed ")); |
1860 iLog->Log(_L("Connection to RLbtServer Passed ")); |
2074 User::LeaveIfError( lbt.Open( lbtserver ) ); |
1861 User::LeaveIfError( lbt.Open( lbtserver ) ); |
2075 iLog->Log(_L("Subsession opened ")); |
1862 iLog->Log(_L("Subsession opened ")); |
2076 CleanupClosePushL( lbt ); |
1863 CleanupClosePushL( lbt ); |
1864 |
|
1865 // Set profile to offline mode.This is required to avoid movement detection blocking the |
|
1866 // trigger firing. |
|
1867 SetProfileToOfflineL(); |
|
1868 // Enable simulation psy |
|
1869 EnableSimPSYL(); |
|
2077 |
1870 |
2078 //Delete all the existing trggers |
1871 //Delete all the existing trggers |
2079 TRAP_IGNORE(lbt.DeleteTriggersL()); |
1872 TRAP_IGNORE(lbt.DeleteTriggersL()); |
2080 |
1873 |
2081 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
1874 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
2109 trig1->SetRequestorL(ReqType,ReqFormat,ReqData); |
1902 trig1->SetRequestorL(ReqType,ReqFormat,ReqData); |
2110 |
1903 |
2111 trig2->SetRequestorL(ReqType,ReqFormat,ReqData); |
1904 trig2->SetRequestorL(ReqType,ReqFormat,ReqData); |
2112 // set condition |
1905 // set condition |
2113 |
1906 |
2114 TCoordinate coordinate(62.5285,23.9385); |
1907 TCoordinate coordinate; |
2115 // TCoordinate coordinate(62.4438,23.9385); |
1908 GetCurrentCoordinateL( coordinate ); |
2116 |
1909 |
2117 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
1910 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
2118 CleanupStack::PushL( circle ); |
1911 CleanupStack::PushL( circle ); |
2119 |
1912 |
2120 |
1913 |
2141 wait->Start( ); |
1934 wait->Start( ); |
2142 iLog->Log(_L("Trigger Created")); |
1935 iLog->Log(_L("Trigger Created")); |
2143 notifier->StartNotification( wait ); |
1936 notifier->StartNotification( wait ); |
2144 wait->Start( ); |
1937 wait->Start( ); |
2145 iLog->Log(_L("Triggers Fired")); |
1938 iLog->Log(_L("Triggers Fired")); |
1939 wait->Start( ); |
|
1940 iLog->Log(_L("Triggers Fired")); |
|
2146 TLbtTriggerFireInfo FireInfo; |
1941 TLbtTriggerFireInfo FireInfo; |
2147 TReal32 trigDistance; |
1942 TReal32 trigDistance; |
2148 TPosition firePosition; |
1943 TPosition firePosition; |
2149 FireInfo = notifier->GetFiredTrigger(); |
1944 FireInfo = notifier->GetFiredTrigger(); |
2150 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
1945 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
2151 firePosition.Distance(coordinate,trigDistance); |
1946 firePosition.Distance(coordinate,trigDistance); |
2152 |
1947 RestoreProfileL(); |
2153 CleanupStack::PopAndDestroy( notifier ); |
1948 CleanupStack::PopAndDestroy( notifier ); |
2154 CleanupStack::PopAndDestroy( trig2); |
1949 CleanupStack::PopAndDestroy( trig2); |
2155 CleanupStack::Pop( trig1 ); |
1950 CleanupStack::Pop( trig1 ); |
2156 CleanupStack::PopAndDestroy( &lbt ); |
1951 CleanupStack::PopAndDestroy( &lbt ); |
2157 CleanupStack::PopAndDestroy( &lbtserver ); |
1952 CleanupStack::PopAndDestroy( &lbtserver ); |
2160 return KErrNone; |
1955 return KErrNone; |
2161 |
1956 |
2162 |
1957 |
2163 } |
1958 } |
2164 |
1959 |
1960 |
|
1961 // Testing the hysteresis condition for entry type of trigger |
|
1962 |
|
1963 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW016_testL( CStifItemParser& /* aItem */ ) |
|
1964 { |
|
1965 |
|
1966 _LIT( KSimulationFile,"c:\\system\\data\\test1.nme" ); |
|
1967 |
|
1968 RLbtServer lbtserver; |
|
1969 RLbt lbt; |
|
1970 RPositionServer iLocationServer; |
|
1971 RPositioner iPositioner; |
|
1972 |
|
1973 // Connect to the location server |
|
1974 User::LeaveIfError(iLocationServer.Connect()); |
|
1975 |
|
1976 // Open the positioner |
|
1977 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
|
1978 |
|
1979 |
|
1980 User::LeaveIfError( lbtserver.Connect() ); |
|
1981 CleanupClosePushL( lbtserver ); |
|
1982 iLog->Log(_L("Connection to RLbtServer Passed ")); |
|
1983 User::LeaveIfError( lbt.Open( lbtserver ) ); |
|
1984 iLog->Log(_L("Subsession opened ")); |
|
1985 CleanupClosePushL( lbt ); |
|
1986 |
|
1987 //Delete all the existing trggers |
|
1988 TRAP_IGNORE(lbt.DeleteTriggersL()); |
|
1989 |
|
1990 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
|
1991 iLog->Log(_L("Simulation PSY Repository object created")); |
|
1992 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
|
1993 iLog->Log(_L("Simulation input file set ")); |
|
1994 CleanupStack::PopAndDestroy(repository); |
|
1995 |
|
1996 //Construct a session trigger |
|
1997 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
|
1998 |
|
1999 //Push to cleanup stack |
|
2000 CleanupStack::PushL( trig ); |
|
2001 iLog->Log(_L("Startup Trigger Entry Created ")); |
|
2002 |
|
2003 // Set Name |
|
2004 trig->SetNameL(_L("Trigger1")); |
|
2005 // _LIT( KMyTriggerHandlingProcessName, "About.exe"); |
|
2006 _LIT( KMyTriggerHandlingProcessName, "ConsoleUI.exe"); |
|
2007 |
|
2008 TSecureId secureid; |
|
2009 trig->SetProcessId(KMyTriggerHandlingProcessName,secureid); |
|
2010 //Set Requestor |
|
2011 CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; |
|
2012 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
|
2013 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
|
2014 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
|
2015 // set condition |
|
2016 |
|
2017 TCoordinate coordinate(65.5285,23.9385); |
|
2018 // TCoordinate coordinate(62.4438,23.9385); |
|
2019 |
|
2020 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
|
2021 CleanupStack::PushL( circle ); |
|
2022 |
|
2023 |
|
2024 // ownership of circle object transferred to the condition object |
|
2025 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
|
2026 circle, |
|
2027 CLbtTriggerConditionArea::EFireOnEnter); |
|
2028 |
|
2029 CleanupStack::Pop( circle ); |
|
2030 |
|
2031 trig->SetCondition(condition); // ownership transferred to object |
|
2032 |
|
2033 TLbtTriggerId trigId; |
|
2034 |
|
2035 |
|
2036 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate); |
|
2037 CleanupStack::PushL( notifier ); |
|
2038 |
|
2039 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
|
2040 |
|
2041 notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); |
|
2042 wait->Start( ); |
|
2043 iLog->Log(_L("Trigger Created")); |
|
2044 notifier->StartNotification( wait ); |
|
2045 wait->Start( ); |
|
2046 // time_t time1,time2; |
|
2047 // Time(); |
|
2048 // notifier->StartNotification( wait ); |
|
2049 // wait->Start( ); |
|
2050 |
|
2051 // notifier->StartNotification( wait ); |
|
2052 wait->Start( ); |
|
2053 notifier->iWaitStatus = KRequestPending; |
|
2054 |
|
2055 // notifier->StartNotification( wait ); |
|
2056 notifier->After(1000000); |
|
2057 wait->Start( ); |
|
2058 |
|
2059 iLog->Log(_L("Trigger Fired")); |
|
2060 TLbtTriggerFireInfo FireInfo; |
|
2061 TReal32 trigDistance; |
|
2062 TPosition firePosition; |
|
2063 FireInfo = notifier->GetFiredTrigger(); |
|
2064 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
|
2065 firePosition.Distance(coordinate,trigDistance); |
|
2066 iPositioner.Close(); |
|
2067 iLocationServer.Close(); |
|
2068 lbt.DeleteTriggerL(trigId); |
|
2069 if(notifier->iTriggerFireCount ==2) |
|
2070 { |
|
2071 CleanupStack::PopAndDestroy( notifier ); |
|
2072 CleanupStack::PopAndDestroy( trig ); |
|
2073 CleanupStack::Pop( &lbt ); |
|
2074 CleanupStack::PopAndDestroy( &lbtserver ); |
|
2075 delete wait; |
|
2076 |
|
2077 return KErrNone; |
|
2078 } |
|
2079 else |
|
2080 { |
|
2081 CleanupStack::PopAndDestroy( notifier ); |
|
2082 CleanupStack::PopAndDestroy( trig ); |
|
2083 CleanupStack::Pop( &lbt ); |
|
2084 CleanupStack::PopAndDestroy( &lbtserver ); |
|
2085 delete wait; |
|
2086 |
|
2087 return -99; |
|
2088 } |
|
2089 } |
|
2090 |
|
2091 //Testing the hysteresis condition for exit type of trigger |
|
2092 |
|
2093 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW017_testL( CStifItemParser& /* aItem */ ) |
|
2094 { |
|
2095 |
|
2096 _LIT( KSimulationFile,"c:\\system\\data\\test2.nme" ); |
|
2097 |
|
2098 RLbtServer lbtserver; |
|
2099 RLbt lbt; |
|
2100 RPositionServer iLocationServer; |
|
2101 RPositioner iPositioner; |
|
2102 |
|
2103 // Connect to the location server |
|
2104 User::LeaveIfError(iLocationServer.Connect()); |
|
2105 |
|
2106 // Open the positioner |
|
2107 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
|
2108 |
|
2109 |
|
2110 User::LeaveIfError( lbtserver.Connect() ); |
|
2111 CleanupClosePushL( lbtserver ); |
|
2112 iLog->Log(_L("Connection to RLbtServer Passed ")); |
|
2113 User::LeaveIfError( lbt.Open( lbtserver ) ); |
|
2114 iLog->Log(_L("Subsession opened ")); |
|
2115 CleanupClosePushL( lbt ); |
|
2116 |
|
2117 //Delete all the existing trggers |
|
2118 TRAP_IGNORE(lbt.DeleteTriggersL()); |
|
2119 |
|
2120 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
|
2121 iLog->Log(_L("Simulation PSY Repository object created")); |
|
2122 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
|
2123 iLog->Log(_L("Simulation input file set ")); |
|
2124 CleanupStack::PopAndDestroy(repository); |
|
2125 |
|
2126 //Construct a session trigger |
|
2127 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
|
2128 |
|
2129 //Push to cleanup stack |
|
2130 CleanupStack::PushL( trig ); |
|
2131 iLog->Log(_L("Startup Trigger Entry Created ")); |
|
2132 |
|
2133 // Set Name |
|
2134 trig->SetNameL(_L("Trigger1")); |
|
2135 // _LIT( KMyTriggerHandlingProcessName, "About.exe"); |
|
2136 _LIT( KMyTriggerHandlingProcessName, "ConsoleUI.exe"); |
|
2137 |
|
2138 TSecureId secureid; |
|
2139 trig->SetProcessId(KMyTriggerHandlingProcessName,secureid); |
|
2140 //Set Requestor |
|
2141 CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; |
|
2142 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
|
2143 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
|
2144 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
|
2145 // set condition |
|
2146 |
|
2147 TCoordinate coordinate(65.5285,23.9385); |
|
2148 // TCoordinate coordinate(62.4438,23.9385); |
|
2149 |
|
2150 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
|
2151 CleanupStack::PushL( circle ); |
|
2152 |
|
2153 |
|
2154 // ownership of circle object transferred to the condition object |
|
2155 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
|
2156 circle, |
|
2157 CLbtTriggerConditionArea::EFireOnExit); |
|
2158 |
|
2159 CleanupStack::Pop( circle ); |
|
2160 |
|
2161 trig->SetCondition(condition); // ownership transferred to object |
|
2162 |
|
2163 TLbtTriggerId trigId; |
|
2164 |
|
2165 |
|
2166 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate); |
|
2167 CleanupStack::PushL( notifier ); |
|
2168 |
|
2169 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
|
2170 |
|
2171 notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); |
|
2172 wait->Start( ); |
|
2173 iLog->Log(_L("Trigger Created")); |
|
2174 notifier->StartNotification( wait ); |
|
2175 wait->Start( ); |
|
2176 // notifier->StartNotification( wait ); |
|
2177 wait->Start( ); |
|
2178 // notifier->StartNotification( wait ); |
|
2179 // wait->Start( ); |
|
2180 notifier->iWaitStatus = KRequestPending; |
|
2181 |
|
2182 // notifier->StartNotification( wait ); |
|
2183 notifier->After(15000000); |
|
2184 wait->Start( ); |
|
2185 iLog->Log(_L("Trigger Fired")); |
|
2186 TLbtTriggerFireInfo FireInfo; |
|
2187 TReal32 trigDistance; |
|
2188 TPosition firePosition; |
|
2189 FireInfo = notifier->GetFiredTrigger(); |
|
2190 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
|
2191 firePosition.Distance(coordinate,trigDistance); |
|
2192 iPositioner.Close(); |
|
2193 iLocationServer.Close(); |
|
2194 lbt.DeleteTriggerL(trigId); |
|
2195 if( notifier->iTriggerFireCount ==2) |
|
2196 { |
|
2197 CleanupStack::PopAndDestroy( notifier ); |
|
2198 CleanupStack::PopAndDestroy( trig ); |
|
2199 CleanupStack::Pop( &lbt ); |
|
2200 CleanupStack::PopAndDestroy( &lbtserver ); |
|
2201 delete wait; |
|
2202 |
|
2203 return KErrNone; |
|
2204 } |
|
2205 else |
|
2206 { |
|
2207 CleanupStack::PopAndDestroy( notifier ); |
|
2208 CleanupStack::PopAndDestroy( trig ); |
|
2209 CleanupStack::Pop( &lbt ); |
|
2210 CleanupStack::PopAndDestroy( &lbtserver ); |
|
2211 delete wait; |
|
2212 |
|
2213 return -99; |
|
2214 } |
|
2215 } |
|
2216 |
|
2217 |
|
2218 //Registering for trigger fire notification after trigger fires multiple times |
|
2219 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW018_testL( CStifItemParser& /* aItem */ ) |
|
2220 { |
|
2221 |
|
2222 _LIT( KSimulationFile,"c:\\system\\data\\test3.nme" ); |
|
2223 |
|
2224 RLbtServer lbtserver; |
|
2225 RLbt lbt; |
|
2226 RPositionServer iLocationServer; |
|
2227 RPositioner iPositioner; |
|
2228 |
|
2229 // Connect to the location server |
|
2230 User::LeaveIfError(iLocationServer.Connect()); |
|
2231 |
|
2232 // Open the positioner |
|
2233 User::LeaveIfError(iPositioner.Open(iLocationServer));//,KPosSimulationPsyImplUid)); |
|
2234 |
|
2235 |
|
2236 User::LeaveIfError( lbtserver.Connect() ); |
|
2237 CleanupClosePushL( lbtserver ); |
|
2238 iLog->Log(_L("Connection to RLbtServer Passed ")); |
|
2239 User::LeaveIfError( lbt.Open( lbtserver ) ); |
|
2240 iLog->Log(_L("Subsession opened ")); |
|
2241 CleanupClosePushL( lbt ); |
|
2242 |
|
2243 //Delete all the existing trggers |
|
2244 TRAP_IGNORE(lbt.DeleteTriggersL()); |
|
2245 |
|
2246 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
|
2247 iLog->Log(_L("Simulation PSY Repository object created")); |
|
2248 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
|
2249 iLog->Log(_L("Simulation input file set ")); |
|
2250 CleanupStack::PopAndDestroy(repository); |
|
2251 |
|
2252 //Construct a session trigger |
|
2253 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
|
2254 |
|
2255 //Push to cleanup stack |
|
2256 CleanupStack::PushL( trig ); |
|
2257 iLog->Log(_L("Startup Trigger Entry Created ")); |
|
2258 |
|
2259 // Set Name |
|
2260 trig->SetNameL(_L("Trigger1")); |
|
2261 // _LIT( KMyTriggerHandlingProcessName, "About.exe"); |
|
2262 _LIT( KMyTriggerHandlingProcessName, "ConsoleUI.exe"); |
|
2263 |
|
2264 TSecureId secureid; |
|
2265 trig->SetProcessId(KMyTriggerHandlingProcessName,secureid); |
|
2266 //Set Requestor |
|
2267 CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; |
|
2268 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
|
2269 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
|
2270 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
|
2271 // set condition |
|
2272 |
|
2273 TCoordinate coordinate(62.5285,23.9385); |
|
2274 // TCoordinate coordinate(62.4438,23.9385); |
|
2275 |
|
2276 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
|
2277 CleanupStack::PushL( circle ); |
|
2278 |
|
2279 |
|
2280 // ownership of circle object transferred to the condition object |
|
2281 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
|
2282 circle, |
|
2283 CLbtTriggerConditionArea::EFireOnEnter); |
|
2284 |
|
2285 CleanupStack::Pop( circle ); |
|
2286 |
|
2287 trig->SetCondition(condition); // ownership transferred to object |
|
2288 |
|
2289 TLbtTriggerId trigId; |
|
2290 |
|
2291 |
|
2292 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate); |
|
2293 CleanupStack::PushL( notifier ); |
|
2294 |
|
2295 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
|
2296 |
|
2297 notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); |
|
2298 wait->Start( ); |
|
2299 iLog->Log(_L("Trigger Created")); |
|
2300 notifier->After(50000000); |
|
2301 notifier->StartNotification(wait); |
|
2302 wait->Start( ); |
|
2303 iLog->Log(_L("Trigger Fired")); |
|
2304 TLbtTriggerFireInfo FireInfo; |
|
2305 TReal32 trigDistance; |
|
2306 TPosition firePosition; |
|
2307 FireInfo = notifier->GetFiredTrigger(); |
|
2308 FireInfo.iFiredPositionInfo.GetPosition(firePosition); |
|
2309 firePosition.Distance(coordinate,trigDistance); |
|
2310 iPositioner.Close(); |
|
2311 iLocationServer.Close(); |
|
2312 |
|
2313 CleanupStack::PopAndDestroy( notifier ); |
|
2314 CleanupStack::PopAndDestroy( trig ); |
|
2315 CleanupStack::Pop( &lbt ); |
|
2316 CleanupStack::PopAndDestroy( &lbtserver ); |
|
2317 delete wait; |
|
2318 |
|
2319 return KErrNone; |
|
2320 |
|
2321 } |
|
2322 |
|
2165 |
2323 |
2166 |
2324 |
2167 //List Trigger Test cases |
2325 //List Trigger Test cases |
2168 //Retrieving all the information about single startup trigger |
2326 //Retrieving all the information about single startup trigger |
2169 |
2327 |
2182 iLog->Log(_L("After RLbt::Open ")); |
2340 iLog->Log(_L("After RLbt::Open ")); |
2183 |
2341 |
2184 /*CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
2342 /*CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
2185 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
2343 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
2186 CleanupStack::PopAndDestroy(repository);*/ |
2344 CleanupStack::PopAndDestroy(repository);*/ |
2187 |
2345 |
2188 //Construct a startup trigger |
2346 //Construct a startup trigger |
2189 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
2347 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
2190 |
2348 |
2191 //Push to cleanup stack |
2349 //Push to cleanup stack |
2192 // CleanupStack::PushL( trig ); |
2350 CleanupStack::PushL( trig ); |
2193 |
2351 |
2194 // Set Name |
2352 // Set Name |
2195 trig->SetNameL(_L("Trigger1")); |
2353 trig->SetNameL(_L("Trigger1")); |
2196 _LIT( KMyTriggerHandlingProcessName, "TrigHandlingProcess.exe" ); |
2354 _LIT( KMyTriggerHandlingProcessName, "TrigHandlingProcess.exe" ); |
2197 |
2355 |
2228 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
2386 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
2229 |
2387 |
2230 notifier->CreateTriggers( lbt,*trig,trigId,EFalse,wait ); |
2388 notifier->CreateTriggers( lbt,*trig,trigId,EFalse,wait ); |
2231 wait->Start( ); |
2389 wait->Start( ); |
2232 //User::After(5000000); |
2390 //User::After(5000000); |
2233 CLbtTriggerInfo *Triginfo = CLbtTriggerInfo::NewL(); |
2391 |
2234 iLog->Log(_L("Before GetTriggerLC ")); |
2392 iLog->Log(_L("Before GetTriggerLC ")); |
2235 |
2393 CLbtTriggerInfo *Triginfo = lbt.GetTriggerLC(trigId); |
2236 Triginfo = lbt.GetTriggerLC(trigId); |
|
2237 iLog->Log(_L("After GetTriggerLC ")); |
2394 iLog->Log(_L("After GetTriggerLC ")); |
2238 CLbtStartupTrigger *TrigEntry = static_cast <CLbtStartupTrigger*>(Triginfo->TriggerEntry()); |
2395 CLbtStartupTrigger *TrigEntry = static_cast <CLbtStartupTrigger*>(Triginfo->TriggerEntry()); |
2239 |
2396 |
2240 TLbtTriggerDynamicInfo * dyninfo = Triginfo -> DynInfo() ; |
2397 TLbtTriggerDynamicInfo * dyninfo = Triginfo -> DynInfo() ; |
2241 |
2398 |
2242 // CleanupStack::PopAndDestroy( trig ); |
2399 // CleanupStack::PopAndDestroy( trig ); |
2243 |
2400 |
2401 //Check the name of the trigger |
|
2402 TDesC Name2 =TrigEntry->Name(); |
|
2403 if(TrigEntry->Name()!=trig->Name()) |
|
2404 { |
|
2405 return -99; |
|
2406 } |
|
2407 //Check the state of the trigger |
|
2408 CLbtTriggerEntry::TLbtTriggerState State2 = TrigEntry->State() ; |
|
2409 if(State2 !=trig->State()) |
|
2410 { |
|
2411 return -99; |
|
2412 } |
|
2413 //Check type of the trigger |
|
2414 TInt Type2 = TrigEntry ->Type(); |
|
2415 if(Type2 != trig->Type()) |
|
2416 { |
|
2417 return -99; |
|
2418 } |
|
2419 //Check Condition of the trigger |
|
2420 CLbtTriggerConditionArea* Condition2 = static_cast <CLbtTriggerConditionArea*>(TrigEntry->GetCondition()); |
|
2421 CLbtTriggerConditionArea::TDirection direction; |
|
2422 direction = Condition2->Direction(); |
|
2423 if(direction!=CLbtTriggerConditionArea::EFireOnEnter) |
|
2424 { |
|
2425 return -99; |
|
2426 } |
|
2427 CLbtGeoAreaBase* area = Condition2->TriggerArea(); |
|
2428 if(area ->Type()!=CLbtGeoAreaBase::ECircle ) |
|
2429 { |
|
2430 return -99; |
|
2431 } |
|
2432 |
|
2433 CLbtGeoCircle* circle2 = static_cast <CLbtGeoCircle*>(area); |
|
2434 TCoordinate center = circle->Center(); |
|
2435 TCoordinate center2 = circle2->Center(); |
|
2436 TReal32 distance; |
|
2437 center2.Distance(center,distance); |
|
2438 if(distance!=0) |
|
2439 { |
|
2440 return -99; |
|
2441 } |
|
2442 TReal radius = circle2->Radius(); |
|
2443 if(radius != circle->Radius()) |
|
2444 { |
|
2445 return -99; |
|
2446 } |
|
2447 |
|
2448 //Check requestors |
|
2449 RRequestorStack aRequestors,aRequestors2 ; |
|
2450 TrigEntry->GetRequestorsL(aRequestors2); |
|
2451 trig->GetRequestorsL(aRequestors); |
|
2452 for(TInt i=0;i<aRequestors.Count();i++) |
|
2453 { |
|
2454 CRequestor *requestor = aRequestors[i]; |
|
2455 if(requestor->RequestorType()!=NULL) |
|
2456 { |
|
2457 return -99; |
|
2458 } |
|
2459 if(requestor->RequestorData()!=KNullDesC) |
|
2460 { |
|
2461 return -99; |
|
2462 } |
|
2463 else if(requestor->RequestorFormat()!=NULL) |
|
2464 { |
|
2465 return -99; |
|
2466 } |
|
2467 |
|
2468 } |
|
2469 aRequestors.ResetAndDestroy(); |
|
2470 aRequestors2.ResetAndDestroy(); |
|
2471 |
|
2472 //Check trigger Id |
|
2473 trigId2 = TrigEntry->Id(); |
|
2474 if(trigId !=trigId2) |
|
2475 { |
|
2476 return -99; |
|
2477 } |
|
2478 //Check ManagerUI |
|
2479 TUid Managerui2 = TrigEntry->ManagerUi(); |
|
2480 if(Managerui2!=aManagerUi) |
|
2481 { |
|
2482 return -99; |
|
2483 } |
|
2484 //Check validity |
|
2485 TLbtTriggerDynamicInfo::TLbtTriggerValidity validity; |
|
2486 validity= dyninfo -> iValidity; |
|
2487 if(validity!=TLbtTriggerDynamicInfo::EValid) |
|
2488 { |
|
2489 return -99; |
|
2490 } |
|
2491 HBufC* startupProcFile = HBufC::NewLC( KMaxFileName ); |
|
2492 TPtr aFileName = startupProcFile->Des(); |
|
2493 TSecureId aSecureId; |
|
2494 TrigEntry->GetProcessId(aFileName,aSecureId); |
|
2495 if(aFileName!=KMyTriggerHandlingProcessName) |
|
2496 { |
|
2497 return -99; |
|
2498 } |
|
2499 CleanupStack::PopAndDestroy(1 );//startupProcFile |
|
2500 //Check Activity status |
|
2501 /* TLbtTriggerDynamicInfo::TLbtTriggerActivityStatus currstatus; |
|
2502 currstatus = dyninfo -> iActivityStatus; |
|
2503 if(currstatus!=TLbtTriggerDynamicInfo::EActive) |
|
2504 { |
|
2505 return -99; |
|
2506 }*/ |
|
2507 |
|
2508 CleanupStack::PopAndDestroy(1 );//list options |
|
2509 CleanupStack::PopAndDestroy( notifier ); |
|
2510 CleanupStack::PopAndDestroy( trig ); |
|
2511 CleanupStack::PopAndDestroy( &lbt ); |
|
2512 CleanupStack::PopAndDestroy( &lbtserver ); |
|
2513 delete wait; |
|
2514 iLog->Log(_L("Test passed ")); |
|
2515 |
|
2516 return KErrNone; |
|
2517 |
|
2518 } |
|
2519 |
|
2520 //Retrieving all the information about single session trigger |
|
2521 |
|
2522 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW071_testL( CStifItemParser& /* aItem */ ) |
|
2523 { |
|
2524 // _LIT( KSimulationFile,"c:\\system\\data\\simu_move2.sps" ); |
|
2525 |
|
2526 RLbtServer lbtserver; |
|
2527 RLbt lbt; |
|
2528 |
|
2529 User::LeaveIfError( lbtserver.Connect() ); |
|
2530 CleanupClosePushL( lbtserver ); |
|
2531 User::LeaveIfError( lbt.Open( lbtserver ) ); |
|
2532 CleanupClosePushL( lbt ); |
|
2533 |
|
2534 |
|
2535 //CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
|
2536 //User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
|
2537 //CleanupStack::PopAndDestroy(repository); |
|
2538 |
|
2539 //Construct a startup trigger |
|
2540 CLbtSessionTrigger* trig = CLbtSessionTrigger::NewL(); |
|
2541 |
|
2542 //Push to cleanup stack |
|
2543 CleanupStack::PushL( trig ); |
|
2544 |
|
2545 // Set Name |
|
2546 trig->SetNameL(_L("Trigger1")); |
|
2547 //Set Requestor |
|
2548 CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; |
|
2549 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
|
2550 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
|
2551 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
|
2552 // set condition |
|
2553 |
|
2554 TCoordinate coordinate(62.5285,23.9385); |
|
2555 |
|
2556 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
|
2557 CleanupStack::PushL( circle ); |
|
2558 |
|
2559 TUid aManagerUi = TUid::Uid(0x87654321); |
|
2560 // ownership of circle object transferred to the condition object |
|
2561 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
|
2562 circle, |
|
2563 CLbtTriggerConditionArea::EFireOnEnter); |
|
2564 |
|
2565 CleanupStack::Pop( circle ); |
|
2566 |
|
2567 trig->SetCondition(condition); // ownership transferred to object |
|
2568 |
|
2569 TLbtTriggerId trigId,trigId2; |
|
2570 trig->SetManagerUi(aManagerUi); |
|
2571 |
|
2572 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate ); |
|
2573 CleanupStack::PushL( notifier ); |
|
2574 |
|
2575 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
|
2576 |
|
2577 notifier->CreateTriggers( lbt,*trig,trigId,EFalse,wait ); |
|
2578 wait->Start( ); |
|
2579 User::After(5000000); |
|
2580 CLbtTriggerInfo *Triginfo = CLbtTriggerInfo::NewL(); |
|
2581 |
|
2582 // TLbtTriggerId trigId=1; |
|
2583 Triginfo = lbt.GetTriggerLC(trigId); |
|
2584 |
|
2585 CLbtTriggerEntry *TrigEntry = Triginfo->TriggerEntry(); |
|
2586 |
|
2587 TLbtTriggerDynamicInfo * dyninfo = Triginfo -> DynInfo() ; |
|
2244 //Check the name of the trigger |
2588 //Check the name of the trigger |
2245 TDesC Name2 =TrigEntry->Name(); |
2589 TDesC Name2 =TrigEntry->Name(); |
2246 if(TrigEntry->Name()!=trig->Name()) |
2590 if(TrigEntry->Name()!=trig->Name()) |
2247 { |
2591 { |
2248 return -99; |
2592 return -99; |
2325 validity= dyninfo -> iValidity; |
2669 validity= dyninfo -> iValidity; |
2326 if(validity!=TLbtTriggerDynamicInfo::EValid) |
2670 if(validity!=TLbtTriggerDynamicInfo::EValid) |
2327 { |
2671 { |
2328 return -99; |
2672 return -99; |
2329 } |
2673 } |
2330 HBufC* startupProcFile = HBufC::NewLC( KMaxFileName ); |
|
2331 TPtr aFileName = startupProcFile->Des(); |
|
2332 TSecureId aSecureId; |
|
2333 TrigEntry->GetProcessId(aFileName,aSecureId); |
|
2334 if(aFileName!=KMyTriggerHandlingProcessName) |
|
2335 { |
|
2336 return -99; |
|
2337 } |
|
2338 CleanupStack::PopAndDestroy(1 );//startupProcFile |
|
2339 //Check Activity status |
|
2340 /* TLbtTriggerDynamicInfo::TLbtTriggerActivityStatus currstatus; |
|
2341 currstatus = dyninfo -> iActivityStatus; |
|
2342 if(currstatus!=TLbtTriggerDynamicInfo::EActive) |
|
2343 { |
|
2344 return -99; |
|
2345 }*/ |
|
2346 CleanupStack::PopAndDestroy(1 );//list options |
|
2347 CleanupStack::PopAndDestroy( notifier ); |
|
2348 CleanupStack::PopAndDestroy( &lbt ); |
|
2349 CleanupStack::PopAndDestroy( &lbtserver ); |
|
2350 // delete wait; |
|
2351 iLog->Log(_L("Test passed ")); |
|
2352 return KErrNone; |
|
2353 |
|
2354 } |
|
2355 |
|
2356 //Retrieving all the information about single session trigger |
|
2357 |
|
2358 TInt CFiringofStartupTriggerAndListTrigger::TCLBTFW071_testL( CStifItemParser& /* aItem */ ) |
|
2359 { |
|
2360 // _LIT( KSimulationFile,"c:\\system\\data\\simu_move2.sps" ); |
|
2361 |
|
2362 RLbtServer lbtserver; |
|
2363 RLbt lbt; |
|
2364 |
|
2365 User::LeaveIfError( lbtserver.Connect() ); |
|
2366 CleanupClosePushL( lbtserver ); |
|
2367 User::LeaveIfError( lbt.Open( lbtserver ) ); |
|
2368 CleanupClosePushL( lbt ); |
|
2369 |
|
2370 |
|
2371 //CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
|
2372 //User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); |
|
2373 //CleanupStack::PopAndDestroy(repository); |
|
2374 |
|
2375 //Construct a startup trigger |
|
2376 CLbtSessionTrigger* trig = CLbtSessionTrigger::NewL(); |
|
2377 |
|
2378 //Push to cleanup stack |
|
2379 CleanupStack::PushL( trig ); |
|
2380 |
|
2381 // Set Name |
|
2382 trig->SetNameL(_L("Trigger1")); |
|
2383 //Set Requestor |
|
2384 CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; |
|
2385 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
|
2386 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
|
2387 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
|
2388 // set condition |
|
2389 |
|
2390 TCoordinate coordinate(62.5285,23.9385); |
|
2391 |
|
2392 CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); |
|
2393 CleanupStack::PushL( circle ); |
|
2394 |
|
2395 TUid aManagerUi = TUid::Uid(0x87654321); |
|
2396 // ownership of circle object transferred to the condition object |
|
2397 CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( |
|
2398 circle, |
|
2399 CLbtTriggerConditionArea::EFireOnEnter); |
|
2400 |
|
2401 CleanupStack::Pop( circle ); |
|
2402 |
|
2403 trig->SetCondition(condition); // ownership transferred to object |
|
2404 |
|
2405 TLbtTriggerId trigId,trigId2; |
|
2406 trig->SetManagerUi(aManagerUi); |
|
2407 |
|
2408 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate ); |
|
2409 CleanupStack::PushL( notifier ); |
|
2410 |
|
2411 CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; |
|
2412 |
|
2413 notifier->CreateTriggers( lbt,*trig,trigId,EFalse,wait ); |
|
2414 wait->Start( ); |
|
2415 User::After(5000000); |
|
2416 CLbtTriggerInfo *Triginfo = CLbtTriggerInfo::NewL(); |
|
2417 |
|
2418 // TLbtTriggerId trigId=1; |
|
2419 Triginfo = lbt.GetTriggerLC(trigId); |
|
2420 |
|
2421 CLbtTriggerEntry *TrigEntry = Triginfo->TriggerEntry(); |
|
2422 |
|
2423 TLbtTriggerDynamicInfo * dyninfo = Triginfo -> DynInfo() ; |
|
2424 //Check the name of the trigger |
|
2425 TDesC Name2 =TrigEntry->Name(); |
|
2426 if(TrigEntry->Name()!=trig->Name()) |
|
2427 { |
|
2428 return -99; |
|
2429 } |
|
2430 //Check the state of the trigger |
|
2431 CLbtTriggerEntry::TLbtTriggerState State2 = TrigEntry->State() ; |
|
2432 if(State2 !=trig->State()) |
|
2433 { |
|
2434 return -99; |
|
2435 } |
|
2436 //Check type of the trigger |
|
2437 TInt Type2 = TrigEntry ->Type(); |
|
2438 if(Type2 != trig->Type()) |
|
2439 { |
|
2440 return -99; |
|
2441 } |
|
2442 //Check Condition of the trigger |
|
2443 CLbtTriggerConditionArea* Condition2 = static_cast <CLbtTriggerConditionArea*>(TrigEntry->GetCondition()); |
|
2444 CLbtTriggerConditionArea::TDirection direction; |
|
2445 direction = Condition2->Direction(); |
|
2446 if(direction!=CLbtTriggerConditionArea::EFireOnEnter) |
|
2447 { |
|
2448 return -99; |
|
2449 } |
|
2450 CLbtGeoAreaBase* area = Condition2->TriggerArea(); |
|
2451 if(area ->Type()!=CLbtGeoAreaBase::ECircle ) |
|
2452 { |
|
2453 return -99; |
|
2454 } |
|
2455 |
|
2456 CLbtGeoCircle* circle2 = static_cast <CLbtGeoCircle*>(area); |
|
2457 TCoordinate center = circle->Center(); |
|
2458 TCoordinate center2 = circle2->Center(); |
|
2459 TReal32 distance; |
|
2460 center2.Distance(center,distance); |
|
2461 if(distance!=0) |
|
2462 { |
|
2463 return -99; |
|
2464 } |
|
2465 TReal radius = circle2->Radius(); |
|
2466 if(radius != circle->Radius()) |
|
2467 { |
|
2468 return -99; |
|
2469 } |
|
2470 //Check requestors |
|
2471 RRequestorStack aRequestors,aRequestors2 ; |
|
2472 TrigEntry->GetRequestorsL(aRequestors2); |
|
2473 trig->GetRequestorsL(aRequestors); |
|
2474 for(TInt i=0;i<aRequestors.Count();i++) |
|
2475 { |
|
2476 CRequestor *requestor = aRequestors[i]; |
|
2477 if(requestor->RequestorType()!=NULL) |
|
2478 { |
|
2479 return -99; |
|
2480 } |
|
2481 if(requestor->RequestorData()!=KNullDesC) |
|
2482 { |
|
2483 return -99; |
|
2484 } |
|
2485 else if(requestor->RequestorFormat()!=NULL) |
|
2486 { |
|
2487 return -99; |
|
2488 } |
|
2489 |
|
2490 } |
|
2491 //Check trigger Id |
|
2492 trigId2 = TrigEntry->Id(); |
|
2493 if(trigId !=trigId2) |
|
2494 { |
|
2495 return -99; |
|
2496 } |
|
2497 //Check ManagerUI |
|
2498 TUid Managerui2 = TrigEntry->ManagerUi(); |
|
2499 if(Managerui2!=aManagerUi) |
|
2500 { |
|
2501 return -99; |
|
2502 } |
|
2503 //Check validity |
|
2504 TLbtTriggerDynamicInfo::TLbtTriggerValidity validity; |
|
2505 validity= dyninfo -> iValidity; |
|
2506 if(validity!=TLbtTriggerDynamicInfo::EValid) |
|
2507 { |
|
2508 return -99; |
|
2509 } |
|
2510 //Check Activity status |
2674 //Check Activity status |
2511 /* TLbtTriggerDynamicInfo::TLbtTriggerActivityStatus currstatus; |
2675 /* TLbtTriggerDynamicInfo::TLbtTriggerActivityStatus currstatus; |
2512 currstatus = dyninfo -> iActivityStatus; |
2676 currstatus = dyninfo -> iActivityStatus; |
2513 if(currstatus!=TLbtTriggerDynamicInfo::EActive) |
2677 if(currstatus!=TLbtTriggerDynamicInfo::EActive) |
2514 { |
2678 { |
3106 CleanupClosePushL( lbt ); |
3270 CleanupClosePushL( lbt ); |
3107 CLbtTriggerInfo *Triginfo = CLbtTriggerInfo::NewL(); |
3271 CLbtTriggerInfo *Triginfo = CLbtTriggerInfo::NewL(); |
3108 _LIT( KFilename,"CreateTest.exe" ); |
3272 _LIT( KFilename,"CreateTest.exe" ); |
3109 RProcess proc; |
3273 RProcess proc; |
3110 TInt retVal =proc.Create(KFilename,KNullDesC); |
3274 TInt retVal =proc.Create(KFilename,KNullDesC); |
3275 TInt triggerId = KLbtNullTriggerId; |
|
3111 if(retVal == KErrNone) |
3276 if(retVal == KErrNone) |
3112 { |
3277 { |
3113 proc.Resume(); |
3278 proc.Resume(); |
3114 TRequestStatus status = KRequestPending; |
3279 TRequestStatus status = KRequestPending; |
3115 proc.Rendezvous(status); |
3280 proc.Rendezvous(status); |
3116 User::WaitForRequest(status); |
3281 User::WaitForRequest(status); |
3117 } |
3282 triggerId = status.Int(); |
3118 TInt triggerId=0; |
3283 } |
3119 RProperty iProperty; |
|
3120 User::LeaveIfError(iProperty.Get( |
|
3121 KPSUidTriggerIdInfo, |
|
3122 KLbttesttriggerid, |
|
3123 triggerId)); |
|
3124 |
3284 |
3125 TRAPD(error, lbt.GetTriggerLC(triggerId); CleanupStack::PopAndDestroy( );); |
3285 TRAPD(error, lbt.GetTriggerLC(triggerId); CleanupStack::PopAndDestroy( );); |
3126 CleanupStack::PopAndDestroy( &lbt ); |
3286 CleanupStack::PopAndDestroy( &lbt ); |
3127 CleanupStack::PopAndDestroy( &lbtserver ); |
3287 CleanupStack::PopAndDestroy( &lbtserver ); |
3128 if(error==KErrNotFound) |
3288 if(error==KErrNotFound) |
3154 User::LeaveIfError( lbt.Open( lbtserver ) ); |
3314 User::LeaveIfError( lbt.Open( lbtserver ) ); |
3155 CleanupClosePushL( lbt ); |
3315 CleanupClosePushL( lbt ); |
3156 lbt.DeleteTriggersL(); |
3316 lbt.DeleteTriggersL(); |
3157 iLog->Log(_L("Before Create Trigger")); |
3317 iLog->Log(_L("Before Create Trigger")); |
3158 _LIT( KFilename,"CreateTest.exe" ); |
3318 _LIT( KFilename,"CreateTest.exe" ); |
3159 RProcess proc; |
3319 RProcess proc; |
3160 TInt retVal =proc.Create(KFilename,KNullDesC); |
3320 TInt retVal =proc.Create(KFilename,KNullDesC); |
3161 if(retVal == KErrNone) |
3321 TInt triggerId = KLbtNullTriggerId; |
3162 { |
3322 if(retVal == KErrNone) |
3163 proc.Resume(); |
3323 { |
3164 TRequestStatus status = KRequestPending; |
3324 proc.Resume(); |
3165 proc.Rendezvous(status); |
3325 TRequestStatus status = KRequestPending; |
3166 User::WaitForRequest(status); |
3326 proc.Rendezvous(status); |
3167 } |
3327 User::WaitForRequest(status); |
3168 iLog->Log(_L("Trigger Created")); |
3328 triggerId = status.Int(); |
3169 TInt triggerId=0; |
3329 } |
3170 RProperty iProperty; |
3330 //create another trigger |
3171 User::LeaveIfError(iProperty.Get( |
|
3172 KPSUidTriggerIdInfo, |
|
3173 KLbttesttriggerid, |
|
3174 triggerId)); |
|
3175 //create another trigger |
|
3176 //Construct a startup trigger |
3331 //Construct a startup trigger |
3177 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
3332 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
3178 |
3333 |
3179 //Push to cleanup stack |
3334 //Push to cleanup stack |
3180 // CleanupStack::PushL( trig ); |
3335 // CleanupStack::PushL( trig ); |
4169 CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; |
4324 CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; |
4170 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
4325 CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; |
4171 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
4326 TBuf<KLbtMaxNameLength> ReqData=_L(""); |
4172 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
4327 trig->SetRequestorL(ReqType,ReqFormat,ReqData); |
4173 _LIT( KFilename,"CreateTest.exe" ); |
4328 _LIT( KFilename,"CreateTest.exe" ); |
4329 |
|
4174 RProcess proc; |
4330 RProcess proc; |
4175 TInt retVal =proc.Create(KFilename,KNullDesC); |
4331 TInt retVal =proc.Create(KFilename,KNullDesC); |
4332 TInt triggerId = KLbtNullTriggerId; |
|
4176 if(retVal == KErrNone) |
4333 if(retVal == KErrNone) |
4177 { |
4334 { |
4178 proc.Resume(); |
4335 proc.Resume(); |
4179 TRequestStatus status = KRequestPending; |
4336 TRequestStatus status = KRequestPending; |
4180 proc.Rendezvous(status); |
4337 proc.Rendezvous(status); |
4181 User::WaitForRequest(status); |
4338 User::WaitForRequest(status); |
4182 } |
4339 triggerId = status.Int(); |
4183 |
4340 } |
4184 TInt triggerId=0; |
4341 |
4185 RProperty iProperty; |
|
4186 User::LeaveIfError(iProperty.Get( |
|
4187 KPSUidTriggerIdInfo, |
|
4188 KLbttesttriggerid, |
|
4189 triggerId)); |
|
4190 User::After(5000000); |
|
4191 RPointerArray < CLbtTriggerInfo > trigInfoList; |
4342 RPointerArray < CLbtTriggerInfo > trigInfoList; |
4192 |
4343 |
4193 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate ); |
4344 CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate ); |
4194 CleanupStack::PushL( notifier ); |
4345 CleanupStack::PushL( notifier ); |
4195 |
4346 |
4268 CleanupClosePushL( lbt ); |
4419 CleanupClosePushL( lbt ); |
4269 TRAP_IGNORE(lbt.DeleteTriggersL()); |
4420 TRAP_IGNORE(lbt.DeleteTriggersL()); |
4270 _LIT( KFilename,"CreateTest.exe" ); |
4421 _LIT( KFilename,"CreateTest.exe" ); |
4271 RProcess proc; |
4422 RProcess proc; |
4272 TInt retVal =proc.Create(KFilename,KNullDesC); |
4423 TInt retVal =proc.Create(KFilename,KNullDesC); |
4424 TInt triggerId = KLbtNullTriggerId; |
|
4273 if(retVal == KErrNone) |
4425 if(retVal == KErrNone) |
4274 { |
4426 { |
4275 proc.Resume(); |
4427 proc.Resume(); |
4276 TRequestStatus status = KRequestPending; |
4428 TRequestStatus status = KRequestPending; |
4277 proc.Rendezvous(status); |
4429 proc.Rendezvous(status); |
4278 User::WaitForRequest(status); |
4430 User::WaitForRequest(status); |
4279 } |
4431 triggerId = status.Int(); |
4280 User::After(5000000); |
4432 } |
4281 TInt triggerId=0; |
|
4282 RProperty iProperty; |
|
4283 User::LeaveIfError(iProperty.Get( |
|
4284 KPSUidTriggerIdInfo, |
|
4285 KLbttesttriggerid, |
|
4286 triggerId)); |
|
4287 |
|
4288 //create another trigger |
4433 //create another trigger |
4289 //Construct a startup trigger |
4434 //Construct a startup trigger |
4290 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
4435 CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); |
4291 |
4436 |
4292 //Push to cleanup stack |
4437 //Push to cleanup stack |
4371 // TCoordinate coordinate(65.5285,23.9385); |
4516 // TCoordinate coordinate(65.5285,23.9385); |
4372 |
4517 |
4373 _LIT( KFilename,"CreateTest.exe" ); |
4518 _LIT( KFilename,"CreateTest.exe" ); |
4374 RProcess proc; |
4519 RProcess proc; |
4375 TInt retVal =proc.Create(KFilename,KNullDesC); |
4520 TInt retVal =proc.Create(KFilename,KNullDesC); |
4521 TInt triggerId = KLbtNullTriggerId; |
|
4376 if(retVal == KErrNone) |
4522 if(retVal == KErrNone) |
4377 { |
4523 { |
4378 proc.Resume(); |
4524 proc.Resume(); |
4379 TRequestStatus status = KRequestPending; |
4525 TRequestStatus status = KRequestPending; |
4380 proc.Rendezvous(status); |
4526 proc.Rendezvous(status); |
4381 User::WaitForRequest(status); |
4527 User::WaitForRequest(status); |
4382 } |
4528 triggerId = status.Int(); |
4383 User::After(5000000); |
4529 } |
4384 TInt triggerId=0; |
4530 |
4385 RProperty iProperty; |
|
4386 User::LeaveIfError(iProperty.Get( |
|
4387 KPSUidTriggerIdInfo, |
|
4388 KLbttesttriggerid, |
|
4389 triggerId)); |
|
4390 RArray< TLbtTriggerId> aTriggerIdList; |
4531 RArray< TLbtTriggerId> aTriggerIdList; |
4391 |
4532 |
4392 TRAP_IGNORE(lbt.DeleteTriggersL()); |
4533 TRAP_IGNORE(lbt.DeleteTriggersL()); |
4393 //create another trigger |
4534 //create another trigger |
4394 //Construct a startup trigger |
4535 //Construct a startup trigger |