1 /* |
|
2 * Copyright (c) 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: Send DTMF string if necessary after creating a call |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <etelmm.h> |
|
19 #include <mmtsy_names.h> |
|
20 #include "msatmultimodeapi.h" |
|
21 #include "csetupcalldtmfsender.h" |
|
22 #include "msatasynctosync.h" |
|
23 #include "SatLog.h" |
|
24 |
|
25 _LIT( KSatDtmfCharp, "p" ); |
|
26 _LIT( KSatDtmfCharw, "w" ); |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CSetupCallDtmfSender::CSetupCallDtmfSender |
|
32 // The class constructor. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CSetupCallDtmfSender::CSetupCallDtmfSender( MSatMultiModeApi& aPhone ) |
|
36 : CActive( EPriorityStandard ), iPhone( aPhone ), iDtmfString( NULL ) |
|
37 { |
|
38 LOG( SIMPLE, |
|
39 "SETUPCALL: CSetupCallDtmfSender::CSetupCallDtmfSender calling" ) |
|
40 |
|
41 CActiveScheduler::Add( this ); |
|
42 |
|
43 LOG( SIMPLE, |
|
44 "SETUPCALL: CSetupCallDtmfSender::CSetupCallDtmfSender exiting" ) |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CSetupCallDtmfSender::NewL |
|
49 // Two-phased constructor. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CSetupCallDtmfSender* CSetupCallDtmfSender::NewL( MSatMultiModeApi& aPhone ) |
|
53 { |
|
54 LOG( SIMPLE, "SETUPCALL: CSetupCallDtmfSender::NewL calling" ) |
|
55 |
|
56 CSetupCallDtmfSender* self = |
|
57 new ( ELeave ) CSetupCallDtmfSender( aPhone ); |
|
58 |
|
59 LOG( SIMPLE, "SETUPCALL: CSetupCallDtmfSender::NewL exiting" ) |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CSetupCallDtmfSender::~CSetupCallDtmfSender |
|
65 // Destructor |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CSetupCallDtmfSender::~CSetupCallDtmfSender() |
|
69 { |
|
70 LOG( SIMPLE, "SETUPCALL: \ |
|
71 CSetupCallDtmfSender::~CSetupCallDtmfSender calling" ) |
|
72 Cancel(); |
|
73 |
|
74 delete iDtmfString; |
|
75 iDtmfString = NULL; |
|
76 |
|
77 LOG( SIMPLE, "SETUPCALL: \ |
|
78 CSetupCallDtmfSender::~CSetupCallDtmfSender exiting" ) |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CSetupCallDtmfSender::SendDtmfString |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CSetupCallDtmfSender::SendDtmfString() |
|
86 { |
|
87 LOG( SIMPLE, "SETUPCALL: CSetupCallDtmfSender::SendDtmfString calling" ) |
|
88 if( !IsActive() && iDtmfString ) |
|
89 { |
|
90 const TInt ret = iPhone.ContinueDTMFStringSending( ETrue ); |
|
91 LOG2( SIMPLE, "SETUPCALL: CSetupCallDtmfSender::SendDtmfString\ |
|
92 ContinueDTMFStringSending ret %d", ret ) |
|
93 iPhone.SendDTMFTones( iStatus, *iDtmfString ); |
|
94 |
|
95 SetActive(); |
|
96 } |
|
97 LOG( SIMPLE, "SETUPCALL: CSetupCallDtmfSender::SendDtmfString exit" ) |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CSetupCallDtmfSender::SeparateDtmfFromTelNumber |
|
102 // Refers to |
|
103 // RPhCltEmergencyCall::RemoveDTMF |
|
104 // RPhCltEmergencyCall::FindStartOfDtmfString |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CSetupCallDtmfSender::SeparateDtmfFromTelNumber(TDes& aString) |
|
108 { |
|
109 LOG( SIMPLE, |
|
110 "SETUPCALL: CSetupCallDtmfSender::SeparateDtmfFromTelNumber calling") |
|
111 |
|
112 delete iDtmfString; |
|
113 iDtmfString = NULL; |
|
114 |
|
115 // String must contain 'p' or 'w'. Find start of dtmf string. |
|
116 TInt indexp; //char 'p' index |
|
117 TInt indexw; // char 'w' index |
|
118 TPtrC ptrDtmfCharp( KSatDtmfCharp ); |
|
119 TPtrC ptrDtmfCharw( KSatDtmfCharw ); |
|
120 |
|
121 indexp = aString.Locate( ptrDtmfCharp[ 0 ] ); |
|
122 indexw = aString.Locate( ptrDtmfCharw[ 0 ] ); |
|
123 |
|
124 TInt dtmfIndex = KErrNotFound; |
|
125 if ( indexp != KErrNotFound || indexw != KErrNotFound ) |
|
126 { |
|
127 // dtmf char found |
|
128 if ( indexw == KErrNotFound ) |
|
129 { |
|
130 // char p index |
|
131 dtmfIndex = indexp; |
|
132 } |
|
133 else if ( indexp == KErrNotFound ) |
|
134 { |
|
135 // char w index |
|
136 dtmfIndex = indexw; |
|
137 } |
|
138 else |
|
139 { |
|
140 // Both chars p and w found, smaller index selected |
|
141 indexp < indexw ? dtmfIndex = indexp : dtmfIndex = indexw; |
|
142 } |
|
143 } |
|
144 LOG2( SIMPLE, |
|
145 "SETUPCALL: CSetupCallDtmfSender::SeparateDtmfFromTelNumber \ |
|
146 dtmfIndex=%d", dtmfIndex ) |
|
147 |
|
148 // Separate purl tel number and dtmf string |
|
149 if ( dtmfIndex != KErrNotFound ) |
|
150 { |
|
151 // Dtmf string to member data for furture sending |
|
152 TPtrC temp( aString.Right( aString.Length() - dtmfIndex ) ); |
|
153 LOG2( SIMPLE, |
|
154 "SETUPCALL: CSetupCallDtmfSender::SeparateDtmfFromTelNumber \ |
|
155 DTMF=%S", &temp) |
|
156 |
|
157 iDtmfString = temp.Alloc(); |
|
158 LOG2( SIMPLE, |
|
159 "SETUPCALL: CSetupCallDtmfSender::SeparateDtmfFromTelNumber \ |
|
160 iDtmfString address=%d", iDtmfString ) |
|
161 |
|
162 // Tel number for dialing call |
|
163 aString.Delete( dtmfIndex, aString.Length() - dtmfIndex ); |
|
164 LOG2( SIMPLE, |
|
165 "SETUPCALL: CSetupCallDtmfSender::SeparateDtmfFromTelNumber \ |
|
166 TelNumber=%S", &aString ) |
|
167 } |
|
168 LOG( SIMPLE, |
|
169 "SETUPCALL: CSetupCallDtmfSender::SeparateDtmfFromTelNumber exit" ) |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CSetupCallDtmfSender::RunL |
|
174 // Handles the command. |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CSetupCallDtmfSender::RunL() |
|
178 { |
|
179 LOG2( SIMPLE, "SETUPCALL: CSetupCallDtmfSender::RunL calling iStatus=%i", |
|
180 iStatus.Int() ) |
|
181 |
|
182 delete iDtmfString; |
|
183 iDtmfString = NULL; |
|
184 |
|
185 LOG( SIMPLE, "SETUPCALL: CSetupCallDtmfSender::RunL exiting" ) |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // From class CActive. |
|
190 // Cancels the sat request. |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 void CSetupCallDtmfSender::DoCancel() |
|
194 { |
|
195 LOG( SIMPLE, "SETUPCALL: CSetupCallDtmfSender::DoCancel calling" ) |
|
196 iPhone.CancelAsyncRequest( EMobilePhoneSendDTMFTones ); |
|
197 LOG( SIMPLE, "SETUPCALL: CSetupCallDtmfSender::DoCancel exiting" ) |
|
198 } |
|
199 |
|
200 // End of File |
|