profilesservices/ProfileEngine/EngSrc/CProfileImpl.cpp
branchRCL_3
changeset 24 8ee96d21d9bf
parent 8 f62c3a3d66b8
child 25 7e0eff37aedb
equal deleted inserted replaced
23:8bda91a87a00 24:8ee96d21d9bf
    17 
    17 
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include "CProfileImpl.h"
    21 #include "CProfileImpl.h"
       
    22 #include "CProfileNameImpl.h"
       
    23 #include "CProfileTonesImpl.h"
       
    24 #include "CProfileExtraTonesImpl.h"
       
    25 #include "CProfileExtraSettingsImpl.h"
       
    26 #include "CProfilePresenceImpl.h"
       
    27 #include "ProfileEngUtils.h"
       
    28 #include "ProfileEnginePrivateCRKeys.h"
    22 #include <e32svr.h>
    29 #include <e32svr.h>
    23 #include <cntitem.h>
    30 #include <cntitem.h>
    24 #include <CPbkContactEngine.h>
       
    25 #include <cntdb.h>
    31 #include <cntdb.h>
    26 #include <cntdef.h>
    32 #include <cntdef.h>
    27 #include <TProfileToneSettings.h>
    33 #include <TProfileToneSettings.h>
    28 #include <MProfilePttSettings.h>
    34 #include <MProfilePttSettings.h>
    29 #include <featmgr.h>
    35 #include <featmgr.h>
    30 #include <bldvariant.hrh>
    36 #include <bldvariant.hrh>
    31 #include <RSSSettings.h>
    37 #include <rsssettings.h>
    32 #include <pathinfo.h>
    38 #include <pathinfo.h>
    33 #include "CProfileNameImpl.h"
       
    34 #include "CProfileTonesImpl.h"
       
    35 #include "CProfileExtraTonesImpl.h"
       
    36 #include "CProfileExtraSettingsImpl.h"
       
    37 #include "CProfilePresenceImpl.h"
       
    38 #include <MProfilesLocalFeatures.h>
    39 #include <MProfilesLocalFeatures.h>
    39 #include <MProfileUtilitySingleton.h>
    40 #include <MProfileUtilitySingleton.h>
    40 #include "ProfilesVariant.hrh"
    41 #include <ProfilesVariant.hrh>
    41 #include "ProfileEngUtils.h"
       
    42 #include "ProfileEnginePrivateCRKeys.h"
       
    43 #include <ProfileEngineDomainConstants.h>
    42 #include <ProfileEngineDomainConstants.h>
       
    43 #include "CProfileVibraSettingsImpl.h"
    44 
    44 
    45 // CONSTANTS
    45 // CONSTANTS
    46 // Max. number of Alert for groups:
    46 // Max. number of Alert for groups:
    47 const TInt KProfilesMaxAlertForGroups = 512;
    47 const TInt KProfilesMaxAlertForGroups = 512;
    48 const TInt KProfilesMaxFlagsLength = 4;
    48 const TInt KProfilesMaxFlagsLength = 4;
    76     iProfileExtraTones = CProfileExtraTonesImpl::NewL();
    76     iProfileExtraTones = CProfileExtraTonesImpl::NewL();
    77     iProfilePresence = CProfilePresenceImpl::NewL();
    77     iProfilePresence = CProfilePresenceImpl::NewL();
    78     // ProfileUtility must be released in destructor:
    78     // ProfileUtility must be released in destructor:
    79     iFeatures = &( ProfileUtilityInstanceL().ProfilesLocalFeatures() );
    79     iFeatures = &( ProfileUtilityInstanceL().ProfilesLocalFeatures() );
    80     iProfileExtraSettings = CProfileExtraSettingsImpl::NewL();
    80     iProfileExtraSettings = CProfileExtraSettingsImpl::NewL();
       
    81     iProfileVibraSettings = CProfileVibraSettingsImpl::NewL();
    81     }
    82     }
    82 
    83 
    83 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    84 // CProfileImpl::ConstructL
    85 // CProfileImpl::ConstructL
    85 // Symbian 2nd phase constructor can leave.
    86 // Symbian 2nd phase constructor can leave.
    86 // -----------------------------------------------------------------------------
    87 // -----------------------------------------------------------------------------
    87 //
    88 //
    88 void CProfileImpl::ConstructL(
    89 void CProfileImpl::ConstructL(
    89     const MProfileExtended& aProfile,
    90     const MProfileExtended2& aProfile,
    90     TInt aId )
    91     TInt aId )
    91     {
    92     {
    92     iProfileName = CProfileNameImpl::NewLC( aId, KNullDesC );
    93     iProfileName = CProfileNameImpl::NewLC( aId, KNullDesC );
    93     CleanupStack::Pop();    // iProfileName
    94     CleanupStack::Pop();    // iProfileName
    94     CommonConstructL();
    95     CommonConstructL();
    95     iProfileTones = CProfileTonesImpl::NewL( aProfile.ProfileTones() );
    96     iProfileTones = CProfileTonesImpl::NewL( aProfile.ProfileTones() );
    96     iProfileExtraTones = CProfileExtraTonesImpl::NewL(
    97     iProfileExtraTones = CProfileExtraTonesImpl::NewL(
    97         aProfile.ProfileExtraTones() );
    98         aProfile.ProfileExtraTones2() );
    98 
    99 
    99     iFeatures = &( ProfileUtilityInstanceL().ProfilesLocalFeatures() );
   100     iFeatures = &( ProfileUtilityInstanceL().ProfilesLocalFeatures() );
   100 
   101 
   101     iProfileExtraSettings = CProfileExtraSettingsImpl::NewL();
   102     iProfileExtraSettings = CProfileExtraSettingsImpl::NewL();
   102     iProfilePresence = CProfilePresenceImpl::NewL(
   103     iProfilePresence = CProfilePresenceImpl::NewL(
   103         aProfile.ProfilePresence() );
   104         aProfile.ProfilePresence() );
   104     iVisibleFlags = aProfile.VisibleFlags();
   105     iVisibleFlags = aProfile.VisibleFlags();
   105     iModifiableFlags = aProfile.ModifiableFlags();
   106     iModifiableFlags = aProfile.ModifiableFlags();
       
   107     
       
   108     iProfileVibraSettings = CProfileVibraSettingsImpl::NewL();
       
   109     
   106     }
   110     }
   107 
   111 
   108 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   109 // CProfileImpl::NewL
   113 // CProfileImpl::NewL
   110 // Two-phased constructor.
   114 // Two-phased constructor.
   140 // Two-phased constructor.
   144 // Two-phased constructor.
   141 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   142 //
   146 //
   143 CProfileImpl* CProfileImpl::NewLC(
   147 CProfileImpl* CProfileImpl::NewLC(
   144     RFs& aFs,
   148     RFs& aFs,
   145     const MProfileExtended& aProfile,
   149     const MProfileExtended2& aProfile,
   146     TInt aId )
   150     TInt aId )
   147     {
   151     {
   148     CProfileImpl* self = new( ELeave ) CProfileImpl( aFs );
   152     CProfileImpl* self = new( ELeave ) CProfileImpl( aFs );
   149 
   153 
   150     CleanupStack::PushL( self );
   154     CleanupStack::PushL( self );
   168         
   172         
   169     delete iProfileName;
   173     delete iProfileName;
   170     delete iProfileTones;
   174     delete iProfileTones;
   171     delete iProfileExtraTones;
   175     delete iProfileExtraTones;
   172     delete iProfilePresence;
   176     delete iProfilePresence;
       
   177     
       
   178     delete iProfileVibraSettings;
   173     }
   179     }
   174 
   180 
   175 // -----------------------------------------------------------------------------
   181 // -----------------------------------------------------------------------------
   176 // CProfileImpl::IsProfileNameChanged
   182 // CProfileImpl::IsProfileNameChanged
   177 //
   183 //
   214 // -----------------------------------------------------------------------------
   220 // -----------------------------------------------------------------------------
   215 //
   221 //
   216 const TArray<TContactItemId> CProfileImpl::AlertForL()
   222 const TArray<TContactItemId> CProfileImpl::AlertForL()
   217     {
   223     {
   218     TInt contactIdListCount( iAlertFor.Count() );
   224     TInt contactIdListCount( iAlertFor.Count() );
   219     if( contactIdListCount > 0 )
   225 
   220         {
       
   221         // create CPbkContactEngine
       
   222         CPbkContactEngine* contactEngine = CPbkContactEngine::NewL( &iFs );
       
   223         CleanupStack::PushL( contactEngine );
       
   224         CContactIdArray* groupIds = contactEngine->Database().GetGroupIdListL();
       
   225 
       
   226         if( !groupIds )
       
   227             { // There are no groups in Contacts db -> clear the alert for IDs:
       
   228             iAlertFor.Reset();
       
   229             }
       
   230         else
       
   231             {
       
   232             CleanupStack::PushL( groupIds );
       
   233             TInt err;
       
   234             for( TInt i( 0 ) ; i < contactIdListCount ; ++i )
       
   235                 {
       
   236                 err = groupIds->Find( iAlertFor[i] );
       
   237 
       
   238                 if( err == KErrNotFound )
       
   239                     {
       
   240                     // remove this
       
   241                     iAlertFor.Remove( i );
       
   242                     --contactIdListCount;
       
   243                     --i;
       
   244                     err = KErrNone;
       
   245                     }
       
   246                 User::LeaveIfError( err );
       
   247                 }
       
   248             CleanupStack::PopAndDestroy();  // groupIds
       
   249             }
       
   250         CleanupStack::PopAndDestroy();  // contactEngine
       
   251         }
       
   252 
   226 
   253     return iAlertFor.Array();
   227     return iAlertFor.Array();
   254     }
   228     }
   255 
   229 
   256 // -----------------------------------------------------------------------------
   230 // -----------------------------------------------------------------------------
   259 // (other items were commented in a header).
   233 // (other items were commented in a header).
   260 // -----------------------------------------------------------------------------
   234 // -----------------------------------------------------------------------------
   261 //
   235 //
   262 TBool CProfileImpl::IsSilent() const
   236 TBool CProfileImpl::IsSilent() const
   263     {
   237     {
       
   238 	//Since 10.1, firstly check maste silence mode
       
   239 	TInt silenceMode( 0 );
       
   240 	CRepository* cenrep = CRepository::NewLC( KCRUidProfileEngine  );
       
   241     cenrep->Get( KProEngSilenceMode , silenceMode );
       
   242     CleanupStack::PopAndDestroy( cenrep );
       
   243     if ( silenceMode ) 
       
   244     	{
       
   245 		return ETrue;
       
   246     	}
       
   247 	
   264     TProfileRingingType ringType( iProfileTones->ToneSettings().iRingingType );
   248     TProfileRingingType ringType( iProfileTones->ToneSettings().iRingingType );
   265     if ( ringType == EProfileRingingTypeSilent )
   249     if ( ringType == EProfileRingingTypeSilent )
   266         {
   250         {
   267         // If ringing type is silent, the whole profile is considered as silent:
   251         // If ringing type is silent, the whole profile is considered as silent:
   268         return ETrue;
   252         return ETrue;
   513     iProfileTones->InternalizeL( aCenRep, aProfileId );
   497     iProfileTones->InternalizeL( aCenRep, aProfileId );
   514     iProfileExtraTones->InternalizeL( aCenRep, aProfileId );
   498     iProfileExtraTones->InternalizeL( aCenRep, aProfileId );
   515 
   499 
   516     iProfilePresence->InternalizeL( aCenRep, aProfileId );
   500     iProfilePresence->InternalizeL( aCenRep, aProfileId );
   517     iProfileExtraSettings->InternalizeL( aCenRep, aProfileId );
   501     iProfileExtraSettings->InternalizeL( aCenRep, aProfileId );
       
   502     
       
   503     iProfileVibraSettings->InternalizeL( aCenRep, aProfileId );
   518     }
   504     }
   519 
   505 
   520 void CProfileImpl::ExternalizeL( CRepository& aCenRep )
   506 void CProfileImpl::ExternalizeL( CRepository& aCenRep )
   521     {
   507     {
   522     TInt profileId = iProfileName->Id();
   508     TInt profileId = iProfileName->Id();
   549     // Tones and presence
   535     // Tones and presence
   550     iProfileTones->ExternalizeL( aCenRep, profileId );
   536     iProfileTones->ExternalizeL( aCenRep, profileId );
   551     iProfileExtraTones->ExternalizeL( aCenRep, profileId );
   537     iProfileExtraTones->ExternalizeL( aCenRep, profileId );
   552     iProfilePresence->ExternalizeL( aCenRep, profileId );
   538     iProfilePresence->ExternalizeL( aCenRep, profileId );
   553     iProfileExtraSettings->ExternalizeL( aCenRep, profileId );
   539     iProfileExtraSettings->ExternalizeL( aCenRep, profileId );
       
   540     
       
   541     iProfileVibraSettings->ExternalizeL(  aCenRep, profileId );
   554     }
   542     }
   555 
   543 
   556 // -----------------------------------------------------------------------------
   544 // -----------------------------------------------------------------------------
   557 // CProfileImpl::SetAlertForL
   545 // CProfileImpl::SetAlertForL
   558 //
   546 //
   596     iAlwaysOnLineEmail = FeatureManager::FeatureSupported( KFeatureIdAlwaysOnLineEmail );
   584     iAlwaysOnLineEmail = FeatureManager::FeatureSupported( KFeatureIdAlwaysOnLineEmail );
   597     iOmaPoc = FeatureManager::FeatureSupported( KFeatureIdOmaPoc );
   585     iOmaPoc = FeatureManager::FeatureSupported( KFeatureIdOmaPoc );
   598     FeatureManager::UnInitializeLib();
   586     FeatureManager::UnInitializeLib();
   599     }
   587     }
   600 
   588 
       
   589 
       
   590 // -----------------------------------------------------------------------------
       
   591 // CProfileImpl::ProfileExtraTones2
       
   592 //
       
   593 // (other items were commented in a header).
       
   594 // -----------------------------------------------------------------------------
       
   595 //
       
   596 const MProfileExtraTones2& CProfileImpl::ProfileExtraTones2() const 
       
   597     {
       
   598     return *iProfileExtraTones;
       
   599     }
       
   600 
       
   601 // -----------------------------------------------------------------------------
       
   602 // CProfileImpl::ProfileSetExtraTones2
       
   603 //
       
   604 // (other items were commented in a header).
       
   605 // -----------------------------------------------------------------------------
       
   606 //
       
   607 MProfileSetExtraTones2& CProfileImpl::ProfileSetExtraTones2() 
       
   608     {
       
   609     return *iProfileExtraTones;
       
   610     }
       
   611 
       
   612 // -----------------------------------------------------------------------------
       
   613 // CProfileImpl::ProfileVibraSettings
       
   614 //
       
   615 // (other items were commented in a header).
       
   616 // -----------------------------------------------------------------------------
       
   617 //
       
   618 const MProfileVibraSettings& CProfileImpl::ProfileVibraSettings() const
       
   619     {
       
   620     return  *iProfileVibraSettings;
       
   621     }
       
   622 
       
   623 // -----------------------------------------------------------------------------
       
   624 // CProfileImpl::ProfileSetVibraSettings
       
   625 //
       
   626 // (other items were commented in a header).
       
   627 // -----------------------------------------------------------------------------
       
   628 //
       
   629 MProfileSetVibraSettings& CProfileImpl::ProfileSetVibraSettings()
       
   630     {
       
   631     return *iProfileVibraSettings;
       
   632     }
       
   633 
   601 //  End of File
   634 //  End of File