sapi_location/tsrc/dev/tlocationprovidertest/src/ttracelocationcancel.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 #include <e32svr.h>
       
    19 #include <StifParser.h>
       
    20 #include <Stiftestinterface.h>
       
    21 #include <LbsRequestor.h>
       
    22 #include <LiwServiceHandler.h>
       
    23 #include <LiwCommon.h>
       
    24 
       
    25 #include "tcomplugin.h"
       
    26 
       
    27 _LIT(LogFileName , "C:\\Notifications.txt") ;
       
    28 
       
    29 class TraceLoctionCancel : public MLiwNotifyCallback
       
    30 {
       
    31 	
       
    32 	public :
       
    33 	TInt iRetStatus ;
       
    34 		
       
    35 		TInt HandleNotifyL(
       
    36             TInt aCmdId,
       
    37             TInt aEventId,
       
    38             CLiwGenericParamList& aEventParamList,
       
    39             const CLiwGenericParamList& aInParamList) 
       
    40 		    {
       
    41 		        
       
    42 		    }
       
    43 
       
    44 		TraceLoctionCancel() : iRetStatus(KErrGeneral)  //Default constructor 
       
    45 			{
       
    46 				;
       
    47 			}
       
    48 	
       
    49 };
       
    50 
       
    51 
       
    52 
       
    53 
       
    54 TInt TraceLocCancelL()
       
    55 {
       
    56 	TraceLoctionCancel MyUpdates ;
       
    57 	
       
    58 	CActiveScheduler *Scheduler  = CActiveScheduler :: Current() ;
       
    59     
       
    60     if(!Scheduler)
       
    61     {
       
    62     	Scheduler = new CActiveScheduler ;
       
    63     }
       
    64     
       
    65    
       
    66     CActiveScheduler :: Install(Scheduler) ;
       
    67     
       
    68     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
    69   
       
    70     // Input and output parameter list
       
    71     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
    72     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
    73     
       
    74     
       
    75 
       
    76 
       
    77 	CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService);
       
    78 	
       
    79 
       
    80 	crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
    81 
       
    82 	RCriteriaArray a;
       
    83 	a.AppendL(crit);
       
    84 	
       
    85 	ServiceHandler->AttachL(a) ;
       
    86 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
    87 
       
    88 	 
       
    89  	 
       
    90 
       
    91 	TInt pos = 0;
       
    92 	
       
    93 	const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
    94 	
       
    95 	if(!errorprm)
       
    96 	{
       
    97 		return KErrGeneral ;
       
    98 	}
       
    99 	
       
   100     pos = 0 ;
       
   101  	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource );
       
   102 	
       
   103 	if(!genericparm)
       
   104 	{
       
   105 	
       
   106 		return KErrGeneral ;
       
   107 	}
       
   108 	
       
   109    MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
   110 	
       
   111 
       
   112     
       
   113 
       
   114 	CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ;
       
   115 	CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ;
       
   116 	TBuf8<20>CmdBuf(KTraceLocation) ;
       
   117 	
       
   118 
       
   119 	locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList ,KLiwOptASyncronous ,  &MyUpdates);
       
   120 	
       
   121    _LIT8(KCancell , "CancelNotification") ;
       
   122    _LIT8( KType ,"CancelRequestType") ;
       
   123    _LIT( KTraceLocCancel ,"TraceCancel") ;
       
   124    
       
   125    InputList->AppendL(TLiwGenericParam (KType , TLiwVariant (KTraceLocCancel))) ;
       
   126    CmdBuf = KCancell ;
       
   127    locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList ,0 ,  &MyUpdates);
       
   128    
       
   129    pos =  0;
       
   130    
       
   131    const TLiwGenericParam *errprm = OutParmList->FindFirst(pos , KErrCode) ;
       
   132    
       
   133    TInt ret = (errprm->Value()).AsTInt32() ;
       
   134     
       
   135     delete Scheduler ;
       
   136     
       
   137     locinterface->Close();
       
   138     delete InputList ;
       
   139     delete  OutParmList ;
       
   140     
       
   141     return ret ;  
       
   142 }
       
   143 
       
   144 
       
   145 
       
   146 
       
   147 TInt TraceLocCancel(TAny * /*Arg*/)
       
   148 {
       
   149 //	__UHEAP_MARK;
       
   150 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   151     TInt val ;
       
   152     TRAPD(err , (val = TraceLocCancelL() ) ) ;
       
   153     delete cleanup ;
       
   154  //    __UHEAP_MARKEND;   
       
   155 
       
   156 	return val ;
       
   157 	
       
   158 }