os/security/contentmgmt/contentaccessfwfordrm/source/caf/agentinfo.h
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 /**
    20  @file
    21  @internalComponent
    22  @released
    23 */
    24 
    25 
    26 #ifndef __AGENTINFO_H__
    27 #define __AGENTINFO_H__
    28 
    29 #include <e32base.h>
    30 
    31 class CImplementationInformation;
    32 
    33 #include <caf/agent.h>
    34 
    35 namespace ContentAccess
    36 	{
    37 	class CAgentFactory;
    38 	class CAgentManager;
    39 
    40 	/**
    41 	 Holds information about a Content Access Agent implementation. 
    42 	
    43 	The metadata is supplied in the agents resource file so the information can be 
    44 	obtained without the need to construct the agent.
    45 	
    46 	The AgentFactoryL() function is used by other CAF classes to access the 
    47 	agent's CAgentFactory implementation.
    48 	
    49 	@internalComponent
    50 	@released
    51 	*/
    52 	class CAgentInfo : public CBase
    53 		{
    54 	public:
    55 		/** 
    56 		Constructs a new CAgentInfo object from an ECOM CImplementationInfo.
    57 		
    58 		@param aImplInfo	An ECOM Implementation from REComSession::ListImplementationsL().
    59 		@return				A new instance of a CAgentInfo object.
    60 		*/
    61 		static CAgentInfo* NewLC(const CImplementationInformation& aImplInfo);
    62 
    63 		virtual ~CAgentInfo();
    64 
    65 		/** 
    66 		Determines whether this agent recognizes the supplier MIME type.
    67 		
    68 		@param aSupplierMime	The supplier MIME type to check.
    69 		@return					ETrue, if the MIME type is a supported supplier MIME type.
    70 		*/
    71 		TBool IsSupportedSupplier(const TDesC8& aSupplierMime) const;
    72 
    73 		/** 
    74 		Determines whether this agent recognizes the consumer MIME type.
    75 		
    76 		@note Scheduled to be removed from the CAF API
    77 		recognizer uses MIME types based upon the content type, not the mime type
    78 		of the file itself. There will be no Consumer MIME types, only modified 
    79 		content types.
    80 		 
    81 		@param aConsumerMime	The consumer mime type to check.
    82 		@return					ETrue, if the MIME type is a supported consumer MIME type.
    83 		*/
    84 		TBool IsSupportedConsumer(const TDesC8& aConsumerMime) const;
    85 
    86 		/** 
    87 		* Exposes the array of supplier MIME types supported by this agent.
    88 		*
    89 		* @return	The array of supplier MIME types.
    90 		*/
    91 		const RPointerArray<HBufC8>& SupplierMimeTypes() const;
    92 
    93 		/** 
    94 		Exposes the array of consumer MIME types supported by this agent.
    95 		
    96 		@note Scheduled to be removed from the CAF API
    97 		recognizer uses MIME types based upon the content type, not the 
    98 		mime type of the file itself. There will be no Consumer mime types, 
    99 		only modified content types.
   100 		
   101 		@return 	A reference to the array of consumer mime types.
   102 		*/
   103 		const RPointerArray<HBufC8>& ConsumerMimeTypes() const;
   104 		
   105 		/** 
   106 		* Gets the preferred buffer size for this agent to recognize 
   107 		* DRM files with the ContentAccess::CAgentResolver::DoRecognize() function.
   108 		*
   109 		* @return	The preferred buffer size.
   110 		*/
   111 		TInt PreferredBufferSize() const;
   112 
   113 		/** The private server directory managed by this agent 
   114 
   115 		This function returns the directory under C:\\private\\ used by this 
   116 		agent. This is specified in the agents resource file in the opaque_data
   117 		field. 
   118 		
   119 		If the agent does not use a private directory the return value will be
   120 		KNullDesC()
   121 
   122 		@return The directory name
   123 		*/
   124 		const TDesC& PrivateDirectoryName() const;
   125 		
   126 		/** The agent 
   127 		
   128 		@return A reference to this agent
   129 		*/
   130 		TAgent& Agent(); 
   131 
   132 		/**
   133 		Accessor for agent factory.
   134 		
   135 		Allows the factory to be constructed once and used many times. 
   136 		DOES NOT transfer ownership of the CAgentFactory to the caller. 
   137 
   138 		@return The CAgentFactory for this particular agent
   139 		*/
   140 		CAgentFactory& AgentFactoryL();
   141 
   142 		/**
   143 		Accessor to the agent manager. 
   144 		
   145 		The agent manager is stateless and this method allows it to be 
   146 		constructed once and used several times. DOES NOT transfer ownership 
   147 		of the CAgentManager to the caller. 
   148 
   149 		@return The CAgentManager for this particular agent
   150 		*/
   151 		CAgentManager& AgentManagerL();
   152 
   153 
   154 	private:
   155 		CAgentInfo();
   156 		void ConstructL(const CImplementationInformation& aImplInfo);
   157 
   158 		// Helper function to parse MIME types of the form:
   159 		// <mime1>,<mime2>,<mime3>
   160 		void ParseMimeTypesL(const TDesC8& aBuf, RPointerArray<HBufC8>& aMimeTypes);
   161 
   162 		// Helper to add descriptor to RPointerArray
   163 		void AddToArrayL(const TDesC8& aElement, RPointerArray<HBufC8>& aArray);
   164 
   165 	private:
   166 		TInt iPreferredBufferSize;
   167 		RPointerArray<HBufC8> iSupplierMimeTypes;
   168 		RPointerArray<HBufC8> iConsumerMimeTypes;
   169 
   170 		CAgentFactory* iAgentFactory;
   171 		CAgentManager* iAgentManager;
   172 
   173 		// Holds the agent name and Implementation UID
   174 		TAgent iAgent;
   175 		
   176 		// Agent private directory is a SID
   177 		TBuf <KMaxSIDLength> iPrivateDirectoryName;
   178 		};
   179 	}
   180 
   181 #endif