19
|
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: Setting item class for tone selection.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// CLASS HEADER
|
|
21 |
#include "CProfilesGSTonesPluginFileListSettingItem.h"
|
|
22 |
|
|
23 |
// INTERNAL INCLUDES
|
|
24 |
#include <Profile.hrh> // From Profile Engine
|
|
25 |
#include <ProfileSettingsView.hrh>
|
|
26 |
#include "ProfilesGSTonesPlugin.hrh"
|
|
27 |
#include <profilesgstonespluginrsc.rsg>
|
|
28 |
#include "MProfilesGSTonesPluginItemDataInterface.h"
|
|
29 |
#include "ProfilesDebug.h"
|
|
30 |
|
|
31 |
// SYSTEM INCLUDES
|
|
32 |
#include <centralrepository.h>
|
|
33 |
#include <coemain.h>
|
|
34 |
#include <CFLDFileListContainer.h>
|
|
35 |
#include <stringloader.h>
|
|
36 |
#include <data_caging_path_literals.hrh>
|
|
37 |
#include <ProfileEngineInternalCRKeys.h>
|
|
38 |
#include <HWRMVibraSDKCRKeys.h>
|
|
39 |
#include <CLFContentListing.hrh>
|
|
40 |
|
|
41 |
namespace
|
|
42 |
{
|
|
43 |
// CONSTANTS
|
|
44 |
_LIT( KIgnoredExtension, ".RNG" );
|
|
45 |
_LIT( KProfileSilentTone, "Z:No_Sound.wav" );
|
|
46 |
// MIME types that should not be shown by FileList
|
|
47 |
_LIT( KProfileTypeMpegUrl, "audio/mpegurl" );
|
|
48 |
_LIT( KProfileTypeRaPlugin, "audio/x-pn-realaudio-plugin" );
|
|
49 |
#ifndef __WMA
|
|
50 |
_LIT( KProfileTypeWma, "audio/x-ms-wma" );
|
|
51 |
#endif
|
|
52 |
}
|
|
53 |
|
|
54 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
55 |
|
|
56 |
// -----------------------------------------------------------------------------
|
|
57 |
// CProfilesGSTonesPluginFileListSettingItem::CProfilesGSTonesPluginFileListSettingItem
|
|
58 |
// C++ constructor can NOT contain any code, that might leave.
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CProfilesGSTonesPluginFileListSettingItem::CProfilesGSTonesPluginFileListSettingItem(
|
|
62 |
TInt aIdentifier,
|
|
63 |
const TDesC& aDefaultToneFileName,
|
|
64 |
CCoeEnv* aCoeEnv,
|
|
65 |
MProfilesGSTonesPluginItemDataInterface& aDataInterface )
|
|
66 |
: CAknSettingItem( aIdentifier ),
|
|
67 |
iDefaultToneFileName( aDefaultToneFileName ),
|
|
68 |
iCoeEnv( aCoeEnv ),
|
|
69 |
iDataInterface( aDataInterface )
|
|
70 |
{
|
|
71 |
}
|
|
72 |
|
|
73 |
// Destructor
|
|
74 |
CProfilesGSTonesPluginFileListSettingItem::~CProfilesGSTonesPluginFileListSettingItem()
|
|
75 |
{
|
|
76 |
PRODEBUG( "~CProfilesGSTonesPluginFileListSettingItem" );
|
|
77 |
if( iVibraNotifyHandler )
|
|
78 |
{
|
|
79 |
iVibraNotifyHandler->StopListening();
|
|
80 |
}
|
|
81 |
|
|
82 |
if( iTypeNotifyHandler )
|
|
83 |
{
|
|
84 |
iTypeNotifyHandler->StopListening();
|
|
85 |
}
|
|
86 |
|
|
87 |
if( iVolumeNotifyHandler )
|
|
88 |
{
|
|
89 |
iVolumeNotifyHandler->StopListening();
|
|
90 |
}
|
|
91 |
|
|
92 |
delete iVibraNotifyHandler;
|
|
93 |
delete iTypeNotifyHandler;
|
|
94 |
delete iVolumeNotifyHandler;
|
|
95 |
|
|
96 |
delete iSession;
|
|
97 |
delete iVibraSession;
|
|
98 |
|
|
99 |
delete iTitle;
|
|
100 |
delete iNoSoundFileName;
|
|
101 |
delete iNoSoundText;
|
|
102 |
|
|
103 |
delete iDefaultToneText;
|
|
104 |
delete iFileListContainer;
|
|
105 |
PRODEBUG( "~CProfilesGSTonesPluginFileListSettingItem end" );
|
|
106 |
}
|
|
107 |
|
|
108 |
// -----------------------------------------------------------------------------
|
|
109 |
// CProfilesGSTonesPluginFileListSettingItem::CompleteConstructionL
|
|
110 |
// -----------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
void CProfilesGSTonesPluginFileListSettingItem::CompleteConstructionL()
|
|
113 |
{
|
|
114 |
PRODEBUG( "CProfilesGSTonesPluginFileListSettingItem::CompleteConstr begin" );
|
|
115 |
iNoSoundText =
|
|
116 |
StringLoader::LoadL( R_PROFILE_TEXT_NONE );
|
|
117 |
|
|
118 |
TFileName fileName;
|
|
119 |
TParse* fp = new(ELeave) TParse();
|
|
120 |
fp->Set(KProfileSilentTone, &KDC_RESOURCE_FILES_DIR, NULL);
|
|
121 |
fileName.Copy( fp->FullName() );
|
|
122 |
delete fp;
|
|
123 |
iNoSoundFileName = fileName.AllocL();
|
|
124 |
iTitle =
|
|
125 |
StringLoader::LoadL( R_PROFILE_TEXT_SELECT_TONE );
|
|
126 |
|
|
127 |
iVibraSession = CRepository::NewL(KCRUidVibraCtrl);
|
|
128 |
iSession = CRepository::NewL(KCRUidProfileEngine);
|
|
129 |
ReadMaxToneFileSizeL( *iSession );
|
|
130 |
|
|
131 |
iVibraNotifyHandler = CCenRepNotifyHandler::NewL(*this,
|
|
132 |
*iVibraSession,
|
|
133 |
CCenRepNotifyHandler::EIntKey,
|
|
134 |
KVibraCtrlProfileVibraEnabled);
|
|
135 |
|
|
136 |
User::LeaveIfError( iVibraSession->Get( KVibraCtrlProfileVibraEnabled, iVibratingAlert ) );
|
|
137 |
|
|
138 |
iVibraNotifyHandler->StartListeningL();
|
|
139 |
|
|
140 |
if( Identifier() == EProfileGSTonesPluginSettingCalendarToneId )
|
|
141 |
{
|
|
142 |
iVolumeNotifyHandler = CCenRepNotifyHandler::NewL(*this,
|
|
143 |
*iSession,
|
|
144 |
CCenRepNotifyHandler::EIntKey,
|
|
145 |
KProEngActiveRingingVolume);
|
|
146 |
|
|
147 |
iTypeNotifyHandler = CCenRepNotifyHandler::NewL(*this,
|
|
148 |
*iSession,
|
|
149 |
CCenRepNotifyHandler::EIntKey,
|
|
150 |
KProEngActiveRingingType);
|
|
151 |
|
|
152 |
User::LeaveIfError( iSession->Get( KProEngActiveRingingVolume,
|
|
153 |
iRingingVolume ) );
|
|
154 |
User::LeaveIfError( iSession->Get( KProEngActiveRingingType,
|
|
155 |
iRingingType ) );
|
|
156 |
|
|
157 |
iVolumeNotifyHandler->StartListeningL();
|
|
158 |
iTypeNotifyHandler->StartListeningL();
|
|
159 |
}
|
|
160 |
|
|
161 |
iDefaultToneText = StringLoader::LoadL(R_QTN_NO_PERSONAL_TONE, iCoeEnv);
|
|
162 |
iInternalToneFileName.Copy( iDataInterface.ItemData() );
|
|
163 |
PRODEBUG( "CProfilesGSTonesPluginFileListSettingItem::CompleteConstr end" );
|
|
164 |
}
|
|
165 |
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
// CProfilesGSTonesPluginFileListSettingItem::StoreL
|
|
168 |
// -----------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
void CProfilesGSTonesPluginFileListSettingItem::StoreL()
|
|
171 |
{
|
|
172 |
if( iInternalToneFileName.Length() == 0 )
|
|
173 |
{
|
|
174 |
iInternalToneFileName = *iNoSoundFileName; // No_Sound.wav
|
|
175 |
}
|
|
176 |
iDataInterface.SetItemDataL( iInternalToneFileName );
|
|
177 |
}
|
|
178 |
|
|
179 |
// -----------------------------------------------------------------------------
|
|
180 |
// CProfilesGSTonesPluginFileListSettingItem::LoadL
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
//
|
|
183 |
void CProfilesGSTonesPluginFileListSettingItem::LoadL()
|
|
184 |
{
|
|
185 |
iInternalToneFileName.Copy( iDataInterface.ItemData() );
|
|
186 |
if( iInternalToneFileName.Length() == 0 )
|
|
187 |
{
|
|
188 |
iInternalToneFileName = *iNoSoundFileName;
|
|
189 |
}
|
|
190 |
}
|
|
191 |
|
|
192 |
// -----------------------------------------------------------------------------
|
|
193 |
// CProfilesGSTonesPluginFileListSettingItem::EditItemL
|
|
194 |
// -----------------------------------------------------------------------------
|
|
195 |
//
|
|
196 |
void CProfilesGSTonesPluginFileListSettingItem::EditItemL( TBool /* aCalledFromMenu */ )
|
|
197 |
{
|
|
198 |
PRODEBUG( "CProfilesGSTonesPluginFileListSettingItem::EditItemL begin" );
|
|
199 |
TInt ringingType( iRingingType );
|
|
200 |
TInt volume( iRingingVolume );
|
|
201 |
TInt id( Identifier() );
|
|
202 |
if( id == EProfileGSTonesPluginSettingCalendarToneId )
|
|
203 |
{
|
|
204 |
if( ( ringingType != EProfileRingingTypeBeepOnce ) &&
|
|
205 |
( ringingType != EProfileRingingTypeSilent ) )
|
|
206 |
{
|
|
207 |
ringingType = EProfileRingingTypeRinging;
|
|
208 |
}
|
|
209 |
}
|
|
210 |
else // Clock alert tone
|
|
211 |
{
|
|
212 |
ringingType = EProfileRingingTypeRinging;
|
|
213 |
volume = EProfileRingingVolumeLevel7;
|
|
214 |
}
|
|
215 |
|
|
216 |
PRODEBUG( "CProfilesGSTonesPluginFileListSettingItem::EditItemL before FLD constr" );
|
|
217 |
|
|
218 |
iFileListContainer = CFLDFileListContainer::NewL();
|
|
219 |
PRODEBUG( "CProfilesGSTonesPluginFileListSettingItem::EditItemL after FLD constr" );
|
|
220 |
|
|
221 |
|
|
222 |
iFileListContainer->InsertNullItemL( *iDefaultToneText, iDefaultToneFileName );
|
|
223 |
// Add "Off" as the last item in tone selection list.
|
|
224 |
iFileListContainer->InsertEndNullItemL( *iNoSoundText, *iNoSoundFileName );
|
|
225 |
iFileListContainer->SetRingingType( ringingType );
|
|
226 |
iFileListContainer->SetVolume( volume );
|
|
227 |
iFileListContainer->SetVibra( iVibratingAlert );
|
|
228 |
iFileListContainer->AddExclusiveMimeTypeL( KProfileTypeMpegUrl );
|
|
229 |
iFileListContainer->AddExclusiveMimeTypeL( KProfileTypeRaPlugin );
|
|
230 |
#ifndef __WMA
|
|
231 |
iFileListContainer->AddExclusiveMimeTypeL( KProfileTypeWma );
|
|
232 |
#endif
|
|
233 |
iFileListContainer->AddExclusiveMediaTypeL( ECLFMediaTypeVideo );
|
|
234 |
|
|
235 |
if( id == EProfileGSTonesPluginSettingCalendarToneId )
|
|
236 |
{
|
|
237 |
iFileListContainer->SetAutomatedType(
|
|
238 |
CDRMHelper::EAutomatedTypeCalendarAlarm );
|
|
239 |
}
|
|
240 |
else
|
|
241 |
{
|
|
242 |
iFileListContainer->SetAutomatedType(
|
|
243 |
CDRMHelper::EAutomatedTypeClockAlarm );
|
|
244 |
}
|
|
245 |
|
|
246 |
// Size limit for voice call tone files
|
|
247 |
if ( ( id == EProfileSettingRingingToneId ||
|
|
248 |
id == EProfileSettingRingingToneLine1Id ||
|
|
249 |
id == EProfileSettingRingingToneLine2Id ) && iSizeLimit )
|
|
250 |
{
|
|
251 |
iFileListContainer->SetMaxFileSize( iSizeLimit );
|
|
252 |
}
|
|
253 |
|
|
254 |
// Launch File List Dialog
|
|
255 |
PRODEBUG( "CProfilesGSTonesPluginFileListSettingItem::EditItemL before FLD launch" );
|
|
256 |
TBool returnValue( iFileListContainer->LaunchL( iInternalToneFileName, *iTitle ) );
|
|
257 |
PRODEBUG( "CProfilesGSTonesPluginFileListSettingItem::EditItemL after FLD launch" );
|
|
258 |
if( returnValue )
|
|
259 |
{
|
|
260 |
// Setting Oked.
|
|
261 |
iDataInterface.SetItemDataL( iInternalToneFileName );
|
|
262 |
UpdateListBoxTextL();
|
|
263 |
}
|
|
264 |
|
|
265 |
delete iFileListContainer;
|
|
266 |
iFileListContainer = NULL;
|
|
267 |
PRODEBUG( "CProfilesGSTonesPluginFileListSettingItem::EditItemL end" );
|
|
268 |
}
|
|
269 |
|
|
270 |
// -----------------------------------------------------------------------------
|
|
271 |
// CProfilesGSTonesPluginFileListSettingItem::SettingTextL
|
|
272 |
// -----------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
const TDesC& CProfilesGSTonesPluginFileListSettingItem::SettingTextL()
|
|
275 |
{
|
|
276 |
PRODEBUG( "CProfilesGSTonesPluginFileListSettingItem::SettingTextL begin" );
|
|
277 |
if( iInternalToneFileName.Length() > 0 )
|
|
278 |
{
|
|
279 |
// FLD has returned a filename
|
|
280 |
if( iInternalToneFileName.CompareF( *iNoSoundFileName ) == 0 )
|
|
281 |
{
|
|
282 |
// Filename is "No_Sound", return localized text "None"
|
|
283 |
iSettingText.Set( *iNoSoundText );
|
|
284 |
}
|
|
285 |
else if( iInternalToneFileName.CompareF( iDefaultToneFileName ) == 0 )
|
|
286 |
{
|
|
287 |
// Filename is "No_Sound", return localized text "None"
|
|
288 |
iSettingText.Set( *iDefaultToneText );
|
|
289 |
}
|
|
290 |
else
|
|
291 |
{
|
|
292 |
// Filename is something else
|
|
293 |
TParsePtrC parse( iInternalToneFileName );
|
|
294 |
if( parse.Ext().CompareF( KIgnoredExtension ) == 0 )
|
|
295 |
{
|
|
296 |
iSettingText.Set( parse.Name() );
|
|
297 |
}
|
|
298 |
else
|
|
299 |
{
|
|
300 |
iSettingText.Set( parse.NameAndExt() );
|
|
301 |
}
|
|
302 |
}
|
|
303 |
}
|
|
304 |
else
|
|
305 |
{
|
|
306 |
// Filename is an empty descriptor, return localised text "None"
|
|
307 |
iSettingText.Set( *iNoSoundText );
|
|
308 |
}
|
|
309 |
PRODEBUG( "CProfilesGSTonesPluginFileListSettingItem::SettingTextL end" );
|
|
310 |
return iSettingText;
|
|
311 |
}
|
|
312 |
|
|
313 |
// -----------------------------------------------------------------------------
|
|
314 |
// CProfilesGSTonesPluginFileListSettingItem::HandleNotifyInt
|
|
315 |
// -----------------------------------------------------------------------------
|
|
316 |
//
|
|
317 |
void CProfilesGSTonesPluginFileListSettingItem::HandleNotifyInt( TUint32 aId,
|
|
318 |
TInt aNewValue )
|
|
319 |
{
|
|
320 |
switch( aId )
|
|
321 |
{
|
|
322 |
case KVibraCtrlProfileVibraEnabled:
|
|
323 |
{
|
|
324 |
iVibratingAlert = aNewValue;
|
|
325 |
if( iFileListContainer )
|
|
326 |
{
|
|
327 |
iFileListContainer->SetVibra( iVibratingAlert );
|
|
328 |
}
|
|
329 |
break;
|
|
330 |
}
|
|
331 |
case KProEngActiveRingingType:
|
|
332 |
{
|
|
333 |
iRingingType = aNewValue;
|
|
334 |
if( iFileListContainer )
|
|
335 |
{
|
|
336 |
iFileListContainer->SetRingingType( iRingingType );
|
|
337 |
}
|
|
338 |
break;
|
|
339 |
}
|
|
340 |
default: // KProEngActiveRingingVolume
|
|
341 |
{
|
|
342 |
iRingingVolume = aNewValue;
|
|
343 |
if( iFileListContainer )
|
|
344 |
{
|
|
345 |
iFileListContainer->SetVolume( iRingingVolume );
|
|
346 |
}
|
|
347 |
break;
|
|
348 |
}
|
|
349 |
}
|
|
350 |
|
|
351 |
}
|
|
352 |
|
|
353 |
// -----------------------------------------------------------------------------
|
|
354 |
// CProfileFileListSettingItem::ReadMaxToneFileSizeL
|
|
355 |
// -----------------------------------------------------------------------------
|
|
356 |
//
|
|
357 |
void CProfilesGSTonesPluginFileListSettingItem::ReadMaxToneFileSizeL(
|
|
358 |
CRepository& aRepository )
|
|
359 |
{
|
|
360 |
// Set file size limit if configured ON.
|
|
361 |
User::LeaveIfError( aRepository.Get( KProEngRingingToneMaxSize,
|
|
362 |
iSizeLimit ) );
|
|
363 |
if ( iSizeLimit < 0 )
|
|
364 |
{
|
|
365 |
iSizeLimit = 0;
|
|
366 |
}
|
|
367 |
iSizeLimit *= KKilo;
|
|
368 |
}
|
|
369 |
|
|
370 |
// End Of File
|