23
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Data structure class for profile settings.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// CLASS HEADER
|
|
21 |
#include "CProfileStruct.h"
|
|
22 |
#include "ProfileInternal.hrh"
|
|
23 |
|
|
24 |
// EXTERNAL INCLUDES
|
|
25 |
#include <MProfileExtended.h>
|
|
26 |
#include <MProfileName.h>
|
|
27 |
#include <MProfileSetName.h>
|
|
28 |
#include <MProfileTones.h>
|
|
29 |
#include <MProfileSetTones.h>
|
|
30 |
#include <MProfileExtraTones.h>
|
|
31 |
#include <MProfileSetExtraTones.h>
|
|
32 |
#include <MProfileExtraSettings.h>
|
|
33 |
#include <MProfileSetExtraSettings.h>
|
|
34 |
#include <MProfilePttSettings.h>
|
|
35 |
#include <MProfileSetPttSettings.h>
|
|
36 |
#include <AknUtils.h> // AknTextUtils
|
|
37 |
#include <MProfileFeedbackSettings.h>
|
|
38 |
#include <MProfileSetFeedbackSettings.h>
|
|
39 |
#include <MProfile3DToneSettings.h>
|
|
40 |
#include <MProfileSet3DToneSettings.h>
|
|
41 |
|
|
42 |
#include <TProfileToneSettings.h>
|
|
43 |
|
|
44 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
45 |
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
// CProfileStruct::CProfileStruct
|
|
48 |
// C++ default constructor can NOT contain any code, that
|
|
49 |
// might leave.
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
CProfileStruct::CProfileStruct( )
|
|
53 |
{
|
|
54 |
}
|
|
55 |
|
|
56 |
// -----------------------------------------------------------------------------
|
|
57 |
// CProfileStruct::NewL
|
|
58 |
// Two-phased constructor.
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CProfileStruct* CProfileStruct::NewL( )
|
|
62 |
{
|
|
63 |
CProfileStruct* self = new (ELeave) CProfileStruct( );
|
|
64 |
CleanupStack::PushL( self );
|
|
65 |
self->ConstructL();
|
|
66 |
CleanupStack::Pop( self );
|
|
67 |
return self;
|
|
68 |
}
|
|
69 |
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
// CProfileStruct::ConstructL
|
|
72 |
// Two-phased constructor.
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
void CProfileStruct::ConstructL()
|
|
76 |
{
|
|
77 |
iRingingTone = new( ELeave ) TFileName();
|
|
78 |
iRingingToneLine2 = new( ELeave ) TFileName();
|
|
79 |
iVideoCallTone = new( ELeave ) TFileName();
|
|
80 |
iMessageAlertTone = new( ELeave ) TFileName();
|
|
81 |
iEmailAlertTone = new( ELeave ) TFileName();
|
|
82 |
iPTTRingingTone = new( ELeave ) TFileName();
|
|
83 |
}
|
|
84 |
|
|
85 |
// Destructor
|
|
86 |
CProfileStruct::~CProfileStruct()
|
|
87 |
{
|
|
88 |
iContactList.Close();
|
|
89 |
delete iRingingTone;
|
|
90 |
delete iRingingToneLine2;
|
|
91 |
delete iVideoCallTone;
|
|
92 |
delete iMessageAlertTone;
|
|
93 |
delete iEmailAlertTone;
|
|
94 |
delete iPTTRingingTone;
|
|
95 |
}
|
|
96 |
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
// CProfileStruct::LoadL
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
void CProfileStruct::LoadL( MProfileExtended* aProfile )
|
|
102 |
{
|
|
103 |
TArray<TContactItemId> array( aProfile->AlertForL() );
|
|
104 |
iContactList.Reset();
|
|
105 |
TInt count( array.Count() );
|
|
106 |
for( TInt index( 0 ); index < count; index++ )
|
|
107 |
{
|
|
108 |
iContactList.Append( array[ index ] );
|
|
109 |
}
|
|
110 |
const MProfileName& name = aProfile->ProfileName();
|
|
111 |
iProfileId = name.Id();
|
|
112 |
iProfileName.Copy( name.Name() );
|
|
113 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( iProfileName );
|
|
114 |
iTitleName.Copy( name.TitleName() );
|
|
115 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( iTitleName );
|
|
116 |
const MProfileTones& tones = aProfile->ProfileTones();
|
|
117 |
iRingingTone->Copy( tones.RingingTone1() );
|
|
118 |
iRingingToneLine2->Copy( tones.RingingTone2() );
|
|
119 |
iMessageAlertTone->Copy( tones.MessageAlertTone() );
|
|
120 |
const TProfileToneSettings& toneSettings = tones.ToneSettings();
|
|
121 |
iRingingType = toneSettings.iRingingType;
|
|
122 |
iKeypadVolume = toneSettings.iKeypadVolume;
|
|
123 |
iRingingVolume = toneSettings.iRingingVolume;
|
|
124 |
iMediaVolume = toneSettings.iMediaVolume;
|
|
125 |
iVibratingAlert = toneSettings.iVibratingAlert;
|
|
126 |
iEmailVibratingAlert = toneSettings.iEmailVibratingAlert;
|
|
127 |
iWarningAndGameTones = toneSettings.iWarningAndGameTones;
|
|
128 |
iTextToSpeech = toneSettings.iTextToSpeech;
|
|
129 |
const MProfileExtraTones& extra = aProfile->ProfileExtraTones();
|
|
130 |
iEmailAlertTone->Copy( extra.EmailAlertTone() );
|
|
131 |
iVideoCallTone->Copy( extra.VideoCallRingingTone() );
|
|
132 |
const MProfileExtraSettings& extraSettings = aProfile->ProfileExtraSettings();
|
|
133 |
const MProfilePttSettings& pttSettings = extraSettings.ProfilePttSettings();
|
|
134 |
iPTTRingingTone->Copy( pttSettings.PttRingingTone() );
|
|
135 |
iPTTStatus = pttSettings.PttStatus();
|
|
136 |
|
|
137 |
const MProfileFeedbackSettings& feedbackSettings = extraSettings.ProfileFeedbackSettings();
|
|
138 |
iTactileFeedback = feedbackSettings.TactileFeedback();
|
|
139 |
iAudioFeedback = feedbackSettings.AudioFeedback();
|
|
140 |
|
|
141 |
const MProfile3DToneSettings& threeDSettings = extraSettings.Profile3DToneSettings();
|
|
142 |
i3DEffect = threeDSettings.Effect();
|
|
143 |
i3DEcho = threeDSettings.Echo();
|
|
144 |
}
|
|
145 |
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
// CProfileStruct::StoreL
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
//
|
|
150 |
void CProfileStruct::StoreL( MProfileExtended* aProfile )
|
|
151 |
{
|
|
152 |
aProfile->SetAlertForL( iContactList.Array() );
|
|
153 |
const MProfileName& name = aProfile->ProfileName();
|
|
154 |
TBuf<KProfileMaxProfileNameLength> profileNameHelperBuffer;
|
|
155 |
profileNameHelperBuffer.Copy( name.Name() );
|
|
156 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion(
|
|
157 |
profileNameHelperBuffer );
|
|
158 |
if( iProfileName.Compare( profileNameHelperBuffer ) )
|
|
159 |
{
|
|
160 |
// Store profile name only if it has changed in order to
|
|
161 |
// preserve localisation.
|
|
162 |
aProfile->ProfileSetName().SetNameL( iProfileName );
|
|
163 |
iTitleName.Copy( iProfileName );
|
|
164 |
}
|
|
165 |
MProfileSetTones& setTones = aProfile->ProfileSetTones();
|
|
166 |
setTones.SetRingingTone1L( *iRingingTone );
|
|
167 |
setTones.SetRingingTone2L( *iRingingToneLine2 );
|
|
168 |
setTones.SetMessageAlertToneL( *iMessageAlertTone );
|
|
169 |
TProfileToneSettings& toneSettings = setTones.SetToneSettings();
|
|
170 |
toneSettings.iRingingType = TProfileRingingType( iRingingType );
|
|
171 |
toneSettings.iKeypadVolume = TProfileKeypadVolume( iKeypadVolume );
|
|
172 |
toneSettings.iRingingVolume = iRingingVolume;
|
|
173 |
toneSettings.iMediaVolume = iMediaVolume;
|
|
174 |
toneSettings.iVibratingAlert = iVibratingAlert;
|
|
175 |
toneSettings.iEmailVibratingAlert = iEmailVibratingAlert;
|
|
176 |
toneSettings.iWarningAndGameTones = iWarningAndGameTones;
|
|
177 |
toneSettings.iTextToSpeech = iTextToSpeech;
|
|
178 |
MProfileSetExtraTones& setExtra = aProfile->ProfileSetExtraTones();
|
|
179 |
setExtra.SetEmailAlertToneL( *iEmailAlertTone );
|
|
180 |
setExtra.SetVideoCallRingingToneL( *iVideoCallTone );
|
|
181 |
|
|
182 |
MProfileSetExtraSettings& setExtraSettings = aProfile->ProfileSetExtraSettings();
|
|
183 |
MProfileSetPttSettings& setPttSettings = setExtraSettings.ProfileSetPttSettings();
|
|
184 |
setPttSettings.SetPttRingingToneL( *iPTTRingingTone );
|
|
185 |
TProfilePttStatus KPttStatus = TProfilePttStatus( iPTTStatus );
|
|
186 |
setPttSettings.SetPttStatus( KPttStatus );
|
|
187 |
|
|
188 |
MProfileSetFeedbackSettings& setFeedbackSettings =
|
|
189 |
setExtraSettings.ProfileSetFeedbackSettings();
|
|
190 |
TProfileTactileFeedback tactileFeedback = TProfileTactileFeedback( iTactileFeedback );
|
|
191 |
TProfileAudioFeedback audioFeedback = TProfileAudioFeedback( iAudioFeedback );
|
|
192 |
setFeedbackSettings.SetTactileFeedback( tactileFeedback );
|
|
193 |
setFeedbackSettings.SetAudioFeedback( audioFeedback );
|
|
194 |
|
|
195 |
MProfileSet3DToneSettings& set3dSettings =
|
|
196 |
setExtraSettings.ProfileSet3DToneSettings();
|
|
197 |
TProfile3DToneEffect threeDEffect = TProfile3DToneEffect( i3DEffect );
|
|
198 |
TProfile3DToneEcho threeDEcho = TProfile3DToneEcho( i3DEcho );
|
|
199 |
set3dSettings.SetEffect( threeDEffect );
|
|
200 |
set3dSettings.SetEcho( threeDEcho );
|
|
201 |
}
|
|
202 |
|
|
203 |
// -----------------------------------------------------------------------------
|
|
204 |
// CProfileStruct::CompareL
|
|
205 |
// -----------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
TBool CProfileStruct::CompareL( MProfileExtended* aProfile ) const
|
|
208 |
{
|
|
209 |
const MProfileTones& tones = aProfile->ProfileTones();
|
|
210 |
const MProfileName& name = aProfile->ProfileName();
|
|
211 |
const TProfileToneSettings& toneSettings = tones.ToneSettings();
|
|
212 |
const MProfileExtraTones& extra = aProfile->ProfileExtraTones();
|
|
213 |
const MProfileExtraSettings& extraSettings = aProfile->ProfileExtraSettings();
|
|
214 |
const MProfilePttSettings& pttSettings = extraSettings.ProfilePttSettings();
|
|
215 |
const MProfileFeedbackSettings& feedbackSettings = extraSettings.ProfileFeedbackSettings();
|
|
216 |
const MProfile3DToneSettings& threeDSettings = extraSettings.Profile3DToneSettings();
|
|
217 |
|
|
218 |
TArray<TContactItemId> array( aProfile->AlertForL() );
|
|
219 |
TInt contactArrayCount( array.Count() );
|
|
220 |
TInt ownContactArrayCount( iContactList.Count() );
|
|
221 |
|
|
222 |
if( ( iProfileId != name.Id() ) ||
|
|
223 |
( iRingingTone->Compare( tones.RingingTone1() ) ) ||
|
|
224 |
( iRingingToneLine2->Compare( tones.RingingTone2() ) ) ||
|
|
225 |
( iVideoCallTone->Compare( extra.VideoCallRingingTone() ) ) ||
|
|
226 |
( iMessageAlertTone->Compare( tones.MessageAlertTone() ) ) ||
|
|
227 |
( iProfileName.Compare( name.Name() ) ) ||
|
|
228 |
( iRingingType != toneSettings.iRingingType ) ||
|
|
229 |
( iKeypadVolume != toneSettings.iKeypadVolume ) ||
|
|
230 |
( iRingingVolume != toneSettings.iRingingVolume ) ||
|
|
231 |
( iMediaVolume != toneSettings.iMediaVolume ) ||
|
|
232 |
( iVibratingAlert != toneSettings.iVibratingAlert ) ||
|
|
233 |
( iEmailVibratingAlert != toneSettings.iEmailVibratingAlert ) ||
|
|
234 |
( iWarningAndGameTones != toneSettings.iWarningAndGameTones ) ||
|
|
235 |
( iTextToSpeech != toneSettings.iTextToSpeech ) ||
|
|
236 |
( iEmailAlertTone->Compare( extra.EmailAlertTone() ) ) ||
|
|
237 |
( ownContactArrayCount != contactArrayCount ) ||
|
|
238 |
( iTactileFeedback != feedbackSettings.TactileFeedback() ) ||
|
|
239 |
( iAudioFeedback != feedbackSettings.AudioFeedback() ) ||
|
|
240 |
( i3DEffect != threeDSettings.Effect() ) ||
|
|
241 |
( i3DEcho != threeDSettings.Echo() ) ||
|
|
242 |
( iPTTRingingTone->Compare( pttSettings.PttRingingTone() ) ) ||
|
|
243 |
( iPTTStatus != pttSettings.PttStatus() ) )
|
|
244 |
{
|
|
245 |
return EFalse;
|
|
246 |
}
|
|
247 |
|
|
248 |
for( TInt index( 0 ); index < contactArrayCount; index++ )
|
|
249 |
{
|
|
250 |
if( iContactList[ index ] != array[ index ] )
|
|
251 |
{
|
|
252 |
return EFalse;
|
|
253 |
}
|
|
254 |
}
|
|
255 |
return ETrue;
|
|
256 |
}
|
|
257 |
|
|
258 |
// End of File
|