969 { |
969 { |
970 CCmsPresenceData& presData = ( CCmsPresenceData& )aContactField.ItemL( i ); |
970 CCmsPresenceData& presData = ( CCmsPresenceData& )aContactField.ItemL( i ); |
971 presData.PreparePresenceDataL( iPresenceIconSize ); |
971 presData.PreparePresenceDataL( iPresenceIconSize ); |
972 TUint32 serviceType = presData.ServiceType(); |
972 TUint32 serviceType = presData.ServiceType(); |
973 |
973 |
974 // The ownerships of mask and bitmap are transferred to this object. |
|
975 CFbsBitmap* mask = presData.Mask(); |
|
976 CFbsBitmap* bitmap = presData.Bitmap(); |
|
977 TBool isValidBitmap = !( bitmap && ( NULL == bitmap->Handle() ) ); |
|
978 |
|
979 // If any one of below condition is satisfied, the bitmap and mask are invalid. |
|
980 // Delete them since the ownerships of them are transferred to this object. |
|
981 if ( !isValidBitmap || serviceType != CCmsContactFieldItem::ECmsPresenceChatNotification ) |
|
982 { |
|
983 delete mask; |
|
984 delete bitmap; |
|
985 } |
|
986 |
|
987 if ( serviceType == CCmsContactFieldItem::ECmsPresenceChatNotification ) |
974 if ( serviceType == CCmsContactFieldItem::ECmsPresenceChatNotification ) |
988 { |
975 { |
|
976 CFbsBitmap* mask = presData.Mask(); |
|
977 CFbsBitmap* bitmap = presData.Bitmap(); |
|
978 |
989 // Find the index for chat item |
979 // Find the index for chat item |
990 TInt index = KErrNotFound; |
980 TInt index = KErrNotFound; |
991 const TInt dataCount = iButtonDataArray.Count(); |
981 const TInt dataCount = iButtonDataArray.Count(); |
992 for ( TInt i = 0; i < dataCount; i++ ) |
982 for ( TInt i = 0; i < dataCount; i++ ) |
993 { |
983 { |
1002 if ( index != KErrNotFound ) |
992 if ( index != KErrNotFound ) |
1003 { |
993 { |
1004 TBool hasPresenceIcon = iButtonDataArray[ index ].iFlags & |
994 TBool hasPresenceIcon = iButtonDataArray[ index ].iFlags & |
1005 TCommLauncherButtonData::EHasPresenceIcon; |
995 TCommLauncherButtonData::EHasPresenceIcon; |
1006 |
996 |
1007 if ( hasPresenceIcon ) |
997 if ( bitmap && ( NULL == bitmap->Handle() ) ) |
1008 { |
998 { |
1009 if ( isValidBitmap ) |
999 if ( hasPresenceIcon ) |
1010 { |
1000 { |
1011 // Update presence icon |
1001 // Delete presence icon from icon array |
1012 iButtonIconArray->At( EPresenceIconIndex )->SetBitmap(bitmap); |
1002 iButtonDataArray[ index ].iFlags &= ~(TCommLauncherButtonData::EHasPresenceIcon); |
1013 iButtonIconArray->At( EPresenceIconIndex )->SetMask(mask); |
1003 iButtonIconArray->Delete( EPresenceIconIndex ); |
1014 } |
1004 } |
1015 else |
|
1016 { |
|
1017 // Delete presence icon from icon array |
|
1018 iButtonDataArray[ index ].iFlags &= ~(TCommLauncherButtonData::EHasPresenceIcon); |
|
1019 CGulIcon* icon = iButtonIconArray->At( EPresenceIconIndex ); |
|
1020 delete icon; |
|
1021 iButtonIconArray->Delete( EPresenceIconIndex ); |
|
1022 } |
|
1023 } |
1005 } |
1024 else if ( isValidBitmap ) |
1006 else if ( bitmap ) |
1025 { |
1007 { |
1026 // Append presence icon to icon array |
1008 if ( hasPresenceIcon ) |
1027 CGulIcon* icon = CGulIcon::NewLC(); |
1009 { |
1028 icon->SetBitmap( bitmap ); |
1010 // Update presence icon |
1029 icon->SetMask( mask ); |
1011 iButtonIconArray->At( EPresenceIconIndex )->SetBitmap(bitmap); |
1030 iButtonIconArray->AppendL( icon ); |
1012 iButtonIconArray->At( EPresenceIconIndex )->SetMask(mask); |
1031 iButtonDataArray[ index ].iFlags |= TCommLauncherButtonData::EHasPresenceIcon; |
1013 } |
1032 CleanupStack::Pop(); // icon |
1014 else |
1033 } |
1015 { |
|
1016 // Append presence icon to icon array |
|
1017 CGulIcon* icon = CGulIcon::NewLC(); |
|
1018 icon->SetBitmap( bitmap ); |
|
1019 icon->SetMask( mask ); |
|
1020 iButtonIconArray->AppendL( icon ); |
|
1021 iButtonDataArray[ index ].iFlags |= TCommLauncherButtonData::EHasPresenceIcon; |
|
1022 CleanupStack::Pop(); // icon |
|
1023 } |
|
1024 } |
1034 } |
1025 } |
|
1026 } |
|
1027 else |
|
1028 { |
|
1029 delete presData.Bitmap(); |
|
1030 delete presData.Mask(); |
1035 } |
1031 } |
1036 } |
1032 } |
1037 } |
1033 } |
1038 |
1034 |
1039 // --------------------------------------------------------------------------- |
1035 // --------------------------------------------------------------------------- |