1 /* |
|
2 * Copyright (c) 2004-2008 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: CPEParserPhoneNumberHandler class methods implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "cpeclientcallrequestmonitor.h" |
|
22 #include "cpemessagehandler.h" |
|
23 #include "cpeparserphonenumberhandler.h" |
|
24 #include <featmgr.h> |
|
25 #include <gsmerror.h> |
|
26 #include <mpecallhandling.h> |
|
27 #include <mpedatastore.h> |
|
28 #include <talogger.h> |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT( KClirSuppress, "*31#" ); |
|
32 _LIT( KClirInvoke, "#31#" ); |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================================= |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CPEParserPhoneNumberHandler::CPEParserPhoneNumberHandler |
|
38 // C++ default constructor can NOT contain any code, that |
|
39 // might leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CPEParserPhoneNumberHandler::CPEParserPhoneNumberHandler( |
|
43 CPEMessageHandler& aOwner, |
|
44 MPECallHandling& aCallHandling, |
|
45 MPEDataStore& aDataStore |
|
46 ) : iOwner( aOwner ), |
|
47 iCallHandling( aCallHandling ), |
|
48 iDataStore( aDataStore ) |
|
49 { |
|
50 TEFLOGSTRING( KTAOBJECT, "PE CPEParserPhoneNumberHandler::CPEParserPhoneNumberHandler" ) |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CPEParserPhoneNumberHandler::ProcessDialToNumberL |
|
55 // Process dial to number. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void CPEParserPhoneNumberHandler::ProcessDialToNumberL( |
|
59 const TDesC& aNumber, |
|
60 const TDesC& aDtmfPostfix, |
|
61 TClir aClir ) |
|
62 { |
|
63 TInt errorCode( ECCPErrorNotFound ); |
|
64 TPEPhoneNumber phoneNumber; |
|
65 TInt callId; |
|
66 |
|
67 TEFLOGSTRING3( KTAINT, |
|
68 "PE CPEParserPhoneNumberHandler::ProcessDialToNumberL, number: %S, dtmf postfix: %S", |
|
69 &aNumber, |
|
70 &aDtmfPostfix ); |
|
71 |
|
72 // Check if phone is locked |
|
73 iOwner.CheckIfPhoneIsLockedL(); |
|
74 |
|
75 if ( aNumber.Length() == 0 ) |
|
76 { |
|
77 User::Leave( ECCPErrorInvalidPhoneNumber ); |
|
78 } |
|
79 |
|
80 if ( aClir == EClirSuppress ) |
|
81 { |
|
82 phoneNumber.Copy( KClirSuppress ); |
|
83 } |
|
84 else if ( aClir == EClirInvoke ) |
|
85 { |
|
86 phoneNumber.Copy( KClirInvoke ); |
|
87 } |
|
88 |
|
89 phoneNumber.Append( aNumber ); |
|
90 |
|
91 TPECallType processType = iDataStore.CallTypeCommand(); |
|
92 if( processType != EPECallTypeVideo ) |
|
93 { |
|
94 // TSY not accept phone number that include + or w chartes. |
|
95 TPEPhoneNumber postfix = FilterPostfixL( aDtmfPostfix ); |
|
96 if( postfix.Length() ) |
|
97 { |
|
98 phoneNumber.Append( postfix ); |
|
99 } |
|
100 } |
|
101 TEFLOGSTRING2( KTAINT, |
|
102 "PE CPEParserPhoneNumberHandler::ProcessDialToNumberL, phoneNumber: %S" |
|
103 , &phoneNumber ); |
|
104 //Check for Offline mode |
|
105 if ( IsPhoneOffline() ) |
|
106 { |
|
107 //Offline mode is active or network registration failed, |
|
108 //only emergency calls allowed |
|
109 TEFLOGSTRING( KTAERROR, |
|
110 "PE CPEGSMPARSERPHONENUMBERHANDLER::PROCESSDIALTONUMBERL: CURRENTLY IN OFFLINE MODE: EMERGENCY CALLS ONLY! " ); |
|
111 errorCode = ECCPErrorNotAllowedInOfflineMode; |
|
112 } |
|
113 else |
|
114 { |
|
115 switch ( processType ) |
|
116 { |
|
117 case EPECallTypeUninitialized: // There is no information about call, assume voice call |
|
118 case EPECallTypeCSVoice: //Make Dial request |
|
119 case EPECallTypeVoIP: |
|
120 { |
|
121 |
|
122 TBool clientCall = iDataStore.CallOriginCommand() != EPECallOriginPhone; |
|
123 errorCode = iCallHandling.DialCall( phoneNumber, callId ); |
|
124 //PhoneClient originated call |
|
125 if( clientCall && ( ECCPErrorNone == errorCode ) ) |
|
126 { |
|
127 iOwner.SetClientInformation( callId, phoneNumber ); |
|
128 } |
|
129 break; |
|
130 } |
|
131 case EPECallTypeVideo: |
|
132 { |
|
133 |
|
134 TBool clientCall = iDataStore.CallOriginCommand() != EPECallOriginPhone; |
|
135 errorCode = iCallHandling.DialMultimedia( phoneNumber, callId ); |
|
136 // Note that video call dialing does not return an error code if it fails |
|
137 // due to insufficient free memory, so we have to check the call identifier as well. |
|
138 if( clientCall |
|
139 && callId != KPECallIdNotUsed |
|
140 && ( ECCPErrorNone == errorCode ) ) |
|
141 { |
|
142 iOwner.SetClientInformation( callId, phoneNumber ); |
|
143 } |
|
144 break; |
|
145 } |
|
146 default: |
|
147 { |
|
148 errorCode = ECCPErrorNotFound; |
|
149 break; |
|
150 } |
|
151 } |
|
152 if ( !errorCode ) |
|
153 { |
|
154 //Set Dtmf string to dataStore |
|
155 iDataStore.SetDtmfPostFix( aDtmfPostfix, callId ); |
|
156 } |
|
157 } |
|
158 iOwner.SetGsmParserErrorCode( errorCode ); |
|
159 |
|
160 // KErrInUse is returned when we are not allowed to make the call. |
|
161 // One of these cases would be where a MO call is alerting and the user |
|
162 // tries to dial another number via Dialer |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CPEParserPhoneNumberHandler::FilterPostfix |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 TPtrC CPEParserPhoneNumberHandler::FilterPostfixL( TPtrC aPostfix ) |
|
170 { |
|
171 TLex input( aPostfix ); |
|
172 TInt stripStart = KErrNotFound; |
|
173 TInt postfixLength = aPostfix.Length(); |
|
174 for ( TInt i = 0; i != postfixLength; i ++ ) |
|
175 { |
|
176 TChar ch( input.Peek() ); |
|
177 if (ch == KDtmfPlus) |
|
178 { |
|
179 User::Leave ( ECCPErrorInvalidPhoneNumber ); |
|
180 } |
|
181 else if ( ch == KDtmfWait ) |
|
182 { |
|
183 if ( i < stripStart || stripStart == KErrNotFound ) |
|
184 { |
|
185 stripStart = i; |
|
186 } |
|
187 } |
|
188 } |
|
189 if ( stripStart != KErrNotFound ) |
|
190 { |
|
191 return aPostfix.Left( stripStart ); |
|
192 } |
|
193 else |
|
194 { |
|
195 return aPostfix; |
|
196 } |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CPEParserPhoneNumberHandler::IsPhoneOffline |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
|
203 TBool CPEParserPhoneNumberHandler::IsPhoneOffline() |
|
204 { |
|
205 TBool isPhoneOffline( EFalse ); |
|
206 |
|
207 if( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) |
|
208 && ( iDataStore.ProfileId() == EProfileOffLineId ) ) |
|
209 { |
|
210 isPhoneOffline = ETrue; |
|
211 } |
|
212 |
|
213 TNWNetworkRegistrationStatus networkRegStatus |
|
214 = iDataStore.NetworkRegistrationStatus(); |
|
215 |
|
216 if( ( networkRegStatus == ENWStatusRegistrationUnknown ) |
|
217 || ( networkRegStatus == ENWStatusNotRegisteredNoService ) |
|
218 || ( networkRegStatus == ENWStatusNotRegisteredEmergencyOnly ) |
|
219 || ( networkRegStatus == ENWStatusRegistrationDenied ) ) |
|
220 { |
|
221 isPhoneOffline = ETrue; |
|
222 } |
|
223 |
|
224 return isPhoneOffline; |
|
225 } |
|
226 |
|
227 // End of File |
|