|
1 /* |
|
2 * Copyright (c) 2007 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: A class responsible handling the views |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "ccappheaders.h" |
|
21 #include <mccappviewpluginbase2.h> |
|
22 #include "ccappmycardpluginuids.hrh" |
|
23 #include "ccacmscontactfetcherwrapper.h" |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CCCAppView::CCCAppView |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CCCAppView::CCCAppView( CCCAAppAppUi& aAppUi ) |
|
32 : iAppUi ( aAppUi ), |
|
33 iViewChangeInProgress ( EFalse ) |
|
34 { |
|
35 CCA_DP( KCCAppLogFile, CCA_L("CCCAppView::CCCAppView")); |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CCCAppView::~CCCAppView |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CCCAppView::~CCCAppView() |
|
43 { |
|
44 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::~CCCAppView")); |
|
45 |
|
46 iPluginUidToBeSynchd.Close(); |
|
47 |
|
48 if ( iCmsWrapper ) |
|
49 { |
|
50 iCmsWrapper->RemoveObserver( *this ); |
|
51 iCmsWrapper->Release(); |
|
52 } |
|
53 iObservers.Reset(); |
|
54 iObservers.Close(); |
|
55 delete iPaneHandler; |
|
56 delete iPluginLoader; |
|
57 delete iViewResetter; |
|
58 delete iDelayedConstructor; |
|
59 |
|
60 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::~CCCAppView")); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CCCAppView::NewL |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CCCAppView* CCCAppView::NewL( CCCAAppAppUi& aAppUi ) |
|
68 { |
|
69 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::NewL")); |
|
70 |
|
71 CCCAppView* self = new( ELeave ) CCCAppView( aAppUi ); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop( self ); |
|
75 |
|
76 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::NewL")); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CCCAppView::ConstructL |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CCCAppView::ConstructL() |
|
85 { |
|
86 //CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::ConstructL")); |
|
87 |
|
88 //CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::ConstructL")); |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CCCAppView::StartView |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 TInt CCCAppView::StartView( const TUid aUid ) |
|
96 { |
|
97 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::StartView")); |
|
98 TRAPD( err, StartViewL( aUid )) |
|
99 CCA_DP( KCCAppLogFile, CCA_L("::StartView - StartViewL returned err: %d"), err ); |
|
100 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::StartView")); |
|
101 return err; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CCCAppView::StartViewL |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void CCCAppView::StartViewL( const TUid aUid ) |
|
109 { |
|
110 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::StartViewL")); |
|
111 iDelayedStarting = ETrue; |
|
112 |
|
113 // At the moment mycard does not need to support tabs, so this is |
|
114 // good enough sollution for launching mycard plugin |
|
115 TBool isUidMyCard = ( aUid == |
|
116 TUid::Uid( KCCAMyCardPluginImplmentationUid ) ); |
|
117 |
|
118 // MyCard does not need CMS session. Initializing CMS for no real use |
|
119 // will only waste time in MyCard launching. |
|
120 if( !isUidMyCard ) |
|
121 { |
|
122 // 1st start the contact fetching |
|
123 iCmsWrapper = CCCAppCmsContactFetcherWrapper::CreateInstanceL( |
|
124 &iAppUi.Parameter(), CCCAppCmsContactFetcherWrapper::EFindContactFromOtherStores ); |
|
125 iCmsWrapper->AddObserverL( *this ); |
|
126 } |
|
127 |
|
128 //In this version support only contact type data (i.e. group data discarded) |
|
129 _LIT8( KCcaOpaqueTag_CNT, "CNT" ); //Contact |
|
130 _LIT8( KCcaOpaqueTag_MCD, "MCD" ); //MyCard |
|
131 _LIT8( KCcaPluginTypeMyCard, "application/x-mycard" ); |
|
132 |
|
133 TPtrC8 properties( isUidMyCard ? KCcaOpaqueTag_MCD : KCcaOpaqueTag_CNT); |
|
134 TPtrC8 type( KNullDesC8 ); |
|
135 if( isUidMyCard ) |
|
136 { |
|
137 type.Set( KCcaPluginTypeMyCard ); |
|
138 } |
|
139 iPluginLoader = CCCAppPluginLoader::NewL( this, properties, type ); |
|
140 CCA_DP( KCCAppLogFile, CCA_L("::ConstructL - iPluginLoader created")); |
|
141 iPaneHandler = CCCAppStatusPaneHandler::NewL( *this ); |
|
142 CCA_DP( KCCAppLogFile, CCA_L("::ConstructL - iPaneHandler created")); |
|
143 |
|
144 // 2nd start constructing the plugin view with preferred |
|
145 // plugin view (if provided) |
|
146 TInt pluginToFocus = iPluginLoader->SetPluginInFocus( aUid ); |
|
147 |
|
148 if(pluginToFocus != KErrNotFound) |
|
149 { |
|
150 iPluginLoader->SetPluginVisibility(aUid, CCCAppPluginData::EPluginVisible); |
|
151 } |
|
152 else |
|
153 { |
|
154 //Not found, try set the first plugin |
|
155 pluginToFocus = 0; |
|
156 if(iPluginLoader->PluginAt(pluginToFocus)) |
|
157 { |
|
158 iPluginLoader->SetPluginVisibility( |
|
159 iPluginLoader->PluginAt(pluginToFocus)->Plugin().Id(), CCCAppPluginData::EPluginVisible); |
|
160 } |
|
161 } |
|
162 |
|
163 //Start plugin and construct CIdle object to call back to finalise |
|
164 //time consuming construction |
|
165 StartPluginL(pluginToFocus); |
|
166 iDelayedConstructor = CIdle::NewL( CActive::EPriorityIdle ); |
|
167 iDelayedConstructor->Start( TCallBack( ConstructDelayedCallbackL, this) ); |
|
168 |
|
169 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::StartViewL")); |
|
170 } |
|
171 |
|
172 // ---------------------------------------------------------------------------- |
|
173 // CCCAppView::ConstructDelayedCallbackL |
|
174 // |
|
175 // Called from CIdle to finish time consuming construction operations |
|
176 // ---------------------------------------------------------------------------- |
|
177 // |
|
178 TInt CCCAppView::ConstructDelayedCallbackL( TAny* aContainer ) |
|
179 { |
|
180 CCCAppView* container = static_cast<CCCAppView*>( aContainer ); |
|
181 container->DoConstructDelayedL(); |
|
182 return 0; |
|
183 } |
|
184 |
|
185 // ---------------------------------------------------------------------------- |
|
186 // CCCAppView::DoConstructDelayedL |
|
187 // |
|
188 // Perform time consuming construction operations |
|
189 // ---------------------------------------------------------------------------- |
|
190 // |
|
191 void CCCAppView::DoConstructDelayedL() |
|
192 { |
|
193 if( iDelayState == EDelayedCreateTabs ) |
|
194 { |
|
195 iPaneHandler->CreateTabsL(); |
|
196 iDelayedConstructor->Start( TCallBack( ConstructDelayedCallbackL, this) ); |
|
197 iDelayState=EDelayedCheckVisibilities; |
|
198 } |
|
199 else if( iDelayState == EDelayedCheckVisibilities ) |
|
200 { |
|
201 CheckOtherPluginVisibilitiesL(); |
|
202 iDelayedConstructor->Start( TCallBack( ConstructDelayedCallbackL, this) ); |
|
203 } |
|
204 else if( iDelayState == EDelayedCheckVisibilitiesOk ) |
|
205 { |
|
206 TInt tabNbr = 0; |
|
207 CCCAppPluginData* currPluginData = iPluginLoader->PluginInFocus(); |
|
208 if( currPluginData ) |
|
209 { |
|
210 TUid currentlyVisiblePluginId = currPluginData->Plugin().Id(); |
|
211 iPluginLoader->PluginVisibility( currentlyVisiblePluginId, tabNbr ); |
|
212 } |
|
213 |
|
214 iPaneHandler->ActivateTab( tabNbr ); |
|
215 iDelayedConstructor->Start( TCallBack( ConstructDelayedCallbackL, this) ); |
|
216 iDelayState=EDelayedFinish; |
|
217 } |
|
218 else |
|
219 { |
|
220 delete iDelayedConstructor; |
|
221 iDelayedConstructor = NULL; |
|
222 iDelayedStarting = EFalse; |
|
223 SynchPluginVisibilityWithTabAfterDelayedStartL(); |
|
224 } |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // CCCAppView::CheckOtherPluginVisibilitiesL |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 void CCCAppView::CheckOtherPluginVisibilitiesL() |
|
232 { |
|
233 TBool pluginVisibility(EFalse); |
|
234 |
|
235 if(iDelayedPluginVisibilityCheck < iPluginLoader->PluginsCount()) |
|
236 { |
|
237 // prepare plugin parameter |
|
238 CCCAppPluginParameter* pluginParam = CCCAppPluginParameter::NewL( *this ); |
|
239 CleanupStack::PushL( pluginParam ); |
|
240 TRAPD(err, pluginVisibility = iPluginLoader-> |
|
241 PluginAt(iDelayedPluginVisibilityCheck)->Plugin().CheckVisibilityL(*pluginParam)); |
|
242 CleanupStack::PopAndDestroy( pluginParam ); |
|
243 if (KErrNone == err) |
|
244 { |
|
245 if(iPluginLoader->SetPluginVisibility(iPluginLoader-> |
|
246 PluginAt(iDelayedPluginVisibilityCheck)->Plugin().Id(), pluginVisibility)) |
|
247 { |
|
248 iDelayedVisibilityChanged = ETrue; |
|
249 } |
|
250 } |
|
251 else |
|
252 { |
|
253 CCA_DP( KCCAppLogFile, CCA_L( |
|
254 "CCCAppStatusPaneHandler::CreateTabsL: Plugin %d visibility check failed."), |
|
255 iDelayedPluginVisibilityCheck); |
|
256 //Remove plugin from plugin loader |
|
257 TUid pluginUid = iPluginLoader->PluginAt(iDelayedPluginVisibilityCheck)->Plugin().Id(); |
|
258 CCA_DP( KCCAppLogFile, CCA_L("::visibility check - problem plugin uid: %d"), pluginUid.iUid ); |
|
259 iPluginLoader->RemovePlugin( pluginUid ); |
|
260 iDelayedVisibilityChanged = ETrue; |
|
261 } |
|
262 } |
|
263 else |
|
264 { |
|
265 //All checked. Reset if changes requested by plugins |
|
266 if(iDelayedVisibilityChanged) |
|
267 { |
|
268 iPaneHandler->CreateTabsL(); |
|
269 } |
|
270 iDelayState=EDelayedCheckVisibilitiesOk; |
|
271 } |
|
272 iDelayedPluginVisibilityCheck++; |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------------------------- |
|
276 // CCCAppView::StartPluginL |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 void CCCAppView::StartPluginL(TInt aPluginToFocus) |
|
280 { |
|
281 /* |
|
282 * Activating plugin is done in two TRAP-levels. The lower is activating |
|
283 * the plugin and if it fails, takes care of recovering from the |
|
284 * situation. The higher level takes care of exiting the application |
|
285 * if something leaves while recovering from the plugin activation. |
|
286 */ |
|
287 CCCAppPluginData* pluginDataInFocus = iPluginLoader->PluginInFocus(); |
|
288 User::LeaveIfNull(pluginDataInFocus); |
|
289 |
|
290 TRAPD( err, ActivatePluginL( *pluginDataInFocus )); |
|
291 if ( KErrNone == err ) |
|
292 {// view started successfully - activate correct tab |
|
293 // activate 1st view plugin in case preferred plugin uid not found |
|
294 iPaneHandler->ActivateTab( KErrNotFound != aPluginToFocus ? aPluginToFocus : 0 ); |
|
295 } |
|
296 else |
|
297 {// problem in plugin activation - try to recover |
|
298 CCA_DP( KCCAppLogFile, CCA_L("::StartViewL - problem in plugin activation: err %d"), err ); |
|
299 RecoverFromBadPluginL(); |
|
300 } |
|
301 } |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // CCCAppView::ChangeView |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 TInt CCCAppView::ChangeView( TBool aForward ) |
|
308 { |
|
309 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::ChangeView")); |
|
310 |
|
311 TInt err = KErrNone; |
|
312 |
|
313 //Forward the call to statusPane only if it is ready |
|
314 if ( iPaneHandler ) |
|
315 { |
|
316 if ( iPaneHandler->IsTabAvailable() ) |
|
317 { |
|
318 TRAP( err, ChangeViewL( aForward )); |
|
319 CCA_DP( KCCAppLogFile, CCA_L("::ChangeView - ChangeViewL returned err: %d"), err ); |
|
320 } |
|
321 } |
|
322 |
|
323 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::ChangeView")); |
|
324 return err; |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // CCCAppView::ChangeViewL |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 void CCCAppView::ChangeViewL( TBool aForward ) |
|
332 { |
|
333 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::ChangeViewL")); |
|
334 |
|
335 const TInt visiblePluginCount = iPluginLoader->VisiblePluginCount(); |
|
336 if ( KCCAppMinPluginCountForTabs > visiblePluginCount // if only 1 plugin, we can stop handling here |
|
337 || iViewChangeInProgress ) // OR view change is in progress |
|
338 return; |
|
339 |
|
340 __ASSERT_DEBUG ( iPaneHandler->TabCount() == visiblePluginCount, CCAppPanic( ECCAppPanicObjectCountMismatch )); |
|
341 |
|
342 iViewChangeInProgress = ETrue; |
|
343 |
|
344 /* |
|
345 * If ActivateTabL changes tab succesfully, it will call TabChangedL, |
|
346 * which then again will do activation the plugin. |
|
347 * |
|
348 * Activating plugin is done in two TRAP-levels. The lower is activating |
|
349 * the plugin and if it fails, takes care of recovering from the |
|
350 * situation. The higher level takes care of exiting the application |
|
351 * if something leaves while recovering from the plugin activation. |
|
352 */ |
|
353 TRAPD( err, iPaneHandler->ActivateTabL( aForward )); |
|
354 if ( KErrNone != err) |
|
355 { |
|
356 CCA_DP( KCCAppLogFile, CCA_L("::ChangeViewL - problem in plugin activation: err %d"), err ); |
|
357 RecoverFromBadPluginL(); |
|
358 } |
|
359 |
|
360 iViewChangeInProgress = EFalse; |
|
361 |
|
362 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::ChangeViewL")); |
|
363 } |
|
364 |
|
365 // --------------------------------------------------------------------------- |
|
366 // CCCAppView::TabChangedL |
|
367 // --------------------------------------------------------------------------- |
|
368 // |
|
369 void CCCAppView::TabChangedL( TInt aIndex ) |
|
370 { |
|
371 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::TabChangedL")); |
|
372 |
|
373 CCCAppPluginData* pluginDataInFocus = iPluginLoader->VisiblePlugin( aIndex, ETrue );// not owned |
|
374 ActivatePluginL( *pluginDataInFocus ); |
|
375 |
|
376 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::TabChangedL")); |
|
377 } |
|
378 |
|
379 // --------------------------------------------------------------------------- |
|
380 // CCCAppView::ActivatePluginL |
|
381 // --------------------------------------------------------------------------- |
|
382 // |
|
383 void CCCAppView::ActivatePluginL( CCCAppPluginData& aPluginDataInFocus ) |
|
384 { |
|
385 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::ActivatePluginL")); |
|
386 |
|
387 //PERFORMANCE LOGGING: 6. Plugin activation |
|
388 WriteToPerfLog(); |
|
389 |
|
390 CCCAppViewPluginBase& plugin = aPluginDataInFocus.Plugin(); |
|
391 |
|
392 if ( !aPluginDataInFocus.IsPluginPrepared() ) |
|
393 {// 1st activation |
|
394 // prepare plugin parameter |
|
395 CCCAppPluginParameter* pluginParam = CCCAppPluginParameter::NewL( *this ); |
|
396 CleanupStack::PushL( pluginParam ); |
|
397 plugin.PreparePluginViewL( *pluginParam ); |
|
398 CleanupStack::PopAndDestroy( pluginParam ); |
|
399 iAppUi.AddViewL( &plugin );// transfers ownership to AppUi -framework |
|
400 aPluginDataInFocus.PluginIsPrepared(); |
|
401 } |
|
402 |
|
403 // activate plugin |
|
404 iAppUi.ActivateLocalViewL( plugin.Id() ); |
|
405 |
|
406 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::ActivatePluginL")); |
|
407 } |
|
408 |
|
409 // --------------------------------------------------------------------------- |
|
410 // CCCAppView::AppUi |
|
411 // --------------------------------------------------------------------------- |
|
412 // |
|
413 CCCAAppAppUi& CCCAppView::AppUi() |
|
414 { |
|
415 CCA_DP( KCCAppLogFile, CCA_L("CCCAppView::AppUi")); |
|
416 return iAppUi; |
|
417 } |
|
418 |
|
419 // --------------------------------------------------------------------------- |
|
420 // CCCAppView::EikonEnv |
|
421 // --------------------------------------------------------------------------- |
|
422 // |
|
423 CEikonEnv& CCCAppView::EikonEnv() |
|
424 { |
|
425 CCA_DP( KCCAppLogFile, CCA_L("CCCAppView::AlfEnv")); |
|
426 return iAppUi.EikonEnv(); |
|
427 } |
|
428 |
|
429 // --------------------------------------------------------------------------- |
|
430 // CCCAppView::PluginLoader |
|
431 // --------------------------------------------------------------------------- |
|
432 // |
|
433 CCCAppPluginLoader& CCCAppView::PluginLoader() |
|
434 { |
|
435 CCA_DP( KCCAppLogFile, CCA_L("CCCAppView::PluginLoader")); |
|
436 return *iPluginLoader; |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------------------------- |
|
440 // CCCAppView::ContactFieldDataObserverNotifyL |
|
441 // --------------------------------------------------------------------------- |
|
442 // |
|
443 void CCCAppView::ContactFieldDataObserverNotifyL( |
|
444 MCCAppContactFieldDataObserver::TParameter& aParameter ) |
|
445 { |
|
446 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::ContactFieldDataObserverNotifyL")); |
|
447 |
|
448 // not interested about other notifications |
|
449 if ( MCCAppContactFieldDataObserver::TParameter::EContactDataFieldAvailable |
|
450 == aParameter.iType && NULL != aParameter.iContactField ) |
|
451 { |
|
452 ContactFieldFetchedNotifyL( *aParameter.iContactField ); |
|
453 } |
|
454 else if ( MCCAppContactFieldDataObserver::TParameter::EContactDeleted |
|
455 == aParameter.iType ) |
|
456 { |
|
457 // Quick fix for the urgent need |
|
458 // |
|
459 // To fix this such manner that CCApplication works as normal Avkon |
|
460 // applications do, let the leave with leave code KLeaveExit |
|
461 // go up to CActive's RunL and return it also through RunError. |
|
462 // Then normal Avkon AppUi functionality AppUi().Exit() will work. |
|
463 AppUi().RunAppShutter(); |
|
464 } |
|
465 |
|
466 |
|
467 |
|
468 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::ContactFieldDataObserverNotifyL")); |
|
469 } |
|
470 |
|
471 // --------------------------------------------------------------------------- |
|
472 // CCCAppView::ContactFieldDataObserverHandleErrorL |
|
473 // --------------------------------------------------------------------------- |
|
474 // |
|
475 void CCCAppView::ContactFieldDataObserverHandleErrorL( |
|
476 TInt aState, TInt aError ) |
|
477 { |
|
478 CCA_DP( KCCAppLogFile, CCA_L("CCCAppView::ContactFieldDataObserverHandleErrorL")); |
|
479 CCA_DP( KCCAppLogFile, CCA_L("::ContactFieldDataObserverHandleErrorL - aState: %d, aError: %d"), aState, aError ); |
|
480 // If no contact found, leave here and launching CCA fails |
|
481 if ( CCCAppCmsContactFetcherWrapper::EOpeningContact == aState ) |
|
482 { |
|
483 User::Leave(aError); |
|
484 } |
|
485 } |
|
486 |
|
487 // --------------------------------------------------------------------------- |
|
488 // CCCAppView::ContactFieldFetchedNotifyL |
|
489 // --------------------------------------------------------------------------- |
|
490 // |
|
491 void CCCAppView::ContactFieldFetchedNotifyL( |
|
492 CCmsContactField& aContactField ) |
|
493 { |
|
494 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::ContactFieldFetchedNotifyL")); |
|
495 |
|
496 if ( CCmsContactFieldItem::ECmsFullName == aContactField.Type() ) |
|
497 {// update titlepane with the name |
|
498 CCA_DP( KCCAppLogFile, CCA_L("::ContactFieldFetchedNotifyL - changing title")); |
|
499 |
|
500 TPtrC newTxt = aContactField.ItemL( 0 ).Data(); |
|
501 iAppUi.SetTitleL( newTxt ); |
|
502 } |
|
503 |
|
504 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::ContactFieldFetchedNotifyL")); |
|
505 } |
|
506 |
|
507 // --------------------------------------------------------------------------- |
|
508 // CCCAppView::RecoverFromBadPluginL |
|
509 // --------------------------------------------------------------------------- |
|
510 // |
|
511 void CCCAppView::RecoverFromBadPluginL() |
|
512 { |
|
513 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::RecoverFromBadPluginL")); |
|
514 |
|
515 #ifdef _DEBUG |
|
516 CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; |
|
517 informationNote->ExecuteLD( _L("Problem in plugin! Check logs!")); |
|
518 #endif |
|
519 |
|
520 //Remove plugin from plugin loader |
|
521 TUid pluginUid = iPluginLoader->PluginInFocus()->Plugin().Id(); |
|
522 CCA_DP( KCCAppLogFile, CCA_L("::RecoverFromBadPluginL - problem plugin uid: %d"), pluginUid.iUid ); |
|
523 iPluginLoader->RemovePlugin( pluginUid ); |
|
524 |
|
525 if ( iPluginLoader->PluginsCount() ) |
|
526 {// Plugins available |
|
527 CCA_DP( KCCAppLogFile, CCA_L("::RecoverFromBadPluginL - plugins found")); |
|
528 |
|
529 // Reset tabs |
|
530 delete iPaneHandler; |
|
531 iPaneHandler = NULL; |
|
532 iPaneHandler = CCCAppStatusPaneHandler::NewL( *this ); |
|
533 iPaneHandler->CreateTabsL(); |
|
534 |
|
535 // Needed to get the focus in most cases to 1st plugin in array |
|
536 delete iViewResetter; |
|
537 iViewResetter = NULL; |
|
538 iViewResetter = CIdle::NewL( CActive::EPriorityStandard ); |
|
539 iViewResetter->Start( TCallBack( ResetViewL, this )); |
|
540 } |
|
541 else |
|
542 {// no plugins left |
|
543 // (should basically never happen, since there should always be working internal plugins) |
|
544 User::Leave( KErrNotFound ); |
|
545 } |
|
546 |
|
547 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::RecoverFromBadPluginL")); |
|
548 } |
|
549 |
|
550 // --------------------------------------------------------------------------- |
|
551 // CCCAppView::CurrentPluginBusy |
|
552 // --------------------------------------------------------------------------- |
|
553 // |
|
554 TBool CCCAppView::CurrentPluginBusy() |
|
555 { |
|
556 TBool isBusy = EFalse; |
|
557 if(iPluginLoader) |
|
558 { |
|
559 CCCAppPluginData* pluginData = iPluginLoader->PluginInFocus(); //not owned |
|
560 if ( pluginData != NULL ) |
|
561 { |
|
562 CCCAppViewPluginBase& plugin = pluginData->Plugin(); |
|
563 MCCAppViewPluginBase2* pluginExtension = |
|
564 reinterpret_cast<MCCAppViewPluginBase2*>( |
|
565 plugin.CCCAppViewPluginBaseExtension( KMCCAppViewPluginBaseExtension2Uid ) ); |
|
566 if ( pluginExtension != NULL ) |
|
567 { |
|
568 isBusy = pluginExtension->PluginBusy(); |
|
569 } |
|
570 } |
|
571 } |
|
572 |
|
573 return isBusy; |
|
574 } |
|
575 |
|
576 // --------------------------------------------------------------------------- |
|
577 // CCCAppView::ResetViewL |
|
578 // --------------------------------------------------------------------------- |
|
579 // |
|
580 TInt CCCAppView::ResetViewL( TAny* aSelf ) |
|
581 { |
|
582 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppView::ResetViewL")); |
|
583 |
|
584 CCCAppView* view = static_cast<CCCAppView*>(aSelf);//not owned |
|
585 |
|
586 // Change focus and activate 1st plugin in array |
|
587 CCCAppPluginData* pluginDataInFocus = |
|
588 view->iPluginLoader->PluginAt( 0, ETrue ); |
|
589 view->ActivatePluginL( *pluginDataInFocus ); |
|
590 view->iPaneHandler->ActivateTab( 0 ); |
|
591 |
|
592 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppView::ResetViewL")); |
|
593 return KErrNone; |
|
594 } |
|
595 // --------------------------------------------------------------------------- |
|
596 // CCCAppView::ContactRelocationL |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 void CCCAppView::CCAppContactEventL() |
|
600 { |
|
601 TInt count = iObservers.Count(); |
|
602 for (TInt i = 0; i < count; i++) |
|
603 { |
|
604 // Inform observers of contact event |
|
605 TRAP_IGNORE(iObservers[i]->NotifyPluginOfContactEventL()); |
|
606 } |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------------------------- |
|
610 // CCCAppView::AddObserverL |
|
611 // --------------------------------------------------------------------------- |
|
612 // |
|
613 void CCCAppView::AddObserverL( MCCAppPluginsContactObserver& aObserver ) |
|
614 { |
|
615 TInt index = iObservers.Find(&aObserver); |
|
616 if (index == KErrNotFound) |
|
617 { |
|
618 iObservers.AppendL(&aObserver); |
|
619 } |
|
620 } |
|
621 |
|
622 // --------------------------------------------------------------------------- |
|
623 // CCCAppView::RemoveObserver |
|
624 // --------------------------------------------------------------------------- |
|
625 // |
|
626 void CCCAppView::RemoveObserver( MCCAppPluginsContactObserver& aObserver ) |
|
627 { |
|
628 TInt index = iObservers.Find(&aObserver); |
|
629 if (index != KErrNotFound) |
|
630 { |
|
631 iObservers.Remove(index); |
|
632 } |
|
633 } |
|
634 |
|
635 // --------------------------------------------------------------------------- |
|
636 // CCCAppView::Parameter |
|
637 // --------------------------------------------------------------------------- |
|
638 // |
|
639 MCCAParameter& CCCAppView::Parameter() |
|
640 { |
|
641 return iAppUi.Parameter(); |
|
642 } |
|
643 |
|
644 // --------------------------------------------------------------------------- |
|
645 // CCCAppView::ShowPluginL |
|
646 // --------------------------------------------------------------------------- |
|
647 // |
|
648 void CCCAppView::ShowPluginL( TUid aUid ) |
|
649 { |
|
650 if(iDelayedStarting) |
|
651 { |
|
652 iPluginLoader->SetPluginVisibility(aUid, CCCAppPluginData::EPluginVisible); |
|
653 iPluginUidToBeSynchd.Append(aUid); |
|
654 } |
|
655 else |
|
656 { |
|
657 PerformShowPluginL( aUid ); |
|
658 } |
|
659 } |
|
660 |
|
661 // --------------------------------------------------------------------------- |
|
662 // CCCAppView::PerformShowPluginL |
|
663 // --------------------------------------------------------------------------- |
|
664 // |
|
665 void CCCAppView::PerformShowPluginL( TUid aUid ) |
|
666 { |
|
667 TInt currentTab(KErrNotFound); |
|
668 CCCAppPluginData* pluginData = iPluginLoader->PluginInFocus( ); |
|
669 iPluginLoader->SetPluginVisibility(aUid, CCCAppPluginData::EPluginVisible); |
|
670 iPaneHandler->CreateTabsL(); |
|
671 |
|
672 if( pluginData ) |
|
673 { |
|
674 iPluginLoader->PluginVisibility( pluginData->Plugin().Id(), currentTab ); |
|
675 iPaneHandler->ActivateTab( currentTab ); |
|
676 } |
|
677 else |
|
678 { |
|
679 iPaneHandler->ActivateTab( 0 ); |
|
680 } |
|
681 } |
|
682 |
|
683 // --------------------------------------------------------------------------- |
|
684 // CCCAppView::HidePluginL |
|
685 // --------------------------------------------------------------------------- |
|
686 // |
|
687 void CCCAppView::HidePluginL( TUid aUid ) |
|
688 { |
|
689 if(iDelayedStarting) |
|
690 { |
|
691 iPluginLoader->SetPluginVisibility(aUid, CCCAppPluginData::EPluginHidden); |
|
692 iPluginUidToBeSynchd.Append(aUid); |
|
693 } |
|
694 else |
|
695 { |
|
696 PerformHidePluginL( aUid ); |
|
697 } |
|
698 } |
|
699 |
|
700 // --------------------------------------------------------------------------- |
|
701 // CCCAppView::PerformHidePluginL |
|
702 // --------------------------------------------------------------------------- |
|
703 // |
|
704 void CCCAppView::PerformHidePluginL( TUid aUid ) |
|
705 { |
|
706 TInt newTab(KErrNotFound); |
|
707 |
|
708 //Currently visible plugin |
|
709 TInt currentTab(KErrNotFound); |
|
710 CCCAppPluginData* currPluginData = iPluginLoader->PluginInFocus( ); |
|
711 iPluginLoader->PluginVisibility( currPluginData->Plugin().Id(), currentTab ); |
|
712 |
|
713 //Hide plugin aUid |
|
714 iPluginLoader->SetPluginVisibility(aUid, CCCAppPluginData::EPluginHidden); |
|
715 iPaneHandler->CreateTabsL(); |
|
716 |
|
717 //Set new visible plugin |
|
718 if( currPluginData ) |
|
719 { |
|
720 if(currPluginData->Plugin().Id() == aUid) |
|
721 { |
|
722 //Current will be hidden, bring previous or next to foreground |
|
723 if( CCCAppPluginData* previousPlugin = iPluginLoader->PreviousPlugin( ETrue )) |
|
724 { |
|
725 ActivatePluginL( *previousPlugin ); |
|
726 iPluginLoader->PluginVisibility( previousPlugin->Plugin().Id(), newTab ); |
|
727 iPaneHandler->ActivateTab( newTab ); |
|
728 return; |
|
729 } |
|
730 else if( CCCAppPluginData* nextPlugin = iPluginLoader->NextPlugin( ETrue )) |
|
731 { |
|
732 ActivatePluginL( *nextPlugin ); |
|
733 iPluginLoader->PluginVisibility( nextPlugin->Plugin().Id(), newTab ); |
|
734 iPaneHandler->ActivateTab( newTab ); |
|
735 return; |
|
736 } |
|
737 else |
|
738 { |
|
739 //Nothing to activate properly |
|
740 ResetViewL( this ); |
|
741 return; |
|
742 } |
|
743 } |
|
744 else |
|
745 { |
|
746 //Retain current plugin in foreground |
|
747 iPluginLoader->PluginVisibility( currPluginData->Plugin().Id(), newTab ); |
|
748 iPaneHandler->ActivateTab( newTab ); |
|
749 return; |
|
750 } |
|
751 } |
|
752 //Nothing to activate properly |
|
753 ResetViewL( this ); |
|
754 return; |
|
755 } |
|
756 |
|
757 |
|
758 // --------------------------------------------------------------------------- |
|
759 // CCCAppView::SynchPluginVisibilityWithTabAfterDelayedStartL |
|
760 // --------------------------------------------------------------------------- |
|
761 // |
|
762 void CCCAppView::SynchPluginVisibilityWithTabAfterDelayedStartL() |
|
763 { |
|
764 CCCAppPluginData* currPluginData = iPluginLoader->PluginInFocus(); |
|
765 TBool syncDone = EFalse; |
|
766 TInt pluginsRequireSynch = iPluginUidToBeSynchd.Count(); |
|
767 if( currPluginData && pluginsRequireSynch ) |
|
768 { |
|
769 TUid currentlyVisiblePluginId = currPluginData->Plugin().Id(); |
|
770 |
|
771 for ( TInt index=0; index<pluginsRequireSynch; index++ ) |
|
772 { |
|
773 if ( currentlyVisiblePluginId == iPluginUidToBeSynchd[index] ) |
|
774 { |
|
775 //is there any change in the visibility of the current visible plugin |
|
776 //the only option could be is that it can become invisible |
|
777 //only on the above case we willbe interested |
|
778 TInt tabNbr = 0; |
|
779 if ( !iPluginLoader->PluginVisibility( currentlyVisiblePluginId, tabNbr ) ) |
|
780 { |
|
781 //This plugin is no more visible so its better to call just HidePluginL() |
|
782 syncDone = ETrue; |
|
783 HidePluginL( currentlyVisiblePluginId ); |
|
784 } |
|
785 break; |
|
786 } |
|
787 } |
|
788 |
|
789 if ( !syncDone ) |
|
790 { |
|
791 //Still synchronisation has not been done |
|
792 //Possible reason could be is that, this plugin is not the currently visible one |
|
793 //so now it becomes much more easy, so just go ahead and call CreateTabsL |
|
794 //only the tab will be reset and the current active plugin will stay active |
|
795 TInt tabNbr = 0; |
|
796 iPaneHandler->CreateTabsL(); |
|
797 //Current the repositioned active tab & activate the same |
|
798 iPluginLoader->PluginVisibility( currentlyVisiblePluginId, tabNbr ); |
|
799 iPaneHandler->ActivateTab( tabNbr ); |
|
800 } |
|
801 } |
|
802 } |
|
803 |
|
804 // End of File |