phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherlpadmodel.cpp
branchRCL_3
changeset 23 5586b4d2ec3e
parent 21 b3431bff8c19
child 35 4ae315f230bc
equal deleted inserted replaced
21:b3431bff8c19 23:5586b4d2ec3e
   300     if ( iButtonDataArray.Count() > aIndex )
   300     if ( iButtonDataArray.Count() > aIndex )
   301         {
   301         {
   302         TPtr textPtr(iTextBuf->Des());
   302         TPtr textPtr(iTextBuf->Des());
   303         textPtr.Zero();
   303         textPtr.Zero();
   304         TPtrC popupText;        
   304         TPtrC popupText;        
   305         TRAPD( error, popupText.Set( const_cast <CCCAppCommLauncherLPadModel*>(this)->TextForPopUpL( aIndex ) ) );
   305         TRAPD( error, popupText.Set( 
       
   306         		const_cast <CCCAppCommLauncherLPadModel*>(this)->TextForPopUpL( aIndex ) ) );
   306         if ( KErrNone == error )
   307         if ( KErrNone == error )
   307             {
   308             {
   308             textPtr.Copy( popupText );
   309             textPtr.Copy( popupText );
   309             }
   310             }
   310         else
   311         else
   332         else
   333         else
   333             {
   334             {
   334             tempText.Append( textPtr );
   335             tempText.Append( textPtr );
   335             }
   336             }
   336         tempText.Append( KColumnListSeparator ); 
   337         tempText.Append( KColumnListSeparator ); 
   337 		
   338         
   338         // TODO: Check presence icon
   339         // Check presence icon
       
   340 		if ( iButtonDataArray[ aIndex ].iFlags & 
       
   341 				TCommLauncherButtonData::EHasPresenceIcon )
       
   342 			{
       
   343 			tempText.AppendNum( EPresenceIconIndex );
       
   344 			}
   339         tempText.Append( KColumnListSeparator ); 
   345         tempText.Append( KColumnListSeparator ); 
   340         
   346         
   341         // Check if show multi icon at the right end of second row
   347         // Check if show multi icon at the right end of second row
   342         if ( IfShowMultiIcon( aIndex ) )
   348         if ( IfShowMultiIcon( aIndex ) )
   343         	{
   349         	{
   401 // CCCAppCommLauncherLPadModel::FillButtonArrayL
   407 // CCCAppCommLauncherLPadModel::FillButtonArrayL
   402 // ---------------------------------------------------------------------------
   408 // ---------------------------------------------------------------------------
   403 //
   409 //
   404 void CCCAppCommLauncherLPadModel::FillButtonArrayL()
   410 void CCCAppCommLauncherLPadModel::FillButtonArrayL()
   405     {
   411     {
       
   412     CalculateLayoutSize();
       
   413     
   406     RArray<VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector>&
   414     RArray<VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector>&
   407         preferredCommMethods = iContainer.Plugin().PreferredCommMethods();//not owned
   415         preferredCommMethods = iContainer.Plugin().PreferredCommMethods();//not owned
   408     const TInt buttonCount = preferredCommMethods.Count();
   416     const TInt buttonCount = preferredCommMethods.Count();
   409 
   417 
   410     for ( TInt i = 0; i < buttonCount; i++ )
   418     for ( TInt i = 0; i < buttonCount; i++ )
   953 // ---------------------------------------------------------------------------
   961 // ---------------------------------------------------------------------------
   954 //
   962 //
   955 void CCCAppCommLauncherLPadModel::Reset()
   963 void CCCAppCommLauncherLPadModel::Reset()
   956     {
   964     {
   957     iButtonDataArray.Reset();
   965     iButtonDataArray.Reset();
   958     }
   966     iButtonIconArray->Reset();
   959 
       
   960 // ---------------------------------------------------------------------------
       
   961 // CCCAppCommLauncherLPadModel::ReplaceWithDefaultIconL
       
   962 // ---------------------------------------------------------------------------
       
   963 //
       
   964 void CCCAppCommLauncherLPadModel::ReplaceWithDefaultIconL(
       
   965     CFbsBitmap*& aBitmap,
       
   966     CFbsBitmap*& aMask,
       
   967     const TUint32 aServiceType )
       
   968     {
       
   969     delete aBitmap;
       
   970     delete aMask;
       
   971     CGulIcon* icon = NULL;
       
   972 
       
   973     switch ( aServiceType )
       
   974         {
       
   975         /* The VOIP Button doesnt show presence CCA UI Spec will be
       
   976          * updated with this info.
       
   977          * Thats why this part of code is commeneted
       
   978         case CCmsContactFieldItem::ECmsPresenceVoIPNotification:
       
   979             icon = LoadIconLC(
       
   980                     EMbmPhonebook2eceQgn_prop_nrtyp_voip,
       
   981                     EMbmPhonebook2eceQgn_prop_nrtyp_voip_mask  );
       
   982             break;*/
       
   983         case CCmsContactFieldItem::ECmsPresenceChatNotification:
       
   984             icon = LoadIconLC(
       
   985                     EMbmPhonebook2eceQgn_prop_nrtyp_chat,
       
   986                     EMbmPhonebook2eceQgn_prop_nrtyp_chat_mask );
       
   987             break;
       
   988         default:
       
   989             // Only ECmsPresenceVoIPNotification and
       
   990             // ECmsPresenceChatNotification supported
       
   991             User::Leave( KErrArgument );
       
   992             break;
       
   993         }
       
   994 
       
   995     aBitmap = icon->Bitmap();
       
   996     aMask = icon->Mask();
       
   997     icon->SetBitmapsOwnedExternally( ETrue );
       
   998     CleanupStack::PopAndDestroy( icon );
       
   999     }
   967     }
  1000 
   968 
  1001 // ---------------------------------------------------------------------------
   969 // ---------------------------------------------------------------------------
  1002 // CCCAppCommLauncherLPadModel::ContactPresenceChangedL
   970 // CCCAppCommLauncherLPadModel::ContactPresenceChangedL
  1003 // ---------------------------------------------------------------------------
   971 // ---------------------------------------------------------------------------
  1004 //
   972 //
  1005 void CCCAppCommLauncherLPadModel::ContactPresenceChangedL(
   973 void CCCAppCommLauncherLPadModel::ContactPresenceChangedL(
  1006     const CCmsContactField& aContactField )
   974     const CCmsContactField& aContactField )
  1007     {
   975     {
  1008     //Get the size of icon for Voip presence
       
  1009     TRect mainPane = iPlugin.ClientRect();
       
  1010     TAknLayoutRect listLayoutRect;
       
  1011         listLayoutRect.LayoutRect(
       
  1012             mainPane,
       
  1013             AknLayoutScalable_Avkon::list_single_large_graphic_pane_g1(0).LayoutLine() );
       
  1014     TSize size(listLayoutRect.Rect().Size());
       
  1015     
       
  1016     const TInt count = aContactField.ItemCount();
   976     const TInt count = aContactField.ItemCount();
  1017     for (TUint i=0; i < count; i++)
   977     for (TUint i=0; i < count; i++)
  1018         {
   978         {
  1019         CCmsPresenceData& presData = ( CCmsPresenceData& )aContactField.ItemL( i );
   979         CCmsPresenceData& presData = ( CCmsPresenceData& )aContactField.ItemL( i );
  1020         presData.PreparePresenceDataL( size );
   980         presData.PreparePresenceDataL( iPresenceIconSize );
  1021         TUint32 serviceType = presData.ServiceType();
   981         TUint32 serviceType = presData.ServiceType();      
  1022         TInt iconInd = KErrNotFound;
   982         
  1023         switch (serviceType)
   983         if ( serviceType == CCmsContactFieldItem::ECmsPresenceChatNotification )
  1024             {
       
  1025             /* The VOIP Button doesnt show presence CCA UI Spec will be
       
  1026              * updated with this info.
       
  1027              * Thats why this part of code is commeneted
       
  1028             case CCmsContactFieldItem::ECmsPresenceVoIPNotification:
       
  1029                 iconInd = MapCommMethodToIcon(
       
  1030                     VPbkFieldTypeSelectorFactory::EVOIPCallSelector );
       
  1031                 break;*/
       
  1032             case CCmsContactFieldItem::ECmsPresenceChatNotification:
       
  1033                 iconInd = MapCommMethodToIcon(
       
  1034                     VPbkFieldTypeSelectorFactory::EInstantMessagingSelector );
       
  1035                 break;
       
  1036             }
       
  1037         if (iconInd > 0 && iconInd < iButtonIconArray->Count())
       
  1038             {
   984             {
  1039             CFbsBitmap* mask = presData.Mask();
   985             CFbsBitmap* mask = presData.Mask();
  1040             CFbsBitmap* bitmap = presData.Bitmap();
   986             CFbsBitmap* bitmap = presData.Bitmap();
  1041 
   987             
  1042             if ( bitmap && NULL == bitmap->Handle() )
   988             // Find the index for chat item
  1043                 {
   989         	TInt index = KErrNotFound;
  1044                 // There should not be a case with empty bitmaps, so
   990         	const TInt dataCount = iButtonDataArray.Count();
  1045                 // replace with the default icons.
   991         	for ( TInt i = 0; i < dataCount; i++ )
  1046                 ReplaceWithDefaultIconL( bitmap, mask, serviceType );
   992         		{
  1047                 }
   993         		if ( iButtonDataArray[ i ].iContactAction 
  1048 
   994     					== VPbkFieldTypeSelectorFactory::EInstantMessagingSelector )
  1049             if ( bitmap || mask )
   995         			{
  1050                 {
   996         			index = i;
  1051                 iButtonIconArray->At(iconInd)->SetBitmap(bitmap);
   997         			break;
  1052                 iButtonIconArray->At(iconInd)->SetMask(mask);
   998         			}
  1053                 }
   999         		}
       
  1000         	
       
  1001         	if ( index != KErrNotFound )
       
  1002         		{
       
  1003         	    TBool hasPresenceIcon = iButtonDataArray[ index ].iFlags & 
       
  1004 			                TCommLauncherButtonData::EHasPresenceIcon;
       
  1005         	
       
  1006                 if ( bitmap && ( NULL == bitmap->Handle() ) )
       
  1007             	    {
       
  1008             	    if ( hasPresenceIcon )
       
  1009             		    {
       
  1010             		    // Delete presence icon from icon array 
       
  1011             		    iButtonDataArray[ index ].iFlags &= ~(TCommLauncherButtonData::EHasPresenceIcon);
       
  1012             		    iButtonIconArray->Delete( EPresenceIconIndex );
       
  1013             		    }
       
  1014             	    }
       
  1015                 else if ( bitmap )
       
  1016                     {           	       	
       
  1017             	    if ( hasPresenceIcon )
       
  1018             		    {
       
  1019             		    // Update presence icon
       
  1020                 	    iButtonIconArray->At( EPresenceIconIndex )->SetBitmap(bitmap);
       
  1021                 	    iButtonIconArray->At( EPresenceIconIndex )->SetMask(mask);
       
  1022             		    }
       
  1023             	    else
       
  1024             		    { 
       
  1025             		    // Append presence icon to icon array
       
  1026                         CGulIcon* icon = CGulIcon::NewLC();
       
  1027                         icon->SetBitmap( bitmap );
       
  1028                         icon->SetMask( mask );
       
  1029                 	    iButtonIconArray->AppendL( icon );
       
  1030                 	    iButtonDataArray[ index ].iFlags |= TCommLauncherButtonData::EHasPresenceIcon;
       
  1031                 	    CleanupStack::Pop(); // icon
       
  1032             		    }
       
  1033                     }
       
  1034         		}
  1054             }
  1035             }
  1055         else
  1036         else
  1056             {
  1037             {
  1057             delete presData.Bitmap();
  1038             delete presData.Bitmap();
  1058             delete presData.Mask();
  1039             delete presData.Mask();
  1453     for ( TInt i = 0; i < services.Count(); i++ )
  1434     for ( TInt i = 0; i < services.Count(); i++ )
  1454         {
  1435         {
  1455         const CPbk2ServiceManager::TService& service = services[i];
  1436         const CPbk2ServiceManager::TService& service = services[i];
  1456         //Found the appropriate service info
  1437         //Found the appropriate service info
  1457         if ( service.iServiceId == aServiceId )
  1438         if ( service.iServiceId == aServiceId )
  1458             {
  1439             {          
  1459             // Get service bitmap size
       
  1460             TSize size = GetServiceBitmapSize();           
       
  1461 
       
  1462             // Set service bitmap size           
  1440             // Set service bitmap size           
  1463             AknIconUtils::SetSize( service.iBitmap, size );
  1441             AknIconUtils::SetSize( service.iBitmap, iServiceIconSize );
  1464             AknIconUtils::SetSize( service.iMask, size );
  1442             AknIconUtils::SetSize( service.iMask, iServiceIconSize );
  1465                
  1443                
  1466             //Trickiest Bitmap cloning
  1444             //Trickiest Bitmap cloning
  1467             //No direct way of cloning a bitmap
  1445             //No direct way of cloning a bitmap
  1468             aBitmap = CloneBitmapLC(size, service.iBitmap);
  1446             aBitmap = CloneBitmapLC( iServiceIconSize, service.iBitmap );
  1469             aMask = CloneBitmapLC(size, service.iMask);
  1447             aMask = CloneBitmapLC( iServiceIconSize, service.iMask );
  1470                        
  1448                        
  1471             aLocalisedServiceName = service.iDisplayName.AllocL(); 
  1449             aLocalisedServiceName = service.iDisplayName.AllocL(); 
  1472             
  1450             
  1473             CleanupStack::Pop( 2 ); //aBitmap, aMask
  1451             CleanupStack::Pop( 2 ); //aBitmap, aMask
  1474             break;
  1452             break;
  1475             }
  1453             }
  1476         }            
  1454         }            
  1477     }
  1455     }
  1478 
  1456 
  1479 // ---------------------------------------------------------------------------
  1457 // ---------------------------------------------------------------------------
  1480 // CCCAppCommLauncherLPadModel::GetServiceBitmapSize
  1458 // CCCAppCommLauncherLPadModel::CalculateLayoutSize()
  1481 // ---------------------------------------------------------------------------
  1459 // ---------------------------------------------------------------------------
  1482 //
  1460 //
  1483 TSize CCCAppCommLauncherLPadModel::GetServiceBitmapSize()
  1461 void CCCAppCommLauncherLPadModel::CalculateLayoutSize()
  1484     {     
  1462     {     
  1485     /*
  1463     /* Calculate the layout size for Voip service icon and presence icon.
  1486      * Calculate the rect of list_double_large_graphic_phob2_cc_pane_g1 
       
  1487      * and select its size as service bitmap size.
       
  1488      * Since the layoutRect is relative to the layoutRect of its parent, so 
  1464      * Since the layoutRect is relative to the layoutRect of its parent, so 
  1489      * we calculate from the topmost-mainPane, then follow below sequence:
  1465      * we calculate from the topmost-mainPane, then follow below sequence:
  1490      * phob2_contact_card_pane
  1466      * phob2_contact_card_pane
  1491      * phob2_cc_listscroll_pane
  1467      * phob2_cc_listscroll_pane
  1492      * phob2_cc_list_pane
  1468      * phob2_cc_list_pane
  1518     TAknLayoutRect listLayoutRect4;
  1494     TAknLayoutRect listLayoutRect4;
  1519     listLayoutRect4.LayoutRect(
  1495     listLayoutRect4.LayoutRect(
  1520             listLayoutRect3.Rect(),
  1496             listLayoutRect3.Rect(),
  1521             AknLayoutScalable_Apps::list_double_large_graphic_phob2_cc_pane_g1(0).LayoutLine() );
  1497             AknLayoutScalable_Apps::list_double_large_graphic_phob2_cc_pane_g1(0).LayoutLine() );
  1522     
  1498     
  1523     TSize size(listLayoutRect4.Rect().Size());   
  1499     TAknLayoutRect listLayoutRect5;
  1524     
  1500     listLayoutRect5.LayoutRect(
  1525     return size;                                                    
  1501             listLayoutRect3.Rect(),
       
  1502             AknLayoutScalable_Apps::list_double_large_graphic_phob2_cc_pane_g2(0).LayoutLine() );
       
  1503     
       
  1504     // Size for service icon
       
  1505     iServiceIconSize = listLayoutRect4.Rect().Size();
       
  1506     
       
  1507     // Size for presence icon
       
  1508     iPresenceIconSize = listLayoutRect5.Rect().Size(); 
  1526     }
  1509     }
  1527 // ---------------------------------------------------------------------------
  1510 // ---------------------------------------------------------------------------
  1528 // CCCAppCommLauncherLPadModel::HandleNotifyChange
  1511 // CCCAppCommLauncherLPadModel::HandleNotifyChange
  1529 // ---------------------------------------------------------------------------
  1512 // ---------------------------------------------------------------------------
  1530 //
  1513 //
  1682         aSubCellNumber);
  1665         aSubCellNumber);
  1683 }
  1666 }
  1684     return result;
  1667     return result;
  1685     }
  1668     }
  1686 
  1669 
       
  1670 // ----------------------------------------------------------
       
  1671 // CCCAppCommLauncherLPadModel::ResourceChangedL
       
  1672 // 
       
  1673 // ----------------------------------------------------------
       
  1674 void CCCAppCommLauncherLPadModel::ResourceChangedL()
       
  1675 	{
       
  1676 	// When layout variant changed, calculate the layout size which will be
       
  1677 	// used in listbox, eg: the size for service icon and presence icon
       
  1678 	CalculateLayoutSize();
       
  1679 	
       
  1680     LoadVoipButtonInfoL();
       
  1681 	}
       
  1682 	
  1687 // End of File
  1683 // End of File