1 /* |
|
2 * Copyright (c) 2002-2006 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: Setting item class for tone selection. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // CLASS HEADER |
|
21 #include "CProfileFileListSettingItem.h" |
|
22 |
|
23 // INTERNAL INCLUDES |
|
24 #include <coemain.h> |
|
25 |
|
26 #include <Profile.hrh> // From Profile Engine |
|
27 #include <StringLoader.h> |
|
28 #include <centralrepository.h> |
|
29 #include <ProfileEngineInternalCRKeys.h> |
|
30 #include <profilesettingsview.rsg> |
|
31 #include <data_caging_path_literals.hrh> |
|
32 #include <CLFContentListing.hrh> // For TCLFMediaType::ECLFMediaTypeVideo |
|
33 #include <featdiscovery.h> // CFeatureDiscovery |
|
34 |
|
35 // for mediafilelist |
|
36 #include <mediafilelist.h> |
|
37 #include <ProfileInternal.hrh> |
|
38 #include <DRMHelper.h> |
|
39 |
|
40 |
|
41 // EXTERNAL INCLUDES |
|
42 #include "ProfilePanics.h" |
|
43 #include "ProfileSettingsView.hrh" |
|
44 |
|
45 namespace |
|
46 { |
|
47 // CONSTANTS |
|
48 _LIT( KIgnoredExtension, ".RNG" ); |
|
49 _LIT( KProfileSilentTone, "Z:No_Sound.wav" ); |
|
50 |
|
51 _LIT( KProfileAudioMpeg, "audio/mpegurl" ); |
|
52 _LIT( KProfileAudioRAPlugin, "audio/x-pn-realaudio-plugin" ); |
|
53 #ifndef __WMA |
|
54 _LIT( KProfileAudioWMA, "audio/x-ms-wma" ); |
|
55 #endif |
|
56 } |
|
57 |
|
58 // ============================ MEMBER FUNCTIONS =============================== |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CProfileFileListSettingItem::CProfileFileListSettingItem |
|
62 // C++ constructor can NOT contain any code, that might leave. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CProfileFileListSettingItem::CProfileFileListSettingItem( |
|
66 TInt aIdentifier, |
|
67 TDes& aToneFileName, |
|
68 const TInt& aRingingType, |
|
69 const TInt& aRingingVolume, |
|
70 const TBool& aVibratingAlert, |
|
71 TInt& a3DEffect, |
|
72 TInt& a3DEcho, |
|
73 CCoeEnv* aCoeEnv ) |
|
74 : CAknSettingItem( aIdentifier ), |
|
75 iExternalToneFileName( aToneFileName ), |
|
76 iRingingType( aRingingType ), |
|
77 iRingingVolume( aRingingVolume ), |
|
78 iVibratingAlert( aVibratingAlert ), |
|
79 i3DEffect( a3DEffect ), |
|
80 i3DEcho( a3DEcho ), |
|
81 iCoeEnv( aCoeEnv ) |
|
82 { |
|
83 } |
|
84 |
|
85 // Destructor |
|
86 CProfileFileListSettingItem::~CProfileFileListSettingItem() |
|
87 { |
|
88 delete iTitle; |
|
89 delete iNoSoundFileName; |
|
90 delete iNoSoundText; |
|
91 delete iInternalToneFileName; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CProfileFileListSettingItem::CompleteConstructionL |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CProfileFileListSettingItem::CompleteConstructionL() |
|
99 { |
|
100 iNoSoundText = |
|
101 StringLoader::LoadL( R_PROFILE_TEXT_NONE ); |
|
102 |
|
103 TFileName fileName; |
|
104 TParse* fp = new(ELeave) TParse(); |
|
105 fp->Set(KProfileSilentTone, &KDC_RESOURCE_FILES_DIR, NULL); |
|
106 fileName.Copy( fp->FullName() ); |
|
107 delete fp; |
|
108 iNoSoundFileName = fileName.AllocL(); |
|
109 iTitle = |
|
110 StringLoader::LoadL( R_PROFILE_TEXT_SELECT_TONE ); |
|
111 |
|
112 iInternalToneFileName = new( ELeave ) TFileName(); |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CProfileFileListSettingItem::StoreL |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CProfileFileListSettingItem::StoreL() |
|
120 { |
|
121 if( iInternalToneFileName->Length() == 0 ) |
|
122 { |
|
123 iInternalToneFileName->Copy( iNoSoundFileName->Des() ); |
|
124 } |
|
125 iExternalToneFileName.Copy( *iInternalToneFileName ); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CProfileFileListSettingItem::LoadL |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CProfileFileListSettingItem::LoadL() |
|
133 { |
|
134 iInternalToneFileName->Copy( iExternalToneFileName ); |
|
135 |
|
136 if( iInternalToneFileName->Length() == 0 ) |
|
137 { |
|
138 iInternalToneFileName->Copy( iNoSoundFileName->Des() ); |
|
139 } |
|
140 } |
|
141 |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CProfileFileListSettingItem::EditItemL |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CProfileFileListSettingItem::EditItemL( TBool /*aCalledFromMenu*/ ) |
|
148 { |
|
149 TInt ringingType( iRingingType ); |
|
150 TInt id( Identifier() ); |
|
151 if( ( id == EProfileSettingMessageAlertToneId ) || |
|
152 ( id == EProfileSettingEmailAlertToneId ) ) |
|
153 { |
|
154 // Message alert tone is always played EProfileRingingTypeRingingOnce |
|
155 // Exceptions are Silent and Beeb Once |
|
156 if( ( ringingType == EProfileRingingTypeRinging ) || |
|
157 ( ringingType == EProfileRingingTypeAscending ) ) |
|
158 { |
|
159 ringingType = EProfileRingingTypeRingingOnce; |
|
160 } |
|
161 } |
|
162 |
|
163 TFileName fileName; |
|
164 TInt nullItem = KErrNotFound; |
|
165 |
|
166 CMediaFileList* list = CMediaFileList::NewL(); |
|
167 CleanupStack::PushL( list ); |
|
168 |
|
169 list->SetAttrL( CMediaFileList::EAttrTitle, *iTitle ); |
|
170 list->SetAttrL( CMediaFileList::EAttrVolume, iRingingVolume ); |
|
171 list->SetAttrL( CMediaFileList::EAttrVibra, iVibratingAlert ); |
|
172 list->SetAttrL( CMediaFileList::EAttrRingingType, ringingType ); |
|
173 list->SetAttrL( CMediaFileList::EAttrExcludeMimeType, KProfileAudioMpeg ); |
|
174 list->SetAttrL( CMediaFileList::EAttrExcludeMimeType, KProfileAudioRAPlugin ); |
|
175 #ifndef __WMA |
|
176 list->SetAttrL( CMediaFileList::EAttrExcludeMimeType, KProfileAudioWMA ); |
|
177 #endif |
|
178 |
|
179 list->SetAttrL( CMediaFileList::EAttrAutomatedType, CDRMHelper::EAutomatedTypeRingingTone ); |
|
180 |
|
181 if( id == EProfileSettingPTTRingingToneId ) |
|
182 { |
|
183 // PTT does not allow videos |
|
184 list->SetAttrL( CMediaFileList::EAttrExcludeFolder, CMediaFileList::EMediaFileTypeVideo ); |
|
185 } |
|
186 |
|
187 if( id == EProfileSettingMessageAlertToneId ) |
|
188 { |
|
189 list->SetAttrL( CMediaFileList::EAttrAutomatedType, CDRMHelper::EAutomatedTypeMessageAlert ); |
|
190 } |
|
191 else if( id == EProfileSettingEmailAlertToneId ) |
|
192 { |
|
193 list->SetAttrL( CMediaFileList::EAttrAutomatedType, CDRMHelper::EAutomatedTypeEmailAlert ); |
|
194 } |
|
195 |
|
196 // Size limit for voice call tone files |
|
197 // Messaging tone size is also limited if the |
|
198 // "FF_LIMITED_MESSAGE_AND_ALARM_TONE_SIZE" feature flag is enabled |
|
199 if ( id == EProfileSettingRingingToneId || |
|
200 id == EProfileSettingRingingToneLine1Id || |
|
201 id == EProfileSettingRingingToneLine2Id || |
|
202 ( id == EProfileSettingMessageAlertToneId && |
|
203 CFeatureDiscovery::IsFeatureSupportedL( KFeatureIdFfLimitedMessageAndAlarmToneSize ) ) ) |
|
204 { |
|
205 TInt sizeLimitKB = 0; |
|
206 CRepository* cenrep = CRepository::NewL( KCRUidProfileEngine ); |
|
207 CleanupStack::PushL( cenrep ); |
|
208 User::LeaveIfError( cenrep->Get( KProEngRingingToneMaxSize, sizeLimitKB ) ); |
|
209 CleanupStack::PopAndDestroy(); // cenrep |
|
210 |
|
211 list->SetAttrL( CMediaFileList::EAttrFileSize, sizeLimitKB ); |
|
212 |
|
213 } |
|
214 |
|
215 list->SetAttrL( CMediaFileList::EAttr3DEffect, i3DEffect ); |
|
216 list->SetAttrL( CMediaFileList::EAttr3DEcho, i3DEcho ); |
|
217 |
|
218 list->SetNullItemL( *iNoSoundText, *iNoSoundFileName, |
|
219 CMediaFileList::EMediaFileTypeAudio, |
|
220 CMediaFileList::ENullItemIconOff ); |
|
221 |
|
222 TInt ret = list->ShowMediaFileListL( iInternalToneFileName, &nullItem, NULL, NULL ); |
|
223 |
|
224 CleanupStack::PopAndDestroy( list ); |
|
225 |
|
226 if( ret ) |
|
227 { |
|
228 // Setting Oked. |
|
229 UpdateListBoxTextL(); |
|
230 } |
|
231 } |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CProfileFileListSettingItem::SettingTextL |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 const TDesC& CProfileFileListSettingItem::SettingTextL() |
|
241 { |
|
242 if( iInternalToneFileName->Length() > 0 ) |
|
243 { |
|
244 // FLD has returned a filename |
|
245 if( iInternalToneFileName->CompareF( *iNoSoundFileName ) == 0 ) |
|
246 { |
|
247 // Filename is "No_Sound", return localized text "None" |
|
248 iSettingText.Set( *iNoSoundText ); |
|
249 } |
|
250 else |
|
251 { |
|
252 // Filename is something else |
|
253 TParsePtrC parse( *iInternalToneFileName ); |
|
254 if( parse.Ext().CompareF( KIgnoredExtension ) == 0 ) |
|
255 { |
|
256 iSettingText.Set( parse.Name() ); |
|
257 } |
|
258 else |
|
259 { |
|
260 iSettingText.Set( parse.NameAndExt() ); |
|
261 } |
|
262 } |
|
263 } |
|
264 else |
|
265 { |
|
266 // Filename is an empty descriptor, return localised text "None" |
|
267 iSettingText.Set( *iNoSoundText ); |
|
268 } |
|
269 return iSettingText; |
|
270 } |
|
271 |
|
272 // End Of File |
|