author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:00:00 +0300 | |
branch | RCL_3 |
changeset 93 | b01126ce0bec |
parent 83 | 5456b4e8b3a8 |
child 102 | ba63c83f4716 |
permissions | -rw-r--r-- |
83 | 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_HNMDMODEL_H |
|
21 |
#define C_HNMDMODEL_H |
|
22 |
||
23 |
#include <e32base.h> |
|
24 |
#include <xmlengelement.h> |
|
25 |
#include <liwgenericparam.h> |
|
26 |
#include <eikenv.h> |
|
27 |
#include "hnglobals.h" |
|
28 |
||
29 |
class CHnMdLocalization; |
|
30 |
class CHnSuiteModelContainer; |
|
31 |
class CHnFilter; |
|
32 |
class THnIdGenerator; |
|
33 |
class CHnMdSuite; |
|
34 |
class CHnMdModel; |
|
35 |
class CHnItemId; |
|
36 |
class MHnSuiteObserver; |
|
37 |
class CHnXmlModelProvider; |
|
38 |
class CHnMdModel; |
|
39 |
class MHnMdModelEventObserver; |
|
40 |
class CHnSuiteModel; |
|
41 |
class CHnRepositoryObserver; |
|
42 |
class MHnEditModeInterface; |
|
43 |
class CHnBitmapIdCache; |
|
44 |
||
45 |
/** |
|
46 |
* Type of the property. |
|
47 |
* |
|
48 |
* @ingroup group_hnmetadatamodel |
|
49 |
*/ |
|
50 |
enum TPropertyType |
|
51 |
{ |
|
52 |
EUndefined = 0, |
|
53 |
EGenre, |
|
54 |
EVisualItemCount |
|
55 |
}; |
|
56 |
||
57 |
/** |
|
58 |
* Mode type. |
|
59 |
* |
|
60 |
* @ingroup group_hnmetadatamodel |
|
61 |
*/ |
|
62 |
enum TMdMode |
|
63 |
{ |
|
64 |
EMdModeNormal = 0, |
|
65 |
EMdModeEdit |
|
66 |
}; |
|
67 |
||
68 |
/** |
|
69 |
* Common pointers. |
|
70 |
* |
|
71 |
* @since S60 5.0 |
|
72 |
* @ingroup group_hnmetadatamodel |
|
73 |
*/ |
|
74 |
struct THnMdCommonPointers |
|
75 |
{ |
|
76 |
/** |
|
77 |
* Not own - Localization. |
|
78 |
*/ |
|
79 |
CHnMdLocalization* iLocalization; |
|
80 |
||
81 |
/** |
|
82 |
* Not own - Query generator. |
|
83 |
*/ |
|
84 |
THnIdGenerator* iIdGenerator; |
|
85 |
||
86 |
/** |
|
87 |
* Not own - Suite model container. |
|
88 |
*/ |
|
89 |
CHnSuiteModelContainer* iContainer; |
|
90 |
||
91 |
/** |
|
92 |
* Not own - Meta data model. |
|
93 |
*/ |
|
94 |
CHnMdModel* iModel; |
|
95 |
||
96 |
/** |
|
97 |
* Not own - Xml model provider. |
|
98 |
*/ |
|
99 |
CHnXmlModelProvider* iXmlModelProvider; |
|
100 |
||
101 |
/** |
|
102 |
* Not own - Cache for bitmap and mask ids. |
|
103 |
*/ |
|
104 |
CHnBitmapIdCache* iBitmapIdCache; |
|
105 |
||
106 |
/** |
|
107 |
* Not own - Model event observer. |
|
108 |
*/ |
|
109 |
MHnMdModelEventObserver* iModelEventObserver; |
|
110 |
||
111 |
/** |
|
112 |
* Not own - Edit mode interface. |
|
113 |
*/ |
|
114 |
MHnEditModeInterface* iEditModeInterface; |
|
115 |
||
116 |
/** |
|
117 |
* Not own - Handler to file server session; |
|
118 |
*/ |
|
119 |
RFs& iFs; |
|
120 |
||
121 |
/** |
|
122 |
* Gets static pointer from TLS. |
|
123 |
*/ |
|
124 |
static THnMdCommonPointers* Static() {return (THnMdCommonPointers*)Dll::Tls(); } |
|
125 |
||
126 |
/** |
|
127 |
* Sets pointer to TLS. |
|
128 |
* |
|
129 |
* @param aCmnPtrs Pointer to set |
|
130 |
*/ |
|
131 |
static void SetStatic( THnMdCommonPointers* aCmnPtrs ) { Dll::SetTls(aCmnPtrs); } |
|
132 |
||
133 |
private: |
|
134 |
||
135 |
// only model can create it |
|
136 |
friend class CHnMdModel; |
|
137 |
||
138 |
/** |
|
139 |
* Standard C++ consturctor. |
|
140 |
*/ |
|
141 |
THnMdCommonPointers() : iFs( CEikonEnv::Static()->FsSession() ) |
|
142 |
{ |
|
143 |
iLocalization = NULL; |
|
144 |
iIdGenerator = NULL; |
|
145 |
iContainer = NULL; |
|
146 |
iModel = NULL; |
|
147 |
iXmlModelProvider = NULL; |
|
148 |
iModelEventObserver = NULL; |
|
149 |
iEditModeInterface = NULL; |
|
150 |
} |
|
151 |
||
152 |
/** |
|
153 |
* Copy constructor declared as private to disallow copying. |
|
154 |
* |
|
155 |
* @param aCmnPtrs Pointer to set. |
|
156 |
*/ |
|
157 |
THnMdCommonPointers( const THnMdCommonPointers& aCmnPtrs ):iFs( aCmnPtrs.iFs ) { } |
|
158 |
||
159 |
/** |
|
160 |
* Assignment operator |
|
161 |
*/ |
|
162 |
THnMdCommonPointers& operator=( const THnMdCommonPointers& ){return *this;} |
|
163 |
}; |
|
164 |
||
165 |
/** |
|
166 |
* Id generator. |
|
167 |
* |
|
168 |
* @lib ?library |
|
169 |
* @since S60 5.0 |
|
170 |
* @ingroup group_hnmetadatamodel |
|
171 |
*/ |
|
172 |
struct THnIdGenerator |
|
173 |
{ |
|
174 |
/** |
|
175 |
* Standatrd C++ constructor. |
|
176 |
*/ |
|
177 |
THnIdGenerator() |
|
178 |
{ |
|
179 |
iId = 0; |
|
180 |
} |
|
181 |
||
182 |
/** |
|
183 |
* Gets next id. |
|
184 |
* @return Next id. |
|
185 |
*/ |
|
186 |
TInt GetNextId() |
|
187 |
{ |
|
188 |
return iId++; |
|
189 |
} |
|
190 |
private: |
|
191 |
||
192 |
/** |
|
193 |
* Copy constructor declared as private to disallow copying. |
|
194 |
* @param aGenerator Id generator; |
|
195 |
*/ |
|
196 |
THnIdGenerator(const THnIdGenerator& aGenerator); |
|
197 |
||
198 |
/** |
|
199 |
* Assignment operator. |
|
200 |
*/ |
|
201 |
THnIdGenerator& operator=(const THnIdGenerator&); |
|
202 |
||
203 |
/** |
|
204 |
* Id |
|
205 |
*/ |
|
206 |
TInt iId; |
|
207 |
}; |
|
208 |
||
209 |
/** |
|
210 |
* Model event observer. |
|
211 |
* |
|
212 |
* @since S60 5.0 |
|
213 |
* @ingroup group_hnmetadatamodel |
|
214 |
*/ |
|
215 |
class MHnMdModelEventObserver |
|
216 |
{ |
|
217 |
public: |
|
218 |
||
219 |
/** |
|
220 |
* Handles modlde event. |
|
221 |
* |
|
222 |
* @since S60 5.0 |
|
223 |
* @param aEventName Event name. |
|
224 |
* @param aParams Parameters. |
|
225 |
*/ |
|
226 |
virtual TInt HandleModelEventL( const TDesC& aEventName, |
|
227 |
CLiwGenericParamList& aParams ) = 0; |
|
228 |
}; |
|
229 |
||
230 |
/** |
|
231 |
* Meta data model |
|
232 |
* |
|
233 |
* This is the main class of the Meta Data Model component. |
|
234 |
* |
|
235 |
* This class is the entry point for building the meta data model |
|
236 |
* and for evaluation. |
|
237 |
* |
|
238 |
* @since S60 5.0 |
|
239 |
* @ingroup group_hnmetadatamodel |
|
240 |
*/ |
|
241 |
NONSHARABLE_CLASS( CHnMdModel ) : public CBase |
|
242 |
{ |
|
243 |
public: |
|
244 |
enum TForegroundGainTriggeringEvent |
|
245 |
{ |
|
246 |
EWhenAnySuiteIsEvaluated, |
|
247 |
EWhenCurrentTopSuiteIsEvaluated, |
|
248 |
ENever |
|
249 |
}; |
|
250 |
public: |
|
251 |
||
252 |
/** |
|
253 |
* Two-phase constructor. |
|
254 |
* |
|
255 |
* @since S60 5.0 |
|
256 |
* @param aModelObserver Model observer. |
|
257 |
* @param aSuiteModelContainer Suite model container. |
|
258 |
* @return Fully constructed object. |
|
259 |
*/ |
|
260 |
IMPORT_C static CHnMdModel* NewL( MHnMdModelEventObserver* aModelObserver, |
|
261 |
CHnSuiteModelContainer * aSuiteModelContainer ); |
|
262 |
||
263 |
/** |
|
264 |
* Two-phase constructor. |
|
265 |
* |
|
266 |
* @since S60 5.0 |
|
267 |
* @param aModelObserver Model observer. |
|
268 |
* @param aSuiteModelContainer Suite model container. |
|
269 |
* @return Fully constructed object. |
|
270 |
*/ |
|
271 |
IMPORT_C static CHnMdModel* NewLC( MHnMdModelEventObserver* aModelObserver, |
|
272 |
CHnSuiteModelContainer * aSuiteModelContainer ); |
|
273 |
||
274 |
/** |
|
275 |
* Standard C++ virtual destructor. |
|
276 |
* |
|
277 |
* @since S60 5.0 |
|
278 |
*/ |
|
279 |
virtual ~CHnMdModel(); |
|
280 |
||
281 |
/** |
|
282 |
* Evaluates the model. Takes filter as a parameter. |
|
283 |
* |
|
284 |
* @since S60 5.0 |
|
285 |
* @param aFilter Filter. |
|
286 |
*/ |
|
287 |
IMPORT_C void EvaluateL( CHnFilter& aFilter ); |
|
288 |
||
289 |
/** |
|
290 |
* Manages evaluation lock. |
|
291 |
* |
|
292 |
* @param aLock Locks evaluation if set to ETrue. |
|
293 |
* @param aEvaluate Runs evaluation if aEvaluate == ETrue. |
|
294 |
*/ |
|
295 |
IMPORT_C void SetEvaluationLockL( TBool aLock, TBool aEvaluate = ETrue ); |
|
296 |
||
297 |
/** |
|
298 |
* Evaluates the model. |
|
299 |
* |
|
300 |
* @since S60 5.0 |
|
301 |
*/ |
|
302 |
IMPORT_C void EvaluateL(); |
|
303 |
||
304 |
/** |
|
305 |
* Switches between edit mode and normal mode |
|
306 |
* |
|
307 |
* @since S60 5.0 |
|
308 |
* @param aMode Suite model container. |
|
309 |
*/ |
|
310 |
IMPORT_C void SetModeL( TMdMode aMode ); |
|
311 |
||
312 |
||
313 |
/** |
|
314 |
* Gets suite's meta data model. |
|
315 |
* |
|
316 |
* @since S60 5.0 |
|
317 |
* @return Suite meta data model. |
|
318 |
*/ |
|
319 |
IMPORT_C CHnMdSuite* GetLastSuite(); |
|
320 |
||
321 |
/** |
|
322 |
* Gets suite's meta data model. |
|
323 |
* |
|
324 |
* @since S60 5.0 |
|
325 |
* @param aPosition Position of the suite in the stack. |
|
326 |
* @return Suite meta data model. |
|
327 |
*/ |
|
328 |
CHnMdSuite* GetSuite( TInt aPosition ); |
|
329 |
||
330 |
/** |
|
331 |
* Gets suite's parameters.. |
|
332 |
* |
|
333 |
* @since S60 5.0 |
|
334 |
* @param aPosition Position of the suite in the stack, |
|
335 |
* from which gets parameters. |
|
336 |
* @return Suite meta data model. |
|
337 |
*/ |
|
338 |
IMPORT_C CLiwGenericParamList& GetSuiteParameters( TInt aPosition ); |
|
339 |
||
340 |
||
341 |
/** |
|
342 |
* Handles back event. |
|
343 |
* |
|
344 |
* @since S60 v3.2 |
|
345 |
* @param aMulContainer Suite model container. |
|
346 |
* @param aGenre Name of the suite. |
|
347 |
* @param aIterations Number of iterations. |
|
348 |
* @return Error code. |
|
349 |
*/ |
|
350 |
IMPORT_C TInt HandleBackEventL( CHnSuiteModelContainer* aMulContainer, |
|
351 |
const TDesC& aGenre, TInt aIterations = KModelCountForRoot ); |
|
352 |
||
353 |
/** |
|
354 |
* Handles sis installation event. |
|
355 |
* |
|
356 |
* @since S60 v3.2 |
|
357 |
* @param aMulContainer Suite model container. |
|
358 |
*/ |
|
359 |
IMPORT_C void HandleSisInstallationEventL( |
|
360 |
CHnSuiteModelContainer* aMulContainer ); |
|
361 |
||
362 |
/** |
|
363 |
* Loads a suite from xml data. |
|
364 |
* |
|
365 |
* @since S60 v5.0 |
|
366 |
* @param aGenre Name of the suite. |
|
367 |
* @param aSuiteParams Suite parameters. |
|
368 |
* @return Error code. |
|
369 |
*/ |
|
370 |
IMPORT_C TInt LoadSuiteL( const TDesC& aGenre, CLiwGenericParamList* aSuiteParams = NULL ); |
|
371 |
||
372 |
/** |
|
373 |
* Check if suite model exists. |
|
374 |
* |
|
375 |
* @since S60 5.0 |
|
376 |
* @param aSuiteModel Suite model name. |
|
377 |
* @return ETrue if suite model exists, otherwise EFalse. |
|
378 |
*/ |
|
379 |
IMPORT_C TBool SuiteModelExistsL( const TDesC8& aSuiteModel ); |
|
380 |
||
381 |
/** |
|
382 |
* Gets suite's meta data model. |
|
383 |
* |
|
384 |
* @since S60 5.0 |
|
385 |
* @param aUri Current ui. |
|
386 |
* @return Suite meta data model. |
|
387 |
*/ |
|
388 |
IMPORT_C void GetCurrentUriL( TDes& aUri ); |
|
389 |
||
390 |
/** |
|
391 |
* Deletes last loaded suite model from data model. |
|
392 |
* |
|
393 |
* @since S60 5.0 |
|
394 |
*/ |
|
395 |
IMPORT_C void DeleteLastSuite(); |
|
396 |
||
397 |
/** |
|
398 |
* Informs metadatamodel to ignore evaluations or |
|
399 |
* to performing evaluations, according to the |
|
400 |
* given parameter. |
|
401 |
* |
|
402 |
* @since S60 5.0 |
|
403 |
* @param aIgnore Metadatamodel ignores evaluations when set to ETrue. |
|
404 |
*/ |
|
405 |
IMPORT_C void IgnoreEvaluations( TBool aIgnore ); |
|
406 |
||
407 |
/** |
|
408 |
* Request that menu goes to foreground when evaluation completes. |
|
409 |
* |
|
410 |
* Default behavior is not to go to foreground when evaluation |
|
411 |
* completes. A change of this behavior requested with this method is |
|
412 |
* only effective until the menu is sent to foreground (once). Then the |
|
413 |
* default behavior is assumed again. |
|
414 |
* Subsequent calls override previous changes. |
|
415 |
* |
|
416 |
* @since S60 5.0 |
|
417 |
* @param aWhen Determines when the foreground should be gained. |
|
418 |
* Possible values are defined in the |
|
419 |
* TForegroundGainTriggeringEvent enum. The value ENever |
|
420 |
* simply means not to bring menu to foreground. |
|
421 |
*/ |
|
422 |
IMPORT_C void QueueForeground( TForegroundGainTriggeringEvent aWhen ); |
|
423 |
||
424 |
/** |
|
425 |
* Is there a queue for foreground gain. |
|
426 |
* |
|
427 |
* @since S60 5.0 |
|
428 |
* @return should foreground be gained after evaluation. |
|
429 |
*/ |
|
430 |
IMPORT_C TBool IsForegroundQueued() const; |
|
431 |
||
432 |
/** |
|
433 |
* Notifies this metadata model that suite evaluation has completed. |
|
434 |
* |
|
435 |
* @param aJustEvaluatedSuite pointer to the suite whose evaluation |
|
436 |
* has completed |
|
437 |
*/ |
|
438 |
void SuiteModelReadyToShowL( CHnSuiteModel* aJustEvaluatedSuite ); |
|
439 |
||
440 |
/** |
|
441 |
* Counts number of loaded suites. |
|
442 |
* |
|
443 |
* @since S60 5.0 |
|
444 |
* @return Number of loaded suites |
|
445 |
*/ |
|
446 |
TInt LoadedSuitesCount(); |
|
447 |
||
448 |
/** |
|
449 |
* Evaluates the suite model on top of the stack. |
|
450 |
* |
|
451 |
* @since S60 5.0 |
|
452 |
*/ |
|
453 |
void EvaluateTopSuiteL(); |
|
454 |
||
455 |
private: |
|
456 |
||
457 |
/** |
|
458 |
* Standard C++ constructor. |
|
459 |
* |
|
460 |
* @since S60 5.0 |
|
461 |
*/ |
|
462 |
CHnMdModel( ); |
|
463 |
||
464 |
/** |
|
465 |
* Standard symbian 2nd pahse constructor. |
|
466 |
* |
|
467 |
* @since S60 5.0 |
|
468 |
* @param aModelObserver Model observer. |
|
469 |
* @param aSuiteModelContainer Model container. |
|
470 |
*/ |
|
471 |
void ConstructL( MHnMdModelEventObserver* aModelObserver, |
|
472 |
CHnSuiteModelContainer * aSuiteModelContainer ); |
|
473 |
||
474 |
private: // data |
|
475 |
||
476 |
/** |
|
477 |
* Id generator. |
|
478 |
*/ |
|
479 |
THnIdGenerator iIdGenerator; |
|
480 |
||
481 |
/** |
|
482 |
* Own - Localization. |
|
483 |
*/ |
|
484 |
CHnMdLocalization* iLocalization; |
|
485 |
||
486 |
/** |
|
487 |
* Own - Xml model provider. |
|
488 |
*/ |
|
489 |
CHnXmlModelProvider* iXmlModelProvider; |
|
490 |
||
491 |
/** |
|
492 |
* Own - bitmap and mask ids cache. |
|
493 |
*/ |
|
494 |
CHnBitmapIdCache* iBitmapIdCache; |
|
495 |
||
496 |
/** |
|
497 |
* Not Own - Event observer. |
|
498 |
*/ |
|
499 |
MHnMdModelEventObserver* iModelEventObserver; |
|
500 |
||
501 |
/** |
|
502 |
* Stores pointers to common objects in the system |
|
503 |
* This object is shared throut the whole system. |
|
504 |
*/ |
|
505 |
THnMdCommonPointers iCmnPtrs; |
|
506 |
||
507 |
/** |
|
508 |
* Stores information about mode. |
|
509 |
*/ |
|
510 |
TMdMode iMode; |
|
511 |
||
512 |
/** |
|
513 |
* Loaded Suites stack. |
|
514 |
* Object and content owned. |
|
515 |
*/ |
|
516 |
RPointerArray<CHnMdSuite> iLoadedSuites; |
|
517 |
||
518 |
/** |
|
519 |
* Repository widget type observer. |
|
520 |
*/ |
|
521 |
CHnRepositoryObserver* iRepositoryWidgetTypeObserver; |
|
522 |
||
523 |
/** |
|
524 |
* Repository folder change observer. |
|
525 |
*/ |
|
526 |
CHnRepositoryObserver* iRepositoryShowFolderObserver; |
|
527 |
||
528 |
/** |
|
529 |
* When set, forces metadatamodel to skip evaluations. |
|
530 |
*/ |
|
531 |
TBool iIgnoreEvaluations; |
|
532 |
||
533 |
/** |
|
534 |
* Queues foreground gain action. |
|
535 |
*/ |
|
536 |
TBool iForegroundQueued; |
|
537 |
||
538 |
/** |
|
539 |
* Not own - pointer to the suite model that must be evaluated |
|
540 |
* before matrix menu can be brought to foreground. |
|
541 |
* |
|
542 |
* When NULL, then any suite evaluation brings menu to foreground. |
|
543 |
* It is only meaningful when iForegroundQueued is ETrue. |
|
544 |
*/ |
|
545 |
CHnSuiteModel* iForegroundTriggeringSuite; |
|
546 |
||
93
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
547 |
/** |
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
548 |
* Repository open item change observer. |
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
549 |
*/ |
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
550 |
CHnRepositoryObserver* iRepositoryOpenItemObserver; |
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
551 |
|
83 | 552 |
}; |
553 |
||
554 |
#endif // C_HNMDMODEL_H |