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