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