sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@internalComponent
|
sl@0
|
22 |
@released
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
#ifndef __RESOLVER_H__
|
sl@0
|
27 |
#define __RESOLVER_H__
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <e32std.h>
|
sl@0
|
30 |
#include <ecom/ecom.h>
|
sl@0
|
31 |
#include <caf/caftypes.h>
|
sl@0
|
32 |
|
sl@0
|
33 |
namespace ContentAccess
|
sl@0
|
34 |
{
|
sl@0
|
35 |
const TUid KF32AgentImplUid = { 0x101FC2CF };
|
sl@0
|
36 |
|
sl@0
|
37 |
class CAgentInfo;
|
sl@0
|
38 |
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
Used to identify the Content Access Agent who handles a particular file.
|
sl@0
|
41 |
|
sl@0
|
42 |
CAgentResolver builds an array of CAgentInfo objects. Each CAgentInfo object
|
sl@0
|
43 |
holds metadata related to a particular agent implementation.
|
sl@0
|
44 |
|
sl@0
|
45 |
This class resolves:
|
sl@0
|
46 |
- Content to the Agent which manages it
|
sl@0
|
47 |
- Supplier mime-types to the agent which imports files with that mime type.
|
sl@0
|
48 |
|
sl@0
|
49 |
@internalComponent
|
sl@0
|
50 |
@released
|
sl@0
|
51 |
*/
|
sl@0
|
52 |
class CAgentResolver : public CActive
|
sl@0
|
53 |
{
|
sl@0
|
54 |
public:
|
sl@0
|
55 |
/** Constructs a new CAgentResolver and puts it on the cleanup stack
|
sl@0
|
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
|
sl@0
|
57 |
* @leave KErrCANoAgent If no F32 agent was found
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
IMPORT_C static CAgentResolver* NewLC(const TBool aDynamicAgentUpdate);
|
sl@0
|
60 |
|
sl@0
|
61 |
/** Constructs a new CAgentResolver
|
sl@0
|
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
|
sl@0
|
63 |
* @leave KErrCANoAgent If no F32 agent was found
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
IMPORT_C static CAgentResolver* NewL(const TBool aDynamicAgentUpdate);
|
sl@0
|
66 |
virtual ~CAgentResolver();
|
sl@0
|
67 |
|
sl@0
|
68 |
/** Finds the agent that handles the given supplier MIME type.
|
sl@0
|
69 |
|
sl@0
|
70 |
@param aMimeType MIME type from the supplier application.
|
sl@0
|
71 |
@return The CAgentInfo object associated with the agent that handles files with this MIME type.
|
sl@0
|
72 |
|
sl@0
|
73 |
@leave KErrCANoAgent If no CA agent supports the given MIME type.
|
sl@0
|
74 |
*/
|
sl@0
|
75 |
CAgentInfo& ResolveSupplierMimeL(const TDesC8& aMimeType) const;
|
sl@0
|
76 |
|
sl@0
|
77 |
/** Finds the agent that handles the given consumer MIME type.
|
sl@0
|
78 |
|
sl@0
|
79 |
@note Planning to remove this from the CAF API
|
sl@0
|
80 |
|
sl@0
|
81 |
@param aMimeType MIME type of the file
|
sl@0
|
82 |
@return The CAgentInfo object associated with the agent that handles files with this MIME type.
|
sl@0
|
83 |
*/
|
sl@0
|
84 |
CAgentInfo& ResolveConsumerMime(const TDesC8& aMimeType) const;
|
sl@0
|
85 |
|
sl@0
|
86 |
/** Finds the agent that handles a file.
|
sl@0
|
87 |
|
sl@0
|
88 |
@param aFile Handle of the file to be resolved.
|
sl@0
|
89 |
@return The CAgentInfo object associated with the agent that will handle this file.
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
CAgentInfo& ResolveFileL(RFile& aFile) const;
|
sl@0
|
92 |
|
sl@0
|
93 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
94 |
|
sl@0
|
95 |
/** Finds the agent which handles this piece of content.
|
sl@0
|
96 |
@param aHeaderData Header data of WMDRM file or stream content.
|
sl@0
|
97 |
@return CAgentInfo object associated with the agent that will handle WMDRM content.
|
sl@0
|
98 |
*/
|
sl@0
|
99 |
CAgentInfo& ResolveFileL(const TDesC8& aHeaderData);
|
sl@0
|
100 |
|
sl@0
|
101 |
#endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
102 |
|
sl@0
|
103 |
/** Finds the agent that handles a file and returns the actual URI of the content.
|
sl@0
|
104 |
|
sl@0
|
105 |
If the aUri is of the form "c:\\private\\agent_name\\"
|
sl@0
|
106 |
it will be translated to the form "c:\\private\\SID\\" in
|
sl@0
|
107 |
aActualUri. Otherwise the aUri is just copied to aActualUri
|
sl@0
|
108 |
|
sl@0
|
109 |
@param aUri Location of file to be resolved.
|
sl@0
|
110 |
@param aActualUri The actual location of the file
|
sl@0
|
111 |
@param aShareMode The file sharing mode to be used with this file
|
sl@0
|
112 |
@return The CAgentInfo object associated with the agent that will handle this file.
|
sl@0
|
113 |
*/
|
sl@0
|
114 |
CAgentInfo& ResolveFileL(const TDesC& aUri, TDes& aActualUri, TContentShareMode aShareMode = EContentShareReadOnly) const;
|
sl@0
|
115 |
|
sl@0
|
116 |
/** Find the agent who owns a directory
|
sl@0
|
117 |
|
sl@0
|
118 |
This function also maps a path from the agent directory name
|
sl@0
|
119 |
to it's actual name in the file system.
|
sl@0
|
120 |
|
sl@0
|
121 |
ie. For example if an agent "x" has files stored in a private server directory
|
sl@0
|
122 |
"c:\\private\\12345678\\"
|
sl@0
|
123 |
|
sl@0
|
124 |
The file appear as "c:\\private\\x\\" to applications using CAF. This function
|
sl@0
|
125 |
converts "c:\\private\\x\\" back to "c:\\private\\12345678\\"
|
sl@0
|
126 |
|
sl@0
|
127 |
@param aPath The path in the form c:\\private\\agent_name\\...
|
sl@0
|
128 |
@param aActualPath The path in the form c:\\private\\SID\\...
|
sl@0
|
129 |
@param aThePrivateDir to ETrue if the directory is just "\\private\\"
|
sl@0
|
130 |
@return The Uid of the agent who owns the directory
|
sl@0
|
131 |
*/
|
sl@0
|
132 |
TUid ResolveDirectory(const TDesC& aPath, TDes& aActualPath, TBool& aThePrivateDir) const;
|
sl@0
|
133 |
|
sl@0
|
134 |
/** Converts a filename containing the agent SID to the filename containing the agent name.
|
sl@0
|
135 |
@param aFileName The filename in the form "c:\\private\\12345678\\"
|
sl@0
|
136 |
@return A buffer to the new filename in the form "c:\\private\\agent_name\\"
|
sl@0
|
137 |
*/
|
sl@0
|
138 |
HBufC* ConvertAgentFileNameL(const TDesC& aFileName) const;
|
sl@0
|
139 |
|
sl@0
|
140 |
/** Determines the MIME types of the a file and the mime type of its contents.
|
sl@0
|
141 |
|
sl@0
|
142 |
This function should only be used by the CAF recogizer DLL.
|
sl@0
|
143 |
|
sl@0
|
144 |
@param aName The file name/URI to be investigated.
|
sl@0
|
145 |
@param aBuffer A buffer containing bytes from the start of the file.
|
sl@0
|
146 |
@param aFileMimeType If the file is recognized this will be populated with
|
sl@0
|
147 |
the mime type of the file.
|
sl@0
|
148 |
@param aContentMimeType If the file is recognized this will be populated with the mime type of the content object within the file.
|
sl@0
|
149 |
|
sl@0
|
150 |
@return ETrue if the file is recognized by content access agent
|
sl@0
|
151 |
@return EFalse if the file is not recognized by a content access agent
|
sl@0
|
152 |
*/
|
sl@0
|
153 |
IMPORT_C TBool DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer, TDes8& aFileMimeType, TDes8& aContentMimeType);
|
sl@0
|
154 |
|
sl@0
|
155 |
/** Gets the preferred buffer size for recognizing files using the RecognizeFile() function.
|
sl@0
|
156 |
|
sl@0
|
157 |
This function should only be used by the CAF recogizer DLL.
|
sl@0
|
158 |
|
sl@0
|
159 |
@return The largest preferred buffer nominated by any agent for recognizing files using the the DoRecognize() function.
|
sl@0
|
160 |
*/
|
sl@0
|
161 |
IMPORT_C TInt PreferredBufferSize();
|
sl@0
|
162 |
|
sl@0
|
163 |
/** Accessor for the SupplierMimeTypes array.
|
sl@0
|
164 |
*
|
sl@0
|
165 |
* @return An array of supplier MIME type supported by CAF agents.
|
sl@0
|
166 |
*/
|
sl@0
|
167 |
IMPORT_C const RArray<TPtrC8>& SupplierMimeTypes() const;
|
sl@0
|
168 |
|
sl@0
|
169 |
/** Accessor for the ConsumerMimeTypes array.
|
sl@0
|
170 |
*
|
sl@0
|
171 |
* @note Planning to remove this from the CAF API
|
sl@0
|
172 |
*
|
sl@0
|
173 |
* @return An array of consumer MIME types supported by CAF agents.
|
sl@0
|
174 |
*/
|
sl@0
|
175 |
IMPORT_C const RArray<TPtrC8>& ConsumerMimeTypes() const;
|
sl@0
|
176 |
|
sl@0
|
177 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
178 |
/** This function should only be used by the CAF recogizer DLL.
|
sl@0
|
179 |
|
sl@0
|
180 |
@param aHeader Header data of WMDRM content.
|
sl@0
|
181 |
@param aFileMimeType If the content is recognized this will be populated with
|
sl@0
|
182 |
the mime type of the content.
|
sl@0
|
183 |
@param aContentMimeType If the content is recognized this will be populated with the mime type of the content.
|
sl@0
|
184 |
|
sl@0
|
185 |
@return ETrue if the content is recognized by content access agent
|
sl@0
|
186 |
@return EFalse if the content is not recognized by a content access agent
|
sl@0
|
187 |
*/
|
sl@0
|
188 |
IMPORT_C TBool DoRecognizeL(const TDesC8& aHeader, TDes8& aFileMimeType, TDes8& aContentMimeType);
|
sl@0
|
189 |
#endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
190 |
|
sl@0
|
191 |
/** Find an agent by it's Uid */
|
sl@0
|
192 |
CAgentInfo& AgentInfoL(const TUid& aUid) const;
|
sl@0
|
193 |
|
sl@0
|
194 |
/** Find an agent by it's name */
|
sl@0
|
195 |
CAgentInfo& AgentInfoL(const TDesC& aAgentName) const;
|
sl@0
|
196 |
|
sl@0
|
197 |
/** Reference an agent in the iAgentInfos array by index */
|
sl@0
|
198 |
CAgentInfo& AgentInfo(TInt aIndex) const;
|
sl@0
|
199 |
|
sl@0
|
200 |
/** The number of agents, excluding the F32Agent */
|
sl@0
|
201 |
TInt AgentInfoCount() const;
|
sl@0
|
202 |
|
sl@0
|
203 |
/** The default F32 agent */
|
sl@0
|
204 |
TUid DefaultAgentUid() const;
|
sl@0
|
205 |
|
sl@0
|
206 |
private:
|
sl@0
|
207 |
// From CActive, used for dynamically updating the list of content access agents
|
sl@0
|
208 |
virtual void DoCancel();
|
sl@0
|
209 |
virtual void RunL();
|
sl@0
|
210 |
|
sl@0
|
211 |
private:
|
sl@0
|
212 |
CAgentResolver(const TBool aDynamicAgentUpdate);
|
sl@0
|
213 |
|
sl@0
|
214 |
/** Second phase constructor for CAgentResolver
|
sl@0
|
215 |
*/
|
sl@0
|
216 |
void ConstructL();
|
sl@0
|
217 |
|
sl@0
|
218 |
|
sl@0
|
219 |
/** Builds a list of all the Content Access Agents. */
|
sl@0
|
220 |
void BuildListOfAgentsL();
|
sl@0
|
221 |
|
sl@0
|
222 |
/** Add an agent to the list of agents */
|
sl@0
|
223 |
void AddAgentL(const CImplementationInformation& aImplInfo);
|
sl@0
|
224 |
|
sl@0
|
225 |
/** Resets the list. */
|
sl@0
|
226 |
void DestroyListOfAgents();
|
sl@0
|
227 |
|
sl@0
|
228 |
/** Is this the F32 Agent
|
sl@0
|
229 |
@param aAgentInfo The agentinfo representing the agent
|
sl@0
|
230 |
@return ETrue if it is the F32Agent, EFalse otherwise
|
sl@0
|
231 |
*/
|
sl@0
|
232 |
TBool IsF32Agent(CAgentInfo& aAgentInfo);
|
sl@0
|
233 |
|
sl@0
|
234 |
// Cleanup item
|
sl@0
|
235 |
static void CleanImplArray(TAny* aArray);
|
sl@0
|
236 |
|
sl@0
|
237 |
private:
|
sl@0
|
238 |
const TBool iDynamicAgentUpdate;
|
sl@0
|
239 |
REComSession* iEcomSession;
|
sl@0
|
240 |
|
sl@0
|
241 |
RArray<TPtrC8> iSupplierMimeTypes;
|
sl@0
|
242 |
RArray<TPtrC8> iConsumerMimeTypes;
|
sl@0
|
243 |
|
sl@0
|
244 |
// Array of agentInfos (not including F32 agent)
|
sl@0
|
245 |
RPointerArray <CAgentInfo> iAgentInfos;
|
sl@0
|
246 |
|
sl@0
|
247 |
// This points to the agent which handles content if it is not
|
sl@0
|
248 |
// recognised by any other agent (this should be the F32Agent)
|
sl@0
|
249 |
CAgentInfo* iDefaultAgent;
|
sl@0
|
250 |
};
|
sl@0
|
251 |
|
sl@0
|
252 |
} // namespace ContentAccess
|
sl@0
|
253 |
#endif /* __RESOLVER_H__ */
|
sl@0
|
254 |
|