phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardcontainer.cpp
branchRCL_3
changeset 20 f4a778e096c2
child 21 9da50d567e3c
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Implementation of mycard plugin control container
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <ccaextensionfactory.h>
       
    21 
       
    22 #include <aknlists.h>
       
    23 #include <eiktxlbm.h>
       
    24 #include <barsread.h>
       
    25 #include <AknsDrawUtils.h>
       
    26 #include <AknsBasicBackgroundControlContext.h>
       
    27 #include <AknUtils.h>
       
    28 #include <s32mem.h>
       
    29 
       
    30 #include <MPbk2ContactNameFormatter.h>
       
    31 #include <MVPbkStoreContact.h>
       
    32 #include <CPbk2IconArray.h>
       
    33 #include <Pbk2UIControls.rsg>
       
    34 #include <MPbk2Command.h>
       
    35 #include <Pbk2MenuFilteringFlags.hrh>
       
    36 #include <MVPbkContactLink.h>
       
    37 
       
    38 #include "ccappmycard.hrh"
       
    39 #include "ccappmycard.h"
       
    40 #include "ccappmycardcontainer.h"
       
    41 #include "ccappmycardcommon.h"
       
    42 #include "ccappmycardheadercontrol.h"
       
    43 #include "ccappmycardplugin.h"
       
    44 #include "ccafactoryextensionnotifier.h"
       
    45 
       
    46 #include <spbcontentprovider.h>
       
    47 #include <spbcontactdatamodel.h> 
       
    48 
       
    49 #include <MVPbkContactFieldTextData.h>
       
    50 #include <ccaextensionfactory.hrh>
       
    51 #include <mccaparameter.h>
       
    52 
       
    53 #include <aknlayoutscalable_avkon.cdl.h>
       
    54 #include <layoutmetadata.cdl.h>
       
    55 #include <AknsUtils.h>
       
    56 #include <ccappmycardpluginrsc.rsg>
       
    57 #include <gulicon.h>
       
    58 #include <phonebook2ece.mbg>
       
    59 #include <VPbkEng.rsg>
       
    60 #include "MVPbkFieldType.h"
       
    61 #include <aknstyluspopupmenu.h>
       
    62 #include <e32std.h>
       
    63 #include <aknlayoutscalable_apps.cdl.h>
       
    64 #include <Pbk2PresentationUtils.h>
       
    65 #include <Pbk2Presentation.rsg>
       
    66 #include <RPbk2LocalizedResourceFile.h>
       
    67 #include <Pbk2DataCaging.hrh>
       
    68 #include <pbk2nameordercenrep.h>
       
    69 #include <centralrepository.h>
       
    70 #include <Phonebook2PrivateCRKeys.h>
       
    71 #include <CPbk2PresentationContact.h>
       
    72 #include <CPbk2PresentationContactFieldCollection.h>
       
    73 
       
    74 #include <CPbk2ApplicationServices.h>
       
    75 #include <CPbk2ServiceManager.h>
       
    76 #include <TPbk2IconId.h>
       
    77 #include <CPbk2IconInfo.h>
       
    78 #include <csxhelp/phob.hlp.hrh>
       
    79 #include <Pbk2UID.h>
       
    80 #include <f32file.h>
       
    81 #include <AknsConstants.h>
       
    82 
       
    83 // unnamed namespace
       
    84 namespace
       
    85 {
       
    86 _LIT( KMyCardIconDefaultFileName, "\\resource\\apps\\phonebook2ece.mif" );
       
    87 const TInt KSubComponentCount = 2;
       
    88 const TInt KNumberOfContacts = 1;
       
    89 const TInt KNoContacts = 0;
       
    90 const TInt KPbk2UiSpecNameOrderFirstNameLastName = 0;
       
    91 const TInt KPbk2UiSpecNameOrderLastNameFirstName = 1;
       
    92 }
       
    93 
       
    94 // =========================== MEMBER FUNCTIONS ===============================
       
    95 
       
    96 // ----------------------------------------------------------------------------
       
    97 // CCCAppMyCardContainer::CCCAppMyCardContainer()
       
    98 // ----------------------------------------------------------------------------
       
    99 //
       
   100 CCCAppMyCardContainer::CCCAppMyCardContainer(
       
   101     CCCAppMyCardPlugin& aPlugin ) :
       
   102     iPlugin( aPlugin ),
       
   103     iModel( aPlugin.Model() ),
       
   104     iNameOrder(KPbk2UiSpecNameOrderFirstNameLastName)
       
   105     {
       
   106     }
       
   107 
       
   108 // ----------------------------------------------------------------------------
       
   109 // CCCAppMyCardContainer::~CCCAppMyCardContainer()
       
   110 // ----------------------------------------------------------------------------
       
   111 //
       
   112 CCCAppMyCardContainer::~CCCAppMyCardContainer()
       
   113     {
       
   114     iModel.SetClipListBoxText( NULL );
       
   115 	iPlugin.MyCard().RemoveObserver( this );
       
   116 	delete iBackground;
       
   117     delete iHeaderCtrl;
       
   118     delete iListBox;
       
   119     delete iImageLoader;
       
   120     delete iFactoryExtensionNotifier;
       
   121     delete iViewLauncher;
       
   122     delete iImageSelectionPopup;
       
   123     }
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // CCCAppMyCardContainer::ConstructL()
       
   127 // ----------------------------------------------------------------------------
       
   128 //
       
   129 void CCCAppMyCardContainer::ConstructL()
       
   130     {
       
   131     CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardContainer::ConstructL()"));
       
   132 
       
   133     iPlugin.MyCard().AddObserverL( this );
       
   134 
       
   135     ResolveNameOrderL();
       
   136     
       
   137     // Header UI control
       
   138     iHeaderCtrl = CCCAppMyCardHeaderControl::NewL( *this );
       
   139     iHeaderCtrl->SetContainerWindowL( *this );
       
   140     iHeaderCtrl->AddObserverL( this );
       
   141 
       
   142     // Details list UI control
       
   143     iListBox = new(ELeave) CAknFormDoubleGraphicStyleListBox;
       
   144     iListBox->ConstructL( this, EAknListBoxSelectionList );
       
   145     iListBox->SetContainerWindowL( *this );
       
   146     iListBox->EnableStretching( EFalse );
       
   147     
       
   148     // Setup listbox
       
   149     iListBox->View()->SetListEmptyTextL( KNullDesC );
       
   150     iListBox->CreateScrollBarFrameL( ETrue );
       
   151     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   152         CEikScrollBarFrame::EOff,
       
   153         CEikScrollBarFrame::EAuto );
       
   154 
       
   155     // Create icons for listbox.
       
   156     TResourceReader reader;
       
   157     iCoeEnv->CreateResourceReaderLC( reader, R_PBK2_FIELDTYPE_ICONS );
       
   158     iIconArray = CPbk2IconArray::NewL( reader );
       
   159   
       
   160     // Calculate preferred size for xsp service icons.
       
   161     TRect mainPane;
       
   162     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane );
       
   163     TAknLayoutRect listLayoutRect;
       
   164     listLayoutRect.LayoutRect(
       
   165         mainPane,
       
   166         AknLayoutScalable_Avkon::list_single_graphic_pane_g1(0).LayoutLine() );
       
   167     TSize size( listLayoutRect.Rect().Size() );
       
   168         
       
   169     // Add xsp service icons
       
   170     CPbk2ApplicationServices* appServices = CPbk2ApplicationServices::InstanceL();
       
   171     CPbk2ServiceManager& servMan = appServices->ServiceManager();
       
   172     
       
   173     const CPbk2ServiceManager::RServicesArray& services = servMan.Services();
       
   174     TUid uid;
       
   175     uid.iUid = KPbk2ServManId;
       
   176     
       
   177     for( TInt i = 0; i < services.Count(); i++ )
       
   178         {
       
   179         const CPbk2ServiceManager::TService& service = services[i];
       
   180         
       
   181         if ( service.iBitmapId && service.iBitmap )
       
   182             {
       
   183             AknIconUtils::SetSize(
       
   184                       service.iBitmap,
       
   185                       size );
       
   186             AknIconUtils::SetSize(
       
   187                       service.iMask,
       
   188                       size );
       
   189             TPbk2IconId id = TPbk2IconId( uid, service.iBitmapId );
       
   190             CPbk2IconInfo* info = CPbk2IconInfo::NewLC(
       
   191                id, service.iBitmap, service.iMask, size );
       
   192             iIconArray->AppendIconL( info );
       
   193             CleanupStack::Pop( info );
       
   194             }        
       
   195         }
       
   196     
       
   197     Release( appServices );
       
   198         
       
   199     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iIconArray );
       
   200     CleanupStack::PopAndDestroy(); // reader
       
   201 
       
   202     // setup model
       
   203     iModel.SetClipListBoxText( this );
       
   204     iModel.UpdateIconsL( *iIconArray );
       
   205     SetNameForHeaderControlL();
       
   206     
       
   207     iListBox->Model()->SetItemTextArray( &iModel.ListBoxModel() );
       
   208     iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   209 
       
   210     // Get the skin background for the view
       
   211     iBackground = CAknsBasicBackgroundControlContext::NewL(
       
   212         KAknsIIDQsnBgAreaMain, TRect(0, 0, 0, 0), EFalse );
       
   213 
       
   214     // Start observing now that the class is ready
       
   215     iListBox->SetListBoxObserver( this );
       
   216     iPlugin.MyCard().AddObserverL( this );
       
   217 
       
   218     if( iPlugin.MyCard().IsContactLinkReady() )
       
   219     	{
       
   220         CCCAppStatusControl* statusControl = iHeaderCtrl->StatusControl();
       
   221     	if( statusControl )
       
   222     	    {
       
   223             statusControl->SetContactLinkL( iPlugin.MyCard().ContactLink() );
       
   224     	    }
       
   225 		iControlLink = ETrue;
       
   226     	}
       
   227     iFactoryExtensionNotifier = CCCaFactoryExtensionNotifier::NewL();
       
   228 
       
   229     TCallBack callBack( CCCAppMyCardContainer::CheckExtensionFactoryL, this );
       
   230     iFactoryExtensionNotifier->ObserveExtensionFactoryL( callBack );
       
   231     
       
   232     CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardContainer::ConstructL()"));
       
   233     }
       
   234 
       
   235 /**
       
   236  * Gets a digit from a descriptor.
       
   237  *
       
   238  * @param aReaderToBuf  Resource reader pointed to a descriptor resource.
       
   239  * @return  The digit.
       
   240  */
       
   241 inline TInt GetDigitFromDescriptorL( TResourceReader& aReaderToBuf )
       
   242     {
       
   243     HBufC* orderBuf = aReaderToBuf.ReadHBufCL();
       
   244     CleanupStack::PushL( orderBuf );
       
   245 
       
   246     TInt result = KPbk2UiSpecNameOrderFirstNameLastName;
       
   247     TPtrC ptr( orderBuf->Des() );
       
   248     if ( ptr.Length() > 0 && TChar(ptr[0]).IsDigit() )
       
   249         {
       
   250         result = TChar(ptr[0]).GetNumericValue();
       
   251         }
       
   252 
       
   253     CleanupStack::PopAndDestroy( orderBuf );
       
   254     
       
   255     return result;
       
   256     }
       
   257 
       
   258 // ----------------------------------------------------------------------------
       
   259 // CCCAppMyCardContainer::ResolveNameOrderL()
       
   260 // ----------------------------------------------------------------------------
       
   261 //
       
   262 inline void CCCAppMyCardContainer::ResolveNameOrderL()
       
   263     {
       
   264     TInt orderInCenRep = EPbk2CenRepNameOrderUndefined;
       
   265 
       
   266     CRepository* sortOrderSettings = CRepository::NewLC(TUid::Uid(KCRUidPhonebook));
       
   267     sortOrderSettings->Get(KPhonebookNameOrdering, orderInCenRep);
       
   268     CleanupStack::PopAndDestroy(sortOrderSettings);    
       
   269     
       
   270     
       
   271     if( orderInCenRep == EPbk2CenRepLastNameFirstName ||
       
   272         orderInCenRep == EPbk2CenRepFirstNameLastName )
       
   273         {
       
   274         iNameOrder = KPbk2UiSpecNameOrderFirstNameLastName;
       
   275         if( orderInCenRep == EPbk2CenRepLastNameFirstName )
       
   276             {
       
   277             iNameOrder = KPbk2UiSpecNameOrderLastNameFirstName;
       
   278             }
       
   279         }
       
   280     else
       
   281         {
       
   282         // Read order from resource
       
   283         
       
   284         // Open resource file for reading language specific default values
       
   285         RPbk2LocalizedResourceFile resFile;
       
   286         resFile.OpenLC( KPbk2RomFileDrive,
       
   287                 KDC_RESOURCE_FILES_DIR, 
       
   288                 Pbk2PresentationUtils::PresentationResourceFile() );
       
   289 
       
   290         // Read the name order value from the resource file
       
   291         TResourceReader reader;
       
   292         reader.SetBuffer( resFile.AllocReadLC( R_QTN_PHOB_NAME_ORDER ) );
       
   293         TInt digit = GetDigitFromDescriptorL( reader );
       
   294         CleanupStack::PopAndDestroy( 2 ); // reader & resFile
       
   295         if( ( digit == KPbk2UiSpecNameOrderFirstNameLastName ) ||
       
   296             ( digit == KPbk2UiSpecNameOrderLastNameFirstName ) )
       
   297             {
       
   298             iNameOrder = digit;
       
   299             }    
       
   300         }
       
   301     }
       
   302 
       
   303 // ----------------------------------------------------------------------------
       
   304 // CCCAppMyCardContainer::Draw()
       
   305 // ----------------------------------------------------------------------------
       
   306 //
       
   307 void CCCAppMyCardContainer::Draw(const TRect& /*aRect*/) const
       
   308     {
       
   309     // Draw the background using skin
       
   310     if (iBackground)
       
   311         {
       
   312         AknsDrawUtils::Background(
       
   313             AknsUtils::SkinInstance(), iBackground, this, SystemGc(), Rect());
       
   314         }
       
   315     }
       
   316 
       
   317 // ----------------------------------------------------------------------------
       
   318 // CCCAppMyCardContainer::SizeChanged()
       
   319 // ----------------------------------------------------------------------------
       
   320 //
       
   321 void CCCAppMyCardContainer::SizeChanged()
       
   322     {
       
   323     TRect rect( Rect() );
       
   324 
       
   325     // Background skin
       
   326     iBackground->SetRect( rect );
       
   327 
       
   328     LayoutControls();
       
   329     
       
   330 	delete iImageSelectionPopup;
       
   331 	iImageSelectionPopup = NULL;
       
   332 
       
   333 	if( !iImageLoader )
       
   334 	    {
       
   335         if( !iModel.IsEmpty() )
       
   336             {
       
   337             TPtrC8 data( iModel.Data( CSpbContactDataModel::EDataImageContent ) );
       
   338             TInt err = KErrNotFound;
       
   339             if( data.Length() )
       
   340                 {
       
   341                 // thumbnail image in model -> load it
       
   342                 TPtrC file( iModel.Text( CSpbContactDataModel::ETextImageFileName ) );
       
   343                 TRAP( err, 
       
   344                     iImageLoader = CCCAppMyCardImageLoader::NewL( *this );
       
   345                     iImageLoader->LoadImageL( data, file, iHeaderCtrl->ThumbnailSize() );
       
   346                     );
       
   347                 }
       
   348             
       
   349             if( err )
       
   350                 {
       
   351                 // no thumbnail image available -> load default
       
   352                 ThumbnailLoadError( KErrNotFound ); 
       
   353                 }
       
   354             }
       
   355 	    }
       
   356 	else
       
   357 	    {
       
   358         // No need to call ResizeImageL() which would invoke the image decoder re-stating
       
   359         // to show the previous user-assigned image if MyCard image is not set. 
       
   360         if ( iMyCardImageSet )
       
   361             {
       
   362             TRAP_IGNORE( iImageLoader->ResizeImageL(iHeaderCtrl->ThumbnailSize()));
       
   363             }
       
   364 	    }
       
   365 	
       
   366     DrawDeferred();
       
   367     }
       
   368 
       
   369 // ---------------------------------------------------------------------------
       
   370 // CCCAppMyCardContainer::LayoutControls
       
   371 // ---------------------------------------------------------------------------
       
   372 //
       
   373 void CCCAppMyCardContainer::LayoutControls()
       
   374     {
       
   375     /**
       
   376      * Option0 (w button, prt)
       
   377      * Option2 (w/o button, prt)
       
   378      * Option1 (w button, lsc)
       
   379      * Option3 (w/o button, lsc)
       
   380      */
       
   381     
       
   382     const TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() );
       
   383     
       
   384     TInt option( isLandscape ? 3 : 2 ); // (w/o button)
       
   385     CCCAppStatusControl* statusControl = iHeaderCtrl->StatusControl();
       
   386     if( statusControl && statusControl->IsVisible() )
       
   387         {
       
   388         // (w button)
       
   389         if( isLandscape )
       
   390             {
       
   391             option = 1;
       
   392             }
       
   393         else
       
   394             {
       
   395             option = 0;
       
   396             }
       
   397         }
       
   398     
       
   399     // contact card pane layout
       
   400     TAknWindowComponentLayout contactCardPaneLayout( 
       
   401             TAknWindowComponentLayout::Compose( 
       
   402                     AknLayoutScalable_Apps::main_phob2_pane( 0 ),
       
   403                     AknLayoutScalable_Apps::phob2_contact_card_pane( 1 ) ) );
       
   404     
       
   405     // header layout
       
   406     TAknWindowComponentLayout headerPaneLayout( 
       
   407         TAknWindowComponentLayout::Compose( 
       
   408             contactCardPaneLayout,
       
   409             AknLayoutScalable_Apps::phob2_cc_data_pane( option ) ) );
       
   410     
       
   411     TAknLayoutRect headerPaneLayoutRect;
       
   412     headerPaneLayoutRect.LayoutRect( Rect(), headerPaneLayout.LayoutLine() );
       
   413     TRect headerPaneRect( headerPaneLayoutRect.Rect() );
       
   414     iHeaderCtrl->SetRect( headerPaneRect );
       
   415     
       
   416     // list layout
       
   417     TAknWindowComponentLayout listPaneLayout( 
       
   418         TAknWindowComponentLayout::Compose( 
       
   419             contactCardPaneLayout,
       
   420             AknLayoutScalable_Apps::phob2_cc_listscroll_pane( option ) ) );
       
   421     
       
   422     TAknLayoutRect listPaneLayoutRect;
       
   423     listPaneLayoutRect.LayoutRect( Rect(), listPaneLayout.LayoutLine() );
       
   424     TRect listPaneRect( listPaneLayoutRect.Rect() );
       
   425     iListBox->SetRect( listPaneRect );
       
   426     }
       
   427 
       
   428 
       
   429 // ----------------------------------------------------------------------------
       
   430 // CCCAppMyCardContainer::CheckExtensionFactoryL()
       
   431 // ----------------------------------------------------------------------------
       
   432 //
       
   433 TInt CCCAppMyCardContainer::CheckExtensionFactoryL(TAny* aPtr)
       
   434     {
       
   435     CCCAppMyCardContainer* self = static_cast<CCCAppMyCardContainer*>( aPtr );
       
   436     self->DoCheckExtensionFactoryL();
       
   437     return 0;
       
   438     }
       
   439 
       
   440 // ----------------------------------------------------------------------------
       
   441 // CCCAppMyCardContainer::DoCheckExtensionFactoryL()
       
   442 // ----------------------------------------------------------------------------
       
   443 //
       
   444 void CCCAppMyCardContainer::DoCheckExtensionFactoryL()
       
   445     {
       
   446     CCCAExtensionFactory* extension = iFactoryExtensionNotifier->ExtensionFactory();
       
   447     TBool visible = EFalse;
       
   448     MCCAStatusProvider* ccaStatusProvider = NULL;
       
   449     
       
   450     if( extension )
       
   451         {
       
   452         if ( !iViewLauncher )
       
   453             {
       
   454             iViewLauncher = extension->CreateViewLauncherL();
       
   455             }
       
   456         if ( iControlLink  // my card link has been set
       
   457                 && iViewLauncher->IsViewSupported( MCCAViewLauncher::EMyCardView ) )
       
   458             {
       
   459             visible = ETrue;
       
   460             }
       
   461         }
       
   462     else
       
   463         {
       
   464         delete iViewLauncher;
       
   465         iViewLauncher = NULL;
       
   466         }
       
   467             
       
   468     CCCAppStatusControl* statusControl = iHeaderCtrl->StatusControl();
       
   469     
       
   470     if( statusControl )
       
   471         {
       
   472 		if( extension )
       
   473         	{				
       
   474 			TAny* factoryExtension = extension->FactoryExtension( KCCAExtensionFactoryStatusProviderCreatorUid );        	
       
   475         	
       
   476 			 if( factoryExtension )
       
   477 				 {
       
   478 				 MCCAExtensionFactoryStatusProviderCreator* statusProviderCreator =
       
   479 						 static_cast<MCCAExtensionFactoryStatusProviderCreator*>( factoryExtension );
       
   480 
       
   481 				   if( statusProviderCreator )
       
   482 					   {
       
   483 					   ccaStatusProvider = statusProviderCreator->CreateStatusProviderL();					   
       
   484 					   }
       
   485 				 }
       
   486         	}
       
   487 		
       
   488 		statusControl->SetStatusProvider( ccaStatusProvider );
       
   489         statusControl->MakeVisible( visible );        
       
   490         LayoutControls();
       
   491         DrawDeferred();
       
   492         }
       
   493     }
       
   494 
       
   495 // ----------------------------------------------------------------------------
       
   496 // CCCAppMyCardContainer::CountComponentControls()
       
   497 // ----------------------------------------------------------------------------
       
   498 //
       
   499 TInt CCCAppMyCardContainer::CountComponentControls() const
       
   500     {
       
   501     return KSubComponentCount;
       
   502     }
       
   503 
       
   504 // ----------------------------------------------------------------------------
       
   505 // CCCAppMyCardContainer::ComponentControl()
       
   506 // ----------------------------------------------------------------------------
       
   507 //
       
   508 CCoeControl* CCCAppMyCardContainer::ComponentControl( TInt aIndex ) const
       
   509     {
       
   510     switch( aIndex )
       
   511         {
       
   512         case 0:
       
   513             {
       
   514             return iHeaderCtrl;
       
   515             }
       
   516         case 1:
       
   517         	{
       
   518 			return iListBox;
       
   519 			}
       
   520         }
       
   521     return NULL;
       
   522     }
       
   523 
       
   524 // ----------------------------------------------------------------------------
       
   525 // CCCAppMyCardContainer::MopSupplyObject()
       
   526 // ----------------------------------------------------------------------------
       
   527 //
       
   528 TTypeUid::Ptr CCCAppMyCardContainer::MopSupplyObject(TTypeUid aId)
       
   529     {
       
   530     // For skinning
       
   531     if( iBackground && aId.iUid == MAknsControlContext::ETypeId )
       
   532         {
       
   533         return MAknsControlContext::SupplyMopObject( aId, iBackground );
       
   534         }
       
   535 
       
   536     return CCoeControl::MopSupplyObject(aId);
       
   537     }
       
   538 
       
   539 // ----------------------------------------------------------------------------
       
   540 // CCCAppMyCardContainer::OfferKeyEventL()
       
   541 // ----------------------------------------------------------------------------
       
   542 //
       
   543 TKeyResponse CCCAppMyCardContainer::OfferKeyEventL(
       
   544     const TKeyEvent& aKeyEvent,
       
   545     TEventCode aType )
       
   546     {
       
   547     TKeyResponse resp = CCCAppViewPluginAknContainer::OfferKeyEventL( aKeyEvent, aType );
       
   548     if( iListBox && resp == EKeyWasNotConsumed )
       
   549         {
       
   550         resp = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   551         }
       
   552     return resp;
       
   553     }
       
   554 
       
   555 // ----------------------------------------------------------------------------
       
   556 // CCCAppMyCardContainer::MyCardEventL()
       
   557 // ----------------------------------------------------------------------------
       
   558 //
       
   559 void CCCAppMyCardContainer::MyCardEventL( MMyCardObserver::TEvent aEvent )
       
   560     {
       
   561     if( aEvent == MMyCardObserver::EEventContactChanged ||
       
   562         ( aEvent == MMyCardObserver::EEventContactLoaded && iModel.IsEmpty() ) )
       
   563         {   
       
   564         TInt itemCount_BeforeChange = iModel.ListBoxModel().MdcaCount();
       
   565         TInt focusItem_BeforeChange = iListBox->CurrentItemIndex();
       
   566     
       
   567         CCCAppMyCard& mycard = iPlugin.MyCard();
       
   568         iModel.SetDataL( mycard.PresentationContactL(), iIconArray );
       
   569         
       
   570         TInt itemCount_AfterChange = iModel.ListBoxModel().MdcaCount();
       
   571         TInt focusItem_AfterChange = iListBox->CurrentItemIndex();
       
   572         
       
   573         if( itemCount_BeforeChange > itemCount_AfterChange && 
       
   574                 focusItem_AfterChange == KErrNotFound )
       
   575             {
       
   576             if( focusItem_BeforeChange >= itemCount_AfterChange )
       
   577             	{
       
   578                 iListBox->SetCurrentItemIndex( itemCount_AfterChange-1 );
       
   579             	}
       
   580             else if( focusItem_BeforeChange >= 0 )
       
   581             	{
       
   582                 iListBox->SetCurrentItemIndex( focusItem_BeforeChange );
       
   583             	}
       
   584             else
       
   585             	{
       
   586                 iListBox->SetCurrentItemIndex( 0 );
       
   587             	}
       
   588             }
       
   589         
       
   590         if( iListBox )
       
   591             {
       
   592             iListBox->HandleItemAdditionL();
       
   593             }
       
   594           
       
   595         // Set own contact name
       
   596         SetNameForHeaderControlL();
       
   597         
       
   598         // start loading image
       
   599         if( !iImageLoader )
       
   600             {
       
   601             // lazy initialization
       
   602             iImageLoader = CCCAppMyCardImageLoader::NewL( *this );
       
   603             }
       
   604         iImageLoader->LoadContactImageL( mycard.StoreContact(), 
       
   605                 iHeaderCtrl->ThumbnailSize() );
       
   606         }
       
   607 
       
   608     CCCAppStatusControl* statusControl = iHeaderCtrl->StatusControl();
       
   609 
       
   610     if( iPlugin.MyCard().IsContactLinkReady() && !iControlLink )
       
   611 		{
       
   612 		if( statusControl )
       
   613 		    {
       
   614             statusControl->SetContactLinkL( iPlugin.MyCard().ContactLink() );
       
   615             iControlLink = ETrue;
       
   616 		    }
       
   617 		}
       
   618 
       
   619     if ( statusControl && !statusControl->IsVisible() &&
       
   620             iControlLink && iViewLauncher &&
       
   621             iViewLauncher->IsViewSupported( MCCAViewLauncher::EMyCardView ) )
       
   622         {
       
   623         statusControl->MakeVisible( ETrue );
       
   624         LayoutControls();
       
   625         DrawDeferred();
       
   626         }
       
   627     }
       
   628 
       
   629 
       
   630 // ----------------------------------------------------------------------------
       
   631 // CCCAppMyCardContainer::ThumbnailReady()
       
   632 // ----------------------------------------------------------------------------
       
   633 //
       
   634 void CCCAppMyCardContainer::ThumbnailReady( CFbsBitmap* aThumbnail )
       
   635     {
       
   636     // takes ownership
       
   637     TRAPD( err, iHeaderCtrl->SetPortraitBitmapL( aThumbnail ) );
       
   638     if( err != KErrNone )
       
   639         {
       
   640         iPlugin.HandleError( err );
       
   641         }
       
   642     // Contact Image set. Set the flag.
       
   643     iMyCardImageSet = ETrue;
       
   644     }
       
   645 
       
   646 // ----------------------------------------------------------------------------
       
   647 // CCCAppMyCardContainer::ThumbnailLoadError()
       
   648 // ----------------------------------------------------------------------------
       
   649 //
       
   650 void CCCAppMyCardContainer::ThumbnailLoadError( TInt /*aError*/ )
       
   651     {
       
   652     CFbsBitmap* bitmap = NULL;
       
   653     CFbsBitmap* mask = NULL;
       
   654     
       
   655     TRAPD( err, AknsUtils::CreateIconL(
       
   656         AknsUtils::SkinInstance(),
       
   657         KAknsIIDQgnPropPbThumpMycard,
       
   658         bitmap,
       
   659         mask,
       
   660         KMyCardIconDefaultFileName,
       
   661         EMbmPhonebook2eceQgn_prop_pb_thump_mycard,
       
   662         EMbmPhonebook2eceQgn_prop_pb_thump_mycard_mask ) );
       
   663     if( !err )
       
   664         {
       
   665         iHeaderCtrl->SetPortraitIcon( bitmap, mask ); // takes ownership
       
   666         }
       
   667     // Default contact image used.
       
   668     iMyCardImageSet = EFalse;
       
   669     }
       
   670 
       
   671 // ----------------------------------------------------------------------------
       
   672 // CCCAppMyCardContainer::HandleListBoxEventL
       
   673 // ----------------------------------------------------------------------------
       
   674 //
       
   675 void CCCAppMyCardContainer::HandleListBoxEventL(
       
   676     CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
   677     {
       
   678     switch( aEventType )
       
   679         {
       
   680         case EEventEnterKeyPressed:
       
   681         case EEventItemDoubleClicked:
       
   682         case EEventItemSingleClicked:
       
   683             {
       
   684             // start the editor and pass tapped field index
       
   685             iPlugin.EditL( FocusedFieldIndex() );
       
   686             break;
       
   687             }
       
   688         default:
       
   689             {
       
   690             // ignored
       
   691             }
       
   692         }
       
   693     }
       
   694 
       
   695 // ---------------------------------------------------------------------------
       
   696 // CCCAppMyCardContainer::Plugin
       
   697 // ---------------------------------------------------------------------------
       
   698 //
       
   699 CCCAppMyCardPlugin& CCCAppMyCardContainer::Plugin()
       
   700     {
       
   701     return iPlugin;
       
   702     }
       
   703 
       
   704 
       
   705 /************************ FUNCTIONS FROM UI CONTROL ************************/
       
   706 
       
   707 // --------------------------------------------------------------------------
       
   708 // CCCAppMyCardContainer::ParentControl
       
   709 // --------------------------------------------------------------------------
       
   710 //
       
   711 MPbk2ContactUiControl* CCCAppMyCardContainer::ParentControl() const
       
   712 	{
       
   713     // Contact info control has no parent control
       
   714     return NULL;
       
   715 	}
       
   716 
       
   717 // --------------------------------------------------------------------------
       
   718 // CCCAppMyCardContainer::NumberOfContacts
       
   719 // --------------------------------------------------------------------------
       
   720 //
       
   721 TInt CCCAppMyCardContainer::NumberOfContacts() const
       
   722 	{
       
   723     return KNumberOfContacts;
       
   724 	}
       
   725 
       
   726 // --------------------------------------------------------------------------
       
   727 // CCCAppMyCardContainer::FocusedContactL
       
   728 // --------------------------------------------------------------------------
       
   729 //
       
   730 const MVPbkBaseContact* CCCAppMyCardContainer::FocusedContactL() const
       
   731 	{
       
   732     return static_cast<MVPbkBaseContact*>( &iPlugin.MyCard().StoreContact() );
       
   733 	}
       
   734 
       
   735 // --------------------------------------------------------------------------
       
   736 // CCCAppMyCardContainer::FocusedViewContactL
       
   737 // --------------------------------------------------------------------------
       
   738 //
       
   739 const MVPbkViewContact* CCCAppMyCardContainer::FocusedViewContactL() const
       
   740 	{
       
   741     return NULL;
       
   742 	}
       
   743 
       
   744 
       
   745 // --------------------------------------------------------------------------
       
   746 // CCCAppMyCardContainer::FocusedStoreContact
       
   747 // --------------------------------------------------------------------------
       
   748 //
       
   749 const MVPbkStoreContact* CCCAppMyCardContainer::FocusedStoreContact() const
       
   750 	{
       
   751 	return &iPlugin.MyCard().StoreContact();
       
   752     }
       
   753 
       
   754 // --------------------------------------------------------------------------
       
   755 // CCCAppMyCardContainer::SetFocusedContactL
       
   756 // --------------------------------------------------------------------------
       
   757 //
       
   758 void CCCAppMyCardContainer::SetFocusedContactL(
       
   759     const MVPbkBaseContact& /*aContact*/ )
       
   760 	{
       
   761     // do nothing
       
   762 	}
       
   763 
       
   764 // --------------------------------------------------------------------------
       
   765 // CCCAppMyCardContainer::SetFocusedContactL
       
   766 // --------------------------------------------------------------------------
       
   767 //
       
   768 void CCCAppMyCardContainer::SetFocusedContactL(
       
   769     const MVPbkContactBookmark& /*aContactBookmark*/)
       
   770 	{
       
   771     // Do nothing
       
   772 	}
       
   773 
       
   774 // --------------------------------------------------------------------------
       
   775 // CCCAppMyCardContainer::SetFocusedContactL
       
   776 // --------------------------------------------------------------------------
       
   777 //
       
   778 void CCCAppMyCardContainer::SetFocusedContactL(
       
   779     const MVPbkContactLink& /*aContactLink*/ )
       
   780 	{
       
   781 	}
       
   782 
       
   783 // --------------------------------------------------------------------------
       
   784 // CCCAppMyCardContainer::FocusedContactIndex
       
   785 // --------------------------------------------------------------------------
       
   786 //
       
   787 TInt CCCAppMyCardContainer::FocusedContactIndex() const
       
   788 	{
       
   789     return KErrNotSupported;
       
   790 	}
       
   791 
       
   792 // --------------------------------------------------------------------------
       
   793 // CCCAppMyCardContainer::SetFocusedContactIndexL
       
   794 // --------------------------------------------------------------------------
       
   795 //
       
   796 void CCCAppMyCardContainer::SetFocusedContactIndexL(TInt /*aIndex*/)
       
   797 	{
       
   798     // Do nothing
       
   799 	}
       
   800 
       
   801 // --------------------------------------------------------------------------
       
   802 // CCCAppMyCardContainer::NumberOfContactFields
       
   803 // --------------------------------------------------------------------------
       
   804 //
       
   805 TInt CCCAppMyCardContainer::NumberOfContactFields() const
       
   806 	{
       
   807     TInt cnt = KErrNotSupported;
       
   808     cnt =  iPlugin.MyCard().StoreContact().Fields().FieldCount();
       
   809     return cnt;
       
   810 	}
       
   811 
       
   812 // --------------------------------------------------------------------------
       
   813 // CCCAppMyCardContainer::FocusedField
       
   814 // --------------------------------------------------------------------------
       
   815 //
       
   816 const MVPbkBaseContactField* CCCAppMyCardContainer::FocusedField() const
       
   817 	{
       
   818 	TInt index = FocusedFieldIndex();
       
   819 	if( index != KErrNotFound )
       
   820 		{
       
   821 		return &iPlugin.MyCard().StoreContact().Fields().FieldAt(index);
       
   822 		}
       
   823     return NULL;
       
   824 	}
       
   825 
       
   826 // --------------------------------------------------------------------------
       
   827 // CCCAppMyCardContainer::FocusedFieldIndex
       
   828 // --------------------------------------------------------------------------
       
   829 //
       
   830 TInt CCCAppMyCardContainer::FocusedFieldIndex() const
       
   831 	{
       
   832     TInt index = KErrNotFound;
       
   833     TRAP_IGNORE( 
       
   834         CPbk2PresentationContact& contact = iPlugin.MyCard().PresentationContactL();
       
   835         index = contact.PresentationFields().StoreIndexOfField( 
       
   836             iModel.PresentationFieldIndex( iListBox->CurrentItemIndex() ) );
       
   837         );
       
   838 	return index;
       
   839 	}
       
   840 
       
   841 // --------------------------------------------------------------------------
       
   842 // CCCAppMyCardContainer::SetFocusedFieldIndex
       
   843 // --------------------------------------------------------------------------
       
   844 //
       
   845 void CCCAppMyCardContainer::SetFocusedFieldIndex( TInt /*aIndex*/ )
       
   846 	{
       
   847 	// do nothing
       
   848 	}
       
   849 
       
   850 // --------------------------------------------------------------------------
       
   851 // CCCAppMyCardContainer::ContactsMarked
       
   852 // --------------------------------------------------------------------------
       
   853 //
       
   854 TBool CCCAppMyCardContainer::ContactsMarked() const
       
   855 	{
       
   856     // This control does not support contacts marking
       
   857     return EFalse;
       
   858 	}
       
   859 
       
   860 // --------------------------------------------------------------------------
       
   861 // CCCAppMyCardContainer::SelectedContactsL
       
   862 // --------------------------------------------------------------------------
       
   863 //
       
   864 MVPbkContactLinkArray* CCCAppMyCardContainer::SelectedContactsL() const
       
   865 	{
       
   866     // No selection support in contact info control
       
   867     return NULL;
       
   868 	}
       
   869 
       
   870 // --------------------------------------------------------------------------
       
   871 // CCCAppMyCardContainer::SelectedContactsOrFocusedContactL
       
   872 // --------------------------------------------------------------------------
       
   873 //
       
   874 MVPbkContactLinkArray*
       
   875 CCCAppMyCardContainer::SelectedContactsOrFocusedContactL() const
       
   876 	{
       
   877     CVPbkContactLinkArray* array = CVPbkContactLinkArray::NewLC();
       
   878     const MVPbkBaseContact* focusedContact = FocusedContactL();
       
   879 
       
   880     if( focusedContact )
       
   881     	{
       
   882         MVPbkContactLink* link = focusedContact->CreateLinkLC();
       
   883         CleanupStack::Pop(); // link
       
   884         array->AppendL(link);
       
   885     	}
       
   886     CleanupStack::Pop(array);
       
   887     return array;
       
   888 	}
       
   889 
       
   890 // --------------------------------------------------------------------------
       
   891 // CCCAppMyCardContainer::SelectedContactsIteratorL
       
   892 // --------------------------------------------------------------------------
       
   893 //
       
   894 MPbk2ContactLinkIterator*
       
   895 CCCAppMyCardContainer::SelectedContactsIteratorL() const
       
   896 	{
       
   897     // No selection support in contact info control
       
   898     return NULL;
       
   899 	}
       
   900 
       
   901 // --------------------------------------------------------------------------
       
   902 // CCCAppMyCardContainer::SelectedContactStoresL
       
   903 // --------------------------------------------------------------------------
       
   904 //
       
   905 CArrayPtr<MVPbkContactStore>*
       
   906 CCCAppMyCardContainer::SelectedContactStoresL() const
       
   907 	{
       
   908     // This is not a contact store control
       
   909     return NULL;
       
   910 	}
       
   911 
       
   912 // --------------------------------------------------------------------------
       
   913 // CCCAppMyCardContainer::ClearMarks
       
   914 // --------------------------------------------------------------------------
       
   915 //
       
   916 
       
   917 void CCCAppMyCardContainer::ClearMarks()
       
   918 	{
       
   919 	// Do nothing
       
   920 	}
       
   921 
       
   922 // --------------------------------------------------------------------------
       
   923 // CCCAppMyCardContainer::SetSelectedContactL
       
   924 // --------------------------------------------------------------------------
       
   925 //
       
   926 void CCCAppMyCardContainer::SetSelectedContactL(
       
   927     TInt /*aIndex*/,
       
   928     TBool /*aSelected*/)
       
   929 	{
       
   930     // Not supported in Contact Info
       
   931 	}
       
   932 
       
   933 // --------------------------------------------------------------------------
       
   934 // CCCAppMyCardContainer::SetSelectedContactL
       
   935 // --------------------------------------------------------------------------
       
   936 //
       
   937 void CCCAppMyCardContainer::SetSelectedContactL(
       
   938     const MVPbkContactBookmark& /*aContactBookmark*/,
       
   939     TBool /*aSelected*/)
       
   940 	{
       
   941     // Not supported
       
   942 	}
       
   943 
       
   944 // --------------------------------------------------------------------------
       
   945 // CCCAppMyCardContainer::SetSelectedContactL
       
   946 // --------------------------------------------------------------------------
       
   947 //
       
   948 void CCCAppMyCardContainer::SetSelectedContactL(
       
   949     const MVPbkContactLink& /*aContactLink*/,
       
   950     TBool /*aSelected*/)
       
   951 	{
       
   952     // Not supported
       
   953 	}
       
   954 
       
   955 // --------------------------------------------------------------------------
       
   956 // CCCAppMyCardContainer::DynInitMenuPaneL
       
   957 // --------------------------------------------------------------------------
       
   958 //
       
   959 void CCCAppMyCardContainer::DynInitMenuPaneL(
       
   960     TInt /*aResourceId*/,
       
   961     CEikMenuPane* /*aMenuPane*/) const
       
   962     {
       
   963     // Nothing to do
       
   964     }
       
   965 
       
   966 // --------------------------------------------------------------------------
       
   967 // CCCAppMyCardContainer::ProcessCommandL
       
   968 // --------------------------------------------------------------------------
       
   969 //
       
   970 void CCCAppMyCardContainer::ProcessCommandL(TInt /*aCommandId*/) const
       
   971         {
       
   972     // Nothing to do
       
   973         }
       
   974 
       
   975 // --------------------------------------------------------------------------
       
   976 // CCCAppMyCardContainer::UpdateAfterCommandExecution
       
   977 // --------------------------------------------------------------------------
       
   978 //
       
   979 void CCCAppMyCardContainer::UpdateAfterCommandExecution()
       
   980 	{
       
   981     if (iCommand)
       
   982     	{
       
   983         /// Reset command pointer, command has completed
       
   984         iCommand->ResetUiControl(*this);
       
   985         iCommand = NULL;
       
   986     	}
       
   987 	}
       
   988 
       
   989 // --------------------------------------------------------------------------
       
   990 // CCCAppMyCardContainer::GetMenuFilteringFlagsL
       
   991 // --------------------------------------------------------------------------
       
   992 //
       
   993 TInt CCCAppMyCardContainer::GetMenuFilteringFlagsL() const
       
   994 	{
       
   995     const TInt fieldCount =
       
   996 		 iPlugin.MyCard().StoreContact().Fields().FieldCount();
       
   997     // If negative will leave
       
   998     User::LeaveIfError( fieldCount );
       
   999 
       
  1000     TInt ret = KPbk2MenuFilteringFlagsNone;
       
  1001     if( fieldCount > KNoContacts )
       
  1002     	{
       
  1003         ret |= KPbk2ListContainsItems;
       
  1004     	}
       
  1005     return ret;
       
  1006 	}
       
  1007 
       
  1008 // --------------------------------------------------------------------------
       
  1009 // CCCAppMyCardContainer::ControlStateL
       
  1010 // --------------------------------------------------------------------------
       
  1011 //
       
  1012 CPbk2ViewState* CCCAppMyCardContainer::ControlStateL() const
       
  1013 	{
       
  1014     return NULL;
       
  1015 	}
       
  1016 
       
  1017 // --------------------------------------------------------------------------
       
  1018 // CCCAppMyCardContainer::RestoreControlStateL
       
  1019 // --------------------------------------------------------------------------
       
  1020 //
       
  1021 void CCCAppMyCardContainer::RestoreControlStateL(
       
  1022     CPbk2ViewState* /*aState*/)
       
  1023 	{
       
  1024     // Do nothing
       
  1025 	}
       
  1026 
       
  1027 // --------------------------------------------------------------------------
       
  1028 // CCCAppMyCardContainer::FindTextL
       
  1029 // --------------------------------------------------------------------------
       
  1030 //
       
  1031 const TDesC& CCCAppMyCardContainer::FindTextL()
       
  1032 	{
       
  1033     // No find box in this control
       
  1034     return KNullDesC;
       
  1035 	}
       
  1036 
       
  1037 // --------------------------------------------------------------------------
       
  1038 // CCCAppMyCardContainer::ResetFindL
       
  1039 // --------------------------------------------------------------------------
       
  1040 //
       
  1041 void CCCAppMyCardContainer::ResetFindL()
       
  1042 	{
       
  1043     // Do nothing
       
  1044 	}
       
  1045 
       
  1046 // --------------------------------------------------------------------------
       
  1047 // CCCAppMyCardContainer::ShowThumbnail
       
  1048 // --------------------------------------------------------------------------
       
  1049 //
       
  1050 void CCCAppMyCardContainer::ShowThumbnail()
       
  1051 	{
       
  1052     // Do nothing
       
  1053 	}
       
  1054 
       
  1055 // --------------------------------------------------------------------------
       
  1056 // CCCAppMyCardContainer::HideThumbnail
       
  1057 // --------------------------------------------------------------------------
       
  1058 //
       
  1059 void CCCAppMyCardContainer::HideThumbnail()
       
  1060 	{
       
  1061     // Do nothing
       
  1062 	}
       
  1063 
       
  1064 // --------------------------------------------------------------------------
       
  1065 // CCCAppMyCardContainer::SetBlank
       
  1066 // --------------------------------------------------------------------------
       
  1067 //
       
  1068 void CCCAppMyCardContainer::SetBlank( TBool /*aBlank*/ )
       
  1069 	{
       
  1070     // This control does not support blanking
       
  1071 	}
       
  1072 
       
  1073 // --------------------------------------------------------------------------
       
  1074 // CCCAppMyCardContainer::RegisterCommand
       
  1075 // --------------------------------------------------------------------------
       
  1076 //
       
  1077 void CCCAppMyCardContainer::RegisterCommand( MPbk2Command* aCommand )
       
  1078 	{
       
  1079     iCommand = aCommand;
       
  1080 	}
       
  1081 
       
  1082 // --------------------------------------------------------------------------
       
  1083 // CCCAppMyCardContainer::SetTextL
       
  1084 // --------------------------------------------------------------------------
       
  1085 //
       
  1086 void CCCAppMyCardContainer::SetTextL( const TDesC& /*aText*/ )
       
  1087 	{
       
  1088     // Do nothing
       
  1089 	}
       
  1090 
       
  1091 // --------------------------------------------------------------------------
       
  1092 // CCCAppMyCardContainer::ContactUiControlExtension
       
  1093 // --------------------------------------------------------------------------
       
  1094 //
       
  1095 TAny* CCCAppMyCardContainer::ContactUiControlExtension( TUid /*aExtensionUid*/ )
       
  1096 	{
       
  1097     return NULL;
       
  1098 	}
       
  1099 
       
  1100 //-----------------------------------------------------------------------------
       
  1101 // void CCCAppMyCardContainer::StatusClickedL()
       
  1102 //-----------------------------------------------------------------------------
       
  1103 //
       
  1104 void CCCAppMyCardContainer::StatusClickedL()
       
  1105 	{
       
  1106     if ( iViewLauncher )
       
  1107 		{
       
  1108         iViewLauncher->LaunchViewL( MCCAViewLauncher::EMyCardView );
       
  1109 		}		
       
  1110 	}
       
  1111 
       
  1112 //------------------------------------------------------------------------------
       
  1113 // void CCCAppMyCardContainer::SetNameForHeaderContorl()
       
  1114 //------------------------------------------------------------------------------
       
  1115 //
       
  1116 void CCCAppMyCardContainer::SetNameForHeaderControlL()
       
  1117 	{
       
  1118     TPtrC fname( iModel.Text( CSpbContactDataModel::ETextFirstName ) );
       
  1119     TPtrC lname( iModel.Text( CSpbContactDataModel::ETextLastName ) );
       
  1120     switch ( iNameOrder )
       
  1121         {
       
  1122         case KPbk2UiSpecNameOrderFirstNameLastName:
       
  1123             {
       
  1124             iHeaderCtrl->SetLabel1TextL( fname );
       
  1125             iHeaderCtrl->SetLabel2TextL( lname );
       
  1126             break;
       
  1127             }
       
  1128         case KPbk2UiSpecNameOrderLastNameFirstName: // FALL THROUGH
       
  1129         default:
       
  1130             {
       
  1131             iHeaderCtrl->SetLabel2TextL( fname );
       
  1132             iHeaderCtrl->SetLabel1TextL( lname );
       
  1133             break;
       
  1134             }
       
  1135         }
       
  1136 	}
       
  1137 
       
  1138 //------------------------------------------------------------------------------
       
  1139 // void CCCAppMyCardContainer::MyCardHeaderControlClickL()
       
  1140 //------------------------------------------------------------------------------
       
  1141 //
       
  1142 void CCCAppMyCardContainer::MyCardHeaderControlClickL( TPoint aPos )
       
  1143 {
       
  1144     if( iPlugin.MyCard().HeaderControlBlocked() )
       
  1145         {
       
  1146         return;
       
  1147         }
       
  1148             
       
  1149     if ( !iImageSelectionPopup )
       
  1150         {
       
  1151         iImageSelectionPopup = CAknStylusPopUpMenu::NewL( &iPlugin, aPos );
       
  1152         TInt resourceReaderId = R_MYCARD_CONTACT_IMAGE_STYLUS_MENU; 
       
  1153         TResourceReader reader;
       
  1154         iCoeEnv->CreateResourceReaderLC( reader , resourceReaderId );
       
  1155         iImageSelectionPopup->ConstructFromResourceL( reader );
       
  1156         CleanupStack::PopAndDestroy(); // reader
       
  1157         }
       
  1158     
       
  1159     // MyCard image has been set. Dim option menu items accordingly
       
  1160     if( iMyCardImageSet )
       
  1161         {        
       
  1162         // If the image has been deleted in the memory, "view image" should be hidden.
       
  1163         TPtrC imageFileName( iModel.Text( CSpbContactDataModel::ETextImageFileName ) );                        
       
  1164         RFs& fs( iCoeEnv->FsSession() );
       
  1165         TEntry entry;
       
  1166         iImageSelectionPopup->SetItemDimmed( ECCAppMyCardCmdStylusViewImageCmd, 
       
  1167                 ( fs.Entry( imageFileName , entry ) == KErrNone ) ? EFalse : ETrue );                                                    
       
  1168         iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusChangeImageCmd, EFalse);
       
  1169         iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusRemoveImageCmd, EFalse);
       
  1170         iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusAddImageCmd, ETrue);
       
  1171         }
       
  1172     // MyCard image has not been set
       
  1173     else
       
  1174         {
       
  1175         iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusViewImageCmd, ETrue);
       
  1176         iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusChangeImageCmd, ETrue);
       
  1177         iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusRemoveImageCmd, ETrue);
       
  1178         iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusAddImageCmd, EFalse);
       
  1179         } 
       
  1180           
       
  1181     PosToScreenCoordinates( this, aPos );
       
  1182    
       
  1183     iImageSelectionPopup->SetPosition( aPos );
       
  1184     iImageSelectionPopup->ShowMenu();   
       
  1185 }
       
  1186  
       
  1187 // ----------------------------------------------------------------------------
       
  1188 // CCCAppCommLauncherContainer::HandlePointerEventL()
       
  1189 // ----------------------------------------------------------------------------
       
  1190 //
       
  1191 void CCCAppMyCardContainer::HandlePointerEventL(
       
  1192     const TPointerEvent& aPointerEvent )
       
  1193     {               
       
  1194     CCoeControl::HandlePointerEventL( aPointerEvent );              
       
  1195     }
       
  1196 
       
  1197 // --------------------------------------------------------------------------
       
  1198 // CCCAppMyCardContainer::ClipFromBeginning
       
  1199 // --------------------------------------------------------------------------
       
  1200 //
       
  1201 TBool CCCAppMyCardContainer::ClipFromBeginning(
       
  1202     TDes& aBuffer, TInt aItemIndex, TInt aSubCellNumber )
       
  1203     {
       
  1204     if( iListBox )
       
  1205         {   
       
  1206         return AknTextUtils::ClipToFit( aBuffer, AknTextUtils::EClipFromBeginning,
       
  1207             iListBox, aItemIndex, aSubCellNumber );
       
  1208         }
       
  1209     return EFalse;
       
  1210     }
       
  1211 
       
  1212 // ---------------------------------------------------------------------------
       
  1213 // CCCAppCommLauncherContainer::PosToScreenCoordinates
       
  1214 // ---------------------------------------------------------------------------
       
  1215 //
       
  1216 void CCCAppMyCardContainer::PosToScreenCoordinates( 
       
  1217         CCoeControl* aControl, TPoint& aPos )
       
  1218      {
       
  1219      TPoint leftUpperPos = aControl->PositionRelativeToScreen();
       
  1220      aPos += leftUpperPos;
       
  1221      }
       
  1222 
       
  1223 // ----------------------------------------------------------------------------
       
  1224 // CCCAppMyCardContainer::GetHelpContext()
       
  1225 // ----------------------------------------------------------------------------
       
  1226 //
       
  1227 void CCCAppMyCardContainer::GetHelpContext(TCoeHelpContext& aContext) const
       
  1228     {
       
  1229     aContext.iMajor.iUid = KPbk2UID3;
       
  1230     aContext.iContext = KHLP_CCA_MY_CARD;
       
  1231     }
       
  1232 
       
  1233 // End of File