os/security/contentmgmt/contentaccessfwfordrm/source/caf/resolver.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/contentmgmt/contentaccessfwfordrm/source/caf/resolver.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,254 @@
     1.4 +/*
     1.5 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @internalComponent
    1.25 + @released
    1.26 +*/
    1.27 +
    1.28 +
    1.29 +#ifndef __RESOLVER_H__
    1.30 +#define __RESOLVER_H__
    1.31 +
    1.32 +#include <e32std.h>
    1.33 +#include <ecom/ecom.h>
    1.34 +#include <caf/caftypes.h>
    1.35 +
    1.36 +namespace ContentAccess
    1.37 +	{
    1.38 +	const TUid KF32AgentImplUid = { 0x101FC2CF };
    1.39 +
    1.40 +	class CAgentInfo;
    1.41 +	
    1.42 +	/**
    1.43 +	Used to identify the Content Access Agent who handles a particular file.
    1.44 +	 
    1.45 +	CAgentResolver builds an array of CAgentInfo objects. Each CAgentInfo object
    1.46 +	holds metadata related to a particular agent implementation.
    1.47 +
    1.48 +	This class resolves:
    1.49 +	  - Content to the Agent which manages it
    1.50 +	  - Supplier mime-types to the agent which imports files with that mime type.
    1.51 +
    1.52 +	@internalComponent
    1.53 +	@released
    1.54 +	*/
    1.55 +	class CAgentResolver : public CActive
    1.56 +			{
    1.57 +		public:
    1.58 +			/** Constructs a new CAgentResolver and puts it on the cleanup stack
    1.59 +			* @param aDynamicAgentUpdate ETrue if the CAgentResolver should update its list of agents when new agents appear. A CActiveScheduler must already be running when ETrue is supplied
    1.60 +			* @leave KErrCANoAgent If no F32 agent was found
    1.61 +			*/
    1.62 +			IMPORT_C static CAgentResolver* NewLC(const TBool aDynamicAgentUpdate);
    1.63 +
    1.64 +			/** Constructs a new CAgentResolver
    1.65 +			* @param aDynamicAgentUpdate ETrue if the CAgentResolver should update its list of agents when new agents appear. A CActiveScheduler must already be running when ETrue is supplied
    1.66 +			* @leave KErrCANoAgent If no F32 agent was found
    1.67 +			*/
    1.68 +			IMPORT_C static CAgentResolver* NewL(const TBool aDynamicAgentUpdate);
    1.69 +			virtual ~CAgentResolver();
    1.70 +	
    1.71 +			/** Finds the agent that handles the given supplier MIME type.
    1.72 +			
    1.73 +			@param aMimeType	MIME type from the supplier application.
    1.74 +			@return				The CAgentInfo object associated with the agent that handles files with this MIME type.
    1.75 +			 
    1.76 +			@leave KErrCANoAgent	If no CA agent supports the given MIME type. 
    1.77 +			*/
    1.78 +			CAgentInfo& ResolveSupplierMimeL(const TDesC8& aMimeType) const;
    1.79 +			 
    1.80 +			/** Finds the agent that handles the given consumer MIME type.
    1.81 +				
    1.82 +			@note	Planning to remove this from the CAF API
    1.83 +			
    1.84 +			@param aMimeType	MIME type of the file
    1.85 +			@return			The CAgentInfo object associated with the agent that handles files with this MIME type.
    1.86 + 			*/
    1.87 +			CAgentInfo& ResolveConsumerMime(const TDesC8& aMimeType) const;
    1.88 +			
    1.89 +			/** Finds the agent that handles a file.
    1.90 +			
    1.91 +			@param aFile Handle of the file to be resolved.
    1.92 +			@return	The CAgentInfo object associated with the agent that will handle this file.
    1.93 +			*/
    1.94 +			CAgentInfo& ResolveFileL(RFile& aFile) const;			
    1.95 +
    1.96 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
    1.97 +			
    1.98 +			/** Finds the agent which handles this piece of content.
    1.99 +			@param aHeaderData	Header data of WMDRM file or stream content.
   1.100 +			@return				CAgentInfo object associated with the agent that will handle WMDRM content.	
   1.101 +			*/
   1.102 +			CAgentInfo& ResolveFileL(const TDesC8& aHeaderData);
   1.103 +			
   1.104 +#endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   1.105 +						
   1.106 +			/** Finds the agent that handles a file and returns the actual URI of the content.
   1.107 +			
   1.108 +			If the aUri is of the form "c:\\private\\agent_name\\" 
   1.109 +			it will be translated to the form "c:\\private\\SID\\" in
   1.110 +			aActualUri. Otherwise the aUri is just copied to aActualUri
   1.111 +			
   1.112 +			@param aUri	Location of file to be resolved.
   1.113 +			@param aActualUri The actual location of the file
   1.114 +			@param aShareMode The file sharing mode to be used with this file
   1.115 +			@return	The CAgentInfo object associated with the agent that will handle this file.
   1.116 +			*/
   1.117 +			CAgentInfo& ResolveFileL(const TDesC& aUri, TDes& aActualUri, TContentShareMode aShareMode = EContentShareReadOnly) const;
   1.118 +
   1.119 +			/** Find the agent who owns a directory
   1.120 +			
   1.121 +			This function also maps a path from the agent directory name
   1.122 +			to it's actual name in the file system.
   1.123 +			
   1.124 +			ie. For example if an agent "x" has files stored in a private server directory
   1.125 +			"c:\\private\\12345678\\" 
   1.126 +			
   1.127 +			The file appear as "c:\\private\\x\\" to applications using CAF. This function
   1.128 +			converts "c:\\private\\x\\" back to "c:\\private\\12345678\\"
   1.129 +
   1.130 +			@param aPath The path in the form c:\\private\\agent_name\\...
   1.131 +			@param aActualPath The path in the form c:\\private\\SID\\...
   1.132 +			@param aThePrivateDir to ETrue if the directory is just "\\private\\" 
   1.133 +			@return	The Uid of the agent who owns the directory
   1.134 +			*/			
   1.135 +			TUid ResolveDirectory(const TDesC& aPath, TDes& aActualPath, TBool& aThePrivateDir) const;
   1.136 +			
   1.137 +			/** Converts a filename containing the agent SID to the filename containing the agent name.
   1.138 +			@param aFileName The filename in the form "c:\\private\\12345678\\"
   1.139 +			@return A buffer to the new filename in the form "c:\\private\\agent_name\\"
   1.140 +			*/
   1.141 +			HBufC* ConvertAgentFileNameL(const TDesC& aFileName) const;
   1.142 +		
   1.143 +			/** Determines the MIME types of the a file and the mime type of its contents.
   1.144 +
   1.145 +			This function should only be used by the CAF recogizer DLL.
   1.146 +			
   1.147 +			@param aName			The file name/URI to be investigated.
   1.148 +			@param aBuffer			A buffer containing bytes from the start of the file.
   1.149 +			@param aFileMimeType	If the file is recognized this will be populated with 
   1.150 +									the mime type of the file.
   1.151 +			@param aContentMimeType	If the file is recognized this will be populated with the mime type of the content object within the file. 
   1.152 +
   1.153 +			@return					ETrue if the file is recognized by content access agent
   1.154 +			@return					EFalse if the file is not recognized by a content access agent
   1.155 +			*/
   1.156 +			IMPORT_C TBool DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer, TDes8& aFileMimeType, TDes8& aContentMimeType);
   1.157 +	
   1.158 +			/** Gets the preferred buffer size for recognizing files using the RecognizeFile() function.
   1.159 +			
   1.160 +			This function should only be used by the CAF recogizer DLL.  
   1.161 +
   1.162 +			@return	The largest preferred buffer nominated by any agent for recognizing files using the the DoRecognize() function.
   1.163 +			*/
   1.164 +			IMPORT_C TInt PreferredBufferSize();
   1.165 +		
   1.166 +			/** Accessor for the SupplierMimeTypes array.
   1.167 +			*
   1.168 +			* @return	An array of supplier MIME type supported by CAF agents.
   1.169 +			*/
   1.170 +			IMPORT_C const RArray<TPtrC8>& SupplierMimeTypes() const;
   1.171 +
   1.172 +			/** Accessor for the ConsumerMimeTypes array.
   1.173 +			*
   1.174 +			* @note	Planning to remove this from the CAF API
   1.175 +			*
   1.176 +			* @return	An array of consumer MIME types supported by CAF agents.
   1.177 +			*/
   1.178 +			IMPORT_C const RArray<TPtrC8>& ConsumerMimeTypes() const;
   1.179 +
   1.180 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT			
   1.181 +			/** This function should only be used by the CAF recogizer DLL.
   1.182 +			
   1.183 +			@param aHeader			Header data of WMDRM content.
   1.184 +			@param aFileMimeType	If the content is recognized this will be populated with 
   1.185 +									the mime type of the content.
   1.186 +			@param aContentMimeType	If the content is recognized this will be populated with the mime type of the content. 
   1.187 +
   1.188 +			@return					ETrue if the content is recognized by content access agent
   1.189 +			@return					EFalse if the content is not recognized by a content access agent
   1.190 +			*/
   1.191 +			IMPORT_C TBool DoRecognizeL(const TDesC8& aHeader, TDes8& aFileMimeType, TDes8& aContentMimeType);
   1.192 +#endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT	
   1.193 +
   1.194 +			/** Find an agent by it's Uid */
   1.195 +			CAgentInfo& AgentInfoL(const TUid& aUid) const;
   1.196 +			
   1.197 +			/** Find an agent by it's name */
   1.198 +			CAgentInfo& AgentInfoL(const TDesC& aAgentName) const;
   1.199 +			
   1.200 +			/** Reference an agent in the iAgentInfos array by index */
   1.201 +			CAgentInfo& AgentInfo(TInt aIndex) const;
   1.202 +			
   1.203 +			/** The number of agents, excluding the F32Agent */
   1.204 +			 TInt AgentInfoCount() const;
   1.205 +			
   1.206 +			/** The default F32 agent */
   1.207 +			TUid DefaultAgentUid() const;
   1.208 +
   1.209 +		private:
   1.210 +			// From CActive, used for dynamically updating the list of content access agents
   1.211 +			virtual void DoCancel();
   1.212 +			virtual void RunL();
   1.213 +		
   1.214 +		private:
   1.215 +			CAgentResolver(const TBool aDynamicAgentUpdate);
   1.216 +			
   1.217 +			/** Second phase constructor for CAgentResolver
   1.218 +			*/
   1.219 +			void ConstructL();
   1.220 +
   1.221 +
   1.222 +			/** Builds a list of all the Content Access Agents. */
   1.223 +			void BuildListOfAgentsL();
   1.224 +			
   1.225 +			/** Add an agent to the list of agents */
   1.226 +			void AddAgentL(const CImplementationInformation& aImplInfo);
   1.227 +
   1.228 +			/** Resets the list. */
   1.229 +			void DestroyListOfAgents();
   1.230 +
   1.231 +			/** Is this the F32 Agent 
   1.232 +			@param aAgentInfo The agentinfo representing the agent
   1.233 +			@return ETrue if it is the F32Agent, EFalse otherwise
   1.234 +			*/
   1.235 +			TBool IsF32Agent(CAgentInfo& aAgentInfo);
   1.236 +
   1.237 +			// Cleanup item
   1.238 +			static void CleanImplArray(TAny* aArray);
   1.239 +
   1.240 +		private:
   1.241 +			const TBool iDynamicAgentUpdate;
   1.242 +			REComSession* iEcomSession;
   1.243 +
   1.244 +			RArray<TPtrC8> iSupplierMimeTypes;
   1.245 +			RArray<TPtrC8> iConsumerMimeTypes;
   1.246 +	
   1.247 +			// Array of agentInfos (not including F32 agent)
   1.248 +			RPointerArray <CAgentInfo> iAgentInfos;
   1.249 +
   1.250 +			// This points to the agent which handles content if it is not
   1.251 +			// recognised by any other agent (this should be the F32Agent)
   1.252 +			CAgentInfo* iDefaultAgent;
   1.253 +			};
   1.254 +
   1.255 +	} // namespace ContentAccess
   1.256 +#endif /* __RESOLVER_H__ */
   1.257 +