author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:19:36 +0300 | |
branch | RCL_3 |
changeset 24 | ea11b8c1e6a4 |
parent 23 | cd54903d48da |
child 27 | d0e1a4b40897 |
permissions | -rw-r--r-- |
23 | 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 |
{ |
|
24
ea11b8c1e6a4
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
208 |
// If the preview tone is not NULL, delete it. |
ea11b8c1e6a4
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
209 |
if ( iPreviewTone ) |
ea11b8c1e6a4
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
210 |
{ |
ea11b8c1e6a4
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
211 |
delete iPreviewTone; |
ea11b8c1e6a4
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
212 |
iPreviewTone = NULL; |
ea11b8c1e6a4
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
213 |
} |
ea11b8c1e6a4
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
214 |
|
23 | 215 |
// Get default tone from cenrep |
216 |
TFileName defaultTone; |
|
217 |
CRepository* cenrep = CRepository::NewL( KCRUidProfileEngine ); |
|
218 |
CleanupStack::PushL( cenrep ); |
|
219 |
User::LeaveIfError( cenrep->Get( KProEngDefaultRingingTone, defaultTone ) ); |
|
220 |
CleanupStack::PopAndDestroy( cenrep ); |
|
221 |
||
222 |
if( !BaflUtils::FileExists( *iFs, iRingingTone ) ) |
|
223 |
{ |
|
224 |
// If the file does not exist, use default tone for volume preview |
|
225 |
iPreviewTone = defaultTone.AllocL(); |
|
226 |
return; |
|
227 |
} |
|
228 |
||
229 |
#ifdef RD_VIDEO_AS_RINGING_TONE |
|
230 |
// Find out MIME type |
|
231 |
RApaLsSession apaLsSession; |
|
232 |
User::LeaveIfError( apaLsSession.Connect() ); |
|
233 |
CleanupClosePushL( apaLsSession ); |
|
234 |
TUid dummyUid = { 0 }; // instantiate as zero |
|
235 |
TDataType dataType( dummyUid ); |
|
236 |
User::LeaveIfError( |
|
237 |
apaLsSession.AppForDocument( iRingingTone, dummyUid, dataType ) ); |
|
238 |
CleanupStack::PopAndDestroy(); // apaLsSession.Close() |
|
239 |
||
240 |
// See if this is a video MIME type |
|
241 |
if ( dataType.Des().MatchF( KFLDCommonVideoType ) == 0 || |
|
242 |
dataType.Des().CompareF( KFLDRM1VideoMimeType ) == 0 || |
|
243 |
dataType.Des().CompareF( KFLDRM2VideoMimeType ) == 0 || |
|
244 |
dataType.Des().CompareF( KFLDSDPVideoMimeType ) == 0 ) |
|
245 |
{ |
|
246 |
iPreviewTone = defaultTone.AllocL(); |
|
247 |
} |
|
248 |
else |
|
249 |
{ |
|
250 |
iPreviewTone = iRingingTone.AllocL(); |
|
251 |
} |
|
252 |
#else |
|
253 |
iPreviewTone = iRingingTone.AllocL(); |
|
254 |
#endif |
|
255 |
} |
|
256 |
||
257 |
// End of File |