phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherlpadmodel.cpp
branchRCL_3
changeset 21 b3431bff8c19
parent 15 e8e3147d53eb
child 23 5586b4d2ec3e
equal deleted inserted replaced
15:e8e3147d53eb 21:b3431bff8c19
    21 
    21 
    22 #include <CPbk2ApplicationServices.h>
    22 #include <CPbk2ApplicationServices.h>
    23 #include <CPbk2ServiceManager.h>
    23 #include <CPbk2ServiceManager.h>
    24 
    24 
    25 #include <aknlayoutscalable_avkon.cdl.h>
    25 #include <aknlayoutscalable_avkon.cdl.h>
       
    26 #include <aknlayoutscalable_apps.cdl.h>
    26 //SpSettings
    27 //SpSettings
    27 #include <spsettings.h>
    28 #include <spsettings.h>
    28 #include <spentry.h>
    29 #include <spentry.h>
    29 #include <mnproviderfinder.h>
    30 #include <mnproviderfinder.h>
    30 #include <StringLoader.h>
    31 #include <StringLoader.h>
   113         }
   114         }
   114 
   115 
   115     CleanupStack::PopAndDestroy(2); // idArray, settings
   116     CleanupStack::PopAndDestroy(2); // idArray, settings
   116     return result;
   117     return result;
   117     }
   118     }
       
   119 
       
   120 
       
   121 /**
       
   122  * Returns index of a first VOIP field.
       
   123  */
       
   124 TInt SelectVOIPIndexL(const CCmsContactField& aContactField)
       
   125     {
       
   126     TInt result = 0; // by default returns 0
       
   127     CSPSettings* settings = CSPSettings::NewLC();
       
   128     RIdArray idArray;
       
   129     TBool found = EFalse;
       
   130     CleanupClosePushL(idArray);
       
   131 
       
   132     TInt error = settings->FindServiceIdsL(idArray);
       
   133     if (error == KErrNone)
       
   134         {
       
   135         for (TInt i = 0; !found && i < idArray.Count(); ++i)
       
   136             {
       
   137             CSPEntry* entry = CSPEntry::NewLC();
       
   138             settings->FindEntryL(idArray[i], *entry);
       
   139 
       
   140             const CSPProperty* prop = NULL;
       
   141             
       
   142             if (entry->GetProperty(prop, EPropertyServiceAttributeMask) == KErrNone)
       
   143                 {
       
   144                 TInt value = 0;
       
   145                 prop->GetValue(value);
       
   146                 
       
   147                 if ( value & ESupportsInternetCall )
       
   148                     {
       
   149                     for (TInt i = 0; i < aContactField.ItemCount(); ++i)
       
   150                                         {
       
   151                         const CCmsContactFieldItem& item = aContactField.ItemL(i);
       
   152                         TPtrC data = item.Data();
       
   153                         TPtrC scheme = ParseService(data);
       
   154                         if (CompareService(*entry, scheme))
       
   155                             {
       
   156                             result = i;
       
   157                             found = ETrue;
       
   158                             break;
       
   159                             }
       
   160                         }
       
   161                     }
       
   162                 }                       
       
   163             CleanupStack::PopAndDestroy(); // entry
       
   164             }
       
   165         }
       
   166 
       
   167     CleanupStack::PopAndDestroy(2); // idArray, settings
       
   168     return result;
       
   169     }
       
   170 
       
   171 
   118 /**
   172 /**
   119  * Clones the Bitmap
   173  * Clones the Bitmap
   120  * This is better than Duplicating the bitmap
   174  * This is better than Duplicating the bitmap
   121  */
   175  */
   122 CFbsBitmap* CloneBitmapLC(TSize aSize, CFbsBitmap* aBitmap)
   176 CFbsBitmap* CloneBitmapLC(TSize aSize, CFbsBitmap* aBitmap)
   271         tempText.Append( KColumnListSeparator );  
   325         tempText.Append( KColumnListSeparator );  
   272         if( textPtr.Length() + tempText.Length() >=
   326         if( textPtr.Length() + tempText.Length() >=
   273                 KCCAppCommLauncherMaxButtonDataTextLength )
   327                 KCCAppCommLauncherMaxButtonDataTextLength )
   274             {
   328             {
   275             tempText.Append( textPtr.Left(
   329             tempText.Append( textPtr.Left(
   276                KCCAppCommLauncherMaxButtonDataTextLength - tempText.Length() - 1 ) );
   330                KCCAppCommLauncherMaxButtonDataTextLength - tempText.Length() - 4 ) );
   277             }
   331             }
   278         else
   332         else
   279             {
   333             {
   280             tempText.Append( textPtr );
   334             tempText.Append( textPtr );
   281             }
   335             }
       
   336         tempText.Append( KColumnListSeparator ); 
       
   337 		
   282         // TODO: Check presence icon
   338         // TODO: Check presence icon
   283         tempText.Append( KColumnListSeparator ); 
   339         tempText.Append( KColumnListSeparator ); 
   284         
   340         
   285         // Check if show multi icon at the right end of second row
   341         // Check if show multi icon at the right end of second row
   286         if ( IfShowMultiIcon( aIndex ) )
   342         if ( IfShowMultiIcon( aIndex ) )
   287         	{
   343         	{
   288         	tempText.AppendNum( EMultiIconIndex );
   344         	tempText.AppendNum( EMultiIconIndex );
   289         	tempText.Append( KColumnListSeparator );  
       
   290         	}  
   345         	}  
   291         }
   346         }
   292 
   347 
   293     return tempText;
   348     return tempText;
   294     }
   349     }
   672                 // fields. Need to filter out voip fields in case of IM
   727                 // fields. Need to filter out voip fields in case of IM
   673                 // commmunication type             
   728                 // commmunication type             
   674                 index = SelectIMIndexL(aContactField);
   729                 index = SelectIMIndexL(aContactField);
   675                 }
   730                 }
   676             
   731             
       
   732             if ( VPbkFieldTypeSelectorFactory::EVOIPCallSelector == aContactAction )
       
   733                 {
       
   734                 index = SelectVOIPIndexL( aContactField );
       
   735                 }
       
   736                 
   677             if ( aContactAction == VPbkFieldTypeSelectorFactory::EUniEditorSelector 
   737             if ( aContactAction == VPbkFieldTypeSelectorFactory::EUniEditorSelector 
   678                 && buttonData.iPopupText.Length() > 0 
   738                 && buttonData.iPopupText.Length() > 0 
   679                 && aContactField.Type() != CCmsContactFieldItem::ECmsMobilePhoneGeneric
   739                 && aContactField.Type() != CCmsContactFieldItem::ECmsMobilePhoneGeneric
   680                 && aContactField.Type() != CCmsContactFieldItem::ECmsMobilePhoneHome
   740                 && aContactField.Type() != CCmsContactFieldItem::ECmsMobilePhoneHome
   681                 && aContactField.Type() != CCmsContactFieldItem::ECmsMobilePhoneWork )
   741                 && aContactField.Type() != CCmsContactFieldItem::ECmsMobilePhoneWork )
   688                 buttonData.iPopupText.Append(
   748                 buttonData.iPopupText.Append(
   689                     aContactField.ItemL( index ).Data().Left(
   749                     aContactField.ItemL( index ).Data().Left(
   690                         KCCAppCommLauncherMaxButtonDataTextLength ));
   750                         KCCAppCommLauncherMaxButtonDataTextLength ));
   691                 }
   751                 }
   692             }
   752             }
   693         }
   753         
       
   754         if( IsPhoneNumber( aContactField ) )
       
   755             {
       
   756             AknTextUtils::DisplayTextLanguageSpecificNumberConversion( buttonData.iPopupText );
       
   757             }
       
   758         
       
   759         }
       
   760     }
       
   761 
       
   762 // ---------------------------------------------------------------------------
       
   763 // CCCAppCommLauncherLPadModel::IsPhoneNumber
       
   764 // ---------------------------------------------------------------------------
       
   765 //
       
   766 TBool CCCAppCommLauncherLPadModel::IsPhoneNumber( const CCmsContactField& aContactField )
       
   767     {
       
   768     TBool isPhoneNumber = EFalse;
       
   769 
       
   770     switch( aContactField.Type() )
       
   771         {
       
   772         case CCmsContactFieldItem::ECmsLandPhoneGeneric:
       
   773         case CCmsContactFieldItem::ECmsLandPhoneHome:
       
   774         case CCmsContactFieldItem::ECmsGroupVoice:
       
   775         case CCmsContactFieldItem::ECmsAssistantNumber:
       
   776         case CCmsContactFieldItem::ECmsDefaultTypePhoneNumber:
       
   777         case CCmsContactFieldItem::ECmsFaxNumberHome:
       
   778         case CCmsContactFieldItem::ECmsFaxNumberWork:
       
   779         case CCmsContactFieldItem::ECmsMobilePhoneGeneric:
       
   780         case CCmsContactFieldItem::ECmsMobilePhoneHome:
       
   781         case CCmsContactFieldItem::ECmsMobilePhoneWork:
       
   782         case CCmsContactFieldItem::ECmsVideoNumberGeneric:
       
   783         case CCmsContactFieldItem::ECmsVideoNumberHome:
       
   784         case CCmsContactFieldItem::ECmsVideoNumberWork:
       
   785         case CCmsContactFieldItem::ECmsVoipNumberGeneric:
       
   786         case CCmsContactFieldItem::ECmsVoipNumberHome:
       
   787         case CCmsContactFieldItem::ECmsVoipNumberWork:
       
   788         case CCmsContactFieldItem::ECmsCarPhone:
       
   789         case CCmsContactFieldItem::ECmsPagerNumber:
       
   790             isPhoneNumber = ETrue;
       
   791             break;
       
   792         default:
       
   793             isPhoneNumber = EFalse;
       
   794             break;
       
   795         }
       
   796 
       
   797     return isPhoneNumber;
   694     }
   798     }
   695 
   799 
   696 // ---------------------------------------------------------------------------
   800 // ---------------------------------------------------------------------------
   697 // CCCAppCommLauncherLPadModel::LoadIconArrayL
   801 // CCCAppCommLauncherLPadModel::LoadIconArrayL
   698 // ---------------------------------------------------------------------------
   802 // ---------------------------------------------------------------------------
   772 CGulIcon* CCCAppCommLauncherLPadModel::LoadIconLC( TInt aBmpId, TInt aMaskId )
   876 CGulIcon* CCCAppCommLauncherLPadModel::LoadIconLC( TInt aBmpId, TInt aMaskId )
   773     {
   877     {
   774     CFbsBitmap* bmp = NULL;
   878     CFbsBitmap* bmp = NULL;
   775     CFbsBitmap* mask = NULL;
   879     CFbsBitmap* mask = NULL;
   776     CGulIcon* icon = CGulIcon::NewLC();
   880     CGulIcon* icon = CGulIcon::NewLC();
   777 
   881    
   778     AknIconUtils::CreateIconLC(
   882     // The color of Icon "many items" should be adjusted to the theme background
   779         bmp, mask, KPbk2ECEIconFileName, aBmpId, aMaskId );
   883     if( EMbmPhonebook2eceQgn_indi_many_items_add == aBmpId)
   780 
   884         {
       
   885         TAknsItemID skin; 
       
   886         skin.Set( EAknsMajorGeneric,  EAknsMinorGenericQgnIndiManyItemsAdd );
       
   887         TAknsItemID color;
       
   888         color.Set( EAknsMajorSkin, EAknsMinorQsnIconColors );
       
   889     
       
   890         AknsUtils::CreateColorIconLC(
       
   891             AknsUtils::SkinInstance(),skin,
       
   892             color, EAknsCIQsnIconColorsCG13,
       
   893             bmp, mask,
       
   894             KPbk2ECEIconFileName,
       
   895             aBmpId, aMaskId,
       
   896             AKN_LAF_COLOR_STATIC( 215 ) );
       
   897         }
       
   898     else
       
   899         {
       
   900         AknIconUtils::CreateIconLC(
       
   901             bmp, mask, KPbk2ECEIconFileName, aBmpId, aMaskId );
       
   902         }
       
   903    
   781     icon->SetBitmap( bmp );
   904     icon->SetBitmap( bmp );
   782     icon->SetMask( mask );
   905     icon->SetMask( mask );
   783     CleanupStack::Pop( 2 ); // bmp, mask
   906     CleanupStack::Pop( 2 ); // bmp, mask
   784 
   907 
   785     return icon;
   908     return icon;
  1331         {
  1454         {
  1332         const CPbk2ServiceManager::TService& service = services[i];
  1455         const CPbk2ServiceManager::TService& service = services[i];
  1333         //Found the appropriate service info
  1456         //Found the appropriate service info
  1334         if ( service.iServiceId == aServiceId )
  1457         if ( service.iServiceId == aServiceId )
  1335             {
  1458             {
  1336             //Calculate the Size of the Bitmap for Comm Launcher
  1459             // Get service bitmap size
  1337             TRect mainPane = iPlugin.ClientRect();                            
  1460             TSize size = GetServiceBitmapSize();           
  1338             TAknLayoutRect listLayoutRect;
  1461 
  1339                 listLayoutRect.LayoutRect(
  1462             // Set service bitmap size           
  1340                     mainPane,
       
  1341                     AknLayoutScalable_Avkon::list_single_large_graphic_pane_g1(0).LayoutLine() );
       
  1342             TSize size(listLayoutRect.Rect().Size());
       
  1343                         
       
  1344             //Set the size of this bitmap.
       
  1345             //without this Cloning of bitmap will not happen            
       
  1346             AknIconUtils::SetSize( service.iBitmap, size );
  1463             AknIconUtils::SetSize( service.iBitmap, size );
  1347             AknIconUtils::SetSize( service.iMask, size );
  1464             AknIconUtils::SetSize( service.iMask, size );
  1348                
  1465                
  1349             //Trickiest Bitmap cloning
  1466             //Trickiest Bitmap cloning
  1350             //No direct way of cloning a bitmap
  1467             //No direct way of cloning a bitmap
  1351             aBitmap = CloneBitmapLC(size, service.iBitmap);
  1468             aBitmap = CloneBitmapLC(size, service.iBitmap);
  1352             aMask = CloneBitmapLC(size, service.iMask);
  1469             aMask = CloneBitmapLC(size, service.iMask);
  1353             
  1470                        
  1354             //Calculate preferred size for xsp service icons
       
  1355             AknLayoutUtils::LayoutMetricsRect(
       
  1356                 AknLayoutUtils::EMainPane, mainPane );            
       
  1357             listLayoutRect.LayoutRect(
       
  1358                 mainPane,
       
  1359                 AknLayoutScalable_Avkon::list_single_graphic_pane_g2(0).LayoutLine() );
       
  1360             TSize xspIconSize(listLayoutRect.Rect().Size()); 
       
  1361             AknIconUtils::SetSize( service.iBitmap, xspIconSize );
       
  1362             AknIconUtils::SetSize( service.iMask, xspIconSize );
       
  1363             
       
  1364             aLocalisedServiceName = service.iDisplayName.AllocL(); 
  1471             aLocalisedServiceName = service.iDisplayName.AllocL(); 
  1365             
  1472             
  1366             CleanupStack::Pop( 2 ); //aBitmap, aMask
  1473             CleanupStack::Pop( 2 ); //aBitmap, aMask
  1367             break;
  1474             break;
  1368             }
  1475             }
  1369         }            
  1476         }            
  1370     }
  1477     }
  1371 
  1478 
  1372 
  1479 // ---------------------------------------------------------------------------
       
  1480 // CCCAppCommLauncherLPadModel::GetServiceBitmapSize
       
  1481 // ---------------------------------------------------------------------------
       
  1482 //
       
  1483 TSize CCCAppCommLauncherLPadModel::GetServiceBitmapSize()
       
  1484     {     
       
  1485     /*
       
  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 
       
  1489      * we calculate from the topmost-mainPane, then follow below sequence:
       
  1490      * phob2_contact_card_pane
       
  1491      * phob2_cc_listscroll_pane
       
  1492      * phob2_cc_list_pane
       
  1493      * list_double_large_graphic_phob2_cc_pane
       
  1494      * list_double_large_graphic_phob2_cc_pane_g1
       
  1495      */
       
  1496     TRect mainPane = iPlugin.ClientRect();
       
  1497     
       
  1498     TAknLayoutRect listLayoutRect0;
       
  1499     listLayoutRect0.LayoutRect(
       
  1500             mainPane,
       
  1501             AknLayoutScalable_Apps::phob2_contact_card_pane(0).LayoutLine() );
       
  1502     
       
  1503     TAknLayoutRect listLayoutRect1;
       
  1504     listLayoutRect1.LayoutRect(
       
  1505     		listLayoutRect0.Rect(),
       
  1506             AknLayoutScalable_Apps::phob2_cc_listscroll_pane(0).LayoutLine() );
       
  1507     
       
  1508     TAknLayoutRect listLayoutRect2;
       
  1509     listLayoutRect2.LayoutRect(
       
  1510     		listLayoutRect1.Rect(),
       
  1511     		AknLayoutScalable_Apps::phob2_cc_list_pane(0).LayoutLine() );
       
  1512     
       
  1513     TAknLayoutRect listLayoutRect3;
       
  1514     listLayoutRect3.LayoutRect(
       
  1515     		listLayoutRect2.Rect(),
       
  1516     		AknLayoutScalable_Apps::list_double_large_graphic_phob2_cc_pane(0).LayoutLine() );
       
  1517             
       
  1518     TAknLayoutRect listLayoutRect4;
       
  1519     listLayoutRect4.LayoutRect(
       
  1520             listLayoutRect3.Rect(),
       
  1521             AknLayoutScalable_Apps::list_double_large_graphic_phob2_cc_pane_g1(0).LayoutLine() );
       
  1522     
       
  1523     TSize size(listLayoutRect4.Rect().Size());   
       
  1524     
       
  1525     return size;                                                    
       
  1526     }
  1373 // ---------------------------------------------------------------------------
  1527 // ---------------------------------------------------------------------------
  1374 // CCCAppCommLauncherLPadModel::HandleNotifyChange
  1528 // CCCAppCommLauncherLPadModel::HandleNotifyChange
  1375 // ---------------------------------------------------------------------------
  1529 // ---------------------------------------------------------------------------
  1376 //
  1530 //
  1377 // from MSPNotifyChangeObserver
  1531 // from MSPNotifyChangeObserver