|
1 /* |
|
2 * Copyright (c) 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: Encapsulates hsps liw service |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_CHSPSWRAPPER_H |
|
21 #define C_CHSPSWRAPPER_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <LiwCommon.h> // for MLiwNotifyCallback |
|
25 |
|
26 class CLiwServiceHandler; |
|
27 class MLiwInterface; |
|
28 class CLiwCriteriaItem; |
|
29 class CLiwMap; |
|
30 class CLiwList; |
|
31 class MDesC8Array; |
|
32 class CLiwDefaultMap; |
|
33 class CLiwDefaultList; |
|
34 class MLiwNotifyCallback; |
|
35 class CLiwGenericParamList; |
|
36 |
|
37 namespace hspswrapper{ |
|
38 |
|
39 |
|
40 class CHspsConfiguration; |
|
41 class CItemMap; |
|
42 class CPluginInfo; |
|
43 class CAddPluginResult; |
|
44 class CPropertyMap; |
|
45 |
|
46 /** |
|
47 * Observer class for hspswrapper |
|
48 * |
|
49 * @code |
|
50 * |
|
51 * @endcode |
|
52 * |
|
53 * @lib hspswrapper.lib |
|
54 * @since S60 v5.0 |
|
55 */ |
|
56 class MHspsWrapperObserver |
|
57 { |
|
58 public: |
|
59 /** |
|
60 * Handle HSPS wrappper notifications |
|
61 * |
|
62 * @param aEvent Event |
|
63 * @param aAppConfUid App configuration uid |
|
64 * @param aPluginName Plugin name |
|
65 * @param aOrigUid Originator uid |
|
66 * @param aPluginUid Plugin uid |
|
67 * @param aPluginId Plugin id |
|
68 */ |
|
69 virtual TInt HandleNotifyL( const TDesC8& aEvent, |
|
70 const TDesC8& aAppConfUid, |
|
71 const TDesC8& aPluginName, |
|
72 const TDesC8& aOrigUid, |
|
73 const TDesC8& aPluginUid, |
|
74 const TDesC8& aPluginId ) = 0; |
|
75 protected: |
|
76 /** |
|
77 * Destructor. Protected to prevent deletion through this interface. |
|
78 */ |
|
79 ~MHspsWrapperObserver() { } |
|
80 }; |
|
81 |
|
82 /** |
|
83 * Return value from add plugin |
|
84 * |
|
85 * @code |
|
86 * |
|
87 * @endcode |
|
88 * |
|
89 * @lib hspswrapper.lib |
|
90 * @since S60 v5.0 |
|
91 */ |
|
92 class CAddPluginResult: public CBase |
|
93 { |
|
94 public: |
|
95 IMPORT_C static CAddPluginResult* NewL(); |
|
96 IMPORT_C ~CAddPluginResult(); |
|
97 /** |
|
98 * Set plugin id |
|
99 * |
|
100 * @param aPluginId Plugin id |
|
101 */ |
|
102 IMPORT_C void SetPluginIdL(const TDesC8& aPluginId); |
|
103 /** |
|
104 * Get plugin id |
|
105 * |
|
106 * @return Plugin id or KNullDesC8 |
|
107 */ |
|
108 IMPORT_C const TDesC8& PluginId()const; |
|
109 |
|
110 /** |
|
111 * Set operation status |
|
112 * |
|
113 * @param aStatus Operation status |
|
114 */ |
|
115 IMPORT_C void SetStatus(TInt aStatus); |
|
116 /** |
|
117 * Get operation status |
|
118 * |
|
119 * @return KErrNotFound, if operation fails |
|
120 */ |
|
121 IMPORT_C TInt Status()const; |
|
122 private: |
|
123 CAddPluginResult(); |
|
124 private: |
|
125 /** |
|
126 * Status of operation. KErrNotFound, if operation fails |
|
127 */ |
|
128 TInt iStatus; |
|
129 /** |
|
130 * Own. Id of the added plugin in the configuration |
|
131 */ |
|
132 HBufC8* iPluginId; |
|
133 }; |
|
134 |
|
135 |
|
136 /** |
|
137 * Wrapper for hsps liw service |
|
138 * |
|
139 * |
|
140 * @code |
|
141 * |
|
142 * @endcode |
|
143 * |
|
144 * @lib hspswrapper.lib |
|
145 * @since S60 v5.0 |
|
146 */ |
|
147 class CHspsWrapper : public CBase, public MLiwNotifyCallback |
|
148 { |
|
149 public: |
|
150 /** |
|
151 * Two-phased constructor. |
|
152 * @param aAppUid Application uid in integer format |
|
153 * @param aObserver Observer |
|
154 */ |
|
155 IMPORT_C static CHspsWrapper* NewL(const TDesC8& aAppUid, |
|
156 MHspsWrapperObserver* aObserver = NULL); |
|
157 /** |
|
158 * Two-phased constructor. |
|
159 * @param aAppUid Application uid in integer format |
|
160 * @param aObserver Observer |
|
161 */ |
|
162 IMPORT_C static CHspsWrapper* NewLC(const TDesC8& aAppUid, |
|
163 MHspsWrapperObserver* aObserver = NULL); |
|
164 /** |
|
165 * Destructor. |
|
166 */ |
|
167 IMPORT_C virtual ~CHspsWrapper(); |
|
168 |
|
169 /** |
|
170 * Fetch active application configuration from hsps and |
|
171 * creates CHspsConfiguration out of liw message |
|
172 * |
|
173 * @return Configuration. Caller has ownership. |
|
174 */ |
|
175 IMPORT_C CHspsConfiguration* GetAppConfigurationL(); |
|
176 |
|
177 /** |
|
178 * Fetch root configurations from hsps. On return aConfs holds |
|
179 * configuration info instancies. Caller takes ownership of |
|
180 * configuration info instancies. |
|
181 * |
|
182 * @param aPlugins Array to hold configuration info instancies |
|
183 */ |
|
184 IMPORT_C void GetAppConfigurationsL( RPointerArray<CPluginInfo>& aPlugins ); |
|
185 |
|
186 /** |
|
187 * Sets root configuration to active. |
|
188 * |
|
189 * @param aConfigurationUid Configuration uid to be activated |
|
190 * @return Operation status. KErrNone (success), KErrNotFound |
|
191 */ |
|
192 IMPORT_C TInt SetAppConfigurationL(const TDesC8& aConfigurationUid ); |
|
193 |
|
194 /** |
|
195 * Fetch plugin configuration from hsps and |
|
196 * creates CHspsConfiguration out of liw message |
|
197 * |
|
198 * @param aPluginId Id of plugin configuration |
|
199 * @return Configuration. Caller has ownership. |
|
200 */ |
|
201 IMPORT_C CHspsConfiguration* GetPluginConfigurationL(const TDesC8& aPluginId); |
|
202 /** |
|
203 * Fetch plugins from hsps. On return aPlugins holds plugin info |
|
204 * instancies. Caller takes ownership of plugin info instancies. |
|
205 * |
|
206 * @param aPlugins Array to hold plugin info instancies |
|
207 * @param aPluginInterface Plugin interface id |
|
208 * @param aPluginType view, widget or template |
|
209 */ |
|
210 IMPORT_C void GetPluginsL( RPointerArray<CPluginInfo>& aPlugins, |
|
211 const TDesC8& aPluginInterface, |
|
212 const TDesC8& aPluginType); |
|
213 |
|
214 /** |
|
215 * Add plugin to hsps. |
|
216 * |
|
217 * @param aTargetConfiguration Id of configuration where the new plugin is attached |
|
218 * @param aPluginUid Plugin uid which is added |
|
219 * @param aPos Position in configuration's plugin list |
|
220 */ |
|
221 IMPORT_C CAddPluginResult* AddPluginL(const TDesC8& aTargetConfiguration, const TDesC8& aPluginUid); |
|
222 |
|
223 /** |
|
224 * Remove plugin from the active configuration. |
|
225 * |
|
226 * @param aPluginId Plugin id to be removed |
|
227 * @return Operation status. KErrNone (success), KErrNotFound |
|
228 */ |
|
229 IMPORT_C TInt RemovePluginL(const TDesC8& aPluginId); |
|
230 |
|
231 /** |
|
232 * Sets plugin active into active configuration. |
|
233 * |
|
234 * @param aPluginId Plugin id to be activated |
|
235 * @return Operation status. KErrNone (success), KErrNotFound |
|
236 */ |
|
237 IMPORT_C TInt SetActivePluginL(const TDesC8& aPluginId); |
|
238 |
|
239 /** |
|
240 * Replace plugin in the active configuration. |
|
241 * |
|
242 * @param aPluginId Plugin id to be replaced |
|
243 * @param aConfUid Configuration uid of the new plugin |
|
244 * @return Operation status. KErrNone (success), KErrNotFound |
|
245 */ |
|
246 IMPORT_C TInt ReplacePluginL( |
|
247 const TDesC8& aPluginId, |
|
248 const TDesC8& aConfUid ); |
|
249 |
|
250 /** |
|
251 * Move plugin inside configuration. |
|
252 * |
|
253 * @param aConfId Configuration |
|
254 * @param aPluginIds List of plugins included in the configuration in new order |
|
255 * @return Operation status. KErrNone (success), KErrArgument, KErrNotFound |
|
256 */ |
|
257 IMPORT_C TInt MovePluginsL(const TDesC8& aConfId, const MDesC8Array& aPluginIds); |
|
258 |
|
259 /** |
|
260 * Stores defined plugin’s settings. |
|
261 * Plugin is identified with unique plugin ID used in application’s configuration |
|
262 * |
|
263 * @param aPluginId Pluging’s ID which settings are stored |
|
264 * @param aSettings List of item maps |
|
265 * @return Operation status. KErrNone (success), KErrNotFound |
|
266 */ |
|
267 IMPORT_C TInt SetPluginSettingsL(const TDesC8& aPluginId, const RPointerArray<CItemMap>& aSettings); |
|
268 |
|
269 /** |
|
270 * Add plugin to hsps. |
|
271 * |
|
272 * @param aTargetConfiguration Id of configuration where the new plugin is attached |
|
273 * @param aPluginUid Plugin uid which is added |
|
274 * @param aIndex Position to which plugin is added |
|
275 */ |
|
276 IMPORT_C CAddPluginResult* AddPluginL(const TDesC8& aTargetConfiguration, const TDesC8& aPluginUid, const TInt aIndex); |
|
277 |
|
278 /** |
|
279 * Set plugin configure state to hsps. |
|
280 * |
|
281 * @param aConfId Configuration id of a plugin that should be confirmed. |
|
282 * @param aState State of the plugin |
|
283 * @param aIncludePlugins ETrue if aState is set to child plugins, EFalse default. |
|
284 * @return Operation status. KErrNone (success), KErrNotFound |
|
285 */ |
|
286 IMPORT_C TInt SetConfStateL( const TDesC8& aConfId, const TDesC8& aState, TBool aIncludePlugins = EFalse ); |
|
287 |
|
288 /** |
|
289 * Returns SAPI service handler. |
|
290 */ |
|
291 IMPORT_C CLiwServiceHandler* ServiceHandler() const; |
|
292 |
|
293 /** |
|
294 * Returns HSPS SAPI service |
|
295 */ |
|
296 IMPORT_C CLiwCriteriaItem* HspsService() const; |
|
297 |
|
298 /** |
|
299 * Returns HSPS services interface |
|
300 */ |
|
301 IMPORT_C MLiwInterface* HspsInterface() const; |
|
302 |
|
303 protected: |
|
304 CHspsWrapper(MHspsWrapperObserver* aObserver); |
|
305 void ConstructL(const TDesC8& aAppUid); |
|
306 |
|
307 void ProcessConfigurationMapL(const CLiwMap& aSource, CHspsConfiguration& aTarget); |
|
308 void ProcessConfigurationPluginsL(const CLiwList& aPluginsList, CHspsConfiguration& aTarget); |
|
309 void ProcessConfigurationSettingsL(const CLiwList& aItemList, CHspsConfiguration& aTarget); |
|
310 void ProcessConfigurationResourcesL(const CLiwList& aObjectList, CHspsConfiguration& aTarget); |
|
311 void ProcessConfItemPropertiesL(const CLiwList& aPropertyMapList,CItemMap& aItemMap); |
|
312 void ProcessPluginsL(const CLiwList& aPluginInfoMapList, RPointerArray<CPluginInfo>& aPlugins); |
|
313 void FillMapFromItemL( CLiwDefaultMap& aMap, const CItemMap& aItemMap ); |
|
314 void FillMapFromPropertiesL( CLiwDefaultList& aInPropertyMapList, const RPointerArray<CPropertyMap>& aProperties ); |
|
315 |
|
316 protected: // from MLiwNotifyCallback |
|
317 |
|
318 /** |
|
319 * Handle HSPS notifications |
|
320 * |
|
321 * @param aCmdId Command id |
|
322 * @param aEventId Event id |
|
323 * @param aEventParamList Event parameters |
|
324 * @param aInParamList In parameters |
|
325 */ |
|
326 TInt HandleNotifyL(TInt aCmdId, TInt aEventId, |
|
327 CLiwGenericParamList& aEventParamList, |
|
328 const CLiwGenericParamList& aInParamList); |
|
329 |
|
330 private: // data |
|
331 |
|
332 /** |
|
333 * Owned. SAPI service handler. |
|
334 */ |
|
335 CLiwServiceHandler* iServiceHandler; |
|
336 /** |
|
337 * Owned. HSPS SAPI service. |
|
338 */ |
|
339 CLiwCriteriaItem* iHspsService; |
|
340 /** |
|
341 * Owned. Provides hsps services. |
|
342 */ |
|
343 MLiwInterface* iHspsInterface; |
|
344 /** |
|
345 * Not owned. Wrapper observer |
|
346 */ |
|
347 MHspsWrapperObserver* iObserver; |
|
348 /* |
|
349 * Asynchronous service request tarnsaction id |
|
350 */ |
|
351 TInt iTransactionId; |
|
352 }; |
|
353 } |
|
354 |
|
355 #endif // C_CHSPSWRAPPER_H |