serviceproviders/sapi_location/tsrc/dev/tlocationprovidertest/src/TraceTO.cpp
changeset 22 fc9cf246af83
child 24 f4292e0e20df
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
       
     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  * Stray signal test function
       
    19  */
       
    20 
       
    21 #include <e32svr.h>
       
    22 #include <StifParser.h>
       
    23 #include <Stiftestinterface.h>
       
    24 #include <LbsRequestor.h>
       
    25 #include <LiwServiceHandler.h>
       
    26 #include <LiwCommon.h>
       
    27  
       
    28  
       
    29  #include "tcomplugin.h"
       
    30  
       
    31 
       
    32  
       
    33 class TOTraceLoc : public MLiwNotifyCallback
       
    34 {
       
    35 
       
    36     MLiwInterface *iLocationInterface ;
       
    37     CLiwGenericParamList *iInputList ;
       
    38     TInt cnt;
       
    39     public :
       
    40     TInt iRetStatus ;
       
    41      
       
    42     TInt HandleNotifyL(
       
    43         TInt aCmdId,
       
    44         TInt aEventId,
       
    45         CLiwGenericParamList& aEventParamList,
       
    46         const CLiwGenericParamList& aInParamList) ;
       
    47 
       
    48     TOTraceLoc() : iRetStatus(KErrGeneral),cnt(0) //Default constructor 
       
    49         {
       
    50             ;
       
    51         }
       
    52     TOTraceLoc(TInt aCmd , MLiwInterface *aInterface , CLiwGenericParamList *aInputList)     ;
       
    53 };
       
    54 
       
    55 
       
    56 TOTraceLoc :: TOTraceLoc(TInt aCmd ,MLiwInterface *aInterface , CLiwGenericParamList *aInputList)
       
    57 { 
       
    58   cnt = 0;
       
    59   iLocationInterface = aInterface ;
       
    60   iInputList = aInputList ;
       
    61     
       
    62 }
       
    63 
       
    64 TInt TOTraceLoc ::  HandleNotifyL(
       
    65         TInt aCmdId,
       
    66         TInt aEventId,
       
    67         CLiwGenericParamList& aEventParamList,
       
    68         const CLiwGenericParamList& aInParamList)
       
    69 {
       
    70 
       
    71 //DeRefrence Allocated Map first 
       
    72     cnt++;
       
    73     TInt trid = aCmdId;
       
    74    
       
    75     if(cnt == 4)
       
    76         {
       
    77    
       
    78         CActiveScheduler::Stop();
       
    79         }
       
    80      return 0 ;
       
    81 }
       
    82   
       
    83   
       
    84 TInt TraceTOL()
       
    85 {
       
    86 __UHEAP_MARK ;
       
    87       RFile LogFile ;
       
    88       RFs LogSession ;
       
    89       TBuf8<50> data ;
       
    90       TRealFormat format ;
       
    91       CActiveScheduler *Scheduler  = CActiveScheduler :: Current() ;
       
    92           
       
    93           if(!Scheduler)
       
    94           {
       
    95               Scheduler = new CActiveScheduler ;
       
    96           }
       
    97           
       
    98          
       
    99           CActiveScheduler :: Install(Scheduler) ;
       
   100            
       
   101       
       
   102       
       
   103        
       
   104        
       
   105       _LIT(LogFileNameCancel , "C:\\cancelinvalid.txt") ;
       
   106 /*
       
   107       if(LogFile.Open(LogSession ,LogFileNameCancel , EFileWrite | EFileShareAny )  == KErrNotFound)
       
   108       {
       
   109           if(LogFile.Create(LogSession ,LogFileNameCancel , EFileWrite | EFileShareAny ) != KErrNone)
       
   110           {
       
   111               _LIT(KLog , "Failed to create  log file\n") ;
       
   112              
       
   113               return KErrGeneral ;
       
   114           }
       
   115 
       
   116       }
       
   117   */    
       
   118       _LIT(KLog , "In CancelWithInvalidTransactionID\n") ;
       
   119       data.Copy(KLog);
       
   120     //  LogFile.Write(data) ;
       
   121       
       
   122      
       
   123 
       
   124       CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   125 
       
   126       // Input and output parameter list
       
   127       CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   128       CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   129 
       
   130 
       
   131 
       
   132 
       
   133       CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService);
       
   134 
       
   135 
       
   136       crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   137 
       
   138       RCriteriaArray a;
       
   139       a.AppendL(crit);
       
   140 
       
   141       ServiceHandler->AttachL(a) ;
       
   142       ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   143 
       
   144        
       
   145        
       
   146 
       
   147       TInt pos = 0;
       
   148 
       
   149       const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ;
       
   150 
       
   151       if(!errorprm)
       
   152       {
       
   153           
       
   154           return KErrGeneral ;
       
   155       }
       
   156 
       
   157 
       
   158       _LIT8(KDataSource, "ILocation");
       
   159        
       
   160        pos = 0 ;
       
   161 
       
   162       const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface);
       
   163 
       
   164       if(!genericparm)
       
   165       {
       
   166           
       
   167           return KErrGeneral ;
       
   168       }
       
   169 
       
   170       MLiwInterface* locinterface = (genericparm->Value()).AsInterface();
       
   171 
       
   172       
       
   173           
       
   174       TBuf8<20>CmdBuf(KTraceLocation) ;
       
   175 
       
   176       outputlist->Reset() ;
       
   177       inputlist->Reset() ;
       
   178       TOTraceLoc* callBack = new(ELeave) TOTraceLoc;
       
   179      
       
   180       //Appending update options
       
   181           CLiwMap* updateoptionMap = CLiwDefaultMap::NewL();
       
   182           
       
   183           TInt32 updateInterval = 2;
       
   184           
       
   185           updateoptionMap->InsertL(KUpdateOptionInterval,TLiwVariant(updateInterval));
       
   186           
       
   187           TInt32 updateTimeOut = 3;
       
   188           updateoptionMap->InsertL(KUpdateOptionTimeOut,TLiwVariant(updateTimeOut));
       
   189           
       
   190           TInt32 updateMaxAge = 1;
       
   191           updateoptionMap->InsertL(KUpdateOptionMaxAge,TLiwVariant(updateMaxAge));
       
   192           
       
   193           TLiwGenericParam updateOption(KUpdateOptionMap,TLiwVariant(updateoptionMap));
       
   194           inputlist->AppendL(updateOption) ;
       
   195           
       
   196       locinterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist,KLiwOptASyncronous, callBack);
       
   197       CActiveScheduler::Start();
       
   198       pos = 0 ;
       
   199 
       
   200       //const TLiwGenericParam *ErrorParm =  outputlist->FindFirst(pos ,KErrorCode ) ;
       
   201       delete updateoptionMap;
       
   202       delete callBack;
       
   203       locinterface->Close() ;
       
   204       delete ServiceHandler ;
       
   205       a.ResetAndDestroy() ;
       
   206       a.Close() ;
       
   207 
       
   208       __UHEAP_MARKEND ;
       
   209       return KErrNone ;
       
   210 
       
   211 
       
   212 
       
   213 }
       
   214 
       
   215 
       
   216 TInt TraceTO(TAny */*Arg*/)
       
   217 {
       
   218   
       
   219     CTrapCleanup* cleanup = CTrapCleanup::New();
       
   220     TInt  Val ;
       
   221     //Install a new active scheduler to this thread 
       
   222     TRAPD(err ,( Val = TraceTOL()) );
       
   223     delete cleanup ;
       
   224     
       
   225     if(err)
       
   226         {
       
   227             return err ;
       
   228         }
       
   229     return Val ;
       
   230 }
       
   231 
       
   232