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 page class for ringing volume setting. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "CProfilePlayingVolumeSettingPage.h" |
|
22 |
|
23 #include <AknQueryDialog.h> |
|
24 #include <CFLDController.h> |
|
25 #include <ProfileSettingsView.rsg> |
|
26 #include "CProfileStruct.h" // KProfileMaxProfileNameLength |
|
27 #include <apgcli.h> // For RApaLsSession |
|
28 #include <bautils.h> // For BaflUtils |
|
29 #include <centralrepository.h> |
|
30 #include <ProfileEngineInternalCRKeys.h> |
|
31 |
|
32 // CONSTANTS |
|
33 namespace |
|
34 { |
|
35 const TInt KRepeatDelayInMicroSeconds( 1000000 ); // One second |
|
36 |
|
37 #ifdef RD_VIDEO_AS_RINGING_TONE |
|
38 _LIT( KFLDCommonVideoType, "video/*" ); |
|
39 _LIT( KFLDRM1VideoMimeType, "application/vnd.rn-realmedia" ); |
|
40 _LIT( KFLDRM2VideoMimeType, "application/x-pn-realmedia" ); |
|
41 _LIT( KFLDSDPVideoMimeType, "application/sdp" ); |
|
42 #endif |
|
43 |
|
44 } |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CProfilePlayingVolumeSettingPage::CProfilePlayingVolumeSettingPage |
|
49 // C++ constructor can NOT contain any code, that might leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CProfilePlayingVolumeSettingPage::CProfilePlayingVolumeSettingPage( |
|
53 TInt aResourceID, |
|
54 TInt& aVolume, |
|
55 const TDesC& aRingingTone, |
|
56 const TInt& aRingingType, |
|
57 const TBool& aVibratingAlert, |
|
58 TBool aDisplayQuery ) |
|
59 : CAknVolumeSettingPage( aResourceID, aVolume ), |
|
60 iRingingTone( aRingingTone ), |
|
61 iRingingType( aRingingType ), |
|
62 iVibratingAlert( aVibratingAlert ), |
|
63 iDisplayQuery( aDisplayQuery ) |
|
64 { |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CProfilePlayingVolumeSettingPage::ConstructL |
|
69 // Symbian 2nd phase constructor can leave. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CProfilePlayingVolumeSettingPage::ConstructL() |
|
73 { |
|
74 CAknVolumeSettingPage::ConstructL(); |
|
75 TBool showErrorMsgs( EFalse ); |
|
76 |
|
77 iFs = new ( ELeave ) RFs; |
|
78 User::LeaveIfError( iFs->Connect() ); |
|
79 |
|
80 CheckRingingToneTypeL(); |
|
81 |
|
82 iController = CFLDController::NewL( showErrorMsgs, KRepeatDelayInMicroSeconds ); |
|
83 iController->CompleteConstructionL( Window() ); |
|
84 iController->SetRingingType( iRingingType ); |
|
85 iController->SetVibra( iVibratingAlert ); |
|
86 } |
|
87 |
|
88 // Destructor. |
|
89 CProfilePlayingVolumeSettingPage::~CProfilePlayingVolumeSettingPage() |
|
90 { |
|
91 if( iFs ) |
|
92 { |
|
93 iFs->Close(); |
|
94 } |
|
95 delete iFs; |
|
96 delete iController; |
|
97 delete iPreviewTone; |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CProfilePlayingVolumeSettingPage::OfferKeyEventL |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 TKeyResponse CProfilePlayingVolumeSettingPage::OfferKeyEventL( |
|
105 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
106 { |
|
107 if( aType == EEventKey ) |
|
108 { |
|
109 if( ( aKeyEvent.iCode == EKeyLeftArrow ) || |
|
110 ( aKeyEvent.iCode == EKeyRightArrow ) ) |
|
111 { |
|
112 // Cache pointer |
|
113 CAknVolumeControl* volumeControl = VolumeControl(); |
|
114 // Get current volume level |
|
115 TInt currentVolume( volumeControl->Value() ); |
|
116 // Call base classes method |
|
117 TKeyResponse response( CAknVolumeSettingPage::OfferKeyEventL( aKeyEvent, aType ) ); |
|
118 // Get new volume level |
|
119 TInt newVolume( volumeControl->Value() ); |
|
120 if( newVolume != currentVolume ) |
|
121 { |
|
122 // Volume level has changed |
|
123 CheckRingingToneTypeL(); |
|
124 iController->SetVolume( newVolume ); |
|
125 iController->HandleFileListBoxEventL( |
|
126 MFLDFileListBoxObserver::EFocusChanged, iPreviewTone->Des() ); |
|
127 } |
|
128 return response; |
|
129 } |
|
130 // Cancels playback on any key event |
|
131 iController->HandleFileListBoxEventL( |
|
132 MFLDFileListBoxObserver::EOtherKeyEvent, iPreviewTone->Des() ); |
|
133 } |
|
134 return CAknVolumeSettingPage::OfferKeyEventL( aKeyEvent, aType ); |
|
135 } |
|
136 |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CProfilePlayingVolumeSettingPage::HandlePointerEventL |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CProfilePlayingVolumeSettingPage::HandlePointerEventL( |
|
143 const TPointerEvent& aPointerEvent ) |
|
144 { |
|
145 if( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
146 { |
|
147 // Get current volume level |
|
148 iTempVolume = VolumeControl()->Value(); |
|
149 } |
|
150 else if( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
151 { |
|
152 CAknVolumeSettingPage::HandlePointerEventL( aPointerEvent ); |
|
153 // Get new volume level |
|
154 TInt newVolume( VolumeControl()->Value() ); |
|
155 if( newVolume != iTempVolume ) |
|
156 { |
|
157 // Volume level has changed |
|
158 CheckRingingToneTypeL(); |
|
159 iController->SetVolume( newVolume ); |
|
160 iController->HandleFileListBoxEventL( |
|
161 MFLDFileListBoxObserver::EFocusChanged, iPreviewTone->Des() ); |
|
162 } |
|
163 return; |
|
164 } |
|
165 // Cancels playback on any key event |
|
166 iController->HandleFileListBoxEventL( |
|
167 MFLDFileListBoxObserver::EOtherKeyEvent, iPreviewTone->Des() ); |
|
168 |
|
169 CAknVolumeSettingPage::HandlePointerEventL( aPointerEvent ); |
|
170 } |
|
171 |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CProfilePlayingVolumeSettingPage::OkToExitL |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TBool CProfilePlayingVolumeSettingPage::OkToExitL(TBool aAccept) |
|
178 { |
|
179 if( aAccept ) |
|
180 { |
|
181 CAknVolumeControl* volumeControl = VolumeControl(); |
|
182 if(( volumeControl->Value() == KProfileMaxVolumeLevel ) // Maximum volume level |
|
183 && (iDisplayQuery)) // Maximum volume query is wanted |
|
184 { |
|
185 iController->HandleFileListBoxEventL( |
|
186 MFLDFileListBoxObserver::EListBoxClosed, KNullDesC ); |
|
187 |
|
188 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
189 TBool returnValue( dlg->ExecuteLD( R_PROFILE_VOLUME_CONFIRMATION_QUERY ) ); |
|
190 if( !returnValue ) |
|
191 { |
|
192 // User didn't want to set volume to maximum level, set it one down. |
|
193 volumeControl->SetValue( KProfileMaxVolumeLevel - 1 ); |
|
194 volumeControl->DrawDeferred(); |
|
195 } |
|
196 return returnValue; |
|
197 } |
|
198 } |
|
199 return ETrue; |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CProfilePlayingVolumeSettingPage::CheckRingingToneTypeL |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 void CProfilePlayingVolumeSettingPage::CheckRingingToneTypeL() |
|
207 { |
|
208 // Get default tone from cenrep |
|
209 TFileName defaultTone; |
|
210 CRepository* cenrep = CRepository::NewL( KCRUidProfileEngine ); |
|
211 CleanupStack::PushL( cenrep ); |
|
212 User::LeaveIfError( cenrep->Get( KProEngDefaultRingingTone, defaultTone ) ); |
|
213 CleanupStack::PopAndDestroy( cenrep ); |
|
214 |
|
215 if( !BaflUtils::FileExists( *iFs, iRingingTone ) ) |
|
216 { |
|
217 // If the file does not exist, use default tone for volume preview |
|
218 iPreviewTone = defaultTone.AllocL(); |
|
219 return; |
|
220 } |
|
221 |
|
222 #ifdef RD_VIDEO_AS_RINGING_TONE |
|
223 // Find out MIME type |
|
224 RApaLsSession apaLsSession; |
|
225 User::LeaveIfError( apaLsSession.Connect() ); |
|
226 CleanupClosePushL( apaLsSession ); |
|
227 TUid dummyUid = { 0 }; // instantiate as zero |
|
228 TDataType dataType( dummyUid ); |
|
229 User::LeaveIfError( |
|
230 apaLsSession.AppForDocument( iRingingTone, dummyUid, dataType ) ); |
|
231 CleanupStack::PopAndDestroy(); // apaLsSession.Close() |
|
232 |
|
233 // See if this is a video MIME type |
|
234 if ( dataType.Des().MatchF( KFLDCommonVideoType ) == 0 || |
|
235 dataType.Des().CompareF( KFLDRM1VideoMimeType ) == 0 || |
|
236 dataType.Des().CompareF( KFLDRM2VideoMimeType ) == 0 || |
|
237 dataType.Des().CompareF( KFLDSDPVideoMimeType ) == 0 ) |
|
238 { |
|
239 iPreviewTone = defaultTone.AllocL(); |
|
240 } |
|
241 else |
|
242 { |
|
243 iPreviewTone = iRingingTone.AllocL(); |
|
244 } |
|
245 #else |
|
246 iPreviewTone = iRingingTone.AllocL(); |
|
247 #endif |
|
248 } |
|
249 |
|
250 // End of File |
|