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