sapi_logging/tsrc/dev/tloggingprovidertest/src/taddtest1.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 <StifParser.h>
       
    19 #include <Stiftestinterface.h>
       
    20 #include <LiwServiceHandler.h>
       
    21 #include <LiwCommon.h>
       
    22 
       
    23 
       
    24 #include "tconstants.h"
       
    25 
       
    26 #include "tprovidertest.h"
       
    27 #include "teventdetails.h"
       
    28 #include "tprovidercallback.h"
       
    29 #include "serviceerrno.h"
       
    30 
       
    31 
       
    32 
       
    33 
       
    34 void Ctprovidertest ::  taddtest1L(void)
       
    35 {
       
    36     TBuf<6> EmptyDes ;
       
    37     NotifyCB cb ;
       
    38    
       
    39  
       
    40    
       
    41     
       
    42     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
    43     
       
    44     
       
    45     
       
    46      // Input and output parameter list
       
    47     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
    48     
       
    49     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
    50     
       
    51     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ;
       
    52     
       
    53   
       
    54     
       
    55     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
    56     
       
    57     RCriteriaArray a;
       
    58     
       
    59 	
       
    60 	a.AppendL(crit);
       
    61 
       
    62    
       
    63     
       
    64 	
       
    65 	ServiceHandler->AttachL(a) ;
       
    66 
       
    67 	
       
    68 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
    69 	 
       
    70  	
       
    71 
       
    72 	
       
    73     TInt pos = 0;
       
    74 	
       
    75  
       
    76 	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos  , KDsInterfaceName);
       
    77 	
       
    78 	if(!genericparm)
       
    79 	{
       
    80 	 _LIT(KLog , "Logging interface not found") ;
       
    81 	 iLog->Log(KLog) ;
       
    82 	 
       
    83 	 User :: Leave(KErrArgument) ;
       
    84 	}
       
    85 	
       
    86    MLiwInterface* LogInterface = (genericparm->Value()).AsInterface();
       
    87    
       
    88      
       
    89 	
       
    90   
       
    91     
       
    92  //First set the identity information
       
    93   TBufC8<20>CmdBufSet(KCmdRequestNotification) ;
       
    94   
       
    95   outputlist->Reset() ;
       
    96   
       
    97   inputlist->Reset() ;
       
    98   
       
    99   CLiwDefaultMap *EventDetails = CLiwDefaultMap :: NewL() ;
       
   100   
       
   101   
       
   102   EventDetails->InsertL(KDelayTime , TLiwVariant(TInt32(300000)) );
       
   103   TBufC16<10> contentType(KContentType) ;
       
   104  
       
   105    
       
   106    //Insert the contenttype to inputlist
       
   107    inputlist->AppendL(TLiwGenericParam(KNullDesC8 , TLiwVariant(contentType))) ;
       
   108  
       
   109   
       
   110   inputlist->AppendL(TLiwGenericParam(KFilter , TLiwVariant(EventDetails))) ;
       
   111   EventDetails->DecRef();
       
   112  
       
   113   
       
   114     
       
   115   LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ,KLiwOptASyncronous, &cb);
       
   116 
       
   117   TInt index1 = 0 ;
       
   118    const TLiwGenericParam *transid = outputlist->FindFirst(index1 , KTransactionId) ;
       
   119   
       
   120   if(!transid)
       
   121     {
       
   122    
       
   123    	 User :: Leave(KErrArgument) ;
       
   124     }
       
   125   TInt32 transid1 = (transid->Value()).AsTInt32() ;   
       
   126     
       
   127   inputlist->Reset() ; outputlist->Reset() ;
       
   128   TBufC8<20>CmdBuf1(KCmdCancel) ;  
       
   129   inputlist->AppendL(TLiwGenericParam(KNullDesC8 , TLiwVariant((TInt32)transid1))) ; 
       
   130   
       
   131   
       
   132   LogInterface->ExecuteCmdL(CmdBuf1 , *inputlist , *outputlist ,KLiwOptCancel ); 
       
   133  
       
   134    
       
   135    TInt index = 0 ;
       
   136    
       
   137    const TLiwGenericParam *ErrCode  = outputlist->FindFirst(index , KErrCode) ;
       
   138    
       
   139    
       
   140    
       
   141   if(!ErrCode )
       
   142     {
       
   143      _LIT(KLog , "Generic error param missing form the outputlist of add" ) ;
       
   144   	 iLog->Log(KLog) ;
       
   145   	 User :: Leave(KErrArgument) ;
       
   146     }
       
   147     
       
   148     TInt retval  = ErrCode->Value().AsTInt32() ; 
       
   149   
       
   150   if(retval != SErrNone )
       
   151   	{
       
   152   	  LogInterface->Close() ;
       
   153   	   delete ServiceHandler;
       
   154   	   a.ResetAndDestroy();
       
   155    	   a.Close();
       
   156     
       
   157   	  
       
   158      _LIT(KLog , "Functionality test of delete call failed ") ;
       
   159   	 iLog->Log(KLog) ;
       
   160   	 User :: Leave(KErrArgument) ;
       
   161   	}
       
   162   	
       
   163   	
       
   164   	LogInterface->Close() ;
       
   165     delete ServiceHandler;
       
   166       
       
   167    	 a.ResetAndDestroy();
       
   168    	 a.Close();
       
   169     
       
   170   
       
   171     
       
   172     
       
   173     
       
   174 }
       
   175 
       
   176 
       
   177 void Ctprovidertest ::  taddtest2L(void)
       
   178 {
       
   179     TBuf<6> EmptyDes ;
       
   180     NotifyCB cb ;
       
   181    
       
   182  
       
   183    
       
   184     
       
   185     CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   186     
       
   187     
       
   188     
       
   189      // Input and output parameter list
       
   190     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   191     
       
   192     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   193     
       
   194     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ;
       
   195     
       
   196   
       
   197     
       
   198     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   199     
       
   200     RCriteriaArray a;
       
   201     
       
   202 	
       
   203 	a.AppendL(crit);
       
   204 
       
   205    
       
   206     
       
   207 	
       
   208 	ServiceHandler->AttachL(a) ;
       
   209 
       
   210 	
       
   211 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   212 	 
       
   213  	
       
   214 
       
   215 	
       
   216     TInt pos = 0;
       
   217 	
       
   218  
       
   219 	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos  , KDsInterfaceName);
       
   220 	
       
   221 	if(!genericparm)
       
   222 	{
       
   223 	 _LIT(KLog , "Logging interface not found") ;
       
   224 	 iLog->Log(KLog) ;
       
   225 	 
       
   226 	 User :: Leave(KErrArgument) ;
       
   227 	}
       
   228 	
       
   229    MLiwInterface* LogInterface = (genericparm->Value()).AsInterface();
       
   230    
       
   231      
       
   232 	
       
   233   
       
   234     
       
   235  //First set the identity information
       
   236   TBufC8<20>CmdBufSet(KCmdRequestNotification) ;
       
   237   
       
   238   outputlist->Reset() ;
       
   239   
       
   240   inputlist->Reset() ;
       
   241   
       
   242   CLiwDefaultMap *EventDetails = CLiwDefaultMap :: NewL() ;
       
   243   
       
   244   
       
   245   EventDetails->InsertL(KDelayTime , TLiwVariant(TInt32(300000)) );
       
   246   TBufC16<10> contentType(KContentType) ;
       
   247  
       
   248    
       
   249    //Insert the contenttype to inputlist
       
   250    inputlist->AppendL(TLiwGenericParam(KNullDesC8 , TLiwVariant(contentType))) ;
       
   251  
       
   252   
       
   253   inputlist->AppendL(TLiwGenericParam(KFilter , TLiwVariant(EventDetails))) ;
       
   254   EventDetails->DecRef();
       
   255  
       
   256   
       
   257     
       
   258   LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ,KLiwOptASyncronous, &cb);
       
   259 
       
   260   TInt index1 = 0 ;
       
   261    const TLiwGenericParam *transid = outputlist->FindFirst(index1 , KTransactionId) ;
       
   262   
       
   263   if(!transid)
       
   264     {
       
   265    
       
   266    	 User :: Leave(KErrArgument) ;
       
   267     }
       
   268   TInt32 transid1 = (transid->Value()).AsTInt32() ; 
       
   269   
       
   270   inputlist->Reset() ; outputlist->Reset() ;
       
   271 
       
   272     CLiwDefaultMap *add = CLiwDefaultMap :: NewL() ;
       
   273    add->InsertL(KEventTypeKey ,TLiwVariant((TInt32)0)) ;
       
   274   
       
   275    //Insert the contenttype to inputlist
       
   276    inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ;
       
   277  
       
   278    
       
   279   inputlist->AppendL(TLiwGenericParam(KEventDetails , TLiwVariant(add))) ;
       
   280    add->DecRef();
       
   281   CmdBufSet = KCmdAdd ;
       
   282   LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); 
       
   283   
       
   284   cb.Start();
       
   285     
       
   286     
       
   287   inputlist->Reset() ; outputlist->Reset() ;
       
   288   TBufC8<20>CmdBuf1(KCmdCancel) ;  
       
   289   inputlist->AppendL(TLiwGenericParam(KNullDesC8 , TLiwVariant((TInt32)transid1))) ; 
       
   290   
       
   291   
       
   292   LogInterface->ExecuteCmdL(CmdBuf1 , *inputlist , *outputlist ,KLiwOptCancel ); 
       
   293  
       
   294    
       
   295    TInt index = 0 ;
       
   296    
       
   297    const TLiwGenericParam *ErrCode  = outputlist->FindFirst(index , KErrCode) ;
       
   298    
       
   299    
       
   300    
       
   301   if(!ErrCode )
       
   302     {
       
   303      _LIT(KLog , "Generic error param missing form the outputlist of add" ) ;
       
   304   	 iLog->Log(KLog) ;
       
   305   	 User :: Leave(KErrArgument) ;
       
   306     }
       
   307     
       
   308     TInt retval  = ErrCode->Value().AsTInt32() ; 
       
   309   
       
   310   if(retval != SErrNone )
       
   311   	{
       
   312   	  LogInterface->Close() ;
       
   313   	   delete ServiceHandler;
       
   314   	   a.ResetAndDestroy();
       
   315    	   a.Close();
       
   316     
       
   317   	  
       
   318      _LIT(KLog , "Functionality test of delete call failed ") ;
       
   319   	 iLog->Log(KLog) ;
       
   320   	 User :: Leave(KErrArgument) ;
       
   321   	}
       
   322   	
       
   323   	
       
   324   	LogInterface->Close() ;
       
   325     delete ServiceHandler;
       
   326       
       
   327    	 a.ResetAndDestroy();
       
   328    	 a.Close();
       
   329     
       
   330   
       
   331     
       
   332     
       
   333     
       
   334 }
       
   335