servicediscoveryandcontrol/pnp/test/upnp/IntegTest/testupnp/src/testupnpmanager.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Contains implementation of CTestUPnPManager class
       
    15 // Contains implemenatation of CTestUPnPManager, CUPnPObserver, CUPnPTimer, 
       
    16 // and CAction classes
       
    17 // 
       
    18 //
       
    19 
       
    20 #include "testupnpmanager.h"
       
    21 
       
    22 
       
    23 /*
       
    24   Constructor:
       
    25   @internalTechnology
       
    26   @test
       
    27 */
       
    28 CTestUPnPManager::CTestUPnPManager()
       
    29 :	CTestStep()
       
    30 	{
       
    31 	iCancelDiscovery = EFalse;
       
    32 	iExpectedData = EFalse;
       
    33 	iDiscoverySuccess = EFalse;
       
    34 	iNotifyCount = 0;
       
    35 	iPublishCount = 0;
       
    36 	iDescribeResponseCount = 0;
       
    37 	iRenewCount = 0;
       
    38 	iFailedNumUris = 0;
       
    39 	}
       
    40 
       
    41 /*
       
    42    Initializes all member vaiables.
       
    43    @param		None.
       
    44    @return		None.
       
    45 */
       
    46 void CTestUPnPManager::InitializeL()
       
    47 	{
       
    48 	iScheduler = new (ELeave) CActiveScheduler;
       
    49 	CActiveScheduler::Install(iScheduler);
       
    50 	}
       
    51 
       
    52 /*
       
    53    Destructor
       
    54    @internalTechnology
       
    55    @test
       
    56 */
       
    57 CTestUPnPManager::~CTestUPnPManager()
       
    58 	{
       
    59 	_LIT(KInfoDesctructorBegin, "Begin: In Destructor CTestUpnPanager....\n");
       
    60 	INFO_PRINTF1(KInfoDesctructorBegin);
       
    61 	if(iStringPoolMgr)
       
    62 		{
       
    63 		iStringPoolMgr->Release();
       
    64 		//this will tkae care of clean up of iStringPool
       
    65 		}
       
    66 	_LIT(KInfoDesctructorBegin2, "Releasing String Pool Manager....\n");
       
    67 	INFO_PRINTF1(KInfoDesctructorBegin2);
       
    68 		
       
    69 	CleanUpObserverArray();
       
    70 	iDeviceLocationArray.Close();
       
    71 	CleanUpResultsArray();
       
    72 	DescriptionSuiteCleanUp();
       
    73 	ScpdUriArrayCleanUp();
       
    74 	ControlUriArrayCleanUp();
       
    75 	EventUriArrayCleanUp();
       
    76 	CloseDiscoverer();
       
    77 	//#ifdef _DEBUG
       
    78 		ClosePublisher();
       
    79 		CActiveScheduler::Install(NULL); //Testing for ONB hangs
       
    80 		_LIT(KInfoDesctructorBegin1, "Deleting the Active Schedulers....\n");
       
    81 		INFO_PRINTF1(KInfoDesctructorBegin1);
       
    82 		delete iScheduler;
       
    83 		iScheduler = NULL;	
       
    84 	//#endif //_Debug
       
    85 
       
    86 	iPublisherObserverMap.Close();	
       
    87 	_LIT(KInfoDesctructorEnd, "End: ....In Destructor CTestUpnPanager\n");
       
    88 	INFO_PRINTF1(KInfoDesctructorEnd);
       
    89 	
       
    90 	//iConnection.Close ();
       
    91 	//iSocketServ.Close ();
       
    92 	}
       
    93 
       
    94 void CTestUPnPManager::ClosePublisher()
       
    95 	{
       
    96 	_LIT(KInfoLogFile, "ClosePublisher....\n");
       
    97 	INFO_PRINTF1(KInfoLogFile);
       
    98 	CancelPublish();
       
    99 	}
       
   100 
       
   101 void CTestUPnPManager::CloseDiscoverer()
       
   102 	{
       
   103 	iControlPoint.Close();
       
   104 	}
       
   105 
       
   106 void CTestUPnPManager::CleanUpObserverArray()
       
   107 	{
       
   108 	_LIT(KInfoLogFile, "CleanUpObserverArray....\n");
       
   109 	INFO_PRINTF1(KInfoLogFile);
       
   110 	if (iObserverArray.Count() > 0 )
       
   111 		{
       
   112 		iObserverArray.ResetAndDestroy();
       
   113 		}
       
   114 	else
       
   115 		{
       
   116 		iObserverArray.Close();
       
   117 		}
       
   118 	_LIT(KInfoLogFile1, "CleanUpObserverArray End....\n");
       
   119 	INFO_PRINTF1(KInfoLogFile1);
       
   120 	}
       
   121 
       
   122 void CTestUPnPManager::CleanUpResultsArray()
       
   123 	{
       
   124 	_LIT(KInfoLogFile, "CleanUpResultsArray....\n");
       
   125 	INFO_PRINTF1(KInfoLogFile);
       
   126 	TInt count = iResultsArray.Count();
       
   127 		for (TInt index(0); index < count ; index++ )
       
   128 			{
       
   129 			iResultsArray[index].Close();
       
   130 			}
       
   131 	iResultsArray.Close();
       
   132 	_LIT(KInfoLogFile1, "CleanUpResultsArray End....\n");
       
   133 	INFO_PRINTF1(KInfoLogFile1);
       
   134 	}
       
   135 
       
   136 void CTestUPnPManager::DescriptionSuiteCleanUp()
       
   137 	{
       
   138 	_LIT(KInfoLogFile, "DescriptionSuiteCleanUp....\n");
       
   139 	INFO_PRINTF1(KInfoLogFile);
       
   140 	TInt count = iDescriptionSuiteArray.Count();
       
   141 	for (TInt index(0); index < count ; index++ )
       
   142 		{
       
   143 		iDescriptionSuiteArray[index].iBaseUrl.Close();
       
   144 		iDescriptionSuiteArray[index].iDescription.Close();
       
   145 		DeleteSeriveUrlsList(index);
       
   146 		}
       
   147 	iDescriptionSuiteArray.Close();
       
   148 	_LIT(KInfoLogFile1, "DescriptionSuiteCleanUp End...\n");
       
   149 	INFO_PRINTF1(KInfoLogFile1);
       
   150 	}
       
   151 
       
   152 void CTestUPnPManager::ScpdUriArrayCleanUp()
       
   153 	{
       
   154 	_LIT(KInfoLogFile, "ScpdUriArrayCleanUp....\n");
       
   155 	INFO_PRINTF1(KInfoLogFile);
       
   156 	TInt count = iScpdUriArray.Count();
       
   157 	for (TInt index(0); index < count ; index++ )
       
   158 		{
       
   159 		iScpdUriArray[index].Close();
       
   160 		}
       
   161 	iScpdUriArray.Close();
       
   162 	
       
   163 	count = iIconUriArray.Count ();
       
   164 	for (TInt index(0); index < count ; index++ )
       
   165 		{
       
   166 		iIconUriArray[index].Close();
       
   167 		}
       
   168 	iIconUriArray.Close();	
       
   169 	
       
   170 	_LIT(KInfoLogFile1, "ScpdUriArrayCleanUp End....\n");
       
   171 	INFO_PRINTF1(KInfoLogFile1);
       
   172 	}
       
   173 
       
   174 void CTestUPnPManager::EventUriArrayCleanUp()
       
   175 	{
       
   176 	_LIT(KInfoLogFile, "EventUriArrayCleanUp....\n");
       
   177 	INFO_PRINTF1(KInfoLogFile);
       
   178 	TInt count = iEventUriArray.Count();
       
   179 	for (TInt index(0); index < count ; index++ )
       
   180 		{
       
   181 		iEventUriArray[index].Close();
       
   182 		}
       
   183 	iEventUriArray.Close();
       
   184 	_LIT(KInfoLogFile1, "EventUriArrayCleanUp End....\n");
       
   185 	INFO_PRINTF1(KInfoLogFile1);
       
   186 	}
       
   187 
       
   188 void CTestUPnPManager::ControlUriArrayCleanUp()
       
   189 	{
       
   190 	_LIT(KInfoLogFile, "ControlUriArrayCleanUp....\n");
       
   191 	INFO_PRINTF1(KInfoLogFile);
       
   192 	TInt count = iControlUriArray.Count();
       
   193 	for (TInt index(0); index < count ; index++ )
       
   194 		{
       
   195 		iControlUriArray[index].Close();
       
   196 		}
       
   197 	iControlUriArray.Close();
       
   198 	_LIT(KInfoLogFile1, "ControlUriArrayCleanUp End....\n");
       
   199 	INFO_PRINTF1(KInfoLogFile1);
       
   200 	}
       
   201 
       
   202 /*
       
   203    Implementation of CTestStep base class virtual and this is used for doing all
       
   204    initialisation common
       
   205     to derived classes here.
       
   206    @param  None
       
   207    @return TVerdict
       
   208  */
       
   209 TVerdict CTestUPnPManager::doTestStepPreambleL()
       
   210 	{
       
   211 	InitializeL();
       
   212 	SavePreviousLogFileL();
       
   213 	return CTestStep::doTestStepPreambleL();
       
   214 	}
       
   215 
       
   216 /*
       
   217  Save the previous log file...if any
       
   218 */
       
   219 void CTestUPnPManager::SavePreviousLogFileL()
       
   220 	{
       
   221 	_LIT(KInfoLogFile, "Saving Previous logs If any.... \n");
       
   222 	INFO_PRINTF1(KInfoLogFile);
       
   223 	RFs fileserv;
       
   224 	TInt error = fileserv.Connect();
       
   225 	if(!error)
       
   226 		{
       
   227 		_LIT(KlogFile, "C:\\logs\\log.txt");
       
   228 		_LIT(KPrefixLog, "C:\\upnplogs\\");
       
   229 		_LIT(KSuffix, "_UDEB");
       
   230 		_LIT(KExtn, ".txt");
       
   231 		
       
   232 		CFileMan* fMan = NULL;
       
   233 		TRAP_IGNORE(fMan = CFileMan::NewL(fileserv));
       
   234 		if(fMan != NULL)
       
   235 			{
       
   236 			CleanupStack::PushL(fMan);
       
   237 			RBuf newFileName, traceFileName ;
       
   238 			const TInt KTwentyFour = 24;
       
   239 			newFileName.Create(ConfigSection().Length() + KTwentyFour );
       
   240 			newFileName.Copy(KPrefixLog);
       
   241 			//Script file name
       
   242 			iScriptName.Copy(ConfigSection());
       
   243 			newFileName.Append(iScriptName);
       
   244 			newFileName.Append(KSuffix);
       
   245 			newFileName.Append(KExtn);
       
   246 			TInt error = fMan->Rename(KlogFile, newFileName);			
       
   247 						
       
   248 			if (error != KErrNone)
       
   249 				{
       
   250 				_LIT(KErrInfo, "Unable to Save Previous logs...May be NO Previous logs exist \n");
       
   251 				ERR_PRINTF1(KErrInfo);
       
   252 				}
       
   253 			else
       
   254 				{
       
   255 				_LIT(KSavingInfo, "<font color=0000ff><b>Saved Previous logs with File Name: <u>%S</u> </b></font> \n");
       
   256 				INFO_PRINTF2(KSavingInfo, &newFileName);
       
   257 				
       
   258 				//btracelog
       
   259 				_LIT(KBtracelogFile, "C:\\logs\\btrace.log");
       
   260 				_LIT(KBTrace, "btrace.log");				
       
   261 				traceFileName.Create(KPrefixLog().Length() + iScriptName.Length() + KBTrace().Length() );
       
   262 	  			traceFileName.Copy(KPrefixLog);
       
   263 	  			traceFileName.Append(iScriptName);
       
   264 	  			traceFileName.Append(KBTrace);	  			
       
   265 	  			error = fMan->Rename(KBtracelogFile, traceFileName);				
       
   266 	  			if ( error == KErrNone )
       
   267 		  			{
       
   268 		  			_LIT(KBtraceInfo, "<font color=0000ff><b>Saved Previous btrace logs with File Name: <u>%S</u> </b></font> \n");		  			
       
   269 					INFO_PRINTF2(KBtraceInfo, &traceFileName);
       
   270 		  			}				
       
   271 				}
       
   272 			CleanupStack::PopAndDestroy(fMan);
       
   273 			newFileName.Close();
       
   274 			traceFileName.Close ();
       
   275 			}
       
   276 		}
       
   277 	fileserv.Close();
       
   278 	_LIT(KInfoLogFile1, "Saving Previous logs End.... \n");
       
   279 	INFO_PRINTF1(KInfoLogFile1);
       
   280 	}
       
   281 
       
   282 /*
       
   283  return Script File name..if any
       
   284 */
       
   285 const TDesC& CTestUPnPManager::ScriptFileName()
       
   286 	{
       
   287 	return iScriptName;
       
   288 	}
       
   289 
       
   290 /*
       
   291    Implementation of CTestStep base class virtual and it is used for doing all
       
   292    after test treatment common to derived classes in here.
       
   293    @return TVerdict
       
   294  */
       
   295 TVerdict CTestUPnPManager::doTestStepPostambleL()
       
   296 	{
       
   297 	return CTestStep::doTestStepPostambleL();
       
   298 	}
       
   299 
       
   300 
       
   301 TVerdict CTestUPnPManager::doTestStepL()
       
   302 	{
       
   303 	SequenceOperationsL();
       
   304 	return TestStepResult();
       
   305 	}
       
   306 
       
   307 /*
       
   308    This function performs operations based on sequence specified in the ini file
       
   309    @param  None
       
   310    @return None
       
   311 */
       
   312 void CTestUPnPManager::SequenceOperationsL()
       
   313 	{
       
   314 	_LIT(KInfoLogFile, "SequenceOperationsL().... \n");
       
   315 	INFO_PRINTF1(KInfoLogFile);
       
   316 	RArray<TPtrC> sequenceList;
       
   317 	CleanupClosePushL(sequenceList);
       
   318 	TPtrC listOfSequences;
       
   319 	_LIT(KListOfSequences, "listofsequences");
       
   320 	GetStringFromConfig(ConfigSection(), KListOfSequences, listOfSequences);
       
   321 
       
   322 	TokenizeStringL(listOfSequences, sequenceList);
       
   323 	TInt numOperations = sequenceList.Count();
       
   324 
       
   325 	for(TInt i(0); i < numOperations; i++)
       
   326 		{
       
   327 		SetCurrentSection(sequenceList[i]);
       
   328 		PerformDesiredOperationsL(sequenceList[i]);
       
   329 		}
       
   330 	CleanupStack::PopAndDestroy(); 
       
   331 	_LIT(KInfoLogFile1, "SequenceOperationsL() End.... \n");
       
   332 	INFO_PRINTF1(KInfoLogFile1);
       
   333 	}
       
   334 
       
   335 void TestUtils::LoadESockL ( RSocketServ& aSocketServ, RConnection& aConnection )
       
   336 	{
       
   337 	User::LeaveIfError ( aSocketServ.Connect () );
       
   338 	User::LeaveIfError ( aConnection.Open ( aSocketServ ) );
       
   339 	TRequestStatus status;
       
   340 	aConnection.Start ( status );
       
   341 	User::WaitForRequest ( status );
       
   342 	User::LeaveIfError ( status.Int () );
       
   343 	aConnection.CancelAllInterfaceNotification ();
       
   344 	aConnection.CancelProgressNotification ();
       
   345 	aConnection.CancelServiceChangeNotification ();
       
   346 	aConnection.CancelAllSubConnectionNotification ();
       
   347 	}
       
   348 
       
   349 /*
       
   350    This function performs desired operations specified as a parameter
       
   351    @param  aOperation string representing operation to be performed
       
   352    @return None
       
   353 */
       
   354 void CTestUPnPManager::PerformDesiredOperationsL(const TDesC& aOperation)
       
   355 	{
       
   356 	const TInt KMatch = 0;
       
   357 	TPtrC operationType;
       
   358 	_LIT(KOperationType, "operationtype");
       
   359 	GetStringFromConfig(aOperation, KOperationType, operationType);
       
   360 	
       
   361 	/*if ( iConnection.SubSessionHandle () == 0 )
       
   362 		{
       
   363 		TestUtils::LoadESockL ( iSocketServ, iConnection );
       
   364 		}*/
       
   365 
       
   366 	if(operationType.Compare(KOpenDiscoverer) == KMatch)
       
   367 		{
       
   368 		OpenDiscovererL();
       
   369 		}
       
   370 	else if(operationType.Compare(KOpenPublisher) == KMatch)
       
   371 		{
       
   372 		OpenMultiplePublisherL();
       
   373 		}
       
   374 	else if(operationType.Compare(KDiscovery) == KMatch)
       
   375 		{
       
   376 		DiscoverL(aOperation);
       
   377 		}
       
   378 	else if(operationType.Compare(KCancelDiscover) == KMatch)
       
   379 		{
       
   380 		CancelDiscoverL(aOperation);
       
   381 		}
       
   382 	else if(operationType.Compare(KCancelDescribe) == KMatch)
       
   383 		{
       
   384 		CancelDescribeL(aOperation);
       
   385 		}
       
   386 	else if(operationType.Compare(KPublishService) == KMatch)
       
   387 		{
       
   388 		PublishServiceL(aOperation);
       
   389 		}
       
   390 	else if(operationType.Compare(KPublishDevice) == KMatch)
       
   391 		{
       
   392 		PublishDeviceL(aOperation);
       
   393 		}
       
   394 	else if(operationType.Compare(KDescribe) == 0)
       
   395 		{
       
   396 		DescribeL();
       
   397 		}
       
   398 	else if(operationType.Compare(KDescribeService) == 0)
       
   399 		{
       
   400 		DescribeServiceL();
       
   401 		}
       
   402 	else if(operationType.Compare(KSubscribe) == 0)
       
   403 		{
       
   404 		SubscribeForStateChangeNotificationsL();
       
   405 		}
       
   406 	else if(operationType.Compare(KUnsubscribe) == 0)
       
   407 		{
       
   408 		UnsubscribeForStateChangeNotificationsL(aOperation);
       
   409 		}
       
   410 	else if(operationType.Compare(KRegisterAnnouncement) == KMatch)
       
   411 		{
       
   412 		RegisterForAnnouncementsL(aOperation);
       
   413 		}
       
   414 	else if(operationType.Compare(KCancelNotify) == KMatch)
       
   415 		{
       
   416 		CancelNotifyAnnouncementL(aOperation);
       
   417 		}
       
   418 	else if(operationType.Compare(KInitiateControl) == KMatch)
       
   419 		{
       
   420 		InitiateActionL(aOperation);
       
   421 		}
       
   422 	else if ( operationType.Compare(KDescribeIcon) == KMatch)
       
   423 		{
       
   424 		DescribeIconL();
       
   425 		}
       
   426 	else if(operationType.Compare(KStartScheduler) == KMatch)
       
   427 		{
       
   428 		CActiveScheduler::Start();
       
   429 		}
       
   430 	else if(operationType.Compare(KStopScheduler) == KMatch)
       
   431 		{
       
   432 		CActiveScheduler::Stop();
       
   433 		}
       
   434 	else if(operationType.Compare(KStartTimer) == KMatch)
       
   435 		{
       
   436 		StartTimerL(aOperation);
       
   437 		}
       
   438 	else if(operationType.Compare(KPrintResults) == 0)
       
   439 		{
       
   440 		PrintAndValidateResultsL(aOperation);
       
   441 		}
       
   442 	}
       
   443 
       
   444 /*
       
   445    Parses a comma separated string and constructs a list out of the values
       
   446    @param	aString a reference to a string to be tokenized
       
   447    @param	aList is an out parameter to store a list of tokens in an arry
       
   448    @param	aSeparator is a character used to delimit the tokens
       
   449   */
       
   450 void CTestUPnPManager::TokenizeStringL(const TDesC& aString, RArray<TPtrC>& aList, TChar aSeparator)
       
   451 	{
       
   452 	TLex lexer(aString);
       
   453 
       
   454 	while(!lexer.Eos())
       
   455 		{
       
   456 		lexer.SkipSpaceAndMark();
       
   457 
       
   458 		while(!lexer.Eos() && lexer.Get() != aSeparator)
       
   459 			{
       
   460 			}
       
   461 
       
   462 		if(!lexer.Eos())
       
   463 			{
       
   464 			lexer.UnGet();
       
   465 			}
       
   466 		aList.AppendL(lexer.MarkedToken());
       
   467 		lexer.Inc();
       
   468 		}
       
   469 	}
       
   470 
       
   471 /*
       
   472    Starts a timer for a wait time and triggers CallBack function as timer expires.
       
   473    @param	None
       
   474    @return	None
       
   475  */
       
   476 void CTestUPnPManager::StartTimerL(const TDesC& aOperationType)
       
   477 	{
       
   478 	_LIT(KInfoLogFile, "StartTimerL.... \n");
       
   479 	INFO_PRINTF1(KInfoLogFile);
       
   480 	_LIT(KWaitTime,"waittime");
       
   481 	TInt waitTime = 0;
       
   482 	GetIntFromConfig(aOperationType, KWaitTime, waitTime);
       
   483 //	TTimeIntervalMicroSeconds32 interval(waitTime);
       
   484 	CUPnPTimer* timer = CUPnPTimer::NewL(this);
       
   485 	CleanupStack::PushL(timer);
       
   486 	timer->IssueRequestL(waitTime);
       
   487 	CActiveScheduler::Start();
       
   488 	CleanupStack::PopAndDestroy(timer);
       
   489 	_LIT(KInfoLogFile1, "StartTimerL End.... \n");
       
   490 	INFO_PRINTF1(KInfoLogFile1);
       
   491 	}
       
   492 
       
   493 /*
       
   494    Sets the current config section.
       
   495    @param	aCurrentSection - a reference string that represent current config section
       
   496    @return	None
       
   497  */
       
   498 void CTestUPnPManager::SetCurrentSection(const TDesC& aCurrentSection)
       
   499 	{
       
   500 	iCurrentSection = aCurrentSection;
       
   501 	}
       
   502 
       
   503 /*
       
   504    Retrieve the current config section.
       
   505    @param
       
   506    @return	Reference to current config section
       
   507  */
       
   508 TDesC& CTestUPnPManager::GetCurrentSection()
       
   509 	{
       
   510 	return	iCurrentSection;
       
   511 	}
       
   512 
       
   513 /*
       
   514 	Tests whether discovering services/devices is performing as specified in UPnP specifications.
       
   515 	@param		aOperationType is reference to a section name in ini file where required parameters
       
   516 				needs to be referred for this operation.
       
   517 	@return		None.
       
   518  */
       
   519 void CTestUPnPManager::DiscoverL(const TDesC& aOperationType)
       
   520 	{
       
   521 	RArray<TPtrC> serviceTypeList;
       
   522 	RArray<TPtrC> mxTimeList;
       
   523 	TPtrC listOfServiceTypes;
       
   524 	TPtrC listOfMxTimes;
       
   525 	_LIT(KListOfServiceTypes, "listofservicetypes");
       
   526 	_LIT(KListOfMxTimes, "listofmxtimes");
       
   527 	_LIT(KInfoLogFile, "DiscoverL.... \n");
       
   528 	INFO_PRINTF1(KInfoLogFile);
       
   529 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
   530 	iObserverArray.Append(upnpObserver);
       
   531 	
       
   532 	RPnPParameterBundle pnpBundle;
       
   533 	pnpBundle.Open ();
       
   534 	CleanupClosePushL( pnpBundle );
       
   535 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
   536 
       
   537 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPDiscoverRequestParamSet);
       
   538 	if(!GetStringFromConfig(GetCurrentSection(), KListOfServiceTypes, listOfServiceTypes)
       
   539 			|| !GetStringFromConfig(GetCurrentSection(), KListOfMxTimes, listOfMxTimes))
       
   540 		{
       
   541 		_LIT(KErrInfo, "Problem in reading values from ini. \n Expected fields are: \n%S, \n%S \n");
       
   542 		ERR_PRINTF3( KErrInfo, &KListOfServiceTypes, &KListOfMxTimes );
       
   543 		//SetTestStepResult(EFail);
       
   544 		return;
       
   545 		}
       
   546 
       
   547 	TokenizeStringL(listOfServiceTypes, serviceTypeList);
       
   548 	TokenizeStringL(listOfMxTimes, mxTimeList);
       
   549 	TInt numUris = serviceTypeList.Count();
       
   550 	iFailedNumUris = serviceTypeList.Count(); //This should be of Unique Uri's count
       
   551 	TInt numMxs = mxTimeList.Count();
       
   552 	TLex responseTimeObj;
       
   553 	//__ASSERT_DEBUG ( numUris == numMxs, User::Panic (KDescoveryTestPanicCategory, KErrMissingURiOrResponceTime ) );
       
   554 	RBuf8 buf;
       
   555 	buf.Create(KMaxUriSize);
       
   556 	for(TInt i(0); i < numUris; i++)
       
   557 		{
       
   558 		CUPnPDiscoverRequestParamSet* discoverParamSet = CUPnPDiscoverRequestParamSet::NewL(pnpFamily );
       
   559 		buf.Copy(serviceTypeList[i]);
       
   560 		discoverParamSet->SetUriL( buf );
       
   561 		//response time
       
   562 		responseTimeObj.Assign(mxTimeList[i]);
       
   563 		TInt responseTime(0);
       
   564 		responseTimeObj.Val(responseTime);
       
   565 		discoverParamSet->SetResponseTime(responseTime);
       
   566 		}
       
   567 	buf.Close();
       
   568 	mxTimeList.Close();
       
   569 	serviceTypeList.Close();
       
   570 	iControlPoint.Discover(pnpBundle);
       
   571 
       
   572 	TBool delayEnabled = EFalse;
       
   573 	_LIT(KDelayEnabled, "delayenabled");
       
   574 	GetBoolFromConfig(GetCurrentSection(), KDelayEnabled, delayEnabled);
       
   575 
       
   576 	TBool SchedulerStatus = ETrue;
       
   577 	_LIT(KSchedulerStatus, "schedulerstart");
       
   578 	GetBoolFromConfig(GetCurrentSection(), KSchedulerStatus, SchedulerStatus);
       
   579 
       
   580 	if(SchedulerStatus)
       
   581 		{
       
   582 		CActiveScheduler::Start();
       
   583 		}
       
   584 
       
   585 	if(!IsDiscoverySuccess() && iFailedNumUris <= 0 )
       
   586 		{
       
   587 		//In Case of failure of Discovery....Trying once more to Discover.
       
   588 		//Retrty Discovery only if and only if All Uri's Timedout
       
   589 		_LIT(KInfoDiscoverRetry, "<font color=00ff00><b><u>Retrying Discovery....</u></b></font> \n");
       
   590 		INFO_PRINTF1(KInfoDiscoverRetry );
       
   591 		SetDiscoveryStatus(ETrue);
       
   592 		iControlPoint.Discover(pnpBundle);
       
   593 		if(SchedulerStatus)
       
   594 			{
       
   595 			CActiveScheduler::Start();
       
   596 			}
       
   597 		}
       
   598 	if(delayEnabled)
       
   599 		{
       
   600 		StartTimerL(aOperationType);
       
   601 		}
       
   602 	_LIT(KInfoLogFile1, "DiscoverL End... \n");
       
   603 	INFO_PRINTF1(KInfoLogFile1);
       
   604 	CleanupStack::PopAndDestroy( &pnpBundle );
       
   605 	}
       
   606 
       
   607 TBool CTestUPnPManager::IsDiscoverySuccess()
       
   608 	{
       
   609 	return iDiscoverySuccess;
       
   610 	}
       
   611 
       
   612 void CTestUPnPManager::SetDiscoveryStatus(TBool aSuccess)
       
   613 	{
       
   614 	_LIT(KInfoDiscoverSetStatus, "Setting iDiscoverySuccesss Flag to %d \n");
       
   615 	INFO_PRINTF2(KInfoDiscoverSetStatus, aSuccess );
       
   616 	iDiscoverySuccess = aSuccess;
       
   617 	}
       
   618 
       
   619 /*
       
   620 	Tests whether Publishing a Service/Device is performing as specified in UPnP specifications.
       
   621 	@param			aOperationType is reference to a section name in ini file where required parameters
       
   622 					needs to be referred for this operation.
       
   623 	@return			None.
       
   624  */
       
   625 void CTestUPnPManager::PublishServiceL (const TDesC& aOperationType)
       
   626 	{
       
   627 	_LIT(KInfoLogFile, "PublishServiceL().... \n");
       
   628 	INFO_PRINTF1(KInfoLogFile);
       
   629 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
   630 	iObserverArray.Append(upnpObserver);
       
   631 	//To keep track of mapping between Observer and Publisher
       
   632 	TInt observerIndex = iObserverArray.Count() - 1;
       
   633 	RPnPParameterBundle pnpBundle ;
       
   634 	pnpBundle.Open();
       
   635 	
       
   636     CleanupClosePushL( pnpBundle );
       
   637     pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
   638     RParameterFamily family = pnpBundle.CreateFamilyL(EUPnPServiceRegisterParamSet);
       
   639     
       
   640 	
       
   641    	CUPnPServiceRegisterParamSet* registerServiceParamSet = CUPnPServiceRegisterParamSet::NewL(family );
       
   642 	TPtrC serviceType;
       
   643 	GetStringFromConfig(aOperationType, KServiceType, serviceType);
       
   644 	RBuf8 serviceTypeBuf;
       
   645 	serviceTypeBuf.Create(serviceType.Length());
       
   646 	serviceTypeBuf.Copy(serviceType);
       
   647 
       
   648 	TPtrC usn;
       
   649 	GetStringFromConfig(aOperationType, KUSN, usn);
       
   650 	RBuf8 usnBuf;
       
   651 	usnBuf.Create(usn.Length());
       
   652 	usnBuf.Copy(usn);
       
   653 
       
   654 	TInt duration;
       
   655 	GetIntFromConfig(aOperationType, KCacheControl, duration);
       
   656 
       
   657 	TPtrC description;
       
   658 	GetStringFromConfig(aOperationType, KDescription, description);
       
   659 	RBuf8 descriptionBuf;
       
   660 	descriptionBuf.Create(description.Length());
       
   661 	descriptionBuf.Copy(description);
       
   662 
       
   663 	TInt serviceduration =  300;
       
   664 	GetIntFromConfig(aOperationType, KServiceMaxDuration, serviceduration);
       
   665 		
       
   666 	registerServiceParamSet->SetUriL ( serviceTypeBuf );
       
   667 	registerServiceParamSet->SetDeviceUidL ( usnBuf );
       
   668 	registerServiceParamSet->SetCacheControlData ( duration );
       
   669 	registerServiceParamSet->SetSubscriptionDuration(serviceduration);
       
   670 	
       
   671 	ExtractServiceDescriptionL (aOperationType, *registerServiceParamSet);
       
   672 
       
   673 	_LIT8(KInitialMessage, "Initial Service Message");
       
   674 	registerServiceParamSet->SetInitialMessageL(KInitialMessage);
       
   675 
       
   676 	//To keep track of mapping between Observer and Publisher
       
   677 	TInt publisherIndex = OpenPublisherL();
       
   678 	//Create mapping of Publsiher and observer
       
   679 	TPublisherObserverMap publisherObserverMapElement;
       
   680 	publisherObserverMapElement.iPublisherIndex = publisherIndex;
       
   681 	publisherObserverMapElement.iObserverIndex =  observerIndex;
       
   682 	publisherObserverMapElement.iPublisherControl = KService;
       
   683 	iPublisherObserverMap.Append(publisherObserverMapElement);
       
   684 
       
   685 	//Publish service nad update publish count
       
   686 	iPublishCount++;
       
   687 	iPublisherArray[publisherIndex].Publish( pnpBundle );
       
   688 
       
   689 	TBool SchedulerStart = EFalse;
       
   690 	_LIT(KSchedulerStart, "schedulerstart");
       
   691 	GetBoolFromConfig(aOperationType, KSchedulerStart, SchedulerStart);
       
   692 	if(SchedulerStart)
       
   693 		{
       
   694 		CActiveScheduler::Start();
       
   695 		}
       
   696 	_LIT(KInfoLogFile1, "PublishServiceL() End.... \n");
       
   697 	INFO_PRINTF1(KInfoLogFile1);
       
   698 	descriptionBuf.Close();
       
   699 	usnBuf.Close();
       
   700 	serviceTypeBuf.Close();
       
   701 	CleanupStack::PopAndDestroy( &pnpBundle );
       
   702 	}
       
   703 	
       
   704 /*
       
   705  * Get publisher mapping index for the given observer index
       
   706  */
       
   707 TInt CTestUPnPManager::GetPublisherIndex (TInt aObserverIndex)
       
   708 	{
       
   709 	_LIT(KInfoLogFile, "GetPublisherIndex.... \n");
       
   710 	INFO_PRINTF1(KInfoLogFile);
       
   711 	
       
   712 	TInt count = iPublisherObserverMap.Count();
       
   713 	for (TInt index(0); index < count ; index++ )
       
   714 		{
       
   715 		if (iPublisherObserverMap[index].iObserverIndex == aObserverIndex)
       
   716 			{
       
   717 			return iPublisherObserverMap[index].iPublisherIndex;
       
   718 			}
       
   719 		}
       
   720 	return KErrNotFound;
       
   721 	}
       
   722 
       
   723 /*
       
   724  * Gets publisher control i.e, Device/Service for the given observer index
       
   725  */
       
   726 TPublisherControl CTestUPnPManager::GetPublisherControl (TInt aObserverIndex)
       
   727 	{
       
   728 	_LIT(KInfoLogFile, "GetPublisherControl.... \n");
       
   729 	INFO_PRINTF1(KInfoLogFile);
       
   730 	
       
   731 	TInt count = iPublisherObserverMap.Count();
       
   732 	for (TInt index(0); index < count ; index++ )
       
   733 		{
       
   734 		if (iPublisherObserverMap[index].iObserverIndex == aObserverIndex)
       
   735 			{
       
   736 			return iPublisherObserverMap[index].iPublisherControl;
       
   737 			}
       
   738 		}
       
   739 	return KErrNoControl;
       
   740 	}
       
   741 
       
   742 /*
       
   743  * Gets publisher control i.e, Device/Service for the given observer index
       
   744  */
       
   745 TPublisherControl CTestUPnPManager::PublisherType (TInt aPublisherIndex)
       
   746 	{
       
   747 	_LIT(KInfoLogFile, "PublisherType.... \n");
       
   748 	INFO_PRINTF1(KInfoLogFile);
       
   749 	TInt count = iPublisherObserverMap.Count();
       
   750 	TPublisherControl publisherControl = KErrNoControl;
       
   751 	for (TInt index(0); index < count ; index++ )
       
   752 		{
       
   753 		if (iPublisherObserverMap[index].iPublisherIndex == aPublisherIndex)
       
   754 			{
       
   755 			switch (iPublisherObserverMap[index].iPublisherControl)
       
   756 				{
       
   757 				case KService:
       
   758 					{
       
   759 					publisherControl = KService;
       
   760 					break;
       
   761 					}
       
   762 				case KDevice:
       
   763 					{
       
   764 					publisherControl = KDevice;
       
   765 					break;
       
   766 					}
       
   767 				default :
       
   768 					{
       
   769 					publisherControl = KErrNoControl;
       
   770 					break;
       
   771 					}
       
   772 				}
       
   773 			}
       
   774 		}
       
   775 	_LIT(KInfoLogFile2, "PublisherType....End \n");
       
   776 	INFO_PRINTF1(KInfoLogFile2);
       
   777 	return publisherControl;
       
   778 	}
       
   779 
       
   780 TInt CTestUPnPManager::NotifyCount()
       
   781 	{
       
   782 	return iNotifyCount;
       
   783 	}
       
   784 
       
   785 TBool CTestUPnPManager::SendNotificationsL (CUPnPObserver* aObserver)
       
   786 	{
       
   787 	_LIT(KInfoLogFile, "SendNotificationsL.... \n");
       
   788 	INFO_PRINTF1(KInfoLogFile);
       
   789 	
       
   790     TInt observerIndex = iObserverArray.Find(aObserver);
       
   791     TInt publisherIndex = GetPublisherIndex(observerIndex);
       
   792     TPublisherControl publisherControl = GetPublisherControl(observerIndex);
       
   793 
       
   794     if(publisherControl != KService)
       
   795     	{
       
   796     	_LIT(KSendNotifyErr,"SEND NOTIFY NOT EXECUTED -- Can be Executed only ON Services...\n");
       
   797     	ERR_PRINTF1(KSendNotifyErr);
       
   798     	return EFalse;
       
   799     	}
       
   800     RPnPParameterBundle pnpBundle;
       
   801     pnpBundle.Open();   
       
   802     CleanupClosePushL( pnpBundle );
       
   803 	pnpBundle.SetPnPObserver((MPnPObserver*)this);
       
   804 
       
   805 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL(EUPnPServiceNotificationParamSet);
       
   806     CUPnPServiceNotificationParamSet* ServiceNotifyParamSet = CUPnPServiceNotificationParamSet::NewL (pnpFamily );
       
   807 
       
   808 	RBuf8 notificationDataBuf;
       
   809 	notificationDataBuf.CreateL(_L8("notification"));
       
   810 
       
   811 	ServiceNotifyParamSet->SetNotificationL (notificationDataBuf );
       
   812 	iNotifyCount++;
       
   813 	if(publisherIndex >= 0)
       
   814 		{
       
   815 		iPublisherArray[publisherIndex].SendNotify( pnpBundle );
       
   816 		_LIT(KSendNotify,"Info: SEND NOTIFY SUCCESSFUL...\n");
       
   817 		INFO_PRINTF1(KSendNotify);
       
   818 		}
       
   819 	else
       
   820 		{
       
   821 		_LIT(KSendNotifyFailed,"Err: SEND NOTIFY UNSUCCESSFUL...\n");
       
   822 		ERR_PRINTF1(KSendNotifyFailed);
       
   823 		}
       
   824 
       
   825 	CleanupStack::PopAndDestroy( &pnpBundle );
       
   826 	notificationDataBuf.Close();
       
   827 	_LIT(KInfoLogFile1, "SendNotificationsL End.... \n");
       
   828 	INFO_PRINTF1(KInfoLogFile1);
       
   829 	
       
   830 	return ETrue;
       
   831 	}
       
   832 
       
   833 /*
       
   834 	Extract service description available in a file, copy it to the buffer and append the same to service register paramset.
       
   835 	@param			aConfigSection - reference to a section name in ini file where required parameters that needs to be referred for this operation.
       
   836 					aServiceRegisterParamSet - Storage for the description buffer
       
   837 	@return			None.
       
   838  */
       
   839 
       
   840 void CTestUPnPManager::ExtractServiceDescriptionL (const TDesC& aConfigSection, CUPnPServiceRegisterParamSet& aServiceRegisterParamSet)
       
   841 	{
       
   842 	_LIT(KInfoLogFile, "ExtractServiceDescriptionL().... \n");
       
   843 	INFO_PRINTF1(KInfoLogFile);
       
   844 	
       
   845 	TPtrC descriptionPath;
       
   846 	_LIT(KDescriptionPath, "Description_Path");
       
   847 	GetStringFromConfig(aConfigSection, KDescriptionPath, descriptionPath);
       
   848 	
       
   849 	TPtrC description;
       
   850 	_LIT(KDescription, "description");
       
   851 	GetStringFromConfig(aConfigSection, KDescription, description);
       
   852 
       
   853 	if((descriptionPath == KNullDesC) && (description == KNullDesC)) 
       
   854 		{
       
   855 		_LIT8(KDefaultServiceDescription, "defaultservicedescription");
       
   856 		TBuf8<KMaxBufLength> descBuf;
       
   857 		descBuf.Copy(KDefaultServiceDescription);
       
   858 		aServiceRegisterParamSet.SetServiceDescriptionL (descBuf);
       
   859 		return;
       
   860 		}
       
   861 	else
       
   862 		{
       
   863 		RFs fs;
       
   864 		RFile file;
       
   865 		TInt err;
       
   866 		RBuf8 buf;
       
   867 		User::LeaveIfError(fs.Connect());
       
   868 		CleanupClosePushL(fs);
       
   869 		if(descriptionPath != KNullDesC)
       
   870 			{
       
   871 			err = file.Open(fs, descriptionPath, EFileShareReadersOnly);
       
   872 			
       
   873 			// For Hardware system path is c:, so descriptionPath value present in '.ini' is referring 'c:'
       
   874 			if ( err == KErrPathNotFound )
       
   875 				{				
       
   876 				RBuf fileName;
       
   877 				TDriveName aSystemDrive;
       
   878 				TDriveUnit driveunit(RFs::GetSystemDrive());
       
   879 				aSystemDrive.Zero();
       
   880 				aSystemDrive=driveunit.Name();				
       
   881 				fileName.CreateL ( descriptionPath.Length () );
       
   882 				fileName.Zero();
       
   883 				fileName.Append(aSystemDrive);
       
   884 				fileName.Append ( descriptionPath.Mid ( aSystemDrive.Length () ) );				
       
   885 				
       
   886 				err = file.Open(fs, fileName, EFileShareReadersOnly);
       
   887 				}
       
   888 			}
       
   889 		else 
       
   890 			{
       
   891 			err = file.Open(fs, description, EFileShareReadersOnly);
       
   892 			
       
   893 			// For Hardware system path is c:, so description value present in '.ini' is referring 'c:'
       
   894 			if ( err == KErrPathNotFound )
       
   895 				{
       
   896 				RBuf fileName;
       
   897 				TDriveName aSystemDrive;
       
   898 				TDriveUnit driveunit(RFs::GetSystemDrive());
       
   899 				aSystemDrive.Zero();
       
   900 				aSystemDrive=driveunit.Name();
       
   901 				fileName.CreateL ( description.Length () );
       
   902 				fileName.Zero();
       
   903 				fileName.Append(aSystemDrive);
       
   904 				fileName.Append ( description.Mid ( aSystemDrive.Length () ) );				
       
   905 				
       
   906 				err = file.Open(fs, fileName, EFileShareReadersOnly);
       
   907 				}
       
   908 			}
       
   909 
       
   910 		if (err != KErrNone)
       
   911 			{
       
   912 			User::LeaveIfError(err);
       
   913 			}
       
   914 		CleanupClosePushL(file);
       
   915 		TInt fileSize = 0;
       
   916 		file.Size(fileSize);
       
   917 		buf.Create(fileSize);
       
   918 		err = file.Read(buf, fileSize);
       
   919 		aServiceRegisterParamSet.SetServiceDescriptionL ( buf );
       
   920 		_LIT(KServiceDescription, "ServiceDescription is.... %S \n");
       
   921 		INFO_PRINTF2(KServiceDescription, &buf);
       
   922 		CleanupStack::PopAndDestroy(2);
       
   923 		buf.Close();
       
   924 		}
       
   925 	_LIT(KInfoLogFile1, "ExtractServiceDescriptionL() End.... \n");
       
   926 	INFO_PRINTF1(KInfoLogFile1);
       
   927 	}
       
   928 
       
   929 void CTestUPnPManager::ResolveScpdUrisL(TInt aIndex)
       
   930 	{
       
   931 	_LIT(KInfoLogFile, "ResolveScpdUrisL .... \n");
       
   932 	INFO_PRINTF1(KInfoLogFile);
       
   933 	if ( aIndex < 0 )
       
   934 		{
       
   935 		_LIT(KBadIndex, "BadIndex...ResolveScpdUrisL Cannot be executed \n");
       
   936 		ERR_PRINTF1(KBadIndex);
       
   937 		return;
       
   938 		}
       
   939 	const TInt KSlashLenghth = 1;
       
   940 	TUriParser8 uri;
       
   941 	uri.Parse(iDescriptionSuiteArray[aIndex].iBaseUrl);
       
   942 	TBuf8<KMaxUriSize> buf;
       
   943 	buf.Copy(uri.Extract(EUriScheme));
       
   944 
       
   945 	buf.Append(KColonSlashSlash);
       
   946 	buf.Append(uri.Extract(EUriHost));
       
   947 
       
   948 	buf.Append(KColon);
       
   949 	buf.Append(uri.Extract(EUriPort));
       
   950 
       
   951 	TInt count = iDescriptionSuiteArray[aIndex].iServiceUrls.Count();
       
   952 	for (TInt scpdIndex(0); scpdIndex < count; scpdIndex++ )
       
   953 		{
       
   954 		RBuf8 scpdUri;
       
   955 		scpdUri.Create(buf.Length() + KSlashLenghth + iDescriptionSuiteArray[aIndex].iServiceUrls[scpdIndex].scpdUrl.Length());
       
   956 		scpdUri.Copy(buf);
       
   957 		 if (iDescriptionSuiteArray[aIndex].iServiceUrls[scpdIndex].scpdUrl.Find(KSlash)!=0)
       
   958 			 {
       
   959 			 scpdUri.Append(KSlash);
       
   960 			 }
       
   961 		 scpdUri.Append(iDescriptionSuiteArray[aIndex].iServiceUrls[scpdIndex].scpdUrl);
       
   962 		 AppendScpdUriL(scpdUri);
       
   963 		}
       
   964 	_LIT(KInfoLogFile1, "ResolveScpdUrisL End .... \n");
       
   965 	INFO_PRINTF1(KInfoLogFile1);
       
   966 	}
       
   967 
       
   968 void CTestUPnPManager::ResolveEventUrisL(TInt aIndex)
       
   969 	{
       
   970 	_LIT(KInfoLogFile, "ResolveEventUrisL.... \n");
       
   971 	INFO_PRINTF1(KInfoLogFile);
       
   972 	if ( aIndex < 0 )
       
   973 		{
       
   974 		_LIT(KBadIndex, "BadIndex...ResolveEventUrisL Cannot be executed \n");
       
   975 		ERR_PRINTF1(KBadIndex);
       
   976 		return;
       
   977 		}
       
   978 	const TInt KSlashLenghth = 1;
       
   979 	TUriParser8 uri;
       
   980 	uri.Parse(iDescriptionSuiteArray[aIndex].iBaseUrl);
       
   981 	TBuf8<KMaxUriSize> buf;
       
   982 	buf.Copy(uri.Extract(EUriScheme));
       
   983 
       
   984 	buf.Append(KColonSlashSlash);
       
   985 	buf.Append(uri.Extract(EUriHost));
       
   986 
       
   987 	buf.Append(KColon);
       
   988 	buf.Append(uri.Extract(EUriPort));
       
   989 
       
   990 	TInt count = iDescriptionSuiteArray[aIndex].iServiceUrls.Count();
       
   991 	for (TInt eventIndex(0); eventIndex < count; eventIndex++ )
       
   992 		{
       
   993 		RBuf8 eventUri;
       
   994 		eventUri.Create(buf.Length() + KSlashLenghth + iDescriptionSuiteArray[aIndex].iServiceUrls[eventIndex].eventSubUrl.Length());
       
   995 		eventUri.Copy(buf);
       
   996 		 if (iDescriptionSuiteArray[aIndex].iServiceUrls[eventIndex].eventSubUrl.Find(KSlash)!=0)
       
   997 			 {
       
   998 			 eventUri.Append(KSlash);
       
   999 			 }
       
  1000 		 eventUri.Append(iDescriptionSuiteArray[aIndex].iServiceUrls[eventIndex].eventSubUrl);
       
  1001 		 AppendEventUriL(eventUri);
       
  1002 		}
       
  1003 	_LIT(KInfoLogFile1, "ResolveEventUrisL End.... \n"); 
       
  1004 	INFO_PRINTF1(KInfoLogFile1);
       
  1005 		
       
  1006 	}
       
  1007 
       
  1008 void CTestUPnPManager::ResolveControlUrisL(TInt aIndex)
       
  1009 	{
       
  1010 	_LIT(KInfoLogFile, "ResolveControlUrisL().... \n");
       
  1011 	INFO_PRINTF1(KInfoLogFile);
       
  1012 	if ( aIndex < 0 )
       
  1013 		{
       
  1014 		_LIT(KBadIndex, "BadIndex...ResolveControlUrisL Cannot be executed \n");
       
  1015 		ERR_PRINTF1(KBadIndex);
       
  1016 		return;
       
  1017 		}
       
  1018 	const TInt KSlashLenghth = 1;
       
  1019 	TUriParser8 uri;
       
  1020 	uri.Parse(iDescriptionSuiteArray[aIndex].iBaseUrl);
       
  1021 	TBuf8<KMaxUriSize> buf;
       
  1022 	buf.Copy(uri.Extract(EUriScheme));
       
  1023 
       
  1024 	buf.Append(KColonSlashSlash);
       
  1025 	buf.Append(uri.Extract(EUriHost));
       
  1026 
       
  1027 	buf.Append(KColon);
       
  1028 	buf.Append(uri.Extract(EUriPort));
       
  1029 
       
  1030 	TInt count = iDescriptionSuiteArray[aIndex].iServiceUrls.Count();
       
  1031 	for (TInt ControlIndex(0); ControlIndex < count; ControlIndex++ )
       
  1032 		{
       
  1033 		RBuf8 controlUri;
       
  1034 		controlUri.Create(buf.Length() + KSlashLenghth + iDescriptionSuiteArray[aIndex].iServiceUrls[ControlIndex].controlUrl.Length());
       
  1035 		controlUri.Copy(buf);
       
  1036 		 if (iDescriptionSuiteArray[aIndex].iServiceUrls[ControlIndex].controlUrl.Find(KSlash)!=0)
       
  1037 			 {
       
  1038 			 controlUri.Append(KSlash);
       
  1039 			 }
       
  1040 		 controlUri.Append(iDescriptionSuiteArray[aIndex].iServiceUrls[ControlIndex].controlUrl);
       
  1041 		 AppendControlUriL(controlUri);
       
  1042 		}
       
  1043 	_LIT(KInfoLogFile1, "ResolveControlUrisL() End.... \n");
       
  1044 	INFO_PRINTF1(KInfoLogFile1);
       
  1045 	}
       
  1046 
       
  1047 void CTestUPnPManager::ResolveIconUrlL ( TInt aBaseDescIdx, const TDesC8& aUrl )
       
  1048 	{
       
  1049 	_LIT(KInfoLogFile, "ResolveIconUrlL.... \n");
       
  1050 	INFO_PRINTF1(KInfoLogFile);
       
  1051 	
       
  1052 	const TInt KSlashLength = 1;
       
  1053 	TUriParser8 uri;
       
  1054 	uri.Parse(iDescriptionSuiteArray[aBaseDescIdx].iBaseUrl);
       
  1055 	TBuf8<KMaxUriSize> buf;
       
  1056 	buf.Copy(uri.Extract(EUriScheme));
       
  1057 	
       
  1058 	buf.Append(KColonSlashSlash);
       
  1059 	buf.Append(uri.Extract(EUriHost));
       
  1060 	
       
  1061 	buf.Append(KColon);
       
  1062 	buf.Append(uri.Extract(EUriPort));	
       
  1063 	
       
  1064 	RBuf8 iconUri;
       
  1065 	if ( aUrl[0] == TChar('/') )
       
  1066 		{
       
  1067 		iconUri.Create(buf.Length() + aUrl.Length());
       
  1068 		iconUri.Copy(buf);
       
  1069 		iconUri.Append (aUrl);
       
  1070 		}
       
  1071 	else
       
  1072 		{
       
  1073 		iconUri.Create(buf.Length() + KSlashLength + aUrl.Length());
       
  1074 		iconUri.Copy(buf);
       
  1075 		iconUri.Append(KSlash);
       
  1076 		iconUri.Append (aUrl);
       
  1077 		}
       
  1078 	
       
  1079 	iIconUriArray.Append (iconUri);
       
  1080 	
       
  1081 	_LIT(KInfoLogFile1, "ResolveIconUrlL End.... \n");
       
  1082 	INFO_PRINTF1(KInfoLogFile1);
       
  1083 	}
       
  1084 
       
  1085 /*
       
  1086 	Opens a handle to a RPnPServiceDiscovery object
       
  1087 	@param			None.
       
  1088 	@return			None.
       
  1089  */
       
  1090 void CTestUPnPManager::OpenDiscovererL()
       
  1091 	{
       
  1092 	_LIT(KInfoLogFile, "OpenDiscovererL().... \n");
       
  1093 	INFO_PRINTF1(KInfoLogFile);
       
  1094 	
       
  1095 	TBool cpStatus = EFalse;
       
  1096 	TInt openStatus = 0;
       
  1097 	_LIT(KCpStatus, "cpstatus");
       
  1098 	GetBoolFromConfig(GetCurrentSection(), KCpStatus, cpStatus);
       
  1099 	if(!cpStatus)
       
  1100 		{
       
  1101 		_LIT(KInfoDiscoverer, "Control Point should not be Created \n");
       
  1102 		INFO_PRINTF1(KInfoDiscoverer);
       
  1103 		return;
       
  1104 		}
       
  1105 	for(TInt i=0;i<3;i++)	
       
  1106 		{
       
  1107 		openStatus = iControlPoint.Open(KTierId);
       
  1108 		if(openStatus == KErrNone)
       
  1109 			{
       
  1110 			break;
       
  1111 			}
       
  1112 		}
       
  1113 	if(openStatus != KErrNone) 
       
  1114 		{
       
  1115 		_LIT(KOpenDiscovererFailed, "Control Point discovery open failed with error %d ");
       
  1116 		ERR_PRINTF2(KOpenDiscovererFailed, openStatus);
       
  1117 		SetTestStepError(openStatus);
       
  1118 		//SetTestStepResult(EFail); 
       
  1119 		}
       
  1120 	else
       
  1121 		{
       
  1122 		_LIT(KOpenDiscovererSuccess, "Control Point Discovery was successfully started with return value %d :");
       
  1123 		INFO_PRINTF2(KOpenDiscovererSuccess, openStatus);
       
  1124 		}
       
  1125 	}
       
  1126 
       
  1127 /*
       
  1128 	Opens a handle to a RPnPServicePublisher object and append the same to Publisher array
       
  1129 	@param			None.
       
  1130 	@return			TBool representing success or failure of the operation.
       
  1131  */
       
  1132 TInt CTestUPnPManager::OpenPublisherL()
       
  1133 	{
       
  1134 	_LIT(KInfoLogFile, "OpenPublisherL().... \n");
       
  1135 	INFO_PRINTF1(KInfoLogFile);
       
  1136 	
       
  1137   	RPnPServicePublisher publisher;
       
  1138 	TInt openStatus = 0;
       
  1139 	for(TInt i=0;i<3;i++)	
       
  1140 		{
       
  1141 		openStatus = publisher.Open(KTierId);
       
  1142 		if(openStatus == KErrNone)
       
  1143 			{
       
  1144 			break;
       
  1145 			}
       
  1146 		}
       
  1147   	if( openStatus != KErrNone )
       
  1148   		{
       
  1149  		_LIT(KOpenDiscovererFailed, "Publisher open failed with error %d ");
       
  1150  		ERR_PRINTF2(KOpenDiscovererFailed, openStatus);
       
  1151  		//SetTestStepResult(EFail);
       
  1152  		}
       
  1153  	else
       
  1154  		{
       
  1155  		_LIT(KOpenPublisherSuccess, "Service publisher was successfully started with return value %d :");
       
  1156   		INFO_PRINTF2(KOpenPublisherSuccess, openStatus);
       
  1157  		}
       
  1158 	iPublisherArray.Append(publisher);
       
  1159 	TInt index = iPublisherArray.Count() - 1;
       
  1160 	return index;
       
  1161 	}
       
  1162 	
       
  1163 /*
       
  1164 	Opens a handle to a RPnPServicePublisher object and append the same to Publisher array
       
  1165 	@param			None.
       
  1166 	@return			TBool representing success or failure of the operation.
       
  1167  */
       
  1168 void CTestUPnPManager::OpenMultiplePublisherL()
       
  1169 	{
       
  1170 	_LIT(KInfoLogFile, "MultipleOpenPublisherL().... \n");
       
  1171 	INFO_PRINTF1(KInfoLogFile);
       
  1172 	
       
  1173   	static RPnPServicePublisher publisher;
       
  1174 	TInt openStatus = 0;
       
  1175 	for(TInt i=0;i<3;i++)	
       
  1176 		{
       
  1177 		openStatus = publisher.Open(KTierId);
       
  1178 		if(openStatus == KErrNone)
       
  1179 			{
       
  1180 			break;
       
  1181 			}
       
  1182 		}
       
  1183   	if( openStatus != KErrNone )
       
  1184   		{
       
  1185  		_LIT(KOpenDiscovererFailed, "Publisher open failed with error %d ");
       
  1186  		ERR_PRINTF2(KOpenDiscovererFailed, openStatus);
       
  1187  		SetTestStepError(openStatus);
       
  1188  		//SetTestStepResult(EFail); 
       
  1189  		}
       
  1190  	else
       
  1191  		{
       
  1192  		_LIT(KOpenPublisherSuccess, "Service publisher was successfully started with return value %d :");
       
  1193   		INFO_PRINTF2(KOpenPublisherSuccess, openStatus);
       
  1194  		}
       
  1195 	}
       
  1196 
       
  1197 
       
  1198 
       
  1199 /*
       
  1200 	Publishing of device as per UPnP specifications.
       
  1201 	@param			aOperationType is reference to a section name in ini file where required parameters
       
  1202 					needs to be referred for this operation.
       
  1203 	@return			None.
       
  1204  */
       
  1205 
       
  1206 void CTestUPnPManager::PublishDeviceL (const TDesC& aOperationType)
       
  1207 	{
       
  1208 	_LIT(KInfoLogFile, "PublishDeviceL().... \n");
       
  1209 	INFO_PRINTF1(KInfoLogFile);
       
  1210 	
       
  1211 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  1212 	iObserverArray.Append(upnpObserver);
       
  1213 
       
  1214 	//To keep track of mapping between Observer and Publisher
       
  1215 	TInt observerIndex = iObserverArray.Count() - 1;
       
  1216 
       
  1217 	RPnPParameterBundle pnpBundle;
       
  1218 	pnpBundle.Open();	
       
  1219 	
       
  1220     CleanupClosePushL( pnpBundle );
       
  1221 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  1222 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL(EUPnPDeviceRegisterParamSet);
       
  1223 	CUPnPDeviceRegisterParamSet* registerDeviceParamSet = CUPnPDeviceRegisterParamSet::NewL(pnpFamily );
       
  1224    	TPtrC parentdeviceuid;
       
  1225 	GetStringFromConfig(aOperationType, KParentDeviceUid, parentdeviceuid);
       
  1226 	RBuf8 parentdeviceuidBuf;
       
  1227 	parentdeviceuidBuf.Create(parentdeviceuid.Length());
       
  1228 	parentdeviceuidBuf.Copy(parentdeviceuid);
       
  1229 
       
  1230 	TPtrC devicetype;
       
  1231 	GetStringFromConfig(aOperationType, KDeviceType, devicetype);
       
  1232 	RBuf8 devicetypeBuf;
       
  1233 	devicetypeBuf.Create(devicetype.Length());
       
  1234 	devicetypeBuf.Copy(devicetype);
       
  1235 
       
  1236 	TPtrC friendlyname;
       
  1237 	GetStringFromConfig(aOperationType, KFriendlyName, friendlyname);
       
  1238 	RBuf8 friendlynameBuf;
       
  1239 	friendlynameBuf.Create(friendlyname.Length());
       
  1240 	friendlynameBuf.Copy(friendlyname);
       
  1241 
       
  1242 	TPtrC manufacturer;
       
  1243 	GetStringFromConfig(aOperationType, KManufacturer, manufacturer);
       
  1244 	RBuf8 manufacturerBuf;
       
  1245 	manufacturerBuf.Create(manufacturer.Length());
       
  1246 	manufacturerBuf.Copy(manufacturer);
       
  1247 
       
  1248 	TPtrC manufacturerurl;
       
  1249 	GetStringFromConfig(aOperationType, KManufacturerURL, manufacturerurl);
       
  1250 	RBuf8 manufacturerurlBuf;
       
  1251 	manufacturerurlBuf.Create(manufacturerurl.Length());
       
  1252 	manufacturerurlBuf.Copy(manufacturerurl);
       
  1253 
       
  1254 	TPtrC modeldescription;
       
  1255 	GetStringFromConfig(aOperationType, KModelDescription, modeldescription);
       
  1256 	RBuf8 modeldescriptionBuf;
       
  1257 	modeldescriptionBuf.Create(modeldescription.Length());
       
  1258 	modeldescriptionBuf.Copy(modeldescription);
       
  1259 
       
  1260 	TPtrC modelname;
       
  1261 	GetStringFromConfig(aOperationType, KModelName, modelname);
       
  1262 	RBuf8 modelnameBuf;
       
  1263 	modelnameBuf.Create(modelname.Length());
       
  1264 	modelnameBuf.Copy(modelname);
       
  1265 
       
  1266 	TPtrC modelnumber;
       
  1267 	GetStringFromConfig(aOperationType, KModelNumber, modelnumber);
       
  1268 	RBuf8 modelnumberBuf;
       
  1269 	modelnumberBuf.Create(modelnumber.Length());
       
  1270 	modelnumberBuf.Copy(modelnumber);
       
  1271 
       
  1272 
       
  1273 	TPtrC modelurl;
       
  1274 	GetStringFromConfig(aOperationType, KModelURL, modelurl);
       
  1275 	RBuf8 modelurlBuf;
       
  1276 	modelurlBuf.Create(modelurl.Length());
       
  1277 	modelurlBuf.Copy(modelurl);
       
  1278 
       
  1279 	TPtrC presentationurl;
       
  1280 	GetStringFromConfig(aOperationType, KPresentationURL, presentationurl);
       
  1281 	RBuf8 presentationurlBuf;
       
  1282 	presentationurlBuf.Create(presentationurl.Length());
       
  1283 	presentationurlBuf.Copy(presentationurl);
       
  1284 
       
  1285 	TPtrC serialnumber;
       
  1286 	GetStringFromConfig(aOperationType, KSerialNumber, serialnumber);
       
  1287 	RBuf8 serialnumberBuf;
       
  1288 	serialnumberBuf.Create(serialnumber.Length());
       
  1289 	serialnumberBuf.Copy(serialnumber);
       
  1290 
       
  1291 	TPtrC udn;
       
  1292 	GetStringFromConfig(aOperationType, KUDN, udn);
       
  1293 	RBuf8 udnBuf;
       
  1294 	udnBuf.Create(udn.Length());
       
  1295 	udnBuf.Copy(udn);
       
  1296 
       
  1297 	TPtrC upc;
       
  1298 	GetStringFromConfig(aOperationType, KUPC, upc);
       
  1299 	RBuf8 upcBuf;
       
  1300 	upcBuf.Create(upc.Length());
       
  1301 	upcBuf.Copy(upc);
       
  1302 
       
  1303 	TInt duration;
       
  1304 	GetIntFromConfig(aOperationType, KCacheControl, duration);
       
  1305 
       
  1306 	TPtrC iconRefer;	
       
  1307 	if ( GetStringFromConfig(aOperationType, KIconRefer, iconRefer) )
       
  1308 		{
       
  1309 		
       
  1310 		//iconRead:
       
  1311 		do
       
  1312 			{
       
  1313 			TPtrC mimeType;
       
  1314 			GetStringFromConfig(iconRefer, KMimeType, mimeType);
       
  1315 			RBuf8 typeBuf;
       
  1316 			typeBuf.Create(mimeType.Length());
       
  1317 			typeBuf.Copy(mimeType);
       
  1318 			
       
  1319 			TPtrC url;
       
  1320 			GetStringFromConfig(iconRefer, KUrl, url);
       
  1321 			RBuf8 urlBuf;
       
  1322 			urlBuf.Create(url.Length());
       
  1323 			urlBuf.Copy(url);
       
  1324 			
       
  1325 			TInt width;
       
  1326 			GetIntFromConfig(iconRefer, KWidth, width);
       
  1327 			
       
  1328 			TInt height;
       
  1329 			GetIntFromConfig(iconRefer, KHeight, height);
       
  1330 			
       
  1331 			TInt depth;
       
  1332 			GetIntFromConfig(iconRefer, KDepth, depth);
       
  1333 			
       
  1334 			CUPnPIconParams* icon = CUPnPIconParams::NewL ();
       
  1335 			icon->SetMimeTypeL (typeBuf);
       
  1336 			icon->SetUrlL (urlBuf);
       
  1337 			icon->SetWidth (width);
       
  1338 			icon->SetHeight (height);
       
  1339 			icon->SetDepth (depth);
       
  1340 			
       
  1341 			registerDeviceParamSet->SetIconInfoL (icon);
       
  1342 			typeBuf.Close ();
       
  1343 			urlBuf.Close ();
       
  1344 			}while ( GetStringFromConfig(iconRefer, KIconRefer, iconRefer) );
       
  1345 /*			
       
  1346 		if ( GetStringFromConfig(iconRefer, KIconRefer, iconRefer) )
       
  1347 			{
       
  1348 			goto iconRead;
       
  1349 			}*/
       
  1350 		}
       
  1351 
       
  1352 	registerDeviceParamSet-> SetParentDeviceUidL(parentdeviceuidBuf);
       
  1353 	registerDeviceParamSet-> SetUriL (devicetypeBuf);
       
  1354 	registerDeviceParamSet-> SetFriendlyNameL (friendlynameBuf);
       
  1355 	registerDeviceParamSet-> SetManufacturerL (manufacturerBuf );
       
  1356 	registerDeviceParamSet-> SetManufactureUrlL (manufacturerurlBuf);
       
  1357 	registerDeviceParamSet-> SetModelDescL (modeldescriptionBuf);
       
  1358 	registerDeviceParamSet-> SetModelNameL (modelnameBuf);
       
  1359 	registerDeviceParamSet-> SetModelNumberL (modelnumberBuf);
       
  1360 	registerDeviceParamSet-> SetModelUriL (modelurlBuf);
       
  1361 	registerDeviceParamSet-> SetPresentationL (presentationurlBuf);
       
  1362 	registerDeviceParamSet-> SetSerialNumberL (serialnumberBuf);
       
  1363 	registerDeviceParamSet-> SetUDNL (udnBuf);
       
  1364 	registerDeviceParamSet-> SetUPCL (upcBuf);
       
  1365 	registerDeviceParamSet-> SetCacheControlData (duration);
       
  1366 
       
  1367 	//To keep track of mapping between Observer and Publisher
       
  1368 	TInt publisherIndex = OpenPublisherL();
       
  1369 	//Create mapping of Publsiher and observer
       
  1370 	TPublisherObserverMap publisherObserverMapElement;
       
  1371 	publisherObserverMapElement.iPublisherIndex = publisherIndex;
       
  1372 	publisherObserverMapElement.iObserverIndex =  observerIndex;
       
  1373 	publisherObserverMapElement.iPublisherControl = KDevice;
       
  1374 	iPublisherObserverMap.Append(publisherObserverMapElement);
       
  1375 
       
  1376 	//Publish Device and update publish count
       
  1377 	iPublishCount++;
       
  1378 	iPublisherArray[publisherIndex].Publish( pnpBundle );
       
  1379 
       
  1380 	TBool SchedulerStart = EFalse;
       
  1381 	_LIT(KSchedulerStart, "schedulerstart");
       
  1382 	GetBoolFromConfig(aOperationType, KSchedulerStart, SchedulerStart);
       
  1383 	if(SchedulerStart)
       
  1384 		{
       
  1385 		CActiveScheduler::Start();
       
  1386 		}
       
  1387 
       
  1388 	upcBuf.Close();
       
  1389 	udnBuf.Close();
       
  1390 	serialnumberBuf.Close();
       
  1391 	presentationurlBuf.Close();
       
  1392 	modelurlBuf.Close();
       
  1393 	modelnumberBuf.Close();
       
  1394 	modelnameBuf.Close();
       
  1395 	manufacturerurlBuf.Close();
       
  1396 	manufacturerBuf.Close();
       
  1397 	friendlynameBuf.Close();
       
  1398 	devicetypeBuf.Close();
       
  1399 	parentdeviceuidBuf.Close();
       
  1400 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  1401 	_LIT(KInfoLogFile1, "PublishDeviceL End.... \n");
       
  1402 	INFO_PRINTF1(KInfoLogFile1);
       
  1403 	}
       
  1404 
       
  1405 /*
       
  1406 Test for Register announcements ssdp:alive and ssdp:byebye messages
       
  1407 	@param			aOperationType is reference to a section name in ini file where required parameters
       
  1408 					needs to be referred for this operation.
       
  1409 	@return			None.
       
  1410 */
       
  1411 void  CTestUPnPManager::RegisterForAnnouncementsL (const TDesC& aOperationType)
       
  1412 	{
       
  1413 	_LIT(KInfoLogFile, "RegisterForAnnouncementsL().... \n");
       
  1414 	INFO_PRINTF1(KInfoLogFile);
       
  1415 	RArray<TPtrC> uriTypeList;
       
  1416 	TPtrC listOfUriTypes;
       
  1417 	_LIT(KListOfUriTypes, "listofuritypes");
       
  1418 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  1419 	iObserverArray.Append(upnpObserver);
       
  1420 	
       
  1421 	RPnPParameterBundle pnpBundle;
       
  1422 	pnpBundle.CreateL ();
       
  1423 	CleanupClosePushL( pnpBundle );
       
  1424 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  1425 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPRegisterAnnouncementParamSet);
       
  1426 	
       
  1427 	if(!GetStringFromConfig(GetCurrentSection(), KListOfUriTypes, listOfUriTypes))
       
  1428 		{
       
  1429 		_LIT(KErrInfo, "Problem in reading values from ini. \n Expected fields are: %S \n");
       
  1430 		ERR_PRINTF2( KErrInfo, &KListOfUriTypes);
       
  1431 		return;
       
  1432 		}
       
  1433 
       
  1434 	TokenizeStringL(listOfUriTypes, uriTypeList);
       
  1435 	TInt numUris = uriTypeList.Count();
       
  1436 	RBuf8 buf;
       
  1437 	buf.Create(KMaxUriSize);
       
  1438 	for(TInt i(0); i < numUris; i++)
       
  1439 		{
       
  1440 		CUPnPRegisterAnnouncementParamSet* announcementParamSet = CUPnPRegisterAnnouncementParamSet::NewL( pnpFamily ); 
       
  1441 		buf.Copy(uriTypeList[i]);
       
  1442 		announcementParamSet->SetUriL( buf ); 
       
  1443 		}
       
  1444 	buf.Close();
       
  1445 	uriTypeList.Close();
       
  1446 	iControlPoint.RegisterNotify( pnpBundle );
       
  1447 	TBool schedulerStart = EFalse;
       
  1448 	_LIT(KSchedulerStart, "schedulerstart");
       
  1449 	GetBoolFromConfig(aOperationType, KSchedulerStart, schedulerStart);
       
  1450 	if(schedulerStart)
       
  1451 		{
       
  1452 		CActiveScheduler::Start();
       
  1453 		}
       
  1454 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  1455 	_LIT(KInfoLogFile1, "RegisterForAnnouncementsL() End.... \n");
       
  1456 	INFO_PRINTF1(KInfoLogFile1);
       
  1457 	
       
  1458 	
       
  1459 	}
       
  1460 
       
  1461 /*
       
  1462 	Tests whether subscribtion to event change notifications is performing as specified in UPnP specifications.
       
  1463 	@param			None.
       
  1464 	@return			None.
       
  1465  */
       
  1466 void  CTestUPnPManager::SubscribeForStateChangeNotificationsL()
       
  1467 	{
       
  1468 	_LIT(KInfoLogFile, "SubscribeForStateChangeNotificationsL() start.... \n");
       
  1469 	INFO_PRINTF1(KInfoLogFile);
       
  1470 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  1471 	CleanupStack::PushL( upnpObserver );
       
  1472 	RPnPParameterBundle pnpBundle;
       
  1473 	pnpBundle.CreateL ();
       
  1474 	CleanupClosePushL( pnpBundle );
       
  1475 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  1476 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPSubscribeRequestParamSet);
       
  1477 	
       
  1478 	TInt subscriptionDuration;
       
  1479     _LIT(KSubscriptionDuration, "subscriptionduration");
       
  1480 	GetIntFromConfig(GetCurrentSection(), KSubscriptionDuration, subscriptionDuration);
       
  1481 	TBool readIni = EFalse;
       
  1482 	GetBoolFromConfig(GetCurrentSection(), KReadIni, readIni);
       
  1483 	if(readIni)
       
  1484 		{
       
  1485 		CUPnPSubscribeRequestParamSet * subscribeParamSet = CUPnPSubscribeRequestParamSet::NewL (pnpFamily ); 
       
  1486 		TPtrC subscriptionUri;
       
  1487 		GetStringFromConfig(GetCurrentSection(), KSubscriptionUri, subscriptionUri);
       
  1488 		RBuf8 subscriptionUriBuf;
       
  1489 		subscriptionUriBuf.Create(subscriptionUri.Length());
       
  1490 		subscriptionUriBuf.Copy(subscriptionUri);
       
  1491 		subscribeParamSet->SetDuration(subscriptionDuration);	
       
  1492 		subscribeParamSet->SetUriL(subscriptionUriBuf);	
       
  1493 		subscriptionUriBuf.Close();
       
  1494 		}
       
  1495 	else
       
  1496 		{
       
  1497 		//Multiple uri's can be submitted for description
       
  1498 		ResolveAllUrisL();
       
  1499 		TInt eventUriCount = iEventUriArray.Count();
       
  1500 		if ( eventUriCount==0 )
       
  1501 			{
       
  1502 			_LIT(KEventSubscription,"Event Subscription Cannot be performed \n");
       
  1503 			INFO_PRINTF1(KEventSubscription);
       
  1504 			CleanupStack::PopAndDestroy( &pnpBundle );
       
  1505 			CleanupStack::PopAndDestroy( upnpObserver );
       
  1506 			//SetTestStepResult(EFail);
       
  1507 			return;
       
  1508 			}
       
  1509 		for(TInt index(0); index < eventUriCount ; index++)
       
  1510 			{
       
  1511 			//for (TInt j(0); j < 10 ; j++)
       
  1512 			//{//Pass Duplicate subscritption reuqest multiple times in single bundle
       
  1513 				CUPnPSubscribeRequestParamSet * subscribeParamSet = CUPnPSubscribeRequestParamSet::NewL (pnpFamily ); 
       
  1514 				subscribeParamSet->SetUriL(iEventUriArray[index]);	
       
  1515 				subscribeParamSet->SetDuration(subscriptionDuration);	
       
  1516 				RBuf eventUri16;
       
  1517 				eventUri16.Create(iEventUriArray[index].Length());
       
  1518 				eventUri16.Copy(iEventUriArray[index]);
       
  1519 				_LIT(KEventSubUriInfo,"Event Uri Submitted for Subscription Request is: %S \n");
       
  1520 				INFO_PRINTF2(KEventSubUriInfo, &eventUri16);
       
  1521 				eventUri16.Close();
       
  1522 			//	}
       
  1523 			}
       
  1524 		}
       
  1525 	iControlPoint.Subscribe( pnpBundle );
       
  1526 	TBool schedulerStart = EFalse;
       
  1527 	_LIT(KSchedulerStart, "schedulerstart");
       
  1528 	GetBoolFromConfig(GetCurrentSection(), KSchedulerStart, schedulerStart);
       
  1529 	if(schedulerStart)
       
  1530 		{
       
  1531 		CActiveScheduler::Start();
       
  1532 		}
       
  1533 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  1534 	CleanupStack::PopAndDestroy( upnpObserver );
       
  1535 	_LIT(KInfoLogFile1, "SubscribeForStateChangeNotificationsL() End.... \n");
       
  1536 	INFO_PRINTF1(KInfoLogFile1);
       
  1537 	}
       
  1538 
       
  1539 void  CTestUPnPManager::ReSubscribeForStateChangeNotificationsL()
       
  1540 	{
       
  1541 	_LIT(KInfoLogFile, "Re-SubscribeForStateChangeNotificationsL() start.... \n");
       
  1542 	INFO_PRINTF1(KInfoLogFile);
       
  1543 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  1544 	CleanupStack::PushL( upnpObserver );
       
  1545 	RPnPParameterBundle pnpBundle;
       
  1546 	pnpBundle.CreateL ();
       
  1547 	CleanupClosePushL( pnpBundle );
       
  1548 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  1549 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPSubscribeRequestParamSet	);
       
  1550 	TInt subscriptionDuration;
       
  1551     _LIT(KSubscriptionDuration, "subscriptionduration");
       
  1552 	GetIntFromConfig(GetCurrentSection(), KSubscriptionDuration, subscriptionDuration);
       
  1553 	
       
  1554 	TInt eventUriCount = iEventUriArray.Count();
       
  1555 	if ( eventUriCount==0 )
       
  1556 		{
       
  1557 		_LIT(KEventSubscription,"Event Subscription Cannot be performed \n");
       
  1558 		INFO_PRINTF1(KEventSubscription);
       
  1559 		CleanupStack::PopAndDestroy( &pnpBundle );
       
  1560 		CleanupStack::PopAndDestroy( upnpObserver );
       
  1561 		//SetTestStepResult(EFail);
       
  1562 		return;
       
  1563 		}
       
  1564 	for(TInt index(0); index < eventUriCount ; index++)
       
  1565 		{
       
  1566 		CUPnPSubscribeRequestParamSet * subscribeParamSet = CUPnPSubscribeRequestParamSet::NewL (pnpFamily );
       
  1567 		subscribeParamSet->SetUriL(iEventUriArray[index]);
       
  1568 		subscribeParamSet->SetDuration(20); 	
       
  1569 		RBuf eventUri16;
       
  1570 		eventUri16.Create(iEventUriArray[index].Length());
       
  1571 		eventUri16.Copy(iEventUriArray[index]);
       
  1572 		_LIT(KEventSubUriInfo,"Event Uri Submitted for Re-Subscription  is: %S \n");
       
  1573 		INFO_PRINTF2(KEventSubUriInfo, &eventUri16);
       
  1574 		eventUri16.Close();
       
  1575 		}
       
  1576 	iControlPoint.Subscribe( pnpBundle );
       
  1577 	CActiveScheduler::Start();
       
  1578 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  1579 	CleanupStack::PopAndDestroy( upnpObserver );
       
  1580 	_LIT(KInfoLogFile1, "Re-SubscribeForStateChangeNotificationsL() End.... \n");
       
  1581 	INFO_PRINTF1(KInfoLogFile1);
       
  1582 	}
       
  1583 /*
       
  1584 	Tests whether unsubscribtion to subscribed events is performing as specified in UPnP specifications.
       
  1585 	@param			None
       
  1586 	@return			None.
       
  1587  */
       
  1588 void  CTestUPnPManager::UnsubscribeForStateChangeNotificationsL(const TDesC& aOperationType)
       
  1589 	{
       
  1590 	_LIT(KInfoLogFile, "UnsubscribeForStateChangeNotificationsL().... \n");
       
  1591 	INFO_PRINTF1(KInfoLogFile);
       
  1592 	
       
  1593 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  1594 	iObserverArray.Append(upnpObserver);
       
  1595 	
       
  1596 	RPnPParameterBundle pnpBundle;
       
  1597 	pnpBundle.CreateL ();
       
  1598 	CleanupClosePushL( pnpBundle );
       
  1599 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  1600 
       
  1601 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPCancelSubscribeParamSet);
       
  1602 	
       
  1603 	TBool readIni = EFalse;
       
  1604 	GetBoolFromConfig(aOperationType, KReadIni, readIni);
       
  1605 	if(readIni)
       
  1606 		{
       
  1607 	CUPnPCancelSubscribeParamSet * unsubscribeParamSet = CUPnPCancelSubscribeParamSet::NewL(pnpFamily); 
       
  1608 	TPtrC unsubscribepath;
       
  1609 	_LIT(KUnsubscribePath, "unsubscribepath");
       
  1610 		GetStringFromConfig(aOperationType, KUnsubscribePath, unsubscribepath);
       
  1611 	RBuf8 unsubscribepathBuf;
       
  1612 	unsubscribepathBuf.Create(unsubscribepath.Length());
       
  1613 	unsubscribepathBuf.Copy(unsubscribepath);
       
  1614 	unsubscribeParamSet->SetUriL(unsubscribepathBuf);
       
  1615 	_LIT(KCanCelSubscribeInfo,"Executing Cancel Subscribe for URI:  %S \n");
       
  1616 	INFO_PRINTF2(KCanCelSubscribeInfo, &unsubscribepath);
       
  1617 	
       
  1618 	iControlPoint.Cancel( pnpBundle );
       
  1619 	unsubscribepathBuf.Close();
       
  1620 	}
       
  1621 	else
       
  1622 	{
       
  1623 		TInt eventUriCount = iEventUriArray.Count();
       
  1624 		if ( eventUriCount==0 )
       
  1625 			{
       
  1626 			_LIT(KEventUnSubscription,"Event UnSubscription Cannot be performed \n");
       
  1627 			INFO_PRINTF1(KEventUnSubscription);
       
  1628 			CleanupStack::PopAndDestroy( &pnpBundle );
       
  1629 			return;
       
  1630 			}
       
  1631 		for(TInt index(0); index < eventUriCount ; index++)//eventUriCount
       
  1632 			{
       
  1633 			CUPnPCancelSubscribeParamSet * unsubscribeParamSet = CUPnPCancelSubscribeParamSet::NewL(pnpFamily); 
       
  1634 			unsubscribeParamSet ->SetUriL(iEventUriArray[index]); 
       
  1635 			RBuf eventUri16;
       
  1636 			eventUri16.Create(iEventUriArray[index].Length());
       
  1637 			eventUri16.Copy(iEventUriArray[index]);
       
  1638 			_LIT(KEventSubUriInfo,"Event Uri Submitted for UnSubscription Request is: %S \n");
       
  1639 			INFO_PRINTF2(KEventSubUriInfo, &eventUri16);
       
  1640 			eventUri16.Close();
       
  1641 			}iControlPoint.Cancel( pnpBundle );
       
  1642 	
       
  1643 			}
       
  1644 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  1645 	_LIT(KInfoLogFile1, "UnsubscribeForStateChangeNotificationsL() End.... \n");
       
  1646 	INFO_PRINTF1(KInfoLogFile1);
       
  1647 	}
       
  1648 
       
  1649 /*
       
  1650 	Test for Intiatting a Control Action from Control Point side
       
  1651 	@param			aOperationType is reference to a section name in ini file where required parameters
       
  1652 					needs to be referred for this operation.
       
  1653 	@return			None.
       
  1654  */
       
  1655 void CTestUPnPManager::InitiateActionL(const TDesC& /* aOperationType */)
       
  1656 	{
       
  1657 	_LIT(KInfoLogFile, "InitiateActionL().... \n");
       
  1658 	INFO_PRINTF1(KInfoLogFile);
       
  1659 	ResolveAllUrisL();
       
  1660 	if(!iAction)
       
  1661 		{
       
  1662 		iAction= CAction::NewL(this);
       
  1663 		}
       
  1664 	for(TInt i(0); i < iControlUriArray.Count(); i++)
       
  1665 		{
       
  1666 		RBuf controlUri16;
       
  1667 		controlUri16.Create(iControlUriArray[i].Length());
       
  1668 		controlUri16.Copy(iControlUriArray[i]);
       
  1669 		_LIT(KContolUri, "<font color=00ff00><b><u>Control Uri Submitted is: %S </b></u></font>");
       
  1670 		INFO_PRINTF2(KContolUri, &controlUri16);
       
  1671 		iAction->InitiateActionControlL(iControlUriArray[i],iControlPoint);
       
  1672 		controlUri16.Close();		
       
  1673 		}
       
  1674 	_LIT(KInfoLogFile1, "InitiateActionL() End.... \n");
       
  1675 	INFO_PRINTF1(KInfoLogFile1);
       
  1676 	}
       
  1677 
       
  1678 /*
       
  1679 	Test for Cancelling Discovery Operation
       
  1680 	@param			aOperationType is reference to a section name in ini file where required parameters
       
  1681 					needs to be referred for this operation.
       
  1682 	@return			None.
       
  1683  */
       
  1684 void CTestUPnPManager::CancelDiscoverL(const TDesC& aOperationType)
       
  1685 	{
       
  1686 	iCancelDiscovery = ETrue;
       
  1687 	const TInt KBufLength = 1000;
       
  1688 	_LIT(KInfoLogFile, "CancelDiscoverL().... \n");
       
  1689 	INFO_PRINTF1(KInfoLogFile);
       
  1690 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  1691 	iObserverArray.Append(upnpObserver);	
       
  1692 	
       
  1693 	RPnPParameterBundle pnpBundle;
       
  1694 	pnpBundle.CreateL ();
       
  1695 	CleanupClosePushL( pnpBundle );
       
  1696 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  1697 
       
  1698 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPCancelDiscoverParamSet);
       
  1699 	
       
  1700 	CUPnPCancelDiscoverParamSet* cancelDiscoverParamSet = CUPnPCancelDiscoverParamSet::NewL(pnpFamily ); 
       
  1701 	TPtrC serviceType;
       
  1702 	GetStringFromConfig(aOperationType, KServiceType, serviceType);
       
  1703 	_LIT(KCanCelDiscoveryInfo,"Executing Cancel Discovery for URI:  %S \n");
       
  1704 	INFO_PRINTF2(KCanCelDiscoveryInfo, &serviceType);
       
  1705 	RBuf8 buf;
       
  1706 	buf.Create(KBufLength);
       
  1707 	buf.Copy(serviceType);
       
  1708 	cancelDiscoverParamSet->SetUriL( buf ); 
       
  1709 	iControlPoint.Cancel ( pnpBundle );
       
  1710 	buf.Close();
       
  1711 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  1712 	
       
  1713 	TBool flag=ETrue;
       
  1714 	_LIT(KStopScheduler,"stopscheduler");
       
  1715 	GetBoolFromConfig(aOperationType,KStopScheduler,flag);
       
  1716 	if(flag)		
       
  1717 		{
       
  1718 		CActiveScheduler::Stop();	
       
  1719 		}
       
  1720 	_LIT(KInfoLogFile1, "CancelDiscoverL() End.... \n");
       
  1721 	INFO_PRINTF1(KInfoLogFile1);
       
  1722 	}
       
  1723 
       
  1724 void CTestUPnPManager::CancelDescribeL(const TDesC& aOperationType)
       
  1725 	{
       
  1726 	//Modify this later
       
  1727 	const TInt KBufLength = 1000;
       
  1728 	_LIT(KInfoLogFile, "CancelDescribeL().... \n");
       
  1729 	INFO_PRINTF1(KInfoLogFile);
       
  1730 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  1731 	iObserverArray.Append(upnpObserver);	
       
  1732 	
       
  1733 	RPnPParameterBundle pnpBundle;
       
  1734 	pnpBundle.CreateL ();
       
  1735 	CleanupClosePushL( pnpBundle );
       
  1736 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  1737 
       
  1738 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPCancelDescribeParamSet);
       
  1739 	
       
  1740 	CUPnPCancelDescribeParamSet* cancelDescribeParamSet = CUPnPCancelDescribeParamSet::NewL( pnpFamily ); 
       
  1741 	TPtrC serviceType;
       
  1742 	GetStringFromConfig(aOperationType, KServiceType, serviceType);
       
  1743 	_LIT(KCanCelDiscoveryInfo,"Executing Cancel Describe for URI:  %S \n");
       
  1744 	INFO_PRINTF2(KCanCelDiscoveryInfo, &serviceType);
       
  1745 	RBuf8 buf;
       
  1746 	buf.Create(KBufLength);
       
  1747 	buf.Copy(serviceType);
       
  1748 	cancelDescribeParamSet->SetUriL( buf ); 
       
  1749 	iControlPoint.Cancel ( pnpBundle );
       
  1750 	buf.Close();
       
  1751 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  1752 	_LIT(KInfoLogFile1, "CancelDescribeL() End.... \n");
       
  1753 	INFO_PRINTF1(KInfoLogFile1);
       
  1754 	}
       
  1755 
       
  1756 /*
       
  1757  Cancells all persistent Device Description Requests.
       
  1758 */
       
  1759 void CTestUPnPManager::CancelAllDeviceDescribeL()
       
  1760 	{
       
  1761 	_LIT(KInfoLogFile, "CancelAllDeviceDescribeL().... \n");
       
  1762 	INFO_PRINTF1(KInfoLogFile);
       
  1763 	
       
  1764 	//this perofrms only Cancellation of all Device descriptions only
       
  1765 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  1766 	iObserverArray.Append(upnpObserver);
       
  1767 		
       
  1768 	RPnPParameterBundle pnpBundle;
       
  1769 	pnpBundle.CreateL ();
       
  1770 	CleanupClosePushL( pnpBundle );
       
  1771 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  1772 
       
  1773 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPCancelDescribeParamSet);
       
  1774 	TInt DevLocCount = iDeviceLocationArray.Count();
       
  1775 	for(TInt index(0); index < DevLocCount  ; index++)
       
  1776 		{
       
  1777 		TBuf8<256> url;
       
  1778 		TUriParser8 uri;
       
  1779 		uri.Parse(iDeviceLocationArray[index]);
       
  1780 		url.Copy(_L8("http://"));
       
  1781 		const TDesC8& scheme = uri.Extract(EUriScheme);
       
  1782 		_LIT8(KScheme, "http");
       
  1783 		//Uri must be of scheme "http" only
       
  1784 		if (scheme.CompareF(KScheme) == 0)
       
  1785 			{
       
  1786 			const TDesC8& host = uri.Extract(EUriHost);
       
  1787 			url.Append(host);
       
  1788 			url.Append(_L8(":"));
       
  1789 			const TDesC8& portStr = uri.Extract ( EUriPort );
       
  1790 			url.Append(portStr);
       
  1791 			url.Append(_L8("/")) ;
       
  1792 			CUPnPCancelDescribeParamSet* cancelDescribeParamSet = CUPnPCancelDescribeParamSet::NewL(pnpFamily ); 
       
  1793 			cancelDescribeParamSet->SetUriL(url); 
       
  1794 			RBuf uri16;
       
  1795 			uri16.Create(url.Length());
       
  1796 			uri16.Copy(url);
       
  1797 			_LIT(KCanCelDescribeInfo,"Executing Cancel Describe for URI:  %S \n");
       
  1798 			INFO_PRINTF2(KCanCelDescribeInfo, &uri16);
       
  1799 			uri16.Close();
       
  1800 			}
       
  1801 		}
       
  1802 	iControlPoint.Cancel ( pnpBundle );
       
  1803 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  1804 	CActiveScheduler::Stop();
       
  1805 	_LIT(KInfoLogFile1, "CancelAllDeviceDescribeL() End.... \n");
       
  1806 	INFO_PRINTF1(KInfoLogFile1);
       
  1807 	
       
  1808 	}
       
  1809 
       
  1810 /*
       
  1811  * this perofrms only Cancellation of all Service descriptions only
       
  1812 */
       
  1813 void CTestUPnPManager::CancelAllServiceDescribeL()
       
  1814 	{
       
  1815 	_LIT(KInfoLogFile, "CancelAllServiceDescribeL().... \n");
       
  1816 	INFO_PRINTF1(KInfoLogFile);
       
  1817 	
       
  1818 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  1819 	iObserverArray.Append(upnpObserver);
       
  1820 	RPnPParameterBundle pnpBundle;
       
  1821 	pnpBundle.CreateL ();
       
  1822 	CleanupClosePushL( pnpBundle );
       
  1823 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  1824 
       
  1825 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPCancelDescribeParamSet);
       
  1826 	TInt scpdCount = iScpdUriArray.Count();
       
  1827 	for(TInt index(0); index < scpdCount  ; index++)
       
  1828 		{
       
  1829 		RBuf uri16;
       
  1830 		uri16.Create(iScpdUriArray[index].Length());
       
  1831 		uri16.Copy(iScpdUriArray[index]);
       
  1832 		_LIT(KCanCelDescribeServiceInfo,"Executing Cancel DescribeService for URI:  %S \n");
       
  1833 		INFO_PRINTF2(KCanCelDescribeServiceInfo, &uri16);
       
  1834 		uri16.Close();
       
  1835 		CUPnPCancelDescribeParamSet* cancelDescribeParamSet = CUPnPCancelDescribeParamSet::NewL(pnpFamily ); 
       
  1836 		cancelDescribeParamSet->SetUriL(iScpdUriArray[index]);
       
  1837 		}
       
  1838 	iControlPoint.Cancel ( pnpBundle );
       
  1839 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  1840 	CActiveScheduler::Stop();
       
  1841 	_LIT(KInfoLogFile1, "CancelAllServiceDescribeL() End.... \n");
       
  1842 	INFO_PRINTF1(KInfoLogFile1);
       
  1843 	
       
  1844 	}
       
  1845 
       
  1846 /*
       
  1847 	Test for Cancelling Register Announcement
       
  1848 	@param			aOperationType is reference to a section name in ini file where required parameters
       
  1849 					needs to be referred for this operation.
       
  1850 	@return			None.
       
  1851  */
       
  1852 void  CTestUPnPManager::CancelNotifyAnnouncementL(const TDesC& aOperationType)
       
  1853 	{
       
  1854 	_LIT(KInfoLogFile, "CancelNotifyAnnouncementL().... \n");
       
  1855 	INFO_PRINTF1(KInfoLogFile);
       
  1856 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  1857 	iObserverArray.Append(upnpObserver);
       
  1858 		
       
  1859 	RPnPParameterBundle pnpBundle;
       
  1860 	pnpBundle.CreateL ();
       
  1861 	CleanupClosePushL( pnpBundle );
       
  1862 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  1863 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL ( EUPnPCancelRegisterNotifyParamSet );
       
  1864 	
       
  1865 	CUPnPCancelRegisterNotifyParamSet * cancelNotifyParamSet = CUPnPCancelRegisterNotifyParamSet::NewL(pnpFamily);
       
  1866 	TPtrC uri;
       
  1867 	GetStringFromConfig(aOperationType, KUri, uri);
       
  1868 	RBuf8 buf;
       
  1869 	buf.Create(uri.Length());
       
  1870 	buf.Copy(uri);
       
  1871 	cancelNotifyParamSet->SetUriL(buf);
       
  1872 	iControlPoint.Cancel ( pnpBundle);
       
  1873 	buf.Close();
       
  1874 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  1875 	_LIT(KInfoLogFile1, "CancelNotifyAnnouncementL() End.... \n");
       
  1876 	INFO_PRINTF1(KInfoLogFile1);
       
  1877 	}
       
  1878 
       
  1879 void CTestUPnPManager::AppendBundlesL(RPnPParameterBundleBase& aPnPBundle)
       
  1880 	{
       
  1881 	iResultsArray.AppendL(aPnPBundle);
       
  1882 	}
       
  1883 
       
  1884 /*
       
  1885    Validates the discovery response received from the callback against the expected discovery response.
       
  1886    @param	aIndex is an integer refers to an index in the ResultsArray of CResults object.
       
  1887    @param	aResultsList is an array for section names for expected results section.
       
  1888    @param	aExpctedResults is an array of Bools and each of the element indicates whether the expected results
       
  1889    			in each section are matched against actual results.
       
  1890    @return	None
       
  1891  */
       
  1892 
       
  1893 void CTestUPnPManager::PrintAndValidateResultsL(const TDesC& aOperationType)
       
  1894 	{
       
  1895 	_LIT(KInfoLogFile, "PrintAndValidateResultsL().... \n");
       
  1896 	INFO_PRINTF1(KInfoLogFile);
       
  1897 	TInt resultsCount = 0;
       
  1898 	const TInt bundleCount = iResultsArray.Count();
       
  1899 	_LIT(KPrintStatement, "printing results \n");
       
  1900 	_LIT(KPrintDesign,"	\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n");
       
  1901 	INFO_PRINTF1(KPrintStatement);
       
  1902 	INFO_PRINTF1(KPrintDesign);
       
  1903 	for(TInt i(0); i < bundleCount; i++)
       
  1904 		{
       
  1905 		RParameterFamily paramFamily =  iResultsArray[i].GetFamilyAtIndex(0);	
       
  1906 		if( !paramFamily.IsNull() )
       
  1907 			{
       
  1908 			switch ( paramFamily.Id() )
       
  1909 				{
       
  1910 				case EUPnPDiscoverResponseParamSet:
       
  1911 					{
       
  1912 					PrintDiscoveryResultsL(paramFamily);
       
  1913 					ValidateDiscoveryResultsL(aOperationType);
       
  1914 					}
       
  1915 				break;
       
  1916 
       
  1917 				case EUPnPPresenceAnnouncementParamSet:
       
  1918 					{					
       
  1919 					CUPnPPresenceAnnouncementParamSet* paramSet  = NULL;
       
  1920 					TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;					
       
  1921 					for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  1922 					{
       
  1923 						paramSet = static_cast<CUPnPPresenceAnnouncementParamSet*>( paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ));
       
  1924 						
       
  1925 						//Paramset at current position						
       
  1926 						if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  1927 							{
       
  1928 							TInt error = paramSet->UPnPEvent().iErrorCode;
       
  1929 							_LIT(KRegisterAliveFailed,"Failed to Send Register Alive Notifications with...Error Code  = %d \n");
       
  1930 							ERR_PRINTF2(KRegisterAliveFailed, error);
       
  1931 							//SetTestStepResult(EFail); 							
       
  1932 							continue;
       
  1933 							}
       
  1934 						TPtrC8 serviceLocation(paramSet->ServiceLocation());
       
  1935 						HBufC* devloc = HBufC::NewLC(serviceLocation.Length());	//1
       
  1936 						devloc->Des().Copy(serviceLocation);
       
  1937 						TPtrC devLocPointer (devloc->Des());
       
  1938 						_LIT(KInfoUri,"The URI found is %S \n");
       
  1939 						INFO_PRINTF2(KInfoUri, &devLocPointer);
       
  1940 
       
  1941 						TInt availabilityDuration = 0;
       
  1942 						availabilityDuration = paramSet->Duration();
       
  1943 						_LIT(KInfoDuration,"The service availability duration is %d \n");
       
  1944 						INFO_PRINTF2(KInfoDuration, &availabilityDuration);
       
  1945 
       
  1946 						_LIT(KInfoAlive,"ssdp:alive notification got from %S AND Duration is %d\n");
       
  1947 						INFO_PRINTF3(KInfoAlive, &devLocPointer, &availabilityDuration);
       
  1948 
       
  1949 						TPtrC8 usn(paramSet->USN());
       
  1950 						HBufC* usnVal = HBufC::NewLC(usn.Length());	//2
       
  1951 						usnVal->Des().Copy(usn);
       
  1952 						TPtrC usnValPointer (usnVal->Des());
       
  1953 						_LIT(KInfoUSN,"The USN found is %S \n");
       
  1954 						INFO_PRINTF2(KInfoUSN, &usnValPointer);
       
  1955 
       
  1956 						TPtrC8 uri(paramSet->Uri());
       
  1957 						HBufC* uriVal = HBufC::NewLC(uri.Length());	//3
       
  1958 						uriVal->Des().Copy(uri);
       
  1959 						TPtrC uriValPointer (uriVal->Des());
       
  1960 						_LIT(KInfoURI,"The Uri found is %S \n");
       
  1961 						INFO_PRINTF2(KInfoURI, &uriValPointer);
       
  1962 						resultsCount++;
       
  1963 						CleanupStack::PopAndDestroy(uriVal);
       
  1964 						CleanupStack::PopAndDestroy(usnVal);
       
  1965 						CleanupStack::PopAndDestroy(devloc);						
       
  1966 						}
       
  1967 					}
       
  1968 				break;
       
  1969 				case EUPnPDescribeResponseParamSet:
       
  1970 					{					
       
  1971 					CUPnPDescribeResponseParamSet* paramSet  = NULL;
       
  1972 					TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;					
       
  1973 					for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  1974 					{
       
  1975 						paramSet = static_cast<CUPnPDescribeResponseParamSet*>( paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ));
       
  1976 						if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  1977 							{
       
  1978 							TInt error = paramSet->UPnPEvent().iErrorCode;
       
  1979 							_LIT(KDescribeFailed,"Failed to Describe with...Error Code  = %d \n");
       
  1980 							ERR_PRINTF2(KDescribeFailed, error);
       
  1981 							//SetTestStepResult(EFail); 
       
  1982 							return;
       
  1983 							}
       
  1984 						TPtrC8 description(paramSet->Description());
       
  1985 						HBufC* descriptionValue = HBufC::NewLC(description.Length());
       
  1986 						descriptionValue->Des().Copy(description);
       
  1987 						TPtrC descriptionPointer (descriptionValue->Des());
       
  1988 						_LIT(KInfoDescribe,"content is  %S \n");
       
  1989 						INFO_PRINTF2(KInfoDescribe, &descriptionPointer);
       
  1990 						CleanupStack::PopAndDestroy(descriptionValue);					
       
  1991 						resultsCount++;
       
  1992 						}
       
  1993 					//Reached Eof the Bundles
       
  1994 					}
       
  1995 				break;
       
  1996 				case EUPnPAbsenceAnnouncementParamSet:
       
  1997 					{					
       
  1998 					CUPnPAbsenceAnnouncementParamSet* paramSet  = NULL;
       
  1999 					TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;					
       
  2000 					for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2001 					{
       
  2002 						paramSet = static_cast<CUPnPAbsenceAnnouncementParamSet*> (paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ));
       
  2003 						//Paramset at current position					
       
  2004 						if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2005 							{
       
  2006 							TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2007 							_LIT(KRegisterByeByeFailed,"Failed to Send Register ByeBye Notifications with...Error Code  = %d \n");
       
  2008 							ERR_PRINTF2(KRegisterByeByeFailed, error);
       
  2009 							//SetTestStepResult(EFail); 							
       
  2010 							continue;
       
  2011 							}
       
  2012 						TPtrC8 usn(paramSet->USN());
       
  2013 						HBufC* usnVal = HBufC::NewLC(usn.Length());
       
  2014 						usnVal->Des().Copy(usn);
       
  2015 						TPtrC usnValPointer (usnVal->Des());
       
  2016 
       
  2017 						_LIT(KInfoBye,"ssdp:byebye notification received from %S \n");
       
  2018 						INFO_PRINTF2(KInfoBye, &usnValPointer);
       
  2019 						resultsCount++;
       
  2020 						CleanupStack::PopAndDestroy(usnVal);						
       
  2021 						}
       
  2022 					}
       
  2023 				break;
       
  2024 				case EUPnPSubscribeResponseParamSet:
       
  2025 					{
       
  2026 					
       
  2027 					CUPnPSubscribeResponseParamSet* paramSet  = NULL;
       
  2028 					TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;					
       
  2029 					for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2030 					{
       
  2031 					paramSet = static_cast<CUPnPSubscribeResponseParamSet*> (paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ));
       
  2032 						RBuf subscriptionUri16;
       
  2033 						subscriptionUri16.Create(paramSet->Uri().Length());
       
  2034 						subscriptionUri16.Copy(paramSet->Uri());
       
  2035 						if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2036 							{
       
  2037 							_LIT(KInfoSubscribeFailed, "Err: Failed to Subscribe.\n %S \n");
       
  2038 							INFO_PRINTF2(KInfoSubscribeFailed,&subscriptionUri16);
       
  2039 							TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2040 							_LIT(KErrSubscribe,"Failed to Subscribe with...Error Code  = %d \n");
       
  2041 							ERR_PRINTF2(KErrSubscribe, error);
       
  2042 							//SetTestStepResult(EFail); 
       
  2043 							}
       
  2044 						else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESubscriptionTimeout)
       
  2045 							{
       
  2046 							_LIT(KInfoSubscribeTimedOut, "Info: SubscribeTimed out \n %S \n");
       
  2047 							INFO_PRINTF2(KInfoSubscribeTimedOut,&subscriptionUri16);
       
  2048 							}
       
  2049 						else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess)
       
  2050 							{
       
  2051 							_LIT(KInfoSubscribeSuccess, "<font color=00ff00><b><u>Info: Subscribtion SUCCESS</u></b></font>\n %S \n");
       
  2052 							INFO_PRINTF2(KInfoSubscribeSuccess,&subscriptionUri16);
       
  2053 							}
       
  2054 						subscriptionUri16.Close();				
       
  2055 						}
       
  2056 					}
       
  2057 				break;
       
  2058 				case EUPnPNotifyEventParamSet:
       
  2059 					{//receives event notifications sent at client
       
  2060 					
       
  2061 					CUPnPNotifyEventParamSet* paramSet  = NULL;
       
  2062 					TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;					
       
  2063 					for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2064 					{
       
  2065 					paramSet = static_cast<CUPnPNotifyEventParamSet*> (paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ));
       
  2066 						RBuf subscriptionUri16;
       
  2067 						subscriptionUri16.Create(paramSet->Uri().Length());
       
  2068 						subscriptionUri16.Copy(paramSet->Uri());
       
  2069 						if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2070 							{
       
  2071 							_LIT(KInfoNotificationsFailed, "Err: Failed to Get Event notifications \n %S \n");
       
  2072 							INFO_PRINTF2(KInfoNotificationsFailed,&subscriptionUri16);
       
  2073 							TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2074 							_LIT(KNotificationsFailed,"Failed to Receive Notifications with...Error Code  = %d \n");
       
  2075 							ERR_PRINTF2(KNotificationsFailed, error);
       
  2076 							//SetTestStepResult(EFail); 
       
  2077 							}
       
  2078 						else if (paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess)
       
  2079 							{
       
  2080 							_LIT(KInfoNotifications, "Notifications for subscribed Uri: %S \t is received \n");
       
  2081 							INFO_PRINTF2(KInfoNotifications, &subscriptionUri16);
       
  2082 							}
       
  2083 						subscriptionUri16.Close();
       
  2084 						}
       
  2085 					}
       
  2086 				break;
       
  2087 				default:
       
  2088 					{
       
  2089 					//Do Nothing
       
  2090 					}
       
  2091 				break;
       
  2092 				}
       
  2093 			}
       
  2094 		}
       
  2095 	_LIT(KEndPrintStatement,"Done with printing results \n");
       
  2096 	INFO_PRINTF1(KEndPrintStatement);
       
  2097 	INFO_PRINTF1(KPrintDesign);
       
  2098 	}
       
  2099 
       
  2100 /*
       
  2101   Constructor:
       
  2102 */
       
  2103 CUPnPObserver::CUPnPObserver()
       
  2104 	:iSequence(0),iResultsCount(0)
       
  2105 	{
       
  2106 	}
       
  2107 
       
  2108 /*
       
  2109   Destructor
       
  2110 */
       
  2111 CUPnPObserver::~CUPnPObserver()
       
  2112 	{
       
  2113 	iFileServ.Close();
       
  2114 	}
       
  2115 
       
  2116 
       
  2117 /*
       
  2118 	Static factory constructor. Uses two phase construction and leaves nothing on the
       
  2119 	CleanupStack. Creates a CTestControlPointService object.
       
  2120 	@param			aManager	A pointer to a CTestUPnPManager object.
       
  2121 	@return			A pointer to the newly created CPnPObserver object.
       
  2122 	@post			A fully constructed and initialized CPnPObserver object.
       
  2123  */
       
  2124 CUPnPObserver* CUPnPObserver::NewL(CTestUPnPManager* aManager)
       
  2125 	{
       
  2126 	CUPnPObserver* self = new(ELeave) CUPnPObserver;
       
  2127 	CleanupStack::PushL(self);
       
  2128 	self->ConstructL(aManager);
       
  2129 	CleanupStack::Pop(self);
       
  2130 	return self;
       
  2131 	}
       
  2132 
       
  2133 /*
       
  2134 	Second phase of two-phase construction method. Does any allocations required to fully construct
       
  2135 	the object.
       
  2136 	@pre 		First phase of construction is complete.
       
  2137 	@param		aManager	A pointer to a CTestUPnPManager object.
       
  2138 	@post		The object is fully constructed and initialized.
       
  2139  */
       
  2140 void CUPnPObserver::ConstructL(CTestUPnPManager* aManager)
       
  2141 	{
       
  2142 	iManager = aManager;
       
  2143 	User::LeaveIfError(iFileServ.Connect());
       
  2144 	}
       
  2145 
       
  2146 
       
  2147 
       
  2148 /*
       
  2149    This method returns a reference to the CTestUPnPManager object.
       
  2150    @param None
       
  2151    return a reference to the CTestUPnPManager object
       
  2152  */
       
  2153 CTestUPnPManager& CUPnPObserver::Manager()
       
  2154 	{
       
  2155 	return *iManager;
       
  2156 	}
       
  2157 
       
  2158 /*
       
  2159    This is called when callback hits. And this method stores the bundle results
       
  2160    and meta information related to that results into results array maintained by manager
       
  2161    for later verification.
       
  2162    @param  aParameterBundle a reference to CPnPParameterBundleBase
       
  2163    @return None
       
  2164  */
       
  2165 void CUPnPObserver::OnPnPEventL ( RPnPParameterBundleBase& aParameterBundle)
       
  2166 	{
       
  2167 	_LIT(KInfoLogFile, "OnPnPEventL ().... \n");
       
  2168 	Manager().INFO_PRINTF1(KInfoLogFile);
       
  2169 	
       
  2170 	CopyResultBundlesL(aParameterBundle);
       
  2171 	RParameterFamily paramFamily = aParameterBundle.GetFamilyAtIndex(0);
       
  2172 	TRAPD ( err, paramFamily.CheckOpenL () );
       
  2173 
       
  2174 	if( err == KErrNone)
       
  2175 		{
       
  2176 		switch ( paramFamily.Id() )
       
  2177 			{
       
  2178 			case EUPnPDiscoverResponseParamSet:
       
  2179 				{				
       
  2180 				CUPnPDiscoverResponseParamSet* paramSet  = NULL;				
       
  2181 				_LIT(KDiscoverResponse,"Discover Response is: \n");
       
  2182 				Manager().INFO_PRINTF1(KDiscoverResponse);
       
  2183 				TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
       
  2184 				for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2185 				   {
       
  2186 				   paramSet = static_cast<CUPnPDiscoverResponseParamSet*> ( paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ) );
       
  2187 					//Printig of Search target
       
  2188 					TPtrC8 uriST(paramSet->Uri());
       
  2189 					HBufC* stUri = HBufC::NewLC(uriST.Length());
       
  2190 					stUri->Des().Copy(uriST);
       
  2191 					TPtrC uriStPtr (stUri->Des());
       
  2192 					_LIT(KInfoST,"<b>The SerachTarget given was <u>%S</u> </b>\n");
       
  2193 					Manager().INFO_PRINTF2(KInfoST, &uriStPtr);
       
  2194 					CleanupStack::PopAndDestroy(stUri);
       
  2195 					
       
  2196 					if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EDiscoveryTimeout)
       
  2197 						{
       
  2198 						_LIT(KDiscoverTimeOut,"Discover Response TimeOut: TUPnPEvent::EDiscoveryTimeout \n");
       
  2199 						Manager().INFO_PRINTF1(KDiscoverTimeOut);
       
  2200 
       
  2201 						_LIT(KInfoLogFile, "EUPnPDiscoverResponseParamSet TimeOut.... \n");
       
  2202 						Manager().INFO_PRINTF1(KInfoLogFile);
       
  2203 						_LIT(KDuplicateUri, "duplicateuri");
       
  2204 						TBool duplicateUri = EFalse;
       
  2205 						Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KDuplicateUri,duplicateUri );
       
  2206 						
       
  2207 						if(duplicateUri)
       
  2208 						{
       
  2209 						
       
  2210 						CActiveScheduler::Stop();	
       
  2211 						_LIT(KInfoRetry, "Discovery Success with results.... \n");
       
  2212 						Manager().INFO_PRINTF1(KInfoRetry);
       
  2213 						Manager().SetDiscoveryStatus(ETrue);
       
  2214 						return;
       
  2215 						}
       
  2216 						
       
  2217 						//Found valid discovery  responses
       
  2218 						if (Manager().iDeviceLocationArray.Count() > 0)
       
  2219 							{
       
  2220 							CActiveScheduler::Stop();
       
  2221 							_LIT(KInfoRetry, "Discovery Success with results.... \n");
       
  2222 							Manager().INFO_PRINTF1(KInfoRetry);
       
  2223 							Manager().SetDiscoveryStatus(ETrue);
       
  2224 							}
       
  2225 						else if(Manager().IsDiscoverySuccess() && Manager().iFailedNumUris <= 1)
       
  2226 							{
       
  2227 							// Discovery Retry also Failured  
       
  2228 							CActiveScheduler::Stop();
       
  2229 							_LIT(KInfoFail, "Discovery Failed.... \n");
       
  2230 							Manager().ERR_PRINTF1(KInfoFail);
       
  2231 							//Manager().SetTestStepResult(EFail);
       
  2232 							}
       
  2233 						else if(Manager().iFailedNumUris >= 1 )
       
  2234 							{
       
  2235 							//Retrty Discovery only if and only if All Uri's Timedout 
       
  2236 							Manager().iFailedNumUris--;
       
  2237 							TInt failedUriCount = Manager().iFailedNumUris;
       
  2238 							if ( failedUriCount == 0 )
       
  2239 								{
       
  2240 								CActiveScheduler::Stop();
       
  2241 								}
       
  2242 							_LIT(KInfoRetry, "<font color=00ff00><b><u>Waiting responses from  %d Uris</u></b></font> \n");
       
  2243 							Manager().INFO_PRINTF2(KInfoRetry, Manager().iFailedNumUris );
       
  2244 							}
       
  2245 						return;
       
  2246 						}
       
  2247 					else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2248 						{
       
  2249 						TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2250 						_LIT(KDiscoverFail,"Discover Response Fail: TUPnPEvent::EFail Error Code is = %d \n");
       
  2251 						Manager().ERR_PRINTF2(KDiscoverFail, error);
       
  2252 						CActiveScheduler::Stop();
       
  2253 						//To eliminate the repetition of Discovery
       
  2254 						Manager().SetDiscoveryStatus(ETrue);
       
  2255 						_LIT(KInfoLogFile, "EUPnPDiscoverResponseParamSet EFail.... \n");
       
  2256 						Manager().INFO_PRINTF1(KInfoLogFile);
       
  2257 						//Manager().SetTestStepResult(EFail); 
       
  2258 						return;
       
  2259 						}
       
  2260 					else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess)
       
  2261 						{
       
  2262 						//opt for Abrupt close of CP
       
  2263 						TBool abruptDiscoveryCloseCP = EFalse;
       
  2264 						_LIT(KAbruptDiscoveryCloseCP,"abruptdiscoveryclosecp");
       
  2265 						Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KAbruptDiscoveryCloseCP,abruptDiscoveryCloseCP );
       
  2266 						if(abruptDiscoveryCloseCP)
       
  2267 							{
       
  2268 							//Closing Control point Abruptly
       
  2269 							_LIT(KInfoSubScribe, "In Discovery Response \n");
       
  2270 							_LIT(KInfoCloseCP, "Closing Control point Abruptly....\n");
       
  2271 							Manager().INFO_PRINTF1(KInfoSubScribe);
       
  2272 							Manager().INFO_PRINTF1(KInfoCloseCP);
       
  2273 							CActiveScheduler::Stop();
       
  2274 							Manager().CloseDiscoverer();
       
  2275 							return;
       
  2276 							}
       
  2277 						//Printing of Loaction
       
  2278 						TPtrC8 deviceLocation(paramSet->DeviceLocation());
       
  2279 						HBufC* devloc = HBufC::NewLC(deviceLocation.Length()); //1
       
  2280 						devloc->Des().Copy(deviceLocation);
       
  2281 						TPtrC devLocPointer (devloc->Des());
       
  2282 						_LIT(KInfoUri,"The Location: %S \n");
       
  2283 						Manager().INFO_PRINTF2(KInfoUri, &devLocPointer);
       
  2284 						 //Storing Device location to array
       
  2285 						 Manager().AppendDeviceLocationL(deviceLocation);
       
  2286 						TPtrC8 usn(paramSet->USN());
       
  2287 						HBufC* usnVal = HBufC::NewLC(usn.Length()); //2
       
  2288 						usnVal->Des().Copy(usn);
       
  2289 						TPtrC usnValPointer (usnVal->Des());
       
  2290 						_LIT(KInfoUSN,"The USN found is %S \n");
       
  2291 						Manager().INFO_PRINTF2(KInfoUSN, &usnValPointer);
       
  2292 
       
  2293 						TInt expiryTime = paramSet->ExpiryTime();
       
  2294 						_LIT(KInfoexpiryTime,"The Expiry Time is %d \n");
       
  2295 						Manager().INFO_PRINTF2(KInfoexpiryTime, expiryTime);
       
  2296 						CleanupStack::PopAndDestroy(usnVal);
       
  2297 						CleanupStack::PopAndDestroy(devloc);				
       
  2298 
       
  2299 						//Cancel discovery
       
  2300 						TBool cancelDiscovery= EFalse;
       
  2301 						_LIT(KCancelDiscover, "canceldiscover");
       
  2302 						Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KCancelDiscover,cancelDiscovery);
       
  2303 						//Eliminate multiple Cancel Discovery 
       
  2304 						//To not to execute Activescheduler::stop many times
       
  2305 						if (cancelDiscovery && !Manager().iCancelDiscovery)
       
  2306 							{
       
  2307 							TPtrC referSection;
       
  2308 							_LIT(KReferSection,"refersection");
       
  2309 							Manager().GetStringFromConfig(Manager().GetCurrentSection(),KReferSection,referSection );
       
  2310 
       
  2311 							_LIT(KInfoCancelDiscovery,"Cancel Discovery is executed \n");
       
  2312 							Manager().INFO_PRINTF1(KInfoCancelDiscovery);
       
  2313 							Manager().CancelDiscoverL(referSection);
       
  2314 							//To eliminate the repetition of Discovery
       
  2315 							Manager().SetDiscoveryStatus(ETrue);
       
  2316 							}
       
  2317 							_LIT(KInfoLogFile, "EUPnPDiscoverResponseParamSet Success.... \n");
       
  2318 							Manager().INFO_PRINTF1(KInfoLogFile);
       
  2319 						}
       
  2320 					}
       
  2321 				}
       
  2322 			break;
       
  2323 			case EUPnPPresenceAnnouncementParamSet:
       
  2324 				{
       
  2325 				CUPnPPresenceAnnouncementParamSet* paramSet  = NULL;				
       
  2326 				TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
       
  2327 				for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2328 				  {			
       
  2329 				  paramSet = static_cast<CUPnPPresenceAnnouncementParamSet*> ( paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ) );
       
  2330 					//Printig of Search target
       
  2331 					TPtrC8 uriST(paramSet->Uri());
       
  2332 					HBufC* stUri = HBufC::NewLC(uriST.Length());
       
  2333 					stUri->Des().Copy(uriST);
       
  2334 					TPtrC uriStPtr (stUri->Des());
       
  2335 					_LIT(KInfoST,"<b>The RegisterNotify URI was:  <u>%S</u> </b>\n");
       
  2336 					Manager().INFO_PRINTF2(KInfoST, &uriStPtr);
       
  2337 					CleanupStack::PopAndDestroy(stUri);
       
  2338 					
       
  2339 					if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2340 						{
       
  2341 						TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2342 						_LIT(KRegisterNotifyFail,"Resgitser Notify Failed: TUPnPEvent::EFail Error Code is = %d \n");
       
  2343 						Manager().ERR_PRINTF2(KRegisterNotifyFail,error);
       
  2344 						CActiveScheduler::Stop();
       
  2345 						//Manager().SetTestStepResult(EFail); 
       
  2346 						return;
       
  2347 						}
       
  2348 					TPtrC8 serviceLocation(paramSet->ServiceLocation());
       
  2349 					HBufC* servloc = HBufC::NewLC(serviceLocation.Length()); //1
       
  2350 					servloc->Des().Copy(serviceLocation);
       
  2351 					TPtrC servlocPointer (servloc->Des());
       
  2352 					TInt duration = paramSet->Duration();
       
  2353 					_LIT(KInfoAlive,"<font color=1f6633><b>ssdp:alive notification got from %S AND Duration is %d </b></font>\n");
       
  2354 					iManager->INFO_PRINTF3(KInfoAlive, &servlocPointer, &duration);
       
  2355 					CleanupStack::PopAndDestroy(servloc);					
       
  2356 					iResultsCount++;
       
  2357 					}
       
  2358 				_LIT(KInfoLogFile, "EUPnPPresenceAnnouncementParamSet.... \n");
       
  2359 				Manager().INFO_PRINTF1(KInfoLogFile);
       
  2360 				}
       
  2361 			break;
       
  2362 
       
  2363 			case EUPnPAbsenceAnnouncementParamSet:
       
  2364 				{				
       
  2365 				CUPnPAbsenceAnnouncementParamSet* paramSet  = NULL;				
       
  2366 				TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
       
  2367 					
       
  2368 				for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2369 				   {		
       
  2370 				   paramSet = static_cast<CUPnPAbsenceAnnouncementParamSet*> ( paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ) );
       
  2371 					//Printig of Search target
       
  2372 					TPtrC8 uriST(paramSet->Uri());
       
  2373 					HBufC* stUri = HBufC::NewLC(uriST.Length());
       
  2374 					stUri->Des().Copy(uriST);
       
  2375 					TPtrC uriStPtr (stUri->Des());
       
  2376 					_LIT(KInfoST,"<b>The RegisterNotify URI was:  <u>%S</u> </b>\n");
       
  2377 					Manager().INFO_PRINTF2(KInfoST, &uriStPtr);
       
  2378 					CleanupStack::PopAndDestroy(stUri);
       
  2379 					if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2380 						{
       
  2381 						TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2382 						_LIT(KRegisterNotifyByeByeFail,"Resgitser Notify ByeBye Failed: TUPnPEvent::EFail Error Code is = %d \n");
       
  2383 						Manager().ERR_PRINTF2(KRegisterNotifyByeByeFail, error);
       
  2384 						CActiveScheduler::Stop();
       
  2385 						//Manager().SetTestStepResult(EFail); 
       
  2386 						return;
       
  2387 						}
       
  2388 					TPtrC8 usn(paramSet->USN());
       
  2389 					HBufC* usnvalue = HBufC::NewLC(usn.Length());	//1
       
  2390 					usnvalue->Des().Copy(usn);
       
  2391 					TPtrC usnPointer (usnvalue->Des());
       
  2392 					_LIT(KInfoBye,"<font color=33121f><b>ssdp:byebye notification received from %S </b></font>\n");
       
  2393 					iManager->INFO_PRINTF2(KInfoBye, &usnPointer);
       
  2394 					CleanupStack::PopAndDestroy(usnvalue);					
       
  2395 					}
       
  2396 					_LIT(KInfoLogFile, "EUPnPAbsenceAnnouncementParamSet.... \n");
       
  2397 					Manager().INFO_PRINTF1(KInfoLogFile);
       
  2398 				}
       
  2399 			break;
       
  2400 
       
  2401 			case EUPnPPublishResponseParamSet:
       
  2402 				{
       
  2403 				TBool flag=EFalse;
       
  2404 				_LIT(KStopScheduler,"stopscheduler");
       
  2405 				TInt responseCount = 0;
       
  2406 				CUPnPPublishResponseParamSet* paramSet  = NULL;
       
  2407 				Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KStopScheduler,flag);
       
  2408 				_LIT(KExpectedPublishEesponseCount,"expectedpublishresponsecount");
       
  2409 				Manager().GetIntFromConfig(Manager().GetCurrentSection(),KExpectedPublishEesponseCount,responseCount);
       
  2410 				TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
       
  2411 					
       
  2412 				for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2413 				   {
       
  2414 				   paramSet = static_cast<CUPnPPublishResponseParamSet*> ( paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ) );
       
  2415 					Manager().iPublishCount--;
       
  2416 					if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess)
       
  2417 						{
       
  2418 						TBool sendNotify= EFalse;
       
  2419 						TInt notifyCount(0);
       
  2420 						_LIT(KInfoPublish, "Info: Succesfully Published a Device/Service.");
       
  2421 						Manager().INFO_PRINTF1(KInfoPublish);
       
  2422 						_LIT(KSendNotify,"sendnotifications");
       
  2423 						Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KSendNotify,sendNotify);
       
  2424 
       
  2425 						if(sendNotify)
       
  2426 							{
       
  2427 							RBuf16 descriptionBaseUri;
       
  2428 							descriptionBaseUri.Create(paramSet->Uri().Length());
       
  2429 							descriptionBaseUri.Copy(paramSet->Uri());
       
  2430 							_LIT(KInfoSendNotify, "Info: Calling Send Notify on Uri %S \n");
       
  2431 							Manager().INFO_PRINTF2(KInfoSendNotify, &descriptionBaseUri);
       
  2432 							descriptionBaseUri.Close();
       
  2433 							Manager().SendNotificationsL(this);
       
  2434 							}
       
  2435 						_LIT(KExpctedNotifications,"expectednotifications");
       
  2436 						Manager().GetIntFromConfig(Manager().GetCurrentSection(),KExpctedNotifications,notifyCount);
       
  2437 						TInt publishCount = Manager().iPublishCount;
       
  2438 						if(flag && notifyCount == Manager().NotifyCount()&& publishCount <= 0 )
       
  2439 							{
       
  2440 							_LIT(KInfoLogFile, "EUPnPPublishResponseParamSet Success....And Stopping Active Scheduler after %d Publishes \n");
       
  2441 							Manager().INFO_PRINTF2(KInfoLogFile, publishCount );
       
  2442 							CActiveScheduler::Stop();
       
  2443 							}
       
  2444 						}
       
  2445 					else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2446 						{
       
  2447 						TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2448 						_LIT(KErrPublish,"Failed to Published a Device/Service...Error Code is = %d \n");
       
  2449 						Manager().ERR_PRINTF2(KErrPublish, error);
       
  2450 						CActiveScheduler::Stop();
       
  2451 						_LIT(KInfoLogFile, "EUPnPPublishResponseParamSet Fail.... \n");
       
  2452 						Manager().INFO_PRINTF1(KInfoLogFile);
       
  2453 						//Manager().SetTestStepResult(EFail); 
       
  2454 						return;
       
  2455 						}
       
  2456 					}
       
  2457 				}
       
  2458 			break;
       
  2459 
       
  2460 			case EUPnPDescribeResponseParamSet:
       
  2461 				{
       
  2462 				//abruptdescribeclosecp
       
  2463 				//opt for Abrupt close of CP
       
  2464 				TBool abruptDiscribeCloseCP = EFalse;
       
  2465 				_LIT(KAbruptDiscribeCloseCP,"abruptdescribeclosecp");
       
  2466 				Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KAbruptDiscribeCloseCP,abruptDiscribeCloseCP );
       
  2467 				if(abruptDiscribeCloseCP)
       
  2468 					{
       
  2469 					//Closing Control point Abruptly
       
  2470 					_LIT(KInfoSubScribe, "In Describe Response \n");
       
  2471 					_LIT(KInfoCloseCP, "Closing Control point Abruptly.... \n");
       
  2472 					Manager().INFO_PRINTF1(KInfoSubScribe);
       
  2473 					Manager().INFO_PRINTF1(KInfoCloseCP);
       
  2474 					CActiveScheduler::Stop();
       
  2475 					Manager().CloseDiscoverer();
       
  2476 					return;
       
  2477 					}
       
  2478 				
       
  2479 				
       
  2480 				CUPnPDescribeResponseParamSet* paramSet  = NULL;
       
  2481 				TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
       
  2482 					
       
  2483 				for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2484 				   {
       
  2485 					//Only one response expected for Describe and no iter increment is required
       
  2486 					//Paramset at current position			
       
  2487 				   paramSet = static_cast<CUPnPDescribeResponseParamSet*> ( paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ) );
       
  2488 					RBuf8 descriptionBuf;
       
  2489 					RBuf8 descriptionBaseUri;
       
  2490 					descriptionBaseUri.Create(paramSet->Uri());
       
  2491 					descriptionBuf.Create(paramSet->Description());
       
  2492 
       
  2493 					RBuf description16;
       
  2494 					description16.Create(descriptionBuf.Length());
       
  2495 					description16.Copy(descriptionBuf);
       
  2496 
       
  2497 					RBuf descriptionUri16;
       
  2498 					descriptionUri16.Create(descriptionBaseUri.Length());
       
  2499 					descriptionUri16.Copy(descriptionBaseUri);
       
  2500 
       
  2501 					if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2502 						{
       
  2503 						TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2504 						_LIT(KDescribeFail,"Describe Response Fail: TUPnPEvent::EFail...Error Code is = %d \n");
       
  2505 						Manager().ERR_PRINTF2(KDescribeFail, error);
       
  2506 						_LIT(KDescriptionUri,"Description Uri is  %S \n");
       
  2507 						Manager().ERR_PRINTF1(KDescribeFail);
       
  2508 						Manager().INFO_PRINTF2(KDescriptionUri, &descriptionUri16  );
       
  2509 						_LIT(KInfoLogFile, "EUPnPDescribeResponseParamSet Fail.... \n");
       
  2510 						Manager().INFO_PRINTF1(KInfoLogFile);
       
  2511 						CActiveScheduler::Stop();
       
  2512 						descriptionBuf.Close();
       
  2513 						descriptionBaseUri.Close();
       
  2514 						description16.Close();
       
  2515 						descriptionUri16.Close();
       
  2516 						//Manager().SetTestStepResult(EFail);
       
  2517 						return;
       
  2518 						}
       
  2519 					Manager().AppendDescriptionL(descriptionBaseUri, descriptionBuf);
       
  2520 					TFileName filename;
       
  2521 					filename.Format(KDefaultFileFormat, 'C');
       
  2522 					TBuf<KMaxBufLength> filenameBuffer(filename);
       
  2523 					//get scriptName
       
  2524 					filenameBuffer.Append(Manager().ScriptFileName());
       
  2525 					_LIT(KUnderScore, "_");
       
  2526 					filenameBuffer.Append(KUnderScore);
       
  2527 					filenameBuffer.AppendNumFixedWidth(iSequence,EDecimal, 4);
       
  2528 					iSequence++;
       
  2529 					filenameBuffer.Append(KDefaultExtension);
       
  2530 					RFile file;
       
  2531 					TInt err=file.Replace(iFileServ,filenameBuffer,EFileRead|EFileWrite|EFileShareAny);
       
  2532 					if (err == KErrNone)
       
  2533 						{
       
  2534 						TInt writeErr= file.Write(descriptionBuf);
       
  2535 						if(writeErr != KErrNone )
       
  2536 							{
       
  2537 							_LIT(KErrWrite,"Unable to Write the description to the File \n");
       
  2538 							Manager().ERR_PRINTF1(KErrWrite);
       
  2539 							}
       
  2540 						_LIT(KDescriptionUri,"Description Uri is  %S \n");
       
  2541 						_LIT(KInfoDescribe,"content is  %S \n");
       
  2542 						Manager().INFO_PRINTF2(KDescriptionUri, &descriptionUri16  );
       
  2543 						Manager().INFO_PRINTF2(KInfoDescribe, &description16);
       
  2544 						Manager().iDescribeResponseCount++;
       
  2545 						}
       
  2546 					descriptionBuf.Close();
       
  2547 					descriptionBaseUri.Close();
       
  2548 					description16.Close();
       
  2549 					descriptionUri16.Close();
       
  2550 					file.Close();
       
  2551 					iResultsCount++;
       
  2552 					}
       
  2553 				TBool cancelAll = EFalse;
       
  2554 				Manager().GetBoolFromConfig(Manager().GetCurrentSection(), KCancelAll, cancelAll );
       
  2555 				TBool cancelAllService = EFalse;
       
  2556 				Manager().GetBoolFromConfig(Manager().GetCurrentSection(), KCancelAllService, cancelAllService );
       
  2557 				TInt descCount = 1;
       
  2558 				Manager().GetIntFromConfig(Manager().GetCurrentSection(), KExpctedDescriptions, descCount );
       
  2559 
       
  2560 				if(Manager().iDescribeResponseCount >= descCount )// Modify this later
       
  2561 					{
       
  2562 					if(cancelAll)
       
  2563 						{
       
  2564 						Manager().CancelAllDeviceDescribeL();
       
  2565 						return;
       
  2566 						}
       
  2567 					else if(cancelAllService)
       
  2568 						{
       
  2569 						Manager().CancelAllServiceDescribeL();
       
  2570 						return;
       
  2571 					}
       
  2572 					else
       
  2573 					{
       
  2574 					CActiveScheduler::Stop();
       
  2575 					_LIT(KInfoLogFile, "EUPnPDescribeResponseParamSet.... \n");
       
  2576 					Manager().INFO_PRINTF1(KInfoLogFile);
       
  2577 					return;
       
  2578 					}
       
  2579 				}
       
  2580 				}
       
  2581 			break;
       
  2582 			case EUPnPSubscribeResponseParamSet:
       
  2583 				{
       
  2584 				
       
  2585 				CUPnPSubscribeResponseParamSet* paramSet  = NULL;
       
  2586 				TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;					
       
  2587 				for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2588 				   {
       
  2589 				   paramSet = static_cast<CUPnPSubscribeResponseParamSet*> ( paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ) );
       
  2590 					//Paramset at current position					
       
  2591 					RBuf subscriptionUri16;
       
  2592 					subscriptionUri16.Create(paramSet->Uri().Length());
       
  2593 					subscriptionUri16.Copy(paramSet->Uri());
       
  2594 					if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2595 						{
       
  2596 						_LIT(KInfoSubscribeFailed, "Info: Failed to Subscribe.\n %S \n");
       
  2597 						Manager().INFO_PRINTF2(KInfoSubscribeFailed,&subscriptionUri16);
       
  2598 						subscriptionUri16.Close();
       
  2599 						TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2600 						_LIT(KSubscribeFailed,"Failed to Subscribe with...Error Code  = %d \n");
       
  2601 						Manager().ERR_PRINTF2(KSubscribeFailed, error);
       
  2602 						CActiveScheduler::Stop();
       
  2603 						_LIT(KInfoLogFile, "EUPnPSubscribeResponseParamSet Fail.... \n");
       
  2604 						Manager().INFO_PRINTF1(KInfoLogFile);
       
  2605 						//Manager().SetTestStepResult(EFail); 
       
  2606 						return;
       
  2607 						}
       
  2608 					else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESubscriptionTimeout)
       
  2609 						{
       
  2610 						_LIT(KInfoSubscribeTimeOut, "Info: Subscription about to expire\n %S \n");
       
  2611 						Manager().INFO_PRINTF2(KInfoSubscribeTimeOut, &subscriptionUri16);
       
  2612 						subscriptionUri16.Close();
       
  2613 						_LIT(KInfoSubscribeTimeOut3, "subscription uri deleted\n");
       
  2614 						Manager().INFO_PRINTF1(KInfoSubscribeTimeOut3);
       
  2615 						
       
  2616 						//Implementation of Resubscribe is here
       
  2617 						TBool renewFlag = EFalse;
       
  2618 						_LIT(KRenewFlag,"renewflag");
       
  2619 						Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KRenewFlag,renewFlag );
       
  2620 						
       
  2621 						_LIT(KInfoSubscribeTimeOut1, "renew flag value %d renew count   %d  \n");
       
  2622 						Manager().INFO_PRINTF3(KInfoSubscribeTimeOut1, renewFlag,Manager().iRenewCount);
       
  2623 
       
  2624 						RDebug::Print( _L( "checked ini to subscribe or resubscribe" ));
       
  2625 
       
  2626 						if( renewFlag && Manager().iRenewCount == 0)
       
  2627 							{//go to renew here only once
       
  2628 							RDebug::Print( _L( "Go to renew here - Stopping Scheduler" ));
       
  2629 							subscriptionUri16.Close();//cleanup activity
       
  2630 							CActiveScheduler::Stop();//this is for start made in prev subscribe
       
  2631 							_LIT(KInfoLogFile, "EUPnPSubscribeResponseParamSet Timeout1.... \n");
       
  2632 							Manager().INFO_PRINTF1(KInfoLogFile);
       
  2633 							Manager().iRenewCount++;
       
  2634 							//renew subscriptions
       
  2635 							_LIT(KInfoSubscribeTimeOut2, "renew count %d \n");
       
  2636 							Manager().INFO_PRINTF2(KInfoSubscribeTimeOut2,Manager().iRenewCount);
       
  2637 							_LIT(KInfoReSubscribe, "Request to RESUBSCRIPTION is Executed\n");
       
  2638 							Manager().INFO_PRINTF1(KInfoReSubscribe);
       
  2639 							Manager().SubscribeForStateChangeNotificationsL();
       
  2640 							return;
       
  2641 							}
       
  2642 						else
       
  2643 							{
       
  2644 							//Unsubscribe before closing
       
  2645 							RDebug::Print( _L( "Unsubscribe before closing" ));
       
  2646 							_LIT(KInfoUnSubscribe, "Request to UNSUBSCRIPTION is Executed As Subscription TIMED OUT \n");
       
  2647 							Manager().INFO_PRINTF1(KInfoUnSubscribe);
       
  2648 							TPtrC referSection;
       
  2649 							_LIT(KReferSection,"refersection");
       
  2650 							Manager().GetStringFromConfig(Manager().GetCurrentSection(),KReferSection,referSection );
       
  2651 							RDebug::Print( _L( "Before calling UnsubscribeForStateChangeNotificationsL" ));
       
  2652 							Manager().UnsubscribeForStateChangeNotificationsL(referSection);
       
  2653 							RDebug::Print( _L( "After calling UnsubscribeForStateChangeNotificationsL" ));
       
  2654 							subscriptionUri16.Close();//cleanup activity
       
  2655 							CActiveScheduler::Stop();
       
  2656 							_LIT(KInfoLogFile, "EUPnPSubscribeResponseParamSet Timeout2.... \n");
       
  2657 							Manager().INFO_PRINTF1(KInfoLogFile);
       
  2658 							return;
       
  2659 							}
       
  2660 						}
       
  2661 					else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess)
       
  2662 						{
       
  2663 						_LIT(KInfoSubscribeSuccess, "Info: SUBSCRIPTION REQUEST IS ACCEPTED FOR SUBSCRIPTION\n %S \n");
       
  2664 						Manager().INFO_PRINTF2(KInfoSubscribeSuccess, &subscriptionUri16);
       
  2665 						
       
  2666 						//opt for Abrupt close of CP
       
  2667 						TBool abruptCloseCP = EFalse;
       
  2668 						_LIT(KAbruptCloseCP,"abruptclosecp");
       
  2669 						Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KAbruptCloseCP,abruptCloseCP );
       
  2670 						if(abruptCloseCP)
       
  2671 							{
       
  2672 							//Closing Control point Abruptly
       
  2673 							_LIT(KInfoSubScribe, "In Subscribe Response \n");
       
  2674 							_LIT(KInfoCloseCP, "Closing Control point Abruptly.... \n");
       
  2675 							Manager().INFO_PRINTF1(KInfoSubScribe);
       
  2676 							Manager().INFO_PRINTF1(KInfoCloseCP);
       
  2677 							CActiveScheduler::Stop();
       
  2678 							Manager().CloseDiscoverer();
       
  2679 							return;
       
  2680 							}
       
  2681 						//Opt for Unsubscribe
       
  2682 						TBool unSubscribeFlag = EFalse;
       
  2683 						_LIT(KUnsubscribeFlag,"unsubscribeflag");
       
  2684 						Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KUnsubscribeFlag,unSubscribeFlag );
       
  2685 						if ( Manager().iRenewCount > 0 )
       
  2686 							{
       
  2687 							TPtrC referSection;
       
  2688 							_LIT(KReferSection,"refersection");
       
  2689 							Manager().GetStringFromConfig(Manager().GetCurrentSection(),KReferSection,referSection );
       
  2690 							Manager().GetBoolFromConfig(referSection,KUnsubscribeFlag,unSubscribeFlag );
       
  2691 							if ( unSubscribeFlag )	
       
  2692 								{
       
  2693 								_LIT(KInfoUnSubscribe, "Request to UNSUBSCRIPTION is Executed After Renew Subscription Success\n  \n");
       
  2694 								Manager().INFO_PRINTF1(KInfoUnSubscribe);
       
  2695 								}
       
  2696 							}
       
  2697 						if(unSubscribeFlag)
       
  2698 							{//go to unsubscribe here
       
  2699 							_LIT(KInfoUnSubscribe, "Request to UNSUBSCRIPTION is Executed Before Subscription Expiry\n  \n");
       
  2700 							Manager().INFO_PRINTF1(KInfoUnSubscribe);
       
  2701 							TPtrC referSection;
       
  2702 							_LIT(KReferSection,"refersection");
       
  2703 							Manager().GetStringFromConfig(Manager().GetCurrentSection(),KReferSection,referSection );
       
  2704 							//Unsubscribe
       
  2705 							Manager().UnsubscribeForStateChangeNotificationsL(referSection);
       
  2706 							subscriptionUri16.Close();//cleanup activity
       
  2707 							CActiveScheduler::Stop();//this is for start made in prev subscribe
       
  2708 							_LIT(KInfoLogFile, "EUPnPSubscribeResponseParamSet Success.... \n");
       
  2709 							Manager().INFO_PRINTF1(KInfoLogFile);
       
  2710 							return;
       
  2711 							}
       
  2712 						else
       
  2713 							{
       
  2714 							
       
  2715 							RDebug::Print( _L("Not going to unsubscribe,waiting for timeout Notifications"));
       
  2716 							}
       
  2717 				
       
  2718 						}
       
  2719 					}
       
  2720 				}
       
  2721 			break;
       
  2722 			case EUPnPNotifyEventParamSet:
       
  2723 				{//receives event notifications sent at client
       
  2724 				_LIT(KInfoLogFile, "EUPnPNotifyEventParamSet.... \n");
       
  2725 				Manager().INFO_PRINTF1(KInfoLogFile);
       
  2726 				
       
  2727 				
       
  2728 				CUPnPNotifyEventParamSet* paramSet  = NULL;
       
  2729 				TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
       
  2730 					
       
  2731 				for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2732 				   {
       
  2733 				   paramSet = static_cast<CUPnPNotifyEventParamSet*> ( paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ) );
       
  2734 					//Paramset at current position
       
  2735 					
       
  2736 					RBuf subscriptionUri16;
       
  2737 					subscriptionUri16.Create(paramSet->Uri().Length());
       
  2738 					subscriptionUri16.Copy(paramSet->Uri());
       
  2739 					if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2740 						{						
       
  2741 						_LIT(KInfoNotificationsFailed, "Info: Failed to Get Event notifications\n %S \n");
       
  2742 						Manager().INFO_PRINTF2(KInfoNotificationsFailed,&subscriptionUri16);
       
  2743 						subscriptionUri16.Close();
       
  2744 						TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2745 						_LIT(KNotificationsFailed,"Failed to Receive Notifications with...Error Code  = %d \n");
       
  2746 						Manager().ERR_PRINTF2(KNotificationsFailed, error);
       
  2747 						//Manager().SetTestStepResult(EFail);
       
  2748 						return;
       
  2749 						}
       
  2750 					else if (paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess)
       
  2751 						{
       
  2752 						_LIT(KInfoNotifications, "Notifications for subscribed Uri: %S \t is received \n");
       
  2753 						Manager().INFO_PRINTF2(KInfoNotifications, &subscriptionUri16);
       
  2754 						subscriptionUri16.Close();//cleanup activity
       
  2755 						}
       
  2756 					}
       
  2757 				_LIT(KInfoLogFile1, "EUPnPNotifyEventParamSet End.... \n");
       
  2758 				Manager().INFO_PRINTF1(KInfoLogFile1);
       
  2759 				}
       
  2760 			break;
       
  2761 			default:
       
  2762 				{
       
  2763 				//Do Nothing
       
  2764 				}
       
  2765 			break;
       
  2766 			}
       
  2767 		}
       
  2768 	}
       
  2769 
       
  2770 /*
       
  2771    Error handling,asynchronous one.
       
  2772    @param  aError Error Code
       
  2773    @return None
       
  2774  */
       
  2775 void CUPnPObserver::OnPnPError(TInt aError)
       
  2776 	{
       
  2777 	_LIT(KPositiveCase,"positivecase");
       
  2778 	TBool positiveCase = ETrue;
       
  2779 	Manager().GetBoolFromConfig(Manager().GetCurrentSection(), KPositiveCase, positiveCase);
       
  2780 	// Note down the error and stop scheduler
       
  2781 	//If not postive case, client.dll will come back before active scheduler start
       
  2782 	//so, don't execute activescheduler::stop
       
  2783 	if (positiveCase)
       
  2784 		{
       
  2785 		CActiveScheduler::Stop();
       
  2786 		}
       
  2787 	_LIT(KErrorMessage, "Error occurred in the UPnP Observer : %d \n");
       
  2788 	Manager().ERR_PRINTF2(KErrorMessage, aError);
       
  2789 	//Manager().SetTestStepResult(EFail);
       
  2790 	}
       
  2791 
       
  2792 /*
       
  2793    This function copies result bundles into results array, which inturn is used in printing results
       
  2794    @param  aPnpBundle a reference to CPnPParameterBundleBase
       
  2795    @return None
       
  2796  */
       
  2797 void CUPnPObserver::CopyResultBundlesL(const RPnPParameterBundleBase& aPnpBundle)
       
  2798 	{
       
  2799 	_LIT(KInfoLogFile, "CUPnPObserver::CopyResultBundlesL().... \n");
       
  2800 	Manager().INFO_PRINTF1(KInfoLogFile);
       
  2801 	
       
  2802 	HBufC8* holdBundle = HBufC8::NewLC(aPnpBundle.Length());
       
  2803 
       
  2804 	if (!holdBundle)
       
  2805         {
       
  2806         User::Leave(KErrNoMemory);
       
  2807         }
       
  2808 
       
  2809     TPtr8 storePtr(holdBundle->Des());
       
  2810 	TInt retOnStore = aPnpBundle.Store(storePtr);
       
  2811 	User::LeaveIfError(retOnStore);
       
  2812 
       
  2813 	TPtrC8 loadPtr(holdBundle->Des());
       
  2814 	RPnPParameterBundleBase newPnpBundle;
       
  2815 	newPnpBundle.CreateL();
       
  2816 	TInt retOnLoad = newPnpBundle.Load(loadPtr);
       
  2817 	User::LeaveIfError(retOnLoad);
       
  2818 	CleanupStack::PushL( &newPnpBundle);
       
  2819 	Manager().AppendBundlesL(newPnpBundle);
       
  2820 	CleanupStack::Pop(&newPnpBundle);
       
  2821 	CleanupStack::PopAndDestroy(holdBundle);
       
  2822 	_LIT(KInfoLogFile1, "CUPnPObserver::CopyResultBundlesL() End.... \n");
       
  2823 	Manager().INFO_PRINTF1(KInfoLogFile1);
       
  2824 	}
       
  2825 
       
  2826 /*
       
  2827    This function Prints Discovery results by getting it from Results bundle
       
  2828    @param  aParamFamily a pointer to CUPnPParameterFamily
       
  2829    @return None
       
  2830  */
       
  2831 void CTestUPnPManager::PrintDiscoveryResultsL(RParameterFamily& aParamFamily)
       
  2832 	{
       
  2833 	_LIT(KInfoLogFile, "CTestUPnPManager::PrintDiscoveryResultsL().... \n");
       
  2834 	INFO_PRINTF1(KInfoLogFile);
       
  2835 
       
  2836 	_LIT(KPrintStatement, "printing results \n");
       
  2837 	_LIT(KPrintDesign,"	\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n");
       
  2838 
       
  2839 	INFO_PRINTF1(KPrintStatement);
       
  2840 	INFO_PRINTF1(KPrintDesign);
       
  2841 	
       
  2842 	TUint count = aParamFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
       
  2843 	CUPnPDiscoverResponseParamSet* paramSet  = NULL;
       
  2844 	
       
  2845 	for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2846 		{
       
  2847 		paramSet = static_cast<CUPnPDiscoverResponseParamSet*>(aParamFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ));
       
  2848 		
       
  2849 		if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2850 			{
       
  2851 			TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2852 			_LIT(KDiscoverFailed,"Failed to Discover with...Error Code  = %d \n");
       
  2853 			ERR_PRINTF2(KDiscoverFailed, error);		
       
  2854 			continue;
       
  2855 			}
       
  2856 		else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EDiscoveryTimeout)
       
  2857 			{
       
  2858 			_LIT(KDiscoverTimeOut,"Discover Response TimeOut: TUPnPEvent::EDiscoveryTimeout \n");
       
  2859 			INFO_PRINTF1(KDiscoverTimeOut);			
       
  2860 			continue;
       
  2861 			}
       
  2862 		TPtrC8 deviceLocation(paramSet->DeviceLocation());
       
  2863 		HBufC* devloc = HBufC::NewLC(deviceLocation.Length());	//1
       
  2864 		devloc->Des().Copy(deviceLocation);
       
  2865 		TPtrC devLocPointer (devloc->Des());
       
  2866 		_LIT(KInfoUri,"The Location: %S \n");
       
  2867 		INFO_PRINTF2(KInfoUri, &devLocPointer);
       
  2868 
       
  2869 		TPtrC8 usn(paramSet->USN());
       
  2870 		HBufC* usnVal = HBufC::NewLC(usn.Length());	//2
       
  2871 		usnVal->Des().Copy(usn);
       
  2872 		TPtrC usnValPointer (usnVal->Des());
       
  2873 		_LIT(KInfoUSN,"The USN found is %S \n");
       
  2874 		INFO_PRINTF2(KInfoUSN, &usnValPointer);
       
  2875 
       
  2876 		TInt expiryTime = paramSet->ExpiryTime();
       
  2877 		_LIT(KInfoexpiryTime,"The Expiry Time or CACHE-CONTROL: max-age =  %d \n");
       
  2878 		INFO_PRINTF2(KInfoexpiryTime, expiryTime);
       
  2879 
       
  2880 		CleanupStack::PopAndDestroy(usnVal);
       
  2881 		CleanupStack::PopAndDestroy(devloc);		
       
  2882 		continue;
       
  2883 		}
       
  2884 	_LIT(KEndPrintStatement,"Done with printing results \n");
       
  2885 	INFO_PRINTF1(KEndPrintStatement);
       
  2886 	INFO_PRINTF1(KPrintDesign);
       
  2887 	}
       
  2888 
       
  2889 void CTestUPnPManager::ValidateDiscoveryResultsL(const TDesC& aOperationType)
       
  2890 	{
       
  2891 	_LIT(KInfoLogFile, "CTestUPnPManager::ValidateDiscoveryResultsL().... \n");
       
  2892 	INFO_PRINTF1(KInfoLogFile);
       
  2893 	
       
  2894 	TInt DeviceLocationCount = NULL;
       
  2895 	TPtrC ExpectedURL;
       
  2896 	GetStringFromConfig(aOperationType, KExpectedURL, ExpectedURL);
       
  2897 
       
  2898 	TInt totalCount(0);
       
  2899 	GetIntFromConfig(aOperationType, KExpectedCount, totalCount);
       
  2900 	const TInt bundleCount = iResultsArray.Count();
       
  2901 
       
  2902 	for(TInt i(0); i < bundleCount; i++)
       
  2903 		{
       
  2904 		RParameterFamily paramFamily = iResultsArray[i].GetFamilyAtIndex(0);
       
  2905 		if( !paramFamily.IsNull() )
       
  2906 			{
       
  2907 	 		if(paramFamily.Id() ==EUPnPDiscoverResponseParamSet)
       
  2908 				{
       
  2909 				
       
  2910 				CUPnPDiscoverResponseParamSet* paramSet  = NULL;
       
  2911 			
       
  2912 				TUint count = paramFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
       
  2913 				
       
  2914 				for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
       
  2915 					{
       
  2916 					paramSet = static_cast<CUPnPDiscoverResponseParamSet*>(paramFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ));
       
  2917 										
       
  2918 					if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail)
       
  2919 						{
       
  2920 						TInt error = paramSet->UPnPEvent().iErrorCode;
       
  2921 						_LIT(KDiscoverFailed,"Failed to Discover with...Error Code  = %d \n");
       
  2922 						ERR_PRINTF2(KDiscoverFailed, error);						
       
  2923 						continue;
       
  2924 						}
       
  2925 					TPtrC8 deviceLocation(paramSet->DeviceLocation());
       
  2926 					HBufC* devloc = HBufC::NewLC(deviceLocation.Length());
       
  2927 					devloc->Des().Copy(deviceLocation);
       
  2928 					TPtrC devLocPointer (devloc->Des());
       
  2929 					DeviceLocationCount++;
       
  2930 					if((ExpectedURL!=KNullDesC) && (ExpectedURL.Compare(devLocPointer) == KErrNone))
       
  2931 						{
       
  2932 						SetTestStepResult(EPass);
       
  2933 						}
       
  2934 					CleanupStack::PopAndDestroy(devloc);					
       
  2935 					continue;
       
  2936 					}
       
  2937 				}
       
  2938 			}
       
  2939 		}
       
  2940 	if((DeviceLocationCount != NULL) &&(DeviceLocationCount == totalCount))
       
  2941 		{
       
  2942 		SetTestStepResult(EPass);
       
  2943 		}
       
  2944 	_LIT(KInfoLogFile1, "CTestUPnPManager::ValidateDiscoveryResultsL() End.... \n");
       
  2945 	INFO_PRINTF1(KInfoLogFile1);
       
  2946 	}
       
  2947 
       
  2948 void CTestUPnPManager::CancelPublish()
       
  2949 	{
       
  2950 	_LIT(KInfoLogFile, "CTestUPnPManager::CancelPublish() Begin....  \n");
       
  2951 	INFO_PRINTF1(KInfoLogFile);
       
  2952 	TInt count = iPublisherArray.Count();
       
  2953 	for(TInt i(count - 1); i >= 0 ; i--)
       
  2954 		{
       
  2955 		TPublisherControl publisherType = PublisherType(i);
       
  2956 		_LIT(KInfoCancelLog, "CTestUPnPManager::CancelPublish()...Closing Publisher....  %d\n");
       
  2957 		INFO_PRINTF2(KInfoCancelLog,i);
       
  2958 		switch(publisherType)
       
  2959 			{
       
  2960 			case KService:
       
  2961 				{
       
  2962 				_LIT(KInfoService, "Closing Publisher.... of Type---->SERVICE\n");
       
  2963 				INFO_PRINTF1(KInfoService);
       
  2964 				break;
       
  2965 				}
       
  2966 			case KDevice:
       
  2967 				{
       
  2968 				_LIT(KInfoDevice, "Closing Publisher.... of Type---->DEVICE\n");
       
  2969 				INFO_PRINTF1(KInfoDevice);
       
  2970 				break;
       
  2971 				}
       
  2972 			default :
       
  2973 				{
       
  2974 				_LIT(KInfoErr, "Closing Publisher.... of Type---->InValid\n");
       
  2975 				ERR_PRINTF1(KInfoErr);
       
  2976 				break;
       
  2977 				}
       
  2978 			}
       
  2979 		iPublisherArray[i].Close();
       
  2980 		}
       
  2981 	_LIT(KInfoLogFile2, "CancelPublish() Array Closed.... \n");
       
  2982 	INFO_PRINTF1(KInfoLogFile2);
       
  2983 	iPublisherArray.Close();
       
  2984 	_LIT(KInfoLogFile3, "CTestUPnPManager::CancelPublish() End.... \n");
       
  2985 	INFO_PRINTF1(KInfoLogFile3);
       
  2986 	}
       
  2987 
       
  2988 void CTestUPnPManager::DescribeServiceL()
       
  2989 	{
       
  2990 	_LIT(KInfoLogFile, "CTestUPnPManager::DescribeServiceL().... \n");
       
  2991 	INFO_PRINTF1(KInfoLogFile);
       
  2992 	
       
  2993 	ResolveAllUrisL();
       
  2994 	TInt scpdUriCount = iScpdUriArray.Count();
       
  2995 	//__ASSERT_DEBUG ( scpdUriCount > 0, User::Panic (KDescribeTestPanicCategory,KErrNoDescriptionPath ) );
       
  2996 	if ( scpdUriCount==0 )
       
  2997 		{
       
  2998 		_LIT(KDescription,"Description Cannot be performed \n");
       
  2999 		INFO_PRINTF1(KDescription);
       
  3000 		//SetTestStepResult(EFail);
       
  3001 		return;
       
  3002 		}
       
  3003 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  3004 	CleanupStack::PushL( upnpObserver );	
       
  3005 	
       
  3006 	RPnPParameterBundle pnpBundle;
       
  3007 	pnpBundle.CreateL ();
       
  3008 	CleanupClosePushL( pnpBundle );
       
  3009 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  3010 
       
  3011 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPDescribeRequestParamSet);
       
  3012 
       
  3013 	// Read the ScpdUrl from ScpdUri Array
       
  3014 	//Make sure that Before this Describe Device, and Discovery is executes Succesfully.
       
  3015 	for(TInt index(0); index < scpdUriCount ; index++)//scpdUriCount
       
  3016 		{
       
  3017 		CUPnPDescribeRequestParamSet* describeParamSet = CUPnPDescribeRequestParamSet::NewL (pnpFamily );
       
  3018 		describeParamSet->SetUriL(iScpdUriArray[index]);	
       
  3019 		RBuf scpdUri16;
       
  3020 		scpdUri16.Create(iScpdUriArray[index].Length());
       
  3021 		scpdUri16.Copy(iScpdUriArray[index]);
       
  3022 		_LIT(KScpdUriInfo,"SCPD Uri Submitted for Description Request is: %S \n");
       
  3023 		INFO_PRINTF2(KScpdUriInfo, &scpdUri16);
       
  3024 		scpdUri16.Close();
       
  3025 		}
       
  3026 	iControlPoint.Describe( pnpBundle );
       
  3027 	CActiveScheduler::Start();
       
  3028 	_LIT(KInfoLogFile1, "CTestUPnPManager::DescribeServiceL() End.... \n");
       
  3029 	INFO_PRINTF1(KInfoLogFile1);
       
  3030 	
       
  3031 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  3032 	CleanupStack::PopAndDestroy( upnpObserver );
       
  3033 	}
       
  3034 	
       
  3035 void CTestUPnPManager::DescribeIconL()
       
  3036 	{
       
  3037 	_LIT(KInfoLogFile, "CTestUPnPManager::DescribeIconL().... \n");
       
  3038 	INFO_PRINTF1(KInfoLogFile);
       
  3039 	
       
  3040 	ResolveAllUrisL();
       
  3041 	TInt uriCount = iIconUriArray.Count();
       
  3042 	if ( uriCount==0 )
       
  3043 		{
       
  3044 		_LIT(KIconDescription,"Description Cannot be performed \n");
       
  3045 		INFO_PRINTF1(KIconDescription);		
       
  3046 		return;
       
  3047 		}
       
  3048 	
       
  3049 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  3050 	CleanupStack::PushL( upnpObserver );
       
  3051 	
       
  3052 	RPnPParameterBundle pnpBundle;
       
  3053 	pnpBundle.CreateL ();
       
  3054 	CleanupClosePushL( pnpBundle );
       
  3055 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  3056 	
       
  3057 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPDescribeRequestParamSet);
       
  3058 	
       
  3059 	//Make sure that Before this Describe Device, and Discovery is executes Succesfully.
       
  3060 	for(TInt index(0); index < uriCount ; index++)
       
  3061 		{
       
  3062 		CUPnPDescribeRequestParamSet* describeParamSet = CUPnPDescribeRequestParamSet::NewL (pnpFamily );
       
  3063 		describeParamSet->SetUriL(iIconUriArray[index]);
       
  3064 		RBuf uri16;
       
  3065 		uri16.Create(iIconUriArray[index].Length());
       
  3066 		uri16.Copy(iIconUriArray[index]);
       
  3067 		_LIT(KScpdUriInfo,"SCPD Uri Submitted for Description Request is: %S \n");
       
  3068 		INFO_PRINTF2(KScpdUriInfo, &uri16);
       
  3069 		uri16.Close();
       
  3070 		}
       
  3071 	iControlPoint.Describe(pnpBundle );
       
  3072 	CActiveScheduler::Start();
       
  3073 	_LIT(KInfoLogFile1, "CTestUPnPManager::DescribeServiceL() End.... \n");
       
  3074 	INFO_PRINTF1(KInfoLogFile1);
       
  3075 	
       
  3076 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  3077 	CleanupStack::PopAndDestroy( upnpObserver );
       
  3078 	}
       
  3079  
       
  3080 void CTestUPnPManager::DescribeL()
       
  3081 	{
       
  3082 	_LIT(KInfoLogFile, "CTestUPnPManager::DescribeL().... \n");
       
  3083 	INFO_PRINTF1(KInfoLogFile);
       
  3084 	
       
  3085 	CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this);
       
  3086 	CleanupStack::PushL( upnpObserver );
       
  3087 	
       
  3088 	RPnPParameterBundle pnpBundle;
       
  3089 	pnpBundle.CreateL ();
       
  3090 	CleanupClosePushL( pnpBundle );
       
  3091 	pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
       
  3092 	
       
  3093 	RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EUPnPDescribeRequestParamSet);	
       
  3094 	RBuf8 descriptionPathBuf;
       
  3095 
       
  3096 	TBool readIni = ETrue;
       
  3097 	GetBoolFromConfig(GetCurrentSection(), KReadIni, readIni);
       
  3098 	if(readIni)
       
  3099 		{
       
  3100 		// Get the Description path from .ini File
       
  3101 		TPtrC descriptionPath;
       
  3102 		GetStringFromConfig(GetCurrentSection(), KDescriptionPath, descriptionPath);
       
  3103 		CUPnPDescribeRequestParamSet* describeParamSet = CUPnPDescribeRequestParamSet::NewL (pnpFamily );	
       
  3104 		descriptionPathBuf.Create(descriptionPath.Length());
       
  3105 		descriptionPathBuf.Copy(descriptionPath);
       
  3106 		describeParamSet->SetUriL(descriptionPathBuf);	
       
  3107 		descriptionPathBuf.Close();
       
  3108 		iControlPoint.Describe( pnpBundle );
       
  3109 		TBool SchedulerStatus = ETrue;
       
  3110 		_LIT(KSchedulerStatus, "schedulerstart");
       
  3111 		GetBoolFromConfig(GetCurrentSection(), KSchedulerStatus, SchedulerStatus);
       
  3112 		if(SchedulerStatus)
       
  3113 			{
       
  3114 			CActiveScheduler::Start();
       
  3115 			}
       
  3116 		}
       
  3117 	else
       
  3118 		{
       
  3119 		// Read the Description path from DevLoaction array
       
  3120 		//Make sure that Before this Describe, Successful Discovery is happend.
       
  3121 		TInt DevLocCount = iDeviceLocationArray.Count();
       
  3122 		if ( DevLocCount==0 )
       
  3123 			{
       
  3124 			_LIT(KDescription,"Description Cannot be performed as NO Uri available to Describe\n");
       
  3125 			INFO_PRINTF1(KDescription);
       
  3126 			CleanupStack::PopAndDestroy( &pnpBundle );
       
  3127 			CleanupStack::PopAndDestroy( upnpObserver );
       
  3128 			//SetTestStepResult(EFail);
       
  3129 			return;
       
  3130 			}
       
  3131 
       
  3132 		//__ASSERT_DEBUG ( DevLocCount > 0, User::Panic (KDescribeTestPanicCategory,KErrNoDescriptionPath ) );
       
  3133 
       
  3134 		for(TInt iter(0); iter < DevLocCount  ; iter++)
       
  3135 			{
       
  3136 			TBuf8<256> url;
       
  3137 			TUriParser8 uri;
       
  3138 			uri.Parse(iDeviceLocationArray[iter]);
       
  3139 			const TDesC8& scheme = uri.Extract(EUriScheme);
       
  3140 			_LIT8(KScheme, "http");
       
  3141 			//Uri must be of scheme "http" only
       
  3142 			if (scheme.CompareF(KScheme) == 0)
       
  3143 				{
       
  3144 				url.Copy(iDeviceLocationArray[iter]);
       
  3145 				CUPnPDescribeRequestParamSet* describeParamSet = CUPnPDescribeRequestParamSet::NewL ( pnpFamily );
       
  3146 				describeParamSet->SetUriL(url);	
       
  3147 				}
       
  3148 			else
       
  3149 				{
       
  3150 				_LIT(KInavlidUri, "Describe Request for InvalidURi");
       
  3151 				INFO_PRINTF1(KInavlidUri);
       
  3152 				return;
       
  3153 				}
       
  3154 			}
       
  3155 			
       
  3156 		iControlPoint.Describe(pnpBundle );
       
  3157 		TBool SchedulerStatus = ETrue;
       
  3158 		_LIT(KSchedulerStatus, "schedulerstart");
       
  3159 		GetBoolFromConfig(GetCurrentSection(), KSchedulerStatus, SchedulerStatus);
       
  3160 		if(SchedulerStatus)
       
  3161 			{
       
  3162 			CActiveScheduler::Start();
       
  3163 			}
       
  3164 		}
       
  3165 	_LIT(KInfoLogFile1, "CTestUPnPManager::DescribeL() End.... \n");
       
  3166 	INFO_PRINTF1(KInfoLogFile1);
       
  3167 	CleanupStack::PopAndDestroy( &pnpBundle );
       
  3168 	CleanupStack::PopAndDestroy( upnpObserver );
       
  3169 	}
       
  3170 
       
  3171 void CTestUPnPManager::ResolveAllUrisL()
       
  3172 	{
       
  3173 	_LIT(KInfoLogFile, "CTestUPnPManager::ResolveAllUrisL().... \n");
       
  3174 	INFO_PRINTF1(KInfoLogFile);
       
  3175 	
       
  3176 	TInt count = iDescriptionSuiteArray.Count();
       
  3177 	//__ASSERT_DEBUG ( count > 0, User::Panic (KDescribeTestPanicCategory, KErrNoServiceUris ) );
       
  3178 	if( count <=0 )
       
  3179 		{
       
  3180 		_LIT(KErrResolve, "No Description is exist to Resolve URIs");
       
  3181 		ERR_PRINTF1(KErrResolve);
       
  3182 		return;
       
  3183 		}
       
  3184 	//Fill the all types of Uris for each base Uri
       
  3185 	for (TInt index(0); index < count ; index++ )
       
  3186 		{
       
  3187 		GetServiceUrlsListL(index);
       
  3188 		ResolveScpdUrisL(index);
       
  3189 		ResolveEventUrisL(index);
       
  3190 		ResolveControlUrisL(index);
       
  3191 		}
       
  3192 	}
       
  3193 
       
  3194 void CTestUPnPManager::GetServiceUrlsListL(TInt aIndex)
       
  3195 	{
       
  3196 	_LIT(KInfoLogFile, "CTestUPnPManager::GetServiceUrlsListL().... \n");
       
  3197 	INFO_PRINTF1(KInfoLogFile);
       
  3198 	
       
  3199 	CUPnPDeviceDescription*	rootDeviceDescription = NULL;
       
  3200 	//Release the content of StringPool if any
       
  3201 	if(iStringPoolMgr)
       
  3202 		iStringPoolMgr->Release();
       
  3203 	DeleteSeriveUrlsList(aIndex);
       
  3204 
       
  3205 	 iStringPoolMgr = CStringPoolManager::NewL();
       
  3206 	 //Store the Parsed node info
       
  3207 	 iStringPool = iStringPoolMgr->StringPool();
       
  3208 	_LIT(KInfoLogFile4, "Creating Stringpool and its manager.... \n");
       
  3209 	INFO_PRINTF1(KInfoLogFile4);
       
  3210 	
       
  3211 	//Parse the device description
       
  3212     CUPnPDescriptionParser* app = CUPnPDescriptionParser::NewL( iStringPool, CUPnPDescriptionParser::EDevice);
       
  3213 	_LIT(KInfoLogFile2, "CTestUPnPManager::CUpnpDeviceXmlParser::NewL().... \n");
       
  3214 	INFO_PRINTF1(KInfoLogFile2);
       
  3215     TRAPD(error,(rootDeviceDescription = static_cast<CUPnPDeviceDescription*>(app->ParseDescriptionBufL(iDescriptionSuiteArray[aIndex].iDescription))));
       
  3216 	if (error != KErrNone)
       
  3217 		{
       
  3218 		_LIT(KErrLogFile1, "CTestUPnPManager::GetServiceUrlsListL() is Terminating.... And Error is %d \n");
       
  3219 		ERR_PRINTF2(KErrLogFile1, error);
       
  3220 		return;
       
  3221 		}
       
  3222 	_LIT(KInfoLogFile3, "rootDeviceDescription.... \n");
       
  3223 	INFO_PRINTF1(KInfoLogFile3);
       
  3224 	
       
  3225    
       
  3226     
       
  3227     delete app;
       
  3228 	app = NULL;
       
  3229 	_LIT(KInfoLogFile5, "Deleting CUpnpDeviceXmlParser().... \n");
       
  3230 	INFO_PRINTF1(KInfoLogFile5);
       
  3231 
       
  3232     //Retrieve the Tag for Base
       
  3233     RString string = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EUrlBase,iStringPoolMgr->GetUPnPTable());
       
  3234     //Get the node info for the Base i.e., value between the start and end Base tags
       
  3235     //If BaseUri exist in Description replace already existing BaseUri
       
  3236 	if(rootDeviceDescription->Property(string).Compare(KNullDesC8)>0)
       
  3237 		{
       
  3238 		//Delete already stored Base uri
       
  3239 		iDescriptionSuiteArray[aIndex].iBaseUrl.Close();
       
  3240 		iDescriptionSuiteArray[aIndex].iBaseUrl.Create(rootDeviceDescription->Property(string).Length());
       
  3241 		iDescriptionSuiteArray[aIndex].iBaseUrl.Copy(rootDeviceDescription->Property(string));
       
  3242 		}
       
  3243 
       
  3244 	//Catch hold of first level of Device
       
  3245 	CUPnPDevice* device = rootDeviceDescription->DeviceObject();
       
  3246 
       
  3247 	TInt count =device->CountOfEmbeddedDeviceInfoTable();
       
  3248 	if(count>0)
       
  3249 		{
       
  3250 		for(TInt i=0;i<count;i++)
       
  3251 			{
       
  3252 			GetEmbeddedDeviceServicesL(aIndex,device->AtEmbeddedDeviceInfoTable(i));
       
  3253 			}
       
  3254 		}
       
  3255 	GetServiceValuesL(aIndex, device);
       
  3256 	
       
  3257 	GetIconUrlsL( aIndex, device);
       
  3258 	
       
  3259 	_LIT(KInfoLogFile6, "Finished GetServiceValuesL.... \n");
       
  3260 	INFO_PRINTF1(KInfoLogFile6);
       
  3261 	delete rootDeviceDescription;
       
  3262 	rootDeviceDescription = NULL;
       
  3263 	_LIT(KInfoLogFile1, "CTestUPnPManager::GetServiceUrlsListL() End.... \n");
       
  3264 	INFO_PRINTF1(KInfoLogFile1);
       
  3265 	}
       
  3266 	
       
  3267 void CTestUPnPManager::GetIconUrlsL ( TInt aBaseDescIdx, CUPnPDevice* aRootDevice )
       
  3268 	{	
       
  3269 	RString strF = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EUrl,iStringPoolMgr->GetUPnPTable());
       
  3270 	
       
  3271 	for ( TInt i = 0; i < aRootDevice->CountOfIconInfoTable (); i++ )
       
  3272 		{
       
  3273 		CUPnPIconInfo* iconInfo = aRootDevice->AtIconInfoTable(i);
       
  3274 		ResolveIconUrlL ( aBaseDescIdx, iconInfo->Property(strF) );
       
  3275 		}
       
  3276 	for ( TInt i = 0; i < aRootDevice->CountOfEmbeddedDeviceInfoTable(); i++ )
       
  3277 		{
       
  3278 		GetIconUrlsL ( aBaseDescIdx, aRootDevice->AtEmbeddedDeviceInfoTable(i) );
       
  3279 		}
       
  3280 	}
       
  3281 
       
  3282 void CTestUPnPManager::DeleteSeriveUrlsList(TInt aIndex)
       
  3283 	{
       
  3284 	_LIT(KInfoLogFile, "CTestUPnPManager::DeleteSeriveUrlsList().... \n");
       
  3285 	INFO_PRINTF1(KInfoLogFile);
       
  3286 	
       
  3287 	for(TInt i=0;i<iDescriptionSuiteArray[aIndex].iServiceUrls.Count();i++)
       
  3288 		{
       
  3289 		iDescriptionSuiteArray[aIndex].iServiceUrls[i].serviceType.Close();
       
  3290 		iDescriptionSuiteArray[aIndex].iServiceUrls[i].scpdUrl.Close();
       
  3291 		iDescriptionSuiteArray[aIndex].iServiceUrls[i].controlUrl.Close();
       
  3292 		iDescriptionSuiteArray[aIndex].iServiceUrls[i].eventSubUrl.Close();		
       
  3293 		}
       
  3294 	iDescriptionSuiteArray[aIndex].iServiceUrls.Close();
       
  3295 	_LIT(KInfoLogFile1, "CTestUPnPManager::DeleteSeriveUrlsList() End.... \n");
       
  3296 	INFO_PRINTF1(KInfoLogFile1);
       
  3297 	}
       
  3298 
       
  3299 void CTestUPnPManager::GetEmbeddedDeviceServicesL(TInt aIndex, CUPnPDevice* aDevice)
       
  3300 	{
       
  3301 	_LIT(KInfoLogFile, "CTestUPnPManager::GetEmbeddedDeviceServicesL().... \n");
       
  3302 	INFO_PRINTF1(KInfoLogFile);
       
  3303 	
       
  3304 	if(aDevice->CountOfEmbeddedDeviceInfoTable() > 0)
       
  3305 		{
       
  3306 		for(TInt i=0;i<aDevice->CountOfEmbeddedDeviceInfoTable();i++)
       
  3307 			{
       
  3308 			GetEmbeddedDeviceServicesL(aIndex, aDevice->AtEmbeddedDeviceInfoTable(i));
       
  3309 			GetServiceValuesL(aIndex, aDevice);
       
  3310 			}
       
  3311 		}
       
  3312 	else
       
  3313 		{
       
  3314 		GetServiceValuesL(aIndex, aDevice);
       
  3315 		}
       
  3316 	}
       
  3317 
       
  3318 
       
  3319 void CTestUPnPManager::AppendDeviceLocationL(TDesC8& aDevLocPointer)
       
  3320 	{
       
  3321 	User::LeaveIfError(	iDeviceLocationArray.Append(aDevLocPointer) );
       
  3322 	}
       
  3323 
       
  3324 void CTestUPnPManager::AppendScpdUriL(RBuf8& aScpdUri)
       
  3325 	{
       
  3326 	User::LeaveIfError(	iScpdUriArray.Append(aScpdUri) );
       
  3327 	}
       
  3328 
       
  3329 void CTestUPnPManager::AppendEventUriL(RBuf8& aEventUri)
       
  3330 	{
       
  3331 	User::LeaveIfError(	iEventUriArray.Append(aEventUri) );
       
  3332 	}
       
  3333 
       
  3334 void CTestUPnPManager::AppendControlUriL(RBuf8& aControlUri)
       
  3335 	{
       
  3336 	User::LeaveIfError(	iControlUriArray.Append(aControlUri) );
       
  3337 	}
       
  3338 
       
  3339 void CTestUPnPManager::AppendDescriptionL(RBuf8& aBaseUri,RBuf8& aDescription)
       
  3340 	{
       
  3341 	TDescriptionSuite buf;
       
  3342 	buf.iDescription.CreateL(aDescription);
       
  3343 	buf.iBaseUrl.CreateL(aBaseUri);
       
  3344 	iDescriptionSuiteArray.Append(buf);
       
  3345 	}
       
  3346 
       
  3347 void CTestUPnPManager::GetServiceValuesL(TInt aIndex, CUPnPDevice* aDevice)
       
  3348 	{
       
  3349 	_LIT(KInfoLogFile, "CTestUPnPManager::GetServiceValuesL().... \n");
       
  3350 	INFO_PRINTF1(KInfoLogFile);
       
  3351 	
       
  3352 	TUint count;
       
  3353 	const CUPnPServiceInfo* servInfo = NULL;
       
  3354 	TServiceUrl serviceurl;
       
  3355 	count = aDevice->CountOfServiceInfoTable();
       
  3356 	if(count > 0)
       
  3357 		{
       
  3358 		for(TInt i = 0;  i< aDevice->CountOfServiceInfoTable(); i++)
       
  3359 			{
       
  3360 			servInfo = aDevice->AtServiceInfoTable(i);
       
  3361 
       
  3362 			RString string = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EServiceType, iStringPoolMgr->GetUPnPTable());
       
  3363 			serviceurl.serviceType.Create(servInfo->Property(string).Length());
       
  3364 			serviceurl.serviceType.Copy(servInfo->Property(string));
       
  3365 
       
  3366 			string = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EScpdUrl, iStringPoolMgr->GetUPnPTable());
       
  3367 			serviceurl.scpdUrl.Create(servInfo->Property(string).Length());
       
  3368 			serviceurl.scpdUrl.Copy(servInfo->Property(string));
       
  3369 
       
  3370 			string = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EContorlUrl, iStringPoolMgr->GetUPnPTable());
       
  3371 			serviceurl.controlUrl.Create(servInfo->Property(string).Length());
       
  3372 			serviceurl.controlUrl.Copy(servInfo->Property(string));
       
  3373 
       
  3374 			string = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EEventSubUrl, iStringPoolMgr->GetUPnPTable());
       
  3375 			serviceurl.eventSubUrl.Create(servInfo->Property(string).Length());
       
  3376 			serviceurl.eventSubUrl.Copy(servInfo->Property(string));
       
  3377 
       
  3378 			iDescriptionSuiteArray[aIndex].iServiceUrls.AppendL(serviceurl);
       
  3379 			}
       
  3380 		}
       
  3381 	_LIT(KInfoLogFile1, "CTestUPnPManager::GetServiceValuesL() End.... \n");
       
  3382 	INFO_PRINTF1(KInfoLogFile1);
       
  3383 	}
       
  3384 
       
  3385 
       
  3386 CUPnPTimer::CUPnPTimer(CTestUPnPManager* aManager)
       
  3387 : CActive(EPriorityHigh),iManager(aManager)
       
  3388     {
       
  3389     CActiveScheduler::Add(this);
       
  3390     }
       
  3391 
       
  3392 
       
  3393 CUPnPTimer::~CUPnPTimer()
       
  3394     {
       
  3395 	Cancel();
       
  3396     }
       
  3397 
       
  3398 
       
  3399 CUPnPTimer* CUPnPTimer::NewL(CTestUPnPManager* aManager)
       
  3400     {
       
  3401 	CUPnPTimer* self = new (ELeave) CUPnPTimer(aManager);
       
  3402 	CleanupStack::PushL(self);
       
  3403 	self->ConstructL();
       
  3404 	CleanupStack::Pop();
       
  3405 	return self;
       
  3406     }
       
  3407 
       
  3408 void CUPnPTimer::ConstructL()
       
  3409 	{
       
  3410 	}
       
  3411 
       
  3412 
       
  3413 void CUPnPTimer::IssueRequestL(TTimeIntervalMicroSeconds32 anInterval)
       
  3414     {
       
  3415 	iTimer.CreateLocal();
       
  3416     iTimer.After(iStatus, anInterval);
       
  3417     SetActive();
       
  3418 	_LIT(KInfoLogFile, "CUPnPTimer::IssueRequestL() End.... \n");
       
  3419 	iManager->INFO_PRINTF1(KInfoLogFile);
       
  3420     }
       
  3421 
       
  3422 
       
  3423 void CUPnPTimer::RunL()
       
  3424 	{
       
  3425 	CActiveScheduler::Stop();
       
  3426 	_LIT(KInfoLogFile, "CUPnPTimer::RunL() End.... \n");
       
  3427 	iManager->INFO_PRINTF1(KInfoLogFile);
       
  3428 	
       
  3429 	}
       
  3430 
       
  3431 void CUPnPTimer::DoCancel()
       
  3432 	{
       
  3433 	iTimer.Cancel();
       
  3434 	}
       
  3435 
       
  3436 CAction* CAction::NewL(CTestUPnPManager* aManager)
       
  3437 	{
       
  3438 	CAction* self = new (ELeave) CAction(aManager);
       
  3439 	CleanupStack::PushL(self);
       
  3440 	self->ConstructL();
       
  3441 	CleanupStack::Pop();
       
  3442 	return self;
       
  3443 
       
  3444 	}
       
  3445 
       
  3446 CAction::CAction(CTestUPnPManager* aManager)
       
  3447 : CActive(CActive::EPriorityStandard),iManager(aManager)
       
  3448 	{
       
  3449 
       
  3450 	}
       
  3451 
       
  3452 CAction::~CAction()
       
  3453 	{
       
  3454 	Cancel();
       
  3455 	iFile.Close ( );
       
  3456 	iFs.Close ( );
       
  3457 	}
       
  3458 
       
  3459 void CAction::ConstructL()
       
  3460 	{
       
  3461 	_LIT(KInfoLogFile, "CAction::ConstructL() .... \n");
       
  3462 	iManager->INFO_PRINTF1(KInfoLogFile);
       
  3463 	CActiveScheduler::Add(this);
       
  3464 	_LIT(KPath, "c:\\upnp\\testupnp\\client\\testdata\\");
       
  3465 	_LIT(KFile, "c:\\upnp\\testupnp\\client\\testdata\\actionresponse.xml");
       
  3466 	User::LeaveIfError ( iFs.Connect ( ) );
       
  3467     TInt err = iFile.Open ( iFs, KFile, EFileWrite );
       
  3468     if(err == KErrNotFound)
       
  3469 		{
       
  3470 		err = iFile.Create(iFs,KFile,EFileWrite);
       
  3471 		}
       
  3472 	else if(err == KErrPathNotFound)
       
  3473 		{
       
  3474 		err= iFs.MkDirAll(KPath);
       
  3475 		if(err==KErrNone || err== KErrAlreadyExists)
       
  3476 			{
       
  3477 			iFile.Create(iFs,KFile,EFileWrite);
       
  3478 			}
       
  3479 		}
       
  3480 	else
       
  3481     	{
       
  3482     	User::LeaveIfError(err);
       
  3483     	}
       
  3484 	}
       
  3485 
       
  3486 void CAction::RunL()
       
  3487 	{
       
  3488 	switch(iActionState)
       
  3489 		{
       
  3490 		case ESendData:
       
  3491 			iActionState = EReceiveData;
       
  3492 			iControlChannel.Recv ( iCtrlMsg, iStatus );
       
  3493 			SetActive();
       
  3494 			_LIT(KInfoLogFile, "CAction::RunL Send Data.... \n");
       
  3495 			iManager->INFO_PRINTF1(KInfoLogFile);
       
  3496 			break;
       
  3497 		case EReceiveData:
       
  3498 		    TInt err = iFile.Write(iCtrlMsg.MessageDes ());
       
  3499 		    if ( !iCtrlMsg.IsLast () )
       
  3500 		    	{
       
  3501 				iCtrlMsg.ClearFlags();
       
  3502 		    	iControlChannel.Recv ( iCtrlMsg, iStatus );
       
  3503 				SetActive();
       
  3504 				_LIT(KInfoLogFile, "CAction::RunL Receive Data... \n");
       
  3505 				iManager->INFO_PRINTF1(KInfoLogFile);
       
  3506 		    	}
       
  3507 			else
       
  3508 				{
       
  3509 				iControlChannel.Close( );
       
  3510 				CActiveScheduler::Stop();
       
  3511 				_LIT(KInfoLogFile, "CAction::RunL End.... \n");
       
  3512 				iManager->INFO_PRINTF1(KInfoLogFile);
       
  3513 				}
       
  3514 			break;
       
  3515 		}
       
  3516 	}
       
  3517 
       
  3518 void CAction::DoCancel()
       
  3519 	{
       
  3520 	}
       
  3521 
       
  3522 void CAction::InitiateActionControlL(TDesC8& aUri,RPnPServiceDiscovery& aControlPoint)
       
  3523 	{
       
  3524 	RFs fs;
       
  3525     RFile	file;
       
  3526     TInt err;
       
  3527     RBuf8 buf;
       
  3528 	_LIT(KInfoLogFile2, "InitiateActionControlL .... \n");
       
  3529 	iManager->INFO_PRINTF1(KInfoLogFile2);
       
  3530 
       
  3531     User::LeaveIfError(fs.Connect());
       
  3532     CleanupClosePushL(fs);
       
  3533     err = file.Open(fs,_L("z:\\upnp\\testupnp\\client\\testdata\\action.xml"),EFileRead);
       
  3534 	if (err != KErrNone)
       
  3535 	    {
       
  3536 	    User::LeaveIfError(err);
       
  3537 	    }
       
  3538 	CleanupClosePushL(file);
       
  3539 	TInt fileSize = 0;
       
  3540 	file.Size(fileSize);
       
  3541 	buf.Create(fileSize);
       
  3542 	err = file.Read(buf, fileSize);
       
  3543 	err= -1;
       
  3544 	err = aControlPoint.InitiateControl ( iControlChannel, aUri );
       
  3545 	_LIT(KInfoLogFile, "InitiateControl() on Control Point Done with %d.... \n");
       
  3546 	iManager->INFO_PRINTF2(KInfoLogFile,err);
       
  3547 	iCtrlMsg.SetMessageDes ( buf );
       
  3548 	iCtrlMsg.SetLast ();
       
  3549 	TInt newLen = buf.Length();
       
  3550 	iCtrlMsg.SetMaxLength (newLen);
       
  3551 	iControlChannel.Send ( iCtrlMsg, iStatus );
       
  3552 	SetActive();
       
  3553 	CActiveScheduler::Start();
       
  3554 	_LIT(KInfoLogFile1, "InitiateActionControlL End.... \n");
       
  3555 	iManager->INFO_PRINTF1(KInfoLogFile1);
       
  3556 	CleanupStack::PopAndDestroy(2 );
       
  3557 	}
       
  3558