sapi_logging/tsrc/testing/tloggingservicetest/src/taddeventasync.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 "tloggingservicetest.h"
       
    20 #include <logcli.h>
       
    21 #include <logwrap.h>
       
    22 
       
    23 #include "loggingasyncservice.h"
       
    24 #include "loggingsyncservice.h"
       
    25 #include "loggingfilter.h"
       
    26 #include "loggingservice.h"
       
    27 #include "loggingevent.h"
       
    28 #include "tlogcallback.h"
       
    29 
       
    30 #include "logobserver.h"
       
    31 
       
    32  
       
    33 #include "logiter.h"
       
    34 
       
    35 
       
    36 
       
    37 //-------------------------------------------------------------
       
    38 // Generic call back function implementation, used by logging 
       
    39 // component
       
    40 //--------------------------------------------------------------
       
    41 
       
    42 static TInt count = 0 ;
       
    43 
       
    44 //--------------------------------------------------------------
       
    45 // Default constructor
       
    46 //--------------------------------------------------------------
       
    47 
       
    48 MLogCallback :: MLogCallback()
       
    49 	{
       
    50 	 iScheduler = new CActiveSchedulerWait() ;
       
    51 	 
       
    52 	}
       
    53 
       
    54 //----------------------------------------------------------------
       
    55 // Default destructor
       
    56 //----------------------------------------------------------------
       
    57 
       
    58 MLogCallback :: ~MLogCallback()
       
    59 	{
       
    60  	delete iScheduler ;
       
    61 	}
       
    62 	
       
    63 //-----------------------------------------------------------------
       
    64 //Starts the async wait loop
       
    65 //-----------------------------------------------------------------
       
    66 
       
    67 
       
    68 void MLogCallback :: Start()
       
    69 	{
       
    70 	 iScheduler->Start() ;
       
    71 	}
       
    72 	
       
    73 void MLogCallback :: HandleNotifyL(TUint aTransid ,TUint aStatus , CLogIter *iter )
       
    74 {
       
    75  	++count ;
       
    76  	 
       
    77     
       
    78     delete iter ;
       
    79 	if(count > 0)
       
    80 		{
       
    81 		 iScheduler->AsyncStop() ;
       
    82 		}
       
    83 	
       
    84 	
       
    85 }
       
    86  
       
    87 
       
    88 
       
    89 void MLogCallback :: CancelNotifyL( TUint aTransid ) 
       
    90 {
       
    91  	
       
    92 	
       
    93 }
       
    94 
       
    95 
       
    96 
       
    97 
       
    98 
       
    99 
       
   100 
       
   101  //addevents1()
       
   102  
       
   103   
       
   104  TInt  addeventas1(void )
       
   105     {
       
   106     CLogObserver *iLogObserver ;//= CLogObserver::NewLC();
       
   107 	CLoggingService *iLoggingService = CLoggingService::NewL();
       
   108     CLogsEvent  *iLogsEvent = CLogsEvent::NewL();
       
   109      
       
   110           
       
   111     
       
   112      TUint iTransid = 1;
       
   113      MLogCallback icallback;
       
   114      //-ve testing 
       
   115      
       
   116       
       
   117      TUid tuid  = KLogCallEventTypeUid;
       
   118     
       
   119    
       
   120     iLogsEvent->SetDuration(300);
       
   121     iLogsEvent->SetEventType(tuid);
       
   122     	iLogsEvent->SetDirection(R_LOG_DIR_IN);
       
   123     
       
   124     
       
   125    TRAPD(ret1, iLoggingService->AddEventL(iTransid,iLogsEvent,&icallback));
       
   126     icallback.Start();
       
   127     
       
   128     
       
   129      delete iLogsEvent;
       
   130      delete iLoggingService;
       
   131        
       
   132     	if(ret1 ==0)
       
   133         
       
   134      return KErrNone;
       
   135     return KErrGeneral;
       
   136 
       
   137     }
       
   138     
       
   139     
       
   140     
       
   141      //addevents1()
       
   142  
       
   143   
       
   144  TInt  addeventas2(void )
       
   145     {
       
   146     
       
   147 	CLoggingService *iLoggingService = CLoggingService::NewL();
       
   148     CLogsEvent  *iLogsEvent = CLogsEvent::NewL();
       
   149     MLogCallback icallback;
       
   150      
       
   151      TUint iTransid = 1;
       
   152      TUid tuid  = KLogCallEventTypeUid;
       
   153      
       
   154        
       
   155     iLogsEvent->SetDuration(300);
       
   156     iLogsEvent->SetEventType(tuid);
       
   157      	iLogsEvent->SetDirection(R_LOG_DIR_IN);
       
   158      
       
   159    	TRAPD(error,iLoggingService->AddEventL(iTransid,iLogsEvent,&icallback));
       
   160       
       
   161       
       
   162       iLoggingService->NotifyUpdatesL(iTransid,100,&icallback);
       
   163        
       
   164      delete iLogsEvent;
       
   165      delete iLoggingService;
       
   166                
       
   167       if(error==0)
       
   168  
       
   169     return KErrNone;
       
   170     return KErrGeneral;
       
   171 
       
   172     }
       
   173     
       
   174     
       
   175     
       
   176     
       
   177     TInt isbusy(void)
       
   178     {
       
   179     
       
   180     TInt ret ;
       
   181 	 TInt flag  ;
       
   182 	 
       
   183 	 
       
   184 	 CLoggingService *LogService = CLoggingService :: NewL() ;
       
   185 	 CLogsFilter  *filter = CLogsFilter :: NewL() ;
       
   186 	 MLogCallback MyCb ;
       
   187 	 CLogsEvent *event = CLogsEvent :: NewL() ;
       
   188 	 filter->SetRequestType(EReadEvents) ;
       
   189 	 LogService->GetListL(1 , filter , &MyCb) ;
       
   190 	 
       
   191 	  ret = LogService->GetListL(2, filter , &MyCb) ;
       
   192     
       
   193     
       
   194     //	if(LogService->IsBusy())
       
   195     delete filter ;
       
   196 	 delete event ;
       
   197 	 delete LogService ;
       
   198 	 return 0;
       
   199     
       
   200     }
       
   201      
       
   202     
       
   203     
       
   204     
       
   205