xml/xmlfw/src/customresolver/customresolver.cpp
changeset 0 e35f40988205
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 // Copyright (c) 2005-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 // Customized ECOM resolver for XML plugin parsers
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include <e32std.h>
       
    24 #include <ecom/implementationinformation.h>
       
    25 
       
    26 #include <xml/xmlframeworkerrors.h>
       
    27 #include <xml/xmlframeworkconstants.h>
       
    28 #include <xml/matchdata.h>
       
    29 
       
    30 #include "customresolver.h"
       
    31 
       
    32 using namespace Xml;
       
    33 
       
    34 /**
       
    35 Class constructor.
       
    36 
       
    37 @param aRegistry Gives the resolver access to a list of implementations of an interface.
       
    38 */
       
    39 CCustomResolver::CCustomResolver(MPublicRegistry& aRegistry)
       
    40 	:CResolver(aRegistry)
       
    41 {
       
    42 	
       
    43 }
       
    44 
       
    45 /**
       
    46 Creates the instance of CCustomResolver class. 
       
    47 
       
    48 @param aRegistry Gives the resolver access to a list of implementations of an interface.
       
    49 
       
    50 @leave KErrNoMemory If there is not enough memory to create an object
       
    51 */
       
    52 
       
    53 CCustomResolver* CCustomResolver::NewL(MPublicRegistry& aRegistry)
       
    54 {
       
    55 	return new (ELeave) CCustomResolver(aRegistry);
       
    56 }
       
    57 	
       
    58 /**
       
    59 Object destructor.
       
    60 */
       
    61 CCustomResolver::~CCustomResolver()
       
    62 {
       
    63 
       
    64 }
       
    65 
       
    66 /**
       
    67 Identifies required parsers. 
       
    68 
       
    69 @param aInterfaceUid 			Interface UID of required parser
       
    70 @param aAdditionalParameters	Additional parameters for parser resolver 
       
    71 
       
    72 @return Parser's Uid or KNullUid if parser isn't found. 
       
    73 
       
    74 @leave KErrNoMemory 			If there is not enough memory to create 
       
    75 							necessary objects
       
    76 								
       
    77 @leave KErrArgument 			If incorrect or partial information is provided 
       
    78 							for parser resolution
       
    79 								
       
    80 @leave KErrXmlMoreThanOneParserMatched 	
       
    81 							If Xml framework narrowed down the query 
       
    82 							to many parsers and a user requested to leave 
       
    83 							in such case (LeaveOnMany flag set). 
       
    84 								
       
    85 */
       
    86 TUid CCustomResolver::IdentifyImplementationL(TUid aInterfaceUid, const TEComResolverParams& aAdditionalParameters) const
       
    87 	
       
    88 {
       
    89 	// Unpack user matching criteria.
       
    90 	// Externalized CMatchData object is stored in a heap based buffer as a stream. 
       
    91 	// Buffer pointer is stored in data type attribute of aAdditionalParameters
       
    92 	// Specialized NewL method creates a CMatchData object based on that pointer. 
       
    93 	CMatchData* criteria = CMatchData::NewL(aAdditionalParameters.DataType());
       
    94 	CleanupStack::PushL(criteria);
       
    95 	
       
    96 	// Verify input data
       
    97 	// Mime type string is a mandatory field for parser resolution
       
    98 	if (criteria->MimeType().Length() == 0 )
       
    99 		User::Leave(KErrArgument);
       
   100 	
       
   101 	// This method is designed for plugin parser resolution only
       
   102 	if (aInterfaceUid != KParserInterfaceUid)
       
   103 		User::Leave(KErrArgument);
       
   104 	
       
   105 	// Use the CResolver method to create an array, so that we get proper cleanup behaviour
       
   106 	RImplInfoArray& implInfo = CResolver::ListAllL(aInterfaceUid);
       
   107 	
       
   108 	// Run the resolution process
       
   109 	TUid uid = criteria->ResolveL(implInfo);
       
   110 	
       
   111 	//clean up
       
   112 	CleanupStack::PopAndDestroy(criteria);
       
   113 	implInfo.Close();
       
   114 	return uid;
       
   115 }
       
   116  
       
   117  
       
   118 /**
       
   119 The ListAllL method is not supported by this customized resolver.
       
   120 
       
   121 @leave KErrNotSupported 
       
   122 */	
       
   123 RImplInfoArray* CCustomResolver::ListAllL(TUid /*aInterfaceUid*/, const TEComResolverParams& /*aAdditionalParameters */) const
       
   124 {
       
   125 	User::Leave(KErrNotSupported);
       
   126 	return NULL; 
       
   127 }
       
   128