25
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2005,2007 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: Ringing tone player.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <cntdef.h>
|
|
21 |
#include <f32file.h>
|
|
22 |
#include <featmgr.h>
|
|
23 |
#include <utility.h>
|
|
24 |
#include <AudioPreference.h>
|
|
25 |
#include <data_caging_path_literals.hrh>
|
|
26 |
#include <MusicPlayerInternalCRKeys.h>
|
|
27 |
#include <ProfileEngineDomainCRKeys.h>
|
|
28 |
#include <telephonyvariant.hrh>
|
|
29 |
#include <UikonInternalPSKeys.h>
|
|
30 |
#include <DRMHelperServerInternalCRKeys.h>
|
|
31 |
#include <DRMHelper.h>
|
|
32 |
#include <activeidle2domainpskeys.h>
|
|
33 |
|
|
34 |
#include "cphoneringingtoneplayerao.h"
|
|
35 |
#include "phoneui.pan"
|
|
36 |
#include "phoneui.hrh"
|
|
37 |
#include "mphoneringingtoneobserver.h"
|
|
38 |
#include "cphonetimer.h"
|
|
39 |
#include "cphonecenrepproxy.h"
|
|
40 |
#include "phoneconstants.h"
|
|
41 |
#include "phonelogger.h"
|
|
42 |
#include "cphoneringingtone.h"
|
|
43 |
#include "tphonecmdparamringtone.h"
|
|
44 |
#include "cphonepubsubproxy.h"
|
|
45 |
#include "cphonecenrepproxy.h"
|
|
46 |
|
|
47 |
// CONSTANTS
|
|
48 |
|
|
49 |
// Minimum acceptable length of parsed DRM message.
|
|
50 |
const TInt KPhoneMinDRMTextLength = 3;
|
|
51 |
// Value field of parsed DRM string.
|
|
52 |
|
|
53 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// CPhoneRingingTonePlayerAO::NewL
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
CPhoneRingingTonePlayerAO* CPhoneRingingTonePlayerAO::NewL()
|
|
60 |
{
|
|
61 |
CPhoneRingingTonePlayerAO* self =
|
|
62 |
new ( ELeave ) CPhoneRingingTonePlayerAO();
|
|
63 |
|
|
64 |
CleanupStack::PushL( self );
|
|
65 |
self->ConstructL();
|
|
66 |
CleanupStack::Pop( self );
|
|
67 |
|
|
68 |
return self;
|
|
69 |
}
|
|
70 |
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
// CPhoneRingingTonePlayerAO::CPhoneRingingTonePlayerAO
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
CPhoneRingingTonePlayerAO::CPhoneRingingTonePlayerAO() :
|
|
76 |
CActive( CActive::EPriorityStandard )
|
|
77 |
{
|
|
78 |
CActiveScheduler::Add( this );
|
|
79 |
}
|
|
80 |
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
// CPhoneRingingTonePlayerAO::ConstructL
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
void CPhoneRingingTonePlayerAO::ConstructL()
|
|
86 |
{
|
|
87 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::ConstructL()" );
|
|
88 |
|
|
89 |
// Connect to the tone server
|
|
90 |
User::LeaveIfError( iToneServer.Connect() );
|
|
91 |
|
|
92 |
// Construct timer.
|
|
93 |
iTimer = CPhoneTimer::NewL();
|
|
94 |
|
|
95 |
// Checks if DRM extend security is needed
|
|
96 |
TInt extSecNeeded = KErrNone;
|
|
97 |
TInt err = CPhoneCenRepProxy::Instance()->GetInt(
|
|
98 |
KCRUidMusicPlayerFeatures,
|
|
99 |
KRequireDRMInPlayback,
|
|
100 |
extSecNeeded );
|
|
101 |
|
|
102 |
iExtSecNeeded = ( ( err == KErrNone ) && extSecNeeded ) ? ETrue : EFalse;
|
|
103 |
iToneServer.SetExtendedSecurityNeeded( iExtSecNeeded );
|
|
104 |
|
|
105 |
CPhoneCenRepProxy::Instance()->NotifyChangeL(
|
|
106 |
KCRUidDRMHelperServer,
|
|
107 |
KDRMHelperServerNotificationPassive,
|
|
108 |
this );
|
|
109 |
|
|
110 |
// Check video player configuration.
|
|
111 |
iArbitraryVideoScaling =
|
|
112 |
CPhoneCenRepProxy::Instance()->IsTelephonyFeatureSupported(
|
|
113 |
KTelephonyLVFlagArbitraryVideoScaling );
|
|
114 |
|
|
115 |
// Construct the default ringing tone
|
|
116 |
TBuf<KMaxFileName> defaultTone;
|
|
117 |
err = CPhoneCenRepProxy::Instance()->GetString(
|
|
118 |
KCRUidProfileEngine,
|
|
119 |
KProEngDefaultRingingTone,
|
|
120 |
defaultTone );
|
|
121 |
|
|
122 |
if ( err == KErrNone )
|
|
123 |
{
|
|
124 |
iToneServer.SetDefaultRingingToneL( defaultTone );
|
|
125 |
}
|
|
126 |
|
|
127 |
// Get maximum tone file size
|
|
128 |
GetMaxToneFileSizeL( iToneFileSizeLimitKB );
|
|
129 |
|
|
130 |
// And set the tone size limit to the tone server too
|
|
131 |
iToneServer.SetToneFileSizeLimit( iToneFileSizeLimitKB );
|
|
132 |
}
|
|
133 |
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
// CPhoneRingingTonePlayerAO::~CPhoneRingingTonePlayerAO
|
|
136 |
// -----------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
CPhoneRingingTonePlayerAO::~CPhoneRingingTonePlayerAO()
|
|
139 |
{
|
|
140 |
Cancel();
|
|
141 |
iToneServer.Close();
|
|
142 |
|
|
143 |
delete iTimer;
|
|
144 |
delete iAudioVideoRingingTone;
|
|
145 |
}
|
|
146 |
|
|
147 |
// -----------------------------------------------------------------------------
|
|
148 |
// CPhoneRingingTonePlayerAO::PlayRingToneL
|
|
149 |
// -----------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
void CPhoneRingingTonePlayerAO::PlayRingToneL(
|
|
152 |
TPhoneCommandParam* aCommandParam )
|
|
153 |
{
|
|
154 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::PlayRingToneL()" );
|
|
155 |
|
|
156 |
// Check that the parameter is a ringing tone
|
|
157 |
if ( aCommandParam->ParamId() == TPhoneCommandParam::EPhoneParamIdRingTone )
|
|
158 |
{
|
|
159 |
// Cast to get the ringing tone parameters
|
|
160 |
TPhoneCmdParamRingTone* ringToneParam =
|
|
161 |
static_cast<TPhoneCmdParamRingTone*>( aCommandParam );
|
|
162 |
|
|
163 |
// Get volume and ringing tone type
|
|
164 |
const TInt volume = ringToneParam->Volume();
|
|
165 |
TProfileRingingType ringingType =
|
|
166 |
static_cast<TProfileRingingType>( ringToneParam->RingingType() );
|
|
167 |
|
|
168 |
// Set ringing tone file name to server
|
|
169 |
iToneServer.SetRingingToneL( ringToneParam->RingTone() );
|
|
170 |
|
|
171 |
if ( !iAudioVideoRingingTone )
|
|
172 |
{
|
|
173 |
iAudioVideoRingingTone = CPhoneRingingTone::NewL(
|
|
174 |
ringToneParam->RingTone() );
|
|
175 |
}
|
|
176 |
else if ( iAudioVideoRingingTone->FileName().Compare(
|
|
177 |
ringToneParam->RingTone() ) )
|
|
178 |
{
|
|
179 |
iAudioVideoRingingTone->SetFileName(
|
|
180 |
ringToneParam->RingTone() );
|
|
181 |
}
|
|
182 |
|
|
183 |
// Caller contact text and image and image has
|
|
184 |
// higher priority than video ringing tone set for caller.
|
|
185 |
if ( iAudioVideoRingingTone->IsVideoRingingTone() &&
|
|
186 |
ringToneParam->IsCallerImage() )
|
|
187 |
{
|
|
188 |
// Play only audio from video ringingtone
|
|
189 |
PlayAudioRingTone(
|
|
190 |
volume,
|
|
191 |
ringingType );
|
|
192 |
}
|
|
193 |
else if ( iAudioVideoRingingTone->IsVideoRingingTone() &&
|
|
194 |
!ringToneParam->IsCallerText() )
|
|
195 |
{
|
|
196 |
// Play video ring tone
|
|
197 |
const TBool ringToneIsPersonal = ringToneParam->Type() ==
|
|
198 |
EPhoneRingTonePersonal;
|
|
199 |
PlayVideoRingingTone(
|
|
200 |
*iAudioVideoRingingTone,
|
|
201 |
volume,
|
|
202 |
ringingType,
|
|
203 |
ringToneIsPersonal );
|
|
204 |
}
|
|
205 |
else
|
|
206 |
{
|
|
207 |
// Play text to speech, if available
|
|
208 |
if ( ringToneParam->TextToSay().Length() )
|
|
209 |
{
|
|
210 |
PlayTtsTone(
|
|
211 |
ringToneParam->TextToSay(),
|
|
212 |
volume,
|
|
213 |
ringingType );
|
|
214 |
}
|
|
215 |
// Play audio ring tone
|
|
216 |
PlayAudioRingTone(
|
|
217 |
volume,
|
|
218 |
ringingType );
|
|
219 |
}
|
|
220 |
}
|
|
221 |
}
|
|
222 |
|
|
223 |
// -----------------------------------------------------------------------------
|
|
224 |
// CPhoneRingingTonePlayerAO::PlayAudioRingTone
|
|
225 |
// -----------------------------------------------------------------------------
|
|
226 |
//
|
|
227 |
void CPhoneRingingTonePlayerAO::PlayAudioRingTone(
|
|
228 |
TInt aVolume,
|
|
229 |
TProfileRingingType aRingingType )
|
|
230 |
{
|
|
231 |
iToneServer.PlayAudioRingTone( aVolume, aRingingType );
|
|
232 |
}
|
|
233 |
|
|
234 |
// -----------------------------------------------------------------------------
|
|
235 |
// CPhoneRingingTonePlayerAO::BeepOnce
|
|
236 |
// -----------------------------------------------------------------------------
|
|
237 |
//
|
|
238 |
void CPhoneRingingTonePlayerAO::BeepOnce( TInt aVolume )
|
|
239 |
{
|
|
240 |
iToneServer.BeepOnce( aVolume );
|
|
241 |
}
|
|
242 |
|
|
243 |
// -----------------------------------------------------------------------------
|
|
244 |
// CPhoneRingingTonePlayerAO::PlaySilentTone
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
void CPhoneRingingTonePlayerAO::PlaySilentTone()
|
|
248 |
{
|
|
249 |
iToneServer.PlaySilentTone();
|
|
250 |
}
|
|
251 |
|
|
252 |
// -----------------------------------------------------------------------------
|
|
253 |
// CPhoneRingingTonePlayerAO::PlayUnsecureVoIPTone
|
|
254 |
// -----------------------------------------------------------------------------
|
|
255 |
//
|
|
256 |
void CPhoneRingingTonePlayerAO::PlayUnsecureVoIPTone()
|
|
257 |
{
|
|
258 |
iToneServer.PlayUnsecureVoIPTone();
|
|
259 |
}
|
|
260 |
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
// CPhoneRingingTonePlayerAO::MuteRingingToneOnAnswer
|
|
263 |
// -----------------------------------------------------------------------------
|
|
264 |
//
|
|
265 |
void CPhoneRingingTonePlayerAO::MuteRingingToneOnAnswer()
|
|
266 |
{
|
|
267 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::MuteRingingToneOnAnswer()" );
|
|
268 |
|
|
269 |
if ( iVideoPlayer &&
|
|
270 |
( iTonePlayingStatus == EVideoTonePlaying ||
|
|
271 |
iTonePlayingStatus == EPersonalVideoTonePlaying ) )
|
|
272 |
{
|
|
273 |
// Mute the video audio
|
|
274 |
iVideoPlayer->MuteVideoRingTone();
|
|
275 |
iTonePlayingStatus = ESilentVideoTonePlaying;
|
|
276 |
iVolume = 0;
|
|
277 |
}
|
|
278 |
else if ( iTonePlayingStatus != ESilentVideoTonePlaying )
|
|
279 |
{
|
|
280 |
iToneServer.MuteRingingTone();
|
|
281 |
}
|
|
282 |
}
|
|
283 |
|
|
284 |
// -----------------------------------------------------------------------------
|
|
285 |
// CPhoneRingingTonePlayerAO::MuteRingingTone
|
|
286 |
// -----------------------------------------------------------------------------
|
|
287 |
//
|
|
288 |
void CPhoneRingingTonePlayerAO::MuteRingingTone()
|
|
289 |
{
|
|
290 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::MuteRingingTone()" );
|
|
291 |
|
|
292 |
if ( iVideoPlayer &&
|
|
293 |
( iTonePlayingStatus == EVideoTonePlaying ||
|
|
294 |
iTonePlayingStatus == EPersonalVideoTonePlaying ) )
|
|
295 |
{
|
|
296 |
// Mute the video audio
|
|
297 |
iVideoPlayer->MuteVideoRingTone();
|
|
298 |
iTonePlayingStatus = ESilentVideoTonePlaying;
|
|
299 |
iVolume = 0;
|
|
300 |
}
|
|
301 |
else if ( iTonePlayingStatus != ESilentVideoTonePlaying )
|
|
302 |
{
|
|
303 |
StopPlaying();
|
|
304 |
}
|
|
305 |
}
|
|
306 |
|
|
307 |
// -----------------------------------------------------------------------------
|
|
308 |
// CPhoneRingingTonePlayerAO::StopPlaying
|
|
309 |
// -----------------------------------------------------------------------------
|
|
310 |
//
|
|
311 |
void CPhoneRingingTonePlayerAO::StopPlaying()
|
|
312 |
{
|
|
313 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::StopPlaying()" );
|
|
314 |
|
|
315 |
// Stop all playback
|
|
316 |
|
|
317 |
iToneServer.StopPlaying();
|
|
318 |
|
|
319 |
if ( iVideoPlayer )
|
|
320 |
{
|
|
321 |
iVideoPlayer->StopVideoRingTone();
|
|
322 |
}
|
|
323 |
|
|
324 |
iTimer->Cancel();
|
|
325 |
|
|
326 |
iTonePlayingStatus = EIdle;
|
|
327 |
}
|
|
328 |
|
|
329 |
// -----------------------------------------------------------------------------
|
|
330 |
// CPhoneRingingTonePlayerAO::PlayTtsTone
|
|
331 |
// -----------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
void CPhoneRingingTonePlayerAO::PlayTtsTone(
|
|
334 |
const TDesC& aTextToSay,
|
|
335 |
TInt aVolume,
|
|
336 |
TProfileRingingType aRingingType )
|
|
337 |
{
|
|
338 |
iToneServer.PlayTtsTone( aTextToSay, aVolume, aRingingType );
|
|
339 |
}
|
|
340 |
|
|
341 |
// -----------------------------------------------------------------------------
|
|
342 |
// CPhoneRingingTonePlayerAO::HandleTimeOutL
|
|
343 |
// -----------------------------------------------------------------------------
|
|
344 |
//
|
|
345 |
void CPhoneRingingTonePlayerAO::HandleTimeOutL()
|
|
346 |
{
|
|
347 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::HandleTimeOutL()" );
|
|
348 |
|
|
349 |
// Guarding timer for startup has expired
|
|
350 |
if ( iTonePlayingStatus == EVideoTonePlaying ||
|
|
351 |
iTonePlayingStatus == ESilentVideoTonePlaying ||
|
|
352 |
iTonePlayingStatus == EPersonalVideoTonePlaying )
|
|
353 |
{
|
|
354 |
iVideoPlayer->CancelVideoRingTone(); // close video ringtone display
|
|
355 |
PlayDefaultTone( iVolume, iRingingType );
|
|
356 |
}
|
|
357 |
}
|
|
358 |
|
|
359 |
// -----------------------------------------------------------------------------
|
|
360 |
// CPhoneRingingTonePlayerAO::PlayDefaultTone
|
|
361 |
// -----------------------------------------------------------------------------
|
|
362 |
//
|
|
363 |
void CPhoneRingingTonePlayerAO::PlayDefaultTone(
|
|
364 |
TInt aVolume,
|
|
365 |
TProfileRingingType aRingingType )
|
|
366 |
{
|
|
367 |
iToneServer.PlayDefaultTone( aVolume, aRingingType );
|
|
368 |
}
|
|
369 |
|
|
370 |
// -----------------------------------------------------------------------------
|
|
371 |
// CPhoneRingingTonePlayerAO::PlayBackupTone
|
|
372 |
// -----------------------------------------------------------------------------
|
|
373 |
//
|
|
374 |
void CPhoneRingingTonePlayerAO::PlayBackupTone(
|
|
375 |
TInt aVolume,
|
|
376 |
TProfileRingingType aRingingType )
|
|
377 |
{
|
|
378 |
iToneServer.PlayBackupTone( aVolume, aRingingType );
|
|
379 |
}
|
|
380 |
|
|
381 |
|
|
382 |
// -----------------------------------------------------------------------------
|
|
383 |
// CPhoneRingingTonePlayerAO::ConvertVideoRingingType
|
|
384 |
// -----------------------------------------------------------------------------
|
|
385 |
//
|
|
386 |
MPhoneVideoPlayer::TPlayMode CPhoneRingingTonePlayerAO::ConvertVideoRingingType(
|
|
387 |
TProfileRingingType aRingingType )
|
|
388 |
{
|
|
389 |
MPhoneVideoPlayer::TPlayMode playMode;
|
|
390 |
|
|
391 |
switch ( aRingingType )
|
|
392 |
{
|
|
393 |
case EProfileRingingTypeAscending:
|
|
394 |
playMode = MPhoneVideoPlayer::EPlayAscending;
|
|
395 |
break;
|
|
396 |
case EProfileRingingTypeRingingOnce:
|
|
397 |
playMode = MPhoneVideoPlayer::EPlayOnce;
|
|
398 |
break;
|
|
399 |
case EProfileRingingTypeRinging:
|
|
400 |
default:
|
|
401 |
playMode = MPhoneVideoPlayer::EPlayInLoop;
|
|
402 |
break;
|
|
403 |
}
|
|
404 |
|
|
405 |
return playMode;
|
|
406 |
}
|
|
407 |
|
|
408 |
// -----------------------------------------------------------------------------
|
|
409 |
// CPhoneRingingTonePlayerAO::RunL
|
|
410 |
// -----------------------------------------------------------------------------
|
|
411 |
//
|
|
412 |
void CPhoneRingingTonePlayerAO::RunL()
|
|
413 |
{
|
|
414 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::RunL()" );
|
|
415 |
|
|
416 |
switch ( iState )
|
|
417 |
{
|
|
418 |
case EPlayingDefaultVideo:
|
|
419 |
{
|
|
420 |
PlayAudioRingTone( iVolume, iRingingType );
|
|
421 |
}
|
|
422 |
break;
|
|
423 |
|
|
424 |
case EIdleState:
|
|
425 |
default:
|
|
426 |
break;
|
|
427 |
} // switch iState
|
|
428 |
|
|
429 |
iState = EIdleState;
|
|
430 |
}
|
|
431 |
|
|
432 |
// -----------------------------------------------------------------------------
|
|
433 |
// CPhoneRingingTonePlayerAO::DoCancel
|
|
434 |
// -----------------------------------------------------------------------------
|
|
435 |
//
|
|
436 |
void CPhoneRingingTonePlayerAO::DoCancel()
|
|
437 |
{
|
|
438 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::DoCancel()" );
|
|
439 |
// Request is completed immediately before SetActive.
|
|
440 |
}
|
|
441 |
|
|
442 |
// -----------------------------------------------------------------------------
|
|
443 |
// CPhoneRingingTonePlayerAO::SetVideoPlayer
|
|
444 |
// -----------------------------------------------------------------------------
|
|
445 |
//
|
|
446 |
void CPhoneRingingTonePlayerAO::SetVideoPlayer(
|
|
447 |
MPhoneVideoPlayer* aVideoPlayer )
|
|
448 |
{
|
|
449 |
iVideoPlayer = aVideoPlayer;
|
|
450 |
}
|
|
451 |
|
|
452 |
// -----------------------------------------------------------------------------
|
|
453 |
// CPhoneRingingTonePlayerAO::PlayVideoRingingTone
|
|
454 |
// -----------------------------------------------------------------------------
|
|
455 |
//
|
|
456 |
void CPhoneRingingTonePlayerAO::PlayVideoRingingTone(
|
|
457 |
const CPhoneRingingTone& aRingingTone,
|
|
458 |
TInt aVolume,
|
|
459 |
TProfileRingingType aRingingType,
|
|
460 |
TBool aPersonalTone )
|
|
461 |
{
|
|
462 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::PlayVideoRingingTone()" );
|
|
463 |
|
|
464 |
__ASSERT_DEBUG( iVideoPlayer, Panic( EPhoneViewGeneralError ) );
|
|
465 |
|
|
466 |
iVolume = aVolume;
|
|
467 |
iRingingType = aRingingType;
|
|
468 |
TBool startTimer( ETrue );
|
|
469 |
|
|
470 |
// Extended security check
|
|
471 |
if ( ExtendedSecurity() )
|
|
472 |
{
|
|
473 |
if ( !aRingingTone.IsFileInRom() &&
|
|
474 |
!aRingingTone.IsFileDrmProtected() )
|
|
475 |
{
|
|
476 |
__PHONELOG( EBasic,
|
|
477 |
EPhoneUIView,
|
|
478 |
"CPhoneRingingTonePlayerAO::HandleVideoPlayerError - PermissionDenied" );
|
|
479 |
PlayDefaultTone( iVolume, iRingingType );
|
|
480 |
return;
|
|
481 |
}
|
|
482 |
__PHONELOG( EBasic,
|
|
483 |
EPhoneUIView,
|
|
484 |
"CPhoneRingingTonePlayerAO::HandleVideoPlayerError - ExtSecChk ok" );
|
|
485 |
}
|
|
486 |
|
|
487 |
__PHONELOG( EBasic, EPhoneUIView, "CPhoneRingingTonePlayerAO::PlayVideoRingingTone - play" );
|
|
488 |
switch( aRingingType )
|
|
489 |
{
|
|
490 |
case EProfileRingingTypeSilent:
|
|
491 |
iVideoPlayer->PlayVideoRingTone(
|
|
492 |
aRingingTone.FileName(),
|
|
493 |
ConvertVideoRingingType( aRingingType ),
|
|
494 |
0,
|
|
495 |
iArbitraryVideoScaling,
|
|
496 |
this );
|
|
497 |
iToneServer.PlaySilentTone(); // To start vibra, video may fail.
|
|
498 |
iVolume = 0; // for repeat
|
|
499 |
startTimer = EFalse; // no need for fallback
|
|
500 |
break;
|
|
501 |
|
|
502 |
case EProfileRingingTypeBeepOnce:
|
|
503 |
iVideoPlayer->PlayVideoRingTone(
|
|
504 |
aRingingTone.FileName(),
|
|
505 |
ConvertVideoRingingType( aRingingType ),
|
|
506 |
0,
|
|
507 |
iArbitraryVideoScaling,
|
|
508 |
this );
|
|
509 |
BeepOnce( iVolume );
|
|
510 |
iVolume = 0; // for repeat
|
|
511 |
startTimer = EFalse; // no need for fallback
|
|
512 |
break;
|
|
513 |
default:
|
|
514 |
iVideoPlayer->PlayVideoRingTone(
|
|
515 |
aRingingTone.FileName(),
|
|
516 |
ConvertVideoRingingType( aRingingType ),
|
|
517 |
iVolume,
|
|
518 |
iArbitraryVideoScaling,
|
|
519 |
this );
|
|
520 |
break;
|
|
521 |
}
|
|
522 |
|
|
523 |
if ( aPersonalTone )
|
|
524 |
{
|
|
525 |
iTonePlayingStatus = EPersonalVideoTonePlaying;
|
|
526 |
}
|
|
527 |
else
|
|
528 |
{
|
|
529 |
iTonePlayingStatus = EVideoTonePlaying;
|
|
530 |
}
|
|
531 |
|
|
532 |
if ( startTimer && !iTimer->IsActive() )
|
|
533 |
{
|
|
534 |
// Start timer to guard video opening
|
|
535 |
iTimer->After( KPhoneMaxRingingWaiting, this );
|
|
536 |
}
|
|
537 |
|
|
538 |
}
|
|
539 |
|
|
540 |
// -----------------------------------------------------------------------------
|
|
541 |
// CPhoneRingingTonePlayerAO::HandleVideoPlayerError
|
|
542 |
// -----------------------------------------------------------------------------
|
|
543 |
//
|
|
544 |
void CPhoneRingingTonePlayerAO::HandleVideoPlayerError(
|
|
545 |
TPhoneVideoPlayerErrorEvent /*aEvent*/,
|
|
546 |
TInt aError )
|
|
547 |
{
|
|
548 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::HandleVideoPlayerError()" );
|
|
549 |
|
|
550 |
if ( aError )
|
|
551 |
{
|
|
552 |
__PHONELOG1( EBasic,
|
|
553 |
EPhoneUIView,
|
|
554 |
"CPhoneRingingTonePlayerAO::HandleVideoPlayerError - error (%d)",
|
|
555 |
aError );
|
|
556 |
}
|
|
557 |
|
|
558 |
// cancel guarding timer
|
|
559 |
iTimer->Cancel();
|
|
560 |
|
|
561 |
// to remove video window
|
|
562 |
iVideoPlayer->CancelVideoRingTone();
|
|
563 |
|
|
564 |
if ( iTonePlayingStatus == EPersonalVideoTonePlaying )
|
|
565 |
{
|
|
566 |
// Play default tone (active profile tone).
|
|
567 |
if ( iAudioVideoRingingTone &&
|
|
568 |
!iAudioVideoRingingTone->IsVideoRingingTone() )
|
|
569 |
{
|
|
570 |
iToneServer.PlayAudioRingTone( iVolume, iRingingType );
|
|
571 |
}
|
|
572 |
else // audio/video tone is video
|
|
573 |
{
|
|
574 |
PlayDefaultVideoAsync();
|
|
575 |
}
|
|
576 |
}
|
|
577 |
else
|
|
578 |
{
|
|
579 |
// Play backup tone
|
|
580 |
PlayDefaultTone( iVolume, iRingingType );
|
|
581 |
}
|
|
582 |
|
|
583 |
}
|
|
584 |
|
|
585 |
// -----------------------------------------------------------------------------
|
|
586 |
// CPhoneRingingTonePlayerAO::HandleVideoPlayerInitComplete
|
|
587 |
// -----------------------------------------------------------------------------
|
|
588 |
//
|
|
589 |
void CPhoneRingingTonePlayerAO::HandleVideoPlayerInitComplete()
|
|
590 |
{
|
|
591 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::HandleVideoPlayerInitComplete()" );
|
|
592 |
|
|
593 |
// cancel guarding timer
|
|
594 |
iTimer->Cancel();
|
|
595 |
|
|
596 |
}
|
|
597 |
|
|
598 |
// -----------------------------------------------------------------------------
|
|
599 |
// CPhoneRingingTonePlayerAO::HandleVideoPlayerPlayingComplete
|
|
600 |
// -----------------------------------------------------------------------------
|
|
601 |
//
|
|
602 |
void CPhoneRingingTonePlayerAO::HandleVideoPlayerPlayingComplete()
|
|
603 |
{
|
|
604 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::HandleVideoPlayerPlayingComplete()" );
|
|
605 |
}
|
|
606 |
|
|
607 |
// -----------------------------------------------------------------------------
|
|
608 |
// CPhoneRingingTonePlayerAO::PlayDefaultVideoAsync
|
|
609 |
// -----------------------------------------------------------------------------
|
|
610 |
//
|
|
611 |
void CPhoneRingingTonePlayerAO::PlayDefaultVideoAsync()
|
|
612 |
{
|
|
613 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::PlayDefaultVideoAsync()" );
|
|
614 |
|
|
615 |
Cancel();
|
|
616 |
|
|
617 |
iState = EPlayingDefaultVideo;
|
|
618 |
|
|
619 |
TRequestStatus* status = &iStatus;
|
|
620 |
User::RequestComplete( status, KErrNone );
|
|
621 |
SetActive();
|
|
622 |
}
|
|
623 |
|
|
624 |
// -----------------------------------------------------------------------------
|
|
625 |
// CPhoneRingingTonePlayerAO::ExtendedSecurity
|
|
626 |
// -----------------------------------------------------------------------------
|
|
627 |
//
|
|
628 |
TBool CPhoneRingingTonePlayerAO::ExtendedSecurity() const
|
|
629 |
{
|
|
630 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::ExtendedSecurity()" );
|
|
631 |
return iExtSecNeeded;
|
|
632 |
}
|
|
633 |
|
|
634 |
|
|
635 |
// -----------------------------------------------------------------------------
|
|
636 |
// CPhoneRingingTonePlayerAO::CheckAndHandleToneSizeLimit
|
|
637 |
// -----------------------------------------------------------------------------
|
|
638 |
//
|
|
639 |
TBool CPhoneRingingTonePlayerAO::CheckAndHandleToneSizeLimit(
|
|
640 |
CPhoneRingingTone* aRingingTone )
|
|
641 |
{
|
|
642 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::CheckAndHandleToneSizeLimit()" );
|
|
643 |
|
|
644 |
TBool bValidSize = ETrue;
|
|
645 |
|
|
646 |
// If user has somehow managed to get a too large file as ringing tone,
|
|
647 |
// play default tone instead.
|
|
648 |
if ( iToneFileSizeLimitKB )
|
|
649 |
{
|
|
650 |
if ( CheckToneFileSize( aRingingTone->FileName(), iToneFileSizeLimitKB) != KErrNone )
|
|
651 |
{
|
|
652 |
bValidSize = EFalse;
|
|
653 |
}
|
|
654 |
}
|
|
655 |
__PHONELOG1(
|
|
656 |
EBasic,
|
|
657 |
EPhoneUIView,
|
|
658 |
"CPhoneRingingTonePlayerAO::CheckAndHandleToneSizeLimit - bValidSize(%d)",
|
|
659 |
bValidSize);
|
|
660 |
|
|
661 |
return bValidSize;
|
|
662 |
}
|
|
663 |
|
|
664 |
// -----------------------------------------------------------------------------
|
|
665 |
// CPhoneRingingTonePlayerAO::CheckToneFileSize
|
|
666 |
// -----------------------------------------------------------------------------
|
|
667 |
//
|
|
668 |
TInt CPhoneRingingTonePlayerAO::CheckToneFileSize( const TDesC& aFile, TInt aSizeLimitKB )
|
|
669 |
{
|
|
670 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::CheckToneFileSize()" );
|
|
671 |
|
|
672 |
// Get file size
|
|
673 |
TInt size = 0;
|
|
674 |
TInt error = KErrNone;
|
|
675 |
RFs& fs = CCoeEnv::Static()->FsSession();
|
|
676 |
TEntry entry;
|
|
677 |
if (KErrNone == fs.Entry( aFile, entry ))
|
|
678 |
{
|
|
679 |
size = entry.iSize;
|
|
680 |
}
|
|
681 |
|
|
682 |
// Check
|
|
683 |
aSizeLimitKB *= Kkilo;
|
|
684 |
if ( aSizeLimitKB && size > aSizeLimitKB )
|
|
685 |
{
|
|
686 |
error = KErrTooBig;
|
|
687 |
}
|
|
688 |
|
|
689 |
__PHONELOG1(
|
|
690 |
EBasic,
|
|
691 |
EPhoneUIView,
|
|
692 |
"CPhoneRingingTonePlayerAO::CheckToneFileSize - size (%d)",
|
|
693 |
size );
|
|
694 |
return error;
|
|
695 |
}
|
|
696 |
|
|
697 |
|
|
698 |
// -----------------------------------------------------------------------------
|
|
699 |
// CPhoneRingingTonePlayerAO::GetMaxToneFileSizeL
|
|
700 |
// -----------------------------------------------------------------------------
|
|
701 |
//
|
|
702 |
void CPhoneRingingTonePlayerAO::GetMaxToneFileSizeL( TInt& aMaxSizeKB ) const
|
|
703 |
{
|
|
704 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::GetMaxToneFileSizeL()" );
|
|
705 |
|
|
706 |
const TInt error = CPhoneCenRepProxy::Instance()->GetInt(
|
|
707 |
KCRUidProfileEngine,
|
|
708 |
KProEngRingingToneMaxSize,
|
|
709 |
aMaxSizeKB );
|
|
710 |
|
|
711 |
if ( error != KErrNone )
|
|
712 |
{
|
|
713 |
aMaxSizeKB = 0;
|
|
714 |
}
|
|
715 |
if ( aMaxSizeKB < 0 )
|
|
716 |
{
|
|
717 |
aMaxSizeKB = 0;
|
|
718 |
}
|
|
719 |
|
|
720 |
__PHONELOG2(
|
|
721 |
EBasic,
|
|
722 |
EPhoneUIView,
|
|
723 |
"CPhoneRingingTonePlayerAO::GetMaxToneFileSizeL - error (%d), aMaxSizeKB(%d)",
|
|
724 |
error,
|
|
725 |
aMaxSizeKB );
|
|
726 |
}
|
|
727 |
|
|
728 |
// -----------------------------------------------------------
|
|
729 |
// CPhoneRingingTonePlayerAO::HandleCenRepChangeL
|
|
730 |
// -----------------------------------------------------------
|
|
731 |
//
|
|
732 |
void CPhoneRingingTonePlayerAO::HandleCenRepChangeL(
|
|
733 |
const TUid& aUid,
|
|
734 |
const TUint /*aId*/ )
|
|
735 |
{
|
|
736 |
__LOGMETHODSTARTEND( EPhoneUIView, "CPhoneRingingTonePlayerAO::HandleCenRepChangeL()");
|
|
737 |
|
|
738 |
if ( aUid == KCRUidDRMHelperServer )
|
|
739 |
{
|
|
740 |
TBuf<256> tempBuf16( KNullDesC );
|
|
741 |
|
|
742 |
User::LeaveIfError( CPhoneCenRepProxy::Instance()->GetString(
|
|
743 |
KCRUidDRMHelperServer,
|
|
744 |
KDRMHelperServerNotificationPassive,
|
|
745 |
tempBuf16 ) );
|
|
746 |
|
|
747 |
const TBool idleIsTopApp = CPhonePubSubProxy::Instance()->Value(
|
|
748 |
KPSUidAiInformation, KActiveIdleState ) == EPSAiForeground;
|
|
749 |
|
|
750 |
// Quick validity check and
|
|
751 |
// The first Tuint8 is the times the content has been informed.
|
|
752 |
// Note should not shown until Idle.
|
|
753 |
if ( idleIsTopApp && tempBuf16.Length() >= KPhoneMinDRMTextLength )
|
|
754 |
{
|
|
755 |
TBuf8<256> tempBuf8;
|
|
756 |
TPtrC8 ptr((TUint8*)tempBuf16.Ptr(), tempBuf16.Size());
|
|
757 |
HBufC8* buf8 = HBufC8::NewLC( 256 );
|
|
758 |
buf8->Des().Copy(ptr);
|
|
759 |
// Extract URI etc.
|
|
760 |
// buf8 format:
|
|
761 |
//<TUint8 aTimes><TUint8 aExpirationMark>
|
|
762 |
//<TUint8 aPermissionType>
|
|
763 |
//<TUint8 aAutomatedContentType><TDesC8 aContentID>
|
|
764 |
TInt8 count = (TInt8)(*(buf8->Ptr()));
|
|
765 |
TChar mark = (TChar)(*(buf8->Ptr()+1));
|
|
766 |
TInt8 permtype = (TChar)(*(buf8->Ptr()+2));
|
|
767 |
TInt8 automcontenttype = (TChar)(*(buf8->Ptr()+3));
|
|
768 |
TBuf8<256> curi = buf8->Right( buf8->Length()-4);
|
|
769 |
|
|
770 |
if ( curi.Ptr()[curi.Size()-1] == 0 )
|
|
771 |
{
|
|
772 |
// The last character in the descriptor is 0, which means
|
|
773 |
// that the original 16-bit desc was padded so
|
|
774 |
// remove the last char...
|
|
775 |
curi.SetLength(curi.Size()-1);
|
|
776 |
}
|
|
777 |
|
|
778 |
// Create DRM helper.
|
|
779 |
CDRMHelper* drmHelper = CDRMHelper::NewLC();
|
|
780 |
// Show notification.
|
|
781 |
drmHelper->SetAutomatedType( (CDRMHelper::TDRMHelperAutomatedType)automcontenttype );
|
|
782 |
TInt error = drmHelper->CheckRightsAmountL( curi );
|
|
783 |
|
|
784 |
__PHONELOG1( EBasic, EPhoneUIView,
|
|
785 |
"CPhoneRingingTonePlayerAO::HandleCenRepChangeL > CheckRightsAmountL, error: %d"
|
|
786 |
, error );
|
|
787 |
|
|
788 |
CleanupStack::PopAndDestroy( drmHelper );
|
|
789 |
CleanupStack::PopAndDestroy( buf8 );
|
|
790 |
}
|
|
791 |
}
|
|
792 |
}
|
|
793 |
|
|
794 |
// End of File
|