|
1 /* |
|
2 * Copyright (c) 2006-2008 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 "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: CFContextSourceManager class declaration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CFCONTEXTSOURCEMANAGER_H |
|
20 #define C_CFCONTEXTSOURCEMANAGER_H |
|
21 |
|
22 #include <cfcontextsourcesetting.h> |
|
23 |
|
24 #include "cfecompluginmanager.h" |
|
25 #include "cfstarterobserver.h" |
|
26 #include "cfstateobserver.h" |
|
27 #include "cfstartereventhandler.h" |
|
28 |
|
29 class CAsyncCallBack; |
|
30 class CCFContextSourcePlugIn; |
|
31 class CCFContextSourceSettingsManager; |
|
32 class CCFContextSourceSettingArray; |
|
33 class MCFExtendedContextInterface; |
|
34 class MCFContextSourceUpgrade; |
|
35 class RFs; |
|
36 class TCFContextSourceInfo; |
|
37 class TContextSourceInitParams; |
|
38 class CImplementationInformation; |
|
39 class CCFContextSourceCommand; |
|
40 class MCFContextSource; |
|
41 class TCFClientContextSourceInfo; |
|
42 |
|
43 |
|
44 /** |
|
45 * Context source manager. |
|
46 * |
|
47 * Context source manager is responsible for loading all the |
|
48 * context source plug-ins that are currently installed. |
|
49 * |
|
50 * @lib CFContextSourceManager.lib |
|
51 * @since S60 4.0 |
|
52 */ |
|
53 NONSHARABLE_CLASS( CCFContextSourceManager ): public CCFEComPluginManager, |
|
54 public MCFStarterObserver, |
|
55 public MCFStateObserver |
|
56 { |
|
57 public: |
|
58 |
|
59 // Two phased constrcutors |
|
60 IMPORT_C static CCFContextSourceManager* NewL( |
|
61 MCFExtendedContextInterface& aCF, |
|
62 RFs& aFs ); |
|
63 IMPORT_C static CCFContextSourceManager* NewLC( |
|
64 MCFExtendedContextInterface& aCF, |
|
65 RFs& aFs ); |
|
66 |
|
67 // Destructor |
|
68 IMPORT_C virtual ~CCFContextSourceManager(); |
|
69 |
|
70 public: // New functions |
|
71 |
|
72 /** |
|
73 * Installs a context source setting. |
|
74 * Setting is stored for a plugin if install succeeds. |
|
75 * |
|
76 * @since S60 5.0 |
|
77 * @param aSettingFile Setting file opened as EFileRead. |
|
78 * @param aContextSourceUid Implementation UID of the context source to |
|
79 * receive setting. |
|
80 * @param aClientThread Client thread making the request. |
|
81 * @return None. Possible leave codes: |
|
82 * - KErrBadHandle, context source not found/loaded. |
|
83 * - KErrExtensionNotSupported, context source does not support |
|
84 * installing settings. |
|
85 * - Otherwise system-wide error code. |
|
86 */ |
|
87 IMPORT_C void InstallSettingL( RFile& aSettingFile, |
|
88 const TUid& aContextSourceUid, |
|
89 RThread& aClientThread ); |
|
90 |
|
91 /** |
|
92 * Uninstalls a context source setting. |
|
93 * Setting is removed if uninstall succeeds. |
|
94 * |
|
95 * @since S60 5.0 |
|
96 * @param aSettingFilename Filename (without path) that was used to |
|
97 * install the setting. |
|
98 * @param aContextSourceUid Implementation UID of the context source. |
|
99 * @param aClientThread Client thread making the request. |
|
100 * @return None. Possible leave codes: |
|
101 * - KErrNotFound, specified setting file not found. |
|
102 * - KErrBadHandle, context source not found/loaded. |
|
103 * - KErrExtensionNotSupported, context source does not support |
|
104 * uninstalling settings. |
|
105 * - Otherwise system-wide error code. |
|
106 */ |
|
107 IMPORT_C void UninstallSettingL( const TDesC& aSettingFilename, |
|
108 const TUid& aContextSourceUid, |
|
109 RThread& aClientThread ); |
|
110 |
|
111 /** |
|
112 * Uninstalls context source settings registered by a client. |
|
113 * Uninstalls all settings ever registered by the client for the context |
|
114 * source. Settings are removed if uninstall succeeds. |
|
115 * |
|
116 * @since S60 5.0 |
|
117 * @param aContextSourceUid Implementation UID of the context source. |
|
118 * @param aClientThread Client thread making the request. |
|
119 * @return None. Possible leave codes: |
|
120 * - KErrBadHandle, context source not found/loaded. |
|
121 * - KErrExtensionNotSupported, context source does not support |
|
122 * uninstalling settings. |
|
123 * - Otherwise system-wide error code. |
|
124 */ |
|
125 IMPORT_C void UninstallSettingsL( const TUid& aContextSourceUid, |
|
126 RThread& aClientThread ); |
|
127 |
|
128 /** |
|
129 * Handles context source command. |
|
130 * |
|
131 * @since S60 5.0 |
|
132 * @param aCommand Context source command. |
|
133 * @return None. Possible leave codes: |
|
134 * - KErrBadHandle, context source not found/loaded. |
|
135 * - KErrExtensionNotSupported, context source does not support commands. |
|
136 * - Otherwise system-wide error code. |
|
137 */ |
|
138 IMPORT_C void HandleContextSourceCommandL( |
|
139 const CCFContextSourceCommand& aCommand ); |
|
140 |
|
141 /** |
|
142 * Registers client as a context source. |
|
143 * Must be called for enabling client to receive source commands. |
|
144 * |
|
145 * @since S60 5.0 |
|
146 * @param aPublisher Context source interface of the publisher client. |
|
147 * @param aPublisherUid Uid (secure id) of the publisher client. |
|
148 * @return KErrNone if successful, otherwise system-wide error code. |
|
149 */ |
|
150 IMPORT_C TInt RegisterClientContextSource( MCFContextSource* aPublisher, |
|
151 const TUid& aPublisherUid ); |
|
152 |
|
153 /** |
|
154 * Deregisters client as a context source. |
|
155 * Must be called when a registered client cannot receive source commands |
|
156 * anymore, i.e. when client session is deleted. |
|
157 * |
|
158 * @since S60 5.0 |
|
159 * @param aPublisher Context source interface of the publisher client. |
|
160 * @return None. |
|
161 */ |
|
162 IMPORT_C void DeregisterClientContextSource( |
|
163 const MCFContextSource& aPublisher ); |
|
164 |
|
165 private: // From base classes |
|
166 |
|
167 // @see MCFInitialize |
|
168 void InitializePhaseL( CCFPhaseBase::TCFPhaseId aPhase ); |
|
169 |
|
170 // from MCFStateObserver |
|
171 void UpdatePlugInsL(); |
|
172 |
|
173 // @see MCFStarterObserver |
|
174 void SetEventHandler( MCFStarterEventHandler& aEventHandler ); |
|
175 |
|
176 private: // New methods |
|
177 |
|
178 // Releases plugin dependencies before deleting |
|
179 void ReleasePlugIn( CCFContextSourcePlugIn*& aPlugIn ); |
|
180 |
|
181 // Call back function for asynchronous plug-in loading |
|
182 static TInt LoaderCallBack( TAny* aLoaderInfo ); |
|
183 |
|
184 // Prepares plug-in loaders |
|
185 void PrepareLoaderL( CImplementationInformation* aImplementationInfo ); |
|
186 |
|
187 // Execute function for plug-in load |
|
188 void ExecuteLoaders(); |
|
189 |
|
190 private: |
|
191 |
|
192 CCFContextSourceManager( MCFExtendedContextInterface& aCF, RFs& aFs ); |
|
193 void ConstructL(); |
|
194 |
|
195 private: // New methods |
|
196 |
|
197 // Loads and initialized plug-in |
|
198 CCFContextSourcePlugIn* CreateAndInitializePlugInL( |
|
199 const TUid& aImplementationUid, |
|
200 TContextSourceInitParams& aParams ); |
|
201 |
|
202 // Init starting phase |
|
203 void InitDeviceStartingPhaseL(); |
|
204 |
|
205 // Init loading plugins phase |
|
206 void InitLoadingPluginsPhaseL(); |
|
207 |
|
208 // Loads plug-ins and appends it into array |
|
209 void LoadPluginL( TUid aUid, TInt aImplVersion ); |
|
210 |
|
211 // Configures setting folder to rom |
|
212 // Returns ETrue if setting file found |
|
213 TBool ConfigureRomSettingFolder( TDes& aFolder, const TUid& aUid ); |
|
214 |
|
215 // Configures setting folder to ram |
|
216 // Returns ETrue if setting file found |
|
217 TBool ConfigureRamSettingFolder( TDes& aFolder, const TUid& aUid ); |
|
218 |
|
219 // Searches the plugin setting folder from setting |
|
220 // files and parses them |
|
221 void ParsePlugInSettingsL( const TDesC& aFolder, |
|
222 CCFContextSourceSettingArray& aSettings ); |
|
223 |
|
224 // Returns parsed plugin settings for a plugin |
|
225 CCFContextSourceSettingArray* PlugInSettingsL( |
|
226 const TUid& aImplementationUid ); |
|
227 |
|
228 /** |
|
229 * Gets context source plugin supporting MCFContextSourceUpgrade |
|
230 * interface. |
|
231 * @param aContextSourceUid Implementation UID of the context source. |
|
232 * @return Pointer to plugin's MCFContextSourceUpgrade interface. |
|
233 * Possible leave codes: |
|
234 * - KErrBadHandle, context source not found/loaded. |
|
235 * - KErrExtensionNotSupported, context source does not support |
|
236 * MCFContextSourceUpgrade interface. |
|
237 */ |
|
238 MCFContextSourceUpgrade* PlugInL( const TUid& aContextSourceUid ) const; |
|
239 |
|
240 /** |
|
241 * Copies setting file into RAM setting folder of a context source. |
|
242 * Overwrites previous setting file by the same name if it exists. |
|
243 * @param aSettingFile Open file handle indicating the file to be copied. |
|
244 * @param aContextSourceUid Implementation UID of the context source to |
|
245 * receive setting. |
|
246 * @param aClientThread Client thread making the request. |
|
247 * @return None. |
|
248 */ |
|
249 void CopySettingFileL( const RFile& aSettingFile, |
|
250 const TUid& aContextSourceUid, |
|
251 RThread& aClientThread ); |
|
252 |
|
253 /** |
|
254 * Deletes setting file(s) from RAM setting folder of a context source. |
|
255 * @param aSettingFile Filename of the setting to be deleted. Use |
|
256 * wildcards to delete more than one file. |
|
257 * @param aContextSourceUid Implementation UID of the context source |
|
258 * whose setting file(s) is to be deleted. |
|
259 * @param aClientThread Client thread making the request. |
|
260 * @return None. |
|
261 */ |
|
262 void DeleteSettingFileL( const TDesC& aSettingFile, |
|
263 const TUid& aContextSourceUid, |
|
264 RThread& aClientThread ); |
|
265 |
|
266 private: // data |
|
267 |
|
268 // Own: Context source settings manager |
|
269 CCFContextSourceSettingsManager* iSettingsManager; |
|
270 |
|
271 // Own: Context source plugin info array |
|
272 RArray<TCFContextSourceInfo> iPlugIns; |
|
273 |
|
274 // Ref: Context framework API |
|
275 MCFExtendedContextInterface& iCF; |
|
276 |
|
277 // Ref: File server session |
|
278 RFs& iFs; |
|
279 |
|
280 // Own: Array of context sources implemented by clients (no duplicates) |
|
281 RArray< TCFClientContextSourceInfo > iClientContextSources; |
|
282 |
|
283 // Loaders for plug-in loading |
|
284 RPointerArray<CAsyncCallBack> iLoaders; |
|
285 |
|
286 // Counter for loaded plug-ins |
|
287 TInt iLoadedCount; |
|
288 |
|
289 // Event handler, not own, can be NULL |
|
290 MCFStarterEventHandler* iEventHandler; |
|
291 }; |
|
292 |
|
293 #endif |