1 /* |
|
2 * Copyright (c) 2007-2010 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: CSC Application´s Service View´s Container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <fbs.h> |
|
20 #include <csc.mbg> |
|
21 #include <csc.rsg> |
|
22 #include <e32std.h> |
|
23 #include <aknapp.h> |
|
24 #include <gulicon.h> |
|
25 #include <eikclbd.h> |
|
26 #include <aknlists.h> |
|
27 #include <pathinfo.h> |
|
28 #include <coecntrl.h> |
|
29 #include <AknsUtils.h> |
|
30 #include <cchclient.h> |
|
31 #include <akncontext.h> |
|
32 #include <AknIconArray.h> |
|
33 #include <StringLoader.h> |
|
34 #include <aknViewAppUi.h> |
|
35 #include <AiwServiceHandler.h> |
|
36 #include <mspnotifychangeobserver.h> |
|
37 #include <cscengsettingscleanupplugininterface.h> |
|
38 |
|
39 #include <csxhelp/voip.hlp.hrh> |
|
40 #include <data_caging_path_literals.hrh> |
|
41 |
|
42 #include "mcscservicecontainerobserver.h" |
|
43 #include "csclogger.h" |
|
44 #include "cscdialog.h" |
|
45 #include "cscconstants.h" |
|
46 #include "cscapplication.h" |
|
47 #include "cscnoteutilities.h" |
|
48 #include "cscengcchhandler.h" |
|
49 #include "cscservicecontainer.h" |
|
50 #include "cscengservicehandler.h" |
|
51 #include "cscengbrandinghandler.h" |
|
52 #include "cscengservicepluginhandler.h" |
|
53 #include "cscenguiextensionpluginhandler.h" |
|
54 |
|
55 const TUint KServiceListItemTextMaxLength = 64; |
|
56 const TUint KMaxUiExetnsionNameLength = 64; |
|
57 |
|
58 // Format of the list item string. |
|
59 _LIT( KServiceListItemTextFormat, "%d\t%S\t" ); |
|
60 |
|
61 // ======== MEMBER FUNCTIONS ======== |
|
62 |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CCSCServiceContainer::CCSCServiceContainer( |
|
68 MCSCServiceContainerObserver& aContainerObserver, |
|
69 CCSCEngServicePluginHandler& aServicePluginHandler, |
|
70 CCSCEngUiExtensionPluginHandler& aUiExtensionPluginHandler, |
|
71 CCSCEngServiceHandler& aServiceHandler, |
|
72 CCSCEngBrandingHandler& aBrandingHandler, |
|
73 CCSCEngCCHHandler& aCCHHandler ): |
|
74 iContainerObserver( aContainerObserver ), |
|
75 iServicePluginHandler( aServicePluginHandler ), |
|
76 iUiExtensionPluginHandler( aUiExtensionPluginHandler ), |
|
77 iServiceHandler( aServiceHandler ), |
|
78 iBrandingHandler( aBrandingHandler ), |
|
79 iCCHHandler( aCCHHandler ) |
|
80 { |
|
81 } |
|
82 |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CCSCServiceContainer::ConstructL( const TRect& aRect ) |
|
88 { |
|
89 CSCDEBUG( "CCSCServiceContainer::ConstructL - begin" ); |
|
90 |
|
91 CreateWindowL(); |
|
92 iDialog = CCSCDialog::NewL(); |
|
93 |
|
94 iListBox = new (ELeave) CAknDouble2LargeStyleListBox; |
|
95 iListBox->SetContainerWindowL( *this ); |
|
96 iListBox->ConstructL( this, EAknGenericListBoxFlags ); |
|
97 iListBox->HideSecondRow( ETrue ); |
|
98 iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
99 |
|
100 HBufC* emptyTxt = StringLoader::LoadLC( R_QTN_CSC_NO_SERVICES_INSTALLED ); |
|
101 iListBox->View()->SetListEmptyTextL( *emptyTxt ); |
|
102 CleanupStack::PopAndDestroy( emptyTxt ); |
|
103 |
|
104 iListBox->CreateScrollBarFrameL( ETrue ); |
|
105 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
106 CEikScrollBarFrame::EOff, |
|
107 CEikScrollBarFrame::EAuto ); |
|
108 |
|
109 CTextListBoxModel* model = iListBox->Model(); |
|
110 MDesCArray* textArray = model->ItemTextArray(); |
|
111 iListBoxItems = static_cast<CDesCArray*>( textArray ); |
|
112 |
|
113 iEikMenuBar = new ( ELeave ) CEikMenuBar(); |
|
114 iEikMenuBar->ConstructL( this, NULL, R_CSC_SERVICEVIEW_MENUBAR ); |
|
115 |
|
116 SetRect( aRect ); |
|
117 |
|
118 UpdateServiceViewL(); |
|
119 |
|
120 ActivateL(); |
|
121 |
|
122 CSCDEBUG( "CCSCServiceContainer::ConstructL - end" ); |
|
123 } |
|
124 |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 CCSCServiceContainer* CCSCServiceContainer::NewL( |
|
130 const TRect& aRect, |
|
131 MCSCServiceContainerObserver& aContainerObserver, |
|
132 CCSCEngServicePluginHandler& aServicePluginHandler, |
|
133 CCSCEngUiExtensionPluginHandler& aUiExtensionPluginHandler, |
|
134 CCSCEngServiceHandler& aServiceHandler, |
|
135 CCSCEngBrandingHandler& aBrandingHandler, |
|
136 CCSCEngCCHHandler& aCCHHandler ) |
|
137 { |
|
138 CCSCServiceContainer* self = |
|
139 new ( ELeave ) CCSCServiceContainer( |
|
140 aContainerObserver, |
|
141 aServicePluginHandler, |
|
142 aUiExtensionPluginHandler, |
|
143 aServiceHandler, |
|
144 aBrandingHandler, |
|
145 aCCHHandler ); |
|
146 |
|
147 CleanupStack::PushL( self ); |
|
148 self->ConstructL( aRect ); |
|
149 CleanupStack::Pop( self ); |
|
150 return self; |
|
151 } |
|
152 |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 CCSCServiceContainer::~CCSCServiceContainer() |
|
158 { |
|
159 CSCDEBUG( "CCSCServiceContainer::~CCSCServiceContainer - begin" ); |
|
160 |
|
161 delete iDialog; |
|
162 delete iArray; |
|
163 delete iListBox; |
|
164 delete iEikMenuBar; |
|
165 |
|
166 iListBoxItemArray.Reset(); |
|
167 iListBoxItemArray.Close(); |
|
168 |
|
169 CSCDEBUG( "CCSCServiceContainer::~CCSCServiceContainer - end" ); |
|
170 } |
|
171 |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // Updates services to listbox. |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void CCSCServiceContainer::UpdateServiceViewL() |
|
178 { |
|
179 CSCDEBUG( "CCSCServiceContainer::UpdateServiceViewL - begin" ); |
|
180 |
|
181 TInt currentItemIndex = CurrentItemIndex(); |
|
182 |
|
183 // Reset listbox items and item array |
|
184 iListBoxItems->Reset(); |
|
185 iListBoxItemArray.Reset(); |
|
186 |
|
187 // Find and add Ui Extension Plug-ins |
|
188 iUiExtensionCount = iUiExtensionPluginHandler.PluginCount(); |
|
189 |
|
190 // Create icon array or cleanup iconarray if it already exists |
|
191 CArrayPtr<CGulIcon>* iconArray = |
|
192 iListBox->ItemDrawer()->ColumnData()->IconArray(); |
|
193 |
|
194 if ( !iconArray ) |
|
195 { |
|
196 iconArray = new( ELeave ) CAknIconArray( 1 ); |
|
197 // Set icon array for ListBox. |
|
198 iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray ); |
|
199 } |
|
200 else |
|
201 { |
|
202 iconArray->ResetAndDestroy(); |
|
203 } |
|
204 |
|
205 // move add new service plugin to top |
|
206 RArray<TUiExtensionPluginInfo> uiPlugins; |
|
207 CleanupClosePushL( uiPlugins ); |
|
208 |
|
209 for( TInt i = 0; i < iUiExtensionCount; i++ ) |
|
210 { |
|
211 TUiExtensionPluginInfo uiExtension = |
|
212 iUiExtensionPluginHandler.ItemFromPluginInfoArray( i ); |
|
213 |
|
214 if ( KAccountCreationPluginUID == uiExtension.iPluginsUid ) |
|
215 { |
|
216 uiPlugins.InsertL( uiExtension, 0 ); |
|
217 } |
|
218 else |
|
219 { |
|
220 uiPlugins.AppendL( uiExtension ); |
|
221 } |
|
222 } |
|
223 |
|
224 iListBoxItemHeight = iListBox->ItemHeight(); |
|
225 |
|
226 TInt iconSize( 0 ); |
|
227 if ( iListBoxItemHeight == KItemHeightPortrait ) |
|
228 { |
|
229 iconSize = iListBoxItemHeight - KIconSizeCorrectionPortrait; |
|
230 } |
|
231 else |
|
232 { |
|
233 iconSize = iListBoxItemHeight - KIconSizeCorrectionLandscape; |
|
234 } |
|
235 |
|
236 for ( TUint i( 0 ) ; i < iUiExtensionCount ; i++ ) |
|
237 { |
|
238 TUiExtensionPluginInfo uiExtension = uiPlugins[i]; |
|
239 |
|
240 if ( 0 == uiExtension.iPlace ) |
|
241 { |
|
242 TBuf<KMaxUiExetnsionNameLength> extensionName; |
|
243 extensionName.Copy( uiExtension.iUiExtensionName ); |
|
244 |
|
245 // To keep track which kind of listbox items we have |
|
246 TListBoxItem listBoxItem; |
|
247 listBoxItem.iItemType = TListBoxItem::EUiExtension; |
|
248 listBoxItem.iPluginUid = uiExtension.iPluginsUid; |
|
249 |
|
250 iListBoxItemArray.Append( listBoxItem ); |
|
251 |
|
252 // Set icon for ui extension |
|
253 SetIconL( listBoxItem, iconArray, iconSize ); |
|
254 |
|
255 TBuf<KServiceListItemTextMaxLength> listBoxItemText; |
|
256 |
|
257 listBoxItemText.Format( |
|
258 KServiceListItemTextFormat, |
|
259 iconArray->Count() - 1, |
|
260 &extensionName ); |
|
261 |
|
262 iListBoxItems->AppendL( listBoxItemText ); |
|
263 } |
|
264 } |
|
265 |
|
266 CleanupStack::PopAndDestroy( &uiPlugins ); |
|
267 |
|
268 // Get services |
|
269 RArray<TUint> serviceIds; |
|
270 CleanupClosePushL( serviceIds ); |
|
271 |
|
272 TRAPD( err, iServiceHandler.GetAllServiceIdsL( serviceIds ) ); |
|
273 |
|
274 for ( TInt i(0) ; i < serviceIds.Count() && !err ; i++ ) |
|
275 { |
|
276 // Check service validity from cch before adding to listbox |
|
277 if ( iCCHHandler.IsServiceValidL( serviceIds[ i ] ) ) |
|
278 { |
|
279 TBuf<KServiceListItemTextMaxLength> listBoxItemText; |
|
280 HBufC* serviceString = NULL; |
|
281 |
|
282 serviceString = StringLoader::LoadLC( |
|
283 R_QTN_CSC_SERVICE_LISTBOX_ITEM, |
|
284 iServiceHandler.ServiceNameL( serviceIds[ i ] ) ); |
|
285 |
|
286 // To keep track which kind of listbox items we have |
|
287 TListBoxItem listBoxItem; |
|
288 listBoxItem.iServiceId = serviceIds[ i ]; |
|
289 |
|
290 // Set icon for service |
|
291 SetIconL( listBoxItem, iconArray, iconSize ); |
|
292 |
|
293 listBoxItemText.Format( |
|
294 KServiceListItemTextFormat, |
|
295 iconArray->Count() - 1, |
|
296 serviceString ); |
|
297 |
|
298 iListBoxItems->AppendL( listBoxItemText ); |
|
299 |
|
300 TInt32 servicePluginId( 0 ); |
|
301 TInt err2( KErrNone ); |
|
302 |
|
303 // Find service plug-in id if service has one |
|
304 TRAP( |
|
305 err2, servicePluginId = |
|
306 iServiceHandler.ServiceSetupPluginIdL( serviceIds[ i ] ) ); |
|
307 |
|
308 if ( !err2 && servicePluginId ) |
|
309 { |
|
310 listBoxItem.iItemType = TListBoxItem::EServicePlugin; |
|
311 listBoxItem.iPluginUid.iUid = servicePluginId; |
|
312 } |
|
313 else if ( KErrNotFound == err2 ) |
|
314 { |
|
315 listBoxItem.iItemType = TListBoxItem::EGeneralService; |
|
316 } |
|
317 |
|
318 iListBoxItemArray.Append( listBoxItem ); |
|
319 |
|
320 CleanupStack::PopAndDestroy( serviceString ); |
|
321 } |
|
322 } |
|
323 |
|
324 CleanupStack::PopAndDestroy( &serviceIds ); |
|
325 |
|
326 UpdateListboxL(); |
|
327 |
|
328 if( iListBoxItemArray.Count() > 0 ) |
|
329 { |
|
330 if ( 0 <= currentItemIndex && |
|
331 ( iListBoxItemArray.Count() > currentItemIndex ) ) |
|
332 { |
|
333 iListBox->SetCurrentItemIndexAndDraw( currentItemIndex ); |
|
334 } |
|
335 else |
|
336 { |
|
337 iListBox->SetCurrentItemIndexAndDraw( 0 ); |
|
338 } |
|
339 } |
|
340 |
|
341 CSCDEBUG( "CCSCServiceContainer::UpdateSerUpdateServiceViewL - end" ); |
|
342 } |
|
343 |
|
344 |
|
345 // --------------------------------------------------------------------------- |
|
346 // Update listbox. Handle item addition and drawing. |
|
347 // --------------------------------------------------------------------------- |
|
348 // |
|
349 void CCSCServiceContainer::UpdateListboxL() |
|
350 { |
|
351 CSCDEBUG( "CCSCServiceContainer::UpdateListboxL - begin" ); |
|
352 |
|
353 iListBox->HandleItemAdditionL(); |
|
354 |
|
355 CSCDEBUG( "CCSCServiceContainer::UpdateListboxL - end" ); |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // Returns current item index of listbox. |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 TInt CCSCServiceContainer::CurrentItemIndex() const |
|
363 { |
|
364 CSCDEBUG2( |
|
365 "CCSCServiceContainer::CurrentItemIndex:%d",iListBox->CurrentItemIndex()); |
|
366 |
|
367 return iListBox->CurrentItemIndex(); |
|
368 } |
|
369 |
|
370 |
|
371 // --------------------------------------------------------------------------- |
|
372 // Returns currently selected list box item. |
|
373 // --------------------------------------------------------------------------- |
|
374 // |
|
375 TListBoxItem CCSCServiceContainer::ListBoxItem() |
|
376 { |
|
377 return iListBoxItemArray[ CurrentItemIndex() ]; |
|
378 } |
|
379 |
|
380 // --------------------------------------------------------------------------- |
|
381 // Returns reference to listbox. |
|
382 // --------------------------------------------------------------------------- |
|
383 // |
|
384 CAknDouble2LargeStyleListBox& CCSCServiceContainer::ListBox() |
|
385 { |
|
386 return *iListBox; |
|
387 } |
|
388 |
|
389 // --------------------------------------------------------------------------- |
|
390 // Returns pen down point. |
|
391 // --------------------------------------------------------------------------- |
|
392 // |
|
393 TPoint CCSCServiceContainer::PenDownPoint() |
|
394 { |
|
395 return iPenDownPoint; |
|
396 } |
|
397 |
|
398 // --------------------------------------------------------------------------- |
|
399 // Returns service count. |
|
400 // --------------------------------------------------------------------------- |
|
401 // |
|
402 TInt CCSCServiceContainer::ServiceCount() |
|
403 { |
|
404 TUint serviceCount( 0 ); |
|
405 |
|
406 for ( TInt i ( 0 ) ; i < iListBoxItemArray.Count() ; i++ ) |
|
407 { |
|
408 //Add count if list box item type is general service or service plugin |
|
409 if ( |
|
410 TListBoxItem::EGeneralService == iListBoxItemArray[i].iItemType || |
|
411 TListBoxItem::EServicePlugin == iListBoxItemArray[i].iItemType ) |
|
412 { |
|
413 serviceCount++; |
|
414 } |
|
415 } |
|
416 |
|
417 return serviceCount; |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------------------------- |
|
421 // Set current item index. |
|
422 // --------------------------------------------------------------------------- |
|
423 // |
|
424 void CCSCServiceContainer::SetCurrentIndex( TInt aIndex ) |
|
425 { |
|
426 CSCDEBUG2( "CCSCServiceContainer::SetCurrentIndex: aIndex=%d", aIndex ); |
|
427 |
|
428 if( ( aIndex < iListBoxItemArray.Count() ) && ( aIndex >= 0 ) ) |
|
429 { |
|
430 iListBox->SetCurrentItemIndex( aIndex ); |
|
431 } |
|
432 else |
|
433 { |
|
434 iListBox->SetCurrentItemIndex( 0 ); |
|
435 } |
|
436 } |
|
437 |
|
438 |
|
439 // --------------------------------------------------------------------------- |
|
440 // Deletes service. |
|
441 // --------------------------------------------------------------------------- |
|
442 // |
|
443 void CCSCServiceContainer::DeleteServiceL() |
|
444 { |
|
445 CSCDEBUG( "CCSCServiceContainer::DeleteServiceL - begin" ); |
|
446 |
|
447 if ( iListBoxItemArray.Count() ) |
|
448 { |
|
449 TListBoxItem item = ListBoxItem(); |
|
450 |
|
451 // Show confirmation query for service deletion |
|
452 if ( CCSCNoteUtilities::ShowCommonQueryL( |
|
453 CCSCNoteUtilities::ECSCDeleteServiceQuery, |
|
454 iServiceHandler.ServiceNameL( item.iServiceId ) ) ) |
|
455 { |
|
456 TBool disabled = iCCHHandler.IsServiceDisabled( item.iServiceId ); |
|
457 |
|
458 // if enabled -> show unable to delete note |
|
459 if ( !disabled ) |
|
460 { |
|
461 CCSCNoteUtilities::ShowInformationNoteL( |
|
462 CCSCNoteUtilities::ECSCUnableToDeleteNote, |
|
463 iServiceHandler.ServiceNameL( item.iServiceId ) ); |
|
464 return; |
|
465 } |
|
466 |
|
467 // First check if there is a service plugin UID. |
|
468 TInt count = iServicePluginHandler.PluginCount( |
|
469 CCSCEngServicePluginHandler::EInitialized ); |
|
470 TBool setupPlugin( EFalse ); |
|
471 for ( TInt i = 0; i < count && !setupPlugin; i++ ) |
|
472 { |
|
473 TServicePluginInfo pluginInfo = |
|
474 iServicePluginHandler.ItemFromPluginInfoArray( i ); |
|
475 if ( pluginInfo.iPluginsUid == item.iPluginUid ) |
|
476 { |
|
477 CSCDEBUG2( " DeleteServiceL - plugin UID match found: %d", |
|
478 item.iPluginUid ); |
|
479 setupPlugin = ETrue; |
|
480 } |
|
481 } |
|
482 |
|
483 if ( setupPlugin ) |
|
484 { |
|
485 HandleServicePluginRemovationL( item.iPluginUid ); |
|
486 } |
|
487 else |
|
488 { |
|
489 TRAPD( err, LaunchCleanupPluginL( item.iServiceId ) ); |
|
490 if ( KErrNone != err ) |
|
491 { |
|
492 iServiceHandler.DeleteServiceL( item.iServiceId ); |
|
493 } |
|
494 } |
|
495 } |
|
496 } |
|
497 |
|
498 CSCDEBUG( "CCSCServiceContainer::DeleteServiceL - end" ); |
|
499 } |
|
500 |
|
501 // --------------------------------------------------------------------------- |
|
502 // Handles service plugin removation. |
|
503 // --------------------------------------------------------------------------- |
|
504 // |
|
505 void CCSCServiceContainer::HandleServicePluginRemovationL( const TUid& aUid ) |
|
506 { |
|
507 CSCDEBUG( |
|
508 "CCSCServiceContainer::HandleServicePluginRemovationL - begin" ); |
|
509 |
|
510 TUint serviceId( 0 ); |
|
511 ResolveServiceIdL( aUid, serviceId ); |
|
512 if ( !serviceId ) |
|
513 { |
|
514 User::Leave( KErrNotFound ); |
|
515 } |
|
516 |
|
517 TBool disabled = iCCHHandler.IsServiceDisabled( serviceId ); |
|
518 |
|
519 // If service is not disabled, try to disable it |
|
520 if ( !disabled ) |
|
521 { |
|
522 iDialog->LaunchWaitNoteL( R_QTN_CSC_REMOVING_SERVICE ); |
|
523 User::LeaveIfError( iCCHHandler.DisableService( serviceId ) ); |
|
524 return; |
|
525 } |
|
526 |
|
527 // Remove service plugin |
|
528 TInt error( KErrNone ); |
|
529 TRAP( error, iServicePluginHandler.DoRemovationL( aUid, EFalse ) ); |
|
530 |
|
531 // If error, remove remainging setting by cleanupplugin |
|
532 if ( error ) |
|
533 { |
|
534 error = KErrNone; |
|
535 TRAP( error, LaunchCleanupPluginL( serviceId ) ); |
|
536 |
|
537 if ( error ) |
|
538 { |
|
539 iServiceHandler.DeleteServiceL( serviceId ); |
|
540 } |
|
541 } |
|
542 } |
|
543 |
|
544 |
|
545 // --------------------------------------------------------------------------- |
|
546 // Updates container data because of layout change. |
|
547 // --------------------------------------------------------------------------- |
|
548 // |
|
549 void CCSCServiceContainer::HandleResourceChange( TInt aType ) |
|
550 { |
|
551 CSCDEBUG( "CCSCServiceContainer::HandleResourceChange - begin" ); |
|
552 |
|
553 if( aType == KAknsMessageSkinChange || |
|
554 aType == KEikDynamicLayoutVariantSwitch ) |
|
555 { |
|
556 TRect mainPaneRect; |
|
557 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
558 mainPaneRect ); |
|
559 SetRect( mainPaneRect ); |
|
560 DrawNow(); |
|
561 iListBox->DrawNow(); |
|
562 |
|
563 // Get handler to status pane. |
|
564 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
565 if ( statusPane ) |
|
566 { |
|
567 statusPane->DrawNow(); |
|
568 } |
|
569 } |
|
570 |
|
571 CCoeControl::HandleResourceChange( aType ); |
|
572 |
|
573 CSCDEBUG( "CCSCServiceContainer::HandleResourceChange - end" ); |
|
574 } |
|
575 |
|
576 |
|
577 // --------------------------------------------------------------------------- |
|
578 // Sets listbox observer. |
|
579 // --------------------------------------------------------------------------- |
|
580 // |
|
581 void CCSCServiceContainer::SetListBoxObserver( |
|
582 MEikListBoxObserver* aObserver ) |
|
583 { |
|
584 iListBox->SetListBoxObserver( aObserver ); |
|
585 } |
|
586 |
|
587 |
|
588 // --------------------------------------------------------------------------- |
|
589 // Hides dialog wait note. |
|
590 // --------------------------------------------------------------------------- |
|
591 // |
|
592 void CCSCServiceContainer::HideDialogWaitNote() |
|
593 { |
|
594 iDialog->DestroyWaitNote(); |
|
595 } |
|
596 |
|
597 |
|
598 // --------------------------------------------------------------------------- |
|
599 // Launches cleanup plugin to remove settings. |
|
600 // --------------------------------------------------------------------------- |
|
601 // |
|
602 void CCSCServiceContainer::LaunchCleanupPluginL( TUint aServiceId ) const |
|
603 { |
|
604 CSCDEBUG( "CCSCServiceContainer::LaunchCleanupPluginL - begin" ); |
|
605 |
|
606 RImplInfoPtrArray implInfoArray; |
|
607 CleanupStack::PushL( TCleanupItem( |
|
608 ResetAndDestroy, &implInfoArray ) ); |
|
609 |
|
610 REComSession::ListImplementationsL( |
|
611 KCSCSettingsCleanupPluginInterfaceUid, |
|
612 implInfoArray ); |
|
613 |
|
614 for ( TInt i( 0 ) ; i < implInfoArray.Count() ; i++ ) |
|
615 { |
|
616 CCSCEngSettingsCleanupPluginInterface* plugin = |
|
617 CCSCEngSettingsCleanupPluginInterface::NewL( |
|
618 implInfoArray[ i ]->ImplementationUid() ); |
|
619 |
|
620 CleanupStack::PushL( plugin ); |
|
621 |
|
622 if ( CCSCEngSettingsCleanupPluginInterface::ESipVoIPCleanupPlugin |
|
623 == plugin->PluginType() ) |
|
624 { |
|
625 plugin->RemoveSettingsL( aServiceId ); |
|
626 } |
|
627 |
|
628 CleanupStack::PopAndDestroy( plugin ); |
|
629 } |
|
630 |
|
631 CleanupStack::PopAndDestroy( &implInfoArray ); |
|
632 REComSession::FinalClose(); |
|
633 |
|
634 CSCDEBUG( "CCSCServiceContainer::LaunchCleanupPluginL - end" ); |
|
635 } |
|
636 |
|
637 |
|
638 // --------------------------------------------------------------------------- |
|
639 // Resolve service id from service plugi uid. |
|
640 // --------------------------------------------------------------------------- |
|
641 // |
|
642 void CCSCServiceContainer::ResolveServiceIdL( |
|
643 const TUid& aUid, TUint& aServiceId ) |
|
644 { |
|
645 RArray<TUint> serviceIds; |
|
646 CleanupClosePushL( serviceIds ); |
|
647 iServiceHandler.GetAllServiceIdsL( serviceIds ); |
|
648 |
|
649 TInt serviceCount( serviceIds.Count() ); |
|
650 |
|
651 if ( serviceCount ) |
|
652 { |
|
653 for ( TInt i = 0 ; i < serviceCount ; i++ ) |
|
654 { |
|
655 TInt32 serviceSetupPluginId( KErrNotFound ); |
|
656 TRAPD( err, serviceSetupPluginId = |
|
657 iServiceHandler.ServiceSetupPluginIdL( serviceIds[ i ] ) ); |
|
658 |
|
659 if ( KErrNone == err && |
|
660 serviceSetupPluginId == aUid.iUid ) |
|
661 { |
|
662 aServiceId = serviceIds[ i ]; |
|
663 break; |
|
664 } |
|
665 } |
|
666 } |
|
667 else |
|
668 { |
|
669 User::Leave( KErrNotFound ); |
|
670 } |
|
671 |
|
672 CleanupStack::PopAndDestroy( &serviceIds ); |
|
673 } |
|
674 |
|
675 // --------------------------------------------------------------------------- |
|
676 // From class CoeControl |
|
677 // Offer key events for controls. |
|
678 // --------------------------------------------------------------------------- |
|
679 // |
|
680 TKeyResponse CCSCServiceContainer::OfferKeyEventL( |
|
681 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
682 { |
|
683 CSCDEBUG2( |
|
684 "CCSCServiceContainer::OfferKeyEventL: aKeyEvent: %d", |
|
685 aKeyEvent.iScanCode ); |
|
686 |
|
687 TKeyResponse result( EKeyWasNotConsumed ); |
|
688 |
|
689 if ( iEikMenuBar->ItemSpecificCommandsEnabled() && |
|
690 EKeyBackspace == aKeyEvent.iCode && |
|
691 ( TListBoxItem::EUiExtension != ListBoxItem().iItemType ) ) |
|
692 { |
|
693 DeleteServiceL(); |
|
694 result = EKeyWasConsumed; |
|
695 } |
|
696 else |
|
697 { |
|
698 result = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
699 } |
|
700 |
|
701 iContainerObserver.UpdateCbaL(); |
|
702 |
|
703 return result; |
|
704 } |
|
705 |
|
706 |
|
707 // --------------------------------------------------------------------------- |
|
708 // From class CoeControl |
|
709 // Returns component controls. |
|
710 // --------------------------------------------------------------------------- |
|
711 // |
|
712 CCoeControl* CCSCServiceContainer::ComponentControl( TInt aIndex ) const |
|
713 { |
|
714 switch ( aIndex ) |
|
715 { |
|
716 case 0: |
|
717 return iListBox; |
|
718 default: |
|
719 return NULL; |
|
720 } |
|
721 } |
|
722 |
|
723 |
|
724 // --------------------------------------------------------------------------- |
|
725 // From class CoeControl |
|
726 // Handle pointer event. |
|
727 // --------------------------------------------------------------------------- |
|
728 // |
|
729 void CCSCServiceContainer::HandlePointerEventL( |
|
730 const TPointerEvent& aPointerEvent ) |
|
731 { |
|
732 iPenDownPoint = aPointerEvent.iPosition; |
|
733 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
734 } |
|
735 |
|
736 |
|
737 // --------------------------------------------------------------------------- |
|
738 // From class MCSCEngCCHObserver |
|
739 // --------------------------------------------------------------------------- |
|
740 // |
|
741 void CCSCServiceContainer::ServiceStatusChanged( |
|
742 TUint /*aServiceId*/, |
|
743 TCCHSubserviceType /*aType*/, |
|
744 const TCchServiceStatus& /*aServiceStatus*/ ) |
|
745 { |
|
746 // not used |
|
747 } |
|
748 |
|
749 |
|
750 // --------------------------------------------------------------------------- |
|
751 // From class CoeControl |
|
752 // Handles controls size changes. |
|
753 // --------------------------------------------------------------------------- |
|
754 // |
|
755 void CCSCServiceContainer::SizeChanged() |
|
756 { |
|
757 if ( iListBox ) |
|
758 { |
|
759 iListBox->SetRect( Rect() ); |
|
760 |
|
761 // Update view if portrait/landscape change happened |
|
762 if ( iListBoxItemHeight != iListBox->ItemHeight() ) |
|
763 { |
|
764 TRAP_IGNORE( UpdateServiceViewL() ); |
|
765 } |
|
766 } |
|
767 } |
|
768 |
|
769 |
|
770 // --------------------------------------------------------------------------- |
|
771 // From class CoeControl |
|
772 // Handles focus changes. |
|
773 // --------------------------------------------------------------------------- |
|
774 // |
|
775 void CCSCServiceContainer::FocusChanged( TDrawNow aDrawNow ) |
|
776 { |
|
777 CCoeControl::FocusChanged( aDrawNow ); |
|
778 |
|
779 if( iListBox ) |
|
780 { |
|
781 iListBox->SetFocus( IsFocused() ); |
|
782 } |
|
783 } |
|
784 |
|
785 |
|
786 // --------------------------------------------------------------------------- |
|
787 // From class CoeControl |
|
788 // Counts components controls. |
|
789 // --------------------------------------------------------------------------- |
|
790 // |
|
791 TInt CCSCServiceContainer::CountComponentControls() const |
|
792 { |
|
793 return 1; // only iListBox |
|
794 } |
|
795 |
|
796 |
|
797 // ----------------------------------------------------------------------------- |
|
798 // From class CoeControl |
|
799 // For getting help context |
|
800 // ----------------------------------------------------------------------------- |
|
801 // |
|
802 void CCSCServiceContainer::GetHelpContext( |
|
803 TCoeHelpContext& aContext ) const |
|
804 { |
|
805 aContext.iMajor = KCscHelpUid; |
|
806 aContext.iContext = KVOIP_HLP_CSC; |
|
807 } |
|
808 |
|
809 |
|
810 // --------------------------------------------------------------------------- |
|
811 // Sets icons for lisbox items. |
|
812 // --------------------------------------------------------------------------- |
|
813 // |
|
814 void CCSCServiceContainer::SetIconL( const TListBoxItem& aListBoxItem, |
|
815 CArrayPtr<CGulIcon>* aIconArray, TInt aIconSize ) |
|
816 { |
|
817 CSCDEBUG( "CCSCServiceContainer::SetIconL - begin" ); |
|
818 |
|
819 if ( NULL == aIconArray ) |
|
820 { |
|
821 return; |
|
822 } |
|
823 |
|
824 TFileName iconsFileName = TParsePtrC( PathInfo::RomRootPath() ).Drive(); |
|
825 iconsFileName.Append( KDC_APP_BITMAP_DIR ); |
|
826 iconsFileName.Append( KCSCAifFile ); |
|
827 |
|
828 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
829 |
|
830 if ( TListBoxItem::EUiExtension == aListBoxItem.iItemType ) |
|
831 { |
|
832 // specific icon for accountcreationplugin |
|
833 if ( KAccountCreationPluginUID == aListBoxItem.iPluginUid ) |
|
834 { |
|
835 aIconArray->AppendL( AknsUtils::CreateGulIconL( |
|
836 skinInstance, |
|
837 KAknsIIDDefault, |
|
838 iconsFileName, |
|
839 EMbmCscQgn_prop_voip_new_service, |
|
840 EMbmCscQgn_prop_voip_new_service ) ); |
|
841 } |
|
842 // specific icon for advanced settings plugin (sip voip settings) |
|
843 else if ( KAdvancedSettingsPluginUID == aListBoxItem.iPluginUid ) |
|
844 { |
|
845 aIconArray->AppendL( AknsUtils::CreateGulIconL( |
|
846 skinInstance, |
|
847 KAknsIIDDefault, |
|
848 iconsFileName, |
|
849 EMbmCscQgn_prop_set_voip_advanced, |
|
850 EMbmCscQgn_prop_set_voip_advanced ) ); |
|
851 } |
|
852 else // generic icon |
|
853 { |
|
854 aIconArray->AppendL( AknsUtils::CreateGulIconL( |
|
855 skinInstance, |
|
856 KAknsIIDDefault, |
|
857 iconsFileName, |
|
858 EMbmCscQgn_prop_set_service, |
|
859 EMbmCscQgn_prop_set_service ) ); |
|
860 } |
|
861 } |
|
862 // Service in question, try to get branded icon. If fails use default icon |
|
863 else |
|
864 { |
|
865 CSCDEBUG( "CCSCServiceContainer::SetIconL - branded icon" ); |
|
866 CFbsBitmap* bitmap = NULL; |
|
867 CFbsBitmap* mask = NULL; |
|
868 |
|
869 // Get service brand id and branded icon(s). |
|
870 TRAPD( err, |
|
871 TBuf16<KBrandIdMaxLength> brandId16 ( KNullDesC ); |
|
872 iServiceHandler.BrandIdL( |
|
873 aListBoxItem.iServiceId, |
|
874 brandId16 ); |
|
875 |
|
876 TBuf8<KBrandIdMaxLength> brandId8 ( KNullDesC8 ); |
|
877 brandId8.Copy( brandId16 ); |
|
878 iBrandingHandler.GetServiceBrandIconL( brandId8, bitmap, |
|
879 mask, aIconSize ); ); |
|
880 // Use default icons if error. |
|
881 if ( KErrNone != err ) |
|
882 { |
|
883 aIconArray->AppendL( AknsUtils::CreateGulIconL( |
|
884 skinInstance, |
|
885 KAknsIIDDefault, |
|
886 iconsFileName, |
|
887 EMbmCscQgn_prop_set_service, |
|
888 EMbmCscQgn_prop_set_service ) ); |
|
889 } |
|
890 // Use branded icons if KErrNone. |
|
891 else |
|
892 { |
|
893 if ( bitmap ) |
|
894 { |
|
895 CSCDEBUG( "CCSCServiceContainer::SetIconL - branded icon" ); |
|
896 CleanupStack::PushL( bitmap ); |
|
897 CleanupStack::PushL( mask ); |
|
898 |
|
899 CFbsBitmap* newBitmap = new (ELeave) CFbsBitmap; |
|
900 if ( KErrNone == newBitmap->Duplicate( bitmap->Handle() ) ) |
|
901 { |
|
902 CleanupStack::PushL( newBitmap ); |
|
903 //ownership transferred (newBitmap) |
|
904 |
|
905 //Create new mask |
|
906 CFbsBitmap* newMask = new (ELeave) CFbsBitmap; |
|
907 if( KErrNone == newMask->Duplicate( mask->Handle() ) ) |
|
908 { |
|
909 CSCDEBUG( "CCSCServiceContainer::SetIconsL - branded newMASK" ); |
|
910 |
|
911 CleanupStack::PushL ( newMask ); |
|
912 CGulIcon* icon = CGulIcon::NewL( |
|
913 AknIconUtils::CreateIconL( newBitmap ), |
|
914 AknIconUtils::CreateIconL( newMask ) ); |
|
915 |
|
916 CleanupStack::Pop( newMask ); |
|
917 CleanupStack::Pop( newBitmap ); |
|
918 |
|
919 CleanupStack::PushL( icon ); |
|
920 aIconArray->AppendL( icon ); |
|
921 CleanupStack::Pop( icon ); |
|
922 CSCDEBUG( "CCSCServiceContainer::SetIconsL - branded newMASK done" ); |
|
923 } |
|
924 else |
|
925 { |
|
926 CSCDEBUG( "CCSCServiceContainer::SetIconsL - Error creating mask duplicate" ); |
|
927 CleanupStack::PopAndDestroy( newBitmap ); |
|
928 delete newMask; |
|
929 newMask = NULL; |
|
930 } |
|
931 } |
|
932 else |
|
933 { |
|
934 delete newBitmap; |
|
935 newBitmap = NULL; |
|
936 |
|
937 aIconArray->AppendL( AknsUtils::CreateGulIconL( |
|
938 skinInstance, |
|
939 KAknsIIDDefault, |
|
940 iconsFileName, |
|
941 EMbmCscQgn_prop_set_service, |
|
942 EMbmCscQgn_prop_set_service ) ); |
|
943 } |
|
944 |
|
945 CleanupStack::PopAndDestroy( mask ); |
|
946 CleanupStack::PopAndDestroy( bitmap ); |
|
947 } |
|
948 } |
|
949 } |
|
950 |
|
951 CSCDEBUG( "CCSCServiceContainer::SetIconsL - end" ); |
|
952 } |
|
953 |
|
954 |
|
955 // --------------------------------------------------------------------------- |
|
956 // CCSCServiceContainer::ResetAndDestroy |
|
957 // --------------------------------------------------------------------------- |
|
958 // |
|
959 void CCSCServiceContainer::ResetAndDestroy( TAny* aArray ) |
|
960 { |
|
961 CSCDEBUG( "CCSCServiceContainer::ResetAndDestroy - end" ); |
|
962 |
|
963 if ( aArray ) |
|
964 { |
|
965 RImplInfoPtrArray* array = |
|
966 reinterpret_cast<RImplInfoPtrArray*>( aArray ); |
|
967 array->ResetAndDestroy(); |
|
968 } |
|
969 |
|
970 CSCDEBUG( "CCSCServiceContainer::ResetAndDestroy - end" ); |
|
971 } |
|
972 |
|