|
1 /* |
|
2 * Copyright (c) 2010 - 2010 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: Phone ringing tone server session. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32base.h> |
|
21 #include <utf.h> |
|
22 |
|
23 #include "phoneconstants.h" |
|
24 #include "mphonetoneserver.h" |
|
25 #include "cphonetoneserver.h" |
|
26 #include "phoneringingtonetrace.h" |
|
27 #include "cphonetoneserversession.h" |
|
28 #include "cphonetoneserverplaybackcontroller.h" |
|
29 |
|
30 |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CPhoneToneServerSession::CPhoneToneServerSession |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CPhoneToneServerSession::CPhoneToneServerSession( const MPhoneToneServer& aServer ) |
|
39 : iServer( aServer ) |
|
40 { |
|
41 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::CPhoneToneServerSession <"); |
|
42 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::CPhoneToneServerSession >"); |
|
43 } |
|
44 |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CPhoneToneServerSession::~CPhoneToneServerSession |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CPhoneToneServerSession::~CPhoneToneServerSession() |
|
51 { |
|
52 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::~CPhoneToneServerSession <"); |
|
53 delete iController; |
|
54 iServer.RunDown(); |
|
55 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::~CPhoneToneServerSession >"); |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CPhoneToneServerSession::NewL |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CPhoneToneServerSession* CPhoneToneServerSession::NewL( const MPhoneToneServer& aServer ) |
|
63 { |
|
64 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::NewL <"); |
|
65 CPhoneToneServerSession* self = new( ELeave )CPhoneToneServerSession( aServer ); |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop( self ); |
|
69 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::NewL >"); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CPhoneToneServerSession::ConstructL |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CPhoneToneServerSession::ConstructL() |
|
78 { |
|
79 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::ConstructL <"); |
|
80 iController = CPhoneToneServerPlaybackController::NewL(); |
|
81 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::ConstructL >"); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CPhoneToneServerSession::ServiceL |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CPhoneToneServerSession::ServiceL( const RMessage2& aMessage ) |
|
89 { |
|
90 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::ServiceL <"); |
|
91 TInt volume = aMessage.Int1(); |
|
92 TProfileRingingType ringingType = ( TProfileRingingType )aMessage.Int2(); |
|
93 |
|
94 switch ( aMessage.Function() ) |
|
95 { |
|
96 |
|
97 //S^4 onwards supported types are |
|
98 //EProfileRingingTypeRinging and EProfileRingingTypeSilent |
|
99 case EPlayAudioRingTone: |
|
100 { |
|
101 if ( EProfileRingingTypeSilent == ringingType ) |
|
102 { |
|
103 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::ServiceL - EProfileRingingTypeSilent"); |
|
104 iController->PlaySilentTone(); |
|
105 } |
|
106 else |
|
107 { |
|
108 TFileName filename; |
|
109 if ( aMessage.GetDesLength( 0 ) < filename.MaxLength() ) |
|
110 { |
|
111 // Ignore error. |
|
112 // Handling is done in audio playing sequence. |
|
113 aMessage.Read( 0, filename ); |
|
114 } |
|
115 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::ServiceL - playNormalTone"); |
|
116 iController->PlayNormalToneL( filename, volume, ringingType ); |
|
117 } |
|
118 } |
|
119 break; |
|
120 |
|
121 case EStopPlaying: |
|
122 { |
|
123 iController->StopTone(); |
|
124 } |
|
125 break; |
|
126 |
|
127 default: |
|
128 break; |
|
129 } |
|
130 |
|
131 aMessage.Complete( KErrNone ); |
|
132 PHONERINGINGTONE_PRINT("CPhoneToneServerSession::ServiceL >"); |
|
133 } |
|
134 |
|
135 // End of file |