phonebookui/Phonebook2/UIControls/src/CPbk2MemoryEntryDefaultsDlg.cpp
branchRCL_3
changeset 23 5586b4d2ec3e
parent 21 b3431bff8c19
child 45 34879f5cfc63
equal deleted inserted replaced
21:b3431bff8c19 23:5586b4d2ec3e
    32 #include <CPbk2FieldPropertyArray.h>
    32 #include <CPbk2FieldPropertyArray.h>
    33 #include <CPbk2StorePropertyArray.h>
    33 #include <CPbk2StorePropertyArray.h>
    34 #include <Phonebook2PrivateCRKeys.h>
    34 #include <Phonebook2PrivateCRKeys.h>
    35 #include <TPbk2DestructionIndicator.h>
    35 #include <TPbk2DestructionIndicator.h>
    36 #include <phonebook2ece.mbg>
    36 #include <phonebook2ece.mbg>
       
    37 #include <CPbk2ApplicationServices.h>
       
    38 #include <CPbk2ServiceManager.h>
       
    39 #include <MPbk2ApplicationServices.h>
       
    40 #include <ccappcommlauncherpluginrsc.rsg>
    37 
    41 
    38 // Virtual Phonebook
    42 // Virtual Phonebook
    39 #include <CVPbkContactManager.h>
    43 #include <CVPbkContactManager.h>
    40 #include <CVPbkDefaultAttribute.h>
    44 #include <CVPbkDefaultAttribute.h>
    41 #include <CVPbkFieldFilter.h>
    45 #include <CVPbkFieldFilter.h>
    56 #include <gulicon.h>
    60 #include <gulicon.h>
    57 #include <AknIconArray.h>
    61 #include <AknIconArray.h>
    58 #include <eikclbd.h>
    62 #include <eikclbd.h>
    59 #include <aknlists.h>
    63 #include <aknlists.h>
    60 #include <aknPopup.h>
    64 #include <aknPopup.h>
       
    65 #include <aknlayoutscalable_avkon.cdl.h>
       
    66 
       
    67 //SpSettings
       
    68 #include <spsettings.h>
       
    69 #include <spentry.h>
       
    70 #include <spproperty.h>
       
    71 
    61 
    72 
    62 // For checking mailbox accounts
    73 // For checking mailbox accounts
    63 #include <emailinterfacefactory.h>
    74 #include <emailinterfacefactory.h>
    64 #include <memailmailbox.h>
    75 #include <memailmailbox.h>
    65 
    76 
   480 // --------------------------------------------------------------------------
   491 // --------------------------------------------------------------------------
   481 //
   492 //
   482 inline CPbk2MemoryEntryDefaultsDlg::CPbk2MemoryEntryDefaultsDlg
   493 inline CPbk2MemoryEntryDefaultsDlg::CPbk2MemoryEntryDefaultsDlg
   483         ( CPbk2PresentationContact& aContact,
   494         ( CPbk2PresentationContact& aContact,
   484           CVPbkContactManager& aManager ):
   495           CVPbkContactManager& aManager ):
   485             iContact( aContact ), iManager( aManager ), iLVFlags( 0 )
   496             iContact( aContact ), iManager( aManager ), iLVFlags( 0 ), iServiceName( NULL )
   486     {
   497     {
   487     // Do nothing
   498     // Do nothing
   488     }
   499     }
   489 
   500 
   490 // --------------------------------------------------------------------------
   501 // --------------------------------------------------------------------------
   500         *iDestroyedPtr = ETrue;
   511         *iDestroyedPtr = ETrue;
   501         }
   512         }
   502     delete iListBox;
   513     delete iListBox;
   503     delete iAttributeProcess;
   514     delete iAttributeProcess;
   504     delete iDefaultsTable;
   515     delete iDefaultsTable;
       
   516     delete iServiceName;
   505 
   517 
   506     FeatureManager::UnInitializeLib();
   518     FeatureManager::UnInitializeLib();
   507 
   519 
   508     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
   520     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
   509         ("CPbk2MemoryEntryDefaultsDlg destructor end"));
   521         ("CPbk2MemoryEntryDefaultsDlg destructor end"));
   719             {
   731             {
   720             label.Set( *noDefault );
   732             label.Set( *noDefault );
   721             }
   733             }
   722 
   734 
   723         // Allocate and format the listbox line
   735         // Allocate and format the listbox line
   724         HBufC* lineBuf = HBufC::NewLC( KFormat().Length()
   736         HBufC* lineBuf = NULL;
   725             + defaultFieldText->Length() + label.Length() );
   737         // If only one Voip service avaliable, use voip service name on internet call item
   726         TPtr line( lineBuf->Des() );
   738         if ( iServiceName && 
   727         
   739         		( iDefaultsTable->At( idx ) == VPbkFieldTypeSelectorFactory::EVOIPCallSelector ) )
   728         // Important: iconArray positions matchs with 
   740         	{
   729         // iDefaultsTable positions. idx -> icon position
   741         	// Use Voip service name
   730         line.Format( KFormat, idx, defaultFieldText, &label);
   742             HBufC* str = StringLoader::LoadLC( R_QTN_CCA_VOIP_CALL_WITH_SERVICENAME, 
   731         
   743                         *iServiceName,             
   732         lines->AppendL( line ) ;
   744                         iCoeEnv );
       
   745         	lineBuf = HBufC::NewLC( KFormat().Length()
       
   746         	            + str->Length() + label.Length() );
       
   747         	TPtr line( lineBuf->Des() );
       
   748         	line.Format( KFormat, idx, str, &label);
       
   749         	lines->AppendL( line ) ;
       
   750         	CleanupStack::PopAndDestroy(2); // lineBuf, str
       
   751         	}
       
   752         else
       
   753         	{
       
   754         	// Use default text
       
   755         	lineBuf = HBufC::NewLC( KFormat().Length()
       
   756         	            + defaultFieldText->Length() + label.Length() );
       
   757         	TPtr line( lineBuf->Des() );
       
   758         	line.Format( KFormat, idx, defaultFieldText, &label);
       
   759         	lines->AppendL( line ) ;
       
   760         	CleanupStack::PopAndDestroy(); // lineBuf
       
   761         	}
   733         
   762         
   734         // Cleanup
   763         // Cleanup
   735         CleanupStack::PopAndDestroy( 2 ); // lineBuf, defaultFieldText        
   764         CleanupStack::PopAndDestroy(); // defaultFieldText        
   736         }
   765         }
   737    
   766    
   738     CleanupStack::PopAndDestroy(); // noDefault
   767     CleanupStack::PopAndDestroy(); // noDefault
   739     }
   768     }
   740 
   769 
   926         
   955         
   927         // Important: iconArray positions matchs
   956         // Important: iconArray positions matchs
   928         // with iDefaultsTable positions
   957         // with iDefaultsTable positions
   929         iconArray->AppendL( icon );
   958         iconArray->AppendL( icon );
   930         
   959         
       
   960         // If only one Voip service avaliable, use brand icon on internet call item
       
   961         TServiceId serviceId;
       
   962         if ( ( iDefaultsTable->At( idx ) == VPbkFieldTypeSelectorFactory::EVOIPCallSelector ) &&
       
   963         		( SupportedVOIPServicesL( serviceId ) == 1 ) )
       
   964         	{
       
   965             CFbsBitmap* bitmap (NULL);
       
   966             CFbsBitmap* mask (NULL);
       
   967 
       
   968             // Load Voip brand bitmap and mask              
       
   969             LoadVoipServiceInfoL( serviceId, bitmap, mask );
       
   970             
       
   971             if ( bitmap || mask )
       
   972                 {          
       
   973                 iconArray->At(idx)->SetBitmap(bitmap);
       
   974                 iconArray->At(idx)->SetMask(mask);
       
   975                 }
       
   976         	}
       
   977         
   931         CleanupStack::Pop(1); // icon
   978         CleanupStack::Pop(1); // icon
   932         }  
   979         }  
   933     // iListBox takes ownership of iconArray
   980     // iListBox takes ownership of iconArray
   934     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
   981     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
   935     CleanupStack::Pop(1); // iconArray
   982     CleanupStack::Pop(1); // iconArray
  1053         ( aSelectorID, *defaultProperties );
  1100         ( aSelectorID, *defaultProperties );
  1054     CleanupStack::Pop( defaultProperties );
  1101     CleanupStack::Pop( defaultProperties );
  1055     iAttributeProcess->RemoveDefaultsL( defaultProperties );
  1102     iAttributeProcess->RemoveDefaultsL( defaultProperties );
  1056     }
  1103     }
  1057 
  1104 
       
  1105 // --------------------------------------------------------------------------
       
  1106 // CPbk2MemoryEntryDefaultsDlg::SupportedVOIPServicesL
       
  1107 // Get supported Voip services
       
  1108 // --------------------------------------------------------------------------
       
  1109 //
       
  1110 TInt CPbk2MemoryEntryDefaultsDlg::SupportedVOIPServicesL( TServiceId& aServiceId )
       
  1111     {   
       
  1112     TInt availableVoipService = 0;    
       
  1113     RIdArray idArray;
       
  1114     CleanupClosePushL(idArray);
       
  1115     
       
  1116     CSPSettings* settings = CSPSettings::NewL();
       
  1117     CleanupStack::PushL( settings );
       
  1118     
       
  1119     User::LeaveIfError( settings->FindServiceIdsL(idArray) ); 
       
  1120     
       
  1121     const TInt count = idArray.Count();   
       
  1122     for (TInt i = 0; i < count; ++i)
       
  1123         {
       
  1124         TBool supported( EFalse );
       
  1125         CSPEntry* entry = CSPEntry::NewLC();
       
  1126         TServiceId id = idArray[i];
       
  1127         User::LeaveIfError( settings->FindEntryL(id, *entry) );
       
  1128         const CSPProperty* property = NULL;
       
  1129         
       
  1130         if (entry->GetProperty(property, EPropertyServiceAttributeMask) == KErrNone)
       
  1131             {
       
  1132             TInt value = 0;
       
  1133             property->GetValue(value);
       
  1134             supported = value & ESupportsInternetCall; 
       
  1135             }
       
  1136         
       
  1137         if ( supported )
       
  1138             {
       
  1139             availableVoipService++;            
       
  1140             aServiceId = id;
       
  1141             }
       
  1142         CleanupStack::PopAndDestroy(); // entry
       
  1143         }
       
  1144     CleanupStack::PopAndDestroy(2); // settings, idArray    
       
  1145     
       
  1146     return availableVoipService;
       
  1147     }
       
  1148 
       
  1149 // ---------------------------------------------------------------------------
       
  1150 // CPbk2MemoryEntryDefaultsDlg::LoadVoipServiceInfoL
       
  1151 // Load Voip service info
       
  1152 // ---------------------------------------------------------------------------
       
  1153 //
       
  1154 void CPbk2MemoryEntryDefaultsDlg::LoadVoipServiceInfoL( 
       
  1155             TServiceId aServiceId,
       
  1156             CFbsBitmap*& aBitmap, CFbsBitmap*& aMask )
       
  1157     {   
       
  1158     CPbk2ApplicationServices* appServices =
       
  1159         CPbk2ApplicationServices::InstanceLC();
       
  1160     
       
  1161     CPbk2ServiceManager& servMan = appServices->ServiceManager();
       
  1162     const CPbk2ServiceManager::RServicesArray& services = servMan.Services();
       
  1163     
       
  1164     const TInt count = services.Count();   
       
  1165     for ( TInt i = 0; i < count; i++ )
       
  1166         {
       
  1167         const CPbk2ServiceManager::TService& service = services[i];
       
  1168 
       
  1169         if ( service.iServiceId == aServiceId )
       
  1170             {
       
  1171             // Calculate preferred size for xsp service icon 
       
  1172             TRect mainPane;
       
  1173             AknLayoutUtils::LayoutMetricsRect(
       
  1174                 AknLayoutUtils::EMainPane, mainPane );
       
  1175             TAknLayoutRect listLayoutRect;
       
  1176             listLayoutRect.LayoutRect(
       
  1177                 mainPane,
       
  1178                 AknLayoutScalable_Avkon::list_double_large_graphic_pane_g1(0).LayoutLine() );
       
  1179             TSize size(listLayoutRect.Rect().Size());
       
  1180             
       
  1181             AknIconUtils::SetSize(
       
  1182                     service.iBitmap,
       
  1183                     size );
       
  1184             AknIconUtils::SetSize(
       
  1185                     service.iMask,
       
  1186                     size );                               
       
  1187     		
       
  1188             aBitmap = new (ELeave) CFbsBitmap;
       
  1189             CleanupStack::PushL( aBitmap );
       
  1190             aBitmap->Duplicate( service.iBitmap->Handle() );
       
  1191             
       
  1192             aMask = new (ELeave) CFbsBitmap;
       
  1193             CleanupStack::PushL( aMask );
       
  1194             aMask->Duplicate( service.iMask->Handle() );                    
       
  1195                      
       
  1196             iServiceName = service.iDisplayName.AllocL();
       
  1197             CleanupStack::Pop( 2 ); // aMask, aBitmap
       
  1198             
       
  1199             break;
       
  1200             }
       
  1201         }
       
  1202     CleanupStack::PopAndDestroy(); // appServices
       
  1203     }
       
  1204 
  1058 //  End of File
  1205 //  End of File