|
1 /* |
|
2 * Copyright (c) 2007-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_HNENGINE_H |
|
21 #define C_HNENGINE_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <eikenv.h> |
|
25 #include <hwrmlight.h> |
|
26 |
|
27 #include "hnglobals.h" |
|
28 #include "hninterface.h" |
|
29 #include "hnmdmodel.h" |
|
30 |
|
31 class CHnMdModel; |
|
32 class CHnSuiteModelContainer; |
|
33 class MHnControllerInterface; |
|
34 class MHnSuiteObserver; |
|
35 |
|
36 /** |
|
37 * @ingroup group_hnengine |
|
38 * Hierarchy Navigator engine - used by Multimedia Menu |
|
39 * to fetch data models. The most commonly used exported method is TriggerHnEventL, |
|
40 * which offers event execution for the framework. This functionality is implemented |
|
41 * through the MHnEventGenerator interface. The class owns the meta data model ( CHnMdModel ) |
|
42 * and suite container ( CHnSuiteModelContainer ) to manage them. The engine manages |
|
43 * the model by processing model events ( HandleModelEventL ) or reseting the models |
|
44 * ( ResetModelsL ). |
|
45 * |
|
46 * @lib hnengine |
|
47 * @since S60 v3.2 |
|
48 */ |
|
49 NONSHARABLE_CLASS( CHnEngine ) : public CHnInterface, |
|
50 public MHnMdModelEventObserver, |
|
51 public MHWRMLightObserver |
|
52 { |
|
53 public: |
|
54 /** |
|
55 * Standard factory method. |
|
56 * |
|
57 * @since S60 v5.0 |
|
58 * @param aController Controller handler. |
|
59 * @return Fully constructed object. |
|
60 */ |
|
61 IMPORT_C static CHnEngine* NewL( MHnControllerInterface& aController ); |
|
62 |
|
63 /** |
|
64 * Standard factory method. |
|
65 * |
|
66 * @since S60 v5.0 |
|
67 * @param aController Controller handler. |
|
68 * @return Fully constructed object. |
|
69 */ |
|
70 IMPORT_C static CHnEngine* NewLC( MHnControllerInterface& aController ); |
|
71 |
|
72 /** |
|
73 * Standard C++ destructor. |
|
74 * |
|
75 * @since S60 v5.0 |
|
76 */ |
|
77 ~CHnEngine(); |
|
78 |
|
79 // from CHnInterface |
|
80 |
|
81 /** |
|
82 * Fetches and constructs data structres, needed by Multimedia |
|
83 * Menu to display suites. |
|
84 * |
|
85 * @since S60 v5.0 |
|
86 * @return Filled suite model object from the stack. |
|
87 */ |
|
88 CHnSuiteModel* GetLastSuiteModelL(); |
|
89 |
|
90 /** |
|
91 * Fetches and constructs data structres, needed by Multimedia |
|
92 * Menu to display suites. |
|
93 * |
|
94 * @since S60 v5.0 |
|
95 * @return Filled suite model object from the stack. |
|
96 */ |
|
97 CHnSuiteModel* GetParentSuiteModelL(); |
|
98 |
|
99 /** |
|
100 * Get count of suite models on the stack. |
|
101 * |
|
102 * @since S60 v5.0 |
|
103 * @return Count of suite models on the stack. |
|
104 */ |
|
105 virtual TInt GetSuiteModelsCountL(); |
|
106 |
|
107 /** |
|
108 * Checks if suite model is loaded. |
|
109 * |
|
110 * @since S60 v5.0 |
|
111 * @return ETrue if suite model is loaded, otherwise EFalse. |
|
112 */ |
|
113 TBool SuiteModelLoadedL( TInt aId ); |
|
114 |
|
115 /** |
|
116 * Loads suite hierarchy specified in URI. |
|
117 * |
|
118 * @since S60 v5.0 |
|
119 * @param aUri The URI contained suite(s) to load. |
|
120 */ |
|
121 IMPORT_C void LoadSuitesFromUriL( const TDesC8& aUri ); |
|
122 |
|
123 public: |
|
124 // from MHnMdModelEventObserver |
|
125 |
|
126 /** |
|
127 * Handle model event. |
|
128 * |
|
129 * @since S60 v5.0 |
|
130 * @param aEventName Event's name to perform. |
|
131 * @param aParams Event specific parameters used to perform action. |
|
132 */ |
|
133 TInt HandleModelEventL( const TDesC& aEventName, CLiwGenericParamList& aParams ); |
|
134 |
|
135 // from CHnInterface |
|
136 |
|
137 /** |
|
138 * Handle back event. |
|
139 * |
|
140 * @since S60 v5.0 |
|
141 * @param aGenre Suite given by the name genre. |
|
142 * @param aIterations Number of iterations. |
|
143 * @return Status code. |
|
144 */ |
|
145 TInt HandleBackEventL( const TDesC& aGenre, |
|
146 TInt aIterations = KModelCountForRoot ); |
|
147 |
|
148 /** |
|
149 * Loads default root suite |
|
150 * |
|
151 * @since S60 v5.0 |
|
152 * @param aSuiteParams Suite parameters. |
|
153 * @return Status error code. |
|
154 */ |
|
155 IMPORT_C TInt InitializeL( CLiwGenericParamList& aSuiteParams ); |
|
156 |
|
157 // from MHnEventGenerator |
|
158 |
|
159 /** |
|
160 * Triggers an event inside hierarchy navigator. |
|
161 * |
|
162 * Used by UI to notify hierarchy navigator of its events, |
|
163 * as well as for hierarchy navigator components to notify |
|
164 * the module of certain events (such as OnSuiteLoaded etc). |
|
165 * |
|
166 * @since S60 v5.0 |
|
167 * @param aHnEventId Internal id of an event (Event names are |
|
168 * mapped to ids). |
|
169 * @param aRecipientId The id of the recipient item. |
|
170 * @param aEventParameters Event specific parameter. |
|
171 * @return Status code. |
|
172 */ |
|
173 IMPORT_C TInt TriggerHnEventL( const TInt aHnEventId, |
|
174 const TInt aRecipientId, CLiwGenericParamList* aEventParameters = NULL ); |
|
175 |
|
176 /** |
|
177 * Splits the source descriptor by a separatos |
|
178 * |
|
179 * @since S60 v5.0 |
|
180 * @param aSource Source descriptor intended to split. |
|
181 * @param aSeparator Separator used to split. |
|
182 * @return Array of descriptors. |
|
183 */ |
|
184 RPointerArray< HBufC8 > SplitL( const TDesC8& aSource, |
|
185 const TDesC8& aSeparator ); |
|
186 |
|
187 /** |
|
188 * Generate param list according to query param. |
|
189 * |
|
190 * @param aUriQuery Descriptor consist of param(s) to split |
|
191 * @param aUriFragment Descriptor containing an uri fragment. |
|
192 * @param aSuiteName The suite's name. |
|
193 * @return Filled generic param list. |
|
194 */ |
|
195 CLiwGenericParamList* UriQueryToLiwListLC( const TDesC8& aUriQuery, |
|
196 const TDesC8& aUriFragment, const TDesC8& aSuiteName ); |
|
197 |
|
198 /** |
|
199 * Resets MD Model and Suite Container. |
|
200 * |
|
201 * @since S60 v5.0 |
|
202 */ |
|
203 IMPORT_C void ResetModelsL(); |
|
204 |
|
205 // from MHnEditModeInterface |
|
206 |
|
207 /** |
|
208 * Sets edit mode. |
|
209 * |
|
210 * @since S60 v5.0 |
|
211 * @param aEditMode Set edit mode member to false/true. |
|
212 */ |
|
213 void SetEditModeL( TBool aEditMode ); |
|
214 |
|
215 /** |
|
216 * Enables to issue a request to Hn engine. |
|
217 * |
|
218 * @since S60 v5.0 |
|
219 * @param aParam Input Parameters. |
|
220 * @param aOutput Target list for output. |
|
221 */ |
|
222 IMPORT_C void HandleRequestL( const CLiwGenericParamList& aParam, |
|
223 CLiwGenericParamList* aOutput = NULL); |
|
224 |
|
225 // from MHWRMLightObserver |
|
226 /** |
|
227 * Called when the device light status changes. |
|
228 * Note that if the light status for certain target changes |
|
229 * very rapidly, some state transitions might be missed. |
|
230 * It is however guaranteed that latest state is always obtained. |
|
231 * |
|
232 * @param aTarget Indicates target(s) the new status applies to. |
|
233 * @param aStatus Indicates light request status. |
|
234 */ |
|
235 virtual void LightStatusChanged(TInt aTarget, |
|
236 CHWRMLight::TLightStatus aStatus); |
|
237 |
|
238 private: |
|
239 /** |
|
240 * Default constructor. |
|
241 * |
|
242 * @since S60 v5.0 |
|
243 * @param aController Controller handler. |
|
244 */ |
|
245 CHnEngine( MHnControllerInterface& aController ); |
|
246 |
|
247 /** |
|
248 * Standard 2nd phase constructor. |
|
249 * |
|
250 * @since S60 v5.0 |
|
251 */ |
|
252 void ConstructL(); |
|
253 |
|
254 /** |
|
255 * Handle new suite loaded event. |
|
256 * |
|
257 * @since S60 v5.0 |
|
258 * @param aParams Event specific parameters. |
|
259 * @return Status code. |
|
260 */ |
|
261 TInt HandleNewSuiteLoadedEventL( CLiwGenericParamList& aParams ); |
|
262 |
|
263 /** |
|
264 * Handle open suit event. |
|
265 * |
|
266 * @since S60 v5.0 |
|
267 * @param aParams Event specific parameters that hold liw packed filter. |
|
268 * @return Status code. |
|
269 */ |
|
270 TInt HandleReevaluateEventL( CLiwGenericParamList& aParams ); |
|
271 |
|
272 /** |
|
273 * Handles widget change. |
|
274 * |
|
275 * @since S60 v5.0 |
|
276 * @param aParams Event specific parameters consist of target widget type. |
|
277 * @return Status code. |
|
278 */ |
|
279 TInt HandleWidgetChangeL( CLiwGenericParamList& aParams ); |
|
280 |
|
281 /** |
|
282 * Handles SetFocus event. |
|
283 * |
|
284 * @since S60 v5.0 |
|
285 * @param aParams Event specific parameters consist of target widget type. |
|
286 * @return Status code. |
|
287 */ |
|
288 TInt HandleSetFocusEventL( const CLiwGenericParamList& aParams ); |
|
289 |
|
290 /** |
|
291 * Handles MoveFocusBeforeDelete event. |
|
292 * |
|
293 * @since S60 v5.0 |
|
294 * @param aParams Event specific parameters consist of target widget type. |
|
295 * @return Status code. |
|
296 */ |
|
297 TInt HandleMoveFocusBeforeDeleteEventL( |
|
298 const CLiwGenericParamList& aParams ); |
|
299 |
|
300 /** |
|
301 * Handles RefreshIcons event. |
|
302 * |
|
303 * @since S60 v5.0 |
|
304 * @param aParams Event specific parameters (ignored) |
|
305 * @return Status code. |
|
306 */ |
|
307 TInt HandleRefreshIconsEventL( const CLiwGenericParamList& aParams ); |
|
308 |
|
309 /** |
|
310 * Handles DisableActionsForItem event. |
|
311 * |
|
312 * @since S60 v5.0 |
|
313 * @param aParams Event specific parameters - contains custom item id |
|
314 * @return Status code. |
|
315 */ |
|
316 TInt HandleDisableActionsForItemL( const CLiwGenericParamList& aParams ); |
|
317 |
|
318 /** |
|
319 * Store widget type to repository. |
|
320 * |
|
321 * @since S60 v5.0 |
|
322 * @param aSuiteName Suite name to that set widget type. |
|
323 * @param aType Widget type to store in repository. |
|
324 * @return Status code. |
|
325 */ |
|
326 TInt HandleWidgetChangeL( const TDesC& aSuiteName, |
|
327 THnSuiteWidgetType aType ); |
|
328 |
|
329 |
|
330 /** |
|
331 * Parse URI path component containing Suites to be loaded. |
|
332 * |
|
333 * @since S60 v5.0 |
|
334 * @param aUriPath Descriptor URI path which consist of suites' names. |
|
335 * @param aOutput Array on output containes parsed suite names. |
|
336 */ |
|
337 void ParseSuiteUriPathL( const TDesC8& aUriPath, |
|
338 CDesC8ArrayFlat& aOutput ); |
|
339 |
|
340 |
|
341 /** |
|
342 * Checks if only root configuration is loaded. |
|
343 * Used to decide if reloading models is needed. |
|
344 * |
|
345 * @since S60 v5.0 |
|
346 * @return Return ETrue if only root configuration is loaded |
|
347 * otherwise EFalse. |
|
348 */ |
|
349 TBool IsOnlyRootConfLoaded(); |
|
350 |
|
351 /** |
|
352 * Resets loaded resources. |
|
353 * |
|
354 * @since S60 5.0 |
|
355 */ |
|
356 void ResetLocalization(); |
|
357 |
|
358 /** |
|
359 * Loads suite with given suite name with parameters |
|
360 * from uri query. |
|
361 * |
|
362 * @since S60 5.0 |
|
363 * @param aSuiteName Name of the suite to load. |
|
364 * @param aUriQuery Descriptor containig parsed part of the uri. |
|
365 * @param aUriFragment Descriptor containig parsed part (fragment) of the uri. |
|
366 * @return Error code when loading suite. |
|
367 */ |
|
368 TInt LoadSuiteFromUriL( const TDesC8& aSuiteName, |
|
369 const TDesC8& aUriQuery, const TDesC8& aUriFragment ); |
|
370 |
|
371 /** |
|
372 * Reads highlight position from uri fragment |
|
373 * and sets it on the suite model. |
|
374 * |
|
375 * @since S60 5.0 |
|
376 * @param aUriFragment Descriptor containig parsed part of the uri. |
|
377 */ |
|
378 void HighlightPlacementFromUriL( const TDesC8& aUriFragment ); |
|
379 |
|
380 |
|
381 /** |
|
382 * Loads folder and sets focus through CR. |
|
383 * |
|
384 * @since S60 v5.0 |
|
385 */ |
|
386 void LoadFromCrL( const TDesC8& aUri ); |
|
387 |
|
388 /** |
|
389 * Handles loading suite from uri if suites names' are the same. |
|
390 * |
|
391 * @param aNextExists ETrue if the next suite's name exists in uri. |
|
392 * @param aUri The URI's parameters passed to the suite. |
|
393 */ |
|
394 void HandleTheSameSuitesL( TBool aNextExists, const TDesC8& aParams ); |
|
395 |
|
396 /** |
|
397 * Checks if suites have the same names. |
|
398 * |
|
399 * @param aLastSuiteName The last suite's name on the stack. |
|
400 * @param aFirstSuiteName The first suite's name in uri. |
|
401 * @return ETrue if names are equal |
|
402 */ |
|
403 TBool SuitesAreTheSameL( const TDesC& aLastSuiteName, const TDesC8& aFirstSuiteName ); |
|
404 |
|
405 /** |
|
406 * Decides whether to hide menu depending on current state and uri parameters |
|
407 * |
|
408 * @param aUri The Uri to parse for exit procedure. |
|
409 * @return ETrue If exit was consumed. |
|
410 */ |
|
411 TBool HandleActionL( const TDesC8& aUri ); |
|
412 |
|
413 /** |
|
414 * Loads suites from uri. |
|
415 * |
|
416 * @param aUri The uri to parse |
|
417 */ |
|
418 void LoadSuitesL( const TDesC8& aUri ); |
|
419 |
|
420 private: // data |
|
421 |
|
422 /** |
|
423 * Own - Meta data model. |
|
424 */ |
|
425 CHnMdModel* iMetaDataModel; |
|
426 |
|
427 /** |
|
428 * Own - Suite container. |
|
429 */ |
|
430 CHnSuiteModelContainer* iSuiteContainer; |
|
431 |
|
432 /** |
|
433 * Not own. |
|
434 * EikonEnv for displaying popup messages. |
|
435 */ |
|
436 CEikonEnv* iEEnv; |
|
437 |
|
438 /** |
|
439 * Not own - Suite observer. |
|
440 */ |
|
441 MHnControllerInterface& iControllerInterface; |
|
442 |
|
443 /** |
|
444 * Edit mode |
|
445 */ |
|
446 TBool iEditMode; |
|
447 |
|
448 /** |
|
449 * Light status observer |
|
450 */ |
|
451 CHWRMLight* iLight; |
|
452 }; |
|
453 |
|
454 #endif //C_HNENGINE_H |