eapol/eapol_framework/eapol_symbian/am/eapvpnif/src/eap_vpn_if_resolver.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2005 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: Standard enrty point for a DLL.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <ecom/ecom.h>
       
    21 #include <ecom/ecomerrorcodes.h>
       
    22 #include <ecom/ecomresolverparams.h>
       
    23 #include <ecom/implementationinformation.h>
       
    24 #include <ecom/publicregistry.h>
       
    25 
       
    26 #include "eap_vpn_if_resolver.h"
       
    27 
       
    28 /// Creates an instance of CEapVpnInterfaceResolver
       
    29 CEapVpnInterfaceResolver* CEapVpnInterfaceResolver::NewL (MPublicRegistry& aRegistry)
       
    30 	{
       
    31 	return new(ELeave) CEapVpnInterfaceResolver (aRegistry);
       
    32 	}
       
    33 
       
    34 // Destructor.
       
    35 CEapVpnInterfaceResolver::~CEapVpnInterfaceResolver()
       
    36 	{
       
    37 	}
       
    38 
       
    39 /// Constructor of CEapVpnInterfaceResolver
       
    40 CEapVpnInterfaceResolver::CEapVpnInterfaceResolver (MPublicRegistry& aRegistry) :
       
    41 	CResolver (aRegistry)
       
    42 	{
       
    43 	}
       
    44 
       
    45 /// This method determines if it can find an appriate implementation
       
    46 /// requested
       
    47 TUid CEapVpnInterfaceResolver::IdentifyImplementationL(TUid aInterfaceUid,
       
    48 	const TEComResolverParams& aAdditionalParameters) const
       
    49 	{
       
    50 	// Aquire a list of implementations for a specific implementation defintion
       
    51 	RImplInfoArray& implementationsInfo = iRegistry.ListImplementationsL (
       
    52 		aInterfaceUid);
       
    53 	TUid found = KNullUid;
       
    54 
       
    55 	if (implementationsInfo.Count())
       
    56 		{
       
    57 		found = Resolve (implementationsInfo, aAdditionalParameters);
       
    58 		}
       
    59 	return found;
       
    60 	}
       
    61 
       
    62 /// This method iterates through a list of RImplInfoArray() objects to
       
    63 /// find the most appropriate implementation.
       
    64 TUid CEapVpnInterfaceResolver::Resolve(const RImplInfoArray& aImplementationsInfo,
       
    65 	const TEComResolverParams& aAdditionalParameters) const
       
    66 	{
       
    67 	const TInt count = aImplementationsInfo.Count();
       
    68 	for (TInt i = 0; i < count; ++i)
       
    69 		{
       
    70 		const CImplementationInformation& impData = *aImplementationsInfo[i];
       
    71 
       
    72 		// Checks each item in the list to see if theres a match.
       
    73 		if (Match (impData.DataType(), aAdditionalParameters.DataType(),
       
    74 			aAdditionalParameters.IsWildcardMatch()))
       
    75 			{
       
    76 			// Returns the Uid of the interface
       
    77 			return impData.ImplementationUid();
       
    78 			}
       
    79 		}
       
    80 
       
    81 	// Nothing found
       
    82 	return KNullUid;
       
    83 	}
       
    84 
       
    85 /// Lists all the implementations of the specified interface definition that
       
    86 /// satisfy the supplied resolution parameters.
       
    87 RImplInfoArray* CEapVpnInterfaceResolver::ListAllL(TUid aInterfaceUid,
       
    88 	const TEComResolverParams& aAdditionalParameters) const
       
    89 	{
       
    90 	RImplInfoArray* retList = new(ELeave) RImplInfoArray;
       
    91 	CleanupStack::PushL (retList);
       
    92 
       
    93 	RImplInfoArray& fullList = iRegistry.ListImplementationsL (aInterfaceUid);
       
    94 
       
    95 	const TBool useWildcards = aAdditionalParameters.IsWildcardMatch();
       
    96 	const TDesC8& matchType = aAdditionalParameters.DataType();
       
    97 	const TInt numImps = fullList.Count();
       
    98 
       
    99 	// Iterates through each item in the list to determine the correct
       
   100 	// interfaces to select.
       
   101 	for (TInt i = 0; i < numImps; ++i)
       
   102 		{
       
   103 		if (Match (fullList[i]->DataType(), matchType, useWildcards))
       
   104 			{
       
   105 			// Adds interface to the list.
       
   106 			User::LeaveIfError (retList->Append (fullList[i]));
       
   107 			}
       
   108 		}
       
   109 
       
   110 	CleanupStack::Pop (retList);
       
   111 
       
   112 	return retList;
       
   113 	}
       
   114 
       
   115 /// The first two parameters is used for comparaison between the two interfaces
       
   116 /// and the third parameter is used to determine the use of wild cards or not.
       
   117 TBool CEapVpnInterfaceResolver::Match(const TDesC8& aImplementationType,
       
   118 	const TDesC8& aMatchType, TBool aUseWildcards) const
       
   119 	{
       
   120 	TInt matchPos = KErrNotFound;
       
   121 
       
   122 	// If wild cards have been set, it will use the correct method to determine
       
   123 	// the correct interface.
       
   124 	if (aUseWildcards)
       
   125 			matchPos = aImplementationType.MatchF (aMatchType);
       
   126 	else
       
   127 			matchPos = aImplementationType.CompareF (aMatchType);
       
   128 
       
   129 	return matchPos != KErrNotFound;
       
   130 	}
       
   131