sapi_logging/tsrc/testing/tlogprovidertest/src/tmisc.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 <LiwServiceHandler.h>
       
    19 #include <LiwCommon.h>
       
    20 #include <logcli.h>
       
    21 #include <logwrap.h>
       
    22 #include "tlogprovidertest.h"
       
    23 #include "serviceerrno.h"
       
    24 #include "tcallback.h"
       
    25 #include "teventdetails.h"
       
    26 #include "tconstants.h"
       
    27 
       
    28 _LIT8(KIMDataSource,		"IMessaging");
       
    29   _LIT8(KService, 		"Service.Messaging");
       
    30   
       
    31   TInt wronginterface1(CEventDetails *aDetails)
       
    32 {
       
    33 
       
    34 
       
    35 	CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
    36      // Input and output parameter list
       
    37     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
    38     
       
    39     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
    40     
       
    41     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIMDataSource , KService) ;
       
    42     
       
    43     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
    44     
       
    45     RCriteriaArray a;
       
    46     
       
    47 	
       
    48 	a.AppendL(crit);
       
    49  	
       
    50 	ServiceHandler->AttachL(a) ;
       
    51 	
       
    52 	
       
    53 	TRAPD(err,ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist));
       
    54 	 
       
    55  	
       
    56 
       
    57 	
       
    58     TInt pos = 0;
       
    59 	
       
    60  
       
    61 	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos  , KIMDataSource);
       
    62 	
       
    63 	if(!genericparm)
       
    64 	{
       
    65 	  outputlist->Reset() ;
       
    66   
       
    67   inputlist->Reset() ;
       
    68 	 a.Close();
       
    69 	 delete crit;
       
    70 delete ServiceHandler;
       
    71 	 
       
    72 	 User :: Leave(KErrArgument) ;
       
    73 	}
       
    74 	
       
    75    MLiwInterface* LogInterface = (genericparm->Value()).AsInterface();
       
    76     
       
    77     
       
    78   TBufC8<20>CmdBufSet(KCmdAdd) ;
       
    79   
       
    80   outputlist->Reset() ;
       
    81   
       
    82   inputlist->Reset() ;
       
    83   
       
    84   CLiwDefaultMap *EventDetails = CLiwDefaultMap :: NewL() ;
       
    85   
       
    86   
       
    87   
       
    88   EventDetails->InsertL(KEventTypeKey , TLiwVariant(aDetails->GetEventType()) );
       
    89   
       
    90   
       
    91   
       
    92   
       
    93 
       
    94   TBuf16 <10> Contents(KContentType) ;
       
    95   
       
    96   inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(Contents))) ;
       
    97   
       
    98   inputlist->AppendL(TLiwGenericParam(KEventDetails , TLiwVariant(EventDetails))) ;
       
    99   
       
   100   EventDetails->DecRef();
       
   101     
       
   102   LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); 
       
   103  
       
   104   
       
   105   
       
   106   
       
   107    TInt index = 0 ;
       
   108    
       
   109    const TLiwGenericParam *ErrCode  = outputlist->FindFirst(index , KErrCode) ;
       
   110    
       
   111    if(!ErrCode )
       
   112     {
       
   113     
       
   114   	 User :: Leave(KErrArgument) ;
       
   115     }
       
   116     
       
   117     TInt retval  = ErrCode->Value().AsTInt32() ;
       
   118   
       
   119   if(retval != SErrNone )
       
   120   	{
       
   121   	
       
   122   	    LogInterface->Close() ;
       
   123   	   delete ServiceHandler;
       
   124   	   a.ResetAndDestroy();
       
   125    	   a.Close();
       
   126     
       
   127       
       
   128     
       
   129   	 User :: Leave(KErrArgument) ;
       
   130   	}
       
   131    
       
   132  
       
   133   
       
   134    
       
   135   index = 0 ;
       
   136   const TLiwGenericParam *genparm = outputlist->FindFirst(index , KResponse) ;
       
   137   
       
   138   if(!genparm)
       
   139     {
       
   140       LogInterface->Close() ;
       
   141      delete ServiceHandler;
       
   142     // delete crit;
       
   143    
       
   144    	 a.ResetAndDestroy();
       
   145    	 a.Close();
       
   146    
       
   147    
       
   148    return KErrArgument;
       
   149    	 //User :: Leave(KErrArgument) ;
       
   150     }
       
   151     
       
   152     
       
   153      
       
   154     
       
   155     
       
   156    
       
   157       LogInterface->Close() ;
       
   158      delete ServiceHandler;
       
   159     // delete crit;
       
   160    
       
   161    	 a.ResetAndDestroy();
       
   162    	 a.Close();
       
   163    
       
   164    
       
   165     }
       
   166 
       
   167 
       
   168 
       
   169 
       
   170 
       
   171 
       
   172  TInt loadtwice(CEventDetails *aDetails)
       
   173 {
       
   174 
       
   175 
       
   176 	CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   177      // Input and output parameter list
       
   178     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   179     
       
   180     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   181     
       
   182     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ;
       
   183     
       
   184     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   185     
       
   186     RCriteriaArray a;
       
   187     
       
   188 	
       
   189 	a.AppendL(crit);
       
   190  	
       
   191 	ServiceHandler->AttachL(a) ;
       
   192 	
       
   193 	
       
   194 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   195 	 ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   196  	
       
   197 
       
   198 	
       
   199     TInt pos = 0;
       
   200 	
       
   201  
       
   202 	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos  , KDsInterfaceName);
       
   203 	
       
   204 	if(!genericparm)
       
   205 	{
       
   206 
       
   207 	 
       
   208 	 User :: Leave(KErrArgument) ;
       
   209 	}
       
   210 	
       
   211    MLiwInterface* LogInterface = (genericparm->Value()).AsInterface();
       
   212     
       
   213     
       
   214   TBufC8<20>CmdBufSet(KCmdAdd) ;
       
   215   
       
   216   outputlist->Reset() ;
       
   217   
       
   218   inputlist->Reset() ;
       
   219   
       
   220   CLiwDefaultMap *EventDetails = CLiwDefaultMap :: NewL() ;
       
   221   
       
   222   
       
   223   
       
   224   EventDetails->InsertL(KEventTypeKey , TLiwVariant(aDetails->GetEventType()) );
       
   225   
       
   226   
       
   227   
       
   228   
       
   229 
       
   230   TBuf16 <10> Contents(KContentType) ;
       
   231   
       
   232   inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(Contents))) ;
       
   233   
       
   234   inputlist->AppendL(TLiwGenericParam(KEventDetails , TLiwVariant(EventDetails))) ;
       
   235   
       
   236   EventDetails->DecRef();
       
   237     
       
   238   LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); 
       
   239  
       
   240   
       
   241   
       
   242   
       
   243    TInt index = 0 ;
       
   244    
       
   245    const TLiwGenericParam *ErrCode  = outputlist->FindFirst(index , KErrCode) ;
       
   246    
       
   247    if(!ErrCode )
       
   248     {
       
   249     
       
   250   	 User :: Leave(KErrArgument) ;
       
   251     }
       
   252     
       
   253     TInt retval  = ErrCode->Value().AsTInt32() ;
       
   254   
       
   255   if(retval != SErrNone )
       
   256   	{
       
   257   	
       
   258   	    LogInterface->Close() ;
       
   259   	   delete ServiceHandler;
       
   260   	   a.ResetAndDestroy();
       
   261    	   a.Close();
       
   262     
       
   263       
       
   264     
       
   265   	 User :: Leave(KErrArgument) ;
       
   266   	}
       
   267    
       
   268  
       
   269   
       
   270    
       
   271   index = 0 ;
       
   272   const TLiwGenericParam *genparm = outputlist->FindFirst(index , KResponse) ;
       
   273   
       
   274   if(!genparm)
       
   275     {
       
   276       LogInterface->Close() ;
       
   277      delete ServiceHandler;
       
   278     // delete crit;
       
   279    
       
   280    	 a.ResetAndDestroy();
       
   281    	 a.Close();
       
   282    
       
   283    
       
   284    return KErrArgument;
       
   285    	 //User :: Leave(KErrArgument) ;
       
   286     }
       
   287     
       
   288     
       
   289      
       
   290     
       
   291     
       
   292    
       
   293       LogInterface->Close() ;
       
   294      delete ServiceHandler;
       
   295     // delete crit;
       
   296    
       
   297    	 a.ResetAndDestroy();
       
   298    	 a.Close();
       
   299    
       
   300    
       
   301     }
       
   302 
       
   303 
       
   304 
       
   305 
       
   306 
       
   307  TInt wrongcommand(CEventDetails *aDetails)
       
   308 {
       
   309 
       
   310 
       
   311 	CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL();
       
   312      // Input and output parameter list
       
   313     CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL());
       
   314     
       
   315     CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL());
       
   316     
       
   317     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ;
       
   318     
       
   319     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   320     
       
   321     RCriteriaArray a;
       
   322     
       
   323 	
       
   324 	a.AppendL(crit);
       
   325  	
       
   326 	ServiceHandler->AttachL(a) ;
       
   327 	
       
   328 	
       
   329 	ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   330 	// ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist);
       
   331  	
       
   332 
       
   333 	
       
   334     TInt pos = 0;
       
   335 	
       
   336  
       
   337 	const TLiwGenericParam *genericparm = outputlist->FindFirst(pos  , KDsInterfaceName);
       
   338 	
       
   339 	if(!genericparm)
       
   340 	{
       
   341 
       
   342 	 
       
   343 	 User :: Leave(KErrArgument) ;
       
   344 	}
       
   345 	
       
   346    MLiwInterface* LogInterface = (genericparm->Value()).AsInterface();
       
   347     
       
   348     
       
   349   TBufC8<20>CmdBufSet(Kother) ;
       
   350   
       
   351   outputlist->Reset() ;
       
   352   
       
   353   inputlist->Reset() ;
       
   354   
       
   355   CLiwDefaultMap *EventDetails = CLiwDefaultMap :: NewL() ;
       
   356   
       
   357   
       
   358   
       
   359   EventDetails->InsertL(KEventTypeKey , TLiwVariant(aDetails->GetEventType()) );
       
   360   
       
   361   
       
   362   
       
   363   
       
   364 
       
   365   TBuf16 <10> Contents(KContentType) ;
       
   366   
       
   367   //inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(Contents))) ;
       
   368   
       
   369   inputlist->AppendL(TLiwGenericParam(KEventDetails , TLiwVariant(EventDetails))) ;
       
   370   
       
   371   EventDetails->DecRef();
       
   372     
       
   373   LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); 
       
   374  
       
   375   
       
   376   
       
   377   
       
   378    TInt index = 0 ;
       
   379    
       
   380    const TLiwGenericParam *ErrCode  = outputlist->FindFirst(index , KErrCode) ;
       
   381    
       
   382    if(!ErrCode )
       
   383     {
       
   384     
       
   385   	 User :: Leave(KErrArgument) ;
       
   386     }
       
   387     
       
   388     TInt retval  = ErrCode->Value().AsTInt32() ;
       
   389   
       
   390   if(retval != SErrServiceNotSupported )
       
   391   	{
       
   392   	
       
   393     
       
   394   	 User :: Leave(KErrArgument) ;
       
   395   	}
       
   396    
       
   397  
       
   398   
       
   399     
       
   400      
       
   401     
       
   402     
       
   403    
       
   404       LogInterface->Close() ;
       
   405      delete ServiceHandler;
       
   406     // delete crit;
       
   407    
       
   408    	 a.ResetAndDestroy();
       
   409    	 a.Close();
       
   410    
       
   411    
       
   412     }
       
   413 
       
   414 
       
   415 
       
   416 
       
   417 
       
   418