First public contribution.
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
26 #ifndef __RESOLVER_H__
27 #define __RESOLVER_H__
30 #include <ecom/ecom.h>
31 #include <caf/caftypes.h>
33 namespace ContentAccess
35 const TUid KF32AgentImplUid = { 0x101FC2CF };
40 Used to identify the Content Access Agent who handles a particular file.
42 CAgentResolver builds an array of CAgentInfo objects. Each CAgentInfo object
43 holds metadata related to a particular agent implementation.
46 - Content to the Agent which manages it
47 - Supplier mime-types to the agent which imports files with that mime type.
52 class CAgentResolver : public CActive
55 /** Constructs a new CAgentResolver and puts it on the cleanup stack
56 * @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
57 * @leave KErrCANoAgent If no F32 agent was found
59 IMPORT_C static CAgentResolver* NewLC(const TBool aDynamicAgentUpdate);
61 /** Constructs a new CAgentResolver
62 * @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
63 * @leave KErrCANoAgent If no F32 agent was found
65 IMPORT_C static CAgentResolver* NewL(const TBool aDynamicAgentUpdate);
66 virtual ~CAgentResolver();
68 /** Finds the agent that handles the given supplier MIME type.
70 @param aMimeType MIME type from the supplier application.
71 @return The CAgentInfo object associated with the agent that handles files with this MIME type.
73 @leave KErrCANoAgent If no CA agent supports the given MIME type.
75 CAgentInfo& ResolveSupplierMimeL(const TDesC8& aMimeType) const;
77 /** Finds the agent that handles the given consumer MIME type.
79 @note Planning to remove this from the CAF API
81 @param aMimeType MIME type of the file
82 @return The CAgentInfo object associated with the agent that handles files with this MIME type.
84 CAgentInfo& ResolveConsumerMime(const TDesC8& aMimeType) const;
86 /** Finds the agent that handles a file.
88 @param aFile Handle of the file to be resolved.
89 @return The CAgentInfo object associated with the agent that will handle this file.
91 CAgentInfo& ResolveFileL(RFile& aFile) const;
93 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
95 /** Finds the agent which handles this piece of content.
96 @param aHeaderData Header data of WMDRM file or stream content.
97 @return CAgentInfo object associated with the agent that will handle WMDRM content.
99 CAgentInfo& ResolveFileL(const TDesC8& aHeaderData);
101 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
103 /** Finds the agent that handles a file and returns the actual URI of the content.
105 If the aUri is of the form "c:\\private\\agent_name\\"
106 it will be translated to the form "c:\\private\\SID\\" in
107 aActualUri. Otherwise the aUri is just copied to aActualUri
109 @param aUri Location of file to be resolved.
110 @param aActualUri The actual location of the file
111 @param aShareMode The file sharing mode to be used with this file
112 @return The CAgentInfo object associated with the agent that will handle this file.
114 CAgentInfo& ResolveFileL(const TDesC& aUri, TDes& aActualUri, TContentShareMode aShareMode = EContentShareReadOnly) const;
116 /** Find the agent who owns a directory
118 This function also maps a path from the agent directory name
119 to it's actual name in the file system.
121 ie. For example if an agent "x" has files stored in a private server directory
122 "c:\\private\\12345678\\"
124 The file appear as "c:\\private\\x\\" to applications using CAF. This function
125 converts "c:\\private\\x\\" back to "c:\\private\\12345678\\"
127 @param aPath The path in the form c:\\private\\agent_name\\...
128 @param aActualPath The path in the form c:\\private\\SID\\...
129 @param aThePrivateDir to ETrue if the directory is just "\\private\\"
130 @return The Uid of the agent who owns the directory
132 TUid ResolveDirectory(const TDesC& aPath, TDes& aActualPath, TBool& aThePrivateDir) const;
134 /** Converts a filename containing the agent SID to the filename containing the agent name.
135 @param aFileName The filename in the form "c:\\private\\12345678\\"
136 @return A buffer to the new filename in the form "c:\\private\\agent_name\\"
138 HBufC* ConvertAgentFileNameL(const TDesC& aFileName) const;
140 /** Determines the MIME types of the a file and the mime type of its contents.
142 This function should only be used by the CAF recogizer DLL.
144 @param aName The file name/URI to be investigated.
145 @param aBuffer A buffer containing bytes from the start of the file.
146 @param aFileMimeType If the file is recognized this will be populated with
147 the mime type of the file.
148 @param aContentMimeType If the file is recognized this will be populated with the mime type of the content object within the file.
150 @return ETrue if the file is recognized by content access agent
151 @return EFalse if the file is not recognized by a content access agent
153 IMPORT_C TBool DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer, TDes8& aFileMimeType, TDes8& aContentMimeType);
155 /** Gets the preferred buffer size for recognizing files using the RecognizeFile() function.
157 This function should only be used by the CAF recogizer DLL.
159 @return The largest preferred buffer nominated by any agent for recognizing files using the the DoRecognize() function.
161 IMPORT_C TInt PreferredBufferSize();
163 /** Accessor for the SupplierMimeTypes array.
165 * @return An array of supplier MIME type supported by CAF agents.
167 IMPORT_C const RArray<TPtrC8>& SupplierMimeTypes() const;
169 /** Accessor for the ConsumerMimeTypes array.
171 * @note Planning to remove this from the CAF API
173 * @return An array of consumer MIME types supported by CAF agents.
175 IMPORT_C const RArray<TPtrC8>& ConsumerMimeTypes() const;
177 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
178 /** This function should only be used by the CAF recogizer DLL.
180 @param aHeader Header data of WMDRM content.
181 @param aFileMimeType If the content is recognized this will be populated with
182 the mime type of the content.
183 @param aContentMimeType If the content is recognized this will be populated with the mime type of the content.
185 @return ETrue if the content is recognized by content access agent
186 @return EFalse if the content is not recognized by a content access agent
188 IMPORT_C TBool DoRecognizeL(const TDesC8& aHeader, TDes8& aFileMimeType, TDes8& aContentMimeType);
189 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
191 /** Find an agent by it's Uid */
192 CAgentInfo& AgentInfoL(const TUid& aUid) const;
194 /** Find an agent by it's name */
195 CAgentInfo& AgentInfoL(const TDesC& aAgentName) const;
197 /** Reference an agent in the iAgentInfos array by index */
198 CAgentInfo& AgentInfo(TInt aIndex) const;
200 /** The number of agents, excluding the F32Agent */
201 TInt AgentInfoCount() const;
203 /** The default F32 agent */
204 TUid DefaultAgentUid() const;
207 // From CActive, used for dynamically updating the list of content access agents
208 virtual void DoCancel();
212 CAgentResolver(const TBool aDynamicAgentUpdate);
214 /** Second phase constructor for CAgentResolver
219 /** Builds a list of all the Content Access Agents. */
220 void BuildListOfAgentsL();
222 /** Add an agent to the list of agents */
223 void AddAgentL(const CImplementationInformation& aImplInfo);
225 /** Resets the list. */
226 void DestroyListOfAgents();
228 /** Is this the F32 Agent
229 @param aAgentInfo The agentinfo representing the agent
230 @return ETrue if it is the F32Agent, EFalse otherwise
232 TBool IsF32Agent(CAgentInfo& aAgentInfo);
235 static void CleanImplArray(TAny* aArray);
238 const TBool iDynamicAgentUpdate;
239 REComSession* iEcomSession;
241 RArray<TPtrC8> iSupplierMimeTypes;
242 RArray<TPtrC8> iConsumerMimeTypes;
244 // Array of agentInfos (not including F32 agent)
245 RPointerArray <CAgentInfo> iAgentInfos;
247 // This points to the agent which handles content if it is not
248 // recognised by any other agent (this should be the F32Agent)
249 CAgentInfo* iDefaultAgent;
252 } // namespace ContentAccess
253 #endif /* __RESOLVER_H__ */