sapi_mediamanagement/tsrc/dev/tmediamgmtprovidertest/src/mediamgmtblocks.cpp
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 /*
       
     2 * Copyright (c) 2002 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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <e32svr.h>
       
    23 #include <StifParser.h>
       
    24 #include <Stiftestinterface.h>
       
    25 #include <LiwServiceHandler.h>
       
    26 #include "mediamgmt.h"
       
    27 
       
    28 using namespace LIW;
       
    29 
       
    30 _LIT8(KGetList,"GetList");
       
    31 
       
    32 //Just for comparison with cfg file
       
    33 _LIT8(KNull8,"NULL");
       
    34 _LIT(KNull,"NULL");
       
    35 
       
    36 
       
    37 //Input Keys/arguments
       
    38 _LIT8(KDsName,"Type");// used by interface class
       
    39 _LIT8(KFileType,"FileType");
       
    40 _LIT8(KKey,"Key");
       
    41 _LIT8(KStartRange,"StartRange");
       
    42 _LIT8(KEndRange,"EndRange");
       
    43 _LIT8(KOrder,"Order");
       
    44 
       
    45 
       
    46 // Filter Map
       
    47 _LIT8(KFilter,"Filter");
       
    48 
       
    49 // Sorting Map
       
    50 _LIT8(KSort,"Sort");
       
    51 
       
    52 //Output Keys/arguments
       
    53 _LIT8(KErrorCode,"ErrorCode");
       
    54 _LIT8(KResponse,"ReturnValue");
       
    55 
       
    56 
       
    57 
       
    58 
       
    59 
       
    60 _LIT8(KService, "Service.MediaManagement");
       
    61 _LIT8(KIDataSource,"IDataSource");
       
    62 _LIT8(KTransactionID,"TransactionID");
       
    63 
       
    64 
       
    65 
       
    66 
       
    67 
       
    68 // ============================ MEMBER FUNCTIONS ===============================
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CMediaMgmt::Delete
       
    72 // Delete here all resources allocated and opened from test methods.
       
    73 // Called from destructor.
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void CMediaMgmt::Delete()
       
    77     {
       
    78 
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CMediaMgmt::RunMethodL
       
    83 // Run specified method. Contains also table of test mothods and their names.
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 TInt CMediaMgmt::RunMethodL(
       
    87     CStifItemParser& aItem )
       
    88     {
       
    89 
       
    90     static TStifFunctionInfo const KFunctions[] =
       
    91         {
       
    92         // Copy this line for every implemented function.
       
    93         // First string is the function name used in TestScripter script file.
       
    94         // Second is the actual implementation member function.
       
    95         ENTRY( "InterfaceClass", CMediaMgmt::InterfaceClassL ),
       
    96 
       
    97         };
       
    98 
       
    99     const TInt count = sizeof( KFunctions ) /
       
   100                         sizeof( TStifFunctionInfo );
       
   101 
       
   102     return RunInternalL( KFunctions, count, aItem );
       
   103 
       
   104     }
       
   105 
       
   106 
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CMediaMgmt::ExampleL
       
   110 // Example test method function.
       
   111 // (other items were commented in a header).
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 TInt CMediaMgmt::InterfaceClassL( CStifItemParser& aItem )
       
   115     {
       
   116     _LIT( KExample, "In InterfaceClass" );
       
   117     iLog->Log( KExample );
       
   118 
       
   119     struct ParamPass* arg1 = new ParamPass();
       
   120     arg1->it = &aItem;
       
   121 	TRequestStatus Status = KRequestPending  ;
       
   122 	RThread FunctionThread ;
       
   123 
       
   124     //creating the thread , this thread is reponsible for sending the request to SAPI
       
   125     TInt ret = FunctionThread.Create( _L("FunctionThread1"), ThreadFunction ,KDefaultStackSize ,
       
   126     						NULL ,( TAny * ) arg1);
       
   127 
       
   128     User::LeaveIfError(ret);
       
   129     FunctionThread.Logon(Status);
       
   130     FunctionThread.Resume() ;
       
   131 
       
   132     // Waiting for thread to die in other words we are making asynch call to synch call :-))
       
   133     User :: WaitForRequest (Status)	;
       
   134 
       
   135     FunctionThread.Close();
       
   136 
       
   137     delete arg1;
       
   138 	return Status.Int() ;
       
   139 
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // Callback:: HandleNotifyL
       
   144 // Call Back Function Called by the Media Management SAPI.
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 
       
   148 
       
   149 
       
   150 TInt Callback:: HandleNotifyL(TInt /*aCmdId*/,TInt aEventId,CLiwGenericParamList& aOutParamList,const CLiwGenericParamList& /*aInParamList*/)
       
   151 {
       
   152 
       
   153 	if ( KLiwEventStarted == aEventId )
       
   154 	{
       
   155 	    arg->log->Log(_L(" Started Event Capture "));
       
   156 		// Asynchronous request started
       
   157 	}
       
   158 	else if ( KLiwEventCanceled == aEventId )
       
   159 	{
       
   160 		// Asynchronous event canceled
       
   161 		arg->log->Log(_L("Cancel Event Capture "));
       
   162 		User::Exit( KErrNone );
       
   163 	}
       
   164 	else if( KLiwEventError == aEventId)
       
   165 	{
       
   166 	    // Error occurs in Asynchronous operation
       
   167 	    arg->log->Log(_L(" Error Event Capture "));
       
   168 	    User::Exit( KErrGeneral );
       
   169 	}
       
   170 	else
       
   171 	{
       
   172 
       
   173 
       
   174 	TInt32 ErrCode = KErrNone;
       
   175 	CLiwIterable* iIterable;
       
   176 	TLiwVariant Map;
       
   177 	const CLiwMap* MetaData;
       
   178 	TInt pos = 0;
       
   179 
       
   180 	// Traiverse the List and Fill in the Log Files
       
   181 	const TLiwGenericParam* p = aOutParamList.FindFirst(pos, KErrorCode); // Finding Error Code
       
   182 	if( p )
       
   183 	{
       
   184 		ErrCode = p->Value().AsTInt32();
       
   185 
       
   186 	}
       
   187 	else
       
   188 	{
       
   189 		arg->log->Log(_L(" Not able to Find the Error Code "));
       
   190 		CActiveScheduler :: Stop() ;
       
   191 		User::Exit( KErrGeneral );
       
   192 	}
       
   193 
       
   194 	if(ErrCode < 0 ) // If any error comes in MG SAPI
       
   195 	{
       
   196 		arg->log->Log(_L(" Error Occured in SAPI = %d"),ErrCode);
       
   197 		CActiveScheduler :: Stop() ;
       
   198 		User::Exit( KErrGeneral );
       
   199 	}
       
   200 
       
   201 	p = aOutParamList.FindFirst(pos, KResponse);// Finding out the response of Media Management
       
   202 	if(!p)
       
   203 	{
       
   204 		arg->log->Log(_L(" Not able to Find the Response "));
       
   205 		CActiveScheduler :: Stop() ;
       
   206 		User::Exit( KErrGeneral );
       
   207 	}
       
   208 	else
       
   209 	{
       
   210 		iIterable = p->Value().AsIterable();// returning Iterator as Response
       
   211 		TBuf8<30> Key;// Key In The Map
       
   212 		TPtrC KeyValue;// value of that key
       
   213 		TLiwVariant val;//just for extracting the value
       
   214 
       
   215 		//-----------Loop for Iterator -------------------------------//
       
   216 		TBuf<200> Output;
       
   217 		int count =0;
       
   218 		while(iIterable->NextL(Map))// Find the next value from Iterator
       
   219 		{
       
   220 			count++;
       
   221 			Output.Copy(_L("\n\nFile\n"));
       
   222 			arg->log->Log(Output);
       
   223 
       
   224 			MetaData = Map.AsMap();// Iterator return the map which contains meta data
       
   225 			Output.Copy(_L("key"));
       
   226 			Output.Append(_L("							"));
       
   227 			Output.Append(_L("KeyValue"));
       
   228 			arg->log->Log(Output);
       
   229 
       
   230 			for(TInt i = 0 ; i <MetaData->Count(); i++ )
       
   231 			{
       
   232 
       
   233 				MetaData->AtL(i,Key);
       
   234 				MetaData->FindL(Key, val);
       
   235 				Key.Trim();
       
   236 				Output.Copy(Key);
       
   237 				Output.Append(_L("            "));
       
   238 				if(EVariantTypeTInt32==val.TypeId())
       
   239 				{
       
   240 					TInt value = val.AsTInt32();
       
   241 					TBuf<30> string;
       
   242 					string.AppendNum(value);
       
   243 					string.Trim();
       
   244 					Output.Append(string);
       
   245 				}
       
   246 				else if(EVariantTypeTTime==val.TypeId())
       
   247 				{
       
   248 					TTime time = val.AsTTime();
       
   249 					_LIT(KTimeFormat,"%F%M/%D/%Y %H:%T");
       
   250 					TBuf <20> StringTime;
       
   251 					time.FormatL(StringTime, KTimeFormat);
       
   252 					StringTime.Trim();
       
   253 					Output.Append(StringTime);
       
   254                     // date format : 5/25/2005 12:40"
       
   255 				}
       
   256 				else
       
   257 				{
       
   258 					val.Get(KeyValue);
       
   259 				//	KeyValue.Trim();
       
   260 				Output.Append(KeyValue);
       
   261 				}
       
   262 				arg->log->Log(Output); // printing Key Values in log files
       
   263 
       
   264 			}
       
   265 		Map.Reset();
       
   266 		}
       
   267 	}
       
   268 	//------Loop for Iterator-----------------------------------------//
       
   269 	CActiveScheduler :: Stop() ;
       
   270 
       
   271 	}
       
   272 	return 0;
       
   273 }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // Thread Function For Sending the Asynch request to Media Management SAPI
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 
       
   280 TInt ThreadFunction (TAny *a)
       
   281 {
       
   282 	// Creating the Cleanup stack for this new thread
       
   283 	 CTrapCleanup* cleanup = CTrapCleanup::New();
       
   284 	 struct ParamPass* arg1 = (ParamPass*) a;
       
   285 	 TInt errorCode = 0;
       
   286 	 TInt error = KErrNone;
       
   287 	 TInt expectedResult;
       
   288 
       
   289 	 TRAP(error, errorCode = GetFilesAsynchL(a));
       
   290 	 delete cleanup;
       
   291 	 if( arg1->it->GetNextInt(expectedResult) != KErrNone )
       
   292         {
       
   293         arg1->log->Log(_L("Failed to Get the Sorting Order ")) ;
       
   294         return KErrGeneral;
       
   295         }
       
   296 	 if(error == KErrNone)
       
   297 	 {
       
   298 	 	if(errorCode>0)
       
   299 	 	{
       
   300 	 	  arg1->log->Log(_L(" Error in input "));
       
   301 	 	  TBuf<30> string;
       
   302 		  string.AppendNum(errorCode);
       
   303 		  arg1->log->Log(string);
       
   304 		  delete arg1->log;
       
   305 		  if( expectedResult != 0)//negative test case
       
   306     	  {
       
   307     	    return KErrNone;
       
   308           }
       
   309 		  return KErrGeneral;
       
   310 
       
   311 	 	}
       
   312 	 	else
       
   313 	 	{
       
   314 	 	   return  KErrNone;
       
   315 	 	}
       
   316 
       
   317 	 }
       
   318 
       
   319 	 return KErrGeneral;
       
   320 }
       
   321 
       
   322 
       
   323 
       
   324 
       
   325 TInt GetFilesAsynchL( TAny *a)
       
   326 {
       
   327     TPtrC cfgCommand16;
       
   328     TPtrC cfgDataSourceName;
       
   329 	TPtrC FileType16;
       
   330 	TPtrC FilterField16;
       
   331 	TPtrC StartVal;
       
   332 	TPtrC EndVal;
       
   333 	TPtrC SortField16;
       
   334 	TPtrC order;
       
   335 	TInt expectedResult = 0;
       
   336 	TInt operation = 0;
       
   337 
       
   338 	struct ParamPass *arg1 = (ParamPass *)a;
       
   339 
       
   340 	arg1->log = CStifLogger::NewL( KMediaMgmtLogPath,
       
   341                           KResultFile,
       
   342                           CStifLogger::ETxt,
       
   343                           CStifLogger::EFile,
       
   344                           ETrue,
       
   345                           EFalse);
       
   346 
       
   347 
       
   348 
       
   349     // Get All the Values From CFG file
       
   350     if( arg1->it->GetNextString ( cfgCommand16 ) != KErrNone )
       
   351         {
       
   352         arg1->log->Log(_L(" Failed to Get the File Type ") );
       
   353         return KErrGeneral;
       
   354         }
       
   355 
       
   356     if( arg1->it->GetNextString ( cfgDataSourceName ) != KErrNone )
       
   357         {
       
   358         arg1->log->Log(_L(" Failed to Get the File Type ") );
       
   359         return KErrGeneral;
       
   360         }
       
   361 
       
   362     if( arg1->it->GetNextString ( FileType16 ) != KErrNone )
       
   363         {
       
   364         arg1->log->Log(_L(" Failed to Get the File Type ") );
       
   365         return KErrGeneral;
       
   366         }
       
   367 	if( arg1->it->GetNextString ( FilterField16 ) != KErrNone )
       
   368         {
       
   369         arg1->log->Log(_L("Failed to Get the Filter Field of File ")) ;
       
   370         return KErrGeneral;
       
   371         }
       
   372     if( arg1->it->GetNextString ( StartVal ) != KErrNone )
       
   373         {
       
   374         arg1->log->Log(_L("Failed to Get the start value of Filter ")) ;
       
   375         return KErrGeneral;
       
   376         }
       
   377 	if( arg1->it->GetNextString ( EndVal ) != KErrNone )
       
   378         {
       
   379         arg1->log->Log(_L("Failed to Get the End Value of Filter ")) ;
       
   380         return KErrGeneral;
       
   381         }
       
   382     if( arg1->it->GetNextString ( SortField16 ) != KErrNone )
       
   383         {
       
   384         arg1->log->Log(_L("Failed to Get the Sort Filed  ")) ;
       
   385         return KErrGeneral;
       
   386         }
       
   387 
       
   388 	if( arg1->it->GetNextString(order) != KErrNone )
       
   389         {
       
   390         arg1->log->Log(_L("Failed to Get the Sorting Order ")) ;
       
   391         return KErrGeneral;
       
   392         }
       
   393 
       
   394     if( arg1->it->GetNextInt(operation) != KErrNone )
       
   395         {
       
   396         arg1->log->Log(_L("Failed to Get the Sorting Order ")) ;
       
   397         return KErrGeneral;
       
   398         }
       
   399 
       
   400         // the below section for giving header to log files
       
   401 
       
   402      	TBuf<200> TestCase;
       
   403 
       
   404      	TestCase.Copy(_L("FileType "));
       
   405      	TestCase.Append(_L("   "));
       
   406 
       
   407        	TestCase.Append(_L("FilterField"));
       
   408      	TestCase.Append(_L("   "));
       
   409 
       
   410 
       
   411      	TestCase.Append(_L("StartVal"));
       
   412      	TestCase.Append(_L("   "));
       
   413 
       
   414 
       
   415      	TestCase.Append(_L("EndVal"));
       
   416      	TestCase.Append(_L("   "));
       
   417 
       
   418 
       
   419      	TestCase.Append(_L("SortField"));
       
   420      	TestCase.Append(_L("   "));
       
   421 
       
   422 
       
   423        	TestCase.Append(_L("order"));
       
   424      	TestCase.Append(_L("   "));
       
   425 
       
   426 
       
   427 
       
   428      	arg1->log->Log(TestCase);
       
   429 
       
   430      	TestCase.Copy(FileType16);
       
   431      	TestCase.Append(_L("   "));
       
   432 
       
   433        	TestCase.Append(FilterField16);
       
   434      	TestCase.Append(_L("   "));
       
   435 
       
   436 
       
   437      	TestCase.Append(StartVal);
       
   438      	TestCase.Append(_L("   "));
       
   439 
       
   440 
       
   441      	TestCase.Append(EndVal);
       
   442      	TestCase.Append(_L("   "));
       
   443 
       
   444 
       
   445      	TestCase.Append(SortField16);
       
   446      	TestCase.Append(_L("   "));
       
   447 
       
   448 
       
   449        	TestCase.Append(order);
       
   450      	TestCase.Append(_L("   "));
       
   451 
       
   452      	arg1->log->Log(TestCase);
       
   453 
       
   454 
       
   455          // Convert 16 Bit values into 8 bit as SAPI accept 8 bit key
       
   456         TBuf8<30> Command ;
       
   457         Command.Copy(cfgCommand16);
       
   458 
       
   459         TBuf8<30> FileType ;
       
   460         //FileType.Copy(FileType16);
       
   461 
       
   462         TBuf8<30> FilterField ;
       
   463         //FilterField.Copy(FilterField16);
       
   464 
       
   465         TBuf8<30> SortField ;
       
   466         //SortField.Copy(SortField16);
       
   467 
       
   468         TBuf8<30> Order ;
       
   469         //Order.Copy(order);
       
   470 
       
   471 	CLiwGenericParamList* input = CLiwGenericParamList::NewL();
       
   472 	CleanupStack::PushL(input);
       
   473     	// Start Scheduler
       
   474 	CActiveScheduler *Scheduler = new (ELeave) CActiveScheduler ;
       
   475 	CActiveScheduler :: Install(Scheduler) ;
       
   476 	CleanupStack::PushL(Scheduler);
       
   477 
       
   478     CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL();
       
   479     CleanupStack::PushL(iServiceHandler);
       
   480 
       
   481     CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIDataSource,KService);
       
   482     crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   483     CleanupStack::PushL(crit);
       
   484 
       
   485 
       
   486     RCriteriaArray critArray;
       
   487     critArray.AppendL(crit);
       
   488     CleanupClosePushL(critArray);
       
   489 
       
   490     iServiceHandler->AttachL(critArray);
       
   491 
       
   492     //Create the object of callback
       
   493 	MLiwNotifyCallback*  aCallBack = new (ELeave) Callback(arg1);
       
   494 	CleanupStack::PushL(aCallBack);
       
   495 
       
   496 
       
   497 
       
   498     CLiwGenericParamList* output = CLiwGenericParamList::NewL();
       
   499 	CleanupStack::PushL(output);
       
   500 	
       
   501 
       
   502     iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output);
       
   503 
       
   504 
       
   505     // Create the Instance of SAPI class and the Input Param and output Param
       
   506     TInt pos = 0;
       
   507     MLiwInterface* Interface = NULL;
       
   508     output->FindFirst(pos,KIDataSource );
       
   509     if(pos != KErrNotFound)
       
   510         {
       
   511         Interface = (*output)[pos].Value().AsInterface();
       
   512         }
       
   513     output->Reset();
       
   514 
       
   515     input->Reset();
       
   516 
       
   517     //MLiwInterface* Interface = CMgDataSourceInterface::NewL();
       
   518     CleanupClosePushL(*Interface);
       
   519 
       
   520 	if( 0 != cfgDataSourceName.CompareF(KNull) )
       
   521 	{
       
   522 	TLiwVariant dsName;
       
   523 	dsName.Set(cfgDataSourceName);
       
   524     TLiwGenericParam dsNameParam(KDsName, dsName);
       
   525 	input->AppendL(dsNameParam);
       
   526 	}
       
   527 	CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL();
       
   528 	TLiwGenericParam iFilterParam(KFilter, TLiwVariant(filterMap));
       
   529 	input->AppendL(iFilterParam);
       
   530 	filterMap->DecRef();
       
   531 
       
   532     CLiwDefaultMap *sortingMap = CLiwDefaultMap::NewL();
       
   533     TLiwGenericParam iSortingParam(KSort, TLiwVariant(sortingMap));
       
   534 	input->AppendL(iSortingParam);
       
   535 	sortingMap->DecRef();
       
   536 
       
   537 
       
   538 
       
   539 
       
   540 
       
   541 	//Inserting data source name
       
   542 
       
   543 //------Send all this thing in Filter Map -------------------------------//
       
   544 
       
   545 
       
   546 
       
   547 	if( 0 != FileType16.CompareF( KNull ) )
       
   548 	{
       
   549 	    TLiwVariant ifileType;
       
   550 	    //ifileType.Set(FileType);
       
   551 	    ifileType.Set(FileType16);
       
   552 	    filterMap->InsertL(KFileType,ifileType);
       
   553 	}
       
   554 
       
   555 	if( 0 != FilterField16.CompareF( KNull ) )
       
   556 	{
       
   557 	    TLiwVariant iFilterField;
       
   558 	    //iFilterField.Set(FilterField);
       
   559 	    iFilterField.Set(FilterField16);
       
   560 	    filterMap->InsertL(KKey,iFilterField);
       
   561 	}
       
   562 
       
   563 	if( 0 != StartVal.CompareF( KNull ) )
       
   564 	{
       
   565 	   	TLiwVariant iStartVal;
       
   566 	    iStartVal.Set(StartVal);
       
   567 	    filterMap->InsertL(KStartRange,iStartVal);
       
   568 	}
       
   569 
       
   570 	if( 0 != EndVal.CompareF( KNull ) )
       
   571 	{
       
   572 	   	TLiwVariant iEndVal;
       
   573 	    iEndVal.Set(EndVal);
       
   574 	    filterMap->InsertL(KEndRange,iEndVal);
       
   575 	}
       
   576 
       
   577 
       
   578 
       
   579 
       
   580 
       
   581 
       
   582 
       
   583 //------------------Send all the below in sorting map----------------------------------------------------------//
       
   584 
       
   585 	if( 0 != SortField16.CompareF( KNull ) )
       
   586 	{
       
   587 	    TLiwVariant iSortField;
       
   588 	    //iSortField.Set(SortField);
       
   589 	    iSortField.Set(SortField16);
       
   590 	    sortingMap->InsertL(KKey,iSortField);
       
   591 	}
       
   592 
       
   593 	if( 0 != order.CompareF( KNull ) )
       
   594 	{
       
   595 	    TLiwVariant iOrder;
       
   596 	    //iOrder.Set(Order);
       
   597 	    iOrder.Set(order);
       
   598 	    sortingMap->InsertL(KOrder,iOrder);
       
   599 	}
       
   600 
       
   601 
       
   602 
       
   603 const TLiwGenericParam* p= NULL;
       
   604 
       
   605 //---------------------------------------------------------------------------------//
       
   606 
       
   607 	if( operation == 0)
       
   608 	{
       
   609 	        // normal asynch operation
       
   610 	        if( Interface != NULL)
       
   611 	    	Interface->ExecuteCmdL(Command,*input,*output,KLiwOptASyncronous,aCallBack);
       
   612 
       
   613 	}
       
   614 	else if(operation == 1)
       
   615 	{
       
   616 	        //cancel
       
   617 	        Interface->ExecuteCmdL(Command,*input,*output,KLiwOptASyncronous,aCallBack);
       
   618 	        pos = 0;
       
   619             p = output->FindFirst(pos, KTransactionID); // Finding Error Code
       
   620             input->Reset();
       
   621             TUint transactionID = 0;
       
   622 	        if( p )
       
   623 	        {
       
   624 		    p->Value().Get(transactionID);
       
   625 		    input->AppendL( TLiwGenericParam( KTransactionID, TLiwVariant( transactionID ) ) );
       
   626             }
       
   627 	    	Interface->ExecuteCmdL(_L8("Cancel"),*input,*output,KLiwOptCancel,aCallBack);
       
   628 
       
   629     }
       
   630 	else if( operation == 3)
       
   631 	{
       
   632 	        // check back to back request
       
   633 	    	Interface->ExecuteCmdL(Command,*input,*output,KLiwOptASyncronous,aCallBack);
       
   634             Interface->ExecuteCmdL(Command,*input,*output,KLiwOptASyncronous,aCallBack);
       
   635             Interface->ExecuteCmdL(Command,*input,*output,KLiwOptCancel,aCallBack);
       
   636 	}
       
   637 		else if(operation == 4)
       
   638 	{
       
   639 	        Interface->Close();
       
   640 	        CleanupStack::Pop();
       
   641 	        CleanupStack::PopAndDestroy(7);
       
   642             return KErrNone;
       
   643 	}
       
   644 	else if(operation == 5) // Stress testing: Calling getlist n number of times
       
   645 	{
       
   646 	TInt no_of_times;
       
   647 	TInt retcode = KErrNone;
       
   648 	arg1->it->GetNextInt(no_of_times);
       
   649 	for (int i=0;i<no_of_times;i++)	
       
   650 	{
       
   651 			
       
   652 		        if( Interface != NULL)
       
   653 		        output->Reset();
       
   654 	        	Interface->ExecuteCmdL(Command,*input,*output,KLiwOptASyncronous,aCallBack);
       
   655 				_LIT8(KErrorCode,"ErrorCode");
       
   656 			    pos = 0;
       
   657 			    TInt retcode;        
       
   658 	            p = output->FindFirst(pos, KErrorCode); // Finding Error Code
       
   659 	            
       
   660 	            TUint transactionID = 0;
       
   661 		        if(p)
       
   662 			    {
       
   663 			    	retcode = p->Value().AsTInt32();
       
   664 
       
   665 			    	if(retcode != KErrNone)
       
   666 			    	{
       
   667 
       
   668 			    	CleanupStack::PopAndDestroy(); //.sorting Map,filterMap,Interface,input, output, Scheduler,aCallBack
       
   669 			    	CleanupStack::PopAndDestroy();
       
   670 			    	CleanupStack::PopAndDestroy();
       
   671 			    	CleanupStack::PopAndDestroy();
       
   672 			    	CleanupStack::PopAndDestroy();
       
   673 			    	CleanupStack::PopAndDestroy();
       
   674 			    	CleanupStack::PopAndDestroy();
       
   675 			    	CleanupStack::PopAndDestroy();
       
   676 			    	return retcode;
       
   677 			    	}
       
   678 			    	else
       
   679 			    		{
       
   680 			    		CActiveScheduler :: Start() ;
       
   681 			    		}
       
   682 			    }
       
   683 				else
       
   684 					{
       
   685 					CleanupStack::PopAndDestroy(input); 
       
   686     				return KErrGeneral ;
       
   687 					}
       
   688 	    
       
   689 	    }
       
   690 	CleanupStack::PopAndDestroy(8); 
       
   691 	return KErrNone;
       
   692 	    
       
   693 	}
       
   694 	
       
   695 	else if(operation == 6) // Loading twice
       
   696 	{
       
   697 		// normal asynch operation
       
   698 	        if( Interface != NULL)
       
   699 	    	Interface->ExecuteCmdL(Command,*input,*output,KLiwOptASyncronous,aCallBack);
       
   700 	        _LIT8(KErrorCode,"ErrorCode");
       
   701 		    pos = 0;
       
   702 		    TInt retcode = KErrNone;
       
   703 		    p = output->FindFirst(pos, KErrorCode); // Finding Error Code
       
   704 
       
   705 
       
   706 		    if(p)
       
   707 		    {
       
   708 		    	retcode = p->Value().AsTInt32();
       
   709 
       
   710 		    	if(retcode != KErrNone)
       
   711 		    	{
       
   712 
       
   713 		    	CleanupStack::PopAndDestroy(); //.sorting Map,filterMap,Interface,input, output, Scheduler,aCallBack
       
   714 		    	CleanupStack::PopAndDestroy();
       
   715 		    	CleanupStack::PopAndDestroy();
       
   716 		    	CleanupStack::PopAndDestroy();
       
   717 		    	CleanupStack::PopAndDestroy();
       
   718 		    	CleanupStack::PopAndDestroy();
       
   719 		    	CleanupStack::PopAndDestroy();
       
   720 		    	CleanupStack::PopAndDestroy();
       
   721 		    	return retcode;
       
   722 		    	}
       
   723 		    }
       
   724 
       
   725 		    CActiveScheduler :: Start() ;
       
   726 		    CleanupStack::PopAndDestroy(7); //Interface ,input, output, coreobj, Scheduler,aCallBack
       
   727 		    
       
   728 		    
       
   729 		    CActiveScheduler *Scheduler = new (ELeave) CActiveScheduler ;
       
   730 			CActiveScheduler :: Install(Scheduler) ;
       
   731 			CleanupStack::PushL(Scheduler);
       
   732 
       
   733 		    CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL();
       
   734 		    CleanupStack::PushL(iServiceHandler);
       
   735 
       
   736 		    CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIDataSource,KService);
       
   737 		    crit->SetServiceClass(TUid::Uid(KLiwClassBase));
       
   738 		    CleanupStack::PushL(crit);
       
   739 
       
   740 
       
   741 		    RCriteriaArray critArray;
       
   742 		    critArray.AppendL(crit);
       
   743 		    CleanupClosePushL(critArray);
       
   744 
       
   745 		    iServiceHandler->AttachL(critArray);
       
   746 
       
   747 		    //Create the object of callback
       
   748 			MLiwNotifyCallback*  aCallBack = new (ELeave) Callback(arg1);
       
   749 			CleanupStack::PushL(aCallBack);
       
   750 
       
   751 
       
   752 
       
   753 		    CLiwGenericParamList* output = CLiwGenericParamList::NewL();
       
   754 			CleanupStack::PushL(output);
       
   755 		
       
   756 
       
   757 		    iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output);
       
   758 
       
   759 
       
   760 		    // Create the Instance of SAPI class and the Input Param and output Param
       
   761 		    TInt pos = 0;
       
   762 		    MLiwInterface* Interface = NULL;
       
   763 		    output->FindFirst(pos,KIDataSource );
       
   764 		    if(pos != KErrNotFound)
       
   765 		        {
       
   766 		        Interface = (*output)[pos].Value().AsInterface();
       
   767 		        }
       
   768 		    output->Reset();
       
   769 		    CleanupClosePushL(*Interface);
       
   770 		    // normal asynch operation
       
   771 	        if( Interface != NULL)
       
   772 	    	Interface->ExecuteCmdL(Command,*input,*output,KLiwOptASyncronous,aCallBack);
       
   773 
       
   774 		    
       
   775 			
       
   776 	}
       
   777 	else
       
   778 	{
       
   779 	        // synchronous
       
   780 	    	Interface->ExecuteCmdL(Command,*input,*output,0,aCallBack);
       
   781 	}
       
   782 
       
   783     _LIT8(KErrorCode,"ErrorCode");
       
   784     pos = 0;
       
   785     TInt retcode = KErrNone;
       
   786     p = output->FindFirst(pos, KErrorCode); // Finding Error Code
       
   787 
       
   788 
       
   789     if(p)
       
   790     {
       
   791     	retcode = p->Value().AsTInt32();
       
   792 
       
   793     	if(retcode != KErrNone)
       
   794     	{
       
   795 
       
   796     	CleanupStack::PopAndDestroy(); //.sorting Map,filterMap,Interface,input, output, Scheduler,aCallBack
       
   797     	CleanupStack::PopAndDestroy();
       
   798     	CleanupStack::PopAndDestroy();
       
   799     	CleanupStack::PopAndDestroy();
       
   800     	CleanupStack::PopAndDestroy();
       
   801     	CleanupStack::PopAndDestroy();
       
   802     	CleanupStack::PopAndDestroy();
       
   803     	CleanupStack::PopAndDestroy();
       
   804     	return retcode;
       
   805     	}
       
   806     }
       
   807 
       
   808     CActiveScheduler :: Start() ;
       
   809     CleanupStack::PopAndDestroy(8); //Interface ,input, output, coreobj, Scheduler,aCallBack
       
   810     return retcode ;
       
   811 }
       
   812