sapi_location/tsrc/dev/tlocationprovidertest/src/tcompluginblocks.cpp
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 /*
       
     2 * Copyright (c) 2002 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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <e32svr.h>
       
    23 #include <StifParser.h>
       
    24 #include <Stiftestinterface.h>
       
    25 #include <LbsRequestor.h>
       
    26 #include <LiwServiceHandler.h>
       
    27 #include <LiwCommon.h>
       
    28 #include <lbs.h>
       
    29 
       
    30 #include "Tcomplugin.h"
       
    31 
       
    32 using namespace LIW;
       
    33 
       
    34 _LIT(LogFileName , "C:\\Notifications.txt") ;
       
    35 
       
    36 //----------------------------------------------------------------------------
       
    37 // CTestProvider :: Delete()
       
    38 //----------------------------------------------------------------------------
       
    39 void CTestProvider::Delete() 
       
    40     {
       
    41 
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CTestProvider::RunMethodL
       
    46 // Run specified method. Contains also table of test mothods and their names.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 TInt CTestProvider::RunMethodL( 
       
    50     CStifItemParser& aItem ) 
       
    51     {
       
    52 
       
    53     static TStifFunctionInfo const KFunctions[] =
       
    54         {  
       
    55         // Copy this line for every implemented function.
       
    56         // First string is the function name used in TestScripter script file.
       
    57         // Second is the actual implementation member function. 
       
    58         ENTRY("GetLocation" , CTestProvider :: GetLocation),
       
    59         ENTRY("LocationUpdates" , CTestProvider :: LocationUpdates),
       
    60         ENTRY("GetLocationAsynch" , CTestProvider :: GetLocationAsynch),
       
    61         ENTRY("ServiceFailed" , CTestProvider :: ServiceFailed),
       
    62         ENTRY("ServiceNotAvailable" , CTestProvider :: ServiceNotAvailable),
       
    63         ENTRY("StraySignalTrace" , CTestProvider :: StraySignal),
       
    64        	ENTRY("StraySignalGetLoc" , CTestProvider :: StraySignalGetLoc),
       
    65        	ENTRY("ConcurrentCallsGetLoc" , CTestProvider:: ConcurrentCallsGetLoc),
       
    66        	ENTRY("ConcurrentCallsTrace" , CTestProvider:: ConcurrentCallsTrace),
       
    67        	ENTRY("EmptyCancelTraceTest" , CTestProvider:: EmptyCancelTraceTest),
       
    68        	ENTRY("EmptyCancelGetLocTest" , CTestProvider:: EmptyCancelGetLocTest),
       
    69        	ENTRY("CancelWrongNotification1" , CTestProvider:: CancelWrongNotification1),
       
    70        	ENTRY("CancelWrongNotification2" , CTestProvider:: CancelWrongNotification2),
       
    71        	ENTRY("GetLocationCancel" , CTestProvider:: GetLocationCancel),
       
    72        	ENTRY("TraceLocationCancel" , CTestProvider:: TraceLocationCancel),
       
    73        	ENTRY("GetLocationTimedOut" , CTestProvider :: GetLocationTimedOut ),
       
    74        	ENTRY("BearingToTest" , CTestProvider :: BearingToTest),
       
    75        	ENTRY("FindDistance" , CTestProvider :: FindDistance),
       
    76        	ENTRY("FindDistanceAgain" , CTestProvider :: FindDistanceAgain),
       
    77        	ENTRY("GetLocationUpdateOpts" , CTestProvider :: GetLocationUpdateOpts),
       
    78        	ENTRY("MoveCoordinates" , CTestProvider :: MoveCoordinates),
       
    79        	ENTRY("GetLocationSynchWrongUpdateMapType" , CTestProvider :: GetLocationSynchWrongUpdateMapType),
       
    80        	ENTRY("CancelWithInvalidTransId" , CTestProvider ::CancelWithInvalidTransId),
       
    81        	ENTRY("getlocationPostionbased" , CTestProvider :: getlocationPostionbased),
       
    82        	ENTRY("getlocationPostionbasedwithupdateoption" , CTestProvider ::getlocationPostionbasedwithupdateoption),
       
    83        	ENTRY("getlocationPostionbasedpdateoption" , CTestProvider :: getlocationPostionbasedpdateoption),
       
    84        	
       
    85        	ENTRY("GetLocationWrongInfoClass" , CTestProvider :: GetLocationWrongInfoClass),
       
    86        	ENTRY("TraceWrongInfoClass" , CTestProvider :: TraceWrongInfoClass),
       
    87        	ENTRY("GetLocNegativeUpdateoption" , CTestProvider :: GetLocNegativeUpdateoption),
       
    88        	ENTRY("TraceNegativeUpdateoption" , CTestProvider :: TraceNegativeUpdateoption),
       
    89        	ENTRY("TestWrongInterfaceName" , CTestProvider :: TestWrongInterfaceName),
       
    90        	ENTRY("TestAllApi" , CTestProvider :: TestAllApi),
       
    91        	ENTRY("CancelTwice" , CTestProvider :: CancelTwice),
       
    92        	
       
    93         
       
    94         };
       
    95 
       
    96     const TInt count = sizeof( KFunctions ) / 
       
    97                         sizeof( TStifFunctionInfo );
       
    98 
       
    99     return RunInternalL( KFunctions, count, aItem );
       
   100 
       
   101     }
       
   102     
       
   103     
       
   104  class ASyncLocCBF : public MLiwNotifyCallback
       
   105 {
       
   106 	
       
   107 	public :
       
   108 	TInt iRetStatus ;
       
   109 		
       
   110 		TInt HandleNotifyL(
       
   111             TInt aCmdId,
       
   112             TInt aEventId,
       
   113             CLiwGenericParamList& aEventParamList,
       
   114             const CLiwGenericParamList& aInParamList) ;
       
   115 
       
   116 		ASyncLocCBF() : iRetStatus(KErrGeneral)  //Default constructor 
       
   117 			{
       
   118 				;
       
   119 			}
       
   120 	
       
   121 };
       
   122 TInt ASyncLocCBF::HandleNotifyL(
       
   123             TInt aCmdId,
       
   124             TInt aEventId,
       
   125             CLiwGenericParamList& aEventParamList,
       
   126             const CLiwGenericParamList& aInParamList) 
       
   127 {
       
   128 	return 0;
       
   129 }
       
   130 
       
   131 
       
   132 TInt CTestProvider :: CancelTwice( CStifItemParser& /*aItem*/ )
       
   133 {
       
   134 __UHEAP_MARK ;
       
   135 	CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   136 
       
   137 	// Input and output parameter list
       
   138 	CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   139 	CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   140 
       
   141 
       
   142 
       
   143 
       
   144 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
   145 
       
   146 
       
   147 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   148 
       
   149 	RCriteriaArray a;
       
   150 	a.AppendL(crit);
       
   151 
       
   152 	ServiceHandler->AttachL(a) ;
       
   153 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   154 
       
   155 	 
       
   156 	 
       
   157 
       
   158 	TInt pos = 0;
       
   159 
       
   160 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
   161 
       
   162 	if(!errorprm)
       
   163 	{
       
   164 		
       
   165 		return KErrGeneral ;
       
   166 	}
       
   167 
       
   168 
       
   169 	_LIT8(KDataSource, "ILocation");
       
   170 	 
       
   171 	 pos = 0 ;
       
   172 
       
   173 	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
   174 
       
   175 	if(!genericparm)
       
   176 	{
       
   177 		
       
   178 		return KErrGeneral ;
       
   179 	}
       
   180 
       
   181 	MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
   182 
       
   183 	
       
   184 	    
       
   185 	TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
   186 
       
   187 	outputlist->Reset() ;
       
   188 	inputlist->Reset() ;
       
   189 	ASyncLocCBF* callBack = new(ELeave) ASyncLocCBF;
       
   190 
       
   191 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist,KLiwOptASyncronous, callBack);
       
   192 
       
   193 	pos = 0 ;
       
   194 
       
   195 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
   196 
       
   197 	if(!ErrorParm)
       
   198 	{
       
   199 		return KErrGeneral ;
       
   200 	}
       
   201 	
       
   202 	TInt reqerror = (ErrorParm->Value()).AsTInt32();
       
   203 	
       
   204 	pos = 0;
       
   205 	
       
   206 	_LIT8(KTransactionId, "TransactionID");
       
   207 	const TLiwGenericParam *transid =  outputlist->FindFirst(pos ,KTransactionId ) ;
       
   208 	if(!transid)
       
   209 	{
       
   210 		return KErrGeneral;
       
   211 	}
       
   212 	TInt32 trid = (transid->Value()).AsTInt32();
       
   213 	outputlist->Reset() ;
       
   214 	inputlist->Reset() ;
       
   215 	
       
   216 	
       
   217 	inputlist->AppendL(TLiwGenericParam(KTransactionId,TLiwVariant(trid)));
       
   218 	
       
   219 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist,KLiwOptCancel);
       
   220 	
       
   221 	ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
   222 
       
   223 	if(!ErrorParm)
       
   224 	{
       
   225 		return KErrGeneral ;
       
   226 	}
       
   227 	
       
   228 	reqerror = (ErrorParm->Value()).AsTInt32();
       
   229 	
       
   230 	/*if( SErrNotFound == reqerror )
       
   231 		{
       
   232 		reqerror = 0;	
       
   233 		}*/
       
   234 	
       
   235 	//Call cancel again with same transaction id
       
   236 	outputlist->Reset() ;
       
   237 	inputlist->Reset() ;
       
   238 	
       
   239 	
       
   240 	inputlist->AppendL(TLiwGenericParam(KTransactionId,TLiwVariant(trid-2)));
       
   241 	
       
   242 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist,KLiwOptCancel);
       
   243 	
       
   244 	ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
   245 
       
   246 	if(!ErrorParm)
       
   247 	{
       
   248 		return KErrGeneral ;
       
   249 	}
       
   250 	
       
   251 	reqerror = (ErrorParm->Value()).AsTInt32();
       
   252 	
       
   253 	if( SErrNotFound == reqerror )
       
   254 		{
       
   255 		reqerror = 0;	
       
   256 		}
       
   257 	
       
   258 
       
   259 	
       
   260 
       
   261 
       
   262 
       
   263 	locinterface->Close() ;
       
   264 	inputlist->Reset();
       
   265 	outputlist->Reset();
       
   266 	delete callBack;
       
   267 	delete ServiceHandler ;
       
   268 	a.ResetAndDestroy() ;
       
   269 	a.Close() ;
       
   270 
       
   271 	__UHEAP_MARKEND ;
       
   272 	return reqerror ;
       
   273 
       
   274 
       
   275 
       
   276 		
       
   277 }
       
   278 TInt CTestProvider :: TestAllApi( CStifItemParser& /*aItem*/ )
       
   279 	{
       
   280 	__UHEAP_MARK ;
       
   281 	TInt start = User::CountAllocCells();
       
   282 	RFile LogFile ;
       
   283 	RFs LogSession ;
       
   284 	TBuf8<50> data ;
       
   285 	TRealFormat format ;
       
   286 	
       
   287 	
       
   288 	 if(LogSession.Connect() != KErrNone)
       
   289 	 {
       
   290 	 	_LIT(KLog , "Failed to connect to file server") ;
       
   291 	 	iLog->Log(KLog) ;
       
   292 	 	return KErrGeneral ;
       
   293 	 }
       
   294 	 
       
   295 	 
       
   296 
       
   297 
       
   298 	if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny )  == KErrNotFound)
       
   299 	{
       
   300 		if(LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) != KErrNone)
       
   301 		{
       
   302 		 	_LIT(KLog , "Failed to create notifications log file") ;
       
   303 		 	iLog->Log(KLog) ;
       
   304 		 	return KErrGeneral ;
       
   305 		}
       
   306 
       
   307 	}
       
   308 	
       
   309 	_LIT(KLog , "In CTGetLocation") ;
       
   310 	iLog->Log(KLog) ;
       
   311 	
       
   312    
       
   313     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   314   
       
   315     // Input and output parameter list
       
   316     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   317     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   318     
       
   319     
       
   320 
       
   321 
       
   322 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
   323 	
       
   324 
       
   325 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   326 
       
   327 	RCriteriaArray a;
       
   328 	a.AppendL(crit);
       
   329 	
       
   330 	ServiceHandler->AttachL(a) ;
       
   331    
       
   332 	
       
   333 	
       
   334 	
       
   335 	
       
   336 	
       
   337 	
       
   338 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   339 
       
   340 	 
       
   341  	 
       
   342 
       
   343 	TInt pos = 0;
       
   344 	
       
   345 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
   346 	
       
   347 	if(!errorprm)
       
   348 	{
       
   349 		_LIT(Klog , "Success/Failure error code missing from outputlist") ;
       
   350 		iLog->Log(Klog) ;
       
   351 		return KErrGeneral ;
       
   352 	}
       
   353 	
       
   354 
       
   355 	_LIT8(KDataSource, "ILocation");
       
   356 	 
       
   357 	 pos = 0 ;
       
   358 
       
   359  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
   360 	
       
   361 	if(!genericparm)
       
   362 	{
       
   363 		_LIT(KLog , "Interface not found");
       
   364 		iLog->Log(KLog) ;
       
   365 		return KErrGeneral ;
       
   366 	}
       
   367 	
       
   368    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
   369   
       
   370   
       
   371     
       
   372     TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
   373     
       
   374     outputlist->Reset() ;
       
   375     inputlist->Reset() ;
       
   376     _LIT(KClass,"GenericLocationInfo");
       
   377     inputlist->AppendL( TLiwGenericParam( KNullDesC8,TLiwVariant(KClass  )  ) );
       
   378     //inputlist->AppendL(TLiwGenericParam(NULL));
       
   379     CLiwDefaultMap* updatemap = CLiwDefaultMap::NewL();
       
   380     
       
   381 	_LIT8(KInterval,"UpdateInterval");
       
   382 	_LIT8(KTimeout,"UpdateTimeOut");
       
   383 	_LIT8(KAge,"UpdateMaxAge");
       
   384 	_LIT8(KPartial,"PartialUpdates");
       
   385 	const TInt KTime = 1000000;
       
   386     
       
   387     updatemap->InsertL(KInterval , TLiwVariant(TInt32(2*KTime)));
       
   388     updatemap->InsertL(KTimeout , TLiwVariant(TInt32(30*KTime)));
       
   389     updatemap->InsertL(KAge , TLiwVariant(TInt32(0)));
       
   390     updatemap->InsertL(KPartial , TLiwVariant(TBool(FALSE)));
       
   391     
       
   392     inputlist->AppendL(TLiwGenericParam(KNullDesC8,TLiwVariant(updatemap)));
       
   393     updatemap->DecRef();
       
   394     
       
   395     
       
   396     
       
   397 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist);
       
   398 	
       
   399 	pos = 0 ;
       
   400 	
       
   401 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
   402 	
       
   403 	if(!ErrorParm)
       
   404 	{
       
   405 		_LIT(Klog, "Success/Failure state not known") ;
       
   406 		iLog->Log(Klog) ;
       
   407 		return KErrGeneral ;
       
   408 	}
       
   409 	
       
   410 	if((ErrorParm->Value()).AsTInt32() )
       
   411 	{
       
   412 		_LIT(KLog , "ExecutecmdL failed ");
       
   413 		iLog->Log(KLog) ;
       
   414 		return (ErrorParm->Value()).AsTInt32() ;	
       
   415 	}
       
   416 	
       
   417 
       
   418 	
       
   419 	    TInt index = 0 ;
       
   420 
       
   421 		const TLiwGenericParam *GenericParam  = outputlist->FindFirst(index , KLocationMap);
       
   422 
       
   423 		
       
   424 		if(!GenericParam)
       
   425 		{
       
   426 			_LIT(Klog, "Out Param not found") ;
       
   427 	    	iLog->Log(Klog) ;
       
   428 			return KErrGeneral ; //Param Error
       
   429 		}	
       
   430 
       
   431 		TLiwVariant Variant ;
       
   432 
       
   433 		Variant = GenericParam->Value() ;
       
   434 		const	CLiwMap *LocMap = Variant.AsMap() ;
       
   435 
       
   436 		TLiwVariant PosVariant ;
       
   437 
       
   438 		LocMap->FindL(KLongitudeKey , PosVariant) ;
       
   439 		TReal64 LongData = (TReal64)PosVariant.AsTReal() ; //Longitude
       
   440 		data.Num(LongData , format) ;
       
   441 		LogFile.Write(_L8("\n")) ;
       
   442 		LogFile.Write(_L8("Logitude = ")) ;
       
   443 		LogFile.Write(data) ;
       
   444 
       
   445 		LocMap->FindL(KLatitudeKey ,PosVariant) ; //Latitude 
       
   446 
       
   447 		TReal64 LatData = (TReal64)PosVariant.AsTReal() ;
       
   448 		data.Num(LatData , format) ;
       
   449 		LogFile.Write(_L8("   Latitude = ")) ;
       
   450 		LogFile.Write(data) ;
       
   451 
       
   452 		LocMap->FindL(KAltitudeKey , PosVariant) ; //Altitude
       
   453 		TReal32 AltData = PosVariant.AsTReal() ;
       
   454 		data.Num(AltData , format) ;
       
   455 
       
   456 		LogFile.Write(_L8("   Altitude = "))	 ;
       
   457 		LogFile.Write(data) ;
       
   458 		
       
   459 		
       
   460 		
       
   461 	//Test Calculate
       
   462 		//TBuf8<20>CmdBufSet(KRequestCalculate) ;
       
   463         outputlist->Reset() ;
       
   464         inputlist->Reset() ;
       
   465        
       
   466         //CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
   467 
       
   468         TLiwGenericParam requesttype(KMathRequest , TLiwVariant(KRequestDistance)) ;
       
   469         inputlist->AppendL(requesttype) ;
       
   470         
       
   471         
       
   472 
       
   473         //Inserting first input param
       
   474         CLiwMap* SourceCoordinate = CLiwDefaultMap::NewL();
       
   475         TReal64 slongitude = 71.03;
       
   476         SourceCoordinate->InsertL(KLongitudeKey,TLiwVariant(slongitude));
       
   477         TReal64 slatitude = 42.37;
       
   478         SourceCoordinate->InsertL(KLatitudeKey,TLiwVariant(slatitude));
       
   479         
       
   480         TReal64 saltitude = 1;
       
   481         SourceCoordinate->InsertL(KAltitudeKey,TLiwVariant(saltitude));
       
   482 
       
   483 
       
   484         TLiwGenericParam scoordinate(KDistanceParmSource,TLiwVariant(SourceCoordinate));
       
   485         inputlist->AppendL(scoordinate) ;
       
   486         SourceCoordinate->DecRef() ;
       
   487 
       
   488 
       
   489 
       
   490         //Inserting 2nd input param
       
   491         CLiwMap* DestCoordinate = CLiwDefaultMap::NewL();
       
   492         TReal64 dlongitude = 83.02;
       
   493         DestCoordinate->InsertL(KLongitudeKey,TLiwVariant(dlongitude));
       
   494         TReal64 dlatitude = 42.42;
       
   495         DestCoordinate->InsertL(KLatitudeKey,TLiwVariant(dlatitude));
       
   496         
       
   497         TReal64 daltitude = 1;
       
   498         DestCoordinate->InsertL(KAltitudeKey,TLiwVariant(daltitude));
       
   499 
       
   500 
       
   501         TLiwGenericParam dcoordinate(KDistanceParmDestination,TLiwVariant(DestCoordinate));
       
   502         inputlist->AppendL(dcoordinate) ;
       
   503         DestCoordinate->DecRef() ;  
       
   504 
       
   505         //CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
   506 
       
   507 
       
   508         TBuf8<20>CmdBufSet(KRequestCalculate) ;
       
   509 
       
   510         locinterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist);
       
   511 
       
   512 
       
   513         pos = 0;
       
   514         const TLiwGenericParam* param = outputlist->FindFirst(pos, KErrorCode);
       
   515 
       
   516 		if((param->Value()).AsTInt32() )
       
   517 			{
       
   518 			_LIT(KLog , "Calculate failed ");
       
   519 			iLog->Log(KLog) ;
       
   520 			return (ErrorParm->Value()).AsTInt32() ;	
       
   521 			}
       
   522 		
       
   523 		pos = 0;
       
   524         const TLiwGenericParam* paramb = outputlist->FindFirst(pos, KErrorCode);
       
   525 
       
   526 		if((paramb->Value()).AsTInt32() )
       
   527 			{
       
   528 			_LIT(KLog , "Calculate failed ");
       
   529 			iLog->Log(KLog) ;
       
   530 			return (paramb->Value()).AsTInt32() ;	
       
   531 			}
       
   532         pos = 0;
       
   533         const TLiwGenericParam* resultparam = outputlist->FindFirst(pos, KMathOpResult);		
       
   534         TLiwVariant resultvariant = resultparam->Value();
       
   535         TReal64 distance = resultvariant.AsTReal();
       
   536 
       
   537 	//Test Calculate done	
       
   538 	 
       
   539 	 LogFile.Close() ;
       
   540 	 LogSession.Close() ;
       
   541   
       
   542 	
       
   543 	locinterface->Close() ;
       
   544 	outputlist->Reset() ;
       
   545     inputlist->Reset() ;
       
   546     
       
   547    	delete ServiceHandler ;
       
   548 	a.ResetAndDestroy() ;
       
   549 	a.Close() ;
       
   550 	TInt end = User::CountAllocCells();
       
   551 	
       
   552 __UHEAP_MARKEND ;
       
   553    return KErrNone ;
       
   554 
       
   555 
       
   556 
       
   557 		
       
   558 	}
       
   559 TInt CTestProvider :: TestWrongInterfaceName( CStifItemParser& /*aItem*/ )
       
   560 	{
       
   561 	__UHEAP_MARK;
       
   562 	
       
   563 	CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   564 
       
   565     // Input and output parameter list
       
   566     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   567     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   568 
       
   569 
       
   570 
       
   571     _LIT8(KServicename,"abc");
       
   572     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KServicename);
       
   573 
       
   574 
       
   575     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   576 
       
   577     RCriteriaArray a;
       
   578     a.AppendL(crit);
       
   579 
       
   580     ServiceHandler->AttachL(a) ;
       
   581     ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   582 
       
   583      
       
   584      
       
   585 
       
   586     TInt pos = 0;
       
   587 
       
   588     const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
   589 
       
   590     if(!errorprm)
       
   591         {
       
   592         //return KErrGeneral ;
       
   593         }
       
   594     TInt error = (errorprm->Value()).AsTInt32();
       
   595     delete ServiceHandler;
       
   596     a.ResetAndDestroy() ;
       
   597 	a.Close() ;
       
   598 	
       
   599 	return KErrNone;
       
   600 	__UHEAP_MARKEND;	
       
   601 	}
       
   602 TInt CTestProvider :: TraceNegativeUpdateoption( CStifItemParser& /*aItem*/ )
       
   603 	{
       
   604 	__UHEAP_MARK;
       
   605 	ASyncLocCBF callback;
       
   606 	CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   607 
       
   608     // Input and output parameter list
       
   609     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   610     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   611 
       
   612 
       
   613 
       
   614 
       
   615     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
   616 
       
   617 
       
   618     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   619 
       
   620     RCriteriaArray a;
       
   621     a.AppendL(crit);
       
   622 
       
   623     ServiceHandler->AttachL(a) ;
       
   624     ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   625 
       
   626      
       
   627      
       
   628 
       
   629     TInt pos = 0;
       
   630 
       
   631     const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
   632 
       
   633     if(!errorprm)
       
   634         {
       
   635         return KErrGeneral ;
       
   636         }
       
   637 
       
   638     pos = 0 ;
       
   639     const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
   640 
       
   641     if(!genericparm)
       
   642         {
       
   643 
       
   644         return KErrGeneral ;
       
   645         }
       
   646 
       
   647     MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
   648     
       
   649     	TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
   650 
       
   651 	CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
   652 	
       
   653 	//Append LocationInformation Category
       
   654 	TLiwGenericParam informationCategory(KLocationInfoCategory , TLiwVariant(KLocationBasicinfo)) ;
       
   655 	InputList->AppendL(informationCategory) ;
       
   656 	
       
   657 	//Appending update options
       
   658 	CLiwMap* updateoptionMap = CLiwDefaultMap::NewL();
       
   659 	
       
   660 	TInt32 updateInterval = 30000;
       
   661 	
       
   662     updateoptionMap->InsertL(KUpdateOptionInterval,TLiwVariant(updateInterval));
       
   663 	
       
   664 	TInt32 updateTimeOut = -10000;
       
   665 	updateoptionMap->InsertL(KUpdateOptionTimeOut,TLiwVariant(updateTimeOut));
       
   666 	
       
   667 	TInt32 updateMaxAge = 2000;
       
   668 	updateoptionMap->InsertL(KUpdateOptionMaxAge,TLiwVariant(updateMaxAge));
       
   669 	
       
   670 	TLiwGenericParam updateOption(KUpdateOptionMap,TLiwVariant(updateoptionMap));
       
   671 	InputList->AppendL(updateOption) ;
       
   672 	updateoptionMap->DecRef();
       
   673 	
       
   674 	CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
   675 	
       
   676 	
       
   677 	locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList,KLiwOptASyncronous,&callback);
       
   678 
       
   679 	
       
   680 	
       
   681 
       
   682 	 pos = 0;
       
   683 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
   684 	
       
   685 	if(!ErrorParm)
       
   686 		{
       
   687 		
       
   688 		return KErrGeneral ;
       
   689 		}
       
   690 	TInt error = (ErrorParm->Value()).AsTInt32();
       
   691 	if( SErrBadArgumentType == error )
       
   692 		{
       
   693 		error = KErrNone;	
       
   694 		
       
   695 		
       
   696 		}
       
   697 	locinterface->Close() ;
       
   698 	outputlist->Reset() ;
       
   699     inputlist->Reset() ;
       
   700    	delete ServiceHandler ;
       
   701    	delete OutParmList;
       
   702    	delete InputList;
       
   703 	a.ResetAndDestroy() ;
       
   704 	a.Close() ;
       
   705 	 __UHEAP_MARKEND ;	
       
   706 	return error;
       
   707 
       
   708 
       
   709 	
       
   710 		
       
   711 	}
       
   712 
       
   713 TInt CTestProvider :: GetLocNegativeUpdateoption( CStifItemParser& /*aItem*/ )
       
   714 	{
       
   715 	__UHEAP_MARK;
       
   716 	CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   717 
       
   718     // Input and output parameter list
       
   719     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   720     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   721 
       
   722 
       
   723 
       
   724 
       
   725     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
   726 
       
   727 
       
   728     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   729 
       
   730     RCriteriaArray a;
       
   731     a.AppendL(crit);
       
   732 
       
   733     ServiceHandler->AttachL(a) ;
       
   734     ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   735 
       
   736      
       
   737      
       
   738 
       
   739     TInt pos = 0;
       
   740 
       
   741     const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
   742 
       
   743     if(!errorprm)
       
   744         {
       
   745         return KErrGeneral ;
       
   746         }
       
   747 
       
   748     pos = 0 ;
       
   749     const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
   750 
       
   751     if(!genericparm)
       
   752         {
       
   753 
       
   754         return KErrGeneral ;
       
   755         }
       
   756 
       
   757     MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
   758     	TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
   759 
       
   760 	CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
   761 	
       
   762 	//Append LocationInformation Category
       
   763 	TLiwGenericParam informationCategory(KLocationInfoCategory , TLiwVariant(KLocationBasicinfo)) ;
       
   764 	InputList->AppendL(informationCategory) ;
       
   765 	
       
   766 	//Appending update options
       
   767 	CLiwMap* updateoptionMap = CLiwDefaultMap::NewL();
       
   768 	
       
   769 	TInt32 updateInterval = 30000;
       
   770 	
       
   771     updateoptionMap->InsertL(KUpdateOptionInterval,TLiwVariant(updateInterval));
       
   772 	
       
   773 	TInt32 updateTimeOut = -10000;
       
   774 	updateoptionMap->InsertL(KUpdateOptionTimeOut,TLiwVariant(updateTimeOut));
       
   775 	
       
   776 	TInt32 updateMaxAge = 2000;
       
   777 	updateoptionMap->InsertL(KUpdateOptionMaxAge,TLiwVariant(updateMaxAge));
       
   778 	
       
   779 	TLiwGenericParam updateOption(KUpdateOptionMap,TLiwVariant(updateoptionMap));
       
   780 	InputList->AppendL(updateOption) ;
       
   781 	updateoptionMap->DecRef();
       
   782 	
       
   783 	CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
   784 	
       
   785 	
       
   786 	
       
   787 
       
   788 	locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList);
       
   789 	
       
   790 
       
   791 	 pos = 0;
       
   792 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
   793 	
       
   794 	if(!ErrorParm)
       
   795 		{
       
   796 		
       
   797 		return KErrGeneral ;
       
   798 		}
       
   799 	TInt error = (ErrorParm->Value()).AsTInt32();
       
   800 	if( SErrBadArgumentType == error )
       
   801 		{
       
   802 		error = KErrNone;	
       
   803 		
       
   804 		
       
   805 		}
       
   806 	locinterface->Close() ;
       
   807    	delete ServiceHandler ;
       
   808    	delete OutParmList;
       
   809    	delete InputList;
       
   810 	a.ResetAndDestroy() ;
       
   811 	a.Close() ;
       
   812 	 __UHEAP_MARKEND ;	
       
   813 	return error;
       
   814 
       
   815 
       
   816 	
       
   817 		
       
   818 	}
       
   819 TInt CTestProvider :: GetLocationWrongInfoClass( CStifItemParser& /*aItem*/ )
       
   820 	{
       
   821 	__UHEAP_MARK ;
       
   822 	
       
   823    
       
   824     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   825   
       
   826     // Input and output parameter list
       
   827     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   828     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   829     
       
   830     
       
   831 
       
   832 
       
   833 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
   834 	
       
   835 
       
   836 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   837 
       
   838 	RCriteriaArray a;
       
   839 	a.AppendL(crit);
       
   840 	
       
   841 	ServiceHandler->AttachL(a) ;
       
   842    
       
   843 	
       
   844 	
       
   845 	
       
   846 	
       
   847 	
       
   848 	
       
   849 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   850 
       
   851 	 
       
   852  	 
       
   853 
       
   854 	TInt pos = 0;
       
   855 	
       
   856 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
   857 	
       
   858 	if(!errorprm)
       
   859 	{
       
   860 		
       
   861 		return KErrGeneral ;
       
   862 	}
       
   863 	
       
   864 
       
   865 	_LIT8(KDataSource, "ILocation");
       
   866 	 
       
   867 	 pos = 0 ;
       
   868 
       
   869  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
   870 	
       
   871 	if(!genericparm)
       
   872 	{
       
   873 		
       
   874 		return KErrGeneral ;
       
   875 	}
       
   876 	
       
   877    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
   878   
       
   879   
       
   880     
       
   881     TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
   882     
       
   883     outputlist->Reset() ;
       
   884     inputlist->Reset() ;
       
   885     _LIT8(KClass,"LocationInformationClass");
       
   886     _LIT(KClassArg,"Invalid");
       
   887     inputlist->AppendL(TLiwGenericParam(KClass,TLiwVariant(KClassArg)));
       
   888     
       
   889 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist);
       
   890 	
       
   891 	pos = 0 ;
       
   892 	
       
   893 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
   894 	
       
   895 	if(!ErrorParm)
       
   896 		{
       
   897 		
       
   898 		return KErrGeneral ;
       
   899 		}
       
   900 	TInt error = (ErrorParm->Value()).AsTInt32();
       
   901 	if( SErrBadArgumentType == error )
       
   902 		{
       
   903 		error = KErrNone;	
       
   904 		
       
   905 		
       
   906 		}
       
   907 	locinterface->Close() ;
       
   908    	delete ServiceHandler ;
       
   909 	a.ResetAndDestroy() ;
       
   910 	a.Close() ;
       
   911 	 __UHEAP_MARKEND ;	
       
   912 	return error;
       
   913 	
       
   914 	}
       
   915 
       
   916 TInt CTestProvider :: TraceWrongInfoClass( CStifItemParser& /*aItem*/ )
       
   917 	{
       
   918 	__UHEAP_MARK ;
       
   919 	TInt start = User::CountAllocCells();
       
   920 	ASyncLocCBF callback;
       
   921 	
       
   922    
       
   923     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   924   
       
   925     // Input and output parameter list
       
   926     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   927     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   928     
       
   929     
       
   930 
       
   931 
       
   932 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
   933 	
       
   934 
       
   935 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   936 
       
   937 	RCriteriaArray a;
       
   938 	a.AppendL(crit);
       
   939 	
       
   940 	ServiceHandler->AttachL(a) ;
       
   941    
       
   942 	
       
   943 	
       
   944 	
       
   945 	
       
   946 	
       
   947 	
       
   948 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   949 
       
   950 	 
       
   951  	 
       
   952 
       
   953 	TInt pos = 0;
       
   954 	
       
   955 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
   956 	
       
   957 	if(!errorprm)
       
   958 	{
       
   959 		
       
   960 		return KErrGeneral ;
       
   961 	}
       
   962 	
       
   963 
       
   964 	_LIT8(KDataSource, "ILocation");
       
   965 	 
       
   966 	 pos = 0 ;
       
   967 
       
   968  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
   969 	
       
   970 	if(!genericparm)
       
   971 	{
       
   972 		
       
   973 		return KErrGeneral ;
       
   974 	}
       
   975 	
       
   976    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
   977   
       
   978   
       
   979     
       
   980     TBuf8<20>CmdBuf(KCmdTraceLocation) ;
       
   981     
       
   982     outputlist->Reset() ;
       
   983     inputlist->Reset() ;
       
   984     _LIT8(KClass,"LocationInformationClass");
       
   985     _LIT(KClassArg,"Invalid");
       
   986     inputlist->AppendL(TLiwGenericParam(KClass,TLiwVariant(KClassArg)));
       
   987     
       
   988 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist,KLiwOptASyncronous,&callback);
       
   989 	
       
   990 	pos = 0 ;
       
   991 	
       
   992 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
   993 	
       
   994 	if(!ErrorParm)
       
   995 		{
       
   996 		
       
   997 		return KErrGeneral ;
       
   998 		}
       
   999 	TInt error = (ErrorParm->Value()).AsTInt32();
       
  1000 	if( SErrBadArgumentType == error )
       
  1001 		{
       
  1002 		error = KErrNone;	
       
  1003 		
       
  1004 		
       
  1005 		}
       
  1006 	locinterface->Close() ;
       
  1007 	outputlist->Reset() ;
       
  1008     inputlist->Reset() ;
       
  1009    	delete ServiceHandler ;
       
  1010 	a.ResetAndDestroy() ;
       
  1011 	a.Close() ;
       
  1012 	TInt end = User::CountAllocCells();
       
  1013 	 __UHEAP_MARKEND ;	
       
  1014 	return error;
       
  1015 	
       
  1016 	}
       
  1017 
       
  1018 TInt CTestProvider :: getlocationPostionbasedpdateoption( CStifItemParser& /*aItem*/ )
       
  1019 {
       
  1020 __UHEAP_MARK ;
       
  1021 	RFile LogFile ;
       
  1022 	RFs LogSession ;
       
  1023 	TBuf8<50> data ;
       
  1024 	TRealFormat format ;
       
  1025 	
       
  1026 	
       
  1027 	 if(LogSession.Connect() != KErrNone)
       
  1028 	 {
       
  1029 	 	_LIT(KLog , "Failed to connect to file server") ;
       
  1030 	 	iLog->Log(KLog) ;
       
  1031 	 	return KErrGeneral ;
       
  1032 	 }
       
  1033 	 
       
  1034 	 
       
  1035 
       
  1036 
       
  1037 	if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny )  == KErrNotFound)
       
  1038 	{
       
  1039 		if(LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) != KErrNone)
       
  1040 		{
       
  1041 		 	_LIT(KLog , "Failed to create notifications log file") ;
       
  1042 		 	iLog->Log(KLog) ;
       
  1043 		 	return KErrGeneral ;
       
  1044 		}
       
  1045 
       
  1046 	}
       
  1047 	
       
  1048 	_LIT(KLog , "In CTGetLocation") ;
       
  1049 	iLog->Log(KLog) ;
       
  1050 	
       
  1051    
       
  1052     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  1053   
       
  1054     // Input and output parameter list
       
  1055     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  1056     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  1057     
       
  1058     
       
  1059 
       
  1060 
       
  1061 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
  1062 	
       
  1063 
       
  1064 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  1065 
       
  1066 	RCriteriaArray a;
       
  1067 	a.AppendL(crit);
       
  1068 	
       
  1069 	ServiceHandler->AttachL(a) ;
       
  1070    
       
  1071 	
       
  1072 	
       
  1073 	
       
  1074 	
       
  1075 	
       
  1076 	
       
  1077 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  1078 
       
  1079 	 
       
  1080  	 
       
  1081 
       
  1082 	TInt pos = 0;
       
  1083 	
       
  1084 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  1085 	
       
  1086 	if(!errorprm)
       
  1087 	{
       
  1088 		_LIT(Klog , "Success/Failure error code missing from outputlist") ;
       
  1089 		iLog->Log(Klog) ;
       
  1090 		return KErrGeneral ;
       
  1091 	}
       
  1092 	
       
  1093 
       
  1094 	_LIT8(KDataSource, "ILocation");
       
  1095 	 
       
  1096 	 pos = 0 ;
       
  1097 
       
  1098  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
  1099 	
       
  1100 	if(!genericparm)
       
  1101 	{
       
  1102 		_LIT(KLog , "Interface not found");
       
  1103 		iLog->Log(KLog) ;
       
  1104 		return KErrGeneral ;
       
  1105 	}
       
  1106 	
       
  1107    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  1108   
       
  1109   
       
  1110     
       
  1111     TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
  1112     
       
  1113     outputlist->Reset() ;
       
  1114     inputlist->Reset() ;
       
  1115     _LIT(KClass,"GenericLocationInfo");
       
  1116     inputlist->AppendL( TLiwGenericParam( KNullDesC8,TLiwVariant(  )  ) );
       
  1117     //inputlist->AppendL(TLiwGenericParam(NULL));
       
  1118     CLiwDefaultMap* updatemap = CLiwDefaultMap::NewL();
       
  1119     
       
  1120 	_LIT8(KInterval,"UpdateInterval");
       
  1121 	_LIT8(KTimeout,"UpdateTimeOut");
       
  1122 	_LIT8(KAge,"UpdateMaxAge");
       
  1123 	_LIT8(KPartial,"PartialUpdates");
       
  1124 	const TInt KTime = 1000000;
       
  1125     
       
  1126     updatemap->InsertL(KInterval , TLiwVariant(TInt32(2*KTime)));
       
  1127     updatemap->InsertL(KTimeout , TLiwVariant(TInt32(30*KTime)));
       
  1128     updatemap->InsertL(KAge , TLiwVariant(TInt32(0)));
       
  1129     updatemap->InsertL(KPartial , TLiwVariant(TBool(FALSE)));
       
  1130     
       
  1131     inputlist->AppendL(TLiwGenericParam(KNullDesC8,TLiwVariant(updatemap)));
       
  1132     updatemap->DecRef();
       
  1133     
       
  1134     
       
  1135     
       
  1136 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist);
       
  1137 	
       
  1138 	pos = 0 ;
       
  1139 	
       
  1140 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
  1141 	
       
  1142 	if(!ErrorParm)
       
  1143 	{
       
  1144 		_LIT(Klog, "Success/Failure state not known") ;
       
  1145 		iLog->Log(Klog) ;
       
  1146 		return KErrGeneral ;
       
  1147 	}
       
  1148 	
       
  1149 	if((ErrorParm->Value()).AsTInt32() )
       
  1150 	{
       
  1151 		_LIT(KLog , "ExecutecmdL failed ");
       
  1152 		iLog->Log(KLog) ;
       
  1153 		//return (ErrorParm->Value()).AsTInt32() ;	
       
  1154 	}
       
  1155 	
       
  1156 
       
  1157 	
       
  1158 	    TInt index = 0 ;
       
  1159 
       
  1160 		const TLiwGenericParam *GenericParam  = outputlist->FindFirst(index , KLocationMap);
       
  1161 
       
  1162 		
       
  1163 		if(!GenericParam)
       
  1164 		{
       
  1165 			_LIT(Klog, "Out Param not found") ;
       
  1166 	    	iLog->Log(Klog) ;
       
  1167 			return KErrGeneral ; //Param Error
       
  1168 		}	
       
  1169 
       
  1170 		TLiwVariant Variant ;
       
  1171 
       
  1172 		Variant = GenericParam->Value() ;
       
  1173 		const	CLiwMap *LocMap = Variant.AsMap() ;
       
  1174 
       
  1175 		TLiwVariant PosVariant ;
       
  1176 
       
  1177 		LocMap->FindL(KLongitudeKey , PosVariant) ;
       
  1178 		TReal64 LongData = (TReal64)PosVariant.AsTReal() ; //Longitude
       
  1179 		data.Num(LongData , format) ;
       
  1180 		LogFile.Write(_L8("\n")) ;
       
  1181 		LogFile.Write(_L8("Logitude = ")) ;
       
  1182 		LogFile.Write(data) ;
       
  1183 
       
  1184 		LocMap->FindL(KLatitudeKey ,PosVariant) ; //Latitude 
       
  1185 
       
  1186 		TReal64 LatData = (TReal64)PosVariant.AsTReal() ;
       
  1187 		data.Num(LatData , format) ;
       
  1188 		LogFile.Write(_L8("   Latitude = ")) ;
       
  1189 		LogFile.Write(data) ;
       
  1190 
       
  1191 		LocMap->FindL(KAltitudeKey , PosVariant) ; //Altitude
       
  1192 		TReal32 AltData = PosVariant.AsTReal() ;
       
  1193 		data.Num(AltData , format) ;
       
  1194 
       
  1195 		LogFile.Write(_L8("   Altitude = "))	 ;
       
  1196 		LogFile.Write(data) ;
       
  1197 	 
       
  1198 	 LogFile.Close() ;
       
  1199 	 LogSession.Close() ;
       
  1200   
       
  1201 	locinterface->Close() ;
       
  1202    	delete ServiceHandler ;
       
  1203 	a.ResetAndDestroy() ;
       
  1204 	a.Close() ;
       
  1205 	
       
  1206 __UHEAP_MARKEND ;
       
  1207    return KErrNone ;
       
  1208 
       
  1209 
       
  1210 
       
  1211 }
       
  1212 
       
  1213 TInt CTestProvider :: getlocationPostionbasedwithupdateoption( CStifItemParser& /*aItem*/ )
       
  1214 {
       
  1215 __UHEAP_MARK ;
       
  1216 	RFile LogFile ;
       
  1217 	RFs LogSession ;
       
  1218 	TBuf8<50> data ;
       
  1219 	TRealFormat format ;
       
  1220 	
       
  1221 	
       
  1222 	 if(LogSession.Connect() != KErrNone)
       
  1223 	 {
       
  1224 	 	_LIT(KLog , "Failed to connect to file server") ;
       
  1225 	 	iLog->Log(KLog) ;
       
  1226 	 	return KErrGeneral ;
       
  1227 	 }
       
  1228 	 
       
  1229 	 
       
  1230 
       
  1231 
       
  1232 	if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny )  == KErrNotFound)
       
  1233 	{
       
  1234 		if(LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) != KErrNone)
       
  1235 		{
       
  1236 		 	_LIT(KLog , "Failed to create notifications log file") ;
       
  1237 		 	iLog->Log(KLog) ;
       
  1238 		 	return KErrGeneral ;
       
  1239 		}
       
  1240 
       
  1241 	}
       
  1242 	
       
  1243 	_LIT(KLog , "In CTGetLocation") ;
       
  1244 	iLog->Log(KLog) ;
       
  1245 	
       
  1246    
       
  1247     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  1248   
       
  1249     // Input and output parameter list
       
  1250     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  1251     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  1252     
       
  1253     
       
  1254 
       
  1255 
       
  1256 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
  1257 	
       
  1258 
       
  1259 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  1260 
       
  1261 	RCriteriaArray a;
       
  1262 	a.AppendL(crit);
       
  1263 	
       
  1264 	ServiceHandler->AttachL(a) ;
       
  1265    
       
  1266 	
       
  1267 	
       
  1268 	
       
  1269 	
       
  1270 	
       
  1271 	
       
  1272 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  1273 
       
  1274 	 
       
  1275  	 
       
  1276 
       
  1277 	TInt pos = 0;
       
  1278 	
       
  1279 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  1280 	
       
  1281 	if(!errorprm)
       
  1282 	{
       
  1283 		_LIT(Klog , "Success/Failure error code missing from outputlist") ;
       
  1284 		iLog->Log(Klog) ;
       
  1285 		return KErrGeneral ;
       
  1286 	}
       
  1287 	
       
  1288 
       
  1289 	_LIT8(KDataSource, "ILocation");
       
  1290 	 
       
  1291 	 pos = 0 ;
       
  1292 
       
  1293  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
  1294 	
       
  1295 	if(!genericparm)
       
  1296 	{
       
  1297 		_LIT(KLog , "Interface not found");
       
  1298 		iLog->Log(KLog) ;
       
  1299 		return KErrGeneral ;
       
  1300 	}
       
  1301 	
       
  1302    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  1303   
       
  1304   
       
  1305     
       
  1306     TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
  1307     
       
  1308     outputlist->Reset() ;
       
  1309     inputlist->Reset() ;
       
  1310     _LIT(KClass,"GenericLocationInfo");
       
  1311     inputlist->AppendL( TLiwGenericParam( KNullDesC8,TLiwVariant( KClass )  ) );
       
  1312     CLiwDefaultMap* updatemap = CLiwDefaultMap::NewL();
       
  1313     
       
  1314 	_LIT8(KInterval,"UpdateInterval");
       
  1315 	_LIT8(KTimeout,"UpdateTimeOut");
       
  1316 	_LIT8(KAge,"UpdateMaxAge");
       
  1317 	_LIT8(KPartial,"PartialUpdates");
       
  1318 	const TInt KTime = 1000000;
       
  1319     
       
  1320     updatemap->InsertL(KInterval , TLiwVariant(TInt32(2*KTime)));
       
  1321     updatemap->InsertL(KTimeout , TLiwVariant(TInt32(30*KTime)));
       
  1322     updatemap->InsertL(KAge , TLiwVariant(TInt32(0)));
       
  1323     updatemap->InsertL(KPartial , TLiwVariant(TBool(FALSE)));
       
  1324     
       
  1325     inputlist->AppendL(TLiwGenericParam(KNullDesC8,TLiwVariant(updatemap)));
       
  1326     updatemap->DecRef();
       
  1327     
       
  1328     
       
  1329     
       
  1330 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist);
       
  1331 	
       
  1332 	pos = 0 ;
       
  1333 	
       
  1334 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
  1335 	
       
  1336 	if(!ErrorParm)
       
  1337 	{
       
  1338 		_LIT(Klog, "Success/Failure state not known") ;
       
  1339 		iLog->Log(Klog) ;
       
  1340 		return KErrGeneral ;
       
  1341 	}
       
  1342 	
       
  1343 	if((ErrorParm->Value()).AsTInt32() )
       
  1344 	{
       
  1345 		_LIT(KLog , "ExecutecmdL failed ");
       
  1346 		iLog->Log(KLog) ;
       
  1347 		return (ErrorParm->Value()).AsTInt32() ;	
       
  1348 	}
       
  1349 	
       
  1350 
       
  1351 	
       
  1352 	    TInt index = 0 ;
       
  1353 
       
  1354 		const TLiwGenericParam *GenericParam  = outputlist->FindFirst(index , KLocationMap);
       
  1355 
       
  1356 		
       
  1357 		if(!GenericParam)
       
  1358 		{
       
  1359 			_LIT(Klog, "Out Param not found") ;
       
  1360 	    	iLog->Log(Klog) ;
       
  1361 			return KErrGeneral ; //Param Error
       
  1362 		}	
       
  1363 
       
  1364 		TLiwVariant Variant ;
       
  1365 
       
  1366 		Variant = GenericParam->Value() ;
       
  1367 		const	CLiwMap *LocMap = Variant.AsMap() ;
       
  1368 
       
  1369 		TLiwVariant PosVariant ;
       
  1370 
       
  1371 		LocMap->FindL(KLongitudeKey , PosVariant) ;
       
  1372 		TReal64 LongData = (TReal64)PosVariant.AsTReal() ; //Longitude
       
  1373 		data.Num(LongData , format) ;
       
  1374 		LogFile.Write(_L8("\n")) ;
       
  1375 		LogFile.Write(_L8("Logitude = ")) ;
       
  1376 		LogFile.Write(data) ;
       
  1377 
       
  1378 		LocMap->FindL(KLatitudeKey ,PosVariant) ; //Latitude 
       
  1379 
       
  1380 		TReal64 LatData = (TReal64)PosVariant.AsTReal() ;
       
  1381 		data.Num(LatData , format) ;
       
  1382 		LogFile.Write(_L8("   Latitude = ")) ;
       
  1383 		LogFile.Write(data) ;
       
  1384 
       
  1385 		LocMap->FindL(KAltitudeKey , PosVariant) ; //Altitude
       
  1386 		TReal32 AltData = PosVariant.AsTReal() ;
       
  1387 		data.Num(AltData , format) ;
       
  1388 
       
  1389 		LogFile.Write(_L8("   Altitude = "))	 ;
       
  1390 		LogFile.Write(data) ;
       
  1391 
       
  1392 	 
       
  1393         TLiwVariant Speed ;
       
  1394 	    
       
  1395 	    index = LocMap->FindL(_L8("HorizontalSpeed") , Speed ) ;
       
  1396 	  
       
  1397 	   if(index )
       
  1398 	     {
       
  1399 		
       
  1400 		 TReal speed =  Speed.AsTReal() ;
       
  1401 
       
  1402 		 data.Num(speed , format) ;
       
  1403 
       
  1404 		LogFile.Write(_L8("Speed = ")) ;
       
  1405 		LogFile.Write(data) ;
       
  1406 
       
  1407 	   }
       
  1408 	   
       
  1409 	  
       
  1410 	  TLiwVariant SpeedError ;
       
  1411 	  index = LocMap->FindL( _L8("HorizontalSpeedError") , SpeedError) ;
       
  1412 	  
       
  1413 	 
       
  1414 	  if(index )
       
  1415 	  {
       
  1416 	
       
  1417 		TReal speed =  SpeedError.AsTReal() ;
       
  1418 
       
  1419 		data.Num(speed , format) ;
       
  1420 
       
  1421 		LogFile.Write(_L8("Speed = ")) ;
       
  1422 		LogFile.Write(data) ;
       
  1423 
       
  1424 	  }
       
  1425 	  
       
  1426 	  index = 0 ;
       
  1427 	  
       
  1428 	  TLiwVariant SatInfo ;
       
  1429 	  
       
  1430 	  index = LocMap->FindL(_L8("SatelliteNumView") , SatInfo) ;
       
  1431 	  
       
  1432 	  if(index )
       
  1433 	  {
       
  1434 	  	
       
  1435 	  	TInt satnumView = SatInfo.AsTInt32() ;
       
  1436 	  	data.Num(satnumView , format);
       
  1437 	  	
       
  1438 	  	LogFile.Write(_L8("Satellite information")) ;
       
  1439 	  	
       
  1440 	  	LogFile.Write(_L8("Number of visible satellites ")) ;
       
  1441 	  	LogFile.Write(data) ;
       
  1442 	  }
       
  1443 	  
       
  1444 	  index = 0 ;
       
  1445 	  
       
  1446 	  TLiwVariant SatInfoview ;
       
  1447 	  
       
  1448 	  index = LocMap->FindL( _L8("SatelliteNumViewUsed") , SatInfoview) ;
       
  1449 	  if(index )
       
  1450 	  {
       
  1451 	  	
       
  1452 	  	
       
  1453 	  	TInt satnumViewUsed = SatInfoview.AsTInt32() ;
       
  1454 	  	data.Num(satnumViewUsed , format);
       
  1455 	  	
       
  1456 	  	LogFile.Write(_L8("\nSatellite information")) ;
       
  1457 	  	
       
  1458 	  	LogFile.Write(_L8("\nSatelliteNumViewUsed")) ;
       
  1459 	  	LogFile.Write(data) ;
       
  1460 	  }
       
  1461 	  
       
  1462 	  index = 0 ;
       
  1463 	   
       
  1464 	  TInt Headinginfo = 0 ;
       
  1465 	  
       
  1466 	  TLiwVariant  Heading ;
       
  1467 	  Headinginfo = LocMap->FindL(_L8("Heading") ,Heading) ;
       
  1468 	  
       
  1469 	  if(Headinginfo)
       
  1470 	  {
       
  1471 	  	
       
  1472 	  	
       
  1473 	  	TReal heading = Heading.AsTReal() ;
       
  1474 	  	data.Num(heading , format);
       
  1475 	  	
       
  1476 	  	LogFile.Write(_L8("\ncompass information")) ;
       
  1477 	  	
       
  1478 	  	LogFile.Write(_L8("\nHeading")) ;
       
  1479 	  	LogFile.Write(data) ;
       
  1480 	  }
       
  1481 	  
       
  1482 	  
       
  1483 	  if(Headinginfo)
       
  1484 	  {
       
  1485 		  	TLiwVariant HeadingError ;
       
  1486 		  	index  = LocMap->FindL( _L8("HeadingError") , HeadingError ) ;
       
  1487 		  	
       
  1488 		  	if(index)
       
  1489 		  	{
       
  1490 			  	
       
  1491 			  	
       
  1492 			  	TReal heading = HeadingError.AsTReal() ;
       
  1493 			  	data.Num(heading , format);
       
  1494 			  	
       
  1495 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  1496 			  	
       
  1497 			  	LogFile.Write(_L8("\nHeading Error")) ;
       
  1498 			  	LogFile.Write(data) ;
       
  1499 		  		
       
  1500 		  	}
       
  1501 		  
       
  1502 		   TLiwVariant MagneticHeading ;
       
  1503 		   index = LocMap->FindL( _L8("MagneticHeading") ,  MagneticHeading) ;
       
  1504 		  	
       
  1505 		  	if(index)
       
  1506 		  	{
       
  1507 			  	
       
  1508 			  	
       
  1509 			  	TReal heading = MagneticHeading.AsTReal() ;
       
  1510 			  	data.Num(heading , format);
       
  1511 			  	
       
  1512 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  1513 			  	
       
  1514 			  	LogFile.Write(_L8("\n MagneticHeading ")) ;
       
  1515 			  	LogFile.Write(data) ;
       
  1516 			  		
       
  1517 		  	}
       
  1518 		  	
       
  1519 		  
       
  1520 		  	TLiwVariant MagneticHeadingError ;
       
  1521 		  	 index = LocMap->FindL(_L8("MagneticHeadingError")  ,MagneticHeadingError) ;
       
  1522 		  	
       
  1523 		  	if(index)
       
  1524 		  	{
       
  1525 			  	
       
  1526 			  	
       
  1527 			  	TReal heading = MagneticHeadingError.AsTReal() ;
       
  1528 			  	data.Num(heading , format);
       
  1529 			  	
       
  1530 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  1531 			  	
       
  1532 			  	LogFile.Write(_L8("\nMagneticHeading Error")) ;
       
  1533 			  	LogFile.Write(data) ;
       
  1534 			  		
       
  1535 		  	}
       
  1536 	  
       
  1537 
       
  1538 	  } //End of Heading
       
  1539 	  
       
  1540 	   
       
  1541 	  
       
  1542 	  TLiwVariant TrueCourse ;
       
  1543 	  index = LocMap->FindL( _L8("TrueCourse") , TrueCourse ) ;
       
  1544 	  
       
  1545 	  if( index)
       
  1546 	  {
       
  1547 	  	
       
  1548 		  
       
  1549 		  	TReal heading = TrueCourse.AsTReal() ;
       
  1550 		  	data.Num(heading , format);
       
  1551 		  	
       
  1552 		  	LogFile.Write(_L8("\nDirection ")) ;
       
  1553 		  	
       
  1554 		  	LogFile.Write(_L8("\n TrueCourse Error")) ;
       
  1555 		  	LogFile.Write(data) ;
       
  1556 		  	
       
  1557 		  	
       
  1558 		  	
       
  1559 		  	 TLiwVariant TrueCourseError ;
       
  1560 		  	 index  = LocMap->FindL( _L8("TrueCourseError") , TrueCourseError ) ;
       
  1561 		  	 
       
  1562 		  	 if( index)
       
  1563 		  	 {
       
  1564 			  
       
  1565 			  	
       
  1566 			  	TReal heading = TrueCourseError.AsTReal() ;
       
  1567 			  	data.Num(heading , format);
       
  1568 			  	
       
  1569 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  1570 			  	
       
  1571 			  	LogFile.Write(_L8("\nMagneticHeading Error")) ;
       
  1572 			  	LogFile.Write(data) ;
       
  1573 			  		
       
  1574 		  	 }
       
  1575 		  	 
       
  1576 		  	
       
  1577 	  }
       
  1578 	  
       
  1579 	  
       
  1580 	 TLiwVariant MagneticCourse ;
       
  1581 	 index =  LocMap->FindL(_L8("MagneticCourse") , MagneticCourse ) ;
       
  1582 	  
       
  1583 	
       
  1584 	   if(index)
       
  1585 	  	 {
       
  1586 		  	
       
  1587 		  	TReal heading = MagneticCourse.AsTReal() ;
       
  1588 		  	data.Num(heading , format);
       
  1589 		  	
       
  1590 		  	LogFile.Write(_L8("\ncompass information")) ;
       
  1591 		  	
       
  1592 		  	LogFile.Write(_L8("\nMagneticCourse ")) ;
       
  1593 		  	LogFile.Write(data) ;
       
  1594 		  	
       
  1595 		  	
       
  1596 		  	
       
  1597 		    TLiwVariant MagneticCourseError  ;
       
  1598 		    index = LocMap->FindL(_L8("MagneticCourseError") ,MagneticCourseError ) ;
       
  1599 		  
       
  1600 		  	 if( index)
       
  1601 		  	 {
       
  1602 			  
       
  1603 			  	
       
  1604 			  	TReal heading = MagneticCourseError.AsTReal() ;
       
  1605 			  	data.Num(heading , format);
       
  1606 			  	
       
  1607 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  1608 			  	
       
  1609 			  	LogFile.Write(_L8("\n MagneticCourseError Error")) ;
       
  1610 			  	LogFile.Write(data) ;
       
  1611 			  		
       
  1612 		  	 }
       
  1613 	  	 
       
  1614 		  		
       
  1615 	  	 }
       
  1616 		  	 
       
  1617 		  	 
       
  1618 		
       
  1619 		TLiwVariant NmeaNum ;
       
  1620 		index = LocMap->FindL(_L8("NMEASentence") , NmeaNum ) ;  	 
       
  1621 	  
       
  1622 	  
       
  1623 	  if(index)
       
  1624 	  	 {
       
  1625 		  	
       
  1626 		  	TInt32 NMEASentence = NmeaNum.AsTInt32() ;
       
  1627 		  	data.Num(NMEASentence , format);
       
  1628 		  	
       
  1629 		  	LogFile.Write(_L8("\nNMEA Information")) ;
       
  1630 		  	
       
  1631 		  	LogFile.Write(_L8("\n number of NMEA Sentences ")) ;
       
  1632 		  	LogFile.Write(data) ;
       
  1633 		  	
       
  1634 		  	index = 0 ;
       
  1635 		  	
       
  1636 		    const TLiwGenericParam *MagneticCourseError  = outputlist->FindFirst(index , _L8("NMEASentenceStart") ) ;
       
  1637 		  
       
  1638 		  	 if(-1 != index)
       
  1639 		  	 {
       
  1640 			  	Variant = MagneticCourseError->Value() ;
       
  1641 			  	
       
  1642 			  
       
  1643 		  	 }
       
  1644 	  	 
       
  1645 		  		
       
  1646 	  	 }
       
  1647 		  	
       
  1648 	  
       
  1649 	 LogFile.Close() ;
       
  1650 	 LogSession.Close() ;
       
  1651   
       
  1652 	locinterface->Close() ;
       
  1653    	delete ServiceHandler ;
       
  1654 	a.ResetAndDestroy() ;
       
  1655 	a.Close() ;
       
  1656 	
       
  1657 __UHEAP_MARKEND ;
       
  1658    return KErrNone ;
       
  1659 
       
  1660 
       
  1661 
       
  1662 }
       
  1663 
       
  1664 
       
  1665 TInt CTestProvider :: getlocationPostionbased( CStifItemParser& /*aItem*/ )
       
  1666 {
       
  1667 __UHEAP_MARK ;
       
  1668 	RFile LogFile ;
       
  1669 	RFs LogSession ;
       
  1670 	TBuf8<50> data ;
       
  1671 	TRealFormat format ;
       
  1672 	
       
  1673 	
       
  1674 	 if(LogSession.Connect() != KErrNone)
       
  1675 	 {
       
  1676 	 	_LIT(KLog , "Failed to connect to file server") ;
       
  1677 	 	iLog->Log(KLog) ;
       
  1678 	 	return KErrGeneral ;
       
  1679 	 }
       
  1680 	 
       
  1681 	 
       
  1682 
       
  1683 
       
  1684 	if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny )  == KErrNotFound)
       
  1685 	{
       
  1686 		if(LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) != KErrNone)
       
  1687 		{
       
  1688 		 	_LIT(KLog , "Failed to create notifications log file") ;
       
  1689 		 	iLog->Log(KLog) ;
       
  1690 		 	return KErrGeneral ;
       
  1691 		}
       
  1692 
       
  1693 	}
       
  1694 	
       
  1695 	_LIT(KLog , "In CTGetLocation") ;
       
  1696 	iLog->Log(KLog) ;
       
  1697 	
       
  1698    
       
  1699     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  1700   
       
  1701     // Input and output parameter list
       
  1702     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  1703     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  1704     
       
  1705     
       
  1706 
       
  1707 
       
  1708 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
  1709 	
       
  1710 
       
  1711 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  1712 
       
  1713 	RCriteriaArray a;
       
  1714 	a.AppendL(crit);
       
  1715 	
       
  1716 	ServiceHandler->AttachL(a) ;
       
  1717    
       
  1718 	
       
  1719 	
       
  1720 	
       
  1721 	
       
  1722 	
       
  1723 	
       
  1724 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  1725 
       
  1726 	 
       
  1727  	 
       
  1728 
       
  1729 	TInt pos = 0;
       
  1730 	
       
  1731 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  1732 	
       
  1733 	if(!errorprm)
       
  1734 	{
       
  1735 		_LIT(Klog , "Success/Failure error code missing from outputlist") ;
       
  1736 		iLog->Log(Klog) ;
       
  1737 		return KErrGeneral ;
       
  1738 	}
       
  1739 	
       
  1740 
       
  1741 	_LIT8(KDataSource, "ILocation");
       
  1742 	 
       
  1743 	 pos = 0 ;
       
  1744 
       
  1745  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
  1746 	
       
  1747 	if(!genericparm)
       
  1748 	{
       
  1749 		_LIT(KLog , "Interface not found");
       
  1750 		iLog->Log(KLog) ;
       
  1751 		return KErrGeneral ;
       
  1752 	}
       
  1753 	
       
  1754    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  1755   
       
  1756   
       
  1757     
       
  1758     TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
  1759     
       
  1760     outputlist->Reset() ;
       
  1761     inputlist->Reset() ;
       
  1762     _LIT(KClass,"GenericLocationInfo");
       
  1763     inputlist->AppendL( TLiwGenericParam( KNullDesC8,TLiwVariant( KClass )  ) );
       
  1764     
       
  1765 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist);
       
  1766 	
       
  1767 	pos = 0 ;
       
  1768 	
       
  1769 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
  1770 	
       
  1771 	if(!ErrorParm)
       
  1772 	{
       
  1773 		_LIT(Klog, "Success/Failure state not known") ;
       
  1774 		iLog->Log(Klog) ;
       
  1775 		return KErrGeneral ;
       
  1776 	}
       
  1777 	
       
  1778 	if((ErrorParm->Value()).AsTInt32() )
       
  1779 	{
       
  1780 		_LIT(KLog , "ExecutecmdL failed ");
       
  1781 		iLog->Log(KLog) ;
       
  1782 		return (ErrorParm->Value()).AsTInt32() ;	
       
  1783 	}
       
  1784 	
       
  1785 
       
  1786 	
       
  1787 	    TInt index = 0 ;
       
  1788 
       
  1789 		const TLiwGenericParam *GenericParam  = outputlist->FindFirst(index , KLocationMap);
       
  1790 
       
  1791 		
       
  1792 		if(!GenericParam)
       
  1793 		{
       
  1794 			_LIT(Klog, "Out Param not found") ;
       
  1795 	    	iLog->Log(Klog) ;
       
  1796 			return KErrGeneral ; //Param Error
       
  1797 		}	
       
  1798 
       
  1799 		TLiwVariant Variant ;
       
  1800 
       
  1801 		Variant = GenericParam->Value() ;
       
  1802 		const	CLiwMap *LocMap = Variant.AsMap() ;
       
  1803 
       
  1804 		TLiwVariant PosVariant ;
       
  1805 
       
  1806 		LocMap->FindL(KLongitudeKey , PosVariant) ;
       
  1807 		TReal64 LongData = (TReal64)PosVariant.AsTReal() ; //Longitude
       
  1808 		data.Num(LongData , format) ;
       
  1809 		LogFile.Write(_L8("\n")) ;
       
  1810 		LogFile.Write(_L8("Logitude = ")) ;
       
  1811 		LogFile.Write(data) ;
       
  1812 
       
  1813 		LocMap->FindL(KLatitudeKey ,PosVariant) ; //Latitude 
       
  1814 
       
  1815 		TReal64 LatData = (TReal64)PosVariant.AsTReal() ;
       
  1816 		data.Num(LatData , format) ;
       
  1817 		LogFile.Write(_L8("   Latitude = ")) ;
       
  1818 		LogFile.Write(data) ;
       
  1819 
       
  1820 		LocMap->FindL(KAltitudeKey , PosVariant) ; //Altitude
       
  1821 		TReal32 AltData = PosVariant.AsTReal() ;
       
  1822 		data.Num(AltData , format) ;
       
  1823 
       
  1824 		LogFile.Write(_L8("   Altitude = "))	 ;
       
  1825 		LogFile.Write(data) ;
       
  1826 
       
  1827 	 
       
  1828         TLiwVariant Speed ;
       
  1829 	    
       
  1830 	    index = LocMap->FindL(_L8("HorizontalSpeed") , Speed ) ;
       
  1831 	  
       
  1832 	   if(index )
       
  1833 	     {
       
  1834 		
       
  1835 		 TReal speed =  Speed.AsTReal() ;
       
  1836 
       
  1837 		 data.Num(speed , format) ;
       
  1838 
       
  1839 		LogFile.Write(_L8("Speed = ")) ;
       
  1840 		LogFile.Write(data) ;
       
  1841 
       
  1842 	   }
       
  1843 	   
       
  1844 	  
       
  1845 	  TLiwVariant SpeedError ;
       
  1846 	  index = LocMap->FindL( _L8("HorizontalSpeedError") , SpeedError) ;
       
  1847 	  
       
  1848 	 
       
  1849 	  if(index )
       
  1850 	  {
       
  1851 	
       
  1852 		TReal speed =  SpeedError.AsTReal() ;
       
  1853 
       
  1854 		data.Num(speed , format) ;
       
  1855 
       
  1856 		LogFile.Write(_L8("Speed = ")) ;
       
  1857 		LogFile.Write(data) ;
       
  1858 
       
  1859 	  }
       
  1860 	  
       
  1861 	  index = 0 ;
       
  1862 	  
       
  1863 	  TLiwVariant SatInfo ;
       
  1864 	  
       
  1865 	  index = LocMap->FindL(_L8("SatelliteNumView") , SatInfo) ;
       
  1866 	  
       
  1867 	  if(index )
       
  1868 	  {
       
  1869 	  	
       
  1870 	  	TInt satnumView = SatInfo.AsTInt32() ;
       
  1871 	  	data.Num(satnumView , format);
       
  1872 	  	
       
  1873 	  	LogFile.Write(_L8("Satellite information")) ;
       
  1874 	  	
       
  1875 	  	LogFile.Write(_L8("Number of visible satellites ")) ;
       
  1876 	  	LogFile.Write(data) ;
       
  1877 	  }
       
  1878 	  
       
  1879 	  index = 0 ;
       
  1880 	  
       
  1881 	  TLiwVariant SatInfoview ;
       
  1882 	  
       
  1883 	  index = LocMap->FindL( _L8("SatelliteNumViewUsed") , SatInfoview) ;
       
  1884 	  if(index )
       
  1885 	  {
       
  1886 	  	
       
  1887 	  	
       
  1888 	  	TInt satnumViewUsed = SatInfoview.AsTInt32() ;
       
  1889 	  	data.Num(satnumViewUsed , format);
       
  1890 	  	
       
  1891 	  	LogFile.Write(_L8("\nSatellite information")) ;
       
  1892 	  	
       
  1893 	  	LogFile.Write(_L8("\nSatelliteNumViewUsed")) ;
       
  1894 	  	LogFile.Write(data) ;
       
  1895 	  }
       
  1896 	  
       
  1897 	  index = 0 ;
       
  1898 	   
       
  1899 	  TInt Headinginfo = 0 ;
       
  1900 	  
       
  1901 	  TLiwVariant  Heading ;
       
  1902 	  Headinginfo = LocMap->FindL(_L8("Heading") ,Heading) ;
       
  1903 	  
       
  1904 	  if(Headinginfo)
       
  1905 	  {
       
  1906 	  	
       
  1907 	  	
       
  1908 	  	TReal heading = Heading.AsTReal() ;
       
  1909 	  	data.Num(heading , format);
       
  1910 	  	
       
  1911 	  	LogFile.Write(_L8("\ncompass information")) ;
       
  1912 	  	
       
  1913 	  	LogFile.Write(_L8("\nHeading")) ;
       
  1914 	  	LogFile.Write(data) ;
       
  1915 	  }
       
  1916 	  
       
  1917 	  
       
  1918 	  if(Headinginfo)
       
  1919 	  {
       
  1920 		  	TLiwVariant HeadingError ;
       
  1921 		  	index  = LocMap->FindL( _L8("HeadingError") , HeadingError ) ;
       
  1922 		  	
       
  1923 		  	if(index)
       
  1924 		  	{
       
  1925 			  	
       
  1926 			  	
       
  1927 			  	TReal heading = HeadingError.AsTReal() ;
       
  1928 			  	data.Num(heading , format);
       
  1929 			  	
       
  1930 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  1931 			  	
       
  1932 			  	LogFile.Write(_L8("\nHeading Error")) ;
       
  1933 			  	LogFile.Write(data) ;
       
  1934 		  		
       
  1935 		  	}
       
  1936 		  
       
  1937 		   TLiwVariant MagneticHeading ;
       
  1938 		   index = LocMap->FindL( _L8("MagneticHeading") ,  MagneticHeading) ;
       
  1939 		  	
       
  1940 		  	if(index)
       
  1941 		  	{
       
  1942 			  	
       
  1943 			  	
       
  1944 			  	TReal heading = MagneticHeading.AsTReal() ;
       
  1945 			  	data.Num(heading , format);
       
  1946 			  	
       
  1947 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  1948 			  	
       
  1949 			  	LogFile.Write(_L8("\n MagneticHeading ")) ;
       
  1950 			  	LogFile.Write(data) ;
       
  1951 			  		
       
  1952 		  	}
       
  1953 		  	
       
  1954 		  
       
  1955 		  	TLiwVariant MagneticHeadingError ;
       
  1956 		  	 index = LocMap->FindL(_L8("MagneticHeadingError")  ,MagneticHeadingError) ;
       
  1957 		  	
       
  1958 		  	if(index)
       
  1959 		  	{
       
  1960 			  	
       
  1961 			  	
       
  1962 			  	TReal heading = MagneticHeadingError.AsTReal() ;
       
  1963 			  	data.Num(heading , format);
       
  1964 			  	
       
  1965 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  1966 			  	
       
  1967 			  	LogFile.Write(_L8("\nMagneticHeading Error")) ;
       
  1968 			  	LogFile.Write(data) ;
       
  1969 			  		
       
  1970 		  	}
       
  1971 	  
       
  1972 
       
  1973 	  } //End of Heading
       
  1974 	  
       
  1975 	   
       
  1976 	  
       
  1977 	  TLiwVariant TrueCourse ;
       
  1978 	  index = LocMap->FindL( _L8("TrueCourse") , TrueCourse ) ;
       
  1979 	  
       
  1980 	  if( index)
       
  1981 	  {
       
  1982 	  	
       
  1983 		  
       
  1984 		  	TReal heading = TrueCourse.AsTReal() ;
       
  1985 		  	data.Num(heading , format);
       
  1986 		  	
       
  1987 		  	LogFile.Write(_L8("\nDirection ")) ;
       
  1988 		  	
       
  1989 		  	LogFile.Write(_L8("\n TrueCourse Error")) ;
       
  1990 		  	LogFile.Write(data) ;
       
  1991 		  	
       
  1992 		  	
       
  1993 		  	
       
  1994 		  	 TLiwVariant TrueCourseError ;
       
  1995 		  	 index  = LocMap->FindL( _L8("TrueCourseError") , TrueCourseError ) ;
       
  1996 		  	 
       
  1997 		  	 if( index)
       
  1998 		  	 {
       
  1999 			  
       
  2000 			  	
       
  2001 			  	TReal heading = TrueCourseError.AsTReal() ;
       
  2002 			  	data.Num(heading , format);
       
  2003 			  	
       
  2004 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  2005 			  	
       
  2006 			  	LogFile.Write(_L8("\nMagneticHeading Error")) ;
       
  2007 			  	LogFile.Write(data) ;
       
  2008 			  		
       
  2009 		  	 }
       
  2010 		  	 
       
  2011 		  	
       
  2012 	  }
       
  2013 	  
       
  2014 	  
       
  2015 	 TLiwVariant MagneticCourse ;
       
  2016 	 index =  LocMap->FindL(_L8("MagneticCourse") , MagneticCourse ) ;
       
  2017 	  
       
  2018 	
       
  2019 	   if(index)
       
  2020 	  	 {
       
  2021 		  	
       
  2022 		  	TReal heading = MagneticCourse.AsTReal() ;
       
  2023 		  	data.Num(heading , format);
       
  2024 		  	
       
  2025 		  	LogFile.Write(_L8("\ncompass information")) ;
       
  2026 		  	
       
  2027 		  	LogFile.Write(_L8("\nMagneticCourse ")) ;
       
  2028 		  	LogFile.Write(data) ;
       
  2029 		  	
       
  2030 		  	
       
  2031 		  	
       
  2032 		    TLiwVariant MagneticCourseError  ;
       
  2033 		    index = LocMap->FindL(_L8("MagneticCourseError") ,MagneticCourseError ) ;
       
  2034 		  
       
  2035 		  	 if( index)
       
  2036 		  	 {
       
  2037 			  
       
  2038 			  	
       
  2039 			  	TReal heading = MagneticCourseError.AsTReal() ;
       
  2040 			  	data.Num(heading , format);
       
  2041 			  	
       
  2042 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  2043 			  	
       
  2044 			  	LogFile.Write(_L8("\n MagneticCourseError Error")) ;
       
  2045 			  	LogFile.Write(data) ;
       
  2046 			  		
       
  2047 		  	 }
       
  2048 	  	 
       
  2049 		  		
       
  2050 	  	 }
       
  2051 		  	 
       
  2052 		  	 
       
  2053 		
       
  2054 		TLiwVariant NmeaNum ;
       
  2055 		index = LocMap->FindL(_L8("NMEASentence") , NmeaNum ) ;  	 
       
  2056 	  
       
  2057 	  
       
  2058 	  if(index)
       
  2059 	  	 {
       
  2060 		  	
       
  2061 		  	TInt32 NMEASentence = NmeaNum.AsTInt32() ;
       
  2062 		  	data.Num(NMEASentence , format);
       
  2063 		  	
       
  2064 		  	LogFile.Write(_L8("\nNMEA Information")) ;
       
  2065 		  	
       
  2066 		  	LogFile.Write(_L8("\n number of NMEA Sentences ")) ;
       
  2067 		  	LogFile.Write(data) ;
       
  2068 		  	
       
  2069 		  	index = 0 ;
       
  2070 		  	
       
  2071 		    const TLiwGenericParam *MagneticCourseError  = outputlist->FindFirst(index , _L8("NMEASentenceStart") ) ;
       
  2072 		  
       
  2073 		  	 if(-1 != index)
       
  2074 		  	 {
       
  2075 			  	Variant = MagneticCourseError->Value() ;
       
  2076 			  	
       
  2077 			  
       
  2078 		  	 }
       
  2079 	  	 
       
  2080 		  		
       
  2081 	  	 }
       
  2082 		  	
       
  2083 	  
       
  2084 	 LogFile.Close() ;
       
  2085 	 LogSession.Close() ;
       
  2086   
       
  2087 	locinterface->Close() ;
       
  2088    	delete ServiceHandler ;
       
  2089 	a.ResetAndDestroy() ;
       
  2090 	a.Close() ;
       
  2091 	
       
  2092 __UHEAP_MARKEND ;
       
  2093    return KErrNone ;
       
  2094 
       
  2095 
       
  2096 
       
  2097 }
       
  2098 
       
  2099 
       
  2100 TInt CTestProvider :: CancelWithInvalidTransId(CStifItemParser& /*aItem*/)
       
  2101 	{
       
  2102 	__UHEAP_MARK ;
       
  2103 	RFile LogFile ;
       
  2104 	RFs LogSession ;
       
  2105 	TBuf8<50> data ;
       
  2106 	TRealFormat format ;
       
  2107 	
       
  2108 	
       
  2109 	 if(LogSession.Connect() != KErrNone)
       
  2110 	 {
       
  2111 	 	_LIT(KLog , "Failed to connect to file server") ;
       
  2112 	 	iLog->Log(KLog) ;
       
  2113 	 	return KErrGeneral ;
       
  2114 	 }
       
  2115 	 
       
  2116 	 
       
  2117 	_LIT(LogFileNameCancel , "C:\\cancelinvalid.txt") ;
       
  2118 
       
  2119 	if(LogFile.Open(LogSession ,LogFileNameCancel , EFileWrite | EFileShareAny )  == KErrNotFound)
       
  2120 	{
       
  2121 		if(LogFile.Create(LogSession ,LogFileNameCancel , EFileWrite | EFileShareAny ) != KErrNone)
       
  2122 		{
       
  2123 		 	_LIT(KLog , "Failed to create  log file\n") ;
       
  2124 		 	iLog->Log(KLog) ;
       
  2125 		 	return KErrGeneral ;
       
  2126 		}
       
  2127 
       
  2128 	}
       
  2129 	
       
  2130 	_LIT(KLog , "In CancelWithInvalidTransactionID\n") ;
       
  2131 	data.Copy(KLog);
       
  2132 	LogFile.Write(data) ;
       
  2133 	
       
  2134 	User::After(5000000);
       
  2135 	
       
  2136    
       
  2137 
       
  2138 	CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  2139 
       
  2140 	// Input and output parameter list
       
  2141 	CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  2142 	CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  2143 
       
  2144 
       
  2145 
       
  2146 
       
  2147 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
  2148 
       
  2149 
       
  2150 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  2151 
       
  2152 	RCriteriaArray a;
       
  2153 	a.AppendL(crit);
       
  2154 
       
  2155 	ServiceHandler->AttachL(a) ;
       
  2156 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  2157 
       
  2158 	 
       
  2159 	 
       
  2160 
       
  2161 	TInt pos = 0;
       
  2162 
       
  2163 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  2164 
       
  2165 	if(!errorprm)
       
  2166 	{
       
  2167 		
       
  2168 		return KErrGeneral ;
       
  2169 	}
       
  2170 
       
  2171 
       
  2172 	_LIT8(KDataSource, "ILocation");
       
  2173 	 
       
  2174 	 pos = 0 ;
       
  2175 
       
  2176 	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
  2177 
       
  2178 	if(!genericparm)
       
  2179 	{
       
  2180 		
       
  2181 		return KErrGeneral ;
       
  2182 	}
       
  2183 
       
  2184 	MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  2185 
       
  2186 	
       
  2187 	    
       
  2188 	TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
  2189 
       
  2190 	outputlist->Reset() ;
       
  2191 	inputlist->Reset() ;
       
  2192 	ASyncLocCBF* callBack ;
       
  2193 
       
  2194 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist,KLiwOptASyncronous, callBack);
       
  2195 
       
  2196 	pos = 0 ;
       
  2197 
       
  2198 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
  2199 
       
  2200 	if(!ErrorParm)
       
  2201 	{
       
  2202 		_LIT(Klog , "Success/Failure error code missing from outputlist\n") ;
       
  2203 		data.Copy(Klog);
       
  2204 		LogFile.Write(data) ;
       
  2205 	
       
  2206 		//LogFile.Write(Klog) ;
       
  2207 		return KErrGeneral ;
       
  2208 	}
       
  2209 	
       
  2210 	TInt reqerror = (ErrorParm->Value()).AsTInt32();
       
  2211 	_LIT(Klog , "ERRor code from getlocationasynch  ") ;
       
  2212 	data.Copy(Klog);
       
  2213 	LogFile.Write(data) ;
       
  2214 		
       
  2215 	//LogFile.Write(Klog) ;
       
  2216 	
       
  2217 	TReal64 errordata = reqerror ; 
       
  2218 	data.Num(errordata , format) ;
       
  2219 	
       
  2220 	
       
  2221 	LogFile.Write(data) ;
       
  2222 
       
  2223 	
       
  2224 	pos = 0;
       
  2225 	
       
  2226 	_LIT8(KTransactionId, "TransactionID");
       
  2227 	const TLiwGenericParam *transid =  outputlist->FindFirst(pos ,KTransactionId ) ;
       
  2228 	if(!transid)
       
  2229 	{
       
  2230 		_LIT(KTran,"Missing Transaction ID\n");
       
  2231 		data.Copy(KTran);
       
  2232 		LogFile.Write(data) ;
       
  2233 		//LogFile.Write(KTran);
       
  2234 		return KErrGeneral;
       
  2235 	}
       
  2236 	TInt trid = (transid->Value()).AsTInt32();
       
  2237 	outputlist->Reset() ;
       
  2238 	inputlist->Reset() ;
       
  2239 	
       
  2240 	
       
  2241 	inputlist->AppendL(TLiwGenericParam(KTransactionId,TLiwVariant(trid-2)));
       
  2242 	
       
  2243 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist,KLiwOptCancel);
       
  2244 	
       
  2245 	ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
  2246 
       
  2247 	if(!ErrorParm)
       
  2248 	{
       
  2249 		_LIT(Klog , "Success/Failure error code missing from outputlist in cancel\n ") ;
       
  2250 		data.Copy(Klog);
       
  2251 		LogFile.Write(data) ;
       
  2252 		//LogFile.Write(Klog);
       
  2253 		return KErrGeneral ;
       
  2254 	}
       
  2255 	
       
  2256 	reqerror = (ErrorParm->Value()).AsTInt32();
       
  2257 	
       
  2258 	_LIT(Klog1 , "\nERRor code from cancel  ") ;
       
  2259 	
       
  2260 	data.Copy(Klog1);
       
  2261 	LogFile.Write(data) ;	
       
  2262 	//LogFile.Write(Klog1) ;
       
  2263 	
       
  2264 	errordata = reqerror ; 
       
  2265 	data.Num(errordata , format) ;
       
  2266 	
       
  2267 	
       
  2268 	LogFile.Write(data) ;
       
  2269 	if( SErrNotFound == reqerror )
       
  2270 		{
       
  2271 		reqerror = 0;	
       
  2272 		}
       
  2273 	
       
  2274 	
       
  2275 
       
  2276 	
       
  2277 
       
  2278 
       
  2279 	LogFile.Close() ;
       
  2280 	LogSession.Close() ;
       
  2281 
       
  2282 	locinterface->Close() ;
       
  2283 	delete ServiceHandler ;
       
  2284 	a.ResetAndDestroy() ;
       
  2285 	a.Close() ;
       
  2286 
       
  2287 	__UHEAP_MARKEND ;
       
  2288 	return reqerror ;
       
  2289 
       
  2290 
       
  2291 
       
  2292 	}
       
  2293 
       
  2294  
       
  2295 TInt CTestProvider :: GetLocationSynchWrongUpdateMapType(CStifItemParser& /*aItem*/)
       
  2296 {
       
  2297 __UHEAP_MARK ;
       
  2298 	
       
  2299    
       
  2300     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  2301   
       
  2302     // Input and output parameter list
       
  2303     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  2304     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  2305     
       
  2306     
       
  2307 
       
  2308 
       
  2309 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
  2310 	
       
  2311 
       
  2312 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  2313 
       
  2314 	RCriteriaArray a;
       
  2315 	a.AppendL(crit);
       
  2316 	
       
  2317 	ServiceHandler->AttachL(a) ;
       
  2318    
       
  2319 	
       
  2320 	
       
  2321 	
       
  2322 	
       
  2323 	
       
  2324 	
       
  2325 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  2326 
       
  2327 	 
       
  2328  	 
       
  2329 
       
  2330 	TInt pos = 0;
       
  2331 	
       
  2332 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  2333 	
       
  2334 	if(!errorprm)
       
  2335 	{
       
  2336 	
       
  2337 		return KErrGeneral ;
       
  2338 	}
       
  2339 	
       
  2340 
       
  2341 	_LIT8(KDataSource, "ILocation");
       
  2342 	 
       
  2343 	 pos = 0 ;
       
  2344 
       
  2345  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
  2346 	
       
  2347 	if(!genericparm)
       
  2348 	{
       
  2349 	
       
  2350 		return KErrGeneral ;
       
  2351 	}
       
  2352 	
       
  2353    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  2354   
       
  2355     
       
  2356     TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
  2357     
       
  2358     outputlist->Reset() ;
       
  2359     inputlist->Reset() ;
       
  2360     _LIT8(KLocCategory,"LocationInformationClass");
       
  2361     _LIT16(KBasic,"BasicLocationInformation");
       
  2362     inputlist->AppendL(TLiwGenericParam(KLocCategory,TLiwVariant(KBasic)));
       
  2363     
       
  2364     
       
  2365     
       
  2366     _LIT8(KUpdate,"Updateoptions");
       
  2367     inputlist->AppendL(TLiwGenericParam(KUpdate,TLiwVariant(30)));
       
  2368     
       
  2369     
       
  2370 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist);
       
  2371 	
       
  2372 	pos = 0 ;
       
  2373 	
       
  2374 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
  2375 	
       
  2376 	
       
  2377 	if(!ErrorParm)
       
  2378 	{
       
  2379 		locinterface->Close() ;
       
  2380 	   	delete ServiceHandler ;
       
  2381 		a.ResetAndDestroy() ;
       
  2382 		a.Close() ;
       
  2383 		return KErrGeneral ;
       
  2384 	}
       
  2385 	
       
  2386 	TInt err = (ErrorParm->Value()).AsTInt32();
       
  2387 	
       
  2388 	if( SErrBadArgumentType == err )
       
  2389 	{
       
  2390 		_LIT8(KErrorMessage,"ErrorMessage");
       
  2391 		_LIT(KNone,"Error");
       
  2392 		
       
  2393 		TPtrC errorstring(KNone);
       
  2394 		pos = 0;
       
  2395 		const TLiwGenericParam *ErrorParmstring =  outputlist->FindFirst(pos ,KErrorMessage ) ;
       
  2396 		TLiwVariant variant =  ErrorParmstring->Value();
       
  2397 	    errorstring.Set( variant.AsDes() );
       
  2398 		
       
  2399 		locinterface->Close() ;
       
  2400 	   	delete ServiceHandler ;
       
  2401 		a.ResetAndDestroy() ;
       
  2402 		a.Close() ;
       
  2403 		__UHEAP_MARKEND ;
       
  2404 		return KErrNone;	
       
  2405 	}
       
  2406 	
       
  2407 
       
  2408 	
       
  2409 	    
       
  2410 
       
  2411 		  	
       
  2412 	  
       
  2413 	locinterface->Close() ;
       
  2414    	delete ServiceHandler ;
       
  2415 	a.ResetAndDestroy() ;
       
  2416 	a.Close() ;
       
  2417 	
       
  2418 __UHEAP_MARKEND ;
       
  2419    return err ;
       
  2420 
       
  2421 
       
  2422 
       
  2423 }
       
  2424  
       
  2425 
       
  2426 TInt CTestProvider :: CTestGetLocation()
       
  2427 {
       
  2428 __UHEAP_MARK ;
       
  2429 	RFile LogFile ;
       
  2430 	RFs LogSession ;
       
  2431 	TBuf8<50> data ;
       
  2432 	TRealFormat format ;
       
  2433 	
       
  2434 	
       
  2435 	 if(LogSession.Connect() != KErrNone)
       
  2436 	 {
       
  2437 	 	_LIT(KLog , "Failed to connect to file server") ;
       
  2438 	 	iLog->Log(KLog) ;
       
  2439 	 	return KErrGeneral ;
       
  2440 	 }
       
  2441 	 
       
  2442 	 
       
  2443 
       
  2444 
       
  2445 	if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny )  == KErrNotFound)
       
  2446 	{
       
  2447 		if(LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) != KErrNone)
       
  2448 		{
       
  2449 		 	_LIT(KLog , "Failed to create notifications log file") ;
       
  2450 		 	iLog->Log(KLog) ;
       
  2451 		 	return KErrGeneral ;
       
  2452 		}
       
  2453 
       
  2454 	}
       
  2455 	
       
  2456 	_LIT(KLog , "In CTGetLocation") ;
       
  2457 	iLog->Log(KLog) ;
       
  2458 	
       
  2459    
       
  2460     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  2461   
       
  2462     // Input and output parameter list
       
  2463     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  2464     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  2465     
       
  2466     
       
  2467 
       
  2468 
       
  2469 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
  2470 	
       
  2471 
       
  2472 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  2473 
       
  2474 	RCriteriaArray a;
       
  2475 	a.AppendL(crit);
       
  2476 	
       
  2477 	ServiceHandler->AttachL(a) ;
       
  2478    
       
  2479 	
       
  2480 	
       
  2481 	
       
  2482 	
       
  2483 	
       
  2484 	
       
  2485 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  2486 
       
  2487 	 
       
  2488  	 
       
  2489 
       
  2490 	TInt pos = 0;
       
  2491 	
       
  2492 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  2493 	
       
  2494 	if(!errorprm)
       
  2495 	{
       
  2496 		_LIT(Klog , "Success/Failure error code missing from outputlist") ;
       
  2497 		iLog->Log(Klog) ;
       
  2498 		return KErrGeneral ;
       
  2499 	}
       
  2500 	
       
  2501 
       
  2502 	_LIT8(KDataSource, "ILocation");
       
  2503 	 
       
  2504 	 pos = 0 ;
       
  2505 
       
  2506  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
  2507 	
       
  2508 	if(!genericparm)
       
  2509 	{
       
  2510 		_LIT(KLog , "Interface not found");
       
  2511 		iLog->Log(KLog) ;
       
  2512 		return KErrGeneral ;
       
  2513 	}
       
  2514 	
       
  2515    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  2516   
       
  2517   
       
  2518     
       
  2519     TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
  2520     
       
  2521     outputlist->Reset() ;
       
  2522     inputlist->Reset() ;
       
  2523     
       
  2524 	locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist);
       
  2525 	
       
  2526 	pos = 0 ;
       
  2527 	
       
  2528 	const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
  2529 	
       
  2530 	if(!ErrorParm)
       
  2531 	{
       
  2532 		_LIT(Klog, "Success/Failure state not known") ;
       
  2533 		iLog->Log(Klog) ;
       
  2534 		return KErrGeneral ;
       
  2535 	}
       
  2536 	
       
  2537 	if((ErrorParm->Value()).AsTInt32() )
       
  2538 	{
       
  2539 		_LIT(KLog , "ExecutecmdL failed ");
       
  2540 		iLog->Log(KLog) ;
       
  2541 		return (ErrorParm->Value()).AsTInt32() ;	
       
  2542 	}
       
  2543 	
       
  2544 
       
  2545 	
       
  2546 	    TInt index = 0 ;
       
  2547 
       
  2548 		const TLiwGenericParam *GenericParam  = outputlist->FindFirst(index , KLocationMap);
       
  2549 
       
  2550 		
       
  2551 		if(!GenericParam)
       
  2552 		{
       
  2553 			_LIT(Klog, "Out Param not found") ;
       
  2554 	    	iLog->Log(Klog) ;
       
  2555 			return KErrGeneral ; //Param Error
       
  2556 		}	
       
  2557 
       
  2558 		TLiwVariant Variant ;
       
  2559 
       
  2560 		Variant = GenericParam->Value() ;
       
  2561 		const	CLiwMap *LocMap = Variant.AsMap() ;
       
  2562 
       
  2563 		TLiwVariant PosVariant ;
       
  2564 
       
  2565 		LocMap->FindL(KLongitudeKey , PosVariant) ;
       
  2566 		TReal64 LongData = (TReal64)PosVariant.AsTReal() ; //Longitude
       
  2567 		data.Num(LongData , format) ;
       
  2568 		LogFile.Write(_L8("\n")) ;
       
  2569 		LogFile.Write(_L8("Logitude = ")) ;
       
  2570 		LogFile.Write(data) ;
       
  2571 
       
  2572 		LocMap->FindL(KLatitudeKey ,PosVariant) ; //Latitude 
       
  2573 
       
  2574 		TReal64 LatData = (TReal64)PosVariant.AsTReal() ;
       
  2575 		data.Num(LatData , format) ;
       
  2576 		LogFile.Write(_L8("   Latitude = ")) ;
       
  2577 		LogFile.Write(data) ;
       
  2578 
       
  2579 		LocMap->FindL(KAltitudeKey , PosVariant) ; //Altitude
       
  2580 		TReal32 AltData = PosVariant.AsTReal() ;
       
  2581 		data.Num(AltData , format) ;
       
  2582 
       
  2583 		LogFile.Write(_L8("   Altitude = "))	 ;
       
  2584 		LogFile.Write(data) ;
       
  2585 
       
  2586 	 
       
  2587         TLiwVariant Speed ;
       
  2588 	    
       
  2589 	    index = LocMap->FindL(_L8("HorizontalSpeed") , Speed ) ;
       
  2590 	  
       
  2591 	   if(index )
       
  2592 	     {
       
  2593 		
       
  2594 		 TReal speed =  Speed.AsTReal() ;
       
  2595 
       
  2596 		 data.Num(speed , format) ;
       
  2597 
       
  2598 		LogFile.Write(_L8("Speed = ")) ;
       
  2599 		LogFile.Write(data) ;
       
  2600 
       
  2601 	   }
       
  2602 	   
       
  2603 	  
       
  2604 	  TLiwVariant SpeedError ;
       
  2605 	  index = LocMap->FindL( _L8("HorizontalSpeedError") , SpeedError) ;
       
  2606 	  
       
  2607 	 
       
  2608 	  if(index )
       
  2609 	  {
       
  2610 	
       
  2611 		TReal speed =  SpeedError.AsTReal() ;
       
  2612 
       
  2613 		data.Num(speed , format) ;
       
  2614 
       
  2615 		LogFile.Write(_L8("Speed = ")) ;
       
  2616 		LogFile.Write(data) ;
       
  2617 
       
  2618 	  }
       
  2619 	  
       
  2620 	  index = 0 ;
       
  2621 	  
       
  2622 	  TLiwVariant SatInfo ;
       
  2623 	  
       
  2624 	  index = LocMap->FindL(_L8("SatelliteNumView") , SatInfo) ;
       
  2625 	  
       
  2626 	  if(index )
       
  2627 	  {
       
  2628 	  	
       
  2629 	  	TInt satnumView = SatInfo.AsTInt32() ;
       
  2630 	  	data.Num(satnumView , format);
       
  2631 	  	
       
  2632 	  	LogFile.Write(_L8("Satellite information")) ;
       
  2633 	  	
       
  2634 	  	LogFile.Write(_L8("Number of visible satellites ")) ;
       
  2635 	  	LogFile.Write(data) ;
       
  2636 	  }
       
  2637 	  
       
  2638 	  index = 0 ;
       
  2639 	  
       
  2640 	  TLiwVariant SatInfoview ;
       
  2641 	  
       
  2642 	  index = LocMap->FindL( _L8("SatelliteNumViewUsed") , SatInfoview) ;
       
  2643 	  if(index )
       
  2644 	  {
       
  2645 	  	
       
  2646 	  	
       
  2647 	  	TInt satnumViewUsed = SatInfoview.AsTInt32() ;
       
  2648 	  	data.Num(satnumViewUsed , format);
       
  2649 	  	
       
  2650 	  	LogFile.Write(_L8("\nSatellite information")) ;
       
  2651 	  	
       
  2652 	  	LogFile.Write(_L8("\nSatelliteNumViewUsed")) ;
       
  2653 	  	LogFile.Write(data) ;
       
  2654 	  }
       
  2655 	  
       
  2656 	  index = 0 ;
       
  2657 	   
       
  2658 	  TInt Headinginfo = 0 ;
       
  2659 	  
       
  2660 	  TLiwVariant  Heading ;
       
  2661 	  Headinginfo = LocMap->FindL(_L8("Heading") ,Heading) ;
       
  2662 	  
       
  2663 	  if(Headinginfo)
       
  2664 	  {
       
  2665 	  	
       
  2666 	  	
       
  2667 	  	TReal heading = Heading.AsTReal() ;
       
  2668 	  	data.Num(heading , format);
       
  2669 	  	
       
  2670 	  	LogFile.Write(_L8("\ncompass information")) ;
       
  2671 	  	
       
  2672 	  	LogFile.Write(_L8("\nHeading")) ;
       
  2673 	  	LogFile.Write(data) ;
       
  2674 	  }
       
  2675 	  
       
  2676 	  
       
  2677 	  if(Headinginfo)
       
  2678 	  {
       
  2679 		  	TLiwVariant HeadingError ;
       
  2680 		  	index  = LocMap->FindL( _L8("HeadingError") , HeadingError ) ;
       
  2681 		  	
       
  2682 		  	if(index)
       
  2683 		  	{
       
  2684 			  	
       
  2685 			  	
       
  2686 			  	TReal heading = HeadingError.AsTReal() ;
       
  2687 			  	data.Num(heading , format);
       
  2688 			  	
       
  2689 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  2690 			  	
       
  2691 			  	LogFile.Write(_L8("\nHeading Error")) ;
       
  2692 			  	LogFile.Write(data) ;
       
  2693 		  		
       
  2694 		  	}
       
  2695 		  
       
  2696 		   TLiwVariant MagneticHeading ;
       
  2697 		   index = LocMap->FindL( _L8("MagneticHeading") ,  MagneticHeading) ;
       
  2698 		  	
       
  2699 		  	if(index)
       
  2700 		  	{
       
  2701 			  	
       
  2702 			  	
       
  2703 			  	TReal heading = MagneticHeading.AsTReal() ;
       
  2704 			  	data.Num(heading , format);
       
  2705 			  	
       
  2706 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  2707 			  	
       
  2708 			  	LogFile.Write(_L8("\n MagneticHeading ")) ;
       
  2709 			  	LogFile.Write(data) ;
       
  2710 			  		
       
  2711 		  	}
       
  2712 		  	
       
  2713 		  
       
  2714 		  	TLiwVariant MagneticHeadingError ;
       
  2715 		  	 index = LocMap->FindL(_L8("MagneticHeadingError")  ,MagneticHeadingError) ;
       
  2716 		  	
       
  2717 		  	if(index)
       
  2718 		  	{
       
  2719 			  	
       
  2720 			  	
       
  2721 			  	TReal heading = MagneticHeadingError.AsTReal() ;
       
  2722 			  	data.Num(heading , format);
       
  2723 			  	
       
  2724 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  2725 			  	
       
  2726 			  	LogFile.Write(_L8("\nMagneticHeading Error")) ;
       
  2727 			  	LogFile.Write(data) ;
       
  2728 			  		
       
  2729 		  	}
       
  2730 	  
       
  2731 
       
  2732 	  } //End of Heading
       
  2733 	  
       
  2734 	   
       
  2735 	  
       
  2736 	  TLiwVariant TrueCourse ;
       
  2737 	  index = LocMap->FindL( _L8("TrueCourse") , TrueCourse ) ;
       
  2738 	  
       
  2739 	  if( index)
       
  2740 	  {
       
  2741 	  	
       
  2742 		  
       
  2743 		  	TReal heading = TrueCourse.AsTReal() ;
       
  2744 		  	data.Num(heading , format);
       
  2745 		  	
       
  2746 		  	LogFile.Write(_L8("\nDirection ")) ;
       
  2747 		  	
       
  2748 		  	LogFile.Write(_L8("\n TrueCourse Error")) ;
       
  2749 		  	LogFile.Write(data) ;
       
  2750 		  	
       
  2751 		  	
       
  2752 		  	
       
  2753 		  	 TLiwVariant TrueCourseError ;
       
  2754 		  	 index  = LocMap->FindL( _L8("TrueCourseError") , TrueCourseError ) ;
       
  2755 		  	 
       
  2756 		  	 if( index)
       
  2757 		  	 {
       
  2758 			  
       
  2759 			  	
       
  2760 			  	TReal heading = TrueCourseError.AsTReal() ;
       
  2761 			  	data.Num(heading , format);
       
  2762 			  	
       
  2763 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  2764 			  	
       
  2765 			  	LogFile.Write(_L8("\nMagneticHeading Error")) ;
       
  2766 			  	LogFile.Write(data) ;
       
  2767 			  		
       
  2768 		  	 }
       
  2769 		  	 
       
  2770 		  	
       
  2771 	  }
       
  2772 	  
       
  2773 	  
       
  2774 	 TLiwVariant MagneticCourse ;
       
  2775 	 index =  LocMap->FindL(_L8("MagneticCourse") , MagneticCourse ) ;
       
  2776 	  
       
  2777 	
       
  2778 	   if(index)
       
  2779 	  	 {
       
  2780 		  	
       
  2781 		  	TReal heading = MagneticCourse.AsTReal() ;
       
  2782 		  	data.Num(heading , format);
       
  2783 		  	
       
  2784 		  	LogFile.Write(_L8("\ncompass information")) ;
       
  2785 		  	
       
  2786 		  	LogFile.Write(_L8("\nMagneticCourse ")) ;
       
  2787 		  	LogFile.Write(data) ;
       
  2788 		  	
       
  2789 		  	
       
  2790 		  	
       
  2791 		    TLiwVariant MagneticCourseError  ;
       
  2792 		    index = LocMap->FindL(_L8("MagneticCourseError") ,MagneticCourseError ) ;
       
  2793 		  
       
  2794 		  	 if( index)
       
  2795 		  	 {
       
  2796 			  
       
  2797 			  	
       
  2798 			  	TReal heading = MagneticCourseError.AsTReal() ;
       
  2799 			  	data.Num(heading , format);
       
  2800 			  	
       
  2801 			  	LogFile.Write(_L8("\ncompass information")) ;
       
  2802 			  	
       
  2803 			  	LogFile.Write(_L8("\n MagneticCourseError Error")) ;
       
  2804 			  	LogFile.Write(data) ;
       
  2805 			  		
       
  2806 		  	 }
       
  2807 	  	 
       
  2808 		  		
       
  2809 	  	 }
       
  2810 		  	 
       
  2811 		  	 
       
  2812 		
       
  2813 		TLiwVariant NmeaNum ;
       
  2814 		index = LocMap->FindL(_L8("NMEASentence") , NmeaNum ) ;  	 
       
  2815 	  
       
  2816 	  
       
  2817 	  if(index)
       
  2818 	  	 {
       
  2819 		  	
       
  2820 		  	TInt32 NMEASentence = NmeaNum.AsTInt32() ;
       
  2821 		  	data.Num(NMEASentence , format);
       
  2822 		  	
       
  2823 		  	LogFile.Write(_L8("\nNMEA Information")) ;
       
  2824 		  	
       
  2825 		  	LogFile.Write(_L8("\n number of NMEA Sentences ")) ;
       
  2826 		  	LogFile.Write(data) ;
       
  2827 		  	
       
  2828 		  	index = 0 ;
       
  2829 		  	
       
  2830 		    const TLiwGenericParam *MagneticCourseError  = outputlist->FindFirst(index , _L8("NMEASentenceStart") ) ;
       
  2831 		  
       
  2832 		  	 if(-1 != index)
       
  2833 		  	 {
       
  2834 			  	Variant = MagneticCourseError->Value() ;
       
  2835 			  	
       
  2836 			  
       
  2837 		  	 }
       
  2838 	  	 
       
  2839 		  		
       
  2840 	  	 }
       
  2841 		  	
       
  2842 	  
       
  2843 	 LogFile.Close() ;
       
  2844 	 LogSession.Close() ;
       
  2845   
       
  2846 	locinterface->Close() ;
       
  2847    	delete ServiceHandler ;
       
  2848 	a.ResetAndDestroy() ;
       
  2849 	a.Close() ;
       
  2850 	
       
  2851 __UHEAP_MARKEND ;
       
  2852    return KErrNone ;
       
  2853 
       
  2854 
       
  2855 
       
  2856 }
       
  2857 
       
  2858 
       
  2859 TInt CTestProvider :: GetLocation(CStifItemParser & /*aItem */)
       
  2860 {
       
  2861    __UHEAP_MARK ; 
       
  2862 	TInt ret = CTestGetLocation() ;
       
  2863 	__UHEAP_MARKEND ;
       
  2864 	return ret ;
       
  2865     
       
  2866 }
       
  2867 
       
  2868 
       
  2869 TInt CTestProvider :: LocationUpdates(CStifItemParser& /*aItem*/)
       
  2870 	{
       
  2871 	_LIT(KTLocTest ,"TLocTest");
       
  2872 	iLog->Log(KTLocTest) ;
       
  2873 	
       
  2874 	TRequestStatus Status = KRequestPending  ;
       
  2875 	RThread FunctionThread ;
       
  2876     
       
  2877     TInt ret = FunctionThread.Create(_L(" LocationUpdates Thread") , GetLocUpdates ,KDefaultStackSize , 
       
  2878     						KMinHeapSize , 0x5000 ,(TAny *) NULL);
       
  2879     						
       
  2880     if(!ret)
       
  2881 	    {
       
  2882 	    FunctionThread.Logon(Status)	;
       
  2883 	    FunctionThread.Resume() ;
       
  2884 	    
       
  2885 	    User :: WaitForRequest (Status)	;				
       
  2886 	    FunctionThread.Close();
       
  2887 
       
  2888 		ret = Status.Int() ;
       
  2889 	    }
       
  2890 	   return ret; 
       
  2891 	}    
       
  2892 #if 0 
       
  2893 TInt CTestProvider :: LastKnownLoc(CStifItemParser& /*aItem*/)
       
  2894 	{
       
  2895 		return KErrNone ;
       
  2896 	}
       
  2897 #endif	
       
  2898 	
       
  2899 TInt  CTestProvider ::GetLocationAsynch(CStifItemParser& /*aItem*/)
       
  2900 	{
       
  2901 	
       
  2902 	
       
  2903 	TRequestStatus Status = KRequestPending  ;
       
  2904 	RThread FunctionThread ;
       
  2905     
       
  2906     FunctionThread.Create(_L("GetLocationAsynch Thread") , FindLocationAsynch ,KDefaultStackSize , 
       
  2907     						KMinHeapSize , 0x5000 ,(TAny *) NULL);
       
  2908     						
       
  2909     FunctionThread.Logon(Status)	;
       
  2910     FunctionThread.Resume() ;
       
  2911     
       
  2912     User :: WaitForRequest (Status)	;				
       
  2913      FunctionThread.Close();
       
  2914 
       
  2915 	return Status.Int() ;
       
  2916 	
       
  2917 	
       
  2918 	}
       
  2919 	
       
  2920 	
       
  2921 TInt  CTestProvider ::ServiceNotAvailable(CStifItemParser& /*aItem*/)
       
  2922 {
       
  2923   
       
  2924 	
       
  2925 	
       
  2926 	 _LIT8(KService, "Service.Location");
       
  2927     _LIT8(KIDataSource,"ILocation");
       
  2928    
       
  2929    return KErrNone ; //Manual test case 
       
  2930     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  2931   
       
  2932     // Input and output parameter list
       
  2933     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  2934     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  2935     
       
  2936     
       
  2937 
       
  2938 
       
  2939 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KService, KIDataSource);
       
  2940 	
       
  2941 
       
  2942 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  2943 
       
  2944 	RCriteriaArray a;
       
  2945 	a.AppendL(crit);
       
  2946 	
       
  2947 	ServiceHandler->AttachL(a) ;
       
  2948    
       
  2949 	
       
  2950 	 
       
  2951  	 
       
  2952 
       
  2953 	TInt pos = 0;
       
  2954 	
       
  2955 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  2956 	
       
  2957 	if(!errorprm)
       
  2958 	{
       
  2959 		_LIT(Klog , "Success/Failure error code missing from outputlist") ;
       
  2960 		iLog->Log(Klog) ;
       
  2961 		return KErrGeneral ;
       
  2962 	}
       
  2963 	
       
  2964 
       
  2965 	_LIT8(KDataSource, "ILocation");
       
  2966 
       
  2967  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
  2968 	
       
  2969 	if(!genericparm)
       
  2970 	{
       
  2971 		_LIT(KLog , "Interface not found");
       
  2972 		iLog->Log(KLog) ;
       
  2973 		return KErrGeneral ;
       
  2974 	}
       
  2975 	
       
  2976    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  2977 
       
  2978 
       
  2979 	TInt result = KErrGeneral ;
       
  2980 	TInt error ;
       
  2981 	TInt index = 0;
       
  2982     
       
  2983 	
       
  2984 	//	CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
  2985 	TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
  2986 	CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
  2987 
       
  2988 	locinterface->ExecuteCmdL(CmdBuf , *InputList , *InputList );
       
  2989 	const TLiwGenericParam *GenericParam = InputList->FindFirst(index , KErrorCode ) ;
       
  2990 
       
  2991 	if(GenericParam)
       
  2992 	{
       
  2993 		TLiwVariant ErrorVariant = GenericParam->Value() ;
       
  2994 		
       
  2995 		error = ErrorVariant.AsTInt32();
       
  2996 	}
       
  2997 
       
  2998 	if((error == KErrNotFound  ) || (error == KPositionQualityLoss))
       
  2999 	{
       
  3000 		_LIT(KLog , "positioning  technology not available") ;
       
  3001 		iLog->Log(KLog) ;
       
  3002 		result = KErrNone  ;
       
  3003 	} 
       
  3004 
       
  3005 	
       
  3006 	locinterface->Close() ;
       
  3007 	delete 	InputList ;
       
  3008 	delete ServiceHandler ;
       
  3009 	
       
  3010 	a.ResetAndDestroy() ;
       
  3011 	//	delete  OutParmList ;
       
  3012 	
       
  3013 	return result  ;
       
  3014 
       
  3015 }
       
  3016  
       
  3017 
       
  3018 
       
  3019 /*
       
  3020  * This is a manual test case were the service was available when the 
       
  3021  * request was made and then   Lost the service (Contact to location servier lost
       
  3022  */
       
  3023  
       
  3024   
       
  3025 TInt CTestProvider :: ServiceFailed(CStifItemParser& /*aItem*/)
       
  3026 {
       
  3027 	_LIT(KTLocTest ,"TLocTest");
       
  3028 	iLog->Log(KTLocTest) ;
       
  3029 	_LIT(KLog , "In service failed test ") ;
       
  3030 	iLog->Log(KTLocTest) ;
       
  3031 	
       
  3032 	return KErrNone ; //Manual test case 
       
  3033 	TRequestStatus Status = KRequestPending  ;
       
  3034 	RThread FunctionThread ;
       
  3035     
       
  3036     TInt ret =  FunctionThread.Create(_L("ServiceFailed Thread") , ServiceFailedTest ,KDefaultStackSize , 
       
  3037     						KMinHeapSize , 0x5000 ,(TAny *) NULL);;
       
  3038     						
       
  3039     if(!ret)
       
  3040 	    {
       
  3041 	    
       
  3042 	    _LIT(Klog , "Created the thread ") ;
       
  3043 	    iLog->Log(Klog) ;
       
  3044 	    FunctionThread.Logon(Status)	;
       
  3045 	    FunctionThread.Resume() ;
       
  3046 	    
       
  3047 	    User :: WaitForRequest (Status)	;				
       
  3048 	    FunctionThread.Close();
       
  3049 
       
  3050 		ret = Status.Int() ;
       
  3051 	    }
       
  3052 	    
       
  3053 	
       
  3054 	if((ret == KErrNotFound  ) || (ret == KPositionQualityLoss))
       
  3055 		{
       
  3056 		_LIT(KLog , "Service provider crashed or went dowm") ;
       
  3057 		iLog->Log(KLog) ;
       
  3058 		}
       
  3059 		
       
  3060 		
       
  3061 	   return ret;	
       
  3062 }
       
  3063 
       
  3064 
       
  3065 
       
  3066 /**
       
  3067  *Stray signal test, tests for any unhandled events from location server
       
  3068  */
       
  3069 
       
  3070 TInt CTestProvider :: StraySignal(CStifItemParser& /*aItem*/)
       
  3071 {
       
  3072 	_LIT(KTLocTest ,"TLocTest");
       
  3073 	iLog->Log(KTLocTest) ;
       
  3074 	_LIT(KLog , "StraySignalTest ") ;
       
  3075 	iLog->Log(KTLocTest) ;
       
  3076 	
       
  3077 	TRequestStatus Status = KRequestPending  ;
       
  3078 	RThread FunctionThread ;
       
  3079     
       
  3080     TInt ret =  FunctionThread.Create(_L("stray signal") , StrayTest ,KDefaultStackSize , 
       
  3081     						KMinHeapSize , 0x5000 ,(TAny *) NULL);;
       
  3082     						
       
  3083     if(!ret)
       
  3084 	    {
       
  3085 	    
       
  3086 	    _LIT(Klog , "Created the thread ") ;
       
  3087 	    iLog->Log(Klog) ;
       
  3088 	    FunctionThread.Logon(Status)	;
       
  3089 	    FunctionThread.Resume() ;
       
  3090 	    
       
  3091 	    User :: WaitForRequest (Status)	;				
       
  3092 	    FunctionThread.Close();
       
  3093 
       
  3094 		ret = Status.Int() ;
       
  3095 	    }
       
  3096 	   
       
  3097 	   return ret;	
       
  3098 }
       
  3099 
       
  3100 
       
  3101 
       
  3102 TInt CTestProvider :: StraySignalGetLoc(CStifItemParser& /*aItem*/)
       
  3103 {
       
  3104 	_LIT(KTLocTest ,"TLocTest");
       
  3105 	iLog->Log(KTLocTest) ;
       
  3106 	_LIT(KLog , "StraySignalTestGetLoc ") ;
       
  3107 	iLog->Log(KTLocTest) ;
       
  3108 	
       
  3109 	TRequestStatus Status = KRequestPending  ;
       
  3110 	RThread FunctionThread ;
       
  3111     
       
  3112     TInt ret =  FunctionThread.Create(_L("stray signal GetLocation") , StrayTestGetLoc ,KDefaultStackSize , 
       
  3113     						KMinHeapSize , 0x5000 ,(TAny *) NULL);;
       
  3114     						
       
  3115     if(!ret)
       
  3116 	    {
       
  3117 	    
       
  3118 	    _LIT(Klog , "Created the thread ") ;
       
  3119 	    iLog->Log(Klog) ;
       
  3120 	    FunctionThread.Logon(Status)	;
       
  3121 	    FunctionThread.Resume() ;
       
  3122 	    
       
  3123 	    User :: WaitForRequest (Status)	;				
       
  3124 	    FunctionThread.Close();
       
  3125 
       
  3126 		ret = Status.Int() ;
       
  3127 	    }
       
  3128 	    
       
  3129 		
       
  3130 	   return ret;	
       
  3131 }
       
  3132 
       
  3133 TInt CTestProvider :: ConcurrentCallsGetLoc (CStifItemParser& /*aItem*/)
       
  3134 {
       
  3135 _LIT(KTLocTest ,"TLocTest");
       
  3136 	iLog->Log(KTLocTest) ;
       
  3137 	
       
  3138 	TRequestStatus Status = KRequestPending  ;
       
  3139 	RThread FunctionThread ;
       
  3140     
       
  3141     TInt ret = FunctionThread.Create(_L(" ConcurrentCallsGetLoc Thread") , ConcurrentGetLocationCalls ,KDefaultStackSize , 
       
  3142     						KMinHeapSize , 0x5000 ,(TAny *) NULL);
       
  3143     						
       
  3144     if(ret == KErrNone)
       
  3145 	    {
       
  3146 	    FunctionThread.Logon(Status)	;
       
  3147 	    FunctionThread.Resume() ;
       
  3148 	    
       
  3149 	    User :: WaitForRequest (Status)	;				
       
  3150 	    
       
  3151 
       
  3152 	   ret = Status.Int() ;
       
  3153 	    }
       
  3154 	  FunctionThread.Close();  
       
  3155 	  
       
  3156 	  if(ret == SErrServiceInUse)
       
  3157 	    return KErrNone ;
       
  3158 	  
       
  3159 	   return KErrGeneral; 
       
  3160 }
       
  3161 
       
  3162 
       
  3163 TInt CTestProvider :: ConcurrentCallsTrace (CStifItemParser& /*aItem*/)
       
  3164 {
       
  3165 _LIT(KTLocTest ,"TLocTest");
       
  3166 	iLog->Log(KTLocTest) ;
       
  3167 	
       
  3168 	TRequestStatus Status = KRequestPending  ;
       
  3169 	RThread FunctionThread ;
       
  3170     
       
  3171     TInt ret = FunctionThread.Create(_L(" ConcurrentCallsGetLoc Thread") , TraceConcurrent ,KDefaultStackSize , 
       
  3172     						KMinHeapSize , 0x5000 ,(TAny *) NULL);
       
  3173     						
       
  3174     if(ret == KErrNone)
       
  3175 	    {
       
  3176 	    FunctionThread.Logon(Status)	;
       
  3177 	    FunctionThread.Resume() ;
       
  3178 	    
       
  3179 	    User :: WaitForRequest (Status)	;				
       
  3180 	    
       
  3181 
       
  3182 	   ret = Status.Int() ;
       
  3183 	    }
       
  3184 	  FunctionThread.Close();  
       
  3185 	  
       
  3186 	  if(ret == SErrServiceInUse)
       
  3187 	  	{
       
  3188 	  	  _LIT(KLog , "Return Type is valid");
       
  3189 	  	  iLog->Log(KLog);
       
  3190 	  	}
       
  3191 	  
       
  3192 	  else
       
  3193 	  	{
       
  3194 	  	 _LIT(KLog , "Return type is not valid\n") ;
       
  3195 	  	 iLog->Log(KLog) ;	
       
  3196 	  	}	
       
  3197 	    return KErrNone ;
       
  3198 	  
       
  3199 	   return KErrGeneral; 
       
  3200 }
       
  3201 
       
  3202 
       
  3203 /**
       
  3204  *Cancel test, to test cancel functionality
       
  3205  */
       
  3206 TInt CTestProvider :: EmptyCancelTraceTest(CStifItemParser& /*aItem*/)
       
  3207     {
       
  3208      __UHEAP_MARK ;
       
  3209      _LIT(KLog , "CancellTest") ;
       
  3210         
       
  3211      
       
  3212 	iLog->Log(KLog) ;
       
  3213 	
       
  3214   	
       
  3215 	 
       
  3216     
       
  3217 	
       
  3218     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  3219   
       
  3220     // Input and output parameter list
       
  3221     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  3222     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  3223     
       
  3224     
       
  3225 
       
  3226 
       
  3227 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
  3228 	
       
  3229 
       
  3230 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  3231 
       
  3232 	RCriteriaArray a;
       
  3233 	a.AppendL(crit);
       
  3234 	
       
  3235 	ServiceHandler->AttachL(a) ;
       
  3236 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  3237 
       
  3238 	 
       
  3239  	 
       
  3240 
       
  3241 	TInt pos = 0;
       
  3242 	
       
  3243 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  3244 	
       
  3245 	if(!errorprm)
       
  3246 	{
       
  3247 		return KErrGeneral ;
       
  3248 	}
       
  3249 	
       
  3250     pos = 0 ;
       
  3251  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
  3252 	
       
  3253 	if(!genericparm)
       
  3254 	{
       
  3255 	
       
  3256 		return KErrGeneral ;
       
  3257 	}
       
  3258 	
       
  3259    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  3260 	
       
  3261    _LIT8(KCancell , "CancelNotification") ;
       
  3262    _LIT8( KType ,"CancelRequestType") ;
       
  3263    _LIT8( KTraceCancel ,"TraceCancel") ;
       
  3264    inputlist->AppendL(TLiwGenericParam (KType , TLiwVariant (KTraceCancel))) ;
       
  3265    
       
  3266    locinterface->ExecuteCmdL(KCancell , *inputlist , *outputlist) ;
       
  3267    
       
  3268    pos = 0 ;
       
  3269    const TLiwGenericParam  *errprm = outputlist->FindFirst(pos , KErrCode) ;
       
  3270    
       
  3271    if(!errprm)
       
  3272     {
       
  3273         _LIT(Kerr, "Success/Failure code missing from outputlist") ;
       
  3274         iLog->Log(Kerr) ;
       
  3275     }
       
  3276    
       
  3277    
       
  3278    TInt ret = KErrGeneral ; //Return Code
       
  3279    TLiwVariant var = errprm->Value() ;
       
  3280    
       
  3281    if(var.AsTInt32() == SErrBadArgumentType )
       
  3282         {
       
  3283             ret= KErrNone ;
       
  3284         }
       
  3285     else
       
  3286         {
       
  3287          _LIT(KDebugMsg , "Return and expected values are different") ;
       
  3288         iLog->Log(KDebugMsg) ; 
       
  3289         }
       
  3290    
       
  3291    locinterface->Close() ;
       
  3292    delete ServiceHandler ;
       
  3293    a.ResetAndDestroy() ;
       
  3294    a.Close() ;
       
  3295 	
       
  3296 __UHEAP_MARKEND ;	
       
  3297      
       
  3298     
       
  3299     
       
  3300     
       
  3301     return ret ;
       
  3302    
       
  3303     }
       
  3304 
       
  3305 /**
       
  3306  *Cancel test, to test cancel functionality
       
  3307  */
       
  3308 TInt CTestProvider :: EmptyCancelGetLocTest(CStifItemParser& /*aItem*/)
       
  3309     {
       
  3310      _LIT(KLog , "CancellTest") ;
       
  3311      iLog->Log(KLog) ;
       
  3312 	
       
  3313 	__UHEAP_MARK ;
       
  3314 	
       
  3315     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  3316   
       
  3317     // Input and output parameter list
       
  3318     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  3319     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  3320     
       
  3321     
       
  3322 
       
  3323 
       
  3324 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
  3325 	
       
  3326 
       
  3327 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  3328 
       
  3329 	RCriteriaArray a;
       
  3330 	a.AppendL(crit);
       
  3331 	
       
  3332 	ServiceHandler->AttachL(a) ;
       
  3333 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  3334 
       
  3335 	 
       
  3336  	 
       
  3337 
       
  3338 	TInt pos = 0;
       
  3339 	
       
  3340 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  3341 	
       
  3342 	if(!errorprm)
       
  3343 	{
       
  3344 		return KErrGeneral ;
       
  3345 	}
       
  3346 	
       
  3347     pos = 0 ;
       
  3348  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
  3349 	
       
  3350 	if(!genericparm)
       
  3351 	{
       
  3352 	
       
  3353 		return KErrGeneral ;
       
  3354 	}
       
  3355 	
       
  3356    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  3357 	
       
  3358   
       
  3359   
       
  3360 
       
  3361    _LIT8(KCancell , "CancelNotification") ;
       
  3362    _LIT8( KType ,"CancelRequestType") ;
       
  3363    _LIT8( KGetLocCancel ,"GetLocCancel") ;
       
  3364    inputlist->AppendL(TLiwGenericParam (KType , TLiwVariant (KGetLocCancel))) ;
       
  3365    
       
  3366    locinterface->ExecuteCmdL(KCancell , *inputlist , *outputlist) ;
       
  3367    
       
  3368    pos = 0 ;
       
  3369    const TLiwGenericParam  *errprm = outputlist->FindFirst(pos , KErrCode) ;
       
  3370    
       
  3371    if(!errprm)
       
  3372     {
       
  3373         _LIT(Kerr, "Success/Failure code missing from outputlist") ;
       
  3374         iLog->Log(Kerr) ;
       
  3375     }
       
  3376    
       
  3377    
       
  3378   TInt ret = KErrGeneral ; 
       
  3379    
       
  3380    if((errprm->Value()).AsTInt32() == SErrBadArgumentType)
       
  3381     {
       
  3382         ret = KErrNone  ;
       
  3383     }
       
  3384     
       
  3385    locinterface->Close() ;
       
  3386    
       
  3387    //delete inlist ;
       
  3388    //Sdelete outlist ;
       
  3389    delete ServiceHandler ;
       
  3390    a.ResetAndDestroy() ;
       
  3391    a.Close() ;
       
  3392   __UHEAP_MARKEND ; 
       
  3393  
       
  3394    return ret ;
       
  3395    
       
  3396     }
       
  3397 
       
  3398 /**
       
  3399  *Cancel test, with wrong notification
       
  3400  */
       
  3401 TInt CTestProvider :: CancelWrongNotification1(CStifItemParser& /*aItem*/)
       
  3402     {
       
  3403     
       
  3404    
       
  3405 	_LIT(KTLocTest ,"TLocTest");
       
  3406 	iLog->Log(KTLocTest) ;
       
  3407 	_LIT(KLog , "StraySignalTest ") ;
       
  3408 	iLog->Log(KTLocTest) ;
       
  3409 	
       
  3410 	TRequestStatus Status = KRequestPending  ;
       
  3411 	RThread FunctionThread ;
       
  3412     
       
  3413     TInt ret =  FunctionThread.Create(_L("Wrong Notification GetLoc cancel") , GetLocWrongCancel ,KDefaultStackSize , 
       
  3414     						KMinHeapSize , 0x5000 ,(TAny *) NULL);;
       
  3415     						
       
  3416     if(!ret)
       
  3417 	    {
       
  3418 	    
       
  3419 	    _LIT(Klog , "Created the thread ") ;
       
  3420 	    iLog->Log(Klog) ;
       
  3421 	    FunctionThread.Logon(Status)	;
       
  3422 	    FunctionThread.Resume() ;
       
  3423 	    
       
  3424 	    User :: WaitForRequest (Status)	;				
       
  3425 	    FunctionThread.Close();
       
  3426 
       
  3427 		ret = Status.Int() ;
       
  3428 	    }
       
  3429 	   else
       
  3430 	    {
       
  3431 	        return ret ;
       
  3432 	    }
       
  3433 	    
       
  3434 	   if(ret == SErrBadArgumentType)  
       
  3435 	    {
       
  3436 	        ret = KErrNone ;
       
  3437 	    }
       
  3438 	   /*else
       
  3439 	    {
       
  3440 	        ret = KErrGeneral ;
       
  3441 	    } */
       
  3442 	   return ret;	
       
  3443     }
       
  3444 
       
  3445 
       
  3446 
       
  3447 /**
       
  3448  *Cancel test, with wrong notification issues a Trace request and then calls for getlocation 
       
  3449  * cancellation
       
  3450  */
       
  3451 TInt CTestProvider :: CancelWrongNotification2(CStifItemParser& /*aItem*/)
       
  3452     {
       
  3453     
       
  3454    
       
  3455 	_LIT(KTLocTest ,"TLocTest");
       
  3456 	iLog->Log(KTLocTest) ;
       
  3457 	_LIT(KLog , "CancelWrongNotification2 ") ;
       
  3458 	iLog->Log(KTLocTest) ;
       
  3459 	
       
  3460 	TRequestStatus Status = KRequestPending  ;
       
  3461 	RThread FunctionThread ;
       
  3462     
       
  3463     TInt ret =  FunctionThread.Create(_L("Wrong Notification Trace cancel") , TraceLocWrongCancel ,KDefaultStackSize , 
       
  3464     						KMinHeapSize , 0x5000 ,(TAny *) NULL);;
       
  3465     						
       
  3466     if(!ret)
       
  3467 	    {
       
  3468 	    
       
  3469 	    _LIT(Klog , "Created the thread ") ;
       
  3470 	    iLog->Log(Klog) ;
       
  3471 	    FunctionThread.Logon(Status)	;
       
  3472 	    FunctionThread.Resume() ;
       
  3473 	    
       
  3474 	    User :: WaitForRequest (Status)	;				
       
  3475 	    FunctionThread.Close();
       
  3476 
       
  3477 		ret = Status.Int() ;
       
  3478 	    }
       
  3479 	   else
       
  3480 	    {
       
  3481 	        return ret ;
       
  3482 	    }
       
  3483 	    
       
  3484 	   if(ret == SErrBadArgumentType)  
       
  3485 	    {
       
  3486 	        ret = KErrNone ;
       
  3487 	    }
       
  3488 	   
       
  3489 	   return ret;	
       
  3490     }
       
  3491 
       
  3492 
       
  3493 /**
       
  3494  *Cancel test, Normal cancel test for getlocation 
       
  3495  */
       
  3496 TInt CTestProvider :: GetLocationCancel(CStifItemParser& /*aItem*/)
       
  3497     {
       
  3498     
       
  3499    
       
  3500 	_LIT(KTLocTest ,"TLocTest");
       
  3501 	iLog->Log(KTLocTest) ;
       
  3502 	_LIT(KLog , "Getlocationcancel ") ;
       
  3503 	iLog->Log(KTLocTest) ;
       
  3504 	
       
  3505 	TRequestStatus Status = KRequestPending  ;
       
  3506 	RThread FunctionThread ;
       
  3507     
       
  3508     TInt ret =  FunctionThread.Create(_L("Getlocationcancel ") , GetLocCancel  ,KDefaultStackSize , 
       
  3509     						KMinHeapSize , 0x5000 ,(TAny *) NULL);;
       
  3510     						
       
  3511     if(!ret)
       
  3512 	    {
       
  3513 	    
       
  3514 	    _LIT(Klog , "Created the thread ") ;
       
  3515 	    iLog->Log(Klog) ;
       
  3516 	    FunctionThread.Logon(Status)	;
       
  3517 	    FunctionThread.Resume() ;
       
  3518 	    
       
  3519 	    User :: WaitForRequest (Status)	;				
       
  3520 	    FunctionThread.Close();
       
  3521 
       
  3522 		ret = Status.Int() ;
       
  3523 	    }
       
  3524 	   else
       
  3525 	    {
       
  3526 	        return ret ;
       
  3527 	    }
       
  3528 	    
       
  3529 	   
       
  3530 	   return ret;	
       
  3531     }
       
  3532     
       
  3533 /**
       
  3534  * GetLocation Timeout
       
  3535  */
       
  3536 TInt CTestProvider :: GetLocationTimedOut(CStifItemParser& /*aItem*/)
       
  3537     {
       
  3538     _LIT(KTLocTest ,"TLocTest");
       
  3539     iLog->Log(KTLocTest) ;
       
  3540     _LIT(KLog , "GetLocationTimedOut ") ;
       
  3541     iLog->Log(KTLocTest) ;
       
  3542     
       
  3543 	return KErrNone ; //This is a manul test case
       
  3544     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  3545   
       
  3546     // Input and output parameter list
       
  3547     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  3548     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  3549     
       
  3550     
       
  3551 
       
  3552 
       
  3553 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
  3554 	
       
  3555 
       
  3556 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  3557 
       
  3558 	RCriteriaArray a;
       
  3559 	a.AppendL(crit);
       
  3560 	
       
  3561 	ServiceHandler->AttachL(a) ;
       
  3562 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  3563 
       
  3564 	 
       
  3565  	 
       
  3566 
       
  3567 	TInt pos = 0;
       
  3568 	
       
  3569 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  3570 	
       
  3571 	if(!errorprm)
       
  3572 	{
       
  3573 		return KErrGeneral ;
       
  3574 	}
       
  3575 	
       
  3576     pos = 0 ;
       
  3577  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
  3578 	
       
  3579 	if(!genericparm)
       
  3580 	{
       
  3581 	
       
  3582 		return KErrGeneral ;
       
  3583 	}
       
  3584 	
       
  3585     MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  3586     inputlist->Reset();
       
  3587     outputlist->Reset();
       
  3588     const  TInt Ksecond = 1000000;
       
  3589     const TInt KUpdatetimeOut = 100 ; //*Ksecond ;
       
  3590 
       
  3591     //SetUpdate time out less then 2 second(response time) ;
       
  3592     CLiwMap *UpdateOptsMap = CLiwDefaultMap :: NewL() ;
       
  3593 
       
  3594     UpdateOptsMap->InsertL(KUpdateOptionTimeOut , (TInt32)KUpdatetimeOut) ;
       
  3595 
       
  3596     inputlist->AppendL(TLiwGenericParam (KUpdateOptionMap , TLiwVariant(UpdateOptsMap)) ) ;
       
  3597 
       
  3598     TBuf8<20>CmdBufSet(KCmdGetLocation)  ;
       
  3599 
       
  3600     locinterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist);
       
  3601     UpdateOptsMap->DecRef() ;
       
  3602     
       
  3603     pos = 0 ;
       
  3604     
       
  3605     const TLiwGenericParam *errcode = outputlist->FindFirst(pos , KErrCode) ;
       
  3606     
       
  3607     if(pos == KErrNotFound)
       
  3608         {
       
  3609            _LIT(KLog , "Success/Error Code is missing ") ;
       
  3610            iLog->Log(KLog) ;
       
  3611            return KErrGeneral ;
       
  3612         }
       
  3613     
       
  3614     pos = (errcode->Value()).AsTInt32() ;
       
  3615     
       
  3616     delete ServiceHandler ;
       
  3617     delete crit ;
       
  3618     locinterface->Close() ;
       
  3619     
       
  3620     if(pos == KErrTimedOut)
       
  3621         {
       
  3622             return KErrNone ;
       
  3623         }
       
  3624     
       
  3625     _LIT(Kerr , "Time out value not set correctly") ;
       
  3626     return KErrNone ;
       
  3627     
       
  3628     }
       
  3629 
       
  3630 /**
       
  3631  *Normal Trace cancell test.
       
  3632  */
       
  3633 TInt CTestProvider :: TraceLocationCancel(CStifItemParser& /*aItem*/)
       
  3634     {
       
  3635     
       
  3636    
       
  3637 	_LIT(KTLocTest ,"TLocTest");
       
  3638 	iLog->Log(KTLocTest) ;
       
  3639 	_LIT(KLog , "Getlocationcancel ") ;
       
  3640 	iLog->Log(KTLocTest) ;
       
  3641 	
       
  3642 	TRequestStatus Status = KRequestPending  ;
       
  3643 	RThread FunctionThread ;
       
  3644     
       
  3645     TInt ret =  FunctionThread.Create(_L("Getlocationcancel ") , TraceLocCancel  ,KDefaultStackSize , 
       
  3646     						KMinHeapSize , 0x5000 ,(TAny *) NULL);;
       
  3647     						
       
  3648     if(!ret)
       
  3649 	    {
       
  3650 	    
       
  3651 	    _LIT(Klog , "Created the thread ") ;
       
  3652 	    iLog->Log(Klog) ;
       
  3653 	    FunctionThread.Logon(Status)	;
       
  3654 	    FunctionThread.Resume() ;
       
  3655 	    
       
  3656 	    User :: WaitForRequest (Status)	;				
       
  3657 	    FunctionThread.Close();
       
  3658 
       
  3659 		ret = Status.Int() ;
       
  3660 	    }
       
  3661 	   else
       
  3662 	    {
       
  3663 	        return ret ;
       
  3664 	    }
       
  3665 	    
       
  3666 	   
       
  3667 	   return ret;	
       
  3668     }
       
  3669 
       
  3670 /**
       
  3671  *Math Operation Find distance : Position based parameter
       
  3672  */
       
  3673  TInt CTestProvider :: FindDistanceAgain(CStifItemParser& /*aItem*/)
       
  3674  {
       
  3675  	__UHEAP_MARK;
       
  3676  	TInt start = User::CountAllocCells();
       
  3677  	CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  3678 
       
  3679     // Input and output parameter list
       
  3680     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  3681     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  3682 
       
  3683 
       
  3684 
       
  3685 
       
  3686     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
  3687 
       
  3688 
       
  3689     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  3690 
       
  3691     RCriteriaArray a;
       
  3692     a.AppendL(crit);
       
  3693 
       
  3694     ServiceHandler->AttachL(a) ;
       
  3695     ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  3696     TInt pos = 0;
       
  3697 
       
  3698     const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  3699 
       
  3700     if(!errorprm)
       
  3701         {
       
  3702         return KErrGeneral ;
       
  3703         }
       
  3704 
       
  3705     pos = 0 ;
       
  3706     const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
  3707 
       
  3708     if(!genericparm)
       
  3709         {
       
  3710 
       
  3711         return KErrGeneral ;
       
  3712         }
       
  3713 
       
  3714     MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  3715     
       
  3716     
       
  3717     
       
  3718     TBuf8<20>CmdBuf(KRequestCalculate) ;
       
  3719 
       
  3720 	CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
  3721 	
       
  3722 	TLiwGenericParam requesttype(KNullDesC8 , TLiwVariant(KRequestBearingTo)) ;
       
  3723 	InputList->AppendL(requesttype) ;
       
  3724 	
       
  3725 	//Inserting first input param
       
  3726 	CLiwMap* SourceCoordinate = CLiwDefaultMap::NewL();
       
  3727 	TReal64 slongitude = 22;
       
  3728 	SourceCoordinate->InsertL(KLongitudeKey,TLiwVariant(slongitude));
       
  3729 	TReal64 slatitude = 88;
       
  3730 	SourceCoordinate->InsertL(KLatitudeKey,TLiwVariant(slatitude));
       
  3731 	TReal64 saltitude = 1;
       
  3732 	SourceCoordinate->InsertL(KAltitudeKey,TLiwVariant(slatitude));
       
  3733 	
       
  3734 	TLiwGenericParam scoordinate(KNullDesC8,TLiwVariant(SourceCoordinate));
       
  3735 	InputList->AppendL(scoordinate) ;
       
  3736 	SourceCoordinate->DecRef() ;
       
  3737 	
       
  3738 	
       
  3739 	
       
  3740 	//Inserting 2nd input param
       
  3741 	CLiwDefaultMap* DestCoordinate = CLiwDefaultMap::NewL();
       
  3742 	TReal64 dlongitude = 13;
       
  3743     DestCoordinate->InsertL(KLongitudeKey,TLiwVariant(dlongitude));
       
  3744 	TReal64 dlatitude = 77;
       
  3745 	
       
  3746 	
       
  3747 	DestCoordinate->InsertL(KLatitudeKey,TLiwVariant(dlatitude));
       
  3748 	TReal64 daltitude = 1;
       
  3749 	DestCoordinate->InsertL(KAltitudeKey,TLiwVariant(dlatitude));
       
  3750 	
       
  3751 	TLiwGenericParam dcoordinate(KNullDesC8,TLiwVariant(DestCoordinate));
       
  3752 	InputList->AppendL(dcoordinate) ;
       
  3753 	DestCoordinate->DecRef() ;
       
  3754 	
       
  3755 
       
  3756 	CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
  3757 	
       
  3758 	
       
  3759 	CmdBuf = KRequestCalculate ;
       
  3760 
       
  3761     locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList);
       
  3762 
       
  3763 
       
  3764      pos = 0;
       
  3765     const TLiwGenericParam* param = OutParmList->FindFirst(pos, KErrorCode);
       
  3766 
       
  3767     pos = 0;
       
  3768     const TLiwGenericParam* resultparam = OutParmList->FindFirst(pos, KMathOpResult);		
       
  3769     TLiwVariant resultvariant = resultparam->Value();
       
  3770     TReal32 bearingTo = resultvariant.AsTReal();
       
  3771 
       
  3772 
       
  3773 
       
  3774 
       
  3775     //Logging result into a file
       
  3776     RFile LogFile ;
       
  3777     RFs LogSession ;
       
  3778     TBuf8<50> Buffer(_L8("BearingTo = ")) ;
       
  3779     LogSession.Connect() ;
       
  3780 
       
  3781     if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny )  == KErrNotFound)
       
  3782         {
       
  3783         LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) ;
       
  3784         }
       
  3785 
       
  3786     TInt End = 0 ;
       
  3787 
       
  3788     LogFile.Seek(ESeekEnd , End) ; //Seek to end of the file before writing 
       
  3789 
       
  3790     TBuf8<50> num ;
       
  3791     TRealFormat format ;
       
  3792 
       
  3793     num.Num(bearingTo , format) ;
       
  3794 
       
  3795 
       
  3796     LogFile.Write(_L8("BearingTo= "));
       
  3797     LogFile.Write(num) ;
       
  3798     LogFile.Write(_L8("\n")) ;
       
  3799     LogFile.Close() ;
       
  3800     LogSession.Close() ;
       
  3801 
       
  3802     locinterface->Close() ;
       
  3803     OutParmList->Reset();
       
  3804     InputList->Reset();
       
  3805 	delete OutParmList ;
       
  3806 	delete InputList ;
       
  3807     delete ServiceHandler ;
       
  3808     a.ResetAndDestroy() ;
       
  3809     
       
  3810     TInt end = User::CountAllocCells();
       
  3811  __UHEAP_MARKEND ;   
       
  3812     
       
  3813 
       
  3814 
       
  3815     return KErrNone ;
       
  3816   
       
  3817     
       
  3818 
       
  3819  	
       
  3820  }
       
  3821 /**
       
  3822  * Math operation BearingTo Test
       
  3823  */
       
  3824  
       
  3825  TInt CTestProvider ::BearingToTest(CStifItemParser& /*aItem*/) 
       
  3826     {
       
  3827      __UHEAP_MARK ;
       
  3828         
       
  3829     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  3830 
       
  3831     // Input and output parameter list
       
  3832     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  3833     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  3834 
       
  3835 
       
  3836 
       
  3837 
       
  3838     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
  3839 
       
  3840 
       
  3841     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  3842 
       
  3843     RCriteriaArray a;
       
  3844     a.AppendL(crit);
       
  3845 
       
  3846     ServiceHandler->AttachL(a) ;
       
  3847     ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  3848 
       
  3849      
       
  3850      
       
  3851 
       
  3852     TInt pos = 0;
       
  3853 
       
  3854     const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  3855 
       
  3856     if(!errorprm)
       
  3857         {
       
  3858         return KErrGeneral ;
       
  3859         }
       
  3860 
       
  3861     pos = 0 ;
       
  3862     const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
  3863 
       
  3864     if(!genericparm)
       
  3865         {
       
  3866 
       
  3867         return KErrGeneral ;
       
  3868         }
       
  3869 
       
  3870     MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  3871     TBuf8<20>CmdBuf(KRequestCalculate) ;
       
  3872 
       
  3873 	CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
  3874 	
       
  3875 	TLiwGenericParam requesttype(KMathRequest , TLiwVariant(KRequestBearingTo)) ;
       
  3876 	InputList->AppendL(requesttype) ;
       
  3877 	
       
  3878 	//Inserting first input param
       
  3879 	CLiwMap* SourceCoordinate = CLiwDefaultMap::NewL();
       
  3880 	TReal64 slongitude = 22;
       
  3881 	SourceCoordinate->InsertL(KLongitudeKey,TLiwVariant(slongitude));
       
  3882 	TReal64 slatitude = 88;
       
  3883 	SourceCoordinate->InsertL(KLatitudeKey,TLiwVariant(slatitude));
       
  3884 	TReal64 saltitude = 1;
       
  3885 	SourceCoordinate->InsertL(KAltitudeKey,TLiwVariant(slatitude));
       
  3886 	
       
  3887 	TLiwGenericParam scoordinate(KDistanceParmSource,TLiwVariant(SourceCoordinate));
       
  3888 	InputList->AppendL(scoordinate) ;
       
  3889 	SourceCoordinate->DecRef() ;
       
  3890 	
       
  3891 	
       
  3892 	
       
  3893 	//Inserting 2nd input param
       
  3894 	CLiwMap* DestCoordinate = CLiwDefaultMap::NewL();
       
  3895 	TReal64 dlongitude = 13;
       
  3896     DestCoordinate->InsertL(KLongitudeKey,TLiwVariant(dlongitude));
       
  3897 	TReal64 dlatitude = 77;
       
  3898 	DestCoordinate->InsertL(KLatitudeKey,TLiwVariant(dlatitude));
       
  3899 	TReal64 daltitude = 1;
       
  3900 	DestCoordinate->InsertL(KAltitudeKey,TLiwVariant(dlatitude));
       
  3901 	
       
  3902 	TLiwGenericParam dcoordinate(KDistanceParmDestination,TLiwVariant(DestCoordinate));
       
  3903 	InputList->AppendL(dcoordinate) ;
       
  3904 	DestCoordinate->DecRef() ;
       
  3905 	
       
  3906 
       
  3907 	CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
  3908 	
       
  3909 	
       
  3910 	CmdBuf = KRequestCalculate ;
       
  3911 
       
  3912     locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList);
       
  3913 
       
  3914 
       
  3915      pos = 0;
       
  3916     const TLiwGenericParam* param = OutParmList->FindFirst(pos, KErrorCode);
       
  3917 
       
  3918     pos = 0;
       
  3919     const TLiwGenericParam* resultparam = OutParmList->FindFirst(pos, KMathOpResult);		
       
  3920     TLiwVariant resultvariant = resultparam->Value();
       
  3921     TReal32 bearingTo = resultvariant.AsTReal();
       
  3922 
       
  3923 
       
  3924 
       
  3925 
       
  3926     //Logging result into a file
       
  3927     RFile LogFile ;
       
  3928     RFs LogSession ;
       
  3929     TBuf8<50> Buffer(_L8("BearingTo = ")) ;
       
  3930     LogSession.Connect() ;
       
  3931 
       
  3932     if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny )  == KErrNotFound)
       
  3933         {
       
  3934         LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) ;
       
  3935         }
       
  3936 
       
  3937     TInt End = 0 ;
       
  3938 
       
  3939     LogFile.Seek(ESeekEnd , End) ; //Seek to end of the file before writing 
       
  3940 
       
  3941     TBuf8<50> num ;
       
  3942     TRealFormat format ;
       
  3943 
       
  3944     num.Num(bearingTo , format) ;
       
  3945 
       
  3946 
       
  3947     LogFile.Write(_L8("BearingTo= "));
       
  3948     LogFile.Write(num) ;
       
  3949     LogFile.Write(_L8("\n")) ;
       
  3950     LogFile.Close() ;
       
  3951     LogSession.Close() ;
       
  3952 
       
  3953     delete OutParmList ; 
       
  3954     dcoordinate.Reset() ;
       
  3955     scoordinate.Reset() ;
       
  3956 	delete InputList ;   
       
  3957     locinterface->Close() ;
       
  3958     inputlist->Reset() ;
       
  3959     outputlist->Reset() ;
       
  3960     delete ServiceHandler ;
       
  3961     a.ResetAndDestroy() ;
       
  3962     a.Close() ;
       
  3963   __UHEAP_MARKEND ;  
       
  3964   return KErrNone ;
       
  3965 
       
  3966   
       
  3967  }
       
  3968  
       
  3969  TInt CTestProvider ::FindDistance(CStifItemParser& /*aItem*/) 
       
  3970     {
       
  3971        __UHEAP_MARK ;
       
  3972         CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  3973 
       
  3974         // Input and output parameter list
       
  3975         CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  3976         CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  3977 
       
  3978 
       
  3979 
       
  3980 
       
  3981         CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
  3982 
       
  3983 
       
  3984         crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  3985 
       
  3986         RCriteriaArray a;
       
  3987         a.AppendL(crit);
       
  3988 
       
  3989         ServiceHandler->AttachL(a) ;
       
  3990         ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  3991 
       
  3992 
       
  3993 
       
  3994 
       
  3995         TInt pos = 0;
       
  3996 
       
  3997         const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  3998 
       
  3999         if(!errorprm)
       
  4000         {
       
  4001         return KErrGeneral ;
       
  4002         }
       
  4003 
       
  4004         pos = 0 ;
       
  4005         const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
  4006 
       
  4007         if(!genericparm)
       
  4008         {
       
  4009 
       
  4010         return KErrGeneral ;
       
  4011         }
       
  4012 
       
  4013         MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  4014         //First set the identity information
       
  4015         
       
  4016       ;
       
  4017         TBuf8<20>CmdBufSet(KRequestCalculate) ;
       
  4018         outputlist->Reset() ;
       
  4019         inputlist->Reset() ;
       
  4020        
       
  4021         CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
  4022 
       
  4023         TLiwGenericParam requesttype(KMathRequest , TLiwVariant(KRequestDistance)) ;
       
  4024         InputList->AppendL(requesttype) ;
       
  4025         
       
  4026         
       
  4027 
       
  4028         //Inserting first input param
       
  4029         CLiwMap* SourceCoordinate = CLiwDefaultMap::NewL();
       
  4030         TReal64 slongitude = 71.03;
       
  4031         SourceCoordinate->InsertL(KLongitudeKey,TLiwVariant(slongitude));
       
  4032         TReal64 slatitude = 42.37;
       
  4033         SourceCoordinate->InsertL(KLatitudeKey,TLiwVariant(slatitude));
       
  4034         TReal64 saltitude = 1;
       
  4035 		SourceCoordinate->InsertL(KAltitudeKey,TLiwVariant(slatitude));
       
  4036 
       
  4037         TLiwGenericParam scoordinate(KDistanceParmSource,TLiwVariant(SourceCoordinate));
       
  4038         InputList->AppendL(scoordinate) ;
       
  4039         SourceCoordinate->DecRef() ;
       
  4040 
       
  4041 
       
  4042 
       
  4043         //Inserting 2nd input param
       
  4044         CLiwMap* DestCoordinate = CLiwDefaultMap::NewL();
       
  4045         TReal64 dlongitude = 83.02;
       
  4046         DestCoordinate->InsertL(KLongitudeKey,TLiwVariant(dlongitude));
       
  4047         TReal64 dlatitude = 42.42;
       
  4048         DestCoordinate->InsertL(KLatitudeKey,TLiwVariant(dlatitude));
       
  4049         TReal64 daltitude = 1;
       
  4050 	    DestCoordinate->InsertL(KAltitudeKey,TLiwVariant(dlatitude));
       
  4051 
       
  4052         TLiwGenericParam dcoordinate(KDistanceParmDestination,TLiwVariant(DestCoordinate));
       
  4053         InputList->AppendL(dcoordinate) ;
       
  4054         DestCoordinate->DecRef() ;  
       
  4055 
       
  4056         CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
  4057 
       
  4058 
       
  4059         CmdBufSet = KRequestCalculate ;
       
  4060 
       
  4061         locinterface->ExecuteCmdL(CmdBufSet , *InputList , *OutParmList);
       
  4062 
       
  4063 
       
  4064         pos = 0;
       
  4065         const TLiwGenericParam* param = OutParmList->FindFirst(pos, KErrorCode);
       
  4066 
       
  4067 
       
  4068         pos = 0;
       
  4069         const TLiwGenericParam* resultparam = OutParmList->FindFirst(pos, KMathOpResult);		
       
  4070         TLiwVariant resultvariant = resultparam->Value();
       
  4071         TReal64 distance = resultvariant.AsTReal();
       
  4072 
       
  4073 
       
  4074 
       
  4075 
       
  4076         //Logging result into a file
       
  4077         RFile LogFile ;
       
  4078         RFs LogSession ;
       
  4079         TBuf8<50> Buffer(_L8("Distance = ")) ;
       
  4080         LogSession.Connect() ;
       
  4081 
       
  4082         if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny )  == KErrNotFound)
       
  4083         {
       
  4084         LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) ;
       
  4085 
       
  4086         }
       
  4087 
       
  4088         TInt End = 0 ;
       
  4089 
       
  4090         LogFile.Seek(ESeekEnd , End) ; //Seek to end of the file before writing 
       
  4091 
       
  4092         TBuf8<50> num ;
       
  4093         TRealFormat format ;
       
  4094         //TReal64 Val = aPosition.Latitude() ;
       
  4095         num.Num(distance , format) ;
       
  4096 
       
  4097         //Logging Latitude 
       
  4098         LogFile.Write(_L8("distance = "));
       
  4099         LogFile.Write(num) ;
       
  4100         LogFile.Write(_L8("\n")) ;
       
  4101         LogFile.Close() ;
       
  4102         LogSession.Close() ;
       
  4103         
       
  4104         delete InputList ;
       
  4105         delete OutParmList ;
       
  4106         locinterface->Close() ;
       
  4107         delete ServiceHandler ;
       
  4108         a.ResetAndDestroy() ;
       
  4109         
       
  4110       __UHEAP_MARKEND ;  
       
  4111         return KErrNone ;
       
  4112           
       
  4113 
       
  4114 	
       
  4115 
       
  4116     }
       
  4117     
       
  4118 TInt CTestProvider ::GetLocationUpdateOpts(CStifItemParser& /*aItem*/) 
       
  4119     {
       
  4120 
       
  4121     __UHEAP_MARK;
       
  4122     RFile LogFile ;
       
  4123 	RFs LogSession ;
       
  4124 	TBuf8<50> data ;
       
  4125 	TRealFormat format ;
       
  4126 	LogSession.Connect()  ;
       
  4127     _LIT8(KLog , "GetLocationUpdateOPts") ;
       
  4128     iLog->Log(KLog) ;
       
  4129     
       
  4130     
       
  4131 
       
  4132     if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny )  == KErrNotFound)
       
  4133         {
       
  4134         LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) ;
       
  4135         }
       
  4136 
       
  4137     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  4138 
       
  4139     // Input and output parameter list
       
  4140     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  4141     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  4142 
       
  4143 
       
  4144 
       
  4145 
       
  4146     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
  4147 
       
  4148 
       
  4149     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  4150 
       
  4151     RCriteriaArray a;
       
  4152     a.AppendL(crit);
       
  4153 
       
  4154     ServiceHandler->AttachL(a) ;
       
  4155     ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  4156 
       
  4157      
       
  4158      
       
  4159 
       
  4160     TInt pos = 0;
       
  4161 
       
  4162     const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  4163 
       
  4164     if(!errorprm)
       
  4165         {
       
  4166         return KErrGeneral ;
       
  4167         }
       
  4168 
       
  4169     pos = 0 ;
       
  4170     const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
  4171 
       
  4172     if(!genericparm)
       
  4173         {
       
  4174 
       
  4175         return KErrGeneral ;
       
  4176         }
       
  4177 
       
  4178     MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  4179     
       
  4180     	TBuf8<20>CmdBuf(KCmdGetLocation) ;
       
  4181 
       
  4182 	CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
  4183 	
       
  4184 	//Append LocationInformation Category
       
  4185 	TLiwGenericParam informationCategory(KLocationInfoCategory , TLiwVariant(KLocationBasicinfo)) ;
       
  4186 	InputList->AppendL(informationCategory) ;
       
  4187 	
       
  4188 	//Appending update options
       
  4189 	CLiwMap* updateoptionMap = CLiwDefaultMap::NewL();
       
  4190 	
       
  4191 	TInt32 updateInterval = 30000;
       
  4192 	
       
  4193     updateoptionMap->InsertL(KUpdateOptionInterval,TLiwVariant(updateInterval));
       
  4194 	
       
  4195 	TInt32 updateTimeOut = 10000;
       
  4196 	updateoptionMap->InsertL(KUpdateOptionTimeOut,TLiwVariant(updateTimeOut));
       
  4197 	
       
  4198 	TInt32 updateMaxAge = 2000;
       
  4199 	updateoptionMap->InsertL(KUpdateOptionMaxAge,TLiwVariant(updateMaxAge));
       
  4200 	
       
  4201 	TLiwGenericParam updateOption(KUpdateOptionMap,TLiwVariant(updateoptionMap));
       
  4202 	InputList->AppendL(updateOption) ;
       
  4203 	
       
  4204 	CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
  4205 	
       
  4206 	
       
  4207 	
       
  4208 
       
  4209 	locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList);
       
  4210 	
       
  4211 
       
  4212 	 pos = 0;
       
  4213 	const TLiwGenericParam* param = OutParmList->FindFirst(pos, KErrorCode);
       
  4214 
       
  4215 
       
  4216 	 pos = 0;
       
  4217 	 const TLiwGenericParam* resultparam = OutParmList->FindFirst(pos, KLocationMap);		
       
  4218 	 TLiwVariant resultvariant = resultparam->Value();
       
  4219 	 
       
  4220 	 const CLiwMap *LocMap = resultvariant.AsMap() ;
       
  4221 
       
  4222 	TLiwVariant PosVariant ;
       
  4223 
       
  4224 	LocMap->FindL(KLongitudeKey , PosVariant) ;
       
  4225 
       
  4226 
       
  4227 	TReal64 LongData = (TReal64)PosVariant.AsTReal() ; //Longitude
       
  4228 	data.Num(LongData , format) ;
       
  4229 	LogFile.Write(_L8("\n")) ;
       
  4230 	LogFile.Write(_L8("Logitude = ")) ;
       
  4231 	LogFile.Write(data) ;
       
  4232 
       
  4233 	LocMap->FindL(KLatitudeKey ,PosVariant) ; //Latitude 
       
  4234 
       
  4235 	TReal64 LatData = (TReal64)PosVariant.AsTReal() ;
       
  4236 	data.Num(LatData , format) ;
       
  4237 	LogFile.Write(_L8("   Latitude = ")) ;
       
  4238 	LogFile.Write(data) ;
       
  4239 
       
  4240 	LocMap->FindL(KAltitudeKey , PosVariant) ; //Altitude
       
  4241 	TReal32 AltData = PosVariant.AsTReal() ;
       
  4242 	data.Num(AltData , format) ;
       
  4243 
       
  4244 	LogFile.Write(_L8("   Altitude = "))	 ;
       
  4245 	LogFile.Write(data) ;
       
  4246 	LogFile.Close() ;
       
  4247 	locinterface->Close() ;
       
  4248 	LogSession.Close() ;
       
  4249 
       
  4250     delete ServiceHandler ;
       
  4251     InputList->Reset();
       
  4252     OutParmList->Reset();
       
  4253 	delete InputList ;
       
  4254 	delete OutParmList ;
       
  4255 	__UHEAP_MARKEND;
       
  4256 	return KErrNone ;
       
  4257 
       
  4258     }
       
  4259     
       
  4260  
       
  4261  
       
  4262 void  FillCoordinatesL ( TCoordinate &aCoordinate , const CLiwMap *aMap )
       
  4263 	{
       
  4264 	TLiwVariant longitudevar ;
       
  4265 	TLiwVariant latitudevar ;
       
  4266 	TLiwVariant altitudevar ;
       
  4267 
       
  4268 	aMap->FindL(KLongitudeKey , longitudevar) ;
       
  4269 	aMap->FindL(KLatitudeKey ,  latitudevar) ;
       
  4270 	aMap->FindL(KAltitudeKey , altitudevar ) ;
       
  4271 
       
  4272 	TReal64 latitude = (TReal64)latitudevar.AsTReal() ; 
       
  4273 	TReal64 longitude = (TReal64)longitudevar.AsTReal() ;
       
  4274 	TReal32 altitude = (TReal32)altitudevar.AsTReal() ;
       
  4275 
       
  4276 	aCoordinate.SetCoordinate( latitude , longitude , altitude) ;
       
  4277 
       
  4278 
       
  4279 	}
       
  4280     
       
  4281 /**
       
  4282  * Math Function test Move coordinates
       
  4283  */
       
  4284  
       
  4285  TInt CTestProvider :: MoveCoordinates(CStifItemParser& /*aItem*/)
       
  4286     {
       
  4287 
       
  4288   __UHEAP_MARK ;
       
  4289     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
  4290 
       
  4291     // Input and output parameter list
       
  4292     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
  4293     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
  4294 
       
  4295 
       
  4296 
       
  4297 
       
  4298     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
  4299 
       
  4300 
       
  4301     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
  4302 
       
  4303     RCriteriaArray a;
       
  4304     a.AppendL(crit);
       
  4305 
       
  4306     ServiceHandler->AttachL(a) ;
       
  4307     ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
  4308 
       
  4309 
       
  4310 
       
  4311 
       
  4312     TInt pos = 0;
       
  4313 
       
  4314     const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
  4315 
       
  4316     if(!errorprm)
       
  4317         {
       
  4318         return KErrGeneral ;
       
  4319         }
       
  4320 
       
  4321     pos = 0 ;
       
  4322     const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
  4323 
       
  4324     if(!genericparm)
       
  4325         {
       
  4326 
       
  4327         return KErrGeneral ;
       
  4328         }
       
  4329 
       
  4330     MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
  4331     
       
  4332     TBuf8<20>CmdBuf(KRequestCalculate) ;
       
  4333     outputlist->Reset() ;
       
  4334     inputlist->Reset() ;   
       
  4335 
       
  4336 
       
  4337 	CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
  4338 	
       
  4339 	TLiwGenericParam requesttype(KMathRequest , TLiwVariant(KRequestMove)) ;
       
  4340 	InputList->AppendL(requesttype) ;
       
  4341 
       
  4342 	
       
  4343 	//Inserting first input param
       
  4344 	CLiwMap* SourceCoordinate = CLiwDefaultMap::NewL();
       
  4345 	TReal64 slongitude = 22;
       
  4346 	SourceCoordinate->InsertL(KLongitudeKey,TLiwVariant(slongitude));
       
  4347 	TReal64 slatitude = 88;
       
  4348 	SourceCoordinate->InsertL(KLatitudeKey,TLiwVariant(slatitude));
       
  4349 	
       
  4350 	TReal64 saltitude = 1;
       
  4351 	SourceCoordinate->InsertL(KAltitudeKey,TLiwVariant(saltitude));
       
  4352 	
       
  4353 	
       
  4354 	
       
  4355 	TLiwGenericParam scoordinate(KDistanceParmSource,TLiwVariant(SourceCoordinate));
       
  4356 	InputList->AppendL(scoordinate) ;
       
  4357 	SourceCoordinate->DecRef() ;
       
  4358 	
       
  4359 	
       
  4360 	
       
  4361 	TReal32 distanceToMove = 345;
       
  4362 	TReal32 bearingToMove = 45;
       
  4363 	
       
  4364 	
       
  4365 	//Inserting distance by which coordinate should be moved
       
  4366 	TLiwVariant distanceVal((TReal)distanceToMove);
       
  4367 	TLiwGenericParam distanceParam(KDistanceMove,distanceVal);
       
  4368 	InputList->AppendL(distanceParam);
       
  4369 	
       
  4370 	//Inserting bearing by which coordinate should be moved
       
  4371 	TLiwVariant bearingVal((TReal)bearingToMove);
       
  4372 	TLiwGenericParam bearingParam(KBearingMove,bearingVal);
       
  4373 	InputList->AppendL(bearingParam);
       
  4374 	
       
  4375 	
       
  4376 	
       
  4377 	
       
  4378 
       
  4379 	CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
  4380 	
       
  4381 	
       
  4382 	
       
  4383 
       
  4384 	locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList);
       
  4385 	
       
  4386 
       
  4387 	
       
  4388 	
       
  4389 	
       
  4390       	TInt mathindex = 0;
       
  4391 			
       
  4392 		// calculation							  						
       
  4393 		const TLiwGenericParam *smapparam = OutParmList->FindFirst(mathindex , KLocationMap) ;
       
  4394 		TLiwVariant mapVariant= smapparam->Value() ; 
       
  4395 		const CLiwMap  *map = mapVariant.AsMap() ;
       
  4396 		TCoordinate source  ;
       
  4397 
       
  4398 		FillCoordinatesL(source , map) ;
       
  4399 		
       
  4400 		TReal64 longitudeInputVal = source.Longitude(); 		
       
  4401 		TReal64 latitudeInputVal = source.Latitude(); 
       
  4402 		TReal64 altitudeInputVal = source.Altitude(); 
       
  4403 				
       
  4404 
       
  4405      //Logging result into a file
       
  4406 	RFile LogFile ;
       
  4407 	RFs LogSession ;
       
  4408 	TBuf8<50> Buffer(_L8("Longitude = ")) ;
       
  4409 	LogSession.Connect() ;
       
  4410 
       
  4411 	if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny )  == KErrNotFound)
       
  4412 		{
       
  4413 		LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) ;
       
  4414 
       
  4415 		}
       
  4416 
       
  4417 	TInt End = 0 ;
       
  4418 
       
  4419 	LogFile.Seek(ESeekEnd , End) ; //Seek to end of the file before writing 
       
  4420 
       
  4421 	TBuf8<50> num ;
       
  4422 	TRealFormat format ;
       
  4423 
       
  4424 	num.Num(longitudeInputVal, format) ;
       
  4425 
       
  4426 	//Logging 
       
  4427 	LogFile.Write(_L8("Longitude = "));
       
  4428 	LogFile.Write(num) ;
       
  4429 	LogFile.Write(_L8("\n")) ;
       
  4430 	//LogFile.Seek(ESeekEnd , End) ;
       
  4431 	num.Num(latitudeInputVal, format) ;
       
  4432 	LogFile.Write(_L8("Latitude = "));
       
  4433 	LogFile.Write(num) ;
       
  4434 	LogFile.Write(_L8("\n")) ;
       
  4435 	num.Num(altitudeInputVal, format) ;
       
  4436 	LogFile.Write(_L8("altitude = "));
       
  4437 	LogFile.Write(num) ;
       
  4438 	LogFile.Write(_L8("\n")) ;
       
  4439 	LogFile.Close() ;
       
  4440 	LogSession.Close() ;
       
  4441 	
       
  4442 	delete OutParmList ;
       
  4443 	delete InputList ;
       
  4444 	locinterface->Close() ;
       
  4445     delete ServiceHandler ;
       
  4446     a.ResetAndDestroy() ;
       
  4447     a.Close() ;
       
  4448   __UHEAP_MARKEND ;
       
  4449    return KErrNone ;
       
  4450     }
       
  4451  
       
  4452      
       
  4453  
       
  4454  
       
  4455  
       
  4456