phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherheadercontrol.cpp
branchRCL_3
changeset 20 f4a778e096c2
child 21 9da50d567e3c
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2008-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 the header part control(s) of the comm launcher view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ccappcommlauncherheadercontrol.h"
       
    20 #include "CPbkThumbnailManager.h"
       
    21 #include <phonebook2ece.mbg>
       
    22 #include <aknstyluspopupmenu.h>
       
    23 #include <CPbk2ContactRelocator.h>
       
    24 #include <touchfeedback.h>
       
    25 #include <w32std.h>
       
    26 
       
    27 const TInt KLabelLineCount = 3;
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // NewL, two-phase construction
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CCCAppCommLauncherHeaderControl* CCCAppCommLauncherHeaderControl::NewL( 
       
    34         CCCAppCommLauncherPlugin& aPlugin )
       
    35     {
       
    36     CCCAppCommLauncherHeaderControl* self= new (ELeave) CCCAppCommLauncherHeaderControl( aPlugin );
       
    37     CleanupStack::PushL(self);
       
    38     self->ConstructL();
       
    39     CleanupStack::Pop(self);
       
    40     return self;
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // C++ (first phase) constructor
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CCCAppCommLauncherHeaderControl::CCCAppCommLauncherHeaderControl( CCCAppCommLauncherPlugin& aPlugin )
       
    48     : iHasContactImage(EFalse), iPlugin( aPlugin )
       
    49     {
       
    50     // No implementation required
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // ConstructL, second phase constructor
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 void CCCAppCommLauncherHeaderControl::ConstructL()
       
    58     { 
       
    59     // Create the header image
       
    60     iImage = new (ELeave) CEikImage();
       
    61     iImage->SetPictureOwnedExternally(ETrue);
       
    62     iImage->SetBrushStyle( CGraphicsContext::ENullBrush ); // transparent
       
    63     iImage->SetAlignment(EHCenterVCenter);    
       
    64     
       
    65     //Favorite Icon    
       
    66     iFavContactIcon = new (ELeave) CEikImage();            
       
    67     iFavContactIcon->SetBrushStyle( CGraphicsContext::ENullBrush ); // transparent
       
    68     iFavContactIcon->SetAlignment(EHCenterVCenter);
       
    69     
       
    70     // Create the header labels
       
    71     for (TInt i=0; i < KLabelLineCount; i++)
       
    72         {
       
    73         CEikLabel* label = new(ELeave) CEikLabel;
       
    74         CleanupStack::PushL(label);
       
    75         iLabels.AppendL(label);
       
    76         CleanupStack::Pop(label);
       
    77         iLabels[i]->SetTextL(KNullDesC());
       
    78         iLabels[i]->SetAlignment(EHLeftVCenter);
       
    79         iLabels[i]->CropText();
       
    80         }
       
    81     iContactImageSize = KPbkPersonalImageSize;
       
    82     // Create the text order
       
    83     iTextOrder = CCCAppCommLauncherHeaderTextOrder::NewL();
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // Destructor
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 CCCAppCommLauncherHeaderControl::~CCCAppCommLauncherHeaderControl()
       
    91     {
       
    92     delete iFavContactIcon;
       
    93     delete iContactImageFullName;
       
    94     delete iContactThumbnailData;
       
    95     if ( iStoreContactImageFullName )
       
    96     	{
       
    97     	delete iStoreContactImageFullName;
       
    98     	iStoreContactImageFullName = NULL;
       
    99     	}
       
   100     
       
   101     iCmsContactFields.Close(); 
       
   102     iLabels.ResetAndDestroy();
       
   103     if (iImage)
       
   104         {
       
   105         delete iImage;
       
   106         iImage = NULL;
       
   107         }
       
   108     delete iImageDecoding;
       
   109     if (iTextOrder)
       
   110         {
       
   111         delete iTextOrder;
       
   112         iTextOrder = NULL;
       
   113         }
       
   114     if (iBitmap)
       
   115         {
       
   116         delete iBitmap;
       
   117         iBitmap = NULL;
       
   118         }
       
   119     if (iMask)
       
   120         {
       
   121         delete iMask;
       
   122         iMask = NULL;
       
   123         }
       
   124     if ( iImageSelectionPopup )
       
   125         {
       
   126         delete iImageSelectionPopup;
       
   127         iImageSelectionPopup = NULL;
       
   128         }
       
   129     if( iPbkCmd )
       
   130         {
       
   131         delete iPbkCmd;
       
   132         iPbkCmd = NULL;
       
   133         }
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------------------------
       
   137 // From CCoeControl, returns the number of child controls to the framework
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 TInt CCCAppCommLauncherHeaderControl::CountComponentControls() const
       
   141     {
       
   142     return 2 + iLabels.Count(); // iImage, iFavContactIcon
       
   143     }
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // From CCoeControl, returns the child controls to the framework by index
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 CCoeControl* CCCAppCommLauncherHeaderControl::ComponentControl(TInt aIndex)  const
       
   150     {
       
   151     TInt imageControl = 2; // iImage, iFavContactIcon    
       
   152     
       
   153     if (aIndex == 0)
       
   154         {
       
   155         return iImage;
       
   156         }
       
   157     else if (aIndex == 1)
       
   158         {
       
   159         return iFavContactIcon;
       
   160         }
       
   161     else if (aIndex - imageControl < iLabels.Count())
       
   162         {
       
   163         return iLabels[aIndex-imageControl];
       
   164         }
       
   165     else
       
   166         {
       
   167         return NULL;
       
   168         }
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // From CCoeControl, called when the control's size changes, handles portrait-landscape switch
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 void CCCAppCommLauncherHeaderControl::SizeChanged()
       
   176     {    
       
   177     const TInt isLandscape = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
       
   178     const TRect rect(Rect());
       
   179     
       
   180     /**
       
   181      * Option0 (w button, lsc)
       
   182      * Option2 (w/o button, lsc)
       
   183      * Option0 (w button, prt)
       
   184      * Option1 (w/o button, prt)
       
   185      */
       
   186    
       
   187     // (w/o button)
       
   188     TInt option( isLandscape ? 2 : 1 );
       
   189     if( iStatusButtonVisibility )
       
   190         {
       
   191         // (w button)
       
   192         if( isLandscape )
       
   193             {
       
   194             option = 0;
       
   195             }
       
   196         else
       
   197             {
       
   198             option = 0;
       
   199             }
       
   200         }    
       
   201    
       
   202     FavoriteIconSizeChanged();
       
   203     
       
   204     AknLayoutUtils::LayoutImage(
       
   205             iImage, rect, AknLayoutScalable_Apps::phob2_cc_data_pane_g1(option));
       
   206    
       
   207     iContactImageSize = iImage->Size();
       
   208     
       
   209     if ( iImageDecoding )
       
   210         {
       
   211         TRAP_IGNORE( iImageDecoding->StartL( iContactImageSize ) );
       
   212         }
       
   213     
       
   214     AknLayoutUtils::LayoutLabel(iLabels[0], rect, AknLayoutScalable_Apps::phob2_cc_data_pane_t1(option));
       
   215     AknLayoutUtils::LayoutLabel(iLabels[1], rect, AknLayoutScalable_Apps::phob2_cc_data_pane_t2(option));
       
   216     AknLayoutUtils::LayoutLabel(iLabels[2], rect, AknLayoutScalable_Apps::phob2_cc_data_pane_t3(option));
       
   217     
       
   218     if( iImageSelectionPopup )
       
   219         {
       
   220         delete iImageSelectionPopup;
       
   221         iImageSelectionPopup = NULL;
       
   222         }
       
   223     
       
   224     TRAP_IGNORE(LabelsSizeChangedL());
       
   225     }
       
   226 
       
   227 // ---------------------------------------------------------------------------
       
   228 // CCCAppCommLauncherHeaderControl::LabelsSizeChangedL()
       
   229 // ---------------------------------------------------------------------------
       
   230 //
       
   231 void CCCAppCommLauncherHeaderControl::LabelsSizeChangedL()
       
   232     {
       
   233     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   234     TRgb color;
       
   235     AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
       
   236         
       
   237     if (iLabels.Count() > 0)
       
   238         {
       
   239         iTextOrder->ClipL(*iLabels[0]->Font(), iLabels[0]->Rect().Width());
       
   240         for (TInt i=0; i < iLabels.Count(); i++)
       
   241             {
       
   242             iLabels[i]->SetTextL(iTextOrder->GetTextForRow(i));
       
   243             iLabels[i]->OverrideColorL( EColorLabelText, color );
       
   244             }
       
   245         }
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // From CCoeControl, overridden to set the container windows for the child
       
   250 // controls of this control (labels and image)
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 void CCCAppCommLauncherHeaderControl::SetContainerWindowL(const CCoeControl& aContainer)
       
   254     {
       
   255     CCoeControl::SetContainerWindowL(aContainer);
       
   256     iImage->SetContainerWindowL(aContainer);
       
   257     iFavContactIcon->SetContainerWindowL(aContainer);    
       
   258     
       
   259     for (TInt i=0; i < iLabels.Count(); i++)
       
   260         {
       
   261         iLabels[i]->SetContainerWindowL(aContainer);
       
   262         }
       
   263     }
       
   264 
       
   265 // ---------------------------------------------------------------------------
       
   266 // The container calls this when its ContactInfoFetchedNotifyL (from 
       
   267 // MCCAppContactHandlerNotifier) is called. Info about the contact is received
       
   268 // here.
       
   269 // ---------------------------------------------------------------------------
       
   270 //
       
   271 void CCCAppCommLauncherHeaderControl::ContactInfoFetchedNotifyL( 
       
   272     const CCmsContactFieldInfo& /*aContactFieldInfo*/ )
       
   273     {
       
   274     }
       
   275 
       
   276 // ---------------------------------------------------------------------------
       
   277 // The container calls this when its ContactFieldFetchedNotifyL (from 
       
   278 // MCCAppContactHandlerNotifier) is called. Data about the contact is received
       
   279 // here.
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 void CCCAppCommLauncherHeaderControl::ContactFieldFetchedNotifyL( 
       
   283         const CCmsContactField& aContactField )
       
   284     {
       
   285     TInt field = aContactField.Type();
       
   286     if ( aContactField.Type() == CCmsContactFieldItem::ECmsImageName )
       
   287     	{
       
   288     	TPtrC data( aContactField.ItemL( 0 ).Data() );
       
   289         if ( data.Length() > 0 )
       
   290         	{
       
   291         	delete iContactImageFullName;
       
   292         	iContactImageFullName = NULL;
       
   293         	iContactImageFullName = data.AllocL();
       
   294         	
       
   295         	if ( iStoreContactImageFullName )
       
   296         		{
       
   297         		delete iStoreContactImageFullName;
       
   298         		iStoreContactImageFullName = NULL;
       
   299         		}
       
   300         	iStoreContactImageFullName = data.AllocL();
       
   301         	}
       
   302     	}
       
   303     else if ( aContactField.Type() == CCmsContactFieldItem::ECmsThumbnailPic )
       
   304         {
       
   305         TPtrC8 data( aContactField.ItemL( 0 ).BinaryData() );
       
   306         if ( data.Length() > 0 )
       
   307         	{
       
   308         	delete iContactThumbnailData;
       
   309         	iContactThumbnailData = NULL;
       
   310         	iContactThumbnailData = data.AllocL();
       
   311         	}
       
   312         else
       
   313             {
       
   314             // When removing header image from the detail view of a contact,
       
   315             // making the picture as NULL firstly.
       
   316             iImage->SetPicture(NULL, NULL);
       
   317             delete iBitmap;
       
   318             iBitmap = NULL;
       
   319             delete iMask;
       
   320             iMask = NULL;
       
   321             }
       
   322         }
       
   323     else
       
   324         {
       
   325         iCmsContactFields.AppendL(aContactField);		
       
   326         }
       
   327     }
       
   328 
       
   329 // ---------------------------------------------------------------------------
       
   330 // Performs processing of retrieved contact fields 
       
   331 // ---------------------------------------------------------------------------
       
   332 //
       
   333 void CCCAppCommLauncherHeaderControl::ContactFieldFetchingCompletedL()
       
   334     {
       
   335     ProcessContactImageDisplayL();
       
   336     iTextOrder->ProcessContactFieldsL(iCmsContactFields); 
       
   337     iCmsContactFields.Reset(); 
       
   338     
       
   339     if (iLabels.Count() > 0)
       
   340         {
       
   341         iTextOrder->ClipL(*iLabels[0]->Font(), iLabels[0]->Rect().Width());
       
   342         }
       
   343     for (TInt i = 0; i < iLabels.Count(); i++)
       
   344         {
       
   345         iLabels[i]->SetTextL(iTextOrder->GetTextForRow(i));
       
   346         }
       
   347     
       
   348 	//Find whether the Contact is a Favorite Contact    
       
   349     if ( iPlugin.IsTopContactL() )            
       
   350         {
       
   351 		//Create the Favorite Icon
       
   352         CFbsBitmap* bmp = NULL;
       
   353         CFbsBitmap* mask = NULL;
       
   354         
       
   355         AknIconUtils::CreateIconLC(
       
   356             bmp, mask, KPbk2ECEIconFileName, 
       
   357             EMbmPhonebook2eceQgn_prop_pb_topc, EMbmPhonebook2eceQgn_prop_pb_topc_mask );            
       
   358         
       
   359         //Create the header image
       
   360         iFavContactIcon->SetPicture( bmp, mask );    
       
   361         CleanupStack::Pop( 2 ); // bmp, mask
       
   362         
       
   363         FavoriteIconSizeChanged();
       
   364         }
       
   365     else
       
   366         {
       
   367         iFavContactIcon->SetPicture(NULL, NULL);
       
   368         }
       
   369 
       
   370     DrawDeferred();
       
   371     }
       
   372 
       
   373 void CCCAppCommLauncherHeaderControl::BitmapReadyL( CFbsBitmap* aBitmap )
       
   374     {
       
   375     SetBitmap(aBitmap);    
       
   376     }
       
   377 
       
   378 // ---------------------------------------------------------------------------
       
   379 // Sets the bitmap shown in the header image 
       
   380 // ---------------------------------------------------------------------------
       
   381 //
       
   382 void CCCAppCommLauncherHeaderControl::SetBitmap(CFbsBitmap* aBmp)
       
   383     {
       
   384     if (iBitmap)
       
   385         {
       
   386         delete iBitmap;
       
   387         iBitmap = NULL;
       
   388         }
       
   389     if (iMask)
       
   390         {
       
   391         delete iMask;
       
   392         iMask = NULL;
       
   393         }
       
   394     iBitmap = aBmp;
       
   395     iImage->SetPicture(aBmp, NULL);
       
   396     iImage->DrawDeferred();    
       
   397     }
       
   398 
       
   399 // ---------------------------------------------------------------------------
       
   400 // Clears the header texts to blank
       
   401 // ---------------------------------------------------------------------------
       
   402 //
       
   403 void CCCAppCommLauncherHeaderControl::ClearL()
       
   404     {
       
   405     for (TInt i = 0; i < iLabels.Count(); i++)
       
   406         {
       
   407         iLabels[i]->SetTextL(KNullDesC());
       
   408         }
       
   409     iTextOrder->Reset();
       
   410     }
       
   411 
       
   412 // ---------------------------------------------------------------------------
       
   413 // SetContactStoreL
       
   414 // ---------------------------------------------------------------------------
       
   415 //
       
   416 void CCCAppCommLauncherHeaderControl::SetContactStoreL(TCmsContactStore aContactStore)
       
   417     {
       
   418     if (!iBitmap && !iMask && !iHasContactImage )
       
   419         {
       
   420         switch (aContactStore)
       
   421             {
       
   422             case ECmsContactStorePbk:
       
   423                 AknIconUtils::CreateIconL( 
       
   424                     iBitmap, iMask, KPbk2ECEIconFileName, 
       
   425                     EMbmPhonebook2eceQgn_prop_pb_thumb_unknown, EMbmPhonebook2eceQgn_prop_pb_thumb_unknown_mask );
       
   426                 iImage->SetPicture(iBitmap, iMask);
       
   427                 SizeChanged();
       
   428                 break;                
       
   429             
       
   430             case ECmsContactStoreSim:
       
   431                 AknIconUtils::CreateIconL( 
       
   432                     iBitmap, iMask, KPbk2ECEIconFileName, 
       
   433                     EMbmPhonebook2eceQgn_note_sim, EMbmPhonebook2eceQgn_note_sim_mask );
       
   434                 iImage->SetPicture(iBitmap, iMask);
       
   435                 SizeChanged();
       
   436                 break;
       
   437                 
       
   438             case ECmsContactStoreSdn:
       
   439                 AknIconUtils::CreateIconL( 
       
   440                     iBitmap, iMask, KPbk2ECEIconFileName, 
       
   441                     EMbmPhonebook2eceQgn_menu_simin, EMbmPhonebook2eceQgn_menu_simin_mask );
       
   442                 iImage->SetPicture(iBitmap, iMask);
       
   443                 SizeChanged();
       
   444                 break;
       
   445             }
       
   446         }
       
   447      }
       
   448 
       
   449 // ---------------------------------------------------------------------------
       
   450 // HandlePointerEventL
       
   451 // ---------------------------------------------------------------------------
       
   452 //
       
   453 void CCCAppCommLauncherHeaderControl::HandlePointerEventL(
       
   454         const TPointerEvent& aPointerEvent)
       
   455     {
       
   456     CCoeControl::HandlePointerEventL( aPointerEvent );
       
   457     switch(aPointerEvent.iType)
       
   458         {
       
   459         case TPointerEvent::EButton1Down:
       
   460             {
       
   461             TCmsContactStore cntStore = iPlugin.ContactHandler().ContactStore();
       
   462             // Image selection popup
       
   463             // Image selection popup should not be shown for contact's that belong to sdn store
       
   464             // Image selection popup can be shown only if the default 
       
   465             //      saving memory includes local contact db (contacts.cdb) or if the contact belongs to
       
   466             //      local contact DB            
       
   467             if( cntStore != ECmsContactStoreSdn 
       
   468                 && IsPhoneMemoryInConfigurationL()
       
   469                      && (cntStore != ECmsContactStoreSim)
       
   470                 && iImage->Rect().Contains(aPointerEvent.iPosition) )
       
   471                 {
       
   472                 // Show the feedback
       
   473                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   474                 if ( feedback )
       
   475                     {
       
   476                     feedback->InstantFeedback( ETouchFeedbackBasic );
       
   477                     }
       
   478                 LaunchStylusPopupL( aPointerEvent );
       
   479                 }
       
   480             break;
       
   481             }
       
   482             
       
   483         default:
       
   484             break;
       
   485         }
       
   486     }
       
   487 
       
   488 // ---------------------------------------------------------------------------
       
   489 // ProcessCommandL
       
   490 // ---------------------------------------------------------------------------
       
   491 //
       
   492 void CCCAppCommLauncherHeaderControl::ProcessCommandL(TInt aCommandId)
       
   493      {
       
   494      switch(aCommandId)
       
   495          {
       
   496          case ECCAppCommLauncherStylusViewImageCmd:
       
   497              DoViewImageCmdL();
       
   498              break;
       
   499              
       
   500          case ECCAppCommLauncherStylusChangeImageCmd:
       
   501              DoChangeImageCmdL();
       
   502              break;
       
   503              
       
   504          case ECCAppCommLauncherStylusRemoveImageCmd:
       
   505              DoRemoveImageCmdL();
       
   506              break;
       
   507              
       
   508          case ECCAppCommLauncherStylusAddImageCmd:
       
   509              DoAddImageCmdL();
       
   510              break;
       
   511              
       
   512          default:
       
   513              break;
       
   514          }
       
   515      }
       
   516  
       
   517 // ---------------------------------------------------------------------------
       
   518 // SetEmphasis
       
   519 // ---------------------------------------------------------------------------
       
   520 //
       
   521  void CCCAppCommLauncherHeaderControl::SetEmphasis(
       
   522          CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/)
       
   523      {
       
   524      // No implementation
       
   525      }
       
   526 
       
   527  // ---------------------------------------------------------------------------
       
   528  // PosToScreenCoordinates
       
   529  // ---------------------------------------------------------------------------
       
   530  //
       
   531  void CCCAppCommLauncherHeaderControl::PosToScreenCoordinates( 
       
   532          CCoeControl* aControl, TPoint& aPos )
       
   533       {
       
   534       TPoint leftUpperPos = aControl->Parent()->PositionRelativeToScreen();
       
   535       aPos += leftUpperPos;
       
   536       }
       
   537  
       
   538  // ---------------------------------------------------------------------------
       
   539  // LaunchStylusPopupL
       
   540  // ---------------------------------------------------------------------------
       
   541  //
       
   542 void CCCAppCommLauncherHeaderControl::LaunchStylusPopupL( const TPointerEvent& aPointerEvent )
       
   543      {
       
   544      iPos = TPoint(0,0);
       
   545      if ( !iImageSelectionPopup )
       
   546          {
       
   547          iImageSelectionPopup = CAknStylusPopUpMenu::NewL( this, iPos, NULL );
       
   548          TInt resourceReaderId = R_CCACOMMLAUNCHER_CONTACT_IMAGE_STYLUS_MENU; 
       
   549          TResourceReader reader;
       
   550          iCoeEnv->CreateResourceReaderLC( reader , resourceReaderId );
       
   551          iImageSelectionPopup->ConstructFromResourceL( reader );
       
   552          CleanupStack::PopAndDestroy(); // reader
       
   553          }
       
   554      
       
   555      if( iHasContactImage )
       
   556          {
       
   557          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusChangeImageCmd, EFalse);
       
   558          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusRemoveImageCmd, EFalse);
       
   559          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusAddImageCmd, ETrue);
       
   560          
       
   561          // If the image has been deleted in the memory, "view image" should be hidden.
       
   562          RFs& fs( iCoeEnv->FsSession() );
       
   563          TEntry entry;
       
   564          iImageSelectionPopup->SetItemDimmed( ECCAppCommLauncherStylusViewImageCmd, 
       
   565         		                            ( fs.Entry( *iStoreContactImageFullName , entry ) == KErrNone ) ? EFalse : ETrue );
       
   566          }
       
   567      else
       
   568          {
       
   569          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusViewImageCmd, ETrue);
       
   570          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusChangeImageCmd, ETrue);
       
   571          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusRemoveImageCmd, ETrue);
       
   572          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusAddImageCmd, EFalse);
       
   573         }
       
   574         
       
   575      iPos.iY = aPointerEvent.iPosition.iY;
       
   576      iPos.iX = aPointerEvent.iPosition.iX;
       
   577      PosToScreenCoordinates(this, iPos);
       
   578      
       
   579     
       
   580 
       
   581      iImageSelectionPopup->SetPosition(iPos);
       
   582      iImageSelectionPopup->ShowMenu();
       
   583      }
       
   584 
       
   585 // ---------------------------------------------------------------------------
       
   586 // DoViewImageCmdL
       
   587 // ---------------------------------------------------------------------------
       
   588 //
       
   589 void CCCAppCommLauncherHeaderControl::DoViewImageCmdL()
       
   590     {
       
   591     if( !iPbkCmd )
       
   592         iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin );
       
   593         
       
   594     iPbkCmd->ExecutePbk2CmdViewImageL(
       
   595             *iPlugin.ContactHandler().ContactIdentifierLC() );
       
   596 
       
   597     CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC
       
   598     }
       
   599 
       
   600 // --------------------------------------------------------------------------- 
       
   601 // DoChangeImageCmdL 
       
   602 // --------------------------------------------------------------------------- 
       
   603 // 
       
   604 void CCCAppCommLauncherHeaderControl::DoChangeImageCmdL() 
       
   605      { 
       
   606      if( !iPbkCmd ) 
       
   607          iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin ); 
       
   608           
       
   609      iPbkCmd->ExecutePbk2CmdChangeImageL( 
       
   610              *iPlugin.ContactHandler().ContactIdentifierLC() ); 
       
   611    
       
   612      CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC 
       
   613      } 
       
   614    
       
   615  // --------------------------------------------------------------------------- 
       
   616  // DoRemoveImageCmdL 
       
   617  // --------------------------------------------------------------------------- 
       
   618  // 
       
   619  void CCCAppCommLauncherHeaderControl::DoRemoveImageCmdL() 
       
   620      { 
       
   621      if( !iPbkCmd ) 
       
   622          iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin ); 
       
   623           
       
   624      iPbkCmd->ExecutePbk2CmdRemoveImageL( 
       
   625              *iPlugin.ContactHandler().ContactIdentifierLC() ); 
       
   626    
       
   627      CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC 
       
   628      } 
       
   629    
       
   630  // --------------------------------------------------------------------------- 
       
   631  // DoAddImageCmdL 
       
   632  // --------------------------------------------------------------------------- 
       
   633  // 
       
   634  void CCCAppCommLauncherHeaderControl::DoAddImageCmdL() 
       
   635      { 
       
   636      if( !iPbkCmd ) 
       
   637          iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin ); 
       
   638           
       
   639      iPbkCmd->ExecutePbk2CmdAddImageL( 
       
   640              *iPlugin.ContactHandler().ContactIdentifierLC() ); 
       
   641    
       
   642      CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC 
       
   643      } 
       
   644    
       
   645  // --------------------------------------------------------------------------
       
   646  // CCCAppCommLauncherHeaderControl::IsPhoneMemoryInConfigurationL
       
   647  // --------------------------------------------------------------------------
       
   648  //
       
   649  TBool CCCAppCommLauncherHeaderControl::IsPhoneMemoryInConfigurationL()
       
   650      {
       
   651      CPbk2ContactRelocator* contactRelocator = CPbk2ContactRelocator::NewL();
       
   652      CleanupStack::PushL( contactRelocator );
       
   653      TBool ret = contactRelocator->IsPhoneMemoryInConfigurationL();
       
   654      CleanupStack::PopAndDestroy( contactRelocator );
       
   655      return ret;
       
   656      }
       
   657  
       
   658  // --------------------------------------------------------------------------
       
   659  // CCCAppCommLauncherHeaderControl::OfferKeyEventL
       
   660  // --------------------------------------------------------------------------
       
   661  //
       
   662  TKeyResponse CCCAppCommLauncherHeaderControl::OfferKeyEventL(
       
   663          const TKeyEvent& aKeyEvent, TEventCode /*aType*/)
       
   664      {
       
   665      TKeyResponse ret( EKeyWasNotConsumed );
       
   666      
       
   667      // If there is a command running in the background
       
   668      // the send key is automatically consumed. This 
       
   669      // avoids e.g launching of a call
       
   670      if ( iPbkCmd && iPbkCmd->IsPbk2CommandRunning() )
       
   671          {
       
   672          if (EKeyYes == aKeyEvent.iCode)
       
   673              {
       
   674              ret = EKeyWasConsumed;
       
   675              }
       
   676          }
       
   677      return ret;
       
   678      }
       
   679  
       
   680  // --------------------------------------------------------------------------
       
   681  // CCCAppCommLauncherHeaderControl::ProcessContactImageDisplayL
       
   682  // --------------------------------------------------------------------------
       
   683  //
       
   684  void CCCAppCommLauncherHeaderControl::ProcessContactImageDisplayL()
       
   685 	 {
       
   686 	 iHasContactImage = EFalse;
       
   687 	 
       
   688      delete iImageDecoding;
       
   689      iImageDecoding = NULL;
       
   690      
       
   691      if ( iContactThumbnailData )
       
   692     	 {
       
   693          RFs& fs = CEikonEnv::Static()->FsSession();
       
   694          iImageDecoding = CCCAppImageDecoding::NewL(
       
   695                  *this, 
       
   696                  fs, 
       
   697                  iContactThumbnailData, 
       
   698                  iContactImageFullName );
       
   699          iContactImageFullName = NULL;  // ownership is moved to CCCAppImageDecoding
       
   700          iContactThumbnailData = NULL;  // ownership is moved to CCCAppImageDecoding   
       
   701          iImageDecoding->StartL( iContactImageSize );
       
   702          iHasContactImage = ETrue;
       
   703          }
       
   704 
       
   705      delete iContactImageFullName;
       
   706      iContactImageFullName = NULL;
       
   707      delete iContactThumbnailData;
       
   708      iContactThumbnailData = NULL;   
       
   709 	 }
       
   710  
       
   711  // --------------------------------------------------------------------------
       
   712  // CCCAppCommLauncherHeaderControl::FavoriteIconSizeChanged
       
   713  // --------------------------------------------------------------------------
       
   714  //
       
   715  void CCCAppCommLauncherHeaderControl::FavoriteIconSizeChanged()
       
   716      {
       
   717      //Set the size for the Favorite Icon
       
   718      //This code must be in Sync with SizeChanged() code
       
   719      const TInt isLandscape = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
       
   720      const TRect rect(Rect());
       
   721      
       
   722      // (w/o button)
       
   723      TInt option( isLandscape ? 2 : 1 );
       
   724      if( iStatusButtonVisibility )
       
   725          {
       
   726          // (w button)
       
   727          if( isLandscape )
       
   728              {
       
   729              option = 0;
       
   730              }
       
   731          else
       
   732              {
       
   733              option = 0;
       
   734              }
       
   735          }    
       
   736     
       
   737      AknLayoutUtils::LayoutImage(
       
   738              iFavContactIcon, rect, AknLayoutScalable_Apps::phob2_cc_data_pane_g2(option));
       
   739              
       
   740      }
       
   741  
       
   742 //End of File