|
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 #include <uri8.h> |
|
20 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
21 #include <sacls.h> |
|
22 #include <apgtask.h> |
|
23 #include <centralrepository.h> |
|
24 #include <AknUtils.h> |
|
25 |
|
26 #include "hnengine.h" |
|
27 #include "hnconvutils.h" |
|
28 #include "hncontrollerinterface.h" |
|
29 #include "hnfilter.h" |
|
30 #include "hnsuitemodelcontainer.h" |
|
31 #include "hnsuitemodel.h" |
|
32 #include "hnserviceglobals.h" |
|
33 #include "hnglobals.h" |
|
34 #include "hnmdsuite.h" |
|
35 #include "hnitemid.h" |
|
36 #include "hnliwutils.h" |
|
37 #include "hnrepositorymanager.h" |
|
38 #include "menudebug.h" |
|
39 #include "hnrepositorymanager.h" |
|
40 #include "hnsuiteobserver.h" |
|
41 #include "hnmdbasekey.h" |
|
42 #include "hnitemsorder.h" |
|
43 |
|
44 _LIT8( KAnd8, "&" ); |
|
45 _LIT8( KEquals8, "=" ); |
|
46 |
|
47 // ======== MEMBER FUNCTIONS ======== |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 void CHnEngine::ConstructL() |
|
54 { |
|
55 iEEnv = CEikonEnv::Static(); |
|
56 iSuiteContainer = CHnSuiteModelContainer::NewL( *this , iControllerInterface ); |
|
57 iMetaDataModel = CHnMdModel::NewL( this, iSuiteContainer ); |
|
58 iLight = CHWRMLight::NewL(this); |
|
59 iInstObserver = CHnInstallNotifier::NewL( this, |
|
60 KUidSystemCategory, KSAUidSoftwareInstallKeyValue ); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 EXPORT_C CHnEngine* CHnEngine::NewL( MHnControllerInterface& aController ) |
|
68 { |
|
69 CHnEngine* self = CHnEngine::NewLC( aController ); |
|
70 CleanupStack::Pop( self ); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 EXPORT_C CHnEngine* CHnEngine::NewLC( MHnControllerInterface& aController ) |
|
79 { |
|
80 CHnEngine* self = new( ELeave ) CHnEngine( aController ); |
|
81 CleanupStack::PushL( self ); |
|
82 self->ConstructL(); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 CHnEngine::CHnEngine( MHnControllerInterface& aController ): |
|
91 iControllerInterface( aController ) |
|
92 { |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 CHnEngine::~CHnEngine() |
|
100 { |
|
101 delete iInstObserver; |
|
102 delete iLight; |
|
103 if( iSuiteContainer ) |
|
104 { |
|
105 iSuiteContainer->RemoveLiwObjects(); |
|
106 } |
|
107 delete iMetaDataModel; |
|
108 delete iSuiteContainer; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 TInt CHnEngine::GetSuiteModelsCountL() |
|
116 { |
|
117 return iSuiteContainer->GetSuiteModelCount(); |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 TBool CHnEngine::SuiteModelLoadedL( TInt aId ) |
|
125 { |
|
126 TBool ret( EFalse ); |
|
127 TInt count( iSuiteContainer->GetSuiteModelCount() ); |
|
128 for( int i=0; i<count; i++ ) |
|
129 { |
|
130 CHnSuiteModel* suite = iSuiteContainer->GetSuiteModel( i ); |
|
131 if( suite->GetItemsOrder()->GetSuiteId() == aId ) |
|
132 { |
|
133 ret = ETrue; |
|
134 break; |
|
135 } |
|
136 } |
|
137 return ret; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 CHnSuiteModel* CHnEngine::GetLastSuiteModelL() |
|
145 { |
|
146 return iSuiteContainer->GetLastSuiteModel(); |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 CHnSuiteModel* CHnEngine::GetParentSuiteModelL() |
|
154 { |
|
155 return iSuiteContainer->GetParentSuiteModel(); |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C TInt CHnEngine::TriggerHnEventL( const TInt aHnEventId, |
|
163 const TInt aRecipientId, CLiwGenericParamList* aEventParameters ) |
|
164 { |
|
165 TInt ret = iSuiteContainer->OfferHnEventL( aHnEventId, aRecipientId, |
|
166 aEventParameters); |
|
167 return ret; |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CHnEngine::HighlightPlacementFromUriL( const TDesC8& aUriFragment ) |
|
175 { |
|
176 TLex8 lexFrag( aUriFragment ); |
|
177 TInt highLight( 0 ); |
|
178 if( !( lexFrag.Val( highLight ) ) ) |
|
179 { |
|
180 iSuiteContainer->GetLastSuiteModel()->SetSuiteHighlightL( highLight ); |
|
181 iControllerInterface.HandleSuiteEventL( ESuiteHighlightChanged, |
|
182 iSuiteContainer->GetLastSuiteModel() ); |
|
183 } |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 TInt CHnEngine::LoadSuiteFromUriL( const TDesC8& aSuiteName, |
|
191 const TDesC8& aUriQuery, const TDesC8& aUriFragment ) |
|
192 { |
|
193 TInt error( KErrNone ); |
|
194 |
|
195 if( !( aSuiteName.Compare( KRoot8 ) ) ) |
|
196 { |
|
197 CLiwGenericParamList* uriParams = |
|
198 UriQueryToLiwListLC( aUriQuery, aUriFragment, aSuiteName ); |
|
199 CLiwGenericParamList* params = CLiwGenericParamList::NewLC(); |
|
200 params->AppendL( iMetaDataModel->GetSuiteParameters( 0 ) ); |
|
201 params->AppendL( *uriParams ); |
|
202 ResetModelsL(); |
|
203 iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated ); |
|
204 error = InitializeL( *params ); |
|
205 CleanupStack::PopAndDestroy( params ); |
|
206 CleanupStack::PopAndDestroy( uriParams ); |
|
207 } |
|
208 else |
|
209 { |
|
210 CLiwGenericParamList* params = |
|
211 UriQueryToLiwListLC( aUriQuery, aUriFragment, aSuiteName ); |
|
212 |
|
213 HBufC* suiteName = HnConvUtils::Str8ToStrLC( aSuiteName ); |
|
214 params->AppendL( TLiwGenericParam( KNewSuiteParamNameEn, |
|
215 TLiwVariant( *suiteName ) ) ); |
|
216 |
|
217 error = HandleNewSuiteLoadedEventL( *params ); |
|
218 |
|
219 CleanupStack::PopAndDestroy( suiteName ); |
|
220 CleanupStack::PopAndDestroy( params ); |
|
221 } |
|
222 |
|
223 return error; |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 TBool CHnEngine::SuitesAreTheSameL( const TDesC& aLastSuiteName, |
|
231 const TDesC8& aFirstSuiteName ) |
|
232 { |
|
233 RBuf8 lastSuiteName; |
|
234 CleanupClosePushL( lastSuiteName ); |
|
235 lastSuiteName.CreateL( aLastSuiteName.Length() ); |
|
236 lastSuiteName.Copy( aLastSuiteName ); |
|
237 TBool suitesAreTheSame( !lastSuiteName.Compare( aFirstSuiteName ) ); |
|
238 CleanupStack::PopAndDestroy( &lastSuiteName ); |
|
239 return suitesAreTheSame; |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CHnEngine::HandleTheSameSuitesL( TBool aNextExists, const TDesC8& aParams ) |
|
247 { |
|
248 RBuf exitMode; |
|
249 CleanupClosePushL( exitMode ); |
|
250 CLiwGenericParamList* params = UriQueryToLiwListLC( aParams, KNullDesC8, KNullDesC8 ); |
|
251 HnLiwUtils::GetStringL( *params, KExitModeParams, exitMode ); |
|
252 |
|
253 if ( !exitMode.Compare( KExitModeHide ) ) |
|
254 { |
|
255 // set parameters |
|
256 iSuiteContainer->GetLastSuiteModel()->SetExitMode( EExitModeHide ); |
|
257 } |
|
258 |
|
259 CleanupStack::PopAndDestroy( params ); |
|
260 CleanupStack::PopAndDestroy( &exitMode ); |
|
261 |
|
262 if ( !aNextExists ) |
|
263 { |
|
264 // refresh if necessary |
|
265 iControllerInterface.NotifyUiRefreshL( ERefreshSuite ); |
|
266 } |
|
267 } |
|
268 // --------------------------------------------------------------------------- |
|
269 // |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 EXPORT_C void CHnEngine::LoadSuitesFromUriL( const TDesC8& aUri ) |
|
273 { |
|
274 DEBUG(("_MM_:CHnEngine::LoadSuitesFromUriL IN")); |
|
275 DEBUG8(("_MM_:\tURI: %S",&aUri)); |
|
276 |
|
277 TBool consumed(EFalse); |
|
278 |
|
279 if ( aUri.Find( KSetFocusWithPref ) != KErrNotFound ) |
|
280 { |
|
281 LoadFromCrL( aUri ); |
|
282 consumed = ETrue; |
|
283 } |
|
284 |
|
285 if ( !consumed ) |
|
286 { |
|
287 consumed = HandleActionL( aUri ); |
|
288 } |
|
289 |
|
290 if ( !consumed ) |
|
291 { |
|
292 LoadSuitesL( aUri ); |
|
293 } |
|
294 |
|
295 DEBUG(("_MM_:CHnEngine::LoadSuitesFromUriL OUT")); |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 // --------------------------------------------------------------------------- |
|
301 // |
|
302 TInt CHnEngine::HandleModelEventL( const TDesC& aEventName, |
|
303 CLiwGenericParamList& aParams ) |
|
304 { |
|
305 TInt ret(KErrNotFound); |
|
306 |
|
307 if ( aEventName == KNewSuiteLoadedMdEvent ) |
|
308 { |
|
309 // This handles new suite creation, putting its visual model |
|
310 // onto the stack eventually. |
|
311 ret = HandleNewSuiteLoadedEventL( aParams ); |
|
312 } |
|
313 else if ( aEventName == KBackMdEvent ) |
|
314 { |
|
315 const TDesC& suiteName = iSuiteContainer->GetLastSuiteModel()->SuiteName(); |
|
316 ret = HandleBackEventL( suiteName ); |
|
317 } |
|
318 else if (aEventName == KReevaluateMdEvent ) |
|
319 { |
|
320 // This event triggers reevaluate on the model. |
|
321 // aParams holds liw packed filter. |
|
322 ret = HandleReevaluateEventL( aParams ); |
|
323 } |
|
324 else if (aEventName == KSwitchWidgetMdEvent ) |
|
325 { |
|
326 // Widget change is requested. |
|
327 ret = HandleWidgetChangeL( aParams ); |
|
328 } |
|
329 else if (aEventName == KRefreshUiMdEvent ) |
|
330 { |
|
331 // Refresh of the whole of the UI is refreshed |
|
332 iControllerInterface.NotifyUiRefreshL( ERefreshSuite ); |
|
333 ret = KErrNone; |
|
334 } |
|
335 else if (aEventName == KRefreshToolbarMdEvent ) |
|
336 { |
|
337 // Just the toolbar in UI is refreshed |
|
338 iControllerInterface.NotifyUiRefreshL( ERefreshToolbar ); |
|
339 ret = KErrNone; |
|
340 } |
|
341 else if (aEventName == KStartEditModeMdEvent ) |
|
342 { |
|
343 // Starting edit mode |
|
344 iControllerInterface.NotifyUiRefreshL( EStartEditMode ); |
|
345 ret = KErrNone; |
|
346 } |
|
347 else if (aEventName == KStopEditModeMdEvent ) |
|
348 { |
|
349 // Stopping edit mode |
|
350 iControllerInterface.NotifyUiRefreshL( EStopEditMode ); |
|
351 ret = KErrNone; |
|
352 } |
|
353 else if (aEventName == KSetFocusEvent ) |
|
354 { |
|
355 // SetFocus |
|
356 ret = HandleSetFocusEventL( aParams ); |
|
357 } |
|
358 else if (aEventName == KZoomLarge ) |
|
359 { |
|
360 // Stopping edit mode |
|
361 iControllerInterface.NotifyUiRefreshL( EZoomLarge ); |
|
362 ret = KErrNone; |
|
363 } |
|
364 else if (aEventName == KZoomSmall) |
|
365 { |
|
366 // Stopping edit mode |
|
367 iControllerInterface.NotifyUiRefreshL( EZoomSmall ); |
|
368 ret = KErrNone; |
|
369 } |
|
370 else if (aEventName == KZoomNormal ) |
|
371 { |
|
372 // Stopping edit mode |
|
373 iControllerInterface.NotifyUiRefreshL( EZoomNormal ); |
|
374 ret = KErrNone; |
|
375 } |
|
376 else if (aEventName == KAppGainForeground ) |
|
377 { |
|
378 //force matrix gain foreground |
|
379 DEBUG(("_MM_:CHnEngine::HandleModelEventL EForegroundGain")); |
|
380 iControllerInterface.NotifyUiRefreshL( EForegroundGain ); |
|
381 ret = KErrNone; |
|
382 } |
|
383 else if (aEventName == KAppGainBackground ) |
|
384 { |
|
385 //force matrix gain background |
|
386 DEBUG(("_MM_:CHnEngine::HandleModelEventL EBackgroundGain")); |
|
387 iControllerInterface.NotifyUiRefreshL( EBackgroundGain ); |
|
388 ret = KErrNone; |
|
389 } |
|
390 |
|
391 return ret; |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 TInt CHnEngine::HandleWidgetChangeL( |
|
399 CLiwGenericParamList& aParams ) |
|
400 { |
|
401 THnSuiteWidgetType type = EChangeWidget; |
|
402 TInt pos( 0 ); |
|
403 const TLiwGenericParam* param = NULL; |
|
404 param = aParams.FindFirst( pos, KWidgetTypeAttrName8 ); |
|
405 if ( pos != KErrNotFound ) |
|
406 { |
|
407 TPtrC widgetType( KNullDesC ); |
|
408 param->Value().Get( widgetType ); |
|
409 if ( widgetType.Compare( KWidgetTypeList ) == 0 ) |
|
410 type = EListWidget; |
|
411 else if ( widgetType.Compare( KWidgetTypeGrid ) == 0 ) |
|
412 type = EGridWidget; |
|
413 else if ( widgetType.Compare( KWidgetTypeCoverFlow ) == 0 ) |
|
414 type = ECoverFlowWidget; |
|
415 } |
|
416 |
|
417 CHnSuiteModel* model = iSuiteContainer->GetLastSuiteModel(); |
|
418 return HandleWidgetChangeL( model->SuiteName(), type ); |
|
419 } |
|
420 |
|
421 // --------------------------------------------------------------------------- |
|
422 // |
|
423 // --------------------------------------------------------------------------- |
|
424 // |
|
425 TInt CHnEngine::HandleWidgetChangeL( const TDesC& aSuiteName, |
|
426 THnSuiteWidgetType aType ) |
|
427 { |
|
428 DEBUG(("_MM_:CMatrixMenuAppUi::HandleWidgetChangeL IN")); |
|
429 TInt ret( KErrGeneral ); |
|
430 |
|
431 CHnRepositoryManager* rep = CHnRepositoryManager::NewLC(); |
|
432 THnSuiteWidgetType type( EUnspecified ); |
|
433 TInt err( rep->ReadSuiteWidgetTypeL( aSuiteName, type ) ); |
|
434 |
|
435 if( ( !err || err == KErrNotFound ) && type != EUnspecified ) |
|
436 { |
|
437 ret = rep->StoreSuiteWidgetTypeL( aSuiteName, aType ); |
|
438 } |
|
439 CleanupStack::PopAndDestroy( rep ); |
|
440 DEBUG(("_MM_:CMatrixMenuAppUi::HandleWidgetChangeL OUT")); |
|
441 return ret; |
|
442 } |
|
443 |
|
444 // --------------------------------------------------------------------------- |
|
445 // |
|
446 // --------------------------------------------------------------------------- |
|
447 // |
|
448 TInt CHnEngine::HandleReevaluateEventL( |
|
449 CLiwGenericParamList& aParams ) |
|
450 { |
|
451 TInt ret(KErrNone); |
|
452 // Paths to retrieve filter values |
|
453 _LIT8( KGenreGlobalPath, "filter:genre"); |
|
454 _LIT8( KIdGlobalPath, "filter:id"); |
|
455 _LIT8( KGenrePath, "filter:[%d]/genre"); |
|
456 _LIT8( KItemPath, "filter:[%d]/item"); |
|
457 |
|
458 CHnFilter* filter = CHnFilter::NewLC(); |
|
459 |
|
460 TLiwGenericParam param; |
|
461 param.PushL(); |
|
462 aParams.AtL(0, param); |
|
463 ASSERT( !param.Name().Compare( KFilterElementItem8 ) ); |
|
464 |
|
465 TLiwVariant suiteIdVariant; |
|
466 suiteIdVariant.PushL(); |
|
467 TLiwVariant genreVariant; |
|
468 genreVariant.PushL(); |
|
469 TInt idFound = |
|
470 HnLiwUtils::GetVariantL( aParams, KIdGlobalPath(), suiteIdVariant ); |
|
471 TInt found = |
|
472 HnLiwUtils::GetVariantL(aParams, KGenreGlobalPath(), genreVariant ); |
|
473 if (idFound != KErrNotFound) |
|
474 { |
|
475 filter->SetSuiteId( suiteIdVariant.AsTInt32() ); |
|
476 filter->SetEvaluateSuiteL( ETrue ); |
|
477 } |
|
478 else if (found != KErrNotFound && found != KErrBadDescriptor) |
|
479 { |
|
480 filter->SetSuiteNameL( genreVariant.AsDes() ); |
|
481 filter->SetEvaluateSuiteL( ETrue ); |
|
482 } |
|
483 else |
|
484 { |
|
485 filter->SetEvaluateSuiteL( EFalse ); |
|
486 // For each entry in the fitler list.... |
|
487 for ( int i=0; i< param.Value().AsList()->Count(); i++ ) |
|
488 { |
|
489 RBuf8 path; |
|
490 CleanupClosePushL( path ); |
|
491 path.CreateL( KGenrePath().Length() ); |
|
492 path.Format( KGenrePath, i ); |
|
493 TLiwVariant genreVariant; |
|
494 HnLiwUtils::GetVariantL(aParams, path, genreVariant ); |
|
495 path.Close(); |
|
496 path.CreateL( KItemPath().Length() ); |
|
497 path.Format( KItemPath, i ); |
|
498 TLiwVariant itemVariant; |
|
499 HnLiwUtils::GetVariantL(aParams, path, itemVariant ); |
|
500 CleanupStack::PopAndDestroy( &path ); |
|
501 |
|
502 TPtrC suiteName; |
|
503 TPtrC itemId; |
|
504 genreVariant.Get(suiteName); |
|
505 itemVariant.Get(itemId); |
|
506 |
|
507 CHnItemId* itemIdObject = CHnItemId::NewLC(suiteName, itemId); |
|
508 filter->AppendItemIdL( itemIdObject ); |
|
509 CleanupStack::Pop( itemIdObject ); |
|
510 |
|
511 genreVariant.Reset(); |
|
512 itemVariant.Reset(); |
|
513 } |
|
514 } |
|
515 CleanupStack::PopAndDestroy( &genreVariant ); |
|
516 CleanupStack::PopAndDestroy( &suiteIdVariant ); |
|
517 CleanupStack::PopAndDestroy( ¶m ); |
|
518 iMetaDataModel->EvaluateL( *filter ); |
|
519 CleanupStack::PopAndDestroy( filter ); |
|
520 return ret; |
|
521 } |
|
522 |
|
523 // --------------------------------------------------------------------------- |
|
524 // |
|
525 // --------------------------------------------------------------------------- |
|
526 // |
|
527 TInt CHnEngine::HandleBackEventL( const TDesC& aGenre, TInt aIterations ) |
|
528 { |
|
529 return iMetaDataModel->HandleBackEventL( |
|
530 iSuiteContainer, aGenre, aIterations ); |
|
531 } |
|
532 |
|
533 // --------------------------------------------------------------------------- |
|
534 // |
|
535 // --------------------------------------------------------------------------- |
|
536 // |
|
537 TInt CHnEngine::HandleNewSuiteLoadedEventL( |
|
538 CLiwGenericParamList& aParams ) |
|
539 { |
|
540 DEBUG(("_MM_:CHnEngine::HandleNewSuiteLoadedEventL IN")); |
|
541 TInt err( KErrNone ); |
|
542 const TLiwGenericParam* param = |
|
543 aParams.FindFirst( err, KNewSuiteParamNameEn ); |
|
544 if( err != KErrNotFound ) |
|
545 { |
|
546 TPtrC genre; |
|
547 param->Value().Get( genre ); |
|
548 DEBUG16(("_MM_:\tSuite genre name: %S",&genre)); |
|
549 // load and evaluate the suite |
|
550 err = iMetaDataModel->LoadSuiteL( genre, &aParams ); |
|
551 if ( !err ) |
|
552 { |
|
553 GetLastSuiteModelL()->RegisterSuiteObserverL( &iControllerInterface, EPriorityNull ); |
|
554 CHnFilter* filter = CHnFilter::NewLC(); |
|
555 filter->SetSuiteNameL( genre ); |
|
556 filter->SetEvaluateSuiteL( ETrue ); |
|
557 if ( iEditMode ) |
|
558 { |
|
559 iMetaDataModel->SetModeL( EMdModeEdit ); |
|
560 } |
|
561 else |
|
562 { |
|
563 iMetaDataModel->SetModeL( EMdModeNormal ); |
|
564 } |
|
565 |
|
566 TRAP( err, iMetaDataModel->EvaluateL( *filter ) ); |
|
567 |
|
568 CleanupStack::PopAndDestroy( filter ); |
|
569 if ( err ) |
|
570 { |
|
571 iMetaDataModel->DeleteLastSuite(); |
|
572 iSuiteContainer->PopSuiteModelL( genre ); |
|
573 } |
|
574 } |
|
575 else |
|
576 { |
|
577 // show error note to User |
|
578 HBufC* message( NULL ); |
|
579 switch ( err ) |
|
580 { |
|
581 case KErrPathNotFound : |
|
582 { |
|
583 message = KDebugNoteDirNotFound().AllocL(); |
|
584 } |
|
585 break; |
|
586 case KErrNotFound : |
|
587 { |
|
588 message = KDebugNoteFileNotFound().AllocL(); |
|
589 } |
|
590 break; |
|
591 default : |
|
592 { |
|
593 message = HBufC::NewL( KDebugNoteOtherError().Length() + |
|
594 KMaxLength ); |
|
595 message->Des().AppendFormat( KDebugNoteOtherError, err ); |
|
596 } |
|
597 break; |
|
598 } |
|
599 iEEnv->AlertWin( *message ); |
|
600 delete message; |
|
601 } |
|
602 } |
|
603 DEBUG(("_MM_:\tReturned error code: %d",err)); |
|
604 DEBUG(("_MM_:CHnEngine::HandleNewSuiteLoadedEventL OUT")); |
|
605 |
|
606 return err; |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------------------------- |
|
610 // |
|
611 // --------------------------------------------------------------------------- |
|
612 // |
|
613 TInt CHnEngine::HandleSetFocusEventL( const CLiwGenericParamList& aParams ) |
|
614 { |
|
615 // Triggering event in hierarchy navigator, specifying |
|
616 // that suite given by the name genre has been |
|
617 DEBUG(("_MM_:CHnEngine::HandleSetFocusEventL IN")); |
|
618 |
|
619 TInt posSuite( 0 ); |
|
620 TInt posItem( 0 ); |
|
621 TInt64 suiteCustomId( KErrNotFound ); |
|
622 TInt64 itemCustomId( KErrNotFound ); |
|
623 |
|
624 // Get suite's and item's custom ids. |
|
625 const TLiwGenericParam* paramSuiteId = aParams.FindFirst( posSuite, KSuiteCustomId8 ); |
|
626 const TLiwGenericParam* paramItemId = aParams.FindFirst( posItem, KItemCustomId8 ); |
|
627 |
|
628 |
|
629 if ( posSuite >= 0 && posItem >= 0 ) |
|
630 { |
|
631 suiteCustomId = paramSuiteId->Value().AsTInt64(); |
|
632 itemCustomId = paramItemId->Value().AsTInt64(); |
|
633 |
|
634 // Get matching suite. |
|
635 CHnSuiteModel* suiteModel = iSuiteContainer->GetMatchingSuiteModel( suiteCustomId ); |
|
636 |
|
637 if ( suiteModel ) |
|
638 { |
|
639 // If suite is not null, then find matching item model. |
|
640 TInt index( KErrNotFound ); |
|
641 CHnItemModel* itemModel = suiteModel->GetMatchingItemModelL( itemCustomId, index ); |
|
642 |
|
643 if ( itemModel ) |
|
644 { |
|
645 // If itemModel is not null then set highlight and set highligh |
|
646 // on matching item. |
|
647 suiteModel->SetSuiteHighlightL( index ); |
|
648 iControllerInterface.HandleSuiteEventL( ESuiteHighlightChanged, suiteModel ); |
|
649 } |
|
650 else |
|
651 { |
|
652 suiteModel->QueueFocus( itemCustomId ); |
|
653 } |
|
654 } |
|
655 } |
|
656 |
|
657 DEBUG(("_MM_:CHnEngine::HandleSetFocusEventL OUT")); |
|
658 return KErrNone; |
|
659 } |
|
660 |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 // --------------------------------------------------------------------------- |
|
664 // |
|
665 TInt CHnEngine::HandleMoveFocusBeforeDeleteEventL( |
|
666 const CLiwGenericParamList& /* aParams */ ) |
|
667 { |
|
668 // Triggering event in hierarchy navigator, specifying |
|
669 // that suite given by the name genre has been |
|
670 DEBUG(("_MM_:CHnEngine::HandleMoveFocusBeforeDeleteEventL IN")); |
|
671 |
|
672 TInt currentHighlight( GetLastSuiteModelL()->GetSuiteHighlight() ); |
|
673 TInt itemsCount( GetLastSuiteModelL()->GetItemModelsCount() ); |
|
674 |
|
675 TInt shift( 0 ); |
|
676 if( AknLayoutUtils::PenEnabled() && iEditMode ) |
|
677 { |
|
678 // add empty item |
|
679 shift = 1; |
|
680 } |
|
681 if( currentHighlight == itemsCount - shift - 1 ) |
|
682 { |
|
683 GetLastSuiteModelL()->SetSuiteHighlightL( currentHighlight - 1 ); |
|
684 } |
|
685 else |
|
686 { |
|
687 GetLastSuiteModelL()->SetSuiteHighlightL( currentHighlight + 1 ); |
|
688 } |
|
689 iControllerInterface.HandleSuiteEventL( |
|
690 ESuiteHighlightChanged, GetLastSuiteModelL() ); |
|
691 |
|
692 DEBUG(("_MM_:CHnEngine::HandleMoveFocusBeforeDeleteEventL OUT")); |
|
693 return KErrNone; |
|
694 } |
|
695 |
|
696 // --------------------------------------------------------------------------- |
|
697 // |
|
698 // --------------------------------------------------------------------------- |
|
699 // |
|
700 TInt CHnEngine::HandleRefreshIconsEventL( const CLiwGenericParamList& /* aParams */ ) |
|
701 { |
|
702 iMetaDataModel->EvaluateL(); |
|
703 return KErrNone; |
|
704 } |
|
705 |
|
706 // --------------------------------------------------------------------------- |
|
707 // |
|
708 // --------------------------------------------------------------------------- |
|
709 // |
|
710 TInt CHnEngine::HandleDisableActionsForItemL( const CLiwGenericParamList& aParams ) |
|
711 { |
|
712 TInt pos( 0 ); |
|
713 aParams.FindFirst( pos, KItemCustomId8 ); |
|
714 if ( pos != KErrNotFound ) |
|
715 { |
|
716 TInt itemCustomId = aParams[pos].Value().AsTInt32(); |
|
717 TInt itemId = 0; |
|
718 CHnItemModel* itemModel = |
|
719 iSuiteContainer->GetLastSuiteModel()->GetMatchingItemModelL( |
|
720 itemCustomId, itemId ); |
|
721 if ( itemModel ) |
|
722 { |
|
723 itemModel->DeleteAllActionModels(); |
|
724 } |
|
725 } |
|
726 return KErrNone; |
|
727 } |
|
728 |
|
729 // --------------------------------------------------------------------------- |
|
730 // |
|
731 // --------------------------------------------------------------------------- |
|
732 // |
|
733 void CHnEngine::InstallChangeL( TInt aStatus ) |
|
734 { |
|
735 switch ( aStatus) |
|
736 { |
|
737 case EInstOpNone: |
|
738 { |
|
739 iMetaDataModel->HandleSisInstallationEventL( iSuiteContainer ); |
|
740 break; |
|
741 } |
|
742 case EInstOpInstall: |
|
743 case EInstOpUninstall: |
|
744 { |
|
745 iMetaDataModel->ReleaseLocalization(); |
|
746 break; |
|
747 } |
|
748 } |
|
749 } |
|
750 // --------------------------------------------------------------------------- |
|
751 // |
|
752 // --------------------------------------------------------------------------- |
|
753 // |
|
754 EXPORT_C TInt CHnEngine::InitializeL( CLiwGenericParamList& aParam ) |
|
755 { |
|
756 DEBUG(("_MM_:CMatrixMenuAppUi::InitializeL IN")); |
|
757 User::LeaveIfError( HandleNewSuiteLoadedEventL( aParam ) ); |
|
758 DEBUG(("_MM_:CMatrixMenuAppUi::InitializeL OUT")); |
|
759 // This is an interface method so some value has to be returned. |
|
760 return KErrNone; |
|
761 } |
|
762 |
|
763 // --------------------------------------------------------------------------- |
|
764 // |
|
765 // --------------------------------------------------------------------------- |
|
766 // |
|
767 void CHnEngine::ParseSuiteUriPathL( const TDesC8& aUriPath, |
|
768 CDesC8ArrayFlat& aOutput ) |
|
769 { |
|
770 DEBUG(("_MM_:CHnEngine::ParseSuiteUriPathL IN")); |
|
771 DEBUG(("_MM_:\tURI path: %S",&aUriPath)); |
|
772 if ( aUriPath.Length() ) |
|
773 { |
|
774 // copy the path so we can freely trim already parsed chunks |
|
775 RBuf8 buf( aUriPath.AllocL() ); |
|
776 CleanupClosePushL( buf ); |
|
777 |
|
778 // get rid of the initial slash |
|
779 if ( buf[0] == KSlash8()[0] ) |
|
780 { |
|
781 buf.Delete( 0, 1 ); |
|
782 DEBUG(("_MM_:\tDeleted leading slash")); |
|
783 } |
|
784 |
|
785 // get the first chunk |
|
786 TInt slashPos = buf.Find( KSlash8 ); |
|
787 TPtrC8 chunkPtr; |
|
788 if ( slashPos != KErrNotFound ) |
|
789 { |
|
790 chunkPtr.Set( buf.Left( slashPos ) ); |
|
791 } |
|
792 else |
|
793 { |
|
794 // no slash - one chunk path |
|
795 chunkPtr.Set( buf ); |
|
796 } |
|
797 |
|
798 while ( chunkPtr.Length() ) |
|
799 { |
|
800 aOutput.AppendL( chunkPtr ); |
|
801 DEBUG8(( "_MM_:\t\tParsed segment: %S", &chunkPtr )); |
|
802 |
|
803 // get rid of the parsed chunk and get a new one |
|
804 if ( slashPos != KErrNotFound ) |
|
805 { |
|
806 // also remove the trailing slash |
|
807 buf.Delete( 0, chunkPtr.Length() + 1 ); |
|
808 slashPos = buf.Find( KSlash8 ); |
|
809 if ( slashPos != KErrNotFound ) |
|
810 { |
|
811 chunkPtr.Set( buf.Left( slashPos ) ); |
|
812 } |
|
813 else |
|
814 { |
|
815 // last chunk |
|
816 chunkPtr.Set( buf ); |
|
817 } |
|
818 } |
|
819 else |
|
820 { |
|
821 // no slashes found, this was the last one |
|
822 break; |
|
823 } |
|
824 } |
|
825 |
|
826 CleanupStack::PopAndDestroy( &buf ); |
|
827 } |
|
828 DEBUG(("_MM_:CHnEngine::ParseSuiteUriPathL OUT")); |
|
829 } |
|
830 |
|
831 // --------------------------------------------------------------------------- |
|
832 // |
|
833 // --------------------------------------------------------------------------- |
|
834 // |
|
835 EXPORT_C void CHnEngine::ResetModelsL() |
|
836 { |
|
837 MMPERF(("CHnEngine::ResetModelsL - START")); |
|
838 |
|
839 iControllerInterface.NotifyUiRefreshL( ERemoveLiwObjects ); |
|
840 |
|
841 if( iSuiteContainer ) |
|
842 { |
|
843 iSuiteContainer->RemoveLiwObjects(); |
|
844 } |
|
845 delete iMetaDataModel; |
|
846 iMetaDataModel = NULL; |
|
847 delete iSuiteContainer; |
|
848 iSuiteContainer = NULL; |
|
849 |
|
850 iSuiteContainer = CHnSuiteModelContainer::NewL( *this , iControllerInterface ); |
|
851 MMPERF(("CHnEngine::ResetModelsL - suite container ready")); |
|
852 |
|
853 iMetaDataModel = CHnMdModel::NewL( this, iSuiteContainer ); |
|
854 |
|
855 MMPERF(("CHnEngine::ResetModelsL - DONE")); |
|
856 } |
|
857 |
|
858 // --------------------------------------------------------------------------- |
|
859 // |
|
860 // --------------------------------------------------------------------------- |
|
861 // |
|
862 CLiwGenericParamList* CHnEngine::UriQueryToLiwListLC( |
|
863 const TDesC8& aUriQuery, const TDesC8& aUriFragment, const TDesC8& aSuiteName ) |
|
864 { |
|
865 CLiwGenericParamList* list = CLiwGenericParamList::NewLC(); |
|
866 |
|
867 CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
868 map->PushL(); |
|
869 |
|
870 RPointerArray< HBufC8 > params = SplitL( aUriQuery, KAnd8 ); |
|
871 |
|
872 for( TInt i = 0; i < params.Count(); i++ ) |
|
873 { |
|
874 RPointerArray< HBufC8 > paramValue = SplitL( *params[ i ], KEquals8 ); |
|
875 CleanupResetAndDestroyPushL( paramValue ); |
|
876 ASSERT( paramValue.Count() == 2 ); |
|
877 map->InsertL( *paramValue[ 0 ], TLiwVariant( *paramValue[ 1 ] ) ); |
|
878 CleanupStack::PopAndDestroy( ¶mValue ); |
|
879 } |
|
880 |
|
881 if ( aUriFragment.Length() > 0 && aSuiteName.Length() > 0 ) |
|
882 { |
|
883 map->InsertL( KUriHighlight, TLiwVariant( aUriFragment ) ); |
|
884 map->InsertL( KUriHighlightSuite, TLiwVariant( aSuiteName ) ); |
|
885 } |
|
886 |
|
887 list->AppendL( TLiwGenericParam( KParams8, TLiwVariant( map ))); |
|
888 |
|
889 params.ResetAndDestroy(); |
|
890 CleanupStack::PopAndDestroy( map ); |
|
891 |
|
892 return list; |
|
893 } |
|
894 |
|
895 // --------------------------------------------------------------------------- |
|
896 // |
|
897 // --------------------------------------------------------------------------- |
|
898 // |
|
899 RPointerArray< HBufC8 > CHnEngine::SplitL( const TDesC8& aSource, |
|
900 const TDesC8& aSeparator ) |
|
901 { |
|
902 RPointerArray< HBufC8 > tokens; |
|
903 CleanupResetAndDestroyPushL( tokens ); |
|
904 |
|
905 if ( aSource.Length() > 0 && aSeparator.Length() > 0 ) |
|
906 { |
|
907 TPtrC8 tmpSource = aSource; |
|
908 |
|
909 TPtrC8 token( KNullDesC8 ); |
|
910 |
|
911 while( ETrue ) |
|
912 { |
|
913 TInt length = tmpSource.Find( aSeparator ); |
|
914 |
|
915 if ( length >= 0 ) |
|
916 { |
|
917 token.Set( tmpSource.Mid( 0, length ) ); |
|
918 tokens.AppendL( token.AllocL() ); |
|
919 tmpSource.Set( tmpSource.Mid( length + 1 ) ); |
|
920 } |
|
921 else |
|
922 { |
|
923 token.Set( tmpSource ); |
|
924 tokens.AppendL( token.AllocL() ); |
|
925 break; |
|
926 } |
|
927 } |
|
928 } |
|
929 CleanupStack::Pop( &tokens ); |
|
930 return tokens; |
|
931 } |
|
932 |
|
933 // --------------------------------------------------------------------------- |
|
934 // |
|
935 // --------------------------------------------------------------------------- |
|
936 // |
|
937 void CHnEngine::SetEditModeL( TBool aEditMode ) |
|
938 { |
|
939 iEditMode = aEditMode; |
|
940 if ( aEditMode ) |
|
941 { |
|
942 iMetaDataModel->SetModeL( EMdModeEdit ); |
|
943 } |
|
944 else |
|
945 { |
|
946 iMetaDataModel->SetModeL( EMdModeNormal ); |
|
947 } |
|
948 //The suite on top of the stack is probably displayed. |
|
949 //Switching to edit mode has some dramatic ui impact, |
|
950 //thus when parts of the suite will get displayed |
|
951 //it may look awkward thus the suite on top of the stack |
|
952 //is marked as uninitialized, therefore ui will be able to |
|
953 //react only to the ready suite model. |
|
954 if (AknLayoutUtils::PenEnabled() || (!AknLayoutUtils::PenEnabled() && iEditMode)) |
|
955 { |
|
956 GetLastSuiteModelL()->GetItemsOrder()->MarkSuiteUninitialized(); |
|
957 iMetaDataModel->EvaluateL(); |
|
958 } |
|
959 } |
|
960 |
|
961 // --------------------------------------------------------------------------- |
|
962 // |
|
963 // --------------------------------------------------------------------------- |
|
964 // |
|
965 TBool CHnEngine::IsOnlyRootConfLoaded() |
|
966 { |
|
967 return ( iSuiteContainer && |
|
968 iSuiteContainer->GetSuiteModelCount() == KModelCountForRoot ); |
|
969 } |
|
970 |
|
971 // --------------------------------------------------------------------------- |
|
972 // |
|
973 // --------------------------------------------------------------------------- |
|
974 // |
|
975 |
|
976 EXPORT_C void CHnEngine::HandleRequestL( const CLiwGenericParamList& aParam, |
|
977 CLiwGenericParamList* /*aOutput*/ ) |
|
978 { |
|
979 TInt pos( 0 ); |
|
980 aParam.FindFirst( pos, KHnRequest ); |
|
981 if (pos != KErrNotFound) |
|
982 { |
|
983 TPtrC8 command = aParam[pos].Value().AsData(); |
|
984 if( command == KSetFocus ) |
|
985 { |
|
986 HandleSetFocusEventL( aParam ); |
|
987 } |
|
988 else if( command == KMoveFocusBeforeDelete ) |
|
989 { |
|
990 HandleMoveFocusBeforeDeleteEventL( aParam ); |
|
991 } |
|
992 else if( command == KRefreshIcons ) |
|
993 { |
|
994 HandleRefreshIconsEventL( aParam ); |
|
995 } |
|
996 else if (command == KEvaluateMdModel) |
|
997 { |
|
998 GetLastSuiteModelL()->GetItemsOrder()->MarkSuiteUninitialized(); |
|
999 iMetaDataModel->EvaluateL(); |
|
1000 } |
|
1001 else if ( command == KDisableActionsForItem ) |
|
1002 { |
|
1003 HandleDisableActionsForItemL( aParam ); |
|
1004 } |
|
1005 } |
|
1006 } |
|
1007 |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // |
|
1010 // --------------------------------------------------------------------------- |
|
1011 // |
|
1012 void CHnEngine::LoadFromCrL( const TDesC8& aUri ) |
|
1013 { |
|
1014 HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() ); |
|
1015 uriBuf->Des().Copy( aUri ); |
|
1016 |
|
1017 TUriParser8 parser; |
|
1018 parser.Parse( *uriBuf ); |
|
1019 User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound ); |
|
1020 |
|
1021 const TDesC8& query = parser.Extract( EUriQuery ); |
|
1022 RPointerArray< HBufC8 > params = SplitL( query, HnLogicalRelations::KLogicalAnd8); |
|
1023 |
|
1024 TBuf8<KApaMaxAppGroupName + KTimeStampBufferLength + KUidStringLength + 2> item; |
|
1025 |
|
1026 for( TInt i = 0; i < params.Count(); i++ ) |
|
1027 { |
|
1028 RPointerArray< HBufC8 > paramValue = SplitL( *params[ i ], HnLogicalRelations::KLogicalEqual8 ); |
|
1029 CleanupResetAndDestroyPushL( paramValue ); |
|
1030 ASSERT( paramValue.Count() == 2 ); |
|
1031 |
|
1032 if ( !paramValue[0]->Compare(KMcsAppGroupName8) ) |
|
1033 { |
|
1034 TBuf8<KApaMaxAppGroupName> appgrname; |
|
1035 if( paramValue[1]->Length()<=KApaMaxAppGroupName ) |
|
1036 { |
|
1037 appgrname.Append( *paramValue[1] ); |
|
1038 } |
|
1039 |
|
1040 //get current time |
|
1041 TTime currentTime; |
|
1042 currentTime.HomeTime(); |
|
1043 TDateTime date(currentTime.DateTime()); |
|
1044 item.Format(KCRepTimeFormat, &appgrname , date.Year(), date.Month(), |
|
1045 date.Day(), date.Hour(), date.Minute(), date.Second(), date.MicroSecond()); |
|
1046 } |
|
1047 else if ( !paramValue[0]->Compare( KKeyTypeUid ) ) |
|
1048 { |
|
1049 item.Append( KComma8 ); |
|
1050 if( paramValue[1]->Length()<=KUidStringLength ) |
|
1051 { |
|
1052 item.Append( *paramValue[1] ); |
|
1053 } |
|
1054 } |
|
1055 CleanupStack::PopAndDestroy( ¶mValue ); |
|
1056 } |
|
1057 |
|
1058 TBuf<KApaMaxAppGroupName + KTimeStampBufferLength + KUidStringLength + 2> item1; |
|
1059 item1.Copy(item); |
|
1060 CRepository *cenRep = CRepository::NewLC( KCRUidMenu ); |
|
1061 cenRep->Set(KMenuShowFolder, item1); |
|
1062 CleanupStack::PopAndDestroy( cenRep ); |
|
1063 |
|
1064 params.ResetAndDestroy(); |
|
1065 CleanupStack::PopAndDestroy( uriBuf ); |
|
1066 |
|
1067 } |
|
1068 // --------------------------------------------------------------------------- |
|
1069 // |
|
1070 // --------------------------------------------------------------------------- |
|
1071 // |
|
1072 void CHnEngine::LightStatusChanged(TInt aTarget, |
|
1073 CHWRMLight::TLightStatus aStatus) |
|
1074 { |
|
1075 DEBUG(("_Mm_:CHnEngine::LightStatusChanged: target %d, status %d - IN", aTarget, aStatus)); |
|
1076 if (CHWRMLight::EPrimaryDisplay == aTarget |
|
1077 || CHWRMLight::EPrimaryDisplayAndKeyboard == aTarget) |
|
1078 { |
|
1079 switch (aStatus) |
|
1080 { |
|
1081 case CHWRMLight::ELightOn: |
|
1082 { |
|
1083 TRAP_IGNORE( iControllerInterface.NotifyUiRefreshL(ELightOn) ); |
|
1084 break; |
|
1085 } |
|
1086 case CHWRMLight::ELightOff: |
|
1087 { |
|
1088 TRAP_IGNORE( iControllerInterface.NotifyUiRefreshL(ELightOff) ); |
|
1089 break; |
|
1090 } |
|
1091 } |
|
1092 } |
|
1093 DEBUG(("_Mm_:CMmAppUi::LightStatusChanged - OUT")); |
|
1094 } |
|
1095 |
|
1096 // --------------------------------------------------------------------------- |
|
1097 // |
|
1098 // --------------------------------------------------------------------------- |
|
1099 // |
|
1100 TBool CHnEngine::HandleActionL( const TDesC8& aUri ) |
|
1101 { |
|
1102 TBool exitActionConsumed(EFalse); |
|
1103 |
|
1104 HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() ); |
|
1105 uriBuf->Des().Copy( aUri ); |
|
1106 |
|
1107 TUriParser8 parser; |
|
1108 parser.Parse( *uriBuf ); |
|
1109 User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound ); |
|
1110 |
|
1111 const TDesC8& host8 = parser.Extract( EUriHost ); |
|
1112 const TDesC8& query = parser.Extract( EUriQuery ); |
|
1113 |
|
1114 RBuf action; |
|
1115 CleanupClosePushL( action ); |
|
1116 CLiwGenericParamList* paramsUri = UriQueryToLiwListLC( query, KNullDesC8, KNullDesC8 ); |
|
1117 HnLiwUtils::GetStringL( *paramsUri, KActionParams, action ); |
|
1118 |
|
1119 if ( !action.Compare( KActionExit ) ) |
|
1120 { |
|
1121 RBuf host; |
|
1122 host.CreateL( host8.Length() ); |
|
1123 CleanupClosePushL( host ); |
|
1124 host.Copy(host8); |
|
1125 CHnSuiteModel* suiteModel = iSuiteContainer->GetSuiteModel( host ); |
|
1126 TBool exitHideHostNotFound( ETrue ); |
|
1127 if( suiteModel && suiteModel->ExitMode() == EExitModeHide ) |
|
1128 { |
|
1129 exitHideHostNotFound = EFalse; |
|
1130 } |
|
1131 |
|
1132 if ( exitHideHostNotFound ) |
|
1133 { |
|
1134 //send to foreground |
|
1135 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
|
1136 CleanupStack::PushL( pl ); |
|
1137 HandleModelEventL( KAppGainForeground, *pl ); |
|
1138 CleanupStack::PopAndDestroy( pl ); |
|
1139 } |
|
1140 else |
|
1141 { |
|
1142 //send to background |
|
1143 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
|
1144 CleanupStack::PushL( pl ); |
|
1145 HandleModelEventL( KAppGainBackground, *pl ); |
|
1146 CleanupStack::PopAndDestroy( pl ); |
|
1147 } |
|
1148 |
|
1149 if ( exitHideHostNotFound && iSuiteContainer->GetLastSuiteModel() == suiteModel ) |
|
1150 { |
|
1151 HandleBackEventL( host, 1 ); |
|
1152 } |
|
1153 else |
|
1154 { |
|
1155 //reset to root |
|
1156 CLiwGenericParamList* params = CLiwGenericParamList::NewLC(); |
|
1157 params->AppendL( iMetaDataModel->GetSuiteParameters( 0 ) ); |
|
1158 ResetModelsL(); |
|
1159 InitializeL( *params ); |
|
1160 CleanupStack::PopAndDestroy( params ); |
|
1161 } |
|
1162 |
|
1163 CleanupStack::PopAndDestroy( &host ); |
|
1164 exitActionConsumed = ETrue; |
|
1165 } |
|
1166 |
|
1167 CleanupStack::PopAndDestroy( paramsUri ); |
|
1168 CleanupStack::PopAndDestroy( &action ); |
|
1169 CleanupStack::PopAndDestroy( uriBuf ); |
|
1170 return exitActionConsumed; |
|
1171 } |
|
1172 |
|
1173 // --------------------------------------------------------------------------- |
|
1174 // |
|
1175 // --------------------------------------------------------------------------- |
|
1176 // |
|
1177 void CHnEngine::LoadSuitesL( const TDesC8& aUri ) |
|
1178 { |
|
1179 TBool sendToForeground(EFalse); |
|
1180 HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() ); |
|
1181 uriBuf->Des().Copy( aUri ); |
|
1182 |
|
1183 TUriParser8 parser; |
|
1184 parser.Parse( *uriBuf ); |
|
1185 User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound ); |
|
1186 |
|
1187 CDesC8ArrayFlat* suiteNameArray = new( ELeave ) CDesC8ArrayFlat( KDefaultGranularity ) ; |
|
1188 CleanupStack::PushL( suiteNameArray ); |
|
1189 |
|
1190 const TDesC8& host = parser.Extract( EUriHost ); |
|
1191 RBuf8 host8; |
|
1192 CleanupClosePushL( host8 ); |
|
1193 if (host.Compare( KNullDesC8 )) |
|
1194 { |
|
1195 host8.CreateL( host ); |
|
1196 host8.LowerCase(); |
|
1197 suiteNameArray->AppendL( host8 ); |
|
1198 DEBUG8(( "_MM_:\tURI host part: %S", &host8 )); |
|
1199 } |
|
1200 |
|
1201 const TDesC8& path = parser.Extract( EUriPath ); |
|
1202 if (path.Compare( KNullDesC8 )) |
|
1203 { |
|
1204 HBufC8* path8 = HBufC8::NewLC( path.Length() ); |
|
1205 path8->Des().Copy( path ); |
|
1206 path8->Des().LowerCase(); |
|
1207 ParseSuiteUriPathL( *path8, *suiteNameArray ); |
|
1208 CleanupStack::PopAndDestroy( path8 ); |
|
1209 } |
|
1210 |
|
1211 TBool suiteExists( EFalse ); |
|
1212 iMetaDataModel->IgnoreEvaluations( ETrue ); |
|
1213 iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated ); |
|
1214 |
|
1215 if( host8.Length() == 0 || ( host8.Length() > 0 && |
|
1216 !iMetaDataModel->SuiteModelExistsL( host8 ) ) ) |
|
1217 { |
|
1218 suiteNameArray->Reset(); |
|
1219 suiteNameArray->AppendL( KRoot8 ); |
|
1220 } |
|
1221 |
|
1222 for( TInt i = 0; i < suiteNameArray->Count(); ++i ) |
|
1223 { |
|
1224 suiteExists = iMetaDataModel->SuiteModelExistsL( |
|
1225 ( *suiteNameArray )[i] ); |
|
1226 TBool nextExists = i < suiteNameArray->Count() - 1 && |
|
1227 iMetaDataModel->SuiteModelExistsL( ( *suiteNameArray )[i + 1] ); |
|
1228 TBool isLast = ( i == ( suiteNameArray->Count() - 1 ) ); |
|
1229 |
|
1230 TBool turnOnEvaluation = ( suiteExists && ( !nextExists || isLast ) ); |
|
1231 if( turnOnEvaluation || !suiteExists ) |
|
1232 { |
|
1233 iMetaDataModel->IgnoreEvaluations( EFalse ); |
|
1234 } |
|
1235 |
|
1236 TInt err( KErrNone ); |
|
1237 |
|
1238 // Ignore loading new suite if the last suite in model is the same |
|
1239 // as first one in the uri. |
|
1240 if ( i == 0 ) |
|
1241 { |
|
1242 if ( SuitesAreTheSameL( iMetaDataModel->GetLastSuite()->SuiteName(), (*suiteNameArray)[i] ) ) |
|
1243 { |
|
1244 HandleTheSameSuitesL( nextExists, parser.Extract( EUriQuery ) ); |
|
1245 sendToForeground = ETrue; |
|
1246 continue; |
|
1247 } |
|
1248 } |
|
1249 |
|
1250 if( suiteExists ) |
|
1251 { |
|
1252 if (!nextExists) |
|
1253 { |
|
1254 // Tricky: queue foreground so that if the suite is evaluated synchronously |
|
1255 // the foreground will be gained. |
|
1256 iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated ); |
|
1257 } |
|
1258 err = LoadSuiteFromUriL( |
|
1259 ( *suiteNameArray )[i], parser.Extract( EUriQuery ), parser.Extract( EUriFragment ) ); |
|
1260 if ( KErrNone == err && !nextExists && iMetaDataModel->IsForegroundQueued() ) |
|
1261 { |
|
1262 // Tricky: if foreground is still queued it means that the suite is evaluated |
|
1263 // asynchronously. Override the previos foreground queue setting with one |
|
1264 // that will be effective only if the last loaded suite is evaluated. |
|
1265 iMetaDataModel->QueueForeground( CHnMdModel::EWhenCurrentTopSuiteIsEvaluated ); |
|
1266 } |
|
1267 if ( err != KErrNone ) |
|
1268 { |
|
1269 sendToForeground = ETrue; |
|
1270 } |
|
1271 } |
|
1272 |
|
1273 if( !suiteExists || err != KErrNone || !nextExists ) |
|
1274 { |
|
1275 CHnFilter* filter = CHnFilter::NewLC(); |
|
1276 |
|
1277 filter->SetSuiteId( |
|
1278 iSuiteContainer->GetLastSuiteModel()->CustomId() ); |
|
1279 |
|
1280 filter->SetEvaluateSuiteL( ETrue ); |
|
1281 iMetaDataModel->IgnoreEvaluations( EFalse ); |
|
1282 |
|
1283 TRAPD( err, iMetaDataModel->EvaluateL( *filter ) ); |
|
1284 |
|
1285 CleanupStack::PopAndDestroy( filter ); |
|
1286 if( err ) |
|
1287 { |
|
1288 iMetaDataModel->DeleteLastSuite(); |
|
1289 iSuiteContainer->PopSuiteModelL( |
|
1290 HnConvUtils::Str8ToStr( ( *suiteNameArray )[i] )->Des() ); |
|
1291 sendToForeground = ETrue; |
|
1292 } |
|
1293 break; |
|
1294 } |
|
1295 } |
|
1296 |
|
1297 // set highlight only when path is valid! |
|
1298 if( suiteExists ) |
|
1299 { |
|
1300 HighlightPlacementFromUriL( parser.Extract( EUriFragment ) ); |
|
1301 } |
|
1302 |
|
1303 CleanupStack::PopAndDestroy( &host8 ); |
|
1304 CleanupStack::PopAndDestroy( suiteNameArray ); |
|
1305 CleanupStack::PopAndDestroy( uriBuf ); |
|
1306 |
|
1307 // send to foreground |
|
1308 if ( sendToForeground ) |
|
1309 { |
|
1310 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
|
1311 CleanupStack::PushL( pl ); |
|
1312 HandleModelEventL( KAppGainForeground, *pl ); |
|
1313 CleanupStack::PopAndDestroy( pl ); |
|
1314 iMetaDataModel->QueueForeground( CHnMdModel::ENever ); |
|
1315 } |
|
1316 |
|
1317 } |
|
1318 |
|
1319 // End of file |