serviceproviders/sapi_location/tsrc/dev/tlocservicetest/src/tstraygetlocationtest.cpp
changeset 22 fc9cf246af83
parent 19 989d2f495d90
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
    28 class ASyncLocCB : public MLocationCallBack
    28 class ASyncLocCB : public MLocationCallBack
    29 {
    29 {
    30 	TInt iCmd ;
    30 	TInt iCmd ;
    31 	TInt iRetStatus ;
    31 	TInt iRetStatus ;
    32 	TInt iCount ;
    32 	TInt iCount ;
    33 	
    33     TInt iTransactionId;
    34 	CLocationService *iService ;
    34 	CLocationService *iService ;
    35 
    35 
    36 
    36 
    37 	public :
    37 	public :
    38 		
    38 		
    41 
    41 
    42 		ASyncLocCB() :iCmd(0) , iRetStatus(KErrGeneral) , iCount(0) //Default constructor 
    42 		ASyncLocCB() :iCmd(0) , iRetStatus(KErrGeneral) , iCount(0) //Default constructor 
    43 			{
    43 			{
    44 				;
    44 				;
    45 			}
    45 			}
    46 		ASyncLocCB(TInt aCmd , CLocationService *aService)	 ;
    46     ASyncLocCB(TInt aCmd , CLocationService *aService,TInt aTransId)	 ;
       
    47 
       
    48     inline TUint GetRequestType(void) 
       
    49         {
       
    50         return iCmd ;
       
    51         }
       
    52 
       
    53 
       
    54     MLocationCallBack* GetCallBackobj()
       
    55 		             {
       
    56 		             return this;  
       
    57 		             }
       
    58 
       
    59     /**
       
    60      * GetTransactionId function returns transcation id associated with current async object
       
    61      *
       
    62      */
       
    63     inline TInt32 GetTransactionId(void)
       
    64         {
       
    65         return iTransactionId ;
       
    66         }
    47 };
    67 };
    48 
    68 
    49 
    69 
    50 ASyncLocCB :: ASyncLocCB(TInt aCmd ,CLocationService *aService):iCount(0) 
    70 ASyncLocCB :: ASyncLocCB(TInt aCmd ,CLocationService *aService,TInt aTransId):iCount(0) 
    51 { 
    71 { 
    52   iCmd = aCmd ;
    72   iCmd = aCmd ;
    53   iService = aService ;
    73   iService = aService ;
       
    74     iTransactionId = aTransId;
    54   	
    75   	
    55 }
    76 }
    56 
    77 
    57 TInt ASyncLocCB :: HandleNotifyL(HPositionGenericInfo* aInfo , TInt Error )
    78 TInt ASyncLocCB :: HandleNotifyL(HPositionGenericInfo* aInfo , TInt Error )
    58 {
    79 {
    59 	if(iCmd == GETLOCATION)
    80 	if(iCmd == GETLOCATION)
    60 		{
    81 		{
    61 		iService->CancelOnGoingService(ECancelGetLocation) ;
    82         //Do nothing
    62 		}
    83 		}
    63 
    84 
    64 	if(iCount > 5)
    85     if(iCount > 2)
    65 		{
    86         {
    66 		 CActiveScheduler *current = CActiveScheduler :: Current() ;
    87         CActiveScheduler *current = CActiveScheduler :: Current() ;
    67 		 current->Stop() ;
    88         current->Stop() ;
    68 		}
    89         }
    69 	iCount++ ;	
    90     iCount++ ;	
    70 	iRetStatus = KErrNone ;
    91     iRetStatus = KErrNone ;
    71 	return iRetStatus ;	
    92     return iRetStatus ;	
    72 }
    93 }
    73   
    94   
    74   
    95   
    75 TInt StrayTestGetLocL()
    96 TInt StrayTestGetLocL()
    76 {
    97 {
    77 	
    98     __UHEAP_MARK ;
    78 	CActiveScheduler *Scheduler = new CActiveScheduler ;
    99     CActiveScheduler *Scheduler = new CActiveScheduler ;
    79 
   100 
    80 	CActiveScheduler :: Install(Scheduler) ;
   101     CActiveScheduler :: Install(Scheduler) ;
    81 	CLocationService *CoreObj = CLocationService ::NewL() ;
   102     CLocationService *CoreObj = CLocationService ::NewL() ;
    82 	ASyncLocCB Updates(TRACE , CoreObj)  ;
   103     ASyncLocCB Updates(TRACE , CoreObj,1000)  ;
    83 	ASyncLocCB GetLoc(GETLOCATION , CoreObj)  ;
       
    84 
   104 
    85 	// GelocUpdateCallBack  MyUpdates(&CmdId  , (CLocationService *)NULL) ;
   105     ASyncLocCB GetLoc(GETLOCATION , CoreObj,2000)  ;
    86 	CoreObj->TraceL(&Updates,EBasicInfo) ;
       
    87 	CoreObj->GetLocationL(&GetLoc,EBasicInfo) ;
       
    88 
   106 
    89 	CActiveScheduler :: Start() ;
   107     // GelocUpdateCallBack  MyUpdates(&CmdId  , (CLocationService *)NULL) ;
       
   108     CoreObj->TraceL(&Updates,EBasicInfo) ;
       
   109     CoreObj->GetLocationL(&GetLoc,EBasicInfo) ;
       
   110 
       
   111     CActiveScheduler :: Start() ;
       
   112     delete CoreObj;
       
   113     delete Scheduler;
       
   114     __UHEAP_MARKEND ;
    90 	return 0 ; // Controll never reaches here
   115 	return 0 ; // Controll never reaches here
    91 }
   116 }
    92 
   117 
    93 
   118 
    94 TInt StrayTestGetLoc(TAny */*Arg*/)
   119 TInt StrayTestGetLoc(TAny */*Arg*/)