phonebookui/Phonebook2/UIControls/src/CPbk2ContactInfoControl.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Phonebook 2 contact info view control.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <CPbk2ContactInfoControl.h>
       
    22 
       
    23 // Phonebook 2
       
    24 #include "CPbk2ContactInfoListBox.h"
       
    25 #include "CPbk2ContactInfoDataSwapper.h"
       
    26 #include "CPbk2ContactFieldDynamicProperties.h"
       
    27 #include "CPbk2ThumbnailLoader.h"
       
    28 #include "Pbk2TitlePanePictureFactory.h"
       
    29 #include <Pbk2UIControls.rsg>
       
    30 #include <Pbk2UIControls.hrh>
       
    31 #include <CPbk2IconArray.h>
       
    32 #include <MPbk2ContactNameFormatter.h>
       
    33 #include <CPbk2ViewState.h>
       
    34 #include <MPbk2ControlObserver.h>
       
    35 #include <CPbk2PresentationContact.h>
       
    36 #include <CPbk2PresentationContactField.h>
       
    37 #include <CPbk2PresentationContactFieldCollection.h>
       
    38 #include <CPbk2FieldPropertyArray.h>
       
    39 #include <Pbk2MenuFilteringFlags.hrh>
       
    40 #include <MPbk2ContactNavigation.h>
       
    41 #include <CPbk2StorePropertyArray.h>
       
    42 #include <CPbk2StoreSpecificFieldPropertyArray.h>
       
    43 #include <MPbk2Command.h>
       
    44 #include <Pbk2Profile.h>
       
    45 
       
    46 // Virtual Phonebook
       
    47 #include <MVPbkContactOperationBase.h>
       
    48 #include <CVPbkContactManager.h>
       
    49 #include <MVPbkContactLink.h>
       
    50 #include <MVPbkStoreContact.h>
       
    51 #include <MVPbkStoreContactField.h>
       
    52 #include <MVPbkStoreContactFieldCollection.h>
       
    53 #include <MVPbkContactStore.h>
       
    54 #include <MVPbkContactStoreProperties.h>
       
    55 #include <MVPbkContactFieldSelector.h>
       
    56 #include <MVPbkFieldType.h>
       
    57 #include <CVPbkFieldTypeSelector.h>
       
    58 #include <CVPbkContactStoreUriArray.h>
       
    59 #include <MVPbkContactFieldTextData.h>
       
    60 #include <VPbkEng.rsg>
       
    61 
       
    62 // System includes
       
    63 #include <akntitle.h>
       
    64 #include <AknsConstants.h>
       
    65 #include <avkon.hrh>
       
    66 #include <barsread.h>
       
    67 #include <bautils.h>
       
    68 
       
    69 // Debugging headers
       
    70 #include <Pbk2Debug.h>
       
    71 
       
    72 
       
    73 /// Unnamed namespace for local definitions
       
    74 namespace {
       
    75 
       
    76 // LOCAL CONSTANTS AND MACROS
       
    77 
       
    78 const TInt KNumberOfControls = 1;
       
    79 const TInt KNoContacts = 0;
       
    80 const TInt KNumberOfContacts = 1;
       
    81 const TInt KDefaultTitleFormat = MPbk2ContactNameFormatter::EUseSeparator;
       
    82 
       
    83 #ifdef _DEBUG
       
    84 enum TPanicCode
       
    85     {
       
    86     EPanicPreCond_FocusedField = 1,
       
    87     EPanicLogic_FocusedField,
       
    88     EPanicPreCond_FocusedFieldIndex,
       
    89     EPanicPostCond_FocusedFieldIndex,
       
    90     EPanicPreCond_FieldPos,
       
    91     EPanicPreCond_OfferKeyEventL,
       
    92     EPanicPreCond_SizeChanged,
       
    93     EPanicPreCond_CountComponentControls,
       
    94     EPanicPreCond_ComponentControl
       
    95     };
       
    96 
       
    97 void Panic(TInt aReason)
       
    98     {
       
    99     _LIT(KPanicText, "CPbk2ContactInfoControl");
       
   100     User::Panic(KPanicText, aReason);
       
   101     }
       
   102 #endif // _DEBUG
       
   103 
       
   104 } /// namespace
       
   105 
       
   106 
       
   107 // --------------------------------------------------------------------------
       
   108 // CPbk2ContactInfoControl::CPbk2ContactInfoControl
       
   109 // --------------------------------------------------------------------------
       
   110 //
       
   111 CPbk2ContactInfoControl::CPbk2ContactInfoControl(
       
   112         CVPbkContactManager& aManager,
       
   113         MPbk2ContactNameFormatter& aNameFormatter,
       
   114         MPbk2FieldPropertyArray& aFieldProperties,
       
   115         CPbk2StorePropertyArray& aStoreProperties,
       
   116         MPbk2ContactNavigation* aNavigator ) :
       
   117     iContactManager( aManager ),
       
   118     iNameFormatter( aNameFormatter ),
       
   119     iNavigator( aNavigator ),
       
   120     iFieldProperties( aFieldProperties ),
       
   121     iStoreProperties( aStoreProperties ),
       
   122     iFocusedFieldIndex( KErrNotFound )
       
   123     {
       
   124     }
       
   125 
       
   126 // --------------------------------------------------------------------------
       
   127 // CPbk2ContactInfoControl::~CPbk2ContactInfoControl
       
   128 // --------------------------------------------------------------------------
       
   129 //
       
   130 CPbk2ContactInfoControl::~CPbk2ContactInfoControl()
       
   131     {
       
   132     if( iTitlePane )
       
   133         {
       
   134         iTitlePane->SetSmallPicture( NULL, NULL, EFalse );
       
   135         }
       
   136     if (iCommand)
       
   137         {
       
   138         // inform the command that the control is deleted
       
   139         iCommand->ResetUiControl(*this);
       
   140         }
       
   141     iObservers.Reset();
       
   142     delete iThumbnailLoader;
       
   143     delete iListBox;
       
   144     delete iContact;
       
   145     delete iStoreContact;
       
   146     delete iRetriever;
       
   147     delete iContactLink;
       
   148     delete iSpecificFieldProperties;
       
   149     }
       
   150 
       
   151 // --------------------------------------------------------------------------
       
   152 // CPbk2ContactInfoControl::ConstructL
       
   153 // --------------------------------------------------------------------------
       
   154 //
       
   155 inline void CPbk2ContactInfoControl::ConstructL(
       
   156         const CCoeControl* aContainer)
       
   157     {
       
   158     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   159         ("CPbk2ContactInfoControl::ConstructL begin"));
       
   160 
       
   161     SetContainerWindowL(*aContainer);
       
   162 
       
   163     // Create the listbox
       
   164     iListBox = CPbk2ContactInfoListBox::NewL(
       
   165         *this, R_PBK2_CONTACT_INFO_CONTROL, iContactManager);
       
   166     iListBox->SetObserver(this);
       
   167     iListBox->SetScrollEventObserver( this );
       
   168     iListBox->SetListBoxObserver( this );
       
   169 
       
   170     // Get flags from listbox
       
   171     iFlags = iListBox->Flags();
       
   172 
       
   173     // Create thumbnail loader
       
   174     iThumbnailLoader = CPbk2ThumbnailLoader::NewL( iContactManager );
       
   175 
       
   176     CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   177     if( statusPane && statusPane->
       
   178         PaneCapabilities( TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() )
       
   179         {
       
   180         iTitlePane = static_cast<CAknTitlePane*>(
       
   181             statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   182         }
       
   183 
       
   184     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   185         ("CPbk2ContactInfoControl::ConstructL end"));
       
   186     }
       
   187 
       
   188 // --------------------------------------------------------------------------
       
   189 // CPbk2ContactInfoControl::NewL
       
   190 // --------------------------------------------------------------------------
       
   191 //
       
   192 EXPORT_C CPbk2ContactInfoControl* CPbk2ContactInfoControl::NewL
       
   193         ( const CCoeControl* aContainer,
       
   194           CVPbkContactManager& aManager,
       
   195           MPbk2ContactNameFormatter& aNameFormatter,
       
   196           MPbk2FieldPropertyArray& aFieldProperties,
       
   197           CPbk2StorePropertyArray& aStoreProperties,
       
   198           MPbk2ContactNavigation* aNavigator )
       
   199     {
       
   200     CPbk2ContactInfoControl* self = new ( ELeave ) CPbk2ContactInfoControl
       
   201         ( aManager, aNameFormatter, aFieldProperties, aStoreProperties,
       
   202           aNavigator );
       
   203     CleanupStack::PushL( self );
       
   204     self->ConstructL( aContainer );
       
   205     CleanupStack::Pop( self );
       
   206     return self;
       
   207     }
       
   208 
       
   209 // --------------------------------------------------------------------------
       
   210 // CPbk2ContactInfoControl::AddObserverL
       
   211 // --------------------------------------------------------------------------
       
   212 //
       
   213 EXPORT_C void CPbk2ContactInfoControl::AddObserverL
       
   214         (MPbk2ControlObserver& aObserver)
       
   215     {
       
   216     User::LeaveIfError(iObservers.Append(&aObserver));
       
   217     }
       
   218 
       
   219 // --------------------------------------------------------------------------
       
   220 // CPbk2ContactInfoControl::RemoveObserver
       
   221 // --------------------------------------------------------------------------
       
   222 //
       
   223 EXPORT_C void CPbk2ContactInfoControl::RemoveObserver
       
   224         (MPbk2ControlObserver& aObserver)
       
   225     {
       
   226     const TInt index = iObservers.Find(&aObserver);
       
   227     if (index >= 0)
       
   228         {
       
   229         iObservers.Remove(index);
       
   230         }
       
   231     }
       
   232 
       
   233 // --------------------------------------------------------------------------
       
   234 // CPbk2ContactInfoControl::ParentControl
       
   235 // --------------------------------------------------------------------------
       
   236 //
       
   237 MPbk2ContactUiControl* CPbk2ContactInfoControl::ParentControl() const
       
   238     {
       
   239     // Contact info control has no parent control
       
   240     return NULL;
       
   241     }
       
   242 
       
   243 // --------------------------------------------------------------------------
       
   244 // CPbk2ContactInfoControl::NumberOfContacts
       
   245 // --------------------------------------------------------------------------
       
   246 //
       
   247 TInt CPbk2ContactInfoControl::NumberOfContacts() const
       
   248     {
       
   249     return KNumberOfContacts;
       
   250     }
       
   251 
       
   252 // --------------------------------------------------------------------------
       
   253 // CPbk2ContactInfoControl::FocusedContactL
       
   254 // --------------------------------------------------------------------------
       
   255 //
       
   256 const MVPbkBaseContact* CPbk2ContactInfoControl::FocusedContactL() const
       
   257     {
       
   258     return iContact;
       
   259     }
       
   260 
       
   261 // --------------------------------------------------------------------------
       
   262 // CPbk2ContactInfoControl::FocusedViewContactL
       
   263 // --------------------------------------------------------------------------
       
   264 //
       
   265 const MVPbkViewContact* CPbk2ContactInfoControl::FocusedViewContactL() const
       
   266     {
       
   267     return NULL;
       
   268     }
       
   269 
       
   270 // --------------------------------------------------------------------------
       
   271 // CPbk2ContactInfoControl::FocusedStoreContact
       
   272 // --------------------------------------------------------------------------
       
   273 //
       
   274 const MVPbkStoreContact* CPbk2ContactInfoControl::FocusedStoreContact() const
       
   275     {
       
   276     return iStoreContact;
       
   277     }
       
   278 
       
   279 // --------------------------------------------------------------------------
       
   280 // CPbk2ContactInfoControl::SetFocusedContactL
       
   281 // --------------------------------------------------------------------------
       
   282 //
       
   283 void CPbk2ContactInfoControl::SetFocusedContactL(
       
   284         const MVPbkBaseContact& aContact)
       
   285     {
       
   286     // Load the new contact
       
   287     delete iContactLink;
       
   288     iContactLink = NULL;
       
   289     iContactLink = aContact.CreateLinkLC();
       
   290     CleanupStack::Pop(); // iContactLink
       
   291 
       
   292     RetrieveContactL( *iContactLink );
       
   293     }
       
   294 
       
   295 // --------------------------------------------------------------------------
       
   296 // CPbk2ContactInfoControl::SetFocusedContactL
       
   297 // --------------------------------------------------------------------------
       
   298 //
       
   299 void CPbk2ContactInfoControl::SetFocusedContactL(
       
   300         const MVPbkContactBookmark& /*aContactBookmark*/ )
       
   301     {
       
   302     // Do nothing
       
   303     }
       
   304 
       
   305 // --------------------------------------------------------------------------
       
   306 // CPbk2ContactInfoControl::SetFocusedContactL
       
   307 // --------------------------------------------------------------------------
       
   308 //
       
   309 void CPbk2ContactInfoControl::SetFocusedContactL(
       
   310         const MVPbkContactLink& aContactLink )
       
   311     {
       
   312     // Load the new contact
       
   313     delete iContactLink;
       
   314     iContactLink = NULL;
       
   315     iContactLink = aContactLink.CloneLC();
       
   316     CleanupStack::Pop(); // iContactLink
       
   317 
       
   318     RetrieveContactL( *iContactLink );
       
   319     }
       
   320 
       
   321 // --------------------------------------------------------------------------
       
   322 // CPbk2ContactInfoControl::FocusedContactIndex
       
   323 // --------------------------------------------------------------------------
       
   324 //
       
   325 TInt CPbk2ContactInfoControl::FocusedContactIndex() const
       
   326     {
       
   327     return KErrNotSupported;
       
   328     }
       
   329 
       
   330 // --------------------------------------------------------------------------
       
   331 // CPbk2ContactInfoControl::SetFocusedContactIndexL
       
   332 // --------------------------------------------------------------------------
       
   333 //
       
   334 void CPbk2ContactInfoControl::SetFocusedContactIndexL( TInt /*aIndex*/ )
       
   335     {
       
   336     // Do nothing
       
   337     }
       
   338 
       
   339 // --------------------------------------------------------------------------
       
   340 // CPbk2ContactInfoControl::NumberOfContactFields
       
   341 // --------------------------------------------------------------------------
       
   342 //
       
   343 TInt CPbk2ContactInfoControl::NumberOfContactFields() const
       
   344     {
       
   345     return iContact->Fields().FieldCount();
       
   346     }
       
   347 
       
   348 // --------------------------------------------------------------------------
       
   349 // CPbk2ContactInfoControl::FocusedField
       
   350 // --------------------------------------------------------------------------
       
   351 //
       
   352 const MVPbkBaseContactField* CPbk2ContactInfoControl::FocusedField() const
       
   353     {
       
   354     // PreCond:
       
   355     __ASSERT_DEBUG(iListBox && iFields, Panic(EPanicPreCond_FocusedField));
       
   356 
       
   357     const MVPbkBaseContactField* ret = NULL;
       
   358     const TInt fieldsCount = iFields->FieldCount();
       
   359     const TInt index = iListBox->CurrentItemIndex();
       
   360     TInt numberOfVisibleFields = 0;
       
   361     if (index >= 0)
       
   362         {
       
   363         __ASSERT_DEBUG(index < iFields->FieldCount(),
       
   364             Panic(EPanicLogic_FocusedField));
       
   365         
       
   366         // Field collection may have hidden fields, so find visible field
       
   367         // corresponding to the focused field in the listbox.
       
   368         for ( TInt i = 0; i < fieldsCount && ret == NULL; i++ )
       
   369             {
       
   370             if ( iFields->At( i ).IsVisibleInDetailsView() && 
       
   371                 iFields->At( i ).DynamicVisibility() )
       
   372                 {
       
   373                 numberOfVisibleFields++;
       
   374                 }
       
   375             if ( numberOfVisibleFields - 1 == index )
       
   376                 {
       
   377                 ret = &iFields->FieldAt( i );
       
   378                 }
       
   379             }
       
   380         }
       
   381 
       
   382     return ret;
       
   383     }
       
   384 
       
   385 // --------------------------------------------------------------------------
       
   386 // CPbk2ContactInfoControl::FocusedFieldIndex
       
   387 // --------------------------------------------------------------------------
       
   388 //
       
   389 TInt CPbk2ContactInfoControl::FocusedFieldIndex() const
       
   390     {
       
   391     // PreCond:
       
   392     __ASSERT_DEBUG(iContact, Panic(EPanicPreCond_FocusedFieldIndex));
       
   393 
       
   394     return iListBox->CurrentItemIndex();
       
   395     }
       
   396 
       
   397 // --------------------------------------------------------------------------
       
   398 // CPbk2ContactInfoControl::SetFocusedFieldIndex
       
   399 // --------------------------------------------------------------------------
       
   400 //
       
   401 void CPbk2ContactInfoControl::SetFocusedFieldIndex(
       
   402         TInt aIndex )
       
   403     {
       
   404     iFocusedFieldIndex = aIndex;
       
   405     }
       
   406 
       
   407 // --------------------------------------------------------------------------
       
   408 // CPbk2ContactInfoControl::ContactsMarked
       
   409 // --------------------------------------------------------------------------
       
   410 //
       
   411 TBool CPbk2ContactInfoControl::ContactsMarked() const
       
   412     {
       
   413     // This control does not support contacts marking
       
   414     return EFalse;
       
   415     }
       
   416 
       
   417 // --------------------------------------------------------------------------
       
   418 // CPbk2ContactInfoControl::SelectedContactsL
       
   419 // --------------------------------------------------------------------------
       
   420 //
       
   421 MVPbkContactLinkArray* CPbk2ContactInfoControl::SelectedContactsL() const
       
   422     {
       
   423     // No selection support in contact info control
       
   424     return NULL;
       
   425     }
       
   426 
       
   427 // --------------------------------------------------------------------------
       
   428 // CPbk2ContactInfoControl::SelectedContactsOrFocusedContactL
       
   429 // --------------------------------------------------------------------------
       
   430 //
       
   431 MVPbkContactLinkArray*
       
   432         CPbk2ContactInfoControl::SelectedContactsOrFocusedContactL() const
       
   433     {
       
   434     CVPbkContactLinkArray* array = CVPbkContactLinkArray::NewLC();
       
   435     const MVPbkBaseContact* focusedContact = FocusedContactL();
       
   436     if ( focusedContact )
       
   437         {
       
   438         MVPbkContactLink* link = focusedContact->CreateLinkLC();
       
   439         CleanupStack::Pop(); // link
       
   440         array->AppendL( link );
       
   441         }
       
   442     CleanupStack::Pop(); // array
       
   443 
       
   444     return array;
       
   445     }
       
   446 
       
   447 // --------------------------------------------------------------------------
       
   448 // CPbk2ContactInfoControl::SelectedContactsIteratorL
       
   449 // --------------------------------------------------------------------------
       
   450 //
       
   451 MPbk2ContactLinkIterator*
       
   452     CPbk2ContactInfoControl::SelectedContactsIteratorL() const
       
   453     {
       
   454     // No selection support in contact info control
       
   455     return NULL;
       
   456     }
       
   457 
       
   458 // --------------------------------------------------------------------------
       
   459 // CPbk2ContactInfoControl::SelectedContactStoresL
       
   460 // --------------------------------------------------------------------------
       
   461 //
       
   462 CArrayPtr<MVPbkContactStore>*
       
   463         CPbk2ContactInfoControl::SelectedContactStoresL() const
       
   464     {
       
   465     // This is not a contact store control
       
   466     return NULL;
       
   467     }
       
   468 
       
   469 // --------------------------------------------------------------------------
       
   470 // CPbk2ContactInfoControl::ClearMarks
       
   471 // --------------------------------------------------------------------------
       
   472 //
       
   473 void CPbk2ContactInfoControl::ClearMarks()
       
   474     {
       
   475     // Do nothing
       
   476     }
       
   477 
       
   478 // --------------------------------------------------------------------------
       
   479 // CPbk2ContactInfoControl::SetSelectedContactL
       
   480 // --------------------------------------------------------------------------
       
   481 //
       
   482 void CPbk2ContactInfoControl::SetSelectedContactL(
       
   483         TInt /*aIndex*/,
       
   484         TBool /*aSelected*/)
       
   485     {
       
   486     // Not supported in Contact Info
       
   487     }
       
   488 
       
   489 // --------------------------------------------------------------------------
       
   490 // CPbk2ContactInfoControl::SetSelectedContactL
       
   491 // --------------------------------------------------------------------------
       
   492 //
       
   493 void CPbk2ContactInfoControl::SetSelectedContactL(
       
   494         const MVPbkContactBookmark& /*aContactBookmark*/,
       
   495         TBool /*aSelected*/ )
       
   496     {
       
   497     // Not supported
       
   498     }
       
   499 
       
   500 // --------------------------------------------------------------------------
       
   501 // CPbk2ContactInfoControl::SetSelectedContactL
       
   502 // --------------------------------------------------------------------------
       
   503 //
       
   504 void CPbk2ContactInfoControl::SetSelectedContactL(
       
   505         const MVPbkContactLink& /*aContactLink*/,
       
   506         TBool /*aSelected*/ )
       
   507     {
       
   508     // Not supported
       
   509     }
       
   510 
       
   511 TInt CPbk2ContactInfoControl::CommandItemCount() const
       
   512 	{
       
   513 	return 0; // No command items.
       
   514 	}
       
   515 
       
   516 const MPbk2UiControlCmdItem& CPbk2ContactInfoControl::CommandItemAt(
       
   517 	TInt /*aIndex*/ ) const
       
   518 	{
       
   519 	// There are no command items in this control
       
   520 	__ASSERT_ALWAYS( EFalse, User::Panic( _L("Pbk2"), 4)); //TODO
       
   521 	MPbk2UiControlCmdItem* item = NULL; // For compiler only
       
   522 	return *item; // For compiler only
       
   523 	}
       
   524 
       
   525 const MPbk2UiControlCmdItem* CPbk2ContactInfoControl::FocusedCommandItem() const
       
   526 	{
       
   527 	return NULL;
       
   528 	}
       
   529 
       
   530 void CPbk2ContactInfoControl::DeleteCommandItemL( TInt /*aIndex*/ )
       
   531 	{
       
   532 	// Do nothing
       
   533 	}
       
   534 
       
   535 void CPbk2ContactInfoControl::AddCommandItemL(MPbk2UiControlCmdItem* /*aCommand*/, TInt /*aIndex*/)
       
   536 	{	
       
   537 	//Do nothing, since there shouldn't be any command items in this state.
       
   538 	}
       
   539 
       
   540 // --------------------------------------------------------------------------
       
   541 // CPbk2ContactInfoControl::DynInitMenuPaneL
       
   542 // --------------------------------------------------------------------------
       
   543 //
       
   544 void CPbk2ContactInfoControl::DynInitMenuPaneL(
       
   545         TInt /*aResourceId*/,
       
   546         CEikMenuPane* /*aMenuPane*/) const
       
   547     {
       
   548     // Nothing to do
       
   549     }
       
   550 
       
   551 // --------------------------------------------------------------------------
       
   552 // CPbk2ContactInfoControl::ProcessCommandL
       
   553 // --------------------------------------------------------------------------
       
   554 //
       
   555 void CPbk2ContactInfoControl::ProcessCommandL(
       
   556         TInt /*aCommandId*/) const
       
   557     {
       
   558     // Nothing to do
       
   559     }
       
   560 
       
   561 // --------------------------------------------------------------------------
       
   562 // CPbk2ContactInfoControl::UpdateAfterCommandExecution
       
   563 // --------------------------------------------------------------------------
       
   564 //
       
   565 void CPbk2ContactInfoControl::UpdateAfterCommandExecution()
       
   566     {
       
   567     if( iCommand )
       
   568         {
       
   569         /// Reset command pointer, command has completed
       
   570         iCommand->ResetUiControl(*this);
       
   571         iCommand = NULL;
       
   572         }
       
   573     iListBox->DrawDeferred();
       
   574     }
       
   575 
       
   576 // --------------------------------------------------------------------------
       
   577 // CPbk2ContactInfoControl::GetMenuFilteringFlagsL
       
   578 // --------------------------------------------------------------------------
       
   579 //
       
   580 TInt CPbk2ContactInfoControl::GetMenuFilteringFlagsL() const
       
   581     {
       
   582     TInt ret = KPbk2MenuFilteringFlagsNone;
       
   583 
       
   584     const TInt fieldCount = FieldCount();
       
   585     User::LeaveIfError( fieldCount );
       
   586     if ( fieldCount > KNoContacts )
       
   587         {
       
   588         ret |= KPbk2ListContainsItems;
       
   589         }
       
   590 
       
   591     return ret;
       
   592     }
       
   593 
       
   594 // --------------------------------------------------------------------------
       
   595 // CPbk2ContactInfoControl::ControlStateL
       
   596 // --------------------------------------------------------------------------
       
   597 //
       
   598 CPbk2ViewState* CPbk2ContactInfoControl::ControlStateL() const
       
   599     {
       
   600     CPbk2ViewState* state = CPbk2ViewState::NewLC();
       
   601     const MVPbkBaseContact* contact = FocusedContactL();
       
   602 
       
   603     if ( contact )
       
   604         {
       
   605         MVPbkContactLink* link = contact->CreateLinkLC();
       
   606         state->SetFocusedContact(link);
       
   607         CleanupStack::Pop(); // link
       
   608         link = NULL; // state has the ownership
       
   609 
       
   610         if ( iListBox->Model()->NumberOfItems() > 0 )
       
   611             {
       
   612             state->SetFocusedFieldIndex( FocusedFieldIndex() );
       
   613             const TInt topIndex = iListBox->TopItemIndex();
       
   614             if ( topIndex >= 0 )
       
   615                 {
       
   616                 const MVPbkStoreContactField& topField =
       
   617                     iFields->FieldAt( topIndex );
       
   618                 state->SetTopFieldIndex( iContact->PresentationFields().
       
   619                     FindFieldIndex( topField ) );
       
   620                 }
       
   621             }
       
   622         }
       
   623 
       
   624     CleanupStack::Pop(); // state
       
   625     return state;
       
   626     }
       
   627 
       
   628 // --------------------------------------------------------------------------
       
   629 // CPbk2ContactInfoControl::RestoreControlStateL
       
   630 // --------------------------------------------------------------------------
       
   631 //
       
   632 void CPbk2ContactInfoControl::RestoreControlStateL(
       
   633         CPbk2ViewState* aState )
       
   634     {
       
   635     const TInt numItems = iListBox->Model()->NumberOfItems();
       
   636     const TInt currentItemIndex = iListBox->CurrentItemIndex();
       
   637 
       
   638     TInt topFieldIndex( KErrNotFound );
       
   639     if ( aState )
       
   640         {
       
   641         if ( iFocusedFieldIndex == KErrNotFound )
       
   642             {
       
   643             iFocusedFieldIndex = aState->FocusedFieldIndex();
       
   644             topFieldIndex = aState->TopFieldIndex();
       
   645             }
       
   646         }
       
   647 
       
   648     if ( iFocusedFieldIndex >= 0 &&
       
   649          iFocusedFieldIndex < numItems )
       
   650         {
       
   651         iListBox->SetCurrentItemIndex(iFocusedFieldIndex);
       
   652         if ( topFieldIndex >= 0 )
       
   653             {
       
   654             iListBox->SetTopItemIndex( topFieldIndex );
       
   655             }
       
   656         iListBox->UpdateScrollBarsL();
       
   657         }
       
   658     else
       
   659         {
       
   660         iListBox->Reset();
       
   661 
       
   662          // Get the field type
       
   663         TResourceReader resReader;
       
   664         CCoeEnv::Static()->CreateResourceReaderLC
       
   665             (resReader, R_PHONEBOOK2_SIP_MSISDN_SELECTOR );
       
   666 
       
   667         CVPbkFieldTypeSelector* selector =
       
   668             CVPbkFieldTypeSelector::NewL(resReader, iContactManager.FieldTypes());
       
   669         CleanupStack::PopAndDestroy(); // resReader
       
   670         CleanupStack::PushL( selector );
       
   671 
       
   672         const TInt count( iFields->FieldCount() );
       
   673         for ( TInt i( 0 ); i < count; ++i )
       
   674             {
       
   675             const MVPbkFieldType* field = iFields->At( i ).BestMatchingFieldType();
       
   676             if ( selector->IsFieldTypeIncluded( *field ) )
       
   677                 {
       
   678                 iListBox->SetCurrentItemIndex( i );
       
   679                 iFocusedFieldIndex = i;
       
   680                 iListBox->UpdateScrollBarsL();
       
   681                 break;
       
   682                 }
       
   683             }
       
   684         CleanupStack::PopAndDestroy( selector );
       
   685         }
       
   686     }
       
   687 
       
   688 // --------------------------------------------------------------------------
       
   689 // CPbk2ContactInfoControl::FindTextL
       
   690 // --------------------------------------------------------------------------
       
   691 //
       
   692 const TDesC& CPbk2ContactInfoControl::FindTextL()
       
   693     {
       
   694     // No find box in this control
       
   695     return KNullDesC;
       
   696     }
       
   697 
       
   698 // --------------------------------------------------------------------------
       
   699 // CPbk2ContactInfoControl::ResetFindL
       
   700 // --------------------------------------------------------------------------
       
   701 //
       
   702 void CPbk2ContactInfoControl::ResetFindL()
       
   703     {
       
   704     // Do nothing
       
   705     }
       
   706 
       
   707 // --------------------------------------------------------------------------
       
   708 // CPbk2ContactInfoControl::ShowThumbnail
       
   709 // --------------------------------------------------------------------------
       
   710 //
       
   711 void CPbk2ContactInfoControl::ShowThumbnail()
       
   712     {
       
   713     if (iThumbnailLoader && IsFocused() )
       
   714         {
       
   715         iThumbnailLoader->LoadThumbnail
       
   716             ( iStoreContact, iListBox, ELocationUpDown );
       
   717         }
       
   718     }
       
   719 
       
   720 // --------------------------------------------------------------------------
       
   721 // CPbk2ContactInfoControl::HideThumbnail
       
   722 // --------------------------------------------------------------------------
       
   723 //
       
   724 void CPbk2ContactInfoControl::HideThumbnail()
       
   725     {
       
   726     if (iThumbnailLoader)
       
   727         {
       
   728         iThumbnailLoader->HideThumbnail();
       
   729         }
       
   730     }
       
   731 
       
   732 // --------------------------------------------------------------------------
       
   733 // CPbk2ContactInfoControl::SetBlank
       
   734 // --------------------------------------------------------------------------
       
   735 //
       
   736 void CPbk2ContactInfoControl::SetBlank(TBool /*aBlank*/)
       
   737     {
       
   738     // This control does not support blanking
       
   739     }
       
   740 
       
   741 // --------------------------------------------------------------------------
       
   742 // CPbk2ContactInfoControl::RegisterCommand
       
   743 // --------------------------------------------------------------------------
       
   744 //
       
   745 void CPbk2ContactInfoControl::RegisterCommand(
       
   746         MPbk2Command* aCommand)
       
   747     {
       
   748     iCommand = aCommand;
       
   749     }
       
   750 
       
   751 // --------------------------------------------------------------------------
       
   752 // CPbk2ContactInfoControl::SetTextL
       
   753 // --------------------------------------------------------------------------
       
   754 //
       
   755 void CPbk2ContactInfoControl::SetTextL( const TDesC& aText )
       
   756     {
       
   757     iListBox->View()->SetListEmptyTextL( aText );
       
   758     }
       
   759 
       
   760 // --------------------------------------------------------------------------
       
   761 // CPbk2ContactInfoControl::ContactUiControlExtension
       
   762 // --------------------------------------------------------------------------
       
   763 //
       
   764 TAny* CPbk2ContactInfoControl::ContactUiControlExtension(TUid aExtensionUid )
       
   765 	{
       
   766      if( aExtensionUid == KMPbk2ContactUiControlExtension2Uid )
       
   767         { 
       
   768 		return static_cast<MPbk2ContactUiControl2*>( this );
       
   769 		}
       
   770 		
       
   771     return NULL;
       
   772     }
       
   773 
       
   774 
       
   775 // --------------------------------------------------------------------------
       
   776 // CPbk2ContactInfoControl::UpdateL
       
   777 // --------------------------------------------------------------------------
       
   778 //
       
   779 void CPbk2ContactInfoControl::UpdateL(
       
   780         MVPbkStoreContact* aContact)
       
   781     {
       
   782     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateL);
       
   783 
       
   784     // Update specific field properties first
       
   785     delete iSpecificFieldProperties;
       
   786     iSpecificFieldProperties = NULL;
       
   787 
       
   788     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLCreateStoreSpecificFieldProps);
       
   789     iSpecificFieldProperties = CPbk2StoreSpecificFieldPropertyArray::NewL(
       
   790         iFieldProperties,
       
   791         iStoreProperties,
       
   792         iContactManager.FieldTypes(),
       
   793         aContact->ParentStore());
       
   794     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLCreateStoreSpecificFieldProps);
       
   795 
       
   796     // Create an presentation contact from the store contact
       
   797     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLCreatePresentationContact);
       
   798     CPbk2PresentationContact* presentation =
       
   799         CPbk2PresentationContact::NewL(*aContact, *iSpecificFieldProperties);
       
   800     CleanupStack::PushL(presentation);
       
   801     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLCreatePresentationContact);
       
   802     
       
   803     // Create title pane picture
       
   804     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLCreateTitlePanePicture);
       
   805     CEikImage* image = Pbk2TitlePanePictureFactory::
       
   806         CreateTitlePanePictureLC( aContact, iStoreProperties );
       
   807     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLCreateTitlePanePicture);
       
   808 
       
   809     // Instantiate a helper object
       
   810     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLCreateSwapper);
       
   811     CPbk2ContactInfoDataSwapper* swapper =
       
   812         new(ELeave) CPbk2ContactInfoDataSwapper;
       
   813     CleanupStack::PushL(swapper);
       
   814     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLCreateSwapper);
       
   815 
       
   816     // Store the members which are to be swapped
       
   817     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLStorePanes);
       
   818     StorePanesL(*swapper, presentation);
       
   819     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLStorePanes);
       
   820 
       
   821     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLCreateDynamicFieldProperties);
       
   822     CPbk2ContactFieldDynamicProperties* filter =
       
   823         CreateDynamicFieldPropertiesLC( *presentation );
       
   824     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLCreateDynamicFieldProperties);
       
   825 
       
   826     // Prepare listbox for state transitition
       
   827     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLPrepareForUpdate);
       
   828     iListBox->PrepareForUpdateL
       
   829         ( *swapper, presentation->PresentationFields(),
       
   830             *iSpecificFieldProperties, filter );
       
   831     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLPrepareForUpdate);
       
   832 
       
   833     CleanupStack::Pop();  // filter
       
   834 
       
   835     // All code that might leave has been executed succesfully, change state
       
   836     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLSetTitlePane);
       
   837     if( iTitlePane )
       
   838         {
       
   839         // Set title pane text
       
   840         if( swapper->iTitlePaneText )
       
   841             {
       
   842             iTitlePane->SetText(swapper->iTitlePaneText);
       
   843             swapper->iTitlePaneText = NULL;
       
   844             }
       
   845         // Set title pane picture
       
   846         // picture ownership is transfered to title pane
       
   847         image->SetPictureOwnedExternally( ETrue );
       
   848         iTitlePane->SetSmallPicture(
       
   849             image->Bitmap(), image->Mask(), image->Bitmap() != NULL );
       
   850         }
       
   851     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLSetTitlePane);
       
   852 
       
   853     // Update listbox
       
   854     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLUpdateListbox);
       
   855     TRAPD(err, iListBox->DoUpdateL(*swapper, *aContact));
       
   856     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLUpdateListbox);
       
   857 
       
   858     // Cleanup and change state
       
   859     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLCleanupState);
       
   860     CleanupStack::PopAndDestroy(swapper);
       
   861     // bitmap and mask from image were transfered to title pane,
       
   862     // so image can be destroyed now
       
   863     CleanupStack::PopAndDestroy( image );
       
   864     CleanupStack::Pop(presentation);
       
   865     delete iContact;
       
   866     iContact = presentation;
       
   867     iFields = &presentation->PresentationFields();
       
   868     User::LeaveIfError(err);
       
   869     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLCleanupState);
       
   870 
       
   871     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLSetIndex);
       
   872     if ( iFocusedFieldIndex >= 0 &&
       
   873          iFocusedFieldIndex < iListBox->Model()->NumberOfItems() )
       
   874         {
       
   875         iListBox->SetCurrentItemIndex(iFocusedFieldIndex);
       
   876         }
       
   877     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLSetIndex);
       
   878 
       
   879     // Update navigators
       
   880     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLUpdateNavigators);
       
   881     if ( iNavigator )
       
   882         {
       
   883         MVPbkContactLink* contactLink = aContact->CreateLinkLC();
       
   884         if ( contactLink )
       
   885             {
       
   886             iNavigator->UpdateNaviIndicatorsL(*contactLink);
       
   887             }
       
   888         CleanupStack::PopAndDestroy(); // contactLink
       
   889         }
       
   890     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLUpdateNavigators);
       
   891 
       
   892     DrawDeferred();
       
   893 
       
   894     // To avoid double deletion, the store contact ownership
       
   895     // is transferred after everything that can leave has been
       
   896     // executed
       
   897     delete iStoreContact;
       
   898     iStoreContact = aContact;
       
   899             
       
   900     // Notify control readiness
       
   901     PBK2_PROFILE_START(Pbk2Profile::EContactInfoControlUpdateLSendEvents);
       
   902     TRAPD( error, SendEventToObserversL( TPbk2ControlEvent::EReady ) );
       
   903     if ( error != KErrNone )
       
   904         {
       
   905         // When function leaves the aContact will be
       
   906         // deleted through CleanupStack by calling function.
       
   907         iStoreContact = NULL;
       
   908         User::Leave( error );
       
   909         }
       
   910 
       
   911     SetFocus( ETrue );
       
   912     
       
   913     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateLSendEvents);
       
   914     PBK2_PROFILE_END(Pbk2Profile::EContactInfoControlUpdateL);
       
   915     }
       
   916 
       
   917 // --------------------------------------------------------------------------
       
   918 // CPbk2ContactInfoControl::FieldCount
       
   919 // --------------------------------------------------------------------------
       
   920 //
       
   921 TInt CPbk2ContactInfoControl::FieldCount() const
       
   922     {
       
   923     TInt ret = KErrNotReady;
       
   924     if ( iFields )
       
   925         {
       
   926         ret = iFields->FieldCount();
       
   927         }
       
   928     return ret;
       
   929     }
       
   930 
       
   931 // --------------------------------------------------------------------------
       
   932 // CPbk2ContactInfoControl::FieldPos
       
   933 // --------------------------------------------------------------------------
       
   934 //
       
   935 TInt CPbk2ContactInfoControl::FieldPos(
       
   936         const MVPbkStoreContactField& aField) const
       
   937     {
       
   938     // PreCond:
       
   939     __ASSERT_DEBUG(iListBox && iFields, Panic(EPanicPreCond_FieldPos));
       
   940 
       
   941     TInt ret = KErrNotFound;
       
   942     const TInt count(iFields->FieldCount());
       
   943     for (TInt i = 0; i < count; ++i)
       
   944         {
       
   945         if (iFields->At(i).IsSame(aField))
       
   946             {
       
   947             ret = i;
       
   948             break;
       
   949             }
       
   950         }
       
   951     return ret;
       
   952     }
       
   953 
       
   954 // --------------------------------------------------------------------------
       
   955 // CPbk2ContactInfoControl::VPbkSingleContactOperationComplete
       
   956 // --------------------------------------------------------------------------
       
   957 //
       
   958 
       
   959 void CPbk2ContactInfoControl::VPbkSingleContactOperationComplete(
       
   960         MVPbkContactOperationBase& aOperation,
       
   961         MVPbkStoreContact* aContact)
       
   962     {
       
   963     if (aContact && &aOperation == iRetriever)
       
   964         {
       
   965         // contact loading completed, update control data
       
   966         TRAPD(err, UpdateL(aContact));
       
   967         if (err != KErrNone)
       
   968             {
       
   969             delete aContact;
       
   970             CCoeEnv::Static()->HandleError(err);
       
   971             }
       
   972 
       
   973         delete iRetriever;
       
   974         iRetriever = NULL;
       
   975         delete iContactLink;
       
   976         iContactLink = NULL;
       
   977         }
       
   978     }
       
   979 
       
   980 // --------------------------------------------------------------------------
       
   981 // CPbk2ContactInfoControl::VPbkSingleContactOperationFailed
       
   982 // --------------------------------------------------------------------------
       
   983 //
       
   984 void CPbk2ContactInfoControl::VPbkSingleContactOperationFailed(
       
   985         MVPbkContactOperationBase& /*aOperation*/,
       
   986         TInt aError)
       
   987     {
       
   988     CCoeEnv::Static()->HandleError(aError);
       
   989     }
       
   990 
       
   991 // --------------------------------------------------------------------------
       
   992 // CPbk2ContactInfoControl::FocusedItemPointed
       
   993 // --------------------------------------------------------------------------
       
   994 //
       
   995 TBool CPbk2ContactInfoControl::FocusedItemPointed()
       
   996     {
       
   997     return iListBox->FocusedItemPointed();
       
   998     }
       
   999 
       
  1000 // --------------------------------------------------------------------------
       
  1001 // CPbk2ContactInfoControl::FocusableItemPointed
       
  1002 // --------------------------------------------------------------------------
       
  1003 //
       
  1004 TBool CPbk2ContactInfoControl::FocusableItemPointed()
       
  1005     {
       
  1006     return iListBox->FocusableItemPointed();
       
  1007     }
       
  1008 
       
  1009 // --------------------------------------------------------------------------
       
  1010 // CPbk2ContactInfoControl::SearchFieldPointed
       
  1011 // --------------------------------------------------------------------------
       
  1012 //
       
  1013 TBool CPbk2ContactInfoControl::SearchFieldPointed()
       
  1014     {
       
  1015     return iListBox->SearchFieldPointed();
       
  1016     }
       
  1017 
       
  1018 // --------------------------------------------------------------------------
       
  1019 // CPbk2ContactInfoControl::OfferKeyEventL
       
  1020 // --------------------------------------------------------------------------
       
  1021 //
       
  1022 TKeyResponse CPbk2ContactInfoControl::OfferKeyEventL(
       
  1023         const TKeyEvent& aKeyEvent,
       
  1024         TEventCode aType)
       
  1025     {
       
  1026     __ASSERT_DEBUG(iListBox, Panic(EPanicPreCond_OfferKeyEventL));
       
  1027 
       
  1028     if ( aType == EEventKey )
       
  1029         {
       
  1030         // Reset iFocusedFieldIndex
       
  1031         // UpdateL method called after editor is closed and correct field
       
  1032         // is focused. Focus jump, if user same time than UpdateL method is
       
  1033         // called, scrolling fields. That's why this iFocusedFieldIndex
       
  1034         // reseting.
       
  1035         iFocusedFieldIndex = KErrNotFound;
       
  1036         }
       
  1037 
       
  1038     // Forward all key events to the list box
       
  1039     TKeyResponse response = iListBox->OfferKeyEventL(aKeyEvent,aType);
       
  1040     
       
  1041     // Ignore Send Key up and down events to prevent Dialer appearance
       
  1042     // on top of Phonebook application.
       
  1043     if ( response == EKeyWasNotConsumed && IsFocused() )
       
  1044         {
       
  1045         if ( ( aType == EEventKeyDown || aType == EEventKeyUp )
       
  1046             && aKeyEvent.iScanCode == EStdKeyYes )
       
  1047             {
       
  1048             response = EKeyWasConsumed;
       
  1049             }
       
  1050         }
       
  1051         
       
  1052 /*
       
  1053 HandleControlEventL does this already...no need for double update...plus the HandleControlEventL works also for touch...
       
  1054     // Let the listbox first handle the key event before drawing the
       
  1055     // thumbnail.
       
  1056     if ( iThumbnailLoader && aType == EEventKey &&
       
  1057         (aKeyEvent.iScanCode == EStdKeyUpArrow ||
       
  1058         aKeyEvent.iScanCode == EStdKeyDownArrow ))
       
  1059         {
       
  1060         RDebug::Print( _L("### info view: OfferKeyEventL!") );
       
  1061         iThumbnailLoader->Refresh();
       
  1062         }
       
  1063 */
       
  1064     return response;
       
  1065     }
       
  1066 
       
  1067 // --------------------------------------------------------------------------
       
  1068 // CPbk2ContactInfoControl::SizeChanged
       
  1069 // --------------------------------------------------------------------------
       
  1070 //
       
  1071 void CPbk2ContactInfoControl::SizeChanged()
       
  1072     {
       
  1073     __ASSERT_DEBUG(iListBox, Panic(EPanicPreCond_SizeChanged));
       
  1074     // Listbox occupies whole area of this control
       
  1075     iListBox->SetRect(Rect());
       
  1076     }
       
  1077 
       
  1078 // --------------------------------------------------------------------------
       
  1079 // CPbk2ContactInfoControl::CountComponentControls
       
  1080 // --------------------------------------------------------------------------
       
  1081 //
       
  1082 TInt CPbk2ContactInfoControl::CountComponentControls() const
       
  1083     {
       
  1084     __ASSERT_DEBUG(iListBox, Panic(EPanicPreCond_CountComponentControls));
       
  1085     
       
  1086     // Always only one child control: the list box.
       
  1087     return KNumberOfControls;
       
  1088     }
       
  1089 
       
  1090 // --------------------------------------------------------------------------
       
  1091 // CPbk2ContactInfoControl::ComponentControl
       
  1092 // --------------------------------------------------------------------------
       
  1093 //
       
  1094 CCoeControl* CPbk2ContactInfoControl::ComponentControl(
       
  1095         TInt PBK2_DEBUG_ONLY(aIndex)) const
       
  1096     {
       
  1097     __ASSERT_DEBUG(iListBox && aIndex==0,
       
  1098         Panic(EPanicPreCond_ComponentControl));
       
  1099 
       
  1100     // Return the one and only child control
       
  1101     return iListBox;
       
  1102     }
       
  1103 
       
  1104 // --------------------------------------------------------------------------
       
  1105 // CPbk2ContactInfoControl::FocusChanged
       
  1106 // --------------------------------------------------------------------------
       
  1107 //
       
  1108 void CPbk2ContactInfoControl::FocusChanged(
       
  1109         TDrawNow aDrawNow )
       
  1110     {
       
  1111     if ( iListBox )
       
  1112         {
       
  1113         iListBox->SetFocus( IsFocused(), aDrawNow );
       
  1114         }
       
  1115 
       
  1116     if ( IsFocused() )
       
  1117         {
       
  1118         ShowThumbnail();
       
  1119         }
       
  1120     else
       
  1121         {
       
  1122         HideThumbnail();
       
  1123         }
       
  1124     }
       
  1125 
       
  1126 // --------------------------------------------------------------------------
       
  1127 // CPbk2ContactInfoControl::HandleResourceChange
       
  1128 // --------------------------------------------------------------------------
       
  1129 //
       
  1130 void CPbk2ContactInfoControl::HandleResourceChange(
       
  1131         TInt aType)
       
  1132     {
       
  1133     CCoeControl::HandleResourceChange(aType);
       
  1134     TRAP_IGNORE(DoHandleResourceChangeL(aType));
       
  1135     }
       
  1136 
       
  1137 // --------------------------------------------------------------------------
       
  1138 // CPbk2ContactInfoControl::HandlePointerEventL
       
  1139 // --------------------------------------------------------------------------
       
  1140 //
       
  1141 void CPbk2ContactInfoControl::HandlePointerEventL(
       
  1142     const TPointerEvent& aPointerEvent )
       
  1143     {
       
  1144     CCoeControl::HandlePointerEventL( aPointerEvent );
       
  1145     if ( AknLayoutUtils::PenEnabled() )
       
  1146         {
       
  1147         switch( aPointerEvent.iType )
       
  1148             {
       
  1149             case TPointerEvent::EButton1Up:
       
  1150                 {
       
  1151                 if ( iListBox != NULL && iListBox->Rect().Contains(
       
  1152                     aPointerEvent.iPosition ) )
       
  1153                     {
       
  1154                     iFocusedFieldIndex = iListBox->CurrentItemIndex();
       
  1155                     }
       
  1156                 break;
       
  1157                 }
       
  1158 
       
  1159             default:
       
  1160                 {
       
  1161                 break;
       
  1162                 }
       
  1163             };
       
  1164         }
       
  1165     }
       
  1166 
       
  1167 // --------------------------------------------------------------------------
       
  1168 // CPbk2ContactInfoControl::HandleControlEventL
       
  1169 // --------------------------------------------------------------------------
       
  1170 //
       
  1171 void CPbk2ContactInfoControl::HandleControlEventL(
       
  1172         CCoeControl* aControl,
       
  1173         TCoeEvent aEventType)
       
  1174     {
       
  1175     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
  1176         ("CPbk2ContactInfoControl::HandleControlEventL(0x%x,0x%x,%d)"),
       
  1177         this, aControl, aEventType);
       
  1178     if ( iThumbnailLoader && (aControl == iListBox) && IsFocused() )
       
  1179         {
       
  1180         iThumbnailLoader->Refresh();
       
  1181         }
       
  1182     }
       
  1183 
       
  1184 // --------------------------------------------------------------------------
       
  1185 // CPbk2ContactInfoControl::StorePanesL
       
  1186 // --------------------------------------------------------------------------
       
  1187 //
       
  1188 inline void CPbk2ContactInfoControl::StorePanesL(
       
  1189         CPbk2ContactInfoDataSwapper& aSwapper,
       
  1190         const CPbk2PresentationContact* aContact)
       
  1191     {
       
  1192     if( iFlags & KPbk2ContactInfoControlUpdateStatusPane )
       
  1193         {
       
  1194         if( (iFlags & KPbk2ContactInfoControlUpdateTitlePane) && iTitlePane )
       
  1195             {
       
  1196             // Store title pane text
       
  1197             if (aContact)
       
  1198                 {
       
  1199                 aSwapper.iTitlePaneText = iNameFormatter.GetContactTitleL(
       
  1200                     aContact->Fields(), KDefaultTitleFormat);
       
  1201                 }
       
  1202             }
       
  1203         if( iFlags & KPbk2ContactInfoControlUpdateContextPane )
       
  1204             {
       
  1205             if (aContact)
       
  1206 				{
       
  1207 	            iThumbnailLoader->LoadThumbnail(&aContact->StoreContact(),
       
  1208 	                                            iListBox,
       
  1209 	                                            ELocationUpDown);
       
  1210 				}
       
  1211             }
       
  1212         }
       
  1213     }
       
  1214 
       
  1215 // --------------------------------------------------------------------------
       
  1216 // CPbk2ContactInfoControl::SendEventToObserversL
       
  1217 // --------------------------------------------------------------------------
       
  1218 //
       
  1219 void CPbk2ContactInfoControl::SendEventToObserversL(
       
  1220         const TPbk2ControlEvent& aEvent)
       
  1221     {
       
  1222     // Loop backwards in case some observer destroys itself in the
       
  1223     // event handler
       
  1224     for (TInt i = iObservers.Count()-1; i >= 0; --i)
       
  1225         {
       
  1226         iObservers[i]->HandleControlEventL(*this, aEvent);
       
  1227         }
       
  1228     }
       
  1229 
       
  1230 // --------------------------------------------------------------------------
       
  1231 // CPbk2ContactInfoControl::CreateDynamicFieldPropertiesLC
       
  1232 // --------------------------------------------------------------------------
       
  1233 //
       
  1234 CPbk2ContactFieldDynamicProperties*
       
  1235     CPbk2ContactInfoControl::CreateDynamicFieldPropertiesLC(
       
  1236         CPbk2PresentationContact& aContact )
       
  1237     {
       
  1238     CPbk2ContactFieldDynamicProperties* filter =
       
  1239         CPbk2ContactFieldDynamicProperties::NewLC();
       
  1240     // Check is there ringtone field and if there is, check that file is still
       
  1241     // available. If not, hide the field.
       
  1242     TInt fieldCount( aContact.Fields().FieldCount() );
       
  1243     for ( TInt i = 0; i < fieldCount; ++i )
       
  1244         {
       
  1245         const MVPbkStoreContactField& field = aContact.Fields().FieldAt( i );
       
  1246         TInt resId( field.BestMatchingFieldType()->FieldTypeResId() );
       
  1247         if ( resId == R_VPBK_FIELD_TYPE_RINGTONE )
       
  1248             {
       
  1249             TPtrC filename =
       
  1250                 MVPbkContactFieldTextData::Cast( field.FieldData() ).Text();
       
  1251             if ( !BaflUtils::FileExists(
       
  1252                 CCoeEnv::Static()->FsSession(),
       
  1253                 filename ) )
       
  1254                 {
       
  1255                 filter->AddHiddenFieldResourceId( resId );
       
  1256                 aContact.PresentationFields().At( i ).
       
  1257                     SetDynamicVisibility( EFalse );
       
  1258                 break;
       
  1259                 }
       
  1260             }
       
  1261         }
       
  1262 
       
  1263     return filter;
       
  1264     }
       
  1265 
       
  1266 // --------------------------------------------------------------------------
       
  1267 // CPbk2ContactInfoControl::DoHandleResourceChangeL
       
  1268 // --------------------------------------------------------------------------
       
  1269 //
       
  1270 void CPbk2ContactInfoControl::DoHandleResourceChangeL(
       
  1271         TInt aType)
       
  1272     {
       
  1273     if (iListBox)
       
  1274         {
       
  1275         iListBox->DoHandleResourceChangeL(aType);
       
  1276         }
       
  1277 /*  This is useless...no need to show or hide thumbnail on layout/skin change...thumbnail will handle it's own resouce change event
       
  1278     if ( aType == KEikDynamicLayoutVariantSwitch ||
       
  1279          aType == KAknsMessageSkinChange )
       
  1280         {
       
  1281         if ( IsFocused() )
       
  1282             {
       
  1283             RDebug::Print( _L("### InfoControl::HandleResourceChangeL - show") );
       
  1284             ShowThumbnail();
       
  1285             }
       
  1286         else
       
  1287             {
       
  1288             RDebug::Print( _L("### InfoControl::HandleResourceChangeL - hide") );
       
  1289             HideThumbnail();
       
  1290             }
       
  1291         }*/
       
  1292     }
       
  1293 
       
  1294 // --------------------------------------------------------------------------
       
  1295 // CPbk2ContactInfoControl::RetrieveContactL
       
  1296 // --------------------------------------------------------------------------
       
  1297 //    
       
  1298 void CPbk2ContactInfoControl::RetrieveContactL( 
       
  1299         const MVPbkContactLink& aContactLink )
       
  1300     {
       
  1301     delete iRetriever;
       
  1302     iRetriever = NULL;
       
  1303     iRetriever = iContactManager.RetrieveContactL( aContactLink, *this );
       
  1304     }
       
  1305 
       
  1306 // --------------------------------------------------------------------------
       
  1307 // 
       
  1308 // --------------------------------------------------------------------------
       
  1309 //    
       
  1310 void CPbk2ContactInfoControl::HandleScrollEventL(CEikScrollBar* /*aScrollBar*/, TEikScrollEvent aEventType)
       
  1311     {
       
  1312 
       
  1313 
       
  1314     switch( aEventType )
       
  1315         {
       
  1316         // drag events -> hide thumbnail
       
  1317         // AL: this isn't very efficient way of doing this...
       
  1318         // ...thumbnail loader interface should be extended to 
       
  1319         // enable thumbnail window to be hidden/shown without 
       
  1320         // destroying and reloading the bitmaps...
       
  1321         case EEikScrollThumbDragHoriz:
       
  1322         case EEikScrollThumbDragVert:
       
  1323             {
       
  1324             iDidMove = ETrue;
       
  1325             HideThumbnail();
       
  1326             break;
       
  1327             }
       
  1328             
       
  1329         // release events
       
  1330         case EEikScrollThumbReleaseHoriz:
       
  1331         case EEikScrollThumbReleaseVert:
       
  1332             {
       
  1333             // AL: this isn't very efficient way of doing this...
       
  1334             // ...thumbnail loader interface should be extended to 
       
  1335             // enable thumbnail window to be hidden/shown without 
       
  1336             // destroying and reloading the bitmaps...
       
  1337             if( iDidMove )
       
  1338                 {
       
  1339                 ShowThumbnail();
       
  1340                 iDidMove = EFalse;
       
  1341                 }
       
  1342             break;
       
  1343             }
       
  1344 
       
  1345         default:
       
  1346             {
       
  1347             iDidMove= EFalse;
       
  1348             if( iThumbnailLoader )
       
  1349                 {
       
  1350                 iThumbnailLoader->Refresh();
       
  1351                 }
       
  1352             }
       
  1353         }
       
  1354     }
       
  1355 // --------------------------------------------------------------------------
       
  1356 // CPbk2ContactInfoControl::HandleListBoxEventL
       
  1357 // --------------------------------------------------------------------------
       
  1358 //
       
  1359 void CPbk2ContactInfoControl::HandleListBoxEventL(
       
  1360     CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
  1361     {
       
  1362     switch ( aEventType )
       
  1363         {
       
  1364         case EEventItemDoubleClicked:
       
  1365             SendEventToObserversL( TPbk2ControlEvent::EContactDoubleTapped );
       
  1366             break;
       
  1367         case EEventItemSingleClicked:
       
  1368             SendEventToObserversL( TPbk2ControlEvent::EContactTapped );
       
  1369             break;   
       
  1370         case EEventEnterKeyPressed:
       
  1371             SendEventToObserversL( TPbk2ControlEvent::EControlEnterKeyPressed );
       
  1372             break;  
       
  1373         default:
       
  1374             ;
       
  1375         }
       
  1376     }
       
  1377 
       
  1378 
       
  1379 //  End of File