sapi_location/tsrc/dev/tlocservicetest/src/tstraygetlocationtest.cpp
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19  * Stray signal test function
       
    20  */
       
    21  #include "locationservice.h"
       
    22  
       
    23  #define TRACE 0 
       
    24  #define GETLOCATION 1
       
    25  
       
    26  _LIT(KRequestor,"testapp");
       
    27  
       
    28 class ASyncLocCB : public MLocationCallBack
       
    29 {
       
    30 	TInt iCmd ;
       
    31 	TInt iRetStatus ;
       
    32 	TInt iCount ;
       
    33 	
       
    34 	CLocationService *iService ;
       
    35 
       
    36 
       
    37 	public :
       
    38 		
       
    39 		
       
    40 		TInt HandleNotifyL(HPositionGenericInfo* aInfo , TInt aError) ;
       
    41 
       
    42 		ASyncLocCB() :iCmd(0) , iRetStatus(KErrGeneral) , iCount(0) //Default constructor 
       
    43 			{
       
    44 				;
       
    45 			}
       
    46 		ASyncLocCB(TInt aCmd , CLocationService *aService)	 ;
       
    47 };
       
    48 
       
    49 
       
    50 ASyncLocCB :: ASyncLocCB(TInt aCmd ,CLocationService *aService):iCount(0) 
       
    51 { 
       
    52   iCmd = aCmd ;
       
    53   iService = aService ;
       
    54   	
       
    55 }
       
    56 
       
    57 TInt ASyncLocCB :: HandleNotifyL(HPositionGenericInfo* aInfo , TInt Error )
       
    58 {
       
    59 	if(iCmd == GETLOCATION)
       
    60 		{
       
    61 		iService->CancelOnGoingService(ECancelGetLocation) ;
       
    62 		}
       
    63 
       
    64 	if(iCount > 5)
       
    65 		{
       
    66 		 CActiveScheduler *current = CActiveScheduler :: Current() ;
       
    67 		 current->Stop() ;
       
    68 		}
       
    69 	iCount++ ;	
       
    70 	iRetStatus = KErrNone ;
       
    71 	return iRetStatus ;	
       
    72 }
       
    73   
       
    74   
       
    75 TInt StrayTestGetLocL()
       
    76 {
       
    77 	
       
    78 	CActiveScheduler *Scheduler = new CActiveScheduler ;
       
    79 
       
    80 	CActiveScheduler :: Install(Scheduler) ;
       
    81 	CLocationService *CoreObj = CLocationService ::NewL() ;
       
    82 	ASyncLocCB Updates(TRACE , CoreObj)  ;
       
    83 	ASyncLocCB GetLoc(GETLOCATION , CoreObj)  ;
       
    84 
       
    85 	// GelocUpdateCallBack  MyUpdates(&CmdId  , (CLocationService *)NULL) ;
       
    86 	CoreObj->TraceL(&Updates,EBasicInfo) ;
       
    87 	CoreObj->GetLocationL(&GetLoc,EBasicInfo) ;
       
    88 
       
    89 	CActiveScheduler :: Start() ;
       
    90 	return 0 ; // Controll never reaches here
       
    91 }
       
    92 
       
    93 
       
    94 TInt StrayTestGetLoc(TAny */*Arg*/)
       
    95 {
       
    96 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    97 	//Install a new active scheduler to this thread 
       
    98 	TRAPD(err , StrayTestGetLocL()) ;
       
    99 	delete cleanup ;
       
   100 	return 0 ;
       
   101 }
       
   102 
       
   103