phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherheadercontrol.cpp
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     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->SetAlignment(EHCenterVCenter);
       
    63     
       
    64     // Create the header labels
       
    65     for (TInt i=0; i < KLabelLineCount; i++)
       
    66         {
       
    67         CEikLabel* label = new(ELeave) CEikLabel;
       
    68         CleanupStack::PushL(label);
       
    69         iLabels.AppendL(label);
       
    70         CleanupStack::Pop(label);
       
    71         iLabels[i]->SetTextL(KNullDesC());
       
    72         iLabels[i]->SetAlignment(EHLeftVCenter);
       
    73         iLabels[i]->CropText();
       
    74         }
       
    75     iContactImageSize = KPbkPersonalImageSize;
       
    76     // Create the text order
       
    77     iTextOrder = CCCAppCommLauncherHeaderTextOrder::NewL();
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // Destructor
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 CCCAppCommLauncherHeaderControl::~CCCAppCommLauncherHeaderControl()
       
    85     {
       
    86     delete iContactImageFullName;
       
    87     delete iContactThumbnailData;
       
    88     
       
    89     iCmsContactFields.Close(); 
       
    90     iLabels.ResetAndDestroy();
       
    91     if (iImage)
       
    92         {
       
    93         delete iImage;
       
    94         iImage = NULL;
       
    95         }
       
    96     if (iImageDecoding)
       
    97         {
       
    98         if (iImageDecoding->IsActive())
       
    99             {
       
   100             iImageDecoding->Cancel();
       
   101             }
       
   102         delete iImageDecoding;
       
   103         iImageDecoding = NULL;
       
   104         }
       
   105     if (iTextOrder)
       
   106         {
       
   107         delete iTextOrder;
       
   108         iTextOrder = NULL;
       
   109         }
       
   110     if (iBitmap)
       
   111         {
       
   112         delete iBitmap;
       
   113         iBitmap = NULL;
       
   114         }
       
   115     if (iMask)
       
   116         {
       
   117         delete iMask;
       
   118         iMask = NULL;
       
   119         }
       
   120     if ( iImageSelectionPopup )
       
   121         {
       
   122         delete iImageSelectionPopup;
       
   123         iImageSelectionPopup = NULL;
       
   124         }
       
   125     if( iPbkCmd )
       
   126         {
       
   127         delete iPbkCmd;
       
   128         iPbkCmd = NULL;
       
   129         }
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // From CCoeControl, returns the number of child controls to the framework
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 TInt CCCAppCommLauncherHeaderControl::CountComponentControls() const
       
   137     {
       
   138     return 1 + iLabels.Count();
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // From CCoeControl, returns the child controls to the framework by index
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 CCoeControl* CCCAppCommLauncherHeaderControl::ComponentControl(TInt aIndex)  const
       
   146     {
       
   147     if (aIndex == 0)
       
   148         {
       
   149         return iImage;
       
   150         }
       
   151     else if (aIndex - 1 < iLabels.Count())
       
   152         {
       
   153         return iLabels[aIndex-1];
       
   154         }
       
   155     else
       
   156         {
       
   157         return NULL;
       
   158         }
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // From CCoeControl, called when the control's size changes, handles portrait-landscape switch
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void CCCAppCommLauncherHeaderControl::SizeChanged()
       
   166     {
       
   167     TInt isLandscape = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
       
   168     
       
   169     AknLayoutUtils::LayoutImage(
       
   170             iImage, Rect(), AknLayoutScalable_Apps::cl_header_pane_g1(isLandscape));
       
   171    
       
   172     TPoint position = iImage->Position();
       
   173     TSize size = iImage->Size();
       
   174     
       
   175     const TPoint newImagePosition = TPoint( position.iX/2, position.iY/2 );
       
   176     iImage->SetPosition( newImagePosition );
       
   177     
       
   178     const TSize newImageSize = TSize( size.iWidth + 2*( position.iX - newImagePosition.iX ) ,
       
   179             size.iHeight + 2*( position.iY - newImagePosition.iY ) );
       
   180     
       
   181     iImage->SetSize( newImageSize );
       
   182     
       
   183     iContactImageSize = newImageSize;
       
   184     
       
   185     if ( iImageDecoding )
       
   186         {
       
   187         // if bitmap was set resize it
       
   188         if (iImageDecoding->IsActive())
       
   189             {
       
   190             iImageDecoding->Cancel();
       
   191             }
       
   192         TRAP_IGNORE( iImageDecoding->StartL( iContactImageSize ) );
       
   193         }
       
   194     
       
   195     TAknLayoutRect labelsRect;
       
   196     labelsRect.LayoutRect(Rect(), AknLayoutScalable_Apps::cl_header_name_pane(isLandscape));
       
   197     
       
   198     AknLayoutUtils::LayoutLabel(iLabels[0], labelsRect.Rect(), AknLayoutScalable_Apps::cl_header_name_pane_t1(2));
       
   199     AknLayoutUtils::LayoutLabel(iLabels[1], labelsRect.Rect(), AknLayoutScalable_Apps::cl_header_name_pane_t2(2));
       
   200     AknLayoutUtils::LayoutLabel(iLabels[2], labelsRect.Rect(), AknLayoutScalable_Apps::cl_header_name_pane_t3(2));
       
   201     
       
   202     if( iImageSelectionPopup )
       
   203         {
       
   204         delete iImageSelectionPopup;
       
   205         iImageSelectionPopup = NULL;
       
   206         }
       
   207     
       
   208     TRAP_IGNORE(LabelsSizeChangedL());
       
   209     }
       
   210 
       
   211 // ---------------------------------------------------------------------------
       
   212 // CCCAppCommLauncherHeaderControl::LabelsSizeChangedL()
       
   213 // ---------------------------------------------------------------------------
       
   214 //
       
   215 void CCCAppCommLauncherHeaderControl::LabelsSizeChangedL()
       
   216     {
       
   217     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   218     TRgb color;
       
   219     AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
       
   220         
       
   221     if (iLabels.Count() > 0)
       
   222         {
       
   223         iTextOrder->ClipL(*iLabels[0]->Font(), iLabels[0]->Rect().Width());
       
   224         for (TInt i=0; i < iLabels.Count(); i++)
       
   225             {
       
   226             iLabels[i]->SetTextL(iTextOrder->GetTextForRow(i));
       
   227             iLabels[i]->OverrideColorL( EColorLabelText, color );
       
   228             }
       
   229         }
       
   230     }
       
   231 
       
   232 // ---------------------------------------------------------------------------
       
   233 // From CCoeControl, overridden to set the container windows for the child
       
   234 // controls of this control (labels and image)
       
   235 // ---------------------------------------------------------------------------
       
   236 //
       
   237 void CCCAppCommLauncherHeaderControl::SetContainerWindowL(const CCoeControl& aContainer)
       
   238     {
       
   239     CCoeControl::SetContainerWindowL(aContainer);
       
   240     iImage->SetContainerWindowL(aContainer);
       
   241     for (TInt i=0; i < iLabels.Count(); i++)
       
   242         {
       
   243         iLabels[i]->SetContainerWindowL(aContainer);
       
   244         }
       
   245     }
       
   246 
       
   247 // ---------------------------------------------------------------------------
       
   248 // The container calls this when its ContactInfoFetchedNotifyL (from 
       
   249 // MCCAppContactHandlerNotifier) is called. Info about the contact is received
       
   250 // here.
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 void CCCAppCommLauncherHeaderControl::ContactInfoFetchedNotifyL( 
       
   254     const CCmsContactFieldInfo& aContactFieldInfo )
       
   255     {
       
   256     }
       
   257 
       
   258 // ---------------------------------------------------------------------------
       
   259 // The container calls this when its ContactFieldFetchedNotifyL (from 
       
   260 // MCCAppContactHandlerNotifier) is called. Data about the contact is received
       
   261 // here.
       
   262 // ---------------------------------------------------------------------------
       
   263 //
       
   264 void CCCAppCommLauncherHeaderControl::ContactFieldFetchedNotifyL( 
       
   265         const CCmsContactField& aContactField )
       
   266     {
       
   267     TInt field = aContactField.Type();
       
   268     if ( aContactField.Type() == CCmsContactFieldItem::ECmsImageName )
       
   269     	{
       
   270     	TPtrC data( aContactField.ItemL( 0 ).Data() );
       
   271         if ( data.Length() > 0 )
       
   272         	{
       
   273         	delete iContactImageFullName;
       
   274         	iContactImageFullName = NULL;
       
   275         	iContactImageFullName = data.AllocL();
       
   276         	}
       
   277     	}
       
   278     else if ( aContactField.Type() == CCmsContactFieldItem::ECmsThumbnailPic )
       
   279         {
       
   280         TPtrC8 data( aContactField.ItemL( 0 ).BinaryData() );
       
   281         if ( data.Length() > 0 )
       
   282         	{
       
   283         	delete iContactThumbnailData;
       
   284         	iContactThumbnailData = NULL;
       
   285         	iContactThumbnailData = data.AllocL();
       
   286         	}
       
   287         else
       
   288             {
       
   289             // When removing header image from the detail view of a contact,
       
   290             // making the picture as NULL firstly.
       
   291             iImage->SetPicture(NULL, NULL);
       
   292             delete iBitmap;
       
   293             iBitmap = NULL;
       
   294             delete iMask;
       
   295             iMask = NULL;
       
   296             }
       
   297         }
       
   298     else
       
   299         {
       
   300         iCmsContactFields.AppendL(aContactField);		
       
   301         }
       
   302     }
       
   303 
       
   304 // ---------------------------------------------------------------------------
       
   305 // Performs processing of retrieved contact fields 
       
   306 // ---------------------------------------------------------------------------
       
   307 //
       
   308 void CCCAppCommLauncherHeaderControl::ContactFieldFetchingCompletedL()
       
   309     {
       
   310     ProcessContactImageDisplayL();
       
   311     iTextOrder->ProcessContactFieldsL(iCmsContactFields); 
       
   312     iCmsContactFields.Reset(); 
       
   313     
       
   314     if (iLabels.Count() > 0)
       
   315         {
       
   316         iTextOrder->ClipL(*iLabels[0]->Font(), iLabels[0]->Rect().Width());
       
   317         }
       
   318     for (TInt i = 0; i < iLabels.Count(); i++)
       
   319         {
       
   320         iLabels[i]->SetTextL(iTextOrder->GetTextForRow(i));
       
   321         }
       
   322     DrawDeferred();
       
   323     }
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // Sets the bitmap shown in the header image 
       
   327 // ---------------------------------------------------------------------------
       
   328 //
       
   329 void CCCAppCommLauncherHeaderControl::SetBitmap(CFbsBitmap* aBmp)
       
   330     {
       
   331     if (iBitmap)
       
   332         {
       
   333         delete iBitmap;
       
   334         iBitmap = NULL;
       
   335         }
       
   336     if (iMask)
       
   337         {
       
   338         delete iMask;
       
   339         iMask = NULL;
       
   340         }
       
   341     iBitmap = aBmp;
       
   342     iImage->SetPicture(aBmp, NULL);
       
   343     iImage->DrawDeferred();
       
   344     }
       
   345 
       
   346 // ---------------------------------------------------------------------------
       
   347 // Clears the header texts to blank
       
   348 // ---------------------------------------------------------------------------
       
   349 //
       
   350 void CCCAppCommLauncherHeaderControl::ClearL()
       
   351     {
       
   352     for (TInt i = 0; i < iLabels.Count(); i++)
       
   353         {
       
   354         iLabels[i]->SetTextL(KNullDesC());
       
   355         }
       
   356     iTextOrder->Reset();
       
   357     }
       
   358 
       
   359 // ---------------------------------------------------------------------------
       
   360 // SetContactStoreL
       
   361 // ---------------------------------------------------------------------------
       
   362 //
       
   363 void CCCAppCommLauncherHeaderControl::SetContactStoreL(TCmsContactStore aContactStore)
       
   364     {
       
   365     if (!iBitmap && !iMask)
       
   366         {
       
   367         switch (aContactStore)
       
   368             {
       
   369             case ECmsContactStorePbk:
       
   370                 AknIconUtils::CreateIconL( 
       
   371                     iBitmap, iMask, KPbk2ECEIconFileName, 
       
   372                     EMbmPhonebook2eceQgn_prop_pb_thumb_unknown, EMbmPhonebook2eceQgn_prop_pb_thumb_unknown_mask );
       
   373                 iImage->SetPicture(iBitmap, iMask);
       
   374                 SizeChanged();
       
   375                 break;                
       
   376             
       
   377             case ECmsContactStoreSim:
       
   378                 AknIconUtils::CreateIconL( 
       
   379                     iBitmap, iMask, KPbk2ECEIconFileName, 
       
   380                     EMbmPhonebook2eceQgn_note_sim, EMbmPhonebook2eceQgn_note_sim_mask );
       
   381                 iImage->SetPicture(iBitmap, iMask);
       
   382                 SizeChanged();
       
   383                 break;
       
   384                 
       
   385             case ECmsContactStoreSdn:
       
   386                 AknIconUtils::CreateIconL( 
       
   387                     iBitmap, iMask, KPbk2ECEIconFileName, 
       
   388                     EMbmPhonebook2eceQgn_menu_simin, EMbmPhonebook2eceQgn_menu_simin_mask );
       
   389                 iImage->SetPicture(iBitmap, iMask);
       
   390                 SizeChanged();
       
   391                 break;
       
   392             }
       
   393         }
       
   394      }
       
   395 
       
   396 // ---------------------------------------------------------------------------
       
   397 // HandlePointerEventL
       
   398 // ---------------------------------------------------------------------------
       
   399 //
       
   400 void CCCAppCommLauncherHeaderControl::HandlePointerEventL(
       
   401         const TPointerEvent& aPointerEvent)
       
   402     {
       
   403     CCoeControl::HandlePointerEventL( aPointerEvent );
       
   404     switch(aPointerEvent.iType)
       
   405         {
       
   406         case TPointerEvent::EButton1Down:
       
   407 
       
   408             // Image selection popup
       
   409             if( iPlugin.ContactHandler().ContactStore() != ECmsContactStoreSdn 
       
   410                 && IsPhoneMemoryInConfigurationL() 
       
   411                 && iImage->Rect().Contains(aPointerEvent.iPosition) )
       
   412                 {
       
   413                 // Show the feedback
       
   414                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   415                 if ( feedback )
       
   416                     {
       
   417                     feedback->InstantFeedback( ETouchFeedbackBasic );
       
   418                     }
       
   419                 LaunchStylusPopupL( aPointerEvent );
       
   420                 }
       
   421             break;
       
   422             
       
   423         default:
       
   424             break;
       
   425         }
       
   426     }
       
   427 
       
   428 // ---------------------------------------------------------------------------
       
   429 // ProcessCommandL
       
   430 // ---------------------------------------------------------------------------
       
   431 //
       
   432 void CCCAppCommLauncherHeaderControl::ProcessCommandL(TInt aCommandId)
       
   433      {
       
   434      switch(aCommandId)
       
   435          {
       
   436          case ECCAppCommLauncherStylusViewImageCmd:
       
   437              DoViewImageCmdL();
       
   438              break;
       
   439              
       
   440          case ECCAppCommLauncherStylusChangeImageCmd:
       
   441              DoChangeImageCmdL();
       
   442              break;
       
   443              
       
   444          case ECCAppCommLauncherStylusRemoveImageCmd:
       
   445              DoRemoveImageCmdL();
       
   446              break;
       
   447              
       
   448          case ECCAppCommLauncherStylusAddImageCmd:
       
   449              DoAddImageCmdL();
       
   450              break;
       
   451              
       
   452          default:
       
   453              break;
       
   454          }
       
   455      }
       
   456  
       
   457 // ---------------------------------------------------------------------------
       
   458 // SetEmphasis
       
   459 // ---------------------------------------------------------------------------
       
   460 //
       
   461  void CCCAppCommLauncherHeaderControl::SetEmphasis(
       
   462          CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/)
       
   463      {
       
   464      // No implementation
       
   465      }
       
   466 
       
   467  // ---------------------------------------------------------------------------
       
   468  // PosToScreenCoordinates
       
   469  // ---------------------------------------------------------------------------
       
   470  //
       
   471  void CCCAppCommLauncherHeaderControl::PosToScreenCoordinates( 
       
   472          CCoeControl* aControl, TPoint& aPos )
       
   473       {
       
   474       TPoint leftUpperPos = aControl->Parent()->PositionRelativeToScreen();
       
   475       aPos += leftUpperPos;
       
   476       }
       
   477  
       
   478  // ---------------------------------------------------------------------------
       
   479  // LaunchStylusPopupL
       
   480  // ---------------------------------------------------------------------------
       
   481  //
       
   482 void CCCAppCommLauncherHeaderControl::LaunchStylusPopupL( const TPointerEvent& aPointerEvent )
       
   483      {
       
   484      iPos = TPoint(0,0);
       
   485      if ( !iImageSelectionPopup )
       
   486          {
       
   487          iImageSelectionPopup = CAknStylusPopUpMenu::NewL( this, iPos, NULL );
       
   488          TInt resourceReaderId = R_CCACOMMLAUNCHER_CONTACT_IMAGE_STYLUS_MENU; 
       
   489          TResourceReader reader;
       
   490          iCoeEnv->CreateResourceReaderLC( reader , resourceReaderId );
       
   491          iImageSelectionPopup->ConstructFromResourceL( reader );
       
   492          CleanupStack::PopAndDestroy(); // reader
       
   493          }
       
   494      
       
   495      if( iHasContactImage )
       
   496          {
       
   497          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusViewImageCmd, EFalse);
       
   498          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusChangeImageCmd, EFalse);
       
   499          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusRemoveImageCmd, EFalse);
       
   500          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusAddImageCmd, ETrue);
       
   501          }
       
   502      else
       
   503          {
       
   504          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusViewImageCmd, ETrue);
       
   505          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusChangeImageCmd, ETrue);
       
   506          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusRemoveImageCmd, ETrue);
       
   507          iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusAddImageCmd, EFalse);
       
   508         }
       
   509         
       
   510      iPos.iY = aPointerEvent.iPosition.iY;
       
   511      iPos.iX = aPointerEvent.iPosition.iX;
       
   512      PosToScreenCoordinates(this, iPos);
       
   513      
       
   514     
       
   515 
       
   516      iImageSelectionPopup->SetPosition(iPos);
       
   517      iImageSelectionPopup->ShowMenu();
       
   518      }
       
   519 
       
   520 // ---------------------------------------------------------------------------
       
   521 // DoViewImageCmdL
       
   522 // ---------------------------------------------------------------------------
       
   523 //
       
   524 void CCCAppCommLauncherHeaderControl::DoViewImageCmdL()
       
   525     {
       
   526     if( !iPbkCmd )
       
   527         iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin );
       
   528         
       
   529     iPbkCmd->ExecutePbk2CmdViewImageL(
       
   530             *iPlugin.ContactHandler().ContactIdentifierLC() );
       
   531 
       
   532     CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC
       
   533     }
       
   534 
       
   535 // --------------------------------------------------------------------------- 
       
   536 // DoChangeImageCmdL 
       
   537 // --------------------------------------------------------------------------- 
       
   538 // 
       
   539 void CCCAppCommLauncherHeaderControl::DoChangeImageCmdL() 
       
   540      { 
       
   541      if( !iPbkCmd ) 
       
   542          iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin ); 
       
   543           
       
   544      iPbkCmd->ExecutePbk2CmdChangeImageL( 
       
   545              *iPlugin.ContactHandler().ContactIdentifierLC() ); 
       
   546    
       
   547      CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC 
       
   548      } 
       
   549    
       
   550  // --------------------------------------------------------------------------- 
       
   551  // DoRemoveImageCmdL 
       
   552  // --------------------------------------------------------------------------- 
       
   553  // 
       
   554  void CCCAppCommLauncherHeaderControl::DoRemoveImageCmdL() 
       
   555      { 
       
   556      if( !iPbkCmd ) 
       
   557          iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin ); 
       
   558           
       
   559      iPbkCmd->ExecutePbk2CmdRemoveImageL( 
       
   560              *iPlugin.ContactHandler().ContactIdentifierLC() ); 
       
   561    
       
   562      CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC 
       
   563      } 
       
   564    
       
   565  // --------------------------------------------------------------------------- 
       
   566  // DoAddImageCmdL 
       
   567  // --------------------------------------------------------------------------- 
       
   568  // 
       
   569  void CCCAppCommLauncherHeaderControl::DoAddImageCmdL() 
       
   570      { 
       
   571      if( !iPbkCmd ) 
       
   572          iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin ); 
       
   573           
       
   574      iPbkCmd->ExecutePbk2CmdAddImageL( 
       
   575              *iPlugin.ContactHandler().ContactIdentifierLC() ); 
       
   576    
       
   577      CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC 
       
   578      } 
       
   579    
       
   580  // --------------------------------------------------------------------------
       
   581  // CCCAppCommLauncherHeaderControl::IsPhoneMemoryInConfigurationL
       
   582  // --------------------------------------------------------------------------
       
   583  //
       
   584  TBool CCCAppCommLauncherHeaderControl::IsPhoneMemoryInConfigurationL()
       
   585      {
       
   586      CPbk2ContactRelocator* contactRelocator = CPbk2ContactRelocator::NewL();
       
   587      CleanupStack::PushL( contactRelocator );
       
   588      TBool ret = contactRelocator->IsPhoneMemoryInConfigurationL();
       
   589      CleanupStack::PopAndDestroy( contactRelocator );
       
   590      return ret;
       
   591      }
       
   592  
       
   593  TKeyResponse CCCAppCommLauncherHeaderControl::OfferKeyEventL(
       
   594          const TKeyEvent& aKeyEvent, TEventCode aType)
       
   595      {
       
   596      TKeyResponse ret( EKeyWasNotConsumed );
       
   597      
       
   598      // If there is a command running in the background
       
   599      // the send key is automatically consumed. This 
       
   600      // avoids e.g launching of a call
       
   601      if ( iPbkCmd && iPbkCmd->IsPbk2CommandRunning() )
       
   602          {
       
   603          if (EKeyYes == aKeyEvent.iCode)
       
   604              {
       
   605              ret = EKeyWasConsumed;
       
   606              }
       
   607          }
       
   608      return ret;
       
   609      }
       
   610  
       
   611  void CCCAppCommLauncherHeaderControl::ProcessContactImageDisplayL()
       
   612 	 {
       
   613 	 iHasContactImage = EFalse;
       
   614 	 
       
   615      if (iImageDecoding)
       
   616          {
       
   617          if (iImageDecoding->IsActive())
       
   618              {
       
   619              iImageDecoding->Cancel();
       
   620              }
       
   621          delete iImageDecoding;
       
   622          iImageDecoding = NULL;
       
   623          }
       
   624      
       
   625      if ( iContactThumbnailData )
       
   626     	 {
       
   627          iImageDecoding = CCCAppCommLauncherImageDecoding::NewL(this, iContactThumbnailData, iContactImageFullName );
       
   628          iImageDecoding->StartL( iContactImageSize );
       
   629          iHasContactImage = ETrue;
       
   630          }
       
   631 
       
   632      delete iContactImageFullName;
       
   633      iContactImageFullName = NULL;
       
   634      delete iContactThumbnailData;
       
   635      iContactThumbnailData = NULL;   
       
   636 	 }