profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp
branchRCL_3
changeset 24 8ee96d21d9bf
parent 17 3b47783fdf16
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 "CProfileEngineImpl.h"
    21 #include "CProfileEngineImpl.h"
       
    22 #include "CProfilesNamesArrayImpl.h"
       
    23 #include "CProfileImpl.h"
       
    24 #include "CProfileNameImpl.h"
       
    25 #include "ProfileEngUtils.h"
       
    26 #include "ProfileEngPanic.h"
       
    27 #include "CProfileTiming.h"
       
    28 #include "ProfileEnginePrivateCRKeys.h"
       
    29 #include "ProfilesDebug.h"
    22 #include <bautils.h> // BaflUtils
    30 #include <bautils.h> // BaflUtils
    23 #include <barsc.h> // RResoureFile
    31 #include <barsc.h> // RResoureFile
    24 #include <featmgr.h>
    32 #include <featmgr.h>
    25 #include <bldvariant.hrh>
    33 #include <bldvariant.hrh>
    26 #include <DRMCommon.h>
    34 #include <DRMCommon.h>
    27 #include <sysutil.h>
    35 #include <sysutil.h>
    28 
    36 
    29 #include <profileeng.rsg>
    37 #include <ProfileEng.rsg>
    30 #include <TProfileToneSettings.h>
    38 #include <TProfileToneSettings.h>
    31 #include <MProfileTones.h>
    39 #include <MProfileTones.h>
    32 #include "CProfilesNamesArrayImpl.h"
       
    33 #include "CProfileImpl.h"
       
    34 #include "CProfileNameImpl.h"
       
    35 #include "ProfileEngUtils.h"
       
    36 #include <MProfileSetName.h>
    40 #include <MProfileSetName.h>
    37 #include <ProfileEng.hrh>
    41 #include <ProfileEng.hrh>
    38 #include <ProfileEngineConstants.h>
    42 #include <ProfileEngineConstants.h>
    39 #include "ProfileEngPanic.h"
       
    40 #include <MProfileSetTones.h>
    43 #include <MProfileSetTones.h>
    41 #include <MProfileSetExtraTones.h>
    44 #include <MProfileSetExtraTones.h>
    42 #include "MProfileExtraSettings.h"
    45 #include <MProfileExtraSettings.h>
    43 #include "MProfileFeedbackSettings.h"
    46 #include <MProfileFeedbackSettings.h>
    44 #include <MProfilesLocalFeatures.h>
    47 #include <MProfilesLocalFeatures.h>
    45 #include <MProfileUtilitySingleton.h>
    48 #include <MProfileUtilitySingleton.h>
    46 #include "ProfilesVariant.hrh" // KProEngFeatureIdVTRingingTone
    49 #include <ProfilesVariant.hrh> // KProEngFeatureIdVTRingingTone
    47 #include "CProfileTiming.h"
       
    48 #include <centralrepository.h>
    50 #include <centralrepository.h>
    49 #include "ProfileEnginePrivateCRKeys.h"
       
    50 #include <ProfileEnginePrivatePSKeys.h>
    51 #include <ProfileEnginePrivatePSKeys.h>
    51 #include <hwrmvibrasdkcrkeys.h>
    52 #include <hwrmvibrasdkcrkeys.h>
    52 #include <data_caging_path_literals.hrh>
    53 #include <data_caging_path_literals.hrh>
    53 #include "ProfilesDebug.h"
       
    54 
    54 
    55 #include <psmsettings.h>
    55 #include <psmsettings.h>
    56 #include <psmsrvdomaincrkeys.h>
    56 #include <psmsrvdomaincrkeys.h>
       
    57 
       
    58 #include <MProfileExtraTones2.h>
       
    59 #include <MProfileVibraSettings.h>
    57 
    60 
    58 
    61 
    59 // ============================ MEMBER FUNCTIONS ===============================
    62 // ============================ MEMBER FUNCTIONS ===============================
    60 
    63 
    61 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
   235 // -----------------------------------------------------------------------------
   238 // -----------------------------------------------------------------------------
   236 //
   239 //
   237 MProfileExtended* CProfileEngineImpl::ProfileLC(
   240 MProfileExtended* CProfileEngineImpl::ProfileLC(
   238     TInt aId )
   241     TInt aId )
   239     {
   242     {
       
   243     return Profile2LC( aId );
       
   244     /*
   240     CProfileImpl* profile = NULL;
   245     CProfileImpl* profile = NULL;
   241 
   246 
   242     iMutex.Wait();
   247     iMutex.Wait();
   243     TInt err( CheckProfileIdL( aId ) );
   248     TInt err( CheckProfileIdL( aId ) );
   244 
   249 
   278             SetLocalizedNameForDynamicProfileL( *profile );
   283             SetLocalizedNameForDynamicProfileL( *profile );
   279             }
   284             }
   280         }
   285         }
   281 
   286 
   282     return profile;
   287     return profile;
       
   288     */
   283     }
   289     }
   284 
   290 
   285 // -----------------------------------------------------------------------------
   291 // -----------------------------------------------------------------------------
   286 // CProfileEngineImpl::ProfileL
   292 // CProfileEngineImpl::ProfileL
   287 //
   293 //
   289 // -----------------------------------------------------------------------------
   295 // -----------------------------------------------------------------------------
   290 //
   296 //
   291 MProfileExtended* CProfileEngineImpl::ProfileL(
   297 MProfileExtended* CProfileEngineImpl::ProfileL(
   292     TInt aId )
   298     TInt aId )
   293     {
   299     {
       
   300     return Profile2L( aId );
       
   301     /*
   294     MProfileExtended* profile = ProfileLC( aId );
   302     MProfileExtended* profile = ProfileLC( aId );
   295     CleanupStack::Pop();    // profile
   303     CleanupStack::Pop();    // profile
   296     return profile;
   304     return profile;
       
   305     */
   297     }
   306     }
   298 
   307 
   299 
   308 
   300 // -----------------------------------------------------------------------------
   309 // -----------------------------------------------------------------------------
   301 // CProfileEngineImpl::SetActiveProfileL
   310 // CProfileEngineImpl::SetActiveProfileL
   308     PRODEBUG1( "SetActiveProfileL( %d )", aId );
   317     PRODEBUG1( "SetActiveProfileL( %d )", aId );
   309     CreatePubSubKeysIfNeededL(); 
   318     CreatePubSubKeysIfNeededL(); 
   310 
   319 
   311     iMutex.Wait();
   320     iMutex.Wait();
   312     TInt err( CheckProfileIdL( aId ) );
   321     TInt err( CheckProfileIdL( aId ) );
       
   322 
   313     if( !err )
   323     if( !err )
   314         {
   324         {
   315         TRAP( err, DoSetActiveProfileL( aId ) );
   325         TRAP( err, DoSetActiveProfileL( aId ) );
   316         }
   326         }
   317     else
   327     else
   567            iCenRep->CleanupCancelTransactionPushL();
   577            iCenRep->CleanupCancelTransactionPushL();
   568            aProfile.ExternalizeL( *iCenRep );
   578            aProfile.ExternalizeL( *iCenRep );
   569 
   579 
   570            if( profileId == activeId )
   580            if( profileId == activeId )
   571                {
   581                {
   572                UpdateActiveProfileSettingsL( aProfile );
   582                MProfileExtended2 *activeProfile = Profile2LC(activeId);
       
   583                UpdateActiveProfileSettingsL( *activeProfile );
       
   584                CleanupStack::PopAndDestroy(); // activeProfile
   573                }
   585                }
   574 
   586 
   575            // write settings to Cenrep:
   587            // write settings to Cenrep:
   576            User::LeaveIfError( iCenRep->CommitTransaction( ignore ) );
   588            User::LeaveIfError( iCenRep->CommitTransaction( ignore ) );
   577            CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL()
   589            CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL()
   623 // CProfileEngineImpl::UpdateActiveProfileSettingsL
   635 // CProfileEngineImpl::UpdateActiveProfileSettingsL
   624 //
   636 //
   625 // (other items were commented in a header).
   637 // (other items were commented in a header).
   626 // -----------------------------------------------------------------------------
   638 // -----------------------------------------------------------------------------
   627 //
   639 //
   628 void CProfileEngineImpl::UpdateActiveProfileSettingsL( MProfile& aProfile,
   640 void CProfileEngineImpl::UpdateActiveProfileSettingsL( MProfileExtended2& aProfile,
   629         TBool aSetId )
   641         TBool aSetId )
   630     {
   642     {
   631     const MProfileTones& profileTones = aProfile.ProfileTones();
   643     const MProfileTones& profileTones = aProfile.ProfileTones();
       
   644     const MProfileExtraTones2& profileExtraTones = aProfile.ProfileExtraTones2();
   632     const MProfileName& profileName = aProfile.ProfileName();
   645     const MProfileName& profileName = aProfile.ProfileName();
   633     const TProfileToneSettings& settings = profileTones.ToneSettings();
   646     const TProfileToneSettings& settings = profileTones.ToneSettings();
       
   647    // const MProfileVibraSettings &vibraSettings = aProfile.ProfileVibraSettings();
   634 
   648 
   635     // These cannot fail because this method is called only in between
   649     // These cannot fail because this method is called only in between
   636     // StartTransaction() and CommitTransaction() calls (except vibra)
   650     // StartTransaction() and CommitTransaction() calls (except vibra)
   637     iCenRep->Set( KProEngActiveRingingType, settings.iRingingType );
   651     iCenRep->Set( KProEngActiveRingingType, settings.iRingingType );
   638     iCenRep->Set( KProEngActiveRingingVolume, settings.iRingingVolume );
   652    
       
   653     //Removed. only master volue used
       
   654     // iCenRep->Set( KProEngActiveRingingVolume, settings.iRingingVolume );
   639     iCenRep->Set( KProEngActiveMessageAlert, !( aProfile.IsSilent() ) );
   655     iCenRep->Set( KProEngActiveMessageAlert, !( aProfile.IsSilent() ) );
       
   656     
       
   657     //Since 10.1
       
   658     iCenRep->Set( KProEngActiveRingTone,profileTones.RingingTone1() );
       
   659     iCenRep->Set( KProEngActiveMessageTone,profileTones.MessageAlertTone() );
       
   660     iCenRep->Set( KProEngActiveReminderTone,profileExtraTones.ReminderTone() );
       
   661     iCenRep->Set( KProEngActiveClockAlarmTone,profileExtraTones.ClockAlarmTone() );
       
   662     
       
   663     /*
       
   664     if ( MasterVibraL() )
       
   665         {
       
   666         iCenRep->Set( KProEngActiveAlertVibra,vibraSettings.AlertVibra() );
       
   667         }
       
   668     else
       
   669         {
       
   670         iCenRep->Set( KProEngActiveAlertVibra,0 );
       
   671         }
       
   672     */
       
   673     
   640     if ( !PowerSaveMode() )
   674     if ( !PowerSaveMode() )
   641         {
   675         {
   642     User::LeaveIfError( iVibraCenRep->Set(
   676     User::LeaveIfError( iVibraCenRep->Set(
   643             KVibraCtrlProfileVibraEnabled, settings.iVibratingAlert ) );
   677             KVibraCtrlProfileVibraEnabled, /*vibraSettings.AlertVibra() != 0 &&*/ MasterVibraL() ) );
   644 
   678 
   645 #ifdef RD_TACTILE_FEEDBACK
   679 #ifdef RD_TACTILE_FEEDBACK
   646 	const MProfileExtraSettings& extraSettings = aProfile.ProfileExtraSettings();
   680 	const MProfileExtraSettings& extraSettings = aProfile.ProfileExtraSettings();
   647 	const MProfileFeedbackSettings& feedbackSettings = 
   681 	const MProfileFeedbackSettings& feedbackSettings = 
   648 			extraSettings.ProfileFeedbackSettings();
   682 			extraSettings.ProfileFeedbackSettings();
   717 
   751 
   718         User::LeaveIfError( aProfilesNames->InsertInOrder( nameImpl ) );
   752         User::LeaveIfError( aProfilesNames->InsertInOrder( nameImpl ) );
   719         CleanupStack::Pop();    // nameImpl
   753         CleanupStack::Pop();    // nameImpl
   720         }
   754         }
   721 
   755 
   722     ReadDynamicProfilesNamesL( aProfilesNames, *profileName );
   756     // Since 10.1, No dynamic profiles in TB 10.1
       
   757  //   ReadDynamicProfilesNamesL( aProfilesNames, *profileName );
   723     CleanupStack::PopAndDestroy();  // profileName
   758     CleanupStack::PopAndDestroy();  // profileName
   724     }
   759     }
   725 
   760 
   726 // -----------------------------------------------------------------------------
   761 // -----------------------------------------------------------------------------
   727 // CProfileEngineImpl::DoSetActiveProfileL
   762 // CProfileEngineImpl::DoSetActiveProfileL
   730 // -----------------------------------------------------------------------------
   765 // -----------------------------------------------------------------------------
   731 //
   766 //
   732 void CProfileEngineImpl::DoSetActiveProfileL(
   767 void CProfileEngineImpl::DoSetActiveProfileL(
   733     TInt aId, TTime* aTime )
   768     TInt aId, TTime* aTime )
   734     {
   769     {
   735     MProfileExtended* profile = ProfileLC( aId );
   770     MProfileExtended2* profile = Profile2LC( aId );
   736 
   771 
   737     User::LeaveIfError( iCenRep->StartTransaction(
   772     User::LeaveIfError( iCenRep->StartTransaction(
   738             CRepository::EReadWriteTransaction ) );
   773             CRepository::EReadWriteTransaction ) );
   739     iCenRep->CleanupCancelTransactionPushL();
   774     iCenRep->CleanupCancelTransactionPushL();
   740     // Cancel first any pending timings (the logic is the same both in new
   775     // Cancel first any pending timings (the logic is the same both in new
   935     {
   970     {
   936     return CProfileEngineImpl::NewL();
   971     return CProfileEngineImpl::NewL();
   937     }
   972     }
   938 
   973 
   939 // -----------------------------------------------------------------------------
   974 // -----------------------------------------------------------------------------
       
   975 // CreateProfileEngineExtendedL create profiles engine and
       
   976 // return internal interface of the profiles engine
       
   977 // Returns: Profiles Engine internal interface
       
   978 // -----------------------------------------------------------------------------
       
   979 //
       
   980 EXPORT_C MProfileEngineExtended2* CreateProfileEngineExtended2L()
       
   981     {
       
   982     return CProfileEngineImpl::NewL();
       
   983     }
       
   984 
       
   985 // -----------------------------------------------------------------------------
   940 // CreateProfileEngineL create profiles engine and return public interface
   986 // CreateProfileEngineL create profiles engine and return public interface
   941 // of the profiles engine.
   987 // of the profiles engine.
   942 // Returns: Profiles Engine public interface
   988 // Returns: Profiles Engine public interface
   943 // -----------------------------------------------------------------------------
   989 // -----------------------------------------------------------------------------
   944 //
   990 //
   956 EXPORT_C MProfileEngineExtended* CreateProfileEngineExtendedL( RFs* aFs )
  1002 EXPORT_C MProfileEngineExtended* CreateProfileEngineExtendedL( RFs* aFs )
   957     {
  1003     {
   958     return CProfileEngineImpl::NewL( aFs );
  1004     return CProfileEngineImpl::NewL( aFs );
   959     }
  1005     }
   960 
  1006 
       
  1007 // -----------------------------------------------------------------------------
       
  1008 // CreateProfileEngineExtendedL create profiles engine and
       
  1009 // return internal interface of the profiles engine
       
  1010 // Returns: Profiles Engine internal interface
       
  1011 // -----------------------------------------------------------------------------
       
  1012 //
       
  1013 EXPORT_C MProfileEngineExtended2* CreateProfileEngineExtended2L( RFs* aFs )
       
  1014     {
       
  1015     return CProfileEngineImpl::NewL( aFs );
       
  1016     }
   961 
  1017 
   962 // -----------------------------------------------------------------------------
  1018 // -----------------------------------------------------------------------------
   963 // CProfileEngineImpl::PowerSaveMode
  1019 // CProfileEngineImpl::PowerSaveMode
   964 //
  1020 //
   965 // -----------------------------------------------------------------------------
  1021 // -----------------------------------------------------------------------------
  1010         
  1066         
  1011     return EFalse;
  1067     return EFalse;
  1012     }
  1068     }
  1013 
  1069 
  1014 
  1070 
       
  1071 
       
  1072 // -----------------------------------------------------------------------------
       
  1073 // CProfileEngineImpl::Profile2LC
       
  1074 //
       
  1075 // -----------------------------------------------------------------------------
       
  1076 //
       
  1077 MProfileExtended2* CProfileEngineImpl::Profile2LC( TInt aId )
       
  1078     {
       
  1079     CProfileImpl* profile = NULL;
       
  1080 
       
  1081     iMutex.Wait();
       
  1082     TInt err( CheckProfileIdL( aId ) );
       
  1083 
       
  1084     if( !err )
       
  1085         {
       
  1086         TRAP( err, profile = GetProfileL( aId ) );
       
  1087         }
       
  1088     iMutex.Signal();
       
  1089 
       
  1090     User::LeaveIfError( err );
       
  1091 
       
  1092     CleanupStack::PushL( profile );
       
  1093 
       
  1094     if( iSideVolumeKeys )
       
  1095         {
       
  1096         // Because SetTemp*VolumeL() functions update only Shared Data those
       
  1097         // values must be read from SD and set to the MProfile instance
       
  1098         // returned to the caller:
       
  1099         TInt activeId( User::LeaveIfError( ActiveProfileId() ) );
       
  1100         if( activeId == aId )
       
  1101             {
       
  1102             TProfileToneSettings& settings =
       
  1103                     profile->ProfileSetTones().SetToneSettings();
       
  1104             settings.iRingingVolume = TempRingingVolumeL();
       
  1105             settings.iMediaVolume = TempMediaVolumeL();
       
  1106             }
       
  1107         }
       
  1108 
       
  1109     if( !profile->IsProfileNameChanged() )
       
  1110         {
       
  1111         if( IsDefaultProfile( aId ) )
       
  1112             {
       
  1113             profile->SetLocalizedProfileNameL( *iProfileLocalisedNames );
       
  1114             }
       
  1115         else
       
  1116             {
       
  1117             SetLocalizedNameForDynamicProfileL( *profile );
       
  1118             }
       
  1119         }
       
  1120 
       
  1121     return profile;
       
  1122     }
       
  1123 
       
  1124 // -----------------------------------------------------------------------------
       
  1125 // CProfileEngineImpl::Profile2L
       
  1126 //
       
  1127 // -----------------------------------------------------------------------------
       
  1128 //
       
  1129 MProfileExtended2* CProfileEngineImpl::Profile2L( TInt aId )
       
  1130     {
       
  1131     MProfileExtended2* profile = Profile2LC( aId );
       
  1132     CleanupStack::Pop();    // profile
       
  1133     return profile;
       
  1134     }
       
  1135 
       
  1136 // -----------------------------------------------------------------------------
       
  1137 // CProfileEngineImpl::CommitChange2L
       
  1138 //
       
  1139 // -----------------------------------------------------------------------------
       
  1140 //
       
  1141 void CProfileEngineImpl::CommitChange2L( MProfileExtended2& aProfile )
       
  1142     {
       
  1143     CommitChangeL (aProfile);
       
  1144     }
       
  1145 
       
  1146 
       
  1147 // -----------------------------------------------------------------------------
       
  1148 // CProfileEngineImpl::MasterVolumeL
       
  1149 //
       
  1150 // -----------------------------------------------------------------------------
       
  1151 //
       
  1152 TInt CProfileEngineImpl::MasterVolumeL() const
       
  1153     {
       
  1154     TInt masterVolume( 0 );
       
  1155     User::LeaveIfError( iCenRep->Get( KProEngMasterVolume, masterVolume ) );
       
  1156     return masterVolume;
       
  1157     }
       
  1158 
       
  1159 // -----------------------------------------------------------------------------
       
  1160 // CProfileEngineImpl::SetMasterVolumeL
       
  1161 //
       
  1162 // -----------------------------------------------------------------------------
       
  1163 //
       
  1164 void CProfileEngineImpl::SetMasterVolumeL( TInt aMasterVolume )
       
  1165     {
       
  1166     User::LeaveIfError( iCenRep->Set( KProEngMasterVolume, aMasterVolume ) );
       
  1167     User::LeaveIfError( iCenRep->Set( KProEngActiveRingingVolume, aMasterVolume ) );
       
  1168     
       
  1169     //Send event through P&S
       
  1170     CreatePubSubKeysIfNeededL();
       
  1171     PublishChangeL( KProEngActiveProfileModified );
       
  1172     }
       
  1173 
       
  1174 // -----------------------------------------------------------------------------
       
  1175 // CProfileEngineImpl::MasterVibraL
       
  1176 //
       
  1177 // -----------------------------------------------------------------------------
       
  1178 //
       
  1179 TBool CProfileEngineImpl::MasterVibraL() const
       
  1180     {
       
  1181     TInt masterVibra( 0 );
       
  1182     User::LeaveIfError( iCenRep->Get( KProEngMasterVibra, masterVibra ) );
       
  1183     return ( masterVibra != 0 );
       
  1184     }
       
  1185 
       
  1186 // -----------------------------------------------------------------------------
       
  1187 // CProfileEngineImpl::SetMasterVibraL
       
  1188 //
       
  1189 // -----------------------------------------------------------------------------
       
  1190 //
       
  1191 void CProfileEngineImpl::SetMasterVibraL( TBool aMasterVibra )
       
  1192     {
       
  1193     User::LeaveIfError( iCenRep->Set( KProEngMasterVibra, aMasterVibra ? 1 : 0 ) );
       
  1194     User::LeaveIfError ( iCenRep->Set( KProEngActiveAlertVibra, aMasterVibra ? 1 : 0 ) );
       
  1195     
       
  1196     /*
       
  1197     MProfileExtended2* activeProfile = Profile2LC( ActiveProfileId() );
       
  1198     const MProfileVibraSettings &vibraSettings = activeProfile->ProfileVibraSettings();
       
  1199     if (activeProfile)
       
  1200         {
       
  1201         if (aMasterVibra)
       
  1202             {
       
  1203             iCenRep->Set( KProEngActiveAlertVibra,vibraSettings.AlertVibra() );
       
  1204             }
       
  1205         else
       
  1206             {
       
  1207             iCenRep->Set( KProEngActiveAlertVibra, 0 );
       
  1208             }        
       
  1209         }
       
  1210     CleanupStack::PopAndDestroy(); // activeProfile
       
  1211     */
       
  1212             
       
  1213     if ( !PowerSaveMode() )
       
  1214         {
       
  1215         User::LeaveIfError( iVibraCenRep->Set(
       
  1216                 KVibraCtrlProfileVibraEnabled, aMasterVibra ? 1 : 0) );
       
  1217         }
       
  1218     
       
  1219     //Send event through P&S
       
  1220     CreatePubSubKeysIfNeededL();
       
  1221     PublishChangeL( KProEngActiveProfileModified );
       
  1222     }
       
  1223 
       
  1224 // -----------------------------------------------------------------------------
       
  1225 // CProfileEngineImpl::SilenceModeL
       
  1226 //
       
  1227 // -----------------------------------------------------------------------------
       
  1228 //
       
  1229 TBool CProfileEngineImpl::SilenceModeL() const
       
  1230     {
       
  1231     TInt silenceMode( 0 );
       
  1232     User::LeaveIfError( iCenRep->Get( KProEngSilenceMode, silenceMode ) );
       
  1233     return ( silenceMode != 0 );
       
  1234     }
       
  1235 
       
  1236 // -----------------------------------------------------------------------------
       
  1237 // CProfileEngineImpl::SetSilenceModeL
       
  1238 //
       
  1239 // -----------------------------------------------------------------------------
       
  1240 //
       
  1241 void CProfileEngineImpl::SetSilenceModeL( TBool aSilenceMode )
       
  1242     {
       
  1243     User::LeaveIfError( iCenRep->Set( KProEngSilenceMode, aSilenceMode ? 1 : 0 ) );
       
  1244     
       
  1245     //Send event through P&S
       
  1246     CreatePubSubKeysIfNeededL();
       
  1247     PublishChangeL( KProEngActiveProfileModified );
       
  1248     }
       
  1249 
  1015 //  End of File
  1250 //  End of File