sapi_location/tsrc/dev/tlocationprovidertest/src/tconcurrentgetlocation.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 ConcurrentGetLoc : 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 	ConcurrentGetLoc() : iRetStatus(KErrGeneral) //Default constructor 
       
    51 		{
       
    52 			;
       
    53 		}
       
    54 	ConcurrentGetLoc(TInt aCmd , MLiwInterface *aInterface , CLiwGenericParamList *aInputList)	 ;
       
    55 };
       
    56 
       
    57 
       
    58 ConcurrentGetLoc :: ConcurrentGetLoc(TInt aCmd ,MLiwInterface *aInterface , CLiwGenericParamList *aInputList)
       
    59 { 
       
    60   
       
    61   iLocationInterface = aInterface ;
       
    62   iInputList = aInputList ;
       
    63   	
       
    64 }
       
    65 
       
    66 TInt ConcurrentGetLoc ::  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 ConcurrentGetLocCallsL()
       
    79 {
       
    80 	
       
    81 	
       
    82 		CActiveScheduler *Scheduler = new CActiveScheduler ;
       
    83 
       
    84 	CActiveScheduler :: Install(Scheduler) ;
       
    85 
       
    86 	 
       
    87     
       
    88 	
       
    89     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
    90   
       
    91     // Input and output parameter list
       
    92     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
    93     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
    94     
       
    95     
       
    96 
       
    97 
       
    98 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
    99 	
       
   100 
       
   101 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   102 
       
   103 	RCriteriaArray a;
       
   104 	a.AppendL(crit);
       
   105 	
       
   106 	ServiceHandler->AttachL(a) ;
       
   107 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   108 
       
   109 	 
       
   110  	 
       
   111 
       
   112 	TInt pos = 0;
       
   113 	
       
   114 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
   115 	
       
   116 	if(!errorprm)
       
   117 	{
       
   118 		return KErrGeneral ;
       
   119 	}
       
   120 	
       
   121     pos = 0 ;
       
   122  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
   123 	
       
   124 	if(!genericparm)
       
   125 	{
       
   126 	
       
   127 		return KErrGeneral ;
       
   128 	}
       
   129 	
       
   130    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
   131   
       
   132 
       
   133 	
       
   134     TBuf8<20>CmdBuf(KGetLocation) ;
       
   135 	
       
   136 	CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
   137 	CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
   138 	
       
   139 	
       
   140 	ConcurrentGetLoc Updates(GETLOCATION , locinterface , InputList)  ;
       
   141 	ConcurrentGetLoc GetLoc(GETLOCATION , locinterface , InputList) ;
       
   142 	
       
   143 	locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList ,KLiwOptASyncronous ,  &Updates);
       
   144 	pos = 0 ;
       
   145 	
       
   146 	const TLiwGenericParam *errparam1 = OutParmList->FindFirst(pos , KErrorCode) ;
       
   147 
       
   148 	
       
   149 	locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList ,KLiwOptASyncronous ,  &GetLoc);
       
   150 	pos = 0 ;
       
   151 	
       
   152 	const TLiwGenericParam *errparam = OutParmList->FindFirst(pos , KErrorCode) ;
       
   153 	
       
   154 	if(!errparam)
       
   155 	{
       
   156 		return KErrNotFound ;
       
   157 	}
       
   158 	
       
   159     TLiwVariant ErrVariant = errparam->Value() ;
       
   160     TInt ret = ErrVariant.AsTInt32() ;
       
   161    
       
   162 	locinterface->Close() ;
       
   163 	delete ServiceHandler ;
       
   164 	delete InputList ;
       
   165 	delete OutParmList ;
       
   166 	delete Scheduler ;
       
   167 	return ret ; // Controll never reaches here
       
   168 }
       
   169 
       
   170 
       
   171 TInt ConcurrentGetLocationCalls(TAny */*Arg*/)
       
   172 {
       
   173   
       
   174 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   175 	TInt  Val ;
       
   176 	//Install a new active scheduler to this thread 
       
   177 	TRAPD(err ,( Val = ConcurrentGetLocCallsL()) );
       
   178 	delete cleanup ;
       
   179  	
       
   180  	if(err)
       
   181  	    {
       
   182  	        return err ;
       
   183  	    }
       
   184 	return Val ;
       
   185 }
       
   186 
       
   187