phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/src/ccappdetailsviewcontainer.cpp
branchRCL_3
changeset 20 f4a778e096c2
child 21 9da50d567e3c
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of detailsview plugin control container
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <aknlists.h>
       
    20 #include <bautils.h>
       
    21 #include <aknlayoutscalable_avkon.cdl.h>
       
    22 
       
    23 #include "ccappdetailsviewcontainer.h"
       
    24 #include "ccappdetailsviewlistboxmodel.h"
       
    25 #include "ccappdetailsviewdefs.h"
       
    26 
       
    27 #include <ccappdetailsviewpluginrsc.rsg>
       
    28 #include <ccappdetailsviewplugin.mbg>
       
    29 
       
    30 #include <csxhelp/phob.hlp.hrh>
       
    31 #include <ccacontactorservice.h>
       
    32 #include <ccappdetailsviewplugin.h>
       
    33 
       
    34 // PhoneBook2
       
    35 #include <Pbk2UIControls.rsg>
       
    36 #include <CVPbkContactLinkArray.h>
       
    37 #include <CVPbkContactManager.h>
       
    38 #include <CPbk2IconArray.h>
       
    39 #include <CPbk2IconInfoContainer.h>
       
    40 #include <MVPbkBaseContact.h>
       
    41 #include <CPbk2UIExtensionManager.h>
       
    42 #include <MPbk2UIExtensionIconSupport.h>
       
    43 #include <CPbk2ApplicationServices.h>
       
    44 #include <Pbk2MenuFilteringFlags.hrh>
       
    45 #include <MPbk2Command.h>
       
    46 #include <CPbk2UIExtensionManager.h>
       
    47 #include "CPbk2ServiceManager.h"
       
    48 #include "CPbk2IconInfo.h"
       
    49 #include <CPbk2CommandHandler.h>
       
    50 #include <pbk2mapcommands.hrh>
       
    51 
       
    52 #include <Pbk2UID.h>
       
    53 
       
    54 // Virtual Phonebook
       
    55 #include <MVPbkContactLink.h>
       
    56 #include <MVPbkStoreContact.h>
       
    57 #include <VPbkFieldTypeSelectorFactory.h>
       
    58 #include <MVPbkFieldType.h>
       
    59 #include <CVPbkFieldTypeSelector.h>
       
    60 #include <MVPbkContactFieldTextData.h>
       
    61 #include <MVPbkContactFieldUriData.h>
       
    62 
       
    63 #include <mccaparameter.h>
       
    64 #include <mccappengine.h>
       
    65 #include <VPbkEng.rsg>
       
    66 
       
    67 /// Unnamed namespace for local definitions
       
    68 namespace {
       
    69 
       
    70     const TInt KNumberOfContacts = 1;
       
    71     const TInt KNoContacts = 0;
       
    72 
       
    73 #ifdef _DEBUG
       
    74     enum TPanicCode
       
    75     {
       
    76         EPanicPreCond_FocusedField = 1,
       
    77         EPanicPreCond_FocusedFieldIndex,
       
    78     };
       
    79 
       
    80     void Panic(TInt aReason)
       
    81     {
       
    82         _LIT(KPanicText, "CCCAppDetailsViewContainer");
       
    83         User::Panic(KPanicText, aReason);
       
    84     }
       
    85 #endif // _DEBUG
       
    86 
       
    87 } // namespace
       
    88 
       
    89 // ============================ MEMBER FUNCTIONS ===============================
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CCCAppDetailsViewContainer::ConstructL()
       
    93 // Symbian 2nd phase constructor can leave.
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CCCAppDetailsViewContainer::ConstructL()
       
    97 {
       
    98     //CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewContainer::ConstructL()"));
       
    99 
       
   100     iCommandHandler = CPbk2CommandHandler::NewL();
       
   101 
       
   102     iListBox = new(ELeave) CAknFormDoubleGraphicStyleListBox;
       
   103 
       
   104     iListBox->ConstructL(this, EAknListBoxLoopScrolling);
       
   105     iListBox->View()->SetListEmptyTextL(KNullDesC);
       
   106     iListBox->SetContainerWindowL(*this);
       
   107     iListBox->CreateScrollBarFrameL(ETrue);
       
   108     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
       
   109         CEikScrollBarFrame::EAuto);
       
   110     iListBox->SetMopParent(this);
       
   111 
       
   112     // Create icon array.
       
   113     TResourceReader reader;
       
   114     iCoeEnv->CreateResourceReaderLC(reader, R_PBK2_FIELDTYPE_ICONS);
       
   115     CPbk2IconArray* iconArray = CPbk2IconArray::NewL(reader);
       
   116     CleanupStack::PushL(iconArray);
       
   117 
       
   118     // Calculate preferred size for xsp service icons.
       
   119     TRect mainPane;
       
   120     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPane);
       
   121     TAknLayoutRect listLayoutRect;
       
   122     listLayoutRect.LayoutRect(
       
   123         mainPane,
       
   124         AknLayoutScalable_Avkon::list_single_graphic_pane_g1(0).LayoutLine());
       
   125     TSize size(listLayoutRect.Rect().Size());
       
   126 
       
   127     // Add xsp service icons.
       
   128     CPbk2ServiceManager& servMan = iAppServices->ServiceManager();
       
   129 
       
   130     const CPbk2ServiceManager::RServicesArray& services = servMan.Services();
       
   131     TUid uid;
       
   132     uid.iUid = KPbk2ServManId;
       
   133 
       
   134     for (TInt i = 0; i < services.Count(); i++)
       
   135     {
       
   136         const CPbk2ServiceManager::TService& service = services[i];
       
   137         if (service.iBitmapId && service.iBitmap)
       
   138         {
       
   139         	AknIconUtils::SetSize(
       
   140         	           service.iBitmap,
       
   141         	           size );
       
   142         	AknIconUtils::SetSize(
       
   143         	           service.iMask,
       
   144         	           size );
       
   145             TPbk2IconId id = TPbk2IconId(uid, service.iBitmapId);
       
   146             CPbk2IconInfo* info = CPbk2IconInfo::NewLC(
       
   147                 id, service.iBitmap, service.iMask, size);
       
   148             iconArray->AppendIconL(info);
       
   149             CleanupStack::Pop(info);
       
   150         }
       
   151     }
       
   152 
       
   153     // Add icons from UI extensions (e.g. USIM extension)
       
   154     // UIExtensionManager handles also e.g. appending SIM store specific
       
   155     // properties to StorePropertyArray.
       
   156     iExtensionManager = CPbk2UIExtensionManager::InstanceL();
       
   157     iExtensionManager->IconSupportL().AppendExtensionIconsL(*iconArray);
       
   158 
       
   159     // Add speed dial and default number icons.
       
   160     TResourceReader reader2;
       
   161     iCoeEnv->CreateResourceReaderLC(reader2, R_DETAILSVIEW_ICON_ARRAY);
       
   162 
       
   163     // create the icon info container from the icon info array
       
   164     CPbk2IconInfoContainer* container =
       
   165         CPbk2IconInfoContainer::NewL(R_DETAILSVIEW_ICON_INFO_ARRAY);
       
   166     CleanupStack::PushL(container);
       
   167     // append the icons from the icon info array
       
   168     iconArray->AppendIconsFromResourceL(reader2, *container);
       
   169     CleanupStack::PopAndDestroy(2); // reader2, container
       
   170 
       
   171     CleanupStack::Pop(iconArray);
       
   172     CleanupStack::PopAndDestroy(); // reader
       
   173 
       
   174     // Set icon array
       
   175     iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray);
       
   176 
       
   177     iListBoxModel = CCCAppDetailsViewListBoxModel::NewL(
       
   178         *iCoeEnv, *iListBox, iAppServices, *iconArray, iPlugin);
       
   179     iListBox->Model()->SetItemTextArray(iListBoxModel);
       
   180     iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
   181 
       
   182     // Set listbox observer
       
   183     iListBox->SetListBoxObserver(this);
       
   184 
       
   185     ActivateL();
       
   186 
       
   187     //CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewContainer::ConstructL()"));
       
   188 }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CCCAppDetailsViewContainer::CCCAppDetailsViewContainer()
       
   192 // C++ default constructor can NOT contain any code, that might leave.
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 CCCAppDetailsViewContainer::CCCAppDetailsViewContainer(const TUid& aPluginUid,
       
   196     CCCAppDetailsViewPlugin& aPlugin)
       
   197 :
       
   198     iPluginUid(aPluginUid),
       
   199     iPlugin(aPlugin)
       
   200 {
       
   201     // No implementation needed.
       
   202 }
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // CCCAppDetailsViewContainer::~CCCAppDetailsViewContainer()
       
   206 // Destructor.
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 CCCAppDetailsViewContainer::~CCCAppDetailsViewContainer()
       
   210 {
       
   211     delete iCommandHandler;
       
   212     if (iCommand)
       
   213     {
       
   214         iCommand->ResetUiControl(*this);
       
   215     }
       
   216     delete iListBoxModel;
       
   217     delete iListBox;
       
   218     Release(iExtensionManager);
       
   219 }
       
   220 
       
   221 // --------------------------------------------------------------------------
       
   222 // CCCAppDetailsViewContainer::CountComponentControls
       
   223 // --------------------------------------------------------------------------
       
   224 //
       
   225 TInt CCCAppDetailsViewContainer::CountComponentControls() const
       
   226 {
       
   227     return iListBox ? 1 : 0;
       
   228 }
       
   229 
       
   230 // --------------------------------------------------------------------------
       
   231 // CCCAppDetailsViewContainer::ComponentControl
       
   232 // --------------------------------------------------------------------------
       
   233 //
       
   234 CCoeControl* CCCAppDetailsViewContainer::ComponentControl(TInt aIndex) const
       
   235 {
       
   236     return ((aIndex == 0) ? iListBox : NULL);
       
   237 }
       
   238 
       
   239 // --------------------------------------------------------------------------
       
   240 // CCCAppDetailsViewContainer::
       
   241 // --------------------------------------------------------------------------
       
   242 //
       
   243 void CCCAppDetailsViewContainer::SetApplicationServices(
       
   244     CPbk2ApplicationServices* aApplicationServices)
       
   245 {
       
   246     iAppServices = aApplicationServices;
       
   247 }
       
   248 
       
   249 // --------------------------------------------------------------------------
       
   250 // CCCAppDetailsViewContainer::
       
   251 // --------------------------------------------------------------------------
       
   252 //
       
   253 CVPbkContactManager& CCCAppDetailsViewContainer::ContactManager() const
       
   254 {
       
   255     return iAppServices->ContactManager();
       
   256 }
       
   257 
       
   258 // --------------------------------------------------------------------------
       
   259 // CCCAppDetailsViewContainer::ListBoxModel
       
   260 // --------------------------------------------------------------------------
       
   261 //
       
   262 CCCAppDetailsViewListBoxModel& CCCAppDetailsViewContainer::ListBoxModel() const
       
   263 {
       
   264     return *iListBoxModel;
       
   265 }
       
   266 
       
   267 // --------------------------------------------------------------------------
       
   268 // CCCAppDetailsViewContainer::OfferKeyEventL
       
   269 // --------------------------------------------------------------------------
       
   270 //
       
   271 TKeyResponse CCCAppDetailsViewContainer::OfferKeyEventL(
       
   272     const TKeyEvent& aKeyEvent, TEventCode aType)
       
   273 {
       
   274     // Temporary solution for handling key events.
       
   275     TKeyResponse result = EKeyWasNotConsumed;
       
   276 
       
   277     /* Uncomment this code if it is necessary to enable navigation hardware keys
       
   278      * on devices which have these keys (its Map Extension feature) 
       
   279     if( aKeyEvent.iScanCode == EStdKeyApplicationD && aType == EEventKeyUp )
       
   280         {
       
   281         DoShowMapCmdL( (TPbk2CommandId)EPbk2ExtensionAssignFromMap );
       
   282         returnValue = EKeyWasConsumed;
       
   283         }
       
   284             
       
   285     if( aKeyEvent.iScanCode == EStdKeyApplicationE && aType == EEventKeyUp )
       
   286         {
       
   287         DoShowMapCmdL( (TPbk2CommandId)EPbk2ExtensionShowOnMap );
       
   288         returnValue = EKeyWasConsumed;
       
   289         }*/
       
   290 
       
   291     switch (aKeyEvent.iCode)
       
   292     {
       
   293     case EKeyLeftArrow:
       
   294     case EKeyRightArrow:
       
   295         return result;
       
   296     }
       
   297 
       
   298     /* On detection of EKeyBackspace or EKeyDelete events we trigger
       
   299      * the contact deletion.
       
   300      */
       
   301     if (( aType == EEventKey) &&
       
   302          ( aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete ))
       
   303     {
       
   304         iListBoxModel->HandleDeleteRequestL();
       
   305         result = EKeyWasConsumed;
       
   306         return result;
       
   307     }
       
   308     
       
   309     // Send key event, to launch call
       
   310     if ( ( aType == EEventKey ) &&
       
   311     		( aKeyEvent.iCode == EKeyYes && IsFocused() ) )
       
   312     {
       
   313         HandleLaunchCallRequestL();       
       
   314         result = EKeyWasConsumed;
       
   315         return result;      
       
   316     }
       
   317     
       
   318     if ( result == EKeyWasNotConsumed )
       
   319     {
       
   320         // Ignore Send Key up and down events to prevent Dialer appearance
       
   321         // on top of cca application.
       
   322         if (( aType == EEventKeyDown || aType == EEventKeyUp )
       
   323             && aKeyEvent.iScanCode == EStdKeyYes )
       
   324         {
       
   325             result = EKeyWasConsumed;
       
   326         }
       
   327     }
       
   328     
       
   329     if ( result == EKeyWasNotConsumed )
       
   330     {
       
   331         // Pass all not consumed keys to the list box cntrl
       
   332         result = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   333     }
       
   334     return result;
       
   335 }
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CCCAppDetailsViewContainer::HandleListBoxEventL()
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 void CCCAppDetailsViewContainer::HandleListBoxEventL(
       
   342     CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
       
   343 {
       
   344 	if ( ( aEventType == EEventItemSingleClicked ) || ( aEventType == EEventEnterKeyPressed ) )
       
   345     {
       
   346         iListBoxModel->HandleEditRequestL();
       
   347     }
       
   348 }
       
   349 
       
   350 // --------------------------------------------------------------------------
       
   351 // CCCAppDetailsViewContainer::SizeChanged
       
   352 // --------------------------------------------------------------------------
       
   353 //
       
   354 void CCCAppDetailsViewContainer::SizeChanged()
       
   355 {
       
   356     if (iListBox)
       
   357     {
       
   358         TRect rect(Rect());
       
   359         iListBox->SetRect(rect);
       
   360     }
       
   361 }
       
   362 
       
   363 // --------------------------------------------------------------------------
       
   364 // CCCAppDetailsViewContainer::FocusChanged
       
   365 // --------------------------------------------------------------------------
       
   366 //
       
   367 void CCCAppDetailsViewContainer::FocusChanged(TDrawNow aDrawNow)
       
   368 {
       
   369     //CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewContainer::FocusChanged()"));
       
   370 
       
   371     CCoeControl::FocusChanged(aDrawNow);
       
   372 
       
   373     if (iListBox)
       
   374     {
       
   375         iListBox->SetFocus(IsFocused(), aDrawNow);
       
   376     }
       
   377 
       
   378     //CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewContainer::FocusChanged()"));
       
   379 }
       
   380 
       
   381 // --------------------------------------------------------------------------
       
   382 // CCCAppDetailsViewContainer::HandleResourceChange
       
   383 // --------------------------------------------------------------------------
       
   384 //
       
   385 void CCCAppDetailsViewContainer::HandleResourceChange(TInt aType)
       
   386 {
       
   387     //CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewContainer::HandleResourceChange()"));
       
   388 
       
   389     // TODO: DoHandleResourceChangeL(aType)
       
   390     CCCAppViewPluginAknContainer::HandleResourceChange(aType);
       
   391 
       
   392     // TODO: this crashes on orientation switch.
       
   393     //       don't know if it works on skin change because there has
       
   394     //       been no skins with different field type icons available
       
   395     //       for testing.
       
   396     /*
       
   397      if (aType == KAknsMessageSkinChange ||
       
   398      aType == KEikDynamicLayoutVariantSwitch)
       
   399      {
       
   400      CPbk2IconArray* iconArray =
       
   401      static_cast<CPbk2IconArray*>(iListBox->ItemDrawer()->ColumnData()->IconArray());
       
   402 
       
   403      if (iconArray)
       
   404      {
       
   405      // Refresh core Phonebook2 icons
       
   406      iconArray->RefreshL();
       
   407 
       
   408      CPbk2UIExtensionManager* extManager =
       
   409      CPbk2UIExtensionManager::InstanceL();
       
   410      extManager->PushL();
       
   411      // Refresh extension icons
       
   412      extManager->IconSupportL().RefreshL(*iconArray);
       
   413      CleanupStack::PopAndDestroy(); // extManager
       
   414      }
       
   415      }
       
   416      */
       
   417 
       
   418     //CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewContainer::HandleResourceChange()"));
       
   419 }
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // CCCAppDetailsViewContainer::GetHelpContext
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 void CCCAppDetailsViewContainer::GetHelpContext(TCoeHelpContext& aContext) const
       
   426 {
       
   427     aContext.iMajor.iUid = KPbk2UID3;
       
   428     aContext.iContext = KHLP_CCA_DETAILS;
       
   429 }
       
   430 
       
   431 // --------------------------------------------------------------------------
       
   432 // CCCAppDetailsViewContainer::ParentControl
       
   433 // --------------------------------------------------------------------------
       
   434 //
       
   435 MPbk2ContactUiControl* CCCAppDetailsViewContainer::ParentControl() const
       
   436 {
       
   437     // Contact info control has no parent control
       
   438     return NULL;
       
   439 }
       
   440 
       
   441 // --------------------------------------------------------------------------
       
   442 // CCCAppDetailsViewContainer::NumberOfContacts
       
   443 // --------------------------------------------------------------------------
       
   444 //
       
   445 TInt CCCAppDetailsViewContainer::NumberOfContacts() const
       
   446 {
       
   447     return KNumberOfContacts;
       
   448 }
       
   449 
       
   450 // --------------------------------------------------------------------------
       
   451 // CCCAppDetailsViewContainer::FocusedContactL
       
   452 // --------------------------------------------------------------------------
       
   453 //
       
   454 const MVPbkBaseContact* CCCAppDetailsViewContainer::FocusedContactL() const
       
   455 {
       
   456     // PreCond:
       
   457     __ASSERT_DEBUG(iListBoxModel, Panic(EPanicPreCond_FocusedField));
       
   458 
       
   459     return static_cast<MVPbkBaseContact*>(iListBoxModel->StoreContact());
       
   460 }
       
   461 
       
   462 // --------------------------------------------------------------------------
       
   463 // CCCAppDetailsViewContainer::FocusedViewContactL
       
   464 // --------------------------------------------------------------------------
       
   465 //
       
   466 const MVPbkViewContact* CCCAppDetailsViewContainer::FocusedViewContactL() const
       
   467 {
       
   468     return NULL;
       
   469 }
       
   470 
       
   471 // --------------------------------------------------------------------------
       
   472 // CCCAppDetailsViewContainer::FocusedStoreContact
       
   473 // --------------------------------------------------------------------------
       
   474 //
       
   475 const MVPbkStoreContact* CCCAppDetailsViewContainer::FocusedStoreContact() const
       
   476 {
       
   477     // PreCond:
       
   478     __ASSERT_DEBUG(iListBoxModel, Panic(EPanicPreCond_FocusedField));
       
   479 
       
   480     return iListBoxModel->StoreContact();
       
   481 }
       
   482 
       
   483 // --------------------------------------------------------------------------
       
   484 // CCCAppDetailsViewContainer::SetFocusedContactL
       
   485 // --------------------------------------------------------------------------
       
   486 //
       
   487 void CCCAppDetailsViewContainer::SetFocusedContactL(
       
   488     const MVPbkBaseContact& aContact)
       
   489 {
       
   490     if (!iListBoxModel->StoreContact()->IsSame(aContact))
       
   491     {
       
   492         MVPbkContactLink* link = aContact.CreateLinkLC();
       
   493         HBufC8* packed = link->PackLC();
       
   494 
       
   495         CVPbkContactLinkArray* links = CVPbkContactLinkArray::NewLC(
       
   496             *packed, ContactManager().ContactStoresL() );
       
   497         CleanupStack::Pop(links); 
       
   498 
       
   499         iListBoxModel->SetLinks(links);
       
   500         DrawDeferred();
       
   501 
       
   502         // Update the CCA parameter contact data
       
   503         HBufC16* link16 = HBufC16::NewLC(packed->Length());
       
   504         link16->Des().Copy( *packed );
       
   505         iAppEngine->Parameter().SetContactDataL(*link16);
       
   506         iAppEngine->CCAppContactEventL();
       
   507         CleanupStack::PopAndDestroy(3); // link16, packed, link
       
   508     }
       
   509 }
       
   510 
       
   511 // --------------------------------------------------------------------------
       
   512 // CCCAppDetailsViewContainer::SetFocusedContactL
       
   513 // --------------------------------------------------------------------------
       
   514 //
       
   515 void CCCAppDetailsViewContainer::SetFocusedContactL(
       
   516     const MVPbkContactBookmark& /*aContactBookmark*/)
       
   517 {
       
   518     // Do nothing
       
   519 }
       
   520 
       
   521 // --------------------------------------------------------------------------
       
   522 // CCCAppDetailsViewContainer::SetFocusedContactL
       
   523 // --------------------------------------------------------------------------
       
   524 //
       
   525 void CCCAppDetailsViewContainer::SetFocusedContactL(
       
   526     const MVPbkContactLink& /*aContactLink*/)
       
   527 {
       
   528     // Do nothing
       
   529 }
       
   530 
       
   531 // --------------------------------------------------------------------------
       
   532 // CCCAppDetailsViewContainer::FocusedContactIndex
       
   533 // --------------------------------------------------------------------------
       
   534 //
       
   535 TInt CCCAppDetailsViewContainer::FocusedContactIndex() const
       
   536 {
       
   537     return KErrNotSupported;
       
   538 }
       
   539 
       
   540 // --------------------------------------------------------------------------
       
   541 // CCCAppDetailsViewContainer::SetFocusedContactIndexL
       
   542 // --------------------------------------------------------------------------
       
   543 //
       
   544 void CCCAppDetailsViewContainer::SetFocusedContactIndexL(TInt /*aIndex*/)
       
   545 {
       
   546     // Do nothing
       
   547 }
       
   548 
       
   549 // --------------------------------------------------------------------------
       
   550 // CCCAppDetailsViewContainer::NumberOfContactFields
       
   551 // --------------------------------------------------------------------------
       
   552 //
       
   553 TInt CCCAppDetailsViewContainer::NumberOfContactFields() const
       
   554 {
       
   555     // PreCond:
       
   556     __ASSERT_DEBUG(iListBoxModel, Panic(EPanicPreCond_FocusedField));
       
   557 
       
   558     TInt cnt = KErrNotSupported;
       
   559     cnt = iListBoxModel->StoreContact()->Fields().FieldCount();
       
   560     return cnt;
       
   561 }
       
   562 
       
   563 // --------------------------------------------------------------------------
       
   564 // CCCAppDetailsViewContainer::FocusedField
       
   565 // --------------------------------------------------------------------------
       
   566 //
       
   567 const MVPbkBaseContactField* CCCAppDetailsViewContainer::FocusedField() const
       
   568 {
       
   569     // PreCond:
       
   570     __ASSERT_DEBUG(iListBoxModel, Panic(EPanicPreCond_FocusedField));
       
   571 
       
   572     TInt index = iListBoxModel->FocusedFieldIndex();
       
   573     if (index != KErrNotFound)
       
   574         {
       
   575         return &iListBoxModel->StoreContact()->Fields().FieldAt(index);
       
   576         }
       
   577     
       
   578     return NULL;
       
   579 
       
   580 }
       
   581 
       
   582 // --------------------------------------------------------------------------
       
   583 // CCCAppDetailsViewContainer::FocusedFieldIndex
       
   584 // --------------------------------------------------------------------------
       
   585 //
       
   586 TInt CCCAppDetailsViewContainer::FocusedFieldIndex() const
       
   587 {
       
   588     // PreCond:
       
   589     __ASSERT_DEBUG(iListBoxModel, Panic(EPanicPreCond_FocusedFieldIndex));
       
   590 
       
   591     return iListBoxModel->FocusedFieldIndex();
       
   592 }
       
   593 
       
   594 // --------------------------------------------------------------------------
       
   595 // CCCAppDetailsViewContainer::SetFocusedFieldIndex
       
   596 // --------------------------------------------------------------------------
       
   597 //
       
   598 void CCCAppDetailsViewContainer::SetFocusedFieldIndex(TInt aIndex)
       
   599 {
       
   600     TInt focusedItemIndex = iListBoxModel->FindFocusListIndexByStoreIndex( aIndex );
       
   601     iListBoxModel->SetInitialFocusIndex(focusedItemIndex);
       
   602 }
       
   603 
       
   604 // --------------------------------------------------------------------------
       
   605 // CCCAppDetailsViewContainer::ContactsMarked
       
   606 // --------------------------------------------------------------------------
       
   607 //
       
   608 TBool CCCAppDetailsViewContainer::ContactsMarked() const
       
   609 {
       
   610     // This control does not support contacts marking
       
   611     return EFalse;
       
   612 }
       
   613 
       
   614 // --------------------------------------------------------------------------
       
   615 // CCCAppDetailsViewContainer::SelectedContactsL
       
   616 // --------------------------------------------------------------------------
       
   617 //
       
   618 MVPbkContactLinkArray* CCCAppDetailsViewContainer::SelectedContactsL() const
       
   619 {
       
   620     // No selection support in contact info control
       
   621     return NULL;
       
   622 }
       
   623 
       
   624 // --------------------------------------------------------------------------
       
   625 // CCCAppDetailsViewContainer::SelectedContactsOrFocusedContactL
       
   626 // --------------------------------------------------------------------------
       
   627 //
       
   628 MVPbkContactLinkArray*
       
   629 CCCAppDetailsViewContainer::SelectedContactsOrFocusedContactL() const
       
   630 {
       
   631     CVPbkContactLinkArray* array = CVPbkContactLinkArray::NewLC();
       
   632     const MVPbkBaseContact* focusedContact = FocusedContactL();
       
   633 
       
   634     if (focusedContact)
       
   635     {
       
   636         MVPbkContactLink* link = focusedContact->CreateLinkLC();
       
   637         CleanupStack::Pop(); // link
       
   638         array->AppendL(link);
       
   639     }
       
   640     CleanupStack::Pop(array);
       
   641 
       
   642     return array;
       
   643 }
       
   644 
       
   645 // --------------------------------------------------------------------------
       
   646 // CCCAppDetailsViewContainer::SelectedContactsIteratorL
       
   647 // --------------------------------------------------------------------------
       
   648 //
       
   649 MPbk2ContactLinkIterator*
       
   650 CCCAppDetailsViewContainer::SelectedContactsIteratorL() const
       
   651 {
       
   652     // No selection support in contact info control
       
   653     return NULL;
       
   654 }
       
   655 
       
   656 // --------------------------------------------------------------------------
       
   657 // CCCAppDetailsViewContainer::SelectedContactStoresL
       
   658 // --------------------------------------------------------------------------
       
   659 //
       
   660 CArrayPtr<MVPbkContactStore>*
       
   661 CCCAppDetailsViewContainer::SelectedContactStoresL() const
       
   662 {
       
   663     // This is not a contact store control
       
   664     return NULL;
       
   665 }
       
   666 
       
   667 // --------------------------------------------------------------------------
       
   668 // CCCAppDetailsViewContainer::ClearMarks
       
   669 // --------------------------------------------------------------------------
       
   670 //
       
   671 void CCCAppDetailsViewContainer::ClearMarks()
       
   672 {
       
   673     // Do nothing
       
   674 }
       
   675 
       
   676 // --------------------------------------------------------------------------
       
   677 // CCCAppDetailsViewContainer::SetSelectedContactL
       
   678 // --------------------------------------------------------------------------
       
   679 //
       
   680 void CCCAppDetailsViewContainer::SetSelectedContactL(
       
   681     TInt /*aIndex*/,
       
   682     TBool /*aSelected*/)
       
   683 {
       
   684     // Not supported in Contact Info
       
   685 }
       
   686 
       
   687 // --------------------------------------------------------------------------
       
   688 // CCCAppDetailsViewContainer::SetSelectedContactL
       
   689 // --------------------------------------------------------------------------
       
   690 //
       
   691 void CCCAppDetailsViewContainer::SetSelectedContactL(
       
   692     const MVPbkContactBookmark& /*aContactBookmark*/,
       
   693     TBool /*aSelected*/)
       
   694 {
       
   695     // Not supported
       
   696 }
       
   697 
       
   698 // --------------------------------------------------------------------------
       
   699 // CCCAppDetailsViewContainer::SetSelectedContactL
       
   700 // --------------------------------------------------------------------------
       
   701 //
       
   702 void CCCAppDetailsViewContainer::SetSelectedContactL(
       
   703     const MVPbkContactLink& /*aContactLink*/,
       
   704     TBool /*aSelected*/)
       
   705 {
       
   706     // Not supported
       
   707 }
       
   708 
       
   709 
       
   710 
       
   711 // --------------------------------------------------------------------------
       
   712 // CCCAppDetailsViewContainer::DynInitMenuPaneL
       
   713 // --------------------------------------------------------------------------
       
   714 //
       
   715 void CCCAppDetailsViewContainer::DynInitMenuPaneL(
       
   716     TInt /*aResourceId*/,
       
   717     CEikMenuPane* /*aMenuPane*/) const
       
   718 {
       
   719     // Nothing to do
       
   720 }
       
   721 
       
   722 // --------------------------------------------------------------------------
       
   723 // CCCAppDetailsViewContainer::ProcessCommandL
       
   724 // --------------------------------------------------------------------------
       
   725 //
       
   726 void CCCAppDetailsViewContainer::ProcessCommandL(TInt /*aCommandId*/) const
       
   727 {
       
   728     // Nothing to do
       
   729 }
       
   730 
       
   731 // --------------------------------------------------------------------------
       
   732 // CCCAppDetailsViewContainer::UpdateAfterCommandExecution
       
   733 // --------------------------------------------------------------------------
       
   734 //
       
   735 void CCCAppDetailsViewContainer::UpdateAfterCommandExecution()
       
   736 {
       
   737     if (iCommand)
       
   738     {
       
   739         /// Reset command pointer, command has completed
       
   740         iCommand->ResetUiControl(*this);
       
   741         iCommand = NULL;
       
   742     }
       
   743 }
       
   744 
       
   745 // --------------------------------------------------------------------------
       
   746 // CCCAppDetailsViewContainer::GetMenuFilteringFlagsL
       
   747 // --------------------------------------------------------------------------
       
   748 //
       
   749 TInt CCCAppDetailsViewContainer::GetMenuFilteringFlagsL() const
       
   750 {
       
   751     // PreCond:
       
   752     __ASSERT_DEBUG(iListBoxModel, Panic(EPanicPreCond_FocusedField));
       
   753 
       
   754     const TInt fieldCount =
       
   755         iListBoxModel->StoreContact()->Fields().FieldCount();
       
   756     // If negative will leave
       
   757     User::LeaveIfError(fieldCount);
       
   758 
       
   759     TInt ret = KPbk2MenuFilteringFlagsNone;
       
   760     if (fieldCount > KNoContacts)
       
   761     {
       
   762         ret |= KPbk2ListContainsItems;
       
   763     }
       
   764 
       
   765     return ret;
       
   766 }
       
   767 
       
   768 // --------------------------------------------------------------------------
       
   769 // CCCAppDetailsViewContainer::ControlStateL
       
   770 // --------------------------------------------------------------------------
       
   771 //
       
   772 CPbk2ViewState* CCCAppDetailsViewContainer::ControlStateL() const
       
   773 {
       
   774     return NULL;
       
   775 }
       
   776 
       
   777 // --------------------------------------------------------------------------
       
   778 // CCCAppDetailsViewContainer::RestoreControlStateL
       
   779 // --------------------------------------------------------------------------
       
   780 //
       
   781 void CCCAppDetailsViewContainer::RestoreControlStateL(
       
   782     CPbk2ViewState* /*aState*/)
       
   783 {
       
   784     // Do nothing
       
   785 }
       
   786 
       
   787 // --------------------------------------------------------------------------
       
   788 // CCCAppDetailsViewContainer::FindTextL
       
   789 // --------------------------------------------------------------------------
       
   790 //
       
   791 const TDesC& CCCAppDetailsViewContainer::FindTextL()
       
   792 {
       
   793     // No find box in this control
       
   794     return KNullDesC;
       
   795 }
       
   796 
       
   797 // --------------------------------------------------------------------------
       
   798 // CCCAppDetailsViewContainer::ResetFindL
       
   799 // --------------------------------------------------------------------------
       
   800 //
       
   801 void CCCAppDetailsViewContainer::ResetFindL()
       
   802 {
       
   803     // Do nothing
       
   804 }
       
   805 
       
   806 // --------------------------------------------------------------------------
       
   807 // CCCAppDetailsViewContainer::ShowThumbnail
       
   808 // --------------------------------------------------------------------------
       
   809 //
       
   810 void CCCAppDetailsViewContainer::ShowThumbnail()
       
   811 {
       
   812     // Do nothing
       
   813 }
       
   814 
       
   815 // --------------------------------------------------------------------------
       
   816 // CCCAppDetailsViewContainer::HideThumbnail
       
   817 // --------------------------------------------------------------------------
       
   818 //
       
   819 void CCCAppDetailsViewContainer::HideThumbnail()
       
   820 {
       
   821     // Do nothing
       
   822 }
       
   823 
       
   824 // --------------------------------------------------------------------------
       
   825 // CCCAppDetailsViewContainer::SetBlank
       
   826 // --------------------------------------------------------------------------
       
   827 //
       
   828 void CCCAppDetailsViewContainer::SetBlank(TBool /*aBlank*/)
       
   829 {
       
   830     // This control does not support blanking
       
   831 }
       
   832 
       
   833 // --------------------------------------------------------------------------
       
   834 // CCCAppDetailsViewContainer::RegisterCommand
       
   835 // --------------------------------------------------------------------------
       
   836 //
       
   837 void CCCAppDetailsViewContainer::RegisterCommand(MPbk2Command* aCommand)
       
   838 {
       
   839     iCommand = aCommand;
       
   840 }
       
   841 
       
   842 // --------------------------------------------------------------------------
       
   843 // CCCAppDetailsViewContainer::SetTextL
       
   844 // --------------------------------------------------------------------------
       
   845 //
       
   846 void CCCAppDetailsViewContainer::SetTextL(const TDesC& /*aText*/)
       
   847 {
       
   848     // Do nothing
       
   849 }
       
   850 
       
   851 // --------------------------------------------------------------------------
       
   852 // CCCAppDetailsViewContainer::ContactUiControlExtension
       
   853 // --------------------------------------------------------------------------
       
   854 //
       
   855 TAny* CCCAppDetailsViewContainer::ContactUiControlExtension(TUid aExtensionUid)
       
   856 {
       
   857     if (aExtensionUid == KMPbk2ContactUiControlExtension2Uid)
       
   858     {
       
   859         return static_cast<MPbk2ContactUiControl2*>(this);
       
   860     }
       
   861 
       
   862     return NULL;
       
   863 }
       
   864 
       
   865 // --------------------------------------------------------------------------
       
   866 // CCCAppDetailsViewContainer::CommandItemCount
       
   867 // --------------------------------------------------------------------------
       
   868 //
       
   869 TInt CCCAppDetailsViewContainer::CommandItemCount() const
       
   870 {
       
   871     return 0; // No command items.
       
   872 }
       
   873 
       
   874 // --------------------------------------------------------------------------
       
   875 // CCCAppDetailsViewContainer::CommandItemAt
       
   876 // --------------------------------------------------------------------------
       
   877 //
       
   878 const MPbk2UiControlCmdItem& CCCAppDetailsViewContainer::CommandItemAt(
       
   879     TInt /*aIndex*/) const
       
   880 {
       
   881     // There are no command items in this control
       
   882     __ASSERT_ALWAYS(EFalse, User::Panic(_L("Pbk2"), 4)); //TODO
       
   883     MPbk2UiControlCmdItem* item = NULL; // For compiler only
       
   884     return *item; // For compiler only
       
   885 }
       
   886 
       
   887 // --------------------------------------------------------------------------
       
   888 // CCCAppDetailsViewContainer::FocusedCommandItem
       
   889 // --------------------------------------------------------------------------
       
   890 //
       
   891 const MPbk2UiControlCmdItem* CCCAppDetailsViewContainer::FocusedCommandItem() const
       
   892 {
       
   893     return NULL;
       
   894 }
       
   895 
       
   896 // --------------------------------------------------------------------------
       
   897 // CCCAppDetailsViewContainer::DeleteCommandItemL
       
   898 // --------------------------------------------------------------------------
       
   899 //
       
   900 void CCCAppDetailsViewContainer::DeleteCommandItemL(TInt /*aIndex*/)
       
   901 {
       
   902     // Do nothing
       
   903 }
       
   904 
       
   905 // --------------------------------------------------------------------------
       
   906 // CCCAppDetailsViewContainer::AddCommandItemL
       
   907 // --------------------------------------------------------------------------
       
   908 //
       
   909 void CCCAppDetailsViewContainer::AddCommandItemL(
       
   910     MPbk2UiControlCmdItem* /*aCommand*/, TInt /*aIndex*/)
       
   911 {
       
   912     //Do nothing, since there shouldn't be any command items in this state.
       
   913 }
       
   914 
       
   915 // ---------------------------------------------------------------------------
       
   916 // CCCAppDetailsViewContainer::DoShowMapCmdL
       
   917 // ---------------------------------------------------------------------------
       
   918 //
       
   919 void CCCAppDetailsViewContainer::DoShowMapCmdL(TPbk2CommandId aCommandId)
       
   920 {
       
   921     iCommandHandler->HandleCommandL(aCommandId, *this, NULL);
       
   922 }
       
   923 
       
   924 // ---------------------------------------------------------------------------
       
   925 // CCCAppDetailsViewContainer::HandleLaunchCallRequestL
       
   926 // ---------------------------------------------------------------------------
       
   927 //
       
   928 void CCCAppDetailsViewContainer::HandleLaunchCallRequestL()
       
   929     {
       
   930     const MVPbkBaseContactField* field = iListBoxModel->FocusedFieldLC();
       
   931     TInt fieldTypeId = field->MatchFieldType(0)->FieldTypeResId();
       
   932     // Video call selector is used for video call, voice call selector for others
       
   933     VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector commMethod;
       
   934     if ( fieldTypeId == R_VPBK_FIELD_TYPE_VIDEONUMBERGEN  || 
       
   935          fieldTypeId == R_VPBK_FIELD_TYPE_VIDEONUMBERHOME ||
       
   936          fieldTypeId == R_VPBK_FIELD_TYPE_VIDEONUMBERWORK )
       
   937         {
       
   938         commMethod = VPbkFieldTypeSelectorFactory::EVideoCallSelector;
       
   939         }
       
   940     else if ( fieldTypeId == R_VPBK_FIELD_TYPE_VOIPHOME || 
       
   941               fieldTypeId == R_VPBK_FIELD_TYPE_VOIPWORK ||
       
   942               fieldTypeId == R_VPBK_FIELD_TYPE_VOIPGEN  ||
       
   943               fieldTypeId == R_VPBK_FIELD_TYPE_IMPP )
       
   944         {
       
   945         commMethod = VPbkFieldTypeSelectorFactory::EVOIPCallSelector;
       
   946         }
       
   947     else
       
   948         {
       
   949         commMethod = VPbkFieldTypeSelectorFactory::EVoiceCallSelector;
       
   950         }
       
   951 	CVPbkFieldTypeSelector* fieldTypeSelctor = 
       
   952 	                 VPbkFieldTypeSelectorFactory::BuildContactActionTypeSelectorL(
       
   953 	                 commMethod, ContactManager().FieldTypes() );
       
   954 	CleanupStack::PushL( fieldTypeSelctor );
       
   955 	        
       
   956 	CCAContactorService* contactorService = iPlugin.ContactorService();
       
   957 	        
       
   958 	if ( fieldTypeSelctor->IsFieldIncluded(*field) && contactorService )
       
   959 	    {
       
   960 	    // Launch call
       
   961 	    TPtrC fullName( KNullDesC() );  // Full name not required
       
   962 	    TUint paramFlag = CCAContactorService::TCSParameter::EUseFieldParam;
       
   963 	    TPtrC8 contactlinkarray( KNullDesC8() ); // Not required
       
   964 	    TVPbkFieldStorageType dataType = field->FieldData().DataType();
       
   965 	    HBufC* selectedFeild = NULL;
       
   966 
       
   967 	    if ( dataType == EVPbkFieldStorageTypeText )
       
   968 	         {
       
   969 	         const MVPbkContactFieldTextData& textData =
       
   970 	               MVPbkContactFieldTextData::Cast( field->FieldData() );
       
   971 	         selectedFeild = textData.Text().AllocLC();
       
   972 	         }      
       
   973 	    else if ( dataType == EVPbkFieldStorageTypeUri )
       
   974 	         {
       
   975 	         const MVPbkContactFieldUriData& textData =
       
   976 	                    MVPbkContactFieldUriData::Cast( field->FieldData() );
       
   977 	         selectedFeild = textData.Text().AllocLC();
       
   978 	         }
       
   979 	            
       
   980 	         CCAContactorService::TCSParameter param(
       
   981 	                commMethod,
       
   982 	                contactlinkarray,//contactlinkarray
       
   983 	                paramFlag,
       
   984 	                fullName,
       
   985 	                *selectedFeild);
       
   986 	    
       
   987 	         contactorService->ExecuteServiceL(param);
       
   988 	            
       
   989 	         CleanupStack::PopAndDestroy(); // selectedFeild
       
   990 	    }
       
   991 	    CleanupStack::PopAndDestroy( 2 ); // field, fieldTypeSelctor   
       
   992 	}
       
   993 // End of File