os/security/contentmgmt/contentaccessfwfordrm/source/caf/resolver.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include <e32debug.h>
    20 #include <ecom/ecom.h>
    21 
    22 #include "resolver.h"
    23 #include <caf/agentfactory.h>
    24 #include <caf/agentinterface.h>
    25 #include "agentinfo.h"
    26 #include <caf/agent.h>
    27 #include <caf/cafpanic.h>
    28 #include <caf/caferr.h>
    29 #include <caf/patchdata.h>
    30 
    31 
    32 using namespace ContentAccess;
    33 
    34 // Constants for the F32 agent
    35 _LIT(KF32Agent,"F32 CA Agent");
    36 
    37 
    38 _LIT(KParentDir, "..\\");
    39 _LIT(KPrivateDir, "\\private\\");
    40 const TInt KPrivateDirLength = 9;   // "\\private\\"
    41 const TInt KPrivateDirAndDriveLength = 11;   // "x:\\private\\"
    42 const TInt KPrivateDirOffset = 2; // "x:\\"
    43 
    44 
    45 EXPORT_C CAgentResolver* CAgentResolver::NewLC(const TBool aDynamicAgentUpdate)
    46 	{
    47 	CAgentResolver* self = new (ELeave) CAgentResolver(aDynamicAgentUpdate);
    48 	CleanupStack::PushL(self);
    49 	self->ConstructL();
    50 	return self;
    51 	}
    52 
    53 EXPORT_C CAgentResolver* CAgentResolver::NewL(const TBool aDynamicAgentUpdate)
    54 	{
    55 	CAgentResolver* self = CAgentResolver::NewLC(aDynamicAgentUpdate);
    56 	CleanupStack::Pop(self);
    57 	return self;
    58 	}
    59 
    60 CAgentResolver::CAgentResolver(const TBool aDynamicAgentUpdate) : CActive(EPriorityStandard), iDynamicAgentUpdate(aDynamicAgentUpdate)
    61 	{
    62 	}
    63 
    64 CAgentResolver::~CAgentResolver()
    65 	{
    66 	// remove ourselves from the ActiveScheduler
    67 	if(IsAdded())
    68 		{
    69 		Deque();
    70 		}
    71 	
    72 	// Unload all the agents
    73 	DestroyListOfAgents();
    74 	
    75 	// Close our ECOM session
    76 	if(iEcomSession)
    77 		{
    78 		if(iDynamicAgentUpdate)
    79 			{
    80 			iEcomSession->CancelNotifyOnChange(iStatus);
    81 			}
    82 		iEcomSession->Close();
    83 		REComSession::FinalClose();
    84 		}
    85 
    86 	iSupplierMimeTypes.Close();
    87 	iConsumerMimeTypes.Close();
    88 	iAgentInfos.Close();
    89 	}
    90 
    91 void CAgentResolver::ConstructL()
    92 	{
    93 	if(iDynamicAgentUpdate)
    94 		{
    95 		// Add ourselves to the current active scheduler so we can get dynamic 
    96 		// updates when agents are removed or new agents are added
    97 		CActiveScheduler::Add(this);
    98 		}
    99 
   100 	iEcomSession = &REComSession::OpenL();
   101 	
   102 	// find all the agents
   103 	BuildListOfAgentsL();
   104 
   105 	if(iDynamicAgentUpdate)
   106 		{
   107 		// register for ECOM update notifications in case a new agent appears
   108 		SetActive();
   109 		iEcomSession->NotifyOnChange(iStatus);
   110 		}
   111 	}
   112 
   113 void CAgentResolver::BuildListOfAgentsL()
   114 	{
   115 	TInt err = KErrNone;
   116 
   117 	// Get all plugins which implement the agent interface
   118 	RImplInfoPtrArray implArray;
   119 	CleanupStack::PushL(TCleanupItem(CleanImplArray, &implArray));
   120 	REComSession::ListImplementationsL(KCAAgentInterfaceUid, implArray);
   121 
   122 	for (TInt i = 0; i < implArray.Count(); ++i)
   123 		{
   124 #ifdef __EPOC32__
   125 		// On hardware - to load agents from sources other than ROM the patch 
   126 		// data KCafLoadPostProductionAgents must be set to True (non-zero).
   127 		// Default SymbianOS behavior is to only load agents from ROM
   128 		if ((KCafLoadPostProductionAgents == 0) &&
   129             !implArray[i]->RomBased())
   130 			{
   131 			// If the agent is not in ROM, don't load it because it might
   132 			// be a security risk.
   133 			continue;
   134 			}
   135 #endif
   136 
   137 		// Construct all the agent infos from these implementations
   138 		TRAP(err, AddAgentL(*implArray[i]));
   139 
   140 		// If we ran out of memory proagate the leave to the caller
   141 		// otherwise don't let a dodgy agent affect the construction of the other
   142 		// agents
   143 		if(err == KErrNoMemory)
   144 			{
   145 			User::Leave(KErrNoMemory);
   146 			}
   147 		}
   148 	CleanupStack::PopAndDestroy(&implArray);  
   149 
   150 
   151 	if (!iDefaultAgent)
   152 		{
   153 		// If we didn't find a default agent, we have a big problem so panic
   154 		User::Panic(KCafPanicString, ECafPanicNoF32Agent);
   155 		}
   156 	}
   157 
   158 void CAgentResolver::AddAgentL(const CImplementationInformation& aImplInfo)
   159 	{
   160 	// Create a CAgentInfo instance
   161 	CAgentInfo* agentInfo = CAgentInfo::NewLC(aImplInfo);
   162 
   163 
   164 	if(IsF32Agent(*agentInfo))
   165 		{
   166 		// It's the F32 Agent
   167 		if(iDefaultAgent)
   168 			{
   169 			// If we already have a default agent something is seriously wrong
   170 			User::Panic(KCafPanicString, ECafPanicDuplicateF32Agent);
   171 			}
   172 
   173 		// Note that the default agent is NOT stored in the agents list, it is a special case
   174 		iDefaultAgent = agentInfo;
   175 		CleanupStack::Pop(agentInfo);
   176 		}
   177 	else
   178 		{
   179 		// All other agents go in the agent list
   180 		User::LeaveIfError(iAgentInfos.Append(agentInfo));
   181 		CleanupStack::Pop(agentInfo);
   182 
   183 		TInt mimeIndex=0;
   184 
   185 		// Update our list of all supplier mime types supported by CAF
   186 		for(mimeIndex=0;mimeIndex < agentInfo->SupplierMimeTypes().Count(); mimeIndex++) 
   187 			{
   188 			User::LeaveIfError(iSupplierMimeTypes.Append(*agentInfo->SupplierMimeTypes()[mimeIndex]));
   189 			}
   190 
   191 		// Update our list of all consumer mime types supported by CAF
   192 		for(mimeIndex=0;mimeIndex < agentInfo->ConsumerMimeTypes().Count(); mimeIndex++) 
   193 			{
   194 			User::LeaveIfError(iConsumerMimeTypes.Append(*agentInfo->ConsumerMimeTypes()[mimeIndex]));
   195 			}
   196 		}
   197 	}
   198 
   199 void CAgentResolver::DestroyListOfAgents()
   200 	{
   201 	iSupplierMimeTypes.Reset();
   202 	iConsumerMimeTypes.Reset();
   203 
   204 	// cant forget to delete the default agent
   205 	delete iDefaultAgent;
   206 	iDefaultAgent = NULL;
   207 
   208 	// Free memory assocated with the iAgentInfos array 
   209 	iAgentInfos.ResetAndDestroy();
   210 	}
   211 
   212 void CAgentResolver::DoCancel()
   213 	{
   214 	// Abort any update notification 
   215 	iEcomSession->CancelNotifyOnChange(iStatus);
   216 	}
   217 
   218 void CAgentResolver::RunL()
   219 	{
   220 	// Called by the ECOM framework if a new agent appears
   221 
   222 	// remove the existing list of agents and build a new one
   223 	DestroyListOfAgents();
   224 	BuildListOfAgentsL();
   225 
   226 	// request notification of any further changes
   227 	iEcomSession->NotifyOnChange(iStatus);
   228 	SetActive();
   229 	}	
   230 
   231 TBool CAgentResolver::IsF32Agent(CAgentInfo& aAgentInfo)
   232 	{
   233 	// Check if the agent has no consumer or supplier mime types
   234 	// and that it has the correct name and Uid
   235 	if (aAgentInfo.Agent().ImplementationUid() == KF32AgentImplUid
   236 		&& aAgentInfo.Agent().Name().Compare(KF32Agent()) == 0 
   237 		&& aAgentInfo.ConsumerMimeTypes().Count() == 0 
   238 		&& aAgentInfo.SupplierMimeTypes().Count() == 0)
   239 		{
   240 		return ETrue;
   241 		}
   242 	else
   243 		{
   244 		return EFalse;
   245 		}
   246 	}
   247 
   248 CAgentInfo& CAgentResolver::ResolveSupplierMimeL(const TDesC8& aMimeType) const
   249 	{
   250 	// Go through all the agents and return the one which supports the
   251 	// required supplier mime type
   252 	CAgentInfo* retVal=NULL;
   253 
   254 	for (TInt i = 0; i < iAgentInfos.Count(); ++i)
   255 		{
   256 		if (iAgentInfos[i]->IsSupportedSupplier(aMimeType))
   257 			{
   258 			retVal = iAgentInfos[i];
   259 			break;
   260 			}
   261 		}
   262 	
   263 	if (!retVal)
   264 		{
   265 		User::Leave(KErrCANoAgent);
   266 		}
   267 	return *retVal;
   268 	}
   269 
   270 CAgentInfo& CAgentResolver::ResolveConsumerMime(const TDesC8& aMimeType) const
   271 	{
   272 	// By default, set the return value to be the default agent. If we find
   273 	// anything better, then we change it
   274 	CAgentInfo* retVal = iDefaultAgent;
   275 
   276 	for (TInt i = 0; i < iAgentInfos.Count(); ++i)
   277 		{
   278 		if (iAgentInfos[i]->IsSupportedConsumer(aMimeType))
   279 			{
   280 			retVal = iAgentInfos[i];
   281 			break;
   282 			}
   283 		}
   284 
   285 	ASSERT(retVal);
   286 	return *retVal;
   287 	}
   288 
   289 CAgentInfo& CAgentResolver::ResolveFileL(const TDesC& aURI, TDes& aActualUri, TContentShareMode aShareMode) const
   290 	{
   291 	// Go through all the agents and return the one which supports the file at the given URI	
   292 	TBool thePrivateDir = EFalse;	
   293 	TUid agentUid = ResolveDirectory(aURI, aActualUri, thePrivateDir);
   294 	
   295 	if(agentUid != iDefaultAgent->Agent().ImplementationUid())
   296 		{
   297 		// this file must be living in a private server directory
   298 		// return the agent who owns the directory
   299 		return AgentInfoL(agentUid);
   300 		}
   301 	else
   302 		{
   303 		TInt agentsCount(iAgentInfos.Count());
   304 		CAgentManager* agentManager = NULL;
   305 		for (TInt i = 0; i < agentsCount; ++i)
   306 			{
   307 			TRAPD(result, agentManager = &iAgentInfos[i]->AgentManagerL());
   308 			if(result != KErrNone)
   309 				{
   310 				if(KErrNoMemory == result)
   311 					{
   312 					User::Leave(result);
   313 					}
   314 				else
   315 					{
   316 					continue;	
   317 					}
   318 				}
   319 			if (agentManager->IsRecognizedL(aURI, aShareMode))
   320 				{
   321 				return *iAgentInfos[i];
   322 				}
   323 			}
   324 		}
   325 	return *iDefaultAgent;
   326 	}
   327 
   328 CAgentInfo& CAgentResolver::ResolveFileL(RFile& aFile) const
   329 	{
   330 	// Go through all the agents and return the one which supports the file
   331 
   332 	TInt agentsCount(iAgentInfos.Count());
   333 	CAgentManager* agentManager = NULL;
   334 	for (TInt i = 0; i < agentsCount; ++i)
   335 		{
   336 		TRAPD(result, agentManager = &iAgentInfos[i]->AgentManagerL());
   337 		if(result != KErrNone)
   338 			{
   339 			if(KErrNoMemory == result)
   340 				{
   341 				User::Leave(result);
   342 				}
   343 			else
   344 				{
   345 				continue;	
   346 				}
   347 			}
   348 		if (agentManager->IsRecognizedL(aFile))
   349 			{
   350 			return *iAgentInfos[i];
   351 			}
   352 		}
   353 	return *iDefaultAgent;
   354 	}
   355 
   356 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   357 
   358 CAgentInfo& CAgentResolver::ResolveFileL(const TDesC8& aHeaderData)
   359 	{
   360 	// Go through all the agents and return the one which supports the given WMDRM content.
   361 	
   362 	TInt agentsCount(iAgentInfos.Count());
   363 	CAgentManager* agentManager = NULL;
   364 	
   365 	for (TInt i = 0; i < agentsCount; ++i)
   366 		{
   367 		TRAPD(result, agentManager = &iAgentInfos[i]->AgentManagerL());
   368 		if(result != KErrNone)
   369 			{
   370 			if(KErrNoMemory == result)
   371 				{
   372 				User::Leave(result);
   373 				}
   374 			else
   375 				{
   376 				continue;	
   377 				}
   378 			}
   379 			
   380 		if (agentManager->IsRecognizedL(aHeaderData))
   381 			{
   382 			return *iAgentInfos[i];
   383 			}
   384 		}
   385 		
   386     // will never reach here	
   387 	return *iDefaultAgent;
   388 	}
   389 	
   390 	
   391 EXPORT_C TBool CAgentResolver::DoRecognizeL(const TDesC8& aHeader, TDes8& aFileMimeType, TDes8& aContentMimeType)
   392 	{
   393 	// Go through all the agents and return the one which supports the given WMDRM content.
   394 	TInt agentsCount(iAgentInfos.Count());
   395 	CAgentManager* agentManager = NULL;
   396 	for (TInt i = 0; i < agentsCount; ++i)
   397 		{
   398 		TRAPD(result, agentManager = &iAgentInfos[i]->AgentManagerL());
   399 		if(result != KErrNone)
   400 			{
   401 			if(KErrNoMemory == result)
   402 				{
   403 				User::Leave(result);
   404 				}
   405 			else
   406 				{
   407 				continue;	
   408 				}
   409 			}
   410 			
   411 		if (agentManager->RecognizeContentL(aHeader, aFileMimeType, aContentMimeType))
   412 			{
   413 			// force to lower case to ensure that chosen lower case scheme for mime types is maintained
   414 			aFileMimeType.LowerCase();
   415 			aContentMimeType.LowerCase();			
   416 			return ETrue;
   417 			}
   418 		}
   419 		
   420 	return EFalse;
   421 	}
   422 	
   423 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   424 	
   425 TUid CAgentResolver::ResolveDirectory(const TDesC& aPath, TDes& aActualPath, TBool& aThePrivateDir) const
   426 	{
   427 	TInt i = 0;
   428 	TInt pathLength = 0;
   429 	TBuf <KPrivateDirAndDriveLength> pathLowerCase;
   430 	
   431 	// Assume it's a publicly accessable path
   432 	aThePrivateDir = EFalse;
   433 	
   434 	// Find the length of the path and private directory
   435 	pathLength = aPath.Length();
   436 
   437 	// Check that the path is long enough to be within a private directory
   438 	// and does not include "..\\".The  "..\\" sequence could be a security risk
   439 	if(aPath.Find(KParentDir()) == KErrNotFound && pathLength >= KPrivateDirAndDriveLength)
   440 		{
   441 		// Create a lower case copy of the left hand side of the path
   442 		TPtrC lowerCasePtr = aPath.Mid(KPrivateDirOffset, KPrivateDirLength);
   443 		pathLowerCase.Copy(lowerCasePtr);
   444 		pathLowerCase.LowerCase();
   445 	
   446 		// Compare the first directory in the path to \\private\\ 
   447 		if(KPrivateDir() == pathLowerCase)
   448 			{
   449 			// It is a private directory of some sort
   450 			if(pathLength > KPrivateDirAndDriveLength)
   451 				{
   452 				// It must be a server private directory data cage
   453 				TPtrC serverDirectoryPath = aPath.Right(pathLength - KPrivateDirAndDriveLength);
   454 				for(i = 0; i < AgentInfoCount(); i++)
   455 					{
   456 					// See if the part after \\private\\ matches the agent name
   457 					TPtrC privateDirectoryName = AgentInfo(i).PrivateDirectoryName();
   458 					TPtrC agentName = AgentInfo(i).Agent().Name();
   459 					if(privateDirectoryName.Length() && agentName.Length() && agentName == serverDirectoryPath.Left(agentName.Length()))
   460 						{
   461 						// It must be this agent's private directory
   462 						// Convert \\private\\agentName\\... to \\private\\SID\\...
   463 						aActualPath.Copy(aPath.Left(KPrivateDirAndDriveLength));
   464 						aActualPath.Append(privateDirectoryName);
   465 						aActualPath.Append(aPath.Right(pathLength - KPrivateDirAndDriveLength - agentName.Length()));
   466 						return AgentInfo(i).Agent().ImplementationUid();
   467 						}
   468 					}
   469 				}
   470 			else
   471 				{
   472 				// It's just the c:\\private\\ directory
   473 				// Use the default agent, any calls will just fail
   474 				aThePrivateDir = ETrue;
   475 				}
   476 			}
   477 		}
   478 	
   479 	// Not an agent private directory so just return the default agent
   480 	aActualPath.Copy(aPath);
   481 	return iDefaultAgent->Agent().ImplementationUid();
   482 	}
   483 
   484 HBufC* CAgentResolver::ConvertAgentFileNameL(const TDesC& aFileName) const
   485 	{
   486 	TInt i = 0;
   487 	TInt fileNameLength = 0;
   488 	TBuf <KPrivateDirAndDriveLength> pathLowerCase;
   489 	
   490 	fileNameLength = aFileName.Length();
   491 	
   492 	// If the path is shorter than the x:\\private\\ it must be a F32 file
   493 	if(fileNameLength  > KPrivateDirAndDriveLength)
   494 		{
   495 		// Create a lower case copy of the left hand side of the path
   496 		TPtrC lowerCasePtr = aFileName.Mid(KPrivateDirOffset, KPrivateDirLength);
   497 		pathLowerCase.Copy(lowerCasePtr);
   498 		pathLowerCase.LowerCase();
   499 	
   500 		// Compare the first directory in the path to \\private\\ 
   501 		if(KPrivateDir() == pathLowerCase)
   502 			{
   503 			// It is a private directory of some sort
   504 			if(fileNameLength > KPrivateDirAndDriveLength)
   505 				{
   506 				// It must be a server private directory data cage
   507 				TPtrC serverDirectoryPath = aFileName.Right(fileNameLength - KPrivateDirAndDriveLength);
   508 				for(i = 0; i < AgentInfoCount(); i++)
   509 					{
   510 					// See if the part after \\private\\ matches the agent name
   511 					TPtrC privateDirectoryName = AgentInfo(i).PrivateDirectoryName();
   512 					TPtrC agentName = AgentInfo(i).Agent().Name();
   513 					if(privateDirectoryName.Length() && agentName.Length() && privateDirectoryName == serverDirectoryPath.Left(privateDirectoryName.Length()))
   514 						{
   515 						// It is this agent's private directory
   516 						// Convert \\private\\SID\\... \\private\\agentName\\... 
   517 						HBufC* buffer = HBufC::NewL(fileNameLength - privateDirectoryName.Length() + agentName.Length());
   518 						TPtr ptr = buffer->Des();
   519 						ptr.Copy(aFileName.Left(KPrivateDirAndDriveLength));
   520 						ptr.Append(agentName);
   521 						ptr.Append(aFileName.Right(fileNameLength - KPrivateDirAndDriveLength - privateDirectoryName.Length()));
   522 						return buffer;
   523 						}
   524 					}
   525 				}
   526 			}
   527 		}
   528 	return aFileName.AllocL();
   529 	}
   530 
   531 EXPORT_C TBool CAgentResolver::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer, TDes8& aFileMimeType, TDes8& aContentMimeType)
   532 	{
   533 
   534 	// Given the filename and buffer from apparc, ask the agents in turn if they recognize the file
   535 	// Note this will not call the DefaultAgent (F32) because it won't be able to recognize anything
   536 
   537 	TInt agentsCount(iAgentInfos.Count());
   538 	CAgentManager* agentManager = NULL;
   539 	for (TInt i = 0; i < agentsCount; ++i)
   540 		{
   541 		TRAPD(result, agentManager = &iAgentInfos[i]->AgentManagerL());
   542 		if(result != KErrNone)
   543 			{
   544 			if(KErrNoMemory == result)
   545 				{
   546 				User::Leave(result);
   547 				}
   548 			else
   549 				{
   550 				continue;	
   551 				}
   552 			}
   553 		if (agentManager->RecognizeFileL(aName, aBuffer, aFileMimeType, aContentMimeType))
   554 			{
   555 			// force to lower case to ensure that chosen lower case scheme for mime types is maintained
   556 			aFileMimeType.LowerCase();
   557 			aContentMimeType.LowerCase();			
   558 			return ETrue;
   559 			}
   560 		}
   561 	return EFalse;
   562 	}
   563 	
   564 
   565 void CAgentResolver::CleanImplArray(TAny* aArray)
   566 	{
   567 	static_cast<RImplInfoPtrArray*>(aArray)->ResetAndDestroy();
   568 	}
   569 
   570 EXPORT_C TInt CAgentResolver::PreferredBufferSize()
   571 	{
   572 	TInt size=0;
   573 
   574 	if(iDefaultAgent != NULL)
   575 		{
   576 		size = iDefaultAgent->PreferredBufferSize();
   577 		}
   578 
   579 	// Find out the maximum buffer requested by any agent
   580 	for (TInt i = 0; i < iAgentInfos.Count(); ++i)
   581 			{
   582 			if(iAgentInfos[i]->PreferredBufferSize() > size)
   583 				{
   584 				size = iAgentInfos[i]->PreferredBufferSize();
   585 				}
   586 			}
   587 	return size;
   588 	}
   589 
   590 
   591 EXPORT_C const RArray<TPtrC8>& CAgentResolver::ConsumerMimeTypes() const
   592 	{
   593 	return iConsumerMimeTypes;
   594 	}
   595 
   596 
   597 EXPORT_C const RArray<TPtrC8>& CAgentResolver::SupplierMimeTypes() const
   598 	{
   599 	return iSupplierMimeTypes;
   600 	}
   601 
   602 
   603 CAgentInfo& CAgentResolver::AgentInfoL(const TDesC& aAgentName) const
   604 	{
   605 	TBool found = EFalse;
   606 	TInt i = 0;
   607 	for(i = 0; i < iAgentInfos.Count(); i++)
   608 		{
   609 		if(iAgentInfos[i]->Agent().Name() == aAgentName)
   610 			{
   611 			found = ETrue;
   612 			break;
   613 			}
   614 		}
   615 	
   616 	if(!found)
   617 		{
   618 		// Can't find the agent so leave
   619 		User::Leave(KErrNotFound);
   620 		}
   621 	
   622 	return *iAgentInfos[i];
   623 	}
   624 
   625 CAgentInfo& CAgentResolver::AgentInfoL(const TUid& aUid) const
   626 	{
   627 	TInt i = 0;
   628 	TBool found = EFalse;
   629 	
   630 	// See if it's the F32 agent
   631 	if(aUid == DefaultAgentUid())
   632 		{
   633 		return *iDefaultAgent;
   634 		}
   635 	
   636 	for(i = 0; i < iAgentInfos.Count(); i++)
   637 		{
   638 		if(iAgentInfos[i]->Agent().ImplementationUid() == aUid)
   639 			{
   640 			found = ETrue;
   641 			break;			
   642 			}
   643 		}
   644 	
   645 	if(!found)
   646 		{
   647 		// couldn't find the agent so leave
   648 		User::Leave(KErrNotFound);
   649 		}
   650 	
   651 	return *iAgentInfos[i];
   652 	}
   653 
   654 CAgentInfo& CAgentResolver::AgentInfo(TInt aIndex) const
   655 		{
   656 		return *iAgentInfos[aIndex];		
   657 		}
   658 
   659 TInt CAgentResolver::AgentInfoCount() const
   660 	{
   661 	return iAgentInfos.Count();	
   662 	}
   663 
   664 TUid CAgentResolver::DefaultAgentUid() const
   665 	{
   666 	return iDefaultAgent->Agent().ImplementationUid();
   667 	}