|
1 /* |
|
2 * Copyright (c) 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: Voice Recorder sub-menu in General Settings. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "CVRGSPluginContainer.h" |
|
21 #include "CVRGSPlugin.h" |
|
22 |
|
23 #include <voicerecorder.rsg> |
|
24 #include <VoiceRecorderUID.h> |
|
25 |
|
26 #include "VRConsts.h" |
|
27 #include "VRUtils.h" |
|
28 #include <csxhelp/vorec.hlp.hrh> |
|
29 |
|
30 |
|
31 #include <aknlists.h> //for CAknSettingStyleListBox |
|
32 #include <aknsettingitemlist.h> |
|
33 #include <CAknMemorySelectionSettingItem.h> |
|
34 #include <aknnotewrappers.h> // for CAknInformationNote |
|
35 //#include <GSCamcorderPlugin.mbg> |
|
36 #include <gslistbox.h> //for listbox clases |
|
37 #include <AknIconArray.h> // CAknIconArray |
|
38 #include <eikclbd.h> // CColumnListBoxData |
|
39 |
|
40 #ifdef RD_MULTIPLE_DRIVE |
|
41 #include <driveinfo.h> |
|
42 #include <CAknMemorySelectionSettingItemMultiDrive.h> |
|
43 #endif |
|
44 |
|
45 const TUid KVRAppUID = { KVoiceRecorderAppUID3 }; |
|
46 |
|
47 // ========================= MEMBER FUNCTIONS ================================ |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CVRGSPluginContainer::ConstructL |
|
51 // Symbian OS default constructor |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 void CVRGSPluginContainer::ConstructL( const TRect& aRect ) |
|
55 { |
|
56 // Construct iListBox |
|
57 iListBox = new ( ELeave ) CAknSettingStyleListBox; |
|
58 iSettingItemArray = new(ELeave) CAknSettingItemArray(2,0,0); |
|
59 |
|
60 if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ) |
|
61 { |
|
62 iQuality = VRUtils::QualityL(); |
|
63 } |
|
64 |
|
65 // Convert the internal memory enumeration to CFD enumeration |
|
66 #ifndef RD_MULTIPLE_DRIVE |
|
67 if ( VRUtils::MemoStoreL() == EMemoStorePhoneMemory ) |
|
68 { |
|
69 iMemoStore = CAknMemorySelectionSettingPage::EPhoneMemory; |
|
70 } |
|
71 else |
|
72 { |
|
73 iMemoStore = CAknMemorySelectionSettingPage::EMemoryCard; |
|
74 } |
|
75 #else |
|
76 iDrive = (TDriveNumber)VRUtils::MemoDriveL(); |
|
77 |
|
78 #endif |
|
79 |
|
80 BaseConstructL( aRect, R_VOREC_GS_VIEW_TITLE, 0 ); |
|
81 } |
|
82 |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CVRGSPluginContainer::~CGSTelPluginContainer |
|
86 // Destructor |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 CVRGSPluginContainer::~CVRGSPluginContainer() |
|
90 { |
|
91 if ( iSettingItemArray ) |
|
92 { |
|
93 iSettingItemArray->ResetAndDestroy(); |
|
94 } |
|
95 |
|
96 delete iSettingItemArray; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CVRGSPluginContainer::CGSTelPluginContainer |
|
101 // Default constructor |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 CVRGSPluginContainer::CVRGSPluginContainer() |
|
105 : iQuality( EQualityMMSOptimized ), |
|
106 iMemoStore( CAknMemorySelectionSettingPage::EPhoneMemory ) |
|
107 { |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CVRGSPluginContainer::UpdateListBoxL |
|
112 // Update listbox item |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CVRGSPluginContainer::UpdateListBoxL( TInt /*aFeatureId*/ ) |
|
116 { |
|
117 |
|
118 // Update the listbox |
|
119 iListBox->HandleItemAdditionL(); |
|
120 } |
|
121 |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // CVRGSPluginContainer::ConstructListBoxL |
|
125 // Update listbox item |
|
126 // Items are added manually, instead of loading them from resources |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CVRGSPluginContainer::ConstructListBoxL( TInt /*aResLbxId*/ ) |
|
130 { |
|
131 iListBox->ConstructL( this, EAknListBoxSelectionList ); |
|
132 |
|
133 // Create items to array |
|
134 CreateListBoxItemsL(); |
|
135 |
|
136 // Set array to listbox |
|
137 CTextListBoxModel* model = iListBox->Model(); |
|
138 model->SetItemTextArray( iSettingItemArray ); |
|
139 // Ownership retained by us |
|
140 model->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
141 |
|
142 iSettingItemArray->RecalculateVisibleIndicesL(); |
|
143 iListBox->CreateScrollBarFrameL( ETrue ); |
|
144 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
145 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
146 iListBox->HandleItemAdditionL(); |
|
147 iListBox->UpdateScrollBarsL(); |
|
148 } |
|
149 |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CVRGSPluginContainer::CreateListBoxItemsL |
|
153 // Update listbox item |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CVRGSPluginContainer::CreateListBoxItemsL() |
|
157 { |
|
158 CAknSettingItem* settingItem; |
|
159 HBufC* itemTitle; |
|
160 TInt id( 0 ); |
|
161 |
|
162 // Add quality setting |
|
163 if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ) |
|
164 { |
|
165 |
|
166 // Add quality setting |
|
167 #ifdef __AAC_ENCODER_PLUGIN |
|
168 settingItem = new( ELeave ) CAknEnumeratedTextPopupSettingItem ( 0, ( TInt& ) iQuality ); |
|
169 |
|
170 #else |
|
171 settingItem = new( ELeave ) CAknBinaryPopupSettingItem ( 0, ( TInt& ) iQuality ); |
|
172 #endif |
|
173 CleanupStack::PushL( settingItem ); |
|
174 |
|
175 itemTitle = iCoeEnv->AllocReadResourceLC( R_QTN_VOREC_SET_QUALITY ); |
|
176 settingItem->ConstructL( EFalse, id, *itemTitle, NULL, |
|
177 R_VR_SETTINGS_DEFAULT_SPEAKER_PAGE, |
|
178 EAknCtPopupField, NULL, |
|
179 R_VR_SETTINGS_QUALITY_TEXTS ); |
|
180 |
|
181 CleanupStack::PopAndDestroy(); // itemTitle |
|
182 |
|
183 // Add quality item to the settings array |
|
184 iSettingItemArray->AppendL( settingItem ); |
|
185 CleanupStack::Pop(); // settingItem |
|
186 id++; |
|
187 } |
|
188 |
|
189 // Add memo store setting |
|
190 // Create the memo store item |
|
191 #ifndef RD_MULTIPLE_DRIVE |
|
192 settingItem = |
|
193 new( ELeave ) CAknMemorySelectionSettingItem( 0, iMemoStore ); |
|
194 //multiple drives |
|
195 #else |
|
196 settingItem = |
|
197 new( ELeave ) CAknMemorySelectionSettingItemMultiDrive(0, iDrive ); |
|
198 #endif |
|
199 |
|
200 CleanupStack::PushL( settingItem ); |
|
201 |
|
202 itemTitle = iCoeEnv->AllocReadResourceLC( R_QTN_VOREC_SET_STORE ); |
|
203 |
|
204 #ifndef RD_MULTIPLE_DRIVE |
|
205 // Set memo store item's title |
|
206 settingItem->ConstructL( EFalse, id, *itemTitle, NULL, |
|
207 R_VOREC_MEMORY_SELECTION_DIALOG, EAknCtPopupSettingList ); |
|
208 #else |
|
209 settingItem->ConstructL( EFalse, id, *itemTitle, NULL, 0, EAknCtPopupSettingList ); |
|
210 #endif |
|
211 |
|
212 CleanupStack::PopAndDestroy(); // itemTitle |
|
213 |
|
214 // Add memo store item to the settings array |
|
215 iSettingItemArray->AppendL( settingItem ); |
|
216 CleanupStack::Pop(); // settingItem |
|
217 id++; |
|
218 |
|
219 } |
|
220 |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // CVRGSPluginContainer::CurrentFeatureId |
|
224 // Get the currently selected feature |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 TInt CVRGSPluginContainer::CurrentFeatureId() const |
|
228 { |
|
229 if ( iSettingItemArray ) |
|
230 { |
|
231 return iSettingItemArray->MdcaCount(); |
|
232 } |
|
233 else |
|
234 { |
|
235 return 0; |
|
236 } |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // CVRGSPluginContainer::GetHelpContext |
|
241 // Get help for this view |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 void CVRGSPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
245 { |
|
246 aContext.iMajor = KVRAppUID; |
|
247 aContext.iContext = KVOREC_HLP_SETTINGS; |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // CVRGSPluginContainer::SizeChanged |
|
252 // Set the size and position of component controls. |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 void CVRGSPluginContainer::SizeChanged() |
|
256 { |
|
257 if ( iListBox ) |
|
258 { |
|
259 iListBox->SetRect( Rect() ); |
|
260 } |
|
261 } |
|
262 |
|
263 void CVRGSPluginContainer::HandleListBoxSelectionL( TInt aCommand ) |
|
264 { |
|
265 TInt index( iListBox->CurrentItemIndex() ); |
|
266 |
|
267 if ( index >=0 ) // index is -1 if there are no items in the list |
|
268 { |
|
269 // Open edit dialog if EAknCmdOpen, invert the value otherwise |
|
270 iSettingItemArray->At( index )->EditItemL( aCommand == EAknCmdOpen ); |
|
271 iListBox->DrawItem( index ); |
|
272 //Store all settings after change |
|
273 StoreAllL(); |
|
274 } |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // CVRGSPluginContainer::StoreAll |
|
279 // Stores values in settings list to permanent storage |
|
280 // --------------------------------------------------------------------------- |
|
281 // |
|
282 void CVRGSPluginContainer::StoreAllL() |
|
283 { |
|
284 // Retrieve values to member variables |
|
285 TInt settingItemCount( iSettingItemArray->Count() ); |
|
286 |
|
287 for ( TInt i( 0 ); i < settingItemCount; i++ ) |
|
288 { |
|
289 iSettingItemArray->At( i )->StoreL(); |
|
290 } |
|
291 |
|
292 // Save memo store setting |
|
293 #ifndef RD_MULTIPLE_DRIVE |
|
294 if ( iMemoStore == CAknMemorySelectionSettingPage::EPhoneMemory ) |
|
295 { |
|
296 VRUtils::SetMemoStoreL( EMemoStorePhoneMemory ); |
|
297 } |
|
298 else |
|
299 { |
|
300 // check if MMC is read-only |
|
301 TVRDriveInfo mmcInfo; |
|
302 VRUtils::GetMMCInfo( mmcInfo ); |
|
303 |
|
304 if ( mmcInfo.iDriveReadOnly ) |
|
305 { |
|
306 HBufC* noteText = iCoeEnv->AllocReadResourceLC( |
|
307 R_QTN_MEMC_READONLY ); |
|
308 CAknInformationNote* infoNote = |
|
309 new( ELeave ) CAknInformationNote( ETrue ); |
|
310 infoNote->ExecuteLD( *noteText ); |
|
311 CleanupStack::PopAndDestroy(); // noteText |
|
312 VRUtils::SetMemoStoreL( EMemoStorePhoneMemory ); |
|
313 } |
|
314 else |
|
315 { |
|
316 VRUtils::SetMemoStoreL( EMemoStoreMMC ); |
|
317 } |
|
318 } |
|
319 #else |
|
320 TUint status( 0 ); |
|
321 TInt defaultDrive = VRUtils::DefaultMemoDriveL(); |
|
322 if (VRUtils::MemoDriveL() != defaultDrive) |
|
323 { |
|
324 VRUtils::GetDriveInfo(iDrive, status); |
|
325 // check if drive status is ok |
|
326 if ( status & DriveInfo::EDriveReadOnly ) |
|
327 { |
|
328 HBufC* noteText = iCoeEnv->AllocReadResourceLC(R_QTN_MEMC_READONLY ); |
|
329 CAknInformationNote* infoNote = new( ELeave ) CAknInformationNote( ETrue ); |
|
330 infoNote->ExecuteLD( *noteText ); |
|
331 CleanupStack::PopAndDestroy(); // noteText |
|
332 |
|
333 // use default device drive to save files |
|
334 iDrive = (TDriveNumber)defaultDrive; |
|
335 } |
|
336 } |
|
337 VRUtils::SetMemoDriveL( iDrive ); |
|
338 #endif |
|
339 |
|
340 // Save quality setting |
|
341 if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ) |
|
342 { |
|
343 // Save the quality setting |
|
344 VRUtils::SetQualityL( iQuality ); |
|
345 } |
|
346 |
|
347 } |
|
348 |
|
349 // End of File |