author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:33:21 +0100 | |
branch | GCC_SURGE |
changeset 51 | f39ed5e045e0 |
parent 30 | ebdbd102c78a |
parent 46 | bc5a64e5bc3c |
permissions | -rw-r--r-- |
37 | 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 |
} |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
188 |
input.Inc(); |
37 | 189 |
} |
190 |
if ( stripStart != KErrNotFound ) |
|
191 |
{ |
|
192 |
return aPostfix.Left( stripStart ); |
|
193 |
} |
|
194 |
else |
|
195 |
{ |
|
196 |
return aPostfix; |
|
197 |
} |
|
198 |
} |
|
199 |
||
200 |
// ----------------------------------------------------------------------------- |
|
201 |
// CPEParserPhoneNumberHandler::IsPhoneOffline |
|
202 |
// ----------------------------------------------------------------------------- |
|
203 |
// |
|
204 |
TBool CPEParserPhoneNumberHandler::IsPhoneOffline() |
|
205 |
{ |
|
206 |
TBool isPhoneOffline( EFalse ); |
|
207 |
||
208 |
if( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
209 |
&& ( EFalse == iOwner.IsNetworkConnectionAllowed() ) ) |
37 | 210 |
{ |
211 |
isPhoneOffline = ETrue; |
|
212 |
} |
|
213 |
||
214 |
TNWNetworkRegistrationStatus networkRegStatus |
|
215 |
= iDataStore.NetworkRegistrationStatus(); |
|
216 |
||
217 |
if( ( networkRegStatus == ENWStatusRegistrationUnknown ) |
|
218 |
|| ( networkRegStatus == ENWStatusNotRegisteredNoService ) |
|
219 |
|| ( networkRegStatus == ENWStatusNotRegisteredEmergencyOnly ) |
|
220 |
|| ( networkRegStatus == ENWStatusRegistrationDenied ) ) |
|
221 |
{ |
|
222 |
isPhoneOffline = ETrue; |
|
223 |
} |
|
224 |
||
225 |
return isPhoneOffline; |
|
226 |
} |
|
227 |
||
228 |
// End of File |