25
|
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:
|
|
15 |
* This class defines a settings dialog for the Voice Recorder application.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include <bldvariant.hrh>
|
|
20 |
|
|
21 |
#include <aknlists.h>
|
|
22 |
#include <featmgr.h>
|
|
23 |
#include "CVRSettingsDialogMMCSupported.h"
|
|
24 |
#include "voicerecorder.hrh"
|
|
25 |
#include <voicerecorder.rsg>
|
|
26 |
#include "VRConsts.h"
|
|
27 |
#include "VRUtils.h"
|
|
28 |
#include <hlplch.h>
|
|
29 |
|
|
30 |
#include <CAknMemorySelectionSettingItem.h>
|
|
31 |
#include <aknnotewrappers.h>
|
|
32 |
#include <StringLoader.h>
|
|
33 |
#include <AknCommonDialogsDynMem.h>
|
|
34 |
|
|
35 |
#ifdef RD_MULTIPLE_DRIVE
|
|
36 |
#include <AknCommonDialogsDynMem.h>
|
|
37 |
#include <driveinfo.h>
|
|
38 |
#include <CAknMemorySelectionDialogMultiDrive.h>
|
|
39 |
#include <CAknMemorySelectionSettingItemMultiDrive.h>
|
|
40 |
#endif
|
|
41 |
|
|
42 |
// ListBox item index
|
|
43 |
enum TListItemIndex
|
|
44 |
{
|
|
45 |
EListItemQualityIndex = 0,
|
|
46 |
ElistItemMemoStoreIndex,
|
|
47 |
};
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
// CVRSettingsDialog::~CVRSettingsDialog
|
|
50 |
//
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CVRSettingsDialog::~CVRSettingsDialog()
|
|
54 |
{
|
|
55 |
iSettingItemArray.ResetAndDestroy();
|
|
56 |
}
|
|
57 |
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
// CVRSettingsDialog::CVRSettingsDialog
|
|
60 |
//
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
CVRSettingsDialog* CVRSettingsDialog::NewL()
|
|
64 |
{
|
|
65 |
CVRSettingsDialog* self = new( ELeave ) CVRSettingsDialog;
|
|
66 |
CleanupStack::PushL( self );
|
|
67 |
self->ConstructL( R_VR_SETTINGS_MENUBAR );
|
|
68 |
CleanupStack::Pop();
|
|
69 |
return self;
|
|
70 |
}
|
|
71 |
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
// CVRSettingsDialog::OkToExitL
|
|
74 |
//
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
TBool CVRSettingsDialog::OkToExitL( TInt aButtonId )
|
|
78 |
{
|
|
79 |
if ( aButtonId == EAknSoftkeyOptions )
|
|
80 |
{
|
|
81 |
DisplayMenuL();
|
|
82 |
return EFalse;
|
|
83 |
}
|
|
84 |
|
|
85 |
// If want to exit settings afterwards
|
|
86 |
TBool exitAfter( ETrue );
|
|
87 |
|
|
88 |
// MSK button pressed in settings view
|
|
89 |
if ( aButtonId == ECmdMSK )
|
|
90 |
{
|
|
91 |
// A new key event is simulated
|
|
92 |
TKeyEvent key;
|
|
93 |
key.iRepeats = 0;
|
|
94 |
key.iCode = EKeyEnter;
|
|
95 |
key.iModifiers = 0;
|
|
96 |
CEikonEnv::Static()->SimulateKeyEventL( key, EEventKey );
|
|
97 |
|
|
98 |
|
|
99 |
exitAfter = EFalse; // No Exit
|
|
100 |
}
|
|
101 |
// Do not store settings anymore when exit
|
|
102 |
return exitAfter;
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
// ---------------------------------------------------------------------------
|
|
108 |
// CVRSettingsDialog::PreLayoutDynInitL
|
|
109 |
// Intialize layout
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
void CVRSettingsDialog::PreLayoutDynInitL()
|
|
113 |
{
|
|
114 |
if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) )
|
|
115 |
{
|
|
116 |
iQuality = VRUtils::QualityL();
|
|
117 |
}
|
|
118 |
// Convert the internal memory enumeration to CFD enumeration
|
|
119 |
#ifndef RD_MULTIPLE_DRIVE
|
|
120 |
if ( VRUtils::MemoStoreL() == EMemoStorePhoneMemory )
|
|
121 |
{
|
|
122 |
iMemoStore = CAknMemorySelectionSettingPage::EPhoneMemory;
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
iMemoStore = CAknMemorySelectionSettingPage::EMemoryCard;
|
|
127 |
}
|
|
128 |
|
|
129 |
// for multiple drives
|
|
130 |
#else
|
|
131 |
iDrive = (TDriveNumber)VRUtils::MemoDriveL();
|
|
132 |
|
|
133 |
#endif
|
|
134 |
|
|
135 |
CAknSettingStyleListBox* listBox = static_cast< CAknSettingStyleListBox* >
|
|
136 |
( Control( EVRSettingsListboxId ) );
|
|
137 |
User::LeaveIfNull( listBox );
|
|
138 |
CAknSettingItem* settingItem;
|
|
139 |
|
|
140 |
HBufC* itemTitle;
|
|
141 |
if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) )
|
|
142 |
{
|
|
143 |
// Add quality setting
|
|
144 |
#ifdef __AAC_ENCODER_PLUGIN
|
|
145 |
settingItem = new( ELeave ) CAknEnumeratedTextPopupSettingItem ( 0, ( TInt& ) iQuality );
|
|
146 |
|
|
147 |
#else
|
|
148 |
settingItem = new( ELeave ) CAknBinaryPopupSettingItem ( 0, ( TInt& ) iQuality );
|
|
149 |
#endif
|
|
150 |
|
|
151 |
CleanupStack::PushL( settingItem );
|
|
152 |
|
|
153 |
itemTitle = iCoeEnv->AllocReadResourceLC( R_QTN_VOREC_SET_QUALITY );
|
|
154 |
settingItem->ConstructL( EFalse, EListItemQualityIndex, *itemTitle, NULL,
|
|
155 |
R_VR_SETTINGS_DEFAULT_SPEAKER_PAGE, EAknCtPopupField, NULL,
|
|
156 |
R_VR_SETTINGS_QUALITY_TEXTS );
|
|
157 |
CleanupStack::PopAndDestroy(); // itemTitle
|
|
158 |
|
|
159 |
// Add quality item to the settings array
|
|
160 |
iSettingItemArray.AppendL( settingItem );
|
|
161 |
CleanupStack::Pop(); // settingItem
|
|
162 |
}
|
|
163 |
|
|
164 |
if ( VRUtils::MultipleMassStorageAvailable() )
|
|
165 |
{
|
|
166 |
// Create the memo store item
|
|
167 |
// Set memo store item's title
|
|
168 |
|
|
169 |
itemTitle = iCoeEnv->AllocReadResourceLC( R_QTN_VOREC_SET_STORE );
|
|
170 |
#ifndef RD_MULTIPLE_DRIVE
|
|
171 |
settingItem = new( ELeave ) CAknMemorySelectionSettingItem( 0, iMemoStore );
|
|
172 |
CleanupStack::PushL( settingItem );
|
|
173 |
settingItem->ConstructL( EFalse, id, *itemTitle, NULL,
|
|
174 |
R_VOREC_MEMORY_SELECTION_DIALOG, EAknCtPopupSettingList );
|
|
175 |
// Add memo store item to the settings array
|
|
176 |
iSettingItemArray.AppendL( settingItem );
|
|
177 |
id++;
|
|
178 |
CleanupStack::Pop(); // settingItem
|
|
179 |
|
|
180 |
#else //multiple drives
|
|
181 |
settingItem = new( ELeave ) CAknMemorySelectionSettingItemMultiDrive(0, iDrive );
|
|
182 |
CleanupStack::PushL( settingItem );
|
|
183 |
TInt includedMedias = AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage |
|
|
184 |
AknCommonDialogsDynMem::EMemoryTypeMMCExternal;
|
|
185 |
static_cast< CAknMemorySelectionSettingItemMultiDrive *> ( settingItem )->SetIncludedMediasL( includedMedias );
|
|
186 |
// Set memo store item's title
|
|
187 |
settingItem->ConstructL( EFalse, ElistItemMemoStoreIndex, *itemTitle, NULL, 0, EAknSetListBox );
|
|
188 |
// Add memo store item to the settings array
|
|
189 |
iSettingItemArray.AppendL( settingItem );
|
|
190 |
CleanupStack::Pop(); // settingItem
|
|
191 |
|
|
192 |
#endif
|
|
193 |
|
|
194 |
CleanupStack::PopAndDestroy(); // itemTitle
|
|
195 |
}
|
|
196 |
CTextListBoxModel* model = listBox->Model();
|
|
197 |
model->SetItemTextArray( &iSettingItemArray );
|
|
198 |
// Ownership retained by us
|
|
199 |
model->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
200 |
|
|
201 |
iSettingItemArray.RecalculateVisibleIndicesL();
|
|
202 |
listBox->CreateScrollBarFrameL( ETrue );
|
|
203 |
listBox->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
204 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
|
|
205 |
listBox->HandleItemAdditionL();
|
|
206 |
listBox->SetListBoxObserver( this );
|
|
207 |
listBox->UpdateScrollBarsL();
|
|
208 |
|
|
209 |
}
|
|
210 |
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
// CVRSettingsDialog::HandleListBoxEventL
|
|
213 |
//
|
|
214 |
// ---------------------------------------------------------------------------
|
|
215 |
//
|
|
216 |
void CVRSettingsDialog::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType)
|
|
217 |
{
|
|
218 |
|
|
219 |
switch ( aEventType )
|
|
220 |
{
|
|
221 |
#ifdef SINGLE_CLICK_INCLUDED
|
|
222 |
case EEventItemSingleClicked:
|
|
223 |
#endif
|
|
224 |
case EEventItemDoubleClicked: // Pointer events (highlighted item before pressing)
|
|
225 |
case EEventEnterKeyPressed: // Normal button presses
|
|
226 |
case EEventEditingStarted: // From ProcessCommand->ECmdChange
|
|
227 |
{
|
|
228 |
TInt index( aListBox->CurrentItemIndex() );
|
|
229 |
TInt driveDefaultMassStorage = VRUtils::DefaultMemoDriveL();
|
|
230 |
TInt driveRemovableMassStorage = VRUtils::GetRemovableMassStorageL();
|
|
231 |
|
|
232 |
if ( index >=0 ) // index is -1 if there are no items in the list
|
|
233 |
{
|
|
234 |
if(index == ElistItemMemoStoreIndex &&
|
|
235 |
!VRUtils::DriveValid(driveDefaultMassStorage) &&
|
|
236 |
!VRUtils::DriveValid(driveRemovableMassStorage) )
|
|
237 |
{
|
|
238 |
break;
|
|
239 |
}
|
|
240 |
iSettingItemArray.At( index )->EditItemL(
|
|
241 |
aEventType == EEventEditingStarted );
|
|
242 |
aListBox->DrawItem( index );
|
|
243 |
}
|
|
244 |
StoreAllSettingsL();
|
|
245 |
break;
|
|
246 |
}
|
|
247 |
default:
|
|
248 |
{
|
|
249 |
break;
|
|
250 |
}
|
|
251 |
}
|
|
252 |
|
|
253 |
}
|
|
254 |
|
|
255 |
// ---------------------------------------------------------------------------
|
|
256 |
// CVRSettingsDialog::ProcessCommandL
|
|
257 |
//
|
|
258 |
// ---------------------------------------------------------------------------
|
|
259 |
//
|
|
260 |
void CVRSettingsDialog::ProcessCommandL( TInt aCommandId )
|
|
261 |
{
|
|
262 |
HideMenu();
|
|
263 |
switch ( aCommandId )
|
|
264 |
{
|
|
265 |
case ECmdChange:
|
|
266 |
{
|
|
267 |
CEikListBox* listBox = static_cast< CEikListBox* >( Control( EVRSettingsListboxId ) );
|
|
268 |
HandleListBoxEventL( listBox, EEventEditingStarted );
|
|
269 |
StoreAllSettingsL();
|
|
270 |
break;
|
|
271 |
}
|
|
272 |
case EEikCmdExit:
|
|
273 |
{
|
|
274 |
TryExitL( EEikCmdExit );
|
|
275 |
CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId );
|
|
276 |
break;
|
|
277 |
}
|
|
278 |
default:
|
|
279 |
{
|
|
280 |
CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId );
|
|
281 |
break;
|
|
282 |
}
|
|
283 |
}
|
|
284 |
}
|
|
285 |
|
|
286 |
// ---------------------------------------------------------------------------
|
|
287 |
// CVRSettingsDialog::StoreAllSettingsL
|
|
288 |
// Stores values in settings list to permanent storage
|
|
289 |
// ---------------------------------------------------------------------------
|
|
290 |
//
|
|
291 |
void CVRSettingsDialog::StoreAllSettingsL()
|
|
292 |
{
|
|
293 |
|
|
294 |
TInt settingItemCount( iSettingItemArray.Count() );
|
|
295 |
|
|
296 |
for ( TInt i( 0 ); i < settingItemCount; i++ )
|
|
297 |
{
|
|
298 |
iSettingItemArray.At( i )->StoreL();
|
|
299 |
}
|
|
300 |
|
|
301 |
#ifndef RD_MULTIPLE_DRIVE
|
|
302 |
if ( iMemoStore == CAknMemorySelectionSettingPage::EPhoneMemory )
|
|
303 |
{
|
|
304 |
VRUtils::SetMemoStoreL( EMemoStorePhoneMemory );
|
|
305 |
}
|
|
306 |
else
|
|
307 |
{
|
|
308 |
// check if MMC is read-only
|
|
309 |
TVRDriveInfo mmcInfo;
|
|
310 |
VRUtils::GetMMCInfo( mmcInfo );
|
|
311 |
|
|
312 |
if ( mmcInfo.iDriveReadOnly )
|
|
313 |
{
|
|
314 |
HBufC* noteText = iCoeEnv->AllocReadResourceLC(
|
|
315 |
R_QTN_MEMC_READONLY );
|
|
316 |
CAknInformationNote* infoNote =
|
|
317 |
new( ELeave ) CAknInformationNote( ETrue );
|
|
318 |
infoNote->ExecuteLD( *noteText );
|
|
319 |
CleanupStack::PopAndDestroy(); // noteText
|
|
320 |
VRUtils::SetMemoStoreL( EMemoStorePhoneMemory );
|
|
321 |
}
|
|
322 |
else
|
|
323 |
{
|
|
324 |
VRUtils::SetMemoStoreL( EMemoStoreMMC );
|
|
325 |
}
|
|
326 |
}
|
|
327 |
|
|
328 |
// for multiple drives
|
|
329 |
#else
|
|
330 |
TUint status( 0 );
|
|
331 |
TInt defaultDrive = VRUtils::DefaultMemoDriveL();
|
|
332 |
if (VRUtils::MemoDriveL() != defaultDrive)
|
|
333 |
{
|
|
334 |
VRUtils::GetDriveInfo(iDrive, status);
|
|
335 |
// check if drive status is ok
|
|
336 |
if ( status & DriveInfo::EDriveReadOnly )
|
|
337 |
{
|
|
338 |
HBufC* noteText = iCoeEnv->AllocReadResourceLC(R_QTN_MEMC_READONLY );
|
|
339 |
CAknInformationNote* infoNote = new( ELeave ) CAknInformationNote( ETrue );
|
|
340 |
infoNote->ExecuteLD( *noteText );
|
|
341 |
CleanupStack::PopAndDestroy(); // noteText
|
|
342 |
|
|
343 |
// use default device drive to save files
|
|
344 |
iDrive = (TDriveNumber)defaultDrive;
|
|
345 |
}
|
|
346 |
}
|
|
347 |
if(iDrive == defaultDrive || iDrive == VRUtils::GetRemovableMassStorageL())
|
|
348 |
{
|
|
349 |
VRUtils::SetMemoDriveL( iDrive );
|
|
350 |
}
|
|
351 |
#endif
|
|
352 |
|
|
353 |
if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) )
|
|
354 |
{
|
|
355 |
// Save the quality setting
|
|
356 |
VRUtils::SetQualityL( iQuality );
|
|
357 |
}
|
|
358 |
}
|
|
359 |
|
|
360 |
// ---------------------------------------------------------------------------
|
|
361 |
// CVRSettingsDialog::DynInitMenuPaneL
|
|
362 |
//
|
|
363 |
// ---------------------------------------------------------------------------
|
|
364 |
//
|
|
365 |
void CVRSettingsDialog::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
|
|
366 |
{
|
|
367 |
|
|
368 |
switch ( aResourceId )
|
|
369 |
{
|
|
370 |
case R_VR_SETTINGS_MENUPANE:
|
|
371 |
{
|
|
372 |
// Check if HELP is enabled in FeatureManager, if not, disable the Help menu item
|
|
373 |
if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
|
|
374 |
{
|
|
375 |
aMenuPane->SetItemDimmed(ECmdHelp, ETrue);
|
|
376 |
}
|
|
377 |
break;
|
|
378 |
}
|
|
379 |
default:
|
|
380 |
{
|
|
381 |
break;
|
|
382 |
}
|
|
383 |
}
|
|
384 |
}
|
|
385 |
|
|
386 |
|
|
387 |
// End of file
|