24
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Sony Ericsson Mobile Communications AB
|
|
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 |
* Sony Ericsson Mobile Communications AB - initial contribution.
|
|
11 |
* Nokia Corporation - additional changes.
|
|
12 |
*
|
|
13 |
* Contributors:
|
|
14 |
*
|
|
15 |
* Description:
|
|
16 |
* Code for TelephonyFuncLine class, used by CTelephony class.
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
|
|
21 |
/**
|
|
22 |
@file
|
|
23 |
*/
|
|
24 |
|
|
25 |
#include <e32def.h>
|
|
26 |
#include "TelephonyFunctions.h"
|
|
27 |
|
|
28 |
|
|
29 |
TInt CTelephonyFunctions::GetLineStatus(const CTelephony::TPhoneLine& aLine, TDes8& aStatus)
|
|
30 |
/**
|
|
31 |
Get the current line status.
|
|
32 |
*/
|
|
33 |
{
|
|
34 |
TInt ret=KErrAccessDenied;
|
|
35 |
|
|
36 |
if(IsFlightModeOn())
|
|
37 |
{
|
|
38 |
return KErrAccessDenied;
|
|
39 |
}
|
|
40 |
|
|
41 |
CTelephony::TCallStatusV1& CallStatusV1 = reinterpret_cast<CTelephony::TCallStatusV1&> ( const_cast<TUint8&> ( *aStatus.Ptr() ) );
|
|
42 |
RMobileCall::TMobileCallStatus callStatus=RMobileCall::EStatusUnknown;
|
|
43 |
|
|
44 |
switch(aLine)
|
|
45 |
{
|
|
46 |
case CTelephony::EVoiceLine:
|
|
47 |
ret= iLineVoice.GetMobileLineStatus(callStatus);
|
|
48 |
break;
|
|
49 |
case CTelephony::EDataLine:
|
|
50 |
if(iLineIsDataOpen)
|
|
51 |
{
|
|
52 |
ret= iLineData.GetMobileLineStatus(callStatus);
|
|
53 |
}
|
|
54 |
else
|
|
55 |
{
|
|
56 |
return KErrNotSupported;
|
|
57 |
}
|
|
58 |
break;
|
|
59 |
case CTelephony::EFaxLine:
|
|
60 |
if(iLineIsFaxOpen)
|
|
61 |
{
|
|
62 |
ret= iLineFax.GetMobileLineStatus(callStatus);
|
|
63 |
}
|
|
64 |
else
|
|
65 |
{
|
|
66 |
return KErrNotSupported;
|
|
67 |
}
|
|
68 |
break;
|
|
69 |
default:
|
|
70 |
return KErrNotFound;
|
|
71 |
}
|
|
72 |
GetCallStatus(callStatus, CallStatusV1.iStatus);
|
|
73 |
return ret;
|
|
74 |
}
|
|
75 |
|
|
76 |
LOCAL_C void CloseArrayOfCallObjects(TAny* aCallArray)
|
|
77 |
/**
|
|
78 |
Close and delete the call object array.
|
|
79 |
*/
|
|
80 |
{
|
|
81 |
CArrayFixFlat<RMobileCall>* callArray = reinterpret_cast<CArrayFixFlat<RMobileCall>*>(aCallArray);
|
|
82 |
TInt count = callArray->Count();
|
|
83 |
for (TInt i=count-1; i>=0; --i)
|
|
84 |
{
|
|
85 |
callArray->At(i).Close();
|
|
86 |
}
|
|
87 |
delete callArray;
|
|
88 |
callArray = NULL;
|
|
89 |
}
|
|
90 |
|
|
91 |
TInt CTelephonyFunctions::GetCallInfoL(TDes8& aCallSelect, TDes8& aCallInfo, TDes8& aRemoteInfo)
|
|
92 |
/**
|
|
93 |
Get the current call information.
|
|
94 |
*/
|
|
95 |
{
|
|
96 |
CTelephony::TCallSelectionV1& CallSelectionV1 = reinterpret_cast<CTelephony::TCallSelectionV1&>
|
|
97 |
( const_cast<TUint8&> ( *aCallSelect.Ptr() ) );
|
|
98 |
|
|
99 |
if(CallSelectionV1.iLine != CTelephony::EVoiceLine)
|
|
100 |
{
|
|
101 |
return KErrAccessDenied;
|
|
102 |
}
|
|
103 |
|
|
104 |
if(IsFlightModeOn())
|
|
105 |
{
|
|
106 |
return KErrAccessDenied;
|
|
107 |
}
|
|
108 |
|
|
109 |
CTelephony::TCallInfoV1& CallInfoV1 = reinterpret_cast<CTelephony::TCallInfoV1&>
|
|
110 |
( const_cast<TUint8&> ( *aCallInfo.Ptr() ) );
|
|
111 |
|
|
112 |
CTelephony::TRemotePartyInfoV1& RemotePartyInfoV1 = reinterpret_cast<CTelephony::TRemotePartyInfoV1&>
|
|
113 |
( const_cast<TUint8&> ( *aRemoteInfo.Ptr() ) );
|
|
114 |
|
|
115 |
TPtr8* callInfoPkgPtr;
|
|
116 |
RMobileCall::TMobileCallInfoV1* callInfoObjPtr;
|
|
117 |
|
|
118 |
if(iTsyVersion == KNoMultimodeTsy)
|
|
119 |
{
|
|
120 |
return KErrNotSupported;
|
|
121 |
}
|
|
122 |
else if(iTsyVersion==KETelExtMultimodeV1 || iTsyVersion==KETelExtMultimodeV2)
|
|
123 |
{
|
|
124 |
RMobileCall::TMobileCallInfoV1* callInfoV1 = new(ELeave) RMobileCall::TMobileCallInfoV1;
|
|
125 |
CleanupStack::PushL(callInfoV1);
|
|
126 |
RMobileCall::TMobileCallInfoV1Pckg* callInfoV1Pckg = new(ELeave) RMobileCall::TMobileCallInfoV1Pckg(*callInfoV1);
|
|
127 |
CleanupStack::PushL(callInfoV1Pckg);
|
|
128 |
callInfoPkgPtr = callInfoV1Pckg;
|
|
129 |
callInfoObjPtr = callInfoV1;
|
|
130 |
}
|
|
131 |
else //TSY v3
|
|
132 |
{
|
|
133 |
RMobileCall::TMobileCallInfoV3* callInfoV3 = new(ELeave) RMobileCall::TMobileCallInfoV3;
|
|
134 |
CleanupStack::PushL(callInfoV3);
|
|
135 |
RMobileCall::TMobileCallInfoV3Pckg* callInfoV3Pckg = new(ELeave) RMobileCall::TMobileCallInfoV3Pckg(*callInfoV3);
|
|
136 |
CleanupStack::PushL(callInfoV3Pckg);
|
|
137 |
callInfoPkgPtr = callInfoV3Pckg;
|
|
138 |
callInfoObjPtr = callInfoV3;
|
|
139 |
}
|
|
140 |
|
|
141 |
TInt numOfCalls=0;
|
|
142 |
User::LeaveIfError(iLineVoice.EnumerateCall(numOfCalls));
|
|
143 |
if (numOfCalls==0)
|
|
144 |
{
|
|
145 |
User::Leave(KErrNotFound);
|
|
146 |
}
|
|
147 |
CArrayFixFlat<RMobileCall>* tempCallArray = new (ELeave) CArrayFixFlat<RMobileCall>(numOfCalls);
|
|
148 |
CleanupStack::PushL(TCleanupItem(CloseArrayOfCallObjects, tempCallArray));
|
|
149 |
TInt i;
|
|
150 |
|
|
151 |
RLine::TCallInfo callinfo;
|
|
152 |
RMobileCall::TMobileCallStatus callStatus;
|
|
153 |
TBool callFound=EFalse;
|
|
154 |
for(i=0; i<numOfCalls; i++)
|
|
155 |
{
|
|
156 |
User::LeaveIfError(iLineVoice.GetCallInfo(i,callinfo));
|
|
157 |
RMobileCall tempCall;
|
|
158 |
|
|
159 |
tempCallArray->AppendL(tempCall);
|
|
160 |
User::LeaveIfError(tempCallArray->At(i).OpenExistingCall(iLineVoice,callinfo.iCallName));
|
|
161 |
User::LeaveIfError(tempCallArray->At(i).GetMobileCallStatus(callStatus));
|
|
162 |
|
|
163 |
if((callStatus==RMobileCall::EStatusConnected) &&
|
|
164 |
(CallSelectionV1.iSelect==CTelephony::EActiveCall))
|
|
165 |
{
|
|
166 |
User::LeaveIfError(tempCallArray->At(i).GetMobileCallInfo(*callInfoPkgPtr));
|
|
167 |
callFound=ETrue;
|
|
168 |
break;
|
|
169 |
}
|
|
170 |
else if((callStatus==RMobileCall::EStatusHold) &&
|
|
171 |
(CallSelectionV1.iSelect==CTelephony::EHeldCall))
|
|
172 |
{
|
|
173 |
User::LeaveIfError(tempCallArray->At(i).GetMobileCallInfo(*callInfoPkgPtr));
|
|
174 |
callFound=ETrue;
|
|
175 |
break;
|
|
176 |
}
|
|
177 |
else if(((callStatus==RMobileCall::EStatusDialling) ||
|
|
178 |
(callStatus==RMobileCall::EStatusRinging) ||
|
|
179 |
(callStatus==RMobileCall::EStatusAnswering) ||
|
|
180 |
(callStatus==RMobileCall::EStatusConnecting) ||
|
|
181 |
(callStatus==RMobileCall::EStatusReconnectPending) ||
|
|
182 |
(callStatus==RMobileCall::EStatusDisconnecting) ||
|
|
183 |
(callStatus==RMobileCall::EStatusDisconnectingWithInband) ||
|
|
184 |
(callStatus==RMobileCall::EStatusTransferring) ||
|
|
185 |
(callStatus==RMobileCall:: EStatusTransferAlerting)
|
|
186 |
) &&
|
|
187 |
(CallSelectionV1.iSelect==CTelephony::EInProgressCall))
|
|
188 |
{
|
|
189 |
User::LeaveIfError(tempCallArray->At(i).GetMobileCallInfo(*callInfoPkgPtr));
|
|
190 |
callFound=ETrue;
|
|
191 |
break;
|
|
192 |
}
|
|
193 |
|
|
194 |
}
|
|
195 |
|
|
196 |
CleanupStack::PopAndDestroy(tempCallArray); //tempCallArray
|
|
197 |
if(!callFound)
|
|
198 |
{
|
|
199 |
CleanupStack::PopAndDestroy(2); //(callInfoV1Pckg or callInfoV3Pckg) AND (callInfoV1 or callInfoV3)
|
|
200 |
return KErrNotFound;
|
|
201 |
}
|
|
202 |
|
|
203 |
GetCallStatus(callInfoObjPtr->iStatus, CallInfoV1.iStatus);
|
|
204 |
|
|
205 |
if (callInfoObjPtr->iValid & RMobileCall::KCallSecurity)
|
|
206 |
{
|
|
207 |
if(callInfoObjPtr->ExtensionId() == KETelExtMultimodeV3)
|
|
208 |
{
|
|
209 |
RMobileCall::TMobileCallInfoV3* callInfoV3Ptr = reinterpret_cast<RMobileCall::TMobileCallInfoV3*>(callInfoObjPtr);
|
|
210 |
|
|
211 |
switch(callInfoV3Ptr->iSecurity)
|
|
212 |
{
|
|
213 |
case RMobilePhone::ECipheringGSM:
|
|
214 |
CallInfoV1.iSecurity = CTelephony::ECipheringGSM;
|
|
215 |
break;
|
|
216 |
case RMobilePhone::ECipheringWCDMA:
|
|
217 |
CallInfoV1.iSecurity = CTelephony::ECipheringWCDMA;
|
|
218 |
break;
|
|
219 |
case RMobilePhone::ECipheringOff:
|
|
220 |
default:
|
|
221 |
CallInfoV1.iSecurity = CTelephony::ECipheringOff;
|
|
222 |
break;
|
|
223 |
}
|
|
224 |
}
|
|
225 |
else
|
|
226 |
CallInfoV1.iSecurity = CTelephony::ECipheringOff;
|
|
227 |
}
|
|
228 |
else
|
|
229 |
{
|
|
230 |
CallInfoV1.iSecurity = CTelephony::TPhoneNetworkSecurity();
|
|
231 |
}
|
|
232 |
|
|
233 |
|
|
234 |
if (callInfoObjPtr->iValid & RMobileCall::KCallStartTime)
|
|
235 |
{
|
|
236 |
CallInfoV1.iStartTime = callInfoObjPtr->iStartTime;
|
|
237 |
}
|
|
238 |
else
|
|
239 |
{
|
|
240 |
CallInfoV1.iStartTime = TDateTime();
|
|
241 |
}
|
|
242 |
if (callInfoObjPtr->iValid & RMobileCall::KCallDuration)
|
|
243 |
{
|
|
244 |
CallInfoV1.iDuration = callInfoObjPtr->iDuration;
|
|
245 |
}
|
|
246 |
else
|
|
247 |
{
|
|
248 |
CallInfoV1.iDuration = 0;
|
|
249 |
}
|
|
250 |
if (callInfoObjPtr->iValid & RMobileCall::KCallExitCode)
|
|
251 |
{
|
|
252 |
CallInfoV1.iExitCode = callInfoObjPtr->iExitCode;
|
|
253 |
}
|
|
254 |
else
|
|
255 |
{
|
|
256 |
CallInfoV1.iExitCode = 0;
|
|
257 |
}
|
|
258 |
|
|
259 |
if (callInfoObjPtr->iValid & RMobileCall::KCallDialledParty)
|
|
260 |
{
|
|
261 |
CopyTelAddress(callInfoObjPtr->iDialledParty, CallInfoV1.iDialledParty);
|
|
262 |
}
|
|
263 |
else
|
|
264 |
{
|
|
265 |
CallInfoV1.iDialledParty = CTelephony::TTelAddress();
|
|
266 |
}
|
|
267 |
|
|
268 |
//see whether we have an existing handle on the call
|
|
269 |
CallInfoV1.iCallId = -1;
|
|
270 |
RMobileCall* poolCall=NULL;
|
|
271 |
RMobileCall::TMobileCallInfoV1 poolCallInfoV1;
|
|
272 |
RMobileCall::TMobileCallInfoV1Pckg poolCallInfoV1Pckg(poolCallInfoV1);
|
|
273 |
TInt err;
|
|
274 |
|
|
275 |
for(int k=0;k<CTelephony::EISVMaxNumOfCalls;k++)
|
|
276 |
{
|
|
277 |
//get RMobileCall object
|
|
278 |
if((poolCall = Call((CTelephony::TCallId)k)) != NULL)
|
|
279 |
{
|
|
280 |
//get call name
|
|
281 |
err = poolCall->GetMobileCallInfo(poolCallInfoV1Pckg);
|
|
282 |
if(err ==KErrNone)
|
|
283 |
{
|
|
284 |
//compare call names
|
|
285 |
if(poolCallInfoV1.iCallName.MatchF(callinfo.iCallName)==0)
|
|
286 |
{
|
|
287 |
CallInfoV1.iCallId = k;
|
|
288 |
break;
|
|
289 |
}
|
|
290 |
}
|
|
291 |
}
|
|
292 |
}
|
|
293 |
|
|
294 |
//fill TRemotePartyInfoV1
|
|
295 |
RMobileCall::TMobileCallRemotePartyInfoV1& mobileRemoteParty = callInfoObjPtr->iRemoteParty;
|
|
296 |
|
|
297 |
switch(mobileRemoteParty.iRemoteIdStatus)
|
|
298 |
{
|
|
299 |
case RMobileCall::ERemoteIdentityAvailable:
|
|
300 |
RemotePartyInfoV1.iRemoteIdStatus = CTelephony::ERemoteIdentityAvailable;
|
|
301 |
break;
|
|
302 |
case RMobileCall::ERemoteIdentitySuppressed:
|
|
303 |
RemotePartyInfoV1.iRemoteIdStatus = CTelephony::ERemoteIdentitySuppressed;
|
|
304 |
break;
|
|
305 |
case RMobileCall::ERemoteIdentityUnknown:
|
|
306 |
default:
|
|
307 |
RemotePartyInfoV1.iRemoteIdStatus = CTelephony::ERemoteIdentityUnknown;
|
|
308 |
break;
|
|
309 |
}
|
|
310 |
|
|
311 |
RemotePartyInfoV1.iCallingName.Copy(mobileRemoteParty.iCallingName);
|
|
312 |
CopyTelAddress(mobileRemoteParty.iRemoteNumber, RemotePartyInfoV1.iRemoteNumber);
|
|
313 |
|
|
314 |
switch(mobileRemoteParty.iDirection)
|
|
315 |
{
|
|
316 |
case RMobileCall::EMobileOriginated:
|
|
317 |
RemotePartyInfoV1.iDirection = CTelephony::EMobileOriginated;
|
|
318 |
break;
|
|
319 |
case RMobileCall::EMobileTerminated:
|
|
320 |
RemotePartyInfoV1.iDirection = CTelephony::EMobileTerminated;
|
|
321 |
break;
|
|
322 |
case RMobileCall::EDirectionUnknown:
|
|
323 |
default:
|
|
324 |
RemotePartyInfoV1.iDirection = CTelephony::EDirectionUnknown;
|
|
325 |
break;
|
|
326 |
}
|
|
327 |
|
|
328 |
CleanupStack::PopAndDestroy(2); //(callInfoV1Pckg or callInfoV3Pckg) AND (callInfoV1 or callInfoV3)
|
|
329 |
|
|
330 |
return KErrNone;
|
|
331 |
}
|
|
332 |
|
|
333 |
void CTelephonyFunctions::CopyTelAddress(const RMobilePhone::TMobileAddress& aFromAddress, CTelephony::TTelAddress& aToAddress)
|
|
334 |
/**
|
|
335 |
Maps a RMobilePhone::TMobileAddress object to a CTelephony::TTelAddress object.
|
|
336 |
*/
|
|
337 |
{
|
|
338 |
aToAddress.iTelNumber.Copy(aFromAddress.iTelNumber);
|
|
339 |
|
|
340 |
switch(aFromAddress.iTypeOfNumber)
|
|
341 |
{
|
|
342 |
case RMobilePhone::EInternationalNumber:
|
|
343 |
aToAddress.iTypeOfNumber=CTelephony::EInternationalNumber;
|
|
344 |
break;
|
|
345 |
case RMobilePhone::ENationalNumber:
|
|
346 |
aToAddress.iTypeOfNumber=CTelephony::ENationalNumber;
|
|
347 |
break;
|
|
348 |
case RMobilePhone::ENetworkSpecificNumber:
|
|
349 |
aToAddress.iTypeOfNumber=CTelephony::ENetworkSpecificNumber;
|
|
350 |
break;
|
|
351 |
case RMobilePhone::ESubscriberNumber:
|
|
352 |
aToAddress.iTypeOfNumber=CTelephony::ESubscriberNumber;
|
|
353 |
break;
|
|
354 |
case RMobilePhone::EAlphanumericNumber:
|
|
355 |
aToAddress.iTypeOfNumber=CTelephony::EAlphanumericNumber;
|
|
356 |
break;
|
|
357 |
case RMobilePhone::EAbbreviatedNumber:
|
|
358 |
aToAddress.iTypeOfNumber=CTelephony::EAbbreviatedNumber;
|
|
359 |
break;
|
|
360 |
case RMobilePhone::EUnknownNumber:
|
|
361 |
default:
|
|
362 |
aToAddress.iTypeOfNumber=CTelephony::EUnknownNumber;
|
|
363 |
break;
|
|
364 |
}
|
|
365 |
|
|
366 |
switch(aFromAddress.iNumberPlan)
|
|
367 |
{
|
|
368 |
case RMobilePhone::EIsdnNumberPlan:
|
|
369 |
aToAddress.iNumberPlan=CTelephony::EIsdnNumberPlan;
|
|
370 |
break;
|
|
371 |
case RMobilePhone::EDataNumberPlan:
|
|
372 |
aToAddress.iNumberPlan=CTelephony::EDataNumberPlan;
|
|
373 |
break;
|
|
374 |
case RMobilePhone::ETelexNumberPlan:
|
|
375 |
aToAddress.iNumberPlan=CTelephony::ETelexNumberPlan;
|
|
376 |
break;
|
|
377 |
case RMobilePhone::EServiceCentreSpecificPlan1:
|
|
378 |
aToAddress.iNumberPlan=CTelephony::EServiceCentreSpecificPlan1;
|
|
379 |
break;
|
|
380 |
case RMobilePhone::EServiceCentreSpecificPlan2:
|
|
381 |
aToAddress.iNumberPlan=CTelephony::EServiceCentreSpecificPlan2;
|
|
382 |
break;
|
|
383 |
case RMobilePhone::ENationalNumberPlan:
|
|
384 |
aToAddress.iNumberPlan=CTelephony::ENationalNumberPlan;
|
|
385 |
break;
|
|
386 |
case RMobilePhone::EPrivateNumberPlan:
|
|
387 |
aToAddress.iNumberPlan=CTelephony::EPrivateNumberPlan;
|
|
388 |
break;
|
|
389 |
case RMobilePhone::EERMESNumberPlan:
|
|
390 |
aToAddress.iNumberPlan=CTelephony::EERMESNumberPlan;
|
|
391 |
break;
|
|
392 |
case RMobilePhone::EUnknownNumberingPlan:
|
|
393 |
default:
|
|
394 |
aToAddress.iNumberPlan=CTelephony::EUnknownNumberingPlan;
|
|
395 |
break;
|
|
396 |
}
|
|
397 |
}
|
|
398 |
|