locationtriggering/tsrc/lbtengine_test/firingofstartuptriggerandlisttrigger/CreateTest/src/CreateTest.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 0 667063e416a2
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 
    19 
    20 
       
    21 #include <e32property.h>
       
    22 
       
    23 #include <lbtcommon.h>
    20 #include <lbtcommon.h>
    24 #include <lbterrors.h>
    21 #include <lbterrors.h>
    25 #include <lbtgeoareabase.h>
    22 #include <lbtgeoareabase.h>
    26 #include <lbtgeocircle.h>
    23 #include <lbtgeocircle.h>
    27 #include <lbtgeorect.h>
    24 #include <lbtgeorect.h>
    35 #include <lbttriggerconditionarea.h>
    32 #include <lbttriggerconditionarea.h>
    36 #include <lbttriggerconditionbase.h>
    33 #include <lbttriggerconditionbase.h>
    37 #include <lbttriggerdynamicinfo.h>
    34 #include <lbttriggerdynamicinfo.h>
    38 #include <lbttriggerentry.h>
    35 #include <lbttriggerentry.h>
    39 
    36 
    40 
       
    41 #include "t_triggerfireobserver.h"	 
    37 #include "t_triggerfireobserver.h"	 
    42 void createtriggerL();
    38 TInt createtriggerL();
    43 GLDEF_C	 TInt E32Main()
    39 GLDEF_C	 TInt E32Main()
    44 	 {
    40 	 {
    45 	 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
    41 	 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
    46 	 if (!CActiveScheduler::Current())
    42 	 if (!CActiveScheduler::Current())
    47 		{
    43 		{
    48 		   TRAP_IGNORE(CActiveScheduler* scheduler=new(ELeave) CActiveScheduler;
    44 		   TRAP_IGNORE(CActiveScheduler* scheduler=new(ELeave) CActiveScheduler;
    49 		   CActiveScheduler::Install(scheduler););
    45 		   CActiveScheduler::Install(scheduler););
    50 		}
    46 		}
    51 	 TRAP_IGNORE(createtriggerL());
    47 	 TLbtTriggerId trigId = KLbtNullTriggerId;
    52 	 RProcess::Rendezvous(KErrNone);
    48 	 TRAP_IGNORE(trigId = createtriggerL());
       
    49 	 RProcess::Rendezvous(trigId);
    53     return 0;
    50     return 0;
    54   }
    51   }
    55   
    52   
    56   void createtriggerL()
    53   TInt createtriggerL()
    57   {
    54   {
    58   	RLbtServer lbtserver;
    55   	RLbtServer lbtserver;
    59  	 RLbt lbt;
    56  	 RLbt lbt;
       
    57  	 
    60  	 
    58  	 
    61  	 User::LeaveIfError( lbtserver.Connect() );
    59  	 User::LeaveIfError( lbtserver.Connect() );
    62      CleanupClosePushL( lbtserver );
    60      CleanupClosePushL( lbtserver );
    63  	 User::LeaveIfError( lbt.Open( lbtserver ) );
    61  	 User::LeaveIfError( lbt.Open( lbtserver ) );
    64  	 CleanupClosePushL( lbt );
    62  	 CleanupClosePushL( lbt );
   103     
   101     
   104     CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait;
   102     CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait;
   105         
   103         
   106     notifier->CreateTriggers( lbt,*trig,trigId,EFalse,wait );
   104     notifier->CreateTriggers( lbt,*trig,trigId,EFalse,wait );
   107     wait->Start( );	
   105     wait->Start( );	
   108     RProperty property;
   106     CleanupStack::PopAndDestroy(4,&lbtserver);
   109 	CleanupClosePushL(property);
   107     return trigId;
   110 	
       
   111 	//Allow all to ready from status information
       
   112 	_LIT_SECURITY_POLICY_PASS(EReadPolicyAlwaysPass);
       
   113 	//Delete the property if already exists
       
   114 	/*
       
   115 	 User::LeaveIfError(property.Delete(
       
   116         KPSUidTriggerIdInfo, 
       
   117         KLbttesttriggerid 
       
   118         ));*/
       
   119 	
       
   120 	// Read policy is always pass and write device data capability
       
   121 	// is required to write to the status information P&S key
       
   122 	property.Define(KPSUidTriggerIdInfo,
       
   123 									   KLbttesttriggerid,
       
   124 									   RProperty::EInt,
       
   125 									   EReadPolicyAlwaysPass,
       
   126 									   TSecurityPolicy(ECapabilityWriteDeviceData) );
       
   127 	
       
   128 
       
   129 	User::LeaveIfError( property.Attach(KPSUidTriggerIdInfo, 
       
   130 										KLbttesttriggerid) );
       
   131 										
       
   132 	User::LeaveIfError( property.Set(KPSUidTriggerIdInfo, 
       
   133 									 KLbttesttriggerid, 
       
   134 									 trigId));
       
   135 	
       
   136 	
       
   137     CleanupStack::PopAndDestroy(5,&lbtserver);
       
   138   }
   108   }