sapi_location/tsrc/dev/tlocationprovidertest/src/ttraceconcurrentcalls.cpp
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19  * Stray signal test function
       
    20  */
       
    21 
       
    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  
       
    29  
       
    30  #include "tcomplugin.h"
       
    31  
       
    32  #define TRACE 0 
       
    33  #define GETLOCATION 1
       
    34  
       
    35 class ConcurrentTraceLoc : public MLiwNotifyCallback
       
    36 {
       
    37 
       
    38 	MLiwInterface *iLocationInterface ;
       
    39 	CLiwGenericParamList *iInputList ;
       
    40 	
       
    41 	public :
       
    42 	TInt iRetStatus ;
       
    43 
       
    44 	TInt HandleNotifyL(
       
    45 	    TInt aCmdId,
       
    46 	    TInt aEventId,
       
    47 	    CLiwGenericParamList& aEventParamList,
       
    48 	    const CLiwGenericParamList& aInParamList) ;
       
    49 
       
    50 	ConcurrentTraceLoc() : iRetStatus(KErrGeneral) //Default constructor 
       
    51 		{
       
    52 			;
       
    53 		}
       
    54 	ConcurrentTraceLoc(TInt aCmd , MLiwInterface *aInterface , CLiwGenericParamList *aInputList)	 ;
       
    55 };
       
    56 
       
    57 
       
    58 ConcurrentTraceLoc :: ConcurrentTraceLoc(TInt aCmd ,MLiwInterface *aInterface , CLiwGenericParamList *aInputList)
       
    59 { 
       
    60   
       
    61   iLocationInterface = aInterface ;
       
    62   iInputList = aInputList ;
       
    63   	
       
    64 }
       
    65 
       
    66 TInt ConcurrentTraceLoc ::  HandleNotifyL(
       
    67 	    TInt aCmdId,
       
    68 	    TInt aEventId,
       
    69 	    CLiwGenericParamList& aEventParamList,
       
    70 	    const CLiwGenericParamList& aInParamList)
       
    71 {
       
    72 
       
    73 //DeRefrence Allocated Map first 
       
    74 	 return 0 ;
       
    75 }
       
    76   
       
    77   
       
    78 TInt TraceConcurrentCallsL()
       
    79 {
       
    80 	
       
    81 	_LIT(KTraceFile , "C:\\Trace.txt") ;
       
    82 	
       
    83 	RFile TraceFile ;
       
    84 	RFs  TraceSession ;
       
    85 	
       
    86 	TraceSession.Connect() ;
       
    87 	
       
    88 	if(TraceFile.Open(TraceSession ,KTraceFile , EFileWrite | EFileShareAny )  == KErrNotFound)
       
    89 	{
       
    90 		if(TraceFile.Create(TraceSession ,KTraceFile , EFileWrite | EFileShareAny ) != KErrNone)
       
    91 		{
       
    92 		 	return KErrGeneral ;
       
    93 		}
       
    94 
       
    95 	}
       
    96     CActiveScheduler *Scheduler = new CActiveScheduler ;
       
    97 
       
    98 	CActiveScheduler :: Install(Scheduler) ;
       
    99 
       
   100 	 
       
   101     
       
   102 	
       
   103     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   104   
       
   105     // Input and output parameter list
       
   106     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   107     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   108     
       
   109     
       
   110 
       
   111 
       
   112 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
   113 	
       
   114 
       
   115 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   116 
       
   117 	RCriteriaArray a;
       
   118 	a.AppendL(crit);
       
   119 	
       
   120 	ServiceHandler->AttachL(a) ;
       
   121 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   122 
       
   123 	 
       
   124  	 
       
   125 
       
   126 	TInt pos = 0;
       
   127 	
       
   128 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
   129 	
       
   130 	
       
   131 	
       
   132 	if(!errorprm)
       
   133 	{
       
   134 		return KErrGeneral ;
       
   135 	}
       
   136 	TraceFile.Write(_L8("Error Param searched \n")) ;
       
   137 	
       
   138     pos = 0 ;
       
   139  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
   140 	
       
   141 	if(!genericparm)
       
   142 	{
       
   143 	
       
   144 		return KErrGeneral ;
       
   145 	}
       
   146 	
       
   147 	TraceFile.Write(_L8("Interface Found")) ;
       
   148 	
       
   149    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
   150 	
       
   151 	
       
   152     TBuf8<20>CmdBuf(KTraceLocation) ;
       
   153 	
       
   154 	CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
   155 	CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
   156 	
       
   157 	
       
   158 	ConcurrentTraceLoc Updates(TRACE , locinterface , InputList)  ;
       
   159 	ConcurrentTraceLoc GetLoc(TRACE , locinterface , InputList) ;
       
   160 	
       
   161 	locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList ,KLiwOptASyncronous ,  &Updates);
       
   162 	pos = 0 ;
       
   163 	
       
   164 	const TLiwGenericParam *errparam1 = outputlist->FindFirst(pos , KErrorCode) ;
       
   165 
       
   166 	
       
   167 	locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList ,KLiwOptASyncronous ,  &GetLoc);
       
   168 	pos = 0 ;
       
   169 	
       
   170 	const TLiwGenericParam *errparam = OutParmList->FindFirst(pos , KErrorCode) ;
       
   171 	
       
   172 	if(!errparam)
       
   173 	{
       
   174 		return KErrNotFound ;
       
   175 	}
       
   176 	TraceFile.Write(_L8("Error param  Found \n")) ;
       
   177 	
       
   178     TLiwVariant ErrVariant = errparam->Value() ;
       
   179     TInt ret = ErrVariant.AsTInt32() ;
       
   180     
       
   181 	locinterface->Close() ;
       
   182 	delete ServiceHandler ;
       
   183 	delete InputList ;
       
   184 	delete OutParmList ;
       
   185 	delete Scheduler ;
       
   186 	TraceFile.Write(_L8("Gracefully returned \n")) ;
       
   187 	return  ret ; 
       
   188 }
       
   189 
       
   190 
       
   191 TInt TraceConcurrent(TAny */*Arg*/)
       
   192 {
       
   193   
       
   194 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   195 	TInt  Val ;
       
   196 	//Install a new active scheduler to this thread 
       
   197 	TRAPD(err ,( Val = TraceConcurrentCallsL()) );
       
   198 	delete cleanup ;
       
   199  	
       
   200  	if(err)
       
   201  	    {
       
   202  	        return err ;
       
   203  	    }
       
   204 	return Val ;
       
   205 }
       
   206 
       
   207